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