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