2 The internal header file includes the common header files, defines
3 internal structure and functions used by DxeCore module.
5 Copyright (c) 2006 - 2010, Intel Corporation. <BR>
6 All rights reserved. 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/Ebc.h>
45 #include <Protocol/Reset.h>
46 #include <Protocol/Cpu.h>
47 #include <Protocol/Metronome.h>
48 #include <Protocol/FirmwareVolumeBlock.h>
49 #include <Protocol/Capsule.h>
50 #include <Protocol/BusSpecificDriverOverride.h>
51 #include <Protocol/TcgService.h>
52 #include <Protocol/HiiPackageList.h>
53 #include <Protocol/SmmBase2.h>
54 #include <Guid/MemoryTypeInformation.h>
55 #include <Guid/FirmwareFileSystem2.h>
56 #include <Guid/HobList.h>
57 #include <Guid/DebugImageInfoTable.h>
58 #include <Guid/FileInfo.h>
59 #include <Guid/Apriori.h>
60 #include <Guid/DxeServices.h>
61 #include <Guid/MemoryAllocationHob.h>
62 #include <Guid/EventLegacyBios.h>
63 #include <Guid/EventGroup.h>
64 #include <Guid/LoadModuleAtFixedAddress.h>
66 #include <Library/DxeCoreEntryPoint.h>
67 #include <Library/DebugLib.h>
68 #include <Library/UefiLib.h>
69 #include <Library/BaseLib.h>
70 #include <Library/HobLib.h>
71 #include <Library/PerformanceLib.h>
72 #include <Library/UefiDecompressLib.h>
73 #include <Library/ExtractGuidedSectionLib.h>
74 #include <Library/CacheMaintenanceLib.h>
75 #include <Library/BaseMemoryLib.h>
76 #include <Library/PeCoffLib.h>
77 #include <Library/PcdLib.h>
78 #include <Library/MemoryAllocationLib.h>
79 #include <Library/DevicePathLib.h>
80 #include <Library/UefiBootServicesTableLib.h>
81 #include <Library/ReportStatusCodeLib.h>
82 #include <Library/TimerLib.h>
83 #include <Library/DxeServicesLib.h>
87 // attributes for reserved memory before it is promoted to system memory
89 #define EFI_MEMORY_PRESENT 0x0100000000000000ULL
90 #define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL
91 #define EFI_MEMORY_TESTED 0x0400000000000000ULL
94 // range for memory mapped port I/O on IPF
96 #define EFI_MEMORY_PORT_IO 0x4000000000000000ULL
100 /// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependecy expression
101 /// to save time. A EFI_DEP_PUSH is evauated one an
102 /// replaced with EFI_DEP_REPLACE_TRUE. If PI spec's Vol 2
103 /// Driver Execution Environment Core Interface use 0xff
104 /// as new DEPEX opcode. EFI_DEP_REPLACE_TRUE should be
105 /// defined to a new value that is not conflicting with PI spec.
107 #define EFI_DEP_REPLACE_TRUE 0xff
110 /// Define the initial size of the dependency expression evaluation stack
112 #define DEPEX_STACK_SIZE_INCREMENT 0x1000
115 EFI_GUID
*ProtocolGuid
;
120 BOOLEAN ArchitecturalProtocol
;
121 } ARCHITECTURAL_PROTOCOL_ENTRY
;
124 // DXE Dispatcher Data structures
127 #define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w')
130 LIST_ENTRY Link
; // mFvHandleList
135 #define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r')
138 LIST_ENTRY Link
; // mDriverList
140 LIST_ENTRY ScheduledLink
; // mScheduledQueue
144 EFI_DEVICE_PATH_PROTOCOL
*FvFileDevicePath
;
145 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
152 EFI_GUID BeforeAfterGuid
;
159 BOOLEAN DepexProtocolError
;
161 EFI_HANDLE ImageHandle
;
163 } EFI_CORE_DRIVER_ENTRY
;
166 //The data structure of GCD memory map entry
168 #define EFI_GCD_MAP_SIGNATURE SIGNATURE_32('g','c','d','m')
172 EFI_PHYSICAL_ADDRESS BaseAddress
;
176 EFI_GCD_MEMORY_TYPE GcdMemoryType
;
177 EFI_GCD_IO_TYPE GcdIoType
;
178 EFI_HANDLE ImageHandle
;
179 EFI_HANDLE DeviceHandle
;
183 // DXE Core Global Variables
185 extern EFI_SYSTEM_TABLE
*gDxeCoreST
;
186 extern EFI_RUNTIME_SERVICES
*gDxeCoreRT
;
187 extern EFI_DXE_SERVICES
*gDxeCoreDS
;
188 extern EFI_HANDLE gDxeCoreImageHandle
;
190 extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress
;
192 extern EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
;
193 extern EFI_CPU_ARCH_PROTOCOL
*gCpu
;
194 extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL
*gWatchdogTimer
;
195 extern EFI_METRONOME_ARCH_PROTOCOL
*gMetronome
;
196 extern EFI_TIMER_ARCH_PROTOCOL
*gTimer
;
197 extern EFI_SECURITY_ARCH_PROTOCOL
*gSecurity
;
198 extern EFI_BDS_ARCH_PROTOCOL
*gBds
;
199 extern EFI_SMM_BASE2_PROTOCOL
*gSmmBase2
;
201 extern EFI_TPL gEfiCurrentTpl
;
203 extern EFI_GUID
*gDxeCoreFileName
;
204 extern EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
206 extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation
[EfiMaxMemoryType
+ 1];
208 extern BOOLEAN gDispatcherRunning
;
209 extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
;
211 extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable
;
212 extern BOOLEAN gLoadFixedAddressCodeMemoryReady
;
214 // Service Initialization Functions
220 Called to initialize the pool.
230 Called to initialize the memory map and add descriptors to
231 the current descriptor list.
232 The first descriptor that is added must be general usable
233 memory as the addition allocates heap.
235 @param Type The type of memory to add
236 @param Start The starting address in the memory range Must be
238 @param NumberOfPages The number of pages in the range
239 @param Attribute Attributes of the memory to add
241 @return None. The range is added to the memory map
245 CoreAddMemoryDescriptor (
246 IN EFI_MEMORY_TYPE Type
,
247 IN EFI_PHYSICAL_ADDRESS Start
,
248 IN UINT64 NumberOfPages
,
254 Release memory lock on mGcdMemorySpaceLock.
258 CoreReleaseGcdMemoryLock (
264 Acquire memory lock on mGcdMemorySpaceLock.
268 CoreAcquireGcdMemoryLock (
274 External function. Initializes memory services based on the memory
275 descriptor HOBs. This function is responsible for priming the memory
276 map, so memory allocations and resource allocations can be made.
277 The first part of this function can not depend on any memory services
278 until at least one memory descriptor is provided to the memory services.
280 @param HobStart The start address of the HOB.
281 @param MemoryBaseAddress Start address of memory region found to init DXE
283 @param MemoryLength Length of memory region found to init DXE core.
285 @retval EFI_SUCCESS Memory services successfully initialized.
289 CoreInitializeMemoryServices (
291 OUT EFI_PHYSICAL_ADDRESS
*MemoryBaseAddress
,
292 OUT UINT64
*MemoryLength
298 External function. Initializes the GCD and memory services based on the memory
299 descriptor HOBs. This function is responsible for priming the GCD map and the
300 memory map, so memory allocations and resource allocations can be made. The
301 HobStart will be relocated to a pool buffer.
303 @param HobStart The start address of the HOB
304 @param MemoryBaseAddress Start address of memory region found to init DXE
306 @param MemoryLength Length of memory region found to init DXE core.
308 @retval EFI_SUCCESS GCD services successfully initialized.
312 CoreInitializeGcdServices (
313 IN OUT VOID
**HobStart
,
314 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress
,
315 IN UINT64 MemoryLength
320 Initializes "event" support.
322 @retval EFI_SUCCESS Always return success
326 CoreInitializeEventServices (
332 Add the Image Services to EFI Boot Services Table and install the protocol
333 interfaces for this image.
335 @param HobStart The HOB to initialize
341 CoreInitializeImageServices (
347 Creates an event that is fired everytime a Protocol of a specific type is installed.
351 CoreNotifyOnArchProtocolInstallation (
357 Return TRUE if all AP services are availible.
359 @retval EFI_SUCCESS All AP services are available
360 @retval EFI_NOT_FOUND At least one AP service is not available
364 CoreAllEfiServicesAvailable (
370 Calcualte the 32-bit CRC in a EFI table using the service provided by the
373 @param Hdr Pointer to an EFI standard header
378 IN OUT EFI_TABLE_HEADER
*Hdr
383 Called by the platform code to process a tick.
385 @param Duration The number of 100ns elasped since the last call
397 Initialize the dispatcher. Initialize the notification function that runs when
398 an FV2 protocol is added to the system.
402 CoreInitializeDispatcher (
408 This is the POSTFIX version of the dependency evaluator. This code does
409 not need to handle Before or After, as it is not valid to call this
410 routine in this case. The SOR is just ignored and is a nop in the grammer.
411 POSTFIX means all the math is done on top of the stack.
413 @param DriverEntry DriverEntry element to update.
415 @retval TRUE If driver is ready to run.
416 @retval FALSE If driver is not ready to run or some fatal error
422 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
427 Preprocess dependency expression and update DriverEntry to reflect the
428 state of Before, After, and SOR dependencies. If DriverEntry->Before
429 or DriverEntry->After is set it will never be cleared. If SOR is set
430 it will be cleared by CoreSchedule(), and then the driver can be
433 @param DriverEntry DriverEntry element to update .
435 @retval EFI_SUCCESS It always works.
439 CorePreProcessDepex (
440 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
446 Terminates all boot services.
448 @param ImageHandle Handle that identifies the exiting image.
449 @param MapKey Key to the latest memory map.
451 @retval EFI_SUCCESS Boot Services terminated
452 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
457 CoreExitBootServices (
458 IN EFI_HANDLE ImageHandle
,
464 Make sure the memory map is following all the construction rules,
465 it is the last time to check memory map error before exit boot services.
467 @param MapKey Memory map key
469 @retval EFI_INVALID_PARAMETER Memory map not consistent with construction
471 @retval EFI_SUCCESS Valid memory map.
475 CoreTerminateMemoryMap (
481 Signals all events in the EventGroup.
483 @param EventGroup The list to signal
487 CoreNotifySignalList (
488 IN EFI_GUID
*EventGroup
494 Boot Service called to add, modify, or remove a system configuration table from
495 the EFI System Table.
497 @param Guid Pointer to the GUID for the entry to add, update, or
499 @param Table Pointer to the configuration table for the entry to add,
500 update, or remove, may be NULL.
502 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.
503 @return EFI_INVALID_PARAMETER Input GUID not valid.
504 @return EFI_NOT_FOUND Attempted to delete non-existant entry
505 @return EFI_OUT_OF_RESOURCES Not enough memory available
510 CoreInstallConfigurationTable (
518 Raise the task priority level to the new level.
519 High level is implemented by disabling processor interrupts.
521 @param NewTpl New task priority level
523 @return The previous task priority level
535 Lowers the task priority to the previous value. If the new
536 priority unmasks events at a higher priority, they are dispatched.
538 @param NewTpl New, lower, task priority
550 Introduces a fine-grained stall.
552 @param Microseconds The number of microseconds to stall execution.
554 @retval EFI_SUCCESS Execution was stalled for at least the requested
555 amount of microseconds.
556 @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet
562 IN UINTN Microseconds
568 Sets the system's watchdog timer.
570 @param Timeout The number of seconds to set the watchdog timer to.
571 A value of zero disables the timer.
572 @param WatchdogCode The numeric code to log on a watchdog timer timeout
573 event. The firmware reserves codes 0x0000 to 0xFFFF.
574 Loaders and operating systems may use other timeout
576 @param DataSize The size, in bytes, of WatchdogData.
577 @param WatchdogData A data buffer that includes a Null-terminated Unicode
578 string, optionally followed by additional binary data.
579 The string is a description that the call may use to
580 further indicate the reason to be logged with a
583 @return EFI_SUCCESS Timeout has been set
584 @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
585 @return EFI_UNSUPPORTED System does not have a timer (currently not used)
586 @return EFI_DEVICE_ERROR Could not complete due to hardware error
591 CoreSetWatchdogTimer (
593 IN UINT64 WatchdogCode
,
595 IN CHAR16
*WatchdogData OPTIONAL
601 Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
602 Calls the private one which contains a BOOLEAN parameter for notifications
604 @param UserHandle The handle to install the protocol handler on,
605 or NULL if a new handle is to be allocated
606 @param Protocol The protocol to add to the handle
607 @param InterfaceType Indicates whether Interface is supplied in
609 @param Interface The interface for the protocol being added
616 CoreInstallProtocolInterface (
617 IN OUT EFI_HANDLE
*UserHandle
,
618 IN EFI_GUID
*Protocol
,
619 IN EFI_INTERFACE_TYPE InterfaceType
,
625 Installs a protocol interface into the boot services environment.
627 @param UserHandle The handle to install the protocol handler on,
628 or NULL if a new handle is to be allocated
629 @param Protocol The protocol to add to the handle
630 @param InterfaceType Indicates whether Interface is supplied in
632 @param Interface The interface for the protocol being added
633 @param Notify indicates whether notify the notification list
636 @retval EFI_INVALID_PARAMETER Invalid parameter
637 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
638 @retval EFI_SUCCESS Protocol interface successfully installed
642 CoreInstallProtocolInterfaceNotify (
643 IN OUT EFI_HANDLE
*UserHandle
,
644 IN EFI_GUID
*Protocol
,
645 IN EFI_INTERFACE_TYPE InterfaceType
,
653 Installs a list of protocol interface into the boot services environment.
654 This function calls InstallProtocolInterface() in a loop. If any error
655 occures all the protocols added by this function are removed. This is
656 basically a lib function to save space.
658 @param Handle The handle to install the protocol handlers on,
659 or NULL if a new handle is to be allocated
660 @param ... EFI_GUID followed by protocol instance. A NULL
661 terminates the list. The pairs are the
662 arguments to InstallProtocolInterface(). All the
663 protocols are added to Handle.
665 @retval EFI_INVALID_PARAMETER Handle is NULL.
666 @retval EFI_SUCCESS Protocol interfaces successfully installed.
671 CoreInstallMultipleProtocolInterfaces (
672 IN OUT EFI_HANDLE
*Handle
,
679 Uninstalls a list of protocol interface in the boot services environment.
680 This function calls UnisatllProtocolInterface() in a loop. This is
681 basically a lib function to save space.
683 @param Handle The handle to uninstall the protocol
684 @param ... EFI_GUID followed by protocol instance. A NULL
685 terminates the list. The pairs are the
686 arguments to UninstallProtocolInterface(). All
687 the protocols are added to Handle.
694 CoreUninstallMultipleProtocolInterfaces (
695 IN EFI_HANDLE Handle
,
702 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
704 @param UserHandle Handle on which the interface is to be
706 @param Protocol The numeric ID of the interface
707 @param OldInterface A pointer to the old interface
708 @param NewInterface A pointer to the new interface
710 @retval EFI_SUCCESS The protocol interface was installed
711 @retval EFI_NOT_FOUND The OldInterface on the handle was not found
712 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
717 CoreReinstallProtocolInterface (
718 IN EFI_HANDLE UserHandle
,
719 IN EFI_GUID
*Protocol
,
720 IN VOID
*OldInterface
,
721 IN VOID
*NewInterface
727 Uninstalls all instances of a protocol:interfacer from a handle.
728 If the last protocol interface is remove from the handle, the
731 @param UserHandle The handle to remove the protocol handler from
732 @param Protocol The protocol, of protocol:interface, to remove
733 @param Interface The interface, of protocol:interface, to remove
735 @retval EFI_INVALID_PARAMETER Protocol is NULL.
736 @retval EFI_SUCCESS Protocol interface successfully uninstalled.
741 CoreUninstallProtocolInterface (
742 IN EFI_HANDLE UserHandle
,
743 IN EFI_GUID
*Protocol
,
750 Queries a handle to determine if it supports a specified protocol.
752 @param UserHandle The handle being queried.
753 @param Protocol The published unique identifier of the protocol.
754 @param Interface Supplies the address where a pointer to the
755 corresponding Protocol Interface is returned.
757 @return The requested protocol interface for the handle
763 IN EFI_HANDLE UserHandle
,
764 IN EFI_GUID
*Protocol
,
771 Locates the installed protocol handler for the handle, and
772 invokes it to obtain the protocol interface. Usage information
773 is registered in the protocol data base.
775 @param UserHandle The handle to obtain the protocol interface on
776 @param Protocol The ID of the protocol
777 @param Interface The location to return the protocol interface
778 @param ImageHandle The handle of the Image that is opening the
779 protocol interface specified by Protocol and
781 @param ControllerHandle The controller handle that is requiring this
783 @param Attributes The open mode of the protocol interface
784 specified by Handle and Protocol.
786 @retval EFI_INVALID_PARAMETER Protocol is NULL.
787 @retval EFI_SUCCESS Get the protocol interface.
793 IN EFI_HANDLE UserHandle
,
794 IN EFI_GUID
*Protocol
,
795 OUT VOID
**Interface OPTIONAL
,
796 IN EFI_HANDLE ImageHandle
,
797 IN EFI_HANDLE ControllerHandle
,
804 Return information about Opened protocols in the system
806 @param UserHandle The handle to close the protocol interface on
807 @param Protocol The ID of the protocol
808 @param EntryBuffer A pointer to a buffer of open protocol
809 information in the form of
810 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
811 @param EntryCount Number of EntryBuffer entries
816 CoreOpenProtocolInformation (
817 IN EFI_HANDLE UserHandle
,
818 IN EFI_GUID
*Protocol
,
819 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
**EntryBuffer
,
820 OUT UINTN
*EntryCount
826 Closes a protocol on a handle that was opened using OpenProtocol().
828 @param UserHandle The handle for the protocol interface that was
829 previously opened with OpenProtocol(), and is
831 @param Protocol The published unique identifier of the protocol.
832 It is the caller's responsibility to pass in a
834 @param AgentHandle The handle of the agent that is closing the
836 @param ControllerHandle If the agent that opened a protocol is a driver
837 that follows the EFI Driver Model, then this
838 parameter is the controller handle that required
839 the protocol interface. If the agent does not
840 follow the EFI Driver Model, then this parameter
841 is optional and may be NULL.
843 @retval EFI_SUCCESS The protocol instance was closed.
844 @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a
846 @retval EFI_NOT_FOUND Can not find the specified protocol or
853 IN EFI_HANDLE UserHandle
,
854 IN EFI_GUID
*Protocol
,
855 IN EFI_HANDLE AgentHandle
,
856 IN EFI_HANDLE ControllerHandle
862 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
865 @param UserHandle The handle from which to retrieve the list of
866 protocol interface GUIDs.
867 @param ProtocolBuffer A pointer to the list of protocol interface GUID
868 pointers that are installed on Handle.
869 @param ProtocolBufferCount A pointer to the number of GUID pointers present
872 @retval EFI_SUCCESS The list of protocol interface GUIDs installed
873 on Handle was returned in ProtocolBuffer. The
874 number of protocol interface GUIDs was returned
875 in ProtocolBufferCount.
876 @retval EFI_INVALID_PARAMETER Handle is NULL.
877 @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
878 @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.
879 @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.
880 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
886 CoreProtocolsPerHandle (
887 IN EFI_HANDLE UserHandle
,
888 OUT EFI_GUID
***ProtocolBuffer
,
889 OUT UINTN
*ProtocolBufferCount
895 Add a new protocol notification record for the request protocol.
897 @param Protocol The requested protocol to add the notify
899 @param Event The event to signal
900 @param Registration Returns the registration record
902 @retval EFI_INVALID_PARAMETER Invalid parameter
903 @retval EFI_SUCCESS Successfully returned the registration record
909 CoreRegisterProtocolNotify (
910 IN EFI_GUID
*Protocol
,
912 OUT VOID
**Registration
917 Removes all the events in the protocol database that match Event.
919 @param Event The event to search for in the protocol
922 @return EFI_SUCCESS when done searching the entire database.
926 CoreUnregisterProtocolNotify (
932 Locates the requested handle(s) and returns them in Buffer.
934 @param SearchType The type of search to perform to locate the
936 @param Protocol The protocol to search for
937 @param SearchKey Dependant on SearchType
938 @param BufferSize On input the size of Buffer. On output the
939 size of data returned.
940 @param Buffer The buffer to return the results in
942 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
943 returned in BufferSize.
944 @retval EFI_INVALID_PARAMETER Invalid parameter
945 @retval EFI_SUCCESS Successfully found the requested handle(s) and
946 returns them in Buffer.
952 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
953 IN EFI_GUID
*Protocol OPTIONAL
,
954 IN VOID
*SearchKey OPTIONAL
,
955 IN OUT UINTN
*BufferSize
,
956 OUT EFI_HANDLE
*Buffer
962 Locates the handle to a device on the device path that best matches the specified protocol.
964 @param Protocol The protocol to search for.
965 @param DevicePath On input, a pointer to a pointer to the device
966 path. On output, the device path pointer is
967 modified to point to the remaining part of the
969 @param Device A pointer to the returned device handle.
971 @retval EFI_SUCCESS The resulting handle was returned.
972 @retval EFI_NOT_FOUND No handles matched the search.
973 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
978 CoreLocateDevicePath (
979 IN EFI_GUID
*Protocol
,
980 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
981 OUT EFI_HANDLE
*Device
987 Function returns an array of handles that support the requested protocol
988 in a buffer allocated from pool. This is a version of CoreLocateHandle()
989 that allocates a buffer for the caller.
991 @param SearchType Specifies which handle(s) are to be returned.
992 @param Protocol Provides the protocol to search by. This
993 parameter is only valid for SearchType
995 @param SearchKey Supplies the search key depending on the
997 @param NumberHandles The number of handles returned in Buffer.
998 @param Buffer A pointer to the buffer to return the requested
999 array of handles that support Protocol.
1001 @retval EFI_SUCCESS The result array of handles was returned.
1002 @retval EFI_NOT_FOUND No handles match the search.
1003 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
1005 @retval EFI_INVALID_PARAMETER One or more paramters are not valid.
1010 CoreLocateHandleBuffer (
1011 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1012 IN EFI_GUID
*Protocol OPTIONAL
,
1013 IN VOID
*SearchKey OPTIONAL
,
1014 IN OUT UINTN
*NumberHandles
,
1015 OUT EFI_HANDLE
**Buffer
1021 Return the first Protocol Interface that matches the Protocol GUID. If
1022 Registration is passed in, return a Protocol Instance that was just add
1023 to the system. If Registration is NULL return the first Protocol Interface
1026 @param Protocol The protocol to search for
1027 @param Registration Optional Registration Key returned from
1028 RegisterProtocolNotify()
1029 @param Interface Return the Protocol interface (instance).
1031 @retval EFI_SUCCESS If a valid Interface is returned
1032 @retval EFI_INVALID_PARAMETER Invalid parameter
1033 @retval EFI_NOT_FOUND Protocol interface not found
1038 CoreLocateProtocol (
1039 IN EFI_GUID
*Protocol
,
1040 IN VOID
*Registration OPTIONAL
,
1041 OUT VOID
**Interface
1046 return handle database key.
1049 @return Handle database key.
1053 CoreGetHandleDatabaseKey (
1059 Go connect any handles that were created or modified while a image executed.
1061 @param Key The Key to show that the handle has been
1066 CoreConnectHandlesByKey (
1073 Connects one or more drivers to a controller.
1075 @param ControllerHandle Handle of the controller to be
1077 @param DriverImageHandle DriverImageHandle A pointer to an
1078 ordered list of driver image
1080 @param RemainingDevicePath RemainingDevicePath A pointer to
1081 the device path that specifies a
1082 child of the controller specified
1083 by ControllerHandle.
1084 @param Recursive Whether the function would be
1085 called recursively or not.
1087 @return Status code.
1092 CoreConnectController (
1093 IN EFI_HANDLE ControllerHandle
,
1094 IN EFI_HANDLE
*DriverImageHandle OPTIONAL
,
1095 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
1096 IN BOOLEAN Recursive
1102 Disonnects a controller from a driver
1104 @param ControllerHandle ControllerHandle The handle of
1105 the controller from which
1108 @param DriverImageHandle DriverImageHandle The driver to
1109 disconnect from ControllerHandle.
1110 @param ChildHandle ChildHandle The handle of the
1113 @retval EFI_SUCCESS One or more drivers were
1114 disconnected from the controller.
1115 @retval EFI_SUCCESS On entry, no drivers are managing
1117 @retval EFI_SUCCESS DriverImageHandle is not NULL,
1118 and on entry DriverImageHandle is
1119 not managing ControllerHandle.
1120 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid
1122 @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
1123 and it is not a valid EFI_HANDLE.
1124 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
1125 is not a valid EFI_HANDLE.
1126 @retval EFI_OUT_OF_RESOURCES There are not enough resources
1127 available to disconnect any
1128 drivers from ControllerHandle.
1129 @retval EFI_DEVICE_ERROR The controller could not be
1130 disconnected because of a device
1136 CoreDisconnectController (
1137 IN EFI_HANDLE ControllerHandle
,
1138 IN EFI_HANDLE DriverImageHandle OPTIONAL
,
1139 IN EFI_HANDLE ChildHandle OPTIONAL
1145 Allocates pages from the memory map.
1147 @param Type The type of allocation to perform
1148 @param MemoryType The type of memory to turn the allocated pages
1150 @param NumberOfPages The number of pages to allocate
1151 @param Memory A pointer to receive the base allocated memory
1154 @return Status. On success, Memory is filled in with the base address allocated
1155 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
1157 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
1158 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
1159 @retval EFI_SUCCESS Pages successfully allocated.
1165 IN EFI_ALLOCATE_TYPE Type
,
1166 IN EFI_MEMORY_TYPE MemoryType
,
1167 IN UINTN NumberOfPages
,
1168 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
1174 Frees previous allocated pages.
1176 @param Memory Base address of memory being freed
1177 @param NumberOfPages The number of pages to free
1179 @retval EFI_NOT_FOUND Could not find the entry that covers the range
1180 @retval EFI_INVALID_PARAMETER Address not aligned
1181 @return EFI_SUCCESS -Pages successfully freed.
1187 IN EFI_PHYSICAL_ADDRESS Memory
,
1188 IN UINTN NumberOfPages
1194 This function returns a copy of the current memory map. The map is an array of
1195 memory descriptors, each of which describes a contiguous block of memory.
1197 @param MemoryMapSize A pointer to the size, in bytes, of the
1198 MemoryMap buffer. On input, this is the size of
1199 the buffer allocated by the caller. On output,
1200 it is the size of the buffer returned by the
1201 firmware if the buffer was large enough, or the
1202 size of the buffer needed to contain the map if
1203 the buffer was too small.
1204 @param MemoryMap A pointer to the buffer in which firmware places
1205 the current memory map.
1206 @param MapKey A pointer to the location in which firmware
1207 returns the key for the current memory map.
1208 @param DescriptorSize A pointer to the location in which firmware
1209 returns the size, in bytes, of an individual
1210 EFI_MEMORY_DESCRIPTOR.
1211 @param DescriptorVersion A pointer to the location in which firmware
1212 returns the version number associated with the
1213 EFI_MEMORY_DESCRIPTOR.
1215 @retval EFI_SUCCESS The memory map was returned in the MemoryMap
1217 @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
1218 buffer size needed to hold the memory map is
1219 returned in MemoryMapSize.
1220 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1226 IN OUT UINTN
*MemoryMapSize
,
1227 IN OUT EFI_MEMORY_DESCRIPTOR
*MemoryMap
,
1229 OUT UINTN
*DescriptorSize
,
1230 OUT UINT32
*DescriptorVersion
1236 Allocate pool of a particular type.
1238 @param PoolType Type of pool to allocate
1239 @param Size The amount of pool to allocate
1240 @param Buffer The address to return a pointer to the allocated
1243 @retval EFI_INVALID_PARAMETER PoolType not valid
1244 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
1245 @retval EFI_SUCCESS Pool successfully allocated.
1251 IN EFI_MEMORY_TYPE PoolType
,
1261 @param Buffer The allocated pool entry to free
1263 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
1264 @retval EFI_SUCCESS Pool successfully freed.
1276 Loads an EFI image into memory and returns a handle to the image.
1278 @param BootPolicy If TRUE, indicates that the request originates
1279 from the boot manager, and that the boot
1280 manager is attempting to load FilePath as a
1282 @param ParentImageHandle The caller's image handle.
1283 @param FilePath The specific file path from which the image is
1285 @param SourceBuffer If not NULL, a pointer to the memory location
1286 containing a copy of the image to be loaded.
1287 @param SourceSize The size in bytes of SourceBuffer.
1288 @param ImageHandle Pointer to the returned image handle that is
1289 created when the image is successfully loaded.
1291 @retval EFI_SUCCESS The image was loaded into memory.
1292 @retval EFI_NOT_FOUND The FilePath was not found.
1293 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1294 @retval EFI_UNSUPPORTED The image type is not supported, or the device
1295 path cannot be parsed to locate the proper
1296 protocol for loading the file.
1297 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
1304 IN BOOLEAN BootPolicy
,
1305 IN EFI_HANDLE ParentImageHandle
,
1306 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
1307 IN VOID
*SourceBuffer OPTIONAL
,
1308 IN UINTN SourceSize
,
1309 OUT EFI_HANDLE
*ImageHandle
1317 @param ImageHandle Handle that identifies the image to be
1320 @retval EFI_SUCCESS The image has been unloaded.
1321 @retval EFI_UNSUPPORTED The image has been sarted, and does not support
1323 @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
1329 IN EFI_HANDLE ImageHandle
1335 Transfer control to a loaded image's entry point.
1337 @param ImageHandle Handle of image to be started.
1338 @param ExitDataSize Pointer of the size to ExitData
1339 @param ExitData Pointer to a pointer to a data buffer that
1340 includes a Null-terminated Unicode string,
1341 optionally followed by additional binary data.
1342 The string is a description that the caller may
1343 use to further indicate the reason for the
1346 @retval EFI_INVALID_PARAMETER Invalid parameter
1347 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1348 @retval EFI_SUCCESS Successfully transfer control to the image's
1355 IN EFI_HANDLE ImageHandle
,
1356 OUT UINTN
*ExitDataSize
,
1357 OUT CHAR16
**ExitData OPTIONAL
1363 Terminates the currently loaded EFI image and returns control to boot services.
1365 @param ImageHandle Handle that identifies the image. This
1366 parameter is passed to the image on entry.
1367 @param Status The image's exit code.
1368 @param ExitDataSize The size, in bytes, of ExitData. Ignored if
1369 ExitStatus is EFI_SUCCESS.
1370 @param ExitData Pointer to a data buffer that includes a
1371 Null-terminated Unicode string, optionally
1372 followed by additional binary data. The string
1373 is a description that the caller may use to
1374 further indicate the reason for the image's
1377 @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
1379 @retval EFI_SUCCESS Successfully terminates the currently loaded
1381 @retval EFI_ACCESS_DENIED Should never reach there.
1382 @retval EFI_OUT_OF_RESOURCES Could not allocate pool
1388 IN EFI_HANDLE ImageHandle
,
1389 IN EFI_STATUS Status
,
1390 IN UINTN ExitDataSize
,
1391 IN CHAR16
*ExitData OPTIONAL
1397 Creates a general-purpose event structure.
1399 @param Type The type of event to create and its mode and
1401 @param NotifyTpl The task priority level of event notifications
1402 @param NotifyFunction Pointer to the events notification function
1403 @param NotifyContext Pointer to the notification functions context;
1404 corresponds to parameter "Context" in the
1405 notification function
1406 @param Event Pointer to the newly created event if the call
1407 succeeds; undefined otherwise
1409 @retval EFI_SUCCESS The event structure was created
1410 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1411 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1418 IN EFI_TPL NotifyTpl
,
1419 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1420 IN VOID
*NotifyContext
, OPTIONAL
1421 OUT EFI_EVENT
*Event
1427 Creates a general-purpose event structure
1429 @param Type The type of event to create and its mode and
1431 @param NotifyTpl The task priority level of event notifications
1432 @param NotifyFunction Pointer to the events notification function
1433 @param NotifyContext Pointer to the notification functions context;
1434 corresponds to parameter "Context" in the
1435 notification function
1436 @param EventGroup GUID for EventGroup if NULL act the same as
1438 @param Event Pointer to the newly created event if the call
1439 succeeds; undefined otherwise
1441 @retval EFI_SUCCESS The event structure was created
1442 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1443 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1450 IN EFI_TPL NotifyTpl
,
1451 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1452 IN CONST VOID
*NotifyContext
, OPTIONAL
1453 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1454 OUT EFI_EVENT
*Event
1460 Sets the type of timer and the trigger time for a timer event.
1462 @param UserEvent The timer event that is to be signaled at the
1464 @param Type The type of time that is specified in
1466 @param TriggerTime The number of 100ns units until the timer
1469 @retval EFI_SUCCESS The event has been set to be signaled at the
1471 @retval EFI_INVALID_PARAMETER Event or Type is not valid
1477 IN EFI_EVENT UserEvent
,
1478 IN EFI_TIMER_DELAY Type
,
1479 IN UINT64 TriggerTime
1485 Signals the event. Queues the event to be notified if needed.
1487 @param UserEvent The event to signal .
1489 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1490 @retval EFI_SUCCESS The event was signaled.
1496 IN EFI_EVENT UserEvent
1502 Stops execution until an event is signaled.
1504 @param NumberOfEvents The number of events in the UserEvents array
1505 @param UserEvents An array of EFI_EVENT
1506 @param UserIndex Pointer to the index of the event which
1507 satisfied the wait condition
1509 @retval EFI_SUCCESS The event indicated by Index was signaled.
1510 @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification
1511 function or Event was not a valid type
1512 @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION
1518 IN UINTN NumberOfEvents
,
1519 IN EFI_EVENT
*UserEvents
,
1520 OUT UINTN
*UserIndex
1526 Closes an event and frees the event structure.
1528 @param UserEvent Event to close
1530 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1531 @retval EFI_SUCCESS The event has been closed
1537 IN EFI_EVENT UserEvent
1543 Check the status of an event.
1545 @param UserEvent The event to check
1547 @retval EFI_SUCCESS The event is in the signaled state
1548 @retval EFI_NOT_READY The event is not in the signaled state
1549 @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL
1555 IN EFI_EVENT UserEvent
1560 Adds reserved memory, system memory, or memory-mapped I/O resources to the
1561 global coherency domain of the processor.
1563 @param GcdMemoryType Memory type of the memory space.
1564 @param BaseAddress Base address of the memory space.
1565 @param Length Length of the memory space.
1566 @param Capabilities alterable attributes of the memory space.
1568 @retval EFI_SUCCESS Merged this memory space into GCD map.
1573 CoreAddMemorySpace (
1574 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1575 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1577 IN UINT64 Capabilities
1582 Allocates nonexistent memory, reserved memory, system memory, or memorymapped
1583 I/O resources from the global coherency domain of the processor.
1585 @param GcdAllocateType The type of allocate operation
1586 @param GcdMemoryType The desired memory type
1587 @param Alignment Align with 2^Alignment
1588 @param Length Length to allocate
1589 @param BaseAddress Base address to allocate
1590 @param ImageHandle The image handle consume the allocated space.
1591 @param DeviceHandle The device handle consume the allocated space.
1593 @retval EFI_INVALID_PARAMETER Invalid parameter.
1594 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1595 @retval EFI_SUCCESS Memory space successfully allocated.
1600 CoreAllocateMemorySpace (
1601 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1602 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1605 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1606 IN EFI_HANDLE ImageHandle
,
1607 IN EFI_HANDLE DeviceHandle OPTIONAL
1612 Frees nonexistent memory, reserved memory, system memory, or memory-mapped
1613 I/O resources from the global coherency domain of the processor.
1615 @param BaseAddress Base address of the memory space.
1616 @param Length Length of the memory space.
1618 @retval EFI_SUCCESS Space successfully freed.
1623 CoreFreeMemorySpace (
1624 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1630 Removes reserved memory, system memory, or memory-mapped I/O resources from
1631 the global coherency domain of the processor.
1633 @param BaseAddress Base address of the memory space.
1634 @param Length Length of the memory space.
1636 @retval EFI_SUCCESS Successfully remove a segment of memory space.
1641 CoreRemoveMemorySpace (
1642 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1648 Retrieves the descriptor for a memory region containing a specified address.
1650 @param BaseAddress Specified start address
1651 @param Descriptor Specified length
1653 @retval EFI_INVALID_PARAMETER Invalid parameter
1654 @retval EFI_SUCCESS Successfully get memory space descriptor.
1659 CoreGetMemorySpaceDescriptor (
1660 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1661 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*Descriptor
1666 Modifies the attributes for a memory region in the global coherency domain of the
1669 @param BaseAddress Specified start address
1670 @param Length Specified length
1671 @param Attributes Specified attributes
1673 @retval EFI_SUCCESS Successfully set attribute of a segment of
1679 CoreSetMemorySpaceAttributes (
1680 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1682 IN UINT64 Attributes
1687 Returns a map of the memory resources in the global coherency domain of the
1690 @param NumberOfDescriptors Number of descriptors.
1691 @param MemorySpaceMap Descriptor array
1693 @retval EFI_INVALID_PARAMETER Invalid parameter
1694 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1695 @retval EFI_SUCCESS Successfully get memory space map.
1700 CoreGetMemorySpaceMap (
1701 OUT UINTN
*NumberOfDescriptors
,
1702 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
**MemorySpaceMap
1707 Adds reserved I/O or I/O resources to the global coherency domain of the processor.
1709 @param GcdIoType IO type of the segment.
1710 @param BaseAddress Base address of the segment.
1711 @param Length Length of the segment.
1713 @retval EFI_SUCCESS Merged this segment into GCD map.
1714 @retval EFI_INVALID_PARAMETER Parameter not valid
1720 IN EFI_GCD_IO_TYPE GcdIoType
,
1721 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1727 Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1728 domain of the processor.
1730 @param GcdAllocateType The type of allocate operation
1731 @param GcdIoType The desired IO type
1732 @param Alignment Align with 2^Alignment
1733 @param Length Length to allocate
1734 @param BaseAddress Base address to allocate
1735 @param ImageHandle The image handle consume the allocated space.
1736 @param DeviceHandle The device handle consume the allocated space.
1738 @retval EFI_INVALID_PARAMETER Invalid parameter.
1739 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1740 @retval EFI_SUCCESS IO space successfully allocated.
1745 CoreAllocateIoSpace (
1746 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1747 IN EFI_GCD_IO_TYPE GcdIoType
,
1750 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1751 IN EFI_HANDLE ImageHandle
,
1752 IN EFI_HANDLE DeviceHandle OPTIONAL
1757 Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1758 domain of the processor.
1760 @param BaseAddress Base address of the segment.
1761 @param Length Length of the segment.
1763 @retval EFI_SUCCESS Space successfully freed.
1769 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1775 Removes reserved I/O or I/O resources from the global coherency domain of the
1778 @param BaseAddress Base address of the segment.
1779 @param Length Length of the segment.
1781 @retval EFI_SUCCESS Successfully removed a segment of IO space.
1787 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1793 Retrieves the descriptor for an I/O region containing a specified address.
1795 @param BaseAddress Specified start address
1796 @param Descriptor Specified length
1798 @retval EFI_INVALID_PARAMETER Descriptor is NULL.
1799 @retval EFI_SUCCESS Successfully get the IO space descriptor.
1804 CoreGetIoSpaceDescriptor (
1805 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1806 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
*Descriptor
1811 Returns a map of the I/O resources in the global coherency domain of the processor.
1813 @param NumberOfDescriptors Number of descriptors.
1814 @param IoSpaceMap Descriptor array
1816 @retval EFI_INVALID_PARAMETER Invalid parameter
1817 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1818 @retval EFI_SUCCESS Successfully get IO space map.
1824 OUT UINTN
*NumberOfDescriptors
,
1825 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
**IoSpaceMap
1830 This is the main Dispatcher for DXE and it exits when there are no more
1831 drivers to run. Drain the mScheduledQueue and load and start a PE
1832 image for each driver. Search the mDiscoveredList to see if any driver can
1833 be placed on the mScheduledQueue. If no drivers are placed on the
1834 mScheduledQueue exit the function. On exit it is assumed the Bds()
1835 will be called, and when the Bds() exits the Dispatcher will be called
1838 @retval EFI_ALREADY_STARTED The DXE Dispatcher is already running
1839 @retval EFI_NOT_FOUND No DXE Drivers were dispatched
1840 @retval EFI_SUCCESS One or more DXE Drivers were dispatched
1850 Check every driver and locate a matching one. If the driver is found, the Unrequested
1851 state flag is cleared.
1853 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1854 the firmware file specified by DriverName.
1855 @param DriverName The Driver name to put in the Dependent state.
1857 @retval EFI_SUCCESS The DriverName was found and it's SOR bit was
1859 @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was
1866 IN EFI_HANDLE FirmwareVolumeHandle
,
1867 IN EFI_GUID
*DriverName
1872 Convert a driver from the Untrused back to the Scheduled state.
1874 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1875 the firmware file specified by DriverName.
1876 @param DriverName The Driver name to put in the Scheduled state
1878 @retval EFI_SUCCESS The file was found in the untrusted state, and it
1879 was promoted to the trusted state.
1880 @retval EFI_NOT_FOUND The file was not found in the untrusted state.
1886 IN EFI_HANDLE FirmwareVolumeHandle
,
1887 IN EFI_GUID
*DriverName
1892 This routine is the driver initialization entry point. It initializes the
1893 libraries, and registers two notification functions. These notification
1894 functions are responsible for building the FV stack dynamically.
1896 @param ImageHandle The image handle.
1897 @param SystemTable The system table.
1899 @retval EFI_SUCCESS Function successfully returned.
1905 IN EFI_HANDLE ImageHandle
,
1906 IN EFI_SYSTEM_TABLE
*SystemTable
1911 Entry point of the section extraction code. Initializes an instance of the
1912 section extraction interface and installs it on a new handle.
1914 @param ImageHandle A handle for the image that is initializing this driver
1915 @param SystemTable A pointer to the EFI system table
1917 @retval EFI_SUCCESS Driver initialized successfully
1918 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
1923 InitializeSectionExtraction (
1924 IN EFI_HANDLE ImageHandle
,
1925 IN EFI_SYSTEM_TABLE
*SystemTable
1930 This DXE service routine is used to process a firmware volume. In
1931 particular, it can be called by BDS to process a single firmware
1932 volume found in a capsule.
1934 @param FvHeader pointer to a firmware volume header
1935 @param Size the size of the buffer pointed to by FvHeader
1936 @param FVProtocolHandle the handle on which a firmware volume protocol
1937 was produced for the firmware volume passed in.
1939 @retval EFI_OUT_OF_RESOURCES if an FVB could not be produced due to lack of
1941 @retval EFI_VOLUME_CORRUPTED if the volume was corrupted
1942 @retval EFI_SUCCESS a firmware volume protocol was produced for the
1948 CoreProcessFirmwareVolume (
1951 OUT EFI_HANDLE
*FVProtocolHandle
1955 //Functions used during debug buils
1959 Displays Architectural protocols that were not loaded and are required for DXE
1960 core to function. Only used in Debug Builds.
1964 CoreDisplayMissingArchProtocols (
1970 Traverse the discovered list for any drivers that were discovered but not loaded
1971 because the dependency experessions evaluated to false.
1975 CoreDisplayDiscoveredNotDispatched (
1981 Place holder function until all the Boot Services and Runtime Services are
1984 @return EFI_NOT_AVAILABLE_YET
1989 CoreEfiNotAvailableYetArg0 (
1995 Place holder function until all the Boot Services and Runtime Services are
1998 @param Arg1 Undefined
2000 @return EFI_NOT_AVAILABLE_YET
2005 CoreEfiNotAvailableYetArg1 (
2011 Place holder function until all the Boot Services and Runtime Services are available.
2013 @param Arg1 Undefined
2014 @param Arg2 Undefined
2016 @return EFI_NOT_AVAILABLE_YET
2021 CoreEfiNotAvailableYetArg2 (
2028 Place holder function until all the Boot Services and Runtime Services are available.
2030 @param Arg1 Undefined
2031 @param Arg2 Undefined
2032 @param Arg3 Undefined
2034 @return EFI_NOT_AVAILABLE_YET
2039 CoreEfiNotAvailableYetArg3 (
2047 Place holder function until all the Boot Services and Runtime Services are available.
2049 @param Arg1 Undefined
2050 @param Arg2 Undefined
2051 @param Arg3 Undefined
2052 @param Arg4 Undefined
2054 @return EFI_NOT_AVAILABLE_YET
2059 CoreEfiNotAvailableYetArg4 (
2068 Place holder function until all the Boot Services and Runtime Services are available.
2070 @param Arg1 Undefined
2071 @param Arg2 Undefined
2072 @param Arg3 Undefined
2073 @param Arg4 Undefined
2074 @param Arg5 Undefined
2076 @return EFI_NOT_AVAILABLE_YET
2081 CoreEfiNotAvailableYetArg5 (
2091 Given a compressed source buffer, this function retrieves the size of the
2092 uncompressed buffer and the size of the scratch buffer required to decompress
2093 the compressed source buffer.
2095 The GetInfo() function retrieves the size of the uncompressed buffer and the
2096 temporary scratch buffer required to decompress the buffer specified by Source
2097 and SourceSize. If the size of the uncompressed buffer or the size of the
2098 scratch buffer cannot be determined from the compressed data specified by
2099 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
2100 size of the uncompressed buffer is returned in DestinationSize, the size of
2101 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
2102 The GetInfo() function does not have scratch buffer available to perform a
2103 thorough checking of the validity of the source data. It just retrieves the
2104 "Original Size" field from the beginning bytes of the source data and output
2105 it as DestinationSize. And ScratchSize is specific to the decompression
2108 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2109 @param Source The source buffer containing the compressed data.
2110 @param SourceSize The size, in bytes, of the source buffer.
2111 @param DestinationSize A pointer to the size, in bytes, of the
2112 uncompressed buffer that will be generated when the
2113 compressed buffer specified by Source and
2114 SourceSize is decompressed.
2115 @param ScratchSize A pointer to the size, in bytes, of the scratch
2116 buffer that is required to decompress the
2117 compressed buffer specified by Source and
2120 @retval EFI_SUCCESS The size of the uncompressed data was returned in
2121 DestinationSize and the size of the scratch buffer
2122 was returned in ScratchSize.
2123 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
2124 the scratch buffer cannot be determined from the
2125 compressed data specified by Source and
2131 DxeMainUefiDecompressGetInfo (
2132 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2134 IN UINT32 SourceSize
,
2135 OUT UINT32
*DestinationSize
,
2136 OUT UINT32
*ScratchSize
2141 Decompresses a compressed source buffer.
2143 The Decompress() function extracts decompressed data to its original form.
2144 This protocol is designed so that the decompression algorithm can be
2145 implemented without using any memory services. As a result, the Decompress()
2146 Function is not allowed to call AllocatePool() or AllocatePages() in its
2147 implementation. It is the caller's responsibility to allocate and free the
2148 Destination and Scratch buffers.
2149 If the compressed source data specified by Source and SourceSize is
2150 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
2151 the compressed source data specified by Source and SourceSize is not in a
2152 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
2154 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2155 @param Source The source buffer containing the compressed data.
2156 @param SourceSize SourceSizeThe size of source data.
2157 @param Destination On output, the destination buffer that contains
2158 the uncompressed data.
2159 @param DestinationSize The size of the destination buffer. The size of
2160 the destination buffer needed is obtained from
2161 EFI_DECOMPRESS_PROTOCOL.GetInfo().
2162 @param Scratch A temporary scratch buffer that is used to perform
2164 @param ScratchSize The size of scratch buffer. The size of the
2165 scratch buffer needed is obtained from GetInfo().
2167 @retval EFI_SUCCESS Decompression completed successfully, and the
2168 uncompressed buffer is returned in Destination.
2169 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
2170 SourceSize is corrupted (not in a valid
2176 DxeMainUefiDecompress (
2177 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2179 IN UINT32 SourceSize
,
2180 IN OUT VOID
*Destination
,
2181 IN UINT32 DestinationSize
,
2182 IN OUT VOID
*Scratch
,
2183 IN UINT32 ScratchSize
2187 SEP member function. This function creates and returns a new section stream
2188 handle to represent the new section stream.
2190 @param SectionStreamLength Size in bytes of the section stream.
2191 @param SectionStream Buffer containing the new section stream.
2192 @param SectionStreamHandle A pointer to a caller allocated UINTN that on
2193 output contains the new section stream handle.
2195 @retval EFI_SUCCESS The section stream is created successfully.
2196 @retval EFI_OUT_OF_RESOURCES memory allocation failed.
2197 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2204 IN UINTN SectionStreamLength
,
2205 IN VOID
*SectionStream
,
2206 OUT UINTN
*SectionStreamHandle
2212 SEP member function. Retrieves requested section from section stream.
2214 @param SectionStreamHandle The section stream from which to extract the
2216 @param SectionType A pointer to the type of section to search for.
2217 @param SectionDefinitionGuid If the section type is EFI_SECTION_GUID_DEFINED,
2218 then SectionDefinitionGuid indicates which of
2219 these types of sections to search for.
2220 @param SectionInstance Indicates which instance of the requested
2222 @param Buffer Double indirection to buffer. If *Buffer is
2223 non-null on input, then the buffer is caller
2224 allocated. If Buffer is NULL, then the buffer
2225 is callee allocated. In either case, the
2226 requried buffer size is returned in *BufferSize.
2227 @param BufferSize On input, indicates the size of *Buffer if
2228 *Buffer is non-null on input. On output,
2229 indicates the required size (allocated size if
2230 callee allocated) of *Buffer.
2231 @param AuthenticationStatus A pointer to a caller-allocated UINT32 that
2232 indicates the authentication status of the
2233 output buffer. If the input section's
2234 GuidedSectionHeader.Attributes field
2235 has the EFI_GUIDED_SECTION_AUTH_STATUS_VALID
2236 bit as clear, AuthenticationStatus must return
2237 zero. Both local bits (19:16) and aggregate
2238 bits (3:0) in AuthenticationStatus are returned
2239 by ExtractSection(). These bits reflect the
2240 status of the extraction operation. The bit
2241 pattern in both regions must be the same, as
2242 the local and aggregate authentication statuses
2243 have equivalent meaning at this level. If the
2244 function returns anything other than
2245 EFI_SUCCESS, the value of *AuthenticationStatus
2248 @retval EFI_SUCCESS Section was retrieved successfully
2249 @retval EFI_PROTOCOL_ERROR A GUID defined section was encountered in the
2250 section stream with its
2251 EFI_GUIDED_SECTION_PROCESSING_REQUIRED bit set,
2252 but there was no corresponding GUIDed Section
2253 Extraction Protocol in the handle database.
2254 *Buffer is unmodified.
2255 @retval EFI_NOT_FOUND An error was encountered when parsing the
2256 SectionStream. This indicates the SectionStream
2257 is not correctly formatted.
2258 @retval EFI_NOT_FOUND The requested section does not exist.
2259 @retval EFI_OUT_OF_RESOURCES The system has insufficient resources to process
2261 @retval EFI_INVALID_PARAMETER The SectionStreamHandle does not exist.
2262 @retval EFI_WARN_TOO_SMALL The size of the caller allocated input buffer is
2263 insufficient to contain the requested section.
2264 The input buffer is filled and section contents
2271 IN UINTN SectionStreamHandle
,
2272 IN EFI_SECTION_TYPE
*SectionType
,
2273 IN EFI_GUID
*SectionDefinitionGuid
,
2274 IN UINTN SectionInstance
,
2276 IN OUT UINTN
*BufferSize
,
2277 OUT UINT32
*AuthenticationStatus
2282 SEP member function. Deletes an existing section stream
2284 @param StreamHandleToClose Indicates the stream to close
2286 @retval EFI_SUCCESS The section stream is closed sucessfully.
2287 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
2288 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2294 CloseSectionStream (
2295 IN UINTN StreamHandleToClose
2299 Creates and initializes the DebugImageInfo Table. Also creates the configuration
2300 table and registers it into the system table.
2303 This function allocates memory, frees it, and then allocates memory at an
2304 address within the initial allocation. Since this function is called early
2305 in DXE core initialization (before drivers are dispatched), this should not
2310 CoreInitializeDebugImageInfoTable (
2316 Update the CRC32 in the Debug Table.
2317 Since the CRC32 service is made available by the Runtime driver, we have to
2318 wait for the Runtime Driver to be installed before the CRC32 can be computed.
2319 This function is called elsewhere by the core when the runtime architectural
2320 protocol is produced.
2324 CoreUpdateDebugTableCrc32 (
2330 Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
2331 the table if it's not large enough to accomidate another entry.
2333 @param ImageInfoType type of debug image information
2334 @param LoadedImage pointer to the loaded image protocol for the image being
2336 @param ImageHandle image handle for the image being loaded
2340 CoreNewDebugImageInfoEntry (
2341 IN UINT32 ImageInfoType
,
2342 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
,
2343 IN EFI_HANDLE ImageHandle
2348 Removes and frees an entry from the DebugImageInfo Table.
2350 @param ImageHandle image handle for the image being unloaded
2354 CoreRemoveDebugImageInfoEntry (
2355 EFI_HANDLE ImageHandle
2360 This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
2362 @param ImageHandle The image handle.
2363 @param SystemTable The system table.
2365 @retval EFI_SUCCESS Successfully initialized firmware volume block
2371 FwVolBlockDriverInit (
2372 IN EFI_HANDLE ImageHandle
,
2373 IN EFI_SYSTEM_TABLE
*SystemTable
2378 This routine produces a firmware volume block protocol on a given
2381 @param BaseAddress base address of the firmware volume image
2382 @param Length length of the firmware volume image
2383 @param ParentHandle handle of parent firmware volume, if this image
2384 came from an FV image file in another firmware
2385 volume (ala capsules)
2386 @param FvProtocol Firmware volume block protocol produced.
2388 @retval EFI_VOLUME_CORRUPTED Volume corrupted.
2389 @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
2390 @retval EFI_SUCCESS Successfully produced a FVB protocol on given
2395 ProduceFVBProtocolOnBuffer (
2396 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2398 IN EFI_HANDLE ParentHandle
,
2399 OUT EFI_HANDLE
*FvProtocol OPTIONAL
2404 Raising to the task priority level of the mutual exclusion
2405 lock, and then acquires ownership of the lock.
2407 @param Lock The lock to acquire
2419 Initialize a basic mutual exclusion lock. Each lock
2420 provides mutual exclusion access at it's task priority
2421 level. Since there is no-premption (at any TPL) or
2422 multiprocessor support, acquiring the lock only consists
2423 of raising to the locks TPL.
2425 @param Lock The EFI_LOCK structure to initialize
2427 @retval EFI_SUCCESS Lock Owned.
2428 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
2432 CoreAcquireLockOrFail (
2438 Releases ownership of the mutual exclusion lock, and
2439 restores the previous task priority level.
2441 @param Lock The lock to release
2443 @return Lock unowned