1 | ␊ |
2 | /*␊ |
3 | * Copyright 2007 David F. Elliott.␉ All rights reserved.␊ |
4 | */␊ |
5 | ␊ |
6 | #include "saio_types.h"␊ |
7 | #include "libsaio.h"␊ |
8 | #include "boot.h"␊ |
9 | #include "bootstruct.h"␊ |
10 | #include "efi.h"␊ |
11 | #include "acpi.h"␊ |
12 | #include "fake_efi.h"␊ |
13 | #include "efi_tables.h"␊ |
14 | #include "platform.h"␊ |
15 | #include "acpi_patcher.h"␊ |
16 | #include "smbios.h"␊ |
17 | #include "device_inject.h"␊ |
18 | #include "convert.h"␊ |
19 | #include "pci.h"␊ |
20 | #include "sl.h"␊ |
21 | ␊ |
22 | extern void setup_pci_devs(pci_dt_t *pci_dt);␊ |
23 | ␊ |
24 | /*␊ |
25 | * Modern Darwin kernels require some amount of EFI because Apple machines all␊ |
26 | * have EFI. Modifying the kernel source to not require EFI is of course␊ |
27 | * possible but would have to be maintained as a separate patch because it is␊ |
28 | * unlikely that Apple wishes to add legacy support to their kernel.␊ |
29 | *␊ |
30 | * As you can see from the Apple-supplied code in bootstruct.c, it seems that␊ |
31 | * the intention was clearly to modify this booter to provide EFI-like structures␊ |
32 | * to the kernel rather than modifying the kernel to handle non-EFI stuff. This␊ |
33 | * makes a lot of sense from an engineering point of view as it means the kernel␊ |
34 | * for the as yet unreleased EFI-only Macs could still be booted by the non-EFI␊ |
35 | * DTK systems so long as the kernel checked to ensure the boot tables were␊ |
36 | * filled in appropriately.␉Modern xnu requires a system table and a runtime␊ |
37 | * services table and performs no checks whatsoever to ensure the pointers to␊ |
38 | * these tables are non-NULL. Therefore, any modern xnu kernel will page fault␊ |
39 | * early on in the boot process if the system table pointer is zero.␊ |
40 | *␊ |
41 | * Even before that happens, the tsc_init function in modern xnu requires the FSB␊ |
42 | * Frequency to be a property in the /efi/platform node of the device tree or else␊ |
43 | * it panics the bootstrap process very early on.␊ |
44 | *␊ |
45 | * As of this writing, the current implementation found here is good enough␊ |
46 | * to make the currently available xnu kernel boot without modification on a␊ |
47 | * system with an appropriate processor. With a minor source modification to␊ |
48 | * the tsc_init function to remove the explicit check for Core or Core 2␊ |
49 | * processors the kernel can be made to boot on other processors so long as␊ |
50 | * the code can be executed by the processor and the machine contains the␊ |
51 | * necessary hardware.␊ |
52 | */␊ |
53 | ␊ |
54 | /*==========================================================================␊ |
55 | * Utility function to make a device tree string from an EFI_GUID␊ |
56 | */␊ |
57 | static inline char * mallocStringForGuid(EFI_GUID const *pGuid)␊ |
58 | {␊ |
59 | ␉char *string = malloc(37);␊ |
60 | ␉efi_guid_unparse_upper(pGuid, string);␊ |
61 | ␉return string;␊ |
62 | }␊ |
63 | ␊ |
64 | /*==========================================================================␊ |
65 | * Function to map 32 bit physical address to 64 bit virtual address␊ |
66 | */␊ |
67 | static uint64_t ptov64(uint32_t addr)␊ |
68 | {␊ |
69 | ␉return ((uint64_t)addr | 0xFFFFFF8000000000ULL);␊ |
70 | }␊ |
71 | ␊ |
72 | /*==========================================================================␊ |
73 | * Fake EFI implementation␊ |
74 | */␊ |
75 | ␊ |
76 | /* Identify ourselves as the EFI firmware vendor */␊ |
77 | static EFI_CHAR16 const FIRMWARE_VENDOR[] = {'C','h','a','m','e','l','e','o','n','_','2','.','1', 0};␊ |
78 | static EFI_UINT32 const FIRMWARE_REVISION = 132; /* FIXME: Find a constant for this. */␊ |
79 | ␊ |
80 | /* Default platform system_id (fix by IntVar) */␊ |
81 | static EFI_CHAR8 const SYSTEM_ID[] = "0123456789ABCDEF"; //random value gen by uuidgen␊ |
82 | ␊ |
83 | /* Just a ret instruction */␊ |
84 | static uint8_t const VOIDRET_INSTRUCTIONS[] = {0xc3};␊ |
85 | ␊ |
86 | /* movl $0x80000003,%eax; ret */␊ |
87 | static uint8_t const UNSUPPORTEDRET_INSTRUCTIONS[] = {0x48, 0xb8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc3};␊ |
88 | ␊ |
89 | EFI_SYSTEM_TABLE_32 *gST32 = NULL;␊ |
90 | EFI_SYSTEM_TABLE_64 *gST64 = NULL;␊ |
91 | Node *gEfiConfigurationTableNode = NULL;␊ |
92 | ␊ |
93 | extern EFI_STATUS addConfigurationTable(EFI_GUID const *pGuid, void *table, char const *alias)␊ |
94 | {␊ |
95 | ␉EFI_UINTN i = 0;␊ |
96 | ␉␊ |
97 | ␉//Azi: as is, cpu's with em64t will use EFI64 on pre 10.6 systems,␊ |
98 | ␉// wich seems to cause no problem. In case it does, force i386 arch.␊ |
99 | ␉if (archCpuType == CPU_TYPE_I386)␊ |
100 | ␉{␊ |
101 | ␉␉i = gST32->NumberOfTableEntries;␊ |
102 | ␉}␊ |
103 | ␉else␊ |
104 | ␉{␊ |
105 | ␉␉i = gST64->NumberOfTableEntries;␊ |
106 | ␉}␊ |
107 | ␉␊ |
108 | ␉// We only do adds, not modifications and deletes like InstallConfigurationTable␊ |
109 | ␉if (i >= MAX_CONFIGURATION_TABLE_ENTRIES)␊ |
110 | ␉␉stop("Ran out of space for configuration tables. Increase the reserved size in the code.\n");␊ |
111 | ␉␊ |
112 | ␉if (pGuid == NULL)␊ |
113 | ␉␉return EFI_INVALID_PARAMETER;␊ |
114 | ␉␊ |
115 | ␉if (table != NULL)␊ |
116 | ␉{␊ |
117 | ␉␉// FIXME␊ |
118 | ␉␉//((EFI_CONFIGURATION_TABLE_64 *)gST->ConfigurationTable)[i].VendorGuid = *pGuid;␊ |
119 | ␉␉//((EFI_CONFIGURATION_TABLE_64 *)gST->ConfigurationTable)[i].VendorTable = (EFI_PTR64)table;␊ |
120 | ␉␉␊ |
121 | ␉␉//++gST->NumberOfTableEntries;␊ |
122 | ␉␉␊ |
123 | ␉␉Node *tableNode = DT__AddChild(gEfiConfigurationTableNode, mallocStringForGuid(pGuid));␊ |
124 | ␉␉␊ |
125 | ␉␉// Use the pointer to the GUID we just stuffed into the system table␊ |
126 | ␉␉DT__AddProperty(tableNode, "guid", sizeof(EFI_GUID), (void*)pGuid);␊ |
127 | ␉␉␊ |
128 | ␉␉// The "table" property is the 32-bit (in our implementation) physical address of the table␊ |
129 | ␉␉DT__AddProperty(tableNode, "table", sizeof(void*) * 2, table);␊ |
130 | ␉␉␊ |
131 | ␉␉// Assume the alias pointer is a global or static piece of data␊ |
132 | ␉␉if (alias != NULL)␊ |
133 | ␉␉␉DT__AddProperty(tableNode, "alias", strlen(alias)+1, (char*)alias);␊ |
134 | ␉␉␊ |
135 | ␉␉return EFI_SUCCESS;␊ |
136 | ␉}␊ |
137 | ␉return EFI_UNSUPPORTED;␊ |
138 | }␊ |
139 | ␊ |
140 | //Azi: crc32 done in place, on the cases were it wasn't.␊ |
141 | /*static inline void fixupEfiSystemTableCRC32(EFI_SYSTEM_TABLE_64 *efiSystemTable)␊ |
142 | {␊ |
143 | ␉efiSystemTable->Hdr.CRC32 = 0;␊ |
144 | ␉efiSystemTable->Hdr.CRC32 = crc32(0L, efiSystemTable, efiSystemTable->Hdr.HeaderSize);␊ |
145 | }*/␊ |
146 | ␊ |
147 | /*␊ |
148 | * What we do here is simply allocate a fake EFI system table and a fake EFI␊ |
149 | * runtime services table.␊ |
150 | *␊ |
151 | * Because we build against modern headers with kBootArgsRevision 4 we␊ |
152 | * also take care to set efiMode = 32.␊ |
153 | */␊ |
154 | void setupEfiTables32(void)␊ |
155 | {␊ |
156 | ␉// We use the fake_efi_pages struct so that we only need to do one kernel␊ |
157 | ␉// memory allocation for all needed EFI data. Otherwise, small allocations␊ |
158 | ␉// like the FIRMWARE_VENDOR string would take up an entire page.␊ |
159 | ␉// NOTE WELL: Do NOT assume this struct has any particular layout within itself.␊ |
160 | ␉// It is absolutely not intended to be publicly exposed anywhere␊ |
161 | ␉// We say pages (plural) although right now we are well within the 1 page size␊ |
162 | ␉// and probably will stay that way.␊ |
163 | ␉struct fake_efi_pages␊ |
164 | ␉{␊ |
165 | ␉␉EFI_SYSTEM_TABLE_32 efiSystemTable;␊ |
166 | ␉␉EFI_RUNTIME_SERVICES_32 efiRuntimeServices;␊ |
167 | ␉␉EFI_CONFIGURATION_TABLE_32 efiConfigurationTable[MAX_CONFIGURATION_TABLE_ENTRIES];␊ |
168 | ␉␉EFI_CHAR16 firmwareVendor[sizeof(FIRMWARE_VENDOR)/sizeof(EFI_CHAR16)];␊ |
169 | ␉␉uint8_t voidret_instructions[sizeof(VOIDRET_INSTRUCTIONS)/sizeof(uint8_t)];␊ |
170 | ␉␉uint8_t unsupportedret_instructions[sizeof(UNSUPPORTEDRET_INSTRUCTIONS)/sizeof(uint8_t)];␊ |
171 | ␉};␊ |
172 | ␉␊ |
173 | ␉struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages*)AllocateKernelMemory(sizeof(struct fake_efi_pages));␊ |
174 | ␉␊ |
175 | ␉// Zero out all the tables in case fields are added later␊ |
176 | ␉//bzero(fakeEfiPages, sizeof(struct fake_efi_pages));␊ |
177 | ␉␊ |
178 | ␉// --------------------------------------------------------------------␊ |
179 | ␉// Initialize some machine code that will return EFI_UNSUPPORTED for␊ |
180 | ␉// functions returning int and simply return for void functions.␊ |
181 | ␉memcpy(fakeEfiPages->voidret_instructions, VOIDRET_INSTRUCTIONS, sizeof(VOIDRET_INSTRUCTIONS));␊ |
182 | ␉memcpy(fakeEfiPages->unsupportedret_instructions, UNSUPPORTEDRET_INSTRUCTIONS, sizeof(UNSUPPORTEDRET_INSTRUCTIONS));␊ |
183 | ␉␊ |
184 | ␉// --------------------------------------------------------------------␊ |
185 | ␉// System table␊ |
186 | ␉EFI_SYSTEM_TABLE_32 *efiSystemTable = gST32 = &fakeEfiPages->efiSystemTable;␊ |
187 | ␉efiSystemTable->Hdr.Signature = EFI_SYSTEM_TABLE_SIGNATURE;␊ |
188 | ␉efiSystemTable->Hdr.Revision = EFI_SYSTEM_TABLE_REVISION;␊ |
189 | ␉efiSystemTable->Hdr.HeaderSize = sizeof(EFI_SYSTEM_TABLE_32);␊ |
190 | ␉efiSystemTable->Hdr.CRC32 = 0; // Initialize to zero and then do CRC32␊ |
191 | ␉efiSystemTable->Hdr.Reserved = 0;␊ |
192 | ␉␊ |
193 | ␉efiSystemTable->FirmwareVendor = (EFI_PTR32)&fakeEfiPages->firmwareVendor;␊ |
194 | ␉memcpy(fakeEfiPages->firmwareVendor, FIRMWARE_VENDOR, sizeof(FIRMWARE_VENDOR));␊ |
195 | ␉efiSystemTable->FirmwareRevision = FIRMWARE_REVISION;␊ |
196 | ␉␊ |
197 | ␉// XXX: We may need to have basic implementations of ConIn/ConOut/StdErr␊ |
198 | ␉// The EFI spec states that all handles are invalid after boot services have been␊ |
199 | ␉// exited so we can probably get by with leaving the handles as zero.␊ |
200 | ␉efiSystemTable->ConsoleInHandle = 0;␊ |
201 | ␉efiSystemTable->ConIn = 0;␊ |
202 | ␉␊ |
203 | ␉efiSystemTable->ConsoleOutHandle = 0;␊ |
204 | ␉efiSystemTable->ConOut = 0;␊ |
205 | ␉␊ |
206 | ␉efiSystemTable->StandardErrorHandle = 0;␊ |
207 | ␉efiSystemTable->StdErr = 0;␊ |
208 | ␉␊ |
209 | ␉efiSystemTable->RuntimeServices = (EFI_PTR32)&fakeEfiPages->efiRuntimeServices;␊ |
210 | ␉␊ |
211 | ␉// According to the EFI spec, BootServices aren't valid after the␊ |
212 | ␉// boot process is exited so we can probably do without it.␊ |
213 | ␉// Apple didn't provide a definition for it in pexpert/i386/efi.h␊ |
214 | ␉// so I'm guessing they don't use it.␊ |
215 | ␉efiSystemTable->BootServices = 0;␊ |
216 | ␉␊ |
217 | ␉efiSystemTable->NumberOfTableEntries = 0;␊ |
218 | ␉efiSystemTable->ConfigurationTable = (EFI_PTR32)fakeEfiPages->efiConfigurationTable;␊ |
219 | ␉␊ |
220 | ␉// We're done. Now CRC32 the thing so the kernel will accept it.␊ |
221 | ␉// Must be initialized to zero before CRC32, done above.␊ |
222 | ␉gST32->Hdr.CRC32 = crc32(0L, gST32, gST32->Hdr.HeaderSize);␊ |
223 | ␉␊ |
224 | ␉// --------------------------------------------------------------------␊ |
225 | ␉// Runtime services␊ |
226 | ␉EFI_RUNTIME_SERVICES_32 *efiRuntimeServices = &fakeEfiPages->efiRuntimeServices;␊ |
227 | ␉efiRuntimeServices->Hdr.Signature = EFI_RUNTIME_SERVICES_SIGNATURE;␊ |
228 | ␉efiRuntimeServices->Hdr.Revision = EFI_RUNTIME_SERVICES_REVISION;␊ |
229 | ␉efiRuntimeServices->Hdr.HeaderSize = sizeof(EFI_RUNTIME_SERVICES_32);␊ |
230 | ␉efiRuntimeServices->Hdr.CRC32 = 0;␊ |
231 | ␉efiRuntimeServices->Hdr.Reserved = 0;␊ |
232 | ␉␊ |
233 | ␉// There are a number of function pointers in the efiRuntimeServices table.␊ |
234 | ␉// These are the Foundation (e.g. core) services and are expected to be present on␊ |
235 | ␉// all EFI-compliant machines.␉Some kernel extensions (notably AppleEFIRuntime)␊ |
236 | ␉// will call these without checking to see if they are null.␊ |
237 | ␉//␊ |
238 | ␉// We don't really feel like doing an EFI implementation in the bootloader␊ |
239 | ␉// but it is nice if we can at least prevent a complete crash by␊ |
240 | ␉// at least providing some sort of implementation until one can be provided␊ |
241 | ␉// nicely in a kext.␊ |
242 | ␉void (*voidret_fp)() = (void*)fakeEfiPages->voidret_instructions;␊ |
243 | ␉void (*unsupportedret_fp)() = (void*)fakeEfiPages->unsupportedret_instructions;␊ |
244 | ␉efiRuntimeServices->GetTime = (EFI_PTR32)unsupportedret_fp;␊ |
245 | ␉efiRuntimeServices->SetTime = (EFI_PTR32)unsupportedret_fp;␊ |
246 | ␉efiRuntimeServices->GetWakeupTime = (EFI_PTR32)unsupportedret_fp;␊ |
247 | ␉efiRuntimeServices->SetWakeupTime = (EFI_PTR32)unsupportedret_fp;␊ |
248 | ␉efiRuntimeServices->SetVirtualAddressMap = (EFI_PTR32)unsupportedret_fp;␊ |
249 | ␉efiRuntimeServices->ConvertPointer = (EFI_PTR32)unsupportedret_fp;␊ |
250 | ␉efiRuntimeServices->GetVariable = (EFI_PTR32)unsupportedret_fp;␊ |
251 | ␉efiRuntimeServices->GetNextVariableName = (EFI_PTR32)unsupportedret_fp;␊ |
252 | ␉efiRuntimeServices->SetVariable = (EFI_PTR32)unsupportedret_fp;␊ |
253 | ␉efiRuntimeServices->GetNextHighMonotonicCount = (EFI_PTR32)unsupportedret_fp;␊ |
254 | ␉efiRuntimeServices->ResetSystem = (EFI_PTR32)voidret_fp;␊ |
255 | ␉␊ |
256 | ␉// We're done.␉Now CRC32 the thing so the kernel will accept it␊ |
257 | ␉efiRuntimeServices->Hdr.CRC32 = crc32(0L, efiRuntimeServices, efiRuntimeServices->Hdr.HeaderSize);␊ |
258 | ␉␊ |
259 | ␉// --------------------------------------------------------------------␊ |
260 | ␉// Finish filling in the rest of the boot args that we need.␊ |
261 | ␉bootArgs->efiSystemTable = (uint32_t)efiSystemTable;␊ |
262 | ␉bootArgs->efiMode = kBootArgsEfiMode32;␊ |
263 | ␉␊ |
264 | ␉// The bootArgs structure as a whole is bzero'd so we don't need to fill in␊ |
265 | ␉// things like efiRuntimeServices* and what not.␊ |
266 | ␉//␊ |
267 | ␉// In fact, the only code that seems to use that is the hibernate code so it␊ |
268 | ␉// knows not to save the pages.␉ It even checks to make sure its nonzero.␊ |
269 | }␊ |
270 | ␊ |
271 | void setupEfiTables64(void)␊ |
272 | {␊ |
273 | ␉struct fake_efi_pages␊ |
274 | ␉{␊ |
275 | ␉␉EFI_SYSTEM_TABLE_64 efiSystemTable;␊ |
276 | ␉␉EFI_RUNTIME_SERVICES_64 efiRuntimeServices;␊ |
277 | ␉␉EFI_CONFIGURATION_TABLE_64 efiConfigurationTable[MAX_CONFIGURATION_TABLE_ENTRIES];␊ |
278 | ␉␉EFI_CHAR16 firmwareVendor[sizeof(FIRMWARE_VENDOR)/sizeof(EFI_CHAR16)];␊ |
279 | ␉␉uint8_t voidret_instructions[sizeof(VOIDRET_INSTRUCTIONS)/sizeof(uint8_t)];␊ |
280 | ␉␉uint8_t unsupportedret_instructions[sizeof(UNSUPPORTEDRET_INSTRUCTIONS)/sizeof(uint8_t)];␊ |
281 | ␉};␊ |
282 | ␉␊ |
283 | ␉struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages*)AllocateKernelMemory(sizeof(struct fake_efi_pages));␊ |
284 | ␉␊ |
285 | ␉// Zero out all the tables in case fields are added later␊ |
286 | ␉//bzero(fakeEfiPages, sizeof(struct fake_efi_pages));␊ |
287 | ␉␊ |
288 | ␉// --------------------------------------------------------------------␊ |
289 | ␉// Initialize some machine code that will return EFI_UNSUPPORTED for␊ |
290 | ␉// functions returning int and simply return for void functions.␊ |
291 | ␉memcpy(fakeEfiPages->voidret_instructions, VOIDRET_INSTRUCTIONS, sizeof(VOIDRET_INSTRUCTIONS));␊ |
292 | ␉memcpy(fakeEfiPages->unsupportedret_instructions, UNSUPPORTEDRET_INSTRUCTIONS, sizeof(UNSUPPORTEDRET_INSTRUCTIONS));␊ |
293 | ␉␊ |
294 | ␉// --------------------------------------------------------------------␊ |
295 | ␉// System table␊ |
296 | ␉EFI_SYSTEM_TABLE_64 *efiSystemTable = gST64 = &fakeEfiPages->efiSystemTable;␊ |
297 | ␉efiSystemTable->Hdr.Signature = EFI_SYSTEM_TABLE_SIGNATURE;␊ |
298 | ␉efiSystemTable->Hdr.Revision = EFI_SYSTEM_TABLE_REVISION;␊ |
299 | ␉efiSystemTable->Hdr.HeaderSize = sizeof(EFI_SYSTEM_TABLE_64);␊ |
300 | ␉efiSystemTable->Hdr.CRC32 = 0; // Initialize to zero and then do CRC32␊ |
301 | ␉efiSystemTable->Hdr.Reserved = 0;␊ |
302 | ␉␊ |
303 | ␉efiSystemTable->FirmwareVendor = ptov64((EFI_PTR32)&fakeEfiPages->firmwareVendor);␊ |
304 | ␉memcpy(fakeEfiPages->firmwareVendor, FIRMWARE_VENDOR, sizeof(FIRMWARE_VENDOR));␊ |
305 | ␉efiSystemTable->FirmwareRevision = FIRMWARE_REVISION;␊ |
306 | ␉␊ |
307 | ␉// XXX: We may need to have basic implementations of ConIn/ConOut/StdErr␊ |
308 | ␉// The EFI spec states that all handles are invalid after boot services have been␊ |
309 | ␉// exited so we can probably get by with leaving the handles as zero.␊ |
310 | ␉efiSystemTable->ConsoleInHandle = 0;␊ |
311 | ␉efiSystemTable->ConIn = 0;␊ |
312 | ␉␊ |
313 | ␉efiSystemTable->ConsoleOutHandle = 0;␊ |
314 | ␉efiSystemTable->ConOut = 0;␊ |
315 | ␉␊ |
316 | ␉efiSystemTable->StandardErrorHandle = 0;␊ |
317 | ␉efiSystemTable->StdErr = 0;␊ |
318 | ␉␊ |
319 | ␉efiSystemTable->RuntimeServices = ptov64((EFI_PTR32)&fakeEfiPages->efiRuntimeServices);␊ |
320 | ␉// According to the EFI spec, BootServices aren't valid after the␊ |
321 | ␉// boot process is exited so we can probably do without it.␊ |
322 | ␉// Apple didn't provide a definition for it in pexpert/i386/efi.h␊ |
323 | ␉// so I'm guessing they don't use it.␊ |
324 | ␉efiSystemTable->BootServices = 0;␊ |
325 | ␉␊ |
326 | ␉efiSystemTable->NumberOfTableEntries = 0;␊ |
327 | ␉efiSystemTable->ConfigurationTable = ptov64((EFI_PTR32)fakeEfiPages->efiConfigurationTable);␊ |
328 | ␉␊ |
329 | ␉// We're done.␉Now CRC32 the thing so the kernel will accept it␊ |
330 | ␉gST64->Hdr.CRC32 = crc32(0L, gST64, gST64->Hdr.HeaderSize);␊ |
331 | ␉␊ |
332 | ␉// --------------------------------------------------------------------␊ |
333 | ␉// Runtime services␊ |
334 | ␉EFI_RUNTIME_SERVICES_64 *efiRuntimeServices = &fakeEfiPages->efiRuntimeServices;␊ |
335 | ␉efiRuntimeServices->Hdr.Signature = EFI_RUNTIME_SERVICES_SIGNATURE;␊ |
336 | ␉efiRuntimeServices->Hdr.Revision = EFI_RUNTIME_SERVICES_REVISION;␊ |
337 | ␉efiRuntimeServices->Hdr.HeaderSize = sizeof(EFI_RUNTIME_SERVICES_64);␊ |
338 | ␉efiRuntimeServices->Hdr.CRC32 = 0;␊ |
339 | ␉efiRuntimeServices->Hdr.Reserved = 0;␊ |
340 | ␉␊ |
341 | ␉// There are a number of function pointers in the efiRuntimeServices table.␊ |
342 | ␉// These are the Foundation (e.g. core) services and are expected to be present on␊ |
343 | ␉// all EFI-compliant machines.␉Some kernel extensions (notably AppleEFIRuntime)␊ |
344 | ␉// will call these without checking to see if they are null.␊ |
345 | ␉//␊ |
346 | ␉// We don't really feel like doing an EFI implementation in the bootloader␊ |
347 | ␉// but it is nice if we can at least prevent a complete crash by␊ |
348 | ␉// at least providing some sort of implementation until one can be provided␊ |
349 | ␉// nicely in a kext.␊ |
350 | ␉␊ |
351 | ␉void (*voidret_fp)() = (void*)fakeEfiPages->voidret_instructions;␊ |
352 | ␉void (*unsupportedret_fp)() = (void*)fakeEfiPages->unsupportedret_instructions;␊ |
353 | ␉efiRuntimeServices->GetTime = ptov64((EFI_PTR32)unsupportedret_fp);␊ |
354 | ␉efiRuntimeServices->SetTime = ptov64((EFI_PTR32)unsupportedret_fp);␊ |
355 | ␉efiRuntimeServices->GetWakeupTime = ptov64((EFI_PTR32)unsupportedret_fp);␊ |
356 | ␉efiRuntimeServices->SetWakeupTime = ptov64((EFI_PTR32)unsupportedret_fp);␊ |
357 | ␉efiRuntimeServices->SetVirtualAddressMap = ptov64((EFI_PTR32)unsupportedret_fp);␊ |
358 | ␉efiRuntimeServices->ConvertPointer = ptov64((EFI_PTR32)unsupportedret_fp);␊ |
359 | ␉efiRuntimeServices->GetVariable = ptov64((EFI_PTR32)unsupportedret_fp);␊ |
360 | ␉efiRuntimeServices->GetNextVariableName = ptov64((EFI_PTR32)unsupportedret_fp);␊ |
361 | ␉efiRuntimeServices->SetVariable = ptov64((EFI_PTR32)unsupportedret_fp);␊ |
362 | ␉efiRuntimeServices->GetNextHighMonotonicCount = ptov64((EFI_PTR32)unsupportedret_fp);␊ |
363 | ␉efiRuntimeServices->ResetSystem = ptov64((EFI_PTR32)voidret_fp);␊ |
364 | ␉␊ |
365 | ␉// We're done.␉Now CRC32 the thing so the kernel will accept it␊ |
366 | ␉efiRuntimeServices->Hdr.CRC32 = crc32(0L, efiRuntimeServices, efiRuntimeServices->Hdr.HeaderSize);␊ |
367 | ␉␊ |
368 | ␉// --------------------------------------------------------------------␊ |
369 | ␉// Finish filling in the rest of the boot args that we need.␊ |
370 | ␉bootArgs->efiSystemTable = (uint32_t)efiSystemTable;␊ |
371 | ␉bootArgs->efiMode = kBootArgsEfiMode64;␊ |
372 | ␉␊ |
373 | ␉// The bootArgs structure as a whole is bzero'd so we don't need to fill in␊ |
374 | ␉// things like efiRuntimeServices* and what not.␊ |
375 | ␉//␊ |
376 | ␉// In fact, the only code that seems to use that is the hibernate code so it␊ |
377 | ␉// knows not to save the pages.␉ It even checks to make sure its nonzero.␊ |
378 | }␊ |
379 | ␊ |
380 | /*␊ |
381 | * In addition to the EFI tables there is also the EFI device tree node.␊ |
382 | * In particular, we need /efi/platform to have an FSBFrequency key. Without it,␊ |
383 | * the tsc_init function will panic very early on in kernel startup, before␊ |
384 | * the console is available.␊ |
385 | */␊ |
386 | ␊ |
387 | /*==========================================================================␊ |
388 | * FSB Frequency detection␊ |
389 | */␊ |
390 | ␊ |
391 | /* These should be const but DT__AddProperty takes char* */␊ |
392 | static const char TSC_Frequency_prop[] = "TSCFrequency";␊ |
393 | static const char FSB_Frequency_prop[] = "FSBFrequency";␊ |
394 | static const char CPU_Frequency_prop[] = "CPUFrequency";␊ |
395 | ␊ |
396 | /*==========================================================================␊ |
397 | * SMBIOS␊ |
398 | */␊ |
399 | ␊ |
400 | /* From Foundation/Efi/Guid/Smbios/SmBios.c */␊ |
401 | EFI_GUID const␉gEfiSmbiosTableGuid = EFI_SMBIOS_TABLE_GUID;␊ |
402 | ␊ |
403 | #define SMBIOS_RANGE_START␉␉0x000F0000␊ |
404 | #define SMBIOS_RANGE_END␉␉0x000FFFFF␊ |
405 | ␊ |
406 | /* '_SM_' in little endian: */␊ |
407 | #define SMBIOS_ANCHOR_UINT32_LE 0x5f4d535f␊ |
408 | ␊ |
409 | #define EFI_ACPI_TABLE_GUID \␊ |
410 | { \␊ |
411 | ␉0xeb9d2d30, 0x2d88, 0x11d3, { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \␊ |
412 | }␊ |
413 | ␊ |
414 | #define EFI_ACPI_20_TABLE_GUID \␊ |
415 | { \␊ |
416 | ␉0x8868e871, 0xe4f1, 0x11d3, { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \␊ |
417 | }␊ |
418 | ␊ |
419 | EFI_GUID gEfiAcpiTableGuid = EFI_ACPI_TABLE_GUID;␊ |
420 | EFI_GUID gEfiAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID;␊ |
421 | ␊ |
422 | ␊ |
423 | /*==========================================================================␊ |
424 | * Fake EFI implementation␊ |
425 | */␊ |
426 | ␊ |
427 | /* These should be const but DT__AddProperty takes char* */␊ |
428 | static const char FIRMWARE_REVISION_PROP[] = "firmware-revision";␊ |
429 | static const char FIRMWARE_ABI_PROP[] = "firmware-abi";␊ |
430 | static const char FIRMWARE_VENDOR_PROP[] = "firmware-vendor";␊ |
431 | static const char FIRMWARE_ABI_32_PROP_VALUE[] = "EFI32";␊ |
432 | static const char FIRMWARE_ABI_64_PROP_VALUE[] = "EFI64";␊ |
433 | static const char SYSTEM_ID_PROP[] = "system-id";␊ |
434 | static const char SYSTEM_SERIAL_PROP[] = "SystemSerialNumber";␊ |
435 | static const char SYSTEM_TYPE_PROP[] = "system-type";␊ |
436 | static const char MODEL_PROP[] = "Model";␊ |
437 | static const char BOARDID_PROP[] = "board-id";␊ |
438 | ␊ |
439 | /*␊ |
440 | * Get an smbios option string option to convert to EFI_CHAR16 string␊ |
441 | */␊ |
442 | static EFI_CHAR16* getSmbiosChar16(const char * key, size_t* len)␊ |
443 | {␊ |
444 | ␉const char␉*src = getStringForKey(key, &bootInfo->smbiosConfig);␊ |
445 | ␉EFI_CHAR16*␉ dst = 0;␊ |
446 | ␉size_t␉␉ i = 0;␊ |
447 | ␉␊ |
448 | ␉if (!key || !(*key) || !len || !src) return 0;␊ |
449 | ␉␊ |
450 | ␉*len = strlen(src);␊ |
451 | ␉dst = (EFI_CHAR16*) malloc( ((*len)+1) * 2 );␊ |
452 | ␉for (; i < (*len); i++)␉ dst[i] = src[i];␊ |
453 | ␉dst[(*len)] = '\0';␊ |
454 | ␉*len = ((*len)+1)*2; // return the CHAR16 bufsize in cluding zero terminated CHAR16␊ |
455 | ␉return dst;␊ |
456 | }␊ |
457 | ␊ |
458 | /*␊ |
459 | * Get the SystemID from the bios dmi info␊ |
460 | */␊ |
461 | static␉EFI_CHAR8* getSmbiosUUID()␊ |
462 | {␊ |
463 | ␉static EFI_CHAR8␉␉ uuid[UUID_LEN];␊ |
464 | ␉int␉␉␉␉␉␉ i, isZero, isOnes;␊ |
465 | ␉SMBByte␉␉␉␉␉*p;␊ |
466 | ␉␊ |
467 | ␉p = (SMBByte*)Platform.UUID;␊ |
468 | ␉␊ |
469 | ␉for (i=0, isZero=1, isOnes=1; i<UUID_LEN; i++)␊ |
470 | ␉{␊ |
471 | ␉␉if (p[i] != 0x00) isZero = 0;␊ |
472 | ␉␉if (p[i] != 0xff) isOnes = 0;␊ |
473 | ␉}␊ |
474 | ␉␊ |
475 | ␉if (isZero || isOnes) // empty or setable means: no uuid present␊ |
476 | ␉{␊ |
477 | ␉␉verbose("No UUID present in SMBIOS System Information Table\n");␊ |
478 | ␉␉return 0;␊ |
479 | ␉}␊ |
480 | ␉␊ |
481 | ␉memcpy(uuid, p, UUID_LEN);␊ |
482 | ␉return uuid;␊ |
483 | }␊ |
484 | ␊ |
485 | /*␊ |
486 | * return a binary UUID value from the overriden SystemID and SMUUID if found, ␊ |
487 | * or from the bios if not, or from a fixed value if no bios value is found ␊ |
488 | */␊ |
489 | static EFI_CHAR8* getSystemID()␊ |
490 | {␊ |
491 | ␉// unable to determine UUID for host. Error: 35 fix␊ |
492 | ␉// Rek: new SMsystemid option conforming to smbios notation standards, this option should␊ |
493 | ␉// belong to smbios config only ...␊ |
494 | ␉const char *sysId = getStringForKey(kSystemID, &bootInfo->chameleonConfig);␊ |
495 | ␉EFI_CHAR8*␉ret = getUUIDFromString(sysId);␊ |
496 | ␉␊ |
497 | ␉if (!sysId || !ret) // try bios dmi info UUID extraction␊ |
498 | ␉{␊ |
499 | ␉␉ret = getSmbiosUUID();␊ |
500 | ␉␉sysId = 0;␊ |
501 | ␉}␊ |
502 | ␉␊ |
503 | ␉if (!ret) // no bios dmi UUID available, set a fixed value for system-id␊ |
504 | ␉␉ret=getUUIDFromString((sysId = (const char*) SYSTEM_ID));␊ |
505 | ␉␊ |
506 | ␉verbose("Customizing SystemID with : %s\n", getStringFromUUID(ret)); // apply a nice formatting to the displayed output␊ |
507 | ␉return ret;␊ |
508 | }␊ |
509 | ␊ |
510 | /*␊ |
511 | * Must be called AFTER setup Acpi because we need to take care of correct␊ |
512 | * facp content to reflect in ioregs␊ |
513 | */␊ |
514 | void setupSystemType()␊ |
515 | {␊ |
516 | ␉Node *node = DT__FindNode("/", false);␊ |
517 | ␉if (node == 0) stop("Couldn't get root node");␊ |
518 | ␉// we need to write this property after facp parsing␊ |
519 | ␉// Export system-type only if it has been overrriden by the SystemType option␊ |
520 | ␉DT__AddProperty(node, SYSTEM_TYPE_PROP, sizeof(Platform.Type), &Platform.Type);␊ |
521 | }␊ |
522 | ␊ |
523 | void setupEfiDeviceTree(void)␊ |
524 | {␊ |
525 | ␉EFI_CHAR8*␉ ret = 0;␊ |
526 | ␉EFI_CHAR16*␉ ret16 = 0;␊ |
527 | ␉size_t␉␉ len = 0;␊ |
528 | ␉Node␉␉*node;␊ |
529 | ␉␊ |
530 | ␉node = DT__FindNode("/", false);␊ |
531 | ␉␊ |
532 | ␉if (node == 0) stop("Couldn't get root node");␊ |
533 | ␉␊ |
534 | ␉// We could also just do DT__FindNode("/efi/platform", true)␊ |
535 | ␉// But I think eventually we want to fill stuff in the efi node␊ |
536 | ␉// too so we might as well create it so we have a pointer for it too.␊ |
537 | ␉node = DT__AddChild(node, "efi");␊ |
538 | ␉␊ |
539 | ␉if (archCpuType == CPU_TYPE_I386)␊ |
540 | ␉{␊ |
541 | ␉␉DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_32_PROP_VALUE), (char*)FIRMWARE_ABI_32_PROP_VALUE);␊ |
542 | ␉}␊ |
543 | ␉else␊ |
544 | ␉{␊ |
545 | ␉␉DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_64_PROP_VALUE), (char*)FIRMWARE_ABI_64_PROP_VALUE);␊ |
546 | ␉}␊ |
547 | ␉␊ |
548 | ␉DT__AddProperty(node, FIRMWARE_REVISION_PROP, sizeof(FIRMWARE_REVISION), (EFI_UINT32*)&FIRMWARE_REVISION);␊ |
549 | ␉DT__AddProperty(node, FIRMWARE_VENDOR_PROP, sizeof(FIRMWARE_VENDOR), (EFI_CHAR16*)FIRMWARE_VENDOR);␊ |
550 | ␉␊ |
551 | ␉// TODO: Fill in other efi properties if necessary␊ |
552 | ␉␊ |
553 | ␉// Set up the /efi/runtime-services table node similar to the way a child node of configuration-table␊ |
554 | ␉// is set up. That is, name and table properties␊ |
555 | ␉Node *runtimeServicesNode = DT__AddChild(node, "runtime-services");␊ |
556 | ␉␊ |
557 | ␉if (archCpuType == CPU_TYPE_I386)␊ |
558 | ␉{␊ |
559 | ␉␉// The value of the table property is the 32-bit physical address for the RuntimeServices table.␊ |
560 | ␉␉// Since the EFI system table already has a pointer to it, we simply use the address of that pointer␊ |
561 | ␉␉// for the pointer to the property data. Warning.. DT finalization calls free on that but we're not␊ |
562 | ␉␉// the only thing to use a non-malloc'd pointer for something in the DT␊ |
563 | ␉␉␊ |
564 | ␉␉DT__AddProperty(runtimeServicesNode, "table", sizeof(uint64_t), &gST32->RuntimeServices);␊ |
565 | ␉}␊ |
566 | ␉else␊ |
567 | ␉{␊ |
568 | ␉␉DT__AddProperty(runtimeServicesNode, "table", sizeof(uint64_t), &gST64->RuntimeServices);␊ |
569 | ␉}␊ |
570 | ␉␊ |
571 | ␉// Set up the /efi/configuration-table node which will eventually have several child nodes for␊ |
572 | ␉// all of the configuration tables needed by various kernel extensions.␊ |
573 | ␉gEfiConfigurationTableNode = DT__AddChild(node, "configuration-table");␊ |
574 | ␉␊ |
575 | ␉// Now fill in the /efi/platform Node␊ |
576 | ␉Node *efiPlatformNode = DT__AddChild(node, "platform");␊ |
577 | ␉␊ |
578 | ␉// NOTE WELL: If you do add FSB Frequency detection, make sure to store␊ |
579 | ␉// the value in the fsbFrequency global and not an malloc'd pointer␊ |
580 | ␉// because the DT_AddProperty function does not copy its args.␊ |
581 | ␉␊ |
582 | ␉if (Platform.CPU.FSBFrequency != 0)␊ |
583 | ␉␉DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &Platform.CPU.FSBFrequency);␊ |
584 | ␉␊ |
585 | ␉// Export TSC and CPU frequencies for use by the kernel or KEXTs␊ |
586 | ␉if (Platform.CPU.TSCFrequency != 0)␊ |
587 | ␉␉DT__AddProperty(efiPlatformNode, TSC_Frequency_prop, sizeof(uint64_t), &Platform.CPU.TSCFrequency);␊ |
588 | ␉␊ |
589 | ␉if (Platform.CPU.CPUFrequency != 0)␊ |
590 | ␉␉DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform.CPU.CPUFrequency);␊ |
591 | ␉␊ |
592 | ␉// Export system-id. Can be disabled with SystemId=No in com.apple.Boot.plist␊ |
593 | ␉if ((ret=getSystemID()))␊ |
594 | ␉␉DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32*) ret);␊ |
595 | ␉␊ |
596 | ␉// Export SystemSerialNumber if present␊ |
597 | ␉if ((ret16=getSmbiosChar16("SMserial", &len)))␊ |
598 | ␉␉DT__AddProperty(efiPlatformNode, SYSTEM_SERIAL_PROP, len, ret16);␊ |
599 | ␉␊ |
600 | ␉// Export Model if present␊ |
601 | ␉if ((ret16=getSmbiosChar16("SMproductname", &len)))␊ |
602 | ␉␉DT__AddProperty(efiPlatformNode, MODEL_PROP, len, ret16);␊ |
603 | ␉␊ |
604 | ␉// Fill /efi/device-properties node.␊ |
605 | ␉setupDeviceProperties(node);␊ |
606 | }␊ |
607 | ␊ |
608 | /*␊ |
609 | * Must be called AFTER getSmbios␊ |
610 | */␊ |
611 | void setupBoardId()␊ |
612 | {␊ |
613 | ␉Node *node;␊ |
614 | ␉node = DT__FindNode("/", false);␊ |
615 | ␉if (node == 0) {␊ |
616 | ␉␉stop("Couldn't get root node");␊ |
617 | ␉}␊ |
618 | ␉const char *boardid = getStringForKey("SMboardproduct", &bootInfo->smbiosConfig);␊ |
619 | ␉if (boardid)␊ |
620 | ␉␉DT__AddProperty(node, BOARDID_PROP, strlen(boardid)+1, (EFI_CHAR16*)boardid);␊ |
621 | }␉␉␊ |
622 | ␊ |
623 | /*␊ |
624 | * Populate the chosen node␊ |
625 | */␊ |
626 | void setupChosenNode()␊ |
627 | {␊ |
628 | ␉Node *chosenNode;␊ |
629 | ␉chosenNode = DT__FindNode("/chosen", false);␊ |
630 | ␉if (chosenNode == 0)␊ |
631 | ␉␉stop("Couldn't get chosen node");␊ |
632 | ␊ |
633 | ␉int bootUUIDLength = strlen(gBootUUIDString);␊ |
634 | ␉if (bootUUIDLength)␊ |
635 | ␉␉DT__AddProperty(chosenNode, "boot-uuid", bootUUIDLength + 1, gBootUUIDString);␊ |
636 | }␊ |
637 | ␊ |
638 | /*␊ |
639 | * Load the smbios.plist override config file if any␊ |
640 | */␊ |
641 | static void setupSmbiosConfigFile(const char *filename)␊ |
642 | {␊ |
643 | ␉char␉␉dirSpecSMBIOS[128];␊ |
644 | ␉const char *override_pathname = NULL;␊ |
645 | ␉int␉␉␉len = 0, err = 0;␊ |
646 | ␉extern void scan_mem();␊ |
647 | ␉␊ |
648 | ␉// Take in account user overriding␊ |
649 | ␉if (getValueForKey(kSMBIOSKey, &override_pathname, &len, &bootInfo->chameleonConfig) && len > 0)␊ |
650 | ␉{␊ |
651 | ␉␉// Specify a path to a file, e.g. SMBIOS=/Extra/macProXY.plist␊ |
652 | ␉␉sprintf(dirSpecSMBIOS, override_pathname);␊ |
653 | ␉␉err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig);␊ |
654 | ␉}␊ |
655 | ␉else␊ |
656 | ␉{␊ |
657 | ␉␉// Check selected volume's Extra.␊ |
658 | ␉␉sprintf(dirSpecSMBIOS, "/Extra/%s", filename);␊ |
659 | ␉␉if ( (err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig)) )␊ |
660 | ␉␉{␊ |
661 | ␉␉␉// Check booter volume/rdbt Extra.␊ |
662 | ␉␉␉sprintf(dirSpecSMBIOS, "bt(0,0)/Extra/%s", filename);␊ |
663 | ␉␉␉err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig);␊ |
664 | ␉␉}␊ |
665 | ␉}␊ |
666 | ␉␊ |
667 | ␉if (err)␊ |
668 | ␉{␊ |
669 | ␉␉verbose("No SMBIOS replacement found.\n");␊ |
670 | ␉}␊ |
671 | ␉␊ |
672 | ␉// get a chance to scan mem dynamically if user asks for it while having the config options␊ |
673 | ␉// loaded as well, as opposed to when it was in scan_platform(); also load the orig. smbios␊ |
674 | ␉// so that we can access dmi info, without patching the smbios yet.␊ |
675 | ␉scan_mem(); ␊ |
676 | }␊ |
677 | ␊ |
678 | /*␊ |
679 | * Installs all the needed configuration table entries␊ |
680 | */␊ |
681 | static void setupEfiConfigurationTable()␊ |
682 | {␊ |
683 | ␉smbios_p = (EFI_PTR32)getSmbios(SMBIOS_PATCHED);␊ |
684 | ␉addConfigurationTable(&gEfiSmbiosTableGuid, &smbios_p, NULL);␊ |
685 | ␉␊ |
686 | ␉setupBoardId(); //need to be called after getSmbios␊ |
687 | ␉␊ |
688 | ␉// Setup ACPI with DSDT overrides (mackerintel's patch)␊ |
689 | ␉setupAcpi();␊ |
690 | ␉␊ |
691 | ␉// We've obviously changed the count.. so fix up the CRC32␊ |
692 | ␉if (archCpuType == CPU_TYPE_I386)␊ |
693 | ␉{␊ |
694 | ␉␉gST32->Hdr.CRC32 = 0;␊ |
695 | ␉␉gST32->Hdr.CRC32 = crc32(0L, gST32, gST32->Hdr.HeaderSize);␊ |
696 | ␉}␊ |
697 | ␉else␊ |
698 | ␉{␊ |
699 | ␉␉gST64->Hdr.CRC32 = 0;␊ |
700 | ␉␉gST64->Hdr.CRC32 = crc32(0L, gST64, gST64->Hdr.HeaderSize);␊ |
701 | ␉}␊ |
702 | ␊ |
703 | ␉// Setup the chosen node␊ |
704 | ␉setupChosenNode();␊ |
705 | }␊ |
706 | ␊ |
707 | void saveOriginalSMBIOS(void)␊ |
708 | {␊ |
709 | ␉Node *node;␊ |
710 | ␉SMBEntryPoint *origeps;␊ |
711 | ␉void *tableAddress;␊ |
712 | ␉␊ |
713 | ␉node = DT__FindNode("/efi/platform", false);␊ |
714 | ␉if (!node)␊ |
715 | ␉{␊ |
716 | ␉␉verbose("/efi/platform node not found\n");␊ |
717 | ␉␉return;␊ |
718 | ␉}␊ |
719 | ␉␊ |
720 | ␉origeps = getSmbios(SMBIOS_ORIGINAL);␊ |
721 | ␉if (!origeps)␊ |
722 | ␉{␊ |
723 | ␉␉return;␊ |
724 | ␉}␊ |
725 | ␉␊ |
726 | ␉tableAddress = (void *)AllocateKernelMemory(origeps->dmi.tableLength);␊ |
727 | ␉if (!tableAddress)␊ |
728 | ␉{␊ |
729 | ␉␉return;␊ |
730 | ␉}␊ |
731 | ␉␊ |
732 | ␉memcpy(tableAddress, (void *)origeps->dmi.tableAddress, origeps->dmi.tableLength);␊ |
733 | ␉DT__AddProperty(node, "SMBIOS", origeps->dmi.tableLength, tableAddress);␊ |
734 | }␊ |
735 | ␊ |
736 | /*␊ |
737 | * Entrypoint from boot.c␊ |
738 | */␊ |
739 | void setupFakeEfi(void)␊ |
740 | {␊ |
741 | ␉// Generate efi device strings ␊ |
742 | ␉setup_pci_devs(root_pci_dev);␊ |
743 | ␉␊ |
744 | ␉readSMBIOSInfo(getSmbios(SMBIOS_ORIGINAL));␊ |
745 | ␉␊ |
746 | ␉// load smbios.plist file if any␊ |
747 | ␉setupSmbiosConfigFile("smbios.plist");␊ |
748 | ␉␊ |
749 | ␉setupSMBIOSTable();␊ |
750 | ␉␊ |
751 | ␉// Initialize the base table␊ |
752 | ␉if (archCpuType == CPU_TYPE_I386)␊ |
753 | ␉{␊ |
754 | ␉␉setupEfiTables32();␊ |
755 | ␉}␊ |
756 | ␉else␊ |
757 | ␉{␊ |
758 | ␉␉setupEfiTables64();␊ |
759 | ␉}␊ |
760 | ␉␊ |
761 | ␉// Initialize the device tree␊ |
762 | ␉setupEfiDeviceTree();␊ |
763 | ␉␊ |
764 | ␉saveOriginalSMBIOS();␊ |
765 | ␉␊ |
766 | ␉// Add configuration table entries to both the services table and the device tree␊ |
767 | ␉setupEfiConfigurationTable();␊ |
768 | }␊ |
769 | |