Chameleon

Chameleon Svn Source Tree

Root/branches/Chimera/i386/libsaio/platform.h

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
12extern bool platformCPUFeature(uint32_t);
13extern void scan_platform(void);
14extern void dumpPhysAddr(const char * title, void * a, int len);
15
16#define bit(n)(1UL << (n))
17#define bitmask(h,l)((bit(h)|(bit(h)-1)) & ~(bit(l)-1))
18#define bitfield(x,h,l)(((x) & bitmask(h,l)) >> l)
19
20/* CPUID index into cpuid_raw */
21#define CPUID_00
22#define CPUID_11
23#define CPUID_22
24#define CPUID_33
25#define CPUID_44
26#define CPUID_805
27#define CPUID_816
28#define CPUID_MAX7
29
30#define CPU_MODEL_YONAH0x0E// Sossaman, Yonah
31#define CPU_MODEL_MEROM0x0F// Allendale, Conroe, Kentsfield, Woodcrest, Clovertown, Tigerton, Merom
32#define CPU_MODEL_PENRYN0x17// Wolfdale, Yorkfield, Harpertown, Penryn
33#define CPU_MODEL_NEHALEM0x1A// Bloomfield. Nehalem-EP, Nehalem-WS, Gainestown
34#define CPU_MODEL_ATOM0x1C// Atom
35#define CPU_MODEL_DUNNINGTON0x1D// Dunnington
36#define CPU_MODEL_FIELDS0x1E// Lynnfield, Clarksfield, Jasper Forest
37#define CPU_MODEL_DALES0x1F// Havendale, Auburndale
38#define CPU_MODEL_DALES_32NM0x25// Clarkdale, Arrandale: Dual core
39#define CPU_MODEL_SANDY_BRIDGE0x2A// Sandy Bridge
40#define CPU_MODEL_WESTMERE0x2C// Gulftown, Westmere-EP, Westmere-WS
41#define CPU_MODEL_NEHALEM_EX0x2E// Beckton
42#define CPU_MODEL_WESTMERE_EX0x2F
43
44/* CPU Features */
45// NOTE: These are currently mapped to the actual bit in the cpuid value
46#define CPU_FEATURE_MMXbit(23)// MMX Instruction Set
47#define CPU_FEATURE_SSEbit(25)// SSE Instruction Set
48#define CPU_FEATURE_SSE2bit(26)// SSE2 Instruction Set
49#define CPU_FEATURE_SSE3bit(0)// SSE3 Instruction Set
50#define CPU_FEATURE_SSE41bit(19)// SSE41 Instruction Set
51#define CPU_FEATURE_SSE42bit(20)// SSE42 Instruction Set
52#define CPU_FEATURE_EM64Tbit(29)// 64Bit Support
53#define CPU_FEATURE_HTTbit(28)// HyperThreading
54#define CPU_FEATURE_MSRbit(5)// MSR Support
55#define CPU_FEATURE_APICbit(9)// On-chip APIC Hardware
56#define CPU_FEATURE_ESTbit(7)// Enhanced Intel SpeedStep
57#define CPU_FEATURE_TM2bit(8)// Thermal Monitor 2
58#define CPU_FEATURE_TM1bit(29)// Thermal Monitor 1
59#define CPU_FEATURE_SSSE3bit(9)// Supplemental SSE3 Instruction Set
60#define CPU_FEATURE_xAPICbit(21)// Extended APIC Mode
61#define CPU_FEATURE_ACPIbit(22)// Thermal Monitor and Software Controlled Clock
62#define CPU_FEATURE_LAHFbit(20)// LAHF/SAHF Instructions
63#define CPU_FEATURE_XDbit(20)// Execute Disable
64
65// NOTE: Determine correct bit for below (28 is already in use)
66#define CPU_FEATURE_MOBILEbit(1)// Mobile CPU
67
68/* SMBIOS Memory Types */
69#define SMB_MEM_TYPE_UNDEFINED0
70#define SMB_MEM_TYPE_OTHER1
71#define SMB_MEM_TYPE_UNKNOWN2
72#define SMB_MEM_TYPE_DRAM3
73#define SMB_MEM_TYPE_EDRAM4
74#define SMB_MEM_TYPE_VRAM5
75#define SMB_MEM_TYPE_SRAM6
76#define SMB_MEM_TYPE_RAM7
77#define SMB_MEM_TYPE_ROM8
78#define SMB_MEM_TYPE_FLASH9
79#define SMB_MEM_TYPE_EEPROM10
80#define SMB_MEM_TYPE_FEPROM11
81#define SMB_MEM_TYPE_EPROM12
82#define SMB_MEM_TYPE_CDRAM13
83#define SMB_MEM_TYPE_3DRAM14
84#define SMB_MEM_TYPE_SDRAM15
85#define SMB_MEM_TYPE_SGRAM16
86#define SMB_MEM_TYPE_RDRAM17
87#define SMB_MEM_TYPE_DDR18
88#define SMB_MEM_TYPE_DDR219
89#define SMB_MEM_TYPE_FBDIMM20
90#define SMB_MEM_TYPE_DDR324// Supported in 10.5.6+ AppleSMBIOS
91
92/* Memory Configuration Types */
93#define SMB_MEM_CHANNEL_UNKNOWN0
94#define SMB_MEM_CHANNEL_SINGLE1
95#define SMB_MEM_CHANNEL_DUAL2
96#define SMB_MEM_CHANNEL_TRIPLE3
97
98/* Maximum number of ram slots */
99#define MAX_RAM_SLOTS8
100#define RAM_SLOT_ENUMERATOR{0, 2, 4, 1, 3, 5, 6, 8, 10, 7, 9, 11}
101
102/* Maximum number of SPD bytes */
103#define MAX_SPD_SIZE256
104
105/* Size of SMBIOS UUID in bytes */
106#define UUID_LEN16
107
108typedef struct _RamSlotInfo_t {
109 uint32_tModuleSize;// Size of Module in MB
110 uint32_tFrequency;// in Mhz
111 const char*Vendor;
112 const char*PartNo;
113 const char*SerialNo;
114 char*spd;// SPD Dump
115 boolInUse;
116 uint8_tType;
117 uint8_tBankConnections;// table type 6, see (3.3.7)
118 uint8_tBankConnCnt;
119
120} RamSlotInfo_t;
121
122typedef struct _PlatformInfo_t {
123struct CPU {
124uint32_tFeatures;// CPU Features like MMX, SSE2, VT, MobileCPU
125uint32_tVendor;// Vendor
126uint32_tSignature;// Signature
127uint32_tStepping;// Stepping
128uint32_tModel;// Model
129uint32_tExtModel;// Extended Model
130uint32_tFamily;// Family
131uint32_tExtFamily;// Extended Family
132uint32_tNoCores;// No Cores per Package
133uint32_tNoThreads;// Threads per Package
134uint8_tMaxCoef;// Max Multiplier
135uint8_tMaxDiv;
136uint8_tCurrCoef;// Current Multiplier
137uint8_tCurrDiv;
138uint64_tTSCFrequency;// TSC Frequency Hz
139uint64_tFSBFrequency;// FSB Frequency Hz
140uint64_tCPUFrequency;// CPU Frequency Hz
141charBrandString[48];// 48 Byte Branding String
142uint32_tCPUID[CPUID_MAX][4];// CPUID 0..4, 80..81 Raw Values
143} CPU;
144
145struct RAM {
146uint64_tFrequency;// Ram Frequency
147uint32_tDivider;// Memory divider
148uint8_tCAS;// CAS 1/2/2.5/3/4/5/6/7
149uint8_tTRC;
150uint8_tTRP;
151uint8_tRAS;
152uint8_tChannels;// Channel Configuration Single,Dual or Triple
153uint8_tNoSlots;// Maximum no of slots available
154uint8_tType;// Standard SMBIOS v2.5 Memory Type
155RamSlotInfo_tDIMM[MAX_RAM_SLOTS];// Information about each slot
156} RAM;
157
158struct DMI {
159intMaxMemorySlots;// number of memory slots polulated by SMBIOS
160intCntMemorySlots;// number of memory slots counted
161intMemoryModules;// number of memory modules installed
162intDIMM[MAX_RAM_SLOTS];// Information and SPD mapping for each slot
163} DMI;
164uint8_tType;// System Type: 1=Desktop, 2=Portable... according ACPI2.0 (FACP: PM_Profile)
165} PlatformInfo_t;
166
167extern PlatformInfo_t Platform;
168
169#endif /* !__LIBSAIO_PLATFORM_H */
170

Archive Download this file

Revision: 757