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