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 set_eth_builtin(pci_dt_t *eth_dev);␊ |
22 | extern void notify_usb_dev(pci_dt_t *pci_dev);␊ |
23 | extern void force_enable_hpet(pci_dt_t *lpc_dev);␊ |
24 | ␊ |
25 | extern pci_dt_t *dram_controller_dev;␊ |
26 | ␊ |
27 | void setup_pci_devs(pci_dt_t *pci_dt)␊ |
28 | {␊ |
29 | ␉char *devicepath;␊ |
30 | ␉bool doit, do_eth_devprop, do_gfx_devprop, do_enable_hpet, do_hda_devprop;␊ |
31 | ␉pci_dt_t *current = pci_dt;␊ |
32 | ␊ |
33 | ␉do_eth_devprop = do_gfx_devprop = do_enable_hpet = do_hda_devprop = false;␊ |
34 | ␊ |
35 | ␉getBoolForKey(kEthernetBuiltIn, &do_eth_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 | ␉␉␉␉␉set_eth_builtin(current);␊ |
59 | ␉␉␉␉}␊ |
60 | ␉␉␉␉break; // PCI_CLASS_NETWORK_ETHERNET␊ |
61 | ␊ |
62 | ␉␉␉case PCI_CLASS_DISPLAY_VGA:␊ |
63 | ␉␉␉␉DBG("GraphicsEnabler %s enabled\n", do_gfx_devprop? "is":"is not");␊ |
64 | ␉␉␉␉if (do_gfx_devprop)␊ |
65 | ␉␉␉␉{␊ |
66 | ␉␉␉␉␉switch (current->vendor_id)␊ |
67 | ␉␉␉␉␉{␊ |
68 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
69 | ␉␉␉␉␉␉␉if (getBoolForKey(kSkipAtiGfx, &doit, &bootInfo->chameleonConfig) && doit)␊ |
70 | ␉␉␉␉␉␉␉{␊ |
71 | ␉␉␉␉␉␉␉␉verbose("Skip ATi/AMD gfx device!\n");␊ |
72 | ␉␉␉␉␉␉␉}␊ |
73 | ␉␉␉␉␉␉␉else␊ |
74 | ␉␉␉␉␉␉␉{␊ |
75 | ␉␉␉␉␉␉␉␉setup_ati_devprop(current);␊ |
76 | ␉␉␉␉␉␉␉}␊ |
77 | ␉␉␉␉␉␉␉break; // PCI_VENDOR_ID_ATI␊ |
78 | ␊ |
79 | ␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL:␊ |
80 | ␉␉␉␉␉␉␉if (getBoolForKey(kSkipIntelGfx, &doit, &bootInfo->chameleonConfig) && doit)␊ |
81 | ␉␉␉␉␉␉␉{␊ |
82 | ␉␉␉␉␉␉␉␉verbose("Skip Intel gfx device!\n");␊ |
83 | ␉␉␉␉␉␉␉}␊ |
84 | ␉␉␉␉␉␉␉else␊ |
85 | ␉␉␉␉␉␉␉{␊ |
86 | ␉␉␉␉␉␉␉␉setup_gma_devprop(current);␊ |
87 | ␉␉␉␉␉␉␉}␊ |
88 | ␉␉␉␉␉␉␉break; // PCI_VENDOR_ID_INTEL␊ |
89 | ␊ |
90 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA:␊ |
91 | ␉␉␉␉␉␉␉if (getBoolForKey(kSkipNvidiaGfx, &doit, &bootInfo->chameleonConfig) && doit)␊ |
92 | ␉␉␉␉␉␉␉{␊ |
93 | ␉␉␉␉␉␉␉␉verbose("Skip Nvidia gfx device!\n");␊ |
94 | ␉␉␉␉␉␉␉}␊ |
95 | ␉␉␉␉␉␉␉else␊ |
96 | ␉␉␉␉␉␉␉{␊ |
97 | ␉␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
98 | ␉␉␉␉␉␉␉}␊ |
99 | ␉␉␉␉␉␉␉break; // PCI_VENDOR_ID_NVIDIA␊ |
100 | ␊ |
101 | ␉␉␉␉␉␉default:␊ |
102 | ␉␉␉␉␉␉␉break;␊ |
103 | ␉␉␉␉␉}␊ |
104 | ␉␉␉␉}␊ |
105 | ␉␉␉␉break; // PCI_CLASS_DISPLAY_VGA␊ |
106 | ␊ |
107 | ␉␉␉case PCI_CLASS_MULTIMEDIA_AUDIO_DEV:␊ |
108 | ␉␉␉␉DBG("Setup HDEF %s enabled\n", do_hda_devprop? "is":"is not");␊ |
109 | ␉␉␉␉if (do_hda_devprop)␊ |
110 | ␉␉␉␉{␊ |
111 | ␉␉␉␉␉setup_hda_devprop(current);␊ |
112 | ␉␉␉␉}␊ |
113 | ␉␉␉␉break; // PCI_CLASS_MULTIMEDIA_AUDIO_DEV␊ |
114 | ␊ |
115 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
116 | ␉␉␉␉DBG("USB\n");␊ |
117 | ␉␉␉␉notify_usb_dev(current);␊ |
118 | ␉␉␉␉break; // PCI_CLASS_SERIAL_USB␊ |
119 | ␊ |
120 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
121 | ␉␉␉␉DBG("Force HPET %s enabled\n", do_enable_hpet? "is":"is not");␊ |
122 | ␉␉␉␉if (do_enable_hpet)␊ |
123 | ␉␉␉␉{␊ |
124 | ␉␉␉␉␉force_enable_hpet(current);␊ |
125 | ␉␉␉␉}␊ |
126 | ␉␉␉␉break; // PCI_CLASS_BRIDGE_ISA␊ |
127 | ␊ |
128 | ␉␉␉}␊ |
129 | ␊ |
130 | ␉␉execute_hook("PCIDevice", current, NULL, NULL, NULL);␊ |
131 | ␉␉DBG("setup_pci_devs current device ID = [%04x:%04x]\n", current->vendor_id, current->device_id);␊ |
132 | ␉␉setup_pci_devs(current->children);␊ |
133 | ␉␉current = current->next;␊ |
134 | ␉}␊ |
135 | }␊ |
136 | |