1 | #include "libsaio.h"␊ |
2 | #include "boot.h"␊ |
3 | #include "bootstruct.h"␊ |
4 | #include "pci.h"␊ |
5 | #include "nvidia.h"␊ |
6 | #include "ati.h"␊ |
7 | #include "gma.h"␊ |
8 | ␊ |
9 | extern void set_eth_builtin(pci_dt_t *eth_dev);␊ |
10 | extern int ehci_acquire(pci_dt_t *pci_dev);␊ |
11 | extern int legacy_off(pci_dt_t *pci_dev);␊ |
12 | extern int uhci_reset(pci_dt_t *pci_dev);␊ |
13 | extern void force_enable_hpet(pci_dt_t *lpc_dev);␊ |
14 | ␊ |
15 | void setup_pci_devs(pci_dt_t *pci_dt)␊ |
16 | {␊ |
17 | ␉char *devicepath;␊ |
18 | ␉bool do_eth_devprop, do_gfx_devprop, fix_ehci, fix_legoff, fix_uhci, fix_usb, do_enable_hpet;␊ |
19 | ␉pci_dt_t *current = pci_dt;␊ |
20 | ␊ |
21 | ␉do_eth_devprop = do_gfx_devprop = fix_ehci = fix_legoff = fix_uhci = fix_usb = do_enable_hpet = false;␊ |
22 | ␊ |
23 | ␉getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->bootConfig);␊ |
24 | ␉getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->bootConfig);␊ |
25 | ␉if (getBoolForKey(kUSBBusFix, &fix_usb, &bootInfo->bootConfig) && fix_usb) {␊ |
26 | ␉␉fix_ehci = fix_uhci = true;␊ |
27 | ␉} else {␊ |
28 | ␉␉getBoolForKey(kEHCIacquire, &fix_ehci, &bootInfo->bootConfig);␊ |
29 | ␉␉getBoolForKey(kUHCIreset, &fix_uhci, &bootInfo->bootConfig);␊ |
30 | ␉}␊ |
31 | ␉getBoolForKey(kUSBLegacyOff, &fix_legoff, &bootInfo->bootConfig);␊ |
32 | ␉getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->bootConfig);␊ |
33 | ␊ |
34 | ␉while (current)␊ |
35 | ␉{␊ |
36 | ␉␉devicepath = get_pci_dev_path(current);␊ |
37 | ␊ |
38 | ␉␉switch (current->class_id)␊ |
39 | ␉␉{␊ |
40 | ␉␉␉case PCI_CLASS_NETWORK_ETHERNET: ␊ |
41 | ␉␉␉␉if (do_eth_devprop)␊ |
42 | ␉␉␉␉␉set_eth_builtin(current);␊ |
43 | ␉␉␉␉break;␊ |
44 | ␉␉␉␉␊ |
45 | ␉␉␉case PCI_CLASS_DISPLAY_VGA:␊ |
46 | ␉␉␉case PCI_CLASS_DISPLAY_OTHER:␊ |
47 | ␉␉␉␉if (do_gfx_devprop)␊ |
48 | ␉␉␉␉␉switch (current->vendor_id)␊ |
49 | ␉␉␉␉␉{␊ |
50 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
51 | ␉␉␉␉␉␉␉verbose("ATI VGA Controller [%04x:%04x] :: %s \n", ␊ |
52 | ␉␉␉␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
53 | ␉␉␉␉␉␉␉setup_ati_devprop(current); ␊ |
54 | ␉␉␉␉␉␉␉break;␊ |
55 | ␉␉␉␉␉␊ |
56 | ␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL: ␊ |
57 | ␉␉␉␉␉␉␉verbose("Intel Graphics Controller [%04x:%04x] :: %s \n",␊ |
58 | ␉␉␉␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
59 | ␉␉␉␉␉␉␉setup_gma_devprop(current);␊ |
60 | ␉␉␉␉␉␉␉break;␊ |
61 | ␉␉␉␉␉␉␉␊ |
62 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA: ␊ |
63 | ␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
64 | ␉␉␉␉␉␉␉break;␊ |
65 | ␉␉␉␉␉}␊ |
66 | ␉␉␉␉break;␊ |
67 | ␊ |
68 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
69 | ␉␉␉␉switch (pci_config_read8(current->dev.addr, PCI_CLASS_PROG))␊ |
70 | ␉␉␉␉{␊ |
71 | ␉␉␉␉␉/* EHCI */␊ |
72 | ␉␉␉␉␉case 0x20:␊ |
73 | ␉␉␉␉ ␉if (fix_ehci)␊ |
74 | ␉␉␉␉␉␉␉ehci_acquire(current);␊ |
75 | ␉␉␉␉␉␉if (fix_legoff)␊ |
76 | ␉␉␉␉␉␉␉legacy_off(current);␊ |
77 | ␉␉␉␉␉␉break;␊ |
78 | ␊ |
79 | ␉␉␉␉␉/* UHCI */␊ |
80 | ␉␉␉␉␉case 0x00:␊ |
81 | ␉␉␉␉ ␉if (fix_uhci)␊ |
82 | ␉␉␉␉␉␉␉uhci_reset(current);␊ |
83 | ␉␉␉␉␉␉break;␊ |
84 | ␉␉␉␉}␊ |
85 | ␉␉␉␉break;␊ |
86 | ␊ |
87 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
88 | ␉␉␉␉if (do_enable_hpet)␊ |
89 | ␉␉␉␉␉force_enable_hpet(current);␊ |
90 | ␉␉␉␉break;␊ |
91 | ␉␉}␊ |
92 | ␉␉␊ |
93 | ␉␉setup_pci_devs(current->children);␊ |
94 | ␉␉current = current->next;␊ |
95 | ␉}␊ |
96 | }␊ |
97 | |