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