1 | #include "libsaio.h"␊ |
2 | #include "boot.h"␊ |
3 | #include "bootstruct.h"␊ |
4 | #include "pci.h"␊ |
5 | #include "gma.h"␊ |
6 | #include "nvidia.h"␊ |
7 | #include "modules.h"␊ |
8 | ␊ |
9 | #define DEBUG_PCI 0␊ |
10 | ␊ |
11 | #if DEBUG_PCI␊ |
12 | #define DBG(x...) msglog(x)␊ |
13 | #else␊ |
14 | #define DBG(x...)␊ |
15 | #endif␊ |
16 | ␊ |
17 | extern bool setup_ati_devprop(pci_dt_t *ati_dev);␊ |
18 | extern void set_eth_builtin(pci_dt_t *eth_dev);␊ |
19 | extern void notify_usb_dev(pci_dt_t *pci_dev);␊ |
20 | extern void force_enable_hpet(pci_dt_t *lpc_dev);␊ |
21 | ␊ |
22 | extern pci_dt_t *dram_controller_dev;␊ |
23 | ␊ |
24 | uint16_t vgaVendor;␊ |
25 | ␊ |
26 | void setup_pci_devs(pci_dt_t *pci_dt)␊ |
27 | {␊ |
28 | ␉char *devicepath;␊ |
29 | ␉bool do_eth_devprop, do_gfx_devprop, do_enable_hpet;␊ |
30 | ␉pci_dt_t *current = pci_dt;␊ |
31 | ␊ |
32 | ␉do_eth_devprop = do_gfx_devprop = do_enable_hpet = false;␊ |
33 | ␊ |
34 | ␉getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->chameleonConfig);␊ |
35 | ␉getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->chameleonConfig);␊ |
36 | ␉getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->chameleonConfig);␊ |
37 | ␊ |
38 | ␉while (current)␊ |
39 | ␉{␊ |
40 | ␉␉devicepath = get_pci_dev_path(current);␊ |
41 | ␊ |
42 | ␉␉switch (current->class_id)␊ |
43 | ␉␉{␊ |
44 | ␉␉␉case PCI_CLASS_BRIDGE_HOST:␊ |
45 | ␉␉␉␉DBG("Setup BRIDGE_HOST \n");␊ |
46 | ␉␉␉␉if (current->dev.addr == PCIADDR(0, 0, 0))␊ |
47 | ␉␉␉␉{␊ |
48 | ␉␉␉␉␉dram_controller_dev = current;␊ |
49 | ␉␉␉␉}␊ |
50 | ␉␉␉␉break;␊ |
51 | ␉␉␉␉␊ |
52 | ␉␉␉case PCI_CLASS_NETWORK_ETHERNET: ␊ |
53 | ␉␉␉␉DBG("Setup ETHERNET %s enabled\n", do_eth_devprop?"":"no");␊ |
54 | ␉␉␉␉if (do_eth_devprop)␊ |
55 | ␉␉␉␉{␊ |
56 | ␉␉␉␉␉set_eth_builtin(current);␊ |
57 | ␉␉␉␉}␊ |
58 | ␉␉␉␉break;␊ |
59 | ␉␉␉␉␊ |
60 | ␉␉␉case PCI_CLASS_DISPLAY_VGA:␊ |
61 | ␉␉␉␉DBG("GraphicsEnabler %s enabled\n", do_gfx_devprop?"":"no");␊ |
62 | ␉␉␉␉if (do_gfx_devprop)␊ |
63 | ␉␉␉␉{␊ |
64 | ␉␉␉␉␉vgaVendor = current->vendor_id;␊ |
65 | ␉␉␉␉␉switch (vgaVendor)␊ |
66 | ␉␉␉␉␉{␊ |
67 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
68 | ␉␉␉␉␉␉␉setup_ati_devprop(current); ␊ |
69 | ␉␉␉␉␉␉␉break;␊ |
70 | ␉␉␉␉␉␊ |
71 | ␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL:␊ |
72 | ␉␉␉␉␉␉␉setup_gma_devprop(current);␊ |
73 | ␉␉␉␉␉␉␉break;␊ |
74 | ␉␉␉␉␉␊ |
75 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA: ␊ |
76 | ␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
77 | ␉␉␉␉␉␉␉break;␊ |
78 | ␉␉␉␉␉}␊ |
79 | ␉␉␉␉}␊ |
80 | ␉␉␉␉break;␊ |
81 | ␊ |
82 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
83 | ␉␉␉␉DBG("USB fix \n");␊ |
84 | ␉␉␉␉notify_usb_dev(current);␊ |
85 | ␉␉␉␉break;␊ |
86 | ␊ |
87 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
88 | ␉␉␉␉DBG("Force HPET %s enabled\n", do_enable_hpet?"":"no");␊ |
89 | ␉␉␉␉if (do_enable_hpet)␊ |
90 | ␉␉␉␉{␊ |
91 | ␉␉␉␉␉force_enable_hpet(current);␊ |
92 | ␉␉␉␉}␊ |
93 | ␉␉␉␉break;␊ |
94 | ␉␉}␊ |
95 | ␉␉␊ |
96 | ␉␉execute_hook("PCIDevice", current, NULL, NULL, NULL);␊ |
97 | ␉␉DBG("setup_pci_devs current devID=%08x\n", current->device_id);␊ |
98 | ␉␉setup_pci_devs(current->children);␊ |
99 | ␉␉current = current->next;␊ |
100 | ␉}␊ |
101 | }␊ |
102 | |