2 The internal header file includes the common header files, defines
3 internal structure and functions used by DxeCore module.
5 Copyright (c) 2006 - 2012, 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>
71 #include <Library/DxeCoreEntryPoint.h>
72 #include <Library/DebugLib.h>
73 #include <Library/UefiLib.h>
74 #include <Library/BaseLib.h>
75 #include <Library/HobLib.h>
76 #include <Library/PerformanceLib.h>
77 #include <Library/UefiDecompressLib.h>
78 #include <Library/ExtractGuidedSectionLib.h>
79 #include <Library/CacheMaintenanceLib.h>
80 #include <Library/BaseMemoryLib.h>
81 #include <Library/PeCoffLib.h>
82 #include <Library/PeCoffGetEntryPointLib.h>
83 #include <Library/PeCoffExtraActionLib.h>
84 #include <Library/PcdLib.h>
85 #include <Library/MemoryAllocationLib.h>
86 #include <Library/DevicePathLib.h>
87 #include <Library/UefiBootServicesTableLib.h>
88 #include <Library/ReportStatusCodeLib.h>
89 #include <Library/TimerLib.h>
90 #include <Library/DxeServicesLib.h>
91 #include <Library/DebugAgentLib.h>
92 #include <Library/CpuExceptionHandlerLib.h>
96 // attributes for reserved memory before it is promoted to system memory
98 #define EFI_MEMORY_PRESENT 0x0100000000000000ULL
99 #define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL
100 #define EFI_MEMORY_TESTED 0x0400000000000000ULL
103 // range for memory mapped port I/O on IPF
105 #define EFI_MEMORY_PORT_IO 0x4000000000000000ULL
109 /// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependecy expression
110 /// to save time. A EFI_DEP_PUSH is evauated one an
111 /// replaced with EFI_DEP_REPLACE_TRUE. If PI spec's Vol 2
112 /// Driver Execution Environment Core Interface use 0xff
113 /// as new DEPEX opcode. EFI_DEP_REPLACE_TRUE should be
114 /// defined to a new value that is not conflicting with PI spec.
116 #define EFI_DEP_REPLACE_TRUE 0xff
119 /// Define the initial size of the dependency expression evaluation stack
121 #define DEPEX_STACK_SIZE_INCREMENT 0x1000
124 EFI_GUID
*ProtocolGuid
;
129 } EFI_CORE_PROTOCOL_NOTIFY_ENTRY
;
132 // DXE Dispatcher Data structures
135 #define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w')
138 LIST_ENTRY Link
; // mFvHandleList
144 #define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r')
147 LIST_ENTRY Link
; // mDriverList
149 LIST_ENTRY ScheduledLink
; // mScheduledQueue
153 EFI_DEVICE_PATH_PROTOCOL
*FvFileDevicePath
;
154 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
161 EFI_GUID BeforeAfterGuid
;
168 BOOLEAN DepexProtocolError
;
170 EFI_HANDLE ImageHandle
;
173 } EFI_CORE_DRIVER_ENTRY
;
176 //The data structure of GCD memory map entry
178 #define EFI_GCD_MAP_SIGNATURE SIGNATURE_32('g','c','d','m')
182 EFI_PHYSICAL_ADDRESS BaseAddress
;
186 EFI_GCD_MEMORY_TYPE GcdMemoryType
;
187 EFI_GCD_IO_TYPE GcdIoType
;
188 EFI_HANDLE ImageHandle
;
189 EFI_HANDLE DeviceHandle
;
193 // DXE Core Global Variables
195 extern EFI_SYSTEM_TABLE
*gDxeCoreST
;
196 extern EFI_RUNTIME_SERVICES
*gDxeCoreRT
;
197 extern EFI_DXE_SERVICES
*gDxeCoreDS
;
198 extern EFI_HANDLE gDxeCoreImageHandle
;
200 extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress
;
202 extern EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
;
203 extern EFI_CPU_ARCH_PROTOCOL
*gCpu
;
204 extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL
*gWatchdogTimer
;
205 extern EFI_METRONOME_ARCH_PROTOCOL
*gMetronome
;
206 extern EFI_TIMER_ARCH_PROTOCOL
*gTimer
;
207 extern EFI_SECURITY_ARCH_PROTOCOL
*gSecurity
;
208 extern EFI_SECURITY2_ARCH_PROTOCOL
*gSecurity2
;
209 extern EFI_BDS_ARCH_PROTOCOL
*gBds
;
210 extern EFI_SMM_BASE2_PROTOCOL
*gSmmBase2
;
212 extern EFI_TPL gEfiCurrentTpl
;
214 extern EFI_GUID
*gDxeCoreFileName
;
215 extern EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
217 extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation
[EfiMaxMemoryType
+ 1];
219 extern BOOLEAN gDispatcherRunning
;
220 extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
;
222 extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable
;
223 extern BOOLEAN gLoadFixedAddressCodeMemoryReady
;
225 // Service Initialization Functions
231 Called to initialize the pool.
241 Called to initialize the memory map and add descriptors to
242 the current descriptor list.
243 The first descriptor that is added must be general usable
244 memory as the addition allocates heap.
246 @param Type The type of memory to add
247 @param Start The starting address in the memory range Must be
249 @param NumberOfPages The number of pages in the range
250 @param Attribute Attributes of the memory to add
252 @return None. The range is added to the memory map
256 CoreAddMemoryDescriptor (
257 IN EFI_MEMORY_TYPE Type
,
258 IN EFI_PHYSICAL_ADDRESS Start
,
259 IN UINT64 NumberOfPages
,
265 Release memory lock on mGcdMemorySpaceLock.
269 CoreReleaseGcdMemoryLock (
275 Acquire memory lock on mGcdMemorySpaceLock.
279 CoreAcquireGcdMemoryLock (
285 External function. Initializes memory services based on the memory
286 descriptor HOBs. This function is responsible for priming the memory
287 map, so memory allocations and resource allocations can be made.
288 The first part of this function can not depend on any memory services
289 until at least one memory descriptor is provided to the memory services.
291 @param HobStart The start address of the HOB.
292 @param MemoryBaseAddress Start address of memory region found to init DXE
294 @param MemoryLength Length of memory region found to init DXE core.
296 @retval EFI_SUCCESS Memory services successfully initialized.
300 CoreInitializeMemoryServices (
302 OUT EFI_PHYSICAL_ADDRESS
*MemoryBaseAddress
,
303 OUT UINT64
*MemoryLength
309 External function. Initializes the GCD and memory services based on the memory
310 descriptor HOBs. This function is responsible for priming the GCD map and the
311 memory map, so memory allocations and resource allocations can be made. The
312 HobStart will be relocated to a pool buffer.
314 @param HobStart The start address of the HOB
315 @param MemoryBaseAddress Start address of memory region found to init DXE
317 @param MemoryLength Length of memory region found to init DXE core.
319 @retval EFI_SUCCESS GCD services successfully initialized.
323 CoreInitializeGcdServices (
324 IN OUT VOID
**HobStart
,
325 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress
,
326 IN UINT64 MemoryLength
331 Initializes "event" support.
333 @retval EFI_SUCCESS Always return success
337 CoreInitializeEventServices (
343 Add the Image Services to EFI Boot Services Table and install the protocol
344 interfaces for this image.
346 @param HobStart The HOB to initialize
352 CoreInitializeImageServices (
358 Creates an event that is fired everytime a Protocol of a specific type is installed.
362 CoreNotifyOnProtocolInstallation (
368 Return TRUE if all AP services are availible.
370 @retval EFI_SUCCESS All AP services are available
371 @retval EFI_NOT_FOUND At least one AP service is not available
375 CoreAllEfiServicesAvailable (
381 Calcualte the 32-bit CRC in a EFI table using the service provided by the
384 @param Hdr Pointer to an EFI standard header
389 IN OUT EFI_TABLE_HEADER
*Hdr
394 Called by the platform code to process a tick.
396 @param Duration The number of 100ns elasped since the last call
408 Initialize the dispatcher. Initialize the notification function that runs when
409 an FV2 protocol is added to the system.
413 CoreInitializeDispatcher (
419 This is the POSTFIX version of the dependency evaluator. This code does
420 not need to handle Before or After, as it is not valid to call this
421 routine in this case. The SOR is just ignored and is a nop in the grammer.
422 POSTFIX means all the math is done on top of the stack.
424 @param DriverEntry DriverEntry element to update.
426 @retval TRUE If driver is ready to run.
427 @retval FALSE If driver is not ready to run or some fatal error
433 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
438 Preprocess dependency expression and update DriverEntry to reflect the
439 state of Before, After, and SOR dependencies. If DriverEntry->Before
440 or DriverEntry->After is set it will never be cleared. If SOR is set
441 it will be cleared by CoreSchedule(), and then the driver can be
444 @param DriverEntry DriverEntry element to update .
446 @retval EFI_SUCCESS It always works.
450 CorePreProcessDepex (
451 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
457 Terminates all boot services.
459 @param ImageHandle Handle that identifies the exiting image.
460 @param MapKey Key to the latest memory map.
462 @retval EFI_SUCCESS Boot Services terminated
463 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
468 CoreExitBootServices (
469 IN EFI_HANDLE ImageHandle
,
475 Make sure the memory map is following all the construction rules,
476 it is the last time to check memory map error before exit boot services.
478 @param MapKey Memory map key
480 @retval EFI_INVALID_PARAMETER Memory map not consistent with construction
482 @retval EFI_SUCCESS Valid memory map.
486 CoreTerminateMemoryMap (
492 Signals all events in the EventGroup.
494 @param EventGroup The list to signal
498 CoreNotifySignalList (
499 IN EFI_GUID
*EventGroup
505 Boot Service called to add, modify, or remove a system configuration table from
506 the EFI System Table.
508 @param Guid Pointer to the GUID for the entry to add, update, or
510 @param Table Pointer to the configuration table for the entry to add,
511 update, or remove, may be NULL.
513 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.
514 @return EFI_INVALID_PARAMETER Input GUID not valid.
515 @return EFI_NOT_FOUND Attempted to delete non-existant entry
516 @return EFI_OUT_OF_RESOURCES Not enough memory available
521 CoreInstallConfigurationTable (
529 Raise the task priority level to the new level.
530 High level is implemented by disabling processor interrupts.
532 @param NewTpl New task priority level
534 @return The previous task priority level
546 Lowers the task priority to the previous value. If the new
547 priority unmasks events at a higher priority, they are dispatched.
549 @param NewTpl New, lower, task priority
561 Introduces a fine-grained stall.
563 @param Microseconds The number of microseconds to stall execution.
565 @retval EFI_SUCCESS Execution was stalled for at least the requested
566 amount of microseconds.
567 @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet
573 IN UINTN Microseconds
579 Sets the system's watchdog timer.
581 @param Timeout The number of seconds to set the watchdog timer to.
582 A value of zero disables the timer.
583 @param WatchdogCode The numeric code to log on a watchdog timer timeout
584 event. The firmware reserves codes 0x0000 to 0xFFFF.
585 Loaders and operating systems may use other timeout
587 @param DataSize The size, in bytes, of WatchdogData.
588 @param WatchdogData A data buffer that includes a Null-terminated Unicode
589 string, optionally followed by additional binary data.
590 The string is a description that the call may use to
591 further indicate the reason to be logged with a
594 @return EFI_SUCCESS Timeout has been set
595 @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
596 @return EFI_UNSUPPORTED System does not have a timer (currently not used)
597 @return EFI_DEVICE_ERROR Could not complete due to hardware error
602 CoreSetWatchdogTimer (
604 IN UINT64 WatchdogCode
,
606 IN CHAR16
*WatchdogData OPTIONAL
612 Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
613 Calls the private one which contains a BOOLEAN parameter for notifications
615 @param UserHandle The handle to install the protocol handler on,
616 or NULL if a new handle is to be allocated
617 @param Protocol The protocol to add to the handle
618 @param InterfaceType Indicates whether Interface is supplied in
620 @param Interface The interface for the protocol being added
627 CoreInstallProtocolInterface (
628 IN OUT EFI_HANDLE
*UserHandle
,
629 IN EFI_GUID
*Protocol
,
630 IN EFI_INTERFACE_TYPE InterfaceType
,
636 Installs a protocol interface into the boot services environment.
638 @param UserHandle The handle to install the protocol handler on,
639 or NULL if a new handle is to be allocated
640 @param Protocol The protocol to add to the handle
641 @param InterfaceType Indicates whether Interface is supplied in
643 @param Interface The interface for the protocol being added
644 @param Notify indicates whether notify the notification list
647 @retval EFI_INVALID_PARAMETER Invalid parameter
648 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
649 @retval EFI_SUCCESS Protocol interface successfully installed
653 CoreInstallProtocolInterfaceNotify (
654 IN OUT EFI_HANDLE
*UserHandle
,
655 IN EFI_GUID
*Protocol
,
656 IN EFI_INTERFACE_TYPE InterfaceType
,
664 Installs a list of protocol interface into the boot services environment.
665 This function calls InstallProtocolInterface() in a loop. If any error
666 occures all the protocols added by this function are removed. This is
667 basically a lib function to save space.
669 @param Handle The handle to install the protocol handlers on,
670 or NULL if a new handle is to be allocated
671 @param ... EFI_GUID followed by protocol instance. A NULL
672 terminates the list. The pairs are the
673 arguments to InstallProtocolInterface(). All the
674 protocols are added to Handle.
676 @retval EFI_INVALID_PARAMETER Handle is NULL.
677 @retval EFI_SUCCESS Protocol interfaces successfully installed.
682 CoreInstallMultipleProtocolInterfaces (
683 IN OUT EFI_HANDLE
*Handle
,
690 Uninstalls a list of protocol interface in the boot services environment.
691 This function calls UnisatllProtocolInterface() in a loop. This is
692 basically a lib function to save space.
694 @param Handle The handle to uninstall the protocol
695 @param ... EFI_GUID followed by protocol instance. A NULL
696 terminates the list. The pairs are the
697 arguments to UninstallProtocolInterface(). All
698 the protocols are added to Handle.
705 CoreUninstallMultipleProtocolInterfaces (
706 IN EFI_HANDLE Handle
,
713 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
715 @param UserHandle Handle on which the interface is to be
717 @param Protocol The numeric ID of the interface
718 @param OldInterface A pointer to the old interface
719 @param NewInterface A pointer to the new interface
721 @retval EFI_SUCCESS The protocol interface was installed
722 @retval EFI_NOT_FOUND The OldInterface on the handle was not found
723 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
728 CoreReinstallProtocolInterface (
729 IN EFI_HANDLE UserHandle
,
730 IN EFI_GUID
*Protocol
,
731 IN VOID
*OldInterface
,
732 IN VOID
*NewInterface
738 Uninstalls all instances of a protocol:interfacer from a handle.
739 If the last protocol interface is remove from the handle, the
742 @param UserHandle The handle to remove the protocol handler from
743 @param Protocol The protocol, of protocol:interface, to remove
744 @param Interface The interface, of protocol:interface, to remove
746 @retval EFI_INVALID_PARAMETER Protocol is NULL.
747 @retval EFI_SUCCESS Protocol interface successfully uninstalled.
752 CoreUninstallProtocolInterface (
753 IN EFI_HANDLE UserHandle
,
754 IN EFI_GUID
*Protocol
,
761 Queries a handle to determine if it supports a specified protocol.
763 @param UserHandle The handle being queried.
764 @param Protocol The published unique identifier of the protocol.
765 @param Interface Supplies the address where a pointer to the
766 corresponding Protocol Interface is returned.
768 @return The requested protocol interface for the handle
774 IN EFI_HANDLE UserHandle
,
775 IN EFI_GUID
*Protocol
,
782 Locates the installed protocol handler for the handle, and
783 invokes it to obtain the protocol interface. Usage information
784 is registered in the protocol data base.
786 @param UserHandle The handle to obtain the protocol interface on
787 @param Protocol The ID of the protocol
788 @param Interface The location to return the protocol interface
789 @param ImageHandle The handle of the Image that is opening the
790 protocol interface specified by Protocol and
792 @param ControllerHandle The controller handle that is requiring this
794 @param Attributes The open mode of the protocol interface
795 specified by Handle and Protocol.
797 @retval EFI_INVALID_PARAMETER Protocol is NULL.
798 @retval EFI_SUCCESS Get the protocol interface.
804 IN EFI_HANDLE UserHandle
,
805 IN EFI_GUID
*Protocol
,
806 OUT VOID
**Interface OPTIONAL
,
807 IN EFI_HANDLE ImageHandle
,
808 IN EFI_HANDLE ControllerHandle
,
815 Return information about Opened protocols in the system
817 @param UserHandle The handle to close the protocol interface on
818 @param Protocol The ID of the protocol
819 @param EntryBuffer A pointer to a buffer of open protocol
820 information in the form of
821 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
822 @param EntryCount Number of EntryBuffer entries
827 CoreOpenProtocolInformation (
828 IN EFI_HANDLE UserHandle
,
829 IN EFI_GUID
*Protocol
,
830 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
**EntryBuffer
,
831 OUT UINTN
*EntryCount
837 Closes a protocol on a handle that was opened using OpenProtocol().
839 @param UserHandle The handle for the protocol interface that was
840 previously opened with OpenProtocol(), and is
842 @param Protocol The published unique identifier of the protocol.
843 It is the caller's responsibility to pass in a
845 @param AgentHandle The handle of the agent that is closing the
847 @param ControllerHandle If the agent that opened a protocol is a driver
848 that follows the EFI Driver Model, then this
849 parameter is the controller handle that required
850 the protocol interface. If the agent does not
851 follow the EFI Driver Model, then this parameter
852 is optional and may be NULL.
854 @retval EFI_SUCCESS The protocol instance was closed.
855 @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a
857 @retval EFI_NOT_FOUND Can not find the specified protocol or
864 IN EFI_HANDLE UserHandle
,
865 IN EFI_GUID
*Protocol
,
866 IN EFI_HANDLE AgentHandle
,
867 IN EFI_HANDLE ControllerHandle
873 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
876 @param UserHandle The handle from which to retrieve the list of
877 protocol interface GUIDs.
878 @param ProtocolBuffer A pointer to the list of protocol interface GUID
879 pointers that are installed on Handle.
880 @param ProtocolBufferCount A pointer to the number of GUID pointers present
883 @retval EFI_SUCCESS The list of protocol interface GUIDs installed
884 on Handle was returned in ProtocolBuffer. The
885 number of protocol interface GUIDs was returned
886 in ProtocolBufferCount.
887 @retval EFI_INVALID_PARAMETER Handle is NULL.
888 @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
889 @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.
890 @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.
891 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
897 CoreProtocolsPerHandle (
898 IN EFI_HANDLE UserHandle
,
899 OUT EFI_GUID
***ProtocolBuffer
,
900 OUT UINTN
*ProtocolBufferCount
906 Add a new protocol notification record for the request protocol.
908 @param Protocol The requested protocol to add the notify
910 @param Event The event to signal
911 @param Registration Returns the registration record
913 @retval EFI_INVALID_PARAMETER Invalid parameter
914 @retval EFI_SUCCESS Successfully returned the registration record
920 CoreRegisterProtocolNotify (
921 IN EFI_GUID
*Protocol
,
923 OUT VOID
**Registration
928 Removes all the events in the protocol database that match Event.
930 @param Event The event to search for in the protocol
933 @return EFI_SUCCESS when done searching the entire database.
937 CoreUnregisterProtocolNotify (
943 Locates the requested handle(s) and returns them in Buffer.
945 @param SearchType The type of search to perform to locate the
947 @param Protocol The protocol to search for
948 @param SearchKey Dependant on SearchType
949 @param BufferSize On input the size of Buffer. On output the
950 size of data returned.
951 @param Buffer The buffer to return the results in
953 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
954 returned in BufferSize.
955 @retval EFI_INVALID_PARAMETER Invalid parameter
956 @retval EFI_SUCCESS Successfully found the requested handle(s) and
957 returns them in Buffer.
963 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
964 IN EFI_GUID
*Protocol OPTIONAL
,
965 IN VOID
*SearchKey OPTIONAL
,
966 IN OUT UINTN
*BufferSize
,
967 OUT EFI_HANDLE
*Buffer
973 Locates the handle to a device on the device path that best matches the specified protocol.
975 @param Protocol The protocol to search for.
976 @param DevicePath On input, a pointer to a pointer to the device
977 path. On output, the device path pointer is
978 modified to point to the remaining part of the
980 @param Device A pointer to the returned device handle.
982 @retval EFI_SUCCESS The resulting handle was returned.
983 @retval EFI_NOT_FOUND No handles matched the search.
984 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
989 CoreLocateDevicePath (
990 IN EFI_GUID
*Protocol
,
991 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
992 OUT EFI_HANDLE
*Device
998 Function returns an array of handles that support the requested protocol
999 in a buffer allocated from pool. This is a version of CoreLocateHandle()
1000 that allocates a buffer for the caller.
1002 @param SearchType Specifies which handle(s) are to be returned.
1003 @param Protocol Provides the protocol to search by. This
1004 parameter is only valid for SearchType
1006 @param SearchKey Supplies the search key depending on the
1008 @param NumberHandles The number of handles returned in Buffer.
1009 @param Buffer A pointer to the buffer to return the requested
1010 array of handles that support Protocol.
1012 @retval EFI_SUCCESS The result array of handles was returned.
1013 @retval EFI_NOT_FOUND No handles match the search.
1014 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
1016 @retval EFI_INVALID_PARAMETER One or more paramters are not valid.
1021 CoreLocateHandleBuffer (
1022 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1023 IN EFI_GUID
*Protocol OPTIONAL
,
1024 IN VOID
*SearchKey OPTIONAL
,
1025 IN OUT UINTN
*NumberHandles
,
1026 OUT EFI_HANDLE
**Buffer
1032 Return the first Protocol Interface that matches the Protocol GUID. If
1033 Registration is passed in, return a Protocol Instance that was just add
1034 to the system. If Registration is NULL return the first Protocol Interface
1037 @param Protocol The protocol to search for
1038 @param Registration Optional Registration Key returned from
1039 RegisterProtocolNotify()
1040 @param Interface Return the Protocol interface (instance).
1042 @retval EFI_SUCCESS If a valid Interface is returned
1043 @retval EFI_INVALID_PARAMETER Invalid parameter
1044 @retval EFI_NOT_FOUND Protocol interface not found
1049 CoreLocateProtocol (
1050 IN EFI_GUID
*Protocol
,
1051 IN VOID
*Registration OPTIONAL
,
1052 OUT VOID
**Interface
1057 return handle database key.
1060 @return Handle database key.
1064 CoreGetHandleDatabaseKey (
1070 Go connect any handles that were created or modified while a image executed.
1072 @param Key The Key to show that the handle has been
1077 CoreConnectHandlesByKey (
1084 Connects one or more drivers to a controller.
1086 @param ControllerHandle The handle of the controller to which driver(s) are to be connected.
1087 @param DriverImageHandle A pointer to an ordered list handles that support the
1088 EFI_DRIVER_BINDING_PROTOCOL.
1089 @param RemainingDevicePath A pointer to the device path that specifies a child of the
1090 controller specified by ControllerHandle.
1091 @param Recursive If TRUE, then ConnectController() is called recursively
1092 until the entire tree of controllers below the controller specified
1093 by ControllerHandle have been created. If FALSE, then
1094 the tree of controllers is only expanded one level.
1096 @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.
1097 2) No drivers were connected to ControllerHandle, but
1098 RemainingDevicePath is not NULL, and it is an End Device
1100 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1101 @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
1102 present in the system.
1103 2) No drivers were connected to ControllerHandle.
1104 @retval EFI_SECURITY_VIOLATION
1105 The user has no permission to start UEFI device drivers on the device path
1106 associated with the ControllerHandle or specified by the RemainingDevicePath.
1111 CoreConnectController (
1112 IN EFI_HANDLE ControllerHandle
,
1113 IN EFI_HANDLE
*DriverImageHandle OPTIONAL
,
1114 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
1115 IN BOOLEAN Recursive
1121 Disonnects a controller from a driver
1123 @param ControllerHandle ControllerHandle The handle of
1124 the controller from which
1127 @param DriverImageHandle DriverImageHandle The driver to
1128 disconnect from ControllerHandle.
1129 @param ChildHandle ChildHandle The handle of the
1132 @retval EFI_SUCCESS One or more drivers were
1133 disconnected from the controller.
1134 @retval EFI_SUCCESS On entry, no drivers are managing
1136 @retval EFI_SUCCESS DriverImageHandle is not NULL,
1137 and on entry DriverImageHandle is
1138 not managing ControllerHandle.
1139 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1140 @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
1141 and it is not a valid EFI_HANDLE.
1142 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
1143 is not a valid EFI_HANDLE.
1144 @retval EFI_OUT_OF_RESOURCES There are not enough resources
1145 available to disconnect any
1146 drivers from ControllerHandle.
1147 @retval EFI_DEVICE_ERROR The controller could not be
1148 disconnected because of a device
1154 CoreDisconnectController (
1155 IN EFI_HANDLE ControllerHandle
,
1156 IN EFI_HANDLE DriverImageHandle OPTIONAL
,
1157 IN EFI_HANDLE ChildHandle OPTIONAL
1163 Allocates pages from the memory map.
1165 @param Type The type of allocation to perform
1166 @param MemoryType The type of memory to turn the allocated pages
1168 @param NumberOfPages The number of pages to allocate
1169 @param Memory A pointer to receive the base allocated memory
1172 @return Status. On success, Memory is filled in with the base address allocated
1173 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
1175 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
1176 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
1177 @retval EFI_SUCCESS Pages successfully allocated.
1183 IN EFI_ALLOCATE_TYPE Type
,
1184 IN EFI_MEMORY_TYPE MemoryType
,
1185 IN UINTN NumberOfPages
,
1186 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
1192 Frees previous allocated pages.
1194 @param Memory Base address of memory being freed
1195 @param NumberOfPages The number of pages to free
1197 @retval EFI_NOT_FOUND Could not find the entry that covers the range
1198 @retval EFI_INVALID_PARAMETER Address not aligned
1199 @return EFI_SUCCESS -Pages successfully freed.
1205 IN EFI_PHYSICAL_ADDRESS Memory
,
1206 IN UINTN NumberOfPages
1212 This function returns a copy of the current memory map. The map is an array of
1213 memory descriptors, each of which describes a contiguous block of memory.
1215 @param MemoryMapSize A pointer to the size, in bytes, of the
1216 MemoryMap buffer. On input, this is the size of
1217 the buffer allocated by the caller. On output,
1218 it is the size of the buffer returned by the
1219 firmware if the buffer was large enough, or the
1220 size of the buffer needed to contain the map if
1221 the buffer was too small.
1222 @param MemoryMap A pointer to the buffer in which firmware places
1223 the current memory map.
1224 @param MapKey A pointer to the location in which firmware
1225 returns the key for the current memory map.
1226 @param DescriptorSize A pointer to the location in which firmware
1227 returns the size, in bytes, of an individual
1228 EFI_MEMORY_DESCRIPTOR.
1229 @param DescriptorVersion A pointer to the location in which firmware
1230 returns the version number associated with the
1231 EFI_MEMORY_DESCRIPTOR.
1233 @retval EFI_SUCCESS The memory map was returned in the MemoryMap
1235 @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
1236 buffer size needed to hold the memory map is
1237 returned in MemoryMapSize.
1238 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1244 IN OUT UINTN
*MemoryMapSize
,
1245 IN OUT EFI_MEMORY_DESCRIPTOR
*MemoryMap
,
1247 OUT UINTN
*DescriptorSize
,
1248 OUT UINT32
*DescriptorVersion
1254 Allocate pool of a particular type.
1256 @param PoolType Type of pool to allocate
1257 @param Size The amount of pool to allocate
1258 @param Buffer The address to return a pointer to the allocated
1261 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
1262 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
1263 @retval EFI_SUCCESS Pool successfully allocated.
1269 IN EFI_MEMORY_TYPE PoolType
,
1279 @param Buffer The allocated pool entry to free
1281 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
1282 @retval EFI_SUCCESS Pool successfully freed.
1294 Loads an EFI image into memory and returns a handle to the image.
1296 @param BootPolicy If TRUE, indicates that the request originates
1297 from the boot manager, and that the boot
1298 manager is attempting to load FilePath as a
1300 @param ParentImageHandle The caller's image handle.
1301 @param FilePath The specific file path from which the image is
1303 @param SourceBuffer If not NULL, a pointer to the memory location
1304 containing a copy of the image to be loaded.
1305 @param SourceSize The size in bytes of SourceBuffer.
1306 @param ImageHandle Pointer to the returned image handle that is
1307 created when the image is successfully loaded.
1309 @retval EFI_SUCCESS The image was loaded into memory.
1310 @retval EFI_NOT_FOUND The FilePath was not found.
1311 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1312 @retval EFI_UNSUPPORTED The image type is not supported, or the device
1313 path cannot be parsed to locate the proper
1314 protocol for loading the file.
1315 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
1317 @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
1319 @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
1320 @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
1321 image from being loaded. NULL is returned in *ImageHandle.
1322 @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
1323 valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
1324 platform policy specifies that the image should not be started.
1330 IN BOOLEAN BootPolicy
,
1331 IN EFI_HANDLE ParentImageHandle
,
1332 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
1333 IN VOID
*SourceBuffer OPTIONAL
,
1334 IN UINTN SourceSize
,
1335 OUT EFI_HANDLE
*ImageHandle
1343 @param ImageHandle Handle that identifies the image to be
1346 @retval EFI_SUCCESS The image has been unloaded.
1347 @retval EFI_UNSUPPORTED The image has been sarted, and does not support
1349 @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
1355 IN EFI_HANDLE ImageHandle
1361 Transfer control to a loaded image's entry point.
1363 @param ImageHandle Handle of image to be started.
1364 @param ExitDataSize Pointer of the size to ExitData
1365 @param ExitData Pointer to a pointer to a data buffer that
1366 includes a Null-terminated string,
1367 optionally followed by additional binary data.
1368 The string is a description that the caller may
1369 use to further indicate the reason for the
1372 @retval EFI_INVALID_PARAMETER Invalid parameter
1373 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1374 @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
1375 @retval EFI_SUCCESS Successfully transfer control to the image's
1382 IN EFI_HANDLE ImageHandle
,
1383 OUT UINTN
*ExitDataSize
,
1384 OUT CHAR16
**ExitData OPTIONAL
1390 Terminates the currently loaded EFI image and returns control to boot services.
1392 @param ImageHandle Handle that identifies the image. This
1393 parameter is passed to the image on entry.
1394 @param Status The image's exit code.
1395 @param ExitDataSize The size, in bytes, of ExitData. Ignored if
1396 ExitStatus is EFI_SUCCESS.
1397 @param ExitData Pointer to a data buffer that includes a
1398 Null-terminated Unicode string, optionally
1399 followed by additional binary data. The string
1400 is a description that the caller may use to
1401 further indicate the reason for the image's
1404 @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
1406 @retval EFI_SUCCESS Successfully terminates the currently loaded
1408 @retval EFI_ACCESS_DENIED Should never reach there.
1409 @retval EFI_OUT_OF_RESOURCES Could not allocate pool
1415 IN EFI_HANDLE ImageHandle
,
1416 IN EFI_STATUS Status
,
1417 IN UINTN ExitDataSize
,
1418 IN CHAR16
*ExitData OPTIONAL
1426 @param Type The type of event to create and its mode and
1428 @param NotifyTpl The task priority level of event notifications
1429 @param NotifyFunction Pointer to the events notification function
1430 @param NotifyContext Pointer to the notification functions context;
1431 corresponds to parameter "Context" in the
1432 notification function
1433 @param Event Pointer to the newly created event if the call
1434 succeeds; undefined otherwise
1436 @retval EFI_SUCCESS The event structure was created
1437 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1438 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1445 IN EFI_TPL NotifyTpl
,
1446 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1447 IN VOID
*NotifyContext
, OPTIONAL
1448 OUT EFI_EVENT
*Event
1454 Creates an event in a group.
1456 @param Type The type of event to create and its mode and
1458 @param NotifyTpl The task priority level of event notifications
1459 @param NotifyFunction Pointer to the events notification function
1460 @param NotifyContext Pointer to the notification functions context;
1461 corresponds to parameter "Context" in the
1462 notification function
1463 @param EventGroup GUID for EventGroup if NULL act the same as
1465 @param Event Pointer to the newly created event if the call
1466 succeeds; undefined otherwise
1468 @retval EFI_SUCCESS The event structure was created
1469 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1470 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1477 IN EFI_TPL NotifyTpl
,
1478 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1479 IN CONST VOID
*NotifyContext
, OPTIONAL
1480 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1481 OUT EFI_EVENT
*Event
1485 Creates a general-purpose event structure
1487 @param Type The type of event to create and its mode and
1489 @param NotifyTpl The task priority level of event notifications
1490 @param NotifyFunction Pointer to the events notification function
1491 @param NotifyContext Pointer to the notification functions context;
1492 corresponds to parameter "Context" in the
1493 notification function
1494 @param EventGroup GUID for EventGroup if NULL act the same as
1496 @param Event Pointer to the newly created event if the call
1497 succeeds; undefined otherwise
1499 @retval EFI_SUCCESS The event structure was created
1500 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1501 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1506 CoreCreateEventInternal (
1508 IN EFI_TPL NotifyTpl
,
1509 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1510 IN CONST VOID
*NotifyContext
, OPTIONAL
1511 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1512 OUT EFI_EVENT
*Event
1516 Sets the type of timer and the trigger time for a timer event.
1518 @param UserEvent The timer event that is to be signaled at the
1520 @param Type The type of time that is specified in
1522 @param TriggerTime The number of 100ns units until the timer
1525 @retval EFI_SUCCESS The event has been set to be signaled at the
1527 @retval EFI_INVALID_PARAMETER Event or Type is not valid
1533 IN EFI_EVENT UserEvent
,
1534 IN EFI_TIMER_DELAY Type
,
1535 IN UINT64 TriggerTime
1541 Signals the event. Queues the event to be notified if needed.
1543 @param UserEvent The event to signal .
1545 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1546 @retval EFI_SUCCESS The event was signaled.
1552 IN EFI_EVENT UserEvent
1558 Stops execution until an event is signaled.
1560 @param NumberOfEvents The number of events in the UserEvents array
1561 @param UserEvents An array of EFI_EVENT
1562 @param UserIndex Pointer to the index of the event which
1563 satisfied the wait condition
1565 @retval EFI_SUCCESS The event indicated by Index was signaled.
1566 @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification
1567 function or Event was not a valid type
1568 @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION
1574 IN UINTN NumberOfEvents
,
1575 IN EFI_EVENT
*UserEvents
,
1576 OUT UINTN
*UserIndex
1582 Closes an event and frees the event structure.
1584 @param UserEvent Event to close
1586 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1587 @retval EFI_SUCCESS The event has been closed
1593 IN EFI_EVENT UserEvent
1599 Check the status of an event.
1601 @param UserEvent The event to check
1603 @retval EFI_SUCCESS The event is in the signaled state
1604 @retval EFI_NOT_READY The event is not in the signaled state
1605 @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL
1611 IN EFI_EVENT UserEvent
1616 Adds reserved memory, system memory, or memory-mapped I/O resources to the
1617 global coherency domain of the processor.
1619 @param GcdMemoryType Memory type of the memory space.
1620 @param BaseAddress Base address of the memory space.
1621 @param Length Length of the memory space.
1622 @param Capabilities alterable attributes of the memory space.
1624 @retval EFI_SUCCESS Merged this memory space into GCD map.
1629 CoreAddMemorySpace (
1630 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1631 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1633 IN UINT64 Capabilities
1638 Allocates nonexistent memory, reserved memory, system memory, or memorymapped
1639 I/O resources from the global coherency domain of the processor.
1641 @param GcdAllocateType The type of allocate operation
1642 @param GcdMemoryType The desired memory type
1643 @param Alignment Align with 2^Alignment
1644 @param Length Length to allocate
1645 @param BaseAddress Base address to allocate
1646 @param ImageHandle The image handle consume the allocated space.
1647 @param DeviceHandle The device handle consume the allocated space.
1649 @retval EFI_INVALID_PARAMETER Invalid parameter.
1650 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1651 @retval EFI_SUCCESS Memory space successfully allocated.
1656 CoreAllocateMemorySpace (
1657 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1658 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1661 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1662 IN EFI_HANDLE ImageHandle
,
1663 IN EFI_HANDLE DeviceHandle OPTIONAL
1668 Frees nonexistent memory, reserved memory, system memory, or memory-mapped
1669 I/O resources from the global coherency domain of the processor.
1671 @param BaseAddress Base address of the memory space.
1672 @param Length Length of the memory space.
1674 @retval EFI_SUCCESS Space successfully freed.
1679 CoreFreeMemorySpace (
1680 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1686 Removes reserved memory, system memory, or memory-mapped I/O resources from
1687 the global coherency domain of the processor.
1689 @param BaseAddress Base address of the memory space.
1690 @param Length Length of the memory space.
1692 @retval EFI_SUCCESS Successfully remove a segment of memory space.
1697 CoreRemoveMemorySpace (
1698 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1704 Retrieves the descriptor for a memory region containing a specified address.
1706 @param BaseAddress Specified start address
1707 @param Descriptor Specified length
1709 @retval EFI_INVALID_PARAMETER Invalid parameter
1710 @retval EFI_SUCCESS Successfully get memory space descriptor.
1715 CoreGetMemorySpaceDescriptor (
1716 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1717 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*Descriptor
1722 Modifies the attributes for a memory region in the global coherency domain of the
1725 @param BaseAddress Specified start address
1726 @param Length Specified length
1727 @param Attributes Specified attributes
1729 @retval EFI_SUCCESS The attributes were set for the memory region.
1730 @retval EFI_INVALID_PARAMETER Length is zero.
1731 @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory
1732 resource range specified by BaseAddress and Length.
1733 @retval EFI_UNSUPPORTED The bit mask of attributes is not support for the memory resource
1734 range specified by BaseAddress and Length.
1735 @retval EFI_ACCESS_DEFINED The attributes for the memory resource range specified by
1736 BaseAddress and Length cannot be modified.
1737 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of
1738 the memory resource range.
1739 @retval EFI_NOT_AVAILABLE_YET The attributes cannot be set because CPU architectural protocol is
1745 CoreSetMemorySpaceAttributes (
1746 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1748 IN UINT64 Attributes
1753 Returns a map of the memory resources in the global coherency domain of the
1756 @param NumberOfDescriptors Number of descriptors.
1757 @param MemorySpaceMap Descriptor array
1759 @retval EFI_INVALID_PARAMETER Invalid parameter
1760 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1761 @retval EFI_SUCCESS Successfully get memory space map.
1766 CoreGetMemorySpaceMap (
1767 OUT UINTN
*NumberOfDescriptors
,
1768 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
**MemorySpaceMap
1773 Adds reserved I/O or I/O resources to the global coherency domain of the processor.
1775 @param GcdIoType IO type of the segment.
1776 @param BaseAddress Base address of the segment.
1777 @param Length Length of the segment.
1779 @retval EFI_SUCCESS Merged this segment into GCD map.
1780 @retval EFI_INVALID_PARAMETER Parameter not valid
1786 IN EFI_GCD_IO_TYPE GcdIoType
,
1787 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1793 Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1794 domain of the processor.
1796 @param GcdAllocateType The type of allocate operation
1797 @param GcdIoType The desired IO type
1798 @param Alignment Align with 2^Alignment
1799 @param Length Length to allocate
1800 @param BaseAddress Base address to allocate
1801 @param ImageHandle The image handle consume the allocated space.
1802 @param DeviceHandle The device handle consume the allocated space.
1804 @retval EFI_INVALID_PARAMETER Invalid parameter.
1805 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1806 @retval EFI_SUCCESS IO space successfully allocated.
1811 CoreAllocateIoSpace (
1812 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1813 IN EFI_GCD_IO_TYPE GcdIoType
,
1816 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1817 IN EFI_HANDLE ImageHandle
,
1818 IN EFI_HANDLE DeviceHandle OPTIONAL
1823 Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1824 domain of the processor.
1826 @param BaseAddress Base address of the segment.
1827 @param Length Length of the segment.
1829 @retval EFI_SUCCESS Space successfully freed.
1835 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1841 Removes reserved I/O or I/O resources from the global coherency domain of the
1844 @param BaseAddress Base address of the segment.
1845 @param Length Length of the segment.
1847 @retval EFI_SUCCESS Successfully removed a segment of IO space.
1853 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1859 Retrieves the descriptor for an I/O region containing a specified address.
1861 @param BaseAddress Specified start address
1862 @param Descriptor Specified length
1864 @retval EFI_INVALID_PARAMETER Descriptor is NULL.
1865 @retval EFI_SUCCESS Successfully get the IO space descriptor.
1870 CoreGetIoSpaceDescriptor (
1871 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1872 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
*Descriptor
1877 Returns a map of the I/O resources in the global coherency domain of the processor.
1879 @param NumberOfDescriptors Number of descriptors.
1880 @param IoSpaceMap Descriptor array
1882 @retval EFI_INVALID_PARAMETER Invalid parameter
1883 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1884 @retval EFI_SUCCESS Successfully get IO space map.
1890 OUT UINTN
*NumberOfDescriptors
,
1891 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
**IoSpaceMap
1896 This is the main Dispatcher for DXE and it exits when there are no more
1897 drivers to run. Drain the mScheduledQueue and load and start a PE
1898 image for each driver. Search the mDiscoveredList to see if any driver can
1899 be placed on the mScheduledQueue. If no drivers are placed on the
1900 mScheduledQueue exit the function. On exit it is assumed the Bds()
1901 will be called, and when the Bds() exits the Dispatcher will be called
1904 @retval EFI_ALREADY_STARTED The DXE Dispatcher is already running
1905 @retval EFI_NOT_FOUND No DXE Drivers were dispatched
1906 @retval EFI_SUCCESS One or more DXE Drivers were dispatched
1916 Check every driver and locate a matching one. If the driver is found, the Unrequested
1917 state flag is cleared.
1919 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1920 the firmware file specified by DriverName.
1921 @param DriverName The Driver name to put in the Dependent state.
1923 @retval EFI_SUCCESS The DriverName was found and it's SOR bit was
1925 @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was
1932 IN EFI_HANDLE FirmwareVolumeHandle
,
1933 IN EFI_GUID
*DriverName
1938 Convert a driver from the Untrused back to the Scheduled state.
1940 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1941 the firmware file specified by DriverName.
1942 @param DriverName The Driver name to put in the Scheduled state
1944 @retval EFI_SUCCESS The file was found in the untrusted state, and it
1945 was promoted to the trusted state.
1946 @retval EFI_NOT_FOUND The file was not found in the untrusted state.
1952 IN EFI_HANDLE FirmwareVolumeHandle
,
1953 IN EFI_GUID
*DriverName
1958 This routine is the driver initialization entry point. It initializes the
1959 libraries, and registers two notification functions. These notification
1960 functions are responsible for building the FV stack dynamically.
1962 @param ImageHandle The image handle.
1963 @param SystemTable The system table.
1965 @retval EFI_SUCCESS Function successfully returned.
1971 IN EFI_HANDLE ImageHandle
,
1972 IN EFI_SYSTEM_TABLE
*SystemTable
1977 Entry point of the section extraction code. Initializes an instance of the
1978 section extraction interface and installs it on a new handle.
1980 @param ImageHandle A handle for the image that is initializing this driver
1981 @param SystemTable A pointer to the EFI system table
1983 @retval EFI_SUCCESS Driver initialized successfully
1984 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
1989 InitializeSectionExtraction (
1990 IN EFI_HANDLE ImageHandle
,
1991 IN EFI_SYSTEM_TABLE
*SystemTable
1996 This DXE service routine is used to process a firmware volume. In
1997 particular, it can be called by BDS to process a single firmware
1998 volume found in a capsule.
2000 @param FvHeader pointer to a firmware volume header
2001 @param Size the size of the buffer pointed to by FvHeader
2002 @param FVProtocolHandle the handle on which a firmware volume protocol
2003 was produced for the firmware volume passed in.
2005 @retval EFI_OUT_OF_RESOURCES if an FVB could not be produced due to lack of
2007 @retval EFI_VOLUME_CORRUPTED if the volume was corrupted
2008 @retval EFI_SUCCESS a firmware volume protocol was produced for the
2014 CoreProcessFirmwareVolume (
2017 OUT EFI_HANDLE
*FVProtocolHandle
2021 //Functions used during debug buils
2025 Displays Architectural protocols that were not loaded and are required for DXE
2026 core to function. Only used in Debug Builds.
2030 CoreDisplayMissingArchProtocols (
2036 Traverse the discovered list for any drivers that were discovered but not loaded
2037 because the dependency experessions evaluated to false.
2041 CoreDisplayDiscoveredNotDispatched (
2047 Place holder function until all the Boot Services and Runtime Services are
2050 @return EFI_NOT_AVAILABLE_YET
2055 CoreEfiNotAvailableYetArg0 (
2061 Place holder function until all the Boot Services and Runtime Services are
2064 @param Arg1 Undefined
2066 @return EFI_NOT_AVAILABLE_YET
2071 CoreEfiNotAvailableYetArg1 (
2077 Place holder function until all the Boot Services and Runtime Services are available.
2079 @param Arg1 Undefined
2080 @param Arg2 Undefined
2082 @return EFI_NOT_AVAILABLE_YET
2087 CoreEfiNotAvailableYetArg2 (
2094 Place holder function until all the Boot Services and Runtime Services are available.
2096 @param Arg1 Undefined
2097 @param Arg2 Undefined
2098 @param Arg3 Undefined
2100 @return EFI_NOT_AVAILABLE_YET
2105 CoreEfiNotAvailableYetArg3 (
2113 Place holder function until all the Boot Services and Runtime Services are available.
2115 @param Arg1 Undefined
2116 @param Arg2 Undefined
2117 @param Arg3 Undefined
2118 @param Arg4 Undefined
2120 @return EFI_NOT_AVAILABLE_YET
2125 CoreEfiNotAvailableYetArg4 (
2134 Place holder function until all the Boot Services and Runtime Services are available.
2136 @param Arg1 Undefined
2137 @param Arg2 Undefined
2138 @param Arg3 Undefined
2139 @param Arg4 Undefined
2140 @param Arg5 Undefined
2142 @return EFI_NOT_AVAILABLE_YET
2147 CoreEfiNotAvailableYetArg5 (
2157 Given a compressed source buffer, this function retrieves the size of the
2158 uncompressed buffer and the size of the scratch buffer required to decompress
2159 the compressed source buffer.
2161 The GetInfo() function retrieves the size of the uncompressed buffer and the
2162 temporary scratch buffer required to decompress the buffer specified by Source
2163 and SourceSize. If the size of the uncompressed buffer or the size of the
2164 scratch buffer cannot be determined from the compressed data specified by
2165 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
2166 size of the uncompressed buffer is returned in DestinationSize, the size of
2167 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
2168 The GetInfo() function does not have scratch buffer available to perform a
2169 thorough checking of the validity of the source data. It just retrieves the
2170 "Original Size" field from the beginning bytes of the source data and output
2171 it as DestinationSize. And ScratchSize is specific to the decompression
2174 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2175 @param Source The source buffer containing the compressed data.
2176 @param SourceSize The size, in bytes, of the source buffer.
2177 @param DestinationSize A pointer to the size, in bytes, of the
2178 uncompressed buffer that will be generated when the
2179 compressed buffer specified by Source and
2180 SourceSize is decompressed.
2181 @param ScratchSize A pointer to the size, in bytes, of the scratch
2182 buffer that is required to decompress the
2183 compressed buffer specified by Source and
2186 @retval EFI_SUCCESS The size of the uncompressed data was returned in
2187 DestinationSize and the size of the scratch buffer
2188 was returned in ScratchSize.
2189 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
2190 the scratch buffer cannot be determined from the
2191 compressed data specified by Source and
2197 DxeMainUefiDecompressGetInfo (
2198 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2200 IN UINT32 SourceSize
,
2201 OUT UINT32
*DestinationSize
,
2202 OUT UINT32
*ScratchSize
2207 Decompresses a compressed source buffer.
2209 The Decompress() function extracts decompressed data to its original form.
2210 This protocol is designed so that the decompression algorithm can be
2211 implemented without using any memory services. As a result, the Decompress()
2212 Function is not allowed to call AllocatePool() or AllocatePages() in its
2213 implementation. It is the caller's responsibility to allocate and free the
2214 Destination and Scratch buffers.
2215 If the compressed source data specified by Source and SourceSize is
2216 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
2217 the compressed source data specified by Source and SourceSize is not in a
2218 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
2220 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2221 @param Source The source buffer containing the compressed data.
2222 @param SourceSize SourceSizeThe size of source data.
2223 @param Destination On output, the destination buffer that contains
2224 the uncompressed data.
2225 @param DestinationSize The size of the destination buffer. The size of
2226 the destination buffer needed is obtained from
2227 EFI_DECOMPRESS_PROTOCOL.GetInfo().
2228 @param Scratch A temporary scratch buffer that is used to perform
2230 @param ScratchSize The size of scratch buffer. The size of the
2231 scratch buffer needed is obtained from GetInfo().
2233 @retval EFI_SUCCESS Decompression completed successfully, and the
2234 uncompressed buffer is returned in Destination.
2235 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
2236 SourceSize is corrupted (not in a valid
2242 DxeMainUefiDecompress (
2243 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2245 IN UINT32 SourceSize
,
2246 IN OUT VOID
*Destination
,
2247 IN UINT32 DestinationSize
,
2248 IN OUT VOID
*Scratch
,
2249 IN UINT32 ScratchSize
2253 SEP member function. This function creates and returns a new section stream
2254 handle to represent the new section stream.
2256 @param SectionStreamLength Size in bytes of the section stream.
2257 @param SectionStream Buffer containing the new section stream.
2258 @param SectionStreamHandle A pointer to a caller allocated UINTN that on
2259 output contains the new section stream handle.
2261 @retval EFI_SUCCESS The section stream is created successfully.
2262 @retval EFI_OUT_OF_RESOURCES memory allocation failed.
2263 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2270 IN UINTN SectionStreamLength
,
2271 IN VOID
*SectionStream
,
2272 OUT UINTN
*SectionStreamHandle
2278 SEP member function. Retrieves requested section from section stream.
2280 @param SectionStreamHandle The section stream from which to extract the
2282 @param SectionType A pointer to the type of section to search for.
2283 @param SectionDefinitionGuid If the section type is EFI_SECTION_GUID_DEFINED,
2284 then SectionDefinitionGuid indicates which of
2285 these types of sections to search for.
2286 @param SectionInstance Indicates which instance of the requested
2288 @param Buffer Double indirection to buffer. If *Buffer is
2289 non-null on input, then the buffer is caller
2290 allocated. If Buffer is NULL, then the buffer
2291 is callee allocated. In either case, the
2292 requried buffer size is returned in *BufferSize.
2293 @param BufferSize On input, indicates the size of *Buffer if
2294 *Buffer is non-null on input. On output,
2295 indicates the required size (allocated size if
2296 callee allocated) of *Buffer.
2297 @param AuthenticationStatus A pointer to a caller-allocated UINT32 that
2298 indicates the authentication status of the
2299 output buffer. If the input section's
2300 GuidedSectionHeader.Attributes field
2301 has the EFI_GUIDED_SECTION_AUTH_STATUS_VALID
2302 bit as clear, AuthenticationStatus must return
2303 zero. Both local bits (19:16) and aggregate
2304 bits (3:0) in AuthenticationStatus are returned
2305 by ExtractSection(). These bits reflect the
2306 status of the extraction operation. The bit
2307 pattern in both regions must be the same, as
2308 the local and aggregate authentication statuses
2309 have equivalent meaning at this level. If the
2310 function returns anything other than
2311 EFI_SUCCESS, the value of *AuthenticationStatus
2313 @param IsFfs3Fv Indicates the FV format.
2315 @retval EFI_SUCCESS Section was retrieved successfully
2316 @retval EFI_PROTOCOL_ERROR A GUID defined section was encountered in the
2317 section stream with its
2318 EFI_GUIDED_SECTION_PROCESSING_REQUIRED bit set,
2319 but there was no corresponding GUIDed Section
2320 Extraction Protocol in the handle database.
2321 *Buffer is unmodified.
2322 @retval EFI_NOT_FOUND An error was encountered when parsing the
2323 SectionStream. This indicates the SectionStream
2324 is not correctly formatted.
2325 @retval EFI_NOT_FOUND The requested section does not exist.
2326 @retval EFI_OUT_OF_RESOURCES The system has insufficient resources to process
2328 @retval EFI_INVALID_PARAMETER The SectionStreamHandle does not exist.
2329 @retval EFI_WARN_TOO_SMALL The size of the caller allocated input buffer is
2330 insufficient to contain the requested section.
2331 The input buffer is filled and section contents
2338 IN UINTN SectionStreamHandle
,
2339 IN EFI_SECTION_TYPE
*SectionType
,
2340 IN EFI_GUID
*SectionDefinitionGuid
,
2341 IN UINTN SectionInstance
,
2343 IN OUT UINTN
*BufferSize
,
2344 OUT UINT32
*AuthenticationStatus
,
2350 SEP member function. Deletes an existing section stream
2352 @param StreamHandleToClose Indicates the stream to close
2354 @retval EFI_SUCCESS The section stream is closed sucessfully.
2355 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
2356 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2362 CloseSectionStream (
2363 IN UINTN StreamHandleToClose
2367 Creates and initializes the DebugImageInfo Table. Also creates the configuration
2368 table and registers it into the system table.
2371 This function allocates memory, frees it, and then allocates memory at an
2372 address within the initial allocation. Since this function is called early
2373 in DXE core initialization (before drivers are dispatched), this should not
2378 CoreInitializeDebugImageInfoTable (
2384 Update the CRC32 in the Debug Table.
2385 Since the CRC32 service is made available by the Runtime driver, we have to
2386 wait for the Runtime Driver to be installed before the CRC32 can be computed.
2387 This function is called elsewhere by the core when the runtime architectural
2388 protocol is produced.
2392 CoreUpdateDebugTableCrc32 (
2398 Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
2399 the table if it's not large enough to accomidate another entry.
2401 @param ImageInfoType type of debug image information
2402 @param LoadedImage pointer to the loaded image protocol for the image being
2404 @param ImageHandle image handle for the image being loaded
2408 CoreNewDebugImageInfoEntry (
2409 IN UINT32 ImageInfoType
,
2410 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
,
2411 IN EFI_HANDLE ImageHandle
2416 Removes and frees an entry from the DebugImageInfo Table.
2418 @param ImageHandle image handle for the image being unloaded
2422 CoreRemoveDebugImageInfoEntry (
2423 EFI_HANDLE ImageHandle
2428 This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
2430 @param ImageHandle The image handle.
2431 @param SystemTable The system table.
2433 @retval EFI_SUCCESS Successfully initialized firmware volume block
2439 FwVolBlockDriverInit (
2440 IN EFI_HANDLE ImageHandle
,
2441 IN EFI_SYSTEM_TABLE
*SystemTable
2446 Get FVB authentication status
2448 @param FvbProtocol FVB protocol.
2450 @return Authentication status.
2454 GetFvbAuthenticationStatus (
2455 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
2459 This routine produces a firmware volume block protocol on a given
2462 @param BaseAddress base address of the firmware volume image
2463 @param Length length of the firmware volume image
2464 @param ParentHandle handle of parent firmware volume, if this image
2465 came from an FV image file and section in another firmware
2466 volume (ala capsules)
2467 @param AuthenticationStatus Authentication status inherited, if this image
2468 came from an FV image file and section in another firmware volume.
2469 @param FvProtocol Firmware volume block protocol produced.
2471 @retval EFI_VOLUME_CORRUPTED Volume corrupted.
2472 @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
2473 @retval EFI_SUCCESS Successfully produced a FVB protocol on given
2478 ProduceFVBProtocolOnBuffer (
2479 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2481 IN EFI_HANDLE ParentHandle
,
2482 IN UINT32 AuthenticationStatus
,
2483 OUT EFI_HANDLE
*FvProtocol OPTIONAL
2488 Raising to the task priority level of the mutual exclusion
2489 lock, and then acquires ownership of the lock.
2491 @param Lock The lock to acquire
2503 Initialize a basic mutual exclusion lock. Each lock
2504 provides mutual exclusion access at it's task priority
2505 level. Since there is no-premption (at any TPL) or
2506 multiprocessor support, acquiring the lock only consists
2507 of raising to the locks TPL.
2509 @param Lock The EFI_LOCK structure to initialize
2511 @retval EFI_SUCCESS Lock Owned.
2512 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
2516 CoreAcquireLockOrFail (
2522 Releases ownership of the mutual exclusion lock, and
2523 restores the previous task priority level.
2525 @param Lock The lock to release
2527 @return Lock unowned
2537 An empty function to pass error checking of CreateEventEx ().
2539 @param Event Event whose notification function is being invoked.
2540 @param Context Pointer to the notification function's context,
2541 which is implementation-dependent.
2546 CoreEmptyCallbackFunction (
2552 Read data from Firmware Block by FVB protocol Read.
2553 The data may cross the multi block ranges.
2555 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to read data.
2556 @param StartLba Pointer to StartLba.
2557 On input, the start logical block index from which to read.
2558 On output,the end logical block index after reading.
2559 @param Offset Pointer to Offset
2560 On input, offset into the block at which to begin reading.
2561 On output, offset into the end block after reading.
2562 @param DataSize Size of data to be read.
2563 @param Data Pointer to Buffer that the data will be read into.
2565 @retval EFI_SUCCESS Successfully read data from firmware block.
2570 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2571 IN OUT EFI_LBA
*StartLba
,
2572 IN OUT UINTN
*Offset
,
2578 Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
2579 copy the real length volume header into it.
2581 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
2582 read the volume header
2583 @param FwVolHeader Pointer to pointer to allocated buffer in which
2584 the volume header is returned.
2586 @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
2587 @retval EFI_SUCCESS Successfully read volume header to the allocated
2593 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2594 OUT EFI_FIRMWARE_VOLUME_HEADER
**FwVolHeader
2598 Verify checksum of the firmware volume header.
2600 @param FvHeader Points to the firmware volume header to be checked
2602 @retval TRUE Checksum verification passed
2603 @retval FALSE Checksum verification failed
2607 VerifyFvHeaderChecksum (
2608 IN EFI_FIRMWARE_VOLUME_HEADER
*FvHeader