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 | ␉␉␉␉if (do_gfx_devprop)␊ |
47 | ␉␉␉␉␉switch (current->vendor_id)␊ |
48 | ␉␉␉␉␉{␊ |
49 | ␉␉␉␉␉␉case PCI_VENDOR_ID_ATI:␊ |
50 | ␉␉␉␉␉␉␉verbose("ATI VGA Controller [%04x:%04x] :: %s \n", ␊ |
51 | ␉␉␉␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
52 | ␉␉␉␉␉␉␉setup_ati_devprop(current); ␊ |
53 | ␉␉␉␉␉␉␉break;␊ |
54 | ␉␉␉␉␉␊ |
55 | ␉␉␉␉␉␉case PCI_VENDOR_ID_INTEL: ␊ |
56 | ␉␉␉␉␉␉␉verbose("Intel Graphics Controller [%04x:%04x] :: %s \n",␊ |
57 | ␉␉␉␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
58 | ␉␉␉␉␉␉␉setup_gma_devprop(current);␊ |
59 | ␉␉␉␉␉␉␉break;␊ |
60 | ␉␉␉␉␉␉␉␊ |
61 | ␉␉␉␉␉␉case PCI_VENDOR_ID_NVIDIA: ␊ |
62 | ␉␉␉␉␉␉␉setup_nvidia_devprop(current);␊ |
63 | ␉␉␉␉␉␉␉break;␊ |
64 | ␉␉␉␉␉}␊ |
65 | ␉␉␉␉break;␊ |
66 | ␊ |
67 | ␉␉␉case PCI_CLASS_SERIAL_USB:␊ |
68 | ␉␉␉␉switch (pci_config_read8(current->dev.addr, PCI_CLASS_PROG))␊ |
69 | ␉␉␉␉{␊ |
70 | ␉␉␉␉␉/* EHCI */␊ |
71 | ␉␉␉␉␉case 0x20:␊ |
72 | ␉␉␉␉ ␉if (fix_ehci)␊ |
73 | ␉␉␉␉␉␉␉ehci_acquire(current);␊ |
74 | ␉␉␉␉␉␉if (fix_legoff)␊ |
75 | ␉␉␉␉␉␉␉legacy_off(current);␊ |
76 | ␉␉␉␉␉␉break;␊ |
77 | ␊ |
78 | ␉␉␉␉␉/* UHCI */␊ |
79 | ␉␉␉␉␉case 0x00:␊ |
80 | ␉␉␉␉ ␉if (fix_uhci)␊ |
81 | ␉␉␉␉␉␉␉uhci_reset(current);␊ |
82 | ␉␉␉␉␉␉break;␊ |
83 | ␉␉␉␉}␊ |
84 | ␉␉␉␉break;␊ |
85 | ␊ |
86 | ␉␉␉case PCI_CLASS_BRIDGE_ISA:␊ |
87 | ␉␉␉␉if (do_enable_hpet)␊ |
88 | ␉␉␉␉␉force_enable_hpet(current);␊ |
89 | ␉␉␉␉break;␊ |
90 | ␉␉}␊ |
91 | ␉␉␊ |
92 | ␉␉setup_pci_devs(current->children);␊ |
93 | ␉␉current = current->next;␊ |
94 | ␉}␊ |
95 | }␊ |
96 | |