Chameleon

Chameleon Svn Source Tree

Root/branches/slice/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
21/* CPUID index into cpuid_raw */
22#define CPUID_00
23#define CPUID_11
24#define CPUID_22
25#define CPUID_33
26#define CPUID_44
27#define CPUID_805
28#define CPUID_816
29#define CPUID_MAX7
30
31#define CPU_MODEL_PENTIUM_M0x0D
32#define CPU_MODEL_YONAH0x0E
33#define CPU_MODEL_MEROM0x0F
34#define CPU_MODEL_PENRYN0x17
35#define CPU_MODEL_NEHALEM0x1A
36#define CPU_MODEL_ATOM0x1C
37#define CPU_MODEL_FIELDS0x1E/* Lynnfield, Clarksfield, Jasper */
38#define CPU_MODEL_DALES0x1F/* Havendale, Auburndale */
39#define CPU_MODEL_DALES_32NM0x25/* Clarkdale, Arrandale */
40#define CPU_MODEL_WESTMERE0x2C/* Gulftown, Westmere-EP, Westmere-WS */
41#define CPU_MODEL_NEHALEM_EX0x2E
42#define CPU_MODEL_WESTMERE_EX0x2F
43
44/* CPU Features */
45// NOTE: Theses 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
56// NOTE: Determine correct bit for bellow (28 is already in use)
57#define CPU_FEATURE_MOBILEbit(1)// Mobile CPU
58//Slice - just use Platform->CPU.Mobile
59#define MEGA 1000000LL
60
61/* SMBIOS Memory Types */
62#define SMB_MEM_TYPE_UNDEFINED0
63#define SMB_MEM_TYPE_OTHER1
64#define SMB_MEM_TYPE_UNKNOWN2
65#define SMB_MEM_TYPE_DRAM3
66#define SMB_MEM_TYPE_EDRAM4
67#define SMB_MEM_TYPE_VRAM5
68#define SMB_MEM_TYPE_SRAM6
69#define SMB_MEM_TYPE_RAM7
70#define SMB_MEM_TYPE_ROM8
71#define SMB_MEM_TYPE_FLASH9
72#define SMB_MEM_TYPE_EEPROM10
73#define SMB_MEM_TYPE_FEPROM11
74#define SMB_MEM_TYPE_EPROM12
75#define SMB_MEM_TYPE_CDRAM13
76#define SMB_MEM_TYPE_3DRAM14
77#define SMB_MEM_TYPE_SDRAM15
78#define SMB_MEM_TYPE_SGRAM16
79#define SMB_MEM_TYPE_RDRAM17
80#define SMB_MEM_TYPE_DDR18
81#define SMB_MEM_TYPE_DDR219
82#define SMB_MEM_TYPE_FBDIMM20
83#define SMB_MEM_TYPE_DDR324// Supported in 10.5.6+ AppleSMBIOS
84
85/* Memory Configuration Types */
86#define SMB_MEM_CHANNEL_UNKNOWN0
87#define SMB_MEM_CHANNEL_SINGLE1
88#define SMB_MEM_CHANNEL_DUAL2
89#define SMB_MEM_CHANNEL_TRIPLE3
90
91/* Maximum number of ram slots */
92#define MAX_RAM_SLOTS12
93#define RAM_SLOT_ENUMERATOR{0, 2, 4, 1, 3, 5, 6, 8, 10, 7, 9, 11}
94
95/* Maximum number of SPD bytes */
96#define MAX_SPD_SIZE256
97
98/* Size of SMBIOS UUID in bytes */
99#define UUID_LEN16
100
101typedef struct _RamSlotInfo_t {
102 uint32_tModuleSize;// Size of Module in MB
103 uint32_tFrequency; // in Mhz
104 const char*Vendor;
105 const char*PartNo;
106 const char*SerialNo;
107 char*spd;// SPD Dump
108 boolInUse;
109 uint8_tType;
110 uint8_tBankConnections; // table type 6, see (3.3.7)
111 uint8_tBankConnCnt;
112
113} RamSlotInfo_t;
114
115typedef struct _PlatformInfo_t {
116struct PCI {
117uint8_tNoDevices;// No of PCI devices
118} PCI;
119struct CPU {
120uint32_tFeatures;// CPU Features like MMX, SSE2, VT, MobileCPU
121uint32_tVendor;// Vendor
122uint32_tSignature;// Signature
123uint32_tStepping;// Stepping
124uint32_tModel;// Model
125uint32_tExtModel;// Extended Model
126uint32_tFamily;// Family
127uint32_tExtFamily;// Extended Family
128uint32_tNoCores;// No Cores per Package
129uint32_tNoThreads;// Threads per Package
130uint8_tMaxCoef;// Max Multiplier
131uint8_tMaxDiv;// Possible 0,5
132uint8_tMinCoef;// Min Multiplier
133uint8_tCurrCoef;// Current Multiplier
134uint8_tCurrDiv;
135floatMaxRatio;// non-integer ratio
136floatCurrRatio;
137uint64_tTSCFrequency;// TSC Frequency Hz
138uint64_tFSBFrequency;// FSB Frequency Hz
139uint64_tCPUFrequency;// CPU Frequency Hz
140boolMobile;// Mobile CPU
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
155charBrandString[48];// Branding String Memory Controller
156RamSlotInfo_tDIMM[MAX_RAM_SLOTS];// Information about each slot
157} RAM;
158
159struct DMI {
160intMaxMemorySlots;// number of memory slots polulated by SMBIOS
161intCntMemorySlots;// number of memory slots counted
162intMemoryModules;// number of memory modules installed
163intDIMM[MAX_RAM_SLOTS];// Information and SPD mapping for each slot
164} DMI;
165uint8_tType;// System Type: 1=Desktop, 2=Portable... according ACPI2.0 (FACP: PM_Profile)
166uint8_t*UUID;
167} PlatformInfo_t;
168
169extern PlatformInfo_t* Platform;
170
171#endif /* !__LIBSAIO_PLATFORM_H */
172

Archive Download this file

Revision: 681