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_GUID
*ProtocolGuid
;
42 } ARCHITECTURAL_PROTOCOL_ENTRY
;
46 // DXE Dispatcher Data structures
49 #define KNOWN_HANDLE_SIGNATURE EFI_SIGNATURE_32('k','n','o','w')
52 LIST_ENTRY Link
; // mFvHandleList
57 #define EFI_CORE_DRIVER_ENTRY_SIGNATURE EFI_SIGNATURE_32('d','r','v','r')
60 LIST_ENTRY Link
; // mDriverList
62 LIST_ENTRY ScheduledLink
; // mScheduledQueue
66 EFI_DEVICE_PATH_PROTOCOL
*FvFileDevicePath
;
67 EFI_FIRMWARE_VOLUME_PROTOCOL
*Fv
;
74 EFI_GUID BeforeAfterGuid
;
81 BOOLEAN DepexProtocolError
;
83 EFI_HANDLE ImageHandle
;
85 } EFI_CORE_DRIVER_ENTRY
;
88 //The data structure of GCD memory map entry
90 #define EFI_GCD_MAP_SIGNATURE EFI_SIGNATURE_32('g','c','d','m')
94 EFI_PHYSICAL_ADDRESS BaseAddress
;
98 EFI_GCD_MEMORY_TYPE GcdMemoryType
;
99 EFI_GCD_IO_TYPE GcdIoType
;
100 EFI_HANDLE ImageHandle
;
101 EFI_HANDLE DeviceHandle
;
105 // DXE Core Global Variables
107 extern EFI_SYSTEM_TABLE
*gST
;
108 extern EFI_BOOT_SERVICES
*gBS
;
109 extern EFI_RUNTIME_SERVICES
*gRT
;
110 extern EFI_DXE_SERVICES
*gDS
;
111 extern EFI_HANDLE gDxeCoreImageHandle
;
113 extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress
;
114 extern EFI_PEI_PE_COFF_LOADER_PROTOCOL
*gEfiPeiPeCoffLoader
;
116 extern EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
;
117 extern EFI_CPU_ARCH_PROTOCOL
*gCpu
;
118 extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL
*gWatchdogTimer
;
119 extern EFI_METRONOME_ARCH_PROTOCOL
*gMetronome
;
120 extern EFI_TIMER_ARCH_PROTOCOL
*gTimer
;
121 extern EFI_SECURITY_ARCH_PROTOCOL
*gSecurity
;
122 extern EFI_BDS_ARCH_PROTOCOL
*gBds
;
123 extern EFI_STATUS_CODE_PROTOCOL
*gStatusCode
;
125 extern EFI_TPL gEfiCurrentTpl
;
127 extern EFI_GUID
*gDxeCoreFileName
;
128 extern EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
130 extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation
[EfiMaxMemoryType
+ 1];
132 extern BOOLEAN gDispatcherRunning
;
135 // Service Initialization Functions
147 Called to initialize the pool.
161 CoreAddMemoryDescriptor (
162 IN EFI_MEMORY_TYPE Type
,
163 IN EFI_PHYSICAL_ADDRESS Start
,
164 IN UINT64 NumberOfPages
,
171 Called to initialize the memory map and add descriptors to
172 the current descriptor list.
174 The first descriptor that is added must be general usable
175 memory as the addition allocates heap.
179 Type - The type of memory to add
181 Start - The starting address in the memory range
184 NumberOfPages - The number of pages in the range
186 Attribute - Attributes of the memory to add
190 None. The range is added to the memory map
196 CoreReleaseGcdMemoryLock (
202 Release memory lock on mGcdMemorySpaceLock
214 CoreAcquireGcdMemoryLock (
220 Acquire memory lock on mGcdMemorySpaceLock
232 CoreInitializeMemoryServices (
234 IN EFI_PHYSICAL_ADDRESS
*MemoryBaseAddress
,
235 IN UINT64
*MemoryLength
241 External function. Initializes the GCD and memory services based on the memory
242 descriptor HOBs. This function is responsible for priming the GCD map and the
243 memory map, so memory allocations and resource allocations can be made. The first
244 part of this function can not depend on any memory services until at least one
245 memory descriptor is provided to the memory services. Then the memory services
246 can be used to intialize the GCD map.
250 HobStart - The start address of the HOB.
252 MemoryBaseAddress - Start address of memory region found to init DXE core.
254 MemoryLength - Length of memory region found to init DXE core.
258 EFI_SUCCESS - Memory services successfully initialized.
265 CoreInitializeGcdServices (
267 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress
,
268 IN UINT64 MemoryLength
274 External function. Initializes the GCD and memory services based on the memory
275 descriptor HOBs. This function is responsible for priming the GCD map and the
276 memory map, so memory allocations and resource allocations can be made. The first
277 part of this function can not depend on any memory services until at least one
278 memory descriptor is provided to the memory services. Then the memory services
279 can be used to intialize the GCD map.
283 HobStart - The start address of the HOB
285 MemoryBaseAddress - Start address of memory region found to init DXE core.
287 MemoryLength - Length of memory region found to init DXE core.
292 EFI_SUCCESS - GCD services successfully initialized.
298 CoreInitializeEventServices (
305 Initializes "event" support and populates parts of the System and Runtime Table.
313 EFI_SUCCESS - Always return success
319 CoreShutdownEventServices (
326 Register all runtime events to make sure they are still available after ExitBootService.
334 EFI_SUCCESS - Always return success
340 CoreInitializeImageServices (
347 Add the Image Services to EFI Boot Services Table and install the protocol
348 interfaces for this image.
352 HobStart - The HOB to initialize
362 CoreShutdownImageServices (
369 Transfer control of runtime images to runtime service
377 EFI_SUCCESS - Function successfully returned
383 CoreNotifyOnArchProtocolInstallation (
389 Creates an event that is fired everytime a Protocol of a specific type is installed
401 CoreAllEfiServicesAvailable (
407 Return TRUE if all AP services are availible.
413 EFI_SUCCESS - All AP services are available
414 EFI_NOT_FOUND - At least one AP service is not available
421 IN OUT EFI_TABLE_HEADER
*Hdr
427 Calcualte the 32-bit CRC in a EFI table using the service provided by the
432 Hdr - Pointer to an EFI standard header
450 Called by the platform code to process a tick.
454 Duration - The number of 100ns elasped since the last call to TimerTick
464 CoreInitializeDispatcher (
471 Initialize the dispatcher. Initialize the notification function that runs when
472 a FV protocol is added to the system.
487 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
493 This is the POSTFIX version of the dependency evaluator. This code does
494 not need to handle Before or After, as it is not valid to call this
495 routine in this case. The SOR is just ignored and is a nop in the grammer.
497 POSTFIX means all the math is done on top of the stack.
501 DriverEntry - DriverEntry element to update
505 TRUE - If driver is ready to run.
507 FALSE - If driver is not ready to run or some fatal error was found.
513 CorePreProcessDepex (
514 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
520 Preprocess dependency expression and update DriverEntry to reflect the
521 state of Before, After, and SOR dependencies. If DriverEntry->Before
522 or DriverEntry->After is set it will never be cleared. If SOR is set
523 it will be cleared by CoreSchedule(), and then the driver can be
528 DriverEntry - DriverEntry element to update
532 EFI_SUCCESS - It always works.
540 CoreExitBootServices (
541 IN EFI_HANDLE ImageHandle
,
548 EFI 1.0 API to terminate Boot Services
552 ImageHandle - Handle that represents the identity of the calling image
554 MapKey -Key to the latest memory map.
558 EFI_SUCCESS - Boot Services terminated
559 EFI_INVALID_PARAMETER - MapKey is incorrect.
565 CoreTerminateMemoryMap (
572 Make sure the memory map is following all the construction rules,
573 it is the last time to check memory map error before exit boot services.
577 MapKey - Memory map key
581 EFI_INVALID_PARAMETER - Memory map not consistent with construction rules.
583 EFI_SUCCESS - Valid memory map.
589 CoreNotifySignalList (
590 IN EFI_GUID
*EventGroup
596 Signals all events on the requested list
600 SignalType - The list to signal
612 CoreInstallConfigurationTable (
620 Boot Service called to add, modify, or remove a system configuration table from
621 the EFI System Table.
625 Guid: Pointer to the GUID for the entry to add, update, or remove
626 Table: Pointer to the configuration table for the entry to add, update, or
631 EFI_SUCCESS Guid, Table pair added, updated, or removed.
632 EFI_INVALID_PARAMETER Input GUID not valid.
633 EFI_NOT_FOUND Attempted to delete non-existant entry
634 EFI_OUT_OF_RESOURCES Not enough memory available
649 Raise the task priority level to the new level.
650 High level is implemented by disabling processor interrupts.
654 NewTpl - New task priority level
658 The previous task priority level
673 Lowers the task priority to the previous value. If the new
674 priority unmasks events at a higher priority, they are dispatched.
678 NewTpl - New, lower, task priority
691 IN UINTN Microseconds
697 Introduces a fine-grained stall.
701 Microseconds The number of microseconds to stall execution
705 EFI_SUCCESS - Execution was stalled for at least the requested amount
708 EFI_NOT_AVAILABLE_YET - gMetronome is not available yet
716 CoreSetWatchdogTimer (
718 IN UINT64 WatchdogCode
,
720 IN CHAR16
*WatchdogData OPTIONAL
726 Sets the system's watchdog timer.
730 Timeout The number of seconds. Zero disables the timer.
732 ///////following three parameters are left for platform specific using
734 WatchdogCode The numberic code to log. 0x0 to 0xffff are firmware
735 DataSize Size of the optional data
736 WatchdogData Optional Null terminated unicode string followed by binary
741 EFI_SUCCESS Timeout has been set
742 EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
743 EFI_UNSUPPORTED System does not have a timer (currently not used)
744 EFI_DEVICE_ERROR Could not complete due to hardware error
752 CoreInstallProtocolInterface (
753 IN OUT EFI_HANDLE
*UserHandle
,
754 IN EFI_GUID
*Protocol
,
755 IN EFI_INTERFACE_TYPE InterfaceType
,
762 Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
763 Calls the private one which contains a BOOLEAN parameter for notifications
767 UserHandle - The handle to install the protocol handler on,
768 or NULL if a new handle is to be allocated
770 Protocol - The protocol to add to the handle
772 InterfaceType - Indicates whether Interface is supplied in native form.
774 Interface - The interface for the protocol being added
784 CoreInstallProtocolInterfaceNotify (
785 IN OUT EFI_HANDLE
*UserHandle
,
786 IN EFI_GUID
*Protocol
,
787 IN EFI_INTERFACE_TYPE InterfaceType
,
795 Installs a protocol interface into the boot services environment.
799 UserHandle - The handle to install the protocol handler on,
800 or NULL if a new handle is to be allocated
802 Protocol - The protocol to add to the handle
804 InterfaceType - Indicates whether Interface is supplied in native form.
806 Interface - The interface for the protocol being added
808 Notify - Whether to notify the notification list for this protocol
812 EFI_INVALID_PARAMETER - Invalid parameter
814 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
816 EFI_SUCCESS - Protocol interface successfully installed
824 CoreInstallMultipleProtocolInterfaces (
825 IN OUT EFI_HANDLE
*Handle
,
832 Installs a list of protocol interface into the boot services environment.
833 This function calls InstallProtocolInterface() in a loop. If any error
834 occures all the protocols added by this function are removed. This is
835 basically a lib function to save space.
839 Handle - The handle to install the protocol handlers on,
840 or NULL if a new handle is to be allocated
841 ... - EFI_GUID followed by protocol instance. A NULL terminates the
842 list. The pairs are the arguments to InstallProtocolInterface().
843 All the protocols are added to Handle.
847 EFI_INVALID_PARAMETER - Handle is NULL.
849 EFI_SUCCESS - Protocol interfaces successfully installed.
857 CoreUninstallMultipleProtocolInterfaces (
858 IN EFI_HANDLE Handle
,
865 Uninstalls a list of protocol interface in the boot services environment.
866 This function calls UnisatllProtocolInterface() in a loop. This is
867 basically a lib function to save space.
871 Handle - The handle to uninstall the protocol
873 ... - EFI_GUID followed by protocol instance. A NULL terminates the
874 list. The pairs are the arguments to UninstallProtocolInterface().
875 All the protocols are added to Handle.
887 CoreReinstallProtocolInterface (
888 IN EFI_HANDLE UserHandle
,
889 IN EFI_GUID
*Protocol
,
890 IN VOID
*OldInterface
,
891 IN VOID
*NewInterface
897 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
901 UserHandle - Handle on which the interface is to be reinstalled
902 Protocol - The numeric ID of the interface
903 OldInterface - A pointer to the old interface
904 NewInterface - A pointer to the new interface
911 On EFI_SUCCESS The protocol interface was installed
912 On EFI_NOT_FOUND The OldInterface on the handle was not found
913 On EFI_INVALID_PARAMETER One of the parameters has an invalid value
921 CoreUninstallProtocolInterface (
922 IN EFI_HANDLE UserHandle
,
923 IN EFI_GUID
*Protocol
,
930 Uninstalls all instances of a protocol:interfacer from a handle.
931 If the last protocol interface is remove from the handle, the
936 UserHandle - The handle to remove the protocol handler from
938 Protocol - The protocol, of protocol:interface, to remove
940 Interface - The interface, of protocol:interface, to remove
944 EFI_INVALID_PARAMETER - Protocol is NULL.
946 EFI_SUCCESS - Protocol interface successfully uninstalled.
955 IN EFI_HANDLE UserHandle
,
956 IN EFI_GUID
*Protocol
,
963 Queries a handle to determine if it supports a specified protocol.
967 UserHandle - The handle being queried.
969 Protocol - The published unique identifier of the protocol.
971 Interface - Supplies the address where a pointer to the corresponding Protocol
972 Interface is returned.
976 The requested protocol interface for the handle
985 IN EFI_HANDLE UserHandle
,
986 IN EFI_GUID
*Protocol
,
987 OUT VOID
**Interface OPTIONAL
,
988 IN EFI_HANDLE ImageHandle
,
989 IN EFI_HANDLE ControllerHandle
,
996 Locates the installed protocol handler for the handle, and
997 invokes it to obtain the protocol interface. Usage information
998 is registered in the protocol data base.
1002 UserHandle - The handle to obtain the protocol interface on
1004 Protocol - The ID of the protocol
1006 Interface - The location to return the protocol interface
1008 ImageHandle - The handle of the Image that is opening the protocol interface
1009 specified by Protocol and Interface.
1011 ControllerHandle - The controller handle that is requiring this interface.
1013 Attributes - The open mode of the protocol interface specified by Handle
1018 EFI_INVALID_PARAMETER - Protocol is NULL.
1020 EFI_SUCCESS - Get the protocol interface.
1028 CoreOpenProtocolInformation (
1029 IN EFI_HANDLE UserHandle
,
1030 IN EFI_GUID
*Protocol
,
1031 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
**EntryBuffer
,
1032 OUT UINTN
*EntryCount
1036 Routine Description:
1038 Return information about Opened protocols in the system
1042 UserHandle - The handle to close the protocol interface on
1044 Protocol - The ID of the protocol
1046 EntryBuffer - A pointer to a buffer of open protocol information in the form of
1047 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
1049 EntryCount - Number of EntryBuffer entries
1061 IN EFI_HANDLE UserHandle
,
1062 IN EFI_GUID
*Protocol
,
1063 IN EFI_HANDLE ImageHandle
,
1064 IN EFI_HANDLE ControllerHandle
1068 Routine Description:
1074 UserHandle - The handle to close the protocol interface on
1076 Protocol - The ID of the protocol
1078 ImageHandle - The user of the protocol to close
1080 ControllerHandle - The user of the protocol to close
1084 EFI_INVALID_PARAMETER - Protocol is NULL.
1092 CoreProtocolsPerHandle (
1093 IN EFI_HANDLE UserHandle
,
1094 OUT EFI_GUID
***ProtocolBuffer
,
1095 OUT UINTN
*ProtocolBufferCount
1099 Routine Description:
1101 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
1106 UserHandle - The handle from which to retrieve the list of protocol interface
1109 ProtocolBuffer - A pointer to the list of protocol interface GUID pointers that are
1110 installed on Handle.
1112 ProtocolBufferCount - A pointer to the number of GUID pointers present in
1116 EFI_SUCCESS - The list of protocol interface GUIDs installed on Handle was returned in
1117 ProtocolBuffer. The number of protocol interface GUIDs was
1118 returned in ProtocolBufferCount.
1119 EFI_INVALID_PARAMETER - Handle is NULL.
1120 EFI_INVALID_PARAMETER - Handle is not a valid EFI_HANDLE.
1121 EFI_INVALID_PARAMETER - ProtocolBuffer is NULL.
1122 EFI_INVALID_PARAMETER - ProtocolBufferCount is NULL.
1123 EFI_OUT_OF_RESOURCES - There is not enough pool memory to store the results.
1131 CoreRegisterProtocolNotify (
1132 IN EFI_GUID
*Protocol
,
1134 OUT VOID
**Registration
1138 Routine Description:
1140 Add a new protocol notification record for the request protocol.
1144 Protocol - The requested protocol to add the notify registration
1146 Event - The event to signal
1148 Registration - Returns the registration record
1153 EFI_INVALID_PARAMETER - Invalid parameter
1155 EFI_SUCCESS - Successfully returned the registration record that has been added
1164 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1165 IN EFI_GUID
*Protocol OPTIONAL
,
1166 IN VOID
*SearchKey OPTIONAL
,
1167 IN OUT UINTN
*BufferSize
,
1168 OUT EFI_HANDLE
*Buffer
1172 Routine Description:
1174 Locates the requested handle(s) and returns them in Buffer.
1178 SearchType - The type of search to perform to locate the handles
1180 Protocol - The protocol to search for
1182 SearchKey - Dependant on SearchType
1184 BufferSize - On input the size of Buffer. On output the
1185 size of data returned.
1187 Buffer - The buffer to return the results in
1192 EFI_BUFFER_TOO_SMALL - Buffer too small, required buffer size is returned in BufferSize.
1194 EFI_INVALID_PARAMETER - Invalid parameter
1196 EFI_SUCCESS - Successfully found the requested handle(s) and returns them in Buffer.
1204 CoreLocateDevicePath (
1205 IN EFI_GUID
*Protocol
,
1206 IN OUT EFI_DEVICE_PATH_PROTOCOL
**FilePath
,
1207 OUT EFI_HANDLE
*Device
1211 Routine Description:
1213 Locates the handle to a device on the device path that supports the specified protocol.
1217 Protocol - The protocol to search for.
1218 FilePath - On input, a pointer to a pointer to the device path. On output, the device
1219 path pointer is modified to point to the remaining part of the devicepath.
1220 Device - A pointer to the returned device handle.
1224 EFI_SUCCESS - The resulting handle was returned.
1225 EFI_NOT_FOUND - No handles matched the search.
1226 EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
1234 CoreLocateHandleBuffer (
1235 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1236 IN EFI_GUID
*Protocol OPTIONAL
,
1237 IN VOID
*SearchKey OPTIONAL
,
1238 IN OUT UINTN
*NumberHandles
,
1239 OUT EFI_HANDLE
**Buffer
1243 Routine Description:
1245 Function returns an array of handles that support the requested protocol
1246 in a buffer allocated from pool. This is a version of CoreLocateHandle()
1247 that allocates a buffer for the caller.
1251 SearchType - Specifies which handle(s) are to be returned.
1252 Protocol - Provides the protocol to search by.
1253 This parameter is only valid for SearchType ByProtocol.
1254 SearchKey - Supplies the search key depending on the SearchType.
1255 NumberHandles - The number of handles returned in Buffer.
1256 Buffer - A pointer to the buffer to return the requested array of
1257 handles that support Protocol.
1261 EFI_SUCCESS - The result array of handles was returned.
1262 EFI_NOT_FOUND - No handles match the search.
1263 EFI_OUT_OF_RESOURCES - There is not enough pool memory to store the matching results.
1264 EFI_INVALID_PARAMETER - Invalid parameter
1272 CoreLocateProtocol (
1273 IN EFI_GUID
*Protocol
,
1274 IN VOID
*Registration OPTIONAL
,
1275 OUT VOID
**Interface
1279 Routine Description:
1281 Return the first Protocol Interface that matches the Protocol GUID. If
1282 Registration is pasased in return a Protocol Instance that was just add
1283 to the system. If Retistration is NULL return the first Protocol Interface
1288 Protocol - The protocol to search for
1290 Registration - Optional Registration Key returned from RegisterProtocolNotify()
1292 Interface - Return the Protocol interface (instance).
1296 EFI_SUCCESS - If a valid Interface is returned
1298 EFI_INVALID_PARAMETER - Invalid parameter
1300 EFI_NOT_FOUND - Protocol interface not found
1306 CoreGetHandleDatabaseKey (
1311 Routine Description:
1313 return handle database key.
1321 Handle database key.
1327 CoreConnectHandlesByKey (
1332 Routine Description:
1334 Go connect any handles that were created or modified while a image executed.
1338 Key - The Key to show that the handle has been created/modified
1349 CoreConnectController (
1350 IN EFI_HANDLE ControllerHandle
,
1351 IN EFI_HANDLE
*DriverImageHandle OPTIONAL
,
1352 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
1353 IN BOOLEAN Recursive
1357 Routine Description:
1359 Connects one or more drivers to a controller.
1363 ControllerHandle - Handle of the controller to be connected.
1365 DriverImageHandle - DriverImageHandle A pointer to an ordered list of driver image handles.
1367 RemainingDevicePath - RemainingDevicePath A pointer to the device path that specifies a child of the
1368 controller specified by ControllerHandle.
1370 Recursive - - Whether the function would be called recursively or not.
1382 CoreDisconnectController (
1383 IN EFI_HANDLE ControllerHandle
,
1384 IN EFI_HANDLE DriverImageHandle OPTIONAL
,
1385 IN EFI_HANDLE ChildHandle OPTIONAL
1389 Routine Description:
1391 Disonnects a controller from a driver
1395 ControllerHandle - ControllerHandle The handle of the controller from which driver(s)
1396 are to be disconnected.
1397 DriverImageHandle - DriverImageHandle The driver to disconnect from ControllerHandle.
1398 ChildHandle - ChildHandle The handle of the child to destroy.
1402 EFI_SUCCESS - One or more drivers were disconnected from the controller.
1403 EFI_SUCCESS - On entry, no drivers are managing ControllerHandle.
1404 EFI_SUCCESS - DriverImageHandle is not NULL, and on entry DriverImageHandle is not managing ControllerHandle.
1405 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
1406 EFI_INVALID_PARAMETER - DriverImageHandle is not NULL, and it is not a valid EFI_HANDLE.
1407 EFI_INVALID_PARAMETER - ChildHandle is not NULL, and it is not a valid EFI_HANDLE.
1408 EFI_OUT_OF_RESOURCES - There are not enough resources available to disconnect any drivers from ControllerHandle.
1409 EFI_DEVICE_ERROR - The controller could not be disconnected because of a device error.
1418 IN EFI_ALLOCATE_TYPE Type
,
1419 IN EFI_MEMORY_TYPE MemoryType
,
1420 IN UINTN NumberOfPages
,
1421 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
1425 Routine Description:
1427 Allocates pages from the memory map.
1431 Type - The type of allocation to perform
1433 MemoryType - The type of memory to turn the allocated pages into
1435 NumberOfPages - The number of pages to allocate
1437 Memory - A pointer to receive the base allocated memory address
1441 Status. On success, Memory is filled in with the base address allocated
1443 EFI_INVALID_PARAMETER - Parameters violate checking rules defined in spec.
1445 EFI_NOT_FOUND - Could not allocate pages match the requirement.
1447 EFI_OUT_OF_RESOURCES - No enough pages to allocate.
1449 EFI_SUCCESS - Pages successfully allocated.
1458 IN EFI_PHYSICAL_ADDRESS Memory
,
1459 IN UINTN NumberOfPages
1463 Routine Description:
1465 Frees previous allocated pages.
1469 Memory - Base address of memory being freed
1471 NumberOfPages - The number of pages to free
1475 EFI_NOT_FOUND - Could not find the entry that covers the range
1477 EFI_INVALID_PARAMETER - Address not aligned
1479 EFI_SUCCESS -Pages successfully freed.
1488 IN OUT UINTN
*MemoryMapSize
,
1489 IN OUT EFI_MEMORY_DESCRIPTOR
*Desc
,
1491 OUT UINTN
*DescriptorSize
,
1492 OUT UINT32
*DescriptorVersion
1496 Routine Description:
1498 Returns the current memory map.
1502 MemoryMapSize - On input the buffer size of MemoryMap allocated by caller
1503 On output the required buffer size to contain the memory map
1505 Desc - The buffer to return the current memory map
1507 MapKey - The address to return the current map key
1509 DescriptorSize - The size in bytes for an individual EFI_MEMORY_DESCRIPTOR
1511 DescriptorVersion - The version number associated with the EFI_MEMORY_DESCRIPTOR
1515 EFI_SUCCESS The current memory map was returned successfully
1517 EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small
1519 EFI_INVALID_PARAMETER One of the parameters has an invalid value
1528 IN EFI_MEMORY_TYPE PoolType
,
1534 Routine Description:
1536 Allocate pool of a particular type.
1540 PoolType - Type of pool to allocate
1542 Size - The amount of pool to allocate
1544 Buffer - The address to return a pointer to the allocated pool
1548 EFI_INVALID_PARAMETER - PoolType not valid
1550 EFI_OUT_OF_RESOURCES - Size exceeds max pool size or allocation failed.
1552 EFI_SUCCESS - Pool successfully allocated.
1565 Routine Description:
1571 Buffer - The allocated pool entry to free
1575 EFI_INVALID_PARAMETER - Buffer is not a valid value.
1577 EFI_SUCCESS - Pool successfully freed.
1586 IN BOOLEAN BootPolicy
,
1587 IN EFI_HANDLE ParentImageHandle
,
1588 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
1589 IN VOID
*SourceBuffer OPTIONAL
,
1590 IN UINTN SourceSize
,
1591 OUT EFI_HANDLE
*ImageHandle
1595 Routine Description:
1597 Loads an EFI image into memory and returns a handle to the image.
1601 BootPolicy - If TRUE, indicates that the request originates from the boot manager,
1602 and that the boot manager is attempting to load FilePath as a boot selection.
1603 ParentImageHandle - The caller's image handle.
1604 FilePath - The specific file path from which the image is loaded.
1605 SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
1606 the image to be loaded.
1607 SourceSize - The size in bytes of SourceBuffer.
1608 ImageHandle - Pointer to the returned image handle that is created when the image
1609 is successfully loaded.
1613 EFI_SUCCESS - The image was loaded into memory.
1614 EFI_NOT_FOUND - The FilePath was not found.
1615 EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
1616 EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
1617 parsed to locate the proper protocol for loading the file.
1618 EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
1626 IN EFI_HANDLE ImageHandle
1630 Routine Description:
1632 Unload the specified image.
1636 ImageHandle - The specified image handle.
1640 EFI_INVALID_PARAMETER - Image handle is NULL.
1642 EFI_UNSUPPORTED - Attempt to unload an unsupported image.
1644 EFI_SUCCESS - Image successfully unloaded.
1653 IN EFI_HANDLE ImageHandle
,
1654 OUT UINTN
*ExitDataSize
,
1655 OUT CHAR16
**ExitData OPTIONAL
1659 Routine Description:
1661 Transfer control to a loaded image's entry point.
1665 ImageHandle - Handle of image to be started.
1667 ExitDataSize - Pointer of the size to ExitData
1669 ExitData - Pointer to a pointer to a data buffer that includes a Null-terminated
1670 Unicode string, optionally followed by additional binary data. The string
1671 is a description that the caller may use to further indicate the reason for
1672 the image¡¯s exit.
1676 EFI_INVALID_PARAMETER - Invalid parameter
1678 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
1680 EFI_SUCCESS - Successfully transfer control to the image's entry point.
1689 IN EFI_HANDLE ImageHandle
,
1690 IN EFI_STATUS Status
,
1691 IN UINTN ExitDataSize
,
1692 IN CHAR16
*ExitData OPTIONAL
1696 Routine Description:
1698 Terminates the currently loaded EFI image and returns control to boot services.
1702 ImageHandle - Handle that identifies the image. This parameter is passed to the image
1704 Status - The image¡¯s exit code.
1705 ExitDataSize - The size, in bytes, of ExitData. Ignored if ExitStatus is
1707 ExitData - Pointer to a data buffer that includes a Null-terminated Unicode string,
1708 optionally followed by additional binary data. The string is a
1709 description that the caller may use to further indicate the reason for
1710 the image¡¯s exit.
1714 EFI_INVALID_PARAMETER - Image handle is NULL or it is not current image.
1716 EFI_SUCCESS - Successfully terminates the currently loaded EFI image.
1718 EFI_ACCESS_DENIED - Should never reach there.
1728 IN EFI_TPL NotifyTpl
,
1729 IN EFI_EVENT_NOTIFY NotifyFunction
,
1730 IN VOID
*NotifyContext
,
1731 OUT EFI_EVENT
*pEvent
1735 Routine Description:
1737 Creates a general-purpose event structure
1741 Type - The type of event to create and its mode and attributes
1742 NotifyTpl - The task priority level of event notifications
1743 NotifyFunction - Pointer to the event\92s notification function
1744 NotifyContext - Pointer to the notification function\92s context; corresponds to
1745 parameter "Context" in the notification function
1746 pEvent - Pointer to the newly created event if the call succeeds; undefined otherwise
1750 EFI_SUCCESS - The event structure was created
1751 EFI_INVALID_PARAMETER - One of the parameters has an invalid value
1752 EFI_OUT_OF_RESOURCES - The event could not be allocated
1762 IN EFI_TPL NotifyTpl
,
1763 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1764 IN CONST VOID
*NotifyContext
, OPTIONAL
1765 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1766 OUT EFI_EVENT
*Event
1770 Routine Description:
1771 Creates a general-purpose event structure
1774 Type - The type of event to create and its mode and attributes
1775 NotifyTpl - The task priority level of event notifications
1776 NotifyFunction - Pointer to the events notification function
1777 NotifyContext - Pointer to the notification functions context; corresponds to
1778 parameter "Context" in the notification function
1779 EventGrout - GUID for EventGroup if NULL act the same as gBS->CreateEvent().
1780 Event - Pointer to the newly created event if the call succeeds; undefined otherwise
1783 EFI_SUCCESS - The event structure was created
1784 EFI_INVALID_PARAMETER - One of the parameters has an invalid value
1785 EFI_OUT_OF_RESOURCES - The event could not be allocated
1795 IN EFI_TIMER_DELAY Type
,
1796 IN UINT64 TriggerTime
1800 Routine Description:
1802 Sets the type of timer and the trigger time for a timer event.
1806 UserEvent - The timer event that is to be signaled at the specified time
1807 Type - The type of time that is specified in TriggerTime
1808 TriggerTime - The number of 100ns units until the timer expires
1812 EFI_SUCCESS - The event has been set to be signaled at the requested time
1813 EFI_INVALID_PARAMETER - Event or Type is not valid
1826 Routine Description:
1828 Signals the event. Queues the event to be notified if needed
1832 Event - The event to signal
1836 EFI_INVALID_PARAMETER - Parameters are not valid.
1838 EFI_SUCCESS - The event was signaled.
1847 IN UINTN NumberOfEvents
,
1848 IN EFI_EVENT
*UserEvents
,
1849 OUT UINTN
*UserIndex
1853 Routine Description:
1855 Stops execution until an event is signaled.
1859 NumberOfEvents - The number of events in the UserEvents array
1860 UserEvents - An array of EFI_EVENT
1861 UserIndex - Pointer to the index of the event which satisfied the wait condition
1865 EFI_SUCCESS - The event indicated by Index was signaled.
1866 EFI_INVALID_PARAMETER - The event indicated by Index has a notification function or
1867 Event was not a valid type
1868 EFI_UNSUPPORTED - The current TPL is not TPL_APPLICATION
1881 Routine Description:
1883 Closes an event and frees the event structure.
1887 UserEvent - Event to close
1891 EFI_INVALID_PARAMETER - Parameters are not valid.
1893 EFI_SUCCESS - The event has been closed
1906 Routine Description:
1908 Check the status of an event
1912 UserEvent - The event to check
1916 EFI_SUCCESS - The event is in the signaled state
1917 EFI_NOT_READY - The event is not in the signaled state
1918 EFI_INVALID_PARAMETER - Event is of type EVT_NOTIFY_SIGNAL
1924 CoreAddMemorySpace (
1925 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1926 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1928 IN UINT64 Capabilities
1932 Routine Description:
1934 Add a segment of memory space to GCD map and add all available pages in this segment
1935 as memory descriptors.
1939 GcdMemoryType - Memory type of the segment.
1941 BaseAddress - Base address of the segment.
1943 Length - Length of the segment.
1945 Capabilities - alterable attributes of the segment.
1949 EFI_SUCCESS - Merged this segment into GCD map.
1955 CoreAllocateMemorySpace (
1956 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1957 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1960 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1961 IN EFI_HANDLE ImageHandle
,
1962 IN EFI_HANDLE DeviceHandle OPTIONAL
1966 Routine Description:
1968 Allocate memory space on GCD map.
1972 GcdAllocateType - The type of allocate operation
1974 GcdMemoryType - The desired memory type
1976 Alignment - Align with 2^Alignment
1978 Length - Length to allocate
1980 BaseAddress - Base address to allocate
1982 ImageHandle - The image handle consume the allocated space.
1984 DeviceHandle - The device handle consume the allocated space.
1988 EFI_INVALID_PARAMETER - Invalid parameter.
1990 EFI_NOT_FOUND - No descriptor contains the desired space.
1992 EFI_SUCCESS - Memory space successfully allocated.
1998 CoreFreeMemorySpace (
1999 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2004 Routine Description:Routine Description:
2006 Free a segment of memory space in GCD map.
2010 BaseAddress - Base address of the segment.
2012 Length - Length of the segment.
2016 EFI_SUCCESS - Space successfully freed.
2022 CoreRemoveMemorySpace (
2023 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2028 Routine Description:Routine Description:
2030 Remove a segment of memory space in GCD map.
2034 BaseAddress - Base address of the segment.
2036 Length - Length of the segment.
2040 EFI_SUCCESS - Successfully a segment of memory space.
2046 CoreGetMemorySpaceDescriptor (
2047 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2048 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*Descriptor
2052 Routine Description:
2054 Search all entries in GCD map which contains specified segment and build it to a descriptor.
2058 BaseAddress - Specified start address
2060 Descriptor - Specified length
2064 EFI_INVALID_PARAMETER - Invalid parameter
2066 EFI_SUCCESS - Successfully get memory space descriptor.
2072 CoreSetMemorySpaceAttributes (
2073 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2075 IN UINT64 Attributes
2079 Routine Description:
2081 Set memory space with specified attributes.
2085 BaseAddress - Specified start address
2087 Length - Specified length
2089 Attributes - Specified attributes
2093 EFI_SUCCESS - Successfully set attribute of a segment of memory space.
2099 CoreGetMemorySpaceMap (
2100 OUT UINTN
*NumberOfDescriptors
,
2101 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
**MemorySpaceMap
2105 Routine Description:
2107 Transer all entries of GCD memory map into memory descriptors and pass to caller.
2111 NumberOfDescriptors - Number of descriptors.
2113 MemorySpaceMap - Descriptor array
2117 EFI_INVALID_PARAMETER - Invalid parameter
2119 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
2121 EFI_SUCCESS - Successfully get memory space map.
2128 IN EFI_GCD_IO_TYPE GcdIoType
,
2129 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2134 Routine Description:
2136 Add a segment of IO space to GCD map.
2140 GcdIoType - IO type of the segment.
2142 BaseAddress - Base address of the segment.
2144 Length - Length of the segment.
2148 EFI_SUCCESS - Merged this segment into GCD map.
2154 CoreAllocateIoSpace (
2155 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
2156 IN EFI_GCD_IO_TYPE GcdIoType
,
2159 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
2160 IN EFI_HANDLE ImageHandle
,
2161 IN EFI_HANDLE DeviceHandle OPTIONAL
2165 Routine Description:
2167 Allocate IO space on GCD map.
2171 GcdAllocateType - The type of allocate operation
2173 GcdIoType - The desired IO type
2175 Alignment - Align with 2^Alignment
2177 Length - Length to allocate
2179 BaseAddress - Base address to allocate
2181 ImageHandle - The image handle consume the allocated space.
2183 DeviceHandle - The device handle consume the allocated space.
2187 EFI_INVALID_PARAMETER - Invalid parameter.
2189 EFI_NOT_FOUND - No descriptor contains the desired space.
2191 EFI_SUCCESS - IO space successfully allocated.
2198 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2203 Routine Description:Routine Description:
2205 Free a segment of IO space in GCD map.
2209 BaseAddress - Base address of the segment.
2211 Length - Length of the segment.
2215 EFI_SUCCESS - Space successfully freed.
2222 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2227 Routine Description:Routine Description:
2229 Remove a segment of IO space in GCD map.
2233 BaseAddress - Base address of the segment.
2235 Length - Length of the segment.
2239 EFI_SUCCESS - Successfully removed a segment of IO space.
2245 CoreGetIoSpaceDescriptor (
2246 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2247 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
*Descriptor
2251 Routine Description:
2253 Search all entries in GCD map which contains specified segment and build it to a descriptor.
2257 BaseAddress - Specified start address
2259 Descriptor - Specified length
2263 EFI_INVALID_PARAMETER - Descriptor is NULL.
2265 EFI_SUCCESS - Successfully get the IO space descriptor.
2272 OUT UINTN
*NumberOfDescriptors
,
2273 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
**IoSpaceMap
2277 Routine Description:
2279 Transer all entries of GCD IO map into IO descriptors and pass to caller.
2283 NumberOfDescriptors - Number of descriptors.
2285 IoSpaceMap - Descriptor array
2289 EFI_INVALID_PARAMETER - Invalid parameter
2291 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
2293 EFI_SUCCESS - Successfully get IO space map.
2306 Routine Description:
2308 This is the main Dispatcher for DXE and it exits when there are no more
2309 drivers to run. Drain the mScheduledQueue and load and start a PE
2310 image for each driver. Search the mDiscoveredList to see if any driver can
2311 be placed on the mScheduledQueue. If no drivers are placed on the
2312 mScheduledQueue exit the function. On exit it is assumed the Bds()
2313 will be called, and when the Bds() exits the Dispatcher will be called
2322 EFI_ALREADY_STARTED - The DXE Dispatcher is already running
2324 EFI_NOT_FOUND - No DXE Drivers were dispatched
2326 EFI_SUCCESS - One or more DXE Drivers were dispatched
2334 IN EFI_HANDLE FirmwareVolumeHandle
,
2335 IN EFI_GUID
*DriverName
2339 Routine Description:
2341 Check every driver and locate a matching one. If the driver is found, the Unrequested
2342 state flag is cleared.
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 Dependent state.
2353 EFI_SUCCESS - The DriverName was found and it's SOR bit was cleared
2355 EFI_NOT_FOUND - The DriverName does not exist or it's SOR bit was not set.
2364 IN EFI_HANDLE FirmwareVolumeHandle
,
2365 IN EFI_GUID
*DriverName
2369 Routine Description:
2371 Convert a driver from the Untrused back to the Scheduled state
2375 FirmwareVolumeHandle - The handle of the Firmware Volume that contains the firmware
2376 file specified by DriverName.
2378 DriverName - The Driver name to put in the Scheduled state
2382 EFI_SUCCESS - The file was found in the untrusted state, and it was promoted
2383 to the trusted state.
2385 EFI_NOT_FOUND - The file was not found in the untrusted state.
2392 IN OUT EFI_STATUS
*Status
,
2393 IN OUT VOID
**Buffer
,
2398 Routine Description:
2400 Helper function called as part of the code needed
2401 to allocate the proper sized buffer for various
2406 Status - Current status
2408 Buffer - Current allocated buffer, or NULL
2410 BufferSize - Current buffer size needed
2414 TRUE - if the buffer was reallocated and the caller
2415 should try the API again.
2417 FALSE - buffer could not be allocated and the caller
2418 should not try the API again.
2426 IN EFI_HANDLE ImageHandle
,
2427 IN EFI_SYSTEM_TABLE
*SystemTable
2431 Routine Description:
2432 This routine is the driver initialization entry point. It initializes the
2433 libraries, and registers two notification functions. These notification
2434 functions are responsible for building the FV stack dynamically.
2437 ImageHandle - The image handle.
2438 SystemTable - The system table.
2441 EFI_SUCCESS - Function successfully returned.
2448 InitializeSectionExtraction (
2449 IN EFI_HANDLE ImageHandle
,
2450 IN EFI_SYSTEM_TABLE
*SystemTable
2454 Routine Description:
2455 Entry point of the section extraction code. Initializes an instance of the
2456 section extraction interface and installs it on a new handle.
2459 ImageHandle EFI_HANDLE: A handle for the image that is initializing this driver
2460 SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table
2463 EFI_SUCCESS: Driver initialized successfully
2464 EFI_OUT_OF_RESOURCES: Could not allocate needed resources
2470 CoreProcessFirmwareVolume (
2473 OUT EFI_HANDLE
*FVProtocolHandle
2477 Routine Description:
2478 This DXE service routine is used to process a firmware volume. In
2479 particular, it can be called by BDS to process a single firmware
2480 volume found in a capsule.
2483 FvHeader - pointer to a firmware volume header
2484 Size - the size of the buffer pointed to by FvHeader
2485 FVProtocolHandle - the handle on which a firmware volume protocol
2486 was produced for the firmware volume passed in.
2489 EFI_OUT_OF_RESOURCES - if an FVB could not be produced due to lack of
2491 EFI_VOLUME_CORRUPTED - if the volume was corrupted
2492 EFI_SUCCESS - a firmware volume protocol was produced for the
2499 //Functions used during debug buils
2502 CoreDisplayMissingArchProtocols (
2507 Routine Description:
2508 Displays Architectural protocols that were not loaded and are required for DXE core to function
2509 Only used in Debug Builds
2520 CoreDisplayDiscoveredNotDispatched (
2525 Routine Description:
2527 Traverse the discovered list for any drivers that were discovered but not loaded
2528 because the dependency experessions evaluated to false