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.
10 #include "vpci_pci_bridge.h"
11 #include "vbus_factory.h"
15 Pci_to_pci_bridge::Pci_to_pci_bridge()
19 _h_len = sizeof(_cfg_space);
20 cfg_hdr()->hdr_type = 1;
21 cfg_hdr()->vendor_device = 0x02000400;
22 cfg_hdr()->status = 0;
23 cfg_hdr()->class_rev = 0x06040000;
26 cfg_write(::Pci_dev::C_primary, 0x00010100, Hw::Pci::Cfg_long);
28 Bridge_cfg *bc = bridge_cfg();
29 bc->io_base = 0xc0; bc->io_base_upper = 0;
30 bc->io_limit = 0xf0; bc->io_limit_upper = 0;
31 bc->mem_base = 0xa000;
32 bc->mem_limit = 0xeff0;
33 bc->pref_base = 0xf001; bc->pref_base_upper = 0;
34 bc->pref_limit = 0xfff1; bc->pref_limit_upper = 0; //0xffffffff;
39 Pci_to_pci_bridge::cfg_read(int reg, l4_uint32_t *v, Cfg_width o)
41 unsigned mask = ~0U >> (32 - (1U << (o + 3)));
44 case 0x18: // bus config stuff
45 *v = (_bus_config >> ((reg & 3)*8)) & mask;
48 case 0x10: // We have no BARs
58 return Pci_virtual_dev::cfg_read(reg, v, o);
63 Pci_to_pci_bridge::cfg_write(int reg, l4_uint32_t v, Cfg_width o)
65 unsigned mask = (~0U >> (32 - (1U << (o + 3)))) << ((reg & 3) * 8);
69 _bus_config = (_bus_config & ~mask) | ((v << ((reg & 3)*8)) & mask);
72 case 0x10: // We have no BARs
80 int r = Pci_virtual_dev::cfg_write(reg, v, o);
85 *(l4_uint32_t*)(_h + 0x1c) &= 0x0000f000;
88 *(l4_uint32_t*)(_h + 0x24) &= 0xfff0fff0;
89 *(l4_uint32_t*)(_h + 0x24) |= 0x00010001;
92 *(l4_uint32_t*)(_h + 0x22) &= 0xfff0fff0;
100 static Dev_factory_t<Pci_to_pci_bridge> __pci_to_pci_factory("PCI_PCI_bridge");