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 1␊ |
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 | void setup_pci_devs(pci_dt_t *pci_dt)␊ |
25 | {␊ |
26 | ␉char *devicepath;␊ |
27 | ␉bool do_eth_devprop, do_gfx_devprop, do_enable_hpet;␊ |
28 | ␉pci_dt_t *current = pci_dt;␊ |
29 | ␊ |
30 | ␉do_eth_devprop = do_gfx_devprop = do_enable_hpet = false;␊ |
31 | ␊ |
32 | ␉getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->chameleonConfig);␊ |
33 | ␉getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->chameleonConfig);␊ |
34 | ␉getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->chameleonConfig);␊ |
35 | ␊ |
36 | ␉while (current)␊ |
37 | ␉{␊ |
38 | ␉␉devicepath = get_pci_dev_path(current);␊ |
39 | ␊ |
40 | ␉␉switch (current->class_id)␊ |
41 | ␉␉{␊ |
42 | ␉␉␉case PCI_CLASS_BRIDGE_HOST:␊ |
43 | ␉␉␉␉DBG("Setup BRIDGE_HOST \n");␊ |
44 | ␉␉␉␉␉if (current->dev.addr == PCIADDR(0, 0, 0))␊ |
45 | ␉␉␉␉␉␉dram_controller_dev = current;␊ |
46 | ␉␉␉␉break;␊ |
47 | ␉␉␉␉␊ |
48 | ␉␉␉case PCI_CLASS_NETWORK_ETHERNET: ␊ |
49 | ␉␉␉␉DBG("Setup ETHERNET %s enabled\n", do_eth_devprop?"":"no");␊ |
50 | ␉␉␉␉if (do_eth_devprop)␊ |
51 | ␉␉␉␉␉set_eth_builtin(current);␊ |
52 | ␉␉␉␉break;␊ |
53 | ␉␉␉␉␊ |
54 | ␉␉␉case PCI_CLASS_DISPLAY_VGA:␊ |
55 | ␉␉␉␉DBG("GraphicsEnabler %s enabled\n", do_gfx_devprop?"":"no");␊ |
56 | ␉␉␉␉if (do_gfx_devprop)␊ |
57 | ␉␉␉␉␉switch (current->vendor_id)␊ |
58 | ␉␉␉␉␉{␊ |
59 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
60 | ␉␉␉␉␉␉␉setup_ati_devprop(current); ␊ |
61 | ␉␉␉␉␉␉␉break;␊ |
62 | ␉␉␉␉␉␊ |
63 | ␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL:␊ |
64 | ␉␉␉␉␉␉␉setup_gma_devprop(current);␊ |
65 | ␉␉␉␉␉␉␉break;␊ |
66 | ␉␉␉␉␉␊ |
67 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA: ␊ |
68 | ␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
69 | ␉␉␉␉␉␉␉break;␊ |
70 | ␉␉␉␉␉}␊ |
71 | ␉␉␉␉break;␊ |
72 | ␊ |
73 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
74 | ␉␉␉␉DBG("USB fix \n");␊ |
75 | ␉␉␉␉notify_usb_dev(current);␊ |
76 | ␉␉␉␉break;␊ |
77 | ␊ |
78 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
79 | ␉␉␉␉DBG("Force HPET %s enabled\n", do_enable_hpet?"":"no");␊ |
80 | ␉␉␉␉if (do_enable_hpet)␊ |
81 | ␉␉␉␉␉force_enable_hpet(current);␊ |
82 | ␉␉␉␉break;␊ |
83 | ␉␉}␊ |
84 | ␉␉␊ |
85 | ␉␉execute_hook("PCIDevice", current, NULL, NULL, NULL);␊ |
86 | ␉␉DBG("setup_pci_devs current devID=%08x\n", current->device_id);␊ |
87 | ␉␉setup_pci_devs(current->children);␊ |
88 | ␉␉DBG("setup_pci_devs children devID=%08x\n", current->device_id);␉␉␊ |
89 | ␉␉current = current->next;␊ |
90 | ␉}␊ |
91 | }␊ |
92 | |