]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/io/server/src/vpci.cc
update
[l4.git] / l4 / pkg / io / server / src / vpci.cc
index 970279db18398ee63ac8f96b1fca68b79e4abb20..b73a315f09411ca6dde986ee032f0a190485128d 100644 (file)
@@ -17,6 +17,7 @@
 #include <l4/io/pciids.h>
 #include <l4/sys/err.h>
 
+#include "debug.h"
 #include "pci.h"
 #include "vpci.h"
 #include "vbus_factory.h"
@@ -93,7 +94,7 @@ Pci_proxy_dev::Pci_proxy_dev(Hw::Pci::If *hwf)
   assert (hwf);
   for (int i = 0; i < 6; ++i)
     {
-      Adr_resource *r = _hwf->bar(i);
+      Resource *r = _hwf->bar(i);
 
       if (!r)
        {
@@ -108,7 +109,7 @@ Pci_proxy_dev::Pci_proxy_dev(Hw::Pci::If *hwf)
       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())
@@ -119,7 +120,7 @@ Pci_proxy_dev::Pci_proxy_dev(Hw::Pci::If *hwf)
 
        }
 
-      // printf("%08lx: %d = %08lx\n", adr(), i, _vbars[i]);
+      //printf("  bar: %d = %08x\n", i, _vbars[i]);
     }
 
   if (_hwf->rom())
@@ -129,18 +130,19 @@ Pci_proxy_dev::Pci_proxy_dev(Hw::Pci::If *hwf)
 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;
        }
     }
@@ -152,7 +154,7 @@ Pci_proxy_dev::irq_enable(Irq_info *irq)
 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];
 }
 
@@ -161,14 +163,14 @@ Pci_proxy_dev::write_bar(int bar, l4_uint32_t v)
 {
   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))
@@ -185,7 +187,7 @@ Pci_proxy_dev::write_rom(l4_uint32_t v)
   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;
 
@@ -301,8 +303,13 @@ public:
   }
 
   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;
 };