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 | #include "cpuid.h"␊ |
12 | #include "cpu_data.h"␊ |
13 | ␊ |
14 | extern bool platformCPUExtFeature(uint32_t);␊ |
15 | extern bool platformCPUFeature(uint32_t);␊ |
16 | extern void scan_platform(void);␊ |
17 | ␊ |
18 | #define bitmask(h,l)␉␉((_Bit(h)|(_Bit(h)-1)) & ~(_Bit(l)-1))␊ |
19 | #define bitfield(x,h,l)␉␉(((x) & bitmask(h,l)) >> l)␊ |
20 | ␊ |
21 | #define quad(hi,lo) (((uint64_t)(hi)) << 32 | (lo))␊ |
22 | ␊ |
23 | ␊ |
24 | /* CPUID index into cpuid_raw */␊ |
25 | /*␊ |
26 | #define CPUID_0␉␉␉␉0␊ |
27 | #define CPUID_1␉␉␉␉1␊ |
28 | #define CPUID_2␉␉␉␉2␊ |
29 | #define CPUID_3␉␉␉␉3␊ |
30 | #define CPUID_4␉␉␉␉4␊ |
31 | #define CPUID_5␉␉␉␉5␊ |
32 | #define CPUID_6␉␉␉␉6␊ |
33 | #define CPUID_80␉␉␉7␊ |
34 | #define CPUID_81␉␉␉8␊ |
35 | #define CPUID_B0␉␉␉9␊ |
36 | #define CPUID_B1␉␉␉10␊ |
37 | #define CPUID_MAX␉␉␉11␊ |
38 | */␊ |
39 | ␊ |
40 | /* Additional models supported by Chameleon (NOT SUPPORTED BY THE APPLE'S ORIGINAL KERNEL) */␊ |
41 | #define CPUID_MODEL_BANIAS 0x09␊ |
42 | #define CPUID_MODEL_DOTHAN 0x0D␊ |
43 | #define CPUID_MODEL_ATOM␉␉␉0x1C␊ |
44 | ␊ |
45 | /* SMBIOS Memory Types */ ␊ |
46 | #define SMB_MEM_TYPE_UNDEFINED␉0␊ |
47 | #define SMB_MEM_TYPE_OTHER␉␉1␊ |
48 | #define SMB_MEM_TYPE_UNKNOWN␉2␊ |
49 | #define SMB_MEM_TYPE_DRAM␉␉3␊ |
50 | #define SMB_MEM_TYPE_EDRAM␉␉4␊ |
51 | #define SMB_MEM_TYPE_VRAM␉␉5␊ |
52 | #define SMB_MEM_TYPE_SRAM␉␉6␊ |
53 | #define SMB_MEM_TYPE_RAM␉␉7␊ |
54 | #define SMB_MEM_TYPE_ROM␉␉8␊ |
55 | #define SMB_MEM_TYPE_FLASH␉␉9␊ |
56 | #define SMB_MEM_TYPE_EEPROM␉␉10␊ |
57 | #define SMB_MEM_TYPE_FEPROM␉␉11␊ |
58 | #define SMB_MEM_TYPE_EPROM␉␉12␊ |
59 | #define SMB_MEM_TYPE_CDRAM␉␉13␊ |
60 | #define SMB_MEM_TYPE_3DRAM␉␉14␊ |
61 | #define SMB_MEM_TYPE_SDRAM␉␉15␊ |
62 | #define SMB_MEM_TYPE_SGRAM␉␉16␊ |
63 | #define SMB_MEM_TYPE_RDRAM␉␉17␊ |
64 | #define SMB_MEM_TYPE_DDR␉␉18␊ |
65 | #define SMB_MEM_TYPE_DDR2␉␉19␊ |
66 | #define SMB_MEM_TYPE_FBDIMM␉␉20␊ |
67 | #define SMB_MEM_TYPE_DDR3␉␉24␉␉␉// Supported in 10.5.6+ AppleSMBIOS␊ |
68 | ␊ |
69 | /* Memory Configuration Types */ ␊ |
70 | #define SMB_MEM_CHANNEL_UNKNOWN␉␉0␊ |
71 | #define SMB_MEM_CHANNEL_SINGLE␉␉1␊ |
72 | #define SMB_MEM_CHANNEL_DUAL␉␉2␊ |
73 | #define SMB_MEM_CHANNEL_TRIPLE␉␉3␊ |
74 | ␊ |
75 | /* Maximum number of ram slots */␊ |
76 | #define MAX_RAM_SLOTS␉␉␉8␊ |
77 | #define RAM_SLOT_ENUMERATOR␉␉{0, 2, 4, 1, 3, 5, 6, 8, 10, 7, 9, 11}␊ |
78 | ␊ |
79 | /* Maximum number of SPD bytes */␊ |
80 | #define MAX_SPD_SIZE␉␉␉256␊ |
81 | ␊ |
82 | /* Size of SMBIOS UUID in bytes */␊ |
83 | #define UUID_LEN␉␉␉16␊ |
84 | ␊ |
85 | typedef struct _RamSlotInfo_t {␊ |
86 | uint32_t␉␉ModuleSize;␉␉␉␉␉␉// Size of Module in MB␊ |
87 | uint32_t␉␉Frequency; // in Mhz␊ |
88 | const char*␉␉Vendor;␊ |
89 | const char*␉␉PartNo;␊ |
90 | const char*␉␉SerialNo;␊ |
91 | char*␉␉␉spd;␉␉␉␉␉␉␉// SPD Dump␊ |
92 | bool␉␉␉InUse;␊ |
93 | uint8_t␉␉␉Type;␊ |
94 | uint8_t␉␉␉BankConnections; // table type 6, see (3.3.7)␊ |
95 | uint8_t␉␉␉BankConnCnt;␊ |
96 | ␊ |
97 | } RamSlotInfo_t;␊ |
98 | ␊ |
99 | ␊ |
100 | ␊ |
101 | typedef struct _PlatformInfo_t {␊ |
102 | ␉␊ |
103 | struct CPU_t {␊ |
104 | uint64_t␉␉Features;␉␉// CPU Features like MMX, SSE2, VT ...␊ |
105 | uint64_t␉␉ExtFeatures; // CPU Extended Features like SYSCALL, XD, EM64T, LAHF ...␊ |
106 | uint32_t␉␉Vendor;␉␉␉// Vendor␊ |
107 | uint32_t␉␉Signature;␉␉// Signature␊ |
108 | uint8_t Stepping;␉␉// Stepping␊ |
109 | uint8_t Model;␉␉␉// Model␊ |
110 | uint8_t ExtModel;␉␉// Extended Model␊ |
111 | uint8_t Family;␉␉␉// Family␊ |
112 | uint8_t ExtFamily;␉␉// Extended Family␊ |
113 | uint32_t␉␉NoCores;␉␉// No Cores per Package␊ |
114 | uint32_t␉␉NoThreads;␉␉// Threads per Package␊ |
115 | uint8_t␉␉␉MaxCoef;␉␉// Max Multiplier␊ |
116 | uint8_t␉␉␉MaxDiv;␊ |
117 | uint8_t␉␉␉CurrCoef;␉␉// Current Multiplier␊ |
118 | uint8_t␉␉␉CurrDiv;␊ |
119 | uint64_t␉␉TSCFrequency;␉␉// TSC Frequency Hz␊ |
120 | uint64_t␉␉FSBFrequency;␉␉// FSB Frequency Hz␊ |
121 | uint64_t␉␉CPUFrequency;␉␉// CPU Frequency Hz␊ |
122 | char␉␉␉BrandString[48];␉// 48 Byte Branding String␊ |
123 | uint8_t Brand; ␊ |
124 | uint32_t␉␉MicrocodeVersion; // The microcode version number a.k.a. signature a.k.a. BIOS ID ␊ |
125 | ␊ |
126 | bool isMobile; ␊ |
127 | bool␉␉ isServer;␉␉␉// Unlike isMobile, if this value is set it will disable all kind of detection and enforce "Server" as platform (must be set by user)␊ |
128 | ␊ |
129 | boolean_t␉dynamic_acceleration;␊ |
130 | boolean_t␉invariant_APIC_timer;␊ |
131 | boolean_t␉fine_grain_clock_mod;␊ |
132 | ␊ |
133 | uint32_t cpuid_max_basic;␊ |
134 | ␉␉uint32_t cpuid_max_ext;␊ |
135 | uint32_t␉sub_Cstates;␊ |
136 | uint32_t extensions;␊ |
137 | ␊ |
138 | } CPU;␊ |
139 | ␊ |
140 | struct RAM_t {␊ |
141 | uint64_t␉␉Frequency;␉␉␉␉// Ram Frequency␊ |
142 | uint32_t␉␉Divider;␉␉␉␉// Memory divider␊ |
143 | uint8_t␉␉␉CAS;␉␉␉␉␉// CAS 1/2/2.5/3/4/5/6/7␊ |
144 | uint8_t␉␉␉TRC;␉␉␉␉␉␊ |
145 | uint8_t␉␉␉TRP;␊ |
146 | uint8_t␉␉␉RAS;␊ |
147 | uint8_t␉␉␉Channels;␉␉␉␉// Channel Configuration Single,Dual or Triple␊ |
148 | uint8_t␉␉␉NoSlots;␉␉␉␉// Maximum no of slots available␊ |
149 | uint8_t␉␉␉Type;␉␉␉␉␉// Standard SMBIOS v2.5 Memory Type␊ |
150 | RamSlotInfo_t␉DIMM[MAX_RAM_SLOTS];␉// Information about each slot␊ |
151 | } RAM;␊ |
152 | ␊ |
153 | struct DMI {␊ |
154 | int␉␉␉MaxMemorySlots;␉␉// number of memory slots polulated by SMBIOS␊ |
155 | int␉␉␉CntMemorySlots;␉␉// number of memory slots counted␊ |
156 | int␉␉␉MemoryModules;␉␉// number of memory modules installed␊ |
157 | int␉␉␉DIMM[MAX_RAM_SLOTS];␉// Information and SPD mapping for each slot␊ |
158 | } DMI;␊ |
159 | ␊ |
160 | ␉uint8_t␉␉␉␉Type;␉␉␉// System Type: 1=Desktop, 2=Portable... according ACPI2.0 (FACP: PreferredProfile)␊ |
161 | ␉uint8_t␉␉␉␉*UUID; // SMBios UUID␊ |
162 | ␉uint32_t␉␉␉hardware_signature;␊ |
163 | ␉int8_t␉␉␉␉sysid[16];␊ |
164 | ␊ |
165 | } PlatformInfo_t;␊ |
166 | ␊ |
167 | extern PlatformInfo_t *Platform;␊ |
168 | #endif /* !__LIBSAIO_PLATFORM_H */␊ |
169 | |