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_devdrop(pci_dt_t *eth_dev);␊ |
22 | extern void setup_wifi_devdrop(pci_dt_t *wifi_dev);␊ |
23 | ␊ |
24 | extern void notify_usb_dev(pci_dt_t *pci_dev);␊ |
25 | extern void force_enable_hpet(pci_dt_t *lpc_dev);␊ |
26 | ␊ |
27 | extern pci_dt_t *dram_controller_dev;␊ |
28 | ␊ |
29 | void setup_pci_devs(pci_dt_t *pci_dt)␊ |
30 | {␊ |
31 | ␉char *devicepath;␊ |
32 | ␊ |
33 | ␉bool do_gfx_devprop = false;␊ |
34 | ␉bool do_skip_n_devprop = false;␊ |
35 | ␉bool do_skip_a_devprop = false;␊ |
36 | ␉bool do_skip_i_devprop = false;␊ |
37 | ␊ |
38 | ␉bool do_enable_hpet = false;␊ |
39 | ␉bool do_hda_devprop = false;␊ |
40 | ␊ |
41 | ␉pci_dt_t *current = pci_dt;␊ |
42 | ␊ |
43 | ␉// GraphicsEnabler␊ |
44 | ␉getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->chameleonConfig);␊ |
45 | ␊ |
46 | ␉// Skip keys␊ |
47 | ␉getBoolForKey(kSkipNvidiaGfx, &do_skip_n_devprop, &bootInfo->chameleonConfig);␊ |
48 | ␉getBoolForKey(kSkipAtiGfx, &do_skip_a_devprop, &bootInfo->chameleonConfig);␊ |
49 | ␉getBoolForKey(kSkipIntelGfx, &do_skip_i_devprop, &bootInfo->chameleonConfig);␊ |
50 | ␊ |
51 | //␉getBoolForKey(kUsbInject, &do_usb_devprop, &bootInfo->chameleonConfig);␊ |
52 | ␊ |
53 | ␉// HDAEnable␊ |
54 | ␉getBoolForKey(kHDAEnabler, &do_hda_devprop, &bootInfo->chameleonConfig);␊ |
55 | ␊ |
56 | ␉// ForceHPET␊ |
57 | ␉getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->chameleonConfig);␊ |
58 | ␊ |
59 | ␉while (current)␊ |
60 | ␉{␊ |
61 | ␉␉devicepath = get_pci_dev_path(current);␊ |
62 | ␊ |
63 | ␉␉switch (current->class_id)␊ |
64 | ␉␉{␊ |
65 | ␉␉␉case PCI_CLASS_BRIDGE_HOST:␊ |
66 | ␉␉␉␉DBG("Setup BRIDGE_HOST \n");␊ |
67 | ␉␉␉␉if (current->dev.addr == PCIADDR(0, 0, 0))␊ |
68 | ␉␉␉␉{␊ |
69 | ␉␉␉␉␉dram_controller_dev = current;␊ |
70 | ␉␉␉␉}␊ |
71 | ␉␉␉␉break; // PCI_CLASS_BRIDGE_HOST␊ |
72 | ␊ |
73 | ␉␉␉case PCI_CLASS_NETWORK_ETHERNET:␊ |
74 | ␉␉␉␉DBG("Setup ETHERNET %s enabled\n", do_eth_devprop? "is":"is not");␊ |
75 | ␉␉␉␉verbose("[ ETHERNET DEVICE INFO ]\n");␊ |
76 | ␉␉␉␉setup_eth_devdrop(current);␊ |
77 | ␉␉␉␉verbose("\n");␊ |
78 | ␉␉␉␉break; // PCI_CLASS_NETWORK_ETHERNET␊ |
79 | ␊ |
80 | ␉␉␉case PCI_CLASS_NETWORK_OTHER:␊ |
81 | ␉␉␉␉DBG("Setup WIRELESS %s enabled\n", do_wifi_devprop? "is":"is not");␊ |
82 | ␉␉␉␉verbose("[ WIRELESS DEVICE INFO ]\n");␊ |
83 | ␉␉␉␉setup_wifi_devdrop(current);␊ |
84 | ␉␉␉␉verbose("\n");␊ |
85 | ␉␉␉␉break; // PCI_CLASS_NETWORK_OTHER␊ |
86 | ␊ |
87 | ␉␉␉case PCI_CLASS_DISPLAY_VGA:␊ |
88 | ␉␉␉␉DBG("GraphicsEnabler %s enabled\n", do_gfx_devprop? "is":"is not");␊ |
89 | ␉␉␉␉if (do_gfx_devprop)␊ |
90 | ␉␉␉␉{␊ |
91 | ␉␉␉␉␉switch (current->vendor_id)␊ |
92 | ␉␉␉␉␉{␊ |
93 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
94 | ␉␉␉␉␉␉␉if ( do_skip_a_devprop )␊ |
95 | ␉␉␉␉␉␉␉{␊ |
96 | ␉␉␉␉␉␉␉␉verbose("Skip ATi/AMD gfx device!\n");␊ |
97 | ␉␉␉␉␉␉␉}␊ |
98 | ␉␉␉␉␉␉␉else␊ |
99 | ␉␉␉␉␉␉␉{␊ |
100 | ␉␉␉␉␉␉␉␉verbose("[ ATi GFX DEVICE INFO ]\n");␊ |
101 | ␉␉␉␉␉␉␉␉setup_ati_devprop(current);␊ |
102 | ␉␉␉␉␉␉␉␉verbose("\n");␊ |
103 | ␉␉␉␉␉␉␉}␊ |
104 | ␉␉␉␉␉␉␉break; // PCI_VENDOR_ID_ATI␊ |
105 | ␊ |
106 | ␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL:␊ |
107 | ␉␉␉␉␉␉␉if ( do_skip_i_devprop )␊ |
108 | ␉␉␉␉␉␉␉{␊ |
109 | ␉␉␉␉␉␉␉␉verbose("Skip Intel gfx device!\n");␊ |
110 | ␉␉␉␉␉␉␉}␊ |
111 | ␉␉␉␉␉␉␉else␊ |
112 | ␉␉␉␉␉␉␉{␊ |
113 | ␉␉␉␉␉␉␉␉verbose("[ INTEL GMA DEVICE INFO ]\n");␊ |
114 | ␉␉␉␉␉␉␉␉setup_gma_devprop(current);␊ |
115 | ␉␉␉␉␉␉␉␉verbose("\n");␊ |
116 | ␉␉␉␉␉␉␉}␊ |
117 | ␉␉␉␉␉␉␉break; // PCI_VENDOR_ID_INTEL␊ |
118 | ␊ |
119 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA:␊ |
120 | ␉␉␉␉␉␉␉if ( do_skip_n_devprop )␊ |
121 | ␉␉␉␉␉␉␉{␊ |
122 | ␉␉␉␉␉␉␉␉verbose("Skip Nvidia gfx device!\n");␊ |
123 | ␉␉␉␉␉␉␉}␊ |
124 | ␉␉␉␉␉␉␉else␊ |
125 | ␉␉␉␉␉␉␉{␊ |
126 | ␉␉␉␉␉␉␉␉verbose("[ NVIDIA GFX DEVICE INFO ]\n");␊ |
127 | ␉␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
128 | ␉␉␉␉␉␉␉␉verbose("\n");␊ |
129 | ␉␉␉␉␉␉␉}␊ |
130 | ␉␉␉␉␉␉␉break; // PCI_VENDOR_ID_NVIDIA␊ |
131 | ␊ |
132 | ␉␉␉␉␉␉default:␊ |
133 | ␉␉␉␉␉␉␉break;␊ |
134 | ␉␉␉␉␉}␊ |
135 | ␉␉␉␉}␊ |
136 | ␉␉␉␉break; // PCI_CLASS_DISPLAY_VGA␊ |
137 | ␊ |
138 | ␉␉␉case PCI_CLASS_MULTIMEDIA_AUDIO_DEV:␊ |
139 | ␉␉␉␉DBG("Setup HDEF %s enabled\n", do_hda_devprop ? "is":"is not");␊ |
140 | ␉␉␉␉if (do_hda_devprop)␊ |
141 | ␉␉␉␉{␊ |
142 | ␉␉␉␉␉verbose("[ AUDIO DEVICE INFO ]\n");␊ |
143 | ␉␉␉␉␉setup_hda_devprop(current);␊ |
144 | ␉␉␉␉␉verbose("\n");␊ |
145 | ␉␉␉␉}␊ |
146 | ␉␉␉␉break; // PCI_CLASS_MULTIMEDIA_AUDIO_DEV␊ |
147 | ␊ |
148 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
149 | ␉␉␉␉DBG("USB\n");␊ |
150 | ␉␉␉␉notify_usb_dev(current);␊ |
151 | //␉␉␉␉if (do_usb_devprop)␊ |
152 | //␉␉␉␉{␊ |
153 | //␉␉␉␉␉set_usb_devprop(current);␊ |
154 | //␉␉␉␉}␊ |
155 | ␉␉␉␉break; // PCI_CLASS_SERIAL_USB␊ |
156 | ␊ |
157 | ␉␉␉case PCI_CLASS_SERIAL_FIREWIRE:␊ |
158 | ␉␉␉␉DBG("FireWire\n");␊ |
159 | ␉␉␉␉verbose("[ FIREWIRE DEVICE INFO ]\n");␊ |
160 | ␉␉␉␉verbose("\tClass code: [%04X]\n\tFireWire device [%04x:%04x]-[%04x:%04x]\n\t%s\n",␊ |
161 | ␉␉␉␉␉current->class_id,current->vendor_id, current->device_id,␊ |
162 | ␉␉␉␉␉current->subsys_id.subsys.vendor_id,␊ |
163 | ␉␉␉␉␉current->subsys_id.subsys.device_id, devicepath);␊ |
164 | //␉␉␉␉set_fwr_devdrop(current);␊ |
165 | ␉␉␉␉verbose("\n");␊ |
166 | ␉␉␉␉break; // PCI_CLASS_SERIAL_FIREWIRE␊ |
167 | ␊ |
168 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
169 | ␉␉␉␉DBG("Force HPET %s enabled\n", do_enable_hpet ? "is":"is not");␊ |
170 | ␉␉␉␉if (do_enable_hpet)␊ |
171 | ␉␉␉␉{␊ |
172 | ␉␉␉␉␉verbose("[ HPET ]\n");␊ |
173 | ␉␉␉␉␉force_enable_hpet(current);␊ |
174 | ␉␉␉␉␉verbose("\n");␊ |
175 | ␉␉␉␉}␊ |
176 | ␉␉␉␉break; // PCI_CLASS_BRIDGE_ISA␊ |
177 | ␊ |
178 | ␉␉␉}␊ |
179 | ␊ |
180 | ␉␉execute_hook("PCIDevice", current, NULL, NULL, NULL);␊ |
181 | ␉␉DBG("setup_pci_devs current device ID = [%04x:%04x]\n", current->vendor_id, current->device_id);␊ |
182 | ␉␉setup_pci_devs(current->children);␊ |
183 | ␉␉current = current->next;␊ |
184 | ␉}␊ |
185 | }␊ |
186 | |