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