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