Chameleon

Chameleon Commit Details

Date:2015-01-21 02:16:43 (4 years 9 months ago)
Author:ErmaC
Commit:2542
Parents: 2541
Message:Sync with trunk (r.2541)
Changes:
M/branches/ErmaC/Enoch/i386/libsaio/smbios.c
M/branches/ErmaC/Enoch/i386/modules/Resolution/edid.c
M/branches/ErmaC/Enoch/i386/libsa/prf.c
M/branches/ErmaC/Enoch/i386/libsaio/smbios_decode.c
M/branches/ErmaC/Enoch/i386/libsaio/smbios.h
M/branches/ErmaC/Enoch/i386/boot2/graphics.c
M/branches/ErmaC/Enoch/package/po/hr.po
M/branches/ErmaC/Enoch/package/po/nl.po
M/branches/ErmaC/Enoch/i386/libsaio/gma.c
M/branches/ErmaC/Enoch/package/po/pl.po
M/branches/ErmaC/Enoch/i386/libsaio/pci.c
M/branches/ErmaC/Enoch/i386/boot2/modules.c
M/branches/ErmaC/Enoch/CHANGES
M/branches/ErmaC/Enoch/package/po/ca.po
M/branches/ErmaC/Enoch/i386/libsaio/stringTable.c
M/branches/ErmaC/Enoch/package/po/sr.po
M/branches/ErmaC/Enoch/i386/libsaio/pci_root.c
M/branches/ErmaC/Enoch/i386/libsaio/convert.c
M/branches/ErmaC/Enoch/i386/libsaio/saio_types.h
M/branches/ErmaC/Enoch/i386/libsa/memory.h
M/branches/ErmaC/Enoch/i386/libsaio/msdos.c
M/branches/ErmaC/Enoch/i386/libsaio/state_generator.c
M/branches/ErmaC/Enoch/i386/boot2/gui.c
M/branches/ErmaC/Enoch/i386/libsaio/smbios_getters.c
M/branches/ErmaC/Enoch/i386/libsaio/fake_efi.c
M/branches/ErmaC/Enoch/i386/modules/Resolution/915resolution.c
M/branches/ErmaC/Enoch/i386/libsaio/device_inject.c
M/branches/ErmaC/Enoch/i386/libsaio/state_generator.h
M/branches/ErmaC/Enoch/i386/libsaio/saio_internal.h
M/branches/ErmaC/Enoch/i386/boot2/options.c
M/branches/ErmaC/Enoch/i386/libsaio/asm.s
M/branches/ErmaC/Enoch/i386/include/IOKit/storage/IOFDiskPartitionScheme.h
M/branches/ErmaC/Enoch/package/po/mk.po
M/branches/ErmaC/Enoch/i386/libsaio/console.c
M/branches/ErmaC/Enoch/i386/libsaio/fdisk.h
M/branches/ErmaC/Enoch/package/po/hu.po
M/branches/ErmaC/Enoch/i386/boot2/boot.c
M/branches/ErmaC/Enoch/i386/libsaio/bootstruct.c
M/branches/ErmaC/Enoch/i386/libsaio/ntfs_private.h
M/branches/ErmaC/Enoch/i386/libsaio/ntfs.c
M/branches/ErmaC/Enoch/i386/boot2/boot.h
M/branches/ErmaC/Enoch/i386/libsaio/vbe.c
M/branches/ErmaC/Enoch/i386/libsaio/sys.c
M/branches/ErmaC/Enoch/i386/libsaio/device_tree.c
M/branches/ErmaC/Enoch/i386/libsaio/hfs.c
M/branches/ErmaC/Enoch/i386/boot2/drivers.c
M/branches/ErmaC/Enoch/i386/libsaio/acpi.h
M/branches/ErmaC/Enoch/i386/libsaio/acpi_patcher.c
M/branches/ErmaC/Enoch/i386/libsaio/spd.c
M/branches/ErmaC/Enoch/i386/libsaio/cpu.c
M/branches/ErmaC/Enoch/i386/libsaio/disk.c

File differences

branches/ErmaC/Enoch/i386/libsaio/asm.s
548548
549549
550550
551
551
popl%edx
ret
// computeRand() end function - - - - - - - - - - - - - - - - - - - - - - - -
branches/ErmaC/Enoch/i386/libsaio/console.c
6767
6868
6969
70
71
72
73
74
75
76
77
78
79
80
81
7082
7183
7284
......
8698
8799
88100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
89126
90127
91128
......
99136
100137
101138
102
139
140
103141
104142
105143
106
144
145
107146
108147
109148
......
117156
118157
119158
120
159
160
121161
122162
123163
......
174214
175215
176216
217
177218
178219
179220
......
300341
301342
302343
303
344
304345
305
346
306347
307348
char *msgbuf = 0;
char *cursor = 0;
// Bungo:
typedef struct {
uint16_t year;
uint8_t mon;
uint8_t day;
uint8_t hour;
uint8_t mins;
uint8_t secs;
uint8_t dlight;
} datetime_t;
static datetime_t datetime;
struct putc_info //Azi: exists on gui.c & printf.c
{
char * str;
return c;
}
uint64_t getRTCdatetime() // 0xYYYYMMDDHHMMSS0L in decimal
{
biosBuf_t bb;
bb.intno = 0x1a;
bb.eax.r.h = 0x04; // get RTC date
//bb.flags.cf = 0;
bios(&bb);
if (bb.flags.cf) return 0;
datetime.year = (bb.ecx.r.h >> 4) * 1000 + (bb.ecx.r.h & 0x0F) * 100 + (bb.ecx.r.l >> 4) * 10 + (bb.ecx.r.l & 0x0F) * 1;
datetime.mon = (bb.edx.r.h >> 4) * 10 + (bb.edx.r.h & 0x0F) * 1;
datetime.day = (bb.edx.r.l >> 4) * 10 + (bb.edx.r.l & 0x0F) * 1;
bb.intno = 0x1a;
bb.eax.r.h = 0x02; // get RTC time
//bb.flags.cf = 0;
bios(&bb);
if (bb.flags.cf) return 0;
datetime.dlight = bb.edx.r.l & 0x0F;
datetime.hour = (bb.ecx.r.h >> 4) * 10 + (bb.ecx.r.h & 0x0F) * 1;
datetime.mins = (bb.ecx.r.l >> 4) * 10 + (bb.ecx.r.l & 0x0F) * 1;
datetime.secs = (bb.edx.r.h >> 4) * 10 + (bb.edx.r.h & 0x0F) * 1;
return *(uint64_t *)&datetime;
}
void initBooterLog(void)
{
msgbuf = malloc(BOOTER_LOG_SIZE);
va_list ap;
struct putc_info pi;
if (!msgbuf) {
if (!msgbuf)
{
return;
}
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) {
if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))
{
return;
}
void setupBooterLog(void)
{
if (!msgbuf) {
if (!msgbuf)
{
return;
}
int printf(const char * fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
}
/** Print a "Press a key to continue..." message and wait for a key press. */
void pause()
void pause()
{
printf("Press a key to continue...\n");
printf("Press a key to continue...\n");
getchar(); // replace getchar() by pause() were useful.
}
branches/ErmaC/Enoch/i386/libsaio/bootstruct.c
9797
9898
9999
100
100101
101102
102103
if (node == 0) {
stop("Couldn't create root node");
}
getPlatformName(platformName);
nameLen = strlen(platformName) + 1;
DT__AddProperty(node, "compatible", nameLen, platformName);
branches/ErmaC/Enoch/i386/libsaio/ntfs_private.h
9494
9595
9696
97
9798
9899
99100
......
105106
106107
107108
108
109
110
109
110
111
112
111113
112
113
114
115
114
115
116
117
116118
117119
120
118121
119122
120123
......
144147
145148
146149
147
150
148151
149152
150153
......
266269
267270
268271
269
272
270273
271274
272275
......
275278
276279
277280
278
281
279282
280
283
281284
282285
283286
};
#define NTFS_AF_INRUN0x00000001
struct attrhdr {
u_int32_t a_type;
u_int32_t reclen;
u_int8_t reserved2;
u_int16_t a_index;
};
#define NTFS_A_STD0x10
#define NTFS_A_ATTRLIST0x20
#define NTFS_A_NAME0x30
#define NTFS_A_STD0x10
#define NTFS_A_ATTRLIST0x20
#define NTFS_A_NAME0x30
#define NTFS_A_VOLUMENAME0x60
#define NTFS_A_DATA0x80
#defineNTFS_A_INDXROOT0x90
#defineNTFS_A_INDX0xA0
#define NTFS_A_INDXBITMAP 0xB0
#define NTFS_A_DATA0x80
#defineNTFS_A_INDXROOT0x90
#defineNTFS_A_INDX0xA0
#define NTFS_A_INDXBITMAP0xB0
#define NTFS_MAXATTRNAME255
struct attr {
struct attrhdr a_hdr;
union {
u_int64_t t_write;
u_int64_t t_mftwrite;
u_int64_t t_access;
} ntfs_times_t;
} ntfs_times_t;
#define NTFS_FFLAG_RDONLY0x01LL
#define NTFS_FFLAG_HIDDEN0x02LL
u_int8_t bf_spc;/* sectors per cluster */
u_int8_t reserved2[7];/* unused (zeroed) */
u_int8_t bf_media;/* media desc. (0xF8) */
u_int8_t reserved3[2];
u_int8_t reserved3[2];/* always 0 */
u_int16_t bf_spt;/* sectors per track */
u_int16_t bf_heads;/* number of heads */
u_int8_t reserver4[12];
cn_t bf_mftmirrcn;/* $MFTMirr cn */
u_int8_t bf_mftrecsz;/* MFT record size (clust) */
/* 0xF6 inducates 1/4 */
u_int8_t reserved5[3];
u_int8_t reserved5[3];
u_int8_t bf_ibsz;/* index buffer size */
u_int8_t reserved6[3];
u_int8_t reserved6[3];
u_int64_t bf_volsn;/* volume ser. num. */
};
branches/ErmaC/Enoch/i386/libsaio/vbe.c
6969
7070
7171
72
72
7373
7474
7575
......
8181
8282
8383
84
84
8585
8686
8787
......
268268
269269
270270
271
272
273
274
275
276
277
278
279
271
272
273
274
275
276
277
278
279
280
280281
281282
282283
283284
284285
285286
286
287
288
289
290
291
292
293
294
287
288
289
290
291
292
293
294
295
295296
296297
297298
298299
299300
300301
301
302
303
304
305
306
307
308
309
302
303
304
305
306
307
308
309
310
310311
311312
312313
313314
314315
315316
316
317
318
319
320
317
318
319
320
321
321322
322323
323324
324325
325326
326327
327
328
329
330
331
332
333
334
328
329
330
331
332
333
334
335
335336
#endif /* UNUSED */
//==============================================================================
int getVBEInfo( void * infoBlock )
int getVBEInfo( void *infoBlock )
{
bb.intno = 0x10;
bb.eax.rr = funcGetControllerInfo;
//==============================================================================
int getVBEModeInfo( int mode, void * minfo_p )
int getVBEModeInfo( int mode, void *minfo_p )
{
bb.intno = 0x10;
bb.eax.rr = funcGetModeInfo;
int setVBEMode(unsigned short mode, const VBECRTCInfoBlock * timing)
{
bb.intno = 0x10;
bb.eax.rr = funcSetMode;
bb.ebx.rr = mode;
if (timing) {
bb.es = SEG(timing);
bb.edi.rr = OFF(timing);
}
bios(&bb);
return(bb.eax.r.h);
bb.intno = 0x10;
bb.eax.rr = funcSetMode;
bb.ebx.rr = mode;
if (timing)
{
bb.es = SEG(timing);
bb.edi.rr = OFF(timing);
}
bios(&bb);
return(bb.eax.r.h);
}
//==============================================================================
int setVBEPalette(void *palette)
{
bb.intno = 0x10;
bb.eax.rr = funcGetSetPaletteData;
bb.ebx.r.l = subfuncSet;
bb.ecx.rr = 256;
bb.edx.rr = 0;
bb.es = SEG(palette);
bb.edi.rr = OFF(palette);
bios(&bb);
return(bb.eax.r.h);
bb.intno = 0x10;
bb.eax.rr = funcGetSetPaletteData;
bb.ebx.r.l = subfuncSet;
bb.ecx.rr = 256;
bb.edx.rr = 0;
bb.es = SEG(palette);
bb.edi.rr = OFF(palette);
bios(&bb);
return(bb.eax.r.h);
}
//==============================================================================
int getVBEPalette(void *palette)
{
bb.intno = 0x10;
bb.eax.rr = funcGetSetPaletteData;
bb.ebx.r.l = subfuncGet;
bb.ecx.rr = 256;
bb.edx.rr = 0;
bb.es = SEG(palette);
bb.edi.rr = OFF(palette);
bios(&bb);
return(bb.eax.r.h);
bb.intno = 0x10;
bb.eax.rr = funcGetSetPaletteData;
bb.ebx.r.l = subfuncGet;
bb.ecx.rr = 256;
bb.edx.rr = 0;
bb.es = SEG(palette);
bb.edi.rr = OFF(palette);
bios(&bb);
return(bb.eax.r.h);
}
//==============================================================================
int getVBECurrentMode(unsigned short *mode)
{
bb.intno = 0x10;
bb.eax.rr = funcGetCurrentMode;
bios(&bb);
*mode = bb.ebx.rr;
return(bb.eax.r.h);
bb.intno = 0x10;
bb.eax.rr = funcGetCurrentMode;
bios(&bb);
*mode = bb.ebx.rr;
return(bb.eax.r.h);
}
//==============================================================================
int getVBEPixelClock(unsigned short mode, unsigned long * pixelClock)
{
bb.intno = 0x10;
bb.eax.rr = funcGetSetPixelClock;
bb.ebx.r.l = 0;
bb.ecx.rx = *pixelClock;
bb.edx.rr = mode;
bios(&bb);
*pixelClock = bb.ecx.rx;
return(bb.eax.r.h);
bb.intno = 0x10;
bb.eax.rr = funcGetSetPixelClock;
bb.ebx.r.l = 0;
bb.ecx.rx = *pixelClock;
bb.edx.rr = mode;
bios(&bb);
*pixelClock = bb.ecx.rx;
return(bb.eax.r.h);
}
branches/ErmaC/Enoch/i386/libsaio/device_tree.c
8787
8888
8989
90
90
9191
9292
9393
9494
9595
96
96
9797
9898
9999
......
159159
160160
161161
162
162
163163
164164
165165
......
183183
184184
185185
186
187
186
187
188188
189189
190190
......
239239
240240
241241
242
242
243243
244244
245245
......
256256
257257
258258
259
259260
260261
261262
......
430431
431432
432433
433
434
434435
435436
436437
437
438
438439
439440
440441
......
447448
448449
449450
450
451
452
453
454
451
452
453
454
455
455456
456
457
457458
458
459
460
459
460
461
461462
462
463
464
463
464
465
466
465467
466
467468
468
469
470
469
470
471
472
473
471474
472
473
474
475
476
477
475478
476
477
478
479479
480480
481481
{
Property *prop;
DPRINTF("DT__AddProperty([Node '%s'], '%s', %d, 0x%x)\n", DT__GetName(node), name, length, value);
DPRINTF("DT__AddProperty([Node '%s'], '%s', %d, 0x%X)\n", DT__GetName(node), name, length, value);
if (freeProperties == NULL) {
void *buf = malloc(kAllocSize);
int i;
DPRINTF("Allocating more free properties\n");
DPRINTF("DT__AddProperty: Allocating more free properties\n");
if (buf == 0) {
return 0;
int i;
DPRINTF("Allocating more free nodes\n");
DPRINTF("DT__AddChild: Allocating more free nodes\n");
bzero(buf, kAllocSize);
node = (Node *)buf;
node = freeNodes;
freeNodes = node->next;
DPRINTF("Got free node 0x%x\n", node);
DPRINTF("prop = 0x%x, children = 0x%x, next = 0x%x\n", node->properties, node->children, node->next);
DPRINTF("DT__AddChild: Got free node 0x%x\n", node);
DPRINTF("DT__AddChild: prop = 0x%x, children = 0x%x, next = 0x%x\n", node->properties, node->children, node->next);
if (parent == NULL)
{
DTInfo.totalPropertySize = 0;
rootNode = DT__AddChild(NULL, "/");
DPRINTF("DT__Initialize done\n");
DPRINTF("DT__Initialize: done\n");
}
//==============================================================================
for (prop = allocedProperties; prop != NULL; prop = prop->next)
{
free((void *)(prop->name));
free(prop->value);
}
// Start at root
node = rootNode;
DPRINTF("root = 0x%x\n", rootNode);
DPRINTF("DT__FindNode: root = 0x%x\n", rootNode);
while (node)
{
// Skip leading slash
// Skip leading slash(es)
while (*path == '/')
{
path++;
*bp = '\0';
if (nameBuf[0] == '\0')
{
// last path entry
break;
}
if (nameBuf[0] == '\0')
{
// last path entry
break;
}
DPRINTF("Node '%s'\n", nameBuf);
DPRINTF("DT__FindNode: Node '%s'\n", nameBuf);
for (child = node->children; child != 0; child = child->next)
{
DPRINTF("Child 0x%x\n", child);
for (child = node->children; child != 0; child = child->next)
{
DPRINTF("DT__FindNode: Child 0x%x\n", child);
if (strcmp(DT__GetName(child), nameBuf) == 0)
{
break;
if (strcmp(DT__GetName(child), nameBuf) == 0)
{
break;
}
}
}
if (child == 0 && createIfMissing)
{
DPRINTF("Creating node\n");
if (child == 0 && createIfMissing)
{
char *str = malloc(strlen(nameBuf) + 1);
// XXX this will leak
strcpy(str, nameBuf);
char *str = malloc(strlen(nameBuf) + 1);
// XXX this will leak
strcpy(str, nameBuf);
child = DT__AddChild(node, str);
DPRINTF("DT__FindNode: Creating node: %s\n", str);
}
child = DT__AddChild(node, str);
}
node = child;
}
branches/ErmaC/Enoch/i386/libsaio/hfs.c
290290
291291
292292
293
293
294294
295295
296296
......
453453
454454
455455
456
456
457457
458458
459459
......
505505
506506
507507
508
508
509509
510510
511511
......
568568
569569
570570
571
571
572572
573573
574574
return HFSReadFile(ih, filePath, (void *)gFSLoadAddress, 0, 0);
}
long HFSReadFile(CICell ih, char * filePath, void *base, u_int64_t offset, u_int64_t length)
long HFSReadFile(CICell ih, char *filePath, void *base, u_int64_t offset, u_int64_t length)
{
char entry[512];
char devStr[12];
nodeSize = SWAP_BE16(gBTHeaders[kBTreeCatalog]->nodeSize);
firstLeafNode = SWAP_BE32(gBTHeaders[kBTreeCatalog]->firstLeafNode);
dirIndex = (long long) firstLeafNode * nodeSize;
dirIndex = (long long)firstLeafNode * nodeSize;
GetCatalogEntry(&dirIndex, &name, &flags, &time, 0, 0);
if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
{
printf("HFS: Resolve path %s failed\n", filePath);
printf("HFS: Resolve path '%s' failed\n", filePath);
return -1;
}
if (offset > fileLength)
{
printf("Offset is too large.\n");
printf("ReadFile(HFS%c): Offset is too large.\n", gIsHFSPlus ? "+" : "");
return -1;
}
branches/ErmaC/Enoch/i386/libsaio/acpi_patcher.c
4242
4343
4444
45
45
4646
4747
4848
......
6565
6666
6767
68
68
6969
7070
7171
72
72
7373
74
74
7575
7676
7777
......
9797
9898
9999
100
100
101101
102102
103103
104104
105105
106106
107
107
108108
109109
110110
......
127127
128128
129129
130
130
131131
132
132
133133
134134
135135
136136
137137
138
138
139139
140140
141
141
142142
143143
144
145
144
145
146146
147147
148148
149149
150
150
151151
152152
153
153
154154
155155
156156
157157
158158
159159
160
161
162
160
161
162
163163
164
164
165165
166166
167167
168
168
169169
170170
171171
172172
173173
174
174
175175
176176
177177
......
186186
187187
188188
189
189
190190
191191
192192
......
202202
203203
204204
205
205
206206
207207
208208
......
212212
213213
214214
215
215
216216
217217
218218
219219
220
220
221221
222222
223223
......
253253
254254
255255
256
256
257257
258258
259259
260260
261261
262262
263
263
264264
265265
266266
......
511511
512512
513513
514
514
515515
516516
517517
......
550550
551551
552552
553
553
554554
555555
556556
......
564564
565565
566566
567
567
568568
569569
570570
......
573573
574574
575575
576
576
577577
578578
579
579
580580
581581
582
583
582
583
584584
585585
586586
587587
588588
589589
590
591
592
593
594
595
590
591
592
593
594
595
596596
597597
598598
......
616616
617617
618618
619
619
620620
621621
622622
......
756756
757757
758758
759
759
760760
761761
762762
......
781781
782782
783783
784
785
786
787
788
784
785
786
787
788
789
789790
790791
791792
......
832833
833834
834835
835
836
836837
837838
838
839
840
841
839
840
841
842
842843
843
844
844845
845846
846847
847848
848
849
849850
850851
851852
......
10601061
10611062
10621063
1063
1064
1065
1066
1064
1065
1066
1067
1068
10671069
10681070
10691071
}
/* Gets the ACPI 1.0 RSDP address */
static struct acpi_2_rsdp* getAddressOfAcpiTable()
static struct acpi_2_rsdp *getAddressOfAcpiTable()
{
/* TODO: Before searching the BIOS space we are supposed to search the first 1K of the EBDA */
}
/* Gets the ACPI 2.0 RSDP address */
static struct acpi_2_rsdp* getAddressOfAcpi20Table()
static struct acpi_2_rsdp *getAddressOfAcpi20Table()
{
/* TODO: Before searching the BIOS space we are supposed to search the first 1K of the EBDA */
void *acpi_addr = (void*)ACPI_RANGE_START;
void *acpi_addr = (void *)ACPI_RANGE_START;
for(; acpi_addr <= (void*)ACPI_RANGE_END; acpi_addr += 16)
for(; acpi_addr <= (void *)ACPI_RANGE_END; acpi_addr += 16)
{
if(*(uint64_t *)acpi_addr == ACPI_SIGNATURE_UINT64_LE)
{
/* The folowing ACPI Table search algo. should be reused anywhere needed:*/
/* WARNING: outDirspec string will be overwritten by subsequent calls! */
int search_and_get_acpi_fd(const char * filename, const char ** outDirspec)
int search_and_get_acpi_fd(const char *filename, const char **outDirspec)
{
int fd = 0;
static char dirSpec[512];
// Try finding 'filename' in the usual places
// Start searching any potential location for ACPI Table
snprintf(dirSpec, sizeof(dirSpec), "%s", filename);
snprintf(dirSpec, sizeof(dirSpec), "%s", filename);
fd = open(dirSpec, 0);
if (fd < 0)
{
return fd;
}
void *loadACPITable (const char * filename)
void *loadACPITable (const char *filename)
{
const char * dirspec=NULL;
const char *dirspec = NULL;
int fd = search_and_get_acpi_fd(filename, &dirspec);
if (fd >= 0)
{
void *tableAddr = (void*)AllocateKernelMemory(file_size (fd));
void *tableAddr = (void*)AllocateKernelMemory(file_size(fd));
if (tableAddr)
{
if (read (fd, tableAddr, file_size (fd))!=file_size (fd))
if (read(fd, tableAddr, file_size(fd)) != file_size(fd))
{
DBG("Couldn't read table %s\n",dirspec);
free (tableAddr);
close (fd);
free(tableAddr);
close(fd);
return NULL;
}
DBG("Table %s read and stored at: %x\n", dirspec, tableAddr);
close (fd);
close(fd);
return tableAddr;
}
close (fd);
close(fd);
DBG("Couldn't allocate memory for table \n", dirspec);
}
//printf("Couldn't find table %s\n", filename);
return NULL;
}
uint8_tacpi_cpu_count = 0;
char* acpi_cpu_name[32];
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)
void get_acpi_cpu_names(unsigned char *dsdt, uint32_t length)
{
uint32_t i;
DBG("Start finding cpu names. length %d\n", length);
DBG("ACPIpatcher: start finding cpu names. Length %d\n", length);
for (i=0; i<length-7; i++)
{
if (dsdt[i] == 0x5B && dsdt[i+1] == 0x83) // ProcessorOP
{
DBG("DSDT: %x%x\n", dsdt[i], dsdt[i+1]);
DBG("ACPIpatcher: DSDT[%X%X]\n", dsdt[i], dsdt[i+1]);
uint32_t offset = i + 3 + (dsdt[i+2] >> 6);
if (!aml_isvalidchar(c))
{
add_name = false;
DBG("Invalid character found in ProcessorOP 0x%x!\n", c);
DBG("ACPIpatcher: invalid character found in ProcessorOP '0x%X'!\n", c);
break;
}
}
acpi_cpu_p_blk = dsdt[i] | (dsdt[i+1] << 8);
}
DBG("Found ACPI CPU: %c%c%c%c\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]);
DBG("ACPIpatcher: found ACPI CPU [%c%c%c%c]\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]);
if (++acpi_cpu_count == 32)
{
}
}
DBG("End finding cpu names: cpu names found: %d\n", acpi_cpu_count);
DBG("ACPIpatcher: finished finding cpu names. Found: %d.\n", acpi_cpu_count);
}
struct acpi_2_fadt *patch_fadt(struct acpi_2_fadt *fadt, struct acpi_2_dsdt *new_dsdt)
{
extern void setupSystemType();
extern void setupSystemType();
struct acpi_2_fadt *fadt_mod = NULL;
bool fadt_rev2_needed = false;
// Allocate new fadt table
if (fadt->Length < 0x84 && fadt_rev2_needed)
{
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(0x84);
fadt_mod = (struct acpi_2_fadt *)AllocateKernelMemory(0x84);
memcpy(fadt_mod, fadt, fadt->Length);
fadt_mod->Length = 0x84;
fadt_mod->Revision = 0x02; // FADT rev 2 (ACPI 1.0B MS extensions)
}
else
{
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length);
fadt_mod = (struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length);
memcpy(fadt_mod, fadt, fadt->Length);
}
// Determine system type / PM_Model
int ssdt_count=0;
// SSDT Options
bool drop_ssdt=false, generate_pstates=false, generate_cstates=false;
bool drop_ssdt = false, generate_pstates = false, generate_cstates = false;
getBoolForKey(kDropSSDT, &drop_ssdt, &bootInfo->chameleonConfig);
getBoolForKey(kGeneratePStates, &generate_pstates, &bootInfo->chameleonConfig);
int rsdplength;
// Find original rsdp
rsdp=(struct acpi_2_rsdp *)(version ? getAddressOfAcpi20Table() : getAddressOfAcpiTable());
rsdp = (struct acpi_2_rsdp *)(version ? getAddressOfAcpi20Table() : getAddressOfAcpiTable());
if (!rsdp)
{
DBG("No ACPI version %d found. Ignoring\n", version+1);
}
continue;
}
rsdplength=version ? rsdp->Length : 20;
rsdplength = version ? rsdp->Length : 20;
DBG("RSDP version %d found @%x. Length=%d\n",version+1,rsdp,rsdplength);
* For more info see ACPI Specification pages 110 and following
*/
rsdp_mod=(struct acpi_2_rsdp *) AllocateKernelMemory(rsdplength);
rsdp_mod = (struct acpi_2_rsdp *) AllocateKernelMemory(rsdplength);
memcpy(rsdp_mod, rsdp, rsdplength);
rsdt=(struct acpi_2_rsdt *)(rsdp->RsdtAddress);
rsdt = (struct acpi_2_rsdt *)rsdp->RsdtAddress;
DBG("RSDT @%x, Length %d\n",rsdt, rsdt ? rsdt->Length : 0);
if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000)
if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length < 0x10000)
{
uint32_t *rsdt_entries;
int rsdt_entries_num;
int dropoffset=0, i;
// mozo: using malloc cos I didn't found how to free already allocated kernel memory
rsdt_mod=(struct acpi_2_rsdt *)malloc(rsdt->Length);
memcpy (rsdt_mod, rsdt, rsdt->Length);
rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod;
rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4;
rsdt_entries=(uint32_t *)(rsdt_mod+1);
for (i=0;i<rsdt_entries_num;i++)
rsdt_mod = (struct acpi_2_rsdt *)malloc(rsdt->Length);
memcpy(rsdt_mod, rsdt, rsdt->Length);
rsdp_mod->RsdtAddress = (uint32_t)rsdt_mod;
rsdt_entries_num = (rsdt_mod->Length - sizeof(struct acpi_2_rsdt)) / 4;
rsdt_entries = (uint32_t *)(rsdt_mod + 1);
for (i = 0;i < rsdt_entries_num;i++)
{
char *table=(char *)(rsdt_entries[i]);
if (!table)
DBG("OEM HPET table was dropped\n");
dropoffset++;
continue;
}
}
if (drop_slic && tableSign(table, "SLIC"))
{
}
fadt_mod = patch_fadt(fadt, new_dsdt);
rsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;
rsdt_entries[i-dropoffset] = (uint32_t)fadt_mod;
// Generate _CST SSDT
if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod)))
// Allocate rsdt in Kernel memory area
rsdt_mod->Length += 4*ssdt_count - 4*dropoffset;
struct acpi_2_rsdt *rsdt_copy = (struct acpi_2_rsdt *)AllocateKernelMemory(rsdt_mod->Length);
memcpy (rsdt_copy, rsdt_mod, rsdt_mod->Length);
free(rsdt_mod); rsdt_mod = rsdt_copy;
rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod;
rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4;
rsdt_entries=(uint32_t *)(rsdt_mod+1);
memcpy(rsdt_copy, rsdt_mod, rsdt_mod->Length);
free(rsdt_mod);
rsdt_mod = rsdt_copy;
rsdp_mod->RsdtAddress = (uint32_t)rsdt_mod;
rsdt_entries_num = (rsdt_mod->Length-sizeof(struct acpi_2_rsdt)) / 4;
rsdt_entries = (uint32_t *)(rsdt_mod + 1);
// Mozodojo: Insert additional SSDTs into RSDT
if(ssdt_count > 0)
int dropoffset=0;
// mozo: using malloc cos I didn't found how to free already allocated kernel memory
xsdt_mod=(struct acpi_2_xsdt*)malloc(xsdt->Length);
xsdt_mod=(struct acpi_2_xsdt*)malloc(xsdt->Length);
memcpy(xsdt_mod, xsdt, xsdt->Length);
rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod;
xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8;
xsdt_entries=(uint64_t *)(xsdt_mod+1);
for (i=0;i<xsdt_entries_num;i++)
rsdp_mod->XsdtAddress = (uint32_t)xsdt_mod;
xsdt_entries_num = (xsdt_mod->Length - sizeof(struct acpi_2_xsdt)) / 8;
xsdt_entries = (uint64_t *)(xsdt_mod + 1);
for (i = 0;i < xsdt_entries_num;i++)
{
char *table=(char *)((uint32_t)(xsdt_entries[i]));
char *table = (char *)((uint32_t)(xsdt_entries[i]));
if (!table)
{
continue;
}
xsdt_entries[i-dropoffset]=xsdt_entries[i];
xsdt_entries[i - dropoffset] = xsdt_entries[i];
if (drop_ssdt && tableSign(table, "SSDT"))
{
xsdt_mod->Length += 8*ssdt_count - 8*dropoffset;
struct acpi_2_xsdt *xsdt_copy = (struct acpi_2_xsdt *)AllocateKernelMemory(xsdt_mod->Length);
memcpy(xsdt_copy, xsdt_mod, xsdt_mod->Length);
free(xsdt_mod); xsdt_mod = xsdt_copy;
rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod;
xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8;
xsdt_entries=(uint64_t *)(xsdt_mod+1);
free(xsdt_mod);
xsdt_mod = xsdt_copy;
rsdp_mod->XsdtAddress = (uint32_t)xsdt_mod;
xsdt_entries_num = (xsdt_mod->Length - sizeof(struct acpi_2_xsdt)) / 8;
xsdt_entries = (uint64_t *)(xsdt_mod + 1);
// Mozodojo: Insert additional SSDTs into XSDT
if(ssdt_count > 0)
branches/ErmaC/Enoch/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
130130
131
131
132
132133
133134
134135
135136
136
137
137
138
138139
139140
140141
......
142143
143144
144145
145
146
146
147
148
147149
148150
149
150
151
152
153
154
151155
152156
153157
154
155
156
158
159
160
161
162
163
164
157165
158166
159167
160168
161169
162
163
170
171
172
173
164174
165175
166
167
176
177
178
179
180
168181
169182
170183
......
179192
180193
181194
182
183
195
196
197
198
184199
185200
186201
......
191206
192207
193208
194
195
209
210
211
212
213
196214
197215
198216
......
215233
216234
217235
218
236
219237
220
238
221239
222
240
223241
224
242
225243
226
227
228
244
229245
246
247
248
249
230250
231251
232252
233253
234254
235
255
236256
257
258
237259
238
239260
240
261
262
241263
242
264
265
266
243267
244268
245269
246270
247271
248
249
250
272
273
274
251275
252
276
277
253278
254279
255
280
281
282
256283
257284
258285
......
262289
263290
264291
265
266292
267
268
269
270
271
272
293
294
295
296
297
298
299
300
273301
274
302
275303
276304
277305
278306
279307
280308
281
282
283309
310
311
312
284313
285314
286315
......
288317
289318
290319
291
320
321
292322
293323
294324
295325
296
297
326
327
298328
299329
300330
......
305335
306336
307337
308
338
339
309340
310341
311342
312
313
314
343
344
345
315346
316347
317348
......
327358
328359
329360
361
362
363
364
365
330366
331367
332368
333369
334
370
371
335372
336373
337374
......
339376
340377
341378
342
343
379
380
381
344382
345383
346384
347385
348
386
387
349388
350389
351390
352
391
392
353393
354394
355395
......
359399
360400
361401
362
363
364
365
366
367
368
369
370
371
402
403
404
405
406
407
408
409
410
411
372412
373413
374414
375415
376
377
416
417
378418
379419
380420
......
420460
421461
422462
423
463
464
424465
425466
426467
427468
428469
429470
430
431
471
472
473
474
432475
433476
434477
#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)
{
int i;
for (i=0; i< SPD_INDEXES_SIZE; i++) {
for (i = 0; i < SPD_INDEXES_SIZE; i++)
{
READ_SPD(spd, base, slot, spd_indexes[i]);
}
}
/** 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]) {
if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR3)
{
switch(spd[12])
{
case 0x0f:
return 1066;
case 0x0c:
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]) {
}
else 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:
/* 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)
{
int i, start = 0, index = 0;
char c;
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;
uint8_t spd_size, spd_type;
uint32_t base, mmio, hostc;
//bool dump = false;
RamSlotInfo_t* slot;
static void read_smb_intel(pci_dt_t *smbus_dev)
{
inti, speed;
uint8_tspd_size, spd_type;
uint32_tbase, mmio, hostc;
uint16_tcmd;
//booldump = false;
RamSlotInfo_t*slot;
uint16_t cmd = pci_config_read16(smbus_dev->dev.addr, 0x04);
cmd = pci_config_read16(smbus_dev->dev.addr, 0x04);
DBG("SMBus CmdReg: 0x%x\n", cmd);
pci_config_write16(smbus_dev->dev.addr, 0x04, cmd | 1);
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
char spdbuf[MAX_SPD_SIZE];
// Search MAX_RAM_SLOTS slots
for (i = 0; i < MAX_RAM_SLOTS; i++) {
for (i = 0; i < MAX_RAM_SLOTS; i++)
{
slot = &Platform.RAM.DIMM[i];
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;
}
branches/ErmaC/Enoch/i386/libsaio/gma.c
396396
397397
398398
399
399
400400
401401
402402
......
716716
717717
718718
719
719
720720
721721
722722
struct DevPropDevice *device = devprop_add_device(string, devicepath);
if (!device) {
printf("Failed initializing dev-prop string dev-entry.\n");
printf("[setup_gma_devprop] Failed initializing dev-prop string dev-entry!\n");
pause();
return false;
}
stringdata = malloc(sizeof(uint8_t) * string->length);
if (!stringdata)
{
printf("No stringdata.\n");
printf("[setup_gma_devprop] No stringdata!\n");
pause();
return false;
}
branches/ErmaC/Enoch/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
100
116
117
101118
102119
103120
104121
105
122
123
106124
107125
108126
......
114132
115133
116134
117
135
136
137
138
118139
119140
120141
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))) {
if (!(new_dsdt = malloc(fsize)))
{
verbose("[ERROR] alloc DSDT memory failed\n");
close (fd);
goto out;
}
if (read (fd, new_dsdt, fsize) != fsize) {
if (read (fd, new_dsdt, fsize) != fsize)
{
verbose("[ERROR] read %s failed\n", dsdt_filename);
free(new_dsdt);
close (fd);
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");
branches/ErmaC/Enoch/i386/libsaio/device_inject.c
2323
2424
2525
26
27
28
29
26
27
28
29
3030
3131
3232
......
5454
5555
5656
57
57
58
5859
5960
6061
6162
62
63
64
6365
64
66
67
6568
69
6670
6771
6872
6973
7074
7175
72
76
7377
74
78
79
7580
7681
7782
......
8388
8489
8590
86
87
88
91
92
93
8994
90
95
96
9197
9298
9399
94100
95
101
102
96103
97104
98105
99
106
107
108
100109
101110
102111
......
108117
109118
110119
111
112
120
121
122
123
113124
114125
115126
116
127
128
117129
118
130
131
132
119133
120
134
135
136
121137
122138
123139
......
127143
128144
129145
130
146
147
131148
132
149
150
151
133152
134
153
154
155
135156
136157
137158
......
142163
143164
144165
145
166
167
146168
147169
148170
149171
150172
151173
152
153
154
155
174
175
176
177
156178
157179
158180
159181
160182
161183
162
184
185
163186
164187
165188
......
172195
173196
174197
175
176
198
199
200
201
177202
178203
179204
......
190215
191216
192217
193
218
219
194220
195221
196
197
222
223
198224
199
225
226
200227
201228
202229
203230
204
231
205232
206233
207234
208235
209236
210
237
238
211239
212240
213241
......
216244
217245
218246
219
247
248
220249
221250
222251
223252
224253
225254
226
255
256
227257
228258
229
230
259
260
261
262
263
231264
232265
233266
234267
235268
236
269
237270
238271
239272
240273
241
274
275
242276
243
277
278
279
244280
245281
246282
......
343379
344380
345381
346
347
348
382
383
384
385
386
387
349388
350389
351390
......
371410
372411
373412
374
413
414
375415
376416
377417
......
379419
380420
381421
382
383
422
423
424
425
384426
385427
386428
#define DBG(x...)msglog(x)
#endif
uint32_t devices_number= 1;
DevPropString *string= NULL;
uint8_t *stringdata= NULL;
uint32_t stringlength= 0;
uint32_tdevices_number= 1;
DevPropString*string= NULL;
uint8_t*stringdata= NULL;
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");
}
}
}
DevPropString *devprop_create_string(void)
{
string = (struct DevPropString*)malloc(sizeof(struct DevPropString));
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;
}
branches/ErmaC/Enoch/i386/libsaio/fdisk.h
4141
4242
4343
44
44
45
4546
4647
4748
4849
4950
50
51
52
51
52
53
54
55
5356
54
55
56
57
58
59
57
58
59
60
61
62
63
64
65
66
67
6068
6169
6270
#define DISK_SIGNATURE0xAA55/* signature of the boot record */
#define FDISK_NPART4 /* number of entries in fdisk table */
#define FDISK_ACTIVE0x80/* indicator of active partition */
#define FDISK_NEXTNAME0xA7/* indicator of NeXT partition */
#define FDISK_DOS120x01/* 12-bit fat < 10MB dos partition */
#define FDISK_DOS16S0x04/* 16-bit fat < 32MB dos partition */
#define FDISK_DOSEXT0x05/* extended DOS partition */
#define FDISK_DOS16B0x06/* 16-bit fat >= 32MB dos partition */
#define FDISK_NTFS0x07/* NTFS partition */
#define FDISK_SMALLFAT320x0b/* FAT32 partition */
#define FDISK_FAT320x0c/* FAT32 partition */
#define FDISK_DOS16SLBA0x0e /* 16-bit FAT, LBA-mapped */
#define FDISK_SMALLFAT320x0B/* DOS FAT32 partition */
#define FDISK_FAT320x0C/* Win FAT32 partition */
#define FDISK_DOS16SLBA0x0E /* Win 16-bit FAT, LBA-mapped */
#define FDISK_WIN_LDM0x42/* NTFS partition */
#define FDISK_LINUX_SWAP0x82 /* Linux swap */
#define FDISK_LINUX0x83 /* Linux native */
#define FDISK_OPENBSD0xa6 /* OpenBSD FFS partition */
#define FDISK_FREEBSD0xa5 /* FreeBSD UFS2 partition */
#define FDISK_BEFS0xeb /* Haiku BeFS partition */
#define FDISK_UFS0xa8/* Apple UFS partition */
#define FDISK_HFS0xaf/* Apple HFS partition */
#define FDISK_BOOTER0xab/* Apple booter partition */
#define FDISK_LINUX_LVM0x8E /* Linux LVM */
#define FDISK_FREEBSD0xA5 /* FreeBSD UFS2 partition */
#define FDISK_OPENBSD0xA6 /* OpenBSD FFS partition */
#define FDISK_NEXTNAME0xA7/* Indicator of NeXT partition */
#define FDISK_UFS0xA8/* Apple UFS partition */
#define FDISK_NETBSD0xA9 /* NetBSD disk label */
#define FDISK_BOOTER0xAB/* Apple booter partition */
#define FDISK_ENCRYPTED0xAE/* Apple encrypted */
#define FDISK_HFS0xAF/* Apple HFS partition */
#define FDISK_BEFS0xEB /* Haiku BeFS partition */
#define FDISK_LINUX_RAID0xFD /* Linux RAID */
#define FDISK_PSEUDO_EXFAT0x107/* Shared with FDISK_NTFS */
/*
branches/ErmaC/Enoch/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
......
347347
348348
349349
350
350
351351
352352
353353
354
354
355355
356356
357357
*/
#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 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)
branches/ErmaC/Enoch/i386/libsaio/sys.c
8585
8686
8787
88
88
8989
9090
9191
......
386386
387387
388388
389
389
390390
391
391
392392
393393
394
394
395395
396396
397397
......
499499
500500
501501
502
502
503503
504504
505
505
506506
507507
508508
......
823823
824824
825825
826
826
827827
828
829
830
828
829
830
831831
832832
833833
834834
835
835
836836
837837
838838
......
949949
950950
951951
952
952
953953
954954
955955
......
968968
969969
970970
971
971
972
972973
973974
974975
......
989990
990991
991992
993
992994
993995
994996
......
9991001
10001002
10011003
1002
1004
10031005
10041006
10051007
......
10191021
10201022
10211023
1022
1024
10231025
10241026
10251027
10261028
10271029
10281030
1029
1031
10301032
10311033
1032
1034
10331035
10341036
10351037
10361038
10371039
10381040
1039
1040
1041
1041
1042
1043
10421044
10431045
10441046
......
10551057
10561058
10571059
1058
1060
1061
10591062
10601063
10611064
1062
1065
10631066
10641067
10651068
......
11201123
11211124
11221125
1123
1126
11241127
11251128
11261129
......
11481151
11491152
11501153
1151
1152
1154
1155
11531156
11541157
11551158
struct devsw
{
const char * name;
const char *name;
// size increased from char to short to handle non-BIOS internal devices
unsigned short biosdev;
int type;
// GetFileInfo - LOW-LEVEL FILESYSTEM FUNCTION.
// Get attributes for the specified file.
static char* gMakeDirSpec;
static char *gMakeDirSpec;
long GetFileInfo(const char * dirSpec, const char * name, long * flags, u_int32_t * time)
long GetFileInfo(const char *dirSpec, const char *name, long *flags, u_int32_t *time)
{
long long index = 0;
const char * entryName;
const char *entryName;
if (gMakeDirSpec == 0)
{
//==========================================================================
// openmem()
int openmem(char * buf, int len)
int openmem(char *buf, int len)
{
int fdesc;
struct iob * io;
struct iob *io;
fdesc = GetFreeFd();
io = &iob[fdesc];
//==========================================================================
struct dirstuff * opendir(const char * path)
struct dirstuff *opendir(const char *path)
{
struct dirstuff * dirp = 0;
const char * dirPath;
BVRef bvr;
struct dirstuff *dirp = 0;
const char *dirPath;
BVRef bvr;
if ((bvr = getBootVolumeRef(path, &dirPath)) == NULL)
goto error;
dirp = (struct dirstuff *) malloc(sizeof(struct dirstuff));
dirp = (struct dirstuff *)malloc(sizeof(struct dirstuff));
if (dirp == NULL)
goto error;
//==========================================================================
BVRef selectBootVolume( BVRef chain )
BVRef selectBootVolume(BVRef chain)
{
bool filteredChain = false;
bool foundPrimary = false;
{
break;
}
if ( bvr->part_no == multiboot_partition && bvr->biosdev == gBIOSDev )
if ( (bvr->part_no == multiboot_partition) && (bvr->biosdev == gBIOSDev) )
{
return bvr;
}
{
break;
}
if (matchVolumeToString(bvr, val, false))
{
free(val);
}
/*
* Scannig the volume chain backwards and trying to find
* Scannig the volume chain backwards and trying to find
* a HFS+ volume with valid boot record signature.
* If not found any active partition then we will
* select this volume as the boot volume.
}
}
if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev )
if ( (bvr->flags & kBVFlagPrimary) && (bvr->biosdev == gBIOSDev) )
{
foundPrimary = true;
}
// zhell -- Undo a regression that was introduced from r491 to 492.
// if gBIOSBootVolume is set already, no change is required
if ( bvr->flags & (kBVFlagBootable|kBVFlagSystemVolume)
if ( (bvr->flags & (kBVFlagBootable | kBVFlagSystemVolume))
&& gBIOSBootVolume
&& (!filteredChain || (filteredChain && bvr->visible))
&& bvr->biosdev == gBIOSDev )
&& (bvr->biosdev == gBIOSDev) )
{
bvr2 = bvr;
}
// zhell -- if gBIOSBootVolume is NOT set, we use the "if" statement
// from r491,
if ( bvr->flags & kBVFlagBootable
&& ! gBIOSBootVolume
&& bvr->biosdev == gBIOSDev )
if ( (bvr->flags & kBVFlagBootable)
&& !gBIOSBootVolume
&& (bvr->biosdev == gBIOSDev) )
{
bvr2 = bvr;
}
{
break;
}
if ( bvr->flags & kBVFlagNativeBoot && bvr->biosdev == gBIOSDev )
if ( (bvr->flags & kBVFlagNativeBoot) && (bvr->biosdev == gBIOSDev) )
{
bvr1 = bvr;
}
if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev )
if ( (bvr->flags & kBVFlagPrimary) && (bvr->biosdev == gBIOSDev) )
{
bvr2 = bvr;
}
is changed to the selected volume unless the volume selector is
that of a ramdisk.
*/
BVRef getBootVolumeRef( const char * path, const char ** outPath )
BVRef getBootVolumeRef(const char *path, const char **outPath)
{
const char*cp;
BVRef bvr= gRootVolume;
}
else if ((cp - path) == 2) // found "xx("
{
const struct devsw * dp;
const char * xp = path;
const struct devsw *dp;
const char *xp = path;
int i;
int unit = -1;
branches/ErmaC/Enoch/i386/libsaio/acpi.h
2222
2323
2424
25
2526
2627
2728
2829
2930
31
3032
3133
3234
......
141143
142144
143145
146
144147
145148
146149
// TODO Migrate
struct acpi_2_rsdp
{
// 1.0
charSignature[8];
uint8_tChecksum;
charOEMID[6];
uint8_tRevision;
uint32_tRsdtAddress;
// 2.0
uint32_tLength;
uint64_tXsdtAddress;
uint8_tExtendedChecksum;
/* Begin Asere */
//Reset Fix
uint32_t Flags;
// Reset Register
uint8_t Reset_SpaceID;
uint8_t Reset_BitWidth;
uint8_t Reset_BitOffset;
branches/ErmaC/Enoch/i386/libsaio/cpu.c
152152
153153
154154
155
156
155
156
157157
158158
159159
lastValue = timerValue;
} while (timerValue > 5);
printf("timerValue %d\n",timerValue);
printf("intermediate 0x%016llx\n",intermediate);
printf("saveTime 0x%016llx\n",saveTime);
printf("intermediate 0x%016llX\n",intermediate);
printf("saveTime 0x%016llX\n",saveTime);
intermediate -= saveTime;// raw count for about 1/20 second
intermediate *= scale[timerValue];// rescale measured time spent
branches/ErmaC/Enoch/i386/libsaio/disk.c
8989
9090
9191
92
9293
9394
9495
......
100101
101102
102103
104
105
106
107
108
109
110
111
103112
113
114
115
116
117
118
119
120
121
122
104123
105124
106125
......
110129
111130
112131
113
114
115
116
117
118
119
120
121
132
133
122134
123
124
125
126135
127136
128137
......
130139
131140
132141
142
133143
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
179
180
181
182
183
134184
135185
136186
......
182232
183233
184234
185
186235
187
188
189
190
191
192
193
194236
195237
196238
197
239
198240
199241
200242
......
207249
208250
209251
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224252
225253
226254
......
247275
248276
249277
250
251
252278
253279
254280
......
366392
367393
368394
369
370395
371396
372397
......
388413
389414
390415
391
416
392417
393418
394419
......
414439
415440
416441
417
442
418443
419444
420445
......
437462
438463
439464
440
441
465
442466
443467
444468
445469
446470
447471
448
449
472
473
450474
451475
452476
......
529553
530554
531555
532
533
534
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
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
535654
536655
537656
......
540659
541660
542661
543
662
544663
545664
546665
......
573692
574693
575694
576
695
577696
578697
579698
......
613732
614733
615734
616
735
617736
618
737
619738
739
740
620741
621742
622743
......
632753
633754
634755
635
756
636757
637758
638759
......
668789
669790
670791
671
792
672793
673794
674795
......
686807
687808
688809
689
810
811
690812
691813
692814
815
693816
694817
695818
......
721844
722845
723846
724
725
726
847
848
849
850
851
852
727853
728854
729855
730856
731857
732858
733
859
860
861
734862
735
863
736864
737865
738866
739867
740
741
742
743
744
745
746
747
748
749
750
868
869
870
871
872
873
874
875
876
877
878
751879
752880
753881
......
796924
797925
798926
799
927
928
800929
801930
802931
932
803933
804934
805935
......
812942
813943
814944
815
945
816946
817
818
819
820
947
948
949
950
821951
822
952
823953
824
825
826
954
955
956
827957
828958
829959
......
841971
842972
843973
844
974
975
845976
846977
847
978
848979
849980
850981
......
857988
858989
859990
860
861
991
862992
863993
864994
......
8791009
8801010
8811011
882
1012
8831013
8841014
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
9011031
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
9201052
9211053
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
9381070
9391071
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
9611093
962
963
964
965
966
967
968
969
970
971
972
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
9731106
974
975
976
977
978
979
980
981
982
983
984
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
9851119
986
987
988
989
990
991
992
993
994
995
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
9961131
997
998
999
1000
1001
1002
1003
1004
1005
1006
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
10071143
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
10181155
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
10301167
1031
1032
1033
1034
1035
1036
1037
1168
1169
1170
1171
1172
1173
1174
10381175
10391176
1040
1041
1177
1178
10421179
10431180
10441181
......
10561193
10571194
10581195
1196
10591197
10601198
10611199
10621200
1063
10641201
10651202
10661203
......
10881225
10891226
10901227
1091
1228
10921229
10931230
1094
1231
10951232
10961233
10971234
......
11011238
11021239
11031240
1104
1241
11051242
11061243
11071244
11081245
11091246
11101247
1111
1112
1113
1114
1115
1248
1249
1250
1251
1252
11161253
11171254
11181255
11191256
11201257
1258
11211259
11221260
11231261
......
11251263
11261264
11271265
1266
11281267
11291268
11301269
......
11651304
11661305
11671306
1168
1307
11691308
11701309
11711310
......
11741313
11751314
11761315
1177
1316
11781317
11791318
11801319
......
12101349
12111350
12121351
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1352
12341353
1235
1354
12361355
12371356
1238
1239
1240
1241
1357
12421358
1243
1359
12441360
12451361
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1362
13081363
13091364
13101365
......
13261381
13271382
13281383
1329
1384
1385
13301386
13311387
13321388
......
13741430
13751431
13761432
1377
1433
13781434
13791435
13801436
......
13841440
13851441
13861442
1387
1443
13881444
13891445
13901446
......
14051461
14061462
14071463
1408
1409
1410
1411
1412
1413
1464
1465
1466
1467
1468
1469
14141470
14151471
14161472
......
14581514
14591515
14601516
1461
1517
1518
14621519
14631520
14641521
14651522
1466
1523
14671524
14681525
14691526
14701527
1471
1528
1529
14721530
14731531
14741532
......
14761534
14771535
14781536
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
14961555
14971556
1498
1499
1557
1558
1559
15001560
15011561
15021562
......
15831643
15841644
15851645
1586
1646
1647
15871648
15881649
15891650
......
16061667
16071668
16081669
1609
1670
1671
16101672
16111673
16121674
1613
1675
1676
16141677
16151678
16161679
16171680
16181681
1619
1682
1683
1684
16201685
16211686
16221687
......
16861751
16871752
16881753
1689
1754
16901755
16911756
16921757
......
17571822
17581823
17591824
1760
1825
17611826
17621827
17631828
17641829
17651830
17661831
1767
1832
17681833
17691834
17701835
......
17961861
17971862
17981863
1799
1864
18001865
18011866
18021867
......
18141879
18151880
18161881
1882
18171883
18181884
18191885
......
18981964
18991965
19001966
1967
19011968
19021969
19031970
19041971
1972
19051973
19061974
19071975
......
19111979
19121980
19131981
1982
19141983
19151984
19161985
19171986
1987
19181988
19191989
19201990
......
20772147
20782148
20792149
2150
20802151
20812152
20822153
......
20972168
20982169
20992170
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
21222171
21232172
21242173
......
22792328
22802329
22812330
2282
2331
22832332
22842333
22852334
......
22942343
22952344
22962345
2297
2346
22982347
22992348
2300
2349
23012350
23022351
23032352
23042353
23052354
2306
2355
23072356
23082357
23092358
......
23432392
23442393
23452394
2346
2395
23472396
2348
2349
2397
2398
23502399
2351
2400
23522401
2353
2402
23542403
2355
2404
23562405
23572406
23582407
23592408
23602409
2361
2410
23622411
23632412
2364
2365
2413
2414
23662415
23672416
23682417
......
24852534
24862535
24872536
2488
2537
24892538
24902539
24912540
......
24982547
24992548
25002549
2501
2550
25022551
25032552
25042553
#define UFS_FRONT_PORCH 0
#define kAPMSector 2 /* Sector number of Apple partition map */
#define kAPMCDSector 8 /* Translated sector of Apple partition map on a CD */
#define ECC_CORRECTED_ERR 0x11
/*
* IORound and IOTrunc convenience functions, in the spirit
#define IOTrunc(value,multiple) \
(((value) / (multiple)) * (multiple));
//==========================================================================
// Maps (E)BIOS return codes to message strings.
struct NamedValue {
unsigned char value;
const char *name;
};
/*
* Map a disk drive to bootable volumes contained within.
*/
struct DiskBVMap {
int biosdev;// BIOS device number (unique)
BVRef bvr;// chain of boot volumes on the disk
int bvrcnt;// number of boot volumes
struct DiskBVMap *next;// linkage to next mapping
};
/*
* trackbuf points to the start of the track cache. Biosread()
* will store the sectors read from disk to this memory area.
*
static char * const trackbuf = (char *) ptov(BIOS_ADDR);
static char * biosbuf;
/*
* Map a disk drive to bootable volumes contained within.
*/
struct DiskBVMap {
int biosdev; // BIOS device number (unique)
BVRef bvr; // chain of boot volumes on the disk
int bvrcnt; // number of boot volumes
struct DiskBVMap * next; // linkage to next mapping
};
static struct DiskBVMap *gDiskBVMap = NULL;
static struct disk_blk0 *gBootSector = NULL;
static struct DiskBVMap * gDiskBVMap = NULL;
static struct disk_blk0 * gBootSector = NULL;
// Function pointers to be filled in if ramdisks are available:
int (*p_ramdiskReadBytes)( int biosdev, unsigned int blkno,
unsigned int byteoff,
int (*p_get_ramdisk_info)(int biosdev, struct driveInfo *dip) = NULL;
static bool getOSVersion(BVRef bvr, char *str);
static bool cache_valid = false;
static const struct NamedValue bios_errors[] =
{
{ 0x10, "Media error" },
{ 0x11, "Corrected ECC error" },
{ 0x20, "Controller or device error" },
{ 0x40, "Seek failed" },
{ 0x80, "Device timeout" },
{ 0xAA, "Drive not ready" },
{ 0x00, NULL }
};
static const struct NamedValue fdiskTypes[] =
{
{ 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" }, // 0xA8
{ FDISK_NETBSD, "NetBSD" }, // 0xA9
{ FDISK_BOOTER,"Apple_Boot" }, // 0xAB
{ FDISK_ENCRYPTED, "Apple_Encrypted" }, // 0xAE
{ FDISK_HFS,"Apple HFS" }, // 0xAF
{ 0xCD,"CD-ROM" }, // 0xCD
{ FDISK_BEFS, "Haiku" }, // 0xEB
{ FDISK_LINUX_RAID, "Linux_RAID" }, // 0xFD
{ 0x00,NULL } /* must be last */
};
//==============================================================================
extern void spinActivityIndicator(int sectors);
//==========================================================================
}
//==========================================================================
// Maps (E)BIOS return codes to message strings.
struct NamedValue {
unsigned char value;
const char * name;
};
//==========================================================================
static const char * getNameForValue( const struct NamedValue * nameTable,
unsigned char value )
{
const struct NamedValue * np;
const struct NamedValue *np;
for ( np = nameTable; np->value; np++)
{
return NULL;
}
#define ECC_CORRECTED_ERR 0x11
static const struct NamedValue bios_errors[] =
{
{ 0x10, "Media error" },
{ 0x11, "Corrected ECC error" },
{ 0x20, "Controller or device error" },
{ 0x40, "Seek failed" },
{ 0x80, "Device timeout" },
{ 0xAA, "Drive not ready" },
{ 0x00, 0 }
};
//==============================================================================
static const char * bios_error(int errnum)
// Return:
// 0 on success, or an error code from INT13/F2 or INT13/F42 BIOS call.
static bool cache_valid = false;
static int Biosread( int biosdev, unsigned long long secno )
{
static int xbiosdev, xcyl, xhead;
return rc;
}
//==============================================================================
int testBiosread(int biosdev, unsigned long long secno)
int error;
int copy_len;
DEBUG_DISK(("%s: dev %x block %x [%d] -> 0x%x...", __FUNCTION__, biosdev, blkno, byteCount, (unsigned)cbuf));
DEBUG_DISK(("%s: dev %X block %X [%d] -> 0x%X...", __FUNCTION__, biosdev, blkno, byteCount, (unsigned)cbuf));
for (; byteCount; cbuf += copy_len, blkno++)
{
//==============================================================================
static int isExtendedFDiskPartition( const struct fdisk_part * part )
static int isExtendedFDiskPartition( const struct fdisk_part *part )
{
static unsigned char extParts[] =
{
//==============================================================================
static int getNextFDiskPartition( int biosdev, int * partno,
const struct fdisk_part ** outPart )
static int getNextFDiskPartition( int biosdev, int *partno, const struct fdisk_part **outPart )
{
static int sBiosdev = -1;
static int sNextPartNo;
static unsigned int sFirstBase;
static unsigned int sExtBase;
static unsigned int sExtDepth;
static struct fdisk_part * sExtPart;
struct fdisk_part * part;
static struct fdisk_part *sExtPart;
struct fdisk_part *part;
if ( sBiosdev != biosdev || *partno < 0 )
{
//==============================================================================
static BVRef newFDiskBVRef( int biosdev, int partno, unsigned int blkoff,
const struct fdisk_part * part,
FSInit initFunc, FSLoadFile loadFunc,
/*
* Trying to figure out the filsystem type of a given partition.
* X = fdisk partition type
* 0 = Unknown/Unused
* -1 = error
*/
static int probeFileSystem(int biosdev, unsigned int blkoff)
{
// detected filesystem type;
int result = -1;
int fatbits = 0;
// Allocating buffer for 4 sectors.
const void *probeBuffer = malloc(PROBEFS_SIZE);
if (probeBuffer == NULL)
{
goto exit;
}
// Reading first 4 sectors of current partition
int error = readBytes(biosdev, blkoff, 0, PROBEFS_SIZE, (void *)probeBuffer);
if (error)
{
goto exit;
}
if (HFSProbe(probeBuffer))
{
result = FDISK_HFS;
}
else if (EX2Probe(probeBuffer))
{
result = FDISK_LINUX;
}
else if (FreeBSDProbe(probeBuffer))
{
result = FDISK_FREEBSD;
}
else if (OpenBSDProbe(probeBuffer))
{
result = FDISK_OPENBSD;
}
else if (BeFSProbe(probeBuffer))
{
result = FDISK_BEFS;
}
else if (NTFSProbe(probeBuffer))
{
result = FDISK_NTFS;
}
else if (EXFATProbe(probeBuffer))
{
result = FDISK_PSEUDO_EXFAT;
}
else if ((fatbits = MSDOSProbe(probeBuffer)))
{
switch (fatbits)
{
case 12:
result = FDISK_DOS12;
break;
case 16:
result = FDISK_DOS16B;
break;
case 32:
default:
result = FDISK_FAT32;
break;
}
}
else
{
// Couldn't detect filesystem type
result = 0;
}
exit:
if (probeBuffer)
{
free((void *)probeBuffer);
}
return result;
}
//==============================================================================
static BVRef newFDiskBVRef( int biosdev,
int partno,
unsigned int blkoff,
const struct fdisk_part *part,
FSInit initFunc,
FSLoadFile loadFunc,
FSReadFile readFunc,
FSGetDirEntry getdirFunc,
FSGetFileBlock getBlockFunc,
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
{
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
BVRef bvr = (BVRef)malloc(sizeof(*bvr));
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
{
// filesystem probe failed.
DEBUG_DISK(("%s: failed probe on dev %x part %d\n", __FUNCTION__, biosdev, partno));
DEBUG_DISK(("%s: failed probe on dev %X part %d\n", __FUNCTION__, biosdev, partno));
(*bvr->bv_free)(bvr);
bvr = NULL;
}
}
if (bvr) bvr->flags |= bvrFlags;
if ( bvr )
{
return bvr;
bvr->flags |= bvrFlags;
}
return bvr;
}
//==============================================================================
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
{
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
BVRef bvr = (BVRef)malloc(sizeof(*bvr));
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
{
// filesystem probe failed.
DEBUG_DISK(("%s: failed probe on dev %x part %d\n", __FUNCTION__, biosdev, partno));
DEBUG_DISK(("%s: failed probe on dev %X part %d\n", __FUNCTION__, biosdev, partno));
(*bvr->bv_free)(bvr);
bvr = NULL;
bvr = NULL;
}
}
if (bvr)
if ( bvr )
{
bvr->flags |= bvrFlags;
}
return bvr;
}
// same as Apple ZFS
//EFI_GUID const GPT_ZFS_GUID= { 0x6A898CC3, 0x1DD2, 0x11B2, { 0x99, 0xA6, 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }; // 0xBF01 "Solaris /usr & Apple ZFS
BVRef newGPTBVRef( int biosdev, int partno, unsigned int blkoff,
const gpt_ent * part,
FSInit initFunc, FSLoadFile loadFunc,
BVRef newGPTBVRef( int biosdev,
int partno,
unsigned int blkoff,
const gpt_ent *part,
FSInit initFunc,
FSLoadFile loadFunc,
FSReadFile readFunc,
FSGetDirEntry getdirFunc,
FSGetFileBlock getBlockFunc,
FSGetUUID getUUIDFunc,
BVGetDescription getDescriptionFunc,
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
int probe,
int type,
unsigned int bvrFlags )
{
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
BVRef bvr = (BVRef)malloc(sizeof(*bvr));
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
bvr->biosdev = biosdev;
bvr->part_no = partno;
bvr->part_boff = blkoff;
bvr->fs_loadfile = loadFunc;
bvr->fs_readfile = readFunc;
bvr->fs_getdirentry = getdirFunc;
bvr->fs_getfileblock= getBlockFunc;
bvr->fs_getuuid = getUUIDFunc;
bvr->description = getDescriptionFunc;
bvr->type = type;
bvr->bv_free = bvFreeFunc;
bvr->biosdev = biosdev;
bvr->part_no = partno;
bvr->part_boff = blkoff;
bvr->fs_loadfile = loadFunc;
bvr->fs_readfile = readFunc;
bvr->fs_getdirentry = getdirFunc;
bvr->fs_getfileblock = getBlockFunc;
bvr->fs_getuuid = getUUIDFunc;
bvr->description = getDescriptionFunc;
bvr->type = type;
bvr->bv_free = bvFreeFunc;
// FIXME: UCS-2 -> UTF-8 the name
strlcpy(bvr->name, "----", DPISTRLEN);
if ( (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)part->ent_type) == 0) || (efi_guid_compare(&GPT_HFS_GUID, (EFI_GUID const*)part->ent_type) == 0) )
bvr = NULL;
}
}
if (bvr)
if ( bvr )
{
bvr->flags |= bvrFlags;
}
return bvr;
}
* one extended partition they will be numbered 1, 2, 5.
*/
static BVRef diskScanFDiskBootVolumes( int biosdev, int * countPtr )
static BVRef diskScanFDiskBootVolumes( int biosdev, int *countPtr )
{
const struct fdisk_part * part;
struct DiskBVMap * map;
int partno = -1;
BVRef bvr;
const struct fdisk_part*part;
struct DiskBVMap*map;
intpartno = -1;
BVRefbvr;
#if UFS_SUPPORT
BVRef booterUFS = NULL;
BVRefbooterUFS = NULL;
#endif
int spc;
struct driveInfo di;
boot_drive_info_t *dp;
intspc;
struct driveInfodi;
boot_drive_info_t*dp;
/* Initialize disk info */
spc = 1;
}
do {
do
{
// Create a new mapping.
map = (struct DiskBVMap *) malloc( sizeof(*map) );
map = (struct DiskBVMap *)malloc(sizeof(*map));
if ( map )
{
map->biosdev = biosdev;
while ( getNextFDiskPartition( biosdev, &partno, &part ) )
{
DEBUG_DISK(("%s: part %d [%x]\n", __FUNCTION__,
partno, part->systid));
DEBUG_DISK(("%s: part %d [%X]\n", __FUNCTION__, partno, part->systid));
bvr = 0;
switch ( part->systid )
UFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
break;
#endif
case FDISK_HFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
case FDISK_HFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
// turbo - we want the booter type scanned also
case FDISK_BOOTER:
if (part->bootid & FDISK_ACTIVE)
gBIOSBootVolume = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
// turbo - we want the booter type scanned also
case FDISK_BOOTER:
if (part->bootid & FDISK_ACTIVE)
{
gBIOSBootVolume = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, 0);
}
break;
#if UFS_SUPPORT
case FDISK_BOOTER:
booterUFS = newFDiskBVRef(
biosdev, partno,
((part->relsect + spc - 1) / spc) * spc,
part,
UFSInitPartition,
UFSLoadFile,
UFSReadFile,
UFSGetDirEntry,
UFSGetFileBlock,
UFSGetUUID,
UFSGetDescription,
UFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
case FDISK_BOOTER:
booterUFS = newFDiskBVRef(
biosdev, partno,
((part->relsect + spc - 1) / spc) * spc,
part,
UFSInitPartition,
UFSLoadFile,
UFSReadFile,
UFSGetDirEntry,
UFSGetFileBlock,
UFSGetUUID,
UFSGetDescription,
UFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
#endif
case FDISK_FAT32:
case FDISK_DOS12:
case FDISK_DOS16S:
case FDISK_DOS16B:
case FDISK_SMALLFAT32:
case FDISK_DOS16SLBA:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
MSDOSInitPartition,
MSDOSLoadFile,
MSDOSReadFile,
MSDOSGetDirEntry,
MSDOSGetFileBlock,
MSDOSGetUUID,
MSDOSGetDescription,
MSDOSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
case FDISK_FAT32:
case FDISK_DOS12:
case FDISK_DOS16S:
case FDISK_DOS16B:
case FDISK_SMALLFAT32:
case FDISK_DOS16SLBA:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
MSDOSInitPartition,
MSDOSLoadFile,
MSDOSReadFile,
MSDOSGetDirEntry,
MSDOSGetFileBlock,
MSDOSGetUUID,
MSDOSGetDescription,
MSDOSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
case FDISK_NTFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0,
NTFSGetUUID,
NTFSGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
case FDISK_NTFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0,
NTFSGetUUID,
NTFSGetDescription,
(BVFree)free,
0,
kBIOSDevTypeHardDrive, 0);
break;
case FDISK_LINUX:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0,
EX2GetUUID,
EX2GetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
case FDISK_LINUX:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0,
EX2GetUUID,
EX2GetDescription,
(BVFree)free,
0,
kBIOSDevTypeHardDrive, 0);
break;
case FDISK_BEFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
BeFSGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
case FDISK_BEFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
BeFSGetDescription,
(BVFree)free,
0,
kBIOSDevTypeHardDrive, 0);
break;
case FDISK_FREEBSD:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
FreeBSDGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
case FDISK_FREEBSD:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
FreeBSDGetDescription,
(BVFree)free,
0,
kBIOSDevTypeHardDrive, 0);
break;
case FDISK_OPENBSD:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
OpenBSDGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
case FDISK_OPENBSD:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
OpenBSDGetDescription,
(BVFree)free,
0,
kBIOSDevTypeHardDrive, 0);
break;
default:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0, 0,
(BVFree)free,
0,
kBIOSDevTypeHardDrive, 0);
break;
}
default:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0, 0,
(BVFree)free,
0,
kBIOSDevTypeHardDrive, 0);
break;
}
if ( bvr )
{
bvr->next = map->bvr;
map->bvr = bvr;
map->bvrcnt++;
}
}
if ( bvr )
{
bvr->next = map->bvr;
map->bvr = bvr;
map->bvrcnt++;
}
}
#if UFS_SUPPORT
// Booting from a CD with an UFS filesystem embedded
// in a booter partition.
// Booting from a CD with an UFS filesystem embedded
// in a booter partition.
if ( booterUFS )
{
}
} while (0);
#if UNUSED
/*
* If no FDisk partition, then we will check for
* an Apple partition map elsewhere.
*/
#if UNUSED
if (map && map->bvrcnt == 0)
{
static struct fdisk_part cdpart;
#endif
// Actually this should always be true given the above code
// (unless malloc failed above)
if(map && map == gDiskBVMap)
if(map && (map == gDiskBVMap))
{
// Don't leave a null map in the chain
if(map->bvrcnt == 0 && map->bvr == NULL)
if((map->bvrcnt == 0) && (map->bvr == NULL))
{
gDiskBVMap = map->next;
free(map);
if (countPtr) *countPtr = map ? map->bvrcnt : 0;
return map ? map->bvr : NULL;
return map ? map->bvr : NULL;
}
//==============================================================================
static BVRef diskScanAPMBootVolumes( int biosdev, int * countPtr )
{
struct DiskBVMap * map;
struct Block0 *block0_p;
unsigned int blksize;
unsigned int factor;
void *buffer = malloc(BPS);
struct DiskBVMap*map;
struct Block0*block0_p;
unsigned intblksize;
unsigned intfactor;
void*buffer = malloc(BPS);
if (!buffer)
{
return NULL;
}
bzero(buffer,BPS);
/* Check for alternate block size */
{
return NULL;
}
block0_p = buffer;
if (OSSwapBigToHostInt16(block0_p->sbSig) == BLOCK0_SIGNATURE)
{
map->next = gDiskBVMap;
gDiskBVMap = map;
for (i=0; i<npart; i++)
for (i = 0; i < npart; i++)
{
error = readBytes( biosdev, (kAPMSector + i) * factor, 0, blksize, buffer );
break;
}
if (i==0)
if (i == 0)
{
npart = OSSwapBigToHostInt32(dpme_p->dpme_map_entries);
}
}
} while (0);
free(buffer);
if (countPtr) *countPtr = map ? map->bvrcnt : 0;
return map ? map->bvr : NULL;
}
//==============================================================================
/*
* Trying to figure out the filsystem type of a given partition.
*/
static int probeFileSystem(int biosdev, unsigned int blkoff)
{
// detected filesystem type;
int result = -1;
int fatbits;
// Allocating buffer for 4 sectors.
const void * probeBuffer = malloc(PROBEFS_SIZE);
if (probeBuffer == NULL)
if (buffer)
{
goto exit;
free(buffer);
}
// Reading first 4 sectors of current partition
int error = readBytes(biosdev, blkoff, 0, PROBEFS_SIZE, (void *)probeBuffer);
if (error)
if (countPtr)
{
goto exit;
*countPtr = map ? map->bvrcnt : 0;
}
if (HFSProbe(probeBuffer))
{
result = FDISK_HFS;
}
else if (EX2Probe(probeBuffer))
{
result = FDISK_LINUX;
}
else if (FreeBSDProbe(probeBuffer))
{
result = FDISK_FREEBSD;
}
else if (OpenBSDProbe(probeBuffer))
{
result = FDISK_OPENBSD;
}
else if (BeFSProbe(probeBuffer))
{
result = FDISK_BEFS;
}
else if (EXFATProbe(probeBuffer))
{
result = FDISK_PSEUDO_EXFAT;
}
else if (NTFSProbe(probeBuffer))
{
result = FDISK_NTFS;
}
else if ( (fatbits = MSDOSProbe(probeBuffer)) )
{
switch (fatbits)
{
case 32:
default:
result = FDISK_FAT32;
break;
case 16:
result = FDISK_DOS16B;
break;
case 12:
result = FDISK_DOS12;
break;
}
}
else
{
// Couldn't detect filesystem type
result = 0;
}
exit:
if (probeBuffer)
{
free((void *)probeBuffer);
}
return result;
return map ? map->bvr : NULL;
}
//==============================================================================
void *buffer = malloc(BPS);
int error;
if ( (error = readBytes( biosdev, /*secno*/0, 0, BPS, buffer )) != 0)
if ((error = readBytes( biosdev, /*secno*/0, 0, BPS, buffer )) != 0)
{
verbose("Failed to read boot sector from BIOS device %02xh. Error=%d\n", biosdev, error);
goto scanErr;
// Determine whether the partition header signature is present.
if ( memcmp(headerMap->hdr_sig, GPT_HDR_SIG, strlen(GPT_HDR_SIG)) )
if (memcmp(headerMap->hdr_sig, GPT_HDR_SIG, strlen(GPT_HDR_SIG)))
{
goto scanErr;
}
UInt32 headerCheck = OSSwapLittleToHostInt32(headerMap->hdr_crc_self);
UInt32 headerSize = OSSwapLittleToHostInt32(headerMap->hdr_size);
if ( headerSize < offsetof(gpt_hdr, padding) )
if (headerSize < offsetof(gpt_hdr, padding))
{
goto scanErr;
}
// Determine whether the partition entry size is valid.
UInt64 gptBlock = 0;
UInt32 gptCheck = 0;
UInt32 gptCount = 0;
UInt32 gptID = 0;
gpt_ent * gptMap = 0;
UInt32 gptSize = 0;
UInt64gptBlock= 0;
UInt32gptCheck= 0;
UInt32gptCount= 0;
UInt32gptID= 0;
gpt_ent*gptMap= 0;
UInt32gptSize= 0;
gptBlock = OSSwapLittleToHostInt64(headerMap->hdr_lba_table);
gptCheck = OSSwapLittleToHostInt32(headerMap->hdr_crc_table);
// fdisk like partition type id.
int fsType = 0;
for(gptID = 1; gptID <= gptCount; ++gptID) {
for(gptID = 1; gptID <= gptCount; ++gptID)
{
BVRef bvr = NULL;
unsigned int bvrFlags = 0;
// size on disk can be larger than sizeof(gpt_ent)
gptMap = (gpt_ent *) ( buffer + ( (gptID - 1) * gptSize) );
gptMap = (gpt_ent *)(buffer + ((gptID - 1) * gptSize));
// 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) ) {
bvrFlags = (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ? kBVFlagBooter : 0;
bvr = newGPTBVRef(biosdev,
gptID,
gptMap->ent_lba_start,
gptMap,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, bvrFlags);
}
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,
gptMap->ent_lba_start,
gptMap,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, bvrFlags);
}
// zef - foreign OS support
if ( (efi_guid_compare(&GPT_BASICDATA_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ||
(efi_guid_compare(&GPT_BASICDATA2_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ) {
if ((efi_guid_compare(&GPT_BASICDATA_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ||
(efi_guid_compare(&GPT_BASICDATA2_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) )
{
switch (fsType)
{
case FDISK_NTFS:
break;
default:
if (biosdev == gBIOSDev) {
if (biosdev == gBIOSDev)
{
gBIOSBootVolume = bvr;
}
break;
}
scanErr:
if (buffer) {
if (buffer)
{
free(buffer);
}
if(map) {
if(map)
{
if(countPtr) *countPtr = map->bvrcnt;
{
return map->bvr;
}
} else {
}
else
{
if(countPtr) *countPtr = 0;
{
return NULL;
{
const char *val;
int len;
if (getValueForKey(kProductVersion, &val, &len, &systemVersion))
{
// getValueForKey uses const char for val
{
ret = -1;
error = 0;
//
// Check for alternate volume label on boot helper partitions.
//
if (bvr->flags & kBVFlagBooter)
{
sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/", BIOS_DEV_UNIT(bvr), bvr->part_no);
strcpy(fileSpec, ".disk_label.contentDetails");
sprintf(fileSpec, "%s", ".disk_label.contentDetails");
ret = GetFileInfo(dirSpec, fileSpec, &flags, &time);
if (!ret)
{
if (bvr->flags & kBVFlagNativeBoot)
{
if (getOSVersion(bvr,bvr->OSVersion) == true)
if (getOSVersion(bvr, bvr->OSVersion) == true)
{
bvr->flags |= kBVFlagSystemVolume;
}
{
return;
}
CacheReset();
diskFreeMap(oldMap);
oldMap = NULL;
{
bvr = diskScanFDiskBootVolumes(biosdev, &count);
}
if (bvr == NULL)
{
bvr = diskScanAPMBootVolumes(biosdev, &count);
}
if (bvr)
{
scanFSLevelBVRSettings(bvr);
{
bvr = map->bvr;
}
if (countPtr)
{
*countPtr += count;
}
return bvr;
}
{
break;
}
nextBVR = bvr->next;
if (bvr->filtered)
//==============================================================================
static const struct NamedValue fdiskTypes[] =
{
{ FDISK_NTFS,"Windows NTFS" },
{ FDISK_DOS12,"Windows FAT12" },
{ FDISK_DOS16B,"Windows FAT16" },
{ FDISK_DOS16S,"Windows FAT16" },
{ FDISK_DOS16SLBA,"Windows FAT16" },
{ FDISK_SMALLFAT32,"Windows FAT32" },
{ FDISK_FAT32,"Windows FAT32" },
{ FDISK_FREEBSD,"FreeBSD" },
{ FDISK_OPENBSD,"OpenBSD" },
{ FDISK_LINUX,"Linux" },
{ FDISK_UFS,"Apple UFS" },
{ FDISK_HFS,"Apple HFS" },
{ FDISK_BOOTER,"Apple Boot/UFS" },
{ FDISK_BEFS,"Haiku" },
{ 0xCD,"CD-ROM" },
{ 0x00,0 } /* must be last */
};
//==============================================================================
bool matchVolumeToString( BVRef bvr, const char* match, long matchLen)
{
char testStr[128];
if (name == NULL)
{
sprintf(p, "TYPE %02x", type);
sprintf(p, "TYPE %02X", type);
}
else
{
//==============================================================================
int readBootSector(int biosdev, unsigned int secno, void * buffer)
int readBootSector(int biosdev, unsigned int secno, void *buffer)
{
int error;
struct disk_blk0 * bootSector = (struct disk_blk0 *) buffer;
struct disk_blk0 * bootSector = (struct disk_blk0 *)buffer;
if (bootSector == NULL)
{
if (gBootSector == NULL)
{
gBootSector = (struct disk_blk0 *) malloc(sizeof(*gBootSector));
gBootSector = (struct disk_blk0 *)malloc(sizeof(*gBootSector));
if (gBootSector == NULL)
{
//==============================================================================
int testFAT32EFIBootSector( int biosdev, unsigned int secno, void * buffer )
int testFAT32EFIBootSector(int biosdev, unsigned int secno, void *buffer)
{
struct disk_boot1f32_blk * bootSector = (struct disk_boot1f32_blk *) buffer;
int error;
struct disk_boot1f32_blk *bootSector = (struct disk_boot1f32_blk *)buffer;
int error;
if ( bootSector == NULL )
if (bootSector == NULL)
{
if ( gBootSector == NULL )
if (gBootSector == NULL)
{
gBootSector = (struct disk_blk0 *) malloc(sizeof(*gBootSector));
gBootSector = (struct disk_blk0 *)malloc(sizeof(*gBootSector));
if ( gBootSector == NULL )
{
return -1;
}
}
bootSector = (struct disk_boot1f32_blk *) gBootSector;
bootSector = (struct disk_boot1f32_blk *)gBootSector;
}
error = readBytes( biosdev, secno, 0, BPS, bootSector );
if ( error || bootSector->signature != DISK_SIGNATURE || strncmp((const char *)bootSector->magic, BOOT1F32_MAGIC, BOOT1F32_MAGICLEN) )
error = readBytes(biosdev, secno, 0, BPS, bootSector);
if (error || bootSector->signature != DISK_SIGNATURE || strncmp((const char *)bootSector->magic, BOOT1F32_MAGIC, BOOT1F32_MAGICLEN) )
{
return -1;
}
int diskIsCDROM(BVRef bvr)
{
struct driveInfo di;
struct driveInfo di;
if (getDriveInfo(bvr->biosdev, &di) == 0 && di.no_emulation)
{
int biosDevIsCDROM(int biosdev)
{
struct driveInfo di;
struct driveInfo di;
if (getDriveInfo(biosdev, &di) == 0 && di.no_emulation)
{
branches/ErmaC/Enoch/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
......
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
828837
829838
830839
831
832
833
840
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
1106
1107
1141
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
1250
1300
12511301
12521302
1253
1303
12541304
1255
1305
1306
12561307
12571308
12581309
1259
1310
1311
12601312
12611313
12621314
12631315
1264
1316
1317
12651318
12661319
12671320
12681321
1269
1322
1323
12701324
12711325
12721326
......
12761330
12771331
12781332
1279
1333
1334
12801335
12811336
12821337
12831338
12841339
12851340
1286
1341
1342
12871343
12881344
12891345
12901346
1291
1347
1348
12921349
12931350
12941351
......
13041361
13051362
13061363
1307
1364
1365
13081366
13091367
13101368
......
13311389
13321390
13331391
1334
1392
1393
13351394
13361395
13371396
......
13501409
13511410
13521411
1412
1413
1414
13531415
13541416
1355
1356
13571417
13581418
13591419
13601420
1361
1421
1422
13621423
1363
1424
1425
13641426
13651427
13661428
......
13911453
13921454
13931455
1394
1456
1457
13951458
13961459
13971460
......
14171480
14181481
14191482
1420
1483
1484
14211485
14221486
1423
1487
1488
14241489
14251490
14261491
......
14321497
14331498
14341499
1435
1500
1501
14361502
14371503
14381504
/* =======================
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
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
if (structHeader->type == kSMBTypeMemoryDevice) {
while ((strSize != 0) && (string[strSize - 1] == ' ')) {
// remove any spaces found at the end but only in MemoryDevice avoiding errors
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 smaller or truncate bigger - we use SMBIOS rev. 2.4 like Apple uses
switch (structPtr->orig->type) {
// 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)
{
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;