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 | /* SMBIOS Memory Types */ ␊ |
25 | #define SMB_MEM_TYPE_UNDEFINED␉0␊ |
26 | #define SMB_MEM_TYPE_OTHER␉␉1␊ |
27 | #define SMB_MEM_TYPE_UNKNOWN␉2␊ |
28 | #define SMB_MEM_TYPE_DRAM␉␉3␊ |
29 | #define SMB_MEM_TYPE_EDRAM␉␉4␊ |
30 | #define SMB_MEM_TYPE_VRAM␉␉5␊ |
31 | #define SMB_MEM_TYPE_SRAM␉␉6␊ |
32 | #define SMB_MEM_TYPE_RAM␉␉7␊ |
33 | #define SMB_MEM_TYPE_ROM␉␉8␊ |
34 | #define SMB_MEM_TYPE_FLASH␉␉9␊ |
35 | #define SMB_MEM_TYPE_EEPROM␉␉10␊ |
36 | #define SMB_MEM_TYPE_FEPROM␉␉11␊ |
37 | #define SMB_MEM_TYPE_EPROM␉␉12␊ |
38 | #define SMB_MEM_TYPE_CDRAM␉␉13␊ |
39 | #define SMB_MEM_TYPE_3DRAM␉␉14␊ |
40 | #define SMB_MEM_TYPE_SDRAM␉␉15␊ |
41 | #define SMB_MEM_TYPE_SGRAM␉␉16␊ |
42 | #define SMB_MEM_TYPE_RDRAM␉␉17␊ |
43 | #define SMB_MEM_TYPE_DDR␉␉18␊ |
44 | #define SMB_MEM_TYPE_DDR2␉␉19␊ |
45 | #define SMB_MEM_TYPE_FBDIMM␉␉20␊ |
46 | #define SMB_MEM_TYPE_DDR3␉␉24␉␉␉// Supported in 10.5.6+ AppleSMBIOS␊ |
47 | ␊ |
48 | /* Memory Configuration Types */ ␊ |
49 | #define SMB_MEM_CHANNEL_UNKNOWN␉␉0␊ |
50 | #define SMB_MEM_CHANNEL_SINGLE␉␉1␊ |
51 | #define SMB_MEM_CHANNEL_DUAL␉␉2␊ |
52 | #define SMB_MEM_CHANNEL_TRIPLE␉␉3␊ |
53 | ␊ |
54 | /* Maximum number of ram slots */␊ |
55 | #define MAX_RAM_SLOTS␉␉␉8␊ |
56 | #define RAM_SLOT_ENUMERATOR␉␉{0, 2, 4, 1, 3, 5, 6, 8, 10, 7, 9, 11}␊ |
57 | ␊ |
58 | /* Maximum number of SPD bytes */␊ |
59 | #define MAX_SPD_SIZE␉␉␉256␊ |
60 | ␊ |
61 | /* Size of SMBIOS UUID in bytes */␊ |
62 | #define UUID_LEN␉␉␉16␊ |
63 | ␊ |
64 | typedef struct _RamSlotInfo_t {␊ |
65 | uint32_t␉␉ModuleSize;␉␉␉␉␉␉// Size of Module in MB␊ |
66 | uint32_t␉␉Frequency; // in Mhz␊ |
67 | const char*␉␉Vendor;␊ |
68 | const char*␉␉PartNo;␊ |
69 | const char*␉␉SerialNo;␊ |
70 | char*␉␉␉spd;␉␉␉␉␉␉␉// SPD Dump␊ |
71 | bool␉␉␉InUse;␊ |
72 | uint8_t␉␉␉Type;␊ |
73 | uint8_t␉␉␉BankConnections; // table type 6, see (3.3.7)␊ |
74 | uint8_t␉␉␉BankConnCnt;␊ |
75 | ␊ |
76 | } RamSlotInfo_t;␊ |
77 | ␊ |
78 | ␊ |
79 | ␊ |
80 | typedef struct _PlatformInfo_t {␊ |
81 | ␉␊ |
82 | struct CPU_t {␊ |
83 | uint64_t␉␉Features;␉␉// CPU Features like MMX, SSE2, VT ...␊ |
84 | uint64_t␉␉ExtFeatures; // CPU Extended Features like SYSCALL, XD, EM64T, LAHF ...␊ |
85 | uint32_t␉␉Vendor;␉␉␉// Vendor␊ |
86 | uint32_t␉␉Signature;␉␉// Signature␊ |
87 | uint8_t Stepping;␉␉// Stepping␊ |
88 | uint8_t Model;␉␉␉// Model␊ |
89 | uint8_t ExtModel;␉␉// Extended Model␊ |
90 | uint8_t Family;␉␉␉// Family␊ |
91 | uint8_t ExtFamily;␉␉// Extended Family␊ |
92 | uint32_t␉␉NoCores;␉␉// No Cores per Package␊ |
93 | uint32_t␉␉NoThreads;␉␉// Threads per Package␊ |
94 | uint8_t␉␉␉MaxCoef;␉␉// Max Multiplier␊ |
95 | uint8_t␉␉␉MaxDiv;␊ |
96 | uint8_t␉␉␉CurrCoef;␉␉// Current Multiplier␊ |
97 | uint8_t␉␉␉CurrDiv;␊ |
98 | uint64_t␉␉TSCFrequency;␉␉// TSC Frequency Hz␊ |
99 | uint64_t␉␉FSBFrequency;␉␉// FSB Frequency Hz␊ |
100 | uint64_t␉␉CPUFrequency;␉␉// CPU Frequency Hz␊ |
101 | char␉␉␉BrandString[48];␉// 48 Byte Branding String␊ |
102 | uint8_t Brand; ␊ |
103 | uint32_t␉␉MicrocodeVersion; // The microcode version number a.k.a. signature a.k.a. BIOS ID ␊ |
104 | ␊ |
105 | bool isMobile; ␊ |
106 | 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)␊ |
107 | ␊ |
108 | boolean_t␉dynamic_acceleration;␊ |
109 | boolean_t␉invariant_APIC_timer;␊ |
110 | boolean_t␉fine_grain_clock_mod;␊ |
111 | ␊ |
112 | uint32_t cpuid_max_basic;␊ |
113 | ␉␉uint32_t cpuid_max_ext;␊ |
114 | uint32_t␉sub_Cstates;␊ |
115 | uint32_t extensions;␊ |
116 | ␊ |
117 | } CPU;␊ |
118 | ␊ |
119 | struct RAM_t {␊ |
120 | uint64_t␉␉Frequency;␉␉␉␉// Ram Frequency␊ |
121 | uint32_t␉␉Divider;␉␉␉␉// Memory divider␊ |
122 | uint8_t␉␉␉CAS;␉␉␉␉␉// CAS 1/2/2.5/3/4/5/6/7␊ |
123 | uint8_t␉␉␉TRC;␉␉␉␉␉␊ |
124 | uint8_t␉␉␉TRP;␊ |
125 | uint8_t␉␉␉RAS;␊ |
126 | uint8_t␉␉␉Channels;␉␉␉␉// Channel Configuration Single,Dual or Triple␊ |
127 | uint8_t␉␉␉NoSlots;␉␉␉␉// Maximum no of slots available␊ |
128 | uint8_t␉␉␉Type;␉␉␉␉␉// Standard SMBIOS v2.5 Memory Type␊ |
129 | RamSlotInfo_t␉DIMM[MAX_RAM_SLOTS];␉// Information about each slot␊ |
130 | } RAM;␊ |
131 | ␊ |
132 | struct DMI {␊ |
133 | int␉␉␉MaxMemorySlots;␉␉// number of memory slots polulated by SMBIOS␊ |
134 | int␉␉␉CntMemorySlots;␉␉// number of memory slots counted␊ |
135 | int␉␉␉MemoryModules;␉␉// number of memory modules installed␊ |
136 | int␉␉␉DIMM[MAX_RAM_SLOTS];␉// Information and SPD mapping for each slot␊ |
137 | } DMI;␊ |
138 | ␊ |
139 | ␉uint8_t␉␉␉␉Type;␉␉␉// System Type: 1=Desktop, 2=Portable... according ACPI2.0 (FACP: PreferredProfile)␊ |
140 | ␉uint8_t␉␉␉␉*UUID; // SMBios UUID␊ |
141 | ␉uint32_t␉␉␉hardware_signature;␊ |
142 | ␉int8_t␉␉␉␉sysid[16];␊ |
143 | ␊ |
144 | } PlatformInfo_t;␊ |
145 | ␊ |
146 | extern PlatformInfo_t *Platform;␊ |
147 | #endif /* !__LIBSAIO_PLATFORM_H */␊ |
148 | |