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 | ␊ |
14 | #ifndef DEBUG_PLATFORM␊ |
15 | #define DEBUG_PLATFORM 0␊ |
16 | #endif␊ |
17 | ␊ |
18 | #if DEBUG_PLATFORM␊ |
19 | #define DBG(x...)␉printf(x)␊ |
20 | #else␊ |
21 | #define DBG(x...)␊ |
22 | #endif␊ |
23 | ␊ |
24 | PlatformInfo_t *Platform;␊ |
25 | ␊ |
26 | /** Return if a CPU feature specified by feature is activated (true) or not (false) */␊ |
27 | bool platformCPUFeature(uint32_t feature)␊ |
28 | {␊ |
29 | ␉return (Platform->CPU.Features & feature) ? true : false;␊ |
30 | }␊ |
31 | ␊ |
32 | /** Return if a CPU Extended feature specified by feature is activated (true) or not (false) */␊ |
33 | bool platformCPUExtFeature(uint32_t feature)␊ |
34 | {␊ |
35 | ␉return (Platform->CPU.ExtFeatures & feature) ? true : false;␊ |
36 | }␊ |
37 | ␊ |
38 | bool platformIsIntel(void)␊ |
39 | {␊ |
40 | ␉return (Platform->CPU.Vendor == 0x756E6547) ? true : false;␊ |
41 | }␊ |
42 | ␊ |
43 | uint32_t getCPUnCores(void)␊ |
44 | {␊ |
45 | ␉return Platform->CPU.NoCores;␊ |
46 | }␊ |
47 | ␊ |
48 | uint32_t getCPUnThreads(void)␊ |
49 | {␊ |
50 | ␉return Platform->CPU.NoThreads;␊ |
51 | }␊ |
52 | ␊ |
53 | uint8_t getCPUModel(void)␊ |
54 | {␊ |
55 | ␉return Platform->CPU.Model;␊ |
56 | }␊ |
57 | ␊ |
58 | uint8_t getCPUFamily(void)␊ |
59 | {␊ |
60 | ␉return Platform->CPU.Family;␊ |
61 | }␊ |
62 | ␊ |
63 | bool platformIsServer(void)␊ |
64 | {␊ |
65 | ␉return (Platform->CPU.isServer) ? true : false;␊ |
66 | }␊ |
67 | ␊ |
68 | bool platformIsMobile(void)␊ |
69 | {␊ |
70 | ␉return (Platform->CPU.isMobile) ? true : false;␊ |
71 | }␊ |
72 | ␊ |
73 | /** ␊ |
74 | Scan platform hardware information, called by the main entry point (common_boot() ) ␊ |
75 | _before_ bootConfig xml parsing settings are loaded␊ |
76 | */␊ |
77 | void scan_platform(void)␊ |
78 | {␉␊ |
79 | ␉Platform = malloc(sizeof(PlatformInfo_t)); ␊ |
80 | ␉memset(Platform, 0, sizeof(PlatformInfo_t));␊ |
81 | ␉build_pci_dt();␊ |
82 | ␉scan_cpu(Platform);␊ |
83 | }␊ |
84 | |