1 | /*␊ |
2 | * platform.h␊ |
3 | * AsereBLN: reworked and extended␊ |
4 | *␊ |
5 | */␊ |
6 | ␊ |
7 | #ifndef __LIBSAIO_PLATFORM_H␊ |
8 | #define __LIBSAIO_PLATFORM_H␊ |
9 | ␊ |
10 | //#include "libsaio.h"␊ |
11 | ␊ |
12 | extern bool platformCPUFeature(uint32_t);␊ |
13 | extern void scan_platform(void);␊ |
14 | extern void dumpPhysAddr(const char * title, void * a, int len);␊ |
15 | ␊ |
16 | /* CPUID Vendor */␊ |
17 | #define CPUID_VENDOR_INTEL 0x756E6547␊ |
18 | #define CPUID_VENDOR_AMD 0x68747541␊ |
19 | ␊ |
20 | /* CPUID index into cpuid_raw */␊ |
21 | #define CPUID_0␉␉␉␉0␊ |
22 | #define CPUID_1␉␉␉␉1␊ |
23 | #define CPUID_2␉␉␉␉2␊ |
24 | #define CPUID_3␉␉␉␉3␊ |
25 | #define CPUID_4␉␉␉␉4␊ |
26 | #define CPUID_5␉␉␉␉5␊ |
27 | #define CPUID_6␉␉␉␉6␊ |
28 | #define CPUID_80␉␉␉7␊ |
29 | #define CPUID_81␉␉␉8␊ |
30 | #define CPUID_88␉␉␉9␊ |
31 | #define CPUID_MAX␉␉␉10␊ |
32 | ␊ |
33 | #define CPU_MODEL_ANY␉␉␉0x00␊ |
34 | #define CPU_MODEL_UNKNOWN␉␉0x01␊ |
35 | #define CPU_MODEL_PRESCOTT␉␉0x03␉␉␉// Celeron D, Pentium 4 (90nm)␊ |
36 | #define CPU_MODEL_NOCONA␉␉0x04␉␉␉// Xeon Nocona/Paxville, Irwindale (90nm)␊ |
37 | #define CPU_MODEL_PRESLER␉␉0x06␉␉␉// Pentium 4, Pentium D (65nm)␊ |
38 | #define CPU_MODEL_PENTIUM_M␉␉0x09␉␉␉// Banias Pentium M (130nm)␊ |
39 | #define CPU_MODEL_DOTHAN␉␉0x0D␉␉␉// Dothan Pentium M, Celeron M (90nm)␊ |
40 | #define CPU_MODEL_YONAH␉␉␉0x0E␉␉␉// Sossaman, Yonah␊ |
41 | #define CPU_MODEL_MEROM␉␉␉0x0F␉␉␉// Allendale, Conroe, Kentsfield, Woodcrest, Clovertown, Tigerton, Merom␊ |
42 | #define CPU_MODEL_CONROE␉␉0x0F␉␉␉// ␊ |
43 | #define CPU_MODEL_CELERON␉␉0x16␉␉␉// Merom, Conroe (65nm)␊ |
44 | #define CPU_MODEL_PENRYN␉␉0x17␉␉␉// Wolfdale, Yorkfield, Harpertown, Penryn␊ |
45 | #define CPU_MODEL_WOLFDALE␉␉0x17␉␉␉// ␊ |
46 | #define CPU_MODEL_NEHALEM␉␉0x1A␉␉␉// Bloomfield. Nehalem-EP, Nehalem-WS, Gainestown␊ |
47 | #define CPU_MODEL_ATOM␉␉␉0x1C␉␉␉// Pineview, Bonnell␊ |
48 | #define CPU_MODEL_XEON_MP␉␉0x1D␉␉␉// MP 7400␊ |
49 | #define CPU_MODEL_FIELDS␉␉0x1E␉␉␉// Lynnfield, Clarksfield, Jasper Forest␊ |
50 | #define CPU_MODEL_DALES␉␉␉0x1F␉␉␉// Havendale, Auburndale␊ |
51 | #define CPU_MODEL_DALES_32NM␉␉0x25␉␉␉// Clarkdale, Arrandale␊ |
52 | #define CPU_MODEL_ATOM_SAN␉␉0x26␉␉␉// Lincroft␊ |
53 | #define CPU_MODEL_LINCROFT␉␉0x27␉␉␉// Bonnell␊ |
54 | #define CPU_MODEL_SANDYBRIDGE␉␉0x2A␉␉␉// Sandy Bridge␊ |
55 | #define CPU_MODEL_WESTMERE␉␉0x2C␉␉␉// Gulftown, Westmere-EP, Westmere-WS␊ |
56 | #define CPU_MODEL_JAKETOWN␉␉0x2D␉␉␉// Sandy Bridge-E, Sandy Bridge-EP␊ |
57 | #define CPU_MODEL_NEHALEM_EX␉␉0x2E␉␉␉// Beckton␊ |
58 | #define CPU_MODEL_WESTMERE_EX␉␉0x2F␉␉␉// Westmere-EX␊ |
59 | //#define CPU_MODEL_BONNELL_ATOM␉0x35␉␉␉// Bonnell␊ |
60 | #define CPU_MODEL_ATOM_2000␉␉0x36␉␉␉// Cedarview / Saltwell␊ |
61 | #define CPU_MODEL_SILVERMONT␉␉0x37␉␉␉// Atom Silvermont␊ |
62 | #define CPU_MODEL_IVYBRIDGE␉␉0x3A␉␉␉// Ivy Bridge␊ |
63 | #define CPU_MODEL_HASWELL␉␉0x3C␉␉␉// Haswell DT␊ |
64 | #define CPU_MODEL_BROADWELL␉␉0x3D␉␉␉// Core M, Broadwell / Core-AVX2␊ |
65 | #define CPU_MODEL_IVYBRIDGE_XEON␉0x3E␉␉␉// Ivy Bridge Xeon␊ |
66 | #define CPU_MODEL_HASWELL_SVR␉␉0x3F␉␉␉// Haswell Server␊ |
67 | //#define CPU_MODEL_HASWELL_H␉␉0x??␉␉␉// Haswell H␊ |
68 | #define CPU_MODEL_HASWELL_ULT␉␉0x45␉␉␉// Haswell ULT␊ |
69 | #define CPU_MODEL_CRYSTALWELL␉␉0x46␉␉␉// Crystal Well␊ |
70 | // 4A silvermont / atom␊ |
71 | #define CPU_MODEL_AVOTON␉␉0x4D␉␉␉// Silvermont/Avoton Atom C2000␊ |
72 | // 4E Core???␊ |
73 | #define CPU_MODEL_BRODWELL_SVR␉␉0x4F␉␉␉// Broadwell Server␊ |
74 | #define CPU_MODEL_BRODWELL_MSVR␉␉0x56␉␉␉// Broadwell Micro Server␊ |
75 | // 5A silvermont / atom␊ |
76 | // 5D silvermont / atom␊ |
77 | ␊ |
78 | /* CPU Features */␊ |
79 | #define CPU_FEATURE_MMX␉␉␉0x00000001␉␉// MMX Instruction Set␊ |
80 | #define CPU_FEATURE_SSE␉␉␉0x00000002␉␉// SSE Instruction Set␊ |
81 | #define CPU_FEATURE_SSE2␉␉0x00000004␉␉// SSE2 Instruction Set␊ |
82 | #define CPU_FEATURE_SSE3␉␉0x00000008␉␉// SSE3 Instruction Set␊ |
83 | #define CPU_FEATURE_SSE41␉␉0x00000010␉␉// SSE41 Instruction Set␊ |
84 | #define CPU_FEATURE_SSE42␉␉0x00000020␉␉// SSE42 Instruction Set␊ |
85 | #define CPU_FEATURE_EM64T␉␉0x00000040␉␉// 64Bit Support␊ |
86 | #define CPU_FEATURE_HTT␉␉␉0x00000080␉␉// HyperThreading␊ |
87 | #define CPU_FEATURE_MOBILE␉␉0x00000100␉␉// Mobile CPU␊ |
88 | #define CPU_FEATURE_MSR␉␉␉0x00000200␉␉// MSR Support␊ |
89 | ␊ |
90 | /* SMBIOS Memory Types */ ␊ |
91 | #define SMB_MEM_TYPE_UNDEFINED␉0␊ |
92 | #define SMB_MEM_TYPE_OTHER␉␉1␊ |
93 | #define SMB_MEM_TYPE_UNKNOWN␉2␊ |
94 | #define SMB_MEM_TYPE_DRAM␉␉3␊ |
95 | #define SMB_MEM_TYPE_EDRAM␉␉4␊ |
96 | #define SMB_MEM_TYPE_VRAM␉␉5␊ |
97 | #define SMB_MEM_TYPE_SRAM␉␉6␊ |
98 | #define SMB_MEM_TYPE_RAM␉␉7␊ |
99 | #define SMB_MEM_TYPE_ROM␉␉8␊ |
100 | #define SMB_MEM_TYPE_FLASH␉␉9␊ |
101 | #define SMB_MEM_TYPE_EEPROM␉␉10␊ |
102 | #define SMB_MEM_TYPE_FEPROM␉␉11␊ |
103 | #define SMB_MEM_TYPE_EPROM␉␉12␊ |
104 | #define SMB_MEM_TYPE_CDRAM␉␉13␊ |
105 | #define SMB_MEM_TYPE_3DRAM␉␉14␊ |
106 | #define SMB_MEM_TYPE_SDRAM␉␉15␊ |
107 | #define SMB_MEM_TYPE_SGRAM␉␉16␊ |
108 | #define SMB_MEM_TYPE_RDRAM␉␉17␊ |
109 | #define SMB_MEM_TYPE_DDR␉␉18␊ |
110 | #define SMB_MEM_TYPE_DDR2␉␉19␊ |
111 | #define SMB_MEM_TYPE_FBDIMM␉␉20␊ |
112 | #define SMB_MEM_TYPE_DDR3␉␉24␉␉␉// Supported in 10.5.6+ AppleSMBIOS␊ |
113 | #define SMB_MEM_TYPE_DDR4␉␉26␊ |
114 | ␊ |
115 | /* Memory Configuration Types */ ␊ |
116 | #define SMB_MEM_CHANNEL_UNKNOWN␉␉0␊ |
117 | #define SMB_MEM_CHANNEL_SINGLE␉␉1␊ |
118 | #define SMB_MEM_CHANNEL_DUAL␉␉2␊ |
119 | #define SMB_MEM_CHANNEL_TRIPLE␉␉3␊ |
120 | ␊ |
121 | /* Maximum number of ram slots */␊ |
122 | #define MAX_RAM_SLOTS␉␉␉8␊ |
123 | #define RAM_SLOT_ENUMERATOR␉␉{0, 2, 4, 1, 3, 5, 6, 8, 10, 7, 9, 11}␊ |
124 | ␊ |
125 | /* Maximum number of SPD bytes */␊ |
126 | #define MAX_SPD_SIZE␉␉␉256␊ |
127 | ␊ |
128 | /* Size of SMBIOS UUID in bytes */␊ |
129 | #define UUID_LEN␉␉␉16␊ |
130 | ␊ |
131 | typedef struct _RamSlotInfo_t␊ |
132 | {␊ |
133 | ␉uint32_t␉␉ModuleSize;␉␉␉␉␉// Size of Module in MB␊ |
134 | ␉uint32_t␉␉Frequency;␉␉␉␉␉// in Mhz␊ |
135 | ␉const char*␉␉Vendor;␊ |
136 | ␉const char*␉␉PartNo;␊ |
137 | ␉const char*␉␉SerialNo;␊ |
138 | ␉char*␉␉␉spd;␉␉␉␉␉␉// SPD Dump␊ |
139 | ␉bool␉␉␉InUse;␊ |
140 | ␉uint8_t␉␉␉Type;␊ |
141 | ␉uint8_t␉␉␉BankConnections;␉␉␉// table type 6, see (3.3.7)␊ |
142 | ␉uint8_t␉␉␉BankConnCnt;␊ |
143 | } RamSlotInfo_t;␊ |
144 | ␊ |
145 | //==============================================================================␊ |
146 | ␊ |
147 | typedef struct _PlatformInfo_t␊ |
148 | {␊ |
149 | ␉struct CPU {␊ |
150 | ␉␉uint32_t␉␉Features;␉␉␉␉// CPU Features like MMX, SSE2, VT, MobileCPU␊ |
151 | ␉␉uint32_t␉␉Vendor;␉␉␉␉␉// Vendor␊ |
152 | ␉␉uint32_t␉␉CoresPerPackage;␊ |
153 | ␉␉uint32_t␉␉LogicalPerPackage;␊ |
154 | ␉␉uint32_t␉␉Signature;␉␉␉␉// Processor Signature␊ |
155 | ␉␉uint32_t␉␉Stepping;␉␉␉␉// Stepping␊ |
156 | ␉␉//uint16_t␉␉Type;␉␉␉␉␉// Type␊ |
157 | ␉␉uint32_t␉␉Model;␉␉␉␉␉// Model␊ |
158 | ␉␉uint32_t␉␉ExtModel;␉␉␉␉// Extended Model␊ |
159 | ␉␉uint32_t␉␉Family;␉␉␉␉␉// Family␊ |
160 | ␉␉uint32_t␉␉ExtFamily;␉␉␉␉// Extended Family␊ |
161 | ␉␉uint32_t␉␉NoCores;␉␉␉␉// No Cores per Package␊ |
162 | ␉␉uint32_t␉␉NoThreads;␉␉␉␉// Threads per Package␊ |
163 | ␉␉uint8_t␉␉␉MaxCoef;␉␉␉␉// Max Multiplier␊ |
164 | ␉␉uint8_t␉␉␉MaxDiv;␉␉␉␉␉// Min Multiplier␊ |
165 | ␉␉uint8_t␉␉␉CurrCoef;␉␉␉␉// Current Multiplier␊ |
166 | ␉␉uint8_t␉␉␉CurrDiv;␊ |
167 | ␉␉uint64_t␉␉TSCFrequency;␉␉␉␉// TSC Frequency Hz␊ |
168 | ␉␉uint64_t␉␉FSBFrequency;␉␉␉␉// FSB Frequency Hz␊ |
169 | ␉␉uint64_t␉␉CPUFrequency;␉␉␉␉// CPU Frequency Hz␊ |
170 | ␉␉uint32_t␉␉MaxRatio;␉␉␉␉// Max Bus Ratio␊ |
171 | ␉␉uint32_t␉␉MinRatio;␉␉␉␉// Min Bus Ratio␊ |
172 | ␉␉char␉␉␉BrandString[48];␉␉␉// 48 Byte Branding String␊ |
173 | ␉␉uint32_t␉␉CPUID[CPUID_MAX][4];␉␉␉// CPUID 0..4, 80..81 Raw Values␊ |
174 | ␉} CPU;␊ |
175 | ␊ |
176 | ␉struct RAM {␊ |
177 | ␉␉uint64_t␉␉Frequency;␉␉␉␉// Ram Frequency␊ |
178 | ␉␉uint32_t␉␉Divider;␉␉␉␉// Memory divider␊ |
179 | ␉␉uint8_t␉␉␉CAS;␉␉␉␉␉// CAS 1/2/2.5/3/4/5/6/7␊ |
180 | ␉␉uint8_t␉␉␉TRC;␉␉␉␉␉␊ |
181 | ␉␉uint8_t␉␉␉TRP;␊ |
182 | ␉␉uint8_t␉␉␉RAS;␊ |
183 | ␉␉uint8_t␉␉␉Channels;␉␉␉␉// Channel Configuration Single,Dual or Triple␊ |
184 | ␉␉uint8_t␉␉␉NoSlots;␉␉␉␉// Maximum no of slots available␊ |
185 | ␉␉uint8_t␉␉␉Type;␉␉␉␉␉// Standard SMBIOS v2.5 Memory Type␊ |
186 | ␉␉RamSlotInfo_t␉DIMM[MAX_RAM_SLOTS];␉// Information about each slot␊ |
187 | ␉} RAM;␊ |
188 | ␊ |
189 | ␉struct DMI {␊ |
190 | ␉␉int␉␉␉MaxMemorySlots;␉␉// number of memory slots populated by SMBIOS␊ |
191 | ␉␉int␉␉␉CntMemorySlots;␉␉// number of memory slots counted␊ |
192 | ␉␉int␉␉␉MemoryModules;␉␉// number of memory modules installed␊ |
193 | ␉␉int␉␉␉DIMM[MAX_RAM_SLOTS];␉// Information and SPD mapping for each slot␊ |
194 | ␉} DMI;␊ |
195 | ␊ |
196 | ␉uint8_t␉␉␉␉Type;␉␉␉// System Type: 1=Desktop, 2=Portable, 3=Workstation... according ACPI2.0 (FACP: PM_Profile)␊ |
197 | ␉uint8_t␉␉␉␉*UUID;␊ |
198 | } PlatformInfo_t;␊ |
199 | ␊ |
200 | extern PlatformInfo_t Platform;␊ |
201 | ␊ |
202 | #endif /* !__LIBSAIO_PLATFORM_H */␊ |
203 | |