]>
Commit | Line | Data |
---|---|---|
e6d4b9d5 | 1 | /** @file |
2 | DXE Core Main Entry Point | |
3 | ||
4 | Copyright (c) 2006 - 2008, Intel Corporation. <BR> | |
5 | All rights reserved. This program and the accompanying materials | |
6 | are licensed and made available under the terms and conditions of the BSD License | |
7 | which accompanies this distribution. The full text of the license may be found at | |
8 | http://opensource.org/licenses/bsd-license.php | |
9 | ||
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | |
12 | ||
13 | **/ | |
14 | ||
15 | #include "DxeMain.h" | |
16 | ||
17 | // | |
18 | // DXE Core Global Variables for Protocols from PEI | |
19 | // | |
20 | EFI_HANDLE mDecompressHandle = NULL; | |
21 | ||
22 | // | |
23 | // DXE Core globals for Architecture Protocols | |
24 | // | |
25 | EFI_SECURITY_ARCH_PROTOCOL *gSecurity = NULL; | |
26 | EFI_CPU_ARCH_PROTOCOL *gCpu = NULL; | |
27 | EFI_METRONOME_ARCH_PROTOCOL *gMetronome = NULL; | |
28 | EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL; | |
29 | EFI_BDS_ARCH_PROTOCOL *gBds = NULL; | |
30 | EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL; | |
31 | ||
32 | // | |
33 | // DXE Core Global used to update core loaded image protocol handle | |
34 | // | |
35 | EFI_GUID *gDxeCoreFileName; | |
36 | EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage; | |
37 | ||
38 | // | |
39 | // DXE Core Module Variables | |
40 | // | |
41 | EFI_BOOT_SERVICES mBootServices = { | |
42 | { | |
43 | EFI_BOOT_SERVICES_SIGNATURE, // Signature | |
44 | EFI_BOOT_SERVICES_REVISION, // Revision | |
45 | sizeof (EFI_BOOT_SERVICES), // HeaderSize | |
46 | 0, // CRC32 | |
47 | 0 // Reserved | |
48 | }, | |
49 | (EFI_RAISE_TPL) CoreRaiseTpl, // RaiseTPL | |
50 | (EFI_RESTORE_TPL) CoreRestoreTpl, // RestoreTPL | |
51 | (EFI_ALLOCATE_PAGES) CoreAllocatePages, // AllocatePages | |
52 | (EFI_FREE_PAGES) CoreFreePages, // FreePages | |
53 | (EFI_GET_MEMORY_MAP) CoreGetMemoryMap, // GetMemoryMap | |
54 | (EFI_ALLOCATE_POOL) CoreAllocatePool, // AllocatePool | |
55 | (EFI_FREE_POOL) CoreFreePool, // FreePool | |
56 | (EFI_CREATE_EVENT) CoreCreateEvent, // CreateEvent | |
57 | (EFI_SET_TIMER) CoreSetTimer, // SetTimer | |
58 | (EFI_WAIT_FOR_EVENT) CoreWaitForEvent, // WaitForEvent | |
59 | (EFI_SIGNAL_EVENT) CoreSignalEvent, // SignalEvent | |
60 | (EFI_CLOSE_EVENT) CoreCloseEvent, // CloseEvent | |
61 | (EFI_CHECK_EVENT) CoreCheckEvent, // CheckEvent | |
62 | (EFI_INSTALL_PROTOCOL_INTERFACE) CoreInstallProtocolInterface, // InstallProtocolInterface | |
63 | (EFI_REINSTALL_PROTOCOL_INTERFACE) CoreReinstallProtocolInterface, // ReinstallProtocolInterface | |
64 | (EFI_UNINSTALL_PROTOCOL_INTERFACE) CoreUninstallProtocolInterface, // UninstallProtocolInterface | |
65 | (EFI_HANDLE_PROTOCOL) CoreHandleProtocol, // HandleProtocol | |
66 | (VOID *) NULL, // Reserved | |
67 | (EFI_REGISTER_PROTOCOL_NOTIFY) CoreRegisterProtocolNotify, // RegisterProtocolNotify | |
68 | (EFI_LOCATE_HANDLE) CoreLocateHandle, // LocateHandle | |
69 | (EFI_LOCATE_DEVICE_PATH) CoreLocateDevicePath, // LocateDevicePath | |
70 | (EFI_INSTALL_CONFIGURATION_TABLE) CoreInstallConfigurationTable, // InstallConfigurationTable | |
71 | (EFI_IMAGE_LOAD) CoreLoadImage, // LoadImage | |
72 | (EFI_IMAGE_START) CoreStartImage, // StartImage | |
73 | (EFI_EXIT) CoreExit, // Exit | |
74 | (EFI_IMAGE_UNLOAD) CoreUnloadImage, // UnloadImage | |
75 | (EFI_EXIT_BOOT_SERVICES) CoreExitBootServices, // ExitBootServices | |
76 | (EFI_GET_NEXT_MONOTONIC_COUNT) CoreEfiNotAvailableYetArg1, // GetNextMonotonicCount | |
77 | (EFI_STALL) CoreStall, // Stall | |
78 | (EFI_SET_WATCHDOG_TIMER) CoreSetWatchdogTimer, // SetWatchdogTimer | |
79 | (EFI_CONNECT_CONTROLLER) CoreConnectController, // ConnectController | |
80 | (EFI_DISCONNECT_CONTROLLER) CoreDisconnectController, // DisconnectController | |
81 | (EFI_OPEN_PROTOCOL) CoreOpenProtocol, // OpenProtocol | |
82 | (EFI_CLOSE_PROTOCOL) CoreCloseProtocol, // CloseProtocol | |
83 | (EFI_OPEN_PROTOCOL_INFORMATION) CoreOpenProtocolInformation, // OpenProtocolInformation | |
84 | (EFI_PROTOCOLS_PER_HANDLE) CoreProtocolsPerHandle, // ProtocolsPerHandle | |
85 | (EFI_LOCATE_HANDLE_BUFFER) CoreLocateHandleBuffer, // LocateHandleBuffer | |
86 | (EFI_LOCATE_PROTOCOL) CoreLocateProtocol, // LocateProtocol | |
87 | (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces | |
88 | (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces | |
89 | (EFI_CALCULATE_CRC32) CoreEfiNotAvailableYetArg3, // CalculateCrc32 | |
90 | (EFI_COPY_MEM) CopyMem, // CopyMem | |
91 | (EFI_SET_MEM) SetMem, // SetMem | |
92 | (EFI_CREATE_EVENT_EX) CoreCreateEventEx // CreateEventEx | |
93 | }; | |
94 | ||
95 | EFI_DXE_SERVICES mDxeServices = { | |
96 | { | |
97 | DXE_SERVICES_SIGNATURE, // Signature | |
98 | DXE_SERVICES_REVISION, // Revision | |
99 | sizeof (DXE_SERVICES), // HeaderSize | |
100 | 0, // CRC32 | |
101 | 0 // Reserved | |
102 | }, | |
103 | (EFI_ADD_MEMORY_SPACE) CoreAddMemorySpace, // AddMemorySpace | |
104 | (EFI_ALLOCATE_MEMORY_SPACE) CoreAllocateMemorySpace, // AllocateMemorySpace | |
105 | (EFI_FREE_MEMORY_SPACE) CoreFreeMemorySpace, // FreeMemorySpace | |
106 | (EFI_REMOVE_MEMORY_SPACE) CoreRemoveMemorySpace, // RemoveMemorySpace | |
107 | (EFI_GET_MEMORY_SPACE_DESCRIPTOR) CoreGetMemorySpaceDescriptor, // GetMemorySpaceDescriptor | |
108 | (EFI_SET_MEMORY_SPACE_ATTRIBUTES) CoreSetMemorySpaceAttributes, // SetMemorySpaceAttributes | |
109 | (EFI_GET_MEMORY_SPACE_MAP) CoreGetMemorySpaceMap, // GetMemorySpaceMap | |
110 | (EFI_ADD_IO_SPACE) CoreAddIoSpace, // AddIoSpace | |
111 | (EFI_ALLOCATE_IO_SPACE) CoreAllocateIoSpace, // AllocateIoSpace | |
112 | (EFI_FREE_IO_SPACE) CoreFreeIoSpace, // FreeIoSpace | |
113 | (EFI_REMOVE_IO_SPACE) CoreRemoveIoSpace, // RemoveIoSpace | |
114 | (EFI_GET_IO_SPACE_DESCRIPTOR) CoreGetIoSpaceDescriptor, // GetIoSpaceDescriptor | |
115 | (EFI_GET_IO_SPACE_MAP) CoreGetIoSpaceMap, // GetIoSpaceMap | |
116 | (EFI_DISPATCH) CoreDispatcher, // Dispatch | |
117 | (EFI_SCHEDULE) CoreSchedule, // Schedule | |
118 | (EFI_TRUST) CoreTrust, // Trust | |
119 | (EFI_PROCESS_FIRMWARE_VOLUME) CoreProcessFirmwareVolume, // ProcessFirmwareVolume | |
120 | }; | |
121 | ||
122 | EFI_SYSTEM_TABLE mEfiSystemTableTemplate = { | |
123 | { | |
124 | EFI_SYSTEM_TABLE_SIGNATURE, // Signature | |
125 | EFI_SYSTEM_TABLE_REVISION, // Revision | |
126 | sizeof (EFI_SYSTEM_TABLE), // HeaderSize | |
127 | 0, // CRC32 | |
128 | 0 // Reserved | |
129 | }, | |
130 | NULL, // FirmwareVendor | |
131 | 0, // FirmwareRevision | |
132 | NULL, // ConsoleInHandle | |
133 | NULL, // ConIn | |
134 | NULL, // ConsoleOutHandle | |
135 | NULL, // ConOut | |
136 | NULL, // StandardErrorHandle | |
137 | NULL, // StdErr | |
138 | NULL, // RuntimeServices | |
139 | &mBootServices, // BootServices | |
140 | 0, // NumberOfConfigurationTableEntries | |
141 | NULL // ConfigurationTable | |
142 | }; | |
143 | ||
144 | EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = { | |
145 | { | |
146 | EFI_RUNTIME_SERVICES_SIGNATURE, // Signature | |
147 | EFI_RUNTIME_SERVICES_REVISION, // Revision | |
148 | sizeof (EFI_RUNTIME_SERVICES), // HeaderSize | |
149 | 0, // CRC32 | |
150 | 0 // Reserved | |
151 | }, | |
152 | (EFI_GET_TIME) CoreEfiNotAvailableYetArg2, // GetTime | |
153 | (EFI_SET_TIME) CoreEfiNotAvailableYetArg1, // SetTime | |
154 | (EFI_GET_WAKEUP_TIME) CoreEfiNotAvailableYetArg3, // GetWakeupTime | |
155 | (EFI_SET_WAKEUP_TIME) CoreEfiNotAvailableYetArg2, // SetWakeupTime | |
156 | (EFI_SET_VIRTUAL_ADDRESS_MAP) CoreEfiNotAvailableYetArg4, // SetVirtualAddressMap | |
157 | (EFI_CONVERT_POINTER) CoreEfiNotAvailableYetArg2, // ConvertPointer | |
158 | (EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable | |
159 | (EFI_GET_NEXT_VARIABLE_NAME) CoreEfiNotAvailableYetArg3, // GetNextVariableName | |
160 | (EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable | |
161 | (EFI_GET_NEXT_HIGH_MONO_COUNT) CoreEfiNotAvailableYetArg1, // GetNextHighMonotonicCount | |
162 | (EFI_RESET_SYSTEM) CoreEfiNotAvailableYetArg4, // ResetSystem | |
163 | (EFI_UPDATE_CAPSULE) CoreEfiNotAvailableYetArg3, // UpdateCapsule | |
164 | (EFI_QUERY_CAPSULE_CAPABILITIES) CoreEfiNotAvailableYetArg4, // QueryCapsuleCapabilities | |
165 | (EFI_QUERY_VARIABLE_INFO) CoreEfiNotAvailableYetArg4 // QueryVariableInfo | |
166 | }; | |
167 | ||
168 | EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate = { | |
169 | INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.ImageHead), | |
170 | INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.EventHead), | |
171 | ||
172 | // | |
173 | // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will | |
174 | // prevent people from having pointer math bugs in their code. | |
175 | // now you have to use *DescriptorSize to make things work. | |
176 | // | |
177 | sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)), | |
178 | EFI_MEMORY_DESCRIPTOR_VERSION, | |
179 | 0, | |
180 | NULL, | |
181 | NULL, | |
182 | FALSE, | |
183 | FALSE | |
184 | }; | |
185 | ||
186 | EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate; | |
187 | ||
188 | // | |
189 | // DXE Core Global Variables for the EFI System Table, Boot Services Table, | |
190 | // DXE Services Table, and Runtime Services Table | |
191 | // | |
192 | EFI_DXE_SERVICES *gDxeCoreDS = &mDxeServices; | |
193 | EFI_SYSTEM_TABLE *gDxeCoreST = NULL; | |
194 | ||
195 | // | |
196 | // For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory | |
197 | // but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it | |
198 | // a value that will not cause debug infrastructure to crash early on. | |
199 | // | |
200 | EFI_RUNTIME_SERVICES *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate; | |
201 | EFI_HANDLE gDxeCoreImageHandle = NULL; | |
202 | ||
203 | ||
204 | // | |
205 | // EFI Decompress Protocol | |
206 | // | |
207 | EFI_DECOMPRESS_PROTOCOL gEfiDecompress = { | |
208 | DxeMainUefiDecompressGetInfo, | |
209 | DxeMainUefiDecompress | |
210 | }; | |
211 | ||
212 | // | |
213 | // Main entry point to the DXE Core | |
214 | // | |
215 | ||
216 | /** | |
217 | Main entry point to DXE Core. | |
218 | ||
219 | @param HobStart Pointer to the beginning of the HOB List from PEI. | |
220 | ||
221 | @return This function should never return. | |
222 | ||
223 | **/ | |
224 | VOID | |
225 | EFIAPI | |
226 | DxeMain ( | |
227 | IN VOID *HobStart | |
228 | ) | |
229 | { | |
230 | EFI_STATUS Status; | |
231 | EFI_PHYSICAL_ADDRESS MemoryBaseAddress; | |
232 | UINT64 MemoryLength; | |
233 | ||
234 | // | |
235 | // Initialize Memory Services | |
236 | // | |
237 | CoreInitializeMemoryServices (&HobStart, &MemoryBaseAddress, &MemoryLength); | |
238 | ||
239 | // | |
240 | // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData | |
241 | // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table | |
242 | // | |
243 | gDxeCoreST = AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate); | |
244 | ASSERT (gDxeCoreST != NULL); | |
245 | ||
246 | gDxeCoreRT = AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate); | |
247 | ASSERT (gDxeCoreRT != NULL); | |
248 | ||
249 | gDxeCoreST->RuntimeServices = gDxeCoreRT; | |
250 | ||
251 | // | |
252 | // Start the Image Services. | |
253 | // | |
254 | Status = CoreInitializeImageServices (HobStart); | |
255 | ASSERT_EFI_ERROR (Status); | |
256 | ||
257 | // | |
258 | // Call constructor for all libraries | |
259 | // | |
260 | ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST); | |
261 | PERF_END (NULL,"PEI", NULL, 0) ; | |
262 | PERF_START (NULL,"DXE", NULL, 0) ; | |
263 | ||
264 | // | |
265 | // Initialize the Global Coherency Domain Services | |
266 | // | |
267 | Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength); | |
268 | ASSERT_EFI_ERROR (Status); | |
269 | ||
270 | // | |
271 | // Install the DXE Services Table into the EFI System Tables's Configuration Table | |
272 | // | |
273 | Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDxeCoreDS); | |
274 | ASSERT_EFI_ERROR (Status); | |
275 | ||
276 | // | |
277 | // Install the HOB List into the EFI System Tables's Configuration Table | |
278 | // | |
279 | Status = CoreInstallConfigurationTable (&gEfiHobListGuid, HobStart); | |
280 | ASSERT_EFI_ERROR (Status); | |
281 | ||
282 | // | |
283 | // Install Memory Type Information Table into the EFI System Tables's Configuration Table | |
284 | // | |
285 | Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation); | |
286 | ASSERT_EFI_ERROR (Status); | |
287 | ||
288 | // | |
289 | // Report Status Code here for DXE_ENTRY_POINT once it is available | |
290 | // | |
291 | REPORT_STATUS_CODE ( | |
292 | EFI_PROGRESS_CODE, | |
293 | FixedPcdGet32(PcdStatusCodeValueDxeCoreEntry) | |
294 | ); | |
295 | ||
296 | // | |
297 | // Create the aligned system table pointer structure that is used by external | |
298 | // debuggers to locate the system table... Also, install debug image info | |
299 | // configuration table. | |
300 | // | |
301 | CoreInitializeDebugImageInfoTable (); | |
302 | CoreNewDebugImageInfoEntry ( | |
303 | EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL, | |
304 | gDxeCoreLoadedImage, | |
305 | gDxeCoreImageHandle | |
306 | ); | |
307 | ||
308 | DEBUG ((DEBUG_INFO | DEBUG_LOAD, "HOBLIST address in DXE = 0x%p\n", HobStart)); | |
309 | ||
310 | // | |
311 | // Initialize the Event Services | |
312 | // | |
313 | Status = CoreInitializeEventServices (); | |
314 | ASSERT_EFI_ERROR (Status); | |
315 | ||
316 | ||
317 | // | |
318 | // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs | |
319 | // | |
320 | // These Protocols are not architectural. This implementation is sharing code between | |
321 | // PEI and DXE in order to save FLASH space. These Protocols could also be implemented | |
322 | // as part of the DXE Core. However, that would also require the DXE Core to be ported | |
323 | // each time a different CPU is used, a different Decompression algorithm is used, or a | |
324 | // different Image type is used. By placing these Protocols in PEI, the DXE Core remains | |
325 | // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform, | |
326 | // and from CPU to CPU. | |
327 | // | |
328 | ||
329 | // | |
330 | // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components | |
331 | // | |
332 | Status = CoreInstallMultipleProtocolInterfaces ( | |
333 | &mDecompressHandle, | |
334 | &gEfiDecompressProtocolGuid, &gEfiDecompress, | |
335 | NULL | |
336 | ); | |
337 | ASSERT_EFI_ERROR (Status); | |
338 | ||
339 | // | |
340 | // Register for the GUIDs of the Architectural Protocols, so the rest of the | |
341 | // EFI Boot Services and EFI Runtime Services tables can be filled in. | |
342 | // | |
343 | CoreNotifyOnArchProtocolInstallation (); | |
344 | ||
345 | // | |
346 | // Produce Firmware Volume Protocols, one for each FV in the HOB list. | |
347 | // | |
348 | Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gDxeCoreST); | |
349 | ASSERT_EFI_ERROR (Status); | |
350 | ||
351 | Status = FwVolDriverInit (gDxeCoreImageHandle, gDxeCoreST); | |
352 | ASSERT_EFI_ERROR (Status); | |
353 | ||
354 | // | |
355 | // Produce the Section Extraction Protocol | |
356 | // | |
357 | Status = InitializeSectionExtraction (gDxeCoreImageHandle, gDxeCoreST); | |
358 | ASSERT_EFI_ERROR (Status); | |
359 | ||
360 | // | |
361 | // Initialize the DXE Dispatcher | |
362 | // | |
363 | PERF_START (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ; | |
364 | CoreInitializeDispatcher (); | |
365 | PERF_END (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ; | |
366 | ||
367 | // | |
368 | // Invoke the DXE Dispatcher | |
369 | // | |
370 | PERF_START (NULL, "CoreDispatcher", "DxeMain", 0); | |
371 | CoreDispatcher (); | |
372 | PERF_END (NULL, "CoreDispatcher", "DxeMain", 0); | |
373 | ||
374 | // | |
375 | // Display Architectural protocols that were not loaded if this is DEBUG build | |
376 | // | |
377 | DEBUG_CODE_BEGIN (); | |
378 | CoreDisplayMissingArchProtocols (); | |
379 | DEBUG_CODE_END (); | |
380 | ||
381 | // | |
382 | // Display any drivers that were not dispatched because dependency expression | |
383 | // evaluated to false if this is a debug build | |
384 | // | |
385 | DEBUG_CODE_BEGIN (); | |
386 | CoreDisplayDiscoveredNotDispatched (); | |
387 | DEBUG_CODE_END (); | |
388 | ||
389 | // | |
390 | // Assert if the Architectural Protocols are not present. | |
391 | // | |
392 | ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ()); | |
393 | ||
394 | // | |
395 | // Report Status code before transfer control to BDS | |
396 | // | |
397 | REPORT_STATUS_CODE ( | |
398 | EFI_PROGRESS_CODE, | |
399 | FixedPcdGet32 (PcdStatusCodeValueDxeCoreHandoffToBds) | |
400 | ); | |
401 | ||
402 | // | |
403 | // Transfer control to the BDS Architectural Protocol | |
404 | // | |
405 | gBds->Entry (gBds); | |
406 | ||
407 | // | |
408 | // BDS should never return | |
409 | // | |
410 | ASSERT (FALSE); | |
411 | CpuDeadLoop (); | |
412 | } | |
413 | ||
414 | ||
415 | ||
416 | /** | |
417 | Place holder function until all the Boot Services and Runtime Services are | |
418 | available. | |
419 | ||
420 | @return EFI_NOT_AVAILABLE_YET | |
421 | ||
422 | **/ | |
423 | EFI_STATUS | |
424 | EFIAPI | |
425 | CoreEfiNotAvailableYetArg0 ( | |
426 | VOID | |
427 | ) | |
428 | { | |
429 | // | |
430 | // This function should never be executed. If it does, then the architectural protocols | |
431 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the | |
432 | // DXE Core and all the Architectural Protocols are complete. | |
433 | // | |
434 | ||
435 | return EFI_NOT_AVAILABLE_YET; | |
436 | } | |
437 | ||
438 | ||
439 | /** | |
440 | Place holder function until all the Boot Services and Runtime Services are | |
441 | available. | |
442 | ||
443 | @param Arg1 Undefined | |
444 | ||
445 | @return EFI_NOT_AVAILABLE_YET | |
446 | ||
447 | **/ | |
448 | EFI_STATUS | |
449 | EFIAPI | |
450 | CoreEfiNotAvailableYetArg1 ( | |
451 | UINTN Arg1 | |
452 | ) | |
453 | { | |
454 | // | |
455 | // This function should never be executed. If it does, then the architectural protocols | |
456 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the | |
457 | // DXE Core and all the Architectural Protocols are complete. | |
458 | // | |
459 | ||
460 | return EFI_NOT_AVAILABLE_YET; | |
461 | } | |
462 | ||
463 | ||
464 | /** | |
465 | Place holder function until all the Boot Services and Runtime Services are available. | |
466 | ||
467 | @param Arg1 Undefined | |
468 | @param Arg2 Undefined | |
469 | ||
470 | @return EFI_NOT_AVAILABLE_YET | |
471 | ||
472 | **/ | |
473 | EFI_STATUS | |
474 | EFIAPI | |
475 | CoreEfiNotAvailableYetArg2 ( | |
476 | UINTN Arg1, | |
477 | UINTN Arg2 | |
478 | ) | |
479 | { | |
480 | // | |
481 | // This function should never be executed. If it does, then the architectural protocols | |
482 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the | |
483 | // DXE Core and all the Architectural Protocols are complete. | |
484 | // | |
485 | ||
486 | return EFI_NOT_AVAILABLE_YET; | |
487 | } | |
488 | ||
489 | ||
490 | /** | |
491 | Place holder function until all the Boot Services and Runtime Services are available. | |
492 | ||
493 | @param Arg1 Undefined | |
494 | @param Arg2 Undefined | |
495 | @param Arg3 Undefined | |
496 | ||
497 | @return EFI_NOT_AVAILABLE_YET | |
498 | ||
499 | **/ | |
500 | EFI_STATUS | |
501 | EFIAPI | |
502 | CoreEfiNotAvailableYetArg3 ( | |
503 | UINTN Arg1, | |
504 | UINTN Arg2, | |
505 | UINTN Arg3 | |
506 | ) | |
507 | { | |
508 | // | |
509 | // This function should never be executed. If it does, then the architectural protocols | |
510 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the | |
511 | // DXE Core and all the Architectural Protocols are complete. | |
512 | // | |
513 | ||
514 | return EFI_NOT_AVAILABLE_YET; | |
515 | } | |
516 | ||
517 | ||
518 | /** | |
519 | Place holder function until all the Boot Services and Runtime Services are available. | |
520 | ||
521 | @param Arg1 Undefined | |
522 | @param Arg2 Undefined | |
523 | @param Arg3 Undefined | |
524 | @param Arg4 Undefined | |
525 | ||
526 | @return EFI_NOT_AVAILABLE_YET | |
527 | ||
528 | **/ | |
529 | EFI_STATUS | |
530 | EFIAPI | |
531 | CoreEfiNotAvailableYetArg4 ( | |
532 | UINTN Arg1, | |
533 | UINTN Arg2, | |
534 | UINTN Arg3, | |
535 | UINTN Arg4 | |
536 | ) | |
537 | { | |
538 | // | |
539 | // This function should never be executed. If it does, then the architectural protocols | |
540 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the | |
541 | // DXE Core and all the Architectural Protocols are complete. | |
542 | // | |
543 | ||
544 | return EFI_NOT_AVAILABLE_YET; | |
545 | } | |
546 | ||
547 | ||
548 | /** | |
549 | Place holder function until all the Boot Services and Runtime Services are available. | |
550 | ||
551 | @param Arg1 Undefined | |
552 | @param Arg2 Undefined | |
553 | @param Arg3 Undefined | |
554 | @param Arg4 Undefined | |
555 | @param Arg5 Undefined | |
556 | ||
557 | @return EFI_NOT_AVAILABLE_YET | |
558 | ||
559 | **/ | |
560 | EFI_STATUS | |
561 | EFIAPI | |
562 | CoreEfiNotAvailableYetArg5 ( | |
563 | UINTN Arg1, | |
564 | UINTN Arg2, | |
565 | UINTN Arg3, | |
566 | UINTN Arg4, | |
567 | UINTN Arg5 | |
568 | ) | |
569 | { | |
570 | // | |
571 | // This function should never be executed. If it does, then the architectural protocols | |
572 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the | |
573 | // DXE Core and all the Architectural Protocols are complete. | |
574 | // | |
575 | ||
576 | return EFI_NOT_AVAILABLE_YET; | |
577 | } | |
578 | ||
579 | ||
580 | /** | |
581 | Calcualte the 32-bit CRC in a EFI table using the service provided by the | |
582 | gRuntime service. | |
583 | ||
584 | @param Hdr Pointer to an EFI standard header | |
585 | ||
586 | **/ | |
587 | VOID | |
588 | CalculateEfiHdrCrc ( | |
589 | IN OUT EFI_TABLE_HEADER *Hdr | |
590 | ) | |
591 | { | |
592 | UINT32 Crc; | |
593 | ||
594 | Hdr->CRC32 = 0; | |
595 | ||
596 | // | |
597 | // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then | |
598 | // Crc will come back as zero if we set it to zero here | |
599 | // | |
600 | Crc = 0; | |
601 | gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc); | |
602 | Hdr->CRC32 = Crc; | |
603 | } | |
604 | ||
605 | ||
606 | /** | |
607 | Terminates all boot services. | |
608 | ||
609 | @param ImageHandle Handle that identifies the exiting image. | |
610 | @param MapKey Key to the latest memory map. | |
611 | ||
612 | @retval EFI_SUCCESS Boot Services terminated | |
613 | @retval EFI_INVALID_PARAMETER MapKey is incorrect. | |
614 | ||
615 | **/ | |
616 | EFI_STATUS | |
617 | EFIAPI | |
618 | CoreExitBootServices ( | |
619 | IN EFI_HANDLE ImageHandle, | |
620 | IN UINTN MapKey | |
621 | ) | |
622 | { | |
623 | EFI_STATUS Status; | |
624 | ||
625 | // | |
626 | // Terminate memory services if the MapKey matches | |
627 | // | |
628 | Status = CoreTerminateMemoryMap (MapKey); | |
629 | if (EFI_ERROR (Status)) { | |
630 | return Status; | |
631 | } | |
632 | ||
633 | // | |
634 | // Disable Timer | |
635 | // | |
636 | gTimer->SetTimerPeriod (gTimer, 0); | |
637 | ||
638 | // | |
639 | // Notify other drivers that we are exiting boot services. | |
640 | // | |
641 | CoreNotifySignalList (&gEfiEventExitBootServicesGuid); | |
642 | ||
643 | // | |
644 | // Disable CPU Interrupts | |
645 | // | |
646 | gCpu->DisableInterrupt (gCpu); | |
647 | ||
648 | // | |
649 | // Report that ExitBootServices() has been called | |
650 | // | |
651 | REPORT_STATUS_CODE ( | |
652 | EFI_PROGRESS_CODE, | |
653 | FixedPcdGet32 (PcdStatusCodeValueBootServiceExit) | |
654 | ); | |
655 | ||
656 | // | |
657 | // Clear the non-runtime values of the EFI System Table | |
658 | // | |
659 | gDxeCoreST->BootServices = NULL; | |
660 | gDxeCoreST->ConIn = NULL; | |
661 | gDxeCoreST->ConsoleInHandle = NULL; | |
662 | gDxeCoreST->ConOut = NULL; | |
663 | gDxeCoreST->ConsoleOutHandle = NULL; | |
664 | gDxeCoreST->StdErr = NULL; | |
665 | gDxeCoreST->StandardErrorHandle = NULL; | |
666 | ||
667 | // | |
668 | // Recompute the 32-bit CRC of the EFI System Table | |
669 | // | |
670 | CalculateEfiHdrCrc (&gDxeCoreST->Hdr); | |
671 | ||
672 | // | |
673 | // Zero out the Boot Service Table | |
674 | // | |
675 | ZeroMem (gBS, sizeof (EFI_BOOT_SERVICES)); | |
676 | gBS = NULL; | |
677 | ||
678 | // | |
679 | // Update the AtRuntime field in Runtiem AP. | |
680 | // | |
681 | gRuntime->AtRuntime = TRUE; | |
682 | ||
683 | return Status; | |
684 | } | |
685 | ||
686 | ||
687 | /** | |
688 | Given a compressed source buffer, this function retrieves the size of the | |
689 | uncompressed buffer and the size of the scratch buffer required to decompress | |
690 | the compressed source buffer. | |
691 | ||
692 | The GetInfo() function retrieves the size of the uncompressed buffer and the | |
693 | temporary scratch buffer required to decompress the buffer specified by Source | |
694 | and SourceSize. If the size of the uncompressed buffer or the size of the | |
695 | scratch buffer cannot be determined from the compressed data specified by | |
696 | Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the | |
697 | size of the uncompressed buffer is returned in DestinationSize, the size of | |
698 | the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned. | |
699 | The GetInfo() function does not have scratch buffer available to perform a | |
700 | thorough checking of the validity of the source data. It just retrieves the | |
701 | "Original Size" field from the beginning bytes of the source data and output | |
702 | it as DestinationSize. And ScratchSize is specific to the decompression | |
703 | implementation. | |
704 | ||
705 | @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance. | |
706 | @param Source The source buffer containing the compressed data. | |
707 | @param SourceSize The size, in bytes, of the source buffer. | |
708 | @param DestinationSize A pointer to the size, in bytes, of the | |
709 | uncompressed buffer that will be generated when the | |
710 | compressed buffer specified by Source and | |
711 | SourceSize is decompressed. | |
712 | @param ScratchSize A pointer to the size, in bytes, of the scratch | |
713 | buffer that is required to decompress the | |
714 | compressed buffer specified by Source and | |
715 | SourceSize. | |
716 | ||
717 | @retval EFI_SUCCESS The size of the uncompressed data was returned in | |
718 | DestinationSize and the size of the scratch buffer | |
719 | was returned in ScratchSize. | |
720 | @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of | |
721 | the scratch buffer cannot be determined from the | |
722 | compressed data specified by Source and | |
723 | SourceSize. | |
724 | ||
725 | **/ | |
726 | EFI_STATUS | |
727 | EFIAPI | |
728 | DxeMainUefiDecompressGetInfo ( | |
729 | IN EFI_DECOMPRESS_PROTOCOL *This, | |
730 | IN VOID *Source, | |
731 | IN UINT32 SourceSize, | |
732 | OUT UINT32 *DestinationSize, | |
733 | OUT UINT32 *ScratchSize | |
734 | ) | |
735 | { | |
736 | if (Source == NULL || DestinationSize == NULL || ScratchSize == NULL) { | |
737 | return EFI_INVALID_PARAMETER; | |
738 | } | |
739 | return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize); | |
740 | } | |
741 | ||
742 | ||
743 | /** | |
744 | Decompresses a compressed source buffer. | |
745 | ||
746 | The Decompress() function extracts decompressed data to its original form. | |
747 | This protocol is designed so that the decompression algorithm can be | |
748 | implemented without using any memory services. As a result, the Decompress() | |
749 | Function is not allowed to call AllocatePool() or AllocatePages() in its | |
750 | implementation. It is the caller's responsibility to allocate and free the | |
751 | Destination and Scratch buffers. | |
752 | If the compressed source data specified by Source and SourceSize is | |
753 | sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If | |
754 | the compressed source data specified by Source and SourceSize is not in a | |
755 | valid compressed data format, then EFI_INVALID_PARAMETER is returned. | |
756 | ||
757 | @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance. | |
758 | @param Source The source buffer containing the compressed data. | |
759 | @param SourceSize SourceSizeThe size of source data. | |
760 | @param Destination On output, the destination buffer that contains | |
761 | the uncompressed data. | |
762 | @param DestinationSize The size of the destination buffer. The size of | |
763 | the destination buffer needed is obtained from | |
764 | EFI_DECOMPRESS_PROTOCOL.GetInfo(). | |
765 | @param Scratch A temporary scratch buffer that is used to perform | |
766 | the decompression. | |
767 | @param ScratchSize The size of scratch buffer. The size of the | |
768 | scratch buffer needed is obtained from GetInfo(). | |
769 | ||
770 | @retval EFI_SUCCESS Decompression completed successfully, and the | |
771 | uncompressed buffer is returned in Destination. | |
772 | @retval EFI_INVALID_PARAMETER The source buffer specified by Source and | |
773 | SourceSize is corrupted (not in a valid | |
774 | compressed format). | |
775 | ||
776 | **/ | |
777 | EFI_STATUS | |
778 | EFIAPI | |
779 | DxeMainUefiDecompress ( | |
780 | IN EFI_DECOMPRESS_PROTOCOL *This, | |
781 | IN VOID *Source, | |
782 | IN UINT32 SourceSize, | |
783 | IN OUT VOID *Destination, | |
784 | IN UINT32 DestinationSize, | |
785 | IN OUT VOID *Scratch, | |
786 | IN UINT32 ScratchSize | |
787 | ) | |
788 | { | |
789 | EFI_STATUS Status; | |
790 | UINT32 TestDestinationSize; | |
791 | UINT32 TestScratchSize; | |
792 | ||
793 | if (Source == NULL || Destination== NULL || Scratch == NULL) { | |
794 | return EFI_INVALID_PARAMETER; | |
795 | } | |
796 | ||
797 | Status = UefiDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize); | |
798 | if (EFI_ERROR (Status)) { | |
799 | return Status; | |
800 | } | |
801 | ||
802 | if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) { | |
803 | return RETURN_INVALID_PARAMETER; | |
804 | } | |
805 | ||
806 | return UefiDecompress (Source, Destination, Scratch); | |
807 | } |