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