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))
32{
33if (isdigit(val[0])) rootuid = val[0] - '0';
34
35if ( (rootuid >= 0) && (rootuid < 10) )
36goto out;
37else
38rootuid = 0;
39}
40
41/* PCEFI compatibility */
42if (getValueForKey("-pci0", &val, &len, &bootInfo->bootConfig))
43{
44rootuid = 0;
45}
46else if (getValueForKey("-pci1", &val, &len, &bootInfo->bootConfig))
47{
48rootuid = 1;
49}
50out:
51verbose("Using PCI-Root-UID value: %d\n", rootuid);
52return rootuid;
53}
54

Archive Download this file

Revision: 1804