Chameleon

Chameleon Svn Source Tree

Root/branches/valv/AnVAL/i386/libsaio/pci_setup.c

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

Archive Download this file

Revision: 169