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 | #define DEBUG_PCI 0␊ |
10 | ␊ |
11 | #if DEBUG_PCI␊ |
12 | #define DBG(x...) msglog(x)␊ |
13 | #else␊ |
14 | #define DBG(x...)␊ |
15 | #endif␊ |
16 | ␊ |
17 | extern bool setup_ati_devprop(pci_dt_t *ati_dev);␊ |
18 | extern void set_eth_builtin(pci_dt_t *eth_dev);␊ |
19 | extern void notify_usb_dev(pci_dt_t *pci_dev);␊ |
20 | extern void force_enable_hpet(pci_dt_t *lpc_dev);␊ |
21 | ␊ |
22 | extern pci_dt_t *dram_controller_dev;␊ |
23 | ␊ |
24 | uint16_t vgaVendor;␊ |
25 | ␊ |
26 | void setup_pci_devs(pci_dt_t *pci_dt)␊ |
27 | {␊ |
28 | ␉char *devicepath;␊ |
29 | ␉bool do_eth_devprop, do_gfx_devprop, do_enable_hpet;␊ |
30 | ␉pci_dt_t *current = pci_dt;␊ |
31 | ␊ |
32 | ␉do_eth_devprop = do_gfx_devprop = do_enable_hpet = false;␊ |
33 | ␊ |
34 | ␉getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->chameleonConfig);␊ |
35 | ␉getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->chameleonConfig);␊ |
36 | ␉getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->chameleonConfig);␊ |
37 | ␊ |
38 | ␉while (current)␊ |
39 | ␉{␊ |
40 | ␉␉devicepath = get_pci_dev_path(current);␊ |
41 | ␊ |
42 | ␉␉switch (current->class_id)␊ |
43 | ␉␉{␊ |
44 | ␉␉␉case PCI_CLASS_BRIDGE_HOST:␊ |
45 | ␉␉␉␉DBG("Setup BRIDGE_HOST \n");␊ |
46 | ␉␉␉␉␉if (current->dev.addr == PCIADDR(0, 0, 0))␊ |
47 | ␉␉␉␉␉␉dram_controller_dev = current;␊ |
48 | ␉␉␉␉break;␊ |
49 | ␉␉␉␉␊ |
50 | ␉␉␉case PCI_CLASS_NETWORK_ETHERNET: ␊ |
51 | ␉␉␉␉DBG("Setup ETHERNET %s enabled\n", do_eth_devprop?"":"no");␊ |
52 | ␉␉␉␉if (do_eth_devprop)␊ |
53 | ␉␉␉␉␉set_eth_builtin(current);␊ |
54 | ␉␉␉␉break;␊ |
55 | ␉␉␉␉␊ |
56 | ␉␉␉case PCI_CLASS_DISPLAY_VGA:␊ |
57 | ␉␉␉␉DBG("GraphicsEnabler %s enabled\n", do_gfx_devprop?"":"no");␊ |
58 | ␉␉␉␉if (do_gfx_devprop)␊ |
59 | ␉␉␉␉{␊ |
60 | ␉␉␉␉␉vgaVendor = current->vendor_id;␊ |
61 | ␉␉␉␉␉switch (vgaVendor)␊ |
62 | ␉␉␉␉␉{␊ |
63 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
64 | ␉␉␉␉␉␉␉setup_ati_devprop(current); ␊ |
65 | ␉␉␉␉␉␉␉break;␊ |
66 | ␉␉␉␉␉␊ |
67 | ␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL:␊ |
68 | ␉␉␉␉␉␉␉setup_gma_devprop(current);␊ |
69 | ␉␉␉␉␉␉␉break;␊ |
70 | ␉␉␉␉␉␊ |
71 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA: ␊ |
72 | ␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
73 | ␉␉␉␉␉␉␉break;␊ |
74 | ␉␉␉␉␉}␊ |
75 | ␉␉␉␉}␊ |
76 | ␉␉␉␉break;␊ |
77 | ␊ |
78 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
79 | ␉␉␉␉DBG("USB fix \n");␊ |
80 | ␉␉␉␉notify_usb_dev(current);␊ |
81 | ␉␉␉␉break;␊ |
82 | ␊ |
83 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
84 | ␉␉␉␉DBG("Force HPET %s enabled\n", do_enable_hpet?"":"no");␊ |
85 | ␉␉␉␉if (do_enable_hpet)␊ |
86 | ␉␉␉␉␉force_enable_hpet(current);␊ |
87 | ␉␉␉␉break;␊ |
88 | ␉␉}␊ |
89 | ␉␉␊ |
90 | ␉␉execute_hook("PCIDevice", current, NULL, NULL, NULL);␊ |
91 | ␉␉DBG("setup_pci_devs current devID=%08x\n", current->device_id);␊ |
92 | ␉␉setup_pci_devs(current->children);␊ |
93 | ␉␉current = current->next;␊ |
94 | ␉}␊ |
95 | }␊ |
96 | |