Chameleon Applications

Chameleon Applications Commit Details

Date:2011-12-03 07:24:52 (8 years 10 months ago)
Author:Rekursor
Commit:382
Parents: 381
Message:Created a rebuilt IOREG dictionary.
Changes:
M/trunk/ChameleonPrefPane/Sources/SmbiosExtractor.h
M/trunk/ChameleonPrefPane/Sources/smbios/smbios.h
M/trunk/ChameleonPrefPane/Sources/SmbiosExtractor.mm
M/trunk/ChameleonPrefPane/Sources/PropertyList.cpp
M/trunk/ChameleonPrefPane/Sources/smbios/smbios.cpp
M/trunk/ChameleonPrefPane/test_util/test_util.xcodeproj/project.pbxproj
M/trunk/ChameleonPrefPane/Sources/smbios/smbios_decode.cpp
M/trunk/ChameleonPrefPane/test_util/test_util.mm

File differences

trunk/ChameleonPrefPane/Sources/smbios/smbios_decode.cpp
106106
107107
108108
109
110
111
112
113
109
110
111
112
113
114
114115
115116
116117
......
162163
163164
164165
165
166
166
167167
168168
169169
......
191191
192192
193193
194
195
196
197
198
199194
200195
201196
......
204199
205200
206201
207
208
209
210
202
203
204
205
211206
212207
213208
DBG("\tmaximumClock: %dMHz\n", structHeader->maximumClock);
DBG("\tcurrentClock: %dMHz\n", structHeader->currentClock);
if (minorVersion < 3 || structHeader->header.length < 35)
return;
DBG("\tserialNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->serialNumber));
DBG("\tassetTag: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->assetTag));
DBG("\tpartNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->partNumber));
if (minorVersion >= 3 && structHeader->header.length >= 35)
{
DBG("\tserialNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->serialNumber));
DBG("\tassetTag: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->assetTag));
DBG("\tpartNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->partNumber));
}
DBG("\n");
}
DBG("\n");
for (SMBStructHeader *structHeader = (SMBStructHeader*)ptr; structHeader < (SMBStructHeader*)end ;)
{
DBG("Type: %d, Length: %d, Handle: 0x%x\n",
structHeader->type, structHeader->length, structHeader->handle);
// DBG("Type: %d, Length: %d, Handle: 0x%x\n", structHeader->type, structHeader->length, structHeader->handle);
switch (structHeader->type)
{
decodeMemoryDevice((SMBMemoryDevice *)structHeader);
break;
/* Skip all Apple Specific Structures */
case kSMBTypeFirmwareVolume:
case kSMBTypeMemorySPD:
break;
case kSMBTypeOemProcessorType:
decodeOemProcessorType((SMBOemProcessorType *)structHeader);
break;
decodeOemProcessorBusSpeed((SMBOemProcessorBusSpeed *)structHeader);
break;
case kSMBTypeEndOfTable:
/* Skip, to be added at the end */
break;
case kSMBTypeEndOfTable:/* Skip, to be added at the end */
/* Skip all Apple Specific Structures */
case kSMBTypeFirmwareVolume:
case kSMBTypeMemorySPD:
default:
break;
}
trunk/ChameleonPrefPane/Sources/smbios/smbios.h
471471
472472
473473
474
475
476
477
478474
#define SMBIOS_ORIGINAL0
#define SMBIOS_PATCHED1
extern void decodeSMBIOSTable(uint8_t *start, uint8_t * end);
#endif /* !__LIBSAIO_SMBIOS_H */
trunk/ChameleonPrefPane/Sources/smbios/smbios.cpp
276276
277277
278278
279
280
281
282279
280
281
282
283283
284284
285285
286286
287287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
SMBEntryPoint *origeps= 0;
SMBEntryPoint *neweps= 0;
static uint8_t stringIndex;// increament when a string is added and set the field value accordingly
static uint8_t stringsSize;// add string size
/*
static uint8_t stringIndex;// increament when a string is added and set the field value accordingly
static uint8_t stringsSize;// add string size
static SMBWord tableLength= 0;
static SMBWord handle= 0;
static SMBWord maxStructSize= 0;
static SMBWord structureCount= 0;
*/
/* Rewrite this function */
void setDefaultSMBData(void)
{
defaultBIOSInfo.vendor= kDefaultVendorManufacturer;
defaultBIOSInfo.releaseDate= kDefaultBIOSReleaseDate;
defaultSystemInfo.manufacturer= kDefaultVendorManufacturer;
defaultSystemInfo.version= kDefaultSystemVersion;
defaultSystemInfo.serialNumber= kDefaultSerialNumber;
defaultBaseBoard.manufacturer= kDefaultVendorManufacturer;
defaultBaseBoard.product= kDefaultBoardProduct;
defaultBIOSInfo.version= kDefaultMacProNehalemBIOSVersion;
defaultSystemInfo.productName= kDefaultMacProNehalem;
defaultSystemInfo.family= kDefaultMacProFamily;
}
char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field)
{
uint8_t *stringPtr = ((uint8_t *)structHeader) + structHeader->length;
if (!field)
return NULL;
for (field--; field != 0 && strlen((char *)stringPtr) > 0;
field--, stringPtr = (uint8_t *)((unsigned long )stringPtr + strlen((char *)stringPtr) + 1));
return (char *)stringPtr;
}
void setSMBStringForField(SMBStructHeader *structHeader, const char *string, uint8_t *field)
{
int strSize;
if (!field)
return;
if (!string)
{
*field = 0;
return;
}
strSize = strlen(string);
// remove any spaces found at the end
while ((strSize != 0) && (string[strSize - 1] == ' '))
strSize--;
if (strSize == 0)
{
*field = 0;
return;
}
memcpy((uint8_t *)structHeader + structHeader->length + stringsSize, string, strSize);
*field = stringIndex;
stringIndex++;
stringsSize += strSize + 1;
}
trunk/ChameleonPrefPane/Sources/SmbiosExtractor.mm
99
1010
1111
12
13
14
15
16
17
18
19
20
21
22
23
1224
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
1353
1454
55
1556
1657
1758
......
1960
2061
2162
22
23
2463
2564
2665
......
4281
4382
4483
45
84
85
86
87
88
89
4690
4791
4892
......
5397
5498
5599
56
100
57101
58102
59103
......
70114
71115
72116
117
73118
119
120
121
74122
75123
76124
125
77126
78127
79128
80129
81130
82
131
83132
133
84134
85135
86136
......
94144
95145
96146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
97435
#include "ShellProcess.h"
#include "string_util.h"
#include "smbios.h"
#include "PropertyList.h"
#include "smbios.h"
#include <stdio.h>
#ifndef DEBUG_SMBIOS
#define DEBUG_SMBIOS 0
#endif
#if 0
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#endif
static SMBWord minorVersion;
static char* getSMBStringForField(SMBStructHeader *structHeader, uint8_t field)
{
uint8_t *stringPtr = ((uint8_t *)structHeader) + structHeader->length;
static char empty[2] = "";
if (!field)
return empty;
for (field--; field != 0 && strlen((char *)stringPtr) > 0;
field--, stringPtr = (uint8_t *)((unsigned long )stringPtr + strlen((char *)stringPtr) + 1));
return ( char*) (stringPtr ? (char*) stringPtr : empty);
}
#define SHVAL(field) [NSString stringWithUTF8String: getSMBStringForField((SMBStructHeader *)structHeader, structHeader->field)]
#define SHVAL2(f,g) SHVAL(f),SHVAL(g)
#define SHVAL3(f,g,h) SHVAL2(f,g),SHVAL(h)
#define SHVAL4(f,g,h,i) SHVAL2(f,g),SHVAL2(h,i)
#define SHVAL5(f,g,h,i,j) SHVAL4(f,g,h,i),SHVAL(j)
#define SHVAL6(f,g,h,i,j,k) SHVAL5(f,g,h,i,j),SHVAL(k)
#define SHVAL7(f,g,h,i,j,k,l) SHVAL6(f,g,h,i,j,k),SHVAL(l)
#define MHZ(f) [NSString stringWithFormat:@"%d MHZ", (int)structHeader->f]
#define DEC(f) [NSString stringWithFormat:@"%d", (int)structHeader->f]
#define LLX(f) [NSString stringWithFormat:@"%llX", structHeader->f]
#define HEX32(f) [NSString stringWithFormat:@"0x%08X", (int)structHeader->f]
#define HEX16(f) [NSString stringWithFormat:@"0x%04X", (int)structHeader->f]
#define HEX8(f) [NSString stringWithFormat:@"%0x02X", (int)structHeader->f]
@implementation SmbiosExtractor
@synthesize dict;
@synthesize smString;
@synthesize bufSize;
-(id) init
self = [super init];
if (self!=nil)
{
buffer = nil;
bufSize=0;
[ self extractSmBios];
}
[smString release];
smString = nil;
}
if (dict!=nil)
{
[dict release];
dict = nil;
}
}
-(void) dealloc
-(NSString*) description
{
return smString;
return [dict description];
}
-(NSUInteger) extractSmBios
const char * p = strstr(line, SmbiosTag)+ tagLen;
std::string s = trim(p, " \t\r\n>");
NSLog(@"Found SMBIOS (%d) [%s]", s.length(), s.c_str() );
[self cleanup];
self.dict = [NSMutableDictionary dictionaryWithCapacity:32];
self.smString = [NSString stringWithUTF8String:s.c_str()];
bufSize = s.length()/2;
buffer = new UInt8[bufSize];
for(size_t pos =0; pos < bufSize; pos++)
{
buffer[pos] = (HexToDec(s[pos*2])*16 + HexToDec(s[pos*2+1]));
}
decodeSMBIOSTable(buffer, buffer+bufSize);
[self decodeSMBIOSTableFrom:buffer to: buffer+bufSize];
}
return 0;
}
return position < bufSize ? buffer[position]: 0;
}
-(BOOL) save:(NSString*) path
{
NSString * error;
id plist = [NSPropertyListSerialization dataFromPropertyList:(id)dict
format:NSPropertyListXMLFormat_v1_0 errorDescription:&error];
[plist writeToFile:path atomically:YES];
return YES;
}
#define ADD_HANDLE(text) [dict setValue:innerDict forKey: [NSString stringWithFormat:@"%@ (0x%02x)", text, (int) structHeader->header.handle] ]
//-------------------------------------------------------------------------------------------------------------------------
// BIOSInformation
//-------------------------------------------------------------------------------------------------------------------------
-(void) decodeBIOSInformation:(SMBBIOSInformation *)structHeader
{
NSDictionary* innerDict = [NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: SHVAL3(vendor, version, releaseDate), nil ]
forKeys: [NSArray arrayWithObjects:@"Vendor", @"Version", @"Release Date", nil]];
ADD_HANDLE(@"BIOS Information");
DBG("BIOSInformation:\n");
DBG("\tvendor: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->vendor));
DBG("\tversion: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->version));
DBG("\treleaseDate: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->releaseDate));
DBG("\n");
}
//-------------------------------------------------------------------------------------------------------------------------
// SystemInformation
//-------------------------------------------------------------------------------------------------------------------------
-(void) decodeSystemInformation:(SMBSystemInformation *)structHeader
{
NSDictionary* innerDict =
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: SHVAL4(manufacturer, productName, version, serialNumber), nil ]
forKeys: [NSArray arrayWithObjects:@"Manufacturer", @"Product Name", @"Version", @"Serial Number", nil]];
ADD_HANDLE(@"System Information");
DBG("SystemInformation:\n");
DBG("\tmanufacturer: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->manufacturer));
DBG("\tproductName: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->productName));
DBG("\tversion: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->version));
DBG("\tserialNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->serialNumber));
if (minorVersion < 1 || structHeader->header.length < 25)
{
DBG("\n");
return;
}
uint8_t *uuid = structHeader->uuid;
DBG("\tuuid: %02X%02X%02X%02X-%02X%02X-%02X%02X-%02x%02X-%02X%02X%02X%02X%02X%02X\n",
uuid[0], uuid[1], uuid[2], uuid[3],
uuid[4], uuid[5],
uuid[6], uuid[7],
uuid[8], uuid[9],
uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);
DBG("\twakeupReason: 0x%x\n", structHeader->wakeupReason);
if (minorVersion < 4 || structHeader->header.length < 27)
{
DBG("\n");
return;
}
DBG("\tskuNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->skuNumber));
DBG("\tfamily: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->family));
DBG("\n");
}
//-------------------------------------------------------------------------------------------------------------------------
// BaseBoard
//-------------------------------------------------------------------------------------------------------------------------
-(void) decodeBaseBoard:(SMBBaseBoard *) structHeader
{
NSDictionary* innerDict =
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: SHVAL7(manufacturer, product, version, serialNumber, assetTagNumber, locationInChassis, boardType), nil ]
forKeys: [NSArray arrayWithObjects:@"Manufacturer", @"Product", @"Version", @"Serial Number",
@"Asset Tag Number", @"Location In Chassis", @"Board Type", nil]];
ADD_HANDLE(@"Base Board");
DBG("BaseBoard:\n");
DBG("\tmanufacturer: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->manufacturer));
DBG("\tproduct: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->product));
DBG("\tversion: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->version));
DBG("\tserialNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->serialNumber));
DBG("\tassetTagNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->assetTagNumber));
DBG("\tlocationInChassis: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->locationInChassis));
DBG("\tboardType: 0x%X\n", structHeader->boardType);
DBG("\n");
}
//-------------------------------------------------------------------------------------------------------------------------
// SystemEnclosure
//-------------------------------------------------------------------------------------------------------------------------
-(void) decodeSystemEnclosure:(SMBSystemEnclosure *) structHeader
{
NSDictionary* innerDict =
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: SHVAL5(manufacturer, type, version, serialNumber, assetTagNumber), nil ]
forKeys: [NSArray arrayWithObjects:@"Manufacturer", @"Type", @"Version", @"Serial Number", @"Asset Tag Number", nil]];
ADD_HANDLE(@"System Enclosure");
DBG("SystemEnclosure:\n");
DBG("\tmanufacturer: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->manufacturer));
DBG("\ttype: %d\n", structHeader->type);
DBG("\tversion: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->version));
DBG("\tserialNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->serialNumber));
DBG("\tassetTagNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->assetTagNumber));
DBG("\n");
}
//-------------------------------------------------------------------------------------------------------------------------
// ProcessorInformation
//-------------------------------------------------------------------------------------------------------------------------
-(void) decodeProcessorInformation:(SMBProcessorInformation *) structHeader
{
NSDictionary* clockDict = [NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: MHZ(externalClock), MHZ(maximumClock), MHZ(currentClock), nil ]
forKeys: [NSArray arrayWithObjects:@"External", @"Maximum", @"Current", nil]];
NSDictionary* procDict = [NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: SHVAL(socketDesignation), DEC(processorType), HEX16(processorFamily), SHVAL(manufacturer),
LLX(processorID), SHVAL(processorVersion), nil ]
forKeys: [NSArray arrayWithObjects:@"Socket", @"Type", @"Family", @"Manufacturer", @"ID", @"Version", nil]];
NSDictionary* innerDict = [NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: procDict, clockDict, nil ]
forKeys: [NSArray arrayWithObjects:@"Processor", @"Clock", nil]];
ADD_HANDLE(@"Processor Information");
DBG("ProcessorInformation:\n");
DBG("\tsocketDesignation: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->socketDesignation));
DBG("\tprocessorType: %d\n", structHeader->processorType);
DBG("\tprocessorFamily: 0x%X\n", structHeader->processorFamily);
DBG("\tmanufacturer: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->manufacturer));
DBG("\tprocessorID: 0x%llX\n", structHeader->processorID);
DBG("\tprocessorVersion: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->processorVersion));
DBG("\texternalClock: %dMHz\n", structHeader->externalClock);
DBG("\tmaximumClock: %dMHz\n", structHeader->maximumClock);
DBG("\tcurrentClock: %dMHz\n", structHeader->currentClock);
if (minorVersion >= 3 && structHeader->header.length >= 35)
{
DBG("\tserialNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->serialNumber));
DBG("\tassetTag: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->assetTag));
DBG("\tpartNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->partNumber));
}
DBG("\n");
}
//-------------------------------------------------------------------------------------------------------------------------
// MemoryDevice
//-------------------------------------------------------------------------------------------------------------------------
-(void) decodeMemoryDevice:(SMBMemoryDevice *) structHeader
{
NSDictionary* memDict = [NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: SHVAL2(deviceLocator, bankLocator),
[NSString stringWithUTF8String: SMBMemoryDeviceTypes[structHeader->memoryType]], nil ]
forKeys: [NSArray arrayWithObjects:@"Device Locator", @"Bank Locator", @"Memory Type", nil]];
NSDictionary* extmemDict = (structHeader->header.length < 27) ? nil :
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: MHZ(memorySpeed), SHVAL4(manufacturer, serialNumber, assetTag, partNumber), nil ]
forKeys: [NSArray arrayWithObjects:@"Memory Speed", @"Manufacturer", @"Serial Number", @"Asset Tag", @"Part Number", nil]];
NSDictionary* innerDict = [NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: memDict, extmemDict, nil ]
forKeys: [NSArray arrayWithObjects:@"Information", @"More Information", nil]];
ADD_HANDLE(@"Memory Device");
DBG("MemoryDevice:\n");
DBG("\tdeviceLocator: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->deviceLocator));
DBG("\tbankLocator: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->bankLocator));
DBG("\tmemoryType: %s\n", SMBMemoryDeviceTypes[structHeader->memoryType]);
if (structHeader->header.length < 27)
{
DBG("\n");
return;
}
DBG("\tmemorySpeed: %dMHz\n", structHeader->memorySpeed);
DBG("\tmanufacturer: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->manufacturer));
DBG("\tserialNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->serialNumber));
DBG("\tassetTag: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->assetTag));
DBG("\tpartNumber: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->partNumber));
DBG("\n");
}
//-------------------------------------------------------------------------------------------------------------------------
// Apple Specific
//-------------------------------------------------------------------------------------------------------------------------
-(void) decodeOemProcessorType:(SMBOemProcessorType *)structHeader
{
NSDictionary* innerDict = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects: SHVAL(ProcessorType), nil ]
forKeys: [NSArray arrayWithObjects:@"Processor Type", nil]];
ADD_HANDLE(@"Apple Processor Type");
DBG("AppleProcessorType:\n");
DBG("\tProcessorType: 0x%x\n", ((SMBOemProcessorType *)structHeader)->ProcessorType);
DBG("\n");
}
-(void) decodeOemProcessorBusSpeed:(SMBOemProcessorBusSpeed *)structHeader
{
NSString * qpi = [NSString stringWithFormat:@"%d.%d GT/s",
((SMBOemProcessorBusSpeed *)structHeader)->ProcessorBusSpeed / 1000,
(((SMBOemProcessorBusSpeed *)structHeader)->ProcessorBusSpeed / 100) % 10];
NSDictionary* innerDict = [NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: qpi, nil ] forKeys: [NSArray arrayWithObjects:@"Bus Speed (QPI)", nil]];
ADD_HANDLE(@"Apple Processor Bus Speed");
DBG("AppleProcessorBusSpeed:\n");
DBG("\tProcessorBusSpeed (QPI): %d.%dGT/s\n",
((SMBOemProcessorBusSpeed *)structHeader)->ProcessorBusSpeed / 1000,
(((SMBOemProcessorBusSpeed *)structHeader)->ProcessorBusSpeed / 100) % 10);
DBG("\n");
}
//-------------------------------------------------------------------------------------------------------------------------
-(void) decodeSMBIOSTableFrom:(uint8_t *) ptr to: (uint8_t*) end
{
DBG("\n");
for (SMBStructHeader *structHeader = (SMBStructHeader*)ptr; structHeader < (SMBStructHeader*)end ;)
{
// DBG("Type: %d, Length: %d, Handle: 0x%x\n", structHeader->type, structHeader->length, structHeader->handle);
switch (structHeader->type)
{
case kSMBTypeBIOSInformation:
[self decodeBIOSInformation: (SMBBIOSInformation *) structHeader];
break;
case kSMBTypeSystemInformation:
[self decodeSystemInformation: (SMBSystemInformation *)structHeader];
break;
case kSMBTypeBaseBoard:
[self decodeBaseBoard: (SMBBaseBoard *)structHeader];
break;
case kSMBTypeSystemEnclosure:
[self decodeSystemEnclosure:(SMBSystemEnclosure *)structHeader];
break;
case kSMBTypeProcessorInformation:
[self decodeProcessorInformation:(SMBProcessorInformation *)structHeader];
break;
case kSMBTypeMemoryDevice:
[self decodeMemoryDevice:(SMBMemoryDevice *)structHeader];
break;
case kSMBTypeOemProcessorType:
[self decodeOemProcessorType:(SMBOemProcessorType *)structHeader];
break;
case kSMBTypeOemProcessorBusSpeed:
[self decodeOemProcessorBusSpeed:(SMBOemProcessorBusSpeed *)structHeader];
break;
case kSMBTypeEndOfTable:/* Skip, to be added at the end */
/* Skip all Apple Specific Structures */
case kSMBTypeFirmwareVolume:
case kSMBTypeMemorySPD:
default:
break;
}
ptr = (uint8_t*) (((unsigned long)structHeader) + structHeader->length);
for (; ((uint16_t *)ptr)[0] != 0; ptr++);
if (((uint16_t *)ptr)[0] == 0)
ptr += 2;
structHeader = (SMBStructHeader *)ptr;
}
DBG("\n");
}
@end
trunk/ChameleonPrefPane/Sources/PropertyList.cpp
251251
252252
253253
254
255
256
257254
258255
259256
bool ret = false;
if (!path || !*path) return false;
struct stat st;
if(stat(path,&st) != 0) return false; // file does not exist;
_propFilePath = path;
CFStringRef cfPath = CFStringCreateWithCString (kCFAllocatorDefault, path, kCFStringEncodingUTF8);
trunk/ChameleonPrefPane/Sources/SmbiosExtractor.h
88
99
1010
11
11
1212
1313
1414
15
1516
1617
18
1719
1820
1921
2022
23
24
2125
2226
23
27
2428
#import <Foundation/Foundation.h>
@interface SmbiosExtractor : NSMutableDictionary {
@interface SmbiosExtractor : NSObject {
UInt8* buffer;
NSUInteger bufSize;
NSString* smString;
NSMutableDictionary* dict;
}
@property (retain) NSMutableDictionary* dict;
@property (retain) NSString* smString;
@property NSUInteger bufSize;
-(NSUInteger) extractSmBios;
-(void) decodeSMBIOSTableFrom:(uint8_t *) ptr to: (uint8_t*) end;
-(NSString*) stringFrom:(NSUInteger) start withLen:(NSUInteger) len;
-(UInt8) ByteFrom:(NSUInteger) position;
-(BOOL) save:(NSString*) path;
@end
trunk/ChameleonPrefPane/test_util/test_util.mm
5050
5151
5252
53
54
5355
54
55
5656
5757
5858
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
SmbiosExtractor* smbe = [[SmbiosExtractor alloc] init];
[smbe save:@"/tmp/chmIOreg.plist"];
NSLog(@"SMBIOS = \n%@", smbe);
#if 1
NSArray* arr = [PartitionInfoElement createBSDPartitionList];
NSLog(@"List of existing bsd disk partitions:\n %@", arr);
trunk/ChameleonPrefPane/test_util/test_util.xcodeproj/project.pbxproj
2121
2222
2323
24
2524
2625
2726
......
6867
6968
7069
71
7270
7371
7472
......
162160
163161
164162
165
166163
167164
168165
......
236233
237234
238235
239
240236
241237
242238
01B45A7D146F72F0002C3699 /* DiskArbitration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01B45A7C146F72F0002C3699 /* DiskArbitration.framework */; };
8485BA071482F662005DF2E4 /* SmbiosExtractor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8485BA061482F662005DF2E4 /* SmbiosExtractor.mm */; };
84DDA1371483527000A7C8FF /* smbios.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84DDA1321483527000A7C8FF /* smbios.cpp */; };
84DDA1381483527000A7C8FF /* smbios_decode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84DDA1341483527000A7C8FF /* smbios_decode.cpp */; };
8DD76F9A0486AA7600D96B5E /* test_util.mm in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* test_util.mm */; settings = {ATTRIBUTES = (); }; };
8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
8DD76F9F0486AA7600D96B5E /* test_util.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859EA3029092ED04C91782 /* test_util.1 */; };
8485BA061482F662005DF2E4 /* SmbiosExtractor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SmbiosExtractor.mm; path = ../Sources/SmbiosExtractor.mm; sourceTree = SOURCE_ROOT; };
84DDA1321483527000A7C8FF /* smbios.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = smbios.cpp; sourceTree = "<group>"; };
84DDA1331483527000A7C8FF /* smbios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = smbios.h; sourceTree = "<group>"; };
84DDA1341483527000A7C8FF /* smbios_decode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = smbios_decode.cpp; sourceTree = "<group>"; };
8DD76FA10486AA7600D96B5E /* test_util */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = test_util; sourceTree = BUILT_PRODUCTS_DIR; };
C6859EA3029092ED04C91782 /* test_util.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = test_util.1; sourceTree = "<group>"; };
/* End PBXFileReference section */
children = (
84DDA1321483527000A7C8FF /* smbios.cpp */,
84DDA1331483527000A7C8FF /* smbios.h */,
84DDA1341483527000A7C8FF /* smbios_decode.cpp */,
);
name = smbios;
path = ../Sources/smbios;
015403AE1470705C008E088A /* PartitionInfoManager.mm in Sources */,
8485BA071482F662005DF2E4 /* SmbiosExtractor.mm in Sources */,
84DDA1371483527000A7C8FF /* smbios.cpp in Sources */,
84DDA1381483527000A7C8FF /* smbios_decode.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

Archive Download the corresponding diff file

Revision: 382