]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Dxe/DxeMain.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / DxeMain.h
1 /** @file
2 The internal header file includes the common header files, defines
3 internal structure and functions used by DxeCore module.
4
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef _DXE_MAIN_H_
11 #define _DXE_MAIN_H_
12
13 #include <PiDxe.h>
14
15 #include <Protocol/LoadedImage.h>
16 #include <Protocol/GuidedSectionExtraction.h>
17 #include <Protocol/DevicePath.h>
18 #include <Protocol/Runtime.h>
19 #include <Protocol/LoadFile.h>
20 #include <Protocol/LoadFile2.h>
21 #include <Protocol/DriverBinding.h>
22 #include <Protocol/VariableWrite.h>
23 #include <Protocol/PlatformDriverOverride.h>
24 #include <Protocol/Variable.h>
25 #include <Protocol/Timer.h>
26 #include <Protocol/SimpleFileSystem.h>
27 #include <Protocol/Bds.h>
28 #include <Protocol/RealTimeClock.h>
29 #include <Protocol/WatchdogTimer.h>
30 #include <Protocol/FirmwareVolume2.h>
31 #include <Protocol/MonotonicCounter.h>
32 #include <Protocol/StatusCode.h>
33 #include <Protocol/Decompress.h>
34 #include <Protocol/LoadPe32Image.h>
35 #include <Protocol/Security.h>
36 #include <Protocol/Security2.h>
37 #include <Protocol/Reset.h>
38 #include <Protocol/Cpu.h>
39 #include <Protocol/Metronome.h>
40 #include <Protocol/FirmwareVolumeBlock.h>
41 #include <Protocol/Capsule.h>
42 #include <Protocol/BusSpecificDriverOverride.h>
43 #include <Protocol/DriverFamilyOverride.h>
44 #include <Protocol/TcgService.h>
45 #include <Protocol/HiiPackageList.h>
46 #include <Protocol/SmmBase2.h>
47 #include <Protocol/PeCoffImageEmulator.h>
48 #include <Guid/MemoryTypeInformation.h>
49 #include <Guid/FirmwareFileSystem2.h>
50 #include <Guid/FirmwareFileSystem3.h>
51 #include <Guid/HobList.h>
52 #include <Guid/DebugImageInfoTable.h>
53 #include <Guid/FileInfo.h>
54 #include <Guid/Apriori.h>
55 #include <Guid/DxeServices.h>
56 #include <Guid/MemoryAllocationHob.h>
57 #include <Guid/EventLegacyBios.h>
58 #include <Guid/EventGroup.h>
59 #include <Guid/EventExitBootServiceFailed.h>
60 #include <Guid/LoadModuleAtFixedAddress.h>
61 #include <Guid/IdleLoopEvent.h>
62 #include <Guid/VectorHandoffTable.h>
63 #include <Ppi/VectorHandoffInfo.h>
64 #include <Guid/MemoryProfile.h>
65
66 #include <Library/DxeCoreEntryPoint.h>
67 #include <Library/DebugLib.h>
68 #include <Library/UefiLib.h>
69 #include <Library/BaseLib.h>
70 #include <Library/HobLib.h>
71 #include <Library/PerformanceLib.h>
72 #include <Library/UefiDecompressLib.h>
73 #include <Library/ExtractGuidedSectionLib.h>
74 #include <Library/CacheMaintenanceLib.h>
75 #include <Library/BaseMemoryLib.h>
76 #include <Library/PeCoffLib.h>
77 #include <Library/PeCoffGetEntryPointLib.h>
78 #include <Library/PeCoffExtraActionLib.h>
79 #include <Library/PcdLib.h>
80 #include <Library/MemoryAllocationLib.h>
81 #include <Library/DevicePathLib.h>
82 #include <Library/UefiBootServicesTableLib.h>
83 #include <Library/ReportStatusCodeLib.h>
84 #include <Library/DxeServicesLib.h>
85 #include <Library/DebugAgentLib.h>
86 #include <Library/CpuExceptionHandlerLib.h>
87
88 //
89 // attributes for reserved memory before it is promoted to system memory
90 //
91 #define EFI_MEMORY_PRESENT 0x0100000000000000ULL
92 #define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL
93 #define EFI_MEMORY_TESTED 0x0400000000000000ULL
94
95 //
96 // range for memory mapped port I/O on IPF
97 //
98 #define EFI_MEMORY_PORT_IO 0x4000000000000000ULL
99
100 ///
101 /// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependency expression
102 /// to save time. A EFI_DEP_PUSH is evaluated one an
103 /// replaced with EFI_DEP_REPLACE_TRUE. If PI spec's Vol 2
104 /// Driver Execution Environment Core Interface use 0xff
105 /// as new DEPEX opcode. EFI_DEP_REPLACE_TRUE should be
106 /// defined to a new value that is not conflicting with PI spec.
107 ///
108 #define EFI_DEP_REPLACE_TRUE 0xff
109
110 ///
111 /// Define the initial size of the dependency expression evaluation stack
112 ///
113 #define DEPEX_STACK_SIZE_INCREMENT 0x1000
114
115 typedef struct {
116 EFI_GUID *ProtocolGuid;
117 VOID **Protocol;
118 EFI_EVENT Event;
119 VOID *Registration;
120 BOOLEAN Present;
121 } EFI_CORE_PROTOCOL_NOTIFY_ENTRY;
122
123 //
124 // DXE Dispatcher Data structures
125 //
126
127 #define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w')
128 typedef struct {
129 UINTN Signature;
130 LIST_ENTRY Link; // mFvHandleList
131 EFI_HANDLE Handle;
132 EFI_GUID FvNameGuid;
133 } KNOWN_HANDLE;
134
135 #define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r')
136 typedef struct {
137 UINTN Signature;
138 LIST_ENTRY Link; // mDriverList
139
140 LIST_ENTRY ScheduledLink; // mScheduledQueue
141
142 EFI_HANDLE FvHandle;
143 EFI_GUID FileName;
144 EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath;
145 EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
146
147 VOID *Depex;
148 UINTN DepexSize;
149
150 BOOLEAN Before;
151 BOOLEAN After;
152 EFI_GUID BeforeAfterGuid;
153
154 BOOLEAN Dependent;
155 BOOLEAN Unrequested;
156 BOOLEAN Scheduled;
157 BOOLEAN Untrusted;
158 BOOLEAN Initialized;
159 BOOLEAN DepexProtocolError;
160
161 EFI_HANDLE ImageHandle;
162 BOOLEAN IsFvImage;
163 } EFI_CORE_DRIVER_ENTRY;
164
165 //
166 // The data structure of GCD memory map entry
167 //
168 #define EFI_GCD_MAP_SIGNATURE SIGNATURE_32('g','c','d','m')
169 typedef struct {
170 UINTN Signature;
171 LIST_ENTRY Link;
172 EFI_PHYSICAL_ADDRESS BaseAddress;
173 UINT64 EndAddress;
174 UINT64 Capabilities;
175 UINT64 Attributes;
176 EFI_GCD_MEMORY_TYPE GcdMemoryType;
177 EFI_GCD_IO_TYPE GcdIoType;
178 EFI_HANDLE ImageHandle;
179 EFI_HANDLE DeviceHandle;
180 } EFI_GCD_MAP_ENTRY;
181
182 #define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','d','r','i')
183
184 typedef struct {
185 UINTN Signature;
186 /// Image handle
187 EFI_HANDLE Handle;
188 /// Image type
189 UINTN Type;
190 /// If entrypoint has been called
191 BOOLEAN Started;
192 /// The image's entry point
193 EFI_IMAGE_ENTRY_POINT EntryPoint;
194 /// loaded image protocol
195 EFI_LOADED_IMAGE_PROTOCOL Info;
196 /// Location in memory
197 EFI_PHYSICAL_ADDRESS ImageBasePage;
198 /// Number of pages
199 UINTN NumberOfPages;
200 /// Original fixup data
201 CHAR8 *FixupData;
202 /// Tpl of started image
203 EFI_TPL Tpl;
204 /// Status returned by started image
205 EFI_STATUS Status;
206 /// Size of ExitData from started image
207 UINTN ExitDataSize;
208 /// Pointer to exit data from started image
209 VOID *ExitData;
210 /// Pointer to pool allocation for context save/restore
211 VOID *JumpBuffer;
212 /// Pointer to buffer for context save/restore
213 BASE_LIBRARY_JUMP_BUFFER *JumpContext;
214 /// Machine type from PE image
215 UINT16 Machine;
216 /// PE/COFF Image Emulator Protocol pointer
217 EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *PeCoffEmu;
218 /// Runtime image list
219 EFI_RUNTIME_IMAGE_ENTRY *RuntimeData;
220 /// Pointer to Loaded Image Device Path Protocol
221 EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
222 /// PeCoffLoader ImageContext
223 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
224 /// Status returned by LoadImage() service.
225 EFI_STATUS LoadImageStatus;
226 } LOADED_IMAGE_PRIVATE_DATA;
227
228 #define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \
229 CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE)
230
231 #define IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE SIGNATURE_32 ('I','P','R','C')
232
233 typedef struct {
234 UINT32 Signature;
235 LIST_ENTRY Link;
236 EFI_PHYSICAL_ADDRESS CodeSegmentBase;
237 UINT64 CodeSegmentSize;
238 } IMAGE_PROPERTIES_RECORD_CODE_SECTION;
239
240 #define IMAGE_PROPERTIES_RECORD_SIGNATURE SIGNATURE_32 ('I','P','R','D')
241
242 typedef struct {
243 UINT32 Signature;
244 LIST_ENTRY Link;
245 EFI_PHYSICAL_ADDRESS ImageBase;
246 UINT64 ImageSize;
247 UINTN CodeSegmentCount;
248 LIST_ENTRY CodeSegmentList;
249 } IMAGE_PROPERTIES_RECORD;
250
251 //
252 // DXE Core Global Variables
253 //
254 extern EFI_SYSTEM_TABLE *gDxeCoreST;
255 extern EFI_RUNTIME_SERVICES *gDxeCoreRT;
256 extern EFI_DXE_SERVICES *gDxeCoreDS;
257 extern EFI_HANDLE gDxeCoreImageHandle;
258
259 extern BOOLEAN gMemoryMapTerminated;
260
261 extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress;
262
263 extern EFI_RUNTIME_ARCH_PROTOCOL *gRuntime;
264 extern EFI_CPU_ARCH_PROTOCOL *gCpu;
265 extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer;
266 extern EFI_METRONOME_ARCH_PROTOCOL *gMetronome;
267 extern EFI_TIMER_ARCH_PROTOCOL *gTimer;
268 extern EFI_SECURITY_ARCH_PROTOCOL *gSecurity;
269 extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2;
270 extern EFI_BDS_ARCH_PROTOCOL *gBds;
271 extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2;
272
273 extern EFI_TPL gEfiCurrentTpl;
274
275 extern EFI_GUID *gDxeCoreFileName;
276 extern EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;
277
278 extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1];
279
280 extern BOOLEAN gDispatcherRunning;
281 extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate;
282
283 extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable;
284 extern BOOLEAN gLoadFixedAddressCodeMemoryReady;
285 //
286 // Service Initialization Functions
287 //
288
289 /**
290 Called to initialize the pool.
291
292 **/
293 VOID
294 CoreInitializePool (
295 VOID
296 );
297
298 /**
299 Called to initialize the memory map and add descriptors to
300 the current descriptor list.
301 The first descriptor that is added must be general usable
302 memory as the addition allocates heap.
303
304 @param Type The type of memory to add
305 @param Start The starting address in the memory range Must be
306 page aligned
307 @param NumberOfPages The number of pages in the range
308 @param Attribute Attributes of the memory to add
309
310 @return None. The range is added to the memory map
311
312 **/
313 VOID
314 CoreAddMemoryDescriptor (
315 IN EFI_MEMORY_TYPE Type,
316 IN EFI_PHYSICAL_ADDRESS Start,
317 IN UINT64 NumberOfPages,
318 IN UINT64 Attribute
319 );
320
321 /**
322 Release memory lock on mGcdMemorySpaceLock.
323
324 **/
325 VOID
326 CoreReleaseGcdMemoryLock (
327 VOID
328 );
329
330 /**
331 Acquire memory lock on mGcdMemorySpaceLock.
332
333 **/
334 VOID
335 CoreAcquireGcdMemoryLock (
336 VOID
337 );
338
339 /**
340 External function. Initializes memory services based on the memory
341 descriptor HOBs. This function is responsible for priming the memory
342 map, so memory allocations and resource allocations can be made.
343 The first part of this function can not depend on any memory services
344 until at least one memory descriptor is provided to the memory services.
345
346 @param HobStart The start address of the HOB.
347 @param MemoryBaseAddress Start address of memory region found to init DXE
348 core.
349 @param MemoryLength Length of memory region found to init DXE core.
350
351 @retval EFI_SUCCESS Memory services successfully initialized.
352
353 **/
354 EFI_STATUS
355 CoreInitializeMemoryServices (
356 IN VOID **HobStart,
357 OUT EFI_PHYSICAL_ADDRESS *MemoryBaseAddress,
358 OUT UINT64 *MemoryLength
359 );
360
361 /**
362 External function. Initializes the GCD and memory services based on the memory
363 descriptor HOBs. This function is responsible for priming the GCD map and the
364 memory map, so memory allocations and resource allocations can be made. The
365 HobStart will be relocated to a pool buffer.
366
367 @param HobStart The start address of the HOB
368 @param MemoryBaseAddress Start address of memory region found to init DXE
369 core.
370 @param MemoryLength Length of memory region found to init DXE core.
371
372 @retval EFI_SUCCESS GCD services successfully initialized.
373
374 **/
375 EFI_STATUS
376 CoreInitializeGcdServices (
377 IN OUT VOID **HobStart,
378 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress,
379 IN UINT64 MemoryLength
380 );
381
382 /**
383 Initializes "event" support.
384
385 @retval EFI_SUCCESS Always return success
386
387 **/
388 EFI_STATUS
389 CoreInitializeEventServices (
390 VOID
391 );
392
393 /**
394 Add the Image Services to EFI Boot Services Table and install the protocol
395 interfaces for this image.
396
397 @param HobStart The HOB to initialize
398
399 @return Status code.
400
401 **/
402 EFI_STATUS
403 CoreInitializeImageServices (
404 IN VOID *HobStart
405 );
406
407 /**
408 Creates an event that is fired everytime a Protocol of a specific type is installed.
409
410 **/
411 VOID
412 CoreNotifyOnProtocolInstallation (
413 VOID
414 );
415
416 /**
417 Return TRUE if all AP services are available.
418
419 @retval EFI_SUCCESS All AP services are available
420 @retval EFI_NOT_FOUND At least one AP service is not available
421
422 **/
423 EFI_STATUS
424 CoreAllEfiServicesAvailable (
425 VOID
426 );
427
428 /**
429 Calcualte the 32-bit CRC in a EFI table using the service provided by the
430 gRuntime service.
431
432 @param Hdr Pointer to an EFI standard header
433
434 **/
435 VOID
436 CalculateEfiHdrCrc (
437 IN OUT EFI_TABLE_HEADER *Hdr
438 );
439
440 /**
441 Called by the platform code to process a tick.
442
443 @param Duration The number of 100ns elapsed since the last call
444 to TimerTick
445
446 **/
447 VOID
448 EFIAPI
449 CoreTimerTick (
450 IN UINT64 Duration
451 );
452
453 /**
454 Initialize the dispatcher. Initialize the notification function that runs when
455 an FV2 protocol is added to the system.
456
457 **/
458 VOID
459 CoreInitializeDispatcher (
460 VOID
461 );
462
463 /**
464 This is the POSTFIX version of the dependency evaluator. This code does
465 not need to handle Before or After, as it is not valid to call this
466 routine in this case. The SOR is just ignored and is a nop in the grammer.
467 POSTFIX means all the math is done on top of the stack.
468
469 @param DriverEntry DriverEntry element to update.
470
471 @retval TRUE If driver is ready to run.
472 @retval FALSE If driver is not ready to run or some fatal error
473 was found.
474
475 **/
476 BOOLEAN
477 CoreIsSchedulable (
478 IN EFI_CORE_DRIVER_ENTRY *DriverEntry
479 );
480
481 /**
482 Preprocess dependency expression and update DriverEntry to reflect the
483 state of Before, After, and SOR dependencies. If DriverEntry->Before
484 or DriverEntry->After is set it will never be cleared. If SOR is set
485 it will be cleared by CoreSchedule(), and then the driver can be
486 dispatched.
487
488 @param DriverEntry DriverEntry element to update .
489
490 @retval EFI_SUCCESS It always works.
491
492 **/
493 EFI_STATUS
494 CorePreProcessDepex (
495 IN EFI_CORE_DRIVER_ENTRY *DriverEntry
496 );
497
498 /**
499 Terminates all boot services.
500
501 @param ImageHandle Handle that identifies the exiting image.
502 @param MapKey Key to the latest memory map.
503
504 @retval EFI_SUCCESS Boot Services terminated
505 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
506
507 **/
508 EFI_STATUS
509 EFIAPI
510 CoreExitBootServices (
511 IN EFI_HANDLE ImageHandle,
512 IN UINTN MapKey
513 );
514
515 /**
516 Make sure the memory map is following all the construction rules,
517 it is the last time to check memory map error before exit boot services.
518
519 @param MapKey Memory map key
520
521 @retval EFI_INVALID_PARAMETER Memory map not consistent with construction
522 rules.
523 @retval EFI_SUCCESS Valid memory map.
524
525 **/
526 EFI_STATUS
527 CoreTerminateMemoryMap (
528 IN UINTN MapKey
529 );
530
531 /**
532 Signals all events in the EventGroup.
533
534 @param EventGroup The list to signal
535
536 **/
537 VOID
538 CoreNotifySignalList (
539 IN EFI_GUID *EventGroup
540 );
541
542 /**
543 Boot Service called to add, modify, or remove a system configuration table from
544 the EFI System Table.
545
546 @param Guid Pointer to the GUID for the entry to add, update, or
547 remove
548 @param Table Pointer to the configuration table for the entry to add,
549 update, or remove, may be NULL.
550
551 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.
552 @return EFI_INVALID_PARAMETER Input GUID not valid.
553 @return EFI_NOT_FOUND Attempted to delete non-existant entry
554 @return EFI_OUT_OF_RESOURCES Not enough memory available
555
556 **/
557 EFI_STATUS
558 EFIAPI
559 CoreInstallConfigurationTable (
560 IN EFI_GUID *Guid,
561 IN VOID *Table
562 );
563
564 /**
565 Raise the task priority level to the new level.
566 High level is implemented by disabling processor interrupts.
567
568 @param NewTpl New task priority level
569
570 @return The previous task priority level
571
572 **/
573 EFI_TPL
574 EFIAPI
575 CoreRaiseTpl (
576 IN EFI_TPL NewTpl
577 );
578
579 /**
580 Lowers the task priority to the previous value. If the new
581 priority unmasks events at a higher priority, they are dispatched.
582
583 @param NewTpl New, lower, task priority
584
585 **/
586 VOID
587 EFIAPI
588 CoreRestoreTpl (
589 IN EFI_TPL NewTpl
590 );
591
592 /**
593 Introduces a fine-grained stall.
594
595 @param Microseconds The number of microseconds to stall execution.
596
597 @retval EFI_SUCCESS Execution was stalled for at least the requested
598 amount of microseconds.
599 @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet
600
601 **/
602 EFI_STATUS
603 EFIAPI
604 CoreStall (
605 IN UINTN Microseconds
606 );
607
608 /**
609 Sets the system's watchdog timer.
610
611 @param Timeout The number of seconds to set the watchdog timer to.
612 A value of zero disables the timer.
613 @param WatchdogCode The numeric code to log on a watchdog timer timeout
614 event. The firmware reserves codes 0x0000 to 0xFFFF.
615 Loaders and operating systems may use other timeout
616 codes.
617 @param DataSize The size, in bytes, of WatchdogData.
618 @param WatchdogData A data buffer that includes a Null-terminated Unicode
619 string, optionally followed by additional binary data.
620 The string is a description that the call may use to
621 further indicate the reason to be logged with a
622 watchdog event.
623
624 @return EFI_SUCCESS Timeout has been set
625 @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
626 @return EFI_UNSUPPORTED System does not have a timer (currently not used)
627 @return EFI_DEVICE_ERROR Could not complete due to hardware error
628
629 **/
630 EFI_STATUS
631 EFIAPI
632 CoreSetWatchdogTimer (
633 IN UINTN Timeout,
634 IN UINT64 WatchdogCode,
635 IN UINTN DataSize,
636 IN CHAR16 *WatchdogData OPTIONAL
637 );
638
639 /**
640 Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
641 Calls the private one which contains a BOOLEAN parameter for notifications
642
643 @param UserHandle The handle to install the protocol handler on,
644 or NULL if a new handle is to be allocated
645 @param Protocol The protocol to add to the handle
646 @param InterfaceType Indicates whether Interface is supplied in
647 native form.
648 @param Interface The interface for the protocol being added
649
650 @return Status code
651
652 **/
653 EFI_STATUS
654 EFIAPI
655 CoreInstallProtocolInterface (
656 IN OUT EFI_HANDLE *UserHandle,
657 IN EFI_GUID *Protocol,
658 IN EFI_INTERFACE_TYPE InterfaceType,
659 IN VOID *Interface
660 );
661
662 /**
663 Installs a protocol interface into the boot services environment.
664
665 @param UserHandle The handle to install the protocol handler on,
666 or NULL if a new handle is to be allocated
667 @param Protocol The protocol to add to the handle
668 @param InterfaceType Indicates whether Interface is supplied in
669 native form.
670 @param Interface The interface for the protocol being added
671 @param Notify indicates whether notify the notification list
672 for this protocol
673
674 @retval EFI_INVALID_PARAMETER Invalid parameter
675 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
676 @retval EFI_SUCCESS Protocol interface successfully installed
677
678 **/
679 EFI_STATUS
680 CoreInstallProtocolInterfaceNotify (
681 IN OUT EFI_HANDLE *UserHandle,
682 IN EFI_GUID *Protocol,
683 IN EFI_INTERFACE_TYPE InterfaceType,
684 IN VOID *Interface,
685 IN BOOLEAN Notify
686 );
687
688 /**
689 Installs a list of protocol interface into the boot services environment.
690 This function calls InstallProtocolInterface() in a loop. If any error
691 occures all the protocols added by this function are removed. This is
692 basically a lib function to save space.
693
694 @param Handle The handle to install the protocol handlers on,
695 or NULL if a new handle is to be allocated
696 @param ... EFI_GUID followed by protocol instance. A NULL
697 terminates the list. The pairs are the
698 arguments to InstallProtocolInterface(). All the
699 protocols are added to Handle.
700
701 @retval EFI_SUCCESS All the protocol interface was installed.
702 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
703 @retval EFI_ALREADY_STARTED A Device Path Protocol instance was passed in that is already present in
704 the handle database.
705 @retval EFI_INVALID_PARAMETER Handle is NULL.
706 @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.
707
708 **/
709 EFI_STATUS
710 EFIAPI
711 CoreInstallMultipleProtocolInterfaces (
712 IN OUT EFI_HANDLE *Handle,
713 ...
714 );
715
716 /**
717 Uninstalls a list of protocol interface in the boot services environment.
718 This function calls UnisatllProtocolInterface() in a loop. This is
719 basically a lib function to save space.
720
721 @param Handle The handle to uninstall the protocol
722 @param ... EFI_GUID followed by protocol instance. A NULL
723 terminates the list. The pairs are the
724 arguments to UninstallProtocolInterface(). All
725 the protocols are added to Handle.
726
727 @return Status code
728
729 **/
730 EFI_STATUS
731 EFIAPI
732 CoreUninstallMultipleProtocolInterfaces (
733 IN EFI_HANDLE Handle,
734 ...
735 );
736
737 /**
738 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
739
740 @param UserHandle Handle on which the interface is to be
741 reinstalled
742 @param Protocol The numeric ID of the interface
743 @param OldInterface A pointer to the old interface
744 @param NewInterface A pointer to the new interface
745
746 @retval EFI_SUCCESS The protocol interface was installed
747 @retval EFI_NOT_FOUND The OldInterface on the handle was not found
748 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
749
750 **/
751 EFI_STATUS
752 EFIAPI
753 CoreReinstallProtocolInterface (
754 IN EFI_HANDLE UserHandle,
755 IN EFI_GUID *Protocol,
756 IN VOID *OldInterface,
757 IN VOID *NewInterface
758 );
759
760 /**
761 Uninstalls all instances of a protocol:interfacer from a handle.
762 If the last protocol interface is remove from the handle, the
763 handle is freed.
764
765 @param UserHandle The handle to remove the protocol handler from
766 @param Protocol The protocol, of protocol:interface, to remove
767 @param Interface The interface, of protocol:interface, to remove
768
769 @retval EFI_INVALID_PARAMETER Protocol is NULL.
770 @retval EFI_SUCCESS Protocol interface successfully uninstalled.
771
772 **/
773 EFI_STATUS
774 EFIAPI
775 CoreUninstallProtocolInterface (
776 IN EFI_HANDLE UserHandle,
777 IN EFI_GUID *Protocol,
778 IN VOID *Interface
779 );
780
781 /**
782 Queries a handle to determine if it supports a specified protocol.
783
784 @param UserHandle The handle being queried.
785 @param Protocol The published unique identifier of the protocol.
786 @param Interface Supplies the address where a pointer to the
787 corresponding Protocol Interface is returned.
788
789 @return The requested protocol interface for the handle
790
791 **/
792 EFI_STATUS
793 EFIAPI
794 CoreHandleProtocol (
795 IN EFI_HANDLE UserHandle,
796 IN EFI_GUID *Protocol,
797 OUT VOID **Interface
798 );
799
800 /**
801 Locates the installed protocol handler for the handle, and
802 invokes it to obtain the protocol interface. Usage information
803 is registered in the protocol data base.
804
805 @param UserHandle The handle to obtain the protocol interface on
806 @param Protocol The ID of the protocol
807 @param Interface The location to return the protocol interface
808 @param ImageHandle The handle of the Image that is opening the
809 protocol interface specified by Protocol and
810 Interface.
811 @param ControllerHandle The controller handle that is requiring this
812 interface.
813 @param Attributes The open mode of the protocol interface
814 specified by Handle and Protocol.
815
816 @retval EFI_INVALID_PARAMETER Protocol is NULL.
817 @retval EFI_SUCCESS Get the protocol interface.
818
819 **/
820 EFI_STATUS
821 EFIAPI
822 CoreOpenProtocol (
823 IN EFI_HANDLE UserHandle,
824 IN EFI_GUID *Protocol,
825 OUT VOID **Interface OPTIONAL,
826 IN EFI_HANDLE ImageHandle,
827 IN EFI_HANDLE ControllerHandle,
828 IN UINT32 Attributes
829 );
830
831 /**
832 Return information about Opened protocols in the system
833
834 @param UserHandle The handle to close the protocol interface on
835 @param Protocol The ID of the protocol
836 @param EntryBuffer A pointer to a buffer of open protocol
837 information in the form of
838 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
839 @param EntryCount Number of EntryBuffer entries
840
841 **/
842 EFI_STATUS
843 EFIAPI
844 CoreOpenProtocolInformation (
845 IN EFI_HANDLE UserHandle,
846 IN EFI_GUID *Protocol,
847 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
848 OUT UINTN *EntryCount
849 );
850
851 /**
852 Closes a protocol on a handle that was opened using OpenProtocol().
853
854 @param UserHandle The handle for the protocol interface that was
855 previously opened with OpenProtocol(), and is
856 now being closed.
857 @param Protocol The published unique identifier of the protocol.
858 It is the caller's responsibility to pass in a
859 valid GUID.
860 @param AgentHandle The handle of the agent that is closing the
861 protocol interface.
862 @param ControllerHandle If the agent that opened a protocol is a driver
863 that follows the EFI Driver Model, then this
864 parameter is the controller handle that required
865 the protocol interface. If the agent does not
866 follow the EFI Driver Model, then this parameter
867 is optional and may be NULL.
868
869 @retval EFI_SUCCESS The protocol instance was closed.
870 @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a
871 valid EFI_HANDLE.
872 @retval EFI_NOT_FOUND Can not find the specified protocol or
873 AgentHandle.
874
875 **/
876 EFI_STATUS
877 EFIAPI
878 CoreCloseProtocol (
879 IN EFI_HANDLE UserHandle,
880 IN EFI_GUID *Protocol,
881 IN EFI_HANDLE AgentHandle,
882 IN EFI_HANDLE ControllerHandle
883 );
884
885 /**
886 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
887 from pool.
888
889 @param UserHandle The handle from which to retrieve the list of
890 protocol interface GUIDs.
891 @param ProtocolBuffer A pointer to the list of protocol interface GUID
892 pointers that are installed on Handle.
893 @param ProtocolBufferCount A pointer to the number of GUID pointers present
894 in ProtocolBuffer.
895
896 @retval EFI_SUCCESS The list of protocol interface GUIDs installed
897 on Handle was returned in ProtocolBuffer. The
898 number of protocol interface GUIDs was returned
899 in ProtocolBufferCount.
900 @retval EFI_INVALID_PARAMETER Handle is NULL.
901 @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
902 @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.
903 @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.
904 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
905 results.
906
907 **/
908 EFI_STATUS
909 EFIAPI
910 CoreProtocolsPerHandle (
911 IN EFI_HANDLE UserHandle,
912 OUT EFI_GUID ***ProtocolBuffer,
913 OUT UINTN *ProtocolBufferCount
914 );
915
916 /**
917 Add a new protocol notification record for the request protocol.
918
919 @param Protocol The requested protocol to add the notify
920 registration
921 @param Event The event to signal
922 @param Registration Returns the registration record
923
924 @retval EFI_INVALID_PARAMETER Invalid parameter
925 @retval EFI_SUCCESS Successfully returned the registration record
926 that has been added
927
928 **/
929 EFI_STATUS
930 EFIAPI
931 CoreRegisterProtocolNotify (
932 IN EFI_GUID *Protocol,
933 IN EFI_EVENT Event,
934 OUT VOID **Registration
935 );
936
937 /**
938 Removes all the events in the protocol database that match Event.
939
940 @param Event The event to search for in the protocol
941 database.
942
943 @return EFI_SUCCESS when done searching the entire database.
944
945 **/
946 EFI_STATUS
947 CoreUnregisterProtocolNotify (
948 IN EFI_EVENT Event
949 );
950
951 /**
952 Locates the requested handle(s) and returns them in Buffer.
953
954 @param SearchType The type of search to perform to locate the
955 handles
956 @param Protocol The protocol to search for
957 @param SearchKey Dependant on SearchType
958 @param BufferSize On input the size of Buffer. On output the
959 size of data returned.
960 @param Buffer The buffer to return the results in
961
962 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
963 returned in BufferSize.
964 @retval EFI_INVALID_PARAMETER Invalid parameter
965 @retval EFI_SUCCESS Successfully found the requested handle(s) and
966 returns them in Buffer.
967
968 **/
969 EFI_STATUS
970 EFIAPI
971 CoreLocateHandle (
972 IN EFI_LOCATE_SEARCH_TYPE SearchType,
973 IN EFI_GUID *Protocol OPTIONAL,
974 IN VOID *SearchKey OPTIONAL,
975 IN OUT UINTN *BufferSize,
976 OUT EFI_HANDLE *Buffer
977 );
978
979 /**
980 Locates the handle to a device on the device path that best matches the specified protocol.
981
982 @param Protocol The protocol to search for.
983 @param DevicePath On input, a pointer to a pointer to the device
984 path. On output, the device path pointer is
985 modified to point to the remaining part of the
986 devicepath.
987 @param Device A pointer to the returned device handle.
988
989 @retval EFI_SUCCESS The resulting handle was returned.
990 @retval EFI_NOT_FOUND No handles matched the search.
991 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
992
993 **/
994 EFI_STATUS
995 EFIAPI
996 CoreLocateDevicePath (
997 IN EFI_GUID *Protocol,
998 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
999 OUT EFI_HANDLE *Device
1000 );
1001
1002 /**
1003 Function returns an array of handles that support the requested protocol
1004 in a buffer allocated from pool. This is a version of CoreLocateHandle()
1005 that allocates a buffer for the caller.
1006
1007 @param SearchType Specifies which handle(s) are to be returned.
1008 @param Protocol Provides the protocol to search by. This
1009 parameter is only valid for SearchType
1010 ByProtocol.
1011 @param SearchKey Supplies the search key depending on the
1012 SearchType.
1013 @param NumberHandles The number of handles returned in Buffer.
1014 @param Buffer A pointer to the buffer to return the requested
1015 array of handles that support Protocol.
1016
1017 @retval EFI_SUCCESS The result array of handles was returned.
1018 @retval EFI_NOT_FOUND No handles match the search.
1019 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
1020 matching results.
1021 @retval EFI_INVALID_PARAMETER One or more parameters are not valid.
1022
1023 **/
1024 EFI_STATUS
1025 EFIAPI
1026 CoreLocateHandleBuffer (
1027 IN EFI_LOCATE_SEARCH_TYPE SearchType,
1028 IN EFI_GUID *Protocol OPTIONAL,
1029 IN VOID *SearchKey OPTIONAL,
1030 IN OUT UINTN *NumberHandles,
1031 OUT EFI_HANDLE **Buffer
1032 );
1033
1034 /**
1035 Return the first Protocol Interface that matches the Protocol GUID. If
1036 Registration is passed in, return a Protocol Instance that was just add
1037 to the system. If Registration is NULL return the first Protocol Interface
1038 you find.
1039
1040 @param Protocol The protocol to search for
1041 @param Registration Optional Registration Key returned from
1042 RegisterProtocolNotify()
1043 @param Interface Return the Protocol interface (instance).
1044
1045 @retval EFI_SUCCESS If a valid Interface is returned
1046 @retval EFI_INVALID_PARAMETER Invalid parameter
1047 @retval EFI_NOT_FOUND Protocol interface not found
1048
1049 **/
1050 EFI_STATUS
1051 EFIAPI
1052 CoreLocateProtocol (
1053 IN EFI_GUID *Protocol,
1054 IN VOID *Registration OPTIONAL,
1055 OUT VOID **Interface
1056 );
1057
1058 /**
1059 return handle database key.
1060
1061
1062 @return Handle database key.
1063
1064 **/
1065 UINT64
1066 CoreGetHandleDatabaseKey (
1067 VOID
1068 );
1069
1070 /**
1071 Go connect any handles that were created or modified while a image executed.
1072
1073 @param Key The Key to show that the handle has been
1074 created/modified
1075
1076 **/
1077 VOID
1078 CoreConnectHandlesByKey (
1079 UINT64 Key
1080 );
1081
1082 /**
1083 Connects one or more drivers to a controller.
1084
1085 @param ControllerHandle The handle of the controller to which driver(s) are to be connected.
1086 @param DriverImageHandle A pointer to an ordered list handles that support the
1087 EFI_DRIVER_BINDING_PROTOCOL.
1088 @param RemainingDevicePath A pointer to the device path that specifies a child of the
1089 controller specified by ControllerHandle.
1090 @param Recursive If TRUE, then ConnectController() is called recursively
1091 until the entire tree of controllers below the controller specified
1092 by ControllerHandle have been created. If FALSE, then
1093 the tree of controllers is only expanded one level.
1094
1095 @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.
1096 2) No drivers were connected to ControllerHandle, but
1097 RemainingDevicePath is not NULL, and it is an End Device
1098 Path Node.
1099 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1100 @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
1101 present in the system.
1102 2) No drivers were connected to ControllerHandle.
1103 @retval EFI_SECURITY_VIOLATION
1104 The user has no permission to start UEFI device drivers on the device path
1105 associated with the ControllerHandle or specified by the RemainingDevicePath.
1106
1107 **/
1108 EFI_STATUS
1109 EFIAPI
1110 CoreConnectController (
1111 IN EFI_HANDLE ControllerHandle,
1112 IN EFI_HANDLE *DriverImageHandle OPTIONAL,
1113 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
1114 IN BOOLEAN Recursive
1115 );
1116
1117 /**
1118 Disonnects a controller from a driver
1119
1120 @param ControllerHandle ControllerHandle The handle of
1121 the controller from which
1122 driver(s) are to be
1123 disconnected.
1124 @param DriverImageHandle DriverImageHandle The driver to
1125 disconnect from ControllerHandle.
1126 @param ChildHandle ChildHandle The handle of the
1127 child to destroy.
1128
1129 @retval EFI_SUCCESS One or more drivers were
1130 disconnected from the controller.
1131 @retval EFI_SUCCESS On entry, no drivers are managing
1132 ControllerHandle.
1133 @retval EFI_SUCCESS DriverImageHandle is not NULL,
1134 and on entry DriverImageHandle is
1135 not managing ControllerHandle.
1136 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1137 @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
1138 and it is not a valid EFI_HANDLE.
1139 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
1140 is not a valid EFI_HANDLE.
1141 @retval EFI_OUT_OF_RESOURCES There are not enough resources
1142 available to disconnect any
1143 drivers from ControllerHandle.
1144 @retval EFI_DEVICE_ERROR The controller could not be
1145 disconnected because of a device
1146 error.
1147
1148 **/
1149 EFI_STATUS
1150 EFIAPI
1151 CoreDisconnectController (
1152 IN EFI_HANDLE ControllerHandle,
1153 IN EFI_HANDLE DriverImageHandle OPTIONAL,
1154 IN EFI_HANDLE ChildHandle OPTIONAL
1155 );
1156
1157 /**
1158 Allocates pages from the memory map.
1159
1160 @param Type The type of allocation to perform
1161 @param MemoryType The type of memory to turn the allocated pages
1162 into
1163 @param NumberOfPages The number of pages to allocate
1164 @param Memory A pointer to receive the base allocated memory
1165 address
1166
1167 @return Status. On success, Memory is filled in with the base address allocated
1168 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
1169 spec.
1170 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
1171 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
1172 @retval EFI_SUCCESS Pages successfully allocated.
1173
1174 **/
1175 EFI_STATUS
1176 EFIAPI
1177 CoreAllocatePages (
1178 IN EFI_ALLOCATE_TYPE Type,
1179 IN EFI_MEMORY_TYPE MemoryType,
1180 IN UINTN NumberOfPages,
1181 IN OUT EFI_PHYSICAL_ADDRESS *Memory
1182 );
1183
1184 /**
1185 Frees previous allocated pages.
1186
1187 @param Memory Base address of memory being freed
1188 @param NumberOfPages The number of pages to free
1189
1190 @retval EFI_NOT_FOUND Could not find the entry that covers the range
1191 @retval EFI_INVALID_PARAMETER Address not aligned
1192 @return EFI_SUCCESS -Pages successfully freed.
1193
1194 **/
1195 EFI_STATUS
1196 EFIAPI
1197 CoreFreePages (
1198 IN EFI_PHYSICAL_ADDRESS Memory,
1199 IN UINTN NumberOfPages
1200 );
1201
1202 /**
1203 This function returns a copy of the current memory map. The map is an array of
1204 memory descriptors, each of which describes a contiguous block of memory.
1205
1206 @param MemoryMapSize A pointer to the size, in bytes, of the
1207 MemoryMap buffer. On input, this is the size of
1208 the buffer allocated by the caller. On output,
1209 it is the size of the buffer returned by the
1210 firmware if the buffer was large enough, or the
1211 size of the buffer needed to contain the map if
1212 the buffer was too small.
1213 @param MemoryMap A pointer to the buffer in which firmware places
1214 the current memory map.
1215 @param MapKey A pointer to the location in which firmware
1216 returns the key for the current memory map.
1217 @param DescriptorSize A pointer to the location in which firmware
1218 returns the size, in bytes, of an individual
1219 EFI_MEMORY_DESCRIPTOR.
1220 @param DescriptorVersion A pointer to the location in which firmware
1221 returns the version number associated with the
1222 EFI_MEMORY_DESCRIPTOR.
1223
1224 @retval EFI_SUCCESS The memory map was returned in the MemoryMap
1225 buffer.
1226 @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
1227 buffer size needed to hold the memory map is
1228 returned in MemoryMapSize.
1229 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1230
1231 **/
1232 EFI_STATUS
1233 EFIAPI
1234 CoreGetMemoryMap (
1235 IN OUT UINTN *MemoryMapSize,
1236 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
1237 OUT UINTN *MapKey,
1238 OUT UINTN *DescriptorSize,
1239 OUT UINT32 *DescriptorVersion
1240 );
1241
1242 /**
1243 Allocate pool of a particular type.
1244
1245 @param PoolType Type of pool to allocate
1246 @param Size The amount of pool to allocate
1247 @param Buffer The address to return a pointer to the allocated
1248 pool
1249
1250 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
1251 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
1252 @retval EFI_SUCCESS Pool successfully allocated.
1253
1254 **/
1255 EFI_STATUS
1256 EFIAPI
1257 CoreAllocatePool (
1258 IN EFI_MEMORY_TYPE PoolType,
1259 IN UINTN Size,
1260 OUT VOID **Buffer
1261 );
1262
1263 /**
1264 Allocate pool of a particular type.
1265
1266 @param PoolType Type of pool to allocate
1267 @param Size The amount of pool to allocate
1268 @param Buffer The address to return a pointer to the allocated
1269 pool
1270
1271 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
1272 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
1273 @retval EFI_SUCCESS Pool successfully allocated.
1274
1275 **/
1276 EFI_STATUS
1277 EFIAPI
1278 CoreInternalAllocatePool (
1279 IN EFI_MEMORY_TYPE PoolType,
1280 IN UINTN Size,
1281 OUT VOID **Buffer
1282 );
1283
1284 /**
1285 Frees pool.
1286
1287 @param Buffer The allocated pool entry to free
1288
1289 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
1290 @retval EFI_SUCCESS Pool successfully freed.
1291
1292 **/
1293 EFI_STATUS
1294 EFIAPI
1295 CoreFreePool (
1296 IN VOID *Buffer
1297 );
1298
1299 /**
1300 Frees pool.
1301
1302 @param Buffer The allocated pool entry to free
1303 @param PoolType Pointer to pool type
1304
1305 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
1306 @retval EFI_SUCCESS Pool successfully freed.
1307
1308 **/
1309 EFI_STATUS
1310 EFIAPI
1311 CoreInternalFreePool (
1312 IN VOID *Buffer,
1313 OUT EFI_MEMORY_TYPE *PoolType OPTIONAL
1314 );
1315
1316 /**
1317 Loads an EFI image into memory and returns a handle to the image.
1318
1319 @param BootPolicy If TRUE, indicates that the request originates
1320 from the boot manager, and that the boot
1321 manager is attempting to load FilePath as a
1322 boot selection.
1323 @param ParentImageHandle The caller's image handle.
1324 @param FilePath The specific file path from which the image is
1325 loaded.
1326 @param SourceBuffer If not NULL, a pointer to the memory location
1327 containing a copy of the image to be loaded.
1328 @param SourceSize The size in bytes of SourceBuffer.
1329 @param ImageHandle Pointer to the returned image handle that is
1330 created when the image is successfully loaded.
1331
1332 @retval EFI_SUCCESS The image was loaded into memory.
1333 @retval EFI_NOT_FOUND The FilePath was not found.
1334 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1335 @retval EFI_UNSUPPORTED The image type is not supported, or the device
1336 path cannot be parsed to locate the proper
1337 protocol for loading the file.
1338 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
1339 resources.
1340 @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
1341 understood.
1342 @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
1343 @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
1344 image from being loaded. NULL is returned in *ImageHandle.
1345 @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
1346 valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
1347 platform policy specifies that the image should not be started.
1348
1349 **/
1350 EFI_STATUS
1351 EFIAPI
1352 CoreLoadImage (
1353 IN BOOLEAN BootPolicy,
1354 IN EFI_HANDLE ParentImageHandle,
1355 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
1356 IN VOID *SourceBuffer OPTIONAL,
1357 IN UINTN SourceSize,
1358 OUT EFI_HANDLE *ImageHandle
1359 );
1360
1361 /**
1362 Unloads an image.
1363
1364 @param ImageHandle Handle that identifies the image to be
1365 unloaded.
1366
1367 @retval EFI_SUCCESS The image has been unloaded.
1368 @retval EFI_UNSUPPORTED The image has been started, and does not support
1369 unload.
1370 @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
1371
1372 **/
1373 EFI_STATUS
1374 EFIAPI
1375 CoreUnloadImage (
1376 IN EFI_HANDLE ImageHandle
1377 );
1378
1379 /**
1380 Transfer control to a loaded image's entry point.
1381
1382 @param ImageHandle Handle of image to be started.
1383 @param ExitDataSize Pointer of the size to ExitData
1384 @param ExitData Pointer to a pointer to a data buffer that
1385 includes a Null-terminated string,
1386 optionally followed by additional binary data.
1387 The string is a description that the caller may
1388 use to further indicate the reason for the
1389 image's exit.
1390
1391 @retval EFI_INVALID_PARAMETER Invalid parameter
1392 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1393 @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
1394 @retval EFI_SUCCESS Successfully transfer control to the image's
1395 entry point.
1396
1397 **/
1398 EFI_STATUS
1399 EFIAPI
1400 CoreStartImage (
1401 IN EFI_HANDLE ImageHandle,
1402 OUT UINTN *ExitDataSize,
1403 OUT CHAR16 **ExitData OPTIONAL
1404 );
1405
1406 /**
1407 Terminates the currently loaded EFI image and returns control to boot services.
1408
1409 @param ImageHandle Handle that identifies the image. This
1410 parameter is passed to the image on entry.
1411 @param Status The image's exit code.
1412 @param ExitDataSize The size, in bytes, of ExitData. Ignored if
1413 ExitStatus is EFI_SUCCESS.
1414 @param ExitData Pointer to a data buffer that includes a
1415 Null-terminated Unicode string, optionally
1416 followed by additional binary data. The string
1417 is a description that the caller may use to
1418 further indicate the reason for the image's
1419 exit.
1420
1421 @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
1422 image.
1423 @retval EFI_SUCCESS Successfully terminates the currently loaded
1424 EFI image.
1425 @retval EFI_ACCESS_DENIED Should never reach there.
1426 @retval EFI_OUT_OF_RESOURCES Could not allocate pool
1427
1428 **/
1429 EFI_STATUS
1430 EFIAPI
1431 CoreExit (
1432 IN EFI_HANDLE ImageHandle,
1433 IN EFI_STATUS Status,
1434 IN UINTN ExitDataSize,
1435 IN CHAR16 *ExitData OPTIONAL
1436 );
1437
1438 /**
1439 Creates an event.
1440
1441 @param Type The type of event to create and its mode and
1442 attributes
1443 @param NotifyTpl The task priority level of event notifications
1444 @param NotifyFunction Pointer to the events notification function
1445 @param NotifyContext Pointer to the notification functions context;
1446 corresponds to parameter "Context" in the
1447 notification function
1448 @param Event Pointer to the newly created event if the call
1449 succeeds; undefined otherwise
1450
1451 @retval EFI_SUCCESS The event structure was created
1452 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1453 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1454
1455 **/
1456 EFI_STATUS
1457 EFIAPI
1458 CoreCreateEvent (
1459 IN UINT32 Type,
1460 IN EFI_TPL NotifyTpl,
1461 IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
1462 IN VOID *NotifyContext OPTIONAL,
1463 OUT EFI_EVENT *Event
1464 );
1465
1466 /**
1467 Creates an event in a group.
1468
1469 @param Type The type of event to create and its mode and
1470 attributes
1471 @param NotifyTpl The task priority level of event notifications
1472 @param NotifyFunction Pointer to the events notification function
1473 @param NotifyContext Pointer to the notification functions context;
1474 corresponds to parameter "Context" in the
1475 notification function
1476 @param EventGroup GUID for EventGroup if NULL act the same as
1477 gBS->CreateEvent().
1478 @param Event Pointer to the newly created event if the call
1479 succeeds; undefined otherwise
1480
1481 @retval EFI_SUCCESS The event structure was created
1482 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1483 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1484
1485 **/
1486 EFI_STATUS
1487 EFIAPI
1488 CoreCreateEventEx (
1489 IN UINT32 Type,
1490 IN EFI_TPL NotifyTpl,
1491 IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
1492 IN CONST VOID *NotifyContext OPTIONAL,
1493 IN CONST EFI_GUID *EventGroup OPTIONAL,
1494 OUT EFI_EVENT *Event
1495 );
1496
1497 /**
1498 Creates a general-purpose event structure
1499
1500 @param Type The type of event to create and its mode and
1501 attributes
1502 @param NotifyTpl The task priority level of event notifications
1503 @param NotifyFunction Pointer to the events notification function
1504 @param NotifyContext Pointer to the notification functions context;
1505 corresponds to parameter "Context" in the
1506 notification function
1507 @param EventGroup GUID for EventGroup if NULL act the same as
1508 gBS->CreateEvent().
1509 @param Event Pointer to the newly created event if the call
1510 succeeds; undefined otherwise
1511
1512 @retval EFI_SUCCESS The event structure was created
1513 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1514 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1515
1516 **/
1517 EFI_STATUS
1518 EFIAPI
1519 CoreCreateEventInternal (
1520 IN UINT32 Type,
1521 IN EFI_TPL NotifyTpl,
1522 IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
1523 IN CONST VOID *NotifyContext OPTIONAL,
1524 IN CONST EFI_GUID *EventGroup OPTIONAL,
1525 OUT EFI_EVENT *Event
1526 );
1527
1528 /**
1529 Sets the type of timer and the trigger time for a timer event.
1530
1531 @param UserEvent The timer event that is to be signaled at the
1532 specified time
1533 @param Type The type of time that is specified in
1534 TriggerTime
1535 @param TriggerTime The number of 100ns units until the timer
1536 expires
1537
1538 @retval EFI_SUCCESS The event has been set to be signaled at the
1539 requested time
1540 @retval EFI_INVALID_PARAMETER Event or Type is not valid
1541
1542 **/
1543 EFI_STATUS
1544 EFIAPI
1545 CoreSetTimer (
1546 IN EFI_EVENT UserEvent,
1547 IN EFI_TIMER_DELAY Type,
1548 IN UINT64 TriggerTime
1549 );
1550
1551 /**
1552 Signals the event. Queues the event to be notified if needed.
1553
1554 @param UserEvent The event to signal .
1555
1556 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1557 @retval EFI_SUCCESS The event was signaled.
1558
1559 **/
1560 EFI_STATUS
1561 EFIAPI
1562 CoreSignalEvent (
1563 IN EFI_EVENT UserEvent
1564 );
1565
1566 /**
1567 Stops execution until an event is signaled.
1568
1569 @param NumberOfEvents The number of events in the UserEvents array
1570 @param UserEvents An array of EFI_EVENT
1571 @param UserIndex Pointer to the index of the event which
1572 satisfied the wait condition
1573
1574 @retval EFI_SUCCESS The event indicated by Index was signaled.
1575 @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification
1576 function or Event was not a valid type
1577 @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION
1578
1579 **/
1580 EFI_STATUS
1581 EFIAPI
1582 CoreWaitForEvent (
1583 IN UINTN NumberOfEvents,
1584 IN EFI_EVENT *UserEvents,
1585 OUT UINTN *UserIndex
1586 );
1587
1588 /**
1589 Closes an event and frees the event structure.
1590
1591 @param UserEvent Event to close
1592
1593 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1594 @retval EFI_SUCCESS The event has been closed
1595
1596 **/
1597 EFI_STATUS
1598 EFIAPI
1599 CoreCloseEvent (
1600 IN EFI_EVENT UserEvent
1601 );
1602
1603 /**
1604 Check the status of an event.
1605
1606 @param UserEvent The event to check
1607
1608 @retval EFI_SUCCESS The event is in the signaled state
1609 @retval EFI_NOT_READY The event is not in the signaled state
1610 @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL
1611
1612 **/
1613 EFI_STATUS
1614 EFIAPI
1615 CoreCheckEvent (
1616 IN EFI_EVENT UserEvent
1617 );
1618
1619 /**
1620 Adds reserved memory, system memory, or memory-mapped I/O resources to the
1621 global coherency domain of the processor.
1622
1623 @param GcdMemoryType Memory type of the memory space.
1624 @param BaseAddress Base address of the memory space.
1625 @param Length Length of the memory space.
1626 @param Capabilities alterable attributes of the memory space.
1627
1628 @retval EFI_SUCCESS Merged this memory space into GCD map.
1629
1630 **/
1631 EFI_STATUS
1632 EFIAPI
1633 CoreAddMemorySpace (
1634 IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
1635 IN EFI_PHYSICAL_ADDRESS BaseAddress,
1636 IN UINT64 Length,
1637 IN UINT64 Capabilities
1638 );
1639
1640 /**
1641 Allocates nonexistent memory, reserved memory, system memory, or memorymapped
1642 I/O resources from the global coherency domain of the processor.
1643
1644 @param GcdAllocateType The type of allocate operation
1645 @param GcdMemoryType The desired memory type
1646 @param Alignment Align with 2^Alignment
1647 @param Length Length to allocate
1648 @param BaseAddress Base address to allocate
1649 @param ImageHandle The image handle consume the allocated space.
1650 @param DeviceHandle The device handle consume the allocated space.
1651
1652 @retval EFI_INVALID_PARAMETER Invalid parameter.
1653 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1654 @retval EFI_SUCCESS Memory space successfully allocated.
1655
1656 **/
1657 EFI_STATUS
1658 EFIAPI
1659 CoreAllocateMemorySpace (
1660 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
1661 IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
1662 IN UINTN Alignment,
1663 IN UINT64 Length,
1664 IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
1665 IN EFI_HANDLE ImageHandle,
1666 IN EFI_HANDLE DeviceHandle OPTIONAL
1667 );
1668
1669 /**
1670 Frees nonexistent memory, reserved memory, system memory, or memory-mapped
1671 I/O resources from the global coherency domain of the processor.
1672
1673 @param BaseAddress Base address of the memory space.
1674 @param Length Length of the memory space.
1675
1676 @retval EFI_SUCCESS Space successfully freed.
1677
1678 **/
1679 EFI_STATUS
1680 EFIAPI
1681 CoreFreeMemorySpace (
1682 IN EFI_PHYSICAL_ADDRESS BaseAddress,
1683 IN UINT64 Length
1684 );
1685
1686 /**
1687 Removes reserved memory, system memory, or memory-mapped I/O resources from
1688 the global coherency domain of the processor.
1689
1690 @param BaseAddress Base address of the memory space.
1691 @param Length Length of the memory space.
1692
1693 @retval EFI_SUCCESS Successfully remove a segment of memory space.
1694
1695 **/
1696 EFI_STATUS
1697 EFIAPI
1698 CoreRemoveMemorySpace (
1699 IN EFI_PHYSICAL_ADDRESS BaseAddress,
1700 IN UINT64 Length
1701 );
1702
1703 /**
1704 Retrieves the descriptor for a memory region containing a specified address.
1705
1706 @param BaseAddress Specified start address
1707 @param Descriptor Specified length
1708
1709 @retval EFI_INVALID_PARAMETER Invalid parameter
1710 @retval EFI_SUCCESS Successfully get memory space descriptor.
1711
1712 **/
1713 EFI_STATUS
1714 EFIAPI
1715 CoreGetMemorySpaceDescriptor (
1716 IN EFI_PHYSICAL_ADDRESS BaseAddress,
1717 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor
1718 );
1719
1720 /**
1721 Modifies the attributes for a memory region in the global coherency domain of the
1722 processor.
1723
1724 @param BaseAddress Specified start address
1725 @param Length Specified length
1726 @param Attributes Specified attributes
1727
1728 @retval EFI_SUCCESS The attributes were set for the memory region.
1729 @retval EFI_INVALID_PARAMETER Length is zero.
1730 @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory
1731 resource range specified by BaseAddress and Length.
1732 @retval EFI_UNSUPPORTED The bit mask of attributes is not support for the memory resource
1733 range specified by BaseAddress and Length.
1734 @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by
1735 BaseAddress and Length cannot be modified.
1736 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of
1737 the memory resource range.
1738 @retval EFI_NOT_AVAILABLE_YET The attributes cannot be set because CPU architectural protocol is
1739 not available yet.
1740
1741 **/
1742 EFI_STATUS
1743 EFIAPI
1744 CoreSetMemorySpaceAttributes (
1745 IN EFI_PHYSICAL_ADDRESS BaseAddress,
1746 IN UINT64 Length,
1747 IN UINT64 Attributes
1748 );
1749
1750 /**
1751 Modifies the capabilities for a memory region in the global coherency domain of the
1752 processor.
1753
1754 @param BaseAddress The physical address that is the start address of a memory region.
1755 @param Length The size in bytes of the memory region.
1756 @param Capabilities The bit mask of capabilities that the memory region supports.
1757
1758 @retval EFI_SUCCESS The capabilities were set for the memory region.
1759 @retval EFI_INVALID_PARAMETER Length is zero.
1760 @retval EFI_UNSUPPORTED The capabilities specified by Capabilities do not include the
1761 memory region attributes currently in use.
1762 @retval EFI_ACCESS_DENIED The capabilities for the memory resource range specified by
1763 BaseAddress and Length cannot be modified.
1764 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the capabilities
1765 of the memory resource range.
1766 **/
1767 EFI_STATUS
1768 EFIAPI
1769 CoreSetMemorySpaceCapabilities (
1770 IN EFI_PHYSICAL_ADDRESS BaseAddress,
1771 IN UINT64 Length,
1772 IN UINT64 Capabilities
1773 );
1774
1775 /**
1776 Returns a map of the memory resources in the global coherency domain of the
1777 processor.
1778
1779 @param NumberOfDescriptors Number of descriptors.
1780 @param MemorySpaceMap Descriptor array
1781
1782 @retval EFI_INVALID_PARAMETER Invalid parameter
1783 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1784 @retval EFI_SUCCESS Successfully get memory space map.
1785
1786 **/
1787 EFI_STATUS
1788 EFIAPI
1789 CoreGetMemorySpaceMap (
1790 OUT UINTN *NumberOfDescriptors,
1791 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap
1792 );
1793
1794 /**
1795 Adds reserved I/O or I/O resources to the global coherency domain of the processor.
1796
1797 @param GcdIoType IO type of the segment.
1798 @param BaseAddress Base address of the segment.
1799 @param Length Length of the segment.
1800
1801 @retval EFI_SUCCESS Merged this segment into GCD map.
1802 @retval EFI_INVALID_PARAMETER Parameter not valid
1803
1804 **/
1805 EFI_STATUS
1806 EFIAPI
1807 CoreAddIoSpace (
1808 IN EFI_GCD_IO_TYPE GcdIoType,
1809 IN EFI_PHYSICAL_ADDRESS BaseAddress,
1810 IN UINT64 Length
1811 );
1812
1813 /**
1814 Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1815 domain of the processor.
1816
1817 @param GcdAllocateType The type of allocate operation
1818 @param GcdIoType The desired IO type
1819 @param Alignment Align with 2^Alignment
1820 @param Length Length to allocate
1821 @param BaseAddress Base address to allocate
1822 @param ImageHandle The image handle consume the allocated space.
1823 @param DeviceHandle The device handle consume the allocated space.
1824
1825 @retval EFI_INVALID_PARAMETER Invalid parameter.
1826 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1827 @retval EFI_SUCCESS IO space successfully allocated.
1828
1829 **/
1830 EFI_STATUS
1831 EFIAPI
1832 CoreAllocateIoSpace (
1833 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
1834 IN EFI_GCD_IO_TYPE GcdIoType,
1835 IN UINTN Alignment,
1836 IN UINT64 Length,
1837 IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
1838 IN EFI_HANDLE ImageHandle,
1839 IN EFI_HANDLE DeviceHandle OPTIONAL
1840 );
1841
1842 /**
1843 Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1844 domain of the processor.
1845
1846 @param BaseAddress Base address of the segment.
1847 @param Length Length of the segment.
1848
1849 @retval EFI_SUCCESS Space successfully freed.
1850
1851 **/
1852 EFI_STATUS
1853 EFIAPI
1854 CoreFreeIoSpace (
1855 IN EFI_PHYSICAL_ADDRESS BaseAddress,
1856 IN UINT64 Length
1857 );
1858
1859 /**
1860 Removes reserved I/O or I/O resources from the global coherency domain of the
1861 processor.
1862
1863 @param BaseAddress Base address of the segment.
1864 @param Length Length of the segment.
1865
1866 @retval EFI_SUCCESS Successfully removed a segment of IO space.
1867
1868 **/
1869 EFI_STATUS
1870 EFIAPI
1871 CoreRemoveIoSpace (
1872 IN EFI_PHYSICAL_ADDRESS BaseAddress,
1873 IN UINT64 Length
1874 );
1875
1876 /**
1877 Retrieves the descriptor for an I/O region containing a specified address.
1878
1879 @param BaseAddress Specified start address
1880 @param Descriptor Specified length
1881
1882 @retval EFI_INVALID_PARAMETER Descriptor is NULL.
1883 @retval EFI_SUCCESS Successfully get the IO space descriptor.
1884
1885 **/
1886 EFI_STATUS
1887 EFIAPI
1888 CoreGetIoSpaceDescriptor (
1889 IN EFI_PHYSICAL_ADDRESS BaseAddress,
1890 OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor
1891 );
1892
1893 /**
1894 Returns a map of the I/O resources in the global coherency domain of the processor.
1895
1896 @param NumberOfDescriptors Number of descriptors.
1897 @param IoSpaceMap Descriptor array
1898
1899 @retval EFI_INVALID_PARAMETER Invalid parameter
1900 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1901 @retval EFI_SUCCESS Successfully get IO space map.
1902
1903 **/
1904 EFI_STATUS
1905 EFIAPI
1906 CoreGetIoSpaceMap (
1907 OUT UINTN *NumberOfDescriptors,
1908 OUT EFI_GCD_IO_SPACE_DESCRIPTOR **IoSpaceMap
1909 );
1910
1911 /**
1912 This is the main Dispatcher for DXE and it exits when there are no more
1913 drivers to run. Drain the mScheduledQueue and load and start a PE
1914 image for each driver. Search the mDiscoveredList to see if any driver can
1915 be placed on the mScheduledQueue. If no drivers are placed on the
1916 mScheduledQueue exit the function. On exit it is assumed the Bds()
1917 will be called, and when the Bds() exits the Dispatcher will be called
1918 again.
1919
1920 @retval EFI_ALREADY_STARTED The DXE Dispatcher is already running
1921 @retval EFI_NOT_FOUND No DXE Drivers were dispatched
1922 @retval EFI_SUCCESS One or more DXE Drivers were dispatched
1923
1924 **/
1925 EFI_STATUS
1926 EFIAPI
1927 CoreDispatcher (
1928 VOID
1929 );
1930
1931 /**
1932 Check every driver and locate a matching one. If the driver is found, the Unrequested
1933 state flag is cleared.
1934
1935 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1936 the firmware file specified by DriverName.
1937 @param DriverName The Driver name to put in the Dependent state.
1938
1939 @retval EFI_SUCCESS The DriverName was found and it's SOR bit was
1940 cleared
1941 @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was
1942 not set.
1943
1944 **/
1945 EFI_STATUS
1946 EFIAPI
1947 CoreSchedule (
1948 IN EFI_HANDLE FirmwareVolumeHandle,
1949 IN EFI_GUID *DriverName
1950 );
1951
1952 /**
1953 Convert a driver from the Untrused back to the Scheduled state.
1954
1955 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1956 the firmware file specified by DriverName.
1957 @param DriverName The Driver name to put in the Scheduled state
1958
1959 @retval EFI_SUCCESS The file was found in the untrusted state, and it
1960 was promoted to the trusted state.
1961 @retval EFI_NOT_FOUND The file was not found in the untrusted state.
1962
1963 **/
1964 EFI_STATUS
1965 EFIAPI
1966 CoreTrust (
1967 IN EFI_HANDLE FirmwareVolumeHandle,
1968 IN EFI_GUID *DriverName
1969 );
1970
1971 /**
1972 This routine is the driver initialization entry point. It initializes the
1973 libraries, and registers two notification functions. These notification
1974 functions are responsible for building the FV stack dynamically.
1975
1976 @param ImageHandle The image handle.
1977 @param SystemTable The system table.
1978
1979 @retval EFI_SUCCESS Function successfully returned.
1980
1981 **/
1982 EFI_STATUS
1983 EFIAPI
1984 FwVolDriverInit (
1985 IN EFI_HANDLE ImageHandle,
1986 IN EFI_SYSTEM_TABLE *SystemTable
1987 );
1988
1989 /**
1990 Entry point of the section extraction code. Initializes an instance of the
1991 section extraction interface and installs it on a new handle.
1992
1993 @param ImageHandle A handle for the image that is initializing this driver
1994 @param SystemTable A pointer to the EFI system table
1995
1996 @retval EFI_SUCCESS Driver initialized successfully
1997 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
1998
1999 **/
2000 EFI_STATUS
2001 EFIAPI
2002 InitializeSectionExtraction (
2003 IN EFI_HANDLE ImageHandle,
2004 IN EFI_SYSTEM_TABLE *SystemTable
2005 );
2006
2007 /**
2008 This DXE service routine is used to process a firmware volume. In
2009 particular, it can be called by BDS to process a single firmware
2010 volume found in a capsule.
2011
2012 @param FvHeader pointer to a firmware volume header
2013 @param Size the size of the buffer pointed to by FvHeader
2014 @param FVProtocolHandle the handle on which a firmware volume protocol
2015 was produced for the firmware volume passed in.
2016
2017 @retval EFI_OUT_OF_RESOURCES if an FVB could not be produced due to lack of
2018 system resources
2019 @retval EFI_VOLUME_CORRUPTED if the volume was corrupted
2020 @retval EFI_SUCCESS a firmware volume protocol was produced for the
2021 firmware volume
2022
2023 **/
2024 EFI_STATUS
2025 EFIAPI
2026 CoreProcessFirmwareVolume (
2027 IN VOID *FvHeader,
2028 IN UINTN Size,
2029 OUT EFI_HANDLE *FVProtocolHandle
2030 );
2031
2032 //
2033 // Functions used during debug buils
2034 //
2035
2036 /**
2037 Displays Architectural protocols that were not loaded and are required for DXE
2038 core to function. Only used in Debug Builds.
2039
2040 **/
2041 VOID
2042 CoreDisplayMissingArchProtocols (
2043 VOID
2044 );
2045
2046 /**
2047 Traverse the discovered list for any drivers that were discovered but not loaded
2048 because the dependency experessions evaluated to false.
2049
2050 **/
2051 VOID
2052 CoreDisplayDiscoveredNotDispatched (
2053 VOID
2054 );
2055
2056 /**
2057 Place holder function until all the Boot Services and Runtime Services are
2058 available.
2059
2060 @param Arg1 Undefined
2061
2062 @return EFI_NOT_AVAILABLE_YET
2063
2064 **/
2065 EFI_STATUS
2066 EFIAPI
2067 CoreEfiNotAvailableYetArg1 (
2068 UINTN Arg1
2069 );
2070
2071 /**
2072 Place holder function until all the Boot Services and Runtime Services are available.
2073
2074 @param Arg1 Undefined
2075 @param Arg2 Undefined
2076
2077 @return EFI_NOT_AVAILABLE_YET
2078
2079 **/
2080 EFI_STATUS
2081 EFIAPI
2082 CoreEfiNotAvailableYetArg2 (
2083 UINTN Arg1,
2084 UINTN Arg2
2085 );
2086
2087 /**
2088 Place holder function until all the Boot Services and Runtime Services are available.
2089
2090 @param Arg1 Undefined
2091 @param Arg2 Undefined
2092 @param Arg3 Undefined
2093
2094 @return EFI_NOT_AVAILABLE_YET
2095
2096 **/
2097 EFI_STATUS
2098 EFIAPI
2099 CoreEfiNotAvailableYetArg3 (
2100 UINTN Arg1,
2101 UINTN Arg2,
2102 UINTN Arg3
2103 );
2104
2105 /**
2106 Place holder function until all the Boot Services and Runtime Services are available.
2107
2108 @param Arg1 Undefined
2109 @param Arg2 Undefined
2110 @param Arg3 Undefined
2111 @param Arg4 Undefined
2112
2113 @return EFI_NOT_AVAILABLE_YET
2114
2115 **/
2116 EFI_STATUS
2117 EFIAPI
2118 CoreEfiNotAvailableYetArg4 (
2119 UINTN Arg1,
2120 UINTN Arg2,
2121 UINTN Arg3,
2122 UINTN Arg4
2123 );
2124
2125 /**
2126 Place holder function until all the Boot Services and Runtime Services are available.
2127
2128 @param Arg1 Undefined
2129 @param Arg2 Undefined
2130 @param Arg3 Undefined
2131 @param Arg4 Undefined
2132 @param Arg5 Undefined
2133
2134 @return EFI_NOT_AVAILABLE_YET
2135
2136 **/
2137 EFI_STATUS
2138 EFIAPI
2139 CoreEfiNotAvailableYetArg5 (
2140 UINTN Arg1,
2141 UINTN Arg2,
2142 UINTN Arg3,
2143 UINTN Arg4,
2144 UINTN Arg5
2145 );
2146
2147 /**
2148 Given a compressed source buffer, this function retrieves the size of the
2149 uncompressed buffer and the size of the scratch buffer required to decompress
2150 the compressed source buffer.
2151
2152 The GetInfo() function retrieves the size of the uncompressed buffer and the
2153 temporary scratch buffer required to decompress the buffer specified by Source
2154 and SourceSize. If the size of the uncompressed buffer or the size of the
2155 scratch buffer cannot be determined from the compressed data specified by
2156 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
2157 size of the uncompressed buffer is returned in DestinationSize, the size of
2158 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
2159 The GetInfo() function does not have scratch buffer available to perform a
2160 thorough checking of the validity of the source data. It just retrieves the
2161 "Original Size" field from the beginning bytes of the source data and output
2162 it as DestinationSize. And ScratchSize is specific to the decompression
2163 implementation.
2164
2165 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2166 @param Source The source buffer containing the compressed data.
2167 @param SourceSize The size, in bytes, of the source buffer.
2168 @param DestinationSize A pointer to the size, in bytes, of the
2169 uncompressed buffer that will be generated when the
2170 compressed buffer specified by Source and
2171 SourceSize is decompressed.
2172 @param ScratchSize A pointer to the size, in bytes, of the scratch
2173 buffer that is required to decompress the
2174 compressed buffer specified by Source and
2175 SourceSize.
2176
2177 @retval EFI_SUCCESS The size of the uncompressed data was returned in
2178 DestinationSize and the size of the scratch buffer
2179 was returned in ScratchSize.
2180 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
2181 the scratch buffer cannot be determined from the
2182 compressed data specified by Source and
2183 SourceSize.
2184
2185 **/
2186 EFI_STATUS
2187 EFIAPI
2188 DxeMainUefiDecompressGetInfo (
2189 IN EFI_DECOMPRESS_PROTOCOL *This,
2190 IN VOID *Source,
2191 IN UINT32 SourceSize,
2192 OUT UINT32 *DestinationSize,
2193 OUT UINT32 *ScratchSize
2194 );
2195
2196 /**
2197 Decompresses a compressed source buffer.
2198
2199 The Decompress() function extracts decompressed data to its original form.
2200 This protocol is designed so that the decompression algorithm can be
2201 implemented without using any memory services. As a result, the Decompress()
2202 Function is not allowed to call AllocatePool() or AllocatePages() in its
2203 implementation. It is the caller's responsibility to allocate and free the
2204 Destination and Scratch buffers.
2205 If the compressed source data specified by Source and SourceSize is
2206 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
2207 the compressed source data specified by Source and SourceSize is not in a
2208 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
2209
2210 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2211 @param Source The source buffer containing the compressed data.
2212 @param SourceSize SourceSizeThe size of source data.
2213 @param Destination On output, the destination buffer that contains
2214 the uncompressed data.
2215 @param DestinationSize The size of the destination buffer. The size of
2216 the destination buffer needed is obtained from
2217 EFI_DECOMPRESS_PROTOCOL.GetInfo().
2218 @param Scratch A temporary scratch buffer that is used to perform
2219 the decompression.
2220 @param ScratchSize The size of scratch buffer. The size of the
2221 scratch buffer needed is obtained from GetInfo().
2222
2223 @retval EFI_SUCCESS Decompression completed successfully, and the
2224 uncompressed buffer is returned in Destination.
2225 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
2226 SourceSize is corrupted (not in a valid
2227 compressed format).
2228
2229 **/
2230 EFI_STATUS
2231 EFIAPI
2232 DxeMainUefiDecompress (
2233 IN EFI_DECOMPRESS_PROTOCOL *This,
2234 IN VOID *Source,
2235 IN UINT32 SourceSize,
2236 IN OUT VOID *Destination,
2237 IN UINT32 DestinationSize,
2238 IN OUT VOID *Scratch,
2239 IN UINT32 ScratchSize
2240 );
2241
2242 /**
2243 SEP member function. This function creates and returns a new section stream
2244 handle to represent the new section stream.
2245
2246 @param SectionStreamLength Size in bytes of the section stream.
2247 @param SectionStream Buffer containing the new section stream.
2248 @param SectionStreamHandle A pointer to a caller allocated UINTN that on
2249 output contains the new section stream handle.
2250
2251 @retval EFI_SUCCESS The section stream is created successfully.
2252 @retval EFI_OUT_OF_RESOURCES memory allocation failed.
2253 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2254 of last section.
2255
2256 **/
2257 EFI_STATUS
2258 EFIAPI
2259 OpenSectionStream (
2260 IN UINTN SectionStreamLength,
2261 IN VOID *SectionStream,
2262 OUT UINTN *SectionStreamHandle
2263 );
2264
2265 /**
2266 SEP member function. Retrieves requested section from section stream.
2267
2268 @param SectionStreamHandle The section stream from which to extract the
2269 requested section.
2270 @param SectionType A pointer to the type of section to search for.
2271 @param SectionDefinitionGuid If the section type is EFI_SECTION_GUID_DEFINED,
2272 then SectionDefinitionGuid indicates which of
2273 these types of sections to search for.
2274 @param SectionInstance Indicates which instance of the requested
2275 section to return.
2276 @param Buffer Double indirection to buffer. If *Buffer is
2277 non-null on input, then the buffer is caller
2278 allocated. If Buffer is NULL, then the buffer
2279 is callee allocated. In either case, the
2280 required buffer size is returned in *BufferSize.
2281 @param BufferSize On input, indicates the size of *Buffer if
2282 *Buffer is non-null on input. On output,
2283 indicates the required size (allocated size if
2284 callee allocated) of *Buffer.
2285 @param AuthenticationStatus A pointer to a caller-allocated UINT32 that
2286 indicates the authentication status of the
2287 output buffer. If the input section's
2288 GuidedSectionHeader.Attributes field
2289 has the EFI_GUIDED_SECTION_AUTH_STATUS_VALID
2290 bit as clear, AuthenticationStatus must return
2291 zero. Both local bits (19:16) and aggregate
2292 bits (3:0) in AuthenticationStatus are returned
2293 by ExtractSection(). These bits reflect the
2294 status of the extraction operation. The bit
2295 pattern in both regions must be the same, as
2296 the local and aggregate authentication statuses
2297 have equivalent meaning at this level. If the
2298 function returns anything other than
2299 EFI_SUCCESS, the value of *AuthenticationStatus
2300 is undefined.
2301 @param IsFfs3Fv Indicates the FV format.
2302
2303 @retval EFI_SUCCESS Section was retrieved successfully
2304 @retval EFI_PROTOCOL_ERROR A GUID defined section was encountered in the
2305 section stream with its
2306 EFI_GUIDED_SECTION_PROCESSING_REQUIRED bit set,
2307 but there was no corresponding GUIDed Section
2308 Extraction Protocol in the handle database.
2309 *Buffer is unmodified.
2310 @retval EFI_NOT_FOUND An error was encountered when parsing the
2311 SectionStream. This indicates the SectionStream
2312 is not correctly formatted.
2313 @retval EFI_NOT_FOUND The requested section does not exist.
2314 @retval EFI_OUT_OF_RESOURCES The system has insufficient resources to process
2315 the request.
2316 @retval EFI_INVALID_PARAMETER The SectionStreamHandle does not exist.
2317 @retval EFI_WARN_TOO_SMALL The size of the caller allocated input buffer is
2318 insufficient to contain the requested section.
2319 The input buffer is filled and section contents
2320 are truncated.
2321
2322 **/
2323 EFI_STATUS
2324 EFIAPI
2325 GetSection (
2326 IN UINTN SectionStreamHandle,
2327 IN EFI_SECTION_TYPE *SectionType,
2328 IN EFI_GUID *SectionDefinitionGuid,
2329 IN UINTN SectionInstance,
2330 IN VOID **Buffer,
2331 IN OUT UINTN *BufferSize,
2332 OUT UINT32 *AuthenticationStatus,
2333 IN BOOLEAN IsFfs3Fv
2334 );
2335
2336 /**
2337 SEP member function. Deletes an existing section stream
2338
2339 @param StreamHandleToClose Indicates the stream to close
2340 @param FreeStreamBuffer TRUE - Need to free stream buffer;
2341 FALSE - No need to free stream buffer.
2342
2343 @retval EFI_SUCCESS The section stream is closed sucessfully.
2344 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
2345 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2346 of last section.
2347
2348 **/
2349 EFI_STATUS
2350 EFIAPI
2351 CloseSectionStream (
2352 IN UINTN StreamHandleToClose,
2353 IN BOOLEAN FreeStreamBuffer
2354 );
2355
2356 /**
2357 Creates and initializes the DebugImageInfo Table. Also creates the configuration
2358 table and registers it into the system table.
2359
2360 Note:
2361 This function allocates memory, frees it, and then allocates memory at an
2362 address within the initial allocation. Since this function is called early
2363 in DXE core initialization (before drivers are dispatched), this should not
2364 be a problem.
2365
2366 **/
2367 VOID
2368 CoreInitializeDebugImageInfoTable (
2369 VOID
2370 );
2371
2372 /**
2373 Update the CRC32 in the Debug Table.
2374 Since the CRC32 service is made available by the Runtime driver, we have to
2375 wait for the Runtime Driver to be installed before the CRC32 can be computed.
2376 This function is called elsewhere by the core when the runtime architectural
2377 protocol is produced.
2378
2379 **/
2380 VOID
2381 CoreUpdateDebugTableCrc32 (
2382 VOID
2383 );
2384
2385 /**
2386 Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
2387 the table if it's not large enough to accomidate another entry.
2388
2389 @param ImageInfoType type of debug image information
2390 @param LoadedImage pointer to the loaded image protocol for the image being
2391 loaded
2392 @param ImageHandle image handle for the image being loaded
2393
2394 **/
2395 VOID
2396 CoreNewDebugImageInfoEntry (
2397 IN UINT32 ImageInfoType,
2398 IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
2399 IN EFI_HANDLE ImageHandle
2400 );
2401
2402 /**
2403 Removes and frees an entry from the DebugImageInfo Table.
2404
2405 @param ImageHandle image handle for the image being unloaded
2406
2407 **/
2408 VOID
2409 CoreRemoveDebugImageInfoEntry (
2410 EFI_HANDLE ImageHandle
2411 );
2412
2413 /**
2414 This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
2415
2416 @param ImageHandle The image handle.
2417 @param SystemTable The system table.
2418
2419 @retval EFI_SUCCESS Successfully initialized firmware volume block
2420 driver.
2421
2422 **/
2423 EFI_STATUS
2424 EFIAPI
2425 FwVolBlockDriverInit (
2426 IN EFI_HANDLE ImageHandle,
2427 IN EFI_SYSTEM_TABLE *SystemTable
2428 );
2429
2430 /**
2431
2432 Get FVB authentication status
2433
2434 @param FvbProtocol FVB protocol.
2435
2436 @return Authentication status.
2437
2438 **/
2439 UINT32
2440 GetFvbAuthenticationStatus (
2441 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol
2442 );
2443
2444 /**
2445 This routine produces a firmware volume block protocol on a given
2446 buffer.
2447
2448 @param BaseAddress base address of the firmware volume image
2449 @param Length length of the firmware volume image
2450 @param ParentHandle handle of parent firmware volume, if this image
2451 came from an FV image file and section in another firmware
2452 volume (ala capsules)
2453 @param AuthenticationStatus Authentication status inherited, if this image
2454 came from an FV image file and section in another firmware volume.
2455 @param FvProtocol Firmware volume block protocol produced.
2456
2457 @retval EFI_VOLUME_CORRUPTED Volume corrupted.
2458 @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
2459 @retval EFI_SUCCESS Successfully produced a FVB protocol on given
2460 buffer.
2461
2462 **/
2463 EFI_STATUS
2464 ProduceFVBProtocolOnBuffer (
2465 IN EFI_PHYSICAL_ADDRESS BaseAddress,
2466 IN UINT64 Length,
2467 IN EFI_HANDLE ParentHandle,
2468 IN UINT32 AuthenticationStatus,
2469 OUT EFI_HANDLE *FvProtocol OPTIONAL
2470 );
2471
2472 /**
2473 Raising to the task priority level of the mutual exclusion
2474 lock, and then acquires ownership of the lock.
2475
2476 @param Lock The lock to acquire
2477
2478 @return Lock owned
2479
2480 **/
2481 VOID
2482 CoreAcquireLock (
2483 IN EFI_LOCK *Lock
2484 );
2485
2486 /**
2487 Initialize a basic mutual exclusion lock. Each lock
2488 provides mutual exclusion access at it's task priority
2489 level. Since there is no-premption (at any TPL) or
2490 multiprocessor support, acquiring the lock only consists
2491 of raising to the locks TPL.
2492
2493 @param Lock The EFI_LOCK structure to initialize
2494
2495 @retval EFI_SUCCESS Lock Owned.
2496 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
2497
2498 **/
2499 EFI_STATUS
2500 CoreAcquireLockOrFail (
2501 IN EFI_LOCK *Lock
2502 );
2503
2504 /**
2505 Releases ownership of the mutual exclusion lock, and
2506 restores the previous task priority level.
2507
2508 @param Lock The lock to release
2509
2510 @return Lock unowned
2511
2512 **/
2513 VOID
2514 CoreReleaseLock (
2515 IN EFI_LOCK *Lock
2516 );
2517
2518 /**
2519 Read data from Firmware Block by FVB protocol Read.
2520 The data may cross the multi block ranges.
2521
2522 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to read data.
2523 @param StartLba Pointer to StartLba.
2524 On input, the start logical block index from which to read.
2525 On output,the end logical block index after reading.
2526 @param Offset Pointer to Offset
2527 On input, offset into the block at which to begin reading.
2528 On output, offset into the end block after reading.
2529 @param DataSize Size of data to be read.
2530 @param Data Pointer to Buffer that the data will be read into.
2531
2532 @retval EFI_SUCCESS Successfully read data from firmware block.
2533 @retval others
2534 **/
2535 EFI_STATUS
2536 ReadFvbData (
2537 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
2538 IN OUT EFI_LBA *StartLba,
2539 IN OUT UINTN *Offset,
2540 IN UINTN DataSize,
2541 OUT UINT8 *Data
2542 );
2543
2544 /**
2545 Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
2546 copy the real length volume header into it.
2547
2548 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
2549 read the volume header
2550 @param FwVolHeader Pointer to pointer to allocated buffer in which
2551 the volume header is returned.
2552
2553 @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
2554 @retval EFI_SUCCESS Successfully read volume header to the allocated
2555 buffer.
2556 @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or
2557 the file system could not be understood.
2558
2559 **/
2560 EFI_STATUS
2561 GetFwVolHeader (
2562 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
2563 OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
2564 );
2565
2566 /**
2567 Verify checksum of the firmware volume header.
2568
2569 @param FvHeader Points to the firmware volume header to be checked
2570
2571 @retval TRUE Checksum verification passed
2572 @retval FALSE Checksum verification failed
2573
2574 **/
2575 BOOLEAN
2576 VerifyFvHeaderChecksum (
2577 IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader
2578 );
2579
2580 /**
2581 Initialize memory profile.
2582
2583 @param HobStart The start address of the HOB.
2584
2585 **/
2586 VOID
2587 MemoryProfileInit (
2588 IN VOID *HobStart
2589 );
2590
2591 /**
2592 Install memory profile protocol.
2593
2594 **/
2595 VOID
2596 MemoryProfileInstallProtocol (
2597 VOID
2598 );
2599
2600 /**
2601 Register image to memory profile.
2602
2603 @param DriverEntry Image info.
2604 @param FileType Image file type.
2605
2606 @return EFI_SUCCESS Register successfully.
2607 @return EFI_UNSUPPORTED Memory profile unsupported,
2608 or memory profile for the image is not required.
2609 @return EFI_OUT_OF_RESOURCES No enough resource for this register.
2610
2611 **/
2612 EFI_STATUS
2613 RegisterMemoryProfileImage (
2614 IN LOADED_IMAGE_PRIVATE_DATA *DriverEntry,
2615 IN EFI_FV_FILETYPE FileType
2616 );
2617
2618 /**
2619 Unregister image from memory profile.
2620
2621 @param DriverEntry Image info.
2622
2623 @return EFI_SUCCESS Unregister successfully.
2624 @return EFI_UNSUPPORTED Memory profile unsupported,
2625 or memory profile for the image is not required.
2626 @return EFI_NOT_FOUND The image is not found.
2627
2628 **/
2629 EFI_STATUS
2630 UnregisterMemoryProfileImage (
2631 IN LOADED_IMAGE_PRIVATE_DATA *DriverEntry
2632 );
2633
2634 /**
2635 Update memory profile information.
2636
2637 @param CallerAddress Address of caller who call Allocate or Free.
2638 @param Action This Allocate or Free action.
2639 @param MemoryType Memory type.
2640 EfiMaxMemoryType means the MemoryType is unknown.
2641 @param Size Buffer size.
2642 @param Buffer Buffer address.
2643 @param ActionString String for memory profile action.
2644 Only needed for user defined allocate action.
2645
2646 @return EFI_SUCCESS Memory profile is updated.
2647 @return EFI_UNSUPPORTED Memory profile is unsupported,
2648 or memory profile for the image is not required,
2649 or memory profile for the memory type is not required.
2650 @return EFI_ACCESS_DENIED It is during memory profile data getting.
2651 @return EFI_ABORTED Memory profile recording is not enabled.
2652 @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.
2653 @return EFI_NOT_FOUND No matched allocate info found for free action.
2654
2655 **/
2656 EFI_STATUS
2657 EFIAPI
2658 CoreUpdateProfile (
2659 IN EFI_PHYSICAL_ADDRESS CallerAddress,
2660 IN MEMORY_PROFILE_ACTION Action,
2661 IN EFI_MEMORY_TYPE MemoryType,
2662 IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool
2663 IN VOID *Buffer,
2664 IN CHAR8 *ActionString OPTIONAL
2665 );
2666
2667 /**
2668 Internal function. Converts a memory range to use new attributes.
2669
2670 @param Start The first address of the range Must be page
2671 aligned
2672 @param NumberOfPages The number of pages to convert
2673 @param NewAttributes The new attributes value for the range.
2674
2675 **/
2676 VOID
2677 CoreUpdateMemoryAttributes (
2678 IN EFI_PHYSICAL_ADDRESS Start,
2679 IN UINT64 NumberOfPages,
2680 IN UINT64 NewAttributes
2681 );
2682
2683 /**
2684 Initialize MemoryAttrubutesTable support.
2685 **/
2686 VOID
2687 EFIAPI
2688 CoreInitializeMemoryAttributesTable (
2689 VOID
2690 );
2691
2692 /**
2693 Initialize Memory Protection support.
2694 **/
2695 VOID
2696 EFIAPI
2697 CoreInitializeMemoryProtection (
2698 VOID
2699 );
2700
2701 /**
2702 Install MemoryAttributesTable on memory allocation.
2703
2704 @param[in] MemoryType EFI memory type.
2705 **/
2706 VOID
2707 InstallMemoryAttributesTableOnMemoryAllocation (
2708 IN EFI_MEMORY_TYPE MemoryType
2709 );
2710
2711 /**
2712 Insert image record.
2713
2714 @param RuntimeImage Runtime image information
2715 **/
2716 VOID
2717 InsertImageRecord (
2718 IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage
2719 );
2720
2721 /**
2722 Remove Image record.
2723
2724 @param RuntimeImage Runtime image information
2725 **/
2726 VOID
2727 RemoveImageRecord (
2728 IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage
2729 );
2730
2731 /**
2732 Protect UEFI image.
2733
2734 @param[in] LoadedImage The loaded image protocol
2735 @param[in] LoadedImageDevicePath The loaded image device path protocol
2736 **/
2737 VOID
2738 ProtectUefiImage (
2739 IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
2740 IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath
2741 );
2742
2743 /**
2744 Unprotect UEFI image.
2745
2746 @param[in] LoadedImage The loaded image protocol
2747 @param[in] LoadedImageDevicePath The loaded image device path protocol
2748 **/
2749 VOID
2750 UnprotectUefiImage (
2751 IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
2752 IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath
2753 );
2754
2755 /**
2756 ExitBootServices Callback function for memory protection.
2757 **/
2758 VOID
2759 MemoryProtectionExitBootServicesCallback (
2760 VOID
2761 );
2762
2763 /**
2764 Manage memory permission attributes on a memory range, according to the
2765 configured DXE memory protection policy.
2766
2767 @param OldType The old memory type of the range
2768 @param NewType The new memory type of the range
2769 @param Memory The base address of the range
2770 @param Length The size of the range (in bytes)
2771
2772 @return EFI_SUCCESS If the the CPU arch protocol is not installed yet
2773 @return EFI_SUCCESS If no DXE memory protection policy has been configured
2774 @return EFI_SUCCESS If OldType and NewType use the same permission attributes
2775 @return other Return value of gCpu->SetMemoryAttributes()
2776
2777 **/
2778 EFI_STATUS
2779 EFIAPI
2780 ApplyMemoryProtectionPolicy (
2781 IN EFI_MEMORY_TYPE OldType,
2782 IN EFI_MEMORY_TYPE NewType,
2783 IN EFI_PHYSICAL_ADDRESS Memory,
2784 IN UINT64 Length
2785 );
2786
2787 /**
2788 Merge continous memory map entries whose have same attributes.
2789
2790 @param MemoryMap A pointer to the buffer in which firmware places
2791 the current memory map.
2792 @param MemoryMapSize A pointer to the size, in bytes, of the
2793 MemoryMap buffer. On input, this is the size of
2794 the current memory map. On output,
2795 it is the size of new memory map after merge.
2796 @param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
2797 **/
2798 VOID
2799 MergeMemoryMap (
2800 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
2801 IN OUT UINTN *MemoryMapSize,
2802 IN UINTN DescriptorSize
2803 );
2804
2805 #endif