#include <l4/io/pciids.h>
#include <l4/sys/err.h>
+#include "debug.h"
#include "pci.h"
#include "vpci.h"
#include "vbus_factory.h"
assert (hwf);
for (int i = 0; i < 6; ++i)
{
- Adr_resource *r = _hwf->bar(i);
+ Resource *r = _hwf->bar(i);
if (!r)
{
else
{
_vbars[i] = r->start();
- if (r->type() == Adr_resource::Io_res)
+ if (r->type() == Resource::Io_res)
_vbars[i] |= 1;
if (r->is_64bit())
}
- // printf("%08lx: %d = %08lx\n", adr(), i, _vbars[i]);
+ //printf(" bar: %d = %08x\n", i, _vbars[i]);
}
if (_hwf->rom())
int
Pci_proxy_dev::irq_enable(Irq_info *irq)
{
- for (Resource_list::iterator i = hwf()->host()->resources()->begin();
- i != hwf()->host()->resources()->end(); ++i)
+ for (Resource_list::const_iterator i = host()->resources()->begin();
+ i != host()->resources()->end(); ++i)
{
- Adr_resource *res = dynamic_cast<Adr_resource*>(*i);
- if (!res)
- continue;
+ Resource *res = *i;
- if (res->type() == Adr_resource::Irq_res /* && (res->start() & 0x80) */)
+ if (res->type() == Resource::Irq_res)
{
irq->irq = res->start();
- irq->trigger = !(res->flags() & Resource::Irq_info_base);
- irq->polarity = !!(res->flags() & (Resource::Irq_info_base * 2));
+ irq->trigger = !res->irq_is_level_triggered();
+ irq->polarity = res->irq_is_low_polarity();
+ d_printf(DBG_DEBUG, "Enable IRQ: %d %x %x\n", irq->irq, irq->trigger, irq->polarity);
+ if (dlevel(DBG_DEBUG2))
+ dump();
return 0;
}
}
l4_uint32_t
Pci_proxy_dev::read_bar(int bar)
{
- //printf("%08x: read bar[%x]: %08x\n", _dev->adr(), bar, _vbars[bar]);
+ // d_printf(DBG_ALL, " read bar[%x]: %08x\n", bar, _vbars[bar]);
return _vbars[bar];
}
{
Hw::Pci::If *p = _hwf;
- Adr_resource *r = p->bar(bar);
+ Resource *r = p->bar(bar);
if (!r)
return;
// printf(" write bar[%x]: %llx-%llx...\n", bar, r->abs_start(), r->abs_end());
l4_uint64_t size_mask = r->alignment();
- if (r->type() == Adr_resource::Io_res)
+ if (r->type() == Resource::Io_res)
size_mask |= 0xffff0000;
if (p->is_64bit_high_bar(bar))
Hw::Pci::If *p = _hwf;
// printf("write rom bar %x %p\n", v, _dev->rom());
- Adr_resource *r = p->rom();
+ Resource *r = p->rom();
if (!r)
return;
}
bool match_hw_feature(const Hw::Dev_feature*) const { return false; }
- int dispatch(l4_umword_t, l4_uint32_t, L4::Ipc_iostream&)
+ int dispatch(l4_umword_t, l4_uint32_t, L4::Ipc::Iostream&)
{ return -L4_ENOSYS; }
+ void set_host(Device *d) { _host = d; }
+ Device *host() const { return _host; }
+
+private:
+ Device *_host;
};