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