2 The internal header file includes the common header files, defines
3 internal structure and functions used by DxeCore module.
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
17 #include <Protocol/LoadedImage.h>
18 #include <Protocol/GuidedSectionExtraction.h>
19 #include <Protocol/DevicePath.h>
20 #include <Protocol/Runtime.h>
21 #include <Protocol/LoadFile.h>
22 #include <Protocol/LoadFile2.h>
23 #include <Protocol/DriverBinding.h>
24 #include <Protocol/VariableWrite.h>
25 #include <Protocol/PlatformDriverOverride.h>
26 #include <Protocol/Variable.h>
27 #include <Protocol/Timer.h>
28 #include <Protocol/SimpleFileSystem.h>
29 #include <Protocol/Bds.h>
30 #include <Protocol/RealTimeClock.h>
31 #include <Protocol/WatchdogTimer.h>
32 #include <Protocol/FirmwareVolume2.h>
33 #include <Protocol/MonotonicCounter.h>
34 #include <Protocol/StatusCode.h>
35 #include <Protocol/Decompress.h>
36 #include <Protocol/LoadPe32Image.h>
37 #include <Protocol/Security.h>
38 #include <Protocol/Security2.h>
39 #include <Protocol/Ebc.h>
40 #include <Protocol/Reset.h>
41 #include <Protocol/Cpu.h>
42 #include <Protocol/Metronome.h>
43 #include <Protocol/FirmwareVolumeBlock.h>
44 #include <Protocol/Capsule.h>
45 #include <Protocol/BusSpecificDriverOverride.h>
46 #include <Protocol/DriverFamilyOverride.h>
47 #include <Protocol/TcgService.h>
48 #include <Protocol/HiiPackageList.h>
49 #include <Protocol/SmmBase2.h>
50 #include <Protocol/PeCoffImageEmulator.h>
51 #include <Guid/MemoryTypeInformation.h>
52 #include <Guid/FirmwareFileSystem2.h>
53 #include <Guid/FirmwareFileSystem3.h>
54 #include <Guid/HobList.h>
55 #include <Guid/DebugImageInfoTable.h>
56 #include <Guid/FileInfo.h>
57 #include <Guid/Apriori.h>
58 #include <Guid/DxeServices.h>
59 #include <Guid/MemoryAllocationHob.h>
60 #include <Guid/EventLegacyBios.h>
61 #include <Guid/EventGroup.h>
62 #include <Guid/EventExitBootServiceFailed.h>
63 #include <Guid/LoadModuleAtFixedAddress.h>
64 #include <Guid/IdleLoopEvent.h>
65 #include <Guid/VectorHandoffTable.h>
66 #include <Ppi/VectorHandoffInfo.h>
67 #include <Guid/MemoryProfile.h>
69 #include <Library/DxeCoreEntryPoint.h>
70 #include <Library/DebugLib.h>
71 #include <Library/UefiLib.h>
72 #include <Library/BaseLib.h>
73 #include <Library/HobLib.h>
74 #include <Library/PerformanceLib.h>
75 #include <Library/UefiDecompressLib.h>
76 #include <Library/ExtractGuidedSectionLib.h>
77 #include <Library/CacheMaintenanceLib.h>
78 #include <Library/BaseMemoryLib.h>
79 #include <Library/PeCoffLib.h>
80 #include <Library/PeCoffGetEntryPointLib.h>
81 #include <Library/PeCoffExtraActionLib.h>
82 #include <Library/PcdLib.h>
83 #include <Library/MemoryAllocationLib.h>
84 #include <Library/DevicePathLib.h>
85 #include <Library/UefiBootServicesTableLib.h>
86 #include <Library/ReportStatusCodeLib.h>
87 #include <Library/DxeServicesLib.h>
88 #include <Library/DebugAgentLib.h>
89 #include <Library/CpuExceptionHandlerLib.h>
93 // attributes for reserved memory before it is promoted to system memory
95 #define EFI_MEMORY_PRESENT 0x0100000000000000ULL
96 #define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL
97 #define EFI_MEMORY_TESTED 0x0400000000000000ULL
100 // range for memory mapped port I/O on IPF
102 #define EFI_MEMORY_PORT_IO 0x4000000000000000ULL
106 /// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependency expression
107 /// to save time. A EFI_DEP_PUSH is evaluated one an
108 /// replaced with EFI_DEP_REPLACE_TRUE. If PI spec's Vol 2
109 /// Driver Execution Environment Core Interface use 0xff
110 /// as new DEPEX opcode. EFI_DEP_REPLACE_TRUE should be
111 /// defined to a new value that is not conflicting with PI spec.
113 #define EFI_DEP_REPLACE_TRUE 0xff
116 /// Define the initial size of the dependency expression evaluation stack
118 #define DEPEX_STACK_SIZE_INCREMENT 0x1000
121 EFI_GUID
*ProtocolGuid
;
126 } EFI_CORE_PROTOCOL_NOTIFY_ENTRY
;
129 // DXE Dispatcher Data structures
132 #define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w')
135 LIST_ENTRY Link
; // mFvHandleList
141 #define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r')
144 LIST_ENTRY Link
; // mDriverList
146 LIST_ENTRY ScheduledLink
; // mScheduledQueue
150 EFI_DEVICE_PATH_PROTOCOL
*FvFileDevicePath
;
151 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
158 EFI_GUID BeforeAfterGuid
;
165 BOOLEAN DepexProtocolError
;
167 EFI_HANDLE ImageHandle
;
170 } EFI_CORE_DRIVER_ENTRY
;
173 //The data structure of GCD memory map entry
175 #define EFI_GCD_MAP_SIGNATURE SIGNATURE_32('g','c','d','m')
179 EFI_PHYSICAL_ADDRESS BaseAddress
;
183 EFI_GCD_MEMORY_TYPE GcdMemoryType
;
184 EFI_GCD_IO_TYPE GcdIoType
;
185 EFI_HANDLE ImageHandle
;
186 EFI_HANDLE DeviceHandle
;
190 #define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','d','r','i')
198 /// If entrypoint has been called
200 /// The image's entry point
201 EFI_IMAGE_ENTRY_POINT EntryPoint
;
202 /// loaded image protocol
203 EFI_LOADED_IMAGE_PROTOCOL Info
;
204 /// Location in memory
205 EFI_PHYSICAL_ADDRESS ImageBasePage
;
208 /// Original fixup data
210 /// Tpl of started image
212 /// Status returned by started image
214 /// Size of ExitData from started image
216 /// Pointer to exit data from started image
218 /// Pointer to pool allocation for context save/restore
220 /// Pointer to buffer for context save/restore
221 BASE_LIBRARY_JUMP_BUFFER
*JumpContext
;
222 /// Machine type from PE image
224 /// EBC Protocol pointer
225 EFI_EBC_PROTOCOL
*Ebc
;
226 /// PE/COFF Image Emulator Protocol pointer
227 EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL
*PeCoffEmu
;
228 /// Runtime image list
229 EFI_RUNTIME_IMAGE_ENTRY
*RuntimeData
;
230 /// Pointer to Loaded Image Device Path Protocol
231 EFI_DEVICE_PATH_PROTOCOL
*LoadedImageDevicePath
;
232 /// PeCoffLoader ImageContext
233 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext
;
234 /// Status returned by LoadImage() service.
235 EFI_STATUS LoadImageStatus
;
236 } LOADED_IMAGE_PRIVATE_DATA
;
238 #define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \
239 CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE)
241 #define IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE SIGNATURE_32 ('I','P','R','C')
246 EFI_PHYSICAL_ADDRESS CodeSegmentBase
;
247 UINT64 CodeSegmentSize
;
248 } IMAGE_PROPERTIES_RECORD_CODE_SECTION
;
250 #define IMAGE_PROPERTIES_RECORD_SIGNATURE SIGNATURE_32 ('I','P','R','D')
255 EFI_PHYSICAL_ADDRESS ImageBase
;
257 UINTN CodeSegmentCount
;
258 LIST_ENTRY CodeSegmentList
;
259 } IMAGE_PROPERTIES_RECORD
;
262 // DXE Core Global Variables
264 extern EFI_SYSTEM_TABLE
*gDxeCoreST
;
265 extern EFI_RUNTIME_SERVICES
*gDxeCoreRT
;
266 extern EFI_DXE_SERVICES
*gDxeCoreDS
;
267 extern EFI_HANDLE gDxeCoreImageHandle
;
269 extern BOOLEAN gMemoryMapTerminated
;
271 extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress
;
273 extern EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
;
274 extern EFI_CPU_ARCH_PROTOCOL
*gCpu
;
275 extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL
*gWatchdogTimer
;
276 extern EFI_METRONOME_ARCH_PROTOCOL
*gMetronome
;
277 extern EFI_TIMER_ARCH_PROTOCOL
*gTimer
;
278 extern EFI_SECURITY_ARCH_PROTOCOL
*gSecurity
;
279 extern EFI_SECURITY2_ARCH_PROTOCOL
*gSecurity2
;
280 extern EFI_BDS_ARCH_PROTOCOL
*gBds
;
281 extern EFI_SMM_BASE2_PROTOCOL
*gSmmBase2
;
283 extern EFI_TPL gEfiCurrentTpl
;
285 extern EFI_GUID
*gDxeCoreFileName
;
286 extern EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
288 extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation
[EfiMaxMemoryType
+ 1];
290 extern BOOLEAN gDispatcherRunning
;
291 extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
;
293 extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable
;
294 extern BOOLEAN gLoadFixedAddressCodeMemoryReady
;
296 // Service Initialization Functions
302 Called to initialize the pool.
312 Called to initialize the memory map and add descriptors to
313 the current descriptor list.
314 The first descriptor that is added must be general usable
315 memory as the addition allocates heap.
317 @param Type The type of memory to add
318 @param Start The starting address in the memory range Must be
320 @param NumberOfPages The number of pages in the range
321 @param Attribute Attributes of the memory to add
323 @return None. The range is added to the memory map
327 CoreAddMemoryDescriptor (
328 IN EFI_MEMORY_TYPE Type
,
329 IN EFI_PHYSICAL_ADDRESS Start
,
330 IN UINT64 NumberOfPages
,
336 Release memory lock on mGcdMemorySpaceLock.
340 CoreReleaseGcdMemoryLock (
346 Acquire memory lock on mGcdMemorySpaceLock.
350 CoreAcquireGcdMemoryLock (
356 External function. Initializes memory services based on the memory
357 descriptor HOBs. This function is responsible for priming the memory
358 map, so memory allocations and resource allocations can be made.
359 The first part of this function can not depend on any memory services
360 until at least one memory descriptor is provided to the memory services.
362 @param HobStart The start address of the HOB.
363 @param MemoryBaseAddress Start address of memory region found to init DXE
365 @param MemoryLength Length of memory region found to init DXE core.
367 @retval EFI_SUCCESS Memory services successfully initialized.
371 CoreInitializeMemoryServices (
373 OUT EFI_PHYSICAL_ADDRESS
*MemoryBaseAddress
,
374 OUT UINT64
*MemoryLength
380 External function. Initializes the GCD and memory services based on the memory
381 descriptor HOBs. This function is responsible for priming the GCD map and the
382 memory map, so memory allocations and resource allocations can be made. The
383 HobStart will be relocated to a pool buffer.
385 @param HobStart The start address of the HOB
386 @param MemoryBaseAddress Start address of memory region found to init DXE
388 @param MemoryLength Length of memory region found to init DXE core.
390 @retval EFI_SUCCESS GCD services successfully initialized.
394 CoreInitializeGcdServices (
395 IN OUT VOID
**HobStart
,
396 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress
,
397 IN UINT64 MemoryLength
402 Initializes "event" support.
404 @retval EFI_SUCCESS Always return success
408 CoreInitializeEventServices (
414 Add the Image Services to EFI Boot Services Table and install the protocol
415 interfaces for this image.
417 @param HobStart The HOB to initialize
423 CoreInitializeImageServices (
429 Creates an event that is fired everytime a Protocol of a specific type is installed.
433 CoreNotifyOnProtocolInstallation (
439 Return TRUE if all AP services are available.
441 @retval EFI_SUCCESS All AP services are available
442 @retval EFI_NOT_FOUND At least one AP service is not available
446 CoreAllEfiServicesAvailable (
452 Calcualte the 32-bit CRC in a EFI table using the service provided by the
455 @param Hdr Pointer to an EFI standard header
460 IN OUT EFI_TABLE_HEADER
*Hdr
465 Called by the platform code to process a tick.
467 @param Duration The number of 100ns elapsed since the last call
479 Initialize the dispatcher. Initialize the notification function that runs when
480 an FV2 protocol is added to the system.
484 CoreInitializeDispatcher (
490 This is the POSTFIX version of the dependency evaluator. This code does
491 not need to handle Before or After, as it is not valid to call this
492 routine in this case. The SOR is just ignored and is a nop in the grammer.
493 POSTFIX means all the math is done on top of the stack.
495 @param DriverEntry DriverEntry element to update.
497 @retval TRUE If driver is ready to run.
498 @retval FALSE If driver is not ready to run or some fatal error
504 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
509 Preprocess dependency expression and update DriverEntry to reflect the
510 state of Before, After, and SOR dependencies. If DriverEntry->Before
511 or DriverEntry->After is set it will never be cleared. If SOR is set
512 it will be cleared by CoreSchedule(), and then the driver can be
515 @param DriverEntry DriverEntry element to update .
517 @retval EFI_SUCCESS It always works.
521 CorePreProcessDepex (
522 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
528 Terminates all boot services.
530 @param ImageHandle Handle that identifies the exiting image.
531 @param MapKey Key to the latest memory map.
533 @retval EFI_SUCCESS Boot Services terminated
534 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
539 CoreExitBootServices (
540 IN EFI_HANDLE ImageHandle
,
546 Make sure the memory map is following all the construction rules,
547 it is the last time to check memory map error before exit boot services.
549 @param MapKey Memory map key
551 @retval EFI_INVALID_PARAMETER Memory map not consistent with construction
553 @retval EFI_SUCCESS Valid memory map.
557 CoreTerminateMemoryMap (
563 Signals all events in the EventGroup.
565 @param EventGroup The list to signal
569 CoreNotifySignalList (
570 IN EFI_GUID
*EventGroup
576 Boot Service called to add, modify, or remove a system configuration table from
577 the EFI System Table.
579 @param Guid Pointer to the GUID for the entry to add, update, or
581 @param Table Pointer to the configuration table for the entry to add,
582 update, or remove, may be NULL.
584 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.
585 @return EFI_INVALID_PARAMETER Input GUID not valid.
586 @return EFI_NOT_FOUND Attempted to delete non-existant entry
587 @return EFI_OUT_OF_RESOURCES Not enough memory available
592 CoreInstallConfigurationTable (
600 Raise the task priority level to the new level.
601 High level is implemented by disabling processor interrupts.
603 @param NewTpl New task priority level
605 @return The previous task priority level
617 Lowers the task priority to the previous value. If the new
618 priority unmasks events at a higher priority, they are dispatched.
620 @param NewTpl New, lower, task priority
632 Introduces a fine-grained stall.
634 @param Microseconds The number of microseconds to stall execution.
636 @retval EFI_SUCCESS Execution was stalled for at least the requested
637 amount of microseconds.
638 @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet
644 IN UINTN Microseconds
650 Sets the system's watchdog timer.
652 @param Timeout The number of seconds to set the watchdog timer to.
653 A value of zero disables the timer.
654 @param WatchdogCode The numeric code to log on a watchdog timer timeout
655 event. The firmware reserves codes 0x0000 to 0xFFFF.
656 Loaders and operating systems may use other timeout
658 @param DataSize The size, in bytes, of WatchdogData.
659 @param WatchdogData A data buffer that includes a Null-terminated Unicode
660 string, optionally followed by additional binary data.
661 The string is a description that the call may use to
662 further indicate the reason to be logged with a
665 @return EFI_SUCCESS Timeout has been set
666 @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
667 @return EFI_UNSUPPORTED System does not have a timer (currently not used)
668 @return EFI_DEVICE_ERROR Could not complete due to hardware error
673 CoreSetWatchdogTimer (
675 IN UINT64 WatchdogCode
,
677 IN CHAR16
*WatchdogData OPTIONAL
683 Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
684 Calls the private one which contains a BOOLEAN parameter for notifications
686 @param UserHandle The handle to install the protocol handler on,
687 or NULL if a new handle is to be allocated
688 @param Protocol The protocol to add to the handle
689 @param InterfaceType Indicates whether Interface is supplied in
691 @param Interface The interface for the protocol being added
698 CoreInstallProtocolInterface (
699 IN OUT EFI_HANDLE
*UserHandle
,
700 IN EFI_GUID
*Protocol
,
701 IN EFI_INTERFACE_TYPE InterfaceType
,
707 Installs a protocol interface into the boot services environment.
709 @param UserHandle The handle to install the protocol handler on,
710 or NULL if a new handle is to be allocated
711 @param Protocol The protocol to add to the handle
712 @param InterfaceType Indicates whether Interface is supplied in
714 @param Interface The interface for the protocol being added
715 @param Notify indicates whether notify the notification list
718 @retval EFI_INVALID_PARAMETER Invalid parameter
719 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
720 @retval EFI_SUCCESS Protocol interface successfully installed
724 CoreInstallProtocolInterfaceNotify (
725 IN OUT EFI_HANDLE
*UserHandle
,
726 IN EFI_GUID
*Protocol
,
727 IN EFI_INTERFACE_TYPE InterfaceType
,
735 Installs a list of protocol interface into the boot services environment.
736 This function calls InstallProtocolInterface() in a loop. If any error
737 occures all the protocols added by this function are removed. This is
738 basically a lib function to save space.
740 @param Handle The handle to install the protocol handlers on,
741 or NULL if a new handle is to be allocated
742 @param ... EFI_GUID followed by protocol instance. A NULL
743 terminates the list. The pairs are the
744 arguments to InstallProtocolInterface(). All the
745 protocols are added to Handle.
747 @retval EFI_SUCCESS All the protocol interface was installed.
748 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
749 @retval EFI_ALREADY_STARTED A Device Path Protocol instance was passed in that is already present in
751 @retval EFI_INVALID_PARAMETER Handle is NULL.
752 @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.
757 CoreInstallMultipleProtocolInterfaces (
758 IN OUT EFI_HANDLE
*Handle
,
765 Uninstalls a list of protocol interface in the boot services environment.
766 This function calls UnisatllProtocolInterface() in a loop. This is
767 basically a lib function to save space.
769 @param Handle The handle to uninstall the protocol
770 @param ... EFI_GUID followed by protocol instance. A NULL
771 terminates the list. The pairs are the
772 arguments to UninstallProtocolInterface(). All
773 the protocols are added to Handle.
780 CoreUninstallMultipleProtocolInterfaces (
781 IN EFI_HANDLE Handle
,
788 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
790 @param UserHandle Handle on which the interface is to be
792 @param Protocol The numeric ID of the interface
793 @param OldInterface A pointer to the old interface
794 @param NewInterface A pointer to the new interface
796 @retval EFI_SUCCESS The protocol interface was installed
797 @retval EFI_NOT_FOUND The OldInterface on the handle was not found
798 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
803 CoreReinstallProtocolInterface (
804 IN EFI_HANDLE UserHandle
,
805 IN EFI_GUID
*Protocol
,
806 IN VOID
*OldInterface
,
807 IN VOID
*NewInterface
813 Uninstalls all instances of a protocol:interfacer from a handle.
814 If the last protocol interface is remove from the handle, the
817 @param UserHandle The handle to remove the protocol handler from
818 @param Protocol The protocol, of protocol:interface, to remove
819 @param Interface The interface, of protocol:interface, to remove
821 @retval EFI_INVALID_PARAMETER Protocol is NULL.
822 @retval EFI_SUCCESS Protocol interface successfully uninstalled.
827 CoreUninstallProtocolInterface (
828 IN EFI_HANDLE UserHandle
,
829 IN EFI_GUID
*Protocol
,
836 Queries a handle to determine if it supports a specified protocol.
838 @param UserHandle The handle being queried.
839 @param Protocol The published unique identifier of the protocol.
840 @param Interface Supplies the address where a pointer to the
841 corresponding Protocol Interface is returned.
843 @return The requested protocol interface for the handle
849 IN EFI_HANDLE UserHandle
,
850 IN EFI_GUID
*Protocol
,
857 Locates the installed protocol handler for the handle, and
858 invokes it to obtain the protocol interface. Usage information
859 is registered in the protocol data base.
861 @param UserHandle The handle to obtain the protocol interface on
862 @param Protocol The ID of the protocol
863 @param Interface The location to return the protocol interface
864 @param ImageHandle The handle of the Image that is opening the
865 protocol interface specified by Protocol and
867 @param ControllerHandle The controller handle that is requiring this
869 @param Attributes The open mode of the protocol interface
870 specified by Handle and Protocol.
872 @retval EFI_INVALID_PARAMETER Protocol is NULL.
873 @retval EFI_SUCCESS Get the protocol interface.
879 IN EFI_HANDLE UserHandle
,
880 IN EFI_GUID
*Protocol
,
881 OUT VOID
**Interface OPTIONAL
,
882 IN EFI_HANDLE ImageHandle
,
883 IN EFI_HANDLE ControllerHandle
,
890 Return information about Opened protocols in the system
892 @param UserHandle The handle to close the protocol interface on
893 @param Protocol The ID of the protocol
894 @param EntryBuffer A pointer to a buffer of open protocol
895 information in the form of
896 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
897 @param EntryCount Number of EntryBuffer entries
902 CoreOpenProtocolInformation (
903 IN EFI_HANDLE UserHandle
,
904 IN EFI_GUID
*Protocol
,
905 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
**EntryBuffer
,
906 OUT UINTN
*EntryCount
912 Closes a protocol on a handle that was opened using OpenProtocol().
914 @param UserHandle The handle for the protocol interface that was
915 previously opened with OpenProtocol(), and is
917 @param Protocol The published unique identifier of the protocol.
918 It is the caller's responsibility to pass in a
920 @param AgentHandle The handle of the agent that is closing the
922 @param ControllerHandle If the agent that opened a protocol is a driver
923 that follows the EFI Driver Model, then this
924 parameter is the controller handle that required
925 the protocol interface. If the agent does not
926 follow the EFI Driver Model, then this parameter
927 is optional and may be NULL.
929 @retval EFI_SUCCESS The protocol instance was closed.
930 @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a
932 @retval EFI_NOT_FOUND Can not find the specified protocol or
939 IN EFI_HANDLE UserHandle
,
940 IN EFI_GUID
*Protocol
,
941 IN EFI_HANDLE AgentHandle
,
942 IN EFI_HANDLE ControllerHandle
948 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
951 @param UserHandle The handle from which to retrieve the list of
952 protocol interface GUIDs.
953 @param ProtocolBuffer A pointer to the list of protocol interface GUID
954 pointers that are installed on Handle.
955 @param ProtocolBufferCount A pointer to the number of GUID pointers present
958 @retval EFI_SUCCESS The list of protocol interface GUIDs installed
959 on Handle was returned in ProtocolBuffer. The
960 number of protocol interface GUIDs was returned
961 in ProtocolBufferCount.
962 @retval EFI_INVALID_PARAMETER Handle is NULL.
963 @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
964 @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.
965 @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.
966 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
972 CoreProtocolsPerHandle (
973 IN EFI_HANDLE UserHandle
,
974 OUT EFI_GUID
***ProtocolBuffer
,
975 OUT UINTN
*ProtocolBufferCount
981 Add a new protocol notification record for the request protocol.
983 @param Protocol The requested protocol to add the notify
985 @param Event The event to signal
986 @param Registration Returns the registration record
988 @retval EFI_INVALID_PARAMETER Invalid parameter
989 @retval EFI_SUCCESS Successfully returned the registration record
995 CoreRegisterProtocolNotify (
996 IN EFI_GUID
*Protocol
,
998 OUT VOID
**Registration
1003 Removes all the events in the protocol database that match Event.
1005 @param Event The event to search for in the protocol
1008 @return EFI_SUCCESS when done searching the entire database.
1012 CoreUnregisterProtocolNotify (
1018 Locates the requested handle(s) and returns them in Buffer.
1020 @param SearchType The type of search to perform to locate the
1022 @param Protocol The protocol to search for
1023 @param SearchKey Dependant on SearchType
1024 @param BufferSize On input the size of Buffer. On output the
1025 size of data returned.
1026 @param Buffer The buffer to return the results in
1028 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
1029 returned in BufferSize.
1030 @retval EFI_INVALID_PARAMETER Invalid parameter
1031 @retval EFI_SUCCESS Successfully found the requested handle(s) and
1032 returns them in Buffer.
1038 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1039 IN EFI_GUID
*Protocol OPTIONAL
,
1040 IN VOID
*SearchKey OPTIONAL
,
1041 IN OUT UINTN
*BufferSize
,
1042 OUT EFI_HANDLE
*Buffer
1048 Locates the handle to a device on the device path that best matches the specified protocol.
1050 @param Protocol The protocol to search for.
1051 @param DevicePath On input, a pointer to a pointer to the device
1052 path. On output, the device path pointer is
1053 modified to point to the remaining part of the
1055 @param Device A pointer to the returned device handle.
1057 @retval EFI_SUCCESS The resulting handle was returned.
1058 @retval EFI_NOT_FOUND No handles matched the search.
1059 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1064 CoreLocateDevicePath (
1065 IN EFI_GUID
*Protocol
,
1066 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
1067 OUT EFI_HANDLE
*Device
1073 Function returns an array of handles that support the requested protocol
1074 in a buffer allocated from pool. This is a version of CoreLocateHandle()
1075 that allocates a buffer for the caller.
1077 @param SearchType Specifies which handle(s) are to be returned.
1078 @param Protocol Provides the protocol to search by. This
1079 parameter is only valid for SearchType
1081 @param SearchKey Supplies the search key depending on the
1083 @param NumberHandles The number of handles returned in Buffer.
1084 @param Buffer A pointer to the buffer to return the requested
1085 array of handles that support Protocol.
1087 @retval EFI_SUCCESS The result array of handles was returned.
1088 @retval EFI_NOT_FOUND No handles match the search.
1089 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
1091 @retval EFI_INVALID_PARAMETER One or more parameters are not valid.
1096 CoreLocateHandleBuffer (
1097 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1098 IN EFI_GUID
*Protocol OPTIONAL
,
1099 IN VOID
*SearchKey OPTIONAL
,
1100 IN OUT UINTN
*NumberHandles
,
1101 OUT EFI_HANDLE
**Buffer
1107 Return the first Protocol Interface that matches the Protocol GUID. If
1108 Registration is passed in, return a Protocol Instance that was just add
1109 to the system. If Registration is NULL return the first Protocol Interface
1112 @param Protocol The protocol to search for
1113 @param Registration Optional Registration Key returned from
1114 RegisterProtocolNotify()
1115 @param Interface Return the Protocol interface (instance).
1117 @retval EFI_SUCCESS If a valid Interface is returned
1118 @retval EFI_INVALID_PARAMETER Invalid parameter
1119 @retval EFI_NOT_FOUND Protocol interface not found
1124 CoreLocateProtocol (
1125 IN EFI_GUID
*Protocol
,
1126 IN VOID
*Registration OPTIONAL
,
1127 OUT VOID
**Interface
1132 return handle database key.
1135 @return Handle database key.
1139 CoreGetHandleDatabaseKey (
1145 Go connect any handles that were created or modified while a image executed.
1147 @param Key The Key to show that the handle has been
1152 CoreConnectHandlesByKey (
1159 Connects one or more drivers to a controller.
1161 @param ControllerHandle The handle of the controller to which driver(s) are to be connected.
1162 @param DriverImageHandle A pointer to an ordered list handles that support the
1163 EFI_DRIVER_BINDING_PROTOCOL.
1164 @param RemainingDevicePath A pointer to the device path that specifies a child of the
1165 controller specified by ControllerHandle.
1166 @param Recursive If TRUE, then ConnectController() is called recursively
1167 until the entire tree of controllers below the controller specified
1168 by ControllerHandle have been created. If FALSE, then
1169 the tree of controllers is only expanded one level.
1171 @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.
1172 2) No drivers were connected to ControllerHandle, but
1173 RemainingDevicePath is not NULL, and it is an End Device
1175 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1176 @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
1177 present in the system.
1178 2) No drivers were connected to ControllerHandle.
1179 @retval EFI_SECURITY_VIOLATION
1180 The user has no permission to start UEFI device drivers on the device path
1181 associated with the ControllerHandle or specified by the RemainingDevicePath.
1186 CoreConnectController (
1187 IN EFI_HANDLE ControllerHandle
,
1188 IN EFI_HANDLE
*DriverImageHandle OPTIONAL
,
1189 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
1190 IN BOOLEAN Recursive
1196 Disonnects a controller from a driver
1198 @param ControllerHandle ControllerHandle The handle of
1199 the controller from which
1202 @param DriverImageHandle DriverImageHandle The driver to
1203 disconnect from ControllerHandle.
1204 @param ChildHandle ChildHandle The handle of the
1207 @retval EFI_SUCCESS One or more drivers were
1208 disconnected from the controller.
1209 @retval EFI_SUCCESS On entry, no drivers are managing
1211 @retval EFI_SUCCESS DriverImageHandle is not NULL,
1212 and on entry DriverImageHandle is
1213 not managing ControllerHandle.
1214 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1215 @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
1216 and it is not a valid EFI_HANDLE.
1217 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
1218 is not a valid EFI_HANDLE.
1219 @retval EFI_OUT_OF_RESOURCES There are not enough resources
1220 available to disconnect any
1221 drivers from ControllerHandle.
1222 @retval EFI_DEVICE_ERROR The controller could not be
1223 disconnected because of a device
1229 CoreDisconnectController (
1230 IN EFI_HANDLE ControllerHandle
,
1231 IN EFI_HANDLE DriverImageHandle OPTIONAL
,
1232 IN EFI_HANDLE ChildHandle OPTIONAL
1238 Allocates pages from the memory map.
1240 @param Type The type of allocation to perform
1241 @param MemoryType The type of memory to turn the allocated pages
1243 @param NumberOfPages The number of pages to allocate
1244 @param Memory A pointer to receive the base allocated memory
1247 @return Status. On success, Memory is filled in with the base address allocated
1248 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
1250 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
1251 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
1252 @retval EFI_SUCCESS Pages successfully allocated.
1258 IN EFI_ALLOCATE_TYPE Type
,
1259 IN EFI_MEMORY_TYPE MemoryType
,
1260 IN UINTN NumberOfPages
,
1261 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
1265 Frees previous allocated pages.
1267 @param Memory Base address of memory being freed
1268 @param NumberOfPages The number of pages to free
1270 @retval EFI_NOT_FOUND Could not find the entry that covers the range
1271 @retval EFI_INVALID_PARAMETER Address not aligned
1272 @return EFI_SUCCESS -Pages successfully freed.
1278 IN EFI_PHYSICAL_ADDRESS Memory
,
1279 IN UINTN NumberOfPages
1283 This function returns a copy of the current memory map. The map is an array of
1284 memory descriptors, each of which describes a contiguous block of memory.
1286 @param MemoryMapSize A pointer to the size, in bytes, of the
1287 MemoryMap buffer. On input, this is the size of
1288 the buffer allocated by the caller. On output,
1289 it is the size of the buffer returned by the
1290 firmware if the buffer was large enough, or the
1291 size of the buffer needed to contain the map if
1292 the buffer was too small.
1293 @param MemoryMap A pointer to the buffer in which firmware places
1294 the current memory map.
1295 @param MapKey A pointer to the location in which firmware
1296 returns the key for the current memory map.
1297 @param DescriptorSize A pointer to the location in which firmware
1298 returns the size, in bytes, of an individual
1299 EFI_MEMORY_DESCRIPTOR.
1300 @param DescriptorVersion A pointer to the location in which firmware
1301 returns the version number associated with the
1302 EFI_MEMORY_DESCRIPTOR.
1304 @retval EFI_SUCCESS The memory map was returned in the MemoryMap
1306 @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
1307 buffer size needed to hold the memory map is
1308 returned in MemoryMapSize.
1309 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1315 IN OUT UINTN
*MemoryMapSize
,
1316 IN OUT EFI_MEMORY_DESCRIPTOR
*MemoryMap
,
1318 OUT UINTN
*DescriptorSize
,
1319 OUT UINT32
*DescriptorVersion
1325 Allocate pool of a particular type.
1327 @param PoolType Type of pool to allocate
1328 @param Size The amount of pool to allocate
1329 @param Buffer The address to return a pointer to the allocated
1332 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
1333 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
1334 @retval EFI_SUCCESS Pool successfully allocated.
1340 IN EFI_MEMORY_TYPE PoolType
,
1346 Allocate pool of a particular type.
1348 @param PoolType Type of pool to allocate
1349 @param Size The amount of pool to allocate
1350 @param Buffer The address to return a pointer to the allocated
1353 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
1354 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
1355 @retval EFI_SUCCESS Pool successfully allocated.
1360 CoreInternalAllocatePool (
1361 IN EFI_MEMORY_TYPE PoolType
,
1369 @param Buffer The allocated pool entry to free
1371 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
1372 @retval EFI_SUCCESS Pool successfully freed.
1384 @param Buffer The allocated pool entry to free
1385 @param PoolType Pointer to pool type
1387 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
1388 @retval EFI_SUCCESS Pool successfully freed.
1393 CoreInternalFreePool (
1395 OUT EFI_MEMORY_TYPE
*PoolType OPTIONAL
1399 Loads an EFI image into memory and returns a handle to the image.
1401 @param BootPolicy If TRUE, indicates that the request originates
1402 from the boot manager, and that the boot
1403 manager is attempting to load FilePath as a
1405 @param ParentImageHandle The caller's image handle.
1406 @param FilePath The specific file path from which the image is
1408 @param SourceBuffer If not NULL, a pointer to the memory location
1409 containing a copy of the image to be loaded.
1410 @param SourceSize The size in bytes of SourceBuffer.
1411 @param ImageHandle Pointer to the returned image handle that is
1412 created when the image is successfully loaded.
1414 @retval EFI_SUCCESS The image was loaded into memory.
1415 @retval EFI_NOT_FOUND The FilePath was not found.
1416 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1417 @retval EFI_UNSUPPORTED The image type is not supported, or the device
1418 path cannot be parsed to locate the proper
1419 protocol for loading the file.
1420 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
1422 @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
1424 @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
1425 @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
1426 image from being loaded. NULL is returned in *ImageHandle.
1427 @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
1428 valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
1429 platform policy specifies that the image should not be started.
1435 IN BOOLEAN BootPolicy
,
1436 IN EFI_HANDLE ParentImageHandle
,
1437 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
1438 IN VOID
*SourceBuffer OPTIONAL
,
1439 IN UINTN SourceSize
,
1440 OUT EFI_HANDLE
*ImageHandle
1448 @param ImageHandle Handle that identifies the image to be
1451 @retval EFI_SUCCESS The image has been unloaded.
1452 @retval EFI_UNSUPPORTED The image has been started, and does not support
1454 @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
1460 IN EFI_HANDLE ImageHandle
1466 Transfer control to a loaded image's entry point.
1468 @param ImageHandle Handle of image to be started.
1469 @param ExitDataSize Pointer of the size to ExitData
1470 @param ExitData Pointer to a pointer to a data buffer that
1471 includes a Null-terminated string,
1472 optionally followed by additional binary data.
1473 The string is a description that the caller may
1474 use to further indicate the reason for the
1477 @retval EFI_INVALID_PARAMETER Invalid parameter
1478 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1479 @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
1480 @retval EFI_SUCCESS Successfully transfer control to the image's
1487 IN EFI_HANDLE ImageHandle
,
1488 OUT UINTN
*ExitDataSize
,
1489 OUT CHAR16
**ExitData OPTIONAL
1495 Terminates the currently loaded EFI image and returns control to boot services.
1497 @param ImageHandle Handle that identifies the image. This
1498 parameter is passed to the image on entry.
1499 @param Status The image's exit code.
1500 @param ExitDataSize The size, in bytes, of ExitData. Ignored if
1501 ExitStatus is EFI_SUCCESS.
1502 @param ExitData Pointer to a data buffer that includes a
1503 Null-terminated Unicode string, optionally
1504 followed by additional binary data. The string
1505 is a description that the caller may use to
1506 further indicate the reason for the image's
1509 @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
1511 @retval EFI_SUCCESS Successfully terminates the currently loaded
1513 @retval EFI_ACCESS_DENIED Should never reach there.
1514 @retval EFI_OUT_OF_RESOURCES Could not allocate pool
1520 IN EFI_HANDLE ImageHandle
,
1521 IN EFI_STATUS Status
,
1522 IN UINTN ExitDataSize
,
1523 IN CHAR16
*ExitData OPTIONAL
1531 @param Type The type of event to create and its mode and
1533 @param NotifyTpl The task priority level of event notifications
1534 @param NotifyFunction Pointer to the events notification function
1535 @param NotifyContext Pointer to the notification functions context;
1536 corresponds to parameter "Context" in the
1537 notification function
1538 @param Event Pointer to the newly created event if the call
1539 succeeds; undefined otherwise
1541 @retval EFI_SUCCESS The event structure was created
1542 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1543 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1550 IN EFI_TPL NotifyTpl
,
1551 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1552 IN VOID
*NotifyContext
, OPTIONAL
1553 OUT EFI_EVENT
*Event
1559 Creates an event in a group.
1561 @param Type The type of event to create and its mode and
1563 @param NotifyTpl The task priority level of event notifications
1564 @param NotifyFunction Pointer to the events notification function
1565 @param NotifyContext Pointer to the notification functions context;
1566 corresponds to parameter "Context" in the
1567 notification function
1568 @param EventGroup GUID for EventGroup if NULL act the same as
1570 @param Event Pointer to the newly created event if the call
1571 succeeds; undefined otherwise
1573 @retval EFI_SUCCESS The event structure was created
1574 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1575 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1582 IN EFI_TPL NotifyTpl
,
1583 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1584 IN CONST VOID
*NotifyContext
, OPTIONAL
1585 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1586 OUT EFI_EVENT
*Event
1590 Creates a general-purpose event structure
1592 @param Type The type of event to create and its mode and
1594 @param NotifyTpl The task priority level of event notifications
1595 @param NotifyFunction Pointer to the events notification function
1596 @param NotifyContext Pointer to the notification functions context;
1597 corresponds to parameter "Context" in the
1598 notification function
1599 @param EventGroup GUID for EventGroup if NULL act the same as
1601 @param Event Pointer to the newly created event if the call
1602 succeeds; undefined otherwise
1604 @retval EFI_SUCCESS The event structure was created
1605 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1606 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1611 CoreCreateEventInternal (
1613 IN EFI_TPL NotifyTpl
,
1614 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1615 IN CONST VOID
*NotifyContext
, OPTIONAL
1616 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1617 OUT EFI_EVENT
*Event
1621 Sets the type of timer and the trigger time for a timer event.
1623 @param UserEvent The timer event that is to be signaled at the
1625 @param Type The type of time that is specified in
1627 @param TriggerTime The number of 100ns units until the timer
1630 @retval EFI_SUCCESS The event has been set to be signaled at the
1632 @retval EFI_INVALID_PARAMETER Event or Type is not valid
1638 IN EFI_EVENT UserEvent
,
1639 IN EFI_TIMER_DELAY Type
,
1640 IN UINT64 TriggerTime
1646 Signals the event. Queues the event to be notified if needed.
1648 @param UserEvent The event to signal .
1650 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1651 @retval EFI_SUCCESS The event was signaled.
1657 IN EFI_EVENT UserEvent
1663 Stops execution until an event is signaled.
1665 @param NumberOfEvents The number of events in the UserEvents array
1666 @param UserEvents An array of EFI_EVENT
1667 @param UserIndex Pointer to the index of the event which
1668 satisfied the wait condition
1670 @retval EFI_SUCCESS The event indicated by Index was signaled.
1671 @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification
1672 function or Event was not a valid type
1673 @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION
1679 IN UINTN NumberOfEvents
,
1680 IN EFI_EVENT
*UserEvents
,
1681 OUT UINTN
*UserIndex
1687 Closes an event and frees the event structure.
1689 @param UserEvent Event to close
1691 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1692 @retval EFI_SUCCESS The event has been closed
1698 IN EFI_EVENT UserEvent
1704 Check the status of an event.
1706 @param UserEvent The event to check
1708 @retval EFI_SUCCESS The event is in the signaled state
1709 @retval EFI_NOT_READY The event is not in the signaled state
1710 @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL
1716 IN EFI_EVENT UserEvent
1721 Adds reserved memory, system memory, or memory-mapped I/O resources to the
1722 global coherency domain of the processor.
1724 @param GcdMemoryType Memory type of the memory space.
1725 @param BaseAddress Base address of the memory space.
1726 @param Length Length of the memory space.
1727 @param Capabilities alterable attributes of the memory space.
1729 @retval EFI_SUCCESS Merged this memory space into GCD map.
1734 CoreAddMemorySpace (
1735 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1736 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1738 IN UINT64 Capabilities
1743 Allocates nonexistent memory, reserved memory, system memory, or memorymapped
1744 I/O resources from the global coherency domain of the processor.
1746 @param GcdAllocateType The type of allocate operation
1747 @param GcdMemoryType The desired memory type
1748 @param Alignment Align with 2^Alignment
1749 @param Length Length to allocate
1750 @param BaseAddress Base address to allocate
1751 @param ImageHandle The image handle consume the allocated space.
1752 @param DeviceHandle The device handle consume the allocated space.
1754 @retval EFI_INVALID_PARAMETER Invalid parameter.
1755 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1756 @retval EFI_SUCCESS Memory space successfully allocated.
1761 CoreAllocateMemorySpace (
1762 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1763 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1766 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1767 IN EFI_HANDLE ImageHandle
,
1768 IN EFI_HANDLE DeviceHandle OPTIONAL
1773 Frees nonexistent memory, reserved memory, system memory, or memory-mapped
1774 I/O resources from the global coherency domain of the processor.
1776 @param BaseAddress Base address of the memory space.
1777 @param Length Length of the memory space.
1779 @retval EFI_SUCCESS Space successfully freed.
1784 CoreFreeMemorySpace (
1785 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1791 Removes reserved memory, system memory, or memory-mapped I/O resources from
1792 the global coherency domain of the processor.
1794 @param BaseAddress Base address of the memory space.
1795 @param Length Length of the memory space.
1797 @retval EFI_SUCCESS Successfully remove a segment of memory space.
1802 CoreRemoveMemorySpace (
1803 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1809 Retrieves the descriptor for a memory region containing a specified address.
1811 @param BaseAddress Specified start address
1812 @param Descriptor Specified length
1814 @retval EFI_INVALID_PARAMETER Invalid parameter
1815 @retval EFI_SUCCESS Successfully get memory space descriptor.
1820 CoreGetMemorySpaceDescriptor (
1821 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1822 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*Descriptor
1827 Modifies the attributes for a memory region in the global coherency domain of the
1830 @param BaseAddress Specified start address
1831 @param Length Specified length
1832 @param Attributes Specified attributes
1834 @retval EFI_SUCCESS The attributes were set for the memory region.
1835 @retval EFI_INVALID_PARAMETER Length is zero.
1836 @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory
1837 resource range specified by BaseAddress and Length.
1838 @retval EFI_UNSUPPORTED The bit mask of attributes is not support for the memory resource
1839 range specified by BaseAddress and Length.
1840 @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by
1841 BaseAddress and Length cannot be modified.
1842 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of
1843 the memory resource range.
1844 @retval EFI_NOT_AVAILABLE_YET The attributes cannot be set because CPU architectural protocol is
1850 CoreSetMemorySpaceAttributes (
1851 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1853 IN UINT64 Attributes
1858 Modifies the capabilities for a memory region in the global coherency domain of the
1861 @param BaseAddress The physical address that is the start address of a memory region.
1862 @param Length The size in bytes of the memory region.
1863 @param Capabilities The bit mask of capabilities that the memory region supports.
1865 @retval EFI_SUCCESS The capabilities were set for the memory region.
1866 @retval EFI_INVALID_PARAMETER Length is zero.
1867 @retval EFI_UNSUPPORTED The capabilities specified by Capabilities do not include the
1868 memory region attributes currently in use.
1869 @retval EFI_ACCESS_DENIED The capabilities for the memory resource range specified by
1870 BaseAddress and Length cannot be modified.
1871 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the capabilities
1872 of the memory resource range.
1876 CoreSetMemorySpaceCapabilities (
1877 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1879 IN UINT64 Capabilities
1884 Returns a map of the memory resources in the global coherency domain of the
1887 @param NumberOfDescriptors Number of descriptors.
1888 @param MemorySpaceMap Descriptor array
1890 @retval EFI_INVALID_PARAMETER Invalid parameter
1891 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1892 @retval EFI_SUCCESS Successfully get memory space map.
1897 CoreGetMemorySpaceMap (
1898 OUT UINTN
*NumberOfDescriptors
,
1899 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
**MemorySpaceMap
1904 Adds reserved I/O or I/O resources to the global coherency domain of the processor.
1906 @param GcdIoType IO type of the segment.
1907 @param BaseAddress Base address of the segment.
1908 @param Length Length of the segment.
1910 @retval EFI_SUCCESS Merged this segment into GCD map.
1911 @retval EFI_INVALID_PARAMETER Parameter not valid
1917 IN EFI_GCD_IO_TYPE GcdIoType
,
1918 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1924 Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1925 domain of the processor.
1927 @param GcdAllocateType The type of allocate operation
1928 @param GcdIoType The desired IO type
1929 @param Alignment Align with 2^Alignment
1930 @param Length Length to allocate
1931 @param BaseAddress Base address to allocate
1932 @param ImageHandle The image handle consume the allocated space.
1933 @param DeviceHandle The device handle consume the allocated space.
1935 @retval EFI_INVALID_PARAMETER Invalid parameter.
1936 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1937 @retval EFI_SUCCESS IO space successfully allocated.
1942 CoreAllocateIoSpace (
1943 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1944 IN EFI_GCD_IO_TYPE GcdIoType
,
1947 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1948 IN EFI_HANDLE ImageHandle
,
1949 IN EFI_HANDLE DeviceHandle OPTIONAL
1954 Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1955 domain of the processor.
1957 @param BaseAddress Base address of the segment.
1958 @param Length Length of the segment.
1960 @retval EFI_SUCCESS Space successfully freed.
1966 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1972 Removes reserved I/O or I/O resources from the global coherency domain of the
1975 @param BaseAddress Base address of the segment.
1976 @param Length Length of the segment.
1978 @retval EFI_SUCCESS Successfully removed a segment of IO space.
1984 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1990 Retrieves the descriptor for an I/O region containing a specified address.
1992 @param BaseAddress Specified start address
1993 @param Descriptor Specified length
1995 @retval EFI_INVALID_PARAMETER Descriptor is NULL.
1996 @retval EFI_SUCCESS Successfully get the IO space descriptor.
2001 CoreGetIoSpaceDescriptor (
2002 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2003 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
*Descriptor
2008 Returns a map of the I/O resources in the global coherency domain of the processor.
2010 @param NumberOfDescriptors Number of descriptors.
2011 @param IoSpaceMap Descriptor array
2013 @retval EFI_INVALID_PARAMETER Invalid parameter
2014 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
2015 @retval EFI_SUCCESS Successfully get IO space map.
2021 OUT UINTN
*NumberOfDescriptors
,
2022 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
**IoSpaceMap
2027 This is the main Dispatcher for DXE and it exits when there are no more
2028 drivers to run. Drain the mScheduledQueue and load and start a PE
2029 image for each driver. Search the mDiscoveredList to see if any driver can
2030 be placed on the mScheduledQueue. If no drivers are placed on the
2031 mScheduledQueue exit the function. On exit it is assumed the Bds()
2032 will be called, and when the Bds() exits the Dispatcher will be called
2035 @retval EFI_ALREADY_STARTED The DXE Dispatcher is already running
2036 @retval EFI_NOT_FOUND No DXE Drivers were dispatched
2037 @retval EFI_SUCCESS One or more DXE Drivers were dispatched
2047 Check every driver and locate a matching one. If the driver is found, the Unrequested
2048 state flag is cleared.
2050 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
2051 the firmware file specified by DriverName.
2052 @param DriverName The Driver name to put in the Dependent state.
2054 @retval EFI_SUCCESS The DriverName was found and it's SOR bit was
2056 @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was
2063 IN EFI_HANDLE FirmwareVolumeHandle
,
2064 IN EFI_GUID
*DriverName
2069 Convert a driver from the Untrused back to the Scheduled state.
2071 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
2072 the firmware file specified by DriverName.
2073 @param DriverName The Driver name to put in the Scheduled state
2075 @retval EFI_SUCCESS The file was found in the untrusted state, and it
2076 was promoted to the trusted state.
2077 @retval EFI_NOT_FOUND The file was not found in the untrusted state.
2083 IN EFI_HANDLE FirmwareVolumeHandle
,
2084 IN EFI_GUID
*DriverName
2089 This routine is the driver initialization entry point. It initializes the
2090 libraries, and registers two notification functions. These notification
2091 functions are responsible for building the FV stack dynamically.
2093 @param ImageHandle The image handle.
2094 @param SystemTable The system table.
2096 @retval EFI_SUCCESS Function successfully returned.
2102 IN EFI_HANDLE ImageHandle
,
2103 IN EFI_SYSTEM_TABLE
*SystemTable
2108 Entry point of the section extraction code. Initializes an instance of the
2109 section extraction interface and installs it on a new handle.
2111 @param ImageHandle A handle for the image that is initializing this driver
2112 @param SystemTable A pointer to the EFI system table
2114 @retval EFI_SUCCESS Driver initialized successfully
2115 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
2120 InitializeSectionExtraction (
2121 IN EFI_HANDLE ImageHandle
,
2122 IN EFI_SYSTEM_TABLE
*SystemTable
2127 This DXE service routine is used to process a firmware volume. In
2128 particular, it can be called by BDS to process a single firmware
2129 volume found in a capsule.
2131 @param FvHeader pointer to a firmware volume header
2132 @param Size the size of the buffer pointed to by FvHeader
2133 @param FVProtocolHandle the handle on which a firmware volume protocol
2134 was produced for the firmware volume passed in.
2136 @retval EFI_OUT_OF_RESOURCES if an FVB could not be produced due to lack of
2138 @retval EFI_VOLUME_CORRUPTED if the volume was corrupted
2139 @retval EFI_SUCCESS a firmware volume protocol was produced for the
2145 CoreProcessFirmwareVolume (
2148 OUT EFI_HANDLE
*FVProtocolHandle
2152 //Functions used during debug buils
2156 Displays Architectural protocols that were not loaded and are required for DXE
2157 core to function. Only used in Debug Builds.
2161 CoreDisplayMissingArchProtocols (
2167 Traverse the discovered list for any drivers that were discovered but not loaded
2168 because the dependency experessions evaluated to false.
2172 CoreDisplayDiscoveredNotDispatched (
2179 Place holder function until all the Boot Services and Runtime Services are
2182 @param Arg1 Undefined
2184 @return EFI_NOT_AVAILABLE_YET
2189 CoreEfiNotAvailableYetArg1 (
2195 Place holder function until all the Boot Services and Runtime Services are available.
2197 @param Arg1 Undefined
2198 @param Arg2 Undefined
2200 @return EFI_NOT_AVAILABLE_YET
2205 CoreEfiNotAvailableYetArg2 (
2212 Place holder function until all the Boot Services and Runtime Services are available.
2214 @param Arg1 Undefined
2215 @param Arg2 Undefined
2216 @param Arg3 Undefined
2218 @return EFI_NOT_AVAILABLE_YET
2223 CoreEfiNotAvailableYetArg3 (
2231 Place holder function until all the Boot Services and Runtime Services are available.
2233 @param Arg1 Undefined
2234 @param Arg2 Undefined
2235 @param Arg3 Undefined
2236 @param Arg4 Undefined
2238 @return EFI_NOT_AVAILABLE_YET
2243 CoreEfiNotAvailableYetArg4 (
2252 Place holder function until all the Boot Services and Runtime Services are available.
2254 @param Arg1 Undefined
2255 @param Arg2 Undefined
2256 @param Arg3 Undefined
2257 @param Arg4 Undefined
2258 @param Arg5 Undefined
2260 @return EFI_NOT_AVAILABLE_YET
2265 CoreEfiNotAvailableYetArg5 (
2275 Given a compressed source buffer, this function retrieves the size of the
2276 uncompressed buffer and the size of the scratch buffer required to decompress
2277 the compressed source buffer.
2279 The GetInfo() function retrieves the size of the uncompressed buffer and the
2280 temporary scratch buffer required to decompress the buffer specified by Source
2281 and SourceSize. If the size of the uncompressed buffer or the size of the
2282 scratch buffer cannot be determined from the compressed data specified by
2283 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
2284 size of the uncompressed buffer is returned in DestinationSize, the size of
2285 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
2286 The GetInfo() function does not have scratch buffer available to perform a
2287 thorough checking of the validity of the source data. It just retrieves the
2288 "Original Size" field from the beginning bytes of the source data and output
2289 it as DestinationSize. And ScratchSize is specific to the decompression
2292 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2293 @param Source The source buffer containing the compressed data.
2294 @param SourceSize The size, in bytes, of the source buffer.
2295 @param DestinationSize A pointer to the size, in bytes, of the
2296 uncompressed buffer that will be generated when the
2297 compressed buffer specified by Source and
2298 SourceSize is decompressed.
2299 @param ScratchSize A pointer to the size, in bytes, of the scratch
2300 buffer that is required to decompress the
2301 compressed buffer specified by Source and
2304 @retval EFI_SUCCESS The size of the uncompressed data was returned in
2305 DestinationSize and the size of the scratch buffer
2306 was returned in ScratchSize.
2307 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
2308 the scratch buffer cannot be determined from the
2309 compressed data specified by Source and
2315 DxeMainUefiDecompressGetInfo (
2316 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2318 IN UINT32 SourceSize
,
2319 OUT UINT32
*DestinationSize
,
2320 OUT UINT32
*ScratchSize
2325 Decompresses a compressed source buffer.
2327 The Decompress() function extracts decompressed data to its original form.
2328 This protocol is designed so that the decompression algorithm can be
2329 implemented without using any memory services. As a result, the Decompress()
2330 Function is not allowed to call AllocatePool() or AllocatePages() in its
2331 implementation. It is the caller's responsibility to allocate and free the
2332 Destination and Scratch buffers.
2333 If the compressed source data specified by Source and SourceSize is
2334 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
2335 the compressed source data specified by Source and SourceSize is not in a
2336 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
2338 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2339 @param Source The source buffer containing the compressed data.
2340 @param SourceSize SourceSizeThe size of source data.
2341 @param Destination On output, the destination buffer that contains
2342 the uncompressed data.
2343 @param DestinationSize The size of the destination buffer. The size of
2344 the destination buffer needed is obtained from
2345 EFI_DECOMPRESS_PROTOCOL.GetInfo().
2346 @param Scratch A temporary scratch buffer that is used to perform
2348 @param ScratchSize The size of scratch buffer. The size of the
2349 scratch buffer needed is obtained from GetInfo().
2351 @retval EFI_SUCCESS Decompression completed successfully, and the
2352 uncompressed buffer is returned in Destination.
2353 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
2354 SourceSize is corrupted (not in a valid
2360 DxeMainUefiDecompress (
2361 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2363 IN UINT32 SourceSize
,
2364 IN OUT VOID
*Destination
,
2365 IN UINT32 DestinationSize
,
2366 IN OUT VOID
*Scratch
,
2367 IN UINT32 ScratchSize
2371 SEP member function. This function creates and returns a new section stream
2372 handle to represent the new section stream.
2374 @param SectionStreamLength Size in bytes of the section stream.
2375 @param SectionStream Buffer containing the new section stream.
2376 @param SectionStreamHandle A pointer to a caller allocated UINTN that on
2377 output contains the new section stream handle.
2379 @retval EFI_SUCCESS The section stream is created successfully.
2380 @retval EFI_OUT_OF_RESOURCES memory allocation failed.
2381 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2388 IN UINTN SectionStreamLength
,
2389 IN VOID
*SectionStream
,
2390 OUT UINTN
*SectionStreamHandle
2396 SEP member function. Retrieves requested section from section stream.
2398 @param SectionStreamHandle The section stream from which to extract the
2400 @param SectionType A pointer to the type of section to search for.
2401 @param SectionDefinitionGuid If the section type is EFI_SECTION_GUID_DEFINED,
2402 then SectionDefinitionGuid indicates which of
2403 these types of sections to search for.
2404 @param SectionInstance Indicates which instance of the requested
2406 @param Buffer Double indirection to buffer. If *Buffer is
2407 non-null on input, then the buffer is caller
2408 allocated. If Buffer is NULL, then the buffer
2409 is callee allocated. In either case, the
2410 required buffer size is returned in *BufferSize.
2411 @param BufferSize On input, indicates the size of *Buffer if
2412 *Buffer is non-null on input. On output,
2413 indicates the required size (allocated size if
2414 callee allocated) of *Buffer.
2415 @param AuthenticationStatus A pointer to a caller-allocated UINT32 that
2416 indicates the authentication status of the
2417 output buffer. If the input section's
2418 GuidedSectionHeader.Attributes field
2419 has the EFI_GUIDED_SECTION_AUTH_STATUS_VALID
2420 bit as clear, AuthenticationStatus must return
2421 zero. Both local bits (19:16) and aggregate
2422 bits (3:0) in AuthenticationStatus are returned
2423 by ExtractSection(). These bits reflect the
2424 status of the extraction operation. The bit
2425 pattern in both regions must be the same, as
2426 the local and aggregate authentication statuses
2427 have equivalent meaning at this level. If the
2428 function returns anything other than
2429 EFI_SUCCESS, the value of *AuthenticationStatus
2431 @param IsFfs3Fv Indicates the FV format.
2433 @retval EFI_SUCCESS Section was retrieved successfully
2434 @retval EFI_PROTOCOL_ERROR A GUID defined section was encountered in the
2435 section stream with its
2436 EFI_GUIDED_SECTION_PROCESSING_REQUIRED bit set,
2437 but there was no corresponding GUIDed Section
2438 Extraction Protocol in the handle database.
2439 *Buffer is unmodified.
2440 @retval EFI_NOT_FOUND An error was encountered when parsing the
2441 SectionStream. This indicates the SectionStream
2442 is not correctly formatted.
2443 @retval EFI_NOT_FOUND The requested section does not exist.
2444 @retval EFI_OUT_OF_RESOURCES The system has insufficient resources to process
2446 @retval EFI_INVALID_PARAMETER The SectionStreamHandle does not exist.
2447 @retval EFI_WARN_TOO_SMALL The size of the caller allocated input buffer is
2448 insufficient to contain the requested section.
2449 The input buffer is filled and section contents
2456 IN UINTN SectionStreamHandle
,
2457 IN EFI_SECTION_TYPE
*SectionType
,
2458 IN EFI_GUID
*SectionDefinitionGuid
,
2459 IN UINTN SectionInstance
,
2461 IN OUT UINTN
*BufferSize
,
2462 OUT UINT32
*AuthenticationStatus
,
2468 SEP member function. Deletes an existing section stream
2470 @param StreamHandleToClose Indicates the stream to close
2471 @param FreeStreamBuffer TRUE - Need to free stream buffer;
2472 FALSE - No need to free stream buffer.
2474 @retval EFI_SUCCESS The section stream is closed sucessfully.
2475 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
2476 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2482 CloseSectionStream (
2483 IN UINTN StreamHandleToClose
,
2484 IN BOOLEAN FreeStreamBuffer
2488 Creates and initializes the DebugImageInfo Table. Also creates the configuration
2489 table and registers it into the system table.
2492 This function allocates memory, frees it, and then allocates memory at an
2493 address within the initial allocation. Since this function is called early
2494 in DXE core initialization (before drivers are dispatched), this should not
2499 CoreInitializeDebugImageInfoTable (
2505 Update the CRC32 in the Debug Table.
2506 Since the CRC32 service is made available by the Runtime driver, we have to
2507 wait for the Runtime Driver to be installed before the CRC32 can be computed.
2508 This function is called elsewhere by the core when the runtime architectural
2509 protocol is produced.
2513 CoreUpdateDebugTableCrc32 (
2519 Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
2520 the table if it's not large enough to accomidate another entry.
2522 @param ImageInfoType type of debug image information
2523 @param LoadedImage pointer to the loaded image protocol for the image being
2525 @param ImageHandle image handle for the image being loaded
2529 CoreNewDebugImageInfoEntry (
2530 IN UINT32 ImageInfoType
,
2531 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
,
2532 IN EFI_HANDLE ImageHandle
2537 Removes and frees an entry from the DebugImageInfo Table.
2539 @param ImageHandle image handle for the image being unloaded
2543 CoreRemoveDebugImageInfoEntry (
2544 EFI_HANDLE ImageHandle
2549 This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
2551 @param ImageHandle The image handle.
2552 @param SystemTable The system table.
2554 @retval EFI_SUCCESS Successfully initialized firmware volume block
2560 FwVolBlockDriverInit (
2561 IN EFI_HANDLE ImageHandle
,
2562 IN EFI_SYSTEM_TABLE
*SystemTable
2567 Get FVB authentication status
2569 @param FvbProtocol FVB protocol.
2571 @return Authentication status.
2575 GetFvbAuthenticationStatus (
2576 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
2580 This routine produces a firmware volume block protocol on a given
2583 @param BaseAddress base address of the firmware volume image
2584 @param Length length of the firmware volume image
2585 @param ParentHandle handle of parent firmware volume, if this image
2586 came from an FV image file and section in another firmware
2587 volume (ala capsules)
2588 @param AuthenticationStatus Authentication status inherited, if this image
2589 came from an FV image file and section in another firmware volume.
2590 @param FvProtocol Firmware volume block protocol produced.
2592 @retval EFI_VOLUME_CORRUPTED Volume corrupted.
2593 @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
2594 @retval EFI_SUCCESS Successfully produced a FVB protocol on given
2599 ProduceFVBProtocolOnBuffer (
2600 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2602 IN EFI_HANDLE ParentHandle
,
2603 IN UINT32 AuthenticationStatus
,
2604 OUT EFI_HANDLE
*FvProtocol OPTIONAL
2609 Raising to the task priority level of the mutual exclusion
2610 lock, and then acquires ownership of the lock.
2612 @param Lock The lock to acquire
2624 Initialize a basic mutual exclusion lock. Each lock
2625 provides mutual exclusion access at it's task priority
2626 level. Since there is no-premption (at any TPL) or
2627 multiprocessor support, acquiring the lock only consists
2628 of raising to the locks TPL.
2630 @param Lock The EFI_LOCK structure to initialize
2632 @retval EFI_SUCCESS Lock Owned.
2633 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
2637 CoreAcquireLockOrFail (
2643 Releases ownership of the mutual exclusion lock, and
2644 restores the previous task priority level.
2646 @param Lock The lock to release
2648 @return Lock unowned
2657 Read data from Firmware Block by FVB protocol Read.
2658 The data may cross the multi block ranges.
2660 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to read data.
2661 @param StartLba Pointer to StartLba.
2662 On input, the start logical block index from which to read.
2663 On output,the end logical block index after reading.
2664 @param Offset Pointer to Offset
2665 On input, offset into the block at which to begin reading.
2666 On output, offset into the end block after reading.
2667 @param DataSize Size of data to be read.
2668 @param Data Pointer to Buffer that the data will be read into.
2670 @retval EFI_SUCCESS Successfully read data from firmware block.
2675 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2676 IN OUT EFI_LBA
*StartLba
,
2677 IN OUT UINTN
*Offset
,
2683 Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
2684 copy the real length volume header into it.
2686 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
2687 read the volume header
2688 @param FwVolHeader Pointer to pointer to allocated buffer in which
2689 the volume header is returned.
2691 @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
2692 @retval EFI_SUCCESS Successfully read volume header to the allocated
2694 @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or
2695 the file system could not be understood.
2700 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2701 OUT EFI_FIRMWARE_VOLUME_HEADER
**FwVolHeader
2705 Verify checksum of the firmware volume header.
2707 @param FvHeader Points to the firmware volume header to be checked
2709 @retval TRUE Checksum verification passed
2710 @retval FALSE Checksum verification failed
2714 VerifyFvHeaderChecksum (
2715 IN EFI_FIRMWARE_VOLUME_HEADER
*FvHeader
2719 Initialize memory profile.
2721 @param HobStart The start address of the HOB.
2730 Install memory profile protocol.
2734 MemoryProfileInstallProtocol (
2739 Register image to memory profile.
2741 @param DriverEntry Image info.
2742 @param FileType Image file type.
2744 @return EFI_SUCCESS Register successfully.
2745 @return EFI_UNSUPPORTED Memory profile unsupported,
2746 or memory profile for the image is not required.
2747 @return EFI_OUT_OF_RESOURCES No enough resource for this register.
2751 RegisterMemoryProfileImage (
2752 IN LOADED_IMAGE_PRIVATE_DATA
*DriverEntry
,
2753 IN EFI_FV_FILETYPE FileType
2757 Unregister image from memory profile.
2759 @param DriverEntry Image info.
2761 @return EFI_SUCCESS Unregister successfully.
2762 @return EFI_UNSUPPORTED Memory profile unsupported,
2763 or memory profile for the image is not required.
2764 @return EFI_NOT_FOUND The image is not found.
2768 UnregisterMemoryProfileImage (
2769 IN LOADED_IMAGE_PRIVATE_DATA
*DriverEntry
2773 Update memory profile information.
2775 @param CallerAddress Address of caller who call Allocate or Free.
2776 @param Action This Allocate or Free action.
2777 @param MemoryType Memory type.
2778 EfiMaxMemoryType means the MemoryType is unknown.
2779 @param Size Buffer size.
2780 @param Buffer Buffer address.
2781 @param ActionString String for memory profile action.
2782 Only needed for user defined allocate action.
2784 @return EFI_SUCCESS Memory profile is updated.
2785 @return EFI_UNSUPPORTED Memory profile is unsupported,
2786 or memory profile for the image is not required,
2787 or memory profile for the memory type is not required.
2788 @return EFI_ACCESS_DENIED It is during memory profile data getting.
2789 @return EFI_ABORTED Memory profile recording is not enabled.
2790 @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.
2791 @return EFI_NOT_FOUND No matched allocate info found for free action.
2797 IN EFI_PHYSICAL_ADDRESS CallerAddress
,
2798 IN MEMORY_PROFILE_ACTION Action
,
2799 IN EFI_MEMORY_TYPE MemoryType
,
2800 IN UINTN Size
, // Valid for AllocatePages/FreePages/AllocatePool
2802 IN CHAR8
*ActionString OPTIONAL
2806 Internal function. Converts a memory range to use new attributes.
2808 @param Start The first address of the range Must be page
2810 @param NumberOfPages The number of pages to convert
2811 @param NewAttributes The new attributes value for the range.
2815 CoreUpdateMemoryAttributes (
2816 IN EFI_PHYSICAL_ADDRESS Start
,
2817 IN UINT64 NumberOfPages
,
2818 IN UINT64 NewAttributes
2822 Initialize PropertiesTable support.
2826 CoreInitializePropertiesTable (
2831 Initialize MemoryAttrubutesTable support.
2835 CoreInitializeMemoryAttributesTable (
2840 Initialize Memory Protection support.
2844 CoreInitializeMemoryProtection (
2849 Install MemoryAttributesTable on memory allocation.
2851 @param[in] MemoryType EFI memory type.
2854 InstallMemoryAttributesTableOnMemoryAllocation (
2855 IN EFI_MEMORY_TYPE MemoryType
2859 Insert image record.
2861 @param RuntimeImage Runtime image information
2865 IN EFI_RUNTIME_IMAGE_ENTRY
*RuntimeImage
2869 Remove Image record.
2871 @param RuntimeImage Runtime image information
2875 IN EFI_RUNTIME_IMAGE_ENTRY
*RuntimeImage
2881 @param[in] LoadedImage The loaded image protocol
2882 @param[in] LoadedImageDevicePath The loaded image device path protocol
2886 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
,
2887 IN EFI_DEVICE_PATH_PROTOCOL
*LoadedImageDevicePath
2891 Unprotect UEFI image.
2893 @param[in] LoadedImage The loaded image protocol
2894 @param[in] LoadedImageDevicePath The loaded image device path protocol
2897 UnprotectUefiImage (
2898 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
,
2899 IN EFI_DEVICE_PATH_PROTOCOL
*LoadedImageDevicePath
2903 ExitBootServices Callback function for memory protection.
2906 MemoryProtectionExitBootServicesCallback (
2911 Manage memory permission attributes on a memory range, according to the
2912 configured DXE memory protection policy.
2914 @param OldType The old memory type of the range
2915 @param NewType The new memory type of the range
2916 @param Memory The base address of the range
2917 @param Length The size of the range (in bytes)
2919 @return EFI_SUCCESS If the the CPU arch protocol is not installed yet
2920 @return EFI_SUCCESS If no DXE memory protection policy has been configured
2921 @return EFI_SUCCESS If OldType and NewType use the same permission attributes
2922 @return other Return value of gCpu->SetMemoryAttributes()
2927 ApplyMemoryProtectionPolicy (
2928 IN EFI_MEMORY_TYPE OldType
,
2929 IN EFI_MEMORY_TYPE NewType
,
2930 IN EFI_PHYSICAL_ADDRESS Memory
,
2935 Merge continous memory map entries whose have same attributes.
2937 @param MemoryMap A pointer to the buffer in which firmware places
2938 the current memory map.
2939 @param MemoryMapSize A pointer to the size, in bytes, of the
2940 MemoryMap buffer. On input, this is the size of
2941 the current memory map. On output,
2942 it is the size of new memory map after merge.
2943 @param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
2947 IN OUT EFI_MEMORY_DESCRIPTOR
*MemoryMap
,
2948 IN OUT UINTN
*MemoryMapSize
,
2949 IN UINTN DescriptorSize