Chameleon

Chameleon Svn Source Tree

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

1/*
2 * Copyright 2009 netkas
3 */
4
5#include "pci_root.h"
6#include "bootstruct.h"
7#include "Platform.h"
8
9#ifndef DEBUG_PCIROOT
10#define DEBUG_PCIROOT 0
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
21
22int getPciRootUID(void)
23{
24const char *val;
25int len;
26
27if (rootuid < 10) return rootuid;
28rootuid = 0;/* default uid = 0 */
29
30if (getValueForKey(kPCIRootUID, &val, &len, DEFAULT_BOOT_CONFIG))
31{
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, DEFAULT_BOOT_CONFIG))
42{
43rootuid = 0;
44}
45else if (getValueForKey("-pci1", &val, &len, DEFAULT_BOOT_CONFIG))
46{
47rootuid = 1;
48}
49out:
50verbose("Using PCI-Root-UID value: %d\n", rootuid);
51return rootuid;
52}
53

Archive Download this file

Revision: 1899