Chameleon

Chameleon Commit Details

Date:2010-09-03 13:08:26 (8 years 10 months ago)
Author:Kabyl
Commit:485
Parents: 484
Message:Merged changes from trunk@475
Changes:
C/trunk/package/Resources/Portuguese.lproj → /branches/Kabyl/package/Resources/Portuguese.lproj
C/trunk/artwork/themes/default/thumb.png → /branches/Kabyl/artwork/themes/default/thumb.png
M/branches/Kabyl/artwork/themes/default/device_generic.png
M/branches/Kabyl/artwork/themes/default/device_hfsraid.png
M/branches/Kabyl/i386/libsaio/fake_efi.c
M/branches/Kabyl/artwork/themes/default/device_ext3.png
M/branches/Kabyl/i386/libsaio/fake_efi.h
M/branches/Kabyl/artwork/themes/default/device_fat_o.png
M/branches/Kabyl/artwork/themes/default/device_ntfs_o.png
M/branches/Kabyl
M/branches/Kabyl/i386/boot2/boot.c
M/branches/Kabyl/artwork/themes/default/device_hfsplus_o.png
M/branches/Kabyl/i386/boot2/boot.h
M/branches/Kabyl/i386/libsaio/acpi_patcher.c
M/branches/Kabyl/artwork/themes/default/device_fat.png
M/branches/Kabyl/artwork/themes/default/device_ntfs.png
M/branches/Kabyl/artwork/themes/default/device_cdrom_o.png
M/branches/Kabyl/i386/libsaio/disk.c
M/branches/Kabyl/artwork/themes/default/device_hfsplus.png
M/branches/Kabyl/i386/boot2/options.c
M/branches/Kabyl/artwork/themes/default/device_generic_o.png
M/branches/Kabyl/doc/BootHelp.txt
M/branches/Kabyl/artwork/themes/default/device_hfsraid_o.png
M/branches/Kabyl/artwork/themes/default/device_ext3_o.png
M/branches/Kabyl/artwork/themes/default/device_cdrom.png

File differences

branches/Kabyl/doc/BootHelp.txt
9090
9191
9292
93
93
9494
95
96
97
95
96
9897
9998
10099
DropSSDT=Yes Skip the SSDT tables while relocating the ACPI tables.
DSDT=<file> Use an alternate DSDT.aml file
(default path: /DSDT.aml /Extra/DSDT.aml).
(default path: /DSDT.aml /Extra/DSDT.aml bt(0,0)/Extra/DSDT.aml).
SMBIOS=<file> Use an alternate smbios.plist file
(default path: /smbios.plist /Extra/smbios.plist
bt(0,0)/Extra/smbios.plist).
SMBIOS=<file> Use an alternate SMBIOS.plist file
(default path: /Extra/SMBIOS.plist bt(0,0)/Extra/SMBIOS.plist).
SMBIOSdefaults=No Don't use the Default values for SMBIOS overriding
if smbios.plist doesn't exist, factory
branches/Kabyl/i386/libsaio/fake_efi.h
88
99
1010
11
12
11
1312
1413
/* Set up space for up to 10 configuration table entries */
#define MAX_CONFIGURATION_TABLE_ENTRIES 10
extern void
setupFakeEfi(void);
extern void setupFakeEfi(void);
#endif /* !__LIBSAIO_FAKE_EFI_H */
branches/Kabyl/i386/libsaio/acpi_patcher.c
8989
9090
9191
92
93
94
95
96
92
93
9794
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
95
96
97
98
99
100
101
102
103
123104
124
125
105
106
126107
127108
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
109
110
111
112
113
114
115
116
117
155118
156119
157120
121
158122
159123
160124
......
706670
707671
708672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
709687
710688
711
689
712690
713691
714692
/** The folowing ACPI Table search algo. should be reused anywhere needed:*/
int search_and_get_acpi_fd(const char * filename, const char ** outDirspec)
{
int fd=0;
const char * overriden_pathname=NULL;
static char dirspec[512]="";
static bool first_time =true;
int len=0;
int fd = 0;
char dirSpec[512] = "";
/// Take in accound user overriding if it's DSDT only
if (strstr(filename, "DSDT") &&
getValueForKey(kDSDT, &overriden_pathname, &len,
&bootInfo->bootConfig))
{
sprintf(dirspec, "%s", overriden_pathname);
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
}
// Check that dirspec is not already assigned with a path
if (!first_time && *dirspec)
{ // it is so start searching this cached patch first
//extract path
for (len=strlen(dirspec)-1; len; len--)
if (dirspec[len]=='/' || len==0)
{
dirspec[len]='\0';
break;
}
// now concat with the filename
strncat(dirspec, "/", sizeof(dirspec));
strncat(dirspec, filename, sizeof(dirspec));
// and test to see if we don't have our big boy here:
fd=open (dirspec,0);
if (fd>=0)
// Try finding 'filename' in the usual places
// Start searching any potential location for ACPI Table
sprintf(dirSpec, "%s", filename);
fd = open(dirSpec, 0);
if (fd < 0)
{
sprintf(dirSpec, "/Extra/%s", filename);
fd = open(dirSpec, 0);
if (fd < 0)
{
// printf("ACPI file search cache hit: file found at %s\n", dirspec);
goto success_fd;
sprintf(dirSpec, "bt(0,0)/Extra/%s", filename);
fd = open(dirSpec, 0);
}
}
// Start searching any potential location for ACPI Table
// search the Extra folders first
sprintf(dirspec,"/Extra/%s",filename);
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
sprintf(dirspec,"bt(0,0)/Extra/%s",filename);
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
sprintf(dirspec, "%s", filename); // search current dir
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
sprintf(dirspec, "/%s", filename); // search root
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
// NOT FOUND:
//verbose("ACPI Table not found: %s\n", filename);
if (outDirspec) *outDirspec = "";
first_time = false;
return -1;
// FOUND
success_fd:
first_time = false;
if (outDirspec) *outDirspec = dirspec;
if (fd < 0)
{
// NOT FOUND:
verbose("ACPI table not found: %s\n", filename);
*dirSpec = '\0';
}
if (outDirspec) *outDirspec = dirSpec;
return fd;
}
void *loadACPITable (const char * filename)
{
void *tableAddr;
{
int version;
void *new_dsdt;
const char *filename;
char dirSpec[128];
int len = 0;
// Try using the file specified with the DSDT option
if (getValueForKey(kDSDT, &filename, &len, &bootInfo->bootConfig))
{
sprintf(dirSpec, filename);
}
else
{
sprintf(dirSpec, "DSDT.aml");
}
// Load replacement DSDT
new_dsdt=loadACPITable("DSDT.aml");
new_dsdt = loadACPITable(dirSpec);
// Mozodojo: going to patch FACP and load SSDT's even if DSDT.aml is not present
/*if (!new_dsdt)
{
branches/Kabyl/i386/libsaio/disk.c
16951695
16961696
16971697
1698
1698
16991699
17001700
17011701
......
17661766
17671767
17681768
1769
1770
1769
17711770
17721771
17731772
bool matchVolumeToString( BVRef bvr, const char* match, long matchLen)
{
char testStr[128];
if ( !bvr || !match || !*match)
return 0;
if ( matchVolumeToString(bvr, volStart, volLen) )
{
strncpy(str, aliasStart, min(strMaxLen, aliasLen));
str[min(strMaxLen, aliasLen)] = '\0';
strncat(str, aliasStart, min(strMaxLen, aliasLen));
free(aliasList);
return true;
branches/Kabyl/i386/libsaio/fake_efi.c
11
22
3
3
44
55
66
......
2121
2222
2323
24
25
26
27
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
2852
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
5453
5554
5655
5756
5857
5958
60
61
62
59
60
61
6362
6463
65
6664
6765
6866
67
6968
7069
71
70
7271
7372
74
7573
7674
7775
......
8179
8280
8381
84
82
8583
8684
8785
86
8887
8988
9089
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
90
91
11192
11293
11394
11495
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
146139
147140
148
141
142
149143
150
151
152
144
145
146
153147
154148
155
156
149
150
151
152
153
154
157155
158
159
160
161
162
156
163157
164
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
165272
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
264380
265381
266382
267
268
269
270
271
383
384
385
386
387
272388
273389
274390
......
284400
285401
286402
287
403
288404
289
290
405
406
291407
292408
293409
294410
295411
296412
297
413
298414
299415
300416
301417
302
418
303419
304420
305421
......
314430
315431
316432
317
433
434
318435
319436
320437
321438
322439
323440
324
441
442
443
444
325445
326446
327
328
329
447
448
449
450
451
452
453
454
455
456
457
458
459
330460
331
461
462
463
332464
333
334
335
336
337
338
339
340
341
342
465
343466
344
345
346
347
467
468
469
470
348471
349
350
351
472
473
474
352475
353476
354477
355
478
479
480
356481
357482
358483
359
484
360485
361486
362487
363488
364
489
490
365491
366492
493
367494
368
495
496
497
498
499
500
369501
370
371
372
373
502
503
504
505
506
507
508
509
510
511
512
513
374514
375
376
377
378
379
380
515
516
517
518
381519
382
383
384
385
386
387520
388521
389
390
391
392
393
522
523
524
525
526
394527
395528
396529
397530
398
399
400
401
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
402576
403
404
405
406
407
408
409
410
411
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
412601
413
414
415
602
603
604
605
606
607
608
609
610
611
612
416613
417
614
615
616
418617
419
420
421
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
422643
423
424
425
426
427
428
644
645
646
647
429648
430
431
432
433
649
650
651
434652
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
653
467654
468655
469
470
471
472
473
656
657
658
474659
475
476
477
478
479
480
481
482
483
484
485
486
487
488660
489661
490662
491663
492
664
493665
494666
495
667
496668
497
669
670
671
672
673
674
675
676
677
678
498679
499680
681
682
683
500684
501
502685
503686
504687
505688
506689
507
690
508691
509692
510
511
693
694
512695
513696
514697
515
516
698
699
700
701
702
703
704
705
706
517707
518708
519
709
520710
521711
522712
/*
* Copyright 2007 David F. Elliott. All rights reserved.
* Copyright 2007 David F. Elliott. All rights reserved.
*/
#include "libsaio.h"
extern void setup_pci_devs(pci_dt_t *pci_dt);
/*
Modern Darwin kernels require some amount of EFI because Apple machines all
have EFI. Modifying the kernel source to not require EFI is of course
possible but would have to be maintained as a separate patch because it is
unlikely that Apple wishes to add legacy support to their kernel.
* Modern Darwin kernels require some amount of EFI because Apple machines all
* have EFI. Modifying the kernel source to not require EFI is of course
* possible but would have to be maintained as a separate patch because it is
* unlikely that Apple wishes to add legacy support to their kernel.
*
* As you can see from the Apple-supplied code in bootstruct.c, it seems that
* the intention was clearly to modify this booter to provide EFI-like structures
* to the kernel rather than modifying the kernel to handle non-EFI stuff. This
* makes a lot of sense from an engineering point of view as it means the kernel
* for the as yet unreleased EFI-only Macs could still be booted by the non-EFI
* DTK systems so long as the kernel checked to ensure the boot tables were
* filled in appropriately. Modern xnu requires a system table and a runtime
* services table and performs no checks whatsoever to ensure the pointers to
* these tables are non-NULL.Therefore, any modern xnu kernel will page fault
* early on in the boot process if the system table pointer is zero.
*
* Even before that happens, the tsc_init function in modern xnu requires the FSB
* Frequency to be a property in the /efi/platform node of the device tree or else
* it panics the bootstrap process very early on.
*
* As of this writing, the current implementation found here is good enough
* to make the currently available xnu kernel boot without modification on a
* system with an appropriate processor. With a minor source modification to
* the tsc_init function to remove the explicit check for Core or Core 2
* processors the kernel can be made to boot on other processors so long as
* the code can be executed by the processor and the machine contains the
* necessary hardware.
*/
As you can see from the Apple-supplied code in bootstruct.c, it seems that
the intention was clearly to modify this booter to provide EFI-like structures
to the kernel rather than modifying the kernel to handle non-EFI stuff. This
makes a lot of sense from an engineering point of view as it means the kernel
for the as yet unreleased EFI-only Macs could still be booted by the non-EFI
DTK systems so long as the kernel checked to ensure the boot tables were
filled in appropriately. Modern xnu requires a system table and a runtime
services table and performs no checks whatsoever to ensure the pointers to
these tables are non-NULL. Therefore, any modern xnu kernel will page fault
early on in the boot process if the system table pointer is zero.
Even before that happens, the tsc_init function in modern xnu requires the FSB
Frequency to be a property in the /efi/platform node of the device tree or else
it panics the bootstrap process very early on.
As of this writing, the current implementation found here is good enough
to make the currently available xnu kernel boot without modification on a
system with an appropriate processor. With a minor source modification to
the tsc_init function to remove the explicit check for Core or Core 2
processors the kernel can be made to boot on other processors so long as
the code can be executed by the processor and the machine contains the
necessary hardware.
*/
/*==========================================================================
* Utility function to make a device tree string from an EFI_GUID
*/
static inline char * mallocStringForGuid(EFI_GUID const *pGuid)
{
char *string = malloc(37);
efi_guid_unparse_upper(pGuid, string);
return string;
char *string = malloc(37);
efi_guid_unparse_upper(pGuid, string);
return string;
}
/*==========================================================================
* Function to map 32 bit physical address to 64 bit virtual address
*/
static uint64_t ptov64(uint32_t addr)
{
return ((uint64_t)addr | 0xFFFFFF8000000000ULL);
return ((uint64_t)addr | 0xFFFFFF8000000000ULL);
}
/*==========================================================================
* Fake EFI implementation
*/
static EFI_UINT32 const FIRMWARE_REVISION = 132; /* FIXME: Find a constant for this. */
/* Default platform system_id (fix by IntVar) */
static EFI_CHAR8 const SYSTEM_ID[] = "0123456789ABCDEF";//random value gen by uuidgen
static EFI_CHAR8 const SYSTEM_ID[] = "0123456789ABCDEF"; //random value gen by uuidgen
/* Just a ret instruction */
static uint8_t const VOIDRET_INSTRUCTIONS[] = {0xc3};
/* movl $0x80000003,%eax; ret */
static uint8_t const UNSUPPORTEDRET_INSTRUCTIONS[] = {0xb8, 0x03, 0x00, 0x00, 0x80, 0xc3};
/* We use the fake_efi_pages struct so that we only need to do one kernel
* memory allocation for all needed EFI data. Otherwise, small allocations
* like the FIRMWARE_VENDOR string would take up an entire page.
* NOTE WELL: Do NOT assume this struct has any particular layout within itself.
* It is absolutely not intended to be publicly exposed anywhere
* We say pages (plural) although right now we are well within the 1 page size
* and probably will stay that way.
*/
struct fake_efi_pages
{
EFI_SYSTEM_TABLE_64 efiSystemTable;
EFI_RUNTIME_SERVICES_64 efiRuntimeServices;
EFI_CONFIGURATION_TABLE_64 efiConfigurationTable[MAX_CONFIGURATION_TABLE_ENTRIES];
EFI_CHAR16 firmwareVendor[sizeof(FIRMWARE_VENDOR)/sizeof(EFI_CHAR16)];
uint8_t voidret_instructions[sizeof(VOIDRET_INSTRUCTIONS)/sizeof(uint8_t)];
uint8_t unsupportedret_instructions[sizeof(UNSUPPORTEDRET_INSTRUCTIONS)/sizeof(uint8_t)];
};
EFI_SYSTEM_TABLE_64 *gST = NULL;
EFI_SYSTEM_TABLE_32 *gST32 = NULL;
EFI_SYSTEM_TABLE_64 *gST64 = NULL;
Node *gEfiConfigurationTableNode = NULL;
extern EFI_STATUS addConfigurationTable(EFI_GUID const *pGuid, void *table, char const *alias)
{
EFI_UINTN i = gST->NumberOfTableEntries;
/* 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");
if(pGuid == NULL)
return EFI_INVALID_PARAMETER;
if(table != NULL)
{
/* FIXME
((EFI_CONFIGURATION_TABLE_64 *)gST->ConfigurationTable)[i].VendorGuid = *pGuid;
((EFI_CONFIGURATION_TABLE_64 *)gST->ConfigurationTable)[i].VendorTable = (EFI_PTR64)table;
++gST->NumberOfTableEntries;
*/
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);
/* The "table" property is the 32-bit (in our implementation) physical address of the table */
DT__AddProperty(tableNode, "table", sizeof(void*) * 2, table);
/* Assume the alias pointer is a global or static piece of data */
if(alias != NULL)
DT__AddProperty(tableNode, "alias", strlen(alias)+1, (char*)alias);
return EFI_SUCCESS;
}
return EFI_UNSUPPORTED;
EFI_UINTN i = 0;
//Azi: as is, cpu's with em64t will use EFI64 on pre 10.6 systems,
// wich seems to cause no problem. In case it does, force i386 arch.
if (archCpuType == CPU_TYPE_I386)
{
i = gST32->NumberOfTableEntries;
}
else
{
i = gST64->NumberOfTableEntries;
}
// 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");
if (pGuid == NULL)
return EFI_INVALID_PARAMETER;
if (table != NULL)
{
// FIXME
//((EFI_CONFIGURATION_TABLE_64 *)gST->ConfigurationTable)[i].VendorGuid = *pGuid;
//((EFI_CONFIGURATION_TABLE_64 *)gST->ConfigurationTable)[i].VendorTable = (EFI_PTR64)table;
//++gST->NumberOfTableEntries;
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);
// The "table" property is the 32-bit (in our implementation) physical address of the table
DT__AddProperty(tableNode, "table", sizeof(void*) * 2, table);
// Assume the alias pointer is a global or static piece of data
if (alias != NULL)
DT__AddProperty(tableNode, "alias", strlen(alias)+1, (char*)alias);
return EFI_SUCCESS;
}
return EFI_UNSUPPORTED;
}
static inline void fixupEfiSystemTableCRC32(EFI_SYSTEM_TABLE_64 *efiSystemTable)
//Azi: crc32 done in place, on the cases were it wasn't.
/*static inline void fixupEfiSystemTableCRC32(EFI_SYSTEM_TABLE_64 *efiSystemTable)
{
efiSystemTable->Hdr.CRC32 = 0;
efiSystemTable->Hdr.CRC32 = crc32(0L, efiSystemTable, efiSystemTable->Hdr.HeaderSize);
}
efiSystemTable->Hdr.CRC32 = 0;
efiSystemTable->Hdr.CRC32 = crc32(0L, efiSystemTable, efiSystemTable->Hdr.HeaderSize);
}*/
/*
What we do here is simply allocate a fake EFI system table and a fake EFI
runtime services table.
* What we do here is simply allocate a fake EFI system table and a fake EFI
* runtime services table.
*
* Because we build against modern headers with kBootArgsRevision 4 we
* also take care to set efiMode = 32.
*/
Because we build against modern headers with kBootArgsRevision 4 we
also take care to set efiMode = 32.
*/
void
setupEfiTables(void)
void setupEfiTables32(void)
{
struct fake_efi_pages *fakeEfiPages= (struct fake_efi_pages*)AllocateKernelMemory(sizeof(struct fake_efi_pages));
// We use the fake_efi_pages struct so that we only need to do one kernel
// memory allocation for all needed EFI data. Otherwise, small allocations
// like the FIRMWARE_VENDOR string would take up an entire page.
// NOTE WELL: Do NOT assume this struct has any particular layout within itself.
// It is absolutely not intended to be publicly exposed anywhere
// We say pages (plural) although right now we are well within the 1 page size
// and probably will stay that way.
struct fake_efi_pages
{
EFI_SYSTEM_TABLE_32 efiSystemTable;
EFI_RUNTIME_SERVICES_32 efiRuntimeServices;
EFI_CONFIGURATION_TABLE_32 efiConfigurationTable[MAX_CONFIGURATION_TABLE_ENTRIES];
EFI_CHAR16 firmwareVendor[sizeof(FIRMWARE_VENDOR)/sizeof(EFI_CHAR16)];
uint8_t voidret_instructions[sizeof(VOIDRET_INSTRUCTIONS)/sizeof(uint8_t)];
uint8_t unsupportedret_instructions[sizeof(UNSUPPORTEDRET_INSTRUCTIONS)/sizeof(uint8_t)];
};
struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages*)AllocateKernelMemory(sizeof(struct fake_efi_pages));
// Zero out all the tables in case fields are added later
bzero(fakeEfiPages, sizeof(struct fake_efi_pages));
// --------------------------------------------------------------------
// Initialize some machine code that will return EFI_UNSUPPORTED for
// functions returning int and simply return for void functions.
memcpy(fakeEfiPages->voidret_instructions, VOIDRET_INSTRUCTIONS, sizeof(VOIDRET_INSTRUCTIONS));
memcpy(fakeEfiPages->unsupportedret_instructions, UNSUPPORTEDRET_INSTRUCTIONS, sizeof(UNSUPPORTEDRET_INSTRUCTIONS));
// --------------------------------------------------------------------
// System table
EFI_SYSTEM_TABLE_32 *efiSystemTable = gST32 = &fakeEfiPages->efiSystemTable;
efiSystemTable->Hdr.Signature = EFI_SYSTEM_TABLE_SIGNATURE;
efiSystemTable->Hdr.Revision = EFI_SYSTEM_TABLE_REVISION;
efiSystemTable->Hdr.HeaderSize = sizeof(EFI_SYSTEM_TABLE_32);
efiSystemTable->Hdr.CRC32 = 0; // Initialize to zero and then do CRC32
efiSystemTable->Hdr.Reserved = 0;
efiSystemTable->FirmwareVendor = (EFI_PTR32)&fakeEfiPages->firmwareVendor;
memcpy(fakeEfiPages->firmwareVendor, FIRMWARE_VENDOR, sizeof(FIRMWARE_VENDOR));
efiSystemTable->FirmwareRevision = FIRMWARE_REVISION;
// XXX: We may need to have basic implementations of ConIn/ConOut/StdErr
// The EFI spec states that all handles are invalid after boot services have been
// exited so we can probably get by with leaving the handles as zero.
efiSystemTable->ConsoleInHandle = 0;
efiSystemTable->ConIn = 0;
efiSystemTable->ConsoleOutHandle = 0;
efiSystemTable->ConOut = 0;
efiSystemTable->StandardErrorHandle = 0;
efiSystemTable->StdErr = 0;
efiSystemTable->RuntimeServices = (EFI_PTR32)&fakeEfiPages->efiRuntimeServices;
// According to the EFI spec, BootServices aren't valid after the
// boot process is exited so we can probably do without it.
// Apple didn't provide a definition for it in pexpert/i386/efi.h
// so I'm guessing they don't use it.
efiSystemTable->BootServices = 0;
efiSystemTable->NumberOfTableEntries = 0;
efiSystemTable->ConfigurationTable = (EFI_PTR32)fakeEfiPages->efiConfigurationTable;
// We're done. Now CRC32 the thing so the kernel will accept it.
// Must be initialized to zero before CRC32, done above.
gST32->Hdr.CRC32 = crc32(0L, gST32, gST32->Hdr.HeaderSize);
// --------------------------------------------------------------------
// Runtime services
EFI_RUNTIME_SERVICES_32 *efiRuntimeServices = &fakeEfiPages->efiRuntimeServices;
efiRuntimeServices->Hdr.Signature = EFI_RUNTIME_SERVICES_SIGNATURE;
efiRuntimeServices->Hdr.Revision = EFI_RUNTIME_SERVICES_REVISION;
efiRuntimeServices->Hdr.HeaderSize = sizeof(EFI_RUNTIME_SERVICES_32);
efiRuntimeServices->Hdr.CRC32 = 0;
efiRuntimeServices->Hdr.Reserved = 0;
// There are a number of function pointers in the efiRuntimeServices table.
// These are the Foundation (e.g. core) services and are expected to be present on
// all EFI-compliant machines.Some kernel extensions (notably AppleEFIRuntime)
// will call these without checking to see if they are null.
//
// We don't really feel like doing an EFI implementation in the bootloader
// but it is nice if we can at least prevent a complete crash by
// at least providing some sort of implementation until one can be provided
// nicely in a kext.
void (*voidret_fp)() = (void*)fakeEfiPages->voidret_instructions;
void (*unsupportedret_fp)() = (void*)fakeEfiPages->unsupportedret_instructions;
efiRuntimeServices->GetTime = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->SetTime = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->GetWakeupTime = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->SetWakeupTime = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->SetVirtualAddressMap = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->ConvertPointer = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->GetVariable = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->GetNextVariableName = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->SetVariable = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->GetNextHighMonotonicCount = (EFI_PTR32)unsupportedret_fp;
efiRuntimeServices->ResetSystem = (EFI_PTR32)voidret_fp;
// We're done.Now CRC32 the thing so the kernel will accept it
efiRuntimeServices->Hdr.CRC32 = crc32(0L, efiRuntimeServices, efiRuntimeServices->Hdr.HeaderSize);
// --------------------------------------------------------------------
// Finish filling in the rest of the boot args that we need.
bootArgs->efiSystemTable = (uint32_t)efiSystemTable;
bootArgs->efiMode = kBootArgsEfiMode32;
// The bootArgs structure as a whole is bzero'd so we don't need to fill in
// things like efiRuntimeServices* and what not.
//
// In fact, the only code that seems to use that is the hibernate code so it
// knows not to save the pages. It even checks to make sure its nonzero.
}
/* Zero out all the tables in case fields are added later */
bzero(fakeEfiPages, sizeof(struct fake_efi_pages));
/* --------------------------------------------------------------------
* Initialize some machine code that will return EFI_UNSUPPORTED for
* functions returning int and simply return for void functions.
*/
memcpy(fakeEfiPages->voidret_instructions, VOIDRET_INSTRUCTIONS, sizeof(VOIDRET_INSTRUCTIONS));
memcpy(fakeEfiPages->unsupportedret_instructions, UNSUPPORTEDRET_INSTRUCTIONS, sizeof(UNSUPPORTEDRET_INSTRUCTIONS));
/* -------------------------------------------------------------------- */
/* System table */
EFI_SYSTEM_TABLE_64 *efiSystemTable = gST = &fakeEfiPages->efiSystemTable;
efiSystemTable->Hdr.Signature = EFI_SYSTEM_TABLE_SIGNATURE;
efiSystemTable->Hdr.Revision = EFI_SYSTEM_TABLE_REVISION;
efiSystemTable->Hdr.HeaderSize = sizeof(EFI_SYSTEM_TABLE_64);
efiSystemTable->Hdr.CRC32 = 0; /* Initialize to zero and then do CRC32 */
efiSystemTable->Hdr.Reserved = 0;
efiSystemTable->FirmwareVendor = (EFI_PTR32)&fakeEfiPages->firmwareVendor;
memcpy(fakeEfiPages->firmwareVendor, FIRMWARE_VENDOR, sizeof(FIRMWARE_VENDOR));
efiSystemTable->FirmwareRevision = FIRMWARE_REVISION;
/* XXX: We may need to have basic implementations of ConIn/ConOut/StdErr */
/* The EFI spec states that all handles are invalid after boot services have been
* exited so we can probably get by with leaving the handles as zero. */
efiSystemTable->ConsoleInHandle = 0;
efiSystemTable->ConIn = 0;
efiSystemTable->ConsoleOutHandle = 0;
efiSystemTable->ConOut = 0;
efiSystemTable->StandardErrorHandle = 0;
efiSystemTable->StdErr = 0;
efiSystemTable->RuntimeServices = ptov64((EFI_PTR32)&fakeEfiPages->efiRuntimeServices);
/* According to the EFI spec, BootServices aren't valid after the
* boot process is exited so we can probably do without it.
* Apple didn't provide a definition for it in pexpert/i386/efi.h
* so I'm guessing they don't use it.
*/
efiSystemTable->BootServices = 0;
efiSystemTable->NumberOfTableEntries = 0;
efiSystemTable->ConfigurationTable = (EFI_PTR32)fakeEfiPages->efiConfigurationTable;
/* We're done. Now CRC32 the thing so the kernel will accept it */
fixupEfiSystemTableCRC32(efiSystemTable);
/* -------------------------------------------------------------------- */
/* Runtime services */
EFI_RUNTIME_SERVICES_64 *efiRuntimeServices = &fakeEfiPages->efiRuntimeServices;
efiRuntimeServices->Hdr.Signature = EFI_RUNTIME_SERVICES_SIGNATURE;
efiRuntimeServices->Hdr.Revision = EFI_RUNTIME_SERVICES_REVISION;
efiRuntimeServices->Hdr.HeaderSize = sizeof(EFI_RUNTIME_SERVICES_64);
efiRuntimeServices->Hdr.CRC32 = 0;
efiRuntimeServices->Hdr.Reserved = 0;
/* There are a number of function pointers in the efiRuntimeServices table.
* These are the Foundation (e.g. core) services and are expected to be present on
* all EFI-compliant machines. Some kernel extensions (notably AppleEFIRuntime)
* will call these without checking to see if they are null.
*
* We don't really feel like doing an EFI implementation in the bootloader
* but it is nice if we can at least prevent a complete crash by
* at least providing some sort of implementation until one can be provided
* nicely in a kext.
*/
void (*voidret_fp)() = (void*)fakeEfiPages->voidret_instructions;
void (*unsupportedret_fp)() = (void*)fakeEfiPages->unsupportedret_instructions;
efiRuntimeServices->GetTime = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->SetTime = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->GetWakeupTime = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->SetWakeupTime = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->SetVirtualAddressMap = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->ConvertPointer = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->GetVariable = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->GetNextVariableName = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->SetVariable = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->GetNextHighMonotonicCount = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->ResetSystem = ptov64((EFI_PTR32)voidret_fp);
/* We're done. Now CRC32 the thing so the kernel will accept it */
efiRuntimeServices->Hdr.CRC32 = crc32(0L, efiRuntimeServices, efiRuntimeServices->Hdr.HeaderSize);
/* -------------------------------------------------------------------- */
/* Finish filling in the rest of the boot args that we need. */
bootArgs->efiSystemTable = (uint32_t)efiSystemTable;
bootArgs->efiMode = kBootArgsEfiMode64;
/* The bootArgs structure as a whole is bzero'd so we don't need to fill in
* things like efiRuntimeServices* and what not.
*
* In fact, the only code that seems to use that is the hibernate code so it
* knows not to save the pages. It even checks to make sure its nonzero.
*/
void setupEfiTables64(void)
{
struct fake_efi_pages
{
EFI_SYSTEM_TABLE_64 efiSystemTable;
EFI_RUNTIME_SERVICES_64 efiRuntimeServices;
EFI_CONFIGURATION_TABLE_64 efiConfigurationTable[MAX_CONFIGURATION_TABLE_ENTRIES];
EFI_CHAR16 firmwareVendor[sizeof(FIRMWARE_VENDOR)/sizeof(EFI_CHAR16)];
uint8_t voidret_instructions[sizeof(VOIDRET_INSTRUCTIONS)/sizeof(uint8_t)];
uint8_t unsupportedret_instructions[sizeof(UNSUPPORTEDRET_INSTRUCTIONS)/sizeof(uint8_t)];
};
struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages*)AllocateKernelMemory(sizeof(struct fake_efi_pages));
// Zero out all the tables in case fields are added later
bzero(fakeEfiPages, sizeof(struct fake_efi_pages));
// --------------------------------------------------------------------
// Initialize some machine code that will return EFI_UNSUPPORTED for
// functions returning int and simply return for void functions.
memcpy(fakeEfiPages->voidret_instructions, VOIDRET_INSTRUCTIONS, sizeof(VOIDRET_INSTRUCTIONS));
memcpy(fakeEfiPages->unsupportedret_instructions, UNSUPPORTEDRET_INSTRUCTIONS, sizeof(UNSUPPORTEDRET_INSTRUCTIONS));
// --------------------------------------------------------------------
// System table
EFI_SYSTEM_TABLE_64 *efiSystemTable = gST64 = &fakeEfiPages->efiSystemTable;
efiSystemTable->Hdr.Signature = EFI_SYSTEM_TABLE_SIGNATURE;
efiSystemTable->Hdr.Revision = EFI_SYSTEM_TABLE_REVISION;
efiSystemTable->Hdr.HeaderSize = sizeof(EFI_SYSTEM_TABLE_64);
efiSystemTable->Hdr.CRC32 = 0; // Initialize to zero and then do CRC32
efiSystemTable->Hdr.Reserved = 0;
efiSystemTable->FirmwareVendor = ptov64((EFI_PTR32)&fakeEfiPages->firmwareVendor);
memcpy(fakeEfiPages->firmwareVendor, FIRMWARE_VENDOR, sizeof(FIRMWARE_VENDOR));
efiSystemTable->FirmwareRevision = FIRMWARE_REVISION;
// XXX: We may need to have basic implementations of ConIn/ConOut/StdErr
// The EFI spec states that all handles are invalid after boot services have been
// exited so we can probably get by with leaving the handles as zero.
efiSystemTable->ConsoleInHandle = 0;
efiSystemTable->ConIn = 0;
efiSystemTable->ConsoleOutHandle = 0;
efiSystemTable->ConOut = 0;
efiSystemTable->StandardErrorHandle = 0;
efiSystemTable->StdErr = 0;
efiSystemTable->RuntimeServices = ptov64((EFI_PTR32)&fakeEfiPages->efiRuntimeServices);
// According to the EFI spec, BootServices aren't valid after the
// boot process is exited so we can probably do without it.
// Apple didn't provide a definition for it in pexpert/i386/efi.h
// so I'm guessing they don't use it.
efiSystemTable->BootServices = 0;
efiSystemTable->NumberOfTableEntries = 0;
efiSystemTable->ConfigurationTable = ptov64((EFI_PTR32)fakeEfiPages->efiConfigurationTable);
// We're done.Now CRC32 the thing so the kernel will accept it
gST64->Hdr.CRC32 = crc32(0L, gST64, gST64->Hdr.HeaderSize);
// --------------------------------------------------------------------
// Runtime services
EFI_RUNTIME_SERVICES_64 *efiRuntimeServices = &fakeEfiPages->efiRuntimeServices;
efiRuntimeServices->Hdr.Signature = EFI_RUNTIME_SERVICES_SIGNATURE;
efiRuntimeServices->Hdr.Revision = EFI_RUNTIME_SERVICES_REVISION;
efiRuntimeServices->Hdr.HeaderSize = sizeof(EFI_RUNTIME_SERVICES_64);
efiRuntimeServices->Hdr.CRC32 = 0;
efiRuntimeServices->Hdr.Reserved = 0;
// There are a number of function pointers in the efiRuntimeServices table.
// These are the Foundation (e.g. core) services and are expected to be present on
// all EFI-compliant machines.Some kernel extensions (notably AppleEFIRuntime)
// will call these without checking to see if they are null.
//
// We don't really feel like doing an EFI implementation in the bootloader
// but it is nice if we can at least prevent a complete crash by
// at least providing some sort of implementation until one can be provided
// nicely in a kext.
void (*voidret_fp)() = (void*)fakeEfiPages->voidret_instructions;
void (*unsupportedret_fp)() = (void*)fakeEfiPages->unsupportedret_instructions;
efiRuntimeServices->GetTime = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->SetTime = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->GetWakeupTime = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->SetWakeupTime = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->SetVirtualAddressMap = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->ConvertPointer = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->GetVariable = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->GetNextVariableName = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->SetVariable = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->GetNextHighMonotonicCount = ptov64((EFI_PTR32)unsupportedret_fp);
efiRuntimeServices->ResetSystem = ptov64((EFI_PTR32)voidret_fp);
// We're done.Now CRC32 the thing so the kernel will accept it
efiRuntimeServices->Hdr.CRC32 = crc32(0L, efiRuntimeServices, efiRuntimeServices->Hdr.HeaderSize);
// --------------------------------------------------------------------
// Finish filling in the rest of the boot args that we need.
bootArgs->efiSystemTable = (uint32_t)efiSystemTable;
bootArgs->efiMode = kBootArgsEfiMode64;
// The bootArgs structure as a whole is bzero'd so we don't need to fill in
// things like efiRuntimeServices* and what not.
//
// In fact, the only code that seems to use that is the hibernate code so it
// knows not to save the pages. It even checks to make sure its nonzero.
}
/*
In addition to the EFI tables there is also the EFI device tree node.
In particular, we need /efi/platform to have an FSBFrequency key. Without it,
the tsc_init function will panic very early on in kernel startup, before
the console is available.
*/
* In addition to the EFI tables there is also the EFI device tree node.
* In particular, we need /efi/platform to have an FSBFrequency key. Without it,
* the tsc_init function will panic very early on in kernel startup, before
* the console is available.
*/
/*==========================================================================
* FSB Frequency detection
*/
/* From Foundation/Efi/Guid/Smbios/SmBios.c */
EFI_GUID const gEfiSmbiosTableGuid = EFI_SMBIOS_TABLE_GUID;
EFI_GUID constgEfiSmbiosTableGuid = EFI_SMBIOS_TABLE_GUID;
#define SMBIOS_RANGE_START 0x000F0000
#define SMBIOS_RANGE_END 0x000FFFFF
#define SMBIOS_RANGE_START0x000F0000
#define SMBIOS_RANGE_END0x000FFFFF
/* '_SM_' in little endian: */
#define SMBIOS_ANCHOR_UINT32_LE 0x5f4d535f
#define EFI_ACPI_TABLE_GUID \
{ \
0xeb9d2d30, 0x2d88, 0x11d3, { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
0xeb9d2d30, 0x2d88, 0x11d3, { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
}
#define EFI_ACPI_20_TABLE_GUID \
{ \
0x8868e871, 0xe4f1, 0x11d3, { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
0x8868e871, 0xe4f1, 0x11d3, { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
}
EFI_GUID gEfiAcpiTableGuid = EFI_ACPI_TABLE_GUID;
static const char const FIRMWARE_REVISION_PROP[] = "firmware-revision";
static const char const FIRMWARE_ABI_PROP[] = "firmware-abi";
static const char const FIRMWARE_VENDOR_PROP[] = "firmware-vendor";
static const char const FIRMWARE_ABI_PROP_VALUE[] = "EFI64";
static const char const FIRMWARE_ABI_32_PROP_VALUE[] = "EFI32";
static const char const FIRMWARE_ABI_64_PROP_VALUE[] = "EFI64";
static const char const SYSTEM_ID_PROP[] = "system-id";
static const char const SYSTEM_SERIAL_PROP[] = "SystemSerialNumber";
static const char const SYSTEM_TYPE_PROP[] = "system-type";
static const char const MODEL_PROP[] = "Model";
/* Get an smbios option string option to convert to EFI_CHAR16 string */
/*
* Get an smbios option string option to convert to EFI_CHAR16 string
*/
static EFI_CHAR16* getSmbiosChar16(const char * key, size_t* len)
{
const char * src= getStringForKey(key, &bootInfo->smbiosConfig);
EFI_CHAR16* dst = 0;
size_t i=0;
const char*src = getStringForKey(key, &bootInfo->smbiosConfig);
EFI_CHAR16* dst = 0;
size_t i = 0;
if (!key || !(*key) || !len || !src) return 0;
*len = strlen(src);
dst = (EFI_CHAR16*) malloc( ((*len)+1) * 2 );
for (; i < (*len); i++) dst[i] = src[i];
dst[(*len)] = '\0';
*len = ((*len)+1)*2; // return the CHAR16 bufsize in cluding zero terminated CHAR16
return dst;
}
if (!key || !(*key) || !len || !src) return 0;
/*
* Get the SystemID from the bios dmi info
*/
*len = strlen(src);
dst = (EFI_CHAR16*) malloc( ((*len)+1) * 2 );
for (; i < (*len); i++) dst[i] = src[i];
dst[(*len)] = '\0';
*len = ((*len)+1)*2; // return the CHAR16 bufsize in cluding zero terminated CHAR16
return dst;
}
/* Get the SystemID from the bios dmi info */
static EFI_CHAR8* getSmbiosUUID()
staticEFI_CHAR8* getSmbiosUUID()
{
SMBByte*p;
inti, isZero, isOnes;
static EFI_CHAR8uuid[UUID_LEN];
static EFI_CHAR8 uuid[UUID_LEN];
int i, isZero, isOnes;
SMBByte*p;
p = (SMBByte*)Platform.UUID;
if (p==NULL) return NULL;
for (i=0, isZero=1, isOnes=1; i<UUID_LEN; i++) {
for (i=0, isZero=1, isOnes=1; i<UUID_LEN; i++)
{
if (p[i] != 0x00) isZero = 0;
if (p[i] != 0xff) isOnes = 0;
}
if (isZero || isOnes) {/* empty or setable means: no uuid present */
if (isZero || isOnes) // empty or setable means: no uuid present
{
verbose("No UUID present in SMBIOS System Information Table\n");
return 0;
}
memcpy(uuid, p, UUID_LEN);
return uuid;
}
/* return a binary UUID value from the overriden SystemID and SMUUID if found,
/*
* return a binary UUID value from the overriden SystemID and SMUUID if found,
* or from the bios if not, or from a fixed value if no bios value is found
*/
static EFI_CHAR8* getSystemID()
{ // unable to determine UUID for host. Error: 35 fix
{
// unable to determine UUID for host. Error: 35 fix
// Rek: new SMsystemid option conforming to smbios notation standards, this option should
// belong to smbios config only ...
const char *sysId = getStringForKey(kSystemID, &bootInfo->bootConfig);
EFI_CHAR8*ret = getUUIDFromString(sysId);
// Rek: new SMsystemid option conforming to smbios notation standards, this option should
// belong to smbios config only ...
const char * sysId = getStringForKey(kSystemID, &bootInfo->bootConfig);
EFI_CHAR8* ret = getUUIDFromString(sysId);
if (!sysId || !ret) // try bios dmi info UUID extraction
{
ret = getSmbiosUUID();
sysId = 0;
}
if (!ret) // no bios dmi UUID available, set a fixed value for system-id
ret=getUUIDFromString((sysId = (const char*) SYSTEM_ID));
verbose("Customizing SystemID with : %s\n", getStringFromUUID(ret)); // apply a nice formatting to the displayed output
return ret;
}
if(!sysId || !ret) { // try bios dmi info UUID extraction
ret = getSmbiosUUID();
sysId = 0;
}
if(!ret) // no bios dmi UUID available, set a fixed value for system-id
ret=getUUIDFromString((sysId = (const char*) SYSTEM_ID));
/*
* Must be called AFTER setup Acpi because we need to take care of correct
* facp content to reflect in ioregs
*/
verbose("Customizing SystemID with : %s\n", getStringFromUUID(ret)); // apply a nice formatting to the displayed output
return ret;
}
// must be called AFTER setup Acpi 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");
// we need to write this property after facp parsing
/* Export system-type only if it has been overrriden by the SystemType option */
DT__AddProperty(node, SYSTEM_TYPE_PROP, sizeof(Platform.Type), &Platform.Type);
Node *node = DT__FindNode("/", false);
if (node == 0) 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
DT__AddProperty(node, SYSTEM_TYPE_PROP, sizeof(Platform.Type), &Platform.Type);
}
void setupEfiDeviceTree(void)
{
EFI_CHAR16* ret16=0;
EFI_CHAR8* ret=0;
size_t len=0;
Node *node;
EFI_CHAR8* ret = 0;
EFI_CHAR16* ret16 = 0;
size_t len = 0;
Node*node;
node = DT__FindNode("/", false);
if (node == 0) stop("Couldn't get root node");
// We could also just do DT__FindNode("/efi/platform", true)
// But I think eventually we want to fill stuff in the efi node
// too so we might as well create it so we have a pointer for it too.
node = DT__AddChild(node, "efi");
if (archCpuType == CPU_TYPE_I386)
{
DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_32_PROP_VALUE), (char*)FIRMWARE_ABI_32_PROP_VALUE);
}
else
{
DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_64_PROP_VALUE), (char*)FIRMWARE_ABI_64_PROP_VALUE);
}
DT__AddProperty(node, FIRMWARE_REVISION_PROP, sizeof(FIRMWARE_REVISION), (EFI_UINT32*)&FIRMWARE_REVISION);
DT__AddProperty(node, FIRMWARE_VENDOR_PROP, sizeof(FIRMWARE_VENDOR), (EFI_CHAR16*)FIRMWARE_VENDOR);
// TODO: Fill in other efi properties if necessary
// Set up the /efi/runtime-services table node similar to the way a child node of configuration-table
// is set up. That is, name and table properties
Node *runtimeServicesNode = DT__AddChild(node, "runtime-services");
if (archCpuType == CPU_TYPE_I386)
{
// The value of the table property is the 32-bit physical address for the RuntimeServices table.
// Since the EFI system table already has a pointer to it, we simply use the address of that pointer
// for the pointer to the property data. Warning.. DT finalization calls free on that but we're not
// the only thing to use a non-malloc'd pointer for something in the DT
DT__AddProperty(runtimeServicesNode, "table", sizeof(uint64_t), &gST32->RuntimeServices);
}
else
{
DT__AddProperty(runtimeServicesNode, "table", sizeof(uint64_t), &gST64->RuntimeServices);
}
node = DT__FindNode("/", false);
if (node == 0) stop("Couldn't get root node");
/* We could also just do DT__FindNode("/efi/platform", true)
* But I think eventually we want to fill stuff in the efi node
* too so we might as well create it so we have a pointer for it too.
*/
node = DT__AddChild(node, "efi");
// Set up the /efi/configuration-table node which will eventually have several child nodes for
// all of the configuration tables needed by various kernel extensions.
gEfiConfigurationTableNode = DT__AddChild(node, "configuration-table");
// Now fill in the /efi/platform Node
Node *efiPlatformNode = DT__AddChild(node, "platform");
// NOTE WELL: If you do add FSB Frequency detection, make sure to store
// the value in the fsbFrequency global and not an malloc'd pointer
// because the DT_AddProperty function does not copy its args.
if (Platform.CPU.FSBFrequency != 0)
DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &Platform.CPU.FSBFrequency);
// Export TSC and CPU frequencies for use by the kernel or KEXTs
if (Platform.CPU.TSCFrequency != 0)
DT__AddProperty(efiPlatformNode, TSC_Frequency_prop, sizeof(uint64_t), &Platform.CPU.TSCFrequency);
if (Platform.CPU.CPUFrequency != 0)
DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform.CPU.CPUFrequency);
// Export system-id. Can be disabled with SystemId=No in com.apple.Boot.plist
if ((ret=getSystemID()))
DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32*) ret);
DT__AddProperty(node, FIRMWARE_REVISION_PROP, sizeof(FIRMWARE_REVISION), (EFI_UINT32*)&FIRMWARE_REVISION);
DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_PROP_VALUE), (char*)FIRMWARE_ABI_PROP_VALUE);
DT__AddProperty(node, FIRMWARE_VENDOR_PROP, sizeof(FIRMWARE_VENDOR), (EFI_CHAR16*)FIRMWARE_VENDOR);
// Export SystemSerialNumber if present
if ((ret16=getSmbiosChar16("SMserial", &len)))
DT__AddProperty(efiPlatformNode, SYSTEM_SERIAL_PROP, len, ret16);
// Export Model if present
if ((ret16=getSmbiosChar16("SMproductname", &len)))
DT__AddProperty(efiPlatformNode, MODEL_PROP, len, ret16);
// Fill /efi/device-properties node.
setupDeviceProperties(node);
}
/* TODO: Fill in other efi properties if necessary */
/*
* Load the smbios.plist override config file if any
*/
/* Set up the /efi/runtime-services table node similar to the way a child node of configuration-table
* is set up. That is, name and table properties */
Node *runtimeServicesNode = DT__AddChild(node, "runtime-services");
static void setupSmbiosConfigFile(const char *filename)
{
chardirSpecSMBIOS[128] = "";
const char *override_pathname = NULL;
intlen = 0, err = 0;
extern void scan_mem();
// Take in account user overriding
if (getValueForKey(kSMBIOSKey, &override_pathname, &len, &bootInfo->bootConfig) && len > 0)
{
// Specify a path to a file, e.g. SMBIOS=/Extra/macProXY.plist
sprintf(dirSpecSMBIOS, override_pathname);
err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig);
}
else
{
// Check selected volume's Extra.
sprintf(dirSpecSMBIOS, "/Extra/%s", filename);
if (err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig))
{
// Check booter volume/rdbt Extra.
sprintf(dirSpecSMBIOS, "bt(0,0)/Extra/%s", filename);
err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig);
}
}
/* The value of the table property is the 32-bit physical address for the RuntimeServices table.
* Since the EFI system table already has a pointer to it, we simply use the address of that pointer
* for the pointer to the property data. Warning.. DT finalization calls free on that but we're not
* the only thing to use a non-malloc'd pointer for something in the DT
*/
DT__AddProperty(runtimeServicesNode, "table", sizeof(uint64_t), &gST->RuntimeServices);
if (err)
{
verbose("No SMBIOS replacement found.\n");
}
/* Set up the /efi/configuration-table node which will eventually have several child nodes for
* all of the configuration tables needed by various kernel extensions.
*/
gEfiConfigurationTableNode = DT__AddChild(node, "configuration-table");
// get a chance to scan mem dynamically if user asks for it while having the config options loaded as well,
// as opposed to when it was in scan_platform(); also load the orig. smbios so that we can access dmi info without
// patching the smbios yet
/* Now fill in the /efi/platform Node */
Node *efiPlatformNode = DT__AddChild(node, "platform");
/* NOTE WELL: If you do add FSB Frequency detection, make sure to store
* the value in the fsbFrequency global and not an malloc'd pointer
* because the DT_AddProperty function does not copy its args.
*/
if(Platform.CPU.FSBFrequency != 0)
DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &Platform.CPU.FSBFrequency);
/* Export TSC and CPU frequencies for use by the kernel or KEXTs */
if(Platform.CPU.TSCFrequency != 0)
DT__AddProperty(efiPlatformNode, TSC_Frequency_prop, sizeof(uint64_t), &Platform.CPU.TSCFrequency);
if(Platform.CPU.CPUFrequency != 0)
DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform.CPU.CPUFrequency);
/* Export system-id. Can be disabled with system-id=No in com.apple.Boot.plist */
if((ret=getSystemID()))
DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32*) ret);
/* Export SystemSerialNumber if present */
if ((ret16=getSmbiosChar16("SMserial", &len)))
DT__AddProperty(efiPlatformNode, SYSTEM_SERIAL_PROP, len, ret16);
/* Export Model if present */
if ((ret16=getSmbiosChar16("SMproductname", &len)))
DT__AddProperty(efiPlatformNode, MODEL_PROP, len, ret16);
/* Fill /efi/device-properties node.
*/
setupDeviceProperties(node);
scan_mem();
}
/* Load the smbios.plist override config file if any */
static void setupSmbiosConfigFile()
{
const char * value = getStringForKey(kSMBIOS, &bootInfo->bootConfig);
extern void scan_mem();
/*
* Installs all the needed configuration table entries
*/
if (!value) value = "/Extra/smbios.plist";
if (loadConfigFile(value, &bootInfo->smbiosConfig) == -1) {
verbose("No SMBIOS replacement found\n");
}
// get a chance to scan mem dynamically if user asks for it while having the config options loaded as well
// as opposed to when it was in scan_platform(), also load the orig. smbios so that we can access dmi info without
// patching the smbios yet
scan_mem();
}
/* Installs all the needed configuration table entries */
static void setupEfiConfigurationTable()
{
smbios_p = (EFI_PTR32)getSmbios(SMBIOS_PATCHED);
addConfigurationTable(&gEfiSmbiosTableGuid, &smbios_p, NULL);
// Setup ACPI with DSDT overrides (mackerintel's patch)
setupAcpi();
// We've obviously changed the count.. so fix up the CRC32
fixupEfiSystemTableCRC32(gST);
if (archCpuType == CPU_TYPE_I386)
{
gST32->Hdr.CRC32 = 0;
gST32->Hdr.CRC32 = crc32(0L, gST32, gST32->Hdr.HeaderSize);
}
else
{
gST64->Hdr.CRC32 = 0;
gST64->Hdr.CRC32 = crc32(0L, gST64, gST64->Hdr.HeaderSize);
}
}
/*
* Entrypoint from boot.c
*/
/* Entrypoint from boot.c */
void setupFakeEfi(void)
{
// Generate efi device strings
setup_pci_devs(root_pci_dev);
readSMBIOSInfo(getSmbios(SMBIOS_ORIGINAL));
readSMBIOSInfo(getSmbios(SMBIOS_ORIGINAL));
// load smbios.plist file if any
setupSmbiosConfigFile();
setupSmbiosConfigFile("smbios.plist");
setupSMBIOSTable();
// Initialize the base table
setupEfiTables();
if (archCpuType == CPU_TYPE_I386)
{
setupEfiTables32();
}
else
{
setupEfiTables64();
}
// Initialize the device tree
setupEfiDeviceTree();
// Add configuration table entries to both the services table and the device tree
setupEfiConfigurationTable();
}
branches/Kabyl/i386/boot2/boot.c
8181
8282
8383
84
8485
85
8686
8787
8888
......
347347
348348
349349
350
351
352350
353351
354352
......
397395
398396
399397
400
401
402
403
404
405
406
407
398
408399
409400
410401
......
608599
609600
610601
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
611634
612635
613636
//static void selectBiosDevice(void);
static unsigned long Adler32(unsigned char *buffer, long length);
static bool getOSVersion(char *str);
static bool gUnloadPXEOnExit = false;
/*
bool tryresumedefault;
bool forceresume;
config_file_t systemVersion;// system.plist of booting partition
// additional variable for testing alternate kernel image locations on boot helper partitions.
char bootFileSpec[512];
}
// Find out which version mac os we're booting.
if (!loadConfigFile("System/Library/CoreServices/SystemVersion.plist", &systemVersion)) {
if (getValueForKey(kProductVersion, &val, &len, &systemVersion)) {
// getValueForKey uses const char for val
// so copy it and trim
strncpy(gMacOSVersion, val, MIN(len, 4));
gMacOSVersion[MIN(len, 4)] = '\0';
}
}
getOSVersion(gMacOSVersion);
if (platformCPUFeature(CPU_FEATURE_EM64T)) {
archCpuType = CPU_TYPE_X86_64;
}
*/
static bool getOSVersion(char *str)
{
bool valid = false;
config_file_t systemVersion;
const char *val;
int len;
if (!loadConfigFile("System/Library/CoreServices/SystemVersion.plist", &systemVersion))
{
valid = true;
}
else if (!loadConfigFile("System/Library/CoreServices/ServerVersion.plist", &systemVersion))
{
valid = true;
}
if (valid)
{
if (getValueForKey(kProductVersion, &val, &len, &systemVersion))
{
// getValueForKey uses const char for val
// so copy it and trim
*str = '\0';
strncat(str, val, MIN(len, 4));
}
else
valid = false;
}
return valid;
}
#define BASE 65521L /* largest prime smaller than 65536 */
#define NMAX 5000
// NMAX (was 5521) the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
branches/Kabyl/i386/boot2/boot.h
7575
7676
7777
78
78
7979
8080
8181
#define kDeviceProperties"device-properties"/* device_inject.c */
#define kHidePartition"Hide Partition"/* disk.c */
#define kRenamePartition"Rename Partition"/* disk.c */
#define kSMBIOS"SMBIOS"/* fake_efi.c */
#define kSMBIOSKey"SMBIOS"/* fake_efi.c */
#define kSystemID"SystemId"/* fake_efi.c */
#define kSystemType"SystemType"/* fake_efi.c */
#define kUseNvidiaROM"UseNvidiaROM"/* nvidia.c */
branches/Kabyl/i386/boot2/options.c
111111
112112
113113
114
114
115115
116116
117117
......
770770
771771
772772
773
774
773
774
775775
776776
777777
778778
779
780
781
779
780
782781
783782
784
783
785784
786785
787786
788
789787
790788
791789
792790
793
794
795791
796792
797793
......
806802
807803
808804
809
805
810806
811807
812808
......
858854
859855
860856
861
857
862858
863859
864860
position_t p = pos( gui.screen.width / 2 + 1 , ( gui.devicelist.pos.y + 3 ) + ( ( gui.devicelist.height - gui.devicelist.iconspacing ) / 2 ) );
char dummy[80];
getBootVolumeDescription( gBootVolume, dummy, 80, true );
getBootVolumeDescription( gBootVolume, dummy, sizeof(dummy) - 1, true );
drawDeviceIcon( gBootVolume, gui.screen.pixmap, p, true );
drawStrCenteredAt( (char *) msg, &font_small, gui.screen.pixmap, gui.countdown.pos );
// When booting from CD, default to hard drive boot when possible.
if (isCDROM && firstRun) {
const char *val;
char *prompt;
char *name;
char *prompt = NULL;
char *name = NULL;
int cnt;
int optionKey;
if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig)) {
cnt += 1;
prompt = malloc(cnt);
strlcpy(prompt, val, cnt);
prompt = malloc(cnt + 1);
strncat(prompt, val, cnt);
} else {
name = malloc(80);
getBootVolumeDescription(gBootVolume, name, 80, false);
getBootVolumeDescription(gBootVolume, name, 79, false);
prompt = malloc(256);
sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name);
free(name);
cnt = 0;
}
if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig )) {
// The key specified is a special key.
} else if (getValueForKey( kCDROMOptionKey, &val, &cnt, &bootInfo->bootConfig ) && cnt >= 1) {
optionKey = val[0];
} else {
// Default to F8.
optionKey = 0x4200;
key = optionKey;
}
if (cnt) {
if (prompt != NULL) {
free(prompt);
}
// Associate a menu item for each BVRef.
for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next) {
if (bvr->visible) {
getBootVolumeDescription(bvr, menuItems[i].name, 80, true);
getBootVolumeDescription(bvr, menuItems[i].name, sizeof(menuItems[i].name) - 1, true);
menuItems[i].param = (void *) bvr;
if (bvr == menuBVR) {
selectIndex = i;
branches/Kabyl/package/Resources/Portuguese.lproj/Description.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Lucida Grande;}
</style>
</head>
<body>
<p class="p1">O Chameleon é um boot loader que combina vários componentes.<br />Ele é baseado na implementação de fake EFI feita por David Elliott, adicionada ao projeto boot-132 da Apple.<br />O Chameleon é extendido com as seguintes características chave:</p>
<br />
<p class="p1">Novos recursos no Chameleon 2.0</p>
<br>
<p class="p1"> - Interface gráfica (GUI) totalmente personalizável para trazer algumas cores ao Bootloader Darwin.</p>
<p class="p1"> - Inicializa DVDs retail lendo uma imagem ramdisk diretamente, sem ajuda de nenhum programa adicional.</p>
<p class="p1"> - Hibernação. Aproveite continuar o seu Mac OS X com uma amostra de imagem da tela.</p>
<p class="p1"> - Substituição de SMBIOS para modificar os valores de fábrica.</p>
<p class="p1"> - Substituição de DSDT para usar uma tabela modificada que pode resolver diversos problemas.</p>
<br>
<p class="p1"> - Injeção de propriedades de dispositivo através do string device-properties.</p>
<p class="p1"> - boot0 / boot1h híbridos para discos particionados em MBR e GPT.</p>
<p class="p1"> - Detecção automática de FSB mesmo para processadores AMD recentes.</p>
<p class="p1"> - Suporte a Software RAID da Apple.</p>
<br />
<p class="p1">Para informações detalhadas visite: <a href="http://chameleon.osx86.hu">http://chameleon.osx86.hu</a></p>
</body>
</html>
branches/Kabyl/package/Resources/Portuguese.lproj/Welcome.rtfd/TXT.rtf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
{\colortbl;\red255\green255\blue255;\red65\green78\blue255;}
\margl1440\margr1440\vieww11660\viewh12980\viewkind0
\pard\ri0\qc
\f0\b\fs72 \cf0 Chameleon
\fs50 \
\fs26 v%CHAMELEONVERSION% r%CHAMELEONREVISION%
\fs50 \
\
\cf2 %CHAMELEONSTAGE%
\fs26 \cf0 \
\
\pard\ri0\ql\qnatural
\cf0 Desenvolvedores: Crazor, Dense, fassl, fxtentacle, iNDi, JrCs, Kabyl, kaitek, mackerintel, mercurysquad, mozodojo, munky, rekursor, Turbo & zef \
\
\
Agradecimentos a: asereBLN, bumby, cosmolt, dfe, Galaxy, kalyway, Krazubu, netkas, sckevyn, smith@@, THeKiNG, XyZ, blackosx\
\pard\tx360\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\b0\fs30 \cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\fs26 \cf0 Copyright \'a9 2010}
branches/Kabyl/package/Resources/Portuguese.lproj/Conclusion.rtfd/TXT.rtf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
{\colortbl;\red255\green255\blue255;\red65\green78\blue255;\red255\green0\blue0;}
\margl1440\margr1440\vieww11660\viewh12980\viewkind0
\pard\ri0\qc
\f0\b\fs72 \cf0 Chameleon
\fs50 \
\fs26 v%CHAMELEONVERSION% r%CHAMELEONREVISION%
\fs50 \
\
\cf2 %CHAMELEONSTAGE%\cf0 \
\pard\ri0\ql\qnatural
\fs26 \cf0 \
\pard\ri0\qc
\fs50 \cf3 Instala\'e7\'e3o Conclu\'edda!
\b0\fs26 \cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\fs18 \cf0 \
{\field{\*\fldinst{HYPERLINK "http://chameleon.osx86.hu/"}}{\fldrslt
\fs26 http://chameleon.osx86.hu/}}
\fs26 \
{\field{\*\fldinst{HYPERLINK "http://forum.voodooprojects.org/index.php"}}{\fldrslt http://forum.voodooprojects.org/index.php}}
\b \
\pard\tx360\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\b0\fs30 \cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\fs26 \cf0 Copyright \'a9 2010}
branches/Kabyl/package/Resources/Portuguese.lproj/License.rtf
1
2
3
4
5
6
7
8
9
10
11
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
{\colortbl;\red255\green255\blue255;}
\vieww22060\viewh18360\viewkind0
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f0\b\fs20 \cf0 PORTUGUESE\
\b0 \
EA0401\
Rev. 4/1/09}

Archive Download the corresponding diff file

Revision: 485