Chameleon

Chameleon Commit Details

Date:2010-08-02 01:03:02 (13 years 7 months ago)
Author:Azimutz
Commit:299
Parents: 298
Message:EFI32/64 patch. Fixes issue 21. Just switching between pre RC3 EFI32 code and the actual EFI64 one, according to selected kernel architecture.
Changes:
M/branches/azimutz/CleanCut/i386/libsaio/fake_efi.c

File differences

branches/azimutz/CleanCut/i386/libsaio/fake_efi.c
8989
9090
9191
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
92
93
11294
11395
11496
11597
116
98
99
100
101
102
103
104
105
106
107
108
109
110
117111
118112
119113
......
146140
147141
148142
149
143
144
150145
151146
152147
153
148
154149
155150
156151
......
159154
160155
161156
162
163
157
164158
165
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
272
166273
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
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
380
265381
266382
267383
......
315431
316432
317433
318
434
435
319436
320437
321438
......
418535
419536
420537
538
539
540
541
542
543
544
545
546
421547
422
423548
424549
425550
......
428553
429554
430555
431
432
433
434
435
436
556
557
558
559
560
561
562
563
564
565
566
567
568
437569
438570
439571
......
496628
497629
498630
499
500
501
502
503
504
505
506
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
507648
508649
509650
......
512653
513654
514655
515
656
516657
517658
518659
519660
520
661
662
663
664
665
666
667
668
521669
522670
523671
/* 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;
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");
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);
}
}*/
/*
What we do here is simply allocate a fake EFI system table and a fake EFI
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.
}
/*
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";
*/
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_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);
/* TODO: Fill in other efi properties if necessary */
* is set up. That is, name and table properties */
Node *runtimeServicesNode = DT__AddChild(node, "runtime-services");
/* 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 (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);
}
/* 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.
/* 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);
smbios_p = (EFI_PTR32)getSmbios(SMBIOS_PATCHED);
addConfigurationTable(&gEfiSmbiosTableGuid, &smbios_p, "SMBIOS_P"); //Azi: give an "alias" to this stuff?
// Setup ACPI with DSDT overrides (mackerintel's patch)
setupAcpi();
// We've obviously changed the count.. so fix up the CRC32
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);
}
}
{
// Generate efi device strings
setup_pci_devs(root_pci_dev);
// load smbios.plist file if any
setupSmbiosConfigFile();
// Initialize the base table
setupEfiTables();
if (archCpuType == CPU_TYPE_I386)
{
setupEfiTables32();
}
else
{
setupEfiTables64();
}
// Initialize the device tree
setupEfiDeviceTree();

Archive Download the corresponding diff file

Revision: 299