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