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