2 * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU General Public License 2.
7 * Please see the COPYING-GPL-2 file for details.
13 // ------------------------------------------------------------------------
14 // Proxy for a real PCI root bridge
15 // ------------------------------------------------------------------------
17 class VPci_root : public VDevice
21 int vbus_dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios);
23 explicit VPci_root() : VDevice() {}
27 char const *hid() const
33 int cfg_read(L4::Ipc::Iostream &ios);
34 int cfg_write(L4::Ipc::Iostream &ios);
35 int irq_enable(L4::Ipc::Iostream &ios);
39 // IMPLEMENTATION --------------------------------------------------------
42 VPci_root::cfg_read(L4::Ipc::Iostream &ios)
50 ios >> bus >> devfn >> reg >> width;
52 int res = pci_root_bridge(0)->cfg_read(bus, devfn, reg, &value, Pci::cfg_w_to_o(width));
61 VPci_root::irq_enable(L4::Ipc::Iostream &ios)
68 ios >> bus >> devfn >> pin;
69 // printf("get IRQ for %02x:%02x.%x: pin INT%c\n", bus, devfn >> 16, devfn & 0xffff, pin + 'A');
70 struct acpica_pci_irq *irq = 0;
71 int res = acpica_pci_irq_find(0, bus, devfn >> 16, pin, &irq);
84 ios << irq->irq << irq->trigger << irq->polarity;
90 VPci_root::cfg_write(L4::Ipc::Iostream &ios)
98 ios >> bus >> devfn >> reg >> value >> width;
100 int res = pci_root_bridge(0)->cfg_write(bus, devfn, reg, value, Pci::cfg_w_to_o(width));
108 VPci_root::vbus_dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios)
112 case 0: return cfg_read(ios);
113 case 1: return cfg_write(ios);
114 case 2: return irq_enable(ios);
115 default: return -L4_ENOSYS;