1 | #include "libsaio.h"␊ |
2 | #include "boot.h"␊ |
3 | #include "bootstruct.h"␊ |
4 | #include "pci.h"␊ |
5 | #include "gma.h"␊ |
6 | #include "nvidia.h"␊ |
7 | #include "modules.h"␊ |
8 | ␊ |
9 | ␊ |
10 | extern bool setup_ati_devprop(pci_dt_t *ati_dev);␊ |
11 | extern void set_eth_builtin(pci_dt_t *eth_dev);␊ |
12 | extern void notify_usb_dev(pci_dt_t *pci_dev);␊ |
13 | extern void force_enable_hpet(pci_dt_t *lpc_dev);␊ |
14 | ␊ |
15 | extern pci_dt_t *dram_controller_dev;␊ |
16 | ␊ |
17 | void setup_pci_devs(pci_dt_t *pci_dt)␊ |
18 | {␊ |
19 | ␉char *devicepath;␊ |
20 | ␉bool doit, do_eth_devprop, do_gfx_devprop, do_enable_hpet;␊ |
21 | ␉pci_dt_t *current = pci_dt;␊ |
22 | ␊ |
23 | ␉do_eth_devprop = do_gfx_devprop = do_enable_hpet = false;␊ |
24 | ␊ |
25 | ␉getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->chameleonConfig);␊ |
26 | ␉getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->chameleonConfig);␊ |
27 | ␉getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->chameleonConfig);␊ |
28 | ␊ |
29 | ␉while (current)␊ |
30 | ␉{␊ |
31 | ␉␉devicepath = get_pci_dev_path(current);␊ |
32 | ␊ |
33 | ␉␉switch (current->class_id)␊ |
34 | ␉␉{␊ |
35 | ␉␉␉case PCI_CLASS_BRIDGE_HOST:␊ |
36 | ␉␉␉␉if (current->dev.addr == PCIADDR(0, 0, 0))␊ |
37 | ␉␉␉␉{␊ |
38 | ␉␉␉␉␉dram_controller_dev = current;␊ |
39 | ␉␉␉␉}␊ |
40 | ␉␉␉␉break;␊ |
41 | ␉␉␉␉␊ |
42 | ␉␉␉case PCI_CLASS_NETWORK_ETHERNET: ␊ |
43 | ␉␉␉␉if (do_eth_devprop)␊ |
44 | ␉␉␉␉␉set_eth_builtin(current);␊ |
45 | ␉␉␉␉break;␊ |
46 | ␊ |
47 | ␉␉␉case PCI_CLASS_DISPLAY_VGA:␊ |
48 | ␉␉␉␉if (do_gfx_devprop)␊ |
49 | ␉␉␉␉{␊ |
50 | ␉␉␉␉␉switch (current->vendor_id)␊ |
51 | ␉␉␉␉␉{␊ |
52 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
53 | ␉␉␉␉␉␉␉if (getBoolForKey(kSkipAtiGfx, &doit, &bootInfo->chameleonConfig) && doit)␊ |
54 | ␉␉␉␉␉␉␉{␊ |
55 | ␉␉␉␉␉␉␉␉verbose("Skip ATi/AMD gfx device!\n");␊ |
56 | ␉␉␉␉␉␉␉}␊ |
57 | ␉␉␉␉␉␉␉else␊ |
58 | ␉␉␉␉␉␉␉{␊ |
59 | ␉␉␉␉␉␉␉␉setup_ati_devprop(current);␊ |
60 | ␉␉␉␉␉␉␉}␊ |
61 | ␉␉␉␉␉␉␉break;␊ |
62 | ␊ |
63 | ␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL:␊ |
64 | ␉␉␉␉␉␉␉if (getBoolForKey(kSkipIntelGfx, &doit, &bootInfo->chameleonConfig) && doit)␊ |
65 | ␉␉␉␉␉␉␉{␊ |
66 | ␉␉␉␉␉␉␉␉verbose("Skip Intel gfx device!\n");␊ |
67 | ␉␉␉␉␉␉␉}␊ |
68 | ␉␉␉␉␉␉␉else␊ |
69 | ␉␉␉␉␉␉␉{␊ |
70 | ␉␉␉␉␉␉␉␉setup_gma_devprop(current);␊ |
71 | ␉␉␉␉␉␉␉}␊ |
72 | ␉␉␉␉␉␉␉break;␊ |
73 | ␊ |
74 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA:␊ |
75 | ␉␉␉␉␉␉␉if (getBoolForKey(kSkipNvidiaGfx, &doit, &bootInfo->chameleonConfig) && doit)␊ |
76 | ␉␉␉␉␉␉␉{␊ |
77 | ␉␉␉␉␉␉␉␉verbose("Skip Nvidia gfx device!\n");␊ |
78 | ␉␉␉␉␉␉␉}␊ |
79 | ␉␉␉␉␉␉␉␉else␊ |
80 | ␉␉␉␉␉␉␉{␊ |
81 | ␉␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
82 | ␉␉␉␉␉␉␉}␊ |
83 | ␉␉␉␉␉␉␉break;␊ |
84 | ␉␉␉␉␉␉}␊ |
85 | ␉␉␉␉␉}␊ |
86 | ␉␉␉␉␉break;␊ |
87 | ␊ |
88 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
89 | ␉␉␉␉notify_usb_dev(current);␊ |
90 | ␉␉␉␉break;␊ |
91 | ␊ |
92 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
93 | ␉␉␉␉if (do_enable_hpet)␊ |
94 | ␉␉␉␉␉force_enable_hpet(current);␊ |
95 | ␉␉␉␉break;␊ |
96 | ␉␉}␊ |
97 | ␉␉␊ |
98 | ␉␉execute_hook("PCIDevice", current, NULL, NULL, NULL);␊ |
99 | ␉␉␊ |
100 | ␉␉setup_pci_devs(current->children);␊ |
101 | ␉␉current = current->next;␊ |
102 | ␉}␊ |
103 | }␊ |
104 | |