Chameleon

Chameleon Commit Details

Date:2015-01-21 01:42:38 (5 years 4 months ago)
Author:ErmaC
Commit:2539
Parents: 2538
Message:Typo, indenting and whitespace
Changes:
M/trunk/i386/libsaio/acpi_patcher.c
M/trunk/i386/libsaio/console.c
M/trunk/i386/libsaio/msdos.c
M/trunk/i386/boot2/bmdecompress.c
M/trunk/i386/libsaio/spd.c
M/trunk/i386/libsaio/state_generator.c
M/trunk/i386/libsaio/disk.c
M/trunk/i386/libsaio/ntfs.c
M/trunk/i386/boot2/boot.h
M/trunk/i386/libsaio/device_inject.c
M/trunk/i386/libsaio/pci.c
M/trunk/i386/libsaio/smbios.c
M/trunk/i386/boot2/options.c
M/trunk/i386/libsaio/device_tree.c
M/trunk/i386/libsaio/pci_root.c

File differences

trunk/i386/libsaio/console.c
177177
178178
179179
180
180181
181182
182183
int printf(const char * fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
trunk/i386/libsaio/device_tree.c
256256
257257
258258
259
259260
260261
261262
for (prop = allocedProperties; prop != NULL; prop = prop->next)
{
free((void *)(prop->name));
free(prop->value);
}
trunk/i386/libsaio/acpi_patcher.c
157157
158158
159159
160
161
160
161
162162
163163
164164
return NULL;
}
uint8_t acpi_cpu_count = 0;
uint32_t acpi_cpu_p_blk = 0;
uint8_t acpi_cpu_count= 0;
uint32_t acpi_cpu_p_blk= 0;
char *acpi_cpu_name[32];
void get_acpi_cpu_names(unsigned char *dsdt, uint32_t length)
trunk/i386/libsaio/spd.c
6969
7070
7171
72
73
74
75
76
77
78
79
80
81
82
83
84
7285
7386
7487
......
111124
112125
113126
114
115
116
117
118
119
120
121
122
123
124
125
126
127127
128128
129129
......
134134
135135
136136
137
138
137
138
139139
140140
141141
......
143143
144144
145145
146
147
146
147
148148
149149
150
151
150
151
152
153
152154
153155
154156
155
156
157
157
158
159
160
161
162
163
158164
159165
160166
161167
162168
163
164
169
170
171
172
165173
166174
167
168
175
176
177
178
169179
170180
171181
......
180190
181191
182192
183
184
185
186
187
188
189
190
191
192
193
194
195
196
193
194
195
196
197
197198
198199
199200
......
207208
208209
209210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
210226
211227
212228
......
216232
217233
218234
219
235
220236
221
237
222238
223
239
224240
225
241
226242
227
228
229
243
230244
245
246
247
248
231249
232250
233251
234252
235253
236
254
237255
238256
239257
240258
241
259
260
242261
243262
244
263
245264
246265
247266
......
249268
250269
251270
252
253
271
272
273
254274
255
275
276
256277
257278
258
279
280
281
259282
260283
261284
......
265288
266289
267290
268
269291
270292
271293
......
281303
282304
283305
284
285
286306
307
308
309
287310
288311
289312
......
296319
297320
298321
299
300
322
323
301324
302325
303326
......
308331
309332
310333
311
334
335
312336
313337
314338
315
316
317
339
340
341
318342
319343
320344
......
330354
331355
332356
357
358
359
360
361
333362
334363
335364
336365
337
366
367
338368
339369
340370
......
342372
343373
344374
345
346
375
376
377
347378
348379
349380
350381
351
382
383
352384
353385
354386
355
387
388
356389
357390
358391
......
362395
363396
364397
365
366
367
368
369
370
371
372
373
374
398
399
400
401
402
403
404
405
406
407
375408
376409
377410
378411
379
380
412
413
381414
382415
383416
......
423456
424457
425458
426
459
460
427461
428462
429463
430464
431465
432466
433
434
467
468
469
470
435471
436472
437473
#define SMBHSTDAT 5
#define SBMBLKDAT 7
int spd_indexes[] = {
SPD_MEMORY_TYPE,
SPD_DDR3_MEMORY_BANK,
SPD_DDR3_MEMORY_CODE,
SPD_NUM_ROWS,
SPD_NUM_COLUMNS,
SPD_NUM_DIMM_BANKS,
SPD_NUM_BANKS_PER_SDRAM,
4,7,8,9,12,64, /* TODO: give names to these values */
95,96,97,98, 122,123,124,125 /* UIS */
};
#define SPD_INDEXES_SIZE (sizeof(spd_indexes) / sizeof(int))
/** Read one byte from the intel i2c, used for reading SPD on intel chipsets only. */
unsigned char smb_read_byte_intel(uint32_t base, uint8_t adr, uint8_t cmd)
/* SPD i2c read optimization: prefetch only what we need, read non prefetcheable bytes on the fly */
#define READ_SPD(spd, base, slot, x) spd[x] = smb_read_byte_intel(base, 0x50 + slot, x)
int spd_indexes[] = {
SPD_MEMORY_TYPE,
SPD_DDR3_MEMORY_BANK,
SPD_DDR3_MEMORY_CODE,
SPD_NUM_ROWS,
SPD_NUM_COLUMNS,
SPD_NUM_DIMM_BANKS,
SPD_NUM_BANKS_PER_SDRAM,
4,7,8,9,12,64, /* TODO: give names to these values */
95,96,97,98, 122,123,124,125 /* UIS */
};
#define SPD_INDEXES_SIZE (sizeof(spd_indexes) / sizeof(int))
/** Read from spd *used* values only*/
static void init_spd(char * spd, uint32_t base, int slot)
{
}
}
/** Get Vendor Name from spd, 2 cases handled DDR3 and DDR2,
have different formats, always return a valid ptr.*/
// Get Vendor Name from spd, 2 cases handled DDR3 and DDR2,
// have different formats, always return a valid ptr.*/
const char * getVendorName(RamSlotInfo_t* slot, uint32_t base, int slot_num)
{
uint8_t bank = 0;
int i = 0;
uint8_t * spd = (uint8_t *) slot->spd;
if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3)
{ // DDR3
if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) // DDR3
{
bank = (spd[SPD_DDR3_MEMORY_BANK] & 0x07f); // constructors like Patriot use b7=1
code = spd[SPD_DDR3_MEMORY_CODE];
for (i=0; i < VEN_MAP_SIZE; i++) {
if (bank==vendorMap[i].bank && code==vendorMap[i].code) {
for (i=0; i < VEN_MAP_SIZE; i++)
{
if (bank==vendorMap[i].bank && code==vendorMap[i].code)
{
return vendorMap[i].name;
}
}
} else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) {
if(spd[64]==0x7f) {
for (i=64; i<72 && spd[i]==0x7f;i++) {
}
else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR)
{
if(spd[64]==0x7f)
{
for (i=64; i<72 && spd[i]==0x7f;i++)
{
bank++;
READ_SPD(spd, base, slot_num, (uint8_t)(i+1)); // prefetch next spd byte to read for next loop
}
READ_SPD(spd, base, slot_num,(uint8_t)i);
code = spd[i];
} else {
code = spd[64];
}
else
{
code = spd[64];
bank = 0;
}
for (i=0; i < VEN_MAP_SIZE; i++) {
if (bank==vendorMap[i].bank && code==vendorMap[i].code) {
for (i=0; i < VEN_MAP_SIZE; i++)
{
if (bank==vendorMap[i].bank && code==vendorMap[i].code)
{
return vendorMap[i].name;
}
}
/* Get Default Memory Module Speed (no overclocking handled) */
int getDDRspeedMhz(const char * spd)
{
if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) {
switch(spd[12]) {
case 0x0f:
return 1066;
case 0x0c:
return 1333;
case 0x0a:
return 1600;
case 0x14:
default:
return 800;
}
} else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) {
switch(spd[9]) {
if ((spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR2) || (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR))
{
switch(spd[9])
{
case 0x50:
return 400;
case 0x3d:
return 1066;
}
}
else if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR3)
{
switch(spd[12])
{
case 0x0f:
return 1066;
case 0x0c:
return 1333;
case 0x0a:
return 1600;
case 0x14:
default:
return 800;
}
}
return 800; // default freq for unknown types
}
/* Get DDR3 or DDR2 serial number, 0 most of the times, always return a valid ptr */
const char *getDDRSerial(const char* spd)
{
static char asciiSerial[16];
static char asciiSerial[17];
if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) // DDR3
if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR3) // DDR3
{
snprintf(asciiSerial, sizeof(asciiSerial), "%X%X%X%X%X%X%X%X", SMST(122) /*& 0x7*/, SLST(122), SMST(123), SLST(123), SMST(124), SLST(124), SMST(125), SLST(125));
snprintf(asciiSerial, sizeof(asciiSerial), "%2X%2X%2X%2X%2X%2X%2X%2X", SMST(122) /*& 0x7*/, SLST(122), SMST(123), SLST(123), SMST(124), SLST(124), SMST(125), SLST(125));
}
else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) // DDR2 or DDR
else if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR) // DDR2 or DDR
{
snprintf(asciiSerial, sizeof(asciiSerial), "%X%X%X%X%X%X%X%X", SMST(95) /*& 0x7*/, SLST(95), SMST(96), SLST(96), SMST(97), SLST(97), SMST(98), SLST(98));
} else {
sprintf(asciiSerial, "000000000000000");
snprintf(asciiSerial, sizeof(asciiSerial), "%2X%2X%2X%2X%2X%2X%2X%2X", SMST(95) /*& 0x7*/, SLST(95), SMST(96), SLST(96), SMST(97), SLST(97), SMST(98), SLST(98));
}
else
{
sprintf(asciiSerial, "0000000000000000");
}
return strdup(asciiSerial);
}
/* Get DDR3 or DDR2 Part Number, always return a valid ptr */
const char * getDDRPartNum(char* spd, uint32_t base, int slot)
const char *getDDRPartNum(char *spd, uint32_t base, int slot)
{
static char asciiPartNo[32];
int i, start=0, index = 0;
if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) {
if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR3)
{
start = 128;
}
else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR)
else if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR)
{
start = 73;
}
// Check that the spd part name is zero terminated and that it is ascii:
bzero(asciiPartNo, sizeof(asciiPartNo));
char c;
for (i=start; i < start + sizeof(asciiPartNo); i++) {
READ_SPD(spd, base, slot, i); // only read once the corresponding model part (ddr3 or ddr2)
for (i = start; i < start + sizeof(asciiPartNo); i++)
{
READ_SPD(spd, base, slot, (uint8_t)i); // only read once the corresponding model part (ddr3 or ddr2)
c = spd[i];
if (isalpha(c) || isdigit(c) || ispunct(c)) {
if (isalpha(c) || isdigit(c) || ispunct(c))
{
// It seems that System Profiler likes only letters and digits...
asciiPartNo[index++] = c;
} else if (!isascii(c)) {
}
else if (!isascii(c))
{
break;
}
}
int mapping []= {0,2,1,3,4,6,5,7,8,10,9,11};
/* Read from smbus the SPD content and interpret it for detecting memory attributes */
static void read_smb_intel(pci_dt_t *smbus_dev) {
int i, speed;
mmio = pci_config_read32(smbus_dev->dev.addr, 0x10);// & ~0x0f;
base = pci_config_read16(smbus_dev->dev.addr, 0x20) & 0xFFFE;
hostc = pci_config_read8(smbus_dev->dev.addr, 0x40);
verbose("Scanning SMBus [%04x:%04x], mmio: 0x%x, ioport: 0x%x, hostc: 0x%x\n",
smbus_dev->vendor_id, smbus_dev->device_id, mmio, base, hostc);
verbose("Scanning SMBus [%04x:%04x], mmio: 0x%x, ioport: 0x%x, hostc: 0x%x\n",
smbus_dev->vendor_id, smbus_dev->device_id, mmio, base, hostc);
//Azi: no use for this!
// getBoolForKey("DumpSPD", &dump, &bootInfo->chameleonConfig);
// needed at least for laptops
spd_size = smb_read_byte_intel(base, 0x50 + i, 0);
DBG("SPD[0] (size): %d @0x%x\n", spd_size, 0x50 + i);
// Check spd is present
if (spd_size && (spd_size != 0xff)) {
if (spd_size && (spd_size != 0xff))
{
slot->spd = spdbuf;
slot->InUse = true;
//for (x = 0; x < spd_size; x++) slot->spd[x] = smb_read_byte_intel(base, 0x50 + i, x);
init_spd(slot->spd, base, i);
switch (slot->spd[SPD_MEMORY_TYPE]) {
switch (slot->spd[SPD_MEMORY_TYPE])
{
case SPD_MEMORY_TYPE_SDRAM_DDR:
slot->ModuleSize = (((1 << ((slot->spd[SPD_NUM_ROWS] & 0x0f)
+ (slot->spd[SPD_NUM_COLUMNS] & 0x0f) - 17)) *
((slot->spd[SPD_NUM_DIMM_BANKS] & 0x7) + 1) *
slot->spd[SPD_NUM_BANKS_PER_SDRAM])/3)*2;
+ (slot->spd[SPD_NUM_COLUMNS] & 0x0f) - 17)) *
((slot->spd[SPD_NUM_DIMM_BANKS] & 0x7) + 1) *
slot->spd[SPD_NUM_BANKS_PER_SDRAM])/3)*2;
break;
case SPD_MEMORY_TYPE_SDRAM_DDR2:
slot->ModuleSize = ((1 << slot->ModuleSize) * (((slot->spd[7] >> 3) & 0x1f) + 1));
break;
default:
slot->ModuleSize = 0;
break;
}
spd_type = (slot->spd[SPD_MEMORY_TYPE] < ((char) 12) ? slot->spd[SPD_MEMORY_TYPE] : 0);
slot->Type = spd_mem_to_smbios[spd_type];
if (slot->Type == UNKNOWN_MEM_TYPE) {
if (slot->Type == UNKNOWN_MEM_TYPE)
{
continue;
}
slot->PartNo = getDDRPartNum(slot->spd, base, i);
slot->SerialNo = getDDRSerial(slot->spd);
// determine spd speed
speed = getDDRspeedMhz(slot->spd);
if (slot->Frequency < speed) {
speed = (uint16_t)getDDRspeedMhz(slot->spd);
if (slot->Frequency < speed)
{
slot->Frequency = speed;
}
// pci memory controller if available, is more reliable
if (Platform.RAM.Frequency > 0) {
if (Platform.RAM.Frequency > 0)
{
uint32_t freq = (uint32_t)Platform.RAM.Frequency / 500000;
// now round off special cases
uint32_t fmod100 = freq %100;
switch(fmod100) {
switch(fmod100)
{
case 1:freq--;break;
case 32:freq++;break;
case 65:freq++; break;
slot->Frequency = freq;
}
verbose("Slot: %d Type %d %dMB (%s) %dMHz Vendor=%s\n PartNo=%s SerialNo=%s\n",
i,
(int)slot->Type,
slot->ModuleSize,
spd_memory_types[spd_type],
slot->Frequency,
slot->Vendor,
slot->PartNo,
slot->SerialNo);
slot->InUse = true;
verbose("Slot: %d Type %d %dMB (%s) %dMHz Vendor=%s\n PartNo=%s SerialNo=%s\n",
i,
(int)slot->Type,
slot->ModuleSize,
spd_memory_types[spd_type],
slot->Frequency,
slot->Vendor,
slot->PartNo,
slot->SerialNo);
slot->InUse = true;
}
// laptops sometimes show slot 0 and 2 with slot 1 empty when only 2 slots are presents so:
Platform.DMI.DIMM[i]=
(uint32_t)((i>0 && Platform.RAM.DIMM[1].InUse==false && fullBanks && Platform.DMI.CntMemorySlots == 2) ?
mapping[i] : i); // for laptops case, mapping setup would need to be more generic than this
(uint32_t)((i > 0 && Platform.RAM.DIMM[1].InUse == false && fullBanks && Platform.DMI.CntMemorySlots == 2) ? mapping[i] : i); // for laptops case, mapping setup would need to be more generic than this
slot->spd = NULL;
} // for
pci_dt_t*current = pci_dt;
int i;
while (current) {
while (current)
{
#if 0
printf("%02x:%02x.%x [%04x] [%04x:%04x] :: %s\n",
current->dev.bits.bus, current->dev.bits.dev, current->dev.bits.func,
current->class_id, current->vendor_id, current->device_id,
get_pci_dev_path(current));
#endif
for ( i = 0; i < sizeof(smbus_controllers) / sizeof(smbus_controllers[0]); i++ ) {
if (current->vendor_id == smbus_controllers[i].vendor && current->device_id == smbus_controllers[i].device) {
for ( i = 0; i < sizeof(smbus_controllers) / sizeof(smbus_controllers[0]); i++ )
{
if (current->vendor_id == smbus_controllers[i].vendor && current->device_id == smbus_controllers[i].device)
{
smbus_controllers[i].read_smb(current); // read smb
return true;
}
trunk/i386/libsaio/pci_root.c
5353
5454
5555
56
56
57
58
59
60
5761
5862
59
60
63
64
65
66
67
68
69
6170
6271
6372
64
65
73
74
75
76
77
78
79
6680
6781
6882
69
83
84
7085
7186
7287
73
88
89
7490
7591
7692
......
84100
85101
86102
87
103
88104
89105
90106
91107
92108
93
94
95
109
110
111
96112
97
113
98114
99115
100116
......
116132
117133
118134
119
135
136
137
138
120139
121140
122141
const char * dsdt_filename = NULL;
extern int search_and_get_acpi_fd(const char *, const char **);
if (rootuid < 10) return rootuid;
if (rootuid < 10)
{
return rootuid;
}
rootuid = 0;/* default uid = 0 */
if (getValueForKey(kPCIRootUID, &val, &len, &bootInfo->chameleonConfig)) {
if (isdigit(val[0])) rootuid = val[0] - '0';
if (getValueForKey(kPCIRootUID, &val, &len, &bootInfo->chameleonConfig))
{
if (isdigit(val[0]))
{
rootuid = val[0] - '0';
}
goto out;
}
/* Chameleon compatibility */
else if (getValueForKey("PciRoot", &val, &len, &bootInfo->chameleonConfig)) {
if (isdigit(val[0])) rootuid = val[0] - '0';
else if (getValueForKey("PciRoot", &val, &len, &bootInfo->chameleonConfig))
{
if (isdigit(val[0]))
{
rootuid = val[0] - '0';
}
goto out;
}
/* PCEFI compatibility */
else if (getValueForKey("-pci0", &val, &len, &bootInfo->chameleonConfig)) {
else if (getValueForKey("-pci0", &val, &len, &bootInfo->chameleonConfig))
{
rootuid = 0;
goto out;
}
else if (getValueForKey("-pci1", &val, &len, &bootInfo->chameleonConfig)) {
else if (getValueForKey("-pci1", &val, &len, &bootInfo->chameleonConfig))
{
rootuid = 1;
goto out;
}
{
sprintf(dsdt_dirSpec, "DSDT.aml");
}
int fd = search_and_get_acpi_fd(dsdt_dirSpec, &dsdt_filename);
// Check booting partition
if (fd<0)
{
verbose("No DSDT found, using 0 as uid value.\n");
rootuid = 0;
goto out;
verbose("No DSDT found, using 0 as uid value.\n");
rootuid = 0;
goto out;
}
fsize = file_size(fd);
if (!(new_dsdt = malloc(fsize)))
free(new_dsdt);
// make sure it really works:
if (rootuid == 11) rootuid=0; //usually when _UID isnt present, it means uid is zero
if (rootuid == 11)
{
rootuid=0; //usually when _UID isnt present, it means uid is zero
}
else if (rootuid < 0 || rootuid > 9)
{
printf("PciRoot uid value wasnt found, using 0, if you want it to be 1, use -PciRootUID flag");
trunk/i386/libsaio/device_inject.c
2323
2424
2525
26
27
28
29
30
26
27
28
29
30
3131
3232
3333
......
5555
5656
5757
58
58
59
5960
6061
6162
6263
63
64
65
6466
65
67
68
6669
6770
6871
......
7376
7477
7578
76
79
80
7781
7882
7983
......
8589
8690
8791
88
89
90
92
93
94
9195
92
96
97
9398
9499
95100
96101
97
102
103
98104
99105
100106
101
107
108
109
102110
103111
104112
......
110118
111119
112120
113
114
121
122
123
124
115125
116126
117127
118
128
129
119130
120
131
132
133
121134
122
135
136
137
123138
124139
125140
......
129144
130145
131146
132
147
148
133149
134
150
151
152
135153
136
154
155
156
137157
138158
139159
......
144164
145165
146166
147
167
168
148169
149170
150171
151172
152173
153174
154
155
156
157
175
176
177
178
158179
159180
160181
161182
162183
163184
164
185
186
165187
166188
167189
......
174196
175197
176198
177
178
199
200
201
202
179203
180204
181205
......
192216
193217
194218
195
219
220
196221
197222
198
199
223
224
200225
201
226
227
202228
203229
204230
205231
206
232
207233
208234
209235
210236
211237
212
238
239
213240
214241
215242
......
218245
219246
220247
221
248
249
222250
223251
224252
225253
226254
227255
228
256
257
229258
230259
231
232
260
261
262
263
264
233265
234266
235267
236268
237269
238
270
239271
240272
241273
242274
243
275
276
244277
245
278
279
280
246281
247282
248283
......
345380
346381
347382
348
349
350
383
384
385
386
387
388
351389
352390
353391
......
373411
374412
375413
376
414
415
377416
378417
379418
......
381420
382421
383422
384
385
423
424
425
426
386427
387428
388429
......
400441
401442
402443
444
403445
446
447
404448
405449
406450
407451
408452
409453
454
410455
456
411457
458
459
412460
413461
414462
......
420468
421469
422470
423
471
472
424473
425474
426475
427476
428
477
478
429479
430480
431481
432
482
483
433484
434485
435486
#define DBG(x...)msglog(x)
#endif
uint32_t devices_number= 1;
uint32_t builtin_set= 0;
DevPropString *string= 0;
uint8_t *stringdata= 0;
uint32_t stringlength= 0;
uint32_tdevices_number= 1;
uint32_tbuiltin_set= 0;
DevPropString*string= 0;
uint8_t*stringdata= 0;
uint32_tstringlength= 0;
char *efi_inject_get_devprop_string(uint32_t *len)
{
/* Use the static "device-properties" boot config key contents if available,
* otheriwse use the generated one.
*/
if (!getValueForKey(kDeviceProperties, &val, &cnt, &bootInfo->chameleonConfig) && string) {
if (!getValueForKey(kDeviceProperties, &val, &cnt, &bootInfo->chameleonConfig) && string)
{
val = (const char*)string;
cnt = strlength * 2;
}
if (cnt > 1) {
if (cnt > 1)
{
binStr = convertHexStr2Binary(val, &cnt2);
if (cnt2 > 0) {
if (cnt2 > 0)
{
DT__AddProperty(node, DEVICE_PROPERTIES_PROP, cnt2, binStr);
DBG("Adding device-properties string to DT");
}
{
string = (struct DevPropString *)malloc(sizeof(struct DevPropString));
if(string == NULL) {
if(string == NULL)
{
return NULL;
}
DevPropDevice *devprop_add_device(DevPropString *string, char *path)
{
DevPropDevice*device = NULL;
const charpciroot_string[] = "PciRoot(0x";
const charpci_device_string[] = "Pci(0x";
DevPropDevice*device= NULL;
const charpciroot_string[]= "PciRoot(0x";
const charpci_device_string[]= "Pci(0x";
if (string == NULL || path == NULL) {
if (string == NULL || path == NULL)
{
printf("ERROR null device path\n");
return NULL;
}
if (strncmp(path, pciroot_string, strlen(pciroot_string))) {
if (strncmp(path, pciroot_string, strlen(pciroot_string)))
{
printf("ERROR parsing device path\n");
return NULL;
}
if (!(device = malloc(sizeof(DevPropDevice)))) {
if (!(device = malloc(sizeof(DevPropDevice))))
{
printf("ERROR malloc failed\n");
return NULL;
}
intx, curr = 0;
charbuff[] = "00";
for (x = 0; x < strlen(path); x++) {
if (!strncmp(&path[x], pci_device_string, strlen(pci_device_string))) {
for (x = 0; x < strlen(path); x++)
{
if (!strncmp(&path[x], pci_device_string, strlen(pci_device_string)))
{
x+=strlen(pci_device_string);
curr=x;
while(path[++x] != ',');
if(x-curr == 2) {
if(x-curr == 2)
{
sprintf(buff, "%c%c", path[curr], path[curr+1]);
} else if(x-curr == 1) {
}
else if(x-curr == 1)
{
sprintf(buff, "%c", path[curr]);
} else {
}
else
{
printf("ERROR parsing device path\n");
numpaths = 0;
break;
x += 3; // 0x
curr = x;
while(path[++x] != ')');
if(x-curr == 2) {
if(x-curr == 2)
{
sprintf(buff, "%c%c", path[curr], path[curr+1]);
} else if(x-curr == 1) {
}
else if(x-curr == 1)
{
sprintf(buff, "%c", path[curr]);
} else {
}
else
{
printf("ERROR parsing device path\n");
numpaths = 0;
break;
}
}
if(!numpaths) {
if(!numpaths)
{
free(device);
return NULL;
}
device->numentries = 0x00;
device->acpi_dev_path.length = 0x0c;
device->acpi_dev_path.type = 0x02;
device->acpi_dev_path.subtype = 0x01;
device->acpi_dev_path._HID = 0xd041030a;
device->acpi_dev_path.length= 0x0c;
device->acpi_dev_path.type= 0x02;
device->acpi_dev_path.subtype= 0x01;
device->acpi_dev_path._HID= 0xd041030a;
device->num_pci_devpaths = numpaths;
device->length = 24 + (6*numpaths);
inti;
for(i = 0; i < numpaths; i++) {
for(i = 0; i < numpaths; i++)
{
device->pci_dev_path[i].length = 0x06;
device->pci_dev_path[i].type = 0x01;
device->pci_dev_path[i].subtype = 0x01;
device->string = string;
device->data = NULL;
if(!string->entries) {
if (!(string->entries = (struct DevPropDevice**) malloc(sizeof(device) * DEV_PROP_DEVICE_MAX_ENTRIES))) {
if(!string->entries)
{
if (!(string->entries = (struct DevPropDevice**) malloc(sizeof(device) * DEV_PROP_DEVICE_MAX_ENTRIES)))
{
free(device);
return NULL;
}
int devprop_add_value(DevPropDevice *device, char *nm, uint8_t *vl, uint32_t len)
{
if(!nm || !vl || !len) {
if(!nm || !vl || !len)
{
return 0;
}
uint32_t length = ((strlen(nm) * 2) + len + (2 * sizeof(uint32_t)) + 2);
uint8_t *data = (uint8_t*)malloc(length);
uint32_t length= ((strlen(nm) * 2) + len + (2 * sizeof(uint32_t)) + 2);
uint8_t *data= (uint8_t*)malloc(length);
if(!data) {
if(!data)
{
return 0;
}
memset(data, 0, length);
uint32_t off= 0;
uint32_t off = 0;
data[off+1] = ((strlen(nm) * 2) + 6) >> 8;
data[off] = ((strlen(nm) * 2) + 6) & 0x00FF;
off += 4;
uint32_t i=0, l = strlen(nm);
for(i = 0 ; i < l ; i++, off += 2) {
for(i = 0 ; i < l ; i++, off += 2)
{
data[off] = *nm++;
}
uint32_t *datalength = (uint32_t*)&data[off];
*datalength = (uint32_t)(l + 4);
off += 4;
for(i = 0 ; i < l ; i++, off++) {
for(i = 0 ; i < l ; i++, off++)
{
data[off] = *vl++;
}
uint32_t offset = device->length - (24 + (6 * device->num_pci_devpaths));
uint8_t *newdata = (uint8_t*)malloc((length + offset));
if(!newdata) {
if(!newdata)
{
return 0;
}
if(device->data) {
if(offset > 1) {
if(device->data)
{
if(offset > 1)
{
memcpy(newdata, device->data, offset);
}
}
memcpy(newdata + offset, data, length);
device->length += length;
device->string->length += length;
device->numentries++;
if(!device->data) {
if(!device->data)
{
device->data = (uint8_t*)malloc(sizeof(uint8_t));
} else {
}
else
{
free(device->data);
}
}
int i;
for(i = 0; i < string->numentries; i++) {
if(string->entries[i]) {
if(string->entries[i]->data) {
for(i = 0; i < string->numentries; i++)
{
if(string->entries[i])
{
if(string->entries[i]->data)
{
free(string->entries[i]->data);
string->entries[i]->data = NULL;
}
inti;
charbuf[3];
if (hex == NULL || bin == NULL || len <= 0 || strlen(hex) != len * 2) {
if (hex == NULL || bin == NULL || len <= 0 || strlen(hex) != len * 2)
{
printf("[ERROR] bin2hex input error\n");
return -1;
}
buf[2] = '\0';
p = (char *) hex;
for (i = 0; i < len; i++) {
if (p[0] == '\0' || p[1] == '\0' || !isxdigit(p[0]) || !isxdigit(p[1])) {
for (i = 0; i < len; i++)
{
if (p[0] == '\0' || p[1] == '\0' || !isxdigit(p[0]) || !isxdigit(p[1]))
{
printf("[ERROR] bin2hex '%s' syntax error\n", hex);
return -2;
}
int devprop_add_network_template(DevPropDevice *device, uint16_t vendor_id)
{
if(!device)
{
return 0;
}
uint8_t builtin = 0x0;
if((vendor_id != 0x168c) && (builtin_set == 0))
{
builtin_set = 1;
builtin = 0x01;
}
if(!devprop_add_value(device, "built-in", (uint8_t*)&builtin, 1))
{
return 0;
}
devices_number++;
return 1;
}
verbose("LAN Controller [%04x:%04x] :: %s\n", eth_dev->vendor_id, eth_dev->device_id, devicepath);
if(!string) {
if(!string)
{
string = devprop_create_string();
}
device = devprop_add_device(string, devicepath);
if(device) {
if(device)
{
verbose("Setting up lan keys\n");
devprop_add_network_template(device, eth_dev->vendor_id);
stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length);
if(stringdata) {
if(stringdata)
{
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
stringlength = string->length;
}
trunk/i386/libsaio/ntfs.c
3131
3232
3333
34
34
3535
3636
3737
......
4141
4242
4343
44
45
44
45
4646
47
48
49
47
48
49
5050
51
51
5252
5353
5454
......
313313
314314
315315
316
316317
317318
318319
......
329330
330331
331332
333
332334
333335
334336
335337
336338
337339
340
338341
339342
340343
......
344347
345348
346349
347
350
348351
349352
350353
351
354
352355
353356
354357
*/
#include "exfat.h"
#define BYTE_ORDER_MARK0xFEFF
#define BYTE_ORDER_MARK0xFEFF
#include "ntfs_private.h"
#define MAX_BLOCK_SIZE2048
#define MAX_CLUSTER_SIZE32768
#define LABEL_LENGTH1024
#define UNKNOWN_LABEL"Untitled NTFS"
#define LABEL_LENGTH1024
#define UNKNOWN_LABEL"Untitled NTFS"
#define FSUR_IO_FAIL -1
#define FSUR_UNRECOGNIZED -1
#define FSUR_RECOGNIZED 0
#define FSUR_IO_FAIL-1
#define FSUR_UNRECOGNIZED-1
#define FSUR_RECOGNIZED0
#define ERROR -1
#define ERROR-1
/*
* Process per-sector "fixups" that NTFS uses to detect corruption of
{
return -1;
}
bzero(buf,MAX_BLOCK_SIZE);
/*
* Read the boot sector, check signatures, and do some minimal
if ( memcmp((void*)boot->bf_sysid, NTFS_BBID, NTFS_BBIDLEN) != 0 )
{
// If not NTFS, maybe it is EXFAT
free(buf);
return EXFATGetUUID(ih, uuidStr);
}
// Check for non-null volume serial number
if( !boot->bf_volsn )
{
free(buf);
return -1;
}
return 0;
}
bool NTFSProbe(const void * buffer)
bool NTFSProbe(const void *buffer)
{
bool result = false;
const struct bootfile* part_bootfile = buffer;// NTFS boot sector structure
const struct bootfile *part_bootfile = buffer;// NTFS boot sector structure
// Looking for NTFS signature.
if (strncmp((const char *)part_bootfile->bf_sysid, NTFS_BBID, NTFS_BBIDLEN) == 0)
trunk/i386/libsaio/disk.c
154154
155155
156156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
157
158
159
160
161
162
163
164
165
166
167
168
169
171170
172
171
173172
174173
175174
176175
177
176
178177
179178
180179
......
593592
594593
595594
596
597595
598596
599597
600598
601
602599
603600
604601
605602
606
607603
608604
609605
......
15291525
15301526
15311527
1532
1528
1529
15331530
15341531
15351532
......
15371534
15381535
15391536
1540
1537
1538
15411539
15421540
15431541
......
16451643
16461644
16471645
1648
1646
1647
16491648
16501649
16511650
......
17521751
17531752
17541753
1754
17551755
17561756
17571757
......
18751875
18761876
18771877
1878
1879
1880
1881
1882
18781883
18791884
18801885
......
19071912
19081913
19091914
1910
1915
1916
19111917
19121918
19131919
......
19581964
19591965
19601966
1967
19611968
19621969
19631970
......
20462053
20472054
20482055
2056
2057
20492058
20502059
20512060
......
21082117
21092118
21102119
2120
2121
2122
2123
21112124
21122125
21132126
......
21302143
21312144
21322145
2146
2147
2148
2149
2150
21332151
21342152
21352153
static const struct NamedValue fdiskTypes[] =
{
{ FDISK_DOS12,"DOS_FAT_12" },
{ FDISK_DOS16S,"DOS_FAT_16_S" },
{ FDISK_DOS16B,"DOS_FAT_16" },
{ FDISK_NTFS,"Windows NTFS" },
{ FDISK_DOS16SLBA,"Windows FAT16" },
{ FDISK_FAT32,"Windows FAT32" },
{ FDISK_SMALLFAT32,"Windows FAT32" },
{ FDISK_LINUX,"Linux" },
{ FDISK_FREEBSD,"FreeBSD" },
{ FDISK_OPENBSD,"OpenBSD" },
{ FDISK_DOS12,"DOS_FAT_12" }, // 0x01
{ FDISK_DOS16S,"DOS_FAT_16_S" }, // 0x04
{ FDISK_DOS16B,"DOS_FAT_16" }, // 0x06
{ FDISK_NTFS,"Windows NTFS" }, // 0x07
{ FDISK_SMALLFAT32,"DOS_FAT_32" }, // 0x0B
{ FDISK_FAT32,"Windows FAT_32" }, // 0x0C
{ FDISK_DOS16SLBA,"Windows FAT_16" }, // 0x0E
{ FDISK_WIN_LDM, "Windows_LDM" }, // 0x42
{ FDISK_LINUX_SWAP, "Linux_Swap" }, // 0x82
{ FDISK_LINUX,"Linux" }, // 0x83
{ FDISK_LINUX_LVM, "Linux_LVM" }, // 0x8E
{ FDISK_FREEBSD,"FreeBSD" }, // 0xA5
{ FDISK_OPENBSD,"OpenBSD" }, // 0xA6
{ FDISK_NEXTNAME, "Apple_Rhapsody_UFS" }, // 0xA7
{ FDISK_UFS,"Apple UFS" },
{ FDISK_UFS,"Apple UFS" }, // 0xA8
{ FDISK_NETBSD, "NetBSD" }, // 0xA9
{ FDISK_BOOTER,"Apple_Boot" }, // 0xAB
{ FDISK_ENCRYPTED, "Apple_Encrypted" }, // 0xAE
{ FDISK_HFS,"Apple HFS" }, // 0xAF
{ 0xCD,"CD-ROM" },
{ 0xCD,"CD-ROM" }, // 0xCD
{ FDISK_BEFS, "Haiku" }, // 0xEB
{ FDISK_LINUX_RAID, "Linux_RAID" }, // 0xFD
{ 0x00,NULL } /* must be last */
{
result = FDISK_FREEBSD;
}
else if (OpenBSDProbe(probeBuffer))
{
result = FDISK_OPENBSD;
}
else if (BeFSProbe(probeBuffer))
{
result = FDISK_BEFS;
}
else if (NTFSProbe(probeBuffer))
{
result = FDISK_NTFS;
// NOTE: EFI_GUID's are in LE and we know we're on an x86.
// The IOGUIDPartitionScheme.cpp code uses byte-based UUIDs, we don't.
if (isPartitionUsed(gptMap)) {
if (isPartitionUsed(gptMap))
{
char stringuuid[100];
efi_guid_unparse_upper((EFI_GUID*)gptMap->ent_type, stringuuid);
verbose("Reading GPT partition %d, type %s\n", gptID, stringuuid);
// Getting fdisk like partition type.
fsType = probeFileSystem(biosdev, gptMap->ent_lba_start);
if ( (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) || (efi_guid_compare(&GPT_HFS_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ) {
if ( (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) || (efi_guid_compare(&GPT_HFS_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) )
{
bvrFlags = (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ? kBVFlagBooter : 0;
bvr = newGPTBVRef(biosdev,
gptID,
break;
default:
if (biosdev == gBIOSDev) {
if (biosdev == gBIOSDev)
{
gBIOSBootVolume = bvr;
}
break;
{
const char *val;
int len;
if (getValueForKey(kProductVersion, &val, &len, &systemVersion))
{
// getValueForKey uses const char for val
void rescanBIOSDevice(int biosdev)
{
struct DiskBVMap *oldMap = diskResetBootVolumes(biosdev);
if (oldMap == NULL)
{
return;
}
CacheReset();
diskFreeMap(oldMap);
oldMap = NULL;
}
else
{
stop("");
stop("diskResetBootVolumes error\n");
return NULL;
}
}
// Return the old map, either to be freed, or reinserted later
{
bvr = diskScanFDiskBootVolumes(biosdev, &count);
}
if (bvr == NULL)
{
bvr = diskScanAPMBootVolumes(biosdev, &count);
{
continue;
}
bzero(newBVR,sizeof(*newBVR));
bcopy(bvr, newBVR, sizeof(*newBVR));
/*
#if DEBUG //Azi: warning - too big for boot-log.. far too big.. i mean HUGE!! :P
for (bvr = chain; bvr; bvr = bvr->next)
{
if (!bvr)
{
break;
}
printf(" bvr: %d, dev: %d, part: %d, flags: %d, vis: %d\n", bvr, bvr->biosdev, bvr->part_no, bvr->flags, bvr->visible);
}
printf("count: %d\n", bvCount);
while (bvr)
{
if (!bvr)
{
break;
}
nextBVR = bvr->next;
if (bvr->filtered)
trunk/i386/libsaio/smbios.c
3434
3535
3636
37
38
39
37
38
39
4040
41
41
4242
4343
4444
4545
4646
47
48
49
50
47
48
49
50
5151
52
53
52
53
5454
55
55
5656
5757
5858
5959
60
61
60
61
6262
63
64
65
66
63
64
65
66
6767
6868
69
69
7070
7171
7272
7373
7474
75
76
77
78
79
75
76
77
78
79
8080
8181
8282
8383
8484
85
86
87
85
86
87
8888
8989
9090
9191
92
93
94
95
96
92
93
94
95
96
9797
9898
9999
100100
101
102
103
104
105
106
107
101
102
103
104
105
106
107
108108
109
109
110110
111111
112112
......
115115
116116
117117
118
118
119119
120120
121121
122122
123
123
124124
125125
126126
127127
128
128
129129
130130
131131
......
208208
209209
210210
211
211
212212
213213
214
214
215215
216216
217
217
218218
219219
220220
221
221
222222
223223
224224
225225
226226
227
227
228228
229229
230
230
231231
232232
233
233
234234
235235
236
236
237237
238238
239
239
240240
241241
242
242
243243
244244
245245
246246
247
247
248248
249249
250
250
251251
252252
253253
254254
255255
256256
257
257
258258
259259
260
260
261261
262262
263263
264
264
265265
266266
267
267
268268
269269
270
270
271271
272272
273
273
274274
275275
276
276
277277
278278
279
279
280280
281281
282282
......
285285
286286
287287
288
288
289289
290290
291
291
292292
293293
294
294
295295
296296
297
297
298298
299299
300
300
301301
302302
303303
......
308308
309309
310310
311
311
312312
313313
314
314
315315
316316
317
317
318318
319319
320
320
321321
322322
323
323
324324
325325
326
326
327327
328328
329
329
330330
331331
332332
333333
334334
335335
336
336
337337
338338
339339
......
372372
373373
374374
375
375
376376
377377
378378
379379
380
380
381381
382382
383383
384384
385
385
386386
387387
388388
389389
390390
391391
392
393
392
393
394394
395395
396396
......
616616
617617
618618
619
619
620620
621
621
622622
623623
624624
......
707707
708708
709709
710
711
710
711
712712
713713
714714
......
780780
781781
782782
783
783
784
784785
785786
786787
787788
788789
789790
790
791
791
792
793
794
792795
793796
794
795
797
798
799
800
801
796802
797803
798804
......
801807
802808
803809
804
805
806
810
811
807812
808813
809814
815
816
810817
811818
812819
......
817824
818825
819826
820
827
828
821829
822830
823831
824
832
833
825834
826835
827836
......
829838
830839
831840
832
833
841
842
843
844
834845
835846
836847
837848
838
849
850
839851
840852
841853
......
854866
855867
856868
857
869
870
858871
859872
860873
861
874
875
862876
863877
864878
......
866880
867881
868882
869
883
884
885
870886
871887
872888
......
877893
878894
879895
880
881
896
897
898
899
882900
883901
884902
885903
886
904
905
887906
888907
889908
890909
891910
892911
912
893913
894914
895915
896916
897
917
918
898919
899920
900921
901
922
923
902924
903925
904926
905
906
927
928
929
930
931
907932
908933
909934
......
922947
923948
924949
925
926
950
951
952
953
927954
928955
929956
930957
931958
932
959
960
933961
934962
935963
......
953981
954982
955983
956
984
985
957986
958987
959988
......
10501079
10511080
10521081
1053
1082
1083
1084
10541085
10551086
10561087
......
10621093
10631094
10641095
1065
1096
1097
10661098
10671099
10681100
......
10901122
10911123
10921124
1093
1125
1126
10941127
1095
1128
1129
10961130
10971131
10981132
......
11001134
11011135
11021136
1103
1137
1138
11041139
11051140
11061141
1107
1142
1143
11081144
11091145
11101146
......
11291165
11301166
11311167
1132
1168
1169
11331170
1134
1171
1172
1173
11351174
11361175
11371176
11381177
11391178
1140
1179
1180
11411181
11421182
1143
1183
1184
11441185
11451186
11461187
11471188
11481189
1149
1190
1191
11501192
11511193
11521194
11531195
11541196
1155
1197
1198
11561199
11571200
11581201
1159
1202
1203
1204
11601205
11611206
11621207
1163
1208
1209
11641210
11651211
11661212
......
11721218
11731219
11741220
1175
1221
1222
11761223
11771224
11781225
......
12061253
12071254
12081255
1209
1256
1257
12101258
12111259
12121260
......
12361284
12371285
12381286
1239
1287
1288
12401289
12411290
12421291
......
12451294
12461295
12471296
1248
1297
1298
12491299
12501300
12511301
12521302
12531303
12541304
1255
1305
1306
12561307
12571308
12581309
1259
1310
1311
12601312
12611313
12621314
......
12771329
12781330
12791331
1280
1332
1333
12811334
12821335
12831336
12841337
12851338
12861339
1287
1340
1341
12881342
12891343
12901344
12911345
1292
1346
1347
12931348
12941349
12951350
......
13051360
13061361
13071362
1308
1363
1364
13091365
13101366
13111367
......
13321388
13331389
13341390
1335
1391
1392
13361393
13371394
13381395
......
13601417
13611418
13621419
1363
1420
1421
13641422
1365
1423
1424
13661425
13671426
13681427
......
13931452
13941453
13951454
1396
1455
1456
13971457
13981458
13991459
......
14191479
14201480
14211481
1422
1482
1483
14231484
14241485
1425
1486
1487
14261488
14271489
14281490
......
14341496
14351497
14361498
1437
1499
1500
14381501
14391502
14401503
/* =======================
BIOS Information (Type 0)
========================= */
#define kSMBBIOSInformationVendorKey "SMbiosvendor" // Apple Inc.
#define kSMBBIOSInformationVersionKey "SMbiosversion" // MP31.88Z.006C.B05.0802291410
#define kSMBBIOSInformationReleaseDateKey "SMbiosdate" // 02/29/08
#define kSMBBIOSInformationVendorKey"SMbiosvendor"// Apple Inc.
#define kSMBBIOSInformationVersionKey"SMbiosversion"// MP31.88Z.006C.B05.0802291410
#define kSMBBIOSInformationReleaseDateKey"SMbiosdate"// 02/29/08
// Bungo
#define kSMBBIOSInformationReleaseKey "SMbiosrelease" // BIOS Revision
#define kSMBBIOSInformationReleaseKey"SMbiosrelease"// BIOS Revision
// example: BIOS Revision: 1.23 --> 2 bytes: Major=0x01, Minor=0x17 --> after swap: 0x1701hex = 5889dec (SMBIOS_spec_DSP0134_2.7.1)
/* =========================
System Information (Type 1)
=========================== */
#define kSMBSystemInformationManufacturerKey "SMmanufacturer" // Apple Inc.
#define kSMBSystemInformationProductNameKey "SMproductname" // MacPro3,1
#define kSMBSystemInformationVersionKey "SMsystemversion" // 1.0
#define kSMBSystemInformationSerialNumberKey "SMserial" // Serial number
#define kSMBSystemInformationManufacturerKey"SMmanufacturer"// Apple Inc.
#define kSMBSystemInformationProductNameKey"SMproductname"// MacPro3,1
#define kSMBSystemInformationVersionKey"SMsystemversion"// 1.0
#define kSMBSystemInformationSerialNumberKey"SMserial"// Serial number
//Bungo
#define kSMBSystemInformationUUIDKey "SMsystemuuid" // ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }'
#define kSMBSystemInformationSKUNumberKey "SMskunumber" // System SKU#
#define kSMBSystemInformationUUIDKey"SMsystemuuid"// ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }'
#define kSMBSystemInformationSKUNumberKey"SMskunumber"// System SKU#
#define kSMBSystemInformationFamilyKey "SMfamily" // MacPro
#define kSMBSystemInformationFamilyKey"SMfamily"// MacPro
/* =========================================
Base Board (or Module) Information (Type 2)
=========================================== */
#define kSMBBaseBoardManufacturerKey "SMboardmanufacturer" // Apple Inc.
#define kSMBBaseBoardProductKey "SMboardproduct" // Mac-F2268DC8
#define kSMBBaseBoardManufacturerKey"SMboardmanufacturer"// Apple Inc.
#define kSMBBaseBoardProductKey"SMboardproduct"// Mac-F2268DC8
// Bungo
#define kSMBBaseBoardVersionKey "SMboardversion" // MacPro3,1
#define kSMBBaseBoardSerialNumberKey "SMboardserial" // C02140302D5DMT31M
#define kSMBBaseBoardAssetTagKey "SMboardassettag" // Base Board Asset Tag# Bungo: renamed folowing convention
#define kSMBBaseBoardLocationInChassisKey "SMboardlocation" // Part Component
#define kSMBBaseBoardVersionKey"SMboardversion"// MacPro3,1
#define kSMBBaseBoardSerialNumberKey"SMboardserial"// C02140302D5DMT31M
#define kSMBBaseBoardAssetTagKey"SMboardassettag"// Base Board Asset Tag# Bungo: renamed folowing convention
#define kSMBBaseBoardLocationInChassisKey"SMboardlocation"// Part Component
// ErmaC BoardType 0x0a(10) or 0x0b(11) MacPro Family
#define kSMBBaseBoardTypeKey "SMboardtype" // 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro
#define kSMBBaseBoardTypeKey"SMboardtype"// 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro
// Bungo
/* =======================
System Enclosure (Type 3)
========================= */
#define kSMBSystemEnclosureManufacturerKey "SMchassismanufacturer" // Apple Inc.
#define kSMBSystemEnclosureTypeKey "SMchassistype" // 7 Desktop
#define kSMBSystemEnclosureVersionKey "SMchassisversion" // Mac-F42C88C8
#define kSMBSystemEnclosureSerialNumberKey "SMchassisserial" // Serial number
#define kSMBSystemEnclosureAssetTagKey "SMchassisassettag" // Pro-Enclosure Bungo: renamed folowing convention
#define kSMBSystemEnclosureManufacturerKey"SMchassismanufacturer"// Apple Inc.
#define kSMBSystemEnclosureTypeKey"SMchassistype"// 7 Desktop
#define kSMBSystemEnclosureVersionKey"SMchassisversion"// Mac-F42C88C8
#define kSMBSystemEnclosureSerialNumberKey"SMchassisserial"// Serial number
#define kSMBSystemEnclosureAssetTagKey"SMchassisassettag"// Pro-Enclosure Bungo: renamed folowing convention
/* ============================
Processor Information (Type 4)
============================== */
// Bungo
#define kSMBProcessorInformationSocketKey "SMcpusocket"
#define kSMBProcessorInformationManufacturerKey "SMcpumanufacturer"
#define kSMBProcessorInformationVersionKey "SMcpuversion"
#define kSMBProcessorInformationSocketKey"SMcpusocket"
#define kSMBProcessorInformationManufacturerKey"SMcpumanufacturer"
#define kSMBProcessorInformationVersionKey"SMcpuversion"
//
#define kSMBProcessorInformationExternalClockKey"SMexternalclock"
#define kSMBProcessorInformationMaximumClockKey"SMmaximalclock"
// Bungo
#define kSMBProcessorInformationCurrentClockKey "SMcurrentclock"
#define kSMBProcessorInformationUpgradeKey "SMcpuupgrade"
#define kSMBProcessorInformationSerialNumberKey "SMcpuserial"
#define kSMBProcessorInformationAssetTagKey "SMcpuassettag" // Bungo: renamed folowing convention
#define kSMBProcessorInformationPartNumberKey "SMcpupartnumber"
#define kSMBProcessorInformationCurrentClockKey"SMcurrentclock"
#define kSMBProcessorInformationUpgradeKey"SMcpuupgrade"
#define kSMBProcessorInformationSerialNumberKey"SMcpuserial"
#define kSMBProcessorInformationAssetTagKey"SMcpuassettag"// Bungo: renamed folowing convention
#define kSMBProcessorInformationPartNumberKey"SMcpupartnumber"
/* =====================
Memory Device (Type 17)
======================= */
#define kSMBMemoryDeviceDeviceLocatorKey "SMmemdevloc" //
#define kSMBMemoryDeviceBankLocatorKey "SMmembankloc" //
#define kSMBMemoryDeviceMemoryTypeKey "SMmemtype" //
#define kSMBMemoryDeviceMemorySpeedKey "SMmemspeed" //
#define kSMBMemoryDeviceManufacturerKey "SMmemmanufacturer" //
#define kSMBMemoryDeviceSerialNumberKey "SMmemserial" //
#define kSMBMemoryDevicePartNumberKey "SMmempart" //
#define kSMBMemoryDeviceDeviceLocatorKey"SMmemdevloc" //
#define kSMBMemoryDeviceBankLocatorKey"SMmembankloc" //
#define kSMBMemoryDeviceMemoryTypeKey"SMmemtype" //
#define kSMBMemoryDeviceMemorySpeedKey"SMmemspeed" //
#define kSMBMemoryDeviceManufacturerKey"SMmemmanufacturer" //
#define kSMBMemoryDeviceSerialNumberKey"SMmemserial" //
#define kSMBMemoryDevicePartNumberKey"SMmempart" //
// Bungo:
#define kSMBMemoryDeviceAssetTagKey "SMmemassettag" //
#define kSMBMemoryDeviceAssetTagKey"SMmemassettag" //
/* ===========================================
Memory SPD Data (Apple Specific - Type 130)
/* ============================================
OEM Processor Type (Apple Specific - Type 131)
============================================== */
#define kSMBOemProcessorTypeKey "SMoemcputype" // Bungo: renamed from SMcputype
#define kSMBOemProcessorTypeKey"SMoemcputype"// Bungo: renamed from SMcputype
/* =================================================
OEM Processor Bus Speed (Apple Specific - Type 132)
=================================================== */
#define kSMBOemProcessorBusSpeedKey "SMoemcpubusspeed" // Bungo: renamed from SMbusspeed
#define kSMBOemProcessorBusSpeedKey"SMoemcpubusspeed"// Bungo: renamed from SMbusspeed
/* ==============================================
OEM Platform Feature (Apple Specific - Type 133)
================================================ */
//#define kSMBOemPlatformFeatureKey "SMoemplatformfeature"
//#define kSMBOemPlatformFeatureKey"SMoemplatformfeature"
/* ==================================================*/
#define getFieldOffset(struct, field)((uint8_t)(uint32_t)&(((struct *)0)->field))
BIOS Information (Type 0)
========================= */
{ kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, vendor),
kSMBBIOSInformationVendorKey, NULL, &defaultBIOSInfo.vendor }, // SMbiosvendor - Apple Inc.
kSMBBIOSInformationVendorKey, NULL, &defaultBIOSInfo.vendor },// SMbiosvendor - Apple Inc.
{ kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, version),
kSMBBIOSInformationVersionKey, NULL, &defaultBIOSInfo.version }, // SMbiosversion - MP31.88Z.006C.B05.0802291410
kSMBBIOSInformationVersionKey, NULL, &defaultBIOSInfo.version },// SMbiosversion - MP31.88Z.006C.B05.0802291410
{ kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, releaseDate),
kSMBBIOSInformationReleaseDateKey, NULL, &defaultBIOSInfo.releaseDate }, // SMbiosdate - 02/29/08
kSMBBIOSInformationReleaseDateKey, NULL, &defaultBIOSInfo.releaseDate },// SMbiosdate - 02/29/08
// Bungo
{ kSMBTypeBIOSInformation, kSMBWord, getFieldOffset(SMBBIOSInformation, releaseMajor),
kSMBBIOSInformationReleaseKey, NULL,(char **)&defaultBIOSInfo.release }, // SMbiosrelease - 0.1 (256)
kSMBBIOSInformationReleaseKey, NULL,(char **)&defaultBIOSInfo.release },// SMbiosrelease - 0.1 (256)
/* =========================
System Information (Type 1)
=========================== */
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, manufacturer),
kSMBSystemInformationManufacturerKey, NULL,&defaultSystemInfo.manufacturer}, // SMmanufacturer - Apple Inc.
kSMBSystemInformationManufacturerKey, NULL,&defaultSystemInfo.manufacturer},// SMmanufacturer - Apple Inc.
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, productName),
kSMBSystemInformationProductNameKey, NULL, &defaultSystemInfo.productName }, // SMproductname - MacPro3,1
kSMBSystemInformationProductNameKey, NULL, &defaultSystemInfo.productName },// SMproductname - MacPro3,1
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, version),
kSMBSystemInformationVersionKey, NULL, &defaultSystemInfo.version }, // SMsystemversion - 1.0
kSMBSystemInformationVersionKey, NULL, &defaultSystemInfo.version },// SMsystemversion - 1.0
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, serialNumber),
kSMBSystemInformationSerialNumberKey, NULL, &defaultSystemInfo.serialNumber }, // SMserial - Serial number
kSMBSystemInformationSerialNumberKey, NULL, &defaultSystemInfo.serialNumber },// SMserial - Serial number
/* Bungo:
{kSMBTypeSystemInformation,kSMBByte,getFieldOffset(SMBSystemInformation, uuid),
kSMBSystemInformationUUIDKey, NULL, NULL}, // SMsystemuuid
kSMBSystemInformationUUIDKey, NULL, NULL},// SMsystemuuid
{kSMBTypeSystemInformation,kSMBByte,getFieldOffset(SMBSystemInformation, wakeupReason),
NULL, NULL, NULL}, // reason for system wakeup
NULL, NULL, NULL},// reason for system wakeup
*/
// Bungo
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, skuNumber),
kSMBSystemInformationSKUNumberKey, NULL, &defaultSystemInfo.skuNumber}, // SMskunumber - System SKU#
kSMBSystemInformationSKUNumberKey, NULL, &defaultSystemInfo.skuNumber},// SMskunumber - System SKU#
{kSMBTypeSystemInformation,kSMBString,getFieldOffset(SMBSystemInformation, family),
kSMBSystemInformationFamilyKey,NULL,&defaultSystemInfo.family}, // SMfamily - MacPro
kSMBSystemInformationFamilyKey,NULL,&defaultSystemInfo.family},// SMfamily - MacPro
/* =========================================
Base Board (or Module) Information (Type 2)
=========================================== */
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, manufacturer),
kSMBBaseBoardManufacturerKey, NULL, &defaultBaseBoard.manufacturer }, // SMboardmanufacturer - Apple Inc.
kSMBBaseBoardManufacturerKey, NULL, &defaultBaseBoard.manufacturer },// SMboardmanufacturer - Apple Inc.
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, product),
kSMBBaseBoardProductKey, NULL, &defaultBaseBoard.product }, // SMboardproduct - Mac-F2268DC8
kSMBBaseBoardProductKey, NULL, &defaultBaseBoard.product },// SMboardproduct - Mac-F2268DC8
// Bungo
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, version),
kSMBBaseBoardVersionKey, NULL, &defaultBaseBoard.version }, // SMboardversion - MacPro3,1
kSMBBaseBoardVersionKey, NULL, &defaultBaseBoard.version },// SMboardversion - MacPro3,1
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, serialNumber),
kSMBBaseBoardSerialNumberKey, NULL, &defaultBaseBoard.serialNumber }, // SMboardserial - C02140302D5DMT31M
kSMBBaseBoardSerialNumberKey, NULL, &defaultBaseBoard.serialNumber },// SMboardserial - C02140302D5DMT31M
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, assetTag),
kSMBBaseBoardAssetTagKey, NULL, &defaultBaseBoard.assetTag }, // SMboardassettag - Base Board Asset Tag#
kSMBBaseBoardAssetTagKey, NULL, &defaultBaseBoard.assetTag },// SMboardassettag - Base Board Asset Tag#
{kSMBTypeBaseBoard,kSMBString,getFieldOffset(SMBBaseBoard, locationInChassis),
kSMBBaseBoardLocationInChassisKey, NULL, &defaultBaseBoard.locationInChassis }, // SMboardlocation - Part Component
kSMBBaseBoardLocationInChassisKey, NULL, &defaultBaseBoard.locationInChassis },// SMboardlocation - Part Component
{kSMBTypeBaseBoard,kSMBByte,getFieldOffset(SMBBaseBoard, boardType),
kSMBBaseBoardTypeKey,NULL, (char **)&defaultBaseBoard.boardType }, // SMboardtype - 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro
kSMBBaseBoardTypeKey,NULL, (char **)&defaultBaseBoard.boardType },// SMboardtype - 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro
/*{kSMBTypeBaseBoard,kSMBByte, getFieldOffset(SMBBaseBoard, numberOfContainedHandles),
NULL , NULL, NULL }, // numberOfContainedHandles = 0
NULL , NULL, NULL },// numberOfContainedHandles = 0
*/
//
System Enclosure (Type 3)
========================= */
{kSMBTypeSystemEnclosure,kSMBString,getFieldOffset(SMBSystemEnclosure, manufacturer),
kSMBSystemEnclosureManufacturerKey, NULL,&defaultChassis.manufacturer }, // SMchassismanufacturer - Apple Inc.
kSMBSystemEnclosureManufacturerKey, NULL,&defaultChassis.manufacturer },// SMchassismanufacturer - Apple Inc.
{kSMBTypeSystemEnclosure, kSMBByte,getFieldOffset(SMBSystemEnclosure, chassisType),
kSMBSystemEnclosureTypeKey, NULL, (char **)&defaultChassis.chassisType}, // SMchassistype - 7
kSMBSystemEnclosureTypeKey, NULL, (char **)&defaultChassis.chassisType},// SMchassistype - 7
{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, version),
kSMBSystemEnclosureVersionKey, NULL, &defaultChassis.version }, // SMchassisversion - Mac-F42C88C8
kSMBSystemEnclosureVersionKey, NULL, &defaultChassis.version },// SMchassisversion - Mac-F42C88C8
{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, serialNumber),
kSMBSystemEnclosureSerialNumberKey, NULL, &defaultChassis.serialNumber }, // SMchassisserial
kSMBSystemEnclosureSerialNumberKey, NULL, &defaultChassis.serialNumber },// SMchassisserial
{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, assetTag),
kSMBSystemEnclosureAssetTagKey, NULL, &defaultChassis.assetTag }, // SMchassisassettag - Pro Enclosure
kSMBSystemEnclosureAssetTagKey, NULL, &defaultChassis.assetTag },// SMchassisassettag - Pro Enclosure
/*
{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, skuNumber),
Processor Information (Type 4)
============================== */
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, socketDesignation),
kSMBProcessorInformationSocketKey, NULL, NULL}, // SMcpusocket -
kSMBProcessorInformationSocketKey, NULL, NULL},// SMcpusocket -
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, manufacturer),
kSMBProcessorInformationManufacturerKey, NULL, NULL}, // SMcpumanufacturer - Intel(R) Corporation
kSMBProcessorInformationManufacturerKey, NULL, NULL},// SMcpumanufacturer - Intel(R) Corporation
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, processorVersion),
kSMBProcessorInformationVersionKey, NULL, NULL}, // SMcpuversion
kSMBProcessorInformationVersionKey, NULL, NULL},// SMcpuversion
{kSMBTypeProcessorInformation,kSMBWord, getFieldOffset(SMBProcessorInformation, externalClock),
kSMBProcessorInformationExternalClockKey, getProcessorInformationExternalClock,NULL}, // SMcpuexternalclock
kSMBProcessorInformationExternalClockKey, getProcessorInformationExternalClock,NULL},// SMcpuexternalclock
{kSMBTypeProcessorInformation,kSMBWord, getFieldOffset(SMBProcessorInformation, maximumClock),
kSMBProcessorInformationMaximumClockKey, getProcessorInformationMaximumClock,NULL}, // SMcpumaximumclock
kSMBProcessorInformationMaximumClockKey, getProcessorInformationMaximumClock,NULL},// SMcpumaximumclock
// Bungo
{kSMBTypeProcessorInformation,kSMBWord,getFieldOffset(SMBProcessorInformation, currentClock),
kSMBProcessorInformationCurrentClockKey, NULL, NULL}, // SMcpucurrentclock
kSMBProcessorInformationCurrentClockKey, NULL, NULL},// SMcpucurrentclock
{kSMBTypeProcessorInformation,kSMBByte,getFieldOffset(SMBProcessorInformation, processorUpgrade),
kSMBProcessorInformationUpgradeKey, NULL, NULL}, // SMcpuupgrade
kSMBProcessorInformationUpgradeKey, NULL, NULL},// SMcpuupgrade
//
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, serialNumber),
kSMBProcessorInformationSerialNumberKey, NULL, NULL},
// Bungo
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, assetTag),
kSMBProcessorInformationAssetTagKey, NULL, NULL}, // SMcpuassettag
kSMBProcessorInformationAssetTagKey, NULL, NULL},// SMcpuassettag
//
{kSMBTypeProcessorInformation,kSMBString,getFieldOffset(SMBProcessorInformation, partNumber),
kSMBProcessorInformationPartNumberKey, NULL, NULL},
// Apple Specific
//-------------------------------------------------------------------------------------------------------------------------
// OEM Processor Type (Apple Specific - Type 131)
{kSMBTypeOemProcessorType,kSMBWord,getFieldOffset(SMBOemProcessorType, ProcessorType),kSMBOemProcessorTypeKey,
{kSMBTypeOemProcessorType,kSMBWord,getFieldOffset(SMBOemProcessorType, ProcessorType),kSMBOemProcessorTypeKey,
getSMBOemProcessorType,NULL},
// OEM Processor Bus Speed (Apple Specific - Type 132)
{kSMBTypeOemProcessorBusSpeed,kSMBWord,getFieldOffset(SMBOemProcessorBusSpeed, ProcessorBusSpeed),kSMBOemProcessorBusSpeedKey,
getSMBOemProcessorBusSpeed,NULL}
getSMBOemProcessorBusSpeed,NULL}
// OEM Platform Feature (Apple Specific - Type 133)
/*
{kSMBTypeOemPlatformFeature,kSMBWord,getFieldOffset(SMBOemPlatformFeature, PlatformFeature),kSMBOemPlatformFeatureKey,
getSMBOemPlatformFeature,NULL}
getSMBOemPlatformFeature,NULL}
*/
};
int numOfSetters = sizeof(SMBSetters) / sizeof(SMBValueSetter);
SMBEntryPoint *origeps= 0;
SMBEntryPoint *neweps= 0;
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
/* ============================================ */
bool useSMBIOSdefaults = true; // Bungo
bool useSMBIOSdefaults = true;// Bungo
SMBByte PlatformType= 1; // Bungo: same as Platfom.Type in platform.h. Because can't get from ACPI FADT PM profile and platformCPUFeature(CPU_FEATURE_MOBILE)) doesn't work as expect, FIXING NEEDED.
SMBByte PlatformType= 1;// Bungo: same as Platfom.Type in platform.h. Because can't get from ACPI FADT PM profile and platformCPUFeature(CPU_FEATURE_MOBILE)) doesn't work as expect, FIXING NEEDED.
/* Rewrite this function */
void setDefaultSMBData(void) // Bungo: setting data from real Macs
defaultChassis.chassisType = kSMBchassisAllInOne;
break;
case CPUID_MODEL_SANDYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (32nm)
case CPUID_MODEL_IVYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (22nm)
case CPUID_MODEL_SANDYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (32nm)
case CPUID_MODEL_IVYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (22nm)
defaultBIOSInfo.version = kDefaultiMacSandyBIOSVersion;
defaultBIOSInfo.releaseDate = kDefaultiMacSandyBIOSReleaseDate;
defaultSystemInfo.productName= kDefaultiMacSandy;
int len;
char key[24];
if (current != structHeader->handle) {
if (current != structHeader->handle)
{
idx++;
current = structHeader->handle;
}
sprintf(key, "%s%d", keyString, idx);
if (value) {
if (getIntForKey(key, (int *)&(value->dword), SMBPlist)) {
if (value)
{
if (getIntForKey(key, (int *)&(value->dword), SMBPlist))
{
return true;
}
} else {
if (getValueForKey(key, string, &len, SMBPlist)) {
}
else
{
if (getValueForKey(key, string, &len, SMBPlist))
{
return true;
}
}
char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field)
{
uint8_t *stringPtr = (uint8_t *)structHeader + structHeader->length;
if (!field) {
if (!field)
{
return NULL;
}
uint8_t *stringPtr = (uint8_t *)structHeader + structHeader->length;
for (field--; field != 0 && strlen((char *)stringPtr) > 0;
field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1));
{
int strSize;
if (!field) {
if (!field)
{
return;
}
if (!string) {
if (!string)
{
*field = 0;
return;
}
strSize = strlen(string);
// remove any spaces found at the end but only in MemoryDevice avoiding errors
if (structHeader->type == kSMBTypeMemoryDevice) {
while ((strSize != 0) && (string[strSize - 1] == ' ')) {
if (structHeader->type == kSMBTypeMemoryDevice)
{
while ((strSize != 0) && (string[strSize - 1] == ' '))
{
strSize--;
}
}
if (strSize == 0) {
if (strSize == 0)
{
*field = 0;
return;
}
bool parsed;
int val;
if (numOfSetters <= idx) {
if (numOfSetters <= idx)
{
return false;
}
switch (SMBSetters[idx].valueType) {
switch (SMBSetters[idx].valueType)
{
case kSMBString:
{
if (SMBSetters[idx].keyString)
if (getValueForKey(SMBSetters[idx].keyString, &string, &len, SMBPlist))
{
break;
} else {
}
else
{
if (structPtr->orig->type == kSMBTypeMemoryDevice)// MemoryDevice only
{
if (getSMBValueForKey(structPtr->orig, SMBSetters[idx].keyString, &string, NULL))
}
}
if (SMBSetters[idx].getSMBValue) {
if (SMBSetters[idx].getSMBValue((returnType *)&string)) {
if (SMBSetters[idx].getSMBValue)
{
if (SMBSetters[idx].getSMBValue((returnType *)&string))
{
break;
}
}
// if ((SMBSetters[idx].defaultValue) && *(SMBSetters[idx].defaultValue)) Bungo
if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue)) {
if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue))
{
string = *(SMBSetters[idx].defaultValue);
break;
}
string = getSMBStringForField(structPtr->orig, *(uint8_t *)value);
break;
}
case kSMBByte:
case kSMBWord:
case kSMBDWord:
case kSMBQWord:
if (SMBSetters[idx].keyString) {
if (SMBSetters[idx].keyString)
{
parsed = getIntForKey(SMBSetters[idx].keyString, &val, SMBPlist);
if (!parsed)
{
if (structPtr->orig->type == kSMBTypeMemoryDevice) { // MemoryDevice only
if (structPtr->orig->type == kSMBTypeMemoryDevice) // MemoryDevice only
{
parsed = getSMBValueForKey(structPtr->orig, SMBSetters[idx].keyString, NULL, (returnType *)&val);
}
}
if (parsed) {
switch (SMBSetters[idx].valueType) {
if (parsed)
{
switch (SMBSetters[idx].valueType)
{
case kSMBByte:
value->byte = (uint8_t)val;
break;
}
}
if (SMBSetters[idx].getSMBValue) {
if (SMBSetters[idx].getSMBValue(value)) {
if (SMBSetters[idx].getSMBValue)
{
if (SMBSetters[idx].getSMBValue(value))
{
return true;
}
}
// #if 0 Bungo: enables code below
// if (*(SMBSetters[idx].defaultValue)) Bungo
if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue)) {
if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue))
{
// value->dword = *(uint32_t *)(SMBSetters[idx].defaultValue); Bungo
switch (SMBSetters[idx].valueType) {
case kSMBByte:
}
// if (SMBSetters[idx].valueType == kSMBString && string) Bungo: use null string too -> "Not Specified"
if ((SMBSetters[idx].valueType == kSMBString) && string) {
if ((SMBSetters[idx].valueType == kSMBString) && string)
{
setSMBStringForField(structPtr->new, string, &value->byte);
}
return true;
/* ==============================================
OEM Platform Feature (Apple Specific - Type 133)
================================================ */
/*void addSMBOemPlatformFeature(SMBStructPtrs *structPtr) {
/*
void addSMBOemPlatformFeature(SMBStructPtrs *structPtr)
{
SMBOemPlatformFeature *p = (SMBOemPlatformFeature *)structPtr->new;
p->header.type= kSMBTypeOemPlatformFeature;
structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemPPlatformFeature) + 2);
tableLength += sizeof(SMBOemPlatformFeature) + 2;
structureCount++;
}*/
}
*/
//-------------------------------------------------------------------------------------------------------------------------
// EndOfTable
// http://forge.voodooprojects.org/p/chameleon/issues/361/
bool forceFullMemInfo = false;
if (structPtr->orig->type == kSMBTypeMemoryDevice) {
if (structPtr->orig->type == kSMBTypeMemoryDevice)
{
getBoolForKey(kMemFullInfo, &forceFullMemInfo, &bootInfo->chameleonConfig);
if (forceFullMemInfo) {
if (forceFullMemInfo)
{
structPtr->orig->length = 27;
}
}*/
stringIndex = 1;
stringsSize = 0;
if (handle < structPtr->orig->handle) {
if (handle < structPtr->orig->handle)
{
handle = structPtr->orig->handle;
}
// Bungo: fix unsuported tables lengths from original smbios: extend shorter or truncate longer - we use SMBIOS rev. 2.4 like Apple uses
switch (structPtr->orig->type) {
switch (structPtr->orig->type)
{
case kSMBTypeBIOSInformation:
structSize = sizeof(SMBBIOSInformation);
break;
}
// memcpy((void *)structPtr->new, structPtr->orig, structPtr->orig->length);
if (structPtr->orig->length <= structSize) {
if (structPtr->orig->length <= structSize)
{
memcpy((void *)structPtr->new, structPtr->orig, structPtr->orig->length);
} else {
}
else
{
memcpy((void *)structPtr->new, structPtr->orig, structSize);
}
structPtr->new->length = structSize;
for (i = 0; i < numOfSetters; i++) {
for (i = 0; i < numOfSetters; i++)
{
// Bungo:
//if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structPtr->orig->length)) {
if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structSize)) {
if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structSize))
{
setterFound = true;
setSMBValue(structPtr, i, (returnType *)((uint8_t *)structPtr->new + SMBSetters[i].fieldOffset));
}
}
if (setterFound) {
if (setterFound)
{
// Bungo:
// ptr = (uint8_t *)structPtr->new + structPtr->orig->length;
ptr = (uint8_t *)structPtr->new + structPtr->new->length;
for (; ((uint16_t *)ptr)[0] != 0; ptr++);
if (((uint16_t *)ptr)[0] == 0) {
if (((uint16_t *)ptr)[0] == 0)
{
ptr += 2;
}
structSize = ptr - (uint8_t *)structPtr->new;
} else {
}
else
{
ptr = (uint8_t *)structPtr->orig + structPtr->orig->length;
for (; ((uint16_t *)ptr)[0] != 0; ptr++);
if (((uint16_t *)ptr)[0] == 0) {
if (((uint16_t *)ptr)[0] == 0)
{
ptr += 2;
}
tableLength += structSize;
if (structSize > maxStructSize) {
if (structSize > maxStructSize)
{
maxStructSize = structSize;
}
ptr = (uint8_t *)((uint32_t)structPtr->orig + structPtr->orig->length);
for (; ((uint16_t *)ptr)[0] != 0; ptr++);
if (((uint16_t *)ptr)[0] == 0) {
if (((uint16_t *)ptr)[0] == 0)
{
ptr += 2;
}
ptr = (uint8_t *)((uint32_t)structHeader + structHeader->length);
for (; ((uint16_t *)ptr)[0] != 0; ptr++);
if (((uint16_t *)ptr)[0] == 0) {
if (((uint16_t *)ptr)[0] == 0)
{
ptr += 2;
}
ptr = ((SMBSystemInformation *)structHeader)->uuid;
if (!sysId || !ret) { // no or bad custom uuid,...
if (!sysId || !ret) // no or bad custom uuid,...
{
sysId = 0;
ret = Platform.UUID; // ...use original (factory) system uuid
}
for (i = 0, isZero = 1, isOnes = 1; i < UUID_LEN; i++) // check if empty (zeroed) or setable (FFed), means: no uuid present
{
if (ret[i] != 0x00) {
if (ret[i] != 0x00)
{
isZero = 0;
}
if (ret[i] != 0xff) {
if (ret[i] != 0xff)
{
isOnes = 0;
}
}
uint8_t *buffer;
// bool setSMB = true; Bungo: now we use useSMBIOSdefaults
if (!origeps) {
if (!origeps)
{
return;
}
neweps = origeps;
structPtr = (SMBStructPtrs *)malloc(sizeof(SMBStructPtrs));
if (!structPtr) {
if (!structPtr)
{
return;
}
buffer = (uint8_t *)malloc(SMB_ALLOC_SIZE);
if (!buffer) {
if (!buffer)
{
free(structPtr);
return;
}
setupNewSMBIOSTable(origeps, structPtr);
neweps = (SMBEntryPoint *)AllocateKernelMemory(sizeof(SMBEntryPoint));
if (!neweps) {
if (!neweps)
{
free(buffer);
free(structPtr);
return;
neweps->dmi.structureCount= structureCount;
neweps->dmi.bcdRevision= 0x24; // ... and 2.4 DMI rev. as real Macs
if (!neweps->dmi.tableAddress) {
if (!neweps->dmi.tableAddress)
{
free(buffer);
free(structPtr);
return;
void *getSmbios(int which)
{
switch (which) {
switch (which)
{
case SMBIOS_ORIGINAL:
if (!origeps) {
if (!origeps)
{
origeps = getAddressOfSmbiosTable();
}
return origeps;
break;
case kSMBTypeSystemEnclosure: // Bungo: determine platform type
switch (((SMBSystemEnclosure *)structHeader)->chassisType) {
switch (((SMBSystemEnclosure *)structHeader)->chassisType)
{
case kSMBchassisDesktop:
case kSMBchassisLPDesktop:
case kSMBchassisAllInOne:
case kSMBTypeMemoryDevice:
Platform.DMI.CntMemorySlots++;
if (((SMBMemoryDevice *)structHeader)->memorySize != 0){
if (((SMBMemoryDevice *)structHeader)->memorySize != 0)
{
Platform.DMI.MemoryModules++;
}
if (((SMBMemoryDevice *)structHeader)->memorySpeed > 0){
if (((SMBMemoryDevice *)structHeader)->memorySpeed > 0)
{
Platform.RAM.DIMM[dimmnbr].Frequency = ((SMBMemoryDevice *)structHeader)->memorySpeed;
}
dimmnbr++;
structPtr = (uint8_t *)((uint32_t)structHeader + structHeader->length);
for (; ((uint16_t *)structPtr)[0] != 0; structPtr++);
if (((uint16_t *)structPtr)[0] == 0) {
if (((uint16_t *)structPtr)[0] == 0)
{
structPtr += 2;
}
trunk/i386/libsaio/pci.c
7575
7676
7777
78
79
78
79
80
81
8082
8183
82
84
85
8386
8487
88
8589
86
90
91
8792
8893
94
8995
9096
9197
......
99105
100106
101107
102
103
104
105
106
107
108
109
110
111
108
109
110
111
112
113
114
115
116
117
118
119
112120
121
113122
114123
115124
116
125
126
117127
118128
119129
......
131141
132142
133143
144
134145
135146
136147
......
144155
145156
146157
147
158
159
148160
149161
150162
......
164176
165177
166178
167
179
168180
169181
170182
......
176188
177189
178190
179
191
192
180193
181194
182195
183
196
197
198
184199
185200
186201
uint8_tsecondary_bus;
uint8_theader_type;
for (dev = 0; dev < 32; dev++) {
for (func = 0; func < 8; func++) {
for (dev = 0; dev < 32; dev++)
{
for (func = 0; func < 8; func++)
{
pci_addr = PCIADDR(bus, dev, func);
id = pci_config_read32(pci_addr, PCI_VENDOR_ID);
if (!id || id == 0xfffffffful) {
if (!id || id == 0xfffffffful)
{
continue;
}
new = (pci_dt_t*)malloc(sizeof(pci_dt_t));
if (!new) {
if (!new)
{
continue;
}
bzero(new, sizeof(pci_dt_t));
new->dev.addr= pci_addr;
new->parent= start;
header_type = pci_config_read8(pci_addr, PCI_HEADER_TYPE);
switch (header_type & 0x7f) {
case PCI_HEADER_TYPE_BRIDGE:
case PCI_HEADER_TYPE_CARDBUS:
secondary_bus = pci_config_read8(pci_addr, PCI_SECONDARY_BUS);
if (secondary_bus != 0) {
scan_pci_bus(new, secondary_bus);
}
break;
default:
break;
switch (header_type & 0x7f)
{
case PCI_HEADER_TYPE_BRIDGE:
case PCI_HEADER_TYPE_CARDBUS:
secondary_bus = pci_config_read8(pci_addr, PCI_SECONDARY_BUS);
if (secondary_bus != 0)
{
scan_pci_bus(new, secondary_bus);
}
break;
default:
break;
}
*current = new;
current = &new->next;
if ((func == 0) && ((header_type & 0x80) == 0)) {
if ((func == 0) && ((header_type & 0x80) == 0))
{
break;
}
}
{
return;
}
rcba = pci_config_read32(PCIADDR(0, 0x1f, 0), 0xf0) & ~1; //this is LPC host
fd = (uint32_t *)(rcba + 0x3418);
/* set SMBus Disable (SD) to 0 */
{
root_pci_dev = malloc(sizeof(pci_dt_t));
if (!root_pci_dev) {
if (!root_pci_dev)
{
return;
}
{
pci_dt_t*current;
pci_dt_t*end;
int dev_path_len = 0;
intdev_path_len = 0;
dev_path[0] = 0;
end = root_pci_dev;
while (current->parent != end)
current = current->parent;
end = current;
if (current->parent == root_pci_dev) {
if (current->parent == root_pci_dev)
{
dev_path_len +=
snprintf(dev_path + dev_path_len, sizeof(dev_path) - dev_path_len, "PciRoot(0x%x)/Pci(0x%x,0x%x)", uid,
current->dev.bits.dev, current->dev.bits.func);
} else {
}
else
{
dev_path_len +=
snprintf(dev_path + dev_path_len, sizeof(dev_path) - dev_path_len, "/Pci(0x%x,0x%x)",
current->dev.bits.dev, current->dev.bits.func);
trunk/i386/libsaio/msdos.c
5252
5353
5454
55
55
5656
57
58
59
60
57
58
59
60
6161
6262
6363
......
149149
150150
151151
152
153
152
154153
155154
156155
......
252251
253252
254253
255
256
254
257255
258256
259257
......
280278
281279
282280
283
284
281
285282
286283
287284
......
346343
347344
348345
349
350
346
351347
352348
353349
......
391387
392388
393389
394
390
391
392
395393
396394
397395
......
417415
418416
419417
420
421
418
422419
423
420
421
422
424423
425424
426425
427426
428427
429
428
429
430
431
430432
431433
432434
......
568570
569571
570572
571
572
573
573574
574575
575576
......
605606
606607
607608
608
609
609
610610
611611
612612
......
633633
634634
635635
636
636637
638
639
637640
638641
642
639643
644
645
640646
641647
642648
......
645651
646652
647653
654
648655
656
657
649658
650659
651660
......
662671
663672
664673
665
666
674
675
667676
668677
669678
......
683692
684693
685694
695
686696
687697
688698
......
691701
692702
693703
704
705
694706
695707
696708
......
711723
712724
713725
726
714727
728
729
715730
716731
717732
......
745760
746761
747762
763
748764
765
749766
750767
751768
752769
770
753771
754772
755773
756774
757775
758776
777
759778
760779
761780
762781
782
763783
764784
765785
......
767787
768788
769789
790
770791
792
793
771794
772795
773796
......
794817
795818
796819
797
798
820
799821
800822
801823
......
816838
817839
818840
841
819842
843
820844
821845
822846
823847
848
849
824850
825851
826852
......
828854
829855
830856
857
831858
859
832860
833861
834862
835863
836864
837865
866
838867
839868
840869
841870
842871
872
843873
844
874
875
876
845877
878
879
846880
847881
882
848883
849884
850885
......
878913
879914
880915
916
881917
918
882919
920
921
883922
923
884924
925
926
885927
928
886929
887930
888931
889932
933
934
890935
936
891937
892938
893939
894940
895941
942
896943
944
897945
946
898947
899
948
949
900950
901951
902
952
953
903954
904955
956
905957
958
959
906960
907961
908962
909963
964
910965
966
967
911968
912969
913970
914971
915972
973
916974
975
976
917977
918978
919979
......
9441004
9451005
9461006
947
948
949
950
951
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
9521017
1018
9531019
9541020
9551021
1022
9561023
957
1024
1025
9581026
9591027
9601028
961
9621029
9631030
964
965
966
967
968
1031
1032
1033
1034
1035
9691036
970
1037
9711038
9721039
9731040
9741041
9751042
1043
1044
1045
9761046
9771047
978
1048
9791049
9801050
9811051
9821052
9831053
1054
1055
9841056
985
1057
1058
9861059
9871060
9881061
......
9971070
9981071
9991072
1073
10001074
1001
1075
1076
10021077
10031078
10041079
......
10261101
10271102
10281103
1029
1030
1104
10311105
10321106
10331107
......
10471121
10481122
10491123
1050
1124
1125
10511126
10521127
10531128
1054
1055
1129
10561130
#include "msdos.h"
#define LABEL_LENGTH11
#define MSDOS_CACHE_BLOCKSIZE BPS
#define MSDOS_CACHE_BLOCKSIZEBPS
#defineCLUST_FIRST2/* reserved cluster range */
#defineCLUST_RSRVD320x0ffffff8/* reserved cluster range */
#defineCLUST_RSRVD160xfff8/* reserved cluster range */
#defineCLUST_RSRVD120xff8/* reserved cluster range */
#defineCLUST_FIRST2/* reserved cluster range */
#defineCLUST_RSRVD320x0ffffff8/* reserved cluster range */
#defineCLUST_RSRVD160xfff8/* reserved cluster range */
#defineCLUST_RSRVD120xff8/* reserved cluster range */
#define tolower(c) (((c)>='A' && c<='Z')?((c) | 0x20):(c))
}
long
MSDOSInitPartition (CICell ih)
long MSDOSInitPartition (CICell ih)
{
union bootsector *bsp;
struct bpb33 *b33;
return 0;
}
static int
readSector(CICell ih, off_t readOffset, char *buf, int size)
static int readSector(CICell ih, off_t readOffset, char *buf, int size)
{
// Caching only FAT entries (4 bytes) by utlizing the cache with sector aligned read requests.
if (size < BPS)
return 0;
}
static int
msdosreadcluster (CICell ih, uint8_t *buf, int size, off_t *cluster)
static int msdosreadcluster (CICell ih, uint8_t *buf, int size, off_t *cluster)
{
off_t readOffset;
char tmpbuf[8];
}
}
static struct direntry *
getnextdirent (CICell ih, uint16_t *longname, struct msdosdirstate *st)
static struct direntry *getnextdirent (CICell ih, uint16_t *longname, struct msdosdirstate *st)
{
struct direntry *dirp;
while (1)
bcopy (&(wdirp->wePart1),longname+WIN_CHARS*(num-1),sizeof (wdirp->wePart1));
bcopy (&(wdirp->wePart2),longname+WIN_CHARS*(num-1)+5,sizeof (wdirp->wePart2));
bcopy (&(wdirp->wePart3),longname+WIN_CHARS*(num-1)+11,sizeof (wdirp->wePart3));
} else {
}
else
{
uint8_t labelchecksum;
int i;
longname[st->vfatnumber*WIN_CHARS]=0;
}
}
static void
initRoot (struct msdosdirstate *st)
static void initRoot (struct msdosdirstate *st)
{
if (msdosrootDirSectors) {/* FAT12 or FAT16 */
if (msdosrootDirSectors)
{
/* FAT12 or FAT16 */
st->root16 = 1;
st->vfatchecksum = 0;
st->nument = 0;
st->cluster = 0;
st->vfatnumber = 0;
} else {/* FAT32 */
}
else
{
/* FAT32 */
st->root16 = 0;
st->vfatchecksum = 0;
st->nument = 0;
{0x00A0,0x00A0}
};
static int
checkname (uint16_t *ucsname, int ucslen, struct direntry *dirp, uint16_t *vfatname)
static int checkname (uint16_t *ucsname, int ucslen, struct direntry *dirp, uint16_t *vfatname)
{
uint16_t tmp[15];
if (vfatname[0])
}
static struct direntry *
getdirpfrompath (CICell ih, char *dirspec, uint8_t *buf)
static struct direntry *getdirpfrompath (CICell ih, char *dirspec, uint8_t *buf)
{
struct msdosdirstate st;
struct direntry *dirp;
{
for (;*ptr && *ptr!='/';ptr++);
if (!*ptr)
{
return dirp;
}
ptr++;
if (!*ptr)
{
return dirp;
}
for (slash=ptr;*slash && *slash!='/';slash++);
c=*slash;
*slash=0;
ucsname[ucslenhost]=0;
*slash=c;
if (!(dirp->deAttributes & ATTR_DIRECTORY))
{
return 0;
}
st.root16 = 0;
st.vfatchecksum = 0;
st.nument = 0;
char ** name, long * flags, u_int32_t * time,
FinderInfo * finderInfo, long * infoValid)
{
struct msdosdirstate *st;
struct direntry *dirp;
struct msdosdirstate*st;
struct direntry*dirp;
uint16_tvfatname[WIN_MAXLEN+2*WIN_CHARS];
if (MSDOSInitPartition (ih)<0)
{
{
return -1;
}
bzero(st,sizeof (struct msdosdirstate) );
if (dirPath[0])
{
uint8_t *buf=malloc(msdosclustersize);
free (st);
return -1;
}
bzero(buf,msdosclustersize );
dirp = getdirpfrompath (ih, dirPath, buf);
if (!dirp || !(dirp->deAttributes & ATTR_DIRECTORY))
{
}
else
{
initRoot (st);
}
*dirIndex = (long long) (long) st;
}
while((dirp = getnextdirent (ih, vfatname, st))&& (dirp->deAttributes & ATTR_VOLUME));
free (st);
return -1;
}
for (i=7;i>=0;i--)
{
if (dirp->deName[i]!=' ')
{
break;
}
}
j=i+1;
tmp[i+1]=0;
for(;i>=0;i--)
tmp[i]=(dirp->deName[i]>=128)?cp850[dirp->deName[i]-128][0]:tolower(dirp->deName[i]);
for (i=2;i>=0;i--)
{
if (dirp->deName[8+i]!=' ')
{
break;
}
}
if (i>=0)
{
tmp[j+i+1]=0;
k=j+i+1;
for(;i>=0;i--)
{
tmp[j+i]=(dirp->deName[i]>=128)?cp850[dirp->deName[i+8]-128][0]:tolower(dirp->deName[i+8]);
}
j=k;
}
return 0;
}
long
MSDOSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length)
long MSDOSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length)
{
uint8_t *buf;
off_t cluster;
{
filePath++;
}
buf = malloc(msdosclustersize);
if (!buf)
{
return -1;
}
bzero(buf,msdosclustersize);
dirp = getdirpfrompath (ih, filePath, buf);
if (!dirp || (dirp->deAttributes & ATTR_DIRECTORY))
free (buf);
return -1;
}
cluster = OSReadLittleInt16 ((dirp->deStartCluster),0);
if (msdosfatbits == 32)
{
cluster |= ((uint32_t)OSReadLittleInt16 ((dirp->deHighClust),0)) <<16;
}
size = (uint32_t)OSReadLittleInt32 ((dirp->deFileSize),0);
if (size<=offset)
{
free (buf);
return -1;
}
nskip=offset/msdosclustersize;
for (i=0;i<nskip;i++)
for (i = 0; i < nskip; i++)
{
msdosreadcluster (ih, 0, 0, &cluster);
}
msdosreadcluster (ih, buf, msdosclustersize, &cluster);
toread=length;
if (length==0 || length>size-offset)
{
toread=size-offset;
uint8_t *buf;
off_t cluster;
struct direntry *dirp;
if (MSDOSInitPartition (ih)<0)
{
return -1;
}
if (filePath[0] == '/')
{
filePath++;
}
buf = malloc(msdosclustersize);
if (!buf)
{
return -1;
}
bzero(buf,msdosclustersize);
dirp = getdirpfrompath (ih, filePath, buf);
if (!dirp || (dirp->deAttributes & ATTR_DIRECTORY))
{
free (buf);
return -1;
}
cluster = OSReadLittleInt16 ((dirp->deStartCluster),0);
if (msdosfatbits == 32)
{
cluster |= ((uint32_t)OSReadLittleInt16 ((dirp->deHighClust),0)) <<16;
}
off_t clusn;
switch (msdosfatbits) {
switch (msdosfatbits)
{
case 32:
if (cluster < CLUST_FIRST ||cluster >= CLUST_RSRVD32)
{
return -1;
}
clusn = cluster - CLUST_FIRST;
break;
case 16:
if (cluster < CLUST_FIRST ||cluster >= CLUST_RSRVD16)
{
return 0;
}
clusn = cluster - CLUST_FIRST;
break;
case 12:
if (cluster < CLUST_FIRST ||cluster >= CLUST_RSRVD12)
{
return 0;
}
clusn = cluster - CLUST_FIRST;
break;
default:
label[0] = 0xE5;
/* Remove any trailing spaces */
for (i=LABEL_LENGTH-1; i>=0; --i) {
if (label[i] == ' ')
label[i] = 0;
else
break;
for (i=LABEL_LENGTH-1; i>=0; --i)
{
if (label[i] == ' ')
{
label[i] = 0;
}
else
{
break;
}
}
labelucs[i++]=0;
len=i;
for (;i>=0;--i)
{
labelucs[i]=label[i]>=128?cp850[label[i]-128][1]:(label[i]);
}
utf_encodestr(labelucs, len, (uint8_t *)str, strMaxLen, OSHostByteOrder() );
}
void MSDOSGetDescription(CICell ih, char *str, long strMaxLen)
{
struct direntry*dirp;
uint8_tlabel[LABEL_LENGTH+1];
uint16_tvfatlabel[WIN_MAXLEN+2*WIN_CHARS];
struct msdosdirstate st;
int labelfound = 0;
struct direntry *dirp;
uint8_t label[LABEL_LENGTH+1];
uint16_t vfatlabel[WIN_MAXLEN+2*WIN_CHARS];
struct msdosdirstate st;
int labelfound = 0;
if (MSDOSInitPartition (ih)<0)
if (MSDOSInitPartition(ih) < 0)
{
str[0]=0;
return;
}
bzero(label,sizeof(label));
bzero(vfatlabel,sizeof(vfatlabel));
label[0] = '\0';
initRoot (&st);
initRoot(&st);
st.buf = malloc(msdosclustersize);
if (!st.buf)
{
return;
}
bzero(st.buf,msdosclustersize);
while ((dirp = getnextdirent (ih, vfatlabel, &st)))
if (dirp->deAttributes & ATTR_VOLUME) {
if (dirp->deAttributes & ATTR_VOLUME)
{
strncpy((char *)label, (char *)dirp->deName, LABEL_LENGTH);
labelfound = 1;
break;
utf_encodestr(vfatlabel, i, (u_int8_t *)str, strMaxLen, OSLittleEndian );
}
else if (labelfound)
{
fixLabel(label, str, strMaxLen);
}
/* else look in the boot blocks */
if (!labelfound || str[0] == '\0')
{
return;
}
long
MSDOSGetUUID(CICell ih, char *uuidStr)
long MSDOSGetUUID(CICell ih, char *uuidStr)
{
char *buf = malloc (512);
if (!buf)
if (msdosfatbits == 32) { /* It's FAT32 */
memcpy(uuidStr+12, (char *)((struct extboot *)bsp->bs710.bsExt)->exVolumeID, 4);
}
else if (msdosfatbits == 16) {
else if (msdosfatbits == 16)
{
memcpy(uuidStr+12, (char *)((struct extboot *)bsp->bs50.bsExt)->exVolumeID, 4);
}
free (buf);
return 0;
return 0;
}
trunk/i386/libsaio/state_generator.c
7272
7373
7474
75
75
7676
7777
7878
......
358358
359359
360360
361
361
362362
363363
364364
struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt *dsdt)
{
if (Platform.CPU.Vendor != 0x756E6547)
if (Platform.CPU.Vendor != CPUID_VENDOR_INTEL) // 0x756E6547
{
DBG("Not an Intel platform: P-States will not be generated !!!\n");
return NULL;
struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt *fadt)
{
if (Platform.CPU.Vendor != 0x756E6547)
if (Platform.CPU.Vendor != CPUID_VENDOR_INTEL) // 0x756E6547
{
DBG("Not an Intel platform: C-States will not be generated !!!\n");
return NULL;
trunk/i386/boot2/boot.h
6161
6262
6363
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
9292
9393
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121121
122122
123
123
124124
125125
126
126
127127
128128
129
130
129
130
131131
132132
133
133
134134
135135
136136
137137
138
138
139139
140140
141141
142142
143
144
145
146
147
148
149
150
143
144
145
146
147
148
149
150
151151
152152
153
154
155
153
154
155
156156
157157
158
158
159159
160160
161
162
163
161
162
163
164164
165165
166
166
167167
168168
169169
170170
171
172
173
174
175
176
177
178
179
180
181
171
172
173
174
175
176
177
178
179
180
181
182182
183183
184
184
185185
186186
187
187
188188
189189
190190
191191
192192
193
194
195
196
197
193
194
195
196
197
198198
199199
200200
201201
202
203
202
203
204204
205205
206206
......
277277
278278
279279
280
280
281281
282
282283
283284
284285
/*
* Keys used in system Boot.plist
*/
#define kGraphicsModeKey"Graphics Mode"
#define kTextModeKey"Text Mode"
#define kQuietBootKey"Quiet Boot"
#define kKernelFlagsKey"Kernel Flags"
#define kKernelArchKey"Kernel Architecture"
#define kMKextCacheKey"MKext Cache"
#define kKernelNameKey"Kernel"
#define kKernelCacheKey"Kernel Cache"
#define kUseKernelCache"UseKernelCache"/* boot.c */
#define kBootDeviceKey"Boot Device"
#define kTimeoutKey"Timeout"
#define kRootDeviceKey"rd"
#define kBootUUIDKey"boot-uuid"
#define kHelperRootUUIDKey"Root UUID"
#define kPlatformKey"platform"
#define kACPIKey"acpi"
#define kCDROMPromptKey"CD-ROM Prompt"
#define kCDROMOptionKey"CD-ROM Option Key"
#define kRescanPromptKey"Rescan Prompt"
#define kRescanKey"Rescan"
#define kScanSingleDriveKey"Scan Single Drive"
#define kInstantMenuKey"Instant Menu"
#define kDefaultKernel"mach_kernel"
#define kOSXKernel"kernel"// Yosemite
#define kGUIKey"GUI"
#define kBootBannerKey"Boot Banner"
#define kShowInfoKey"ShowInfo"// gui.c
#define kWaitForKeypressKey"Wait"
#define kGraphicsModeKey"Graphics Mode"
#define kTextModeKey"Text Mode"
#define kQuietBootKey"Quiet Boot"
#define kKernelFlagsKey"Kernel Flags"
#define kKernelArchKey"Kernel Architecture"
#define kMKextCacheKey"MKext Cache"
#define kKernelNameKey"Kernel"
#define kKernelCacheKey"Kernel Cache"
#define kUseKernelCache"UseKernelCache"/* boot.c */
#define kBootDeviceKey"Boot Device"
#define kTimeoutKey"Timeout"
#define kRootDeviceKey"rd"
#define kBootUUIDKey"boot-uuid"
#define kHelperRootUUIDKey"Root UUID"
#define kPlatformKey"platform"
#define kACPIKey"acpi"
#define kCDROMPromptKey"CD-ROM Prompt"
#define kCDROMOptionKey"CD-ROM Option Key"
#define kRescanPromptKey"Rescan Prompt"
#define kRescanKey"Rescan"
#define kScanSingleDriveKey"Scan Single Drive"
#define kInstantMenuKey"Instant Menu"
#define kDefaultKernel"mach_kernel"
#define kOSXKernel"kernel"// Yosemite
#define kGUIKey"GUI"
#define kBootBannerKey"Boot Banner"
#define kShowInfoKey"ShowInfo"// gui.c
#define kWaitForKeypressKey"Wait"
/* AsereBLN: added these keys */
#define kUseAtiROM"UseAtiROM"/* ati.c */
#define kWake"Wake"/* boot.c */
#define kForceWake"ForceWake"/* boot.c */
#define kWakeImage"WakeImage"/* boot.c */
#define kProductVersion"ProductVersion"/* boot.c */
#define karch"arch"/* boot.c */
#define kDSDT"DSDT"/* acpi_patcher.c */
#define kDropSSDT"DropSSDT"/* acpi_patcher.c */
#define kDeviceProperties"device-properties"/* device_inject.c */
#define kHidePartition"Hide Partition"/* disk.c */
#define kRenamePartition"Rename Partition"/* disk.c */
#define kSMBIOSKey"SMBIOS"/* fake_efi.c */
//#define kSystemID"SystemId"/* fake_efi.c */
#define kSystemType"SystemType"/* fake_efi.c */
#define kUseNvidiaROM"UseNvidiaROM"/* nvidia.c */
#define kVBIOS"VBIOS"/* nvidia.c && ati.c */
#define kPCIRootUID"PCIRootUID"/* pci_root.c */
#define kEthernetBuiltIn"EthernetBuiltIn"/* pci_setup.c */
#define kGraphicsEnabler"GraphicsEnabler"/* pci_setup.c */
#define kForceHPET"ForceHPET"/* pci_setup.c */
#define kUseMemDetect"UseMemDetect"/* platform.c */
#define kSMBIOSdefaults"SMBIOSdefaults"/* smbios_patcher.c */
#define kUSBBusFix"USBBusFix"/* usb.c */
#define kEHCIacquire"EHCIacquire"/* usb.c */
#define kUHCIreset"UHCIreset"/* usb.c */
#define kEHCIhard"EHCIhard"/* usb.c */
#define kDefaultPartition"Default Partition"/* sys.c */
#define kUseAtiROM"UseAtiROM"/* ati.c */
#define kWake"Wake"/* boot.c */
#define kForceWake"ForceWake"/* boot.c */
#define kWakeImage"WakeImage"/* boot.c */
#define kProductVersion"ProductVersion"/* boot.c */
#define karch"arch"/* boot.c */
#define kDSDT"DSDT"/* acpi_patcher.c */
#define kDropSSDT"DropSSDT"/* acpi_patcher.c */
#define kDeviceProperties"device-properties"/* device_inject.c */
#define kHidePartition"Hide Partition"/* disk.c */
#define kRenamePartition"Rename Partition"/* disk.c */
#define kSMBIOSKey"SMBIOS"/* fake_efi.c */
//#define kSystemID"SystemId"/* fake_efi.c */
#define kSystemType"SystemType"/* fake_efi.c */
#define kUseNvidiaROM"UseNvidiaROM"/* nvidia.c */
#define kVBIOS"VBIOS"/* nvidia.c && ati.c */
#define kPCIRootUID"PCIRootUID"/* pci_root.c */
#define kEthernetBuiltIn"EthernetBuiltIn"/* pci_setup.c */
#define kGraphicsEnabler"GraphicsEnabler"/* pci_setup.c */
#define kForceHPET"ForceHPET"/* pci_setup.c */
#define kUseMemDetect"UseMemDetect"/* platform.c */
#define kSMBIOSdefaults"SMBIOSdefaults"/* smbios_patcher.c */
#define kUSBBusFix"USBBusFix"/* usb.c */
#define kEHCIacquire"EHCIacquire"/* usb.c */
#define kUHCIreset"UHCIreset"/* usb.c */
#define kEHCIhard"EHCIhard"/* usb.c */
#define kDefaultPartition"Default Partition"/* sys.c */
/* Zenith432: added this */
#define kXHCILegacyOff"XHCILegacyOff"/* usb.c */
#define kXHCILegacyOff"XHCILegacyOff"/* usb.c */
/* Duvel300: added this */
#define kRestartFix"RestartFix"/* acpi_patcher.c */
#define kRestartFix"RestartFix"/* acpi_patcher.c */
/* Slice: added this */
#define kPS2RestartFix"PS2RestartFix"/* acpi_patcher.c */
#define kUseIntelHDMI"UseIntelHDMI"/* ati.c && nvidia.c && gma.c */
#define kPS2RestartFix"PS2RestartFix"/* acpi_patcher.c */
#define kUseIntelHDMI"UseIntelHDMI"/* ati.c && nvidia.c && gma.c */
/* Signal64: added this key */
#define kLegacyOff"USBLegacyOff"/* usb.c */
#define kLegacyOff"USBLegacyOff"/* usb.c */
/* Lebidou: added this key */
/* Meklort: added this key */
#define kMD0Image"md0"/* ramdisk.h */
#define kMD0Image"md0"/* ramdisk.h */
/* Andyvand: added these keys */
/* Mojodojo: added these keys */
#define kGeneratePStates"GeneratePStates"/* acpi_patcher.c */
#define kGenerateCStates"GenerateCStates"/* acpi_patcher.c */
#define kCSTUsingSystemIO"CSTUsingSystemIO"/* acpi_patcher.c */
#define kEnableC2State"EnableC2State"/* acpi_patcher.c */
#define kEnableC3State"EnableC3State"/* acpi_patcher.c */
#define kEnableC4State"EnableC4State"/* acpi_patcher.c */
#define kEnableC6State"EnableC6State"/* acpi_patcher.c */
#define kEnableC7State"EnableC7State"/* acpi_patcher.c */
#define kGeneratePStates"GeneratePStates"/* acpi_patcher.c */
#define kGenerateCStates"GenerateCStates"/* acpi_patcher.c */
#define kCSTUsingSystemIO"CSTUsingSystemIO"/* acpi_patcher.c */
#define kEnableC2State"EnableC2State"/* acpi_patcher.c */
#define kEnableC3State"EnableC3State"/* acpi_patcher.c */
#define kEnableC4State"EnableC4State"/* acpi_patcher.c */
#define kEnableC6State"EnableC6State"/* acpi_patcher.c */
#define kEnableC7State"EnableC7State"/* acpi_patcher.c */
/* valv: added these keys */
#define kbusratio"busratio"/* cpu.c */
#define kDcfg0"display_0"/* nvidia.c */
#define kDcfg1"display_1"/* nvidia.c */
#define kbusratio"busratio"/* cpu.c */
#define kDcfg0"display_0"/* nvidia.c */
#define kDcfg1"display_1"/* nvidia.c */
/* Marchrius: added these keys */
#define kEnableBacklight"EnableBacklight"/* nvidia.c */
#define kEnableBacklight"EnableBacklight"/* nvidia.c */
/* Kabyl: added these keys */
#define kAtiConfig"AtiConfig"/* ati.c */
#define kAtiPorts"AtiPorts"/* ati.c */
#define kATYbinimage"ATYbinimage"/* ati.c */
#define kAtiConfig"AtiConfig"/* ati.c */
#define kAtiPorts"AtiPorts"/* ati.c */
#define kATYbinimage"ATYbinimage"/* ati.c */
/* cosmo1: added these keys */
#define kEnableHDMIAudio"EnableHDMIAudio"/* ati.c && nvidia.c */
#define kEnableHDMIAudio"EnableHDMIAudio"/* ati.c && nvidia.c */
/* cparm: added these keys */
/* ErmaC: added these keys */
#define kEnableDualLink"EnableDualLink"/* nvidia.c && gma.c*/
#define kNvidiaGeneric"NvidiaGeneric"/* nvidia.c */
#define kSkipIntelGfx"SkipIntelGfx"/* pci_setup.c */
#define kSkipNvidiaGfx"SkipNvidiaGfx"/* pci_setup.c */
#define kSkipAtiGfx"SkipAtiGfx"/* pci_setup.c */
#define kIntelCapriFB"IntelCapriFB"/* gma.c was HD4K-ig */
#define kIntelAzulFB"IntelAzulFB"/* gma.c was HD5K-ig */
#define kAAPLCustomIG"InjectIntel-ig"/* gma.c */
#define kHDAEnabler"HDAEnabler"/* pci_setup.c */
#define kHDEFLayoutID"HDEFLayoutID"/* hda.c */
#define kHDAULayoutID"HDAULayoutID"/* hda.c */
#define kEnableDualLink"EnableDualLink"/* nvidia.c && gma.c*/
#define kNvidiaGeneric"NvidiaGeneric"/* nvidia.c */
#define kSkipIntelGfx"SkipIntelGfx"/* pci_setup.c */
#define kSkipNvidiaGfx"SkipNvidiaGfx"/* pci_setup.c */
#define kSkipAtiGfx"SkipAtiGfx"/* pci_setup.c */
#define kIntelCapriFB"IntelCapriFB"/* gma.c was HD4K-ig */
#define kIntelAzulFB"IntelAzulFB"/* gma.c was HD5K-ig */
#define kAAPLCustomIG"InjectIntel-ig"/* gma.c */
#define kHDAEnabler"HDAEnabler"/* pci_setup.c */
#define kHDEFLayoutID"HDEFLayoutID"/* hda.c */
#define kHDAULayoutID"HDAULayoutID"/* hda.c */
/* Karas: added these keys */
#define kMemFullInfo"ForceFullMemInfo"/* smbios.c */
#define kMemFullInfo"ForceFullMemInfo"/* smbios.c */
/* Bungo: added these keys */
#define kPrivateData"PrivateData"/* smbios_decode.c */
#define kPrivateData"PrivateData"/* smbios_decode.c */
/*
* Flags to the booter or kernel
*/
#define kVerboseModeFlag"-v"
#define kSafeModeFlag"-x"
#define kIgnoreCachesFlag"-f"
#define kIgnoreBootFileFlag"-F"
#define kSingleUserModeFlag"-s"
#define kVerboseModeFlag"-v"
#define kSafeModeFlag"-x"
#define kIgnoreCachesFlag"-f"
#define kIgnoreBootFileFlag"-F"
#define kSingleUserModeFlag"-s"
/*
* Booter behavior control
*/
#define kBootTimeout-1
#define kCDBootTimeout8
#define kBootTimeout-1
#define kCDBootTimeout8
/*
* A global set by boot() to record the device that the booter was loaded from.
extern long LoadDrivers(char * dirSpec);
extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize);
typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin);
// Bungo
// Bungo
extern char *gDarwinBuildVerStr;
/*!
Hookable function pointer called during the driver loading phase that
allows other code to cause additional drivers to be loaded.
trunk/i386/boot2/bmdecompress.c
4141
4242
4343
44
45
46
47
48
49
4450
4551
4652
......
153159
154160
155161
162
163
164
165
166
167
156168
157169
158170
uint16_t * sc1 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t));
if (!sc0 || !sc1 || !sc2 || !sc3)
{
return;
}
uint32_t sr0, sr1, sr2, sr3;
bzero(sc0, (width+2) * sizeof(uint16_t));
uint16_t * sc1 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t));
if (!sc0 || !sc1 || !sc2 || !sc3)
{
return;
}
uint32_t sr0, sr1, sr2, sr3;
bzero(sc0, (width+2) * sizeof(uint16_t));
trunk/i386/boot2/options.c
3838
3939
4040
41
42
41
42
4343
4444
4545
#define DBG(x...)msglog(x)
#endif
bool showBootBanner = true; //Azi:showinfo
static bool shouldboot = false;
boolshowBootBanner = true; //Azi:showinfo
static boolshouldboot = false;
extern int multiboot_timeout;
extern int multiboot_timeout_set;

Archive Download the corresponding diff file

Revision: 2539