Chameleon

Chameleon Commit Details

Date:2011-10-25 18:23:06 (8 years 7 months ago)
Author:armel cadet-petit
Commit:1659
Parents: 1658
Message:Ported the serial number randomizer to smbiosgetters
Changes:
M/branches/cparm/i386/modules/SMBiosGetters/smbios_decode.c
M/branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
M/branches/cparm/i386/modules/SMBiosGetters/mysmbios.h
M/branches/cparm/i386/modules/SMBiosGetters/SMBiosGetters.c
M/branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c
M/branches/cparm/CHANGES

File differences

branches/cparm/CHANGES
1
2
3
14
25
6
37
48
59
- Ported the serial number randomizer to smbiosgetters,
Warning: smbiosgetters (and also the Gui module) still don't work when built with Xcode4.
- Implemented a serial number randomizer in smbiospatcher
(can be useful for icloud registration problems, especially when the serial number is already used by another machine,
DISCLAIMER: Please read the iCloud License (http://www.apple.com/legal/icloud/ww/) carefully before using this option.
By using this option, you are agreeing to be bound by
the terms of the iCloud License (http://www.apple.com/legal/icloud/ww/). If you do not or cannot agree to the terms
branches/cparm/i386/modules/SMBiosGetters/smbios_decode.c
2121
2222
2323
24
2524
2625
2726
static SMBWord minorVersion;
//extern char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field);
static void decodeBIOSInformation(SMBBIOSInformation *structHeader);
static void decodeSystemInformation(SMBSystemInformation *structHeader);
static void decodeBaseBoard(SMBBaseBoard *structHeader);
branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
6767
6868
6969
70
70
7171
72
73
74
75
76
72
7773
78
79
80
81
74
75
76
77
8278
8379
84
85
86
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
8798
8899
89
90
91
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
92118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
93139
94
95
96
140
141
142
143
144
145
146
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
97179
98
99
100
101
102
103
104
105
106
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
107219
108
109
110
111
112
113
114
115
116
117
118
119
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
120238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
121258
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
122317
123318
124319
......
127322
128323
129324
130
131
132
325
326
327
133328
134329
135330
136
137
138
139
140
331
332
333
334
335
141336
142337
143338
144
145
339
340
146341
147342
148343
......
152347
153348
154349
155
350
156351
157352
158353
......
162357
163358
164359
165
360
166361
167362
168
363
169364
170365
171
366
172367
173368
174369
175370
176371
177
372
178373
179374
180
375
181376
182377
183
378
184379
185380
186
381
187382
188383
189
384
190385
191386
192
193
387
388
194389
195390
196391
197392
198393
199
394
200395
201396
202
397
203398
204
399
205400
206
401
207402
208
403
209404
210
211
405
406
212407
213408
214409
215410
216
411
217412
218
413
219414
220
415
221416
222417
223
418
224419
225420
226421
227422
228423
229
424
230425
231
426
232427
233
428
234429
235
430
236431
237432
238433
239434
240435
241
436
242437
243438
244
439
245440
246441
247
442
248443
249444
250
445
251446
252447
253
448
254449
255450
256
451
257452
258
453
259454
260455
261
262
456
457
263458
264459
265460
266461
267462
268
463
269464
270465
271466
......
295490
296491
297492
298
493
299494
300495
301496
302497
303498
304
499
305500
306501
307502
308503
309504
310
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
311629
312630
313631
314632
315633
316634
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
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
410789
411
412
413
414
790
791
792
793
794
415795
416
417
418
419
420
421
422
423
424
425
426
427
796
797
798
428799
429800
430801
......
436807
437808
438809
439
810
440811
441812
442813
443814
444815
445
816
446817
447
818
448819
449820
450821
......
459830
460831
461832
462
833
463834
464835
465
836
466837
467838
468839
469840
470841
471
842
472843
473
474
844
845
475846
476847
477848
478849
479850
480851
481
852
482853
483854
484
855
485856
486857
487858
......
496867
497868
498869
499
870
500871
501872
502873
......
504875
505876
506877
507
878
508879
509880
510881
......
524895
525896
526897
898
899
900
901
527902
528903
529
904
905
906
907
908
909
530910
531911
532912
......
543923
544924
545925
546
926
547927
548928
549929
......
596976
597977
598978
599
979
600980
601981
602982
......
6201000
6211001
6221002
623
1003
6241004
625
1005
6261006
6271007
6281008
......
6311011
6321012
6331013
634
1014
6351015
6361016
6371017
......
6591039
6601040
6611041
662
1042
6631043
664
1044
6651045
6661046
6671047
......
6751055
6761056
6771057
678
1058
6791059
6801060
6811061
......
6841064
6851065
6861066
687
1067
6881068
6891069
6901070
691
1071
6921072
6931073
694
1074
6951075
6961076
697
1077
6981078
699
1079
7001080
701
702
703
704
1081
1082
1083
1084
7051085
7061086
7071087
7081088
7091089
710
1090
7111091
7121092
7131093
7141094
715
1095
7161096
7171097
718
1098
7191099
7201100
7211101
7221102
7231103
7241104
725
1105
7261106
7271107
7281108
7291109
7301110
7311111
732
1112
7331113
734
1114
7351115
736
1116
7371117
7381118
739
1119
7401120
741
1121
7421122
7431123
7441124
7451125
7461126
7471127
748
1128
7491129
7501130
7511131
7521132
753
1133
7541134
7551135
7561136
......
7581138
7591139
7601140
761
1141
7621142
7631143
7641144
......
7661146
7671147
7681148
769
1149
7701150
7711151
7721152
773
1153
7741154
7751155
776
1156
7771157
7781158
7791159
7801160
7811161
782
1162
7831163
784
1164
7851165
786
1166
7871167
788
1168
7891169
7901170
791
1171
7921172
7931173
7941174
7951175
7961176
797
1177
7981178
799
1179
8001180
8011181
802
1182
8031183
8041184
8051185
806
1186
8071187
8081188
809
810
811
1189
1190
8121191
8131192
814
1193
8151194
8161195
8171196
818
1197
8191198
8201199
8211200
8221201
8231202
8241203
825
1204
8261205
8271206
8281207
......
8321211
8331212
8341213
835
1214
8361215
8371216
8381217
......
8421221
8431222
8441223
845
1224
8461225
8471226
848
1227
8491228
850
1229
8511230
8521231
853
1232
8541233
8551234
856
1235
8571236
8581237
8591238
......
8651244
8661245
8671246
868
1247
8691248
8701249
8711250
8721251
873
1252
8741253
8751254
8761255
......
8781257
8791258
8801259
881
1260
8821261
8831262
8841263
885
1264
8861265
8871266
8881267
......
8941273
8951274
8961275
897
1276
8981277
8991278
900
1279
9011280
9021281
903
1282
9041283
9051284
9061285
//-------------------------------------------------------------------------------------------------------------------------
// Default SMBIOS Data
//-------------------------------------------------------------------------------------------------------------------------
/* Rewrite: use a struct */
static char fake_serial[11];
#define kDefaultVendorManufacturer"Apple Inc."
#define kDefaultBIOSReleaseDate"11/06/2009"
#define kDefaultSerialNumber"SOMESRLNMBR"
#define kDefaultBoardProduct"Mac-F4208DC8"
#define kDefaultSystemVersion"1.0"
static char const sn_gen_pn_str[36] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// defaults for a Mac mini
#define kDefaultMacminiFamily"Macmini"
#define kDefaultMacmini"Macmini2,1"
#define kDefaultMacminiBIOSVersion" MM21.88Z.009A.B00.0903051113"
typedef struct {
const char* key;
const char* value;
} SMStrEntryPair;
// defaults for a MacBook
#define kDefaultMacBookFamily"MacBook"
#define kDefaultMacBook"MacBook4,1"
#define kDefaultMacBookBIOSVersion" MB41.88Z.0073.B00.0903051113"
static const SMStrEntryPair const sm_macbook_defaults[]={
{"SMbiosvendor", "Apple Inc." },
{"SMbiosversion", "MB41.88Z.00C1.B00.0802091535"},
{"SMbiosdate", "02/09/2008" },
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "MacBook4,1" },
{"SMsystemversion", "1.0" },
{"SMserial", "RM83064H0P1" },
{"SMserialProductCountry","RM" },
{"SMserialYear", "8" },
{"SMserialWeek", "30" },
{"SMserialProductNumber","64H" },
{"SMserialModel","0P1" },
{"SMfamily", "MacBook" },
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F22788A9" },
{ "",""}
};
// defaults for a MacBook Pro
#define kDefaultMacBookProFamily"MacBookPro"
#define kDefaultMacBookPro"MacBookPro4,1"
#define kDefaultMacBookProBIOSVersion" MBP41.88Z.0073.B00.0903051113"
static const SMStrEntryPair const sm_macbookpro_defaults[]={
{"SMbiosvendor", "Apple Inc." },
{"SMbiosversion", "MBP41.88Z.00C1.B03.0802271651"},
{"SMbiosdate", "02/27/2008" },
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "MacBookPro4,1" },
{"SMsystemversion", "1.0" },
{"SMserial", "W88198N6YJX" },
{"SMserialProductCountry","W8" },
{"SMserialYear", "8" },
{"SMserialWeek", "19" },
{"SMserialProductNumber","8N6" },
{"SMserialModel","YJX" },
{"SMfamily", "MacBookPro" },
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F42C89C8" },
{ "",""}
};
// defaults for a Mac mini
static const SMStrEntryPair const sm_macmini_defaults[]={
{"SMbiosvendor", "Apple Inc." },
{"SMbiosversion", "MM21.88Z.009A.B00.0706281359"},
{"SMbiosdate", "06/28/2007" },
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "Macmini2,1" },
{"SMsystemversion", "1.0" },
{"SMserial", "YM8054BYYL2" },
{"SMserialProductCountry","YM" },
{"SMserialYear", "8" },
{"SMserialWeek", "05" },
{"SMserialProductNumber","4BY" },
{"SMserialModel","YL2" },
{"SMfamily", "Napa Mac" },
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F4208EAA" },
{ "",""}
};
// defaults for an iMac
#define kDefaultiMacFamily"iMac"
#define kDefaultiMac"iMac8,1"
#define kDefaultiMacBIOSVersion" IM81.88Z.00C1.B00.0903051113"
static const SMStrEntryPair const sm_imac_defaults[]={
{"SMbiosvendor", "Apple Inc." },
{"SMbiosversion", "IM71.88Z.007A.B03.0803051705"},
{"SMbiosdate", "03/05/2008" },
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "iMac7,1" },
{"SMsystemversion", "1.0" },
{"SMserial", "W87410PWX87" },
{"SMserialProductCountry","W8" },
{"SMserialYear", "7" },
{"SMserialWeek", "41" },
{"SMserialProductNumber","0PW" },
{"SMserialModel","X87" },
{"SMfamily", "Mac" },
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F4238CC8" },
{ "",""}
};
// defaults for a Mac Pro
static const SMStrEntryPair const sm_macpro_defaults[]={
{"SMbiosvendor", "Apple Computer, Inc."},
{"SMbiosversion", "MP31.88Z.006C.B02.0801021250"},
{"SMbiosdate", "01/02/2008"},
{"SMmanufacter", "Apple Computer, Inc."},
{"SMproductname", "MacPro3,1"},
{"SMsystemversion", "1.0"},
{"SMserial", "G88014V4XYK"},
{"SMserialProductCountry","G8" },
{"SMserialYear", "8" },
{"SMserialWeek", "01" },
{"SMserialProductNumber","4V4" },
{"SMserialModel","XYK" },
{"SMfamily", "MacPro"},
{"SMboardmanufacter", "Apple Computer, Inc."},
{"SMboardproduct", "Mac-F42C88C8"},
{ "",""}
};
// defaults for an iMac11,1 core i3/i5/i7
#define kDefaultiMacNehalem"iMac11,1"
#define kDefaultiMacNehalemBIOSVersion" IM111.88Z.0034.B00.0903051113"
// defaults for an iMac12,1
#define kDefaultiMacSandy"iMac12,1"
#define kDefaultiMacSandyBIOSVersion" IM121.88Z.0047.B00.1102091756"
// defaults for a Mac Pro
#define kDefaultMacProFamily"MacPro"
#define kDefaultMacPro"MacPro3,1"
#define kDefaultMacProBIOSVersion" MP31.88Z.006C.B05.0903051113"
static const SMStrEntryPair const sm_imac_core_defaults[]={
{"SMbiosvendor", "Apple Inc."},
{"SMbiosversion", "IM111.88Z.0034.B00.0910301727"},
{"SMbiosdate", "10/30/2009"},
{"SMmanufacter", "Apple Inc."},
{"SMproductname", "iMac11,1"},
{"SMsystemversion", "1.0"},
{"SMserial", "W89470DZ5RU"},
{"SMserialProductCountry", "W8" },
{"SMserialYear", "9" },
{"SMserialWeek", "47" },
{"SMserialProductNumber", "0DZ" },
{"SMserialModel", "5RU" },
{"SMfamily", "iMac"},
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F2268DAE"},
{ "",""}
};
// defaults for an iMac12,1 : todo: populate correctly
static const SMStrEntryPair const sm_imac_sandy_defaults[]={
{"SMbiosvendor", "Apple Inc."},
{"SMbiosversion", "IM121.88Z.0047.B00.1102091756"},
{"SMbiosdate", "10/30/2011"},
{"SMmanufacter", "Apple Inc."},
{"SMproductname", "iMac12,1"},
{"SMsystemversion", "1.0"},
{"SMserial", "W89470DZ5RU"},
{"SMserialProductCountry", "W8" },
{"SMserialYear", "9" },
{"SMserialWeek", "47" },
{"SMserialProductNumber", "0DZ" },
{"SMserialModel", "5RU" },
{"SMfamily", "iMac"},
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F2268DAE"},
{ "",""}
};
// defaults for a Mac Pro 4,1 core i7/Xeon
#define kDefaultMacProNehalem"MacPro4,1"
#define kDefaultMacProNehalemBIOSVersion" MP41.88Z.0081.B04.0903051113"
// defaults for a Mac Pro 5,1 core i7/Xeon
#define kDefaultMacProWestmere"MacPro5,1"
#define kDefaultMacProWestmereBIOSVersion" MP51.88Z.007F.B00.1008031144"
#define kDefaulMacProWestmereBIOSReleaseDate"08/03/10"
// defaults for a Xserve
#define kDefaultXserve"Xserve2,1"
#define kDefaultXserveBIOSVersion" XS21.88Z.006C.B06.0804011317"
#define kDefaulXserveBIOSReleaseDate"04/01/2008"
#define kDefaultXserveFamily"Xserve"
//-------------------------------------------------------------------------------------------------------------------------
static const SMStrEntryPair const sm_macpro_core_defaults[]={
{"SMbiosvendor", "Apple Computer, Inc."},
{"SMbiosversion", "MP41.88Z.0081.B03.0902231259"},
{"SMbiosdate", "02/23/2009"},
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "MacPro4,1"},
{"SMsystemversion", "1.0"},
{"SMserial", "CK91601V8Q0"},
{"SMserialProductCountry","CK" },
{"SMserialYear", "9" },
{"SMserialWeek", "16" },
{"SMserialProductNumber","01V" },
{"SMserialModel","8Q0" },
{"SMfamily", "MacPro"},
{"SMboardmanufacter", "Apple Computer, Inc."},
{"SMboardproduct", "Mac-F221BEC8"},
{ "",""}
};
// defaults for a Mac Pro 5,1 Westmere
static const SMStrEntryPair const sm_macpro_westmere_defaults[]={
{"SMbiosvendor", "Apple Computer, Inc."},
{"SMbiosversion", "MP51.88Z.007F.B00.1008031144"},
{"SMbiosdate", "08/03/2010"},
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "MacPro5,1"},
{"SMsystemversion", "0.0"},
{"SMserial", "YM0330U7EUH"},
{"SMserialProductCountry","YM" },
{"SMserialYear", "0" },
{"SMserialWeek", "33" },
{"SMserialProductNumber","0U7" },
{"SMserialModel","EUH" },
{"SMfamily", "MacPro"},
{"SMboardmanufacter", "Apple Computer, Inc."},
{"SMboardproduct", "Mac-F221BEC8"},
{ "",""}
};
// default for a Xserve
static const SMStrEntryPair const sm_xserve_defaults[]={
{"SMbiosvendor", "Apple Inc."},
{"SMbiosversion", "XS21.88Z.006C.B06.0804011317"},
{"SMbiosdate", "04/01/2008"},
{"SMmanufacter", "Apple Inc."},
{"SMproductname", "Xserve2,1"},
{"SMsystemversion", "1.0"},
{"SMserial", "CK816033X8S"},
{"SMserialProductCountry","CK" },
{"SMserialYear", "8" },
{"SMserialWeek", "16" },
{"SMserialProductNumber","033" },
{"SMserialModel","X8S" },
{"SMfamily", "Xserve"},
{"SMboardmanufacter", "Apple Inc."},
{"SMboardproduct", "Mac-F42289C8"},
{ "",""}
};
typedef struct {
const char* code;
const char* info;
} SMProductCountry;
static const SMProductCountry const sm_country_list[]={
{"1C","China" },
{"2Z","Refurbished" },
{"4H","China" },
{"5K","China" },
{"8H","China" },
{"5D","China" },
{"7J","China " },
{"CK","Cork " },
/*{"E","Singapur" },*/
{"EE","Taiwan" },
/*{"F","Fremont " },*/
{"FC","Fountain " },
{"G8","USA" },
{"GQ","Refurbished" },
{"PT","Korea" },
{"CY","Korea" },
{"QT","Taiwan" },
{"QP","China" },
{"RN","Mexico" },
{"RM","Refurbished/Remanufactured"},
{"SG","Singapore" },
{"UV","Taiwan" },
{"U2","Taiwan" },
{"V7","Taiwan" },
{"VM","China" },
{"W8","Shanghai" },
{"WQ","China" },
{"XA","Elk Grove Sacramento"},
{"XB","Elk Grove Sacramento"},
{"YM","China /Konfiguriert"}
};
#define getFieldOffset(struct, field)((uint8_t)(uint32_t)&(((struct *)0)->field))
typedef struct {
} SMBStructPtrs;
struct {
char *vendor;
char *version;
char *releaseDate;
const char *vendor;
const char *version;
const char *releaseDate;
} defaultBIOSInfo;
struct {
char *manufacturer;
char *productName;
char *version;
char *serialNumber;
char *family;
const char *manufacturer;
const char *productName;
const char *version;
const char *serialNumber;
const char *family;
} defaultSystemInfo;
struct {
char *manufacturer;
char *product;
const char *manufacturer;
const char *product;
} defaultBaseBoard;
uint8_tfieldOffset;
char*keyString;
bool(*getSMBValue)(returnType *);
char**defaultValue;
const char**defaultValue;
} SMBValueSetter;
SMBValueSetter SMBSetters[] =
//-------------------------------------------------------------------------------------------------------------------------
{kSMBTypeBIOSInformation,kSMBString,getFieldOffset(SMBBIOSInformation, vendor),kSMBBIOSInformationVendorKey,
NULL,&defaultBIOSInfo.vendor},
{kSMBTypeBIOSInformation,kSMBString,getFieldOffset(SMBBIOSInformation, version),kSMBBIOSInformationVersionKey,
NULL,&defaultBIOSInfo.version},
{kSMBTypeBIOSInformation,kSMBString,getFieldOffset(SMBBIOSInformation, releaseDate),kSMBBIOSInformationReleaseDateKey,
NULL,&defaultBIOSInfo.releaseDate},
//-------------------------------------------------------------------------------------------------------------------------
// SystemInformation
//-------------------------------------------------------------------------------------------------------------------------
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, manufacturer),kSMBSystemInformationManufacturerKey,
NULL,&defaultSystemInfo.manufacturer},
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, productName),kSMBSystemInformationProductNameKey,
NULL,&defaultSystemInfo.productName},
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, version),kSMBSystemInformationVersionKey,
NULL,&defaultSystemInfo.version},
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, serialNumber),kSMBSystemInformationSerialNumberKey,
NULL,&defaultSystemInfo.serialNumber},
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, skuNumber),NULL,
NULL,NULL},
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, family),kSMBSystemInformationFamilyKey,
NULL,&defaultSystemInfo.family},
//-------------------------------------------------------------------------------------------------------------------------
// BaseBoard
//-------------------------------------------------------------------------------------------------------------------------
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, manufacturer),kSMBBaseBoardManufacturerKey,
NULL,&defaultBaseBoard.manufacturer},
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, product),kSMBBaseBoardProductKey,
NULL,&defaultBaseBoard.product},
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, version),NULL,NULL,NULL},
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, serialNumber),NULL,NULL,NULL},
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, assetTagNumber),NULL,NULL,NULL},
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, locationInChassis),NULL,NULL,NULL},
//-------------------------------------------------------------------------------------------------------------------------
// ProcessorInformation
//-------------------------------------------------------------------------------------------------------------------------
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, socketDesignation),NULL,NULL,NULL},
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, manufacturer),NULL,NULL,NULL},
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, processorVersion),NULL,NULL,NULL},
{kSMBTypeProcessorInformation,kSMBWord,getFieldOffset(SMBProcessorInformation, externalClock),kSMBProcessorInformationExternalClockKey,
getProcessorInformationExternalClock,NULL},
{kSMBTypeProcessorInformation,kSMBWord,getFieldOffset(SMBProcessorInformation, maximumClock),kSMBProcessorInformationMaximumClockKey,
getProcessorInformationMaximumClock,NULL},
{kSMBTypeProcessorInformation,kSMBWord,getFieldOffset(SMBProcessorInformation, currentClock),kSMBProcessorInformationCurrentClockKey,
getProcessorInformationCurrentClock,NULL},
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, serialNumber),NULL,NULL,NULL},
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, assetTag),NULL,NULL,NULL},
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, partNumber),NULL,NULL,NULL},
//-------------------------------------------------------------------------------------------------------------------------
// Memory Device
//-------------------------------------------------------------------------------------------------------------------------
{kSMBTypeMemoryDevice,kSMBString,getFieldOffset(SMBMemoryDevice, deviceLocator),kSMBMemoryDeviceDeviceLocatorKey,
NULL,NULL},
{kSMBTypeMemoryDevice,kSMBString,getFieldOffset(SMBMemoryDevice, bankLocator),kSMBMemoryDeviceBankLocatorKey,
NULL,NULL},
{kSMBTypeMemoryDevice,kSMBByte,getFieldOffset(SMBMemoryDevice, memoryType),kSMBMemoryDeviceMemoryTypeKey,
getSMBMemoryDeviceMemoryType,NULL},
{kSMBTypeMemoryDevice,kSMBWord,getFieldOffset(SMBMemoryDevice, memorySpeed),kSMBMemoryDeviceMemorySpeedKey,
getSMBMemoryDeviceMemorySpeed,NULL},
{kSMBTypeMemoryDevice,kSMBString,getFieldOffset(SMBMemoryDevice, manufacturer),kSMBMemoryDeviceManufacturerKey,
getSMBMemoryDeviceManufacturer,NULL},
{kSMBTypeMemoryDevice,kSMBString,getFieldOffset(SMBMemoryDevice, serialNumber),kSMBMemoryDeviceSerialNumberKey,
getSMBMemoryDeviceSerialNumber,NULL},
{kSMBTypeMemoryDevice,kSMBString,getFieldOffset(SMBMemoryDevice, assetTag),NULL,NULL,NULL},
{kSMBTypeMemoryDevice,kSMBString,getFieldOffset(SMBMemoryDevice, partNumber),kSMBMemoryDevicePartNumberKey,
getSMBMemoryDevicePartNumber,NULL},
//-------------------------------------------------------------------------------------------------------------------------
// Apple Specific
//-------------------------------------------------------------------------------------------------------------------------
{kSMBTypeOemProcessorType,kSMBWord,getFieldOffset(SMBOemProcessorType, ProcessorType),kSMBOemProcessorTypeKey,
getSMBOemProcessorType,NULL},
{kSMBTypeOemProcessorBusSpeed,kSMBWord,getFieldOffset(SMBOemProcessorBusSpeed, ProcessorBusSpeed),kSMBOemProcessorBusSpeedKey,
getSMBOemProcessorBusSpeed,NULL}
};
static void setupNewSMBIOSTable(SMBEntryPoint *eps, SMBStructPtrs *structPtr);
char *getDefaultSMBproductName(void)
const char *getDefaultSMBproductName(void)
{
setDefaultSMBData();
return defaultSystemInfo.productName;
}
char *getDefaultSMBBoardProduct(void)
const char *getDefaultSMBBoardProduct(void)
{
setDefaultSMBData();
return defaultBaseBoard.product;
}
/* Rewrite this function */
const char* sm_search_str(const SMStrEntryPair*sm_defaults, const char * key)
{
int i;
for (i=0; sm_defaults[i].key[0]; i++) {
if (!strcmp (sm_defaults[i].key, key)) {
return sm_defaults[i].value;
}
}
// Shouldn't happen
printf ("Error: no default for %s known\n", key);
sleep (2);
return "";
}
const char* sm_get_random_productNumber()
{
static char str[4] = {0x00,0x00,0x00,0x00};
if(str[0] == 0)
{
// Get randomized characters
int rand_sn1 ;
int rand_sn2 ;
int rand_sn3 ;
struct ran_obj* random_serial_obj = random_init(0,35);
rand_sn1 = random(random_serial_obj);
rand_sn2 = random(random_serial_obj);
rand_sn3 = random(random_serial_obj);
random_free(random_serial_obj);
// Append all charaters to the string
char tmp[2];
bzero(tmp,sizeof(tmp));
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn1]);
strcpy (str, tmp);
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn2]);
strcat (str, tmp);
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn3]);
strcat (str, tmp);
DBG ("fake_productNumber: %s\n",str);
}
return str;
}
const char* sm_get_random_week()
{
static char str[4] = {0x00,0x00,0x00,0x00};
if(str[0] == 0)
{
// Get randomized characters
int rand_week ;
struct ran_obj* random_week_obj = random_init(0,47)/* random_init(1,48) */;
rand_week = random(random_week_obj);
random_free(random_week_obj);
// Append all charaters to the string
char tmp[3];
bzero(tmp,sizeof(tmp));
if (rand_week < 10) {
sprintf(tmp,"0%d",rand_week);
strcpy (str, tmp);
} else if (rand_week < 100) { // avoid overflow in case random return a number >= 100
sprintf(tmp,"%d",rand_week);
strcpy (str, tmp);
}
DBG ("fake_week: %s\n",str);
}
return str;
}
const char* sm_get_random_year()
{
static char str[2] = {0x00,0x00};
if(str[0] == 0)
{
// Get randomized characters
int rand_year ;
struct ran_obj* random_year_obj = random_init(0,9);
rand_year = random(random_year_obj);
random_free(random_year_obj);
// Append all charaters to the string
char tmp[2];
bzero(tmp,sizeof(tmp));
if (rand_year < 10) {
sprintf(tmp,"%d",rand_year);
strcpy (str, tmp);
}
DBG ("fake_year: %s\n",str);
}
return str;
}
const char* sm_get_random_country()
{
static char str[3] = {0x00,0x00,0x00};
if(str[0] == 0)
{
// Get randomized characters
int rand_country ;
struct ran_obj* random_country_obj = random_init(0,(sizeof(sm_country_list) / sizeof(sm_country_list[0]))-1);
rand_country = random(random_country_obj);
random_free(random_country_obj);
strcpy (str, sm_country_list[rand_country].code);
DBG ("fake_country: %s (%s)\n",str,sm_country_list[rand_country].info);
}
return str;
}
static void setDefaultSMBData(void)
{
static bool setDefSMB = true;
if (setDefSMB) {
if (Platform->CPU.isServer == true) {
defaultBIOSInfo.version= kDefaultXserveBIOSVersion;
defaultSystemInfo.productName= kDefaultXserve;
defaultBIOSInfo.releaseDate= kDefaulXserveBIOSReleaseDate;
defaultSystemInfo.family= kDefaultXserveFamily;
}
else if (Platform->CPU.isMobile == true)
{
if (Platform->CPU.NoCores > 1)
{
defaultBIOSInfo.version= kDefaultMacBookProBIOSVersion;
defaultSystemInfo.productName= kDefaultMacBookPro;
defaultSystemInfo.family= kDefaultMacBookProFamily;
}
else
{
defaultBIOSInfo.version= kDefaultMacBookBIOSVersion;
defaultSystemInfo.productName= kDefaultMacBook;
defaultSystemInfo.family= kDefaultMacBookFamily;
}
}
else
{
switch (Platform->CPU.NoCores)
{
case 1:
defaultBIOSInfo.version= kDefaultMacminiBIOSVersion;
defaultSystemInfo.productName= kDefaultMacmini;
defaultSystemInfo.family= kDefaultMacminiFamily;
break;
case 2:
defaultBIOSInfo.version= kDefaultiMacBIOSVersion;
defaultSystemInfo.productName= kDefaultiMac;
defaultSystemInfo.family= kDefaultiMacFamily;
break;
default:
{
switch (Platform->CPU.Family)
{
case 0x06:
{
switch (Platform->CPU.Model)
{
case CPUID_MODEL_FIELDS:// Intel Core i5, i7 LGA1156 (45nm)
case CPUID_MODEL_DALES:// Intel Core i5, i7 LGA1156 (45nm) ???
case CPUID_MODEL_DALES_32NM:// Intel Core i3, i5, i7 LGA1156 (32nm) (Clarkdale, Arrandale)
case 0x19:// Intel Core i5 650 @3.20 Ghz
defaultBIOSInfo.version= kDefaultiMacNehalemBIOSVersion;
defaultSystemInfo.productName= kDefaultiMacNehalem;
defaultSystemInfo.family= kDefaultiMacFamily;
break;
case CPUID_MODEL_SANDYBRIDGE:
case CPUID_MODEL_JAKETOWN: // Until Apple release a MacPro6,1 ??
defaultBIOSInfo.version= kDefaultiMacSandyBIOSVersion;
defaultSystemInfo.productName= kDefaultiMacSandy;
defaultSystemInfo.family= kDefaultiMacFamily;
break;
case CPUID_MODEL_NEHALEM:
case CPUID_MODEL_NEHALEM_EX:
defaultBIOSInfo.version= kDefaultMacProNehalemBIOSVersion;
defaultSystemInfo.productName= kDefaultMacProNehalem;
defaultSystemInfo.family= kDefaultMacProFamily;
break;
case CPUID_MODEL_WESTMERE:
case CPUID_MODEL_WESTMERE_EX:
defaultBIOSInfo.version= kDefaultMacProWestmereBIOSVersion;
defaultBIOSInfo.releaseDate= kDefaulMacProWestmereBIOSReleaseDate;
defaultSystemInfo.productName= kDefaultMacProWestmere;
defaultSystemInfo.family= kDefaultMacProFamily;
break;
default:
defaultBIOSInfo.version= kDefaultMacProBIOSVersion;
defaultSystemInfo.productName= kDefaultMacPro;
defaultSystemInfo.family= kDefaultMacProFamily;
break;
}
break;
}
default:
defaultBIOSInfo.version= kDefaultMacProBIOSVersion;
defaultSystemInfo.productName= kDefaultMacPro;
defaultSystemInfo.family= kDefaultMacProFamily;
break;
}
break;
}
}
}
const SMStrEntryPair*sm_defaults;
const SMStrEntryPair*sm_chosen;
if (Platform->CPU.isServer == true)
{
sm_defaults=sm_xserve_defaults;
} else if (Platform->CPU.isMobile == true) {
if (Platform->CPU.NoCores > 1) {
sm_defaults=sm_macbookpro_defaults;
} else {
sm_defaults=sm_macbook_defaults;
}
} else {
switch (Platform->CPU.NoCores)
{
case 1:
sm_defaults=sm_macmini_defaults;
break;
case 2:
sm_defaults=sm_imac_defaults;
break;
default:
{
switch (Platform->CPU.Family)
{
case 0x06:
{
switch (Platform->CPU.Model)
{
case CPUID_MODEL_FIELDS: // Intel Core i5, i7 LGA1156 (45nm)
case CPUID_MODEL_DALES: // Intel Core i5, i7 LGA1156 (45nm) ???
case CPUID_MODEL_DALES_32NM: // Intel Core i3, i5, i7 LGA1156 (32nm) (Clarkdale, Arrandale)
case 0x19: // Intel Core i5 650 @3.20 Ghz
sm_defaults=sm_imac_core_defaults;
break;
case CPUID_MODEL_SANDYBRIDGE:
case CPUID_MODEL_JAKETOWN:
sm_defaults=sm_imac_sandy_defaults;
break;
case CPUID_MODEL_NEHALEM:
case CPUID_MODEL_NEHALEM_EX:
sm_defaults=sm_macpro_core_defaults;
break;
case CPUID_MODEL_WESTMERE:
case CPUID_MODEL_WESTMERE_EX:
sm_defaults=sm_macpro_westmere_defaults;
break;
default:
sm_defaults=sm_macpro_defaults;
break;
}
break;
}
default:
sm_defaults=sm_macpro_defaults;
break;
}
break;
}
}
}
{
const char*str;
intsize;
if (getValueForKey("SMproductname", &str, &size, &bootInfo->smbiosConfig))
{
if (strstr (str, "MacPro5"))
{
sm_chosen = sm_macpro_westmere_defaults ;
}
else if (strstr (str, "MacPro4"))
{
sm_chosen = sm_macpro_core_defaults ;
}
else if (strstr (str, "MacPro"))
{
sm_chosen = sm_macpro_defaults ;
}
else if (strstr (str,"MacBookPro"))
{
sm_chosen = sm_macbookpro_defaults ;
}
else if (strstr (str, "MacBook"))
{
sm_chosen = sm_macbook_defaults ;
}
else if (!strcmp ("iMac12,1", str))
{
sm_chosen = sm_imac_sandy_defaults ;
}
else if (!strcmp ("iMac11,1", str))
{
sm_chosen = sm_imac_core_defaults ;
}
else if (strstr (str, "iMac"))
{
sm_chosen = sm_imac_defaults ;
}
else if (strstr (str, "Macmini"))
{
sm_chosen = sm_macmini_defaults ;
}
else if (strstr (str, "Xserve"))
{
sm_chosen = sm_xserve_defaults ;
}
else
{
sm_chosen = sm_defaults ;
}
}
else
sm_chosen = sm_defaults;
}
bzero (fake_serial,sizeof(fake_serial));
bool randomSerial = false;
getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig) ;
if ( randomSerial ) // useless
strcat (fake_serial,sm_get_random_country());
else
strcpy (fake_serial,sm_search_str(sm_chosen, "SMserialProductCountry"));
if ( randomSerial ) // useless
strcat (fake_serial,sm_get_random_year());
else
strcat (fake_serial,sm_search_str(sm_chosen, "SMserialYear"));
if ( randomSerial ) // useless
strcat (fake_serial,sm_get_random_week());
else
strcat (fake_serial,sm_search_str(sm_chosen, "SMserialWeek"));
if ( randomSerial )
strcat (fake_serial,sm_get_random_productNumber());
else
strcat (fake_serial,sm_search_str(sm_chosen, "SMserialProductNumber"));
strcat (fake_serial,sm_search_str(sm_chosen, "SMserialModel"));
if ( randomSerial )
msglog ("fake_serial: %s\n",fake_serial);
defaultBIOSInfo.version= sm_search_str(sm_chosen, "SMbiosversion");
defaultBIOSInfo.releaseDate= sm_search_str(sm_chosen, "SMbiosdate");
defaultBIOSInfo.vendor= sm_search_str(sm_chosen, "SMbiosvendor");
if (!defaultBIOSInfo.vendor)
defaultBIOSInfo.vendor= kDefaultVendorManufacturer;
if (!defaultBIOSInfo.releaseDate)
defaultBIOSInfo.releaseDate= kDefaultBIOSReleaseDate;
defaultSystemInfo.productName= sm_search_str(sm_chosen, "SMproductname");
defaultSystemInfo.family= sm_search_str(sm_chosen, "SMfamily");
defaultSystemInfo.manufacturer= sm_search_str(sm_chosen, "SMboardmanufacter");
defaultSystemInfo.version= sm_search_str(sm_chosen, "SMsystemversion");
defaultSystemInfo.serialNumber= fake_serial;
if (!defaultSystemInfo.manufacturer)
defaultSystemInfo.manufacturer= kDefaultVendorManufacturer;
if (!defaultSystemInfo.version)
defaultSystemInfo.version= kDefaultSystemVersion;
if (!defaultSystemInfo.serialNumber)
defaultSystemInfo.serialNumber= kDefaultSerialNumber;
if (!defaultBaseBoard.manufacturer)
defaultBaseBoard.manufacturer= kDefaultVendorManufacturer;
if (!defaultBaseBoard.product)
defaultBaseBoard.product= kDefaultBoardProduct;
defaultBaseBoard.manufacturer= sm_search_str(sm_chosen, "SMboardmanufacter");
defaultBaseBoard.product= sm_search_str(sm_chosen, "SMboardproduct");
setDefSMB = false;
}
}
static int current = -1;
int len;
char key[24];
if (current != structHeader->handle)
{
idx++;
current = structHeader->handle;
}
sprintf(key, "%s%d", keyString, idx);
if (value)
{
if (getIntForKey(key, (int *)&(value->dword), SMBPlist))
return false;
}
char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field)
const char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field)
{
uint8_t *stringPtr = (uint8_t *)structHeader + structHeader->length;
if (!field)
{
//return (char *)0;
return NULL;
}
for (field--; field != 0 && strlen((char *)stringPtr) > 0;
field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1));
field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1));
return (char *)stringPtr;
}
static void setSMBStringForField(SMBStructHeader *structHeader, const char *string, uint8_t *field)
{
int strSize;
if (!field)
{
return;
}
if (!string)
while ((strSize != 0) && (string[strSize - 1] == ' '))
strSize--;
if (strSize == 0)
{
*field = 0;
}
memcpy((uint8_t *)structHeader + structHeader->length + stringsSize, string, strSize);
*field = stringIndex;
stringIndex++;
switch (SMBSetters[idx].valueType)
{
case kSMBString:
{
bool randomSerial = false;
getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig);
if (SMBSetters[idx].keyString)
{
if (getValueForKey(SMBSetters[idx].keyString, &string, &len, SMBPlist))
if ((SMBSetters[idx].defaultValue) && *(SMBSetters[idx].defaultValue) && randomSerial && (!strcmp ("SMserial", SMBSetters[idx].keyString)))
{
string = *(SMBSetters[idx].defaultValue);
break;
}
else if (getValueForKey(SMBSetters[idx].keyString, &string, &len, SMBPlist))
break;
else
if (structPtr->orig->type == kSMBTypeMemoryDevice)// MemoryDevice only
}
string = getSMBStringForField(structPtr->orig, *(uint8_t *)value);
break;
}
case kSMBByte:
case kSMBWord:
case kSMBDWord:
if (SMBSetters[idx].valueType == kSMBString && string)
setSMBStringForField(structPtr->new, string, &value->byte);
return true;
}
//-------------------------------------------------------------------------------------------------------------------------
p->header.type= kSMBTypeOemProcessorType;
p->header.length= sizeof(SMBOemProcessorType);
p->header.handle= handle++;
setSMBValue(structPtr, numOfSetters - 2 , (returnType *)&(p->ProcessorType));
structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemProcessorType) + 2);
tableLength += sizeof(SMBOemProcessorType) + 2;
structureCount++;
static void addSMBOemProcessorBusSpeed(SMBStructPtrs *structPtr)
{
SMBOemProcessorBusSpeed *p = (SMBOemProcessorBusSpeed *)structPtr->new;
switch (Platform->CPU.Family)
{
case 0x06:
p->header.type= kSMBTypeOemProcessorBusSpeed;
p->header.length= sizeof(SMBOemProcessorBusSpeed);
p->header.handle= handle++;
setSMBValue(structPtr, numOfSetters -1, (returnType *)&(p->ProcessorBusSpeed));
structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemProcessorBusSpeed) + 2);
tableLength += sizeof(SMBOemProcessorBusSpeed) + 2;
structureCount++;
structPtr->new->type= kSMBTypeEndOfTable;
structPtr->new->length= sizeof(SMBStructHeader);
structPtr->new->handle= handle++;
structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBStructHeader) + 2);
tableLength += sizeof(SMBStructHeader) + 2;
structureCount++;
static void setSMBStruct(SMBStructPtrs *structPtr)
{
bool setterFound = false;
uint8_t *ptr;
SMBWord structSize;
int i;
stringIndex = 1;
stringsSize = 0;
if (handle < structPtr->orig->handle)
handle = structPtr->orig->handle;
memcpy((void *)structPtr->new, structPtr->orig, structPtr->orig->length);
for (i = 0; i < numOfSetters; i++)
/*if (structPtr->orig->type == SMBSetters[i].type)
{
if (SMBSetters[i].fieldOffset > structPtr->orig->length)
continue;*/
/*if (structPtr->orig->type == SMBSetters[i].type)
{
if (SMBSetters[i].fieldOffset > structPtr->orig->length)
continue;*/
if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structPtr->orig->length))
{
setterFound = true;
setSMBValue(structPtr, i, (returnType *)((uint8_t *)structPtr->new + SMBSetters[i].fieldOffset));
}
if (setterFound)
{
ptr = (uint8_t *)structPtr->new + structPtr->orig->length;
for (; ((uint16_t *)ptr)[0] != 0; ptr++);
if (((uint16_t *)ptr)[0] == 0)
ptr += 2;
structSize = ptr - (uint8_t *)structPtr->new;
}
else
{
ptr = (uint8_t *)structPtr->orig + structPtr->orig->length;
for (; ((uint16_t *)ptr)[0] != 0; ptr++);
if (((uint16_t *)ptr)[0] == 0)
ptr += 2;
structSize = ptr - (uint8_t *)structPtr->orig;
memcpy((void *)structPtr->new, structPtr->orig, structSize);
}
structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + structSize);
tableLength += structSize;
if (structSize > maxStructSize)
maxStructSize = structSize;
structureCount++;
}
static void setupNewSMBIOSTable(SMBEntryPoint *eps, SMBStructPtrs *structPtr)
{
uint8_t *ptr = (uint8_t *)eps->dmi.tableAddress;
structPtr->orig = (SMBStructHeader *)ptr;
for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structPtr->orig + sizeof(SMBStructHeader)));)
{
switch (structPtr->orig->type)
{
/* Skip all Apple Specific Structures */
/* Skip all Apple Specific Structures */
case kSMBTypeFirmwareVolume:
case kSMBTypeMemorySPD:
case kSMBTypeOemProcessorType:
/* And this one too, to be added at the end */
case kSMBTypeEndOfTable:
break;
default:
{
/* Add */
break;
}
}
ptr = (uint8_t *)((uint32_t)structPtr->orig + structPtr->orig->length);
for (; ((uint16_t *)ptr)[0] != 0; ptr++);
if (((uint16_t *)ptr)[0] == 0)
ptr += 2;
structPtr->orig = (SMBStructHeader *)ptr;
}
addSMBFirmwareVolume(structPtr);
addSMBMemorySPD(structPtr);
addSMBOemProcessorType(structPtr);
addSMBOemProcessorBusSpeed(structPtr);
addSMBEndOfTable(structPtr);
}
SMBEntryPoint * setupSMBIOSTable(SMBEntryPoint *origeps)
{
SMBStructPtrs *structPtr;
//uint8_t *buffer;
uint8_t *buffer;
bool setSMB = true;
if (!origeps)
return NULL;
structPtr = (SMBStructPtrs *)malloc(sizeof(SMBStructPtrs));
if (!structPtr)
return NULL;
/*
buffer = malloc(SMB_ALLOC_SIZE);
if (!buffer)
return NULL;*/
uint8_t buffer[SMB_ALLOC_SIZE]; // put the buffer in the stack fix some problem with xcode4, but all data seems to be corrupted
return NULL;
bzero(buffer, SMB_ALLOC_SIZE);
structPtr->new = (SMBStructHeader *)buffer;
getBoolForKey(kSMBIOSdefaults, &setSMB, &bootInfo->bootConfig);
if (setSMB)
setDefaultSMBData();
setupNewSMBIOSTable(origeps, structPtr);
SMBEntryPoint *neweps = (SMBEntryPoint *)AllocateKernelMemory(sizeof(SMBEntryPoint));
if (!neweps)
return NULL;
bzero(neweps, sizeof(SMBEntryPoint));
neweps->anchor[0]= '_';
neweps->anchor[1]= 'S';
neweps->anchor[2]= 'M';
neweps->minorVersion= 4;
neweps->maxStructureSize= maxStructSize;
neweps->entryPointRevision= 0;
neweps->dmi.anchor[0]= '_';
neweps->dmi.anchor[1]= 'D';
neweps->dmi.anchor[2]= 'M';
neweps->dmi.tableAddress= AllocateKernelMemory(tableLength);
neweps->dmi.structureCount= structureCount;
neweps->dmi.bcdRevision= 0x24;
if (!neweps->dmi.tableAddress)
return NULL;
memcpy((void *)neweps->dmi.tableAddress, buffer, tableLength);
neweps->dmi.checksum= 0;
neweps->dmi.checksum= 0x100 - checksum8(&neweps->dmi, sizeof(DMIEntryPoint));
neweps->checksum= 0;
neweps->checksum= 0x100 - checksum8(neweps, sizeof(SMBEntryPoint));
//free(buffer);
decodeSMBIOSTable(neweps);
{
uint8_t *structPtr = (uint8_t *)eps->dmi.tableAddress;
SMBStructHeader *structHeader = (SMBStructHeader *)structPtr;
int dimmnbr = 0;
Platform->DMI.MaxMemorySlots= 0;
Platform->DMI.CntMemorySlots= 0;
Platform->DMI.MemoryModules= 0;
for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structHeader + sizeof(SMBStructHeader)));)
{
switch (structHeader->type)
case kSMBTypeSystemInformation:
Platform->UUID = ((SMBSystemInformation *)structHeader)->uuid;
break;
case kSMBTypePhysicalMemoryArray:
Platform->DMI.MaxMemorySlots += ((SMBPhysicalMemoryArray *)structHeader)->numMemoryDevices;
break;
case kSMBTypeMemoryDevice:
Platform->DMI.CntMemorySlots++;
if (((SMBMemoryDevice *)structHeader)->memorySize != 0)
default:
break;
}
structPtr = (uint8_t *)((uint32_t)structHeader + structHeader->length);
for (; ((uint16_t *)structPtr)[0] != 0; structPtr++);
if (((uint16_t *)structPtr)[0] == 0)
structPtr += 2;
structHeader = (SMBStructHeader *)structPtr;
}
}
branches/cparm/i386/modules/SMBiosGetters/mysmbios.h
2828
2929
3030
31
32
3133
3234
3335
......
358360
359361
360362
361
362
363
363
364
365
364366
365367
#define kSMBIOSdefaults"SMBIOSdefaults"
#define kSMBIOSRandomSerial"randomSerial"
extern uint64_t smbios_p;
typedef struct SMBAnchor
extern void readSMBIOSInfo(SMBEntryPoint *eps);
extern SMBEntryPoint * setupSMBIOSTable(SMBEntryPoint *origeps);
extern void decodeSMBIOSTable(SMBEntryPoint *eps);
extern char *getDefaultSMBproductName(void);
extern char *getDefaultSMBBoardProduct(void);
extern char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field);
extern const char *getDefaultSMBproductName(void);
extern const char *getDefaultSMBBoardProduct(void);
extern const char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field);
#endif /* !__LIBSAIO_MYSMBIOS_H */
branches/cparm/i386/modules/SMBiosGetters/SMBiosGetters.c
4040
4141
4242
43
43
4444
4545
4646
......
5454
5555
5656
57
57
5858
5959
6060
if (getValueForKey("SMproductname", &val, &len, &bootInfo->smbiosConfig)) {
gPlatformName = (char *)val;
} else {
gPlatformName = getDefaultSMBproductName();
gPlatformName = (char *)getDefaultSMBproductName();
}
}
if (getValueForKey("SMboardproduct", &val, &len, &bootInfo->smbiosConfig)) {
gboardproduct = (char *)val;
} else {
gboardproduct = getDefaultSMBBoardProduct();
gboardproduct = (char *)getDefaultSMBBoardProduct();
}
}
branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c
197197
198198
199199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
200220
201221
202222
......
425445
426446
427447
428
429
430
431
432
448
449
450
451
452
453
454
455
433456
434457
435458
......
451474
452475
453476
454
477
455478
479
480
481
482
456483
457484
458485
{ "",""}
};
// defaults for a Mac Pro 5,1 Westmere
static const SMStrEntryPair const sm_macpro_westmere_defaults[]={
{"SMbiosvendor", "Apple Computer, Inc."},
{"SMbiosversion", "MP51.88Z.007F.B00.1008031144"},
{"SMbiosdate", "08/03/2010"},
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "MacPro5,1"},
{"SMsystemversion", "0.0"},
{"SMserial", "YM0330U7EUH"},
{"SMserialProductCountry","YM" },
{"SMserialYear", "0" },
{"SMserialWeek", "33" },
{"SMserialProductNumber","0U7" },
{"SMserialModel","EUH" },
{"SMfamily", "MacPro"},
{"SMboardmanufacter", "Apple Computer, Inc."},
{"SMboardproduct", "Mac-F221BEC8"},
{ "",""}
};
// default for a Xserve
static const SMStrEntryPair const sm_xserve_defaults[]={
{"SMbiosvendor", "Apple Inc."},
break;
case CPUID_MODEL_NEHALEM:
case CPUID_MODEL_NEHALEM_EX:
case CPUID_MODEL_WESTMERE:
case CPUID_MODEL_WESTMERE_EX:
sm_defaults=sm_macpro_core_defaults;
break;
case CPUID_MODEL_NEHALEM_EX:
sm_defaults=sm_macpro_core_defaults;
break;
case CPUID_MODEL_WESTMERE:
case CPUID_MODEL_WESTMERE_EX:
sm_defaults=sm_macpro_westmere_defaults;
break;
default:
sm_defaults=sm_macpro_defaults;
break;
if (getValueForKey("SMproductname", &str, &size, &bootInfo->smbiosConfig))
{
if (strstr (str, "MacPro4"))
if (strstr (str, "MacPro5"))
{
sm_chosen = sm_macpro_westmere_defaults ;
}
else if (strstr (str, "MacPro4"))
{
sm_chosen = sm_macpro_core_defaults ;
}
else if (strstr (str, "MacPro"))

Archive Download the corresponding diff file

Revision: 1659