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