2 The internal header file includes the common header files, defines
3 internal structure and functions used by DxeCore module.
5 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
23 #include <Protocol/LoadedImage.h>
24 #include <Protocol/GuidedSectionExtraction.h>
25 #include <Protocol/DevicePath.h>
26 #include <Protocol/Runtime.h>
27 #include <Protocol/LoadFile.h>
28 #include <Protocol/LoadFile2.h>
29 #include <Protocol/DriverBinding.h>
30 #include <Protocol/VariableWrite.h>
31 #include <Protocol/PlatformDriverOverride.h>
32 #include <Protocol/Variable.h>
33 #include <Protocol/Timer.h>
34 #include <Protocol/SimpleFileSystem.h>
35 #include <Protocol/Bds.h>
36 #include <Protocol/RealTimeClock.h>
37 #include <Protocol/WatchdogTimer.h>
38 #include <Protocol/FirmwareVolume2.h>
39 #include <Protocol/MonotonicCounter.h>
40 #include <Protocol/StatusCode.h>
41 #include <Protocol/Decompress.h>
42 #include <Protocol/LoadPe32Image.h>
43 #include <Protocol/Security.h>
44 #include <Protocol/Security2.h>
45 #include <Protocol/Ebc.h>
46 #include <Protocol/Reset.h>
47 #include <Protocol/Cpu.h>
48 #include <Protocol/Metronome.h>
49 #include <Protocol/FirmwareVolumeBlock.h>
50 #include <Protocol/Capsule.h>
51 #include <Protocol/BusSpecificDriverOverride.h>
52 #include <Protocol/DriverFamilyOverride.h>
53 #include <Protocol/TcgService.h>
54 #include <Protocol/HiiPackageList.h>
55 #include <Protocol/SmmBase2.h>
56 #include <Guid/MemoryTypeInformation.h>
57 #include <Guid/FirmwareFileSystem2.h>
58 #include <Guid/FirmwareFileSystem3.h>
59 #include <Guid/HobList.h>
60 #include <Guid/DebugImageInfoTable.h>
61 #include <Guid/FileInfo.h>
62 #include <Guid/Apriori.h>
63 #include <Guid/DxeServices.h>
64 #include <Guid/MemoryAllocationHob.h>
65 #include <Guid/EventLegacyBios.h>
66 #include <Guid/EventGroup.h>
67 #include <Guid/EventExitBootServiceFailed.h>
68 #include <Guid/LoadModuleAtFixedAddress.h>
69 #include <Guid/IdleLoopEvent.h>
70 #include <Guid/VectorHandoffTable.h>
71 #include <Ppi/VectorHandoffInfo.h>
72 #include <Guid/MemoryProfile.h>
74 #include <Library/DxeCoreEntryPoint.h>
75 #include <Library/DebugLib.h>
76 #include <Library/UefiLib.h>
77 #include <Library/BaseLib.h>
78 #include <Library/HobLib.h>
79 #include <Library/PerformanceLib.h>
80 #include <Library/UefiDecompressLib.h>
81 #include <Library/ExtractGuidedSectionLib.h>
82 #include <Library/CacheMaintenanceLib.h>
83 #include <Library/BaseMemoryLib.h>
84 #include <Library/PeCoffLib.h>
85 #include <Library/PeCoffGetEntryPointLib.h>
86 #include <Library/PeCoffExtraActionLib.h>
87 #include <Library/PcdLib.h>
88 #include <Library/MemoryAllocationLib.h>
89 #include <Library/DevicePathLib.h>
90 #include <Library/UefiBootServicesTableLib.h>
91 #include <Library/ReportStatusCodeLib.h>
92 #include <Library/TimerLib.h>
93 #include <Library/DxeServicesLib.h>
94 #include <Library/DebugAgentLib.h>
95 #include <Library/CpuExceptionHandlerLib.h>
99 // attributes for reserved memory before it is promoted to system memory
101 #define EFI_MEMORY_PRESENT 0x0100000000000000ULL
102 #define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL
103 #define EFI_MEMORY_TESTED 0x0400000000000000ULL
106 // range for memory mapped port I/O on IPF
108 #define EFI_MEMORY_PORT_IO 0x4000000000000000ULL
112 /// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependency expression
113 /// to save time. A EFI_DEP_PUSH is evaluated one an
114 /// replaced with EFI_DEP_REPLACE_TRUE. If PI spec's Vol 2
115 /// Driver Execution Environment Core Interface use 0xff
116 /// as new DEPEX opcode. EFI_DEP_REPLACE_TRUE should be
117 /// defined to a new value that is not conflicting with PI spec.
119 #define EFI_DEP_REPLACE_TRUE 0xff
122 /// Define the initial size of the dependency expression evaluation stack
124 #define DEPEX_STACK_SIZE_INCREMENT 0x1000
127 EFI_GUID
*ProtocolGuid
;
132 } EFI_CORE_PROTOCOL_NOTIFY_ENTRY
;
135 // DXE Dispatcher Data structures
138 #define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w')
141 LIST_ENTRY Link
; // mFvHandleList
147 #define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r')
150 LIST_ENTRY Link
; // mDriverList
152 LIST_ENTRY ScheduledLink
; // mScheduledQueue
156 EFI_DEVICE_PATH_PROTOCOL
*FvFileDevicePath
;
157 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
164 EFI_GUID BeforeAfterGuid
;
171 BOOLEAN DepexProtocolError
;
173 EFI_HANDLE ImageHandle
;
176 } EFI_CORE_DRIVER_ENTRY
;
179 //The data structure of GCD memory map entry
181 #define EFI_GCD_MAP_SIGNATURE SIGNATURE_32('g','c','d','m')
185 EFI_PHYSICAL_ADDRESS BaseAddress
;
189 EFI_GCD_MEMORY_TYPE GcdMemoryType
;
190 EFI_GCD_IO_TYPE GcdIoType
;
191 EFI_HANDLE ImageHandle
;
192 EFI_HANDLE DeviceHandle
;
196 #define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','d','r','i')
204 /// If entrypoint has been called
206 /// The image's entry point
207 EFI_IMAGE_ENTRY_POINT EntryPoint
;
208 /// loaded image protocol
209 EFI_LOADED_IMAGE_PROTOCOL Info
;
210 /// Location in memory
211 EFI_PHYSICAL_ADDRESS ImageBasePage
;
214 /// Original fixup data
216 /// Tpl of started image
218 /// Status returned by started image
220 /// Size of ExitData from started image
222 /// Pointer to exit data from started image
224 /// Pointer to pool allocation for context save/restore
226 /// Pointer to buffer for context save/restore
227 BASE_LIBRARY_JUMP_BUFFER
*JumpContext
;
228 /// Machine type from PE image
230 /// EBC Protocol pointer
231 EFI_EBC_PROTOCOL
*Ebc
;
232 /// Runtime image list
233 EFI_RUNTIME_IMAGE_ENTRY
*RuntimeData
;
234 /// Pointer to Loaded Image Device Path Protocol
235 EFI_DEVICE_PATH_PROTOCOL
*LoadedImageDevicePath
;
236 /// PeCoffLoader ImageContext
237 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext
;
238 /// Status returned by LoadImage() service.
239 EFI_STATUS LoadImageStatus
;
240 } LOADED_IMAGE_PRIVATE_DATA
;
242 #define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \
243 CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE)
245 #define IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE SIGNATURE_32 ('I','P','R','C')
250 EFI_PHYSICAL_ADDRESS CodeSegmentBase
;
251 UINT64 CodeSegmentSize
;
252 } IMAGE_PROPERTIES_RECORD_CODE_SECTION
;
254 #define IMAGE_PROPERTIES_RECORD_SIGNATURE SIGNATURE_32 ('I','P','R','D')
259 EFI_PHYSICAL_ADDRESS ImageBase
;
261 UINTN CodeSegmentCount
;
262 LIST_ENTRY CodeSegmentList
;
263 } IMAGE_PROPERTIES_RECORD
;
266 // DXE Core Global Variables
268 extern EFI_SYSTEM_TABLE
*gDxeCoreST
;
269 extern EFI_RUNTIME_SERVICES
*gDxeCoreRT
;
270 extern EFI_DXE_SERVICES
*gDxeCoreDS
;
271 extern EFI_HANDLE gDxeCoreImageHandle
;
273 extern BOOLEAN gMemoryMapTerminated
;
275 extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress
;
277 extern EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
;
278 extern EFI_CPU_ARCH_PROTOCOL
*gCpu
;
279 extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL
*gWatchdogTimer
;
280 extern EFI_METRONOME_ARCH_PROTOCOL
*gMetronome
;
281 extern EFI_TIMER_ARCH_PROTOCOL
*gTimer
;
282 extern EFI_SECURITY_ARCH_PROTOCOL
*gSecurity
;
283 extern EFI_SECURITY2_ARCH_PROTOCOL
*gSecurity2
;
284 extern EFI_BDS_ARCH_PROTOCOL
*gBds
;
285 extern EFI_SMM_BASE2_PROTOCOL
*gSmmBase2
;
287 extern EFI_TPL gEfiCurrentTpl
;
289 extern EFI_GUID
*gDxeCoreFileName
;
290 extern EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
292 extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation
[EfiMaxMemoryType
+ 1];
294 extern BOOLEAN gDispatcherRunning
;
295 extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
;
297 extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable
;
298 extern BOOLEAN gLoadFixedAddressCodeMemoryReady
;
300 // Service Initialization Functions
306 Called to initialize the pool.
316 Called to initialize the memory map and add descriptors to
317 the current descriptor list.
318 The first descriptor that is added must be general usable
319 memory as the addition allocates heap.
321 @param Type The type of memory to add
322 @param Start The starting address in the memory range Must be
324 @param NumberOfPages The number of pages in the range
325 @param Attribute Attributes of the memory to add
327 @return None. The range is added to the memory map
331 CoreAddMemoryDescriptor (
332 IN EFI_MEMORY_TYPE Type
,
333 IN EFI_PHYSICAL_ADDRESS Start
,
334 IN UINT64 NumberOfPages
,
340 Release memory lock on mGcdMemorySpaceLock.
344 CoreReleaseGcdMemoryLock (
350 Acquire memory lock on mGcdMemorySpaceLock.
354 CoreAcquireGcdMemoryLock (
360 External function. Initializes memory services based on the memory
361 descriptor HOBs. This function is responsible for priming the memory
362 map, so memory allocations and resource allocations can be made.
363 The first part of this function can not depend on any memory services
364 until at least one memory descriptor is provided to the memory services.
366 @param HobStart The start address of the HOB.
367 @param MemoryBaseAddress Start address of memory region found to init DXE
369 @param MemoryLength Length of memory region found to init DXE core.
371 @retval EFI_SUCCESS Memory services successfully initialized.
375 CoreInitializeMemoryServices (
377 OUT EFI_PHYSICAL_ADDRESS
*MemoryBaseAddress
,
378 OUT UINT64
*MemoryLength
384 External function. Initializes the GCD and memory services based on the memory
385 descriptor HOBs. This function is responsible for priming the GCD map and the
386 memory map, so memory allocations and resource allocations can be made. The
387 HobStart will be relocated to a pool buffer.
389 @param HobStart The start address of the HOB
390 @param MemoryBaseAddress Start address of memory region found to init DXE
392 @param MemoryLength Length of memory region found to init DXE core.
394 @retval EFI_SUCCESS GCD services successfully initialized.
398 CoreInitializeGcdServices (
399 IN OUT VOID
**HobStart
,
400 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress
,
401 IN UINT64 MemoryLength
406 Initializes "event" support.
408 @retval EFI_SUCCESS Always return success
412 CoreInitializeEventServices (
418 Add the Image Services to EFI Boot Services Table and install the protocol
419 interfaces for this image.
421 @param HobStart The HOB to initialize
427 CoreInitializeImageServices (
433 Creates an event that is fired everytime a Protocol of a specific type is installed.
437 CoreNotifyOnProtocolInstallation (
443 Return TRUE if all AP services are available.
445 @retval EFI_SUCCESS All AP services are available
446 @retval EFI_NOT_FOUND At least one AP service is not available
450 CoreAllEfiServicesAvailable (
456 Calcualte the 32-bit CRC in a EFI table using the service provided by the
459 @param Hdr Pointer to an EFI standard header
464 IN OUT EFI_TABLE_HEADER
*Hdr
469 Called by the platform code to process a tick.
471 @param Duration The number of 100ns elapsed since the last call
483 Initialize the dispatcher. Initialize the notification function that runs when
484 an FV2 protocol is added to the system.
488 CoreInitializeDispatcher (
494 This is the POSTFIX version of the dependency evaluator. This code does
495 not need to handle Before or After, as it is not valid to call this
496 routine in this case. The SOR is just ignored and is a nop in the grammer.
497 POSTFIX means all the math is done on top of the stack.
499 @param DriverEntry DriverEntry element to update.
501 @retval TRUE If driver is ready to run.
502 @retval FALSE If driver is not ready to run or some fatal error
508 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
513 Preprocess dependency expression and update DriverEntry to reflect the
514 state of Before, After, and SOR dependencies. If DriverEntry->Before
515 or DriverEntry->After is set it will never be cleared. If SOR is set
516 it will be cleared by CoreSchedule(), and then the driver can be
519 @param DriverEntry DriverEntry element to update .
521 @retval EFI_SUCCESS It always works.
525 CorePreProcessDepex (
526 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
532 Terminates all boot services.
534 @param ImageHandle Handle that identifies the exiting image.
535 @param MapKey Key to the latest memory map.
537 @retval EFI_SUCCESS Boot Services terminated
538 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
543 CoreExitBootServices (
544 IN EFI_HANDLE ImageHandle
,
550 Make sure the memory map is following all the construction rules,
551 it is the last time to check memory map error before exit boot services.
553 @param MapKey Memory map key
555 @retval EFI_INVALID_PARAMETER Memory map not consistent with construction
557 @retval EFI_SUCCESS Valid memory map.
561 CoreTerminateMemoryMap (
567 Signals all events in the EventGroup.
569 @param EventGroup The list to signal
573 CoreNotifySignalList (
574 IN EFI_GUID
*EventGroup
580 Boot Service called to add, modify, or remove a system configuration table from
581 the EFI System Table.
583 @param Guid Pointer to the GUID for the entry to add, update, or
585 @param Table Pointer to the configuration table for the entry to add,
586 update, or remove, may be NULL.
588 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.
589 @return EFI_INVALID_PARAMETER Input GUID not valid.
590 @return EFI_NOT_FOUND Attempted to delete non-existant entry
591 @return EFI_OUT_OF_RESOURCES Not enough memory available
596 CoreInstallConfigurationTable (
604 Raise the task priority level to the new level.
605 High level is implemented by disabling processor interrupts.
607 @param NewTpl New task priority level
609 @return The previous task priority level
621 Lowers the task priority to the previous value. If the new
622 priority unmasks events at a higher priority, they are dispatched.
624 @param NewTpl New, lower, task priority
636 Introduces a fine-grained stall.
638 @param Microseconds The number of microseconds to stall execution.
640 @retval EFI_SUCCESS Execution was stalled for at least the requested
641 amount of microseconds.
642 @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet
648 IN UINTN Microseconds
654 Sets the system's watchdog timer.
656 @param Timeout The number of seconds to set the watchdog timer to.
657 A value of zero disables the timer.
658 @param WatchdogCode The numeric code to log on a watchdog timer timeout
659 event. The firmware reserves codes 0x0000 to 0xFFFF.
660 Loaders and operating systems may use other timeout
662 @param DataSize The size, in bytes, of WatchdogData.
663 @param WatchdogData A data buffer that includes a Null-terminated Unicode
664 string, optionally followed by additional binary data.
665 The string is a description that the call may use to
666 further indicate the reason to be logged with a
669 @return EFI_SUCCESS Timeout has been set
670 @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
671 @return EFI_UNSUPPORTED System does not have a timer (currently not used)
672 @return EFI_DEVICE_ERROR Could not complete due to hardware error
677 CoreSetWatchdogTimer (
679 IN UINT64 WatchdogCode
,
681 IN CHAR16
*WatchdogData OPTIONAL
687 Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
688 Calls the private one which contains a BOOLEAN parameter for notifications
690 @param UserHandle The handle to install the protocol handler on,
691 or NULL if a new handle is to be allocated
692 @param Protocol The protocol to add to the handle
693 @param InterfaceType Indicates whether Interface is supplied in
695 @param Interface The interface for the protocol being added
702 CoreInstallProtocolInterface (
703 IN OUT EFI_HANDLE
*UserHandle
,
704 IN EFI_GUID
*Protocol
,
705 IN EFI_INTERFACE_TYPE InterfaceType
,
711 Installs a protocol interface into the boot services environment.
713 @param UserHandle The handle to install the protocol handler on,
714 or NULL if a new handle is to be allocated
715 @param Protocol The protocol to add to the handle
716 @param InterfaceType Indicates whether Interface is supplied in
718 @param Interface The interface for the protocol being added
719 @param Notify indicates whether notify the notification list
722 @retval EFI_INVALID_PARAMETER Invalid parameter
723 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
724 @retval EFI_SUCCESS Protocol interface successfully installed
728 CoreInstallProtocolInterfaceNotify (
729 IN OUT EFI_HANDLE
*UserHandle
,
730 IN EFI_GUID
*Protocol
,
731 IN EFI_INTERFACE_TYPE InterfaceType
,
739 Installs a list of protocol interface into the boot services environment.
740 This function calls InstallProtocolInterface() in a loop. If any error
741 occures all the protocols added by this function are removed. This is
742 basically a lib function to save space.
744 @param Handle The handle to install the protocol handlers on,
745 or NULL if a new handle is to be allocated
746 @param ... EFI_GUID followed by protocol instance. A NULL
747 terminates the list. The pairs are the
748 arguments to InstallProtocolInterface(). All the
749 protocols are added to Handle.
751 @retval EFI_SUCCESS All the protocol interface was installed.
752 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
753 @retval EFI_ALREADY_STARTED A Device Path Protocol instance was passed in that is already present in
755 @retval EFI_INVALID_PARAMETER Handle is NULL.
756 @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.
761 CoreInstallMultipleProtocolInterfaces (
762 IN OUT EFI_HANDLE
*Handle
,
769 Uninstalls a list of protocol interface in the boot services environment.
770 This function calls UnisatllProtocolInterface() in a loop. This is
771 basically a lib function to save space.
773 @param Handle The handle to uninstall the protocol
774 @param ... EFI_GUID followed by protocol instance. A NULL
775 terminates the list. The pairs are the
776 arguments to UninstallProtocolInterface(). All
777 the protocols are added to Handle.
784 CoreUninstallMultipleProtocolInterfaces (
785 IN EFI_HANDLE Handle
,
792 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
794 @param UserHandle Handle on which the interface is to be
796 @param Protocol The numeric ID of the interface
797 @param OldInterface A pointer to the old interface
798 @param NewInterface A pointer to the new interface
800 @retval EFI_SUCCESS The protocol interface was installed
801 @retval EFI_NOT_FOUND The OldInterface on the handle was not found
802 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
807 CoreReinstallProtocolInterface (
808 IN EFI_HANDLE UserHandle
,
809 IN EFI_GUID
*Protocol
,
810 IN VOID
*OldInterface
,
811 IN VOID
*NewInterface
817 Uninstalls all instances of a protocol:interfacer from a handle.
818 If the last protocol interface is remove from the handle, the
821 @param UserHandle The handle to remove the protocol handler from
822 @param Protocol The protocol, of protocol:interface, to remove
823 @param Interface The interface, of protocol:interface, to remove
825 @retval EFI_INVALID_PARAMETER Protocol is NULL.
826 @retval EFI_SUCCESS Protocol interface successfully uninstalled.
831 CoreUninstallProtocolInterface (
832 IN EFI_HANDLE UserHandle
,
833 IN EFI_GUID
*Protocol
,
840 Queries a handle to determine if it supports a specified protocol.
842 @param UserHandle The handle being queried.
843 @param Protocol The published unique identifier of the protocol.
844 @param Interface Supplies the address where a pointer to the
845 corresponding Protocol Interface is returned.
847 @return The requested protocol interface for the handle
853 IN EFI_HANDLE UserHandle
,
854 IN EFI_GUID
*Protocol
,
861 Locates the installed protocol handler for the handle, and
862 invokes it to obtain the protocol interface. Usage information
863 is registered in the protocol data base.
865 @param UserHandle The handle to obtain the protocol interface on
866 @param Protocol The ID of the protocol
867 @param Interface The location to return the protocol interface
868 @param ImageHandle The handle of the Image that is opening the
869 protocol interface specified by Protocol and
871 @param ControllerHandle The controller handle that is requiring this
873 @param Attributes The open mode of the protocol interface
874 specified by Handle and Protocol.
876 @retval EFI_INVALID_PARAMETER Protocol is NULL.
877 @retval EFI_SUCCESS Get the protocol interface.
883 IN EFI_HANDLE UserHandle
,
884 IN EFI_GUID
*Protocol
,
885 OUT VOID
**Interface OPTIONAL
,
886 IN EFI_HANDLE ImageHandle
,
887 IN EFI_HANDLE ControllerHandle
,
894 Return information about Opened protocols in the system
896 @param UserHandle The handle to close the protocol interface on
897 @param Protocol The ID of the protocol
898 @param EntryBuffer A pointer to a buffer of open protocol
899 information in the form of
900 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
901 @param EntryCount Number of EntryBuffer entries
906 CoreOpenProtocolInformation (
907 IN EFI_HANDLE UserHandle
,
908 IN EFI_GUID
*Protocol
,
909 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
**EntryBuffer
,
910 OUT UINTN
*EntryCount
916 Closes a protocol on a handle that was opened using OpenProtocol().
918 @param UserHandle The handle for the protocol interface that was
919 previously opened with OpenProtocol(), and is
921 @param Protocol The published unique identifier of the protocol.
922 It is the caller's responsibility to pass in a
924 @param AgentHandle The handle of the agent that is closing the
926 @param ControllerHandle If the agent that opened a protocol is a driver
927 that follows the EFI Driver Model, then this
928 parameter is the controller handle that required
929 the protocol interface. If the agent does not
930 follow the EFI Driver Model, then this parameter
931 is optional and may be NULL.
933 @retval EFI_SUCCESS The protocol instance was closed.
934 @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a
936 @retval EFI_NOT_FOUND Can not find the specified protocol or
943 IN EFI_HANDLE UserHandle
,
944 IN EFI_GUID
*Protocol
,
945 IN EFI_HANDLE AgentHandle
,
946 IN EFI_HANDLE ControllerHandle
952 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
955 @param UserHandle The handle from which to retrieve the list of
956 protocol interface GUIDs.
957 @param ProtocolBuffer A pointer to the list of protocol interface GUID
958 pointers that are installed on Handle.
959 @param ProtocolBufferCount A pointer to the number of GUID pointers present
962 @retval EFI_SUCCESS The list of protocol interface GUIDs installed
963 on Handle was returned in ProtocolBuffer. The
964 number of protocol interface GUIDs was returned
965 in ProtocolBufferCount.
966 @retval EFI_INVALID_PARAMETER Handle is NULL.
967 @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
968 @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.
969 @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.
970 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
976 CoreProtocolsPerHandle (
977 IN EFI_HANDLE UserHandle
,
978 OUT EFI_GUID
***ProtocolBuffer
,
979 OUT UINTN
*ProtocolBufferCount
985 Add a new protocol notification record for the request protocol.
987 @param Protocol The requested protocol to add the notify
989 @param Event The event to signal
990 @param Registration Returns the registration record
992 @retval EFI_INVALID_PARAMETER Invalid parameter
993 @retval EFI_SUCCESS Successfully returned the registration record
999 CoreRegisterProtocolNotify (
1000 IN EFI_GUID
*Protocol
,
1002 OUT VOID
**Registration
1007 Removes all the events in the protocol database that match Event.
1009 @param Event The event to search for in the protocol
1012 @return EFI_SUCCESS when done searching the entire database.
1016 CoreUnregisterProtocolNotify (
1022 Locates the requested handle(s) and returns them in Buffer.
1024 @param SearchType The type of search to perform to locate the
1026 @param Protocol The protocol to search for
1027 @param SearchKey Dependant on SearchType
1028 @param BufferSize On input the size of Buffer. On output the
1029 size of data returned.
1030 @param Buffer The buffer to return the results in
1032 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
1033 returned in BufferSize.
1034 @retval EFI_INVALID_PARAMETER Invalid parameter
1035 @retval EFI_SUCCESS Successfully found the requested handle(s) and
1036 returns them in Buffer.
1042 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1043 IN EFI_GUID
*Protocol OPTIONAL
,
1044 IN VOID
*SearchKey OPTIONAL
,
1045 IN OUT UINTN
*BufferSize
,
1046 OUT EFI_HANDLE
*Buffer
1052 Locates the handle to a device on the device path that best matches the specified protocol.
1054 @param Protocol The protocol to search for.
1055 @param DevicePath On input, a pointer to a pointer to the device
1056 path. On output, the device path pointer is
1057 modified to point to the remaining part of the
1059 @param Device A pointer to the returned device handle.
1061 @retval EFI_SUCCESS The resulting handle was returned.
1062 @retval EFI_NOT_FOUND No handles matched the search.
1063 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1068 CoreLocateDevicePath (
1069 IN EFI_GUID
*Protocol
,
1070 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
1071 OUT EFI_HANDLE
*Device
1077 Function returns an array of handles that support the requested protocol
1078 in a buffer allocated from pool. This is a version of CoreLocateHandle()
1079 that allocates a buffer for the caller.
1081 @param SearchType Specifies which handle(s) are to be returned.
1082 @param Protocol Provides the protocol to search by. This
1083 parameter is only valid for SearchType
1085 @param SearchKey Supplies the search key depending on the
1087 @param NumberHandles The number of handles returned in Buffer.
1088 @param Buffer A pointer to the buffer to return the requested
1089 array of handles that support Protocol.
1091 @retval EFI_SUCCESS The result array of handles was returned.
1092 @retval EFI_NOT_FOUND No handles match the search.
1093 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
1095 @retval EFI_INVALID_PARAMETER One or more parameters are not valid.
1100 CoreLocateHandleBuffer (
1101 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1102 IN EFI_GUID
*Protocol OPTIONAL
,
1103 IN VOID
*SearchKey OPTIONAL
,
1104 IN OUT UINTN
*NumberHandles
,
1105 OUT EFI_HANDLE
**Buffer
1111 Return the first Protocol Interface that matches the Protocol GUID. If
1112 Registration is passed in, return a Protocol Instance that was just add
1113 to the system. If Registration is NULL return the first Protocol Interface
1116 @param Protocol The protocol to search for
1117 @param Registration Optional Registration Key returned from
1118 RegisterProtocolNotify()
1119 @param Interface Return the Protocol interface (instance).
1121 @retval EFI_SUCCESS If a valid Interface is returned
1122 @retval EFI_INVALID_PARAMETER Invalid parameter
1123 @retval EFI_NOT_FOUND Protocol interface not found
1128 CoreLocateProtocol (
1129 IN EFI_GUID
*Protocol
,
1130 IN VOID
*Registration OPTIONAL
,
1131 OUT VOID
**Interface
1136 return handle database key.
1139 @return Handle database key.
1143 CoreGetHandleDatabaseKey (
1149 Go connect any handles that were created or modified while a image executed.
1151 @param Key The Key to show that the handle has been
1156 CoreConnectHandlesByKey (
1163 Connects one or more drivers to a controller.
1165 @param ControllerHandle The handle of the controller to which driver(s) are to be connected.
1166 @param DriverImageHandle A pointer to an ordered list handles that support the
1167 EFI_DRIVER_BINDING_PROTOCOL.
1168 @param RemainingDevicePath A pointer to the device path that specifies a child of the
1169 controller specified by ControllerHandle.
1170 @param Recursive If TRUE, then ConnectController() is called recursively
1171 until the entire tree of controllers below the controller specified
1172 by ControllerHandle have been created. If FALSE, then
1173 the tree of controllers is only expanded one level.
1175 @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.
1176 2) No drivers were connected to ControllerHandle, but
1177 RemainingDevicePath is not NULL, and it is an End Device
1179 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1180 @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
1181 present in the system.
1182 2) No drivers were connected to ControllerHandle.
1183 @retval EFI_SECURITY_VIOLATION
1184 The user has no permission to start UEFI device drivers on the device path
1185 associated with the ControllerHandle or specified by the RemainingDevicePath.
1190 CoreConnectController (
1191 IN EFI_HANDLE ControllerHandle
,
1192 IN EFI_HANDLE
*DriverImageHandle OPTIONAL
,
1193 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
1194 IN BOOLEAN Recursive
1200 Disonnects a controller from a driver
1202 @param ControllerHandle ControllerHandle The handle of
1203 the controller from which
1206 @param DriverImageHandle DriverImageHandle The driver to
1207 disconnect from ControllerHandle.
1208 @param ChildHandle ChildHandle The handle of the
1211 @retval EFI_SUCCESS One or more drivers were
1212 disconnected from the controller.
1213 @retval EFI_SUCCESS On entry, no drivers are managing
1215 @retval EFI_SUCCESS DriverImageHandle is not NULL,
1216 and on entry DriverImageHandle is
1217 not managing ControllerHandle.
1218 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1219 @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
1220 and it is not a valid EFI_HANDLE.
1221 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
1222 is not a valid EFI_HANDLE.
1223 @retval EFI_OUT_OF_RESOURCES There are not enough resources
1224 available to disconnect any
1225 drivers from ControllerHandle.
1226 @retval EFI_DEVICE_ERROR The controller could not be
1227 disconnected because of a device
1233 CoreDisconnectController (
1234 IN EFI_HANDLE ControllerHandle
,
1235 IN EFI_HANDLE DriverImageHandle OPTIONAL
,
1236 IN EFI_HANDLE ChildHandle OPTIONAL
1242 Allocates pages from the memory map.
1244 @param Type The type of allocation to perform
1245 @param MemoryType The type of memory to turn the allocated pages
1247 @param NumberOfPages The number of pages to allocate
1248 @param Memory A pointer to receive the base allocated memory
1251 @return Status. On success, Memory is filled in with the base address allocated
1252 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
1254 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
1255 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
1256 @retval EFI_SUCCESS Pages successfully allocated.
1262 IN EFI_ALLOCATE_TYPE Type
,
1263 IN EFI_MEMORY_TYPE MemoryType
,
1264 IN UINTN NumberOfPages
,
1265 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
1269 Frees previous allocated pages.
1271 @param Memory Base address of memory being freed
1272 @param NumberOfPages The number of pages to free
1274 @retval EFI_NOT_FOUND Could not find the entry that covers the range
1275 @retval EFI_INVALID_PARAMETER Address not aligned
1276 @return EFI_SUCCESS -Pages successfully freed.
1282 IN EFI_PHYSICAL_ADDRESS Memory
,
1283 IN UINTN NumberOfPages
1287 This function returns a copy of the current memory map. The map is an array of
1288 memory descriptors, each of which describes a contiguous block of memory.
1290 @param MemoryMapSize A pointer to the size, in bytes, of the
1291 MemoryMap buffer. On input, this is the size of
1292 the buffer allocated by the caller. On output,
1293 it is the size of the buffer returned by the
1294 firmware if the buffer was large enough, or the
1295 size of the buffer needed to contain the map if
1296 the buffer was too small.
1297 @param MemoryMap A pointer to the buffer in which firmware places
1298 the current memory map.
1299 @param MapKey A pointer to the location in which firmware
1300 returns the key for the current memory map.
1301 @param DescriptorSize A pointer to the location in which firmware
1302 returns the size, in bytes, of an individual
1303 EFI_MEMORY_DESCRIPTOR.
1304 @param DescriptorVersion A pointer to the location in which firmware
1305 returns the version number associated with the
1306 EFI_MEMORY_DESCRIPTOR.
1308 @retval EFI_SUCCESS The memory map was returned in the MemoryMap
1310 @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
1311 buffer size needed to hold the memory map is
1312 returned in MemoryMapSize.
1313 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1319 IN OUT UINTN
*MemoryMapSize
,
1320 IN OUT EFI_MEMORY_DESCRIPTOR
*MemoryMap
,
1322 OUT UINTN
*DescriptorSize
,
1323 OUT UINT32
*DescriptorVersion
1329 Allocate pool of a particular type.
1331 @param PoolType Type of pool to allocate
1332 @param Size The amount of pool to allocate
1333 @param Buffer The address to return a pointer to the allocated
1336 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
1337 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
1338 @retval EFI_SUCCESS Pool successfully allocated.
1344 IN EFI_MEMORY_TYPE PoolType
,
1350 Allocate pool of a particular type.
1352 @param PoolType Type of pool to allocate
1353 @param Size The amount of pool to allocate
1354 @param Buffer The address to return a pointer to the allocated
1357 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
1358 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
1359 @retval EFI_SUCCESS Pool successfully allocated.
1364 CoreInternalAllocatePool (
1365 IN EFI_MEMORY_TYPE PoolType
,
1373 @param Buffer The allocated pool entry to free
1375 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
1376 @retval EFI_SUCCESS Pool successfully freed.
1388 @param Buffer The allocated pool entry to free
1389 @param PoolType Pointer to pool type
1391 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
1392 @retval EFI_SUCCESS Pool successfully freed.
1397 CoreInternalFreePool (
1399 OUT EFI_MEMORY_TYPE
*PoolType OPTIONAL
1403 Loads an EFI image into memory and returns a handle to the image.
1405 @param BootPolicy If TRUE, indicates that the request originates
1406 from the boot manager, and that the boot
1407 manager is attempting to load FilePath as a
1409 @param ParentImageHandle The caller's image handle.
1410 @param FilePath The specific file path from which the image is
1412 @param SourceBuffer If not NULL, a pointer to the memory location
1413 containing a copy of the image to be loaded.
1414 @param SourceSize The size in bytes of SourceBuffer.
1415 @param ImageHandle Pointer to the returned image handle that is
1416 created when the image is successfully loaded.
1418 @retval EFI_SUCCESS The image was loaded into memory.
1419 @retval EFI_NOT_FOUND The FilePath was not found.
1420 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1421 @retval EFI_UNSUPPORTED The image type is not supported, or the device
1422 path cannot be parsed to locate the proper
1423 protocol for loading the file.
1424 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
1426 @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
1428 @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
1429 @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
1430 image from being loaded. NULL is returned in *ImageHandle.
1431 @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
1432 valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
1433 platform policy specifies that the image should not be started.
1439 IN BOOLEAN BootPolicy
,
1440 IN EFI_HANDLE ParentImageHandle
,
1441 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
1442 IN VOID
*SourceBuffer OPTIONAL
,
1443 IN UINTN SourceSize
,
1444 OUT EFI_HANDLE
*ImageHandle
1452 @param ImageHandle Handle that identifies the image to be
1455 @retval EFI_SUCCESS The image has been unloaded.
1456 @retval EFI_UNSUPPORTED The image has been started, and does not support
1458 @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
1464 IN EFI_HANDLE ImageHandle
1470 Transfer control to a loaded image's entry point.
1472 @param ImageHandle Handle of image to be started.
1473 @param ExitDataSize Pointer of the size to ExitData
1474 @param ExitData Pointer to a pointer to a data buffer that
1475 includes a Null-terminated string,
1476 optionally followed by additional binary data.
1477 The string is a description that the caller may
1478 use to further indicate the reason for the
1481 @retval EFI_INVALID_PARAMETER Invalid parameter
1482 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1483 @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
1484 @retval EFI_SUCCESS Successfully transfer control to the image's
1491 IN EFI_HANDLE ImageHandle
,
1492 OUT UINTN
*ExitDataSize
,
1493 OUT CHAR16
**ExitData OPTIONAL
1499 Terminates the currently loaded EFI image and returns control to boot services.
1501 @param ImageHandle Handle that identifies the image. This
1502 parameter is passed to the image on entry.
1503 @param Status The image's exit code.
1504 @param ExitDataSize The size, in bytes, of ExitData. Ignored if
1505 ExitStatus is EFI_SUCCESS.
1506 @param ExitData Pointer to a data buffer that includes a
1507 Null-terminated Unicode string, optionally
1508 followed by additional binary data. The string
1509 is a description that the caller may use to
1510 further indicate the reason for the image's
1513 @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
1515 @retval EFI_SUCCESS Successfully terminates the currently loaded
1517 @retval EFI_ACCESS_DENIED Should never reach there.
1518 @retval EFI_OUT_OF_RESOURCES Could not allocate pool
1524 IN EFI_HANDLE ImageHandle
,
1525 IN EFI_STATUS Status
,
1526 IN UINTN ExitDataSize
,
1527 IN CHAR16
*ExitData OPTIONAL
1535 @param Type The type of event to create and its mode and
1537 @param NotifyTpl The task priority level of event notifications
1538 @param NotifyFunction Pointer to the events notification function
1539 @param NotifyContext Pointer to the notification functions context;
1540 corresponds to parameter "Context" in the
1541 notification function
1542 @param Event Pointer to the newly created event if the call
1543 succeeds; undefined otherwise
1545 @retval EFI_SUCCESS The event structure was created
1546 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1547 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1554 IN EFI_TPL NotifyTpl
,
1555 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1556 IN VOID
*NotifyContext
, OPTIONAL
1557 OUT EFI_EVENT
*Event
1563 Creates an event in a group.
1565 @param Type The type of event to create and its mode and
1567 @param NotifyTpl The task priority level of event notifications
1568 @param NotifyFunction Pointer to the events notification function
1569 @param NotifyContext Pointer to the notification functions context;
1570 corresponds to parameter "Context" in the
1571 notification function
1572 @param EventGroup GUID for EventGroup if NULL act the same as
1574 @param Event Pointer to the newly created event if the call
1575 succeeds; undefined otherwise
1577 @retval EFI_SUCCESS The event structure was created
1578 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1579 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1586 IN EFI_TPL NotifyTpl
,
1587 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1588 IN CONST VOID
*NotifyContext
, OPTIONAL
1589 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1590 OUT EFI_EVENT
*Event
1594 Creates a general-purpose event structure
1596 @param Type The type of event to create and its mode and
1598 @param NotifyTpl The task priority level of event notifications
1599 @param NotifyFunction Pointer to the events notification function
1600 @param NotifyContext Pointer to the notification functions context;
1601 corresponds to parameter "Context" in the
1602 notification function
1603 @param EventGroup GUID for EventGroup if NULL act the same as
1605 @param Event Pointer to the newly created event if the call
1606 succeeds; undefined otherwise
1608 @retval EFI_SUCCESS The event structure was created
1609 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1610 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1615 CoreCreateEventInternal (
1617 IN EFI_TPL NotifyTpl
,
1618 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1619 IN CONST VOID
*NotifyContext
, OPTIONAL
1620 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1621 OUT EFI_EVENT
*Event
1625 Sets the type of timer and the trigger time for a timer event.
1627 @param UserEvent The timer event that is to be signaled at the
1629 @param Type The type of time that is specified in
1631 @param TriggerTime The number of 100ns units until the timer
1634 @retval EFI_SUCCESS The event has been set to be signaled at the
1636 @retval EFI_INVALID_PARAMETER Event or Type is not valid
1642 IN EFI_EVENT UserEvent
,
1643 IN EFI_TIMER_DELAY Type
,
1644 IN UINT64 TriggerTime
1650 Signals the event. Queues the event to be notified if needed.
1652 @param UserEvent The event to signal .
1654 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1655 @retval EFI_SUCCESS The event was signaled.
1661 IN EFI_EVENT UserEvent
1667 Stops execution until an event is signaled.
1669 @param NumberOfEvents The number of events in the UserEvents array
1670 @param UserEvents An array of EFI_EVENT
1671 @param UserIndex Pointer to the index of the event which
1672 satisfied the wait condition
1674 @retval EFI_SUCCESS The event indicated by Index was signaled.
1675 @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification
1676 function or Event was not a valid type
1677 @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION
1683 IN UINTN NumberOfEvents
,
1684 IN EFI_EVENT
*UserEvents
,
1685 OUT UINTN
*UserIndex
1691 Closes an event and frees the event structure.
1693 @param UserEvent Event to close
1695 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1696 @retval EFI_SUCCESS The event has been closed
1702 IN EFI_EVENT UserEvent
1708 Check the status of an event.
1710 @param UserEvent The event to check
1712 @retval EFI_SUCCESS The event is in the signaled state
1713 @retval EFI_NOT_READY The event is not in the signaled state
1714 @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL
1720 IN EFI_EVENT UserEvent
1725 Adds reserved memory, system memory, or memory-mapped I/O resources to the
1726 global coherency domain of the processor.
1728 @param GcdMemoryType Memory type of the memory space.
1729 @param BaseAddress Base address of the memory space.
1730 @param Length Length of the memory space.
1731 @param Capabilities alterable attributes of the memory space.
1733 @retval EFI_SUCCESS Merged this memory space into GCD map.
1738 CoreAddMemorySpace (
1739 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1740 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1742 IN UINT64 Capabilities
1747 Allocates nonexistent memory, reserved memory, system memory, or memorymapped
1748 I/O resources from the global coherency domain of the processor.
1750 @param GcdAllocateType The type of allocate operation
1751 @param GcdMemoryType The desired memory type
1752 @param Alignment Align with 2^Alignment
1753 @param Length Length to allocate
1754 @param BaseAddress Base address to allocate
1755 @param ImageHandle The image handle consume the allocated space.
1756 @param DeviceHandle The device handle consume the allocated space.
1758 @retval EFI_INVALID_PARAMETER Invalid parameter.
1759 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1760 @retval EFI_SUCCESS Memory space successfully allocated.
1765 CoreAllocateMemorySpace (
1766 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1767 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1770 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1771 IN EFI_HANDLE ImageHandle
,
1772 IN EFI_HANDLE DeviceHandle OPTIONAL
1777 Frees nonexistent memory, reserved memory, system memory, or memory-mapped
1778 I/O resources from the global coherency domain of the processor.
1780 @param BaseAddress Base address of the memory space.
1781 @param Length Length of the memory space.
1783 @retval EFI_SUCCESS Space successfully freed.
1788 CoreFreeMemorySpace (
1789 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1795 Removes reserved memory, system memory, or memory-mapped I/O resources from
1796 the global coherency domain of the processor.
1798 @param BaseAddress Base address of the memory space.
1799 @param Length Length of the memory space.
1801 @retval EFI_SUCCESS Successfully remove a segment of memory space.
1806 CoreRemoveMemorySpace (
1807 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1813 Retrieves the descriptor for a memory region containing a specified address.
1815 @param BaseAddress Specified start address
1816 @param Descriptor Specified length
1818 @retval EFI_INVALID_PARAMETER Invalid parameter
1819 @retval EFI_SUCCESS Successfully get memory space descriptor.
1824 CoreGetMemorySpaceDescriptor (
1825 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1826 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*Descriptor
1831 Modifies the attributes for a memory region in the global coherency domain of the
1834 @param BaseAddress Specified start address
1835 @param Length Specified length
1836 @param Attributes Specified attributes
1838 @retval EFI_SUCCESS The attributes were set for the memory region.
1839 @retval EFI_INVALID_PARAMETER Length is zero.
1840 @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory
1841 resource range specified by BaseAddress and Length.
1842 @retval EFI_UNSUPPORTED The bit mask of attributes is not support for the memory resource
1843 range specified by BaseAddress and Length.
1844 @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by
1845 BaseAddress and Length cannot be modified.
1846 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of
1847 the memory resource range.
1848 @retval EFI_NOT_AVAILABLE_YET The attributes cannot be set because CPU architectural protocol is
1854 CoreSetMemorySpaceAttributes (
1855 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1857 IN UINT64 Attributes
1862 Modifies the capabilities for a memory region in the global coherency domain of the
1865 @param BaseAddress The physical address that is the start address of a memory region.
1866 @param Length The size in bytes of the memory region.
1867 @param Capabilities The bit mask of capabilities that the memory region supports.
1869 @retval EFI_SUCCESS The capabilities were set for the memory region.
1870 @retval EFI_INVALID_PARAMETER Length is zero.
1871 @retval EFI_UNSUPPORTED The capabilities specified by Capabilities do not include the
1872 memory region attributes currently in use.
1873 @retval EFI_ACCESS_DENIED The capabilities for the memory resource range specified by
1874 BaseAddress and Length cannot be modified.
1875 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the capabilities
1876 of the memory resource range.
1880 CoreSetMemorySpaceCapabilities (
1881 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1883 IN UINT64 Capabilities
1888 Returns a map of the memory resources in the global coherency domain of the
1891 @param NumberOfDescriptors Number of descriptors.
1892 @param MemorySpaceMap Descriptor array
1894 @retval EFI_INVALID_PARAMETER Invalid parameter
1895 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1896 @retval EFI_SUCCESS Successfully get memory space map.
1901 CoreGetMemorySpaceMap (
1902 OUT UINTN
*NumberOfDescriptors
,
1903 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
**MemorySpaceMap
1908 Adds reserved I/O or I/O resources to the global coherency domain of the processor.
1910 @param GcdIoType IO type of the segment.
1911 @param BaseAddress Base address of the segment.
1912 @param Length Length of the segment.
1914 @retval EFI_SUCCESS Merged this segment into GCD map.
1915 @retval EFI_INVALID_PARAMETER Parameter not valid
1921 IN EFI_GCD_IO_TYPE GcdIoType
,
1922 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1928 Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1929 domain of the processor.
1931 @param GcdAllocateType The type of allocate operation
1932 @param GcdIoType The desired IO type
1933 @param Alignment Align with 2^Alignment
1934 @param Length Length to allocate
1935 @param BaseAddress Base address to allocate
1936 @param ImageHandle The image handle consume the allocated space.
1937 @param DeviceHandle The device handle consume the allocated space.
1939 @retval EFI_INVALID_PARAMETER Invalid parameter.
1940 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1941 @retval EFI_SUCCESS IO space successfully allocated.
1946 CoreAllocateIoSpace (
1947 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1948 IN EFI_GCD_IO_TYPE GcdIoType
,
1951 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1952 IN EFI_HANDLE ImageHandle
,
1953 IN EFI_HANDLE DeviceHandle OPTIONAL
1958 Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1959 domain of the processor.
1961 @param BaseAddress Base address of the segment.
1962 @param Length Length of the segment.
1964 @retval EFI_SUCCESS Space successfully freed.
1970 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1976 Removes reserved I/O or I/O resources from the global coherency domain of the
1979 @param BaseAddress Base address of the segment.
1980 @param Length Length of the segment.
1982 @retval EFI_SUCCESS Successfully removed a segment of IO space.
1988 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1994 Retrieves the descriptor for an I/O region containing a specified address.
1996 @param BaseAddress Specified start address
1997 @param Descriptor Specified length
1999 @retval EFI_INVALID_PARAMETER Descriptor is NULL.
2000 @retval EFI_SUCCESS Successfully get the IO space descriptor.
2005 CoreGetIoSpaceDescriptor (
2006 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2007 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
*Descriptor
2012 Returns a map of the I/O resources in the global coherency domain of the processor.
2014 @param NumberOfDescriptors Number of descriptors.
2015 @param IoSpaceMap Descriptor array
2017 @retval EFI_INVALID_PARAMETER Invalid parameter
2018 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
2019 @retval EFI_SUCCESS Successfully get IO space map.
2025 OUT UINTN
*NumberOfDescriptors
,
2026 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
**IoSpaceMap
2031 This is the main Dispatcher for DXE and it exits when there are no more
2032 drivers to run. Drain the mScheduledQueue and load and start a PE
2033 image for each driver. Search the mDiscoveredList to see if any driver can
2034 be placed on the mScheduledQueue. If no drivers are placed on the
2035 mScheduledQueue exit the function. On exit it is assumed the Bds()
2036 will be called, and when the Bds() exits the Dispatcher will be called
2039 @retval EFI_ALREADY_STARTED The DXE Dispatcher is already running
2040 @retval EFI_NOT_FOUND No DXE Drivers were dispatched
2041 @retval EFI_SUCCESS One or more DXE Drivers were dispatched
2051 Check every driver and locate a matching one. If the driver is found, the Unrequested
2052 state flag is cleared.
2054 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
2055 the firmware file specified by DriverName.
2056 @param DriverName The Driver name to put in the Dependent state.
2058 @retval EFI_SUCCESS The DriverName was found and it's SOR bit was
2060 @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was
2067 IN EFI_HANDLE FirmwareVolumeHandle
,
2068 IN EFI_GUID
*DriverName
2073 Convert a driver from the Untrused back to the Scheduled state.
2075 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
2076 the firmware file specified by DriverName.
2077 @param DriverName The Driver name to put in the Scheduled state
2079 @retval EFI_SUCCESS The file was found in the untrusted state, and it
2080 was promoted to the trusted state.
2081 @retval EFI_NOT_FOUND The file was not found in the untrusted state.
2087 IN EFI_HANDLE FirmwareVolumeHandle
,
2088 IN EFI_GUID
*DriverName
2093 This routine is the driver initialization entry point. It initializes the
2094 libraries, and registers two notification functions. These notification
2095 functions are responsible for building the FV stack dynamically.
2097 @param ImageHandle The image handle.
2098 @param SystemTable The system table.
2100 @retval EFI_SUCCESS Function successfully returned.
2106 IN EFI_HANDLE ImageHandle
,
2107 IN EFI_SYSTEM_TABLE
*SystemTable
2112 Entry point of the section extraction code. Initializes an instance of the
2113 section extraction interface and installs it on a new handle.
2115 @param ImageHandle A handle for the image that is initializing this driver
2116 @param SystemTable A pointer to the EFI system table
2118 @retval EFI_SUCCESS Driver initialized successfully
2119 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
2124 InitializeSectionExtraction (
2125 IN EFI_HANDLE ImageHandle
,
2126 IN EFI_SYSTEM_TABLE
*SystemTable
2131 This DXE service routine is used to process a firmware volume. In
2132 particular, it can be called by BDS to process a single firmware
2133 volume found in a capsule.
2135 @param FvHeader pointer to a firmware volume header
2136 @param Size the size of the buffer pointed to by FvHeader
2137 @param FVProtocolHandle the handle on which a firmware volume protocol
2138 was produced for the firmware volume passed in.
2140 @retval EFI_OUT_OF_RESOURCES if an FVB could not be produced due to lack of
2142 @retval EFI_VOLUME_CORRUPTED if the volume was corrupted
2143 @retval EFI_SUCCESS a firmware volume protocol was produced for the
2149 CoreProcessFirmwareVolume (
2152 OUT EFI_HANDLE
*FVProtocolHandle
2156 //Functions used during debug buils
2160 Displays Architectural protocols that were not loaded and are required for DXE
2161 core to function. Only used in Debug Builds.
2165 CoreDisplayMissingArchProtocols (
2171 Traverse the discovered list for any drivers that were discovered but not loaded
2172 because the dependency experessions evaluated to false.
2176 CoreDisplayDiscoveredNotDispatched (
2182 Place holder function until all the Boot Services and Runtime Services are
2185 @return EFI_NOT_AVAILABLE_YET
2190 CoreEfiNotAvailableYetArg0 (
2196 Place holder function until all the Boot Services and Runtime Services are
2199 @param Arg1 Undefined
2201 @return EFI_NOT_AVAILABLE_YET
2206 CoreEfiNotAvailableYetArg1 (
2212 Place holder function until all the Boot Services and Runtime Services are available.
2214 @param Arg1 Undefined
2215 @param Arg2 Undefined
2217 @return EFI_NOT_AVAILABLE_YET
2222 CoreEfiNotAvailableYetArg2 (
2229 Place holder function until all the Boot Services and Runtime Services are available.
2231 @param Arg1 Undefined
2232 @param Arg2 Undefined
2233 @param Arg3 Undefined
2235 @return EFI_NOT_AVAILABLE_YET
2240 CoreEfiNotAvailableYetArg3 (
2248 Place holder function until all the Boot Services and Runtime Services are available.
2250 @param Arg1 Undefined
2251 @param Arg2 Undefined
2252 @param Arg3 Undefined
2253 @param Arg4 Undefined
2255 @return EFI_NOT_AVAILABLE_YET
2260 CoreEfiNotAvailableYetArg4 (
2269 Place holder function until all the Boot Services and Runtime Services are available.
2271 @param Arg1 Undefined
2272 @param Arg2 Undefined
2273 @param Arg3 Undefined
2274 @param Arg4 Undefined
2275 @param Arg5 Undefined
2277 @return EFI_NOT_AVAILABLE_YET
2282 CoreEfiNotAvailableYetArg5 (
2292 Given a compressed source buffer, this function retrieves the size of the
2293 uncompressed buffer and the size of the scratch buffer required to decompress
2294 the compressed source buffer.
2296 The GetInfo() function retrieves the size of the uncompressed buffer and the
2297 temporary scratch buffer required to decompress the buffer specified by Source
2298 and SourceSize. If the size of the uncompressed buffer or the size of the
2299 scratch buffer cannot be determined from the compressed data specified by
2300 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
2301 size of the uncompressed buffer is returned in DestinationSize, the size of
2302 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
2303 The GetInfo() function does not have scratch buffer available to perform a
2304 thorough checking of the validity of the source data. It just retrieves the
2305 "Original Size" field from the beginning bytes of the source data and output
2306 it as DestinationSize. And ScratchSize is specific to the decompression
2309 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2310 @param Source The source buffer containing the compressed data.
2311 @param SourceSize The size, in bytes, of the source buffer.
2312 @param DestinationSize A pointer to the size, in bytes, of the
2313 uncompressed buffer that will be generated when the
2314 compressed buffer specified by Source and
2315 SourceSize is decompressed.
2316 @param ScratchSize A pointer to the size, in bytes, of the scratch
2317 buffer that is required to decompress the
2318 compressed buffer specified by Source and
2321 @retval EFI_SUCCESS The size of the uncompressed data was returned in
2322 DestinationSize and the size of the scratch buffer
2323 was returned in ScratchSize.
2324 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
2325 the scratch buffer cannot be determined from the
2326 compressed data specified by Source and
2332 DxeMainUefiDecompressGetInfo (
2333 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2335 IN UINT32 SourceSize
,
2336 OUT UINT32
*DestinationSize
,
2337 OUT UINT32
*ScratchSize
2342 Decompresses a compressed source buffer.
2344 The Decompress() function extracts decompressed data to its original form.
2345 This protocol is designed so that the decompression algorithm can be
2346 implemented without using any memory services. As a result, the Decompress()
2347 Function is not allowed to call AllocatePool() or AllocatePages() in its
2348 implementation. It is the caller's responsibility to allocate and free the
2349 Destination and Scratch buffers.
2350 If the compressed source data specified by Source and SourceSize is
2351 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
2352 the compressed source data specified by Source and SourceSize is not in a
2353 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
2355 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2356 @param Source The source buffer containing the compressed data.
2357 @param SourceSize SourceSizeThe size of source data.
2358 @param Destination On output, the destination buffer that contains
2359 the uncompressed data.
2360 @param DestinationSize The size of the destination buffer. The size of
2361 the destination buffer needed is obtained from
2362 EFI_DECOMPRESS_PROTOCOL.GetInfo().
2363 @param Scratch A temporary scratch buffer that is used to perform
2365 @param ScratchSize The size of scratch buffer. The size of the
2366 scratch buffer needed is obtained from GetInfo().
2368 @retval EFI_SUCCESS Decompression completed successfully, and the
2369 uncompressed buffer is returned in Destination.
2370 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
2371 SourceSize is corrupted (not in a valid
2377 DxeMainUefiDecompress (
2378 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2380 IN UINT32 SourceSize
,
2381 IN OUT VOID
*Destination
,
2382 IN UINT32 DestinationSize
,
2383 IN OUT VOID
*Scratch
,
2384 IN UINT32 ScratchSize
2388 SEP member function. This function creates and returns a new section stream
2389 handle to represent the new section stream.
2391 @param SectionStreamLength Size in bytes of the section stream.
2392 @param SectionStream Buffer containing the new section stream.
2393 @param SectionStreamHandle A pointer to a caller allocated UINTN that on
2394 output contains the new section stream handle.
2396 @retval EFI_SUCCESS The section stream is created successfully.
2397 @retval EFI_OUT_OF_RESOURCES memory allocation failed.
2398 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2405 IN UINTN SectionStreamLength
,
2406 IN VOID
*SectionStream
,
2407 OUT UINTN
*SectionStreamHandle
2413 SEP member function. Retrieves requested section from section stream.
2415 @param SectionStreamHandle The section stream from which to extract the
2417 @param SectionType A pointer to the type of section to search for.
2418 @param SectionDefinitionGuid If the section type is EFI_SECTION_GUID_DEFINED,
2419 then SectionDefinitionGuid indicates which of
2420 these types of sections to search for.
2421 @param SectionInstance Indicates which instance of the requested
2423 @param Buffer Double indirection to buffer. If *Buffer is
2424 non-null on input, then the buffer is caller
2425 allocated. If Buffer is NULL, then the buffer
2426 is callee allocated. In either case, the
2427 required buffer size is returned in *BufferSize.
2428 @param BufferSize On input, indicates the size of *Buffer if
2429 *Buffer is non-null on input. On output,
2430 indicates the required size (allocated size if
2431 callee allocated) of *Buffer.
2432 @param AuthenticationStatus A pointer to a caller-allocated UINT32 that
2433 indicates the authentication status of the
2434 output buffer. If the input section's
2435 GuidedSectionHeader.Attributes field
2436 has the EFI_GUIDED_SECTION_AUTH_STATUS_VALID
2437 bit as clear, AuthenticationStatus must return
2438 zero. Both local bits (19:16) and aggregate
2439 bits (3:0) in AuthenticationStatus are returned
2440 by ExtractSection(). These bits reflect the
2441 status of the extraction operation. The bit
2442 pattern in both regions must be the same, as
2443 the local and aggregate authentication statuses
2444 have equivalent meaning at this level. If the
2445 function returns anything other than
2446 EFI_SUCCESS, the value of *AuthenticationStatus
2448 @param IsFfs3Fv Indicates the FV format.
2450 @retval EFI_SUCCESS Section was retrieved successfully
2451 @retval EFI_PROTOCOL_ERROR A GUID defined section was encountered in the
2452 section stream with its
2453 EFI_GUIDED_SECTION_PROCESSING_REQUIRED bit set,
2454 but there was no corresponding GUIDed Section
2455 Extraction Protocol in the handle database.
2456 *Buffer is unmodified.
2457 @retval EFI_NOT_FOUND An error was encountered when parsing the
2458 SectionStream. This indicates the SectionStream
2459 is not correctly formatted.
2460 @retval EFI_NOT_FOUND The requested section does not exist.
2461 @retval EFI_OUT_OF_RESOURCES The system has insufficient resources to process
2463 @retval EFI_INVALID_PARAMETER The SectionStreamHandle does not exist.
2464 @retval EFI_WARN_TOO_SMALL The size of the caller allocated input buffer is
2465 insufficient to contain the requested section.
2466 The input buffer is filled and section contents
2473 IN UINTN SectionStreamHandle
,
2474 IN EFI_SECTION_TYPE
*SectionType
,
2475 IN EFI_GUID
*SectionDefinitionGuid
,
2476 IN UINTN SectionInstance
,
2478 IN OUT UINTN
*BufferSize
,
2479 OUT UINT32
*AuthenticationStatus
,
2485 SEP member function. Deletes an existing section stream
2487 @param StreamHandleToClose Indicates the stream to close
2488 @param FreeStreamBuffer TRUE - Need to free stream buffer;
2489 FALSE - No need to free stream buffer.
2491 @retval EFI_SUCCESS The section stream is closed sucessfully.
2492 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
2493 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2499 CloseSectionStream (
2500 IN UINTN StreamHandleToClose
,
2501 IN BOOLEAN FreeStreamBuffer
2505 Creates and initializes the DebugImageInfo Table. Also creates the configuration
2506 table and registers it into the system table.
2509 This function allocates memory, frees it, and then allocates memory at an
2510 address within the initial allocation. Since this function is called early
2511 in DXE core initialization (before drivers are dispatched), this should not
2516 CoreInitializeDebugImageInfoTable (
2522 Update the CRC32 in the Debug Table.
2523 Since the CRC32 service is made available by the Runtime driver, we have to
2524 wait for the Runtime Driver to be installed before the CRC32 can be computed.
2525 This function is called elsewhere by the core when the runtime architectural
2526 protocol is produced.
2530 CoreUpdateDebugTableCrc32 (
2536 Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
2537 the table if it's not large enough to accomidate another entry.
2539 @param ImageInfoType type of debug image information
2540 @param LoadedImage pointer to the loaded image protocol for the image being
2542 @param ImageHandle image handle for the image being loaded
2546 CoreNewDebugImageInfoEntry (
2547 IN UINT32 ImageInfoType
,
2548 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
,
2549 IN EFI_HANDLE ImageHandle
2554 Removes and frees an entry from the DebugImageInfo Table.
2556 @param ImageHandle image handle for the image being unloaded
2560 CoreRemoveDebugImageInfoEntry (
2561 EFI_HANDLE ImageHandle
2566 This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
2568 @param ImageHandle The image handle.
2569 @param SystemTable The system table.
2571 @retval EFI_SUCCESS Successfully initialized firmware volume block
2577 FwVolBlockDriverInit (
2578 IN EFI_HANDLE ImageHandle
,
2579 IN EFI_SYSTEM_TABLE
*SystemTable
2584 Get FVB authentication status
2586 @param FvbProtocol FVB protocol.
2588 @return Authentication status.
2592 GetFvbAuthenticationStatus (
2593 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
2597 This routine produces a firmware volume block protocol on a given
2600 @param BaseAddress base address of the firmware volume image
2601 @param Length length of the firmware volume image
2602 @param ParentHandle handle of parent firmware volume, if this image
2603 came from an FV image file and section in another firmware
2604 volume (ala capsules)
2605 @param AuthenticationStatus Authentication status inherited, if this image
2606 came from an FV image file and section in another firmware volume.
2607 @param FvProtocol Firmware volume block protocol produced.
2609 @retval EFI_VOLUME_CORRUPTED Volume corrupted.
2610 @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
2611 @retval EFI_SUCCESS Successfully produced a FVB protocol on given
2616 ProduceFVBProtocolOnBuffer (
2617 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2619 IN EFI_HANDLE ParentHandle
,
2620 IN UINT32 AuthenticationStatus
,
2621 OUT EFI_HANDLE
*FvProtocol OPTIONAL
2626 Raising to the task priority level of the mutual exclusion
2627 lock, and then acquires ownership of the lock.
2629 @param Lock The lock to acquire
2641 Initialize a basic mutual exclusion lock. Each lock
2642 provides mutual exclusion access at it's task priority
2643 level. Since there is no-premption (at any TPL) or
2644 multiprocessor support, acquiring the lock only consists
2645 of raising to the locks TPL.
2647 @param Lock The EFI_LOCK structure to initialize
2649 @retval EFI_SUCCESS Lock Owned.
2650 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
2654 CoreAcquireLockOrFail (
2660 Releases ownership of the mutual exclusion lock, and
2661 restores the previous task priority level.
2663 @param Lock The lock to release
2665 @return Lock unowned
2674 Read data from Firmware Block by FVB protocol Read.
2675 The data may cross the multi block ranges.
2677 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to read data.
2678 @param StartLba Pointer to StartLba.
2679 On input, the start logical block index from which to read.
2680 On output,the end logical block index after reading.
2681 @param Offset Pointer to Offset
2682 On input, offset into the block at which to begin reading.
2683 On output, offset into the end block after reading.
2684 @param DataSize Size of data to be read.
2685 @param Data Pointer to Buffer that the data will be read into.
2687 @retval EFI_SUCCESS Successfully read data from firmware block.
2692 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2693 IN OUT EFI_LBA
*StartLba
,
2694 IN OUT UINTN
*Offset
,
2700 Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
2701 copy the real length volume header into it.
2703 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
2704 read the volume header
2705 @param FwVolHeader Pointer to pointer to allocated buffer in which
2706 the volume header is returned.
2708 @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
2709 @retval EFI_SUCCESS Successfully read volume header to the allocated
2711 @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or
2712 the file system could not be understood.
2717 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2718 OUT EFI_FIRMWARE_VOLUME_HEADER
**FwVolHeader
2722 Verify checksum of the firmware volume header.
2724 @param FvHeader Points to the firmware volume header to be checked
2726 @retval TRUE Checksum verification passed
2727 @retval FALSE Checksum verification failed
2731 VerifyFvHeaderChecksum (
2732 IN EFI_FIRMWARE_VOLUME_HEADER
*FvHeader
2736 Initialize memory profile.
2738 @param HobStart The start address of the HOB.
2747 Install memory profile protocol.
2751 MemoryProfileInstallProtocol (
2756 Register image to memory profile.
2758 @param DriverEntry Image info.
2759 @param FileType Image file type.
2761 @return EFI_SUCCESS Register successfully.
2762 @return EFI_UNSUPPORTED Memory profile unsupported,
2763 or memory profile for the image is not required.
2764 @return EFI_OUT_OF_RESOURCES No enough resource for this register.
2768 RegisterMemoryProfileImage (
2769 IN LOADED_IMAGE_PRIVATE_DATA
*DriverEntry
,
2770 IN EFI_FV_FILETYPE FileType
2774 Unregister image from memory profile.
2776 @param DriverEntry Image info.
2778 @return EFI_SUCCESS Unregister successfully.
2779 @return EFI_UNSUPPORTED Memory profile unsupported,
2780 or memory profile for the image is not required.
2781 @return EFI_NOT_FOUND The image is not found.
2785 UnregisterMemoryProfileImage (
2786 IN LOADED_IMAGE_PRIVATE_DATA
*DriverEntry
2790 Update memory profile information.
2792 @param CallerAddress Address of caller who call Allocate or Free.
2793 @param Action This Allocate or Free action.
2794 @param MemoryType Memory type.
2795 EfiMaxMemoryType means the MemoryType is unknown.
2796 @param Size Buffer size.
2797 @param Buffer Buffer address.
2798 @param ActionString String for memory profile action.
2799 Only needed for user defined allocate action.
2801 @return EFI_SUCCESS Memory profile is updated.
2802 @return EFI_UNSUPPORTED Memory profile is unsupported,
2803 or memory profile for the image is not required,
2804 or memory profile for the memory type is not required.
2805 @return EFI_ACCESS_DENIED It is during memory profile data getting.
2806 @return EFI_ABORTED Memory profile recording is not enabled.
2807 @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.
2808 @return EFI_NOT_FOUND No matched allocate info found for free action.
2814 IN EFI_PHYSICAL_ADDRESS CallerAddress
,
2815 IN MEMORY_PROFILE_ACTION Action
,
2816 IN EFI_MEMORY_TYPE MemoryType
,
2817 IN UINTN Size
, // Valid for AllocatePages/FreePages/AllocatePool
2819 IN CHAR8
*ActionString OPTIONAL
2823 Internal function. Converts a memory range to use new attributes.
2825 @param Start The first address of the range Must be page
2827 @param NumberOfPages The number of pages to convert
2828 @param NewAttributes The new attributes value for the range.
2832 CoreUpdateMemoryAttributes (
2833 IN EFI_PHYSICAL_ADDRESS Start
,
2834 IN UINT64 NumberOfPages
,
2835 IN UINT64 NewAttributes
2839 Initialize PropertiesTable support.
2843 CoreInitializePropertiesTable (
2848 Initialize MemoryAttrubutesTable support.
2852 CoreInitializeMemoryAttributesTable (
2857 Initialize Memory Protection support.
2861 CoreInitializeMemoryProtection (
2866 Install MemoryAttributesTable on memory allocation.
2868 @param[in] MemoryType EFI memory type.
2871 InstallMemoryAttributesTableOnMemoryAllocation (
2872 IN EFI_MEMORY_TYPE MemoryType
2876 Insert image record.
2878 @param RuntimeImage Runtime image information
2882 IN EFI_RUNTIME_IMAGE_ENTRY
*RuntimeImage
2886 Remove Image record.
2888 @param RuntimeImage Runtime image information
2892 IN EFI_RUNTIME_IMAGE_ENTRY
*RuntimeImage
2898 @param[in] LoadedImage The loaded image protocol
2899 @param[in] LoadedImageDevicePath The loaded image device path protocol
2903 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
,
2904 IN EFI_DEVICE_PATH_PROTOCOL
*LoadedImageDevicePath
2908 Unprotect UEFI image.
2910 @param[in] LoadedImage The loaded image protocol
2911 @param[in] LoadedImageDevicePath The loaded image device path protocol
2914 UnprotectUefiImage (
2915 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
,
2916 IN EFI_DEVICE_PATH_PROTOCOL
*LoadedImageDevicePath
2920 ExitBootServices Callback function for memory protection.
2923 MemoryProtectionExitBootServicesCallback (
2928 Manage memory permission attributes on a memory range, according to the
2929 configured DXE memory protection policy.
2931 @param OldType The old memory type of the range
2932 @param NewType The new memory type of the range
2933 @param Memory The base address of the range
2934 @param Length The size of the range (in bytes)
2936 @return EFI_SUCCESS If the the CPU arch protocol is not installed yet
2937 @return EFI_SUCCESS If no DXE memory protection policy has been configured
2938 @return EFI_SUCCESS If OldType and NewType use the same permission attributes
2939 @return other Return value of gCpu->SetMemoryAttributes()
2944 ApplyMemoryProtectionPolicy (
2945 IN EFI_MEMORY_TYPE OldType
,
2946 IN EFI_MEMORY_TYPE NewType
,
2947 IN EFI_PHYSICAL_ADDRESS Memory
,
2952 Merge continous memory map entries whose have same attributes.
2954 @param MemoryMap A pointer to the buffer in which firmware places
2955 the current memory map.
2956 @param MemoryMapSize A pointer to the size, in bytes, of the
2957 MemoryMap buffer. On input, this is the size of
2958 the current memory map. On output,
2959 it is the size of new memory map after merge.
2960 @param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
2964 IN OUT EFI_MEMORY_DESCRIPTOR
*MemoryMap
,
2965 IN OUT UINTN
*MemoryMapSize
,
2966 IN UINTN DescriptorSize