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 | typedef struct _RamSlotInfo_t {␊ |
66 | uint32_t␉␉ModuleSize;␉␉␉␉␉␉// Size of Module in MB␊ |
67 | uint32_t␉␉Frequency; // in Mhz␊ |
68 | const char*␉␉Vendor;␊ |
69 | const char*␉␉PartNo;␊ |
70 | const char*␉␉SerialNo;␊ |
71 | char*␉␉␉spd;␉␉␉␉␉␉␉// SPD Dump␊ |
72 | bool␉␉␉InUse;␊ |
73 | uint8_t␉␉␉Type;␊ |
74 | uint8_t␉␉␉BankConnections; // table type 6, see (3.3.7)␊ |
75 | uint8_t␉␉␉BankConnCnt;␊ |
76 | ␊ |
77 | } RamSlotInfo_t;␊ |
78 | ␊ |
79 | #define envVendor "boot.cpu.vendor"␊ |
80 | #define envFamily "boot.cpu.family"␊ |
81 | ␊ |
82 | #define envCPUIDMaxBasic "boot.cpu.max_basic"␊ |
83 | #define envCPUIDMaxExt "boot.cpu.max_ext" ␊ |
84 | #define envMicrocodeVersion "boot.cpu.microcode_version" ␊ |
85 | #define envSignature "boot.cpu.signature" ␊ |
86 | #define envStepping "boot.cpu.stepping" ␊ |
87 | #define envModel "boot.cpu.model" ␊ |
88 | #define envBrandString "boot.cpu.brand_string" ␊ |
89 | #define envNoThreads "boot.cpu.logical_per_package" ␊ |
90 | #define envNoCores "boot.cpu.cores_per_package"␊ |
91 | #define envExtModel "boot.cpu.extmodel" ␊ |
92 | #define envExtFamily "boot.cpu.extfamily" ␊ |
93 | #define envBrand "boot.cpu.brand" ␊ |
94 | #define envFeatures "boot.cpu.feature_bits"␊ |
95 | #define envExtFeatures "boot.cpu.extfeature_bits"␊ |
96 | ␊ |
97 | #define envSubCstates "boot.cpu.mwait.sub_Cstates" ␊ |
98 | #define envExtensions "boot.cpu.mwait.extensions" ␊ |
99 | ␊ |
100 | #define envDynamicAcceleration "boot.cpu.thermal.dynamic_acceleration"␊ |
101 | #define envInvariantAPICTimer "boot.cpu.thermal.invariant_APIC_timer"␊ |
102 | #define envFineGrainClockMod "boot.cpu.thermal.fine_grain_clock_mod" ␊ |
103 | ␊ |
104 | #define envIsMobile "boot.hw.is_mobile" ␊ |
105 | #define envMaxCoef "boot.hw.maxcoef" ␊ |
106 | #define envMaxDiv "boot.hw.maxdiv" ␊ |
107 | #define envCurrCoef "boot.hw.currcoef" ␊ |
108 | #define envCurrDiv "boot.hw.currdiv" ␊ |
109 | #define envTSCFreq "boot.hw.tscfrequency" ␊ |
110 | #define envFSBFreq "boot.hw.busfrequency" ␊ |
111 | #define envCPUFreq "boot.hw.cpufrequency"␊ |
112 | #define envIsServer "boot.hw.is_server"␊ |
113 | #define envHardwareSignature "boot.hw.signature"␊ |
114 | #define envType "boot.hw.type"␊ |
115 | #define envUUID "boot.hw.uuid_ptr"␊ |
116 | #define envSysId "boot.hw.sysid"␊ |
117 | #define envgBIOSDev "boot.hw.bios_device"␊ |
118 | #define envgDeviceCount "boot.hw.device_count"␊ |
119 | #define envarchCpuType␉␉␉"boot.hw.cputype"␊ |
120 | ␊ |
121 | #define envPCIRootDev "boot.hw.pci_root_dev"␊ |
122 | ␊ |
123 | #define envgHaveKernelCache␉␉"boot.kern.HaveKernelCache"␊ |
124 | #define envAdler32␉␉␉␉"boot.kern.adler32"␊ |
125 | #define envkCacheFile "boot.kern.kernelcache"␊ |
126 | #define envMKextName "boot.kern.mkextcache"␊ |
127 | #define envArgCntRemaining "boot.kern.argCount_remaining"␊ |
128 | #define envgBootArgs␉␉␉"boot.kern.boot_args"␊ |
129 | ␊ |
130 | #define envgBootMode "boot.options.boot_mode"␊ |
131 | #define envSysConfigValid "boot.options.sysconfing_valid"␊ |
132 | #define envgOverrideKernel "boot.options.kernel_overide"␊ |
133 | #define envgEnableCDROMRescan "boot.options.rescan_cdrom"␊ |
134 | #define envgScanSingleDrive "boot.options.single_drive"␊ |
135 | #define envShouldboot "boot.options.should_boot"␊ |
136 | #define envgVerboseMode "boot.options.boot_verbose"␊ |
137 | ␊ |
138 | #define envDriverExtSpec "boot.drivers.extspec"␊ |
139 | #define envDriverSpec "boot.drivers.spec"␊ |
140 | #define envDriverFileSpec "boot.drivers.filespec"␊ |
141 | #define envDriverTempSpec "boot.drivers.tempspec"␊ |
142 | #define envDriverFileName "boot.drivers.filename"␊ |
143 | ␊ |
144 | #define envBootBanner "boot.ui.banner"␊ |
145 | #define envBootPrompt "boot.ui.prompt"␊ |
146 | #define envBootRescanPrompt "boot.ui.promptrescan"␊ |
147 | ␊ |
148 | #define envgMenuRow "boot.ui.menu_row"␊ |
149 | #define envgMenuHeight "boot.ui.menu_height"␊ |
150 | #define envgMenuItemCount "boot.ui.menu_itemcount"␊ |
151 | #define envgMenuTop "boot.ui.menu_top"␊ |
152 | #define envgMenuBottom "boot.ui.menu_bottom"␊ |
153 | #define envgMenuSelection "boot.ui.menu_selection"␊ |
154 | #define envgMenuStart "boot.ui.menu_start"␊ |
155 | #define envgMenuEnd "boot.ui.menu_end"␊ |
156 | ␊ |
157 | #define envConsoleErr␉␉␉"boot.console.stderr"␊ |
158 | ␊ |
159 | #define envDeviceNumber "boot.dev.efi.devcount"␊ |
160 | #define envEFIString "boot.dev.efi.efistring"␊ |
161 | ␊ |
162 | #define envgBootFileType␉␉"boot.disk.Bootfiletype"␊ |
163 | #define envHFSLoadVerbose␉␉"boot.disk.HFSLoadVerbose"␊ |
164 | #define envgFSLoadAddress␉␉"boot.disk.FSLoadAddress"␊ |
165 | #define envgBIOSBootVolume␉␉"boot.disk.BIOSBootVolume"␊ |
166 | #define envgBootVolume␉␉␉"boot.disk.BootVolume"␊ |
167 | ␊ |
168 | #define envConvMem "boot.memmap.Conventional"␊ |
169 | #define envExtMem "boot.memmap.Extended"␊ |
170 | #define envMemoryMap "boot.memmap.Address"␊ |
171 | #define envMemoryMapCnt "boot.memmap.Count"␊ |
172 | #define envMemoryMapNode␉␉ "boot.memmap.devNode"␊ |
173 | ␊ |
174 | #define envRamFrequency "boot.ram.frequency"␊ |
175 | #define envRamCas "boot.ram.tCAS"␊ |
176 | #define envRamTrc "boot.ram.tRCD"␊ |
177 | #define envRamRas "boot.ram.tRAS"␊ |
178 | #define envRamTrp "boot.ram.tRP"␊ |
179 | #define envRamChannels "boot.ram.channels"␊ |
180 | #define envRamType "boot.ram.type"␊ |
181 | #define envRamDimm "boot.ram.dimm"␊ |
182 | ␊ |
183 | #define envDMIMemModules "boot.dmi.memory_modules"␊ |
184 | #define envDMIMaxMemorySlots "boot.dmi.max_slots"␊ |
185 | #define envDMICntMemorySlots "boot.dmi.slots_count"␊ |
186 | #define envDmiDimm "boot.dmi.dimm"␊ |
187 | ␊ |
188 | #if UNUSED␊ |
189 | typedef struct _PlatformInfo_t {␊ |
190 | ␉␊ |
191 | struct CPU_t {␊ |
192 | uint64_t␉␉Features;␉␉// CPU Features like MMX, SSE2, VT ...␊ |
193 | uint64_t␉␉ExtFeatures; // CPU Extended Features like SYSCALL, XD, EM64T, LAHF ...␊ |
194 | uint32_t␉␉Vendor;␉␉␉// Vendor␊ |
195 | uint32_t␉␉Signature;␉␉// Signature␊ |
196 | uint8_t Stepping;␉␉// Stepping␊ |
197 | uint8_t Model;␉␉␉// Model␊ |
198 | uint8_t ExtModel;␉␉// Extended Model␊ |
199 | uint8_t Family;␉␉␉// Family␊ |
200 | uint8_t ExtFamily;␉␉// Extended Family␊ |
201 | uint32_t␉␉NoCores;␉␉// No Cores per Package␊ |
202 | uint32_t␉␉NoThreads;␉␉// Threads per Package␊ |
203 | uint8_t␉␉␉MaxCoef;␉␉// Max Multiplier␊ |
204 | uint8_t␉␉␉MaxDiv;␊ |
205 | uint8_t␉␉␉CurrCoef;␉␉// Current Multiplier␊ |
206 | uint8_t␉␉␉CurrDiv;␊ |
207 | uint64_t␉␉TSCFrequency;␉␉// TSC Frequency Hz␊ |
208 | uint64_t␉␉FSBFrequency;␉␉// FSB Frequency Hz␊ |
209 | uint64_t␉␉CPUFrequency;␉␉// CPU Frequency Hz␊ |
210 | char␉␉␉BrandString[48];␉// 48 Byte Branding String␊ |
211 | uint8_t Brand; ␊ |
212 | uint32_t␉␉MicrocodeVersion; // The microcode version number a.k.a. signature a.k.a. BIOS ID ␊ |
213 | ␊ |
214 | bool isMobile; ␊ |
215 | 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)␊ |
216 | ␊ |
217 | boolean_t␉dynamic_acceleration;␊ |
218 | boolean_t␉invariant_APIC_timer;␊ |
219 | boolean_t␉fine_grain_clock_mod;␊ |
220 | ␊ |
221 | uint32_t cpuid_max_basic;␊ |
222 | ␉␉uint32_t cpuid_max_ext;␊ |
223 | uint32_t␉sub_Cstates;␊ |
224 | uint32_t extensions;␊ |
225 | ␊ |
226 | } CPU;␊ |
227 | ␊ |
228 | struct RAM_t {␊ |
229 | uint64_t␉␉Frequency;␉␉␉␉// Ram Frequency␊ |
230 | uint32_t␉␉Divider;␉␉␉␉// Memory divider␊ |
231 | uint8_t␉␉␉CAS;␉␉␉␉␉// CAS 1/2/2.5/3/4/5/6/7␊ |
232 | uint8_t␉␉␉TRC;␉␉␉␉␉␊ |
233 | uint8_t␉␉␉TRP;␊ |
234 | uint8_t␉␉␉RAS;␊ |
235 | uint8_t␉␉␉Channels;␉␉␉␉// Channel Configuration Single,Dual or Triple␊ |
236 | uint8_t␉␉␉NoSlots;␉␉␉␉// Maximum no of slots available␊ |
237 | uint8_t␉␉␉Type;␉␉␉␉␉// Standard SMBIOS v2.5 Memory Type␊ |
238 | RamSlotInfo_t␉DIMM[MAX_RAM_SLOTS];␉// Information about each slot␊ |
239 | } RAM;␊ |
240 | ␊ |
241 | struct DMI {␊ |
242 | int␉␉␉MaxMemorySlots;␉␉// number of memory slots polulated by SMBIOS␊ |
243 | int␉␉␉CntMemorySlots;␉␉// number of memory slots counted␊ |
244 | int␉␉␉MemoryModules;␉␉// number of memory modules installed␊ |
245 | int␉␉␉DIMM[MAX_RAM_SLOTS];␉// Information and SPD mapping for each slot␊ |
246 | } DMI;␊ |
247 | ␊ |
248 | ␉uint8_t␉␉␉␉Type;␉␉␉// System Type: 1=Desktop, 2=Portable... according ACPI2.0 (FACP: PreferredProfile)␊ |
249 | ␉uint8_t␉␉␉␉*UUID; // SMBios UUID␊ |
250 | ␉uint32_t␉␉␉hardware_signature;␊ |
251 | ␉int8_t␉␉␉␉sysid[16];␊ |
252 | ␊ |
253 | } PlatformInfo_t;␊ |
254 | #endif␊ |
255 | ␊ |
256 | #endif /* !__LIBSAIO_PLATFORM_H */␊ |
257 | |