2 The internal header file includes the common header files, defines
3 internal structure and functions used by DxeCore module.
5 Copyright (c) 2006 - 2013, 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>
73 #include <Library/DxeCoreEntryPoint.h>
74 #include <Library/DebugLib.h>
75 #include <Library/UefiLib.h>
76 #include <Library/BaseLib.h>
77 #include <Library/HobLib.h>
78 #include <Library/PerformanceLib.h>
79 #include <Library/UefiDecompressLib.h>
80 #include <Library/ExtractGuidedSectionLib.h>
81 #include <Library/CacheMaintenanceLib.h>
82 #include <Library/BaseMemoryLib.h>
83 #include <Library/PeCoffLib.h>
84 #include <Library/PeCoffGetEntryPointLib.h>
85 #include <Library/PeCoffExtraActionLib.h>
86 #include <Library/PcdLib.h>
87 #include <Library/MemoryAllocationLib.h>
88 #include <Library/DevicePathLib.h>
89 #include <Library/UefiBootServicesTableLib.h>
90 #include <Library/ReportStatusCodeLib.h>
91 #include <Library/TimerLib.h>
92 #include <Library/DxeServicesLib.h>
93 #include <Library/DebugAgentLib.h>
94 #include <Library/CpuExceptionHandlerLib.h>
98 // attributes for reserved memory before it is promoted to system memory
100 #define EFI_MEMORY_PRESENT 0x0100000000000000ULL
101 #define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL
102 #define EFI_MEMORY_TESTED 0x0400000000000000ULL
105 // range for memory mapped port I/O on IPF
107 #define EFI_MEMORY_PORT_IO 0x4000000000000000ULL
111 /// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependecy expression
112 /// to save time. A EFI_DEP_PUSH is evauated one an
113 /// replaced with EFI_DEP_REPLACE_TRUE. If PI spec's Vol 2
114 /// Driver Execution Environment Core Interface use 0xff
115 /// as new DEPEX opcode. EFI_DEP_REPLACE_TRUE should be
116 /// defined to a new value that is not conflicting with PI spec.
118 #define EFI_DEP_REPLACE_TRUE 0xff
121 /// Define the initial size of the dependency expression evaluation stack
123 #define DEPEX_STACK_SIZE_INCREMENT 0x1000
126 EFI_GUID
*ProtocolGuid
;
131 } EFI_CORE_PROTOCOL_NOTIFY_ENTRY
;
134 // DXE Dispatcher Data structures
137 #define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w')
140 LIST_ENTRY Link
; // mFvHandleList
146 #define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r')
149 LIST_ENTRY Link
; // mDriverList
151 LIST_ENTRY ScheduledLink
; // mScheduledQueue
155 EFI_DEVICE_PATH_PROTOCOL
*FvFileDevicePath
;
156 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
163 EFI_GUID BeforeAfterGuid
;
170 BOOLEAN DepexProtocolError
;
172 EFI_HANDLE ImageHandle
;
175 } EFI_CORE_DRIVER_ENTRY
;
178 //The data structure of GCD memory map entry
180 #define EFI_GCD_MAP_SIGNATURE SIGNATURE_32('g','c','d','m')
184 EFI_PHYSICAL_ADDRESS BaseAddress
;
188 EFI_GCD_MEMORY_TYPE GcdMemoryType
;
189 EFI_GCD_IO_TYPE GcdIoType
;
190 EFI_HANDLE ImageHandle
;
191 EFI_HANDLE DeviceHandle
;
195 // DXE Core Global Variables
197 extern EFI_SYSTEM_TABLE
*gDxeCoreST
;
198 extern EFI_RUNTIME_SERVICES
*gDxeCoreRT
;
199 extern EFI_DXE_SERVICES
*gDxeCoreDS
;
200 extern EFI_HANDLE gDxeCoreImageHandle
;
202 extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress
;
204 extern EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
;
205 extern EFI_CPU_ARCH_PROTOCOL
*gCpu
;
206 extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL
*gWatchdogTimer
;
207 extern EFI_METRONOME_ARCH_PROTOCOL
*gMetronome
;
208 extern EFI_TIMER_ARCH_PROTOCOL
*gTimer
;
209 extern EFI_SECURITY_ARCH_PROTOCOL
*gSecurity
;
210 extern EFI_SECURITY2_ARCH_PROTOCOL
*gSecurity2
;
211 extern EFI_BDS_ARCH_PROTOCOL
*gBds
;
212 extern EFI_SMM_BASE2_PROTOCOL
*gSmmBase2
;
214 extern EFI_TPL gEfiCurrentTpl
;
216 extern EFI_GUID
*gDxeCoreFileName
;
217 extern EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
219 extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation
[EfiMaxMemoryType
+ 1];
221 extern BOOLEAN gDispatcherRunning
;
222 extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
;
224 extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable
;
225 extern BOOLEAN gLoadFixedAddressCodeMemoryReady
;
227 // Service Initialization Functions
233 Called to initialize the pool.
243 Called to initialize the memory map and add descriptors to
244 the current descriptor list.
245 The first descriptor that is added must be general usable
246 memory as the addition allocates heap.
248 @param Type The type of memory to add
249 @param Start The starting address in the memory range Must be
251 @param NumberOfPages The number of pages in the range
252 @param Attribute Attributes of the memory to add
254 @return None. The range is added to the memory map
258 CoreAddMemoryDescriptor (
259 IN EFI_MEMORY_TYPE Type
,
260 IN EFI_PHYSICAL_ADDRESS Start
,
261 IN UINT64 NumberOfPages
,
267 Release memory lock on mGcdMemorySpaceLock.
271 CoreReleaseGcdMemoryLock (
277 Acquire memory lock on mGcdMemorySpaceLock.
281 CoreAcquireGcdMemoryLock (
287 External function. Initializes memory services based on the memory
288 descriptor HOBs. This function is responsible for priming the memory
289 map, so memory allocations and resource allocations can be made.
290 The first part of this function can not depend on any memory services
291 until at least one memory descriptor is provided to the memory services.
293 @param HobStart The start address of the HOB.
294 @param MemoryBaseAddress Start address of memory region found to init DXE
296 @param MemoryLength Length of memory region found to init DXE core.
298 @retval EFI_SUCCESS Memory services successfully initialized.
302 CoreInitializeMemoryServices (
304 OUT EFI_PHYSICAL_ADDRESS
*MemoryBaseAddress
,
305 OUT UINT64
*MemoryLength
311 External function. Initializes the GCD and memory services based on the memory
312 descriptor HOBs. This function is responsible for priming the GCD map and the
313 memory map, so memory allocations and resource allocations can be made. The
314 HobStart will be relocated to a pool buffer.
316 @param HobStart The start address of the HOB
317 @param MemoryBaseAddress Start address of memory region found to init DXE
319 @param MemoryLength Length of memory region found to init DXE core.
321 @retval EFI_SUCCESS GCD services successfully initialized.
325 CoreInitializeGcdServices (
326 IN OUT VOID
**HobStart
,
327 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress
,
328 IN UINT64 MemoryLength
333 Initializes "event" support.
335 @retval EFI_SUCCESS Always return success
339 CoreInitializeEventServices (
345 Add the Image Services to EFI Boot Services Table and install the protocol
346 interfaces for this image.
348 @param HobStart The HOB to initialize
354 CoreInitializeImageServices (
360 Creates an event that is fired everytime a Protocol of a specific type is installed.
364 CoreNotifyOnProtocolInstallation (
370 Return TRUE if all AP services are availible.
372 @retval EFI_SUCCESS All AP services are available
373 @retval EFI_NOT_FOUND At least one AP service is not available
377 CoreAllEfiServicesAvailable (
383 Calcualte the 32-bit CRC in a EFI table using the service provided by the
386 @param Hdr Pointer to an EFI standard header
391 IN OUT EFI_TABLE_HEADER
*Hdr
396 Called by the platform code to process a tick.
398 @param Duration The number of 100ns elasped since the last call
410 Initialize the dispatcher. Initialize the notification function that runs when
411 an FV2 protocol is added to the system.
415 CoreInitializeDispatcher (
421 This is the POSTFIX version of the dependency evaluator. This code does
422 not need to handle Before or After, as it is not valid to call this
423 routine in this case. The SOR is just ignored and is a nop in the grammer.
424 POSTFIX means all the math is done on top of the stack.
426 @param DriverEntry DriverEntry element to update.
428 @retval TRUE If driver is ready to run.
429 @retval FALSE If driver is not ready to run or some fatal error
435 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
440 Preprocess dependency expression and update DriverEntry to reflect the
441 state of Before, After, and SOR dependencies. If DriverEntry->Before
442 or DriverEntry->After is set it will never be cleared. If SOR is set
443 it will be cleared by CoreSchedule(), and then the driver can be
446 @param DriverEntry DriverEntry element to update .
448 @retval EFI_SUCCESS It always works.
452 CorePreProcessDepex (
453 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
459 Terminates all boot services.
461 @param ImageHandle Handle that identifies the exiting image.
462 @param MapKey Key to the latest memory map.
464 @retval EFI_SUCCESS Boot Services terminated
465 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
470 CoreExitBootServices (
471 IN EFI_HANDLE ImageHandle
,
477 Make sure the memory map is following all the construction rules,
478 it is the last time to check memory map error before exit boot services.
480 @param MapKey Memory map key
482 @retval EFI_INVALID_PARAMETER Memory map not consistent with construction
484 @retval EFI_SUCCESS Valid memory map.
488 CoreTerminateMemoryMap (
494 Signals all events in the EventGroup.
496 @param EventGroup The list to signal
500 CoreNotifySignalList (
501 IN EFI_GUID
*EventGroup
507 Boot Service called to add, modify, or remove a system configuration table from
508 the EFI System Table.
510 @param Guid Pointer to the GUID for the entry to add, update, or
512 @param Table Pointer to the configuration table for the entry to add,
513 update, or remove, may be NULL.
515 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.
516 @return EFI_INVALID_PARAMETER Input GUID not valid.
517 @return EFI_NOT_FOUND Attempted to delete non-existant entry
518 @return EFI_OUT_OF_RESOURCES Not enough memory available
523 CoreInstallConfigurationTable (
531 Raise the task priority level to the new level.
532 High level is implemented by disabling processor interrupts.
534 @param NewTpl New task priority level
536 @return The previous task priority level
548 Lowers the task priority to the previous value. If the new
549 priority unmasks events at a higher priority, they are dispatched.
551 @param NewTpl New, lower, task priority
563 Introduces a fine-grained stall.
565 @param Microseconds The number of microseconds to stall execution.
567 @retval EFI_SUCCESS Execution was stalled for at least the requested
568 amount of microseconds.
569 @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet
575 IN UINTN Microseconds
581 Sets the system's watchdog timer.
583 @param Timeout The number of seconds to set the watchdog timer to.
584 A value of zero disables the timer.
585 @param WatchdogCode The numeric code to log on a watchdog timer timeout
586 event. The firmware reserves codes 0x0000 to 0xFFFF.
587 Loaders and operating systems may use other timeout
589 @param DataSize The size, in bytes, of WatchdogData.
590 @param WatchdogData A data buffer that includes a Null-terminated Unicode
591 string, optionally followed by additional binary data.
592 The string is a description that the call may use to
593 further indicate the reason to be logged with a
596 @return EFI_SUCCESS Timeout has been set
597 @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
598 @return EFI_UNSUPPORTED System does not have a timer (currently not used)
599 @return EFI_DEVICE_ERROR Could not complete due to hardware error
604 CoreSetWatchdogTimer (
606 IN UINT64 WatchdogCode
,
608 IN CHAR16
*WatchdogData OPTIONAL
614 Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
615 Calls the private one which contains a BOOLEAN parameter for notifications
617 @param UserHandle The handle to install the protocol handler on,
618 or NULL if a new handle is to be allocated
619 @param Protocol The protocol to add to the handle
620 @param InterfaceType Indicates whether Interface is supplied in
622 @param Interface The interface for the protocol being added
629 CoreInstallProtocolInterface (
630 IN OUT EFI_HANDLE
*UserHandle
,
631 IN EFI_GUID
*Protocol
,
632 IN EFI_INTERFACE_TYPE InterfaceType
,
638 Installs a protocol interface into the boot services environment.
640 @param UserHandle The handle to install the protocol handler on,
641 or NULL if a new handle is to be allocated
642 @param Protocol The protocol to add to the handle
643 @param InterfaceType Indicates whether Interface is supplied in
645 @param Interface The interface for the protocol being added
646 @param Notify indicates whether notify the notification list
649 @retval EFI_INVALID_PARAMETER Invalid parameter
650 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
651 @retval EFI_SUCCESS Protocol interface successfully installed
655 CoreInstallProtocolInterfaceNotify (
656 IN OUT EFI_HANDLE
*UserHandle
,
657 IN EFI_GUID
*Protocol
,
658 IN EFI_INTERFACE_TYPE InterfaceType
,
666 Installs a list of protocol interface into the boot services environment.
667 This function calls InstallProtocolInterface() in a loop. If any error
668 occures all the protocols added by this function are removed. This is
669 basically a lib function to save space.
671 @param Handle The handle to install the protocol handlers on,
672 or NULL if a new handle is to be allocated
673 @param ... EFI_GUID followed by protocol instance. A NULL
674 terminates the list. The pairs are the
675 arguments to InstallProtocolInterface(). All the
676 protocols are added to Handle.
678 @retval EFI_SUCCESS All the protocol interface was installed.
679 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
680 @retval EFI_ALREADY_STARTED A Device Path Protocol instance was passed in that is already present in
682 @retval EFI_INVALID_PARAMETER Handle is NULL.
683 @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.
688 CoreInstallMultipleProtocolInterfaces (
689 IN OUT EFI_HANDLE
*Handle
,
696 Uninstalls a list of protocol interface in the boot services environment.
697 This function calls UnisatllProtocolInterface() in a loop. This is
698 basically a lib function to save space.
700 @param Handle The handle to uninstall the protocol
701 @param ... EFI_GUID followed by protocol instance. A NULL
702 terminates the list. The pairs are the
703 arguments to UninstallProtocolInterface(). All
704 the protocols are added to Handle.
711 CoreUninstallMultipleProtocolInterfaces (
712 IN EFI_HANDLE Handle
,
719 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
721 @param UserHandle Handle on which the interface is to be
723 @param Protocol The numeric ID of the interface
724 @param OldInterface A pointer to the old interface
725 @param NewInterface A pointer to the new interface
727 @retval EFI_SUCCESS The protocol interface was installed
728 @retval EFI_NOT_FOUND The OldInterface on the handle was not found
729 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
734 CoreReinstallProtocolInterface (
735 IN EFI_HANDLE UserHandle
,
736 IN EFI_GUID
*Protocol
,
737 IN VOID
*OldInterface
,
738 IN VOID
*NewInterface
744 Uninstalls all instances of a protocol:interfacer from a handle.
745 If the last protocol interface is remove from the handle, the
748 @param UserHandle The handle to remove the protocol handler from
749 @param Protocol The protocol, of protocol:interface, to remove
750 @param Interface The interface, of protocol:interface, to remove
752 @retval EFI_INVALID_PARAMETER Protocol is NULL.
753 @retval EFI_SUCCESS Protocol interface successfully uninstalled.
758 CoreUninstallProtocolInterface (
759 IN EFI_HANDLE UserHandle
,
760 IN EFI_GUID
*Protocol
,
767 Queries a handle to determine if it supports a specified protocol.
769 @param UserHandle The handle being queried.
770 @param Protocol The published unique identifier of the protocol.
771 @param Interface Supplies the address where a pointer to the
772 corresponding Protocol Interface is returned.
774 @return The requested protocol interface for the handle
780 IN EFI_HANDLE UserHandle
,
781 IN EFI_GUID
*Protocol
,
788 Locates the installed protocol handler for the handle, and
789 invokes it to obtain the protocol interface. Usage information
790 is registered in the protocol data base.
792 @param UserHandle The handle to obtain the protocol interface on
793 @param Protocol The ID of the protocol
794 @param Interface The location to return the protocol interface
795 @param ImageHandle The handle of the Image that is opening the
796 protocol interface specified by Protocol and
798 @param ControllerHandle The controller handle that is requiring this
800 @param Attributes The open mode of the protocol interface
801 specified by Handle and Protocol.
803 @retval EFI_INVALID_PARAMETER Protocol is NULL.
804 @retval EFI_SUCCESS Get the protocol interface.
810 IN EFI_HANDLE UserHandle
,
811 IN EFI_GUID
*Protocol
,
812 OUT VOID
**Interface OPTIONAL
,
813 IN EFI_HANDLE ImageHandle
,
814 IN EFI_HANDLE ControllerHandle
,
821 Return information about Opened protocols in the system
823 @param UserHandle The handle to close the protocol interface on
824 @param Protocol The ID of the protocol
825 @param EntryBuffer A pointer to a buffer of open protocol
826 information in the form of
827 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
828 @param EntryCount Number of EntryBuffer entries
833 CoreOpenProtocolInformation (
834 IN EFI_HANDLE UserHandle
,
835 IN EFI_GUID
*Protocol
,
836 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
**EntryBuffer
,
837 OUT UINTN
*EntryCount
843 Closes a protocol on a handle that was opened using OpenProtocol().
845 @param UserHandle The handle for the protocol interface that was
846 previously opened with OpenProtocol(), and is
848 @param Protocol The published unique identifier of the protocol.
849 It is the caller's responsibility to pass in a
851 @param AgentHandle The handle of the agent that is closing the
853 @param ControllerHandle If the agent that opened a protocol is a driver
854 that follows the EFI Driver Model, then this
855 parameter is the controller handle that required
856 the protocol interface. If the agent does not
857 follow the EFI Driver Model, then this parameter
858 is optional and may be NULL.
860 @retval EFI_SUCCESS The protocol instance was closed.
861 @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a
863 @retval EFI_NOT_FOUND Can not find the specified protocol or
870 IN EFI_HANDLE UserHandle
,
871 IN EFI_GUID
*Protocol
,
872 IN EFI_HANDLE AgentHandle
,
873 IN EFI_HANDLE ControllerHandle
879 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
882 @param UserHandle The handle from which to retrieve the list of
883 protocol interface GUIDs.
884 @param ProtocolBuffer A pointer to the list of protocol interface GUID
885 pointers that are installed on Handle.
886 @param ProtocolBufferCount A pointer to the number of GUID pointers present
889 @retval EFI_SUCCESS The list of protocol interface GUIDs installed
890 on Handle was returned in ProtocolBuffer. The
891 number of protocol interface GUIDs was returned
892 in ProtocolBufferCount.
893 @retval EFI_INVALID_PARAMETER Handle is NULL.
894 @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
895 @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.
896 @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.
897 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
903 CoreProtocolsPerHandle (
904 IN EFI_HANDLE UserHandle
,
905 OUT EFI_GUID
***ProtocolBuffer
,
906 OUT UINTN
*ProtocolBufferCount
912 Add a new protocol notification record for the request protocol.
914 @param Protocol The requested protocol to add the notify
916 @param Event The event to signal
917 @param Registration Returns the registration record
919 @retval EFI_INVALID_PARAMETER Invalid parameter
920 @retval EFI_SUCCESS Successfully returned the registration record
926 CoreRegisterProtocolNotify (
927 IN EFI_GUID
*Protocol
,
929 OUT VOID
**Registration
934 Removes all the events in the protocol database that match Event.
936 @param Event The event to search for in the protocol
939 @return EFI_SUCCESS when done searching the entire database.
943 CoreUnregisterProtocolNotify (
949 Locates the requested handle(s) and returns them in Buffer.
951 @param SearchType The type of search to perform to locate the
953 @param Protocol The protocol to search for
954 @param SearchKey Dependant on SearchType
955 @param BufferSize On input the size of Buffer. On output the
956 size of data returned.
957 @param Buffer The buffer to return the results in
959 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
960 returned in BufferSize.
961 @retval EFI_INVALID_PARAMETER Invalid parameter
962 @retval EFI_SUCCESS Successfully found the requested handle(s) and
963 returns them in Buffer.
969 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
970 IN EFI_GUID
*Protocol OPTIONAL
,
971 IN VOID
*SearchKey OPTIONAL
,
972 IN OUT UINTN
*BufferSize
,
973 OUT EFI_HANDLE
*Buffer
979 Locates the handle to a device on the device path that best matches the specified protocol.
981 @param Protocol The protocol to search for.
982 @param DevicePath On input, a pointer to a pointer to the device
983 path. On output, the device path pointer is
984 modified to point to the remaining part of the
986 @param Device A pointer to the returned device handle.
988 @retval EFI_SUCCESS The resulting handle was returned.
989 @retval EFI_NOT_FOUND No handles matched the search.
990 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
995 CoreLocateDevicePath (
996 IN EFI_GUID
*Protocol
,
997 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
998 OUT EFI_HANDLE
*Device
1004 Function returns an array of handles that support the requested protocol
1005 in a buffer allocated from pool. This is a version of CoreLocateHandle()
1006 that allocates a buffer for the caller.
1008 @param SearchType Specifies which handle(s) are to be returned.
1009 @param Protocol Provides the protocol to search by. This
1010 parameter is only valid for SearchType
1012 @param SearchKey Supplies the search key depending on the
1014 @param NumberHandles The number of handles returned in Buffer.
1015 @param Buffer A pointer to the buffer to return the requested
1016 array of handles that support Protocol.
1018 @retval EFI_SUCCESS The result array of handles was returned.
1019 @retval EFI_NOT_FOUND No handles match the search.
1020 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
1022 @retval EFI_INVALID_PARAMETER One or more paramters are not valid.
1027 CoreLocateHandleBuffer (
1028 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1029 IN EFI_GUID
*Protocol OPTIONAL
,
1030 IN VOID
*SearchKey OPTIONAL
,
1031 IN OUT UINTN
*NumberHandles
,
1032 OUT EFI_HANDLE
**Buffer
1038 Return the first Protocol Interface that matches the Protocol GUID. If
1039 Registration is passed in, return a Protocol Instance that was just add
1040 to the system. If Registration is NULL return the first Protocol Interface
1043 @param Protocol The protocol to search for
1044 @param Registration Optional Registration Key returned from
1045 RegisterProtocolNotify()
1046 @param Interface Return the Protocol interface (instance).
1048 @retval EFI_SUCCESS If a valid Interface is returned
1049 @retval EFI_INVALID_PARAMETER Invalid parameter
1050 @retval EFI_NOT_FOUND Protocol interface not found
1055 CoreLocateProtocol (
1056 IN EFI_GUID
*Protocol
,
1057 IN VOID
*Registration OPTIONAL
,
1058 OUT VOID
**Interface
1063 return handle database key.
1066 @return Handle database key.
1070 CoreGetHandleDatabaseKey (
1076 Go connect any handles that were created or modified while a image executed.
1078 @param Key The Key to show that the handle has been
1083 CoreConnectHandlesByKey (
1090 Connects one or more drivers to a controller.
1092 @param ControllerHandle The handle of the controller to which driver(s) are to be connected.
1093 @param DriverImageHandle A pointer to an ordered list handles that support the
1094 EFI_DRIVER_BINDING_PROTOCOL.
1095 @param RemainingDevicePath A pointer to the device path that specifies a child of the
1096 controller specified by ControllerHandle.
1097 @param Recursive If TRUE, then ConnectController() is called recursively
1098 until the entire tree of controllers below the controller specified
1099 by ControllerHandle have been created. If FALSE, then
1100 the tree of controllers is only expanded one level.
1102 @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.
1103 2) No drivers were connected to ControllerHandle, but
1104 RemainingDevicePath is not NULL, and it is an End Device
1106 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1107 @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
1108 present in the system.
1109 2) No drivers were connected to ControllerHandle.
1110 @retval EFI_SECURITY_VIOLATION
1111 The user has no permission to start UEFI device drivers on the device path
1112 associated with the ControllerHandle or specified by the RemainingDevicePath.
1117 CoreConnectController (
1118 IN EFI_HANDLE ControllerHandle
,
1119 IN EFI_HANDLE
*DriverImageHandle OPTIONAL
,
1120 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
1121 IN BOOLEAN Recursive
1127 Disonnects a controller from a driver
1129 @param ControllerHandle ControllerHandle The handle of
1130 the controller from which
1133 @param DriverImageHandle DriverImageHandle The driver to
1134 disconnect from ControllerHandle.
1135 @param ChildHandle ChildHandle The handle of the
1138 @retval EFI_SUCCESS One or more drivers were
1139 disconnected from the controller.
1140 @retval EFI_SUCCESS On entry, no drivers are managing
1142 @retval EFI_SUCCESS DriverImageHandle is not NULL,
1143 and on entry DriverImageHandle is
1144 not managing ControllerHandle.
1145 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1146 @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
1147 and it is not a valid EFI_HANDLE.
1148 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
1149 is not a valid EFI_HANDLE.
1150 @retval EFI_OUT_OF_RESOURCES There are not enough resources
1151 available to disconnect any
1152 drivers from ControllerHandle.
1153 @retval EFI_DEVICE_ERROR The controller could not be
1154 disconnected because of a device
1160 CoreDisconnectController (
1161 IN EFI_HANDLE ControllerHandle
,
1162 IN EFI_HANDLE DriverImageHandle OPTIONAL
,
1163 IN EFI_HANDLE ChildHandle OPTIONAL
1169 Allocates pages from the memory map.
1171 @param Type The type of allocation to perform
1172 @param MemoryType The type of memory to turn the allocated pages
1174 @param NumberOfPages The number of pages to allocate
1175 @param Memory A pointer to receive the base allocated memory
1178 @return Status. On success, Memory is filled in with the base address allocated
1179 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
1181 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
1182 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
1183 @retval EFI_SUCCESS Pages successfully allocated.
1189 IN EFI_ALLOCATE_TYPE Type
,
1190 IN EFI_MEMORY_TYPE MemoryType
,
1191 IN UINTN NumberOfPages
,
1192 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
1198 Frees previous allocated pages.
1200 @param Memory Base address of memory being freed
1201 @param NumberOfPages The number of pages to free
1203 @retval EFI_NOT_FOUND Could not find the entry that covers the range
1204 @retval EFI_INVALID_PARAMETER Address not aligned
1205 @return EFI_SUCCESS -Pages successfully freed.
1211 IN EFI_PHYSICAL_ADDRESS Memory
,
1212 IN UINTN NumberOfPages
1218 This function returns a copy of the current memory map. The map is an array of
1219 memory descriptors, each of which describes a contiguous block of memory.
1221 @param MemoryMapSize A pointer to the size, in bytes, of the
1222 MemoryMap buffer. On input, this is the size of
1223 the buffer allocated by the caller. On output,
1224 it is the size of the buffer returned by the
1225 firmware if the buffer was large enough, or the
1226 size of the buffer needed to contain the map if
1227 the buffer was too small.
1228 @param MemoryMap A pointer to the buffer in which firmware places
1229 the current memory map.
1230 @param MapKey A pointer to the location in which firmware
1231 returns the key for the current memory map.
1232 @param DescriptorSize A pointer to the location in which firmware
1233 returns the size, in bytes, of an individual
1234 EFI_MEMORY_DESCRIPTOR.
1235 @param DescriptorVersion A pointer to the location in which firmware
1236 returns the version number associated with the
1237 EFI_MEMORY_DESCRIPTOR.
1239 @retval EFI_SUCCESS The memory map was returned in the MemoryMap
1241 @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
1242 buffer size needed to hold the memory map is
1243 returned in MemoryMapSize.
1244 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1250 IN OUT UINTN
*MemoryMapSize
,
1251 IN OUT EFI_MEMORY_DESCRIPTOR
*MemoryMap
,
1253 OUT UINTN
*DescriptorSize
,
1254 OUT UINT32
*DescriptorVersion
1260 Allocate pool of a particular type.
1262 @param PoolType Type of pool to allocate
1263 @param Size The amount of pool to allocate
1264 @param Buffer The address to return a pointer to the allocated
1267 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
1268 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
1269 @retval EFI_SUCCESS Pool successfully allocated.
1275 IN EFI_MEMORY_TYPE PoolType
,
1285 @param Buffer The allocated pool entry to free
1287 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
1288 @retval EFI_SUCCESS Pool successfully freed.
1300 Loads an EFI image into memory and returns a handle to the image.
1302 @param BootPolicy If TRUE, indicates that the request originates
1303 from the boot manager, and that the boot
1304 manager is attempting to load FilePath as a
1306 @param ParentImageHandle The caller's image handle.
1307 @param FilePath The specific file path from which the image is
1309 @param SourceBuffer If not NULL, a pointer to the memory location
1310 containing a copy of the image to be loaded.
1311 @param SourceSize The size in bytes of SourceBuffer.
1312 @param ImageHandle Pointer to the returned image handle that is
1313 created when the image is successfully loaded.
1315 @retval EFI_SUCCESS The image was loaded into memory.
1316 @retval EFI_NOT_FOUND The FilePath was not found.
1317 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1318 @retval EFI_UNSUPPORTED The image type is not supported, or the device
1319 path cannot be parsed to locate the proper
1320 protocol for loading the file.
1321 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
1323 @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
1325 @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
1326 @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
1327 image from being loaded. NULL is returned in *ImageHandle.
1328 @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
1329 valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
1330 platform policy specifies that the image should not be started.
1336 IN BOOLEAN BootPolicy
,
1337 IN EFI_HANDLE ParentImageHandle
,
1338 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
1339 IN VOID
*SourceBuffer OPTIONAL
,
1340 IN UINTN SourceSize
,
1341 OUT EFI_HANDLE
*ImageHandle
1349 @param ImageHandle Handle that identifies the image to be
1352 @retval EFI_SUCCESS The image has been unloaded.
1353 @retval EFI_UNSUPPORTED The image has been sarted, and does not support
1355 @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
1361 IN EFI_HANDLE ImageHandle
1367 Transfer control to a loaded image's entry point.
1369 @param ImageHandle Handle of image to be started.
1370 @param ExitDataSize Pointer of the size to ExitData
1371 @param ExitData Pointer to a pointer to a data buffer that
1372 includes a Null-terminated string,
1373 optionally followed by additional binary data.
1374 The string is a description that the caller may
1375 use to further indicate the reason for the
1378 @retval EFI_INVALID_PARAMETER Invalid parameter
1379 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1380 @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
1381 @retval EFI_SUCCESS Successfully transfer control to the image's
1388 IN EFI_HANDLE ImageHandle
,
1389 OUT UINTN
*ExitDataSize
,
1390 OUT CHAR16
**ExitData OPTIONAL
1396 Terminates the currently loaded EFI image and returns control to boot services.
1398 @param ImageHandle Handle that identifies the image. This
1399 parameter is passed to the image on entry.
1400 @param Status The image's exit code.
1401 @param ExitDataSize The size, in bytes, of ExitData. Ignored if
1402 ExitStatus is EFI_SUCCESS.
1403 @param ExitData Pointer to a data buffer that includes a
1404 Null-terminated Unicode string, optionally
1405 followed by additional binary data. The string
1406 is a description that the caller may use to
1407 further indicate the reason for the image's
1410 @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
1412 @retval EFI_SUCCESS Successfully terminates the currently loaded
1414 @retval EFI_ACCESS_DENIED Should never reach there.
1415 @retval EFI_OUT_OF_RESOURCES Could not allocate pool
1421 IN EFI_HANDLE ImageHandle
,
1422 IN EFI_STATUS Status
,
1423 IN UINTN ExitDataSize
,
1424 IN CHAR16
*ExitData OPTIONAL
1432 @param Type The type of event to create and its mode and
1434 @param NotifyTpl The task priority level of event notifications
1435 @param NotifyFunction Pointer to the events notification function
1436 @param NotifyContext Pointer to the notification functions context;
1437 corresponds to parameter "Context" in the
1438 notification function
1439 @param Event Pointer to the newly created event if the call
1440 succeeds; undefined otherwise
1442 @retval EFI_SUCCESS The event structure was created
1443 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1444 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1451 IN EFI_TPL NotifyTpl
,
1452 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1453 IN VOID
*NotifyContext
, OPTIONAL
1454 OUT EFI_EVENT
*Event
1460 Creates an event in a group.
1462 @param Type The type of event to create and its mode and
1464 @param NotifyTpl The task priority level of event notifications
1465 @param NotifyFunction Pointer to the events notification function
1466 @param NotifyContext Pointer to the notification functions context;
1467 corresponds to parameter "Context" in the
1468 notification function
1469 @param EventGroup GUID for EventGroup if NULL act the same as
1471 @param Event Pointer to the newly created event if the call
1472 succeeds; undefined otherwise
1474 @retval EFI_SUCCESS The event structure was created
1475 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1476 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1483 IN EFI_TPL NotifyTpl
,
1484 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1485 IN CONST VOID
*NotifyContext
, OPTIONAL
1486 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1487 OUT EFI_EVENT
*Event
1491 Creates a general-purpose event structure
1493 @param Type The type of event to create and its mode and
1495 @param NotifyTpl The task priority level of event notifications
1496 @param NotifyFunction Pointer to the events notification function
1497 @param NotifyContext Pointer to the notification functions context;
1498 corresponds to parameter "Context" in the
1499 notification function
1500 @param EventGroup GUID for EventGroup if NULL act the same as
1502 @param Event Pointer to the newly created event if the call
1503 succeeds; undefined otherwise
1505 @retval EFI_SUCCESS The event structure was created
1506 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1507 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1512 CoreCreateEventInternal (
1514 IN EFI_TPL NotifyTpl
,
1515 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1516 IN CONST VOID
*NotifyContext
, OPTIONAL
1517 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1518 OUT EFI_EVENT
*Event
1522 Sets the type of timer and the trigger time for a timer event.
1524 @param UserEvent The timer event that is to be signaled at the
1526 @param Type The type of time that is specified in
1528 @param TriggerTime The number of 100ns units until the timer
1531 @retval EFI_SUCCESS The event has been set to be signaled at the
1533 @retval EFI_INVALID_PARAMETER Event or Type is not valid
1539 IN EFI_EVENT UserEvent
,
1540 IN EFI_TIMER_DELAY Type
,
1541 IN UINT64 TriggerTime
1547 Signals the event. Queues the event to be notified if needed.
1549 @param UserEvent The event to signal .
1551 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1552 @retval EFI_SUCCESS The event was signaled.
1558 IN EFI_EVENT UserEvent
1564 Stops execution until an event is signaled.
1566 @param NumberOfEvents The number of events in the UserEvents array
1567 @param UserEvents An array of EFI_EVENT
1568 @param UserIndex Pointer to the index of the event which
1569 satisfied the wait condition
1571 @retval EFI_SUCCESS The event indicated by Index was signaled.
1572 @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification
1573 function or Event was not a valid type
1574 @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION
1580 IN UINTN NumberOfEvents
,
1581 IN EFI_EVENT
*UserEvents
,
1582 OUT UINTN
*UserIndex
1588 Closes an event and frees the event structure.
1590 @param UserEvent Event to close
1592 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1593 @retval EFI_SUCCESS The event has been closed
1599 IN EFI_EVENT UserEvent
1605 Check the status of an event.
1607 @param UserEvent The event to check
1609 @retval EFI_SUCCESS The event is in the signaled state
1610 @retval EFI_NOT_READY The event is not in the signaled state
1611 @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL
1617 IN EFI_EVENT UserEvent
1622 Adds reserved memory, system memory, or memory-mapped I/O resources to the
1623 global coherency domain of the processor.
1625 @param GcdMemoryType Memory type of the memory space.
1626 @param BaseAddress Base address of the memory space.
1627 @param Length Length of the memory space.
1628 @param Capabilities alterable attributes of the memory space.
1630 @retval EFI_SUCCESS Merged this memory space into GCD map.
1635 CoreAddMemorySpace (
1636 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1637 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1639 IN UINT64 Capabilities
1644 Allocates nonexistent memory, reserved memory, system memory, or memorymapped
1645 I/O resources from the global coherency domain of the processor.
1647 @param GcdAllocateType The type of allocate operation
1648 @param GcdMemoryType The desired memory type
1649 @param Alignment Align with 2^Alignment
1650 @param Length Length to allocate
1651 @param BaseAddress Base address to allocate
1652 @param ImageHandle The image handle consume the allocated space.
1653 @param DeviceHandle The device handle consume the allocated space.
1655 @retval EFI_INVALID_PARAMETER Invalid parameter.
1656 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1657 @retval EFI_SUCCESS Memory space successfully allocated.
1662 CoreAllocateMemorySpace (
1663 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1664 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1667 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1668 IN EFI_HANDLE ImageHandle
,
1669 IN EFI_HANDLE DeviceHandle OPTIONAL
1674 Frees nonexistent memory, reserved memory, system memory, or memory-mapped
1675 I/O resources from the global coherency domain of the processor.
1677 @param BaseAddress Base address of the memory space.
1678 @param Length Length of the memory space.
1680 @retval EFI_SUCCESS Space successfully freed.
1685 CoreFreeMemorySpace (
1686 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1692 Removes reserved memory, system memory, or memory-mapped I/O resources from
1693 the global coherency domain of the processor.
1695 @param BaseAddress Base address of the memory space.
1696 @param Length Length of the memory space.
1698 @retval EFI_SUCCESS Successfully remove a segment of memory space.
1703 CoreRemoveMemorySpace (
1704 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1710 Retrieves the descriptor for a memory region containing a specified address.
1712 @param BaseAddress Specified start address
1713 @param Descriptor Specified length
1715 @retval EFI_INVALID_PARAMETER Invalid parameter
1716 @retval EFI_SUCCESS Successfully get memory space descriptor.
1721 CoreGetMemorySpaceDescriptor (
1722 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1723 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*Descriptor
1728 Modifies the attributes for a memory region in the global coherency domain of the
1731 @param BaseAddress Specified start address
1732 @param Length Specified length
1733 @param Attributes Specified attributes
1735 @retval EFI_SUCCESS The attributes were set for the memory region.
1736 @retval EFI_INVALID_PARAMETER Length is zero.
1737 @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory
1738 resource range specified by BaseAddress and Length.
1739 @retval EFI_UNSUPPORTED The bit mask of attributes is not support for the memory resource
1740 range specified by BaseAddress and Length.
1741 @retval EFI_ACCESS_DEFINED The attributes for the memory resource range specified by
1742 BaseAddress and Length cannot be modified.
1743 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of
1744 the memory resource range.
1745 @retval EFI_NOT_AVAILABLE_YET The attributes cannot be set because CPU architectural protocol is
1751 CoreSetMemorySpaceAttributes (
1752 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1754 IN UINT64 Attributes
1759 Returns a map of the memory resources in the global coherency domain of the
1762 @param NumberOfDescriptors Number of descriptors.
1763 @param MemorySpaceMap Descriptor array
1765 @retval EFI_INVALID_PARAMETER Invalid parameter
1766 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1767 @retval EFI_SUCCESS Successfully get memory space map.
1772 CoreGetMemorySpaceMap (
1773 OUT UINTN
*NumberOfDescriptors
,
1774 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
**MemorySpaceMap
1779 Adds reserved I/O or I/O resources to the global coherency domain of the processor.
1781 @param GcdIoType IO type of the segment.
1782 @param BaseAddress Base address of the segment.
1783 @param Length Length of the segment.
1785 @retval EFI_SUCCESS Merged this segment into GCD map.
1786 @retval EFI_INVALID_PARAMETER Parameter not valid
1792 IN EFI_GCD_IO_TYPE GcdIoType
,
1793 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1799 Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1800 domain of the processor.
1802 @param GcdAllocateType The type of allocate operation
1803 @param GcdIoType The desired IO type
1804 @param Alignment Align with 2^Alignment
1805 @param Length Length to allocate
1806 @param BaseAddress Base address to allocate
1807 @param ImageHandle The image handle consume the allocated space.
1808 @param DeviceHandle The device handle consume the allocated space.
1810 @retval EFI_INVALID_PARAMETER Invalid parameter.
1811 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1812 @retval EFI_SUCCESS IO space successfully allocated.
1817 CoreAllocateIoSpace (
1818 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1819 IN EFI_GCD_IO_TYPE GcdIoType
,
1822 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1823 IN EFI_HANDLE ImageHandle
,
1824 IN EFI_HANDLE DeviceHandle OPTIONAL
1829 Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1830 domain of the processor.
1832 @param BaseAddress Base address of the segment.
1833 @param Length Length of the segment.
1835 @retval EFI_SUCCESS Space successfully freed.
1841 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1847 Removes reserved I/O or I/O resources from the global coherency domain of the
1850 @param BaseAddress Base address of the segment.
1851 @param Length Length of the segment.
1853 @retval EFI_SUCCESS Successfully removed a segment of IO space.
1859 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1865 Retrieves the descriptor for an I/O region containing a specified address.
1867 @param BaseAddress Specified start address
1868 @param Descriptor Specified length
1870 @retval EFI_INVALID_PARAMETER Descriptor is NULL.
1871 @retval EFI_SUCCESS Successfully get the IO space descriptor.
1876 CoreGetIoSpaceDescriptor (
1877 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1878 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
*Descriptor
1883 Returns a map of the I/O resources in the global coherency domain of the processor.
1885 @param NumberOfDescriptors Number of descriptors.
1886 @param IoSpaceMap Descriptor array
1888 @retval EFI_INVALID_PARAMETER Invalid parameter
1889 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1890 @retval EFI_SUCCESS Successfully get IO space map.
1896 OUT UINTN
*NumberOfDescriptors
,
1897 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
**IoSpaceMap
1902 This is the main Dispatcher for DXE and it exits when there are no more
1903 drivers to run. Drain the mScheduledQueue and load and start a PE
1904 image for each driver. Search the mDiscoveredList to see if any driver can
1905 be placed on the mScheduledQueue. If no drivers are placed on the
1906 mScheduledQueue exit the function. On exit it is assumed the Bds()
1907 will be called, and when the Bds() exits the Dispatcher will be called
1910 @retval EFI_ALREADY_STARTED The DXE Dispatcher is already running
1911 @retval EFI_NOT_FOUND No DXE Drivers were dispatched
1912 @retval EFI_SUCCESS One or more DXE Drivers were dispatched
1922 Check every driver and locate a matching one. If the driver is found, the Unrequested
1923 state flag is cleared.
1925 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1926 the firmware file specified by DriverName.
1927 @param DriverName The Driver name to put in the Dependent state.
1929 @retval EFI_SUCCESS The DriverName was found and it's SOR bit was
1931 @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was
1938 IN EFI_HANDLE FirmwareVolumeHandle
,
1939 IN EFI_GUID
*DriverName
1944 Convert a driver from the Untrused back to the Scheduled state.
1946 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1947 the firmware file specified by DriverName.
1948 @param DriverName The Driver name to put in the Scheduled state
1950 @retval EFI_SUCCESS The file was found in the untrusted state, and it
1951 was promoted to the trusted state.
1952 @retval EFI_NOT_FOUND The file was not found in the untrusted state.
1958 IN EFI_HANDLE FirmwareVolumeHandle
,
1959 IN EFI_GUID
*DriverName
1964 This routine is the driver initialization entry point. It initializes the
1965 libraries, and registers two notification functions. These notification
1966 functions are responsible for building the FV stack dynamically.
1968 @param ImageHandle The image handle.
1969 @param SystemTable The system table.
1971 @retval EFI_SUCCESS Function successfully returned.
1977 IN EFI_HANDLE ImageHandle
,
1978 IN EFI_SYSTEM_TABLE
*SystemTable
1983 Entry point of the section extraction code. Initializes an instance of the
1984 section extraction interface and installs it on a new handle.
1986 @param ImageHandle A handle for the image that is initializing this driver
1987 @param SystemTable A pointer to the EFI system table
1989 @retval EFI_SUCCESS Driver initialized successfully
1990 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
1995 InitializeSectionExtraction (
1996 IN EFI_HANDLE ImageHandle
,
1997 IN EFI_SYSTEM_TABLE
*SystemTable
2002 This DXE service routine is used to process a firmware volume. In
2003 particular, it can be called by BDS to process a single firmware
2004 volume found in a capsule.
2006 @param FvHeader pointer to a firmware volume header
2007 @param Size the size of the buffer pointed to by FvHeader
2008 @param FVProtocolHandle the handle on which a firmware volume protocol
2009 was produced for the firmware volume passed in.
2011 @retval EFI_OUT_OF_RESOURCES if an FVB could not be produced due to lack of
2013 @retval EFI_VOLUME_CORRUPTED if the volume was corrupted
2014 @retval EFI_SUCCESS a firmware volume protocol was produced for the
2020 CoreProcessFirmwareVolume (
2023 OUT EFI_HANDLE
*FVProtocolHandle
2027 //Functions used during debug buils
2031 Displays Architectural protocols that were not loaded and are required for DXE
2032 core to function. Only used in Debug Builds.
2036 CoreDisplayMissingArchProtocols (
2042 Traverse the discovered list for any drivers that were discovered but not loaded
2043 because the dependency experessions evaluated to false.
2047 CoreDisplayDiscoveredNotDispatched (
2053 Place holder function until all the Boot Services and Runtime Services are
2056 @return EFI_NOT_AVAILABLE_YET
2061 CoreEfiNotAvailableYetArg0 (
2067 Place holder function until all the Boot Services and Runtime Services are
2070 @param Arg1 Undefined
2072 @return EFI_NOT_AVAILABLE_YET
2077 CoreEfiNotAvailableYetArg1 (
2083 Place holder function until all the Boot Services and Runtime Services are available.
2085 @param Arg1 Undefined
2086 @param Arg2 Undefined
2088 @return EFI_NOT_AVAILABLE_YET
2093 CoreEfiNotAvailableYetArg2 (
2100 Place holder function until all the Boot Services and Runtime Services are available.
2102 @param Arg1 Undefined
2103 @param Arg2 Undefined
2104 @param Arg3 Undefined
2106 @return EFI_NOT_AVAILABLE_YET
2111 CoreEfiNotAvailableYetArg3 (
2119 Place holder function until all the Boot Services and Runtime Services are available.
2121 @param Arg1 Undefined
2122 @param Arg2 Undefined
2123 @param Arg3 Undefined
2124 @param Arg4 Undefined
2126 @return EFI_NOT_AVAILABLE_YET
2131 CoreEfiNotAvailableYetArg4 (
2140 Place holder function until all the Boot Services and Runtime Services are available.
2142 @param Arg1 Undefined
2143 @param Arg2 Undefined
2144 @param Arg3 Undefined
2145 @param Arg4 Undefined
2146 @param Arg5 Undefined
2148 @return EFI_NOT_AVAILABLE_YET
2153 CoreEfiNotAvailableYetArg5 (
2163 Given a compressed source buffer, this function retrieves the size of the
2164 uncompressed buffer and the size of the scratch buffer required to decompress
2165 the compressed source buffer.
2167 The GetInfo() function retrieves the size of the uncompressed buffer and the
2168 temporary scratch buffer required to decompress the buffer specified by Source
2169 and SourceSize. If the size of the uncompressed buffer or the size of the
2170 scratch buffer cannot be determined from the compressed data specified by
2171 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
2172 size of the uncompressed buffer is returned in DestinationSize, the size of
2173 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
2174 The GetInfo() function does not have scratch buffer available to perform a
2175 thorough checking of the validity of the source data. It just retrieves the
2176 "Original Size" field from the beginning bytes of the source data and output
2177 it as DestinationSize. And ScratchSize is specific to the decompression
2180 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2181 @param Source The source buffer containing the compressed data.
2182 @param SourceSize The size, in bytes, of the source buffer.
2183 @param DestinationSize A pointer to the size, in bytes, of the
2184 uncompressed buffer that will be generated when the
2185 compressed buffer specified by Source and
2186 SourceSize is decompressed.
2187 @param ScratchSize A pointer to the size, in bytes, of the scratch
2188 buffer that is required to decompress the
2189 compressed buffer specified by Source and
2192 @retval EFI_SUCCESS The size of the uncompressed data was returned in
2193 DestinationSize and the size of the scratch buffer
2194 was returned in ScratchSize.
2195 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
2196 the scratch buffer cannot be determined from the
2197 compressed data specified by Source and
2203 DxeMainUefiDecompressGetInfo (
2204 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2206 IN UINT32 SourceSize
,
2207 OUT UINT32
*DestinationSize
,
2208 OUT UINT32
*ScratchSize
2213 Decompresses a compressed source buffer.
2215 The Decompress() function extracts decompressed data to its original form.
2216 This protocol is designed so that the decompression algorithm can be
2217 implemented without using any memory services. As a result, the Decompress()
2218 Function is not allowed to call AllocatePool() or AllocatePages() in its
2219 implementation. It is the caller's responsibility to allocate and free the
2220 Destination and Scratch buffers.
2221 If the compressed source data specified by Source and SourceSize is
2222 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
2223 the compressed source data specified by Source and SourceSize is not in a
2224 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
2226 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2227 @param Source The source buffer containing the compressed data.
2228 @param SourceSize SourceSizeThe size of source data.
2229 @param Destination On output, the destination buffer that contains
2230 the uncompressed data.
2231 @param DestinationSize The size of the destination buffer. The size of
2232 the destination buffer needed is obtained from
2233 EFI_DECOMPRESS_PROTOCOL.GetInfo().
2234 @param Scratch A temporary scratch buffer that is used to perform
2236 @param ScratchSize The size of scratch buffer. The size of the
2237 scratch buffer needed is obtained from GetInfo().
2239 @retval EFI_SUCCESS Decompression completed successfully, and the
2240 uncompressed buffer is returned in Destination.
2241 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
2242 SourceSize is corrupted (not in a valid
2248 DxeMainUefiDecompress (
2249 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2251 IN UINT32 SourceSize
,
2252 IN OUT VOID
*Destination
,
2253 IN UINT32 DestinationSize
,
2254 IN OUT VOID
*Scratch
,
2255 IN UINT32 ScratchSize
2259 SEP member function. This function creates and returns a new section stream
2260 handle to represent the new section stream.
2262 @param SectionStreamLength Size in bytes of the section stream.
2263 @param SectionStream Buffer containing the new section stream.
2264 @param SectionStreamHandle A pointer to a caller allocated UINTN that on
2265 output contains the new section stream handle.
2267 @retval EFI_SUCCESS The section stream is created successfully.
2268 @retval EFI_OUT_OF_RESOURCES memory allocation failed.
2269 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2276 IN UINTN SectionStreamLength
,
2277 IN VOID
*SectionStream
,
2278 OUT UINTN
*SectionStreamHandle
2284 SEP member function. Retrieves requested section from section stream.
2286 @param SectionStreamHandle The section stream from which to extract the
2288 @param SectionType A pointer to the type of section to search for.
2289 @param SectionDefinitionGuid If the section type is EFI_SECTION_GUID_DEFINED,
2290 then SectionDefinitionGuid indicates which of
2291 these types of sections to search for.
2292 @param SectionInstance Indicates which instance of the requested
2294 @param Buffer Double indirection to buffer. If *Buffer is
2295 non-null on input, then the buffer is caller
2296 allocated. If Buffer is NULL, then the buffer
2297 is callee allocated. In either case, the
2298 requried buffer size is returned in *BufferSize.
2299 @param BufferSize On input, indicates the size of *Buffer if
2300 *Buffer is non-null on input. On output,
2301 indicates the required size (allocated size if
2302 callee allocated) of *Buffer.
2303 @param AuthenticationStatus A pointer to a caller-allocated UINT32 that
2304 indicates the authentication status of the
2305 output buffer. If the input section's
2306 GuidedSectionHeader.Attributes field
2307 has the EFI_GUIDED_SECTION_AUTH_STATUS_VALID
2308 bit as clear, AuthenticationStatus must return
2309 zero. Both local bits (19:16) and aggregate
2310 bits (3:0) in AuthenticationStatus are returned
2311 by ExtractSection(). These bits reflect the
2312 status of the extraction operation. The bit
2313 pattern in both regions must be the same, as
2314 the local and aggregate authentication statuses
2315 have equivalent meaning at this level. If the
2316 function returns anything other than
2317 EFI_SUCCESS, the value of *AuthenticationStatus
2319 @param IsFfs3Fv Indicates the FV format.
2321 @retval EFI_SUCCESS Section was retrieved successfully
2322 @retval EFI_PROTOCOL_ERROR A GUID defined section was encountered in the
2323 section stream with its
2324 EFI_GUIDED_SECTION_PROCESSING_REQUIRED bit set,
2325 but there was no corresponding GUIDed Section
2326 Extraction Protocol in the handle database.
2327 *Buffer is unmodified.
2328 @retval EFI_NOT_FOUND An error was encountered when parsing the
2329 SectionStream. This indicates the SectionStream
2330 is not correctly formatted.
2331 @retval EFI_NOT_FOUND The requested section does not exist.
2332 @retval EFI_OUT_OF_RESOURCES The system has insufficient resources to process
2334 @retval EFI_INVALID_PARAMETER The SectionStreamHandle does not exist.
2335 @retval EFI_WARN_TOO_SMALL The size of the caller allocated input buffer is
2336 insufficient to contain the requested section.
2337 The input buffer is filled and section contents
2344 IN UINTN SectionStreamHandle
,
2345 IN EFI_SECTION_TYPE
*SectionType
,
2346 IN EFI_GUID
*SectionDefinitionGuid
,
2347 IN UINTN SectionInstance
,
2349 IN OUT UINTN
*BufferSize
,
2350 OUT UINT32
*AuthenticationStatus
,
2356 SEP member function. Deletes an existing section stream
2358 @param StreamHandleToClose Indicates the stream to close
2360 @retval EFI_SUCCESS The section stream is closed sucessfully.
2361 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
2362 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2368 CloseSectionStream (
2369 IN UINTN StreamHandleToClose
2373 Creates and initializes the DebugImageInfo Table. Also creates the configuration
2374 table and registers it into the system table.
2377 This function allocates memory, frees it, and then allocates memory at an
2378 address within the initial allocation. Since this function is called early
2379 in DXE core initialization (before drivers are dispatched), this should not
2384 CoreInitializeDebugImageInfoTable (
2390 Update the CRC32 in the Debug Table.
2391 Since the CRC32 service is made available by the Runtime driver, we have to
2392 wait for the Runtime Driver to be installed before the CRC32 can be computed.
2393 This function is called elsewhere by the core when the runtime architectural
2394 protocol is produced.
2398 CoreUpdateDebugTableCrc32 (
2404 Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
2405 the table if it's not large enough to accomidate another entry.
2407 @param ImageInfoType type of debug image information
2408 @param LoadedImage pointer to the loaded image protocol for the image being
2410 @param ImageHandle image handle for the image being loaded
2414 CoreNewDebugImageInfoEntry (
2415 IN UINT32 ImageInfoType
,
2416 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
,
2417 IN EFI_HANDLE ImageHandle
2422 Removes and frees an entry from the DebugImageInfo Table.
2424 @param ImageHandle image handle for the image being unloaded
2428 CoreRemoveDebugImageInfoEntry (
2429 EFI_HANDLE ImageHandle
2434 This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
2436 @param ImageHandle The image handle.
2437 @param SystemTable The system table.
2439 @retval EFI_SUCCESS Successfully initialized firmware volume block
2445 FwVolBlockDriverInit (
2446 IN EFI_HANDLE ImageHandle
,
2447 IN EFI_SYSTEM_TABLE
*SystemTable
2452 Get FVB authentication status
2454 @param FvbProtocol FVB protocol.
2456 @return Authentication status.
2460 GetFvbAuthenticationStatus (
2461 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
2465 This routine produces a firmware volume block protocol on a given
2468 @param BaseAddress base address of the firmware volume image
2469 @param Length length of the firmware volume image
2470 @param ParentHandle handle of parent firmware volume, if this image
2471 came from an FV image file and section in another firmware
2472 volume (ala capsules)
2473 @param AuthenticationStatus Authentication status inherited, if this image
2474 came from an FV image file and section in another firmware volume.
2475 @param FvProtocol Firmware volume block protocol produced.
2477 @retval EFI_VOLUME_CORRUPTED Volume corrupted.
2478 @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
2479 @retval EFI_SUCCESS Successfully produced a FVB protocol on given
2484 ProduceFVBProtocolOnBuffer (
2485 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2487 IN EFI_HANDLE ParentHandle
,
2488 IN UINT32 AuthenticationStatus
,
2489 OUT EFI_HANDLE
*FvProtocol OPTIONAL
2494 Raising to the task priority level of the mutual exclusion
2495 lock, and then acquires ownership of the lock.
2497 @param Lock The lock to acquire
2509 Initialize a basic mutual exclusion lock. Each lock
2510 provides mutual exclusion access at it's task priority
2511 level. Since there is no-premption (at any TPL) or
2512 multiprocessor support, acquiring the lock only consists
2513 of raising to the locks TPL.
2515 @param Lock The EFI_LOCK structure to initialize
2517 @retval EFI_SUCCESS Lock Owned.
2518 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
2522 CoreAcquireLockOrFail (
2528 Releases ownership of the mutual exclusion lock, and
2529 restores the previous task priority level.
2531 @param Lock The lock to release
2533 @return Lock unowned
2543 An empty function to pass error checking of CreateEventEx ().
2545 @param Event Event whose notification function is being invoked.
2546 @param Context Pointer to the notification function's context,
2547 which is implementation-dependent.
2552 CoreEmptyCallbackFunction (
2558 Read data from Firmware Block by FVB protocol Read.
2559 The data may cross the multi block ranges.
2561 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to read data.
2562 @param StartLba Pointer to StartLba.
2563 On input, the start logical block index from which to read.
2564 On output,the end logical block index after reading.
2565 @param Offset Pointer to Offset
2566 On input, offset into the block at which to begin reading.
2567 On output, offset into the end block after reading.
2568 @param DataSize Size of data to be read.
2569 @param Data Pointer to Buffer that the data will be read into.
2571 @retval EFI_SUCCESS Successfully read data from firmware block.
2576 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2577 IN OUT EFI_LBA
*StartLba
,
2578 IN OUT UINTN
*Offset
,
2584 Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
2585 copy the real length volume header into it.
2587 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
2588 read the volume header
2589 @param FwVolHeader Pointer to pointer to allocated buffer in which
2590 the volume header is returned.
2592 @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
2593 @retval EFI_SUCCESS Successfully read volume header to the allocated
2599 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2600 OUT EFI_FIRMWARE_VOLUME_HEADER
**FwVolHeader
2604 Verify checksum of the firmware volume header.
2606 @param FvHeader Points to the firmware volume header to be checked
2608 @retval TRUE Checksum verification passed
2609 @retval FALSE Checksum verification failed
2613 VerifyFvHeaderChecksum (
2614 IN EFI_FIRMWARE_VOLUME_HEADER
*FvHeader