1 | /*␊ |
2 | * platform.c␊ |
3 | *␊ |
4 | * AsereBLN: cleanup␊ |
5 | *␊ |
6 | *␉ALL functions and struct. here will be DEPRECATED soon, i prefer Hash. (hmm, i mean hashable structures ... of course)␊ |
7 | *␊ |
8 | */␊ |
9 | ␊ |
10 | #include "libsaio.h"␊ |
11 | #include "boot.h"␊ |
12 | #include "bootstruct.h"␊ |
13 | #include "pci.h"␊ |
14 | #include "platform.h"␊ |
15 | #include "cpu.h"␊ |
16 | ␊ |
17 | #ifndef DEBUG_PLATFORM␊ |
18 | #define DEBUG_PLATFORM 0␊ |
19 | #endif␊ |
20 | ␊ |
21 | #if DEBUG_PLATFORM␊ |
22 | #define DBG(x...)␉printf(x)␊ |
23 | #else␊ |
24 | #define DBG(x...)␊ |
25 | #endif␊ |
26 | ␊ |
27 | PlatformInfo_t *Platform;␊ |
28 | ␊ |
29 | /** Return if a CPU feature specified by feature is activated (true) or not (false) */␊ |
30 | bool platformCPUFeature(uint32_t feature)␊ |
31 | {␊ |
32 | ␉return (Platform->CPU.Features & feature) ? true : false;␊ |
33 | }␊ |
34 | ␊ |
35 | /** Return if a CPU Extended feature specified by feature is activated (true) or not (false) */␊ |
36 | bool platformCPUExtFeature(uint32_t feature)␊ |
37 | {␊ |
38 | ␉return (Platform->CPU.ExtFeatures & feature) ? true : false;␊ |
39 | }␊ |
40 | ␊ |
41 | bool platformIsIntel(void)␊ |
42 | {␊ |
43 | ␉return (Platform->CPU.Vendor == 0x756E6547) ? true : false;␊ |
44 | }␊ |
45 | ␊ |
46 | uint32_t getCPUnCores(void)␊ |
47 | {␊ |
48 | ␉return Platform->CPU.NoCores;␊ |
49 | }␊ |
50 | ␊ |
51 | uint32_t getCPUnThreads(void)␊ |
52 | {␊ |
53 | ␉return Platform->CPU.NoThreads;␊ |
54 | }␊ |
55 | ␊ |
56 | uint8_t getCPUModel(void)␊ |
57 | {␊ |
58 | ␉return Platform->CPU.Model;␊ |
59 | }␊ |
60 | ␊ |
61 | uint8_t getCPUFamily(void)␊ |
62 | {␊ |
63 | ␉return Platform->CPU.Family;␊ |
64 | }␊ |
65 | ␊ |
66 | bool platformIsServer(void)␊ |
67 | {␊ |
68 | ␉return (Platform->CPU.isServer) ? true : false;␊ |
69 | }␊ |
70 | ␊ |
71 | bool platformIsMobile(void)␊ |
72 | {␊ |
73 | ␉return (Platform->CPU.isMobile) ? true : false;␊ |
74 | }␊ |
75 | ␊ |
76 | /** ␊ |
77 | Scan platform hardware information, called by the main entry point (common_boot() ) ␊ |
78 | _before_ bootConfig xml parsing settings are loaded␊ |
79 | */␊ |
80 | void scan_platform(void)␊ |
81 | {␉␊ |
82 | ␉Platform = malloc(sizeof(PlatformInfo_t)); ␊ |
83 | ␉memset(Platform, 0, sizeof(PlatformInfo_t));␊ |
84 | ␉build_pci_dt();␊ |
85 | ␉scan_cpu(Platform);␊ |
86 | }␊ |
87 | |