2 The internal header file includes the common header files, defines
3 internal structure and functions used by DxeCore module.
5 Copyright (c) 2006 - 2011, 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/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/DriverFamilyOverride.h>
52 #include <Protocol/TcgService.h>
53 #include <Protocol/HiiPackageList.h>
54 #include <Protocol/SmmBase2.h>
55 #include <Guid/MemoryTypeInformation.h>
56 #include <Guid/FirmwareFileSystem2.h>
57 #include <Guid/FirmwareFileSystem3.h>
58 #include <Guid/HobList.h>
59 #include <Guid/DebugImageInfoTable.h>
60 #include <Guid/FileInfo.h>
61 #include <Guid/Apriori.h>
62 #include <Guid/DxeServices.h>
63 #include <Guid/MemoryAllocationHob.h>
64 #include <Guid/EventLegacyBios.h>
65 #include <Guid/EventGroup.h>
66 #include <Guid/LoadModuleAtFixedAddress.h>
67 #include <Guid/IdleLoopEvent.h>
69 #include <Library/DxeCoreEntryPoint.h>
70 #include <Library/DebugLib.h>
71 #include <Library/UefiLib.h>
72 #include <Library/BaseLib.h>
73 #include <Library/HobLib.h>
74 #include <Library/PerformanceLib.h>
75 #include <Library/UefiDecompressLib.h>
76 #include <Library/ExtractGuidedSectionLib.h>
77 #include <Library/CacheMaintenanceLib.h>
78 #include <Library/BaseMemoryLib.h>
79 #include <Library/PeCoffLib.h>
80 #include <Library/PeCoffGetEntryPointLib.h>
81 #include <Library/PeCoffExtraActionLib.h>
82 #include <Library/PcdLib.h>
83 #include <Library/MemoryAllocationLib.h>
84 #include <Library/DevicePathLib.h>
85 #include <Library/UefiBootServicesTableLib.h>
86 #include <Library/ReportStatusCodeLib.h>
87 #include <Library/TimerLib.h>
88 #include <Library/DxeServicesLib.h>
89 #include <Library/DebugAgentLib.h>
93 // attributes for reserved memory before it is promoted to system memory
95 #define EFI_MEMORY_PRESENT 0x0100000000000000ULL
96 #define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL
97 #define EFI_MEMORY_TESTED 0x0400000000000000ULL
100 // range for memory mapped port I/O on IPF
102 #define EFI_MEMORY_PORT_IO 0x4000000000000000ULL
106 /// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependecy expression
107 /// to save time. A EFI_DEP_PUSH is evauated one an
108 /// replaced with EFI_DEP_REPLACE_TRUE. If PI spec's Vol 2
109 /// Driver Execution Environment Core Interface use 0xff
110 /// as new DEPEX opcode. EFI_DEP_REPLACE_TRUE should be
111 /// defined to a new value that is not conflicting with PI spec.
113 #define EFI_DEP_REPLACE_TRUE 0xff
116 /// Define the initial size of the dependency expression evaluation stack
118 #define DEPEX_STACK_SIZE_INCREMENT 0x1000
121 EFI_GUID
*ProtocolGuid
;
126 } EFI_CORE_PROTOCOL_NOTIFY_ENTRY
;
129 // DXE Dispatcher Data structures
132 #define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w')
135 LIST_ENTRY Link
; // mFvHandleList
141 #define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r')
144 LIST_ENTRY Link
; // mDriverList
146 LIST_ENTRY ScheduledLink
; // mScheduledQueue
150 EFI_DEVICE_PATH_PROTOCOL
*FvFileDevicePath
;
151 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
158 EFI_GUID BeforeAfterGuid
;
165 BOOLEAN DepexProtocolError
;
167 EFI_HANDLE ImageHandle
;
170 } EFI_CORE_DRIVER_ENTRY
;
173 //The data structure of GCD memory map entry
175 #define EFI_GCD_MAP_SIGNATURE SIGNATURE_32('g','c','d','m')
179 EFI_PHYSICAL_ADDRESS BaseAddress
;
183 EFI_GCD_MEMORY_TYPE GcdMemoryType
;
184 EFI_GCD_IO_TYPE GcdIoType
;
185 EFI_HANDLE ImageHandle
;
186 EFI_HANDLE DeviceHandle
;
190 // DXE Core Global Variables
192 extern EFI_SYSTEM_TABLE
*gDxeCoreST
;
193 extern EFI_RUNTIME_SERVICES
*gDxeCoreRT
;
194 extern EFI_DXE_SERVICES
*gDxeCoreDS
;
195 extern EFI_HANDLE gDxeCoreImageHandle
;
197 extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress
;
199 extern EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
;
200 extern EFI_CPU_ARCH_PROTOCOL
*gCpu
;
201 extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL
*gWatchdogTimer
;
202 extern EFI_METRONOME_ARCH_PROTOCOL
*gMetronome
;
203 extern EFI_TIMER_ARCH_PROTOCOL
*gTimer
;
204 extern EFI_SECURITY_ARCH_PROTOCOL
*gSecurity
;
205 extern EFI_BDS_ARCH_PROTOCOL
*gBds
;
206 extern EFI_SMM_BASE2_PROTOCOL
*gSmmBase2
;
208 extern EFI_TPL gEfiCurrentTpl
;
210 extern EFI_GUID
*gDxeCoreFileName
;
211 extern EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
213 extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation
[EfiMaxMemoryType
+ 1];
215 extern BOOLEAN gDispatcherRunning
;
216 extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
;
218 extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable
;
219 extern BOOLEAN gLoadFixedAddressCodeMemoryReady
;
221 // Service Initialization Functions
227 Called to initialize the pool.
237 Called to initialize the memory map and add descriptors to
238 the current descriptor list.
239 The first descriptor that is added must be general usable
240 memory as the addition allocates heap.
242 @param Type The type of memory to add
243 @param Start The starting address in the memory range Must be
245 @param NumberOfPages The number of pages in the range
246 @param Attribute Attributes of the memory to add
248 @return None. The range is added to the memory map
252 CoreAddMemoryDescriptor (
253 IN EFI_MEMORY_TYPE Type
,
254 IN EFI_PHYSICAL_ADDRESS Start
,
255 IN UINT64 NumberOfPages
,
261 Release memory lock on mGcdMemorySpaceLock.
265 CoreReleaseGcdMemoryLock (
271 Acquire memory lock on mGcdMemorySpaceLock.
275 CoreAcquireGcdMemoryLock (
281 External function. Initializes memory services based on the memory
282 descriptor HOBs. This function is responsible for priming the memory
283 map, so memory allocations and resource allocations can be made.
284 The first part of this function can not depend on any memory services
285 until at least one memory descriptor is provided to the memory services.
287 @param HobStart The start address of the HOB.
288 @param MemoryBaseAddress Start address of memory region found to init DXE
290 @param MemoryLength Length of memory region found to init DXE core.
292 @retval EFI_SUCCESS Memory services successfully initialized.
296 CoreInitializeMemoryServices (
298 OUT EFI_PHYSICAL_ADDRESS
*MemoryBaseAddress
,
299 OUT UINT64
*MemoryLength
305 External function. Initializes the GCD and memory services based on the memory
306 descriptor HOBs. This function is responsible for priming the GCD map and the
307 memory map, so memory allocations and resource allocations can be made. The
308 HobStart will be relocated to a pool buffer.
310 @param HobStart The start address of the HOB
311 @param MemoryBaseAddress Start address of memory region found to init DXE
313 @param MemoryLength Length of memory region found to init DXE core.
315 @retval EFI_SUCCESS GCD services successfully initialized.
319 CoreInitializeGcdServices (
320 IN OUT VOID
**HobStart
,
321 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress
,
322 IN UINT64 MemoryLength
327 Initializes "event" support.
329 @retval EFI_SUCCESS Always return success
333 CoreInitializeEventServices (
339 Add the Image Services to EFI Boot Services Table and install the protocol
340 interfaces for this image.
342 @param HobStart The HOB to initialize
348 CoreInitializeImageServices (
354 Creates an event that is fired everytime a Protocol of a specific type is installed.
358 CoreNotifyOnProtocolInstallation (
364 Return TRUE if all AP services are availible.
366 @retval EFI_SUCCESS All AP services are available
367 @retval EFI_NOT_FOUND At least one AP service is not available
371 CoreAllEfiServicesAvailable (
377 Calcualte the 32-bit CRC in a EFI table using the service provided by the
380 @param Hdr Pointer to an EFI standard header
385 IN OUT EFI_TABLE_HEADER
*Hdr
390 Called by the platform code to process a tick.
392 @param Duration The number of 100ns elasped since the last call
404 Initialize the dispatcher. Initialize the notification function that runs when
405 an FV2 protocol is added to the system.
409 CoreInitializeDispatcher (
415 This is the POSTFIX version of the dependency evaluator. This code does
416 not need to handle Before or After, as it is not valid to call this
417 routine in this case. The SOR is just ignored and is a nop in the grammer.
418 POSTFIX means all the math is done on top of the stack.
420 @param DriverEntry DriverEntry element to update.
422 @retval TRUE If driver is ready to run.
423 @retval FALSE If driver is not ready to run or some fatal error
429 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
434 Preprocess dependency expression and update DriverEntry to reflect the
435 state of Before, After, and SOR dependencies. If DriverEntry->Before
436 or DriverEntry->After is set it will never be cleared. If SOR is set
437 it will be cleared by CoreSchedule(), and then the driver can be
440 @param DriverEntry DriverEntry element to update .
442 @retval EFI_SUCCESS It always works.
446 CorePreProcessDepex (
447 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
453 Terminates all boot services.
455 @param ImageHandle Handle that identifies the exiting image.
456 @param MapKey Key to the latest memory map.
458 @retval EFI_SUCCESS Boot Services terminated
459 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
464 CoreExitBootServices (
465 IN EFI_HANDLE ImageHandle
,
471 Make sure the memory map is following all the construction rules,
472 it is the last time to check memory map error before exit boot services.
474 @param MapKey Memory map key
476 @retval EFI_INVALID_PARAMETER Memory map not consistent with construction
478 @retval EFI_SUCCESS Valid memory map.
482 CoreTerminateMemoryMap (
488 Signals all events in the EventGroup.
490 @param EventGroup The list to signal
494 CoreNotifySignalList (
495 IN EFI_GUID
*EventGroup
501 Boot Service called to add, modify, or remove a system configuration table from
502 the EFI System Table.
504 @param Guid Pointer to the GUID for the entry to add, update, or
506 @param Table Pointer to the configuration table for the entry to add,
507 update, or remove, may be NULL.
509 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.
510 @return EFI_INVALID_PARAMETER Input GUID not valid.
511 @return EFI_NOT_FOUND Attempted to delete non-existant entry
512 @return EFI_OUT_OF_RESOURCES Not enough memory available
517 CoreInstallConfigurationTable (
525 Raise the task priority level to the new level.
526 High level is implemented by disabling processor interrupts.
528 @param NewTpl New task priority level
530 @return The previous task priority level
542 Lowers the task priority to the previous value. If the new
543 priority unmasks events at a higher priority, they are dispatched.
545 @param NewTpl New, lower, task priority
557 Introduces a fine-grained stall.
559 @param Microseconds The number of microseconds to stall execution.
561 @retval EFI_SUCCESS Execution was stalled for at least the requested
562 amount of microseconds.
563 @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet
569 IN UINTN Microseconds
575 Sets the system's watchdog timer.
577 @param Timeout The number of seconds to set the watchdog timer to.
578 A value of zero disables the timer.
579 @param WatchdogCode The numeric code to log on a watchdog timer timeout
580 event. The firmware reserves codes 0x0000 to 0xFFFF.
581 Loaders and operating systems may use other timeout
583 @param DataSize The size, in bytes, of WatchdogData.
584 @param WatchdogData A data buffer that includes a Null-terminated Unicode
585 string, optionally followed by additional binary data.
586 The string is a description that the call may use to
587 further indicate the reason to be logged with a
590 @return EFI_SUCCESS Timeout has been set
591 @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
592 @return EFI_UNSUPPORTED System does not have a timer (currently not used)
593 @return EFI_DEVICE_ERROR Could not complete due to hardware error
598 CoreSetWatchdogTimer (
600 IN UINT64 WatchdogCode
,
602 IN CHAR16
*WatchdogData OPTIONAL
608 Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
609 Calls the private one which contains a BOOLEAN parameter for notifications
611 @param UserHandle The handle to install the protocol handler on,
612 or NULL if a new handle is to be allocated
613 @param Protocol The protocol to add to the handle
614 @param InterfaceType Indicates whether Interface is supplied in
616 @param Interface The interface for the protocol being added
623 CoreInstallProtocolInterface (
624 IN OUT EFI_HANDLE
*UserHandle
,
625 IN EFI_GUID
*Protocol
,
626 IN EFI_INTERFACE_TYPE InterfaceType
,
632 Installs a protocol interface into the boot services environment.
634 @param UserHandle The handle to install the protocol handler on,
635 or NULL if a new handle is to be allocated
636 @param Protocol The protocol to add to the handle
637 @param InterfaceType Indicates whether Interface is supplied in
639 @param Interface The interface for the protocol being added
640 @param Notify indicates whether notify the notification list
643 @retval EFI_INVALID_PARAMETER Invalid parameter
644 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
645 @retval EFI_SUCCESS Protocol interface successfully installed
649 CoreInstallProtocolInterfaceNotify (
650 IN OUT EFI_HANDLE
*UserHandle
,
651 IN EFI_GUID
*Protocol
,
652 IN EFI_INTERFACE_TYPE InterfaceType
,
660 Installs a list of protocol interface into the boot services environment.
661 This function calls InstallProtocolInterface() in a loop. If any error
662 occures all the protocols added by this function are removed. This is
663 basically a lib function to save space.
665 @param Handle The handle to install the protocol handlers on,
666 or NULL if a new handle is to be allocated
667 @param ... EFI_GUID followed by protocol instance. A NULL
668 terminates the list. The pairs are the
669 arguments to InstallProtocolInterface(). All the
670 protocols are added to Handle.
672 @retval EFI_INVALID_PARAMETER Handle is NULL.
673 @retval EFI_SUCCESS Protocol interfaces successfully installed.
678 CoreInstallMultipleProtocolInterfaces (
679 IN OUT EFI_HANDLE
*Handle
,
686 Uninstalls a list of protocol interface in the boot services environment.
687 This function calls UnisatllProtocolInterface() in a loop. This is
688 basically a lib function to save space.
690 @param Handle The handle to uninstall the protocol
691 @param ... EFI_GUID followed by protocol instance. A NULL
692 terminates the list. The pairs are the
693 arguments to UninstallProtocolInterface(). All
694 the protocols are added to Handle.
701 CoreUninstallMultipleProtocolInterfaces (
702 IN EFI_HANDLE Handle
,
709 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
711 @param UserHandle Handle on which the interface is to be
713 @param Protocol The numeric ID of the interface
714 @param OldInterface A pointer to the old interface
715 @param NewInterface A pointer to the new interface
717 @retval EFI_SUCCESS The protocol interface was installed
718 @retval EFI_NOT_FOUND The OldInterface on the handle was not found
719 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
724 CoreReinstallProtocolInterface (
725 IN EFI_HANDLE UserHandle
,
726 IN EFI_GUID
*Protocol
,
727 IN VOID
*OldInterface
,
728 IN VOID
*NewInterface
734 Uninstalls all instances of a protocol:interfacer from a handle.
735 If the last protocol interface is remove from the handle, the
738 @param UserHandle The handle to remove the protocol handler from
739 @param Protocol The protocol, of protocol:interface, to remove
740 @param Interface The interface, of protocol:interface, to remove
742 @retval EFI_INVALID_PARAMETER Protocol is NULL.
743 @retval EFI_SUCCESS Protocol interface successfully uninstalled.
748 CoreUninstallProtocolInterface (
749 IN EFI_HANDLE UserHandle
,
750 IN EFI_GUID
*Protocol
,
757 Queries a handle to determine if it supports a specified protocol.
759 @param UserHandle The handle being queried.
760 @param Protocol The published unique identifier of the protocol.
761 @param Interface Supplies the address where a pointer to the
762 corresponding Protocol Interface is returned.
764 @return The requested protocol interface for the handle
770 IN EFI_HANDLE UserHandle
,
771 IN EFI_GUID
*Protocol
,
778 Locates the installed protocol handler for the handle, and
779 invokes it to obtain the protocol interface. Usage information
780 is registered in the protocol data base.
782 @param UserHandle The handle to obtain the protocol interface on
783 @param Protocol The ID of the protocol
784 @param Interface The location to return the protocol interface
785 @param ImageHandle The handle of the Image that is opening the
786 protocol interface specified by Protocol and
788 @param ControllerHandle The controller handle that is requiring this
790 @param Attributes The open mode of the protocol interface
791 specified by Handle and Protocol.
793 @retval EFI_INVALID_PARAMETER Protocol is NULL.
794 @retval EFI_SUCCESS Get the protocol interface.
800 IN EFI_HANDLE UserHandle
,
801 IN EFI_GUID
*Protocol
,
802 OUT VOID
**Interface OPTIONAL
,
803 IN EFI_HANDLE ImageHandle
,
804 IN EFI_HANDLE ControllerHandle
,
811 Return information about Opened protocols in the system
813 @param UserHandle The handle to close the protocol interface on
814 @param Protocol The ID of the protocol
815 @param EntryBuffer A pointer to a buffer of open protocol
816 information in the form of
817 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
818 @param EntryCount Number of EntryBuffer entries
823 CoreOpenProtocolInformation (
824 IN EFI_HANDLE UserHandle
,
825 IN EFI_GUID
*Protocol
,
826 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
**EntryBuffer
,
827 OUT UINTN
*EntryCount
833 Closes a protocol on a handle that was opened using OpenProtocol().
835 @param UserHandle The handle for the protocol interface that was
836 previously opened with OpenProtocol(), and is
838 @param Protocol The published unique identifier of the protocol.
839 It is the caller's responsibility to pass in a
841 @param AgentHandle The handle of the agent that is closing the
843 @param ControllerHandle If the agent that opened a protocol is a driver
844 that follows the EFI Driver Model, then this
845 parameter is the controller handle that required
846 the protocol interface. If the agent does not
847 follow the EFI Driver Model, then this parameter
848 is optional and may be NULL.
850 @retval EFI_SUCCESS The protocol instance was closed.
851 @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a
853 @retval EFI_NOT_FOUND Can not find the specified protocol or
860 IN EFI_HANDLE UserHandle
,
861 IN EFI_GUID
*Protocol
,
862 IN EFI_HANDLE AgentHandle
,
863 IN EFI_HANDLE ControllerHandle
869 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
872 @param UserHandle The handle from which to retrieve the list of
873 protocol interface GUIDs.
874 @param ProtocolBuffer A pointer to the list of protocol interface GUID
875 pointers that are installed on Handle.
876 @param ProtocolBufferCount A pointer to the number of GUID pointers present
879 @retval EFI_SUCCESS The list of protocol interface GUIDs installed
880 on Handle was returned in ProtocolBuffer. The
881 number of protocol interface GUIDs was returned
882 in ProtocolBufferCount.
883 @retval EFI_INVALID_PARAMETER Handle is NULL.
884 @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
885 @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.
886 @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.
887 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
893 CoreProtocolsPerHandle (
894 IN EFI_HANDLE UserHandle
,
895 OUT EFI_GUID
***ProtocolBuffer
,
896 OUT UINTN
*ProtocolBufferCount
902 Add a new protocol notification record for the request protocol.
904 @param Protocol The requested protocol to add the notify
906 @param Event The event to signal
907 @param Registration Returns the registration record
909 @retval EFI_INVALID_PARAMETER Invalid parameter
910 @retval EFI_SUCCESS Successfully returned the registration record
916 CoreRegisterProtocolNotify (
917 IN EFI_GUID
*Protocol
,
919 OUT VOID
**Registration
924 Removes all the events in the protocol database that match Event.
926 @param Event The event to search for in the protocol
929 @return EFI_SUCCESS when done searching the entire database.
933 CoreUnregisterProtocolNotify (
939 Locates the requested handle(s) and returns them in Buffer.
941 @param SearchType The type of search to perform to locate the
943 @param Protocol The protocol to search for
944 @param SearchKey Dependant on SearchType
945 @param BufferSize On input the size of Buffer. On output the
946 size of data returned.
947 @param Buffer The buffer to return the results in
949 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
950 returned in BufferSize.
951 @retval EFI_INVALID_PARAMETER Invalid parameter
952 @retval EFI_SUCCESS Successfully found the requested handle(s) and
953 returns them in Buffer.
959 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
960 IN EFI_GUID
*Protocol OPTIONAL
,
961 IN VOID
*SearchKey OPTIONAL
,
962 IN OUT UINTN
*BufferSize
,
963 OUT EFI_HANDLE
*Buffer
969 Locates the handle to a device on the device path that best matches the specified protocol.
971 @param Protocol The protocol to search for.
972 @param DevicePath On input, a pointer to a pointer to the device
973 path. On output, the device path pointer is
974 modified to point to the remaining part of the
976 @param Device A pointer to the returned device handle.
978 @retval EFI_SUCCESS The resulting handle was returned.
979 @retval EFI_NOT_FOUND No handles matched the search.
980 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
985 CoreLocateDevicePath (
986 IN EFI_GUID
*Protocol
,
987 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
988 OUT EFI_HANDLE
*Device
994 Function returns an array of handles that support the requested protocol
995 in a buffer allocated from pool. This is a version of CoreLocateHandle()
996 that allocates a buffer for the caller.
998 @param SearchType Specifies which handle(s) are to be returned.
999 @param Protocol Provides the protocol to search by. This
1000 parameter is only valid for SearchType
1002 @param SearchKey Supplies the search key depending on the
1004 @param NumberHandles The number of handles returned in Buffer.
1005 @param Buffer A pointer to the buffer to return the requested
1006 array of handles that support Protocol.
1008 @retval EFI_SUCCESS The result array of handles was returned.
1009 @retval EFI_NOT_FOUND No handles match the search.
1010 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
1012 @retval EFI_INVALID_PARAMETER One or more paramters are not valid.
1017 CoreLocateHandleBuffer (
1018 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1019 IN EFI_GUID
*Protocol OPTIONAL
,
1020 IN VOID
*SearchKey OPTIONAL
,
1021 IN OUT UINTN
*NumberHandles
,
1022 OUT EFI_HANDLE
**Buffer
1028 Return the first Protocol Interface that matches the Protocol GUID. If
1029 Registration is passed in, return a Protocol Instance that was just add
1030 to the system. If Registration is NULL return the first Protocol Interface
1033 @param Protocol The protocol to search for
1034 @param Registration Optional Registration Key returned from
1035 RegisterProtocolNotify()
1036 @param Interface Return the Protocol interface (instance).
1038 @retval EFI_SUCCESS If a valid Interface is returned
1039 @retval EFI_INVALID_PARAMETER Invalid parameter
1040 @retval EFI_NOT_FOUND Protocol interface not found
1045 CoreLocateProtocol (
1046 IN EFI_GUID
*Protocol
,
1047 IN VOID
*Registration OPTIONAL
,
1048 OUT VOID
**Interface
1053 return handle database key.
1056 @return Handle database key.
1060 CoreGetHandleDatabaseKey (
1066 Go connect any handles that were created or modified while a image executed.
1068 @param Key The Key to show that the handle has been
1073 CoreConnectHandlesByKey (
1080 Connects one or more drivers to a controller.
1082 @param ControllerHandle Handle of the controller to be
1084 @param DriverImageHandle DriverImageHandle A pointer to an
1085 ordered list of driver image
1087 @param RemainingDevicePath RemainingDevicePath A pointer to
1088 the device path that specifies a
1089 child of the controller specified
1090 by ControllerHandle.
1091 @param Recursive Whether the function would be
1092 called recursively or not.
1094 @return Status code.
1099 CoreConnectController (
1100 IN EFI_HANDLE ControllerHandle
,
1101 IN EFI_HANDLE
*DriverImageHandle OPTIONAL
,
1102 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
1103 IN BOOLEAN Recursive
1109 Disonnects a controller from a driver
1111 @param ControllerHandle ControllerHandle The handle of
1112 the controller from which
1115 @param DriverImageHandle DriverImageHandle The driver to
1116 disconnect from ControllerHandle.
1117 @param ChildHandle ChildHandle The handle of the
1120 @retval EFI_SUCCESS One or more drivers were
1121 disconnected from the controller.
1122 @retval EFI_SUCCESS On entry, no drivers are managing
1124 @retval EFI_SUCCESS DriverImageHandle is not NULL,
1125 and on entry DriverImageHandle is
1126 not managing ControllerHandle.
1127 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
1128 @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
1129 and it is not a valid EFI_HANDLE.
1130 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
1131 is not a valid EFI_HANDLE.
1132 @retval EFI_OUT_OF_RESOURCES There are not enough resources
1133 available to disconnect any
1134 drivers from ControllerHandle.
1135 @retval EFI_DEVICE_ERROR The controller could not be
1136 disconnected because of a device
1142 CoreDisconnectController (
1143 IN EFI_HANDLE ControllerHandle
,
1144 IN EFI_HANDLE DriverImageHandle OPTIONAL
,
1145 IN EFI_HANDLE ChildHandle OPTIONAL
1151 Allocates pages from the memory map.
1153 @param Type The type of allocation to perform
1154 @param MemoryType The type of memory to turn the allocated pages
1156 @param NumberOfPages The number of pages to allocate
1157 @param Memory A pointer to receive the base allocated memory
1160 @return Status. On success, Memory is filled in with the base address allocated
1161 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
1163 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
1164 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
1165 @retval EFI_SUCCESS Pages successfully allocated.
1171 IN EFI_ALLOCATE_TYPE Type
,
1172 IN EFI_MEMORY_TYPE MemoryType
,
1173 IN UINTN NumberOfPages
,
1174 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
1180 Frees previous allocated pages.
1182 @param Memory Base address of memory being freed
1183 @param NumberOfPages The number of pages to free
1185 @retval EFI_NOT_FOUND Could not find the entry that covers the range
1186 @retval EFI_INVALID_PARAMETER Address not aligned
1187 @return EFI_SUCCESS -Pages successfully freed.
1193 IN EFI_PHYSICAL_ADDRESS Memory
,
1194 IN UINTN NumberOfPages
1200 This function returns a copy of the current memory map. The map is an array of
1201 memory descriptors, each of which describes a contiguous block of memory.
1203 @param MemoryMapSize A pointer to the size, in bytes, of the
1204 MemoryMap buffer. On input, this is the size of
1205 the buffer allocated by the caller. On output,
1206 it is the size of the buffer returned by the
1207 firmware if the buffer was large enough, or the
1208 size of the buffer needed to contain the map if
1209 the buffer was too small.
1210 @param MemoryMap A pointer to the buffer in which firmware places
1211 the current memory map.
1212 @param MapKey A pointer to the location in which firmware
1213 returns the key for the current memory map.
1214 @param DescriptorSize A pointer to the location in which firmware
1215 returns the size, in bytes, of an individual
1216 EFI_MEMORY_DESCRIPTOR.
1217 @param DescriptorVersion A pointer to the location in which firmware
1218 returns the version number associated with the
1219 EFI_MEMORY_DESCRIPTOR.
1221 @retval EFI_SUCCESS The memory map was returned in the MemoryMap
1223 @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
1224 buffer size needed to hold the memory map is
1225 returned in MemoryMapSize.
1226 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1232 IN OUT UINTN
*MemoryMapSize
,
1233 IN OUT EFI_MEMORY_DESCRIPTOR
*MemoryMap
,
1235 OUT UINTN
*DescriptorSize
,
1236 OUT UINT32
*DescriptorVersion
1242 Allocate pool of a particular type.
1244 @param PoolType Type of pool to allocate
1245 @param Size The amount of pool to allocate
1246 @param Buffer The address to return a pointer to the allocated
1249 @retval EFI_INVALID_PARAMETER PoolType not valid
1250 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
1251 @retval EFI_SUCCESS Pool successfully allocated.
1257 IN EFI_MEMORY_TYPE PoolType
,
1267 @param Buffer The allocated pool entry to free
1269 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
1270 @retval EFI_SUCCESS Pool successfully freed.
1282 Loads an EFI image into memory and returns a handle to the image.
1284 @param BootPolicy If TRUE, indicates that the request originates
1285 from the boot manager, and that the boot
1286 manager is attempting to load FilePath as a
1288 @param ParentImageHandle The caller's image handle.
1289 @param FilePath The specific file path from which the image is
1291 @param SourceBuffer If not NULL, a pointer to the memory location
1292 containing a copy of the image to be loaded.
1293 @param SourceSize The size in bytes of SourceBuffer.
1294 @param ImageHandle Pointer to the returned image handle that is
1295 created when the image is successfully loaded.
1297 @retval EFI_SUCCESS The image was loaded into memory.
1298 @retval EFI_NOT_FOUND The FilePath was not found.
1299 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1300 @retval EFI_UNSUPPORTED The image type is not supported, or the device
1301 path cannot be parsed to locate the proper
1302 protocol for loading the file.
1303 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
1305 @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
1307 @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
1308 @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
1309 image from being loaded. NULL is returned in *ImageHandle.
1310 @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
1311 valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
1312 platform policy specifies that the image should not be started.
1318 IN BOOLEAN BootPolicy
,
1319 IN EFI_HANDLE ParentImageHandle
,
1320 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
1321 IN VOID
*SourceBuffer OPTIONAL
,
1322 IN UINTN SourceSize
,
1323 OUT EFI_HANDLE
*ImageHandle
1331 @param ImageHandle Handle that identifies the image to be
1334 @retval EFI_SUCCESS The image has been unloaded.
1335 @retval EFI_UNSUPPORTED The image has been sarted, and does not support
1337 @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
1343 IN EFI_HANDLE ImageHandle
1349 Transfer control to a loaded image's entry point.
1351 @param ImageHandle Handle of image to be started.
1352 @param ExitDataSize Pointer of the size to ExitData
1353 @param ExitData Pointer to a pointer to a data buffer that
1354 includes a Null-terminated string,
1355 optionally followed by additional binary data.
1356 The string is a description that the caller may
1357 use to further indicate the reason for the
1360 @retval EFI_INVALID_PARAMETER Invalid parameter
1361 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1362 @retval EFI_SUCCESS Successfully transfer control to the image's
1369 IN EFI_HANDLE ImageHandle
,
1370 OUT UINTN
*ExitDataSize
,
1371 OUT CHAR16
**ExitData OPTIONAL
1377 Terminates the currently loaded EFI image and returns control to boot services.
1379 @param ImageHandle Handle that identifies the image. This
1380 parameter is passed to the image on entry.
1381 @param Status The image's exit code.
1382 @param ExitDataSize The size, in bytes, of ExitData. Ignored if
1383 ExitStatus is EFI_SUCCESS.
1384 @param ExitData Pointer to a data buffer that includes a
1385 Null-terminated Unicode string, optionally
1386 followed by additional binary data. The string
1387 is a description that the caller may use to
1388 further indicate the reason for the image's
1391 @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
1393 @retval EFI_SUCCESS Successfully terminates the currently loaded
1395 @retval EFI_ACCESS_DENIED Should never reach there.
1396 @retval EFI_OUT_OF_RESOURCES Could not allocate pool
1402 IN EFI_HANDLE ImageHandle
,
1403 IN EFI_STATUS Status
,
1404 IN UINTN ExitDataSize
,
1405 IN CHAR16
*ExitData OPTIONAL
1411 Creates a general-purpose event structure.
1413 @param Type The type of event to create and its mode and
1415 @param NotifyTpl The task priority level of event notifications
1416 @param NotifyFunction Pointer to the events notification function
1417 @param NotifyContext Pointer to the notification functions context;
1418 corresponds to parameter "Context" in the
1419 notification function
1420 @param Event Pointer to the newly created event if the call
1421 succeeds; undefined otherwise
1423 @retval EFI_SUCCESS The event structure was created
1424 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1425 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1432 IN EFI_TPL NotifyTpl
,
1433 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1434 IN VOID
*NotifyContext
, OPTIONAL
1435 OUT EFI_EVENT
*Event
1441 Creates a general-purpose event structure
1443 @param Type The type of event to create and its mode and
1445 @param NotifyTpl The task priority level of event notifications
1446 @param NotifyFunction Pointer to the events notification function
1447 @param NotifyContext Pointer to the notification functions context;
1448 corresponds to parameter "Context" in the
1449 notification function
1450 @param EventGroup GUID for EventGroup if NULL act the same as
1452 @param Event Pointer to the newly created event if the call
1453 succeeds; undefined otherwise
1455 @retval EFI_SUCCESS The event structure was created
1456 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
1457 @retval EFI_OUT_OF_RESOURCES The event could not be allocated
1464 IN EFI_TPL NotifyTpl
,
1465 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1466 IN CONST VOID
*NotifyContext
, OPTIONAL
1467 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1468 OUT EFI_EVENT
*Event
1474 Sets the type of timer and the trigger time for a timer event.
1476 @param UserEvent The timer event that is to be signaled at the
1478 @param Type The type of time that is specified in
1480 @param TriggerTime The number of 100ns units until the timer
1483 @retval EFI_SUCCESS The event has been set to be signaled at the
1485 @retval EFI_INVALID_PARAMETER Event or Type is not valid
1491 IN EFI_EVENT UserEvent
,
1492 IN EFI_TIMER_DELAY Type
,
1493 IN UINT64 TriggerTime
1499 Signals the event. Queues the event to be notified if needed.
1501 @param UserEvent The event to signal .
1503 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1504 @retval EFI_SUCCESS The event was signaled.
1510 IN EFI_EVENT UserEvent
1516 Stops execution until an event is signaled.
1518 @param NumberOfEvents The number of events in the UserEvents array
1519 @param UserEvents An array of EFI_EVENT
1520 @param UserIndex Pointer to the index of the event which
1521 satisfied the wait condition
1523 @retval EFI_SUCCESS The event indicated by Index was signaled.
1524 @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification
1525 function or Event was not a valid type
1526 @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION
1532 IN UINTN NumberOfEvents
,
1533 IN EFI_EVENT
*UserEvents
,
1534 OUT UINTN
*UserIndex
1540 Closes an event and frees the event structure.
1542 @param UserEvent Event to close
1544 @retval EFI_INVALID_PARAMETER Parameters are not valid.
1545 @retval EFI_SUCCESS The event has been closed
1551 IN EFI_EVENT UserEvent
1557 Check the status of an event.
1559 @param UserEvent The event to check
1561 @retval EFI_SUCCESS The event is in the signaled state
1562 @retval EFI_NOT_READY The event is not in the signaled state
1563 @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL
1569 IN EFI_EVENT UserEvent
1574 Adds reserved memory, system memory, or memory-mapped I/O resources to the
1575 global coherency domain of the processor.
1577 @param GcdMemoryType Memory type of the memory space.
1578 @param BaseAddress Base address of the memory space.
1579 @param Length Length of the memory space.
1580 @param Capabilities alterable attributes of the memory space.
1582 @retval EFI_SUCCESS Merged this memory space into GCD map.
1587 CoreAddMemorySpace (
1588 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1589 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1591 IN UINT64 Capabilities
1596 Allocates nonexistent memory, reserved memory, system memory, or memorymapped
1597 I/O resources from the global coherency domain of the processor.
1599 @param GcdAllocateType The type of allocate operation
1600 @param GcdMemoryType The desired memory type
1601 @param Alignment Align with 2^Alignment
1602 @param Length Length to allocate
1603 @param BaseAddress Base address to allocate
1604 @param ImageHandle The image handle consume the allocated space.
1605 @param DeviceHandle The device handle consume the allocated space.
1607 @retval EFI_INVALID_PARAMETER Invalid parameter.
1608 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1609 @retval EFI_SUCCESS Memory space successfully allocated.
1614 CoreAllocateMemorySpace (
1615 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1616 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1619 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1620 IN EFI_HANDLE ImageHandle
,
1621 IN EFI_HANDLE DeviceHandle OPTIONAL
1626 Frees nonexistent memory, reserved memory, system memory, or memory-mapped
1627 I/O resources from the global coherency domain of the processor.
1629 @param BaseAddress Base address of the memory space.
1630 @param Length Length of the memory space.
1632 @retval EFI_SUCCESS Space successfully freed.
1637 CoreFreeMemorySpace (
1638 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1644 Removes reserved memory, system memory, or memory-mapped I/O resources from
1645 the global coherency domain of the processor.
1647 @param BaseAddress Base address of the memory space.
1648 @param Length Length of the memory space.
1650 @retval EFI_SUCCESS Successfully remove a segment of memory space.
1655 CoreRemoveMemorySpace (
1656 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1662 Retrieves the descriptor for a memory region containing a specified address.
1664 @param BaseAddress Specified start address
1665 @param Descriptor Specified length
1667 @retval EFI_INVALID_PARAMETER Invalid parameter
1668 @retval EFI_SUCCESS Successfully get memory space descriptor.
1673 CoreGetMemorySpaceDescriptor (
1674 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1675 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*Descriptor
1680 Modifies the attributes for a memory region in the global coherency domain of the
1683 @param BaseAddress Specified start address
1684 @param Length Specified length
1685 @param Attributes Specified attributes
1687 @retval EFI_SUCCESS The attributes were set for the memory region.
1688 @retval EFI_INVALID_PARAMETER Length is zero.
1689 @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory
1690 resource range specified by BaseAddress and Length.
1691 @retval EFI_UNSUPPORTED The bit mask of attributes is not support for the memory resource
1692 range specified by BaseAddress and Length.
1693 @retval EFI_ACCESS_DEFINED The attributes for the memory resource range specified by
1694 BaseAddress and Length cannot be modified.
1695 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of
1696 the memory resource range.
1697 @retval EFI_NOT_AVAILABLE_YET The attributes cannot be set because CPU architectural protocol is
1703 CoreSetMemorySpaceAttributes (
1704 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1706 IN UINT64 Attributes
1711 Returns a map of the memory resources in the global coherency domain of the
1714 @param NumberOfDescriptors Number of descriptors.
1715 @param MemorySpaceMap Descriptor array
1717 @retval EFI_INVALID_PARAMETER Invalid parameter
1718 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1719 @retval EFI_SUCCESS Successfully get memory space map.
1724 CoreGetMemorySpaceMap (
1725 OUT UINTN
*NumberOfDescriptors
,
1726 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
**MemorySpaceMap
1731 Adds reserved I/O or I/O resources to the global coherency domain of the processor.
1733 @param GcdIoType IO type of the segment.
1734 @param BaseAddress Base address of the segment.
1735 @param Length Length of the segment.
1737 @retval EFI_SUCCESS Merged this segment into GCD map.
1738 @retval EFI_INVALID_PARAMETER Parameter not valid
1744 IN EFI_GCD_IO_TYPE GcdIoType
,
1745 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1751 Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1752 domain of the processor.
1754 @param GcdAllocateType The type of allocate operation
1755 @param GcdIoType The desired IO type
1756 @param Alignment Align with 2^Alignment
1757 @param Length Length to allocate
1758 @param BaseAddress Base address to allocate
1759 @param ImageHandle The image handle consume the allocated space.
1760 @param DeviceHandle The device handle consume the allocated space.
1762 @retval EFI_INVALID_PARAMETER Invalid parameter.
1763 @retval EFI_NOT_FOUND No descriptor contains the desired space.
1764 @retval EFI_SUCCESS IO space successfully allocated.
1769 CoreAllocateIoSpace (
1770 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1771 IN EFI_GCD_IO_TYPE GcdIoType
,
1774 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1775 IN EFI_HANDLE ImageHandle
,
1776 IN EFI_HANDLE DeviceHandle OPTIONAL
1781 Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency
1782 domain of the processor.
1784 @param BaseAddress Base address of the segment.
1785 @param Length Length of the segment.
1787 @retval EFI_SUCCESS Space successfully freed.
1793 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1799 Removes reserved I/O or I/O resources from the global coherency domain of the
1802 @param BaseAddress Base address of the segment.
1803 @param Length Length of the segment.
1805 @retval EFI_SUCCESS Successfully removed a segment of IO space.
1811 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1817 Retrieves the descriptor for an I/O region containing a specified address.
1819 @param BaseAddress Specified start address
1820 @param Descriptor Specified length
1822 @retval EFI_INVALID_PARAMETER Descriptor is NULL.
1823 @retval EFI_SUCCESS Successfully get the IO space descriptor.
1828 CoreGetIoSpaceDescriptor (
1829 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1830 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
*Descriptor
1835 Returns a map of the I/O resources in the global coherency domain of the processor.
1837 @param NumberOfDescriptors Number of descriptors.
1838 @param IoSpaceMap Descriptor array
1840 @retval EFI_INVALID_PARAMETER Invalid parameter
1841 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
1842 @retval EFI_SUCCESS Successfully get IO space map.
1848 OUT UINTN
*NumberOfDescriptors
,
1849 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
**IoSpaceMap
1854 This is the main Dispatcher for DXE and it exits when there are no more
1855 drivers to run. Drain the mScheduledQueue and load and start a PE
1856 image for each driver. Search the mDiscoveredList to see if any driver can
1857 be placed on the mScheduledQueue. If no drivers are placed on the
1858 mScheduledQueue exit the function. On exit it is assumed the Bds()
1859 will be called, and when the Bds() exits the Dispatcher will be called
1862 @retval EFI_ALREADY_STARTED The DXE Dispatcher is already running
1863 @retval EFI_NOT_FOUND No DXE Drivers were dispatched
1864 @retval EFI_SUCCESS One or more DXE Drivers were dispatched
1874 Check every driver and locate a matching one. If the driver is found, the Unrequested
1875 state flag is cleared.
1877 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1878 the firmware file specified by DriverName.
1879 @param DriverName The Driver name to put in the Dependent state.
1881 @retval EFI_SUCCESS The DriverName was found and it's SOR bit was
1883 @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was
1890 IN EFI_HANDLE FirmwareVolumeHandle
,
1891 IN EFI_GUID
*DriverName
1896 Convert a driver from the Untrused back to the Scheduled state.
1898 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
1899 the firmware file specified by DriverName.
1900 @param DriverName The Driver name to put in the Scheduled state
1902 @retval EFI_SUCCESS The file was found in the untrusted state, and it
1903 was promoted to the trusted state.
1904 @retval EFI_NOT_FOUND The file was not found in the untrusted state.
1910 IN EFI_HANDLE FirmwareVolumeHandle
,
1911 IN EFI_GUID
*DriverName
1916 This routine is the driver initialization entry point. It initializes the
1917 libraries, and registers two notification functions. These notification
1918 functions are responsible for building the FV stack dynamically.
1920 @param ImageHandle The image handle.
1921 @param SystemTable The system table.
1923 @retval EFI_SUCCESS Function successfully returned.
1929 IN EFI_HANDLE ImageHandle
,
1930 IN EFI_SYSTEM_TABLE
*SystemTable
1935 Entry point of the section extraction code. Initializes an instance of the
1936 section extraction interface and installs it on a new handle.
1938 @param ImageHandle A handle for the image that is initializing this driver
1939 @param SystemTable A pointer to the EFI system table
1941 @retval EFI_SUCCESS Driver initialized successfully
1942 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
1947 InitializeSectionExtraction (
1948 IN EFI_HANDLE ImageHandle
,
1949 IN EFI_SYSTEM_TABLE
*SystemTable
1954 This DXE service routine is used to process a firmware volume. In
1955 particular, it can be called by BDS to process a single firmware
1956 volume found in a capsule.
1958 @param FvHeader pointer to a firmware volume header
1959 @param Size the size of the buffer pointed to by FvHeader
1960 @param FVProtocolHandle the handle on which a firmware volume protocol
1961 was produced for the firmware volume passed in.
1963 @retval EFI_OUT_OF_RESOURCES if an FVB could not be produced due to lack of
1965 @retval EFI_VOLUME_CORRUPTED if the volume was corrupted
1966 @retval EFI_SUCCESS a firmware volume protocol was produced for the
1972 CoreProcessFirmwareVolume (
1975 OUT EFI_HANDLE
*FVProtocolHandle
1979 //Functions used during debug buils
1983 Displays Architectural protocols that were not loaded and are required for DXE
1984 core to function. Only used in Debug Builds.
1988 CoreDisplayMissingArchProtocols (
1994 Traverse the discovered list for any drivers that were discovered but not loaded
1995 because the dependency experessions evaluated to false.
1999 CoreDisplayDiscoveredNotDispatched (
2005 Place holder function until all the Boot Services and Runtime Services are
2008 @return EFI_NOT_AVAILABLE_YET
2013 CoreEfiNotAvailableYetArg0 (
2019 Place holder function until all the Boot Services and Runtime Services are
2022 @param Arg1 Undefined
2024 @return EFI_NOT_AVAILABLE_YET
2029 CoreEfiNotAvailableYetArg1 (
2035 Place holder function until all the Boot Services and Runtime Services are available.
2037 @param Arg1 Undefined
2038 @param Arg2 Undefined
2040 @return EFI_NOT_AVAILABLE_YET
2045 CoreEfiNotAvailableYetArg2 (
2052 Place holder function until all the Boot Services and Runtime Services are available.
2054 @param Arg1 Undefined
2055 @param Arg2 Undefined
2056 @param Arg3 Undefined
2058 @return EFI_NOT_AVAILABLE_YET
2063 CoreEfiNotAvailableYetArg3 (
2071 Place holder function until all the Boot Services and Runtime Services are available.
2073 @param Arg1 Undefined
2074 @param Arg2 Undefined
2075 @param Arg3 Undefined
2076 @param Arg4 Undefined
2078 @return EFI_NOT_AVAILABLE_YET
2083 CoreEfiNotAvailableYetArg4 (
2092 Place holder function until all the Boot Services and Runtime Services are available.
2094 @param Arg1 Undefined
2095 @param Arg2 Undefined
2096 @param Arg3 Undefined
2097 @param Arg4 Undefined
2098 @param Arg5 Undefined
2100 @return EFI_NOT_AVAILABLE_YET
2105 CoreEfiNotAvailableYetArg5 (
2115 Given a compressed source buffer, this function retrieves the size of the
2116 uncompressed buffer and the size of the scratch buffer required to decompress
2117 the compressed source buffer.
2119 The GetInfo() function retrieves the size of the uncompressed buffer and the
2120 temporary scratch buffer required to decompress the buffer specified by Source
2121 and SourceSize. If the size of the uncompressed buffer or the size of the
2122 scratch buffer cannot be determined from the compressed data specified by
2123 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
2124 size of the uncompressed buffer is returned in DestinationSize, the size of
2125 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
2126 The GetInfo() function does not have scratch buffer available to perform a
2127 thorough checking of the validity of the source data. It just retrieves the
2128 "Original Size" field from the beginning bytes of the source data and output
2129 it as DestinationSize. And ScratchSize is specific to the decompression
2132 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2133 @param Source The source buffer containing the compressed data.
2134 @param SourceSize The size, in bytes, of the source buffer.
2135 @param DestinationSize A pointer to the size, in bytes, of the
2136 uncompressed buffer that will be generated when the
2137 compressed buffer specified by Source and
2138 SourceSize is decompressed.
2139 @param ScratchSize A pointer to the size, in bytes, of the scratch
2140 buffer that is required to decompress the
2141 compressed buffer specified by Source and
2144 @retval EFI_SUCCESS The size of the uncompressed data was returned in
2145 DestinationSize and the size of the scratch buffer
2146 was returned in ScratchSize.
2147 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
2148 the scratch buffer cannot be determined from the
2149 compressed data specified by Source and
2155 DxeMainUefiDecompressGetInfo (
2156 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2158 IN UINT32 SourceSize
,
2159 OUT UINT32
*DestinationSize
,
2160 OUT UINT32
*ScratchSize
2165 Decompresses a compressed source buffer.
2167 The Decompress() function extracts decompressed data to its original form.
2168 This protocol is designed so that the decompression algorithm can be
2169 implemented without using any memory services. As a result, the Decompress()
2170 Function is not allowed to call AllocatePool() or AllocatePages() in its
2171 implementation. It is the caller's responsibility to allocate and free the
2172 Destination and Scratch buffers.
2173 If the compressed source data specified by Source and SourceSize is
2174 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
2175 the compressed source data specified by Source and SourceSize is not in a
2176 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
2178 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
2179 @param Source The source buffer containing the compressed data.
2180 @param SourceSize SourceSizeThe size of source data.
2181 @param Destination On output, the destination buffer that contains
2182 the uncompressed data.
2183 @param DestinationSize The size of the destination buffer. The size of
2184 the destination buffer needed is obtained from
2185 EFI_DECOMPRESS_PROTOCOL.GetInfo().
2186 @param Scratch A temporary scratch buffer that is used to perform
2188 @param ScratchSize The size of scratch buffer. The size of the
2189 scratch buffer needed is obtained from GetInfo().
2191 @retval EFI_SUCCESS Decompression completed successfully, and the
2192 uncompressed buffer is returned in Destination.
2193 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
2194 SourceSize is corrupted (not in a valid
2200 DxeMainUefiDecompress (
2201 IN EFI_DECOMPRESS_PROTOCOL
*This
,
2203 IN UINT32 SourceSize
,
2204 IN OUT VOID
*Destination
,
2205 IN UINT32 DestinationSize
,
2206 IN OUT VOID
*Scratch
,
2207 IN UINT32 ScratchSize
2211 SEP member function. This function creates and returns a new section stream
2212 handle to represent the new section stream.
2214 @param SectionStreamLength Size in bytes of the section stream.
2215 @param SectionStream Buffer containing the new section stream.
2216 @param SectionStreamHandle A pointer to a caller allocated UINTN that on
2217 output contains the new section stream handle.
2219 @retval EFI_SUCCESS The section stream is created successfully.
2220 @retval EFI_OUT_OF_RESOURCES memory allocation failed.
2221 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2228 IN UINTN SectionStreamLength
,
2229 IN VOID
*SectionStream
,
2230 OUT UINTN
*SectionStreamHandle
2236 SEP member function. Retrieves requested section from section stream.
2238 @param SectionStreamHandle The section stream from which to extract the
2240 @param SectionType A pointer to the type of section to search for.
2241 @param SectionDefinitionGuid If the section type is EFI_SECTION_GUID_DEFINED,
2242 then SectionDefinitionGuid indicates which of
2243 these types of sections to search for.
2244 @param SectionInstance Indicates which instance of the requested
2246 @param Buffer Double indirection to buffer. If *Buffer is
2247 non-null on input, then the buffer is caller
2248 allocated. If Buffer is NULL, then the buffer
2249 is callee allocated. In either case, the
2250 requried buffer size is returned in *BufferSize.
2251 @param BufferSize On input, indicates the size of *Buffer if
2252 *Buffer is non-null on input. On output,
2253 indicates the required size (allocated size if
2254 callee allocated) of *Buffer.
2255 @param AuthenticationStatus A pointer to a caller-allocated UINT32 that
2256 indicates the authentication status of the
2257 output buffer. If the input section's
2258 GuidedSectionHeader.Attributes field
2259 has the EFI_GUIDED_SECTION_AUTH_STATUS_VALID
2260 bit as clear, AuthenticationStatus must return
2261 zero. Both local bits (19:16) and aggregate
2262 bits (3:0) in AuthenticationStatus are returned
2263 by ExtractSection(). These bits reflect the
2264 status of the extraction operation. The bit
2265 pattern in both regions must be the same, as
2266 the local and aggregate authentication statuses
2267 have equivalent meaning at this level. If the
2268 function returns anything other than
2269 EFI_SUCCESS, the value of *AuthenticationStatus
2271 @param IsFfs3Fv Indicates the FV format.
2273 @retval EFI_SUCCESS Section was retrieved successfully
2274 @retval EFI_PROTOCOL_ERROR A GUID defined section was encountered in the
2275 section stream with its
2276 EFI_GUIDED_SECTION_PROCESSING_REQUIRED bit set,
2277 but there was no corresponding GUIDed Section
2278 Extraction Protocol in the handle database.
2279 *Buffer is unmodified.
2280 @retval EFI_NOT_FOUND An error was encountered when parsing the
2281 SectionStream. This indicates the SectionStream
2282 is not correctly formatted.
2283 @retval EFI_NOT_FOUND The requested section does not exist.
2284 @retval EFI_OUT_OF_RESOURCES The system has insufficient resources to process
2286 @retval EFI_INVALID_PARAMETER The SectionStreamHandle does not exist.
2287 @retval EFI_WARN_TOO_SMALL The size of the caller allocated input buffer is
2288 insufficient to contain the requested section.
2289 The input buffer is filled and section contents
2296 IN UINTN SectionStreamHandle
,
2297 IN EFI_SECTION_TYPE
*SectionType
,
2298 IN EFI_GUID
*SectionDefinitionGuid
,
2299 IN UINTN SectionInstance
,
2301 IN OUT UINTN
*BufferSize
,
2302 OUT UINT32
*AuthenticationStatus
,
2308 SEP member function. Deletes an existing section stream
2310 @param StreamHandleToClose Indicates the stream to close
2312 @retval EFI_SUCCESS The section stream is closed sucessfully.
2313 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
2314 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end
2320 CloseSectionStream (
2321 IN UINTN StreamHandleToClose
2325 Creates and initializes the DebugImageInfo Table. Also creates the configuration
2326 table and registers it into the system table.
2329 This function allocates memory, frees it, and then allocates memory at an
2330 address within the initial allocation. Since this function is called early
2331 in DXE core initialization (before drivers are dispatched), this should not
2336 CoreInitializeDebugImageInfoTable (
2342 Update the CRC32 in the Debug Table.
2343 Since the CRC32 service is made available by the Runtime driver, we have to
2344 wait for the Runtime Driver to be installed before the CRC32 can be computed.
2345 This function is called elsewhere by the core when the runtime architectural
2346 protocol is produced.
2350 CoreUpdateDebugTableCrc32 (
2356 Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
2357 the table if it's not large enough to accomidate another entry.
2359 @param ImageInfoType type of debug image information
2360 @param LoadedImage pointer to the loaded image protocol for the image being
2362 @param ImageHandle image handle for the image being loaded
2366 CoreNewDebugImageInfoEntry (
2367 IN UINT32 ImageInfoType
,
2368 IN EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
,
2369 IN EFI_HANDLE ImageHandle
2374 Removes and frees an entry from the DebugImageInfo Table.
2376 @param ImageHandle image handle for the image being unloaded
2380 CoreRemoveDebugImageInfoEntry (
2381 EFI_HANDLE ImageHandle
2386 This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
2388 @param ImageHandle The image handle.
2389 @param SystemTable The system table.
2391 @retval EFI_SUCCESS Successfully initialized firmware volume block
2397 FwVolBlockDriverInit (
2398 IN EFI_HANDLE ImageHandle
,
2399 IN EFI_SYSTEM_TABLE
*SystemTable
2404 This routine produces a firmware volume block protocol on a given
2407 @param BaseAddress base address of the firmware volume image
2408 @param Length length of the firmware volume image
2409 @param ParentHandle handle of parent firmware volume, if this image
2410 came from an FV image file in another firmware
2411 volume (ala capsules)
2412 @param FvProtocol Firmware volume block protocol produced.
2414 @retval EFI_VOLUME_CORRUPTED Volume corrupted.
2415 @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
2416 @retval EFI_SUCCESS Successfully produced a FVB protocol on given
2421 ProduceFVBProtocolOnBuffer (
2422 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2424 IN EFI_HANDLE ParentHandle
,
2425 OUT EFI_HANDLE
*FvProtocol OPTIONAL
2430 Raising to the task priority level of the mutual exclusion
2431 lock, and then acquires ownership of the lock.
2433 @param Lock The lock to acquire
2445 Initialize a basic mutual exclusion lock. Each lock
2446 provides mutual exclusion access at it's task priority
2447 level. Since there is no-premption (at any TPL) or
2448 multiprocessor support, acquiring the lock only consists
2449 of raising to the locks TPL.
2451 @param Lock The EFI_LOCK structure to initialize
2453 @retval EFI_SUCCESS Lock Owned.
2454 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
2458 CoreAcquireLockOrFail (
2464 Releases ownership of the mutual exclusion lock, and
2465 restores the previous task priority level.
2467 @param Lock The lock to release
2469 @return Lock unowned
2479 An empty function to pass error checking of CreateEventEx ().
2481 @param Event Event whose notification function is being invoked.
2482 @param Context Pointer to the notification function's context,
2483 which is implementation-dependent.
2488 CoreEmptyCallbackFunction (
2494 Read data from Firmware Block by FVB protocol Read.
2495 The data may cross the multi block ranges.
2497 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to read data.
2498 @param StartLba Pointer to StartLba.
2499 On input, the start logical block index from which to read.
2500 On output,the end logical block index after reading.
2501 @param Offset Pointer to Offset
2502 On input, offset into the block at which to begin reading.
2503 On output, offset into the end block after reading.
2504 @param DataSize Size of data to be read.
2505 @param Data Pointer to Buffer that the data will be read into.
2507 @retval EFI_SUCCESS Successfully read data from firmware block.
2512 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2513 IN OUT EFI_LBA
*StartLba
,
2514 IN OUT UINTN
*Offset
,
2520 Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
2521 copy the real length volume header into it.
2523 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
2524 read the volume header
2525 @param FwVolHeader Pointer to pointer to allocated buffer in which
2526 the volume header is returned.
2528 @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
2529 @retval EFI_SUCCESS Successfully read volume header to the allocated
2535 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
2536 OUT EFI_FIRMWARE_VOLUME_HEADER
**FwVolHeader
2540 Verify checksum of the firmware volume header.
2542 @param FvHeader Points to the firmware volume header to be checked
2544 @retval TRUE Checksum verification passed
2545 @retval FALSE Checksum verification failed
2549 VerifyFvHeaderChecksum (
2550 IN EFI_FIRMWARE_VOLUME_HEADER
*FvHeader