1 | #include "libsaio.h"␊ |
2 | #include "boot.h"␊ |
3 | #include "bootstruct.h"␊ |
4 | #include "pci.h"␊ |
5 | #include "modules.h"␊ |
6 | ␊ |
7 | #ifndef DEBUG_PCI_SETUP␊ |
8 | #define DEBUG_PCI_SETUP 0␊ |
9 | #endif␊ |
10 | ␊ |
11 | #if DEBUG_PCI_SETUP␊ |
12 | #define DBG(x...)␉printf(x)␊ |
13 | #else␊ |
14 | #define DBG(x...)␊ |
15 | #endif␊ |
16 | ␊ |
17 | extern bool setup_ati_devprop(pci_dt_t *ati_dev);␊ |
18 | extern bool setup_nvidia_devprop(pci_dt_t *nvda_dev);␊ |
19 | extern bool setup_gma_devprop(pci_dt_t *gma_dev);␊ |
20 | extern bool setup_hda_devprop(pci_dt_t *hda_dev);␊ |
21 | extern void setup_eth_builtin(pci_dt_t *eth_dev);␊ |
22 | extern void setup_wifi_airport(pci_dt_t *wifi_dev);␊ |
23 | extern bool set_usb_devprop(pci_dt_t *usb_dev);␊ |
24 | extern void notify_usb_dev(pci_dt_t *pci_dev);␊ |
25 | extern void force_enable_hpet(pci_dt_t *lpc_dev);␊ |
26 | extern pci_dt_t *dram_controller_dev;␊ |
27 | ␊ |
28 | void setup_pci_devs(pci_dt_t *pci_dt)␊ |
29 | {␊ |
30 | ␉char *devicepath;␊ |
31 | ␉bool doit, do_eth_devprop, do_wifi_devprop, /*do_usb_devprop,*/ do_gfx_devprop, do_enable_hpet, do_hda_devprop = false;␊ |
32 | ␉pci_dt_t *current = pci_dt;␊ |
33 | ␊ |
34 | ␉getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->chameleonConfig);␊ |
35 | ␉getBoolForKey(kEnableWifi, &do_wifi_devprop, &bootInfo->chameleonConfig);␊ |
36 | ␉getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->chameleonConfig);␊ |
37 | //␉getBoolForKey(kUsbInject, &do_usb_devprop, &bootInfo->chameleonConfig);␊ |
38 | ␉getBoolForKey(kHDAEnabler, &do_hda_devprop, &bootInfo->chameleonConfig);␊ |
39 | ␉getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->chameleonConfig);␊ |
40 | ␊ |
41 | ␉while (current)␊ |
42 | ␉{␊ |
43 | ␉␉devicepath = get_pci_dev_path(current);␊ |
44 | ␊ |
45 | ␉␉switch (current->class_id)␊ |
46 | ␉␉{␊ |
47 | ␉␉␉case PCI_CLASS_BRIDGE_HOST:␊ |
48 | ␉␉␉␉DBG("Setup BRIDGE_HOST \n");␊ |
49 | ␉␉␉␉if (current->dev.addr == PCIADDR(0, 0, 0))␊ |
50 | ␉␉␉␉{␊ |
51 | ␉␉␉␉␉dram_controller_dev = current;␊ |
52 | ␉␉␉␉}␊ |
53 | ␉␉␉␉break; // PCI_CLASS_BRIDGE_HOST␊ |
54 | ␊ |
55 | ␉␉␉case PCI_CLASS_NETWORK_ETHERNET:␊ |
56 | ␉␉␉␉DBG("Setup ETHERNET %s enabled\n", do_eth_devprop? "is":"is not");␊ |
57 | ␉␉␉␉if (do_eth_devprop)␊ |
58 | ␉␉␉␉{␊ |
59 | ␉␉␉␉␉setup_eth_builtin(current);␊ |
60 | ␉␉␉␉}␊ |
61 | ␉␉␉␉break; // PCI_CLASS_NETWORK_ETHERNET␊ |
62 | ␊ |
63 | ␉␉␉case PCI_CLASS_NETWORK_OTHER:␊ |
64 | ␉␉␉␉DBG("Setup WIRELESS %s enabled\n", do_wifi_devprop? "is":"is not");␊ |
65 | ␉␉␉␉if (do_wifi_devprop)␊ |
66 | ␉␉␉␉{␊ |
67 | ␉␉␉␉␉setup_wifi_airport(current);␊ |
68 | ␉␉␉␉}␊ |
69 | ␉␉␉␉break; // PCI_CLASS_NETWORK_OTHER␊ |
70 | ␊ |
71 | ␉␉␉case PCI_CLASS_DISPLAY_VGA:␊ |
72 | ␉␉␉␉DBG("GraphicsEnabler %s enabled\n", do_gfx_devprop? "is":"is not");␊ |
73 | ␉␉␉␉if (do_gfx_devprop)␊ |
74 | ␉␉␉␉{␊ |
75 | ␉␉␉␉␉switch (current->vendor_id)␊ |
76 | ␉␉␉␉␉{␊ |
77 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
78 | ␉␉␉␉␉␉␉if (getBoolForKey(kSkipAtiGfx, &doit, &bootInfo->chameleonConfig) && doit)␊ |
79 | ␉␉␉␉␉␉␉{␊ |
80 | ␉␉␉␉␉␉␉␉verbose("Skip ATi/AMD gfx device!\n");␊ |
81 | ␉␉␉␉␉␉␉}␊ |
82 | ␉␉␉␉␉␉␉else␊ |
83 | ␉␉␉␉␉␉␉{␊ |
84 | ␉␉␉␉␉␉␉␉setup_ati_devprop(current);␊ |
85 | ␉␉␉␉␉␉␉}␊ |
86 | ␉␉␉␉␉␉␉break; // PCI_VENDOR_ID_ATI␊ |
87 | ␊ |
88 | ␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL:␊ |
89 | ␉␉␉␉␉␉␉if (getBoolForKey(kSkipIntelGfx, &doit, &bootInfo->chameleonConfig) && doit)␊ |
90 | ␉␉␉␉␉␉␉{␊ |
91 | ␉␉␉␉␉␉␉␉verbose("Skip Intel gfx device!\n");␊ |
92 | ␉␉␉␉␉␉␉}␊ |
93 | ␉␉␉␉␉␉␉else␊ |
94 | ␉␉␉␉␉␉␉{␊ |
95 | ␉␉␉␉␉␉␉␉setup_gma_devprop(current);␊ |
96 | ␉␉␉␉␉␉␉}␊ |
97 | ␉␉␉␉␉␉␉break; // PCI_VENDOR_ID_INTEL␊ |
98 | ␊ |
99 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA:␊ |
100 | ␉␉␉␉␉␉␉if (getBoolForKey(kSkipNvidiaGfx, &doit, &bootInfo->chameleonConfig) && doit)␊ |
101 | ␉␉␉␉␉␉␉{␊ |
102 | ␉␉␉␉␉␉␉␉verbose("Skip Nvidia gfx device!\n");␊ |
103 | ␉␉␉␉␉␉␉}␊ |
104 | ␉␉␉␉␉␉␉else␊ |
105 | ␉␉␉␉␉␉␉{␊ |
106 | ␉␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
107 | ␉␉␉␉␉␉␉}␊ |
108 | ␉␉␉␉␉␉␉break; // PCI_VENDOR_ID_NVIDIA␊ |
109 | ␊ |
110 | ␉␉␉␉␉␉default:␊ |
111 | ␉␉␉␉␉␉␉break;␊ |
112 | ␉␉␉␉␉}␊ |
113 | ␉␉␉␉}␊ |
114 | ␉␉␉␉break; // PCI_CLASS_DISPLAY_VGA␊ |
115 | ␊ |
116 | ␉␉␉case PCI_CLASS_MULTIMEDIA_AUDIO_DEV:␊ |
117 | ␉␉␉␉DBG("Setup HDEF %s enabled\n", do_hda_devprop? "is":"is not");␊ |
118 | ␉␉␉␉if (do_hda_devprop)␊ |
119 | ␉␉␉␉{␊ |
120 | ␉␉␉␉␉setup_hda_devprop(current);␊ |
121 | ␉␉␉␉}␊ |
122 | ␉␉␉␉break; // PCI_CLASS_MULTIMEDIA_AUDIO_DEV␊ |
123 | ␊ |
124 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
125 | ␉␉␉␉DBG("USB\n");␊ |
126 | ␉␉␉␉notify_usb_dev(current);␊ |
127 | ␉␉␉␉/*if (do_usb_devprop)␊ |
128 | ␉␉␉␉{␊ |
129 | ␉␉␉␉␉set_usb_devprop(current);␊ |
130 | ␉␉␉␉}*/␊ |
131 | ␉␉␉␉break; // PCI_CLASS_SERIAL_USB␊ |
132 | ␊ |
133 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
134 | ␉␉␉␉DBG("Force HPET %s enabled\n", do_enable_hpet? "is":"is not");␊ |
135 | ␉␉␉␉if (do_enable_hpet)␊ |
136 | ␉␉␉␉{␊ |
137 | ␉␉␉␉␉force_enable_hpet(current);␊ |
138 | ␉␉␉␉}␊ |
139 | ␉␉␉␉break; // PCI_CLASS_BRIDGE_ISA␊ |
140 | ␊ |
141 | ␉␉␉}␊ |
142 | ␊ |
143 | ␉␉execute_hook("PCIDevice", current, NULL, NULL, NULL);␊ |
144 | ␉␉DBG("setup_pci_devs current device ID = [%04x:%04x]\n", current->vendor_id, current->device_id);␊ |
145 | ␉␉setup_pci_devs(current->children);␊ |
146 | ␉␉current = current->next;␊ |
147 | ␉}␊ |
148 | }␊ |
149 | |