Chameleon

Chameleon Svn Source Tree

Root/branches/slice/trunkM/i386/libsaio/pci_setup.c

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

Archive Download this file

Revision: 1201