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 | #define bitmask(h,l)␉␉((_Bit(h)|(_Bit(h)-1)) & ~(_Bit(l)-1))␊ |
15 | #define bitfield(x,h,l)␉␉(((x) & bitmask(h,l)) >> l)␊ |
16 | ␊ |
17 | #define quad(hi,lo) (((uint64_t)(hi)) << 32 | (lo))␊ |
18 | ␊ |
19 | /* Additional models supported by Chameleon (NOT SUPPORTED BY THE APPLE'S ORIGINAL KERNEL) */␊ |
20 | #define CPUID_MODEL_BANIAS 0x09␊ |
21 | #define CPUID_MODEL_DOTHAN 0x0D␊ |
22 | #define CPUID_MODEL_ATOM␉␉␉0x1C␊ |
23 | ␊ |
24 | /* CPUID Vendor */␊ |
25 | #define CPUID_VENDOR_INTEL 0x756E6547␊ |
26 | #define CPUID_VENDOR_AMD 0x68747541␊ |
27 | ␊ |
28 | /* SMBIOS Memory Types */ ␊ |
29 | #define SMB_MEM_TYPE_UNDEFINED␉0␊ |
30 | #define SMB_MEM_TYPE_OTHER␉␉1␊ |
31 | #define SMB_MEM_TYPE_UNKNOWN␉2␊ |
32 | #define SMB_MEM_TYPE_DRAM␉␉3␊ |
33 | #define SMB_MEM_TYPE_EDRAM␉␉4␊ |
34 | #define SMB_MEM_TYPE_VRAM␉␉5␊ |
35 | #define SMB_MEM_TYPE_SRAM␉␉6␊ |
36 | #define SMB_MEM_TYPE_RAM␉␉7␊ |
37 | #define SMB_MEM_TYPE_ROM␉␉8␊ |
38 | #define SMB_MEM_TYPE_FLASH␉␉9␊ |
39 | #define SMB_MEM_TYPE_EEPROM␉␉10␊ |
40 | #define SMB_MEM_TYPE_FEPROM␉␉11␊ |
41 | #define SMB_MEM_TYPE_EPROM␉␉12␊ |
42 | #define SMB_MEM_TYPE_CDRAM␉␉13␊ |
43 | #define SMB_MEM_TYPE_3DRAM␉␉14␊ |
44 | #define SMB_MEM_TYPE_SDRAM␉␉15␊ |
45 | #define SMB_MEM_TYPE_SGRAM␉␉16␊ |
46 | #define SMB_MEM_TYPE_RDRAM␉␉17␊ |
47 | #define SMB_MEM_TYPE_DDR␉␉18␊ |
48 | #define SMB_MEM_TYPE_DDR2␉␉19␊ |
49 | #define SMB_MEM_TYPE_FBDIMM␉␉20␊ |
50 | #define SMB_MEM_TYPE_DDR3␉␉24␉␉␉// Supported in 10.5.6+ AppleSMBIOS␊ |
51 | ␊ |
52 | /* Memory Configuration Types */ ␊ |
53 | #define SMB_MEM_CHANNEL_UNKNOWN␉␉0␊ |
54 | #define SMB_MEM_CHANNEL_SINGLE␉␉1␊ |
55 | #define SMB_MEM_CHANNEL_DUAL␉␉2␊ |
56 | #define SMB_MEM_CHANNEL_TRIPLE␉␉3␊ |
57 | ␊ |
58 | /* Maximum number of ram slots */␊ |
59 | #define MAX_RAM_SLOTS␉␉␉8␊ |
60 | #define RAM_SLOT_ENUMERATOR␉␉{0, 2, 4, 1, 3, 5, 6, 8, 10, 7, 9, 11}␊ |
61 | ␊ |
62 | /* Maximum number of SPD bytes */␊ |
63 | #define MAX_SPD_SIZE␉␉␉256␊ |
64 | ␊ |
65 | /* Size of SMBIOS UUID in bytes */␊ |
66 | #define UUID_LEN␉␉␉16␊ |
67 | ␊ |
68 | typedef struct _RamSlotInfo_t {␊ |
69 | uint32_t␉␉ModuleSize;␉␉␉␉␉␉// Size of Module in MB␊ |
70 | uint32_t␉␉Frequency; // in Mhz␊ |
71 | const char*␉␉Vendor;␊ |
72 | const char*␉␉PartNo;␊ |
73 | const char*␉␉SerialNo;␊ |
74 | char*␉␉␉spd;␉␉␉␉␉␉␉// SPD Dump␊ |
75 | bool␉␉␉InUse;␊ |
76 | uint8_t␉␉␉Type;␊ |
77 | uint8_t␉␉␉BankConnections; // table type 6, see (3.3.7)␊ |
78 | uint8_t␉␉␉BankConnCnt;␊ |
79 | ␊ |
80 | } RamSlotInfo_t;␊ |
81 | ␊ |
82 | #define envVendor "boot.cpu.vendor"␊ |
83 | #define envFamily "boot.cpu.family"␊ |
84 | ␊ |
85 | #define envCPUIDMaxBasic "boot.cpu.max_basic"␊ |
86 | #define envCPUIDMaxExt "boot.cpu.max_ext" ␊ |
87 | #define envMicrocodeVersion "boot.cpu.microcode_version" ␊ |
88 | #define envSignature "boot.cpu.signature" ␊ |
89 | #define envStepping "boot.cpu.stepping" ␊ |
90 | #define envModel "boot.cpu.model" ␊ |
91 | #define envBrandString "boot.cpu.brand_string" ␊ |
92 | #define envNoThreads "boot.cpu.logical_per_package" ␊ |
93 | #define envNoCores "boot.cpu.cores_per_package"␊ |
94 | #define envExtModel "boot.cpu.extmodel" ␊ |
95 | #define envExtFamily "boot.cpu.extfamily" ␊ |
96 | #define envBrand "boot.cpu.brand" ␊ |
97 | #define envFeatures "boot.cpu.feature_bits"␊ |
98 | #define envExtFeatures "boot.cpu.extfeature_bits"␊ |
99 | ␊ |
100 | #define envSubCstates "boot.cpu.mwait.sub_Cstates" ␊ |
101 | #define envExtensions "boot.cpu.mwait.extensions" ␊ |
102 | ␊ |
103 | #define envDynamicAcceleration "boot.cpu.thermal.dynamic_acceleration"␊ |
104 | #define envInvariantAPICTimer "boot.cpu.thermal.invariant_APIC_timer"␊ |
105 | #define envFineGrainClockMod "boot.cpu.thermal.fine_grain_clock_mod" ␊ |
106 | ␊ |
107 | #define envIsMobile "boot.hw.is_mobile" ␊ |
108 | #define envMaxCoef "boot.hw.maxcoef" ␊ |
109 | #define envMaxDiv "boot.hw.maxdiv" ␊ |
110 | #define envCurrCoef "boot.hw.currcoef" ␊ |
111 | #define envCurrDiv "boot.hw.currdiv" ␊ |
112 | #define envTSCFreq "boot.hw.tscfrequency" ␊ |
113 | #define envFSBFreq "boot.hw.busfrequency" ␊ |
114 | #define envCPUFreq "boot.hw.cpufrequency"␊ |
115 | #define envIsServer "boot.hw.is_server"␊ |
116 | #define envHardwareSignature "boot.hw.signature"␊ |
117 | #define envType "boot.hw.type"␊ |
118 | #define envUUID "boot.hw.uuid_ptr"␊ |
119 | #define envSysId "boot.hw.sysid"␊ |
120 | #define envgBIOSDev "boot.hw.bios_device"␊ |
121 | #define envgDeviceCount "boot.hw.device_count"␊ |
122 | ␊ |
123 | #define envAdler32␉␉␉␉"boot.kern.adler32"␊ |
124 | #define envkCache "boot.kern.kernelcache"␊ |
125 | #define envMKextName "boot.kern.mkextcache"␊ |
126 | #define envArgCntRemaining "boot.kern.argCount_remaining"␊ |
127 | #define envgBootArgs␉␉␉"boot.kern.boot_args"␊ |
128 | ␊ |
129 | #define envgBootMode "boot.options.boot_mode"␊ |
130 | #define envSysConfigValid "boot.options.sysconfing_valid"␊ |
131 | #define envgOverrideKernel "boot.options.kernel_overide"␊ |
132 | #define envgEnableCDROMRescan "boot.options.rescan_cdrom"␊ |
133 | #define envgScanSingleDrive "boot.options.single_drive"␊ |
134 | #define envShouldboot "boot.options.should_boot"␊ |
135 | ␊ |
136 | #define envDriverExtSpec "boot.drivers.extspec"␊ |
137 | #define envDriverSpec "boot.drivers.spec"␊ |
138 | #define envDriverFileSpec "boot.drivers.filespec"␊ |
139 | #define envDriverTempSpec "boot.drivers.tempspec"␊ |
140 | #define envDriverFileName "boot.drivers.filename"␊ |
141 | ␊ |
142 | #define envBootBanner "boot.ui.banner"␊ |
143 | #define envBootPrompt "boot.ui.prompt"␊ |
144 | #define envBootRescanPrompt "boot.ui.promptrescan"␊ |
145 | ␊ |
146 | #define envgMenuRow "boot.ui.menu_row"␊ |
147 | #define envgMenuHeight "boot.ui.menu_height"␊ |
148 | #define envgMenuItemCount "boot.ui.menu_itemcount"␊ |
149 | #define envgMenuTop "boot.ui.menu_top"␊ |
150 | #define envgMenuBottom "boot.ui.menu_bottom"␊ |
151 | #define envgMenuSelection "boot.ui.menu_selection"␊ |
152 | #define envgMenuStart "boot.ui.menu_start"␊ |
153 | #define envgMenuEnd "boot.ui.menu_end"␊ |
154 | ␊ |
155 | #define envConvMem "boot.memmap.Conventional"␊ |
156 | #define envExtMem "boot.memmap.Extended"␊ |
157 | #define envMemoryMap "boot.memmap.Address"␊ |
158 | #define envMemoryMapCnt "boot.memmap.Count"␊ |
159 | ␊ |
160 | ␊ |
161 | #define envRamFrequency "boot.ram.frequency"␊ |
162 | #define envRamCas "boot.ram.tCAS"␊ |
163 | #define envRamTrc "boot.ram.tRCD"␊ |
164 | #define envRamRas "boot.ram.tRAS"␊ |
165 | #define envRamTrp "boot.ram.tRP"␊ |
166 | #define envRamChannels "boot.ram.channels"␊ |
167 | #define envRamType "boot.ram.type"␊ |
168 | #define envRamDimm "boot.ram.dimm"␊ |
169 | ␊ |
170 | #define envDMIMemModules "boot.dmi.memory_modules"␊ |
171 | #define envDMIMaxMemorySlots "boot.dmi.max_slots"␊ |
172 | #define envDMICntMemorySlots "boot.dmi.slots_count"␊ |
173 | #define envDmiDimm "boot.dmi.dimm"␊ |
174 | ␊ |
175 | #if UNUSED␊ |
176 | typedef struct _PlatformInfo_t {␊ |
177 | ␉␊ |
178 | struct CPU_t {␊ |
179 | uint64_t␉␉Features;␉␉// CPU Features like MMX, SSE2, VT ...␊ |
180 | uint64_t␉␉ExtFeatures; // CPU Extended Features like SYSCALL, XD, EM64T, LAHF ...␊ |
181 | uint32_t␉␉Vendor;␉␉␉// Vendor␊ |
182 | uint32_t␉␉Signature;␉␉// Signature␊ |
183 | uint8_t Stepping;␉␉// Stepping␊ |
184 | uint8_t Model;␉␉␉// Model␊ |
185 | uint8_t ExtModel;␉␉// Extended Model␊ |
186 | uint8_t Family;␉␉␉// Family␊ |
187 | uint8_t ExtFamily;␉␉// Extended Family␊ |
188 | uint32_t␉␉NoCores;␉␉// No Cores per Package␊ |
189 | uint32_t␉␉NoThreads;␉␉// Threads per Package␊ |
190 | uint8_t␉␉␉MaxCoef;␉␉// Max Multiplier␊ |
191 | uint8_t␉␉␉MaxDiv;␊ |
192 | uint8_t␉␉␉CurrCoef;␉␉// Current Multiplier␊ |
193 | uint8_t␉␉␉CurrDiv;␊ |
194 | uint64_t␉␉TSCFrequency;␉␉// TSC Frequency Hz␊ |
195 | uint64_t␉␉FSBFrequency;␉␉// FSB Frequency Hz␊ |
196 | uint64_t␉␉CPUFrequency;␉␉// CPU Frequency Hz␊ |
197 | char␉␉␉BrandString[48];␉// 48 Byte Branding String␊ |
198 | uint8_t Brand; ␊ |
199 | uint32_t␉␉MicrocodeVersion; // The microcode version number a.k.a. signature a.k.a. BIOS ID ␊ |
200 | ␊ |
201 | bool isMobile; ␊ |
202 | 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)␊ |
203 | ␊ |
204 | boolean_t␉dynamic_acceleration;␊ |
205 | boolean_t␉invariant_APIC_timer;␊ |
206 | boolean_t␉fine_grain_clock_mod;␊ |
207 | ␊ |
208 | uint32_t cpuid_max_basic;␊ |
209 | ␉␉uint32_t cpuid_max_ext;␊ |
210 | uint32_t␉sub_Cstates;␊ |
211 | uint32_t extensions;␊ |
212 | ␊ |
213 | } CPU;␊ |
214 | ␊ |
215 | struct RAM_t {␊ |
216 | uint64_t␉␉Frequency;␉␉␉␉// Ram Frequency␊ |
217 | uint32_t␉␉Divider;␉␉␉␉// Memory divider␊ |
218 | uint8_t␉␉␉CAS;␉␉␉␉␉// CAS 1/2/2.5/3/4/5/6/7␊ |
219 | uint8_t␉␉␉TRC;␉␉␉␉␉␊ |
220 | uint8_t␉␉␉TRP;␊ |
221 | uint8_t␉␉␉RAS;␊ |
222 | uint8_t␉␉␉Channels;␉␉␉␉// Channel Configuration Single,Dual or Triple␊ |
223 | uint8_t␉␉␉NoSlots;␉␉␉␉// Maximum no of slots available␊ |
224 | uint8_t␉␉␉Type;␉␉␉␉␉// Standard SMBIOS v2.5 Memory Type␊ |
225 | RamSlotInfo_t␉DIMM[MAX_RAM_SLOTS];␉// Information about each slot␊ |
226 | } RAM;␊ |
227 | ␊ |
228 | struct DMI {␊ |
229 | int␉␉␉MaxMemorySlots;␉␉// number of memory slots polulated by SMBIOS␊ |
230 | int␉␉␉CntMemorySlots;␉␉// number of memory slots counted␊ |
231 | int␉␉␉MemoryModules;␉␉// number of memory modules installed␊ |
232 | int␉␉␉DIMM[MAX_RAM_SLOTS];␉// Information and SPD mapping for each slot␊ |
233 | } DMI;␊ |
234 | ␊ |
235 | ␉uint8_t␉␉␉␉Type;␉␉␉// System Type: 1=Desktop, 2=Portable... according ACPI2.0 (FACP: PreferredProfile)␊ |
236 | ␉uint8_t␉␉␉␉*UUID; // SMBios UUID␊ |
237 | ␉uint32_t␉␉␉hardware_signature;␊ |
238 | ␉int8_t␉␉␉␉sysid[16];␊ |
239 | ␊ |
240 | } PlatformInfo_t;␊ |
241 | #endif␊ |
242 | ␊ |
243 | #ifdef ShowCurrentDate␊ |
244 | #include "efi.h"␊ |
245 | extern char * Date(void);␊ |
246 | extern void rtc_time(EFI_TIME *time);␊ |
247 | #endif␊ |
248 | ␊ |
249 | #endif /* !__LIBSAIO_PLATFORM_H */␊ |
250 | |