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#include "Platform.h"
9
10#ifndef DEBUG_PCIROOT
11#define DEBUG_PCIROOT 1
12#endif
13
14#if DEBUG_PCIROOT
15#define DBG(x...) printf(x)
16#else
17#define DBG(x...)
18#endif
19
20static int rootuid = 10; //value means function wasnt ran yet
21
22
23int getPciRootUID(void)
24{
25const char *val;
26int len;
27
28if (rootuid < 10) return rootuid;
29rootuid = 0;/* default uid = 0 */
30
31if (getValueForKey(kPCIRootUID, &val, &len, &bootInfo->bootConfig)) {
32if (isdigit(val[0])) rootuid = val[0] - '0';
33
34if ( (rootuid >= 0) && (rootuid < 10) )
35goto out;
36else
37rootuid = 0;
38}
39
40/* PCEFI compatibility */
41if (getValueForKey("-pci0", &val, &len, &bootInfo->bootConfig)) {
42rootuid = 0;
43}
44else if (getValueForKey("-pci1", &val, &len, &bootInfo->bootConfig)) {
45rootuid = 1;
46}
47out:
48verbose("Using PCI-Root-UID value: %d\n", rootuid);
49return rootuid;
50}
51

Archive Download this file

Revision: 1119