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