3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
26 #include "DebugImageInfo.h"
28 #include "FwVolBlock.h"
29 #include "FwVolDriver.h"
37 /// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependecy expression
38 /// to save time. A EFI_DEP_PUSH is evauated one an
39 /// replaced with EFI_DEP_REPLACE_TRUE
41 #define EFI_DEP_REPLACE_TRUE 0xff
44 /// Define the initial size of the dependency expression evaluation stack
46 #define DEPEX_STACK_SIZE_INCREMENT 0x1000
49 EFI_GUID
*ProtocolGuid
;
54 } ARCHITECTURAL_PROTOCOL_ENTRY
;
58 // DXE Dispatcher Data structures
61 #define KNOWN_HANDLE_SIGNATURE EFI_SIGNATURE_32('k','n','o','w')
64 LIST_ENTRY Link
; // mFvHandleList
69 #define EFI_CORE_DRIVER_ENTRY_SIGNATURE EFI_SIGNATURE_32('d','r','v','r')
72 LIST_ENTRY Link
; // mDriverList
74 LIST_ENTRY ScheduledLink
; // mScheduledQueue
78 EFI_DEVICE_PATH_PROTOCOL
*FvFileDevicePath
;
79 EFI_FIRMWARE_VOLUME_PROTOCOL
*Fv
;
86 EFI_GUID BeforeAfterGuid
;
93 BOOLEAN DepexProtocolError
;
95 EFI_HANDLE ImageHandle
;
97 } EFI_CORE_DRIVER_ENTRY
;
100 //The data structure of GCD memory map entry
102 #define EFI_GCD_MAP_SIGNATURE EFI_SIGNATURE_32('g','c','d','m')
106 EFI_PHYSICAL_ADDRESS BaseAddress
;
110 EFI_GCD_MEMORY_TYPE GcdMemoryType
;
111 EFI_GCD_IO_TYPE GcdIoType
;
112 EFI_HANDLE ImageHandle
;
113 EFI_HANDLE DeviceHandle
;
117 // DXE Core Global Variables
119 extern EFI_SYSTEM_TABLE
*gST
;
120 extern EFI_BOOT_SERVICES
*gBS
;
121 extern EFI_RUNTIME_SERVICES
*gRT
;
122 extern EFI_DXE_SERVICES
*gDS
;
123 extern EFI_HANDLE gDxeCoreImageHandle
;
125 extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress
;
126 extern EFI_PEI_PE_COFF_LOADER_PROTOCOL
*gEfiPeiPeCoffLoader
;
128 extern EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
;
129 extern EFI_CPU_ARCH_PROTOCOL
*gCpu
;
130 extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL
*gWatchdogTimer
;
131 extern EFI_METRONOME_ARCH_PROTOCOL
*gMetronome
;
132 extern EFI_TIMER_ARCH_PROTOCOL
*gTimer
;
133 extern EFI_SECURITY_ARCH_PROTOCOL
*gSecurity
;
134 extern EFI_BDS_ARCH_PROTOCOL
*gBds
;
135 extern EFI_STATUS_CODE_PROTOCOL
*gStatusCode
;
137 extern EFI_TPL gEfiCurrentTpl
;
139 extern EFI_GUID
*gDxeCoreFileName
;
140 extern EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
142 extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation
[EfiMaxMemoryType
+ 1];
144 extern BOOLEAN gDispatcherRunning
;
145 extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
;
148 // Service Initialization Functions
160 Called to initialize the pool.
174 CoreAddMemoryDescriptor (
175 IN EFI_MEMORY_TYPE Type
,
176 IN EFI_PHYSICAL_ADDRESS Start
,
177 IN UINT64 NumberOfPages
,
184 Called to initialize the memory map and add descriptors to
185 the current descriptor list.
187 The first descriptor that is added must be general usable
188 memory as the addition allocates heap.
192 Type - The type of memory to add
194 Start - The starting address in the memory range
197 NumberOfPages - The number of pages in the range
199 Attribute - Attributes of the memory to add
203 None. The range is added to the memory map
209 CoreReleaseGcdMemoryLock (
215 Release memory lock on mGcdMemorySpaceLock
227 CoreAcquireGcdMemoryLock (
233 Acquire memory lock on mGcdMemorySpaceLock
245 CoreInitializeMemoryServices (
247 IN EFI_PHYSICAL_ADDRESS
*MemoryBaseAddress
,
248 IN UINT64
*MemoryLength
254 External function. Initializes the GCD and memory services based on the memory
255 descriptor HOBs. This function is responsible for priming the GCD map and the
256 memory map, so memory allocations and resource allocations can be made. The first
257 part of this function can not depend on any memory services until at least one
258 memory descriptor is provided to the memory services. Then the memory services
259 can be used to intialize the GCD map.
263 HobStart - The start address of the HOB.
265 MemoryBaseAddress - Start address of memory region found to init DXE core.
267 MemoryLength - Length of memory region found to init DXE core.
271 EFI_SUCCESS - Memory services successfully initialized.
278 CoreInitializeGcdServices (
280 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress
,
281 IN UINT64 MemoryLength
287 External function. Initializes the GCD and memory services based on the memory
288 descriptor HOBs. This function is responsible for priming the GCD map and the
289 memory map, so memory allocations and resource allocations can be made. The first
290 part of this function can not depend on any memory services until at least one
291 memory descriptor is provided to the memory services. Then the memory services
292 can be used to intialize the GCD map.
296 HobStart - The start address of the HOB
298 MemoryBaseAddress - Start address of memory region found to init DXE core.
300 MemoryLength - Length of memory region found to init DXE core.
305 EFI_SUCCESS - GCD services successfully initialized.
311 CoreInitializeEventServices (
318 Initializes "event" support and populates parts of the System and Runtime Table.
326 EFI_SUCCESS - Always return success
332 CoreInitializeImageServices (
339 Add the Image Services to EFI Boot Services Table and install the protocol
340 interfaces for this image.
344 HobStart - The HOB to initialize
354 CoreNotifyOnArchProtocolInstallation (
360 Creates an event that is fired everytime a Protocol of a specific type is installed
372 CoreAllEfiServicesAvailable (
378 Return TRUE if all AP services are availible.
384 EFI_SUCCESS - All AP services are available
385 EFI_NOT_FOUND - At least one AP service is not available
392 IN OUT EFI_TABLE_HEADER
*Hdr
398 Calcualte the 32-bit CRC in a EFI table using the service provided by the
403 Hdr - Pointer to an EFI standard header
421 Called by the platform code to process a tick.
425 Duration - The number of 100ns elasped since the last call to TimerTick
435 CoreInitializeDispatcher (
442 Initialize the dispatcher. Initialize the notification function that runs when
443 a FV protocol is added to the system.
458 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
464 This is the POSTFIX version of the dependency evaluator. This code does
465 not need to handle Before or After, as it is not valid to call this
466 routine in this case. The SOR is just ignored and is a nop in the grammer.
468 POSTFIX means all the math is done on top of the stack.
472 DriverEntry - DriverEntry element to update
476 TRUE - If driver is ready to run.
478 FALSE - If driver is not ready to run or some fatal error was found.
484 CorePreProcessDepex (
485 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
491 Preprocess dependency expression and update DriverEntry to reflect the
492 state of Before, After, and SOR dependencies. If DriverEntry->Before
493 or DriverEntry->After is set it will never be cleared. If SOR is set
494 it will be cleared by CoreSchedule(), and then the driver can be
499 DriverEntry - DriverEntry element to update
503 EFI_SUCCESS - It always works.
511 CoreExitBootServices (
512 IN EFI_HANDLE ImageHandle
,
519 EFI 1.0 API to terminate Boot Services
523 ImageHandle - Handle that represents the identity of the calling image
525 MapKey -Key to the latest memory map.
529 EFI_SUCCESS - Boot Services terminated
530 EFI_INVALID_PARAMETER - MapKey is incorrect.
536 CoreTerminateMemoryMap (
543 Make sure the memory map is following all the construction rules,
544 it is the last time to check memory map error before exit boot services.
548 MapKey - Memory map key
552 EFI_INVALID_PARAMETER - Memory map not consistent with construction rules.
554 EFI_SUCCESS - Valid memory map.
560 CoreNotifySignalList (
561 IN EFI_GUID
*EventGroup
567 Signals all events on the requested list
571 SignalType - The list to signal
583 CoreInstallConfigurationTable (
591 Boot Service called to add, modify, or remove a system configuration table from
592 the EFI System Table.
596 Guid: Pointer to the GUID for the entry to add, update, or remove
597 Table: Pointer to the configuration table for the entry to add, update, or
602 EFI_SUCCESS Guid, Table pair added, updated, or removed.
603 EFI_INVALID_PARAMETER Input GUID not valid.
604 EFI_NOT_FOUND Attempted to delete non-existant entry
605 EFI_OUT_OF_RESOURCES Not enough memory available
620 Raise the task priority level to the new level.
621 High level is implemented by disabling processor interrupts.
625 NewTpl - New task priority level
629 The previous task priority level
644 Lowers the task priority to the previous value. If the new
645 priority unmasks events at a higher priority, they are dispatched.
649 NewTpl - New, lower, task priority
662 IN UINTN Microseconds
668 Introduces a fine-grained stall.
672 Microseconds The number of microseconds to stall execution
676 EFI_SUCCESS - Execution was stalled for at least the requested amount
679 EFI_NOT_AVAILABLE_YET - gMetronome is not available yet
687 CoreSetWatchdogTimer (
689 IN UINT64 WatchdogCode
,
691 IN CHAR16
*WatchdogData OPTIONAL
697 Sets the system's watchdog timer.
701 Timeout The number of seconds. Zero disables the timer.
703 ///////following three parameters are left for platform specific using
705 WatchdogCode The numberic code to log. 0x0 to 0xffff are firmware
706 DataSize Size of the optional data
707 WatchdogData Optional Null terminated unicode string followed by binary
712 EFI_SUCCESS Timeout has been set
713 EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
714 EFI_UNSUPPORTED System does not have a timer (currently not used)
715 EFI_DEVICE_ERROR Could not complete due to hardware error
723 CoreInstallProtocolInterface (
724 IN OUT EFI_HANDLE
*UserHandle
,
725 IN EFI_GUID
*Protocol
,
726 IN EFI_INTERFACE_TYPE InterfaceType
,
733 Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
734 Calls the private one which contains a BOOLEAN parameter for notifications
738 UserHandle - The handle to install the protocol handler on,
739 or NULL if a new handle is to be allocated
741 Protocol - The protocol to add to the handle
743 InterfaceType - Indicates whether Interface is supplied in native form.
745 Interface - The interface for the protocol being added
755 CoreInstallProtocolInterfaceNotify (
756 IN OUT EFI_HANDLE
*UserHandle
,
757 IN EFI_GUID
*Protocol
,
758 IN EFI_INTERFACE_TYPE InterfaceType
,
766 Installs a protocol interface into the boot services environment.
770 UserHandle - The handle to install the protocol handler on,
771 or NULL if a new handle is to be allocated
773 Protocol - The protocol to add to the handle
775 InterfaceType - Indicates whether Interface is supplied in native form.
777 Interface - The interface for the protocol being added
779 Notify - Whether to notify the notification list for this protocol
783 EFI_INVALID_PARAMETER - Invalid parameter
785 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
787 EFI_SUCCESS - Protocol interface successfully installed
795 CoreInstallMultipleProtocolInterfaces (
796 IN OUT EFI_HANDLE
*Handle
,
803 Installs a list of protocol interface into the boot services environment.
804 This function calls InstallProtocolInterface() in a loop. If any error
805 occures all the protocols added by this function are removed. This is
806 basically a lib function to save space.
810 Handle - The handle to install the protocol handlers on,
811 or NULL if a new handle is to be allocated
812 ... - EFI_GUID followed by protocol instance. A NULL terminates the
813 list. The pairs are the arguments to InstallProtocolInterface().
814 All the protocols are added to Handle.
818 EFI_INVALID_PARAMETER - Handle is NULL.
820 EFI_SUCCESS - Protocol interfaces successfully installed.
828 CoreUninstallMultipleProtocolInterfaces (
829 IN EFI_HANDLE Handle
,
836 Uninstalls a list of protocol interface in the boot services environment.
837 This function calls UnisatllProtocolInterface() in a loop. This is
838 basically a lib function to save space.
842 Handle - The handle to uninstall the protocol
844 ... - EFI_GUID followed by protocol instance. A NULL terminates the
845 list. The pairs are the arguments to UninstallProtocolInterface().
846 All the protocols are added to Handle.
858 CoreReinstallProtocolInterface (
859 IN EFI_HANDLE UserHandle
,
860 IN EFI_GUID
*Protocol
,
861 IN VOID
*OldInterface
,
862 IN VOID
*NewInterface
868 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
872 UserHandle - Handle on which the interface is to be reinstalled
873 Protocol - The numeric ID of the interface
874 OldInterface - A pointer to the old interface
875 NewInterface - A pointer to the new interface
882 On EFI_SUCCESS The protocol interface was installed
883 On EFI_NOT_FOUND The OldInterface on the handle was not found
884 On EFI_INVALID_PARAMETER One of the parameters has an invalid value
892 CoreUninstallProtocolInterface (
893 IN EFI_HANDLE UserHandle
,
894 IN EFI_GUID
*Protocol
,
901 Uninstalls all instances of a protocol:interfacer from a handle.
902 If the last protocol interface is remove from the handle, the
907 UserHandle - The handle to remove the protocol handler from
909 Protocol - The protocol, of protocol:interface, to remove
911 Interface - The interface, of protocol:interface, to remove
915 EFI_INVALID_PARAMETER - Protocol is NULL.
917 EFI_SUCCESS - Protocol interface successfully uninstalled.
926 IN EFI_HANDLE UserHandle
,
927 IN EFI_GUID
*Protocol
,
934 Queries a handle to determine if it supports a specified protocol.
938 UserHandle - The handle being queried.
940 Protocol - The published unique identifier of the protocol.
942 Interface - Supplies the address where a pointer to the corresponding Protocol
943 Interface is returned.
947 The requested protocol interface for the handle
956 IN EFI_HANDLE UserHandle
,
957 IN EFI_GUID
*Protocol
,
958 OUT VOID
**Interface OPTIONAL
,
959 IN EFI_HANDLE ImageHandle
,
960 IN EFI_HANDLE ControllerHandle
,
967 Locates the installed protocol handler for the handle, and
968 invokes it to obtain the protocol interface. Usage information
969 is registered in the protocol data base.
973 UserHandle - The handle to obtain the protocol interface on
975 Protocol - The ID of the protocol
977 Interface - The location to return the protocol interface
979 ImageHandle - The handle of the Image that is opening the protocol interface
980 specified by Protocol and Interface.
982 ControllerHandle - The controller handle that is requiring this interface.
984 Attributes - The open mode of the protocol interface specified by Handle
989 EFI_INVALID_PARAMETER - Protocol is NULL.
991 EFI_SUCCESS - Get the protocol interface.
999 CoreOpenProtocolInformation (
1000 IN EFI_HANDLE UserHandle
,
1001 IN EFI_GUID
*Protocol
,
1002 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
**EntryBuffer
,
1003 OUT UINTN
*EntryCount
1007 Routine Description:
1009 Return information about Opened protocols in the system
1013 UserHandle - The handle to close the protocol interface on
1015 Protocol - The ID of the protocol
1017 EntryBuffer - A pointer to a buffer of open protocol information in the form of
1018 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
1020 EntryCount - Number of EntryBuffer entries
1032 IN EFI_HANDLE UserHandle
,
1033 IN EFI_GUID
*Protocol
,
1034 IN EFI_HANDLE ImageHandle
,
1035 IN EFI_HANDLE ControllerHandle
1039 Routine Description:
1045 UserHandle - The handle to close the protocol interface on
1047 Protocol - The ID of the protocol
1049 ImageHandle - The user of the protocol to close
1051 ControllerHandle - The user of the protocol to close
1055 EFI_INVALID_PARAMETER - Protocol is NULL.
1063 CoreProtocolsPerHandle (
1064 IN EFI_HANDLE UserHandle
,
1065 OUT EFI_GUID
***ProtocolBuffer
,
1066 OUT UINTN
*ProtocolBufferCount
1070 Routine Description:
1072 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
1077 UserHandle - The handle from which to retrieve the list of protocol interface
1080 ProtocolBuffer - A pointer to the list of protocol interface GUID pointers that are
1081 installed on Handle.
1083 ProtocolBufferCount - A pointer to the number of GUID pointers present in
1087 EFI_SUCCESS - The list of protocol interface GUIDs installed on Handle was returned in
1088 ProtocolBuffer. The number of protocol interface GUIDs was
1089 returned in ProtocolBufferCount.
1090 EFI_INVALID_PARAMETER - Handle is NULL.
1091 EFI_INVALID_PARAMETER - Handle is not a valid EFI_HANDLE.
1092 EFI_INVALID_PARAMETER - ProtocolBuffer is NULL.
1093 EFI_INVALID_PARAMETER - ProtocolBufferCount is NULL.
1094 EFI_OUT_OF_RESOURCES - There is not enough pool memory to store the results.
1102 CoreRegisterProtocolNotify (
1103 IN EFI_GUID
*Protocol
,
1105 OUT VOID
**Registration
1109 Routine Description:
1111 Add a new protocol notification record for the request protocol.
1115 Protocol - The requested protocol to add the notify registration
1117 Event - The event to signal
1119 Registration - Returns the registration record
1124 EFI_INVALID_PARAMETER - Invalid parameter
1126 EFI_SUCCESS - Successfully returned the registration record that has been added
1135 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1136 IN EFI_GUID
*Protocol OPTIONAL
,
1137 IN VOID
*SearchKey OPTIONAL
,
1138 IN OUT UINTN
*BufferSize
,
1139 OUT EFI_HANDLE
*Buffer
1143 Routine Description:
1145 Locates the requested handle(s) and returns them in Buffer.
1149 SearchType - The type of search to perform to locate the handles
1151 Protocol - The protocol to search for
1153 SearchKey - Dependant on SearchType
1155 BufferSize - On input the size of Buffer. On output the
1156 size of data returned.
1158 Buffer - The buffer to return the results in
1163 EFI_BUFFER_TOO_SMALL - Buffer too small, required buffer size is returned in BufferSize.
1165 EFI_INVALID_PARAMETER - Invalid parameter
1167 EFI_SUCCESS - Successfully found the requested handle(s) and returns them in Buffer.
1175 CoreLocateDevicePath (
1176 IN EFI_GUID
*Protocol
,
1177 IN OUT EFI_DEVICE_PATH_PROTOCOL
**FilePath
,
1178 OUT EFI_HANDLE
*Device
1182 Routine Description:
1184 Locates the handle to a device on the device path that supports the specified protocol.
1188 Protocol - The protocol to search for.
1189 FilePath - On input, a pointer to a pointer to the device path. On output, the device
1190 path pointer is modified to point to the remaining part of the devicepath.
1191 Device - A pointer to the returned device handle.
1195 EFI_SUCCESS - The resulting handle was returned.
1196 EFI_NOT_FOUND - No handles matched the search.
1197 EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
1205 CoreLocateHandleBuffer (
1206 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1207 IN EFI_GUID
*Protocol OPTIONAL
,
1208 IN VOID
*SearchKey OPTIONAL
,
1209 IN OUT UINTN
*NumberHandles
,
1210 OUT EFI_HANDLE
**Buffer
1214 Routine Description:
1216 Function returns an array of handles that support the requested protocol
1217 in a buffer allocated from pool. This is a version of CoreLocateHandle()
1218 that allocates a buffer for the caller.
1222 SearchType - Specifies which handle(s) are to be returned.
1223 Protocol - Provides the protocol to search by.
1224 This parameter is only valid for SearchType ByProtocol.
1225 SearchKey - Supplies the search key depending on the SearchType.
1226 NumberHandles - The number of handles returned in Buffer.
1227 Buffer - A pointer to the buffer to return the requested array of
1228 handles that support Protocol.
1232 EFI_SUCCESS - The result array of handles was returned.
1233 EFI_NOT_FOUND - No handles match the search.
1234 EFI_OUT_OF_RESOURCES - There is not enough pool memory to store the matching results.
1235 EFI_INVALID_PARAMETER - Invalid parameter
1243 CoreLocateProtocol (
1244 IN EFI_GUID
*Protocol
,
1245 IN VOID
*Registration OPTIONAL
,
1246 OUT VOID
**Interface
1250 Routine Description:
1252 Return the first Protocol Interface that matches the Protocol GUID. If
1253 Registration is pasased in return a Protocol Instance that was just add
1254 to the system. If Retistration is NULL return the first Protocol Interface
1259 Protocol - The protocol to search for
1261 Registration - Optional Registration Key returned from RegisterProtocolNotify()
1263 Interface - Return the Protocol interface (instance).
1267 EFI_SUCCESS - If a valid Interface is returned
1269 EFI_INVALID_PARAMETER - Invalid parameter
1271 EFI_NOT_FOUND - Protocol interface not found
1277 CoreGetHandleDatabaseKey (
1282 Routine Description:
1284 return handle database key.
1292 Handle database key.
1298 CoreConnectHandlesByKey (
1303 Routine Description:
1305 Go connect any handles that were created or modified while a image executed.
1309 Key - The Key to show that the handle has been created/modified
1320 CoreConnectController (
1321 IN EFI_HANDLE ControllerHandle
,
1322 IN EFI_HANDLE
*DriverImageHandle OPTIONAL
,
1323 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
1324 IN BOOLEAN Recursive
1328 Routine Description:
1330 Connects one or more drivers to a controller.
1334 ControllerHandle - Handle of the controller to be connected.
1336 DriverImageHandle - DriverImageHandle A pointer to an ordered list of driver image handles.
1338 RemainingDevicePath - RemainingDevicePath A pointer to the device path that specifies a child of the
1339 controller specified by ControllerHandle.
1341 Recursive - - Whether the function would be called recursively or not.
1353 CoreDisconnectController (
1354 IN EFI_HANDLE ControllerHandle
,
1355 IN EFI_HANDLE DriverImageHandle OPTIONAL
,
1356 IN EFI_HANDLE ChildHandle OPTIONAL
1360 Routine Description:
1362 Disonnects a controller from a driver
1366 ControllerHandle - ControllerHandle The handle of the controller from which driver(s)
1367 are to be disconnected.
1368 DriverImageHandle - DriverImageHandle The driver to disconnect from ControllerHandle.
1369 ChildHandle - ChildHandle The handle of the child to destroy.
1373 EFI_SUCCESS - One or more drivers were disconnected from the controller.
1374 EFI_SUCCESS - On entry, no drivers are managing ControllerHandle.
1375 EFI_SUCCESS - DriverImageHandle is not NULL, and on entry DriverImageHandle is not managing ControllerHandle.
1376 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
1377 EFI_INVALID_PARAMETER - DriverImageHandle is not NULL, and it is not a valid EFI_HANDLE.
1378 EFI_INVALID_PARAMETER - ChildHandle is not NULL, and it is not a valid EFI_HANDLE.
1379 EFI_OUT_OF_RESOURCES - There are not enough resources available to disconnect any drivers from ControllerHandle.
1380 EFI_DEVICE_ERROR - The controller could not be disconnected because of a device error.
1389 IN EFI_ALLOCATE_TYPE Type
,
1390 IN EFI_MEMORY_TYPE MemoryType
,
1391 IN UINTN NumberOfPages
,
1392 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
1396 Routine Description:
1398 Allocates pages from the memory map.
1402 Type - The type of allocation to perform
1404 MemoryType - The type of memory to turn the allocated pages into
1406 NumberOfPages - The number of pages to allocate
1408 Memory - A pointer to receive the base allocated memory address
1412 Status. On success, Memory is filled in with the base address allocated
1414 EFI_INVALID_PARAMETER - Parameters violate checking rules defined in spec.
1416 EFI_NOT_FOUND - Could not allocate pages match the requirement.
1418 EFI_OUT_OF_RESOURCES - No enough pages to allocate.
1420 EFI_SUCCESS - Pages successfully allocated.
1429 IN EFI_PHYSICAL_ADDRESS Memory
,
1430 IN UINTN NumberOfPages
1434 Routine Description:
1436 Frees previous allocated pages.
1440 Memory - Base address of memory being freed
1442 NumberOfPages - The number of pages to free
1446 EFI_NOT_FOUND - Could not find the entry that covers the range
1448 EFI_INVALID_PARAMETER - Address not aligned
1450 EFI_SUCCESS -Pages successfully freed.
1459 IN OUT UINTN
*MemoryMapSize
,
1460 IN OUT EFI_MEMORY_DESCRIPTOR
*Desc
,
1462 OUT UINTN
*DescriptorSize
,
1463 OUT UINT32
*DescriptorVersion
1467 Routine Description:
1469 Returns the current memory map.
1473 MemoryMapSize - On input the buffer size of MemoryMap allocated by caller
1474 On output the required buffer size to contain the memory map
1476 Desc - The buffer to return the current memory map
1478 MapKey - The address to return the current map key
1480 DescriptorSize - The size in bytes for an individual EFI_MEMORY_DESCRIPTOR
1482 DescriptorVersion - The version number associated with the EFI_MEMORY_DESCRIPTOR
1486 EFI_SUCCESS The current memory map was returned successfully
1488 EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small
1490 EFI_INVALID_PARAMETER One of the parameters has an invalid value
1499 IN EFI_MEMORY_TYPE PoolType
,
1505 Routine Description:
1507 Allocate pool of a particular type.
1511 PoolType - Type of pool to allocate
1513 Size - The amount of pool to allocate
1515 Buffer - The address to return a pointer to the allocated pool
1519 EFI_INVALID_PARAMETER - PoolType not valid
1521 EFI_OUT_OF_RESOURCES - Size exceeds max pool size or allocation failed.
1523 EFI_SUCCESS - Pool successfully allocated.
1536 Routine Description:
1542 Buffer - The allocated pool entry to free
1546 EFI_INVALID_PARAMETER - Buffer is not a valid value.
1548 EFI_SUCCESS - Pool successfully freed.
1557 IN BOOLEAN BootPolicy
,
1558 IN EFI_HANDLE ParentImageHandle
,
1559 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
1560 IN VOID
*SourceBuffer OPTIONAL
,
1561 IN UINTN SourceSize
,
1562 OUT EFI_HANDLE
*ImageHandle
1566 Routine Description:
1568 Loads an EFI image into memory and returns a handle to the image.
1572 BootPolicy - If TRUE, indicates that the request originates from the boot manager,
1573 and that the boot manager is attempting to load FilePath as a boot selection.
1574 ParentImageHandle - The caller's image handle.
1575 FilePath - The specific file path from which the image is loaded.
1576 SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
1577 the image to be loaded.
1578 SourceSize - The size in bytes of SourceBuffer.
1579 ImageHandle - Pointer to the returned image handle that is created when the image
1580 is successfully loaded.
1584 EFI_SUCCESS - The image was loaded into memory.
1585 EFI_NOT_FOUND - The FilePath was not found.
1586 EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
1587 EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
1588 parsed to locate the proper protocol for loading the file.
1589 EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
1597 IN EFI_HANDLE ImageHandle
1601 Routine Description:
1603 Unload the specified image.
1607 ImageHandle - The specified image handle.
1611 EFI_INVALID_PARAMETER - Image handle is NULL.
1613 EFI_UNSUPPORTED - Attempt to unload an unsupported image.
1615 EFI_SUCCESS - Image successfully unloaded.
1624 IN EFI_HANDLE ImageHandle
,
1625 OUT UINTN
*ExitDataSize
,
1626 OUT CHAR16
**ExitData OPTIONAL
1630 Routine Description:
1632 Transfer control to a loaded image's entry point.
1636 ImageHandle - Handle of image to be started.
1638 ExitDataSize - Pointer of the size to ExitData
1640 ExitData - Pointer to a pointer to a data buffer that includes a Null-terminated
1641 Unicode string, optionally followed by additional binary data. The string
1642 is a description that the caller may use to further indicate the reason for
1647 EFI_INVALID_PARAMETER - Invalid parameter
1649 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
1651 EFI_SUCCESS - Successfully transfer control to the image's entry point.
1660 IN EFI_HANDLE ImageHandle
,
1661 IN EFI_STATUS Status
,
1662 IN UINTN ExitDataSize
,
1663 IN CHAR16
*ExitData OPTIONAL
1667 Routine Description:
1669 Terminates the currently loaded EFI image and returns control to boot services.
1673 ImageHandle - Handle that identifies the image. This parameter is passed to the image
1675 Status - The image's exit code.
1676 ExitDataSize - The size, in bytes, of ExitData. Ignored if ExitStatus is
1678 ExitData - Pointer to a data buffer that includes a Null-terminated Unicode string,
1679 optionally followed by additional binary data. The string is a
1680 description that the caller may use to further indicate the reason for
1685 EFI_INVALID_PARAMETER - Image handle is NULL or it is not current image.
1687 EFI_SUCCESS - Successfully terminates the currently loaded EFI image.
1689 EFI_ACCESS_DENIED - Should never reach there.
1699 IN EFI_TPL NotifyTpl
,
1700 IN EFI_EVENT_NOTIFY NotifyFunction
,
1701 IN VOID
*NotifyContext
,
1702 OUT EFI_EVENT
*pEvent
1706 Routine Description:
1708 Creates a general-purpose event structure
1712 Type - The type of event to create and its mode and attributes
1713 NotifyTpl - The task priority level of event notifications
1714 NotifyFunction - Pointer to the event's notification function
1715 NotifyContext - Pointer to the notification function's context; corresponds to
1716 parameter "Context" in the notification function
1717 pEvent - Pointer to the newly created event if the call succeeds; undefined otherwise
1721 EFI_SUCCESS - The event structure was created
1722 EFI_INVALID_PARAMETER - One of the parameters has an invalid value
1723 EFI_OUT_OF_RESOURCES - The event could not be allocated
1733 IN EFI_TPL NotifyTpl
,
1734 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1735 IN CONST VOID
*NotifyContext
, OPTIONAL
1736 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1737 OUT EFI_EVENT
*Event
1741 Routine Description:
1742 Creates a general-purpose event structure
1745 Type - The type of event to create and its mode and attributes
1746 NotifyTpl - The task priority level of event notifications
1747 NotifyFunction - Pointer to the events notification function
1748 NotifyContext - Pointer to the notification functions context; corresponds to
1749 parameter "Context" in the notification function
1750 EventGrout - GUID for EventGroup if NULL act the same as gBS->CreateEvent().
1751 Event - Pointer to the newly created event if the call succeeds; undefined otherwise
1754 EFI_SUCCESS - The event structure was created
1755 EFI_INVALID_PARAMETER - One of the parameters has an invalid value
1756 EFI_OUT_OF_RESOURCES - The event could not be allocated
1766 IN EFI_TIMER_DELAY Type
,
1767 IN UINT64 TriggerTime
1771 Routine Description:
1773 Sets the type of timer and the trigger time for a timer event.
1777 UserEvent - The timer event that is to be signaled at the specified time
1778 Type - The type of time that is specified in TriggerTime
1779 TriggerTime - The number of 100ns units until the timer expires
1783 EFI_SUCCESS - The event has been set to be signaled at the requested time
1784 EFI_INVALID_PARAMETER - Event or Type is not valid
1797 Routine Description:
1799 Signals the event. Queues the event to be notified if needed
1803 Event - The event to signal
1807 EFI_INVALID_PARAMETER - Parameters are not valid.
1809 EFI_SUCCESS - The event was signaled.
1818 IN UINTN NumberOfEvents
,
1819 IN EFI_EVENT
*UserEvents
,
1820 OUT UINTN
*UserIndex
1824 Routine Description:
1826 Stops execution until an event is signaled.
1830 NumberOfEvents - The number of events in the UserEvents array
1831 UserEvents - An array of EFI_EVENT
1832 UserIndex - Pointer to the index of the event which satisfied the wait condition
1836 EFI_SUCCESS - The event indicated by Index was signaled.
1837 EFI_INVALID_PARAMETER - The event indicated by Index has a notification function or
1838 Event was not a valid type
1839 EFI_UNSUPPORTED - The current TPL is not TPL_APPLICATION
1852 Routine Description:
1854 Closes an event and frees the event structure.
1858 UserEvent - Event to close
1862 EFI_INVALID_PARAMETER - Parameters are not valid.
1864 EFI_SUCCESS - The event has been closed
1877 Routine Description:
1879 Check the status of an event
1883 UserEvent - The event to check
1887 EFI_SUCCESS - The event is in the signaled state
1888 EFI_NOT_READY - The event is not in the signaled state
1889 EFI_INVALID_PARAMETER - Event is of type EVT_NOTIFY_SIGNAL
1895 CoreAddMemorySpace (
1896 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1897 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1899 IN UINT64 Capabilities
1903 Routine Description:
1905 Add a segment of memory space to GCD map and add all available pages in this segment
1906 as memory descriptors.
1910 GcdMemoryType - Memory type of the segment.
1912 BaseAddress - Base address of the segment.
1914 Length - Length of the segment.
1916 Capabilities - alterable attributes of the segment.
1920 EFI_SUCCESS - Merged this segment into GCD map.
1926 CoreAllocateMemorySpace (
1927 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1928 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1931 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1932 IN EFI_HANDLE ImageHandle
,
1933 IN EFI_HANDLE DeviceHandle OPTIONAL
1937 Routine Description:
1939 Allocate memory space on GCD map.
1943 GcdAllocateType - The type of allocate operation
1945 GcdMemoryType - The desired memory type
1947 Alignment - Align with 2^Alignment
1949 Length - Length to allocate
1951 BaseAddress - Base address to allocate
1953 ImageHandle - The image handle consume the allocated space.
1955 DeviceHandle - The device handle consume the allocated space.
1959 EFI_INVALID_PARAMETER - Invalid parameter.
1961 EFI_NOT_FOUND - No descriptor contains the desired space.
1963 EFI_SUCCESS - Memory space successfully allocated.
1969 CoreFreeMemorySpace (
1970 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1975 Routine Description:Routine Description:
1977 Free a segment of memory space in GCD map.
1981 BaseAddress - Base address of the segment.
1983 Length - Length of the segment.
1987 EFI_SUCCESS - Space successfully freed.
1993 CoreRemoveMemorySpace (
1994 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1999 Routine Description:Routine Description:
2001 Remove a segment of memory space in GCD map.
2005 BaseAddress - Base address of the segment.
2007 Length - Length of the segment.
2011 EFI_SUCCESS - Successfully a segment of memory space.
2017 CoreGetMemorySpaceDescriptor (
2018 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2019 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*Descriptor
2023 Routine Description:
2025 Search all entries in GCD map which contains specified segment and build it to a descriptor.
2029 BaseAddress - Specified start address
2031 Descriptor - Specified length
2035 EFI_INVALID_PARAMETER - Invalid parameter
2037 EFI_SUCCESS - Successfully get memory space descriptor.
2043 CoreSetMemorySpaceAttributes (
2044 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2046 IN UINT64 Attributes
2050 Routine Description:
2052 Set memory space with specified attributes.
2056 BaseAddress - Specified start address
2058 Length - Specified length
2060 Attributes - Specified attributes
2064 EFI_SUCCESS - Successfully set attribute of a segment of memory space.
2070 CoreGetMemorySpaceMap (
2071 OUT UINTN
*NumberOfDescriptors
,
2072 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
**MemorySpaceMap
2076 Routine Description:
2078 Transer all entries of GCD memory map into memory descriptors and pass to caller.
2082 NumberOfDescriptors - Number of descriptors.
2084 MemorySpaceMap - Descriptor array
2088 EFI_INVALID_PARAMETER - Invalid parameter
2090 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
2092 EFI_SUCCESS - Successfully get memory space map.
2099 IN EFI_GCD_IO_TYPE GcdIoType
,
2100 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2105 Routine Description:
2107 Add a segment of IO space to GCD map.
2111 GcdIoType - IO type of the segment.
2113 BaseAddress - Base address of the segment.
2115 Length - Length of the segment.
2119 EFI_SUCCESS - Merged this segment into GCD map.
2125 CoreAllocateIoSpace (
2126 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
2127 IN EFI_GCD_IO_TYPE GcdIoType
,
2130 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
2131 IN EFI_HANDLE ImageHandle
,
2132 IN EFI_HANDLE DeviceHandle OPTIONAL
2136 Routine Description:
2138 Allocate IO space on GCD map.
2142 GcdAllocateType - The type of allocate operation
2144 GcdIoType - The desired IO type
2146 Alignment - Align with 2^Alignment
2148 Length - Length to allocate
2150 BaseAddress - Base address to allocate
2152 ImageHandle - The image handle consume the allocated space.
2154 DeviceHandle - The device handle consume the allocated space.
2158 EFI_INVALID_PARAMETER - Invalid parameter.
2160 EFI_NOT_FOUND - No descriptor contains the desired space.
2162 EFI_SUCCESS - IO space successfully allocated.
2169 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2174 Routine Description:Routine Description:
2176 Free a segment of IO space in GCD map.
2180 BaseAddress - Base address of the segment.
2182 Length - Length of the segment.
2186 EFI_SUCCESS - Space successfully freed.
2193 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2198 Routine Description:Routine Description:
2200 Remove a segment of IO space in GCD map.
2204 BaseAddress - Base address of the segment.
2206 Length - Length of the segment.
2210 EFI_SUCCESS - Successfully removed a segment of IO space.
2216 CoreGetIoSpaceDescriptor (
2217 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2218 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
*Descriptor
2222 Routine Description:
2224 Search all entries in GCD map which contains specified segment and build it to a descriptor.
2228 BaseAddress - Specified start address
2230 Descriptor - Specified length
2234 EFI_INVALID_PARAMETER - Descriptor is NULL.
2236 EFI_SUCCESS - Successfully get the IO space descriptor.
2243 OUT UINTN
*NumberOfDescriptors
,
2244 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
**IoSpaceMap
2248 Routine Description:
2250 Transer all entries of GCD IO map into IO descriptors and pass to caller.
2254 NumberOfDescriptors - Number of descriptors.
2256 IoSpaceMap - Descriptor array
2260 EFI_INVALID_PARAMETER - Invalid parameter
2262 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
2264 EFI_SUCCESS - Successfully get IO space map.
2277 Routine Description:
2279 This is the main Dispatcher for DXE and it exits when there are no more
2280 drivers to run. Drain the mScheduledQueue and load and start a PE
2281 image for each driver. Search the mDiscoveredList to see if any driver can
2282 be placed on the mScheduledQueue. If no drivers are placed on the
2283 mScheduledQueue exit the function. On exit it is assumed the Bds()
2284 will be called, and when the Bds() exits the Dispatcher will be called
2293 EFI_ALREADY_STARTED - The DXE Dispatcher is already running
2295 EFI_NOT_FOUND - No DXE Drivers were dispatched
2297 EFI_SUCCESS - One or more DXE Drivers were dispatched
2305 IN EFI_HANDLE FirmwareVolumeHandle
,
2306 IN EFI_GUID
*DriverName
2310 Routine Description:
2312 Check every driver and locate a matching one. If the driver is found, the Unrequested
2313 state flag is cleared.
2317 FirmwareVolumeHandle - The handle of the Firmware Volume that contains the firmware
2318 file specified by DriverName.
2320 DriverName - The Driver name to put in the Dependent state.
2324 EFI_SUCCESS - The DriverName was found and it's SOR bit was cleared
2326 EFI_NOT_FOUND - The DriverName does not exist or it's SOR bit was not set.
2335 IN EFI_HANDLE FirmwareVolumeHandle
,
2336 IN EFI_GUID
*DriverName
2340 Routine Description:
2342 Convert a driver from the Untrused back to the Scheduled state
2346 FirmwareVolumeHandle - The handle of the Firmware Volume that contains the firmware
2347 file specified by DriverName.
2349 DriverName - The Driver name to put in the Scheduled state
2353 EFI_SUCCESS - The file was found in the untrusted state, and it was promoted
2354 to the trusted state.
2356 EFI_NOT_FOUND - The file was not found in the untrusted state.
2363 IN OUT EFI_STATUS
*Status
,
2364 IN OUT VOID
**Buffer
,
2369 Routine Description:
2371 Helper function called as part of the code needed
2372 to allocate the proper sized buffer for various
2377 Status - Current status
2379 Buffer - Current allocated buffer, or NULL
2381 BufferSize - Current buffer size needed
2385 TRUE - if the buffer was reallocated and the caller
2386 should try the API again.
2388 FALSE - buffer could not be allocated and the caller
2389 should not try the API again.
2397 IN EFI_HANDLE ImageHandle
,
2398 IN EFI_SYSTEM_TABLE
*SystemTable
2402 Routine Description:
2403 This routine is the driver initialization entry point. It initializes the
2404 libraries, and registers two notification functions. These notification
2405 functions are responsible for building the FV stack dynamically.
2408 ImageHandle - The image handle.
2409 SystemTable - The system table.
2412 EFI_SUCCESS - Function successfully returned.
2419 InitializeSectionExtraction (
2420 IN EFI_HANDLE ImageHandle
,
2421 IN EFI_SYSTEM_TABLE
*SystemTable
2425 Routine Description:
2426 Entry point of the section extraction code. Initializes an instance of the
2427 section extraction interface and installs it on a new handle.
2430 ImageHandle EFI_HANDLE: A handle for the image that is initializing this driver
2431 SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table
2434 EFI_SUCCESS: Driver initialized successfully
2435 EFI_OUT_OF_RESOURCES: Could not allocate needed resources
2441 CoreProcessFirmwareVolume (
2444 OUT EFI_HANDLE
*FVProtocolHandle
2448 Routine Description:
2449 This DXE service routine is used to process a firmware volume. In
2450 particular, it can be called by BDS to process a single firmware
2451 volume found in a capsule.
2454 FvHeader - pointer to a firmware volume header
2455 Size - the size of the buffer pointed to by FvHeader
2456 FVProtocolHandle - the handle on which a firmware volume protocol
2457 was produced for the firmware volume passed in.
2460 EFI_OUT_OF_RESOURCES - if an FVB could not be produced due to lack of
2462 EFI_VOLUME_CORRUPTED - if the volume was corrupted
2463 EFI_SUCCESS - a firmware volume protocol was produced for the
2470 //Functions used during debug buils
2473 CoreDisplayMissingArchProtocols (
2478 Routine Description:
2479 Displays Architectural protocols that were not loaded and are required for DXE core to function
2480 Only used in Debug Builds
2491 CoreDisplayDiscoveredNotDispatched (
2496 Routine Description:
2498 Traverse the discovered list for any drivers that were discovered but not loaded
2499 because the dependency experessions evaluated to false