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