]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
1) Change GUID of emuvariable module.
[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
6979fd93 302 // The HobStart is relocated in gcd service init. Sync mHobStart varible.\r
303 //\r
304 mHobStart = HobStart;\r
305 \r
28a00297 306 // Install the DXE Services Table into the EFI System Tables's Configuration Table\r
307 //\r
308 Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDxeCoreDS);\r
309 ASSERT_EFI_ERROR (Status);\r
310\r
311 //\r
312 // Install the HOB List into the EFI System Tables's Configuration Table\r
313 //\r
314 Status = CoreInstallConfigurationTable (&gEfiHobListGuid, HobStart);\r
315 ASSERT_EFI_ERROR (Status);\r
316\r
317 //\r
318 // Install Memory Type Information Table into the EFI System Tables's Configuration Table\r
319 //\r
320 Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation);\r
321 ASSERT_EFI_ERROR (Status);\r
322\r
323 //\r
324 // Initialize the ReportStatusCode with PEI version, if available\r
325 //\r
326 CoreGetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **)&gStatusCode->ReportStatusCode);\r
327\r
328 //\r
329 // Report Status Code here for DXE_ENTRY_POINT once it is available\r
330 //\r
331 CoreReportProgressCode ((EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT));\r
332\r
333 //\r
334 // Create the aligned system table pointer structure that is used by external\r
335 // debuggers to locate the system table... Also, install debug image info\r
336 // configuration table.\r
337 //\r
338 CoreInitializeDebugImageInfoTable ();\r
339 CoreNewDebugImageInfoEntry (\r
340 EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,\r
341 gDxeCoreLoadedImage,\r
342 gDxeCoreImageHandle\r
343 );\r
344\r
34ec75fc 345 DEBUG ((EFI_D_INFO | EFI_D_LOAD, "HOBLIST address in DXE = 0x%016lx\n", (UINT64) (UINTN) HobStart));\r
28a00297 346\r
347 //\r
348 // Initialize the Event Services\r
349 //\r
350 Status = CoreInitializeEventServices ();\r
351 ASSERT_EFI_ERROR (Status);\r
352\r
353\r
354 //\r
355 // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs\r
356 //\r
357 // These Protocols are not architectural. This implementation is sharing code between\r
358 // PEI and DXE in order to save FLASH space. These Protocols could also be implemented\r
359 // as part of the DXE Core. However, that would also require the DXE Core to be ported\r
360 // each time a different CPU is used, a different Decompression algorithm is used, or a\r
361 // different Image type is used. By placing these Protocols in PEI, the DXE Core remains\r
362 // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,\r
363 // and from CPU to CPU.\r
364 //\r
365\r
366 //\r
367 // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components\r
368 //\r
369 Status = CoreInstallMultipleProtocolInterfaces (\r
370 &mDecompressHandle,\r
371 &gEfiDecompressProtocolGuid, &gEfiDecompress,\r
372 NULL\r
373 );\r
374 ASSERT_EFI_ERROR (Status);\r
375\r
28a00297 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