Chameleon

Chameleon Svn Source Tree

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

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
21int getPciRootUID(void)
22{
23const char *val;
24int len;
25
26if (rootuid < 10) return rootuid;
27rootuid = 0;/* default uid = 0 */
28
29if (getValueForKey(kPCIRootUID, &val, &len, &bootInfo->bootConfig)) {
30if (isdigit(val[0])) rootuid = val[0] - '0';
31}
32/* Chameleon compatibility */
33else if (getValueForKey("PciRoot", &val, &len, &bootInfo->bootConfig)) {
34if (isdigit(val[0])) rootuid = val[0] - '0';
35}
36/* PCEFI compatibility */
37else if (getValueForKey("-pci0", &val, &len, &bootInfo->bootConfig)) {
38rootuid = 0;
39}
40else if (getValueForKey("-pci1", &val, &len, &bootInfo->bootConfig)) {
41rootuid = 1;
42}
43
44verbose("Using PCI-Root-UID value: %d\n", rootuid);
45return rootuid;
46}
47

Archive Download this file

Revision: 789