1 | /*␊ |
2 | * platform.c␊ |
3 | *␊ |
4 | */␊ |
5 | ␊ |
6 | #include "libsaio.h"␊ |
7 | #include "boot.h"␊ |
8 | #include "bootstruct.h"␊ |
9 | #include "pci.h"␊ |
10 | #include "platform.h"␊ |
11 | #include "cpu.h"␊ |
12 | #include "mem.h"␊ |
13 | #include "spd.h"␊ |
14 | ␊ |
15 | #ifndef DEBUG_PLATFORM␊ |
16 | #define DEBUG_PLATFORM 0␊ |
17 | #endif␊ |
18 | ␊ |
19 | #if DEBUG_PLATFORM␊ |
20 | #define DBG(x...)␉printf(x)␊ |
21 | #else␊ |
22 | #define DBG(x...)␊ |
23 | #endif␊ |
24 | ␊ |
25 | PlatformInfo_t Platform;␊ |
26 | ␊ |
27 | bool platformCPUFeature(uint32_t feature)␊ |
28 | {␊ |
29 | ␉if (Platform.CPU.Features & feature) {␊ |
30 | ␉␉return true;␊ |
31 | ␉} else {␊ |
32 | ␉␉return false;␊ |
33 | ␉}␊ |
34 | }␊ |
35 | ␊ |
36 | void scan_platform(void)␊ |
37 | {␊ |
38 | ␉const char␉*value;␊ |
39 | ␉int len;␊ |
40 | ␊ |
41 | ␉memset(&Platform, 0, sizeof(Platform));␊ |
42 | ␉build_pci_dt();␊ |
43 | ␉scan_cpu(&Platform);␊ |
44 | ␉scan_memory(&Platform);␊ |
45 | ␉scan_spd(&Platform);␊ |
46 | ␊ |
47 | ␉Platform.Type = 1; /* Desktop */␊ |
48 | ␉if (getValueForKey(kSystemType, &value, &len, &bootInfo->bootConfig) && value != NULL) {␊ |
49 | ␉␉Platform.Type = (unsigned char) strtoul(value, NULL, 10);␊ |
50 | ␉␉if (Platform.Type > 6) {␊ |
51 | ␉␉␉verbose("Error: system-type must be between 0 to 6. Defaulting to 1 !\n");␊ |
52 | ␉␉␉Platform.Type = 1;␊ |
53 | ␉␉}␊ |
54 | ␉}␊ |
55 | }␊ |
56 | |