Chameleon

Chameleon Svn Source Tree

Root/branches/meklort/i386/libsaio/pci_root.c

Source at commit 534 created 13 years 7 months ago.
By meklort, ACPI Pather is now a module. untested.
1/*
2 * Copyright 2009 netkas
3 */
4
5#include "libsaio.h"
6#include "boot.h"
7#include "bootstruct.h"
8
9#ifndef DEBUG_PCIROOT
10#define DEBUG_PCIROOT 1
11#endif
12
13#if DEBUG_PCIROOT
14#define DBG(x...) printf(x)
15#else
16#define DBG(x...)
17#endif
18
19static int rootuid = 10; //value means function wasnt ran yet
20
21static unsigned int findrootuid(unsigned char * dsdt, int len)
22{
23int i;
24for (i=0; i<64 && i<len-5; i++) //not far than 64 symbols from pci root
25{
26if(dsdt[i] == '_' && dsdt[i+1] == 'U' && dsdt[i+2] == 'I' && dsdt[i+3] == 'D' && dsdt[i+5] == 0x08)
27{
28return dsdt[i+4];
29}
30}
31return 11;
32}
33
34unsigned int findpciroot(unsigned char * dsdt,int len)
35{
36int i;
37
38for (i=0; i<len-4; i++) {
39if(dsdt[i] == 'P' && dsdt[i+1] == 'C' && dsdt[i+2] == 'I' && (dsdt[i+3] == 0x08 || dsdt [i+4] == 0x08)) {
40return findrootuid(dsdt+i, len-i);
41}
42}
43return 10;
44}
45
46int getPciRootUID(void)
47{
48const char *val;
49int len;
50extern int search_and_get_acpi_fd(const char *, const char **);
51
52if (rootuid < 10) return rootuid;
53rootuid = 0;/* default uid = 0 */
54
55if (getValueForKey(kPCIRootUID, &val, &len, &bootInfo->bootConfig)) {
56if (isdigit(val[0])) rootuid = val[0] - '0';
57}
58/* Chameleon compatibility */
59else if (getValueForKey("PciRoot", &val, &len, &bootInfo->bootConfig)) {
60if (isdigit(val[0])) rootuid = val[0] - '0';
61}
62/* PCEFI compatibility */
63else if (getValueForKey("-pci0", &val, &len, &bootInfo->bootConfig)) {
64rootuid = 0;
65}
66else if (getValueForKey("-pci1", &val, &len, &bootInfo->bootConfig)) {
67rootuid = 1;
68}
69
70verbose("Using PCI-Root-UID value: %d\n", rootuid);
71return rootuid;
72}
73

Archive Download this file

Revision: 534