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>
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_SUCCESS All the protocol interface was installed.
677 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
678 @retval EFI_ALREADY_STARTED A Device Path Protocol instance was passed in that is already present in
680 @retval EFI_INVALID_PARAMETER Handle is NULL.
681 @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.
686 CoreInstallMultipleProtocolInterfaces (
687 IN OUT EFI_HANDLE
*Handle
,
694 Uninstalls a list of protocol interface in the boot services environment.
695 This function calls UnisatllProtocolInterface() in a loop. This is
696 basically a lib function to save space.
698 @param Handle The handle to uninstall the protocol
699 @param ... EFI_GUID followed by protocol instance. A NULL
700 terminates the list. The pairs are the
701 arguments to UninstallProtocolInterface(). All
702 the protocols are added to Handle.
709 CoreUninstallMultipleProtocolInterfaces (
710 IN EFI_HANDLE Handle
,
717 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
719 @param UserHandle Handle on which the interface is to be
721 @param Protocol The numeric ID of the interface
722 @param OldInterface A pointer to the old interface
723 @param NewInterface A pointer to the new interface
725 @retval EFI_SUCCESS The protocol interface was installed
726 @retval EFI_NOT_FOUND The OldInterface on the handle was not found
727 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
732 CoreReinstallProtocolInterface (
733 IN EFI_HANDLE UserHandle
,
734 IN EFI_GUID
*Protocol
,
735 IN VOID
*OldInterface
,
736 IN VOID
*NewInterface
742 Uninstalls all instances of a protocol:interfacer from a handle.
743 If the last protocol interface is remove from the handle, the
746 @param UserHandle The handle to remove the protocol handler from
747 @param Protocol The protocol, of protocol:interface, to remove
748 @param Interface The interface, of protocol:interface, to remove
750 @retval EFI_INVALID_PARAMETER Protocol is NULL.
751 @retval EFI_SUCCESS Protocol interface successfully uninstalled.
756 CoreUninstallProtocolInterface (
757 IN EFI_HANDLE UserHandle
,
758 IN EFI_GUID
*Protocol
,
765 Queries a handle to determine if it supports a specified protocol.
767 @param UserHandle The handle being queried.
768 @param Protocol The published unique identifier of the protocol.
769 @param Interface Supplies the address where a pointer to the
770 corresponding Protocol Interface is returned.
772 @return The requested protocol interface for the handle
778 IN EFI_HANDLE UserHandle
,
779 IN EFI_GUID
*Protocol
,
786 Locates the installed protocol handler for the handle, and
787 invokes it to obtain the protocol interface. Usage information
788 is registered in the protocol data base.
790 @param UserHandle The handle to obtain the protocol interface on
791 @param Protocol The ID of the protocol
792 @param Interface The location to return the protocol interface
793 @param ImageHandle The handle of the Image that is opening the
794 protocol interface specified by Protocol and
796 @param ControllerHandle The controller handle that is requiring this
798 @param Attributes The open mode of the protocol interface
799 specified by Handle and Protocol.
801 @retval EFI_INVALID_PARAMETER Protocol is NULL.
802 @retval EFI_SUCCESS Get the protocol interface.
808 IN EFI_HANDLE UserHandle
,
809 IN EFI_GUID
*Protocol
,
810 OUT VOID
**Interface OPTIONAL
,
811 IN EFI_HANDLE ImageHandle
,
812 IN EFI_HANDLE ControllerHandle
,
819 Return information about Opened protocols in the system
821 @param UserHandle The handle to close the protocol interface on
822 @param Protocol The ID of the protocol
823 @param EntryBuffer A pointer to a buffer of open protocol
824 information in the form of
825 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
826 @param EntryCount Number of EntryBuffer entries
831 CoreOpenProtocolInformation (
832 IN EFI_HANDLE UserHandle
,
833 IN EFI_GUID
*Protocol
,
834 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
**EntryBuffer
,
835 OUT UINTN
*EntryCount
841 Closes a protocol on a handle that was opened using OpenProtocol().
843 @param UserHandle The handle for the protocol interface that was
844 previously opened with OpenProtocol(), and is
846 @param Protocol The published unique identifier of the protocol.
847 It is the caller's responsibility to pass in a
849 @param AgentHandle The handle of the agent that is closing the
851 @param ControllerHandle If the agent that opened a protocol is a driver
852 that follows the EFI Driver Model, then this
853 parameter is the controller handle that required
854 the protocol interface. If the agent does not
855 follow the EFI Driver Model, then this parameter
856 is optional and may be NULL.
858 @retval EFI_SUCCESS The protocol instance was closed.
859 @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a
861 @retval EFI_NOT_FOUND Can not find the specified protocol or
868 IN EFI_HANDLE UserHandle
,
869 IN EFI_GUID
*Protocol
,
870 IN EFI_HANDLE AgentHandle
,
871 IN EFI_HANDLE ControllerHandle
877 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
880 @param UserHandle The handle from which to retrieve the list of
881 protocol interface GUIDs.
882 @param ProtocolBuffer A pointer to the list of protocol interface GUID
883 pointers that are installed on Handle.
884 @param ProtocolBufferCount A pointer to the number of GUID pointers present
887 @retval EFI_SUCCESS The list of protocol interface GUIDs installed
888 on Handle was returned in ProtocolBuffer. The
889 number of protocol interface GUIDs was returned
890 in ProtocolBufferCount.
891 @retval EFI_INVALID_PARAMETER Handle is NULL.
892 @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
893 @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.
894 @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.
895 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
901 CoreProtocolsPerHandle (
902 IN EFI_HANDLE UserHandle
,
903 OUT EFI_GUID
***ProtocolBuffer
,
904 OUT UINTN
*ProtocolBufferCount
910 Add a new protocol notification record for the request protocol.
912 @param Protocol The requested protocol to add the notify
914 @param Event The event to signal
915 @param Registration Returns the registration record
917 @retval EFI_INVALID_PARAMETER Invalid parameter
918 @retval EFI_SUCCESS Successfully returned the registration record
924 CoreRegisterProtocolNotify (
925 IN EFI_GUID
*Protocol
,
927 OUT VOID
**Registration
932 Removes all the events in the protocol database that match Event.
934 @param Event The event to search for in the protocol
937 @return EFI_SUCCESS when done searching the entire database.
941 CoreUnregisterProtocolNotify (
947 Locates the requested handle(s) and returns them in Buffer.
949 @param SearchType The type of search to perform to locate the
951 @param Protocol The protocol to search for
952 @param SearchKey Dependant on SearchType
953 @param BufferSize On input the size of Buffer. On output the
954 size of data returned.
955 @param Buffer The buffer to return the results in
957 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
958 returned in BufferSize.
959 @retval EFI_INVALID_PARAMETER Invalid parameter
960 @retval EFI_SUCCESS Successfully found the requested handle(s) and
961 returns them in Buffer.
967 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
968 IN EFI_GUID
*Protocol OPTIONAL
,
969 IN VOID
*SearchKey OPTIONAL
,
970 IN OUT UINTN
*BufferSize
,
971 OUT EFI_HANDLE
*Buffer
977 Locates the handle to a device on the device path that best matches the specified protocol.
979 @param Protocol The protocol to search for.
980 @param DevicePath On input, a pointer to a pointer to the device
981 path. On output, the device path pointer is
982 modified to point to the remaining part of the
984 @param Device A pointer to the returned device handle.
986 @retval EFI_SUCCESS The resulting handle was returned.
987 @retval EFI_NOT_FOUND No handles matched the search.
988 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
993 CoreLocateDevicePath (
994 IN EFI_GUID
*Protocol
,
995 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
996 OUT EFI_HANDLE
*Device
1002 Function returns an array of handles that support the requested protocol
1003 in a buffer allocated from pool. This is a version of CoreLocateHandle()
1004 that allocates a buffer for the caller.
1006 @param SearchType Specifies which handle(s) are to be returned.
1007 @param Protocol Provides the protocol to search by. This
1008 parameter is only valid for SearchType
1010 @param SearchKey Supplies the search key depending on the
1012 @param NumberHandles The number of handles returned in Buffer.
1013 @param Buffer A pointer to the buffer to return the requested
1014 array of handles that support Protocol.
1016 @retval EFI_SUCCESS The result array of handles was returned.
1017 @retval EFI_NOT_FOUND No handles match the search.
1018 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
1020 @retval EFI_INVALID_PARAMETER One or more paramters are not valid.
1025 CoreLocateHandleBuffer (
1026 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1027 IN EFI_GUID
*Protocol OPTIONAL
,
1028 IN VOID
*SearchKey OPTIONAL
,
1029 IN OUT UINTN
*NumberHandles
,
1030 OUT EFI_HANDLE
**Buffer
1036 Return the first Protocol Interface that matches the Protocol GUID. If
1037 Registration is passed in, return a Protocol Instance that was just add
1038 to the system. If Registration is NULL return the first Protocol Interface
1041 @param Protocol The protocol to search for
1042 @param Registration Optional Registration Key returned from
1043 RegisterProtocolNotify()
1044 @param Interface Return the Protocol interface (instance).
1046 @retval EFI_SUCCESS If a valid Interface is returned
1047 @retval EFI_INVALID_PARAMETER Invalid parameter
1048 @retval EFI_NOT_FOUND Protocol interface not found
1053 CoreLocateProtocol (
1054 IN EFI_GUID
*Protocol
,
1055 IN VOID
*Registration OPTIONAL
,
1056 OUT VOID
**Interface
1061 return handle database key.
1064 @return Handle database key.
1068 CoreGetHandleDatabaseKey (
1074 Go connect any handles that were created or modified while a image executed.
1076 @param Key The Key to show that the handle has been
1081 CoreConnectHandlesByKey (
1088 Connects one or more drivers to a controller.
1090 @param ControllerHandle The handle of the controller to which driver(s) are to be connected.
1091 @param DriverImageHandle A pointer to an ordered list handles that support the
1092 EFI_DRIVER_BINDING_PROTOCOL.
1093 @param RemainingDevicePath A pointer to the device path that specifies a child of the
1094 controller specified by ControllerHandle.
1095 @param Recursive If TRUE, then ConnectController() is called recursively
1096 until the entire tree of controllers below the controller specified
1097 by ControllerHandle have been created. If FALSE, then
1098 the tree of controllers is only expanded one level.
1100 @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.
1101 2) No drivers were connected to ControllerHandle, but
1102 RemainingDevicePath is not NULL, and it is an End Device
1104 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1105 @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
1106 present in the system.
1107 2) No drivers were connected to ControllerHandle.
1108 @retval EFI_SECURITY_VIOLATION
1109 The user has no permission to start UEFI device drivers on the device path
1110 associated with the ControllerHandle or specified by the RemainingDevicePath.
1115 CoreConnectController (
1116 IN EFI_HANDLE ControllerHandle
,
1117 IN EFI_HANDLE
*DriverImageHandle OPTIONAL
,
1118 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
1119 IN BOOLEAN Recursive
1125 Disonnects a controller from a driver
1127 @param ControllerHandle ControllerHandle The handle of
1128 the controller from which
1131 @param DriverImageHandle DriverImageHandle The driver to
1132 disconnect from ControllerHandle.
1133 @param ChildHandle ChildHandle The handle of the
1136 @retval EFI_SUCCESS One or more drivers were
1137 disconnected from the controller.
1138 @retval EFI_SUCCESS On entry, no drivers are managing
1140 @retval EFI_SUCCESS DriverImageHandle is not NULL,
1141 and on entry DriverImageHandle is
1142 not managing ControllerHandle.
1143 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1144 @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
1145 and it is not a valid EFI_HANDLE.
1146 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
1147 is not a valid EFI_HANDLE.
1148 @retval EFI_OUT_OF_RESOURCES There are not enough resources
1149 available to disconnect any
1150 drivers from ControllerHandle.
1151 @retval EFI_DEVICE_ERROR The controller could not be
1152 disconnected because of a device
1158 CoreDisconnectController (
1159 IN EFI_HANDLE ControllerHandle
,
1160 IN EFI_HANDLE DriverImageHandle OPTIONAL
,
1161 IN EFI_HANDLE ChildHandle OPTIONAL
1167 Allocates pages from the memory map.
1169 @param Type The type of allocation to perform
1170 @param MemoryType The type of memory to turn the allocated pages
1172 @param NumberOfPages The number of pages to allocate
1173 @param Memory A pointer to receive the base allocated memory
1176 @return Status. On success, Memory is filled in with the base address allocated
1177 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
1179 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
1180 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
1181 @retval EFI_SUCCESS Pages successfully allocated.
1187 IN EFI_ALLOCATE_TYPE Type
,
1188 IN EFI_MEMORY_TYPE MemoryType
,
1189 IN UINTN NumberOfPages
,
1190 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
1196 Frees previous allocated pages.
1198 @param Memory Base address of memory being freed
1199 @param NumberOfPages The number of pages to free
1201 @retval EFI_NOT_FOUND Could not find the entry that covers the range
1202 @retval EFI_INVALID_PARAMETER Address not aligned
1203 @return EFI_SUCCESS -Pages successfully freed.
1209 IN EFI_PHYSICAL_ADDRESS Memory
,
1210 IN UINTN NumberOfPages
1216 This function returns a copy of the current memory map. The map is an array of
1217 memory descriptors, each of which describes a contiguous block of memory.
1219 @param MemoryMapSize A pointer to the size, in bytes, of the
1220 MemoryMap buffer. On input, this is the size of
1221 the buffer allocated by the caller. On output,
1222 it is the size of the buffer returned by the
1223 firmware if the buffer was large enough, or the
1224 size of the buffer needed to contain the map if
1225 the buffer was too small.
1226 @param MemoryMap A pointer to the buffer in which firmware places
1227 the current memory map.
1228 @param MapKey A pointer to the location in which firmware
1229 returns the key for the current memory map.
1230 @param DescriptorSize A pointer to the location in which firmware
1231 returns the size, in bytes, of an individual
1232 EFI_MEMORY_DESCRIPTOR.
1233 @param DescriptorVersion A pointer to the location in which firmware
1234 returns the version number associated with the
1235 EFI_MEMORY_DESCRIPTOR.
1237 @retval EFI_SUCCESS The memory map was returned in the MemoryMap
1239 @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
1240 buffer size needed to hold the memory map is
1241 returned in MemoryMapSize.
1242 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1248 IN OUT UINTN
*MemoryMapSize
,
1249 IN OUT EFI_MEMORY_DESCRIPTOR
*MemoryMap
,
1251 OUT UINTN
*DescriptorSize
,
1252 OUT UINT32
*DescriptorVersion
1258 Allocate pool of a particular type.
1260 @param PoolType Type of pool to allocate
1261 @param Size The amount of pool to allocate
1262 @param Buffer The address to return a pointer to the allocated
1265 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
1266 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
1267 @retval EFI_SUCCESS Pool successfully allocated.
1273 IN EFI_MEMORY_TYPE PoolType
,
1283 @param Buffer The allocated pool entry to free
1285 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
1286 @retval EFI_SUCCESS Pool successfully freed.
1298 Loads an EFI image into memory and returns a handle to the image.
1300 @param BootPolicy If TRUE, indicates that the request originates
1301 from the boot manager, and that the boot
1302 manager is attempting to load FilePath as a
1304 @param ParentImageHandle The caller's image handle.
1305 @param FilePath The specific file path from which the image is
1307 @param SourceBuffer If not NULL, a pointer to the memory location
1308 containing a copy of the image to be loaded.
1309 @param SourceSize The size in bytes of SourceBuffer.
1310 @param ImageHandle Pointer to the returned image handle that is
1311 created when the image is successfully loaded.
1313 @retval EFI_SUCCESS The image was loaded into memory.
1314 @retval EFI_NOT_FOUND The FilePath was not found.
1315 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1316 @retval EFI_UNSUPPORTED The image type is not supported, or the device
1317 path cannot be parsed to locate the proper
1318 protocol for loading the file.
1319 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
1321 @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
1323 @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
1324 @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
1325 image from being loaded. NULL is returned in *ImageHandle.
1326 @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
1327 valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
1328 platform policy specifies that the image should not be started.
1334 IN BOOLEAN BootPolicy
,
1335 IN EFI_HANDLE ParentImageHandle
,
1336 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
1337 IN VOID
*SourceBuffer OPTIONAL
,
1338 IN UINTN SourceSize
,
1339 OUT EFI_HANDLE
*ImageHandle
1347 @param ImageHandle Handle that identifies the image to be
1350 @retval EFI_SUCCESS The image has been unloaded.
1351 @retval EFI_UNSUPPORTED The image has been sarted, and does not support
1353 @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
1359 IN EFI_HANDLE ImageHandle
1365 Transfer control to a loaded image's entry point.
1367 @param ImageHandle Handle of image to be started.
1368 @param ExitDataSize Pointer of the size to ExitData
1369 @param ExitData Pointer to a pointer to a data buffer that
1370 includes a Null-terminated string,
1371 optionally followed by additional binary data.
1372 The string is a description that the caller may
1373 use to further indicate the reason for the
1376 @retval EFI_INVALID_PARAMETER Invalid parameter
1377 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1378 @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
1379 @retval EFI_SUCCESS Successfully transfer control to the image's
1386 IN EFI_HANDLE ImageHandle
,
1387 OUT UINTN
*ExitDataSize
,
1388 OUT CHAR16
**ExitData OPTIONAL
1394 Terminates the currently loaded EFI image and returns control to boot services.
1396 @param ImageHandle Handle that identifies the image. This
1397 parameter is passed to the image on entry.
1398 @param Status The image's exit code.
1399 @param ExitDataSize The size, in bytes, of ExitData. Ignored if
1400 ExitStatus is EFI_SUCCESS.
1401 @param ExitData Pointer to a data buffer that includes a
1402 Null-terminated Unicode string, optionally
1403 followed by additional binary data. The string
1404 is a description that the caller may use to
1405 further indicate the reason for the image's
1408 @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
1410 @retval EFI_SUCCESS Successfully terminates the currently loaded
1412 @retval EFI_ACCESS_DENIED Should never reach there.
1413 @retval EFI_OUT_OF_RESOURCES Could not allocate pool
1419 IN EFI_HANDLE ImageHandle
,
1420 IN EFI_STATUS Status
,
1421 IN UINTN ExitDataSize
,
1422 IN CHAR16
*ExitData OPTIONAL
1430 @param Type The type of event to create and its mode and
1432 @param NotifyTpl The task priority level of event notifications
1433 @param NotifyFunction Pointer to the events notification function
1434 @param NotifyContext Pointer to the notification functions context;
1435 corresponds to parameter "Context" in the
1436 notification function
1437 @param Event Pointer to the newly created event if the call
1438 succeeds; undefined otherwise
1440 @retval EFI_SUCCESS The event structure was created
1441 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1442 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1449 IN EFI_TPL NotifyTpl
,
1450 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1451 IN VOID
*NotifyContext
, OPTIONAL
1452 OUT EFI_EVENT
*Event
1458 Creates an event in a group.
1460 @param Type The type of event to create and its mode and
1462 @param NotifyTpl The task priority level of event notifications
1463 @param NotifyFunction Pointer to the events notification function
1464 @param NotifyContext Pointer to the notification functions context;
1465 corresponds to parameter "Context" in the
1466 notification function
1467 @param EventGroup GUID for EventGroup if NULL act the same as
1469 @param Event Pointer to the newly created event if the call
1470 succeeds; undefined otherwise
1472 @retval EFI_SUCCESS The event structure was created
1473 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1474 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1481 IN EFI_TPL NotifyTpl
,
1482 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1483 IN CONST VOID
*NotifyContext
, OPTIONAL
1484 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1485 OUT EFI_EVENT
*Event
1489 Creates a general-purpose event structure
1491 @param Type The type of event to create and its mode and
1493 @param NotifyTpl The task priority level of event notifications
1494 @param NotifyFunction Pointer to the events notification function
1495 @param NotifyContext Pointer to the notification functions context;
1496 corresponds to parameter "Context" in the
1497 notification function
1498 @param EventGroup GUID for EventGroup if NULL act the same as
1500 @param Event Pointer to the newly created event if the call
1501 succeeds; undefined otherwise
1503 @retval EFI_SUCCESS The event structure was created
1504 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1505 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1510 CoreCreateEventInternal (
1512 IN EFI_TPL NotifyTpl
,
1513 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1514 IN CONST VOID
*NotifyContext
, OPTIONAL
1515 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1516 OUT EFI_EVENT
*Event
1520 Sets the type of timer and the trigger time for a timer event.
1522 @param UserEvent The timer event that is to be signaled at the
1524 @param Type The type of time that is specified in
1526 @param TriggerTime The number of 100ns units until the timer
1529 @retval EFI_SUCCESS The event has been set to be signaled at the
1531 @retval EFI_INVALID_PARAMETER Event or Type is not valid
1537 IN EFI_EVENT UserEvent
,
1538 IN EFI_TIMER_DELAY Type
,
1539 IN UINT64 TriggerTime
1545 Signals the event. Queues the event to be notified if needed.
1547 @param UserEvent The event to signal .
1549 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1550 @retval EFI_SUCCESS The event was signaled.
1556 IN EFI_EVENT UserEvent
1562 Stops execution until an event is signaled.
1564 @param NumberOfEvents The number of events in the UserEvents array
1565 @param UserEvents An array of EFI_EVENT
1566 @param UserIndex Pointer to the index of the event which
1567 satisfied the wait condition
1569 @retval EFI_SUCCESS The event indicated by Index was signaled.
1570 @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification
1571 function or Event was not a valid type
1572 @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION
1578 IN UINTN NumberOfEvents
,
1579 IN EFI_EVENT
*UserEvents
,
1580 OUT UINTN
*UserIndex
1586 Closes an event and frees the event structure.
1588 @param UserEvent Event to close
1590 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1591 @retval EFI_SUCCESS The event has been closed
1597 IN EFI_EVENT UserEvent
1603 Check the status of an event.
1605 @param UserEvent The event to check
1607 @retval EFI_SUCCESS The event is in the signaled state
1608 @retval EFI_NOT_READY The event is not in the signaled state
1609 @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL
1615 IN EFI_EVENT UserEvent
1620 Adds reserved memory, system memory, or memory-mapped I/O resources to the
1621 global coherency domain of the processor.
1623 @param GcdMemoryType Memory type of the memory space.
1624 @param BaseAddress Base address of the memory space.
1625 @param Length Length of the memory space.
1626 @param Capabilities alterable attributes of the memory space.
1628 @retval EFI_SUCCESS Merged this memory space into GCD map.
1633 CoreAddMemorySpace (
1634 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1635 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1637 IN UINT64 Capabilities
1642 Allocates nonexistent memory, reserved memory, system memory, or memorymapped
1643 I/O resources from the global coherency domain of the processor.
1645 @param GcdAllocateType The type of allocate operation
1646 @param GcdMemoryType The desired memory type
1647 @param Alignment Align with 2^Alignment
1648 @param Length Length to allocate
1649 @param BaseAddress Base address to allocate
1650 @param ImageHandle The image handle consume the allocated space.
1651 @param DeviceHandle The device handle consume the allocated space.
1653 @retval EFI_INVALID_PARAMETER Invalid parameter.
1654 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1655 @retval EFI_SUCCESS Memory space successfully allocated.
1660 CoreAllocateMemorySpace (
1661 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1662 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1665 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1666 IN EFI_HANDLE ImageHandle
,
1667 IN EFI_HANDLE DeviceHandle OPTIONAL
1672 Frees nonexistent memory, reserved memory, system memory, or memory-mapped
1673 I/O resources from the global coherency domain of the processor.
1675 @param BaseAddress Base address of the memory space.
1676 @param Length Length of the memory space.
1678 @retval EFI_SUCCESS Space successfully freed.
1683 CoreFreeMemorySpace (
1684 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1690 Removes reserved memory, system memory, or memory-mapped I/O resources from
1691 the global coherency domain of the processor.
1693 @param BaseAddress Base address of the memory space.
1694 @param Length Length of the memory space.
1696 @retval EFI_SUCCESS Successfully remove a segment of memory space.
1701 CoreRemoveMemorySpace (
1702 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1708 Retrieves the descriptor for a memory region containing a specified address.
1710 @param BaseAddress Specified start address
1711 @param Descriptor Specified length
1713 @retval EFI_INVALID_PARAMETER Invalid parameter
1714 @retval EFI_SUCCESS Successfully get memory space descriptor.
1719 CoreGetMemorySpaceDescriptor (
1720 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1721 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*Descriptor
1726 Modifies the attributes for a memory region in the global coherency domain of the
1729 @param BaseAddress Specified start address
1730 @param Length Specified length
1731 @param Attributes Specified attributes
1733 @retval EFI_SUCCESS The attributes were set for the memory region.
1734 @retval EFI_INVALID_PARAMETER Length is zero.
1735 @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory
1736 resource range specified by BaseAddress and Length.
1737 @retval EFI_UNSUPPORTED The bit mask of attributes is not support for the memory resource
1738 range specified by BaseAddress and Length.
1739 @retval EFI_ACCESS_DEFINED The attributes for the memory resource range specified by
1740 BaseAddress and Length cannot be modified.
1741 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of
1742 the memory resource range.
1743 @retval EFI_NOT_AVAILABLE_YET The attributes cannot be set because CPU architectural protocol is
1749 CoreSetMemorySpaceAttributes (
1750 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1752 IN UINT64 Attributes
1757 Returns a map of the memory resources in the global coherency domain of the
1760 @param NumberOfDescriptors Number of descriptors.
1761 @param MemorySpaceMap Descriptor array
1763 @retval EFI_INVALID_PARAMETER Invalid parameter
1764 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1765 @retval EFI_SUCCESS Successfully get memory space map.
1770 CoreGetMemorySpaceMap (
1771 OUT UINTN
*NumberOfDescriptors
,
1772 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
**MemorySpaceMap
1777 Adds reserved I/O or I/O resources to the global coherency domain of the processor.
1779 @param GcdIoType IO type of the segment.
1780 @param BaseAddress Base address of the segment.
1781 @param Length Length of the segment.
1783 @retval EFI_SUCCESS Merged this segment into GCD map.
1784 @retval EFI_INVALID_PARAMETER Parameter not valid
1790 IN EFI_GCD_IO_TYPE GcdIoType
,
1791 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1797 Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1798 domain of the processor.
1800 @param GcdAllocateType The type of allocate operation
1801 @param GcdIoType The desired IO type
1802 @param Alignment Align with 2^Alignment
1803 @param Length Length to allocate
1804 @param BaseAddress Base address to allocate
1805 @param ImageHandle The image handle consume the allocated space.
1806 @param DeviceHandle The device handle consume the allocated space.
1808 @retval EFI_INVALID_PARAMETER Invalid parameter.
1809 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1810 @retval EFI_SUCCESS IO space successfully allocated.
1815 CoreAllocateIoSpace (
1816 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1817 IN EFI_GCD_IO_TYPE GcdIoType
,
1820 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1821 IN EFI_HANDLE ImageHandle
,
1822 IN EFI_HANDLE DeviceHandle OPTIONAL
1827 Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1828 domain of the processor.
1830 @param BaseAddress Base address of the segment.
1831 @param Length Length of the segment.
1833 @retval EFI_SUCCESS Space successfully freed.
1839 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1845 Removes reserved I/O or I/O resources from the global coherency domain of the
1848 @param BaseAddress Base address of the segment.
1849 @param Length Length of the segment.
1851 @retval EFI_SUCCESS Successfully removed a segment of IO space.
1857 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1863 Retrieves the descriptor for an I/O region containing a specified address.
1865 @param BaseAddress Specified start address
1866 @param Descriptor Specified length
1868 @retval EFI_INVALID_PARAMETER Descriptor is NULL.
1869 @retval EFI_SUCCESS Successfully get the IO space descriptor.
1874 CoreGetIoSpaceDescriptor (
1875 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1876 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
*Descriptor
1881 Returns a map of the I/O resources in the global coherency domain of the processor.
1883 @param NumberOfDescriptors Number of descriptors.
1884 @param IoSpaceMap Descriptor array
1886 @retval EFI_INVALID_PARAMETER Invalid parameter
1887 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1888 @retval EFI_SUCCESS Successfully get IO space map.
1894 OUT UINTN
*NumberOfDescriptors
,
1895 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
**IoSpaceMap
1900 This is the main Dispatcher for DXE and it exits when there are no more
1901 drivers to run. Drain the mScheduledQueue and load and start a PE
1902 image for each driver. Search the mDiscoveredList to see if any driver can
1903 be placed on the mScheduledQueue. If no drivers are placed on the
1904 mScheduledQueue exit the function. On exit it is assumed the Bds()
1905 will be called, and when the Bds() exits the Dispatcher will be called
1908 @retval EFI_ALREADY_STARTED The DXE Dispatcher is already running
1909 @retval EFI_NOT_FOUND No DXE Drivers were dispatched
1910 @retval EFI_SUCCESS One or more DXE Drivers were dispatched
1920 Check every driver and locate a matching one. If the driver is found, the Unrequested
1921 state flag is cleared.
1923 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1924 the firmware file specified by DriverName.
1925 @param DriverName The Driver name to put in the Dependent state.
1927 @retval EFI_SUCCESS The DriverName was found and it's SOR bit was
1929 @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was
1936 IN EFI_HANDLE FirmwareVolumeHandle
,
1937 IN EFI_GUID
*DriverName
1942 Convert a driver from the Untrused back to the Scheduled state.
1944 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1945 the firmware file specified by DriverName.
1946 @param DriverName The Driver name to put in the Scheduled state
1948 @retval EFI_SUCCESS The file was found in the untrusted state, and it
1949 was promoted to the trusted state.
1950 @retval EFI_NOT_FOUND The file was not found in the untrusted state.
1956 IN EFI_HANDLE FirmwareVolumeHandle
,
1957 IN EFI_GUID
*DriverName
1962 This routine is the driver initialization entry point. It initializes the
1963 libraries, and registers two notification functions. These notification
1964 functions are responsible for building the FV stack dynamically.
1966 @param ImageHandle The image handle.
1967 @param SystemTable The system table.
1969 @retval EFI_SUCCESS Function successfully returned.
1975 IN EFI_HANDLE ImageHandle
,
1976 IN EFI_SYSTEM_TABLE
*SystemTable
1981 Entry point of the section extraction code. Initializes an instance of the
1982 section extraction interface and installs it on a new handle.
1984 @param ImageHandle A handle for the image that is initializing this driver
1985 @param SystemTable A pointer to the EFI system table
1987 @retval EFI_SUCCESS Driver initialized successfully
1988 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
1993 InitializeSectionExtraction (
1994 IN EFI_HANDLE ImageHandle
,
1995 IN EFI_SYSTEM_TABLE
*SystemTable
2000 This DXE service routine is used to process a firmware volume. In
2001 particular, it can be called by BDS to process a single firmware
2002 volume found in a capsule.
2004 @param FvHeader pointer to a firmware volume header
2005 @param Size the size of the buffer pointed to by FvHeader
2006 @param FVProtocolHandle the handle on which a firmware volume protocol
2007 was produced for the firmware volume passed in.
2009 @retval EFI_OUT_OF_RESOURCES if an FVB could not be produced due to lack of
2011 @retval EFI_VOLUME_CORRUPTED if the volume was corrupted
2012 @retval EFI_SUCCESS a firmware volume protocol was produced for the
2018 CoreProcessFirmwareVolume (
2021 OUT EFI_HANDLE
*FVProtocolHandle
2025 //Functions used during debug buils
2029 Displays Architectural protocols that were not loaded and are required for DXE
2030 core to function. Only used in Debug Builds.
2034 CoreDisplayMissingArchProtocols (
2040 Traverse the discovered list for any drivers that were discovered but not loaded
2041 because the dependency experessions evaluated to false.
2045 CoreDisplayDiscoveredNotDispatched (
2051 Place holder function until all the Boot Services and Runtime Services are
2054 @return EFI_NOT_AVAILABLE_YET
2059 CoreEfiNotAvailableYetArg0 (
2065 Place holder function until all the Boot Services and Runtime Services are
2068 @param Arg1 Undefined
2070 @return EFI_NOT_AVAILABLE_YET
2075 CoreEfiNotAvailableYetArg1 (
2081 Place holder function until all the Boot Services and Runtime Services are available.
2083 @param Arg1 Undefined
2084 @param Arg2 Undefined
2086 @return EFI_NOT_AVAILABLE_YET
2091 CoreEfiNotAvailableYetArg2 (
2098 Place holder function until all the Boot Services and Runtime Services are available.
2100 @param Arg1 Undefined
2101 @param Arg2 Undefined
2102 @param Arg3 Undefined
2104 @return EFI_NOT_AVAILABLE_YET
2109 CoreEfiNotAvailableYetArg3 (
2117 Place holder function until all the Boot Services and Runtime Services are available.
2119 @param Arg1 Undefined
2120 @param Arg2 Undefined
2121 @param Arg3 Undefined
2122 @param Arg4 Undefined
2124 @return EFI_NOT_AVAILABLE_YET
2129 CoreEfiNotAvailableYetArg4 (
2138 Place holder function until all the Boot Services and Runtime Services are available.
2140 @param Arg1 Undefined
2141 @param Arg2 Undefined
2142 @param Arg3 Undefined
2143 @param Arg4 Undefined
2144 @param Arg5 Undefined
2146 @return EFI_NOT_AVAILABLE_YET
2151 CoreEfiNotAvailableYetArg5 (
2161 Given a compressed source buffer, this function retrieves the size of the
2162 uncompressed buffer and the size of the scratch buffer required to decompress
2163 the compressed source buffer.
2165 The GetInfo() function retrieves the size of the uncompressed buffer and the
2166 temporary scratch buffer required to decompress the buffer specified by Source
2167 and SourceSize. If the size of the uncompressed buffer or the size of the
2168 scratch buffer cannot be determined from the compressed data specified by
2169 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
2170 size of the uncompressed buffer is returned in DestinationSize, the size of
2171 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
2172 The GetInfo() function does not have scratch buffer available to perform a
2173 thorough checking of the validity of the source data. It just retrieves the
2174 "Original Size" field from the beginning bytes of the source data and output
2175 it as DestinationSize. And ScratchSize is specific to the decompression
2178 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2179 @param Source The source buffer containing the compressed data.
2180 @param SourceSize The size, in bytes, of the source buffer.
2181 @param DestinationSize A pointer to the size, in bytes, of the
2182 uncompressed buffer that will be generated when the
2183 compressed buffer specified by Source and
2184 SourceSize is decompressed.
2185 @param ScratchSize A pointer to the size, in bytes, of the scratch
2186 buffer that is required to decompress the
2187 compressed buffer specified by Source and
2190 @retval EFI_SUCCESS The size of the uncompressed data was returned in
2191 DestinationSize and the size of the scratch buffer
2192 was returned in ScratchSize.
2193 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
2194 the scratch buffer cannot be determined from the
2195 compressed data specified by Source and
2201 DxeMainUefiDecompressGetInfo (
2202 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2204 IN UINT32 SourceSize
,
2205 OUT UINT32
*DestinationSize
,
2206 OUT UINT32
*ScratchSize
2211 Decompresses a compressed source buffer.
2213 The Decompress() function extracts decompressed data to its original form.
2214 This protocol is designed so that the decompression algorithm can be
2215 implemented without using any memory services. As a result, the Decompress()
2216 Function is not allowed to call AllocatePool() or AllocatePages() in its
2217 implementation. It is the caller's responsibility to allocate and free the
2218 Destination and Scratch buffers.
2219 If the compressed source data specified by Source and SourceSize is
2220 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
2221 the compressed source data specified by Source and SourceSize is not in a
2222 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
2224 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2225 @param Source The source buffer containing the compressed data.
2226 @param SourceSize SourceSizeThe size of source data.
2227 @param Destination On output, the destination buffer that contains
2228 the uncompressed data.
2229 @param DestinationSize The size of the destination buffer. The size of
2230 the destination buffer needed is obtained from
2231 EFI_DECOMPRESS_PROTOCOL.GetInfo().
2232 @param Scratch A temporary scratch buffer that is used to perform
2234 @param ScratchSize The size of scratch buffer. The size of the
2235 scratch buffer needed is obtained from GetInfo().
2237 @retval EFI_SUCCESS Decompression completed successfully, and the
2238 uncompressed buffer is returned in Destination.
2239 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
2240 SourceSize is corrupted (not in a valid
2246 DxeMainUefiDecompress (
2247 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2249 IN UINT32 SourceSize
,
2250 IN OUT VOID
*Destination
,
2251 IN UINT32 DestinationSize
,
2252 IN OUT VOID
*Scratch
,
2253 IN UINT32 ScratchSize
2257 SEP member function. This function creates and returns a new section stream
2258 handle to represent the new section stream.
2260 @param SectionStreamLength Size in bytes of the section stream.
2261 @param SectionStream Buffer containing the new section stream.
2262 @param SectionStreamHandle A pointer to a caller allocated UINTN that on
2263 output contains the new section stream handle.
2265 @retval EFI_SUCCESS The section stream is created successfully.
2266 @retval EFI_OUT_OF_RESOURCES memory allocation failed.
2267 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2274 IN UINTN SectionStreamLength
,
2275 IN VOID
*SectionStream
,
2276 OUT UINTN
*SectionStreamHandle
2282 SEP member function. Retrieves requested section from section stream.
2284 @param SectionStreamHandle The section stream from which to extract the
2286 @param SectionType A pointer to the type of section to search for.
2287 @param SectionDefinitionGuid If the section type is EFI_SECTION_GUID_DEFINED,
2288 then SectionDefinitionGuid indicates which of
2289 these types of sections to search for.
2290 @param SectionInstance Indicates which instance of the requested
2292 @param Buffer Double indirection to buffer. If *Buffer is
2293 non-null on input, then the buffer is caller
2294 allocated. If Buffer is NULL, then the buffer
2295 is callee allocated. In either case, the
2296 requried buffer size is returned in *BufferSize.
2297 @param BufferSize On input, indicates the size of *Buffer if
2298 *Buffer is non-null on input. On output,
2299 indicates the required size (allocated size if
2300 callee allocated) of *Buffer.
2301 @param AuthenticationStatus A pointer to a caller-allocated UINT32 that
2302 indicates the authentication status of the
2303 output buffer. If the input section's
2304 GuidedSectionHeader.Attributes field
2305 has the EFI_GUIDED_SECTION_AUTH_STATUS_VALID
2306 bit as clear, AuthenticationStatus must return
2307 zero. Both local bits (19:16) and aggregate
2308 bits (3:0) in AuthenticationStatus are returned
2309 by ExtractSection(). These bits reflect the
2310 status of the extraction operation. The bit
2311 pattern in both regions must be the same, as
2312 the local and aggregate authentication statuses
2313 have equivalent meaning at this level. If the
2314 function returns anything other than
2315 EFI_SUCCESS, the value of *AuthenticationStatus
2317 @param IsFfs3Fv Indicates the FV format.
2319 @retval EFI_SUCCESS Section was retrieved successfully
2320 @retval EFI_PROTOCOL_ERROR A GUID defined section was encountered in the
2321 section stream with its
2322 EFI_GUIDED_SECTION_PROCESSING_REQUIRED bit set,
2323 but there was no corresponding GUIDed Section
2324 Extraction Protocol in the handle database.
2325 *Buffer is unmodified.
2326 @retval EFI_NOT_FOUND An error was encountered when parsing the
2327 SectionStream. This indicates the SectionStream
2328 is not correctly formatted.
2329 @retval EFI_NOT_FOUND The requested section does not exist.
2330 @retval EFI_OUT_OF_RESOURCES The system has insufficient resources to process
2332 @retval EFI_INVALID_PARAMETER The SectionStreamHandle does not exist.
2333 @retval EFI_WARN_TOO_SMALL The size of the caller allocated input buffer is
2334 insufficient to contain the requested section.
2335 The input buffer is filled and section contents
2342 IN UINTN SectionStreamHandle
,
2343 IN EFI_SECTION_TYPE
*SectionType
,
2344 IN EFI_GUID
*SectionDefinitionGuid
,
2345 IN UINTN SectionInstance
,
2347 IN OUT UINTN
*BufferSize
,
2348 OUT UINT32
*AuthenticationStatus
,
2354 SEP member function. Deletes an existing section stream
2356 @param StreamHandleToClose Indicates the stream to close
2358 @retval EFI_SUCCESS The section stream is closed sucessfully.
2359 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
2360 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2366 CloseSectionStream (
2367 IN UINTN StreamHandleToClose
2371 Creates and initializes the DebugImageInfo Table. Also creates the configuration
2372 table and registers it into the system table.
2375 This function allocates memory, frees it, and then allocates memory at an
2376 address within the initial allocation. Since this function is called early
2377 in DXE core initialization (before drivers are dispatched), this should not
2382 CoreInitializeDebugImageInfoTable (
2388 Update the CRC32 in the Debug Table.
2389 Since the CRC32 service is made available by the Runtime driver, we have to
2390 wait for the Runtime Driver to be installed before the CRC32 can be computed.
2391 This function is called elsewhere by the core when the runtime architectural
2392 protocol is produced.
2396 CoreUpdateDebugTableCrc32 (
2402 Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
2403 the table if it's not large enough to accomidate another entry.
2405 @param ImageInfoType type of debug image information
2406 @param LoadedImage pointer to the loaded image protocol for the image being
2408 @param ImageHandle image handle for the image being loaded
2412 CoreNewDebugImageInfoEntry (
2413 IN UINT32 ImageInfoType
,
2414 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
,
2415 IN EFI_HANDLE ImageHandle
2420 Removes and frees an entry from the DebugImageInfo Table.
2422 @param ImageHandle image handle for the image being unloaded
2426 CoreRemoveDebugImageInfoEntry (
2427 EFI_HANDLE ImageHandle
2432 This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
2434 @param ImageHandle The image handle.
2435 @param SystemTable The system table.
2437 @retval EFI_SUCCESS Successfully initialized firmware volume block
2443 FwVolBlockDriverInit (
2444 IN EFI_HANDLE ImageHandle
,
2445 IN EFI_SYSTEM_TABLE
*SystemTable
2450 Get FVB authentication status
2452 @param FvbProtocol FVB protocol.
2454 @return Authentication status.
2458 GetFvbAuthenticationStatus (
2459 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
2463 This routine produces a firmware volume block protocol on a given
2466 @param BaseAddress base address of the firmware volume image
2467 @param Length length of the firmware volume image
2468 @param ParentHandle handle of parent firmware volume, if this image
2469 came from an FV image file and section in another firmware
2470 volume (ala capsules)
2471 @param AuthenticationStatus Authentication status inherited, if this image
2472 came from an FV image file and section in another firmware volume.
2473 @param FvProtocol Firmware volume block protocol produced.
2475 @retval EFI_VOLUME_CORRUPTED Volume corrupted.
2476 @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
2477 @retval EFI_SUCCESS Successfully produced a FVB protocol on given
2482 ProduceFVBProtocolOnBuffer (
2483 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2485 IN EFI_HANDLE ParentHandle
,
2486 IN UINT32 AuthenticationStatus
,
2487 OUT EFI_HANDLE
*FvProtocol OPTIONAL
2492 Raising to the task priority level of the mutual exclusion
2493 lock, and then acquires ownership of the lock.
2495 @param Lock The lock to acquire
2507 Initialize a basic mutual exclusion lock. Each lock
2508 provides mutual exclusion access at it's task priority
2509 level. Since there is no-premption (at any TPL) or
2510 multiprocessor support, acquiring the lock only consists
2511 of raising to the locks TPL.
2513 @param Lock The EFI_LOCK structure to initialize
2515 @retval EFI_SUCCESS Lock Owned.
2516 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
2520 CoreAcquireLockOrFail (
2526 Releases ownership of the mutual exclusion lock, and
2527 restores the previous task priority level.
2529 @param Lock The lock to release
2531 @return Lock unowned
2541 An empty function to pass error checking of CreateEventEx ().
2543 @param Event Event whose notification function is being invoked.
2544 @param Context Pointer to the notification function's context,
2545 which is implementation-dependent.
2550 CoreEmptyCallbackFunction (
2556 Read data from Firmware Block by FVB protocol Read.
2557 The data may cross the multi block ranges.
2559 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to read data.
2560 @param StartLba Pointer to StartLba.
2561 On input, the start logical block index from which to read.
2562 On output,the end logical block index after reading.
2563 @param Offset Pointer to Offset
2564 On input, offset into the block at which to begin reading.
2565 On output, offset into the end block after reading.
2566 @param DataSize Size of data to be read.
2567 @param Data Pointer to Buffer that the data will be read into.
2569 @retval EFI_SUCCESS Successfully read data from firmware block.
2574 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2575 IN OUT EFI_LBA
*StartLba
,
2576 IN OUT UINTN
*Offset
,
2582 Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
2583 copy the real length volume header into it.
2585 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
2586 read the volume header
2587 @param FwVolHeader Pointer to pointer to allocated buffer in which
2588 the volume header is returned.
2590 @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
2591 @retval EFI_SUCCESS Successfully read volume header to the allocated
2597 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2598 OUT EFI_FIRMWARE_VOLUME_HEADER
**FwVolHeader
2602 Verify checksum of the firmware volume header.
2604 @param FvHeader Points to the firmware volume header to be checked
2606 @retval TRUE Checksum verification passed
2607 @retval FALSE Checksum verification failed
2611 VerifyFvHeaderChecksum (
2612 IN EFI_FIRMWARE_VOLUME_HEADER
*FvHeader