Chameleon

Chameleon Commit Details

Date:2015-01-21 02:16:43 (9 years 3 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;
}
ptr = (uint8_t *)((uint32_t)structHeader + structHeader->length);
for (; ((uint16_t *)ptr)[0] != 0; ptr++);
if (((uint16_t *)ptr)[0] == 0) {
if (((uint16_t *)ptr)[0] == 0)
{
ptr += 2;
}
ptr = ((SMBSystemInformation *)structHeader)->uuid;
if (!sysId || !ret) { // no or bad custom UUID,...
if (!sysId || !ret) // no or bad custom uuid,...
{
sysId = 0;
ret = Platform.UUID; // ...try bios dmi system uuid extraction
ret = Platform.UUID; // ...use original (factory) system uuid
}
for (i=0, isZero=1, isOnes=1; i<UUID_LEN; i++) // check if empty or setable, means: no uuid present
for (i = 0, isZero = 1, isOnes = 1; i < UUID_LEN; i++) // check if empty (zeroed) or setable (FFed), means: no uuid present
{
if (ret[i] != 0x00) {
if (ret[i] != 0x00)
{
isZero = 0;
}
if (ret[i] != 0xff) {
if (ret[i] != 0xff)
{
isOnes = 0;
}
}
if (isZero || isOnes) { // if empty or setable...
if (isZero || isOnes) // if empty or setable...
{
verbose("No UUID present in SMBIOS System Information Table\n");
ret = FixedUUID; // ...set a fixed value for system-id = 000102030405060708090A0B0C0D0E0F
}
memcpy(ptr, ret, UUID_LEN); // fix uuid in the table
memcpy(ptr, ret, UUID_LEN); // save uuid into the patched SMBIOS Table 1
return ptr;
} // Bungo: end fix
uint8_t *buffer;
// bool setSMB = true; Bungo: now we use useSMBIOSdefaults
if (!origeps) {
if (!origeps)
{
return;
}
neweps = origeps;
structPtr = (SMBStructPtrs *)malloc(sizeof(SMBStructPtrs));
if (!structPtr) {
if (!structPtr)
{
return;
}
buffer = (uint8_t *)malloc(SMB_ALLOC_SIZE);
if (!buffer) {
if (!buffer)
{
free(structPtr);
return;
}
setupNewSMBIOSTable(origeps, structPtr);
neweps = (SMBEntryPoint *)AllocateKernelMemory(sizeof(SMBEntryPoint));
if (!neweps) {
if (!neweps)
{
free(buffer);
free(structPtr);
return;
neweps->dmi.structureCount= structureCount;
neweps->dmi.bcdRevision= 0x24; // ... and 2.4 DMI rev. as real Macs
if (!neweps->dmi.tableAddress) {
if (!neweps->dmi.tableAddress)
{
free(buffer);
free(structPtr);
return;
free(buffer);
free(structPtr);
DBG("SMBIOS orig was = %x\n", origeps);
DBG("SMBIOS new is = %x\n", neweps);
decodeSMBIOSTable(neweps);
DBG("SMBIOS orig was = %x\n", origeps);
DBG("SMBIOS new is = %x\n", neweps);
}
void *getSmbios(int which)
{
switch (which) {
switch (which)
{
case SMBIOS_ORIGINAL:
if (!origeps) {
if (!origeps)
{
origeps = getAddressOfSmbiosTable();
}
return origeps;
break;
case kSMBTypeSystemEnclosure: // Bungo: determine platform type
switch (((SMBSystemEnclosure *)structHeader)->chassisType) {
switch (((SMBSystemEnclosure *)structHeader)->chassisType)
{
case kSMBchassisDesktop:
case kSMBchassisLPDesktop:
case kSMBchassisAllInOne:
case kSMBTypeMemoryDevice:
Platform.DMI.CntMemorySlots++;
if (((SMBMemoryDevice *)structHeader)->memorySize != 0){
if (((SMBMemoryDevice *)structHeader)->memorySize != 0)
{
Platform.DMI.MemoryModules++;
}
if (((SMBMemoryDevice *)structHeader)->memorySpeed > 0){
if (((SMBMemoryDevice *)structHeader)->memorySpeed > 0)
{
Platform.RAM.DIMM[dimmnbr].Frequency = ((SMBMemoryDevice *)structHeader)->memorySpeed;
}
dimmnbr++;
structPtr = (uint8_t *)((uint32_t)structHeader + structHeader->length);
for (; ((uint16_t *)structPtr)[0] != 0; structPtr++);
if (((uint16_t *)structPtr)[0] == 0) {
if (((uint16_t *)structPtr)[0] == 0)
{
structPtr += 2;
}
branches/ErmaC/Enoch/i386/libsaio/smbios_decode.c
2323
2424
2525
26
27
28
29
26
27
28
29
3030
31
31
3232
3333
3434
......
223223
224224
225225
226
227
226
228227
229228
230229
231230
232231
233232
234
233
234
235235
236236
237
237
238
238239
239240
240241
......
243244
244245
245246
246
247
247248
248249
249250
......
372373
373374
374375
375
376
376377
377378
378379
379380
380
381
382
381383
382
384
385
386
383387
384388
385389
......
388392
389393
390394
391
392
393
394
395
395
396
397
398
399
400
401
402
403
404
405
406
396407
397408
398409
......
533544
534545
535546
536
547
537548
538549
539550
extern char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field);
// Bungo:
#define NotSpecifiedStr "Not Specified" // no string
#define OutOfSpecStr "<OUT OF SPEC>" // value out of smbios spec. range
#define PrivateStr "** PRIVATE **" // masking private data
#define neverMask false
#define NotSpecifiedStr "Not Specified" // no string
#define OutOfSpecStr "<OUT OF SPEC>" // value out of smbios spec. range
#define PrivateStr "** PRIVATE **" // masking private data
#define neverMask false
static bool privateData = true;
static bool privateData = true;
static SMBByte minorVersion; // SMBIOS rev. minor
static SMBByte majorVersion; // SMBIOS rev. major
static SMBByte bcdRevisionLo; // DMI rev. minor
"FBD2"/* 19h FBD2 */
};
static const int kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) /
sizeof(SMBMemoryDeviceTypes[0]);
static const int kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) / sizeof(SMBMemoryDeviceTypes[0]);
// Bungo: fixes random string readout if null in smbios to "Not Specified" as dmidecode displays
char *SMBStringForField(SMBStructHeader *structHeader, uint8_t field, const bool mask)
{
char *str = NULL;
str = getSMBStringForField(structHeader, field);
if (!field) {
if (!field)
{
str = NotSpecifiedStr;
}
else if (mask) {
else if (mask)
{
str = PrivateStr;
}
void printHeader(SMBStructHeader *structHeader)
{
DBG("Handle: 0x%04x, DMI type %d, %d bytes\n", structHeader->handle, structHeader->type, structHeader->length);
DBG("Handle: 0x%04X, DMI type %d, %d bytes\n", structHeader->handle, structHeader->type, structHeader->length);
}
//-------------------------------------------------------------------------------------------------------------------------
//DBG("\tSignature: Type %u, Family %u, Model %u, Stepping %u\n", (eax >> 12) & 0x3, ((eax >> 20) & 0xFF) + ((eax >> 8) & 0x0F), ((eax >> 12) & 0xF0) + ((eax >> 4) & 0x0F), eax & 0xF);
// Flags:
DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->processorVersion, neverMask));
//DBG("\tVoltage: 0.%xV\n", ((SMBProcessorInformation *)structHeader)->voltage);
//DBG("\tVoltage: 0.%dV\n", ((SMBProcessorInformation *)structHeader)->voltage);
DBG("\tExternal Clock: %d MHz\n", ((SMBProcessorInformation *)structHeader)->externalClock);
DBG("\tMax Speed: %d MHz\n", ((SMBProcessorInformation *)structHeader)->maximumClock);
DBG("\tCurrent Speed: %d MHz\n", ((SMBProcessorInformation *)structHeader)->currentClock);
// Status: Populated/Unpopulated
if ((((SMBProcessorInformation *)structHeader)->processorUpgrade < 1) || (((SMBProcessorInformation *)structHeader)->processorUpgrade > 0x2C)) {
if ((((SMBProcessorInformation *)structHeader)->processorUpgrade < 1) || (((SMBProcessorInformation *)structHeader)->processorUpgrade > 0x2C))
{
DBG("\tUpgrade: %s\n", OutOfSpecStr);
} else {
}
else
{
DBG("\tUpgrade: %s\n", SMBProcessorUpgrades[((SMBProcessorInformation *)structHeader)->processorUpgrade - 1]);
}
// L1 Cache Handle:
DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->serialNumber, privateData));
DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->assetTag, neverMask));
DBG("\tPart Number: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->partNumber, neverMask));
if(((SMBProcessorInformation *)structHeader)->coreCount != 0) {
DBG("\tCore Count: %d\n", ((SMBProcessorInformation *)structHeader)->coreCount);}
if(((SMBProcessorInformation *)structHeader)->coreEnabled != 0) {
DBG("\tCore Enabled: %d\n", ((SMBProcessorInformation *)structHeader)->coreEnabled);}
if(((SMBProcessorInformation *)structHeader)->threadCount != 0) {
if(((SMBProcessorInformation *)structHeader)->coreCount != 0)
{
DBG("\tCore Count: %d\n", ((SMBProcessorInformation *)structHeader)->coreCount);
}
if(((SMBProcessorInformation *)structHeader)->coreEnabled != 0)
{
DBG("\tCore Enabled: %d\n", ((SMBProcessorInformation *)structHeader)->coreEnabled);
}
if(((SMBProcessorInformation *)structHeader)->threadCount != 0)
{
DBG("\tThread Count: %d\n", ((SMBProcessorInformation *)structHeader)->threadCount);
}
// Characteristics:
{
printHeader(structHeader);
DBG("Apple specific Processor Type\n");
DBG("\tCpu-type: 0x%x\n", ((SMBOemProcessorType *)structHeader)->ProcessorType);
DBG("\tCpu-type = 0x%04X\n", ((SMBOemProcessorType *)structHeader)->ProcessorType);
DBG("\n");
}
branches/ErmaC/Enoch/i386/libsaio/smbios.h
2323
2424
2525
26
2726
2827
2928
......
3332
3433
3534
36
3735
3836
3937
......
140138
141139
142140
143
141
144142
145143
146144
......
160158
161159
162160
163
161
164162
165163
166164
......
199197
200198
201199
202
200
203201
204202
205203
......
268266
269267
270268
271
269
272270
273271
274272
......
287285
288286
289287
290
288
289
291290
292291
293292
......
542541
543542
544543
545
544
546545
547546
548547
......
567566
568567
569568
570
569
571570
572571
573572
......
610609
611610
612611
613
612
614613
615614
616615
......
627626
628627
629628
630
629
631630
632631
633632
......
648647
649648
650649
651
650
652651
653652
654653
......
684683
685684
686685
687
686
688687
689688
690689
......
700699
701700
702701
703
702
704703
705704
706705
......
735734
736735
737736
738
737
739738
740739
741740
......
787786
788787
789788
790
789
791790
792791
793792
......
861860
862861
863862
864
865863
#ifndef __LIBSAIO_SMBIOS_H
#define __LIBSAIO_SMBIOS_H
/* Based on System Management BIOS Reference Specification v2.4 */
// http://dmtf.org/standards/smbios
typedef uint32_t SMBDWord;
typedef uint64_t SMBQWord;
typedef struct DMIEntryPoint
{
SMBByte anchor[5];
};
//----------------------------------------------------------------------------------------------------------
// Struct - BIOS Information (Type 0)
// Struct - BIOS Information (Type 0), Apple uses 24 bytes length
typedef struct SMBBIOSInformation
{
SMB_STRUCT_HEADER
} __attribute__((packed)) SMBBIOSInformation;
//----------------------------------------------------------------------------------------------------------
// Struct - System Information (Type 1)
// Struct - System Information (Type 1), Apple uses 27 bytes length
typedef struct SMBSystemInformation
{
// 2.0+ spec (8 bytes)
kSMBBaseBoardInterconnect = 0x0D// Interconnect board
} BASE_BOARD_TYPE;
// Struct - Base Board (or Module) Information (Type 2)
// Struct - Base Board (or Module) Information (Type 2), Apple uses 16 bytes length
typedef struct SMBBaseBoard
{
SMB_STRUCT_HEADER // Type 2
kSMBChassisSecurityStatusExternalInterfaceLockedEnabled = 0x05
} MISC_CHASSIS_SECURITY_STATE;
// Struct - System Enclosure (Type 3)
// Struct - System Enclosure (Type 3), Apple uses 21 bytes length
typedef struct SMBSystemEnclosure
{
SMB_STRUCT_HEADER // Type 3
SMBByte containedElementCount;// Number of Contained Element record that follow, in the range 0 to 255
//SMBByte containedElementRecord;// Byte leght of each Contained Element record that follow, in the range 0 to 255
//SMBByte containedElements;// Elements, possibly defined by other SMBIOS structures present in chassis
//SMBString skuNumber;// Number of null-terminated string describing the chassis or enclosure SKU number (2.7+)
// 2.7+
//SMBString skuNumber;// Number of null-terminated string describing the chassis or enclosure SKU number
} __attribute__((packed)) SMBSystemEnclosure;
//----------------------------------------------------------------------------------------------------------
kSMBprocessorUpgradeSocketFM2 = 0x2A
} PROCESSOR_UPGRADE;
// Struct - Processor Information (Type 4).
// Struct - Processor Information (Type 4), Apple uses 35 bytes length
typedef struct SMBProcessorInformation
{
// 2.0+ spec (26 bytes)
SMBString serialNumber;
SMBString assetTag;
SMBString partNumber;
// 2.5+ spec (38 bytes)
// 2.5+ spec (40 bytes)
SMBByte coreCount;
SMBByte coreEnabled;
SMBByte threadCount;
#define kSMBMemoryModuleSizeNotInstalled 0x7F
//----------------------------------------------------------------------------------------------------------
// Struct - Cache Information (Type 7)
// Struct - Cache Information (Type 7), Apple uses 19 bytes length
typedef struct SMBCacheInformation
{
SMB_STRUCT_HEADER // Type 7
} __attribute__((packed)) SMBCacheInformation;
//----------------------------------------------------------------------------------------------------------
// Struct - System Slots (Type 9)
// Struct - System Slots (Type 9), Apple uses 13 bytes length
typedef struct SMBSystemSlot
{
// 2.0+ spec (12 bytes)
} __attribute__((packed)) SMBSystemSlot;
//----------------------------------------------------------------------------------------------------------
// Struct - OEM Strings (Type 11)
// Struct - OEM Strings (Type 11), Apple uses 5 bytes length
typedef struct SMBOEMStrings
{
SMB_STRUCT_HEADER // Type 11
kSMBMemoryArrayErrorCorrectionTypeCRC = 0x07
} MEMORY_ERROR_CORRECTION;
// Struct - Physical Memory Array (Type 16)
// Struct - Physical Memory Array (Type 16), Apple uses 15 bytes length
typedef struct SMBPhysicalMemoryArray
{
// 2.1+ spec (15 bytes)
} __attribute__((packed)) SMBPhysicalMemoryArray;
//----------------------------------------------------------------------------------------------------------
// Struct - Memory Device (Type 17)
// Struct - Memory Device (Type 17), Apple uses 27 bytes length
typedef struct SMBMemoryDevice
{
// 2.1+ spec (21 bytes)
//----------------------------------------------------------------------------------------------------------
// Struct - Memory Array Mapped Address (Type 19)
// Struct - Memory Array Mapped Address (Type 19), Apple uses 15 bytes length
//typedef struct SMBMemoryArrayMappedAddress
//{
// 2.1+ spec
SMBDWord EndAddress;
} __attribute__((packed)) FW_REGION_INFO;
// Struct - Firmware Volume Description (Apple Specific - Type 128)
// Struct - Firmware Volume Description (Apple Specific - Type 128), Apple uses 88 bytes length
typedef struct SMBFirmwareVolume
{
SMB_STRUCT_HEADER// Type 128
extern void decodeSMBIOSTable(SMBEntryPoint *eps);
#endif /* !__LIBSAIO_SMBIOS_H */
branches/ErmaC/Enoch/i386/libsaio/pci.c
7575
7676
7777
78
79
78
79
80
81
8082
8183
82
84
85
8386
8487
88
8589
86
90
91
8792
8893
94
8995
9096
9197
......
99105
100106
101107
102
103
104
105
106
107
108
109
110
111
108
109
110
111
112
113
114
115
116
117
118
119
112120
121
113122
114123
115124
116
125
126
117127
118128
119129
......
131141
132142
133143
144
134145
135146
136147
......
144155
145156
146157
147
158
159
148160
149161
150162
......
159171
160172
161173
174
162175
163176
164177
165178
166
179
167180
168181
169182
......
175188
176189
177190
178
191
192
179193
180194
181195
182
196
197
198
183199
184200
185201
uint8_tsecondary_bus;
uint8_theader_type;
for (dev = 0; dev < 32; dev++) {
for (func = 0; func < 8; func++) {
for (dev = 0; dev < 32; dev++)
{
for (func = 0; func < 8; func++)
{
pci_addr = PCIADDR(bus, dev, func);
id = pci_config_read32(pci_addr, PCI_VENDOR_ID);
if (!id || id == 0xfffffffful) {
if (!id || id == 0xfffffffful)
{
continue;
}
new = (pci_dt_t*)malloc(sizeof(pci_dt_t));
if (!new) {
if (!new)
{
continue;
}
bzero(new, sizeof(pci_dt_t));
new->dev.addr= pci_addr;
new->parent= start;
header_type = pci_config_read8(pci_addr, PCI_HEADER_TYPE);
switch (header_type & 0x7f) {
case PCI_HEADER_TYPE_BRIDGE:
case PCI_HEADER_TYPE_CARDBUS:
secondary_bus = pci_config_read8(pci_addr, PCI_SECONDARY_BUS);
if (secondary_bus != 0) {
scan_pci_bus(new, secondary_bus);
}
break;
default:
break;
switch (header_type & 0x7f)
{
case PCI_HEADER_TYPE_BRIDGE:
case PCI_HEADER_TYPE_CARDBUS:
secondary_bus = pci_config_read8(pci_addr, PCI_SECONDARY_BUS);
if (secondary_bus != 0)
{
scan_pci_bus(new, secondary_bus);
}
break;
default:
break;
}
*current = new;
current = &new->next;
if ((func == 0) && ((header_type & 0x80) == 0)) {
if ((func == 0) && ((header_type & 0x80) == 0))
{
break;
}
}
{
return;
}
rcba = pci_config_read32(PCIADDR(0, 0x1f, 0), 0xf0) & ~1; //this is LPC host
fd = (uint32_t *)(rcba + 0x3418);
/* set SMBus Disable (SD) to 0 */
{
root_pci_dev = malloc(sizeof(pci_dt_t));
if (!root_pci_dev) {
if (!root_pci_dev)
{
return;
}
}
static char dev_path[256];
char *get_pci_dev_path(pci_dt_t *pci_dt)
{
pci_dt_t*current;
pci_dt_t*end;
int dev_path_len = 0;
intdev_path_len = 0;
dev_path[0] = 0;
end = root_pci_dev;
while (current->parent != end)
current = current->parent;
end = current;
if (current->parent == root_pci_dev) {
if (current->parent == root_pci_dev)
{
dev_path_len +=
snprintf(dev_path + dev_path_len, sizeof(dev_path) - dev_path_len, "PciRoot(0x%x)/Pci(0x%x,0x%x)", uid,
current->dev.bits.dev, current->dev.bits.func);
} else {
}
else
{
dev_path_len +=
snprintf(dev_path + dev_path_len, sizeof(dev_path) - dev_path_len, "/Pci(0x%x,0x%x)",
current->dev.bits.dev, current->dev.bits.func);
branches/ErmaC/Enoch/i386/libsaio/stringTable.c
332332
333333
334334
335
335
336336
337
338
339
337
338
339
340
340341
341342
342343
......
347348
348349
349350
350
351
351352
352353
353354
354355
355
356
356
357
358
359
357360
358
361
362
363
359364
360365
361366
......
363368
364369
365370
366
371
367372
368373
369374
370375
371376
372377
373
378
374379
375380
376381
......
508513
509514
510515
511
516
512517
513518
514519
......
547552
548553
549554
550
555
551556
552557
553558
......
617622
618623
619624
620
625
621626
622627
623628
}
/* Return NULL if no option has been successfully retrieved, or the string otherwise */
const char * getStringForKey(const char * key, config_file_t *config)
const char *getStringForKey(const char *key, config_file_t *config)
{
static const char* value =0;
int len=0;
if(!getValueForKey(key, &value, &len, config)) {
static const char *value = 0;
int len = 0;
if (!getValueForKey(key, &value, &len, config))
{
value = 0;
}
return value;
* The boolean value of the key is stored in 'val'.
*/
bool getBoolForKey( const char *key, bool *result_val, config_file_t *config )
bool getBoolForKey(const char *key, bool *result_val, config_file_t *config)
{
const char *key_val;
int size;
if (getValueForKey(key, &key_val, &size, config)) {
if ( (size >= 1) && (key_val[0] == 'Y' || key_val[0] == 'y') ) {
if (getValueForKey(key, &key_val, &size, config))
{
if ((size >= 1) && (key_val[0] == 'Y' || key_val[0] == 'y'))
{
*result_val = true;
} else {
}
else
{
*result_val = false;
}
return true;
return false;
}
bool getIntForKey( const char *key, int *value, config_file_t *config )
bool getIntForKey(const char *key, int *value, config_file_t *config)
{
const char *val;
int size, sum;
bool negative = false;
if (getValueForKey(key, &val, &size, config)) {
if ( size ) {
if (size) {
if (*val == '-') {
negative = true;
val++;
if (override) {
*val = overrideVal;
*size = overrideSize;
return true;
ret = true;
}
}
}
// (and does not modify dict pointer).
// Prints an error message if there is a parsing error.
//
int ParseXMLFile( char * buffer, TagPtr * dict )
int ParseXMLFile( char *buffer, TagPtr *dict )
{
long length, pos;
TagPtr tag;
"/Mac OS X Install Data/com.apple.Boot.plist",// OS X Installer (Lion 10.7)
"/OS X Install Data/com.apple.Boot.plist",// OS X Installer (10.8+)
"/.IABootFiles/com.apple.Boot.plist",// OS X Installer
"/Library/Preferences/SystemConfiguration/com.apple.Boot.plist",// com.boot.Apple.plist
"/Library/Preferences/SystemConfiguration/com.apple.Boot.plist",// com.apple.Boot.plist
"/com.apple.recovery.boot/com.apple.Boot.plist"// OS X Recovery
};
branches/ErmaC/Enoch/i386/libsaio/convert.c
2929
3030
3131
32
32
3333
3434
35
35
3636
3737
3838
39
39
4040
4141
4242
4343
4444
45
45
4646
4747
4848
char*p = (char *)source;
inti;
charbuf[3];
static EFI_CHAR8 uuid[UUID_LEN+1]="";
static EFI_CHAR8 uuid[UUID_LEN+1] = "";
buf[2] = '\0';
for (i=0; i<UUID_LEN; i++)
for (i = 0; i < UUID_LEN; i++)
{
if (p[0] == '\0' || p[1] == '\0' || !isxdigit(p[0]) || !isxdigit(p[1]))
{
verbose("[ERROR] UUID='%s' syntax error\n", source);
verbose("[ERROR] UUID='%s' syntax error.\n", source);
return 0;
}
buf[0] = *p++;
buf[1] = *p++;
uuid[i] = (unsigned char) strtoul(buf, NULL, 16);
if (*p == '-' && (i % 2) == 1 && i < UUID_LEN - 1)
if ((*p == '-') && ((i % 2) == 1) && (i < UUID_LEN - 1))
{
p++;
}
branches/ErmaC/Enoch/i386/libsaio/saio_types.h
145145
146146
147147
148
149
148
149
150150
151151
152152
......
206206
207207
208208
209
209
210210
211211
212212
structBootVolume;
typedef struct BootVolume * BVRef;
typedef struct BootVolume * CICell;
typedef structBootVolume *BVRef;
typedef structBootVolume *CICell;
typedef long (*FSInit)(CICell ih);
typedef long (*FSLoadFile)(CICell ih, char * filePath);
BVFreebv_free;/* BVFree function */
uint32_tmodTime;
charlabel[BVSTRLEN];/* partition volume label */
charaltlabel[BVSTRLEN];/* partition volume label */
charaltlabel[BVSTRLEN];/* alternate partition volume label */
boolfiltered;/* newFilteredBVChain() will set to TRUE */
boolvisible;/* will shown in the device list */
charOSVersion[8];
branches/ErmaC/Enoch/i386/libsaio/msdos.c
5252
5353
5454
55
55
5656
57
58
59
60
57
58
59
60
6161
6262
6363
......
149149
150150
151151
152
153
152
154153
155154
156155
......
252251
253252
254253
255
256
254
257255
258256
259257
......
280278
281279
282280
283
284
281
285282
286283
287284
......
346343
347344
348345
349
350
346
351347
352348
353349
......
391387
392388
393389
394
390
391
392
395393
396394
397395
......
417415
418416
419417
420
421
418
422419
423
420
421
422
424423
425424
426425
427426
428427
429
428
429
430
431
430432
431433
432434
......
568570
569571
570572
571
572
573
573574
574575
575576
......
605606
606607
607608
608
609
609
610610
611611
612612
......
633633
634634
635635
636
636637
638
639
637640
638641
642
639643
644
645
640646
641647
642648
......
645651
646652
647653
654
648655
656
657
649658
650659
651660
......
662671
663672
664673
665
666
674
675
667676
668677
669678
......
714723
715724
716725
726
717727
728
729
718730
719731
720732
......
748760
749761
750762
763
751764
765
752766
753767
754768
755769
770
756771
757772
758773
759774
760775
761776
777
762778
763779
764780
765781
782
766783
767784
768785
......
770787
771788
772789
790
773791
792
793
774794
775795
776796
......
797817
798818
799819
800
801
820
802821
803822
804823
......
819838
820839
821840
841
822842
843
823844
824845
825846
826847
848
827849
828850
829851
......
832854
833855
834856
857
835858
859
836860
837861
838862
839863
840864
841865
866
842867
843868
844869
845870
846871
872
847873
848
874
875
876
849877
878
879
850880
851881
882
852883
853884
854885
......
884915
885916
886917
918
887919
920
888921
922
923
889924
925
890926
927
928
891929
930
892931
893932
894933
......
896935
897936
898937
938
899939
900940
901941
902942
903943
944
904945
946
905947
948
906949
907
950
951
908952
909953
910
954
955
911956
912957
958
913959
960
961
914962
915963
916964
917965
966
918967
968
969
919970
920971
921972
922973
923974
975
924976
977
978
925979
926980
927981
......
9521006
9531007
9541008
955
956
957
958
959
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
9601019
1020
9611021
9621022
9631023
1024
9641025
965
1026
1027
9661028
9671029
9681030
969
9701031
9711032
972
973
974
975
976
1033
1034
1035
1036
1037
9771038
978
1039
9791040
9801041
9811042
......
9861047
9871048
9881049
989
1050
9901051
9911052
9921053
......
9951056
9961057
9971058
998
1059
1060
9991061
10001062
10011063
......
10101072
10111073
10121074
1075
10131076
1014
1077
1078
10151079
10161080
10171081
......
10391103
10401104
10411105
1042
1043
1106
10441107
10451108
10461109
......
10601123
10611124
10621125
1063
1126
1127
10641128
10651129
10661130
1067
1068
1131
10691132
#include "msdos.h"
#define LABEL_LENGTH11
#define MSDOS_CACHE_BLOCKSIZE BPS
#define MSDOS_CACHE_BLOCKSIZEBPS
#defineCLUST_FIRST2/* reserved cluster range */
#defineCLUST_RSRVD320x0ffffff8/* reserved cluster range */
#defineCLUST_RSRVD160xfff8/* reserved cluster range */
#defineCLUST_RSRVD120xff8/* reserved cluster range */
#defineCLUST_FIRST2/* reserved cluster range */
#defineCLUST_RSRVD320x0ffffff8/* reserved cluster range */
#defineCLUST_RSRVD160xfff8/* reserved cluster range */
#defineCLUST_RSRVD120xff8/* reserved cluster range */
#define tolower(c) (((c)>='A' && c<='Z')?((c) | 0x20):(c))
}
long
MSDOSInitPartition (CICell ih)
long MSDOSInitPartition (CICell ih)
{
union bootsector *bsp;
struct bpb33 *b33;
return 0;
}
static int
readSector(CICell ih, off_t readOffset, char *buf, int size)
static int readSector(CICell ih, off_t readOffset, char *buf, int size)
{
// Caching only FAT entries (4 bytes) by utlizing the cache with sector aligned read requests.
if (size < BPS)
return 0;
}
static int
msdosreadcluster (CICell ih, uint8_t *buf, int size, off_t *cluster)
static int msdosreadcluster (CICell ih, uint8_t *buf, int size, off_t *cluster)
{
off_t readOffset;
char tmpbuf[8];
}
}
static struct direntry *
getnextdirent (CICell ih, uint16_t *longname, struct msdosdirstate *st)
static struct direntry *getnextdirent (CICell ih, uint16_t *longname, struct msdosdirstate *st)
{
struct direntry *dirp;
while (1)
bcopy (&(wdirp->wePart1),longname+WIN_CHARS*(num-1),sizeof (wdirp->wePart1));
bcopy (&(wdirp->wePart2),longname+WIN_CHARS*(num-1)+5,sizeof (wdirp->wePart2));
bcopy (&(wdirp->wePart3),longname+WIN_CHARS*(num-1)+11,sizeof (wdirp->wePart3));
} else {
}
else
{
uint8_t labelchecksum;
int i;
longname[st->vfatnumber*WIN_CHARS]=0;
}
}
static void
initRoot (struct msdosdirstate *st)
static void initRoot (struct msdosdirstate *st)
{
if (msdosrootDirSectors) {/* FAT12 or FAT16 */
if (msdosrootDirSectors)
{
/* FAT12 or FAT16 */
st->root16 = 1;
st->vfatchecksum = 0;
st->nument = 0;
st->cluster = 0;
st->vfatnumber = 0;
} else {/* FAT32 */
}
else
{
/* FAT32 */
st->root16 = 0;
st->vfatchecksum = 0;
st->nument = 0;
{0x00A0,0x00A0}
};
static int
checkname (uint16_t *ucsname, int ucslen, struct direntry *dirp, uint16_t *vfatname)
static int checkname (uint16_t *ucsname, int ucslen, struct direntry *dirp, uint16_t *vfatname)
{
uint16_t tmp[15];
if (vfatname[0])
}
static struct direntry *
getdirpfrompath (CICell ih, char *dirspec, uint8_t *buf)
static struct direntry *getdirpfrompath (CICell ih, char *dirspec, uint8_t *buf)
{
struct msdosdirstate st;
struct direntry *dirp;
{
for (;*ptr && *ptr!='/';ptr++);
if (!*ptr)
{
return dirp;
}
ptr++;
if (!*ptr)
{
return dirp;
}
for (slash=ptr;*slash && *slash!='/';slash++);
c=*slash;
*slash=0;
ucsname[ucslenhost]=0;
*slash=c;
if (!(dirp->deAttributes & ATTR_DIRECTORY))
{
return 0;
}
st.root16 = 0;
st.vfatchecksum = 0;
st.nument = 0;
char ** name, long * flags, u_int32_t * time,
FinderInfo * finderInfo, long * infoValid)
{
struct msdosdirstate *st;
struct direntry *dirp;
struct msdosdirstate*st;
struct direntry*dirp;
uint16_tvfatname[WIN_MAXLEN+2*WIN_CHARS];
if (MSDOSInitPartition (ih)<0)
{
}
else
{
initRoot (st);
}
*dirIndex = (long long) (long) st;
}
while((dirp = getnextdirent (ih, vfatname, st))&& (dirp->deAttributes & ATTR_VOLUME));
free (st);
return -1;
}
for (i=7;i>=0;i--)
{
if (dirp->deName[i]!=' ')
{
break;
}
}
j=i+1;
tmp[i+1]=0;
for(;i>=0;i--)
tmp[i]=(dirp->deName[i]>=128)?cp850[dirp->deName[i]-128][0]:tolower(dirp->deName[i]);
for (i=2;i>=0;i--)
{
if (dirp->deName[8+i]!=' ')
{
break;
}
}
if (i>=0)
{
tmp[j+i+1]=0;
k=j+i+1;
for(;i>=0;i--)
{
tmp[j+i]=(dirp->deName[i]>=128)?cp850[dirp->deName[i+8]-128][0]:tolower(dirp->deName[i+8]);
}
j=k;
}
return 0;
}
long
MSDOSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length)
long MSDOSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length)
{
uint8_t *buf;
off_t cluster;
{
filePath++;
}
buf = malloc(msdosclustersize);
if (!buf)
{
return -1;
}
bzero(buf,msdosclustersize);
dirp = getdirpfrompath (ih, filePath, buf);
free (buf);
return -1;
}
cluster = OSReadLittleInt16 ((dirp->deStartCluster),0);
if (msdosfatbits == 32)
{
cluster |= ((uint32_t)OSReadLittleInt16 ((dirp->deHighClust),0)) <<16;
}
size = (uint32_t)OSReadLittleInt32 ((dirp->deFileSize),0);
if (size<=offset)
{
free (buf);
return -1;
}
nskip=offset/msdosclustersize;
for (i=0;i<nskip;i++)
for (i = 0; i < nskip; i++)
{
msdosreadcluster (ih, 0, 0, &cluster);
}
msdosreadcluster (ih, buf, msdosclustersize, &cluster);
toread=length;
if (length==0 || length>size-offset)
{
toread=size-offset;
uint8_t *buf;
off_t cluster;
struct direntry *dirp;
if (MSDOSInitPartition (ih)<0)
{
return -1;
}
if (filePath[0] == '/')
{
filePath++;
}
buf = malloc(msdosclustersize);
if (!buf)
{
return -1;
bzero(buf,msdosclustersize);
dirp = getdirpfrompath (ih, filePath, buf);
if (!dirp || (dirp->deAttributes & ATTR_DIRECTORY))
{
free (buf);
return -1;
}
cluster = OSReadLittleInt16 ((dirp->deStartCluster),0);
if (msdosfatbits == 32)
{
cluster |= ((uint32_t)OSReadLittleInt16 ((dirp->deHighClust),0)) <<16;
}
off_t clusn;
switch (msdosfatbits) {
switch (msdosfatbits)
{
case 32:
if (cluster < CLUST_FIRST ||cluster >= CLUST_RSRVD32)
{
return -1;
}
clusn = cluster - CLUST_FIRST;
break;
case 16:
if (cluster < CLUST_FIRST ||cluster >= CLUST_RSRVD16)
{
return 0;
}
clusn = cluster - CLUST_FIRST;
break;
case 12:
if (cluster < CLUST_FIRST ||cluster >= CLUST_RSRVD12)
{
return 0;
}
clusn = cluster - CLUST_FIRST;
break;
default:
label[0] = 0xE5;
/* Remove any trailing spaces */
for (i=LABEL_LENGTH-1; i>=0; --i) {
if (label[i] == ' ')
label[i] = 0;
else
break;
for (i=LABEL_LENGTH-1; i>=0; --i)
{
if (label[i] == ' ')
{
label[i] = 0;
}
else
{
break;
}
}
labelucs[i++]=0;
len=i;
for (;i>=0;--i)
{
labelucs[i]=label[i]>=128?cp850[label[i]-128][1]:(label[i]);
}
utf_encodestr(labelucs, len, (uint8_t *)str, strMaxLen, OSHostByteOrder() );
}
void MSDOSGetDescription(CICell ih, char *str, long strMaxLen)
{
struct direntry*dirp;
uint8_tlabel[LABEL_LENGTH+1];
uint16_tvfatlabel[WIN_MAXLEN+2*WIN_CHARS];
struct msdosdirstate st;
int labelfound = 0;
struct direntry *dirp;
uint8_t label[LABEL_LENGTH+1];
uint16_t vfatlabel[WIN_MAXLEN+2*WIN_CHARS];
struct msdosdirstate st;
int labelfound = 0;
if (MSDOSInitPartition (ih)<0)
if (MSDOSInitPartition(ih) < 0)
{
str[0]=0;
return;
label[0] = '\0';
initRoot (&st);
initRoot(&st);
st.buf = malloc(msdosclustersize);
if (!st.buf)
{
bzero(st.buf,msdosclustersize);
while ((dirp = getnextdirent (ih, vfatlabel, &st)))
if (dirp->deAttributes & ATTR_VOLUME) {
if (dirp->deAttributes & ATTR_VOLUME)
{
strncpy((char *)label, (char *)dirp->deName, LABEL_LENGTH);
labelfound = 1;
break;
utf_encodestr(vfatlabel, i, (u_int8_t *)str, strMaxLen, OSLittleEndian );
}
else if (labelfound)
{
fixLabel(label, str, strMaxLen);
}
/* else look in the boot blocks */
if (!labelfound || str[0] == '\0')
{
return;
}
long
MSDOSGetUUID(CICell ih, char *uuidStr)
long MSDOSGetUUID(CICell ih, char *uuidStr)
{
char *buf = malloc (512);
if (!buf)
if (msdosfatbits == 32) { /* It's FAT32 */
memcpy(uuidStr+12, (char *)((struct extboot *)bsp->bs710.bsExt)->exVolumeID, 4);
}
else if (msdosfatbits == 16) {
else if (msdosfatbits == 16)
{
memcpy(uuidStr+12, (char *)((struct extboot *)bsp->bs50.bsExt)->exVolumeID, 4);
}
free (buf);
return 0;
return 0;
}
branches/ErmaC/Enoch/i386/libsaio/state_generator.c
6969
7070
7171
72
72
7373
7474
75
75
7676
7777
7878
......
355355
356356
357357
358
358
359359
360360
361
361
362362
363363
364364
......
370370
371371
372372
373
373
374374
375375
376376
0x00, 0x00, 0x00, 0x79, 0x00,
};
struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt* dsdt)
struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt *dsdt)
{
if (Platform.CPU.Vendor != 0x756E6547)
if (Platform.CPU.Vendor != CPUID_VENDOR_INTEL) // 0x756E6547
{
DBG("Not an Intel platform: P-States will not be generated !!!\n");
return NULL;
return NULL;
}
struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt* fadt)
struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt *fadt)
{
if (Platform.CPU.Vendor != 0x756E6547)
if (Platform.CPU.Vendor != CPUID_VENDOR_INTEL) // 0x756E6547
{
DBG("Not an Intel platform: C-States will not be generated !!!\n");
return NULL;
return NULL;
}
struct acpi_2_dsdt* dsdt = (void*)fadt->DSDT;
struct acpi_2_dsdt *dsdt = (void *)fadt->DSDT;
if (dsdt == NULL)
{
branches/ErmaC/Enoch/i386/libsaio/fake_efi.c
123123
124124
125125
126
126
127127
128128
129129
......
142142
143143
144144
145
145
146146
147147
148148
......
551551
552552
553553
554
555
554
555
556556
557557
558558
559559
560560
561561
562
562
563563
564564
565565
......
676676
677677
678678
679
679
680680
681681
682682
......
695695
696696
697697
698
698
699699
700700
701701
// We only do adds, not modifications and deletes like InstallConfigurationTable
if (i >= MAX_CONFIGURATION_TABLE_ENTRIES)
{
stop("Ran out of space for configuration tables. Increase the reserved size in the code.\n");
stop("Fake EFI [ERROR]: Ran out of space for configuration tables [%d]. Increase the reserved size in the code.\n", i);
}
if (pGuid == NULL)
Node *tableNode = DT__AddChild(gEfiConfigurationTableNode, mallocStringForGuid(pGuid));
// Use the pointer to the GUID we just stuffed into the system table
DT__AddProperty(tableNode, "guid", sizeof(EFI_GUID), (void*)pGuid);
DT__AddProperty(tableNode, "guid", sizeof(EFI_GUID), (void *)pGuid);
// The "table" property is the 32-bit (in our implementation) physical address of the table
DT__AddProperty(tableNode, "table", sizeof(void*) * 2, table);
*/
/*
* Must be called AFTER setup Acpi because we need to take care of correct
* facp content to reflect in ioregs
* Must be called AFTER setupAcpi because we need to take care of correct
* FACP content to reflect in ioregs
*/
void setupSystemType()
{
Node *node = DT__FindNode("/", false);
if (node == 0)
{
stop("Couldn't get root node");
stop("Couldn't get root '/' node");
}
// we need to write this property after facp parsing
// Export system-type only if it has been overrriden by the SystemType option
node = DT__FindNode("/", false);
if (node == 0)
{
stop("Couldn't get root node");
stop("Couldn't get root '/' node");
}
const char *boardid = getStringForKey("SMboardproduct", &bootInfo->smbiosConfig);
if (boardid)
chosenNode = DT__FindNode("/chosen", false);
if (chosenNode == 0)
{
stop("Couldn't get chosen node");
stop("setupChosenNode: Couldn't get '/chosen' node");
}
int length = strlen(gBootUUIDString);
branches/ErmaC/Enoch/i386/libsaio/smbios_getters.c
3131
3232
3333
34
3534
3635
3736
......
4948
5049
5150
51
5252
53
5453
5554
5655
5756
57
5858
5959
6060
......
7878
7979
8080
81
8281
8382
8483
......
138137
139138
140139
140
141
141142
142
143
143144
144
145
146
145147
146148
147149
148150
149
151
152
150153
151154
152155
......
181184
182185
183186
184
187
185188
186189
187190
......
381384
382385
383386
384
387
388
385389
386390
387391
......
429433
430434
431435
432
436
437
433438
434439
435440
436441
437
442
443
438444
439
445
446
440447
441448
442449
switch (Platform.CPU.Family)
{
case 0x06:
{
switch (Platform.CPU.Model)
{
// set external clock to 0 for SANDY
break;
default:
value->word = (uint16_t)(Platform.CPU.FSBFrequency/1000000LL);
break;
}
}
break;
default:
value->word = (uint16_t)(Platform.CPU.FSBFrequency/1000000LL);
break;
}
}
else
switch (Platform.CPU.Family)
{
case 0x06:
{
switch (Platform.CPU.Model)
{
case CPUID_MODEL_PENTIUM_M:
value->word = qpibusspeed;
return true;
}
break;
default:
break; //Unsupported CPU type
break;
}
}
break;
default:
break;
}
}
return false;
return false; //Unsupported CPU type
}
uint16_t simpleGetSMBOemProcessorType(void)
{
case 0x0F:
case 0x06:
{
switch (Platform.CPU.Model)
{
case CPUID_MODEL_PENTIUM_M:
default:
break; // Unsupported CPU type
}
}
break;
default:
break;
}
static int idx = -1;
intmap;
if (!bootInfo->memDetect) {
if (!bootInfo->memDetect)
{
return false;
}
idx++;
if (idx < MAX_RAM_SLOTS) {
if (idx < MAX_RAM_SLOTS)
{
map = Platform.DMI.DIMM[idx];
if (Platform.RAM.DIMM[map].InUse && Platform.RAM.DIMM[map].Frequency != 0) {
if (Platform.RAM.DIMM[map].InUse && Platform.RAM.DIMM[map].Frequency != 0)
{
DBG("RAM Detected Freq = %d Mhz\n", Platform.RAM.DIMM[map].Frequency);
value->dword = Platform.RAM.DIMM[map].Frequency;
return true;
branches/ErmaC/Enoch/i386/libsaio/state_generator.h
1515
1616
1717
18
19
20
18
19
20
2121
2222
#include "aml_generator.h"
#include "libsaio.h"
void get_acpi_cpu_names(uint8_t* dsdt, uint32_t length);
struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt* fadt);
struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt* dsdt);
voidget_acpi_cpu_names(uint8_t *dsdt, uint32_t length);
structacpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt *fadt);
structacpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt *dsdt);
#endif /* !__LIBSAIO_STATE_GENERATOR_H */
branches/ErmaC/Enoch/i386/libsaio/saio_internal.h
9898
9999
100100
101
101102
102103
103104
extern void stop(const char *format, ...) __attribute__ ((noreturn));
//Azi: replace getc/getchar with ? console.c
extern void pause();
extern uint64_t getRTCdatetime();
/* disk.c */
extern void rescanBIOSDevice(int biosdev);
branches/ErmaC/Enoch/i386/include/IOKit/storage/IOFDiskPartitionScheme.h
5656
5757
5858
59
59
6060
6161
6262
UInt8 beghead; /* (beginning head) */
UInt8 begsect; /* (beginning sector; beginning cylinder, high 2 bits) */
UInt8 begcyl; /* (beginning cylinder, low 8 bits) */
UInt8 systid; /* (type) */
UInt8 systid; /* (OS type) */
UInt8 endhead; /* (ending head) */
UInt8 endsect; /* (ending sector; ending cylinder, high 2 bits) */
UInt8 endcyl; /* (ending cylinder, low 8 bits) */
branches/ErmaC/Enoch/i386/boot2/graphics.c
279279
280280
281281
282
282283
283284
284285
......
427428
428429
429430
430
431
432
433
431
432
433
434
434435
435
436
436
437
437438
438439
439440
440441
441442
442443
443
444
445
446
444
445
446
447
447448
448449
449450
......
484485
485486
486487
487
488
488489
489
490
490491
491492
492493
......
520521
521522
522523
523
524
524
525525
526526
527527
......
11201120
11211121
11221122
1123
1124
1123
1124
11251125
1126
1127
1126
1127
1128
11281129
1129
1130
1130
1131
11311132
1132
1133
11331134
1134
1135
1135
1136
11361137
11371138
11381139
11391140
1140
1141
11411142
11421143
11431144
1144
1145
11451146
11461147
11471148
......
11631164
11641165
11651166
1166
1167
11671168
11681169
11691170
......
11831184
11841185
11851186
1186
1187
11871188
11881189
11891190
......
11991200
12001201
12011202
1202
1203
12031204
12041205
12051206
......
12151216
12161217
12171218
1218
1219
12191220
12201221
12211222
12221223
12231224
12241225
1225
1226
12261227
12271228
12281229
......
12391240
12401241
12411242
1242
1243
12431244
1244
1245
12451246
12461247
12471248
12481249
12491250
1250
1251
12511252
12521253
12531254
// Get mode information.
bzero( &modeInfo, sizeof(modeInfo) );
err = getVBEModeInfo( *modePtr, &modeInfo );
if ( err != errSuccess )
{
unsigned char bitsPerPixel,
unsigned short refreshRate )
{
VBEModeInfoBlock minfo;
unsigned short mode;
unsigned short vesaVersion;
int err = errFuncNotSupported;
VBEModeInfoBlock minfo;
unsigned short mode;
unsigned short vesaVersion;
int err = errFuncNotSupported;
do {
mode = getVESAModeWithProperties( width, height, bitsPerPixel,
do {
mode = getVESAModeWithProperties( width, height, bitsPerPixel,
maColorModeBit |
maModeIsSupportedBit |
maGraphicsModeBit |
maLinearFrameBufferAvailBit,
0,
&minfo, &vesaVersion );
if ( mode == modeEndOfList )
{
break;
}
if ( mode == modeEndOfList )
{
break;
}
//
// FIXME : generateCRTCTiming() causes crash.
// Set the mode with default refresh rate.
err = setVBEMode( mode | kLinearFrameBufferBit, NULL );
err = setVBEMode(mode | kLinearFrameBufferBit, NULL);
if ( err != errSuccess )
if (err != errSuccess)
{
break;
}
bootArgs->Video.v_rowBytes = minfo.BytesPerScanline;
bootArgs->Video.v_baseAddr = VBEMakeUInt32(minfo.PhysBasePtr);
}
while ( 0 );
} while ( 0 );
return err;
}
unsigned long numbers[],
unsigned long maxArrayCount )
{
char * propStr;
unsigned long count = 0;
char *propStr;
unsigned long count = 0;
propStr = newStringForKey( (char *) propKey , &bootInfo->chameleonConfig );
if ( propStr )
propStr = newStringForKey((char *)propKey , &bootInfo->chameleonConfig);
if (propStr)
{
char * delimiter = propStr;
char * p = propStr;
char *delimiter = propStr;
char *p = propStr;
while ( count < maxArrayCount && *p != '\0' )
while ((count < maxArrayCount) && (*p != '\0'))
{
unsigned long val = strtoul( p, &delimiter, 10 );
if ( p != delimiter )
unsigned long val = strtoul(p, &delimiter, 10);
if (p != delimiter)
{
numbers[count++] = val;
p = delimiter;
}
while ( ( *p != '\0' ) && !isdigit(*p) )
while ((*p != '\0') && !isdigit(*p))
p++;
}
free( propStr );
free(propStr);
}
return count;
// Use the default resolution if we don't have an initialized GUI.
if (gui.screen.width == 0 || gui.screen.height == 0)
{
gui.screen.width = DEFAULT_SCREEN_WIDTH;
gui.screen.width = DEFAULT_SCREEN_WIDTH;
gui.screen.height = DEFAULT_SCREEN_HEIGHT;
}
if ( params[2] == 888 )
params[2] = 32;
return setVESAGraphicsMode( params[0], params[1], params[2], params[3] );
return setVESAGraphicsMode( params[0], params[1], params[2], params[3] );
}
//==========================================================================
if ( mode == GRAPHICS_MODE )
{
if ( (err=initGraphicsMode ()) == errSuccess )
if ( (err = initGraphicsMode()) == errSuccess )
{
if (gVerboseMode)
{
if ( (mode == VGA_TEXT_MODE) || (err != errSuccess) )
{
count = getNumberArrayFromProperty( kTextModeKey, params, 2 );
count = getNumberArrayFromProperty(kTextModeKey, params, 2);
if ( count < 2 )
{
params[0] = 80; // Default text mode is 80x25.
params[1] = 25;
}
setVESATextMode( params[0], params[1], 4 );
setVESATextMode(params[0], params[1], 4);
bootArgs->Video.v_display = VGA_TEXT_MODE;
}
unsigned short vesaVersion;
unsigned short mode = modeEndOfList;
getNumberArrayFromProperty( kGraphicsModeKey, params, 4);
getNumberArrayFromProperty(kGraphicsModeKey, params, 4);
mode = getVESAModeWithProperties( params[0], params[1], params[2],
mode = getVESAModeWithProperties(params[0], params[1], params[2],
maColorModeBit |
maModeIsSupportedBit |
maGraphicsModeBit |
maLinearFrameBufferAvailBit,
0,
&minfo, &vesaVersion );
&minfo, &vesaVersion);
params[0] = minfo.XResolution;
params[1] = minfo.YResolution;
branches/ErmaC/Enoch/i386/boot2/drivers.c
110110
111111
112112
113
114
115
116
117
118
113
114
115
116
117
118
119
120
119121
120122
121
123
122124
123125
124126
......
186188
187189
188190
189
191
190192
191193
192194
......
238240
239241
240242
241
243
242244
243245
244246
......
295297
296298
297299
298
300
299301
300302
301303
......
877879
878880
879881
880
881
882882
883883
884884
885
885
886886
887887
888888
......
899899
900900
901901
902
902
903903
904904
905905
......
912912
913913
914914
915
915
916
916917
917
918
919
920
918
921919
922920
923921
......
939937
940938
941939
942
940
943941
944942
945943
946
944
947945
948946
949947
......
955953
956954
957955
958
956
959957
960958
961959
962960
963
961
964962
965963
966964
......
969967
970968
971969
972
970
973971
974972
975973
......
991989
992990
993991
994
992
995993
996994
997995
static long InitDriverSupport(void);
ModulePtr gModuleHead, gModuleTail;
static TagPtr gPersonalityHead, gPersonalityTail;
static char * gExtensionsSpec;
static char * gDriverSpec;
static char * gFileSpec;
static char * gTempSpec;
static char * gFileName;
static TagPtrgPersonalityHead, gPersonalityTail;
static char*gExtensionsSpec;
static char*gDriverSpec;
static char*gFileSpec;
static char*gTempSpec;
static char*gFileName;
// Bungo
char *gDarwinBuildVerStr = "Darwin Kernel Version";
/*static*/ unsigned long
Adler32( unsigned char * buffer, long length )
Adler32( unsigned char *buffer, long length )
{
long cnt;
unsigned long result, lowHalf, highHalf;
{
if (NetLoadDrivers(dirSpec) != 0)
{
error("Could not load drivers from the network\n");
error("LoadDrivers: Could not load drivers from the network\n");
return -1;
}
}
if (gMKextName[0] != '\0')
{
verbose("LoadDrivers: Loading from [%s]\n", gMKextName);
verbose("LoadDrivers: Loading from '%s'\n", gMKextName);
if ( LoadDriverMKext(gMKextName) != 0 )
{
error("Could not load %s\n", gMKextName);
|| (((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1))))
{
snprintf(gDriverSpec, sizeof(altDirSpec) + 18, "%sExtensions.mkext", altDirSpec);
verbose("LoadDrivers: Loading from [%s]\n", gDriverSpec);
verbose("LoadDrivers: Loading from '%s'\n", gDriverSpec);
if (LoadDriverMKext(gDriverSpec) == 0)
{
static char gPlatformName[64];
#endif
char *gDarwinBuildVerStr = "Darwin Kernel Version"; // Bungo
long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize)
{
long ret = 0;
compressed_kernel_header * kernel_header = (compressed_kernel_header *) binary;
compressed_kernel_header *kernel_header = (compressed_kernel_header *)binary;
u_int32_t uncompressed_size = 0, size = 0, adler32 = 0;
void *buffer = NULL;
unsigned long len = 0;
if (kernel_header->signature == OSSwapBigToHostConstInt32('comp'))
{
DBG("Decompressing Kernel: ");
DBG("Decompressing Kernel Cache");
if ((kernel_header->compress_type != OSSwapBigToHostConstInt32('lzss')) &&
(kernel_header->compress_type != OSSwapBigToHostConstInt32('lzvn')))
{
verbose ("Decompressing Kernel Using lzss\n");
}
else
if (kernel_header->compress_type == OSSwapBigToHostConstInt32('lzvn'))
{
if (kernel_header->compress_type == OSSwapBigToHostConstInt32('lzvn'))
{
verbose ("Decompressing Kernel Using lzvn\n");
}
verbose ("Decompressing Kernel Using lzvn\n");
}
#if NOTDEF
switch (kernel_header->compress_type)
{
case OSSwapBigToHostConstInt32('lzvn'):
size = lzvn_decode( binary, uncompressed_size, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size));
size = lzvn_decode(binary, uncompressed_size, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size));
break;
case OSSwapBigToHostConstInt32('lzss'):
size = decompress_lzss( (u_int8_t *)binary, uncompressed_size, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size));
size = decompress_lzss((u_int8_t *)binary, uncompressed_size, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size));
break;
default:
{
if ( kernel_header->compress_type == OSSwapBigToHostConstInt32('lzvn'))
{
error("ERROR: size mismatch from lzvn (found: %x, expected: %x).\n", size, uncompressed_size);
error("ERROR! Size mismatch from lzvn (found: %x, expected: %x).\n", size, uncompressed_size);
}
if ( kernel_header->compress_type == OSSwapBigToHostConstInt32('lzss'))
{
error("ERROR: size mismatch from lzss (found: %x, expected: %x).\n", size, uncompressed_size);
error("ERROR! size mismatch from lzss (found: %x, expected: %x).\n", size, uncompressed_size);
}
return -1;
adler32 = Adler32(binary, uncompressed_size);
if (OSSwapBigToHostInt32(kernel_header->adler32) != adler32)
{
error("ERROR: adler mismatch (found: %x, expected: %x).\n", adler32, OSSwapBigToHostInt32(kernel_header->adler32));
error("ERROR! Adler mismatch (found: %X, expected: %X).\n", adler32, OSSwapBigToHostInt32(kernel_header->adler32));
return -1;
}
gDarwinBuildVerStr = (char *)binary + size;
// Notify modules that the kernel has been decompressed, thinned and is about to be decoded
execute_hook("DecodeKernel", (void*)binary, NULL, NULL, NULL);
execute_hook("DecodeKernel", (void *)binary, NULL, NULL, NULL);
ret = DecodeMachO(binary, rentry, raddr, rsize);
if (ret < 0 && archCpuType == CPU_TYPE_X86_64)
branches/ErmaC/Enoch/i386/boot2/boot.c
7272
7373
7474
75
75
76
77
78
79
7680
7781
7882
......
8185
8286
8387
84
88
89
8590
8691
87
8892
93
94
95
96
8997
9098
9199
......
93101
94102
95103
96
97104
98105
99106
......
127134
128135
129136
130
137
131138
132139
133140
......
135142
136143
137144
138
145
139146
140147
141148
142149
143
150
144151
145152
146153
......
151158
152159
153160
154
161
155162
156163
157164
......
161168
162169
163170
164
171
165172
166173
167174
......
180187
181188
182189
183
190
184191
185192
186193
......
198205
199206
200207
201
208
202209
203210
204211
......
256263
257264
258265
259
266
260267
261268
262269
263
264
265270
266271
272
273
267274
268
275
269276
270277
271278
......
273280
274281
275282
276
277
278
283
284
285
279286
280
287
281288
282
283
284
285
289
290
286291
287
288
292
289293
290
291
294
295
296
297
298
299
292300
301
293302
294
303
295304
296
297
305
306
298307
299308
300309
301310
302311
303
312
304313
305314
306315
......
363372
364373
365374
366
375
367376
368377
369378
......
372381
373382
374383
375
384
376385
377386
378387
379388
380
389
381390
382391
383392
......
474483
475484
476485
486
487
488
477489
478
479490
480491
481492
......
506517
507518
508519
509
510
511
512
520
521
522
523
513524
514525
515526
......
667678
668679
669680
670
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
671700
672
673
674
701
675702
676
677
703
704
705
678706
679
680
681
682
683
684
685
686707
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
708
709
710
711
712
713
702714
703
715
716
717
718
704719
705
720
721
722
723
724
725
726
727
728
706729
707730
708731
......
724747
725748
726749
727
728750
729
730751
731752
732753
733
734
735754
736
737755
738756
739757
......
764782
765783
766784
767
785
768786
769787
770788
......
782800
783801
784802
785
803
786804
787805
788806
*/
#define kBootErrorTimeout 5
boolgOverrideKernel, gEnableCDROMRescan, gScanSingleDrive, useGUI;
boolgOverrideKernel;
boolgEnableCDROMRescan;
boolgScanSingleDrive;
booluseGUI;
static boolgUnloadPXEOnExit = false;
static chargCacheNameAdler[64 + 256];
chargRootDevice[ROOT_DEVICE_SIZE];
chargMKextName[512];
chargMacOSVersion[8];
intbvCount = 0, gDeviceCount = 0;
intbvCount = 0;
intgDeviceCount = 0;
//intmenucount = 0;
longgBootMode; /* defaults to 0 == kBootModeNormal */
BVRefbvr, menuBVR, bvChain;
BVRefbvr;
BVRefmenuBVR;
BVRefbvChain;
static unsigned longAdler32(unsigned char *buffer, long length);
//static voidselectBiosDevice(void);
extern char* msgbuf;
void showTextBuffer(char *buf, int size);
//==========================================================================
// Zero the BSS.
}
//==========================================================================
// execKernel - Load the kernel image (mach-o) and jump to its entry point.
// ExecKernel - Load the kernel image (mach-o) and jump to its entry point.
static int ExecKernel(void *binary)
{
entry_tkernelEntry;
bootArgs->kaddr = bootArgs->ksize = 0;
execute_hook("ExecKernel", (void*)binary, NULL, NULL, NULL);
execute_hook("ExecKernel", (void *)binary, NULL, NULL, NULL);
ret = DecodeKernel(binary,
&kernelEntry,
(char **) &bootArgs->kaddr,
(int *)&bootArgs->ksize );
(int *)&bootArgs->ksize);
if ( ret != 0 )
{
reserveKernBootStruct();
// Notify modules that the kernel has been decoded
execute_hook("DecodedKernel", (void*)binary, (void*)bootArgs->kaddr, (void*)bootArgs->ksize, NULL);
execute_hook("DecodedKernel", (void *)binary, (void *)bootArgs->kaddr, (void *)bootArgs->ksize, NULL);
setupFakeEfi();
LoadDrivers("/");
}
execute_hook("DriversLoaded", (void*)binary, NULL, NULL, NULL);
execute_hook("DriversLoaded", (void *)binary, NULL, NULL, NULL);
clearActivityIndicator();
{
if ( (ret = nbpUnloadBaseCode()) != nbpStatusSuccess )
{
printf("nbpUnloadBaseCode error %d\n", (int) ret);
printf("nbpUnloadBaseCode error %d\n", (int)ret);
sleep(2);
}
}
// verbose mode.
if (gVerboseMode)
{
setVideoMode( GRAPHICS_MODE, 0 );
setVideoMode(GRAPHICS_MODE, 0);
}
else
{
if (cacheFile[0] != 0)
{
strlcpy(kernelCacheFile, cacheFile, sizeof(kernelCacheFile));
verbose("Specified kernel cache file path = %s\n", cacheFile);
verbose("Specified kernel cache file path: %s\n", cacheFile);
}
else
{
// Lion, Mountain Lion, Mavericks, and Yosemite prelink kernel cache file
// for 10.7 10.8 10.9 10.10
if ( LION || MOUNTAIN_LION || MAVERICKS || YOSEMITE)
{
// Lion, Mountain Lion, Mavericks, and Yosemite prelink kernel cache file
// for 10.7 10.8 10.9 10.10
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCachePathSnow);
verbose("10.7, 10.8, 10.9 & 10.10 kernel cache file path = %s\n", kernelCacheFile);
verbose("Kernel Cache file path (Mac OS X 10.7 and newer): %s\n", kernelCacheFile);;
}
// Snow Leopard prelink kernel cache file
else if ( SNOW_LEOPARD )
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "kernelcache_%s",
(archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64");
intlnam = strlen(kernelCacheFile) + 9; //with adler32
char *name;
u_int32_t prev_time = 0;
intlnam = strlen(kernelCacheFile) + 9; //with adler32
char*name;
u_int32_t prev_time = 0;
structdirstuff* cacheDir = opendir(kDefaultCachePathSnow);
struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow);
/* TODO: handle error? */
if (cacheDir)
{
while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0)
/* TODO: handle error? */
if (cacheDir)
{
if (((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time
&& strstr(name, kernelCacheFile) && (name[lnam] != '.'))
while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0)
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s%s", kDefaultCachePathSnow, name);
prev_time = time;
if (((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time
&& strstr(name, kernelCacheFile) && (name[lnam] != '.'))
{
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s%s", kDefaultCachePathSnow, name);
prev_time = time;
}
}
verbose("Kernel Cache file path (Mac OS X 10.6.X): %s\n", kernelCacheFile);
}
verbose("Snow Leopard kernel cache file path = %s\n", kernelCacheFile);
closedir(cacheDir);
}
closedir(cacheDir);
} else {
else
{
// Reset cache name.
bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);
snprintf(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64, "%s,%s", gRootDevice, bootInfo->bootFile);
adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler));
snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s.%08lX", kDefaultCachePathLeo, adler32);
verbose("Reseted kernel cache file path = %s\n", kernelCacheFile);
verbose("Reseted kernel cache file path: %s\n", kernelCacheFile);;
}
}
// Check if the kernel file is more recent than the cache file
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat) && (kerneltime > cachetime))
{
DBG("Kernel file (%s) is more recent than Kernel Cache (%s)! Ignoring Kernel Cache.\n", bootInfo->bootFile, kernelCacheFile);
DBG("Kernel file '%s' is more recent than Kernel Cache '%s'! Ignoring Kernel Cache.\n", bootInfo->bootFile, kernelCacheFile);
return -1;
}
// Check if the S/L/E directory time is more recent than the cache file
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory) && (exttime > cachetime))
{
DBG("Folder: '/System/Library/Extensions' is more recent than Kernel Cache file (%s)! Ignoring Kernel Cache.\n", kernelCacheFile);
DBG("Folder '/System/Library/Extensions' is more recent than Kernel Cache file '%s'! Ignoring Kernel Cache.\n", kernelCacheFile);
return -1;
}
// Since the kernel cache file exists and is the most recent try to load it
DBG("Loading kernel cache: '%s'\n", kernelCachePath);
DBG("Loading Kernel Cache from: '%s'\n", kernelCachePath);
ret = LoadThinFatFile(kernelCachePath, binary);
return ret; // ret contain the length of the binary
gEnableCDROMRescan = true;
}
// Disable rescanPrompt option by default
rescanPrompt = false;
// Ask the user for Rescan option by setting "Rescan Prompt"=y in system config.
rescanPrompt = false;
if (getBoolForKey(kRescanPromptKey, &rescanPrompt , &bootInfo->chameleonConfig) && rescanPrompt && biosDevIsCDROM(gBIOSDev))
{
gEnableCDROMRescan = promptForRescanOption();
init_module_system();
#if DEBUG
printf(" Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n",
gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags);
printf(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n",
gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags);
printf("Default: %d, ->biosdev: %d, ->part_no: %d ->flags: 0x%08X\n",
gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags);
printf("bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: 0x%08X\n",
gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags);
getchar();
#endif
}
getBoolForKey(kUseKernelCache, &useKernelCache, &bootInfo->chameleonConfig);
if (useKernelCache) do {
if (useKernelCache)
{
do
{
// Determine the name of the Kernel Cache
if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig))
{
if (val[0] == '\\')
{
len--;
val++;
}
/* FIXME: check len vs sizeof(kernelCacheFile) */
strlcpy(kernelCacheFile, val, len + 1);
}
else
{
kernelCacheFile[0] = 0; // Use default kernel cache file
}
// Determine the name of the Kernel Cache
if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) {
if (val[0] == '\\')
if (gOverrideKernel && kernelCacheFile[0] == 0)
{
len--;
val++;
DBG("Using a non default kernel (%s) without specifying 'Kernel Cache' path, KernelCache will not be used\n", bootInfo->bootFile);
useKernelCache = false;
break;
}
/* FIXME: check len vs sizeof(kernelCacheFile) */
strlcpy(kernelCacheFile, val, len + 1);
}
else
{
kernelCacheFile[0] = 0; // Use default kernel cache file
}
if (gOverrideKernel && kernelCacheFile[0] == 0)
{
DBG("Using a non default kernel (%s) without specifying 'Kernel Cache' path, KernelCache will not be used\n", bootInfo->bootFile);
useKernelCache = false;
break;
}
if (gMKextName[0] != 0)
{
DBG("Using a specific MKext Cache (%s), KernelCache will not be used\n",
gMKextName);
useKernelCache = false;
break;
}
if (gBootFileType != kBlockDeviceType)
useKernelCache = false;
if (gMKextName[0] != 0)
{
DBG("Using a specific MKext Cache (%s), KernelCache will not be used\n", gMKextName);
useKernelCache = false;
break;
}
} while(0);
if (gBootFileType != kBlockDeviceType)
{
useKernelCache = false;
}
do {
} while(0);
}
else
{
DBG("Kernel Cache using disabled by user.");
}
do
{
if (useKernelCache)
{
ret = LoadKernelCache(kernelCacheFile, &binary);
{
if ( !YOSEMITE )
{
//printf(HEADER " (%s).\n", bootInfo->bootFile);
snprintf(bootFile, sizeof(bootFile), "/%s", bootInfo->bootFile); // append a leading /
//sleep(1);
}
else
{
//printf(HEADER " (%s).\n", bootInfo->bootFile);
snprintf(bootFile, sizeof(bootFile), kDefaultKernelPathForYos"%s", bootInfo->bootFile); // Yosemite
//sleep(1);
}
}
else
strlcpy(bootFilePath, bootFile, sizeof(bootFilePath));
}
DBG("Loading kernel: '%s'\n", bootFilePath);
DBG("Loading kernel from: '%s'\n", bootFilePath);
ret = LoadThinFatFile(bootFilePath, &binary);
if (ret <= 0 && archCpuType == CPU_TYPE_X86_64)
{
if (ret <= 0)
{
printf("Can't find %s\n", bootFile);
printf("Can't find boot file: '%s'\n", bootFile);
sleep(1);
if (gBootFileType == kNetworkDeviceType)
branches/ErmaC/Enoch/i386/boot2/boot.h
4343
4444
4545
46
47
46
47
4848
4949
50
51
50
51
5252
5353
54
55
54
55
5656
5757
5858
59
59
6060
6161
6262
6363
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
9292
9393
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121121
122122
123
123
124124
125125
126
126
127127
128128
129
130
131
132
129
130
131
132
133133
134134
135135
......
137137
138138
139139
140
141
140
141
142142
143143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160160
161161
162
163
164
165
166
167
168
169
162
163
164
165
166
167
168
169
170170
171171
172
173
174
172
173
174
175175
176176
177
177
178178
179179
180
181
182
180
181
182
183183
184184
185
185
186186
187187
188188
189
189
190190
191191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208208
209209
210
210
211211
212212
213
214
213
215214
215
216216
217217
218218
219
220
221
222
223
219
220
221
222
223
224224
225225
226226
227227
228
229
228
229
230230
231231
232232
......
257257
258258
259259
260
260
261261
262262
263263
......
283283
284284
285285
286
286
287287
288288
289289
......
292292
293293
294294
295
295
296296
297297
298298
299299
300300
301301
302
303302
304303
305304
306
307305
306
307
308
308309
309310
310311
......
315316
316317
317318
318
319319
320320
321321
......
339339
340340
341341
342
343
344
345
342
343
344
345
346346
347
348
349
350
351
347
348
349
350
351
352352
353353
354354
......
369369
370370
371371
372
372
373373
374
375
376374
*/
// kernel cache
#define kDefaultCachePathLeo "/System/Library/Caches/com.apple.kernelcaches/"
#define kDefaultCachePathSnow "/System/Library/Caches/com.apple.kext.caches/Startup/"
#define kDefaultCachePathLeo"/System/Library/Caches/com.apple.kernelcaches/"
#define kDefaultCachePathSnow"/System/Library/Caches/com.apple.kext.caches/Startup/"
// Lion installer
#define kLionInstallerDataFolder "/Mac OS X Install Data/"
#define kLionInstallerPlist kLionInstallerDataFolder "com.apple.Boot.plist"
#define kLionInstallerDataFolder"/Mac OS X Install Data/"
#define kLionInstallerPlistkLionInstallerDataFolder "com.apple.Boot.plist"
// Mountain Lion installer
#define kMLionInstallerDataFolder "/OS X Install Data/"
#define kMLionInstallerPlist kMLionInstallerDataFolder "com.apple.Boot.plist"
#define kMLionInstallerDataFolder"/OS X Install Data/"
#define kMLionInstallerPlistkMLionInstallerDataFolder "com.apple.Boot.plist"
//kernel path
#define kDefaultKernelPathPreYos"/"
#define kDefaultKernelPathForYos"/System/Library/Kernels/" //for Yosemite
#define kDefaultKernelPathForYos"/System/Library/Kernels/" //for Yosemite and newer
/*
* Keys used in system Boot.plist
*/
#define kGraphicsModeKey"Graphics Mode"
#define kTextModeKey"Text Mode"
#define kQuietBootKey"Quiet Boot"
#define kKernelFlagsKey"Kernel Flags"
#define kKernelArchKey"Kernel Architecture"
#define kMKextCacheKey"MKext Cache"
#define kKernelNameKey"Kernel"
#define kKernelCacheKey"Kernel Cache"
#define kUseKernelCache"UseKernelCache"/* boot.c */
#define kBootDeviceKey"Boot Device"
#define kTimeoutKey"Timeout"
#define kRootDeviceKey"rd"
#define kBootUUIDKey"boot-uuid"
#define kHelperRootUUIDKey"Root UUID"
#define kPlatformKey"platform"
#define kACPIKey"acpi"
#define kCDROMPromptKey"CD-ROM Prompt"
#define kCDROMOptionKey"CD-ROM Option Key"
#define kRescanPromptKey"Rescan Prompt"
#define kRescanKey"Rescan"
#define kScanSingleDriveKey"Scan Single Drive"
#define kInstantMenuKey"Instant Menu"
#define kDefaultKernel"mach_kernel"
#define kOSXKernel"kernel"// Yosemite
#define kGUIKey"GUI"
#define kBootBannerKey"Boot Banner"
#define kShowInfoKey"ShowInfo"/* gui.c */
#define kWaitForKeypressKey"Wait"
#define kGraphicsModeKey"Graphics Mode"
#define kTextModeKey"Text Mode"
#define kQuietBootKey"Quiet Boot"
#define kKernelFlagsKey"Kernel Flags"
#define kKernelArchKey"Kernel Architecture"
#define kMKextCacheKey"MKext Cache"
#define kKernelNameKey"Kernel"
#define kKernelCacheKey"Kernel Cache"
#define kUseKernelCache"UseKernelCache"/* boot.c */
#define kBootDeviceKey"Boot Device"
#define kTimeoutKey"Timeout"
#define kRootDeviceKey"rd"
#define kBootUUIDKey"boot-uuid"
#define kHelperRootUUIDKey"Root UUID"
#define kPlatformKey"platform"
#define kACPIKey"acpi"
#define kCDROMPromptKey"CD-ROM Prompt"
#define kCDROMOptionKey"CD-ROM Option Key"
#define kRescanPromptKey"Rescan Prompt"
#define kRescanKey"Rescan"
#define kScanSingleDriveKey"Scan Single Drive"
#define kInstantMenuKey"Instant Menu"
#define kDefaultKernel"mach_kernel"
#define kOSXKernel"kernel"// Yosemite
#define kGUIKey"GUI"
#define kBootBannerKey"Boot Banner"
#define kShowInfoKey"ShowInfo"// gui.c
#define kWaitForKeypressKey"Wait"
/* AsereBLN: added these keys */
#define kUseAtiROM"UseAtiROM"/* ati.c */
#define kWake"Wake"/* boot.c */
#define kForceWake"ForceWake"/* boot.c */
#define kWakeImage"WakeImage"/* boot.c */
#define kProductVersion"ProductVersion"/* boot.c */
#define karch"arch"/* boot.c */
#define kDSDT"DSDT"/* acpi_patcher.c */
#define kDropSSDT"DropSSDT"/* acpi_patcher.c */
#define kDeviceProperties"device-properties"/* device_inject.c */
#define kHidePartition"Hide Partition"/* disk.c */
#define kRenamePartition"Rename Partition"/* disk.c */
#define kSMBIOSKey"SMBIOS"/* fake_efi.c */
//#define kSystemID"SystemId"/* fake_efi.c */
#define kSystemType"SystemType"/* fake_efi.c */
#define kUseNvidiaROM"UseNvidiaROM"/* nvidia.c */
#define kVBIOS"VBIOS"/* nvidia.c && ati.c */
#define kPCIRootUID"PCIRootUID"/* pci_root.c */
#define kEthernetBuiltIn"EthernetBuiltIn"/* pci_setup.c */
#define kGraphicsEnabler"GraphicsEnabler"/* pci_setup.c */
#define kForceHPET"ForceHPET"/* pci_setup.c */
#define kUseMemDetect"UseMemDetect"/* platform.c */
#define kSMBIOSdefaults"SMBIOSdefaults"/* smbios_patcher.c */
#define kUSBBusFix"USBBusFix"/* usb.c */
#define kEHCIacquire"EHCIacquire"/* usb.c */
#define kUHCIreset"UHCIreset"/* usb.c */
#define kEHCIhard"EHCIhard"/* usb.c */
#define kDefaultPartition"Default Partition"/* sys.c */
#define kUseAtiROM"UseAtiROM"/* ati.c */
#define kWake"Wake"/* boot.c */
#define kForceWake"ForceWake"/* boot.c */
#define kWakeImage"WakeImage"/* boot.c */
#define kProductVersion"ProductVersion"/* boot.c */
#define karch"arch"/* boot.c */
#define kDSDT"DSDT"/* acpi_patcher.c */
#define kDropSSDT"DropSSDT"/* acpi_patcher.c */
#define kDeviceProperties"device-properties"/* device_inject.c */
#define kHidePartition"Hide Partition"/* disk.c */
#define kRenamePartition"Rename Partition"/* disk.c */
#define kSMBIOSKey"SMBIOS"/* fake_efi.c */
//#define kSystemID"SystemId"/* fake_efi.c */
#define kSystemType"SystemType"/* fake_efi.c */
#define kUseNvidiaROM"UseNvidiaROM"/* nvidia.c */
#define kVBIOS"VBIOS"/* nvidia.c && ati.c */
#define kPCIRootUID"PCIRootUID"/* pci_root.c */
#define kEthernetBuiltIn"EthernetBuiltIn"/* pci_setup.c */
#define kGraphicsEnabler"GraphicsEnabler"/* pci_setup.c */
#define kForceHPET"ForceHPET"/* pci_setup.c */
#define kUseMemDetect"UseMemDetect"/* platform.c */
#define kSMBIOSdefaults"SMBIOSdefaults"/* smbios_patcher.c */
#define kUSBBusFix"USBBusFix"/* usb.c */
#define kEHCIacquire"EHCIacquire"/* usb.c */
#define kUHCIreset"UHCIreset"/* usb.c */
#define kEHCIhard"EHCIhard"/* usb.c */
#define kDefaultPartition"Default Partition"/* sys.c */
/* Zenith432: added this */
#define kXHCILegacyOff"XHCILegacyOff"/* usb.c */
#define kXHCILegacyOff"XHCILegacyOff"/* usb.c */
/* Duvel300: added this */
#define kRestartFix"RestartFix"/* acpi_patcher.c */
#define kRestartFix"RestartFix"/* acpi_patcher.c */
/* Slice: added this */
#define kPS2RestartFix"PS2RestartFix"/* acpi_patcher.c */
//#define kInjectEDID"InjectEDID"/* ati.c */
//#define kCustomEDID"CustomEDID"/* ati.c */
#define kUseIntelHDMI"UseIntelHDMI"/* ati.c && nvidia.c && gma.c */
#define kPS2RestartFix"PS2RestartFix"/* acpi_patcher.c */
//#define kInjectEDID"InjectEDID"/* ati.c */
//#define kCustomEDID"CustomEDID"/* ati.c */
#define kUseIntelHDMI"UseIntelHDMI"/* ati.c && nvidia.c && gma.c */
/* Signal64: added this key */
#define kLegacyOff"USBLegacyOff"/* usb.c */
/* Lebidou: added this key */
/* Meklort: added this key */
#define kMD0Image"md0"/* ramdisk.h */
#define kEnableWifi"EnableWifi"/* pci_setup.c */
#define kMD0Image"md0"/* ramdisk.h */
#define kEnableWifi"EnableWifi"/* pci_setup.c */
/* Andyvand: added these keys */
//#define kSSDT"SSDT"/* acpi_patcher.c */
#define kHPET"HPET"/* acpi_patcher.c */
#define kSBST"SBST"/* acpi_patcher.c */
#define kECDT"ECDT"/* acpi_patcher.c */
#define kASFT"ASFT"/* acpi_patcher.c */
#define kDMAR"DMAR"/* acpi_patcher.c */
#define kFADT"FADT"/* acpi_patcher.c */
#define kAPIC"APIC"/* acpi_patcher.c */
#define kMCFG"MCFG"/* acpi_patcher.c */
#define kDropHPET"DropHPET"/* acpi_patcher.c */
#define kDropSLIC"DropSLIC"/* acpi_patcher.c */
#define kDropSBST"DropSBST"/* acpi_patcher.c */
#define kDropECDT"DropECDT"/* acpi_patcher.c */
#define kDropASFT"DropASFT"/* acpi_patcher.c */
#define kDropDMAR"DropDMAR"/* acpi_patcher.c */
#define kUpdateACPI"UpdateACPI"/* acpi_patcher.c */
//#define kSSDT"SSDT"/* acpi_patcher.c */
#define kHPET"HPET"/* acpi_patcher.c */
#define kSBST"SBST"/* acpi_patcher.c */
#define kECDT"ECDT"/* acpi_patcher.c */
#define kASFT"ASFT"/* acpi_patcher.c */
#define kDMAR"DMAR"/* acpi_patcher.c */
#define kFADT"FADT"/* acpi_patcher.c */
#define kAPIC"APIC"/* acpi_patcher.c */
#define kMCFG"MCFG"/* acpi_patcher.c */
#define kDropHPET"DropHPET"/* acpi_patcher.c */
#define kDropSLIC"DropSLIC"/* acpi_patcher.c */
#define kDropSBST"DropSBST"/* acpi_patcher.c */
#define kDropECDT"DropECDT"/* acpi_patcher.c */
#define kDropASFT"DropASFT"/* acpi_patcher.c */
#define kDropDMAR"DropDMAR"/* acpi_patcher.c */
#define kUpdateACPI"UpdateACPI"/* acpi_patcher.c */
/* Mojodojo: added these keys */
#define kGeneratePStates"GeneratePStates"/* acpi_patcher.c */
#define kGenerateCStates"GenerateCStates"/* acpi_patcher.c */
#define kCSTUsingSystemIO"CSTUsingSystemIO"/* acpi_patcher.c */
#define kEnableC2State"EnableC2State"/* acpi_patcher.c */
#define kEnableC3State"EnableC3State"/* acpi_patcher.c */
#define kEnableC4State"EnableC4State"/* acpi_patcher.c */
#define kEnableC6State"EnableC6State"/* acpi_patcher.c */
#define kEnableC7State"EnableC7State"/* acpi_patcher.c */
#define kGeneratePStates"GeneratePStates"/* acpi_patcher.c */
#define kGenerateCStates"GenerateCStates"/* acpi_patcher.c */
#define kCSTUsingSystemIO"CSTUsingSystemIO"/* acpi_patcher.c */
#define kEnableC2State"EnableC2State"/* acpi_patcher.c */
#define kEnableC3State"EnableC3State"/* acpi_patcher.c */
#define kEnableC4State"EnableC4State"/* acpi_patcher.c */
#define kEnableC6State"EnableC6State"/* acpi_patcher.c */
#define kEnableC7State"EnableC7State"/* acpi_patcher.c */
/* valv: added these keys */
#define kbusratio"busratio"/* cpu.c */
#define kDcfg0"display_0"/* nvidia.c */
#define kDcfg1"display_1"/* nvidia.c */
#define kbusratio"busratio"/* cpu.c */
#define kDcfg0"display_0"/* nvidia.c */
#define kDcfg1"display_1"/* nvidia.c */
/* Marchrius: added these keys */
#define kEnableBacklight"EnableBacklight"/* nvidia.c */
#define kEnableBacklight"EnableBacklight"/* nvidia.c */
/* Kabyl: added these keys */
#define kAtiConfig"AtiConfig"/* ati.c */
#define kAtiPorts"AtiPorts"/* ati.c */
#define kATYbinimage"ATYbinimage"/* ati.c */
#define kAtiConfig"AtiConfig"/* ati.c */
#define kAtiPorts"AtiPorts"/* ati.c */
#define kATYbinimage"ATYbinimage"/* ati.c */
/* cosmo1: added these keys */
#define kEnableHDMIAudio"EnableHDMIAudio"/* ati.c && nvidia.c */
#define kEnableHDMIAudio"EnableHDMIAudio"/* ati.c && nvidia.c */
/* cparm: added these keys */
//#define kRebootOnPanic"RebootOnPanic"
//#define kEnableHiDPI"EnableHiDPI"/* enable High resolution display (aka Retina) */
//#define kEnableHiDPI"EnableHiDPI"/* enable High resolution display (aka Retina) */
/* ErmaC: added these keys */
#define kEnableDualLink"EnableDualLink"/* ati.c && nvidia.c && gma.c*/
#define kNvidiaGeneric"NvidiaGeneric"/* nvidia.c */
#define kSkipIntelGfx"SkipIntelGfx"/* pci_setup.c */
#define kSkipNvidiaGfx"SkipNvidiaGfx"/* pci_setup.c */
#define kSkipAtiGfx"SkipAtiGfx"/* pci_setup.c */
//#define kUsbInject"USBInject"/* usb.c */
#define kIntelCapriFB"IntelCapriFB"/* gma.c was HD4K-ig */
#define kIntelAzulFB"IntelAzulFB"/* gma.c was HD5K-ig */
#define kAAPLCustomIG"InjectIntel-ig"/* gma.c */
#define kHDAEnabler"HDAEnabler"/* pci_setup.c */
#define kHDEFLayoutID"HDEFLayoutID"/* hda.c */
#define kHDAULayoutID"HDAULayoutID"/* hda.c */
#define kBGRT"BGRT"/* acpi_patcher.c */
#define kDropBGRT"DropBGRT"/* acpi_patcher.c */
#define kDropMCFG"DropMCFG"/* acpi_patcher.c */
#define kDropAPIC"DropAPIC"/* acpi_patcher.c */
#define kEnableDualLink"EnableDualLink"/* ati.c && nvidia.c && gma.c*/
#define kNvidiaGeneric"NvidiaGeneric"/* nvidia.c */
#define kSkipIntelGfx"SkipIntelGfx"/* pci_setup.c */
#define kSkipNvidiaGfx"SkipNvidiaGfx"/* pci_setup.c */
#define kSkipAtiGfx"SkipAtiGfx"/* pci_setup.c */
//#define kUsbInject"USBInject"/* usb.c */
#define kIntelCapriFB"IntelCapriFB"/* gma.c was HD4K-ig */
#define kIntelAzulFB"IntelAzulFB"/* gma.c was HD5K-ig */
#define kAAPLCustomIG"InjectIntel-ig"/* gma.c */
#define kHDAEnabler"HDAEnabler"/* pci_setup.c */
#define kHDEFLayoutID"HDEFLayoutID"/* hda.c */
#define kHDAULayoutID"HDAULayoutID"/* hda.c */
#define kBGRT"BGRT"/* acpi_patcher.c */
#define kDropBGRT"DropBGRT"/* acpi_patcher.c */
#define kDropMCFG"DropMCFG"/* acpi_patcher.c */
#define kDropAPIC"DropAPIC"/* acpi_patcher.c */
/* Karas: added these keys */
#define kMemFullInfo"ForceFullMemInfo"/* smbios.c */
#define kMemFullInfo"ForceFullMemInfo"/* smbios.c */
/* Bungo: added these keys */
// mask private data or no
#define kPrivateData"PrivateData"/* smbios_decode.c */
#define kPrivateData"PrivateData"/* smbios_decode.c */
/*
* Flags to the booter or kernel
*/
#define kVerboseModeFlag"-v"
#define kSafeModeFlag"-x"
#define kIgnoreCachesFlag"-f"
#define kIgnoreBootFileFlag"-F"
#define kSingleUserModeFlag"-s"
#define kVerboseModeFlag"-v"
#define kSafeModeFlag"-x"
#define kIgnoreCachesFlag"-f"
#define kIgnoreBootFileFlag"-F"
#define kSingleUserModeFlag"-s"
/*
* Booter behavior control
*/
#define kBootTimeout -1
#define kCDBootTimeout 8
#define kBootTimeout-1
#define kCDBootTimeout8
/*
* A global set by boot() to record the device that the booter was loaded from.
extern void initialize_runtime();
extern void common_boot(int biosdev);
bool checkOSVersion(const char * version);
/*
* usb.c
*/
unsigned short y,
unsigned short width,
unsigned short height,
unsigned char * data
unsigned char *data
);
extern int
convertImage( unsigned short width,
unsigned char **newImageData );
extern char * decodeRLE( const void * rleData, int rleBlocks, int outBytes );
extern void drawBootGraphics(void);
extern void drawPreview(void *src, uint8_t * saveunder);
extern void drawPreview(void *src, uint8_t *saveunder);
extern int getVideoMode(void);
extern void loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or);
/*
* drivers.c
*/
extern char *gDarwinBuildVerStr; // Bungo
extern long LoadExtraDrivers(char * dirSpec);
extern long LoadDrivers(char * dirSpec);
extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize);
typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin);
// Bungo
extern char *gDarwinBuildVerStr;
/*!
Hookable function pointer called during the driver loading phase that
allows other code to cause additional drivers to be loaded.
* options.c
*/
extern char gBootUUIDString[];
extern int getBootOptions(bool firstRun);
extern int processBootOptions();
extern int selectAlternateBootDevice(int bootdevice);
/*
* lzvn.c
*/
extern size_t lzvn_decode(void * dst,
size_t dst_size,
const void * src,
size_t src_size);
extern size_t lzvn_decode(void*dst,
size_tdst_size,
const void*src,
size_tsrc_size);
/*
extern size_t lzvn_encode(void * dst,
size_t dst_size,
const void * src,
size_t src_size,
void * work);
extern size_t lzvn_encode(void*dst,
size_tdst_size,
const void*src,
size_tsrc_size,
void*work);
*/
struct compressed_kernel_header {
void HibernateBootSnow(char *boot_device);
/* bmdecompress.c */
void * DecompressData(void *srcbase, int *dw, int *dh, int *bytesPerPixel);
void *DecompressData(void *srcbase, int *dw, int *dh, int *bytesPerPixel);
bool checkOSVersion(const char * version);
#endif /* !__BOOT2_BOOT_H */
branches/ErmaC/Enoch/i386/boot2/modules.c
7676
7777
7878
79
79
8080
8181
8282
......
8888
8989
9090
91
91
92
9293
9394
9495
......
123124
124125
125126
126
127
127128
128129
129130
......
164165
165166
166167
167
168
168169
169170
170
171
171172
172173
173
174
174175
175176
176177
177178
178
179
179180
180181
181182
......
208209
209210
210211
212
211213
212214
213215
......
215217
216218
217219
218
220
221
219222
220223
221224
222225
223
224
225
226
227
226
227
228
229
230
228231
229232
230233
......
237240
238241
239242
240
243
244
241245
242246
243247
244248
245
249
246250
247251
248252
249
253
250254
251255
252256
253257
254
258
259
255260
256261
257262
......
311316
312317
313318
314
319
315320
316321
317322
......
320325
321326
322327
323
328
324329
325330
326331
327332
328
333
334
329335
330336
331337
......
335341
336342
337343
338
344
345
339346
340347
341348
......
365372
366373
367374
368
375
369376
370377
371378
......
431438
432439
433440
434
441
435442
436443
437444
......
564571
565572
566573
567
574
568575
569576
570577
......
925932
926933
927934
928
935
929936
930937
931938
......
944951
945952
946953
947
954
948955
949956
950957
......
962969
963970
964971
965
972
966973
967974
968975
......
987994
988995
989996
990
997
991998
992999
9931000
......
10721079
10731080
10741081
1075
1082
1083
10761084
10771085
10781086
......
10861094
10871095
10881096
1089
1097
1098
10901099
10911100
10921101
10931102
10941103
1095
1104
10961105
10971106
10981107
......
11081117
11091118
11101119
1111
1120
1121
11121122
1113
1123
11141124
11151125
11161126
11171127
1118
1128
11191129
11201130
11211131
1132
11221133
11231134
11241135
11251136
1126
1137
1138
11271139
11281140
11291141
......
11831195
11841196
11851197
1186
1198
11871199
11881200
11891201
......
12061218
12071219
12081220
1209
1221
12101222
12111223
12121224
12131225
12141226
1215
1227
12161228
12171229
12181230
// Module system was compiled in (Symbols.dylib addr known)
module_start = parse_mach(module_data, &load_module, &add_symbol, NULL);
if(module_start && module_start != (void*)0xFFFFFFFF)
if(module_start && (module_start != (void*)0xFFFFFFFF))
{
// Notify the system that it was laoded
module_loaded(SYMBOLS_MODULE, module_start, SYMBOLS_AUTHOR, SYMBOLS_DESCRIPTION, SYMBOLS_VERSION, SYMBOLS_COMPAT);
else
{
// The module does not have a valid start function
printf("Unable to start %s at 0x%x\n", SYMBOLS_MODULE, module_data); pause();
printf("Unable to start %s at 0x%x\n", SYMBOLS_MODULE, module_data);
pause();
}
}
module_start = parse_mach(module_data, &load_module, &add_symbol, NULL);
if(module_start && module_start != (void*)0xFFFFFFFF)
if(module_start && (module_start != (void*)0xFFFFFFFF))
{
// Notify the system that it was laoded
module_loaded(name, module_start, NULL, NULL, 0, 0 /*moduleName, NULL, moduleVersion, moduleCompat*/);
*/
void load_all_modules()
{
char* name;
char *name;
long flags;
u_int32_t time;
struct dirstuff* moduleDir = opendir("/Extra/modules/");
struct dirstuff *moduleDir = opendir("/Extra/modules/");
if(!moduleDir)
{
verbose("Warning: Unable to open modules folder at '/Extra/modules/'. Ignoring modules.\n");
verbose("[WARNING!] Unable to open modules folder at '/Extra/modules/'. Ignoring modules.\n");
return;
}
while (readdir(moduleDir, (const char**)&name, &flags, &time) >= 0) {
if(strcmp(&name[strlen(name) - sizeof("dylib")], ".dylib") == 0) {
char* tmp = malloc(strlen(name) + 1);
char *tmp = malloc(strlen(name) + 1);
strcpy(tmp, name);
if(!load_module(tmp))
// Check to see if the module has already been loaded
if(is_module_loaded(module))
{
DBG("Module '%s' already loaded.\n", module);
return 1;
}
fh = open(modString, 0);
if(fh < 0)
{
DBG("WARNING: Unable to locate module %s\n", modString); DBGPAUSE();
DBG("[WARNING!] Unable to locate module '%s'. Not loaded.\n", modString);
DBGPAUSE();
return 0;
}
unsigned int moduleSize = file_size(fh);
if(moduleSize == 0)
{
DBG("WARNING: The module %s has a file size of %d, the module will not be loaded.\n", modString, moduleSize);
return 0;
}
if(moduleSize == 0)
{
DBG("[WARNING!] The module '%s' has a file size=%d. Not loading.\n", modString, moduleSize);
return 0;
}
char* module_base = (char*) malloc(moduleSize);
if (moduleSize && read(fh, module_base, moduleSize) == moduleSize)
// Notify the system that it was laoded
module_loaded(module, module_start, NULL, NULL, 0, 0 /*moduleName, NULL, moduleVersion, moduleCompat*/);
(*module_start)();// Start the module
DBG("Module %s Loaded.\n", module); DBGPAUSE();
DBG("Module %s Loaded.\n", module);
DBGPAUSE();
}
#if CONFIG_MODULE_DEBUG
else // The module does not have a valid start function. This may be a library.
{
printf("WARNING: Unable to start %s\n", module);
printf("[WARNING!] Unable to start module '%s'.\n", module);
getchar();
}
#else
else msglog("WARNING: Unable to start %s\n", module);
else msglog("[WARNING!] Unable to start module '%s'.\n", module);
#endif
}
else
{
DBG("Unable to read in module %s\n.", module); DBGPAUSE();
DBG("[WARNING!] Unable to read in module '%s'.\n", module);
DBGPAUSE();
retVal = 0;
}
new_entry->compat = compat;
DBG("Module '%s' by '%s' Loaded.\n", name, author);
DBG("\tInitialization: 0x%X\n", start);
DBG("\tInitialization: 0x%08X\n", start);
DBG("\tDescription: %s\n", description);
DBG("\tVersion: %d\n", version); // todo: sperate to major.minor.bugfix
DBG("\tCompat: %d\n", compat); // todo: ^^^ major.minor.bugfix
int is_module_loaded(const char* name)
{
// todo sorted search
moduleList_t* entry = loadedModules;
moduleList_t *entry = loadedModules;
while(entry)
{
if(strcmp(entry->name, name) == 0)
{
DBG("Located module %s\n", name); DBGPAUSE();
DBG("Located module %s\n", name);
DBGPAUSE();
return 1;
}
else
}
DBG("Module %s not loaded\n", name); DBGPAUSE();
DBG("Module %s not loaded\n", name);
DBGPAUSE();
return 0;
}
}
#if CONFIG_MODULE_DEBUG
printf("Unable to locate symbol %s\n", name);
printf("[WARNING!] Unable to locate symbol %s.\n", name);
getchar();
#endif
}
else
{
verbose("Invalid mach magic 0x%X\n", ((struct mach_header*)binary)->magic);
verbose("[ERROR!] Invalid mach magic: 0x%08X.\n", ((struct mach_header*)binary)->magic);
return NULL;
}
break;
default:
DBG("Unhandled loadcommand 0x%X\n", loadCommand->cmd & 0x7FFFFFFF);
DBG("[WARNING!] Unhandled loadcommand: 0x%08X.\n", loadCommand->cmd & 0x7FFFFFFF);
break;
}
}
else
{
printf("Unable to bind symbol %s\n", symbolName);
printf("[ERROR!] Unable to bind symbol %s.\n", symbolName);
getchar();
}
}
else
{
printf("Unable to bind symbol %s\n", symbolName);
printf("[ERROR!] Unable to bind symbol %s.\n", symbolName);
getchar();
}
}
else
{
printf("Unable to bind symbol %s\n", symbolName);
printf("[ERROR!] Unable to bind symbol %s.\n", symbolName);
getchar();
}
segmentAddress += (immediate * sizeof(void*)) + sizeof(void*);
}
else
{
printf("Unable to bind symbol %s\n", symbolName);
printf("[ERROR!] Unable to bind symbol %s.\n", symbolName);
getchar();
}
break;
*/
int execute_hook(const char* name, void* arg1, void* arg2, void* arg3, void* arg4)
{
DBG("Attempting to execute hook '%s'\n", name); DBGPAUSE();
DBG("Attempting to execute hook '%s'...\n", name);
DBGPAUSE();
moduleHook_t* hook = hook_exists(name);
if(hook)
callbacks->callback(arg1, arg2, arg3, arg4);
callbacks = callbacks->next;
}
DBG("Hook '%s' executed.\n", name); DBGPAUSE();
DBG("Hook '%s' executed.\n", name);
DBGPAUSE();
return 1;
}
else
{
// Callback for this hook doesn't exist;
DBG("No callbacks for '%s' hook.\n", name);
DBG("No callbacks for hook '%s'.\n", name);
return 0;
}
}
*/
void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*))
{
DBG("Adding callback for '%s' hook.\n", name); DBGPAUSE();
DBG("Adding callback for '%s' hook... ", name);
DBGPAUSE();
moduleHook_t* hook = hook_exists(name);
moduleHook_t *hook = hook_exists(name);
if(hook)
{
// append
callbackList_t* newCallback = malloc(sizeof(callbackList_t));
callbackList_t *newCallback = malloc(sizeof(callbackList_t));
newCallback->next = hook->callbacks;
hook->callbacks = newCallback;
newCallback->callback = callback;
DBG("Added.\n");
}
else
{
// create new hook
moduleHook_t* newHook = malloc(sizeof(moduleHook_t));
DBG("Hook not exists, creating a new hook.\n");
moduleHook_t *newHook = malloc(sizeof(moduleHook_t));
newHook->name = name;
newHook->callbacks = malloc(sizeof(callbackList_t));
newHook->callbacks->callback = callback;
void dyld_stub_binder()
{
printf("ERROR: dyld_stub_binder was called, should have been take care of by the linker.\n");
printf("[ERROR!] 'dyld_stub_binder' was called, should have been take care of by the linker.\n");
getchar();
}
void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*))
{
printf("WARNING: register_hook_callback is not supported when compiled in.\n");
printf("[WARNING!] 'register_hook_callback' is not supported when compiled in.\n");
pause();
}
int replace_function(const char* symbol, void* newAddress)
{
printf("WARNING: replace_functions is not supported when compiled in.\n");
printf("[WARNING!] 'replace_functions' is not supported when compiled in.\n");
pause();
return 0;
}
branches/ErmaC/Enoch/i386/boot2/gui.c
916916
917917
918918
919
919
920920
921921
922922
......
938938
939939
940940
941
941
942
942943
943944
944
945
946
945947
946948
947949
int initGUI(void)
{
intval;
intval;
intlen;
chardirspec[256];
#endif
}
// parse display size parameters
if (getIntForKey("screen_width", &val, &bootInfo->themeConfig) && val > 0) {
if (getIntForKey("screen_width", &val, &bootInfo->themeConfig) && (val > 0))
{
screen_params[0] = val;
}
if (getIntForKey("screen_height", &val, &bootInfo->themeConfig) && val > 0) {
if (getIntForKey("screen_height", &val, &bootInfo->themeConfig) && (val > 0))
{
screen_params[1] = val;
}
branches/ErmaC/Enoch/i386/boot2/options.c
5050
5151
5252
53
5453
54
55
5556
5657
5758
5859
5960
6061
61
62
6263
6364
6465
......
185186
186187
187188
188
189
190
191
192
189
190
191
192
193
193194
194195
195196
......
260261
261262
262263
263
264
264265
265
266
267
268
269
270
266
267
268
269
270
271
271272
272
273
274
275
276
277
278
279
280
273
274
275
276
277
278
281279
282
283
284
285
286
287
288
289
290
291
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
292295
293296
294
295
296
297
297
298
299
300
298301
299
300
301
302
303
302
303
304
305
306
307
308
309
310
304311
305
312
306313
307314
308315
......
375382
376383
377384
378
385
379386
380
381
382
387
388
389
383390
384391
385392
......
905912
906913
907914
908
915
909916
910917
911918
......
11141121
11151122
11161123
1117
1124
11181125
11191126
11201127
11211128
11221129
11231130
1124
1131
1132
11251133
11261134
11271135
......
11791187
11801188
11811189
1182
1183
1190
11841191
11851192
11861193
......
11971204
11981205
11991206
1200
1201
1202
1203
1207
1208
1209
1210
1211
12041212
12051213
12061214
......
12171225
12181226
12191227
1220
1228
1229
12211230
12221231
12231232
......
12261235
12271236
12281237
1229
1238
1239
12301240
12311241
12321242
......
12591269
12601270
12611271
1262
12631272
1264
12651273
12661274
12671275
12681276
12691277
1270
12711278
12721279
12731280
......
12991306
13001307
13011308
1302
1303
1309
13041310
13051311
13061312
......
13781384
13791385
13801386
1381
1387
13821388
13831389
13841390
extern intgDeviceCount;
intselectIndex = 0;
MenuItem * menuItems = NULL;
MenuItem *menuItems = NULL;
enum {
kMenuTopRow = 5,
kMenuMaxItems = 10,
kScreenLastRow = 24
};
extern char* msgbuf;
extern char *msgbuf;
void showTextBuffer(char *buf_orig, int size);
//==========================================================================
char gBootArgs[BOOT_STRING_LEN];
static char * gBootArgsPtr = gBootArgs;
static char * gBootArgsEnd = gBootArgs + BOOT_STRING_LEN - 1;
static char booterCommand[BOOT_STRING_LEN];
static char booterParam[BOOT_STRING_LEN];
chargBootArgs[BOOT_STRING_LEN];
static char*gBootArgsPtr = gBootArgs;
static char*gBootArgsEnd = gBootArgs + BOOT_STRING_LEN - 1;
static charbooterCommand[BOOT_STRING_LEN];
static charbooterParam[BOOT_STRING_LEN];
static void clearBootArgs(void)
{
static void updateBootArgs( int key )
{
key = ASCII_KEY(key);
key = ASCII_KEY(key);
switch ( key )
{
case KEY_BKSP:
if ( gBootArgsPtr > gBootArgs )
{
*--gBootArgsPtr = '\0';
switch ( key )
{
case KEY_BKSP:
if ( gBootArgsPtr > gBootArgs )
{
*--gBootArgsPtr = '\0';
int x, y, t;
getCursorPositionAndType( &x, &y, &t );
if ( x == 0 && y )
{
x = 80; y--;
}
if (x) {
x--;
}
int x, y, t;
getCursorPositionAndType( &x, &y, &t );
if ( x == 0 && y )
{
x = 80; y--;
}
if( bootArgs->Video.v_display == VGA_TEXT_MODE )
{
setCursorPosition( x, y, 0 );
putca(' ', 0x07, 1);
}
else
{
updateGraphicBootPrompt();
}
}
if (x)
{
x--;
}
if( bootArgs->Video.v_display == VGA_TEXT_MODE )
{
setCursorPosition( x, y, 0 );
putca(' ', 0x07, 1);
}
else
{
updateGraphicBootPrompt();
}
}
break;
default:
if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd)
{
*gBootArgsPtr++ = key;
default:
if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd)
{
*gBootArgsPtr++ = key;
if( bootArgs->Video.v_display != VGA_TEXT_MODE )
updateGraphicBootPrompt();
else if ( key >= ' ' && key < 0x7f)
putchar(key);
}
if( bootArgs->Video.v_display != VGA_TEXT_MODE )
{
updateGraphicBootPrompt();
}
else if ( key >= ' ' && key < 0x7f)
{
putchar(key);
}
}
break;
break;
}
}
// Draw the visible items.
if( bootArgs->Video.v_display != VGA_TEXT_MODE )
{
drawDeviceList(gMenuStart, gMenuEnd, gMenuSelection);
else {
}
else
{
changeCursor( 0, row, kCursorTypeHidden, &cursorState );
for ( i = gMenuTop; i <= gMenuBottom; i++ )
// gDeviceCount is actually > 0, so menuItems[selectIndex] exists
menuBVR = (BVRef)(menuItems[selectIndex].param);
// what happen is bvChain is empty ?
// what happen if bvChain is empty ?
}
}
bool copyArgument(const char *argName, const char *val, int cnt, char **argP, int *cntRemainingP)
{
int argLen = argName ? strlen(argName) : 0;
int len = argLen + cnt + 1; // + 1 to account for space.
int len = argLen + cnt + 1; // +1 to account for space
if (argName)
{
len++; // +1 to account for '='
}
if (len > *cntRemainingP) {
if (len > *cntRemainingP)
{
error("Warning: boot arguments too long, truncating\n");
return false;
}
// Maximum config table value size
#define VALUE_SIZE 2048
int
processBootOptions()
int processBootOptions()
{
const char *cp = gBootArgs;
const char *val = 0;
skipblanks( &cp );
// Update the unit and partition number.
if ( gBootVolume ) {
if (!( gBootVolume->flags & kBVFlagNativeBoot )) {
readBootSector( gBootVolume->biosdev, gBootVolume->part_boff, (void *) 0x7c00 );
if (gBootVolume)
{
if (!(gBootVolume->flags & kBVFlagNativeBoot))
{
readBootSector(gBootVolume->biosdev, gBootVolume->part_boff, (void *)0x7c00);
//
// Setup edx, and signal intention to chain load the
// foreign booter.
}
// If no boot volume fail immediately because we're just going to fail
// trying to load the config file anyway.
else {
else
{
return -1;
}
// Load config table specified by the user, or use the default.
if (!getValueForBootKey(cp, "config", &val, &cnt)) {
if (!getValueForBootKey(cp, "config", &val, &cnt))
{
val = 0;
cnt = 0;
}
{
if( YOSEMITE ) // is 10.10
{
strlcpy( bootInfo->bootFile, kOSXKernel, sizeof(bootInfo->bootFile) );
//printf(HEADER "/System/Library/Kernels/%s\n", bootInfo->bootFile);
}
else
{ // OSX is not 10.10
strlcpy( bootInfo->bootFile, kDefaultKernel, sizeof(bootInfo->bootFile) );
//printf(HEADER "/%s\n", bootInfo->bootFile);
}
}
}
argP = bootArgs->CommandLine;
// Get config kernel flags, if not ignored.
if (getValueForBootKey(cp, kIgnoreBootFileFlag, &val, &cnt) ||
!getValueForKey( kKernelFlagsKey, &val, &cnt, &bootInfo->bootConfig ))
if (getValueForBootKey(cp, kIgnoreBootFileFlag, &val, &cnt) || !getValueForKey(kKernelFlagsKey, &val, &cnt, &bootInfo->bootConfig))
{
val = "";
cnt = 0;
{
copyArgument( kRootDeviceKey, val, cnt, &argP, &cntRemaining);
}
strlcpy( gRootDevice, val, (cnt + 1));
strlcpy(gRootDevice, val, (cnt + 1));
}
/*
branches/ErmaC/Enoch/i386/modules/Resolution/915resolution.c
350350
351351
352352
353
353
354
355
354356
355357
356358
} else {
verbose(", BT_ATI_2\n");
}
} else {
}
else
{
/*
* check if we have NVIDIA
branches/ErmaC/Enoch/i386/modules/Resolution/edid.c
265265
266266
267267
268
268
269
269270
270271
271
272
273
272274
273275
274276
......
278280
279281
280282
281
283
284
282285
283286
284
287
288
289
285290
286291
287292
......
343348
344349
345350
346
351
352
347353
348354
349355
yResolution = val;
}
*/
if(!xResolution || !yResolution || !bpResolution) {
if(!xResolution || !yResolution || !bpResolution)
{
char* edidInfo = readEDID();
if(!edidInfo) {
if(!edidInfo)
{
return;
}
//yResolution = edidInfo[59] | ((edidInfo[61] & 0xF0) << 4);
//Slice - done here
if(fb_parse_edid((struct EDID *)edidInfo, &mode) == 0) {
if(fb_parse_edid((struct EDID *)edidInfo, &mode) == 0)
{
xResolution = DEFAULT_SCREEN_WIDTH;
yResolution = DEFAULT_SCREEN_HEIGHT;
} else {
}
else
{
xResolution = mode.h_active;
yResolution = mode.v_active;
}
msglog("Buffer location: 0x%X status: %d\n", SEG(edidInfo) << 16 | OFF(edidInfo), status);
int j, i;
for (j = 0; j < 8; j++) {
for (j = 0; j < 8; j++)
{
for(i = 0; i < 16; i++) msglog(" 0x%02X", edidInfo[((i+1) * (j + 1)) - 1]);
msglog("\n");
}
branches/ErmaC/Enoch/i386/libsa/prf.c
104104
105105
106106
107
107
108
108109
109110
110
111
112
113
111114
112115
113116
......
152155
153156
154157
155
158
159
156160
157161
158162
......
160164
161165
162166
163
167
168
164169
165170
166171
......
168173
169174
170175
171
176
177
172178
173179
174180
175181
176182
177183
178
184
185
179186
180187
181188
loop:
while ((c = *fmt++) != '%') {
if(c == '\0') {
if(c == '\0')
{
return len;
}
if (putfn_p) {
if (putfn_p)
{
(*putfn_p)(c, putfn_arg);
}
len++;
case 'o': case 'O':
b = 8;
number:
if (putfn_p) {
if (putfn_p)
{
printn((u_long)*adx, b, flag, minwidth, putfn_p, putfn_arg);
}
len++;
case 's':
s = (char *)*adx;
while ((c = *s++)) {
if (putfn_p) {
if (putfn_p)
{
(*putfn_p)(c, putfn_arg);
}
len++;
}
while (width++ < minwidth)
{
if (putfn_p) {
if (putfn_p)
{
(*putfn_p)(' ', putfn_arg);
}
len++;
}
break;
case 'c':
if (putfn_p) {
if (putfn_p)
{
(*putfn_p)((char)*adx, putfn_arg);
}
len++;
branches/ErmaC/Enoch/i386/libsa/memory.h
9090
9191
9292
93
93
9494
9595
9696
#define KERNEL_LEN 0x08000000
#define ZALLOC_ADDR 0x08100000 // 256M zalloc area
#define ZALLOC_LEN 0x10000000
#define ZALLOC_LEN 0x14000000
#define LOAD_ADDR 0x18100000 // 64M File load buffer
#define LOAD_LEN 0x04000000
branches/ErmaC/Enoch/package/po/mk.po
609609
610610
611611
612
612
613613
614614
615615
......
621621
622622
623623
624
624
625625
626626
627627
......
631631
632632
633633
634
635
634
636635
637
636
638637
639638
640639
......
644643
645644
646645
647
648
646
649647
650
648
651649
652650
653651
#: Resources/templates/Localizable.strings:126
#, no-wrap
msgid "PrivateData=No"
msgstr ""
msgstr "PrivateData=No"
#. type: "PrivateData_description"
#: Resources/templates/Localizable.strings:127
#: Resources/templates/Localizable.strings:131
#, no-wrap
msgid "USBBusFix=Yes"
msgstr ""
msgstr "USBBusFix=Yes"
#. type: "USBBusFix_description"
#: Resources/templates/Localizable.strings:132
#. type: "USBLegacyOff_title"
#: Resources/templates/Localizable.strings:134
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "USBLegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "USBLegacyOff=Yes"
#. type: "USBLegacyOff_description"
#: Resources/templates/Localizable.strings:135
#. type: "XHCILegacyOff_title"
#: Resources/templates/Localizable.strings:137
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "XHCILegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "XHCILegacyOff=Yes"
#. type: "XHCILegacyOff_description"
#: Resources/templates/Localizable.strings:138
branches/ErmaC/Enoch/package/po/nl.po
628628
629629
630630
631
631
632632
633633
634634
......
640640
641641
642642
643
643
644644
645645
646646
......
650650
651651
652652
653
654
653
655654
656
655
657656
658657
659658
......
663662
664663
665664
666
667
665
668666
669
667
670668
671669
672670
#: Resources/templates/Localizable.strings:126
#, no-wrap
msgid "PrivateData=No"
msgstr ""
msgstr "PrivateData=No"
#. type: "PrivateData_description"
#: Resources/templates/Localizable.strings:127
#: Resources/templates/Localizable.strings:131
#, no-wrap
msgid "USBBusFix=Yes"
msgstr ""
msgstr "USBBusFix=Yes"
#. type: "USBBusFix_description"
#: Resources/templates/Localizable.strings:132
#. type: "USBLegacyOff_title"
#: Resources/templates/Localizable.strings:134
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "USBLegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "USBLegacyOff=Yes"
#. type: "USBLegacyOff_description"
#: Resources/templates/Localizable.strings:135
#. type: "XHCILegacyOff_title"
#: Resources/templates/Localizable.strings:137
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "XHCILegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "XHCILegacyOff=Yes"
#. type: "XHCILegacyOff_description"
#: Resources/templates/Localizable.strings:138
branches/ErmaC/Enoch/package/po/hr.po
610610
611611
612612
613
613
614614
615615
616616
......
622622
623623
624624
625
625
626626
627627
628628
......
632632
633633
634634
635
636
635
637636
638
637
639638
640639
641640
......
645644
646645
647646
648
649
647
650648
651
649
652650
653651
654652
#: Resources/templates/Localizable.strings:126
#, no-wrap
msgid "PrivateData=No"
msgstr ""
msgstr "PrivateData=No"
#. type: "PrivateData_description"
#: Resources/templates/Localizable.strings:127
#: Resources/templates/Localizable.strings:131
#, no-wrap
msgid "USBBusFix=Yes"
msgstr ""
msgstr "USBBusFix=Yes"
#. type: "USBBusFix_description"
#: Resources/templates/Localizable.strings:132
#. type: "USBLegacyOff_title"
#: Resources/templates/Localizable.strings:134
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "USBLegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "USBLegacyOff=Yes"
#. type: "USBLegacyOff_description"
#: Resources/templates/Localizable.strings:135
#. type: "XHCILegacyOff_title"
#: Resources/templates/Localizable.strings:137
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "XHCILegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "XHCILegacyOff=Yes"
#. type: "XHCILegacyOff_description"
#: Resources/templates/Localizable.strings:138
branches/ErmaC/Enoch/package/po/pl.po
614614
615615
616616
617
617
618618
619619
620620
......
626626
627627
628628
629
629
630630
631631
632632
......
636636
637637
638638
639
640
639
641640
642
641
643642
644643
645644
......
649648
650649
651650
652
653
651
654652
655
653
656654
657655
658656
#: Resources/templates/Localizable.strings:126
#, no-wrap
msgid "PrivateData=No"
msgstr ""
msgstr "PrivateData=No"
#. type: "PrivateData_description"
#: Resources/templates/Localizable.strings:127
#: Resources/templates/Localizable.strings:131
#, no-wrap
msgid "USBBusFix=Yes"
msgstr ""
msgstr "USBBusFix=Yes"
#. type: "USBBusFix_description"
#: Resources/templates/Localizable.strings:132
#. type: "USBLegacyOff_title"
#: Resources/templates/Localizable.strings:134
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "USBLegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "USBLegacyOff=Yes"
#. type: "USBLegacyOff_description"
#: Resources/templates/Localizable.strings:135
#. type: "XHCILegacyOff_title"
#: Resources/templates/Localizable.strings:137
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "XHCILegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "XHCILegacyOff=Yes"
#. type: "XHCILegacyOff_description"
#: Resources/templates/Localizable.strings:138
branches/ErmaC/Enoch/package/po/hu.po
603603
604604
605605
606
606
607607
608608
609609
......
615615
616616
617617
618
618
619619
620620
621621
......
625625
626626
627627
628
629
628
630629
631
630
632631
633632
634633
......
638637
639638
640639
641
642
640
643641
644
642
645643
646644
647645
#: Resources/templates/Localizable.strings:126
#, no-wrap
msgid "PrivateData=No"
msgstr ""
msgstr "PrivateData=No"
#. type: "PrivateData_description"
#: Resources/templates/Localizable.strings:127
#: Resources/templates/Localizable.strings:131
#, no-wrap
msgid "USBBusFix=Yes"
msgstr ""
msgstr "USBBusFix=Yes"
#. type: "USBBusFix_description"
#: Resources/templates/Localizable.strings:132
#. type: "USBLegacyOff_title"
#: Resources/templates/Localizable.strings:134
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "USBLegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "USBLegacyOff=Yes"
#. type: "USBLegacyOff_description"
#: Resources/templates/Localizable.strings:135
#. type: "XHCILegacyOff_title"
#: Resources/templates/Localizable.strings:137
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "XHCILegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "XHCILegacyOff=Yes"
#. type: "XHCILegacyOff_description"
#: Resources/templates/Localizable.strings:138
branches/ErmaC/Enoch/package/po/ca.po
612612
613613
614614
615
615
616616
617617
618618
......
624624
625625
626626
627
627
628628
629629
630630
......
634634
635635
636636
637
638
637
639638
640
639
641640
642641
643642
......
647646
648647
649648
650
651
649
652650
653
651
654652
655653
656654
#: Resources/templates/Localizable.strings:126
#, no-wrap
msgid "PrivateData=No"
msgstr ""
msgstr "PrivateData=No"
#. type: "PrivateData_description"
#: Resources/templates/Localizable.strings:127
#: Resources/templates/Localizable.strings:131
#, no-wrap
msgid "USBBusFix=Yes"
msgstr ""
msgstr "USBBusFix=Yes"
#. type: "USBBusFix_description"
#: Resources/templates/Localizable.strings:132
#. type: "USBLegacyOff_title"
#: Resources/templates/Localizable.strings:134
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "USBLegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "USBLegacyOff=Yes"
#. type: "USBLegacyOff_description"
#: Resources/templates/Localizable.strings:135
#. type: "XHCILegacyOff_title"
#: Resources/templates/Localizable.strings:137
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "XHCILegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "XHCILegacyOff=Yes"
#. type: "XHCILegacyOff_description"
#: Resources/templates/Localizable.strings:138
branches/ErmaC/Enoch/package/po/sr.po
608608
609609
610610
611
611
612612
613613
614614
......
620620
621621
622622
623
623
624624
625625
626626
......
630630
631631
632632
633
634
633
635634
636
635
637636
638637
639638
......
643642
644643
645644
646
647
645
648646
649
647
650648
651649
652650
#: Resources/templates/Localizable.strings:126
#, no-wrap
msgid "PrivateData=No"
msgstr ""
msgstr "PrivateData=No"
#. type: "PrivateData_description"
#: Resources/templates/Localizable.strings:127
#: Resources/templates/Localizable.strings:131
#, no-wrap
msgid "USBBusFix=Yes"
msgstr ""
msgstr "USBBusFix=Yes"
#. type: "USBBusFix_description"
#: Resources/templates/Localizable.strings:132
#. type: "USBLegacyOff_title"
#: Resources/templates/Localizable.strings:134
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "USBLegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "USBLegacyOff=Yes"
#. type: "USBLegacyOff_description"
#: Resources/templates/Localizable.strings:135
#. type: "XHCILegacyOff_title"
#: Resources/templates/Localizable.strings:137
#, fuzzy, no-wrap
#| msgid "LegacyLogo=Yes"
#, no-wrap
msgid "XHCILegacyOff=Yes"
msgstr "LegacyLogo=Yes"
msgstr "XHCILegacyOff=Yes"
#. type: "XHCILegacyOff_description"
#: Resources/templates/Localizable.strings:138
branches/ErmaC/Enoch/CHANGES
1
12
23
34
- Bungo : Added getRTCdatetime() Int 1Ah function 02h - RTC service
- Zenith432 : Use caching with ExFat filesystem
- Zenith432 : Add turning off USB legacy for XHCI (XHCILegacyOff)
- Zenith432 : saio_types.h, biosfn.c - minor typo in bios-defined data structure that isn't actually used.

Archive Download the corresponding diff file

Revision: 2542