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 | ␊ |
19 | static int rootuid = 10; //value means function wasnt ran yet␊ |
20 | ␊ |
21 | int getPciRootUID(void)␊ |
22 | {␊ |
23 | ␉const char *val;␊ |
24 | ␉int len;␊ |
25 | ␊ |
26 | ␉if (rootuid < 10) return rootuid;␊ |
27 | ␉rootuid = 0;␉/* default uid = 0 */␊ |
28 | ␊ |
29 | ␉if (getValueForKey(kPCIRootUID, &val, &len, DEFAULT_BOOT_CONFIG))␊ |
30 | ␉{␊ |
31 | ␉␉if (isdigit(val[0])) rootuid = val[0] - '0';␊ |
32 | ␉␉␊ |
33 | ␉␉if ( (rootuid >= 0) && (rootuid < 10) ) ␊ |
34 | ␉␉␉goto out;␊ |
35 | ␉␉else␊ |
36 | ␉␉␉rootuid = 0;␊ |
37 | ␉}␉␊ |
38 | ␉␊ |
39 | ␉/* PCEFI compatibility */␊ |
40 | ␉if (getValueForKey("-pci0", &val, &len, DEFAULT_BOOT_CONFIG))␊ |
41 | ␉{␊ |
42 | ␉␉rootuid = 0;␊ |
43 | ␉}␊ |
44 | ␉else if (getValueForKey("-pci1", &val, &len, DEFAULT_BOOT_CONFIG))␊ |
45 | ␉{␊ |
46 | ␉␉rootuid = 1;␊ |
47 | ␉}␊ |
48 | out:␊ |
49 | ␉verbose("Using PCI-Root-UID value: %d\n", rootuid);␊ |
50 | ␉return rootuid;␊ |
51 | }␊ |
52 | |