1 | /*␊ |
2 | * platform.c␊ |
3 | *␊ |
4 | * AsereBLN: cleanup␊ |
5 | */␊ |
6 | ␊ |
7 | #include "libsaio.h"␊ |
8 | #include "boot.h"␊ |
9 | #include "bootstruct.h"␊ |
10 | #include "pci.h"␊ |
11 | #include "platform.h"␊ |
12 | #include "cpu.h"␊ |
13 | #include "spd.h"␊ |
14 | #include "dram_controllers.h"␊ |
15 | ␊ |
16 | #ifndef DEBUG_PLATFORM␊ |
17 | #define DEBUG_PLATFORM 0␊ |
18 | #endif␊ |
19 | ␊ |
20 | #if DEBUG_PLATFORM␊ |
21 | #define DBG(x...)␉printf(x)␊ |
22 | #else␊ |
23 | #define DBG(x...)␊ |
24 | #endif␊ |
25 | ␊ |
26 | PlatformInfo_t Platform;␊ |
27 | pci_dt_t * dram_controller_dev = NULL;␊ |
28 | ␊ |
29 | /** Return if a CPU feature specified by feature is activated (true) or not (false) */␊ |
30 | bool platformCPUFeature(uint32_t feature)␊ |
31 | {␊ |
32 | ␉if (Platform.CPU.Features & feature)␊ |
33 | ␉{␊ |
34 | ␉␉return true;␊ |
35 | ␉}␊ |
36 | ␉else␊ |
37 | ␉{␊ |
38 | ␉␉return false;␊ |
39 | ␉}␊ |
40 | }␊ |
41 | ␊ |
42 | /** scan mem for memory autodection purpose */␊ |
43 | void scan_mem()␊ |
44 | {␊ |
45 | ␉static bool done = false;␊ |
46 | ␉if (done)␊ |
47 | ␉{␊ |
48 | ␉␉return;␊ |
49 | ␉}␊ |
50 | ␊ |
51 | ␉/* our code only works on Intel chipsets so make sure here */␊ |
52 | ␉if (pci_config_read16(PCIADDR(0, 0x00, 0), 0x00) != 0x8086)␊ |
53 | ␉{␊ |
54 | ␉␉bootInfo->memDetect = false;␊ |
55 | ␉}␊ |
56 | ␉else␊ |
57 | ␉{␊ |
58 | ␉␉bootInfo->memDetect = true;␊ |
59 | ␉}␊ |
60 | ␉/* manually */␊ |
61 | ␉getBoolForKey(kUseMemDetect, &bootInfo->memDetect, &bootInfo->chameleonConfig);␊ |
62 | ␊ |
63 | ␉if (bootInfo->memDetect)␊ |
64 | ␉{␊ |
65 | ␉␉if (dram_controller_dev != NULL)␊ |
66 | ␉␉{␊ |
67 | ␉␉␉scan_dram_controller(dram_controller_dev); // Rek: pci dev ram controller direct and fully informative scan ...␊ |
68 | ␉␉}␊ |
69 | ␉␉scan_spd(&Platform);␊ |
70 | ␉}␊ |
71 | ␉done = true;␊ |
72 | }␊ |
73 | ␊ |
74 | /*␊ |
75 | * Scan platform hardware information, called by the main entry point (common_boot() ) ␊ |
76 | * _before_ bootConfig xml parsing settings are loaded␊ |
77 | */␊ |
78 | void scan_platform(void)␊ |
79 | {␊ |
80 | ␉memset(&Platform, 0, sizeof(Platform));␊ |
81 | ␉build_pci_dt();␊ |
82 | ␉scan_cpu(&Platform);␊ |
83 | ␉//scan_mem(); Rek: called after pci devs init in fake_efi now ...␊ |
84 | }␊ |
85 | |