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
;
133 extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
;
136 // Service Initialization Functions
148 Called to initialize the pool.
162 CoreAddMemoryDescriptor (
163 IN EFI_MEMORY_TYPE Type
,
164 IN EFI_PHYSICAL_ADDRESS Start
,
165 IN UINT64 NumberOfPages
,
172 Called to initialize the memory map and add descriptors to
173 the current descriptor list.
175 The first descriptor that is added must be general usable
176 memory as the addition allocates heap.
180 Type - The type of memory to add
182 Start - The starting address in the memory range
185 NumberOfPages - The number of pages in the range
187 Attribute - Attributes of the memory to add
191 None. The range is added to the memory map
197 CoreReleaseGcdMemoryLock (
203 Release memory lock on mGcdMemorySpaceLock
215 CoreAcquireGcdMemoryLock (
221 Acquire memory lock on mGcdMemorySpaceLock
233 CoreInitializeMemoryServices (
235 IN EFI_PHYSICAL_ADDRESS
*MemoryBaseAddress
,
236 IN UINT64
*MemoryLength
242 External function. Initializes the GCD and memory services based on the memory
243 descriptor HOBs. This function is responsible for priming the GCD map and the
244 memory map, so memory allocations and resource allocations can be made. The first
245 part of this function can not depend on any memory services until at least one
246 memory descriptor is provided to the memory services. Then the memory services
247 can be used to intialize the GCD map.
251 HobStart - The start address of the HOB.
253 MemoryBaseAddress - Start address of memory region found to init DXE core.
255 MemoryLength - Length of memory region found to init DXE core.
259 EFI_SUCCESS - Memory services successfully initialized.
266 CoreInitializeGcdServices (
268 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress
,
269 IN UINT64 MemoryLength
275 External function. Initializes the GCD and memory services based on the memory
276 descriptor HOBs. This function is responsible for priming the GCD map and the
277 memory map, so memory allocations and resource allocations can be made. The first
278 part of this function can not depend on any memory services until at least one
279 memory descriptor is provided to the memory services. Then the memory services
280 can be used to intialize the GCD map.
284 HobStart - The start address of the HOB
286 MemoryBaseAddress - Start address of memory region found to init DXE core.
288 MemoryLength - Length of memory region found to init DXE core.
293 EFI_SUCCESS - GCD services successfully initialized.
299 CoreInitializeEventServices (
306 Initializes "event" support and populates parts of the System and Runtime Table.
314 EFI_SUCCESS - Always return success
320 CoreInitializeImageServices (
327 Add the Image Services to EFI Boot Services Table and install the protocol
328 interfaces for this image.
332 HobStart - The HOB to initialize
342 CoreNotifyOnArchProtocolInstallation (
348 Creates an event that is fired everytime a Protocol of a specific type is installed
360 CoreAllEfiServicesAvailable (
366 Return TRUE if all AP services are availible.
372 EFI_SUCCESS - All AP services are available
373 EFI_NOT_FOUND - At least one AP service is not available
380 IN OUT EFI_TABLE_HEADER
*Hdr
386 Calcualte the 32-bit CRC in a EFI table using the service provided by the
391 Hdr - Pointer to an EFI standard header
409 Called by the platform code to process a tick.
413 Duration - The number of 100ns elasped since the last call to TimerTick
423 CoreInitializeDispatcher (
430 Initialize the dispatcher. Initialize the notification function that runs when
431 a FV protocol is added to the system.
446 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
452 This is the POSTFIX version of the dependency evaluator. This code does
453 not need to handle Before or After, as it is not valid to call this
454 routine in this case. The SOR is just ignored and is a nop in the grammer.
456 POSTFIX means all the math is done on top of the stack.
460 DriverEntry - DriverEntry element to update
464 TRUE - If driver is ready to run.
466 FALSE - If driver is not ready to run or some fatal error was found.
472 CorePreProcessDepex (
473 IN EFI_CORE_DRIVER_ENTRY
*DriverEntry
479 Preprocess dependency expression and update DriverEntry to reflect the
480 state of Before, After, and SOR dependencies. If DriverEntry->Before
481 or DriverEntry->After is set it will never be cleared. If SOR is set
482 it will be cleared by CoreSchedule(), and then the driver can be
487 DriverEntry - DriverEntry element to update
491 EFI_SUCCESS - It always works.
499 CoreExitBootServices (
500 IN EFI_HANDLE ImageHandle
,
507 EFI 1.0 API to terminate Boot Services
511 ImageHandle - Handle that represents the identity of the calling image
513 MapKey -Key to the latest memory map.
517 EFI_SUCCESS - Boot Services terminated
518 EFI_INVALID_PARAMETER - MapKey is incorrect.
524 CoreTerminateMemoryMap (
531 Make sure the memory map is following all the construction rules,
532 it is the last time to check memory map error before exit boot services.
536 MapKey - Memory map key
540 EFI_INVALID_PARAMETER - Memory map not consistent with construction rules.
542 EFI_SUCCESS - Valid memory map.
548 CoreNotifySignalList (
549 IN EFI_GUID
*EventGroup
555 Signals all events on the requested list
559 SignalType - The list to signal
571 CoreInstallConfigurationTable (
579 Boot Service called to add, modify, or remove a system configuration table from
580 the EFI System Table.
584 Guid: Pointer to the GUID for the entry to add, update, or remove
585 Table: Pointer to the configuration table for the entry to add, update, or
590 EFI_SUCCESS Guid, Table pair added, updated, or removed.
591 EFI_INVALID_PARAMETER Input GUID not valid.
592 EFI_NOT_FOUND Attempted to delete non-existant entry
593 EFI_OUT_OF_RESOURCES Not enough memory available
608 Raise the task priority level to the new level.
609 High level is implemented by disabling processor interrupts.
613 NewTpl - New task priority level
617 The previous task priority level
632 Lowers the task priority to the previous value. If the new
633 priority unmasks events at a higher priority, they are dispatched.
637 NewTpl - New, lower, task priority
650 IN UINTN Microseconds
656 Introduces a fine-grained stall.
660 Microseconds The number of microseconds to stall execution
664 EFI_SUCCESS - Execution was stalled for at least the requested amount
667 EFI_NOT_AVAILABLE_YET - gMetronome is not available yet
675 CoreSetWatchdogTimer (
677 IN UINT64 WatchdogCode
,
679 IN CHAR16
*WatchdogData OPTIONAL
685 Sets the system's watchdog timer.
689 Timeout The number of seconds. Zero disables the timer.
691 ///////following three parameters are left for platform specific using
693 WatchdogCode The numberic code to log. 0x0 to 0xffff are firmware
694 DataSize Size of the optional data
695 WatchdogData Optional Null terminated unicode string followed by binary
700 EFI_SUCCESS Timeout has been set
701 EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
702 EFI_UNSUPPORTED System does not have a timer (currently not used)
703 EFI_DEVICE_ERROR Could not complete due to hardware error
711 CoreInstallProtocolInterface (
712 IN OUT EFI_HANDLE
*UserHandle
,
713 IN EFI_GUID
*Protocol
,
714 IN EFI_INTERFACE_TYPE InterfaceType
,
721 Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
722 Calls the private one which contains a BOOLEAN parameter for notifications
726 UserHandle - The handle to install the protocol handler on,
727 or NULL if a new handle is to be allocated
729 Protocol - The protocol to add to the handle
731 InterfaceType - Indicates whether Interface is supplied in native form.
733 Interface - The interface for the protocol being added
743 CoreInstallProtocolInterfaceNotify (
744 IN OUT EFI_HANDLE
*UserHandle
,
745 IN EFI_GUID
*Protocol
,
746 IN EFI_INTERFACE_TYPE InterfaceType
,
754 Installs a protocol interface into the boot services environment.
758 UserHandle - The handle to install the protocol handler on,
759 or NULL if a new handle is to be allocated
761 Protocol - The protocol to add to the handle
763 InterfaceType - Indicates whether Interface is supplied in native form.
765 Interface - The interface for the protocol being added
767 Notify - Whether to notify the notification list for this protocol
771 EFI_INVALID_PARAMETER - Invalid parameter
773 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
775 EFI_SUCCESS - Protocol interface successfully installed
783 CoreInstallMultipleProtocolInterfaces (
784 IN OUT EFI_HANDLE
*Handle
,
791 Installs a list of protocol interface into the boot services environment.
792 This function calls InstallProtocolInterface() in a loop. If any error
793 occures all the protocols added by this function are removed. This is
794 basically a lib function to save space.
798 Handle - The handle to install the protocol handlers on,
799 or NULL if a new handle is to be allocated
800 ... - EFI_GUID followed by protocol instance. A NULL terminates the
801 list. The pairs are the arguments to InstallProtocolInterface().
802 All the protocols are added to Handle.
806 EFI_INVALID_PARAMETER - Handle is NULL.
808 EFI_SUCCESS - Protocol interfaces successfully installed.
816 CoreUninstallMultipleProtocolInterfaces (
817 IN EFI_HANDLE Handle
,
824 Uninstalls a list of protocol interface in the boot services environment.
825 This function calls UnisatllProtocolInterface() in a loop. This is
826 basically a lib function to save space.
830 Handle - The handle to uninstall the protocol
832 ... - EFI_GUID followed by protocol instance. A NULL terminates the
833 list. The pairs are the arguments to UninstallProtocolInterface().
834 All the protocols are added to Handle.
846 CoreReinstallProtocolInterface (
847 IN EFI_HANDLE UserHandle
,
848 IN EFI_GUID
*Protocol
,
849 IN VOID
*OldInterface
,
850 IN VOID
*NewInterface
856 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
860 UserHandle - Handle on which the interface is to be reinstalled
861 Protocol - The numeric ID of the interface
862 OldInterface - A pointer to the old interface
863 NewInterface - A pointer to the new interface
870 On EFI_SUCCESS The protocol interface was installed
871 On EFI_NOT_FOUND The OldInterface on the handle was not found
872 On EFI_INVALID_PARAMETER One of the parameters has an invalid value
880 CoreUninstallProtocolInterface (
881 IN EFI_HANDLE UserHandle
,
882 IN EFI_GUID
*Protocol
,
889 Uninstalls all instances of a protocol:interfacer from a handle.
890 If the last protocol interface is remove from the handle, the
895 UserHandle - The handle to remove the protocol handler from
897 Protocol - The protocol, of protocol:interface, to remove
899 Interface - The interface, of protocol:interface, to remove
903 EFI_INVALID_PARAMETER - Protocol is NULL.
905 EFI_SUCCESS - Protocol interface successfully uninstalled.
914 IN EFI_HANDLE UserHandle
,
915 IN EFI_GUID
*Protocol
,
922 Queries a handle to determine if it supports a specified protocol.
926 UserHandle - The handle being queried.
928 Protocol - The published unique identifier of the protocol.
930 Interface - Supplies the address where a pointer to the corresponding Protocol
931 Interface is returned.
935 The requested protocol interface for the handle
944 IN EFI_HANDLE UserHandle
,
945 IN EFI_GUID
*Protocol
,
946 OUT VOID
**Interface OPTIONAL
,
947 IN EFI_HANDLE ImageHandle
,
948 IN EFI_HANDLE ControllerHandle
,
955 Locates the installed protocol handler for the handle, and
956 invokes it to obtain the protocol interface. Usage information
957 is registered in the protocol data base.
961 UserHandle - The handle to obtain the protocol interface on
963 Protocol - The ID of the protocol
965 Interface - The location to return the protocol interface
967 ImageHandle - The handle of the Image that is opening the protocol interface
968 specified by Protocol and Interface.
970 ControllerHandle - The controller handle that is requiring this interface.
972 Attributes - The open mode of the protocol interface specified by Handle
977 EFI_INVALID_PARAMETER - Protocol is NULL.
979 EFI_SUCCESS - Get the protocol interface.
987 CoreOpenProtocolInformation (
988 IN EFI_HANDLE UserHandle
,
989 IN EFI_GUID
*Protocol
,
990 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
**EntryBuffer
,
991 OUT UINTN
*EntryCount
997 Return information about Opened protocols in the system
1001 UserHandle - The handle to close the protocol interface on
1003 Protocol - The ID of the protocol
1005 EntryBuffer - A pointer to a buffer of open protocol information in the form of
1006 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
1008 EntryCount - Number of EntryBuffer entries
1020 IN EFI_HANDLE UserHandle
,
1021 IN EFI_GUID
*Protocol
,
1022 IN EFI_HANDLE ImageHandle
,
1023 IN EFI_HANDLE ControllerHandle
1027 Routine Description:
1033 UserHandle - The handle to close the protocol interface on
1035 Protocol - The ID of the protocol
1037 ImageHandle - The user of the protocol to close
1039 ControllerHandle - The user of the protocol to close
1043 EFI_INVALID_PARAMETER - Protocol is NULL.
1051 CoreProtocolsPerHandle (
1052 IN EFI_HANDLE UserHandle
,
1053 OUT EFI_GUID
***ProtocolBuffer
,
1054 OUT UINTN
*ProtocolBufferCount
1058 Routine Description:
1060 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
1065 UserHandle - The handle from which to retrieve the list of protocol interface
1068 ProtocolBuffer - A pointer to the list of protocol interface GUID pointers that are
1069 installed on Handle.
1071 ProtocolBufferCount - A pointer to the number of GUID pointers present in
1075 EFI_SUCCESS - The list of protocol interface GUIDs installed on Handle was returned in
1076 ProtocolBuffer. The number of protocol interface GUIDs was
1077 returned in ProtocolBufferCount.
1078 EFI_INVALID_PARAMETER - Handle is NULL.
1079 EFI_INVALID_PARAMETER - Handle is not a valid EFI_HANDLE.
1080 EFI_INVALID_PARAMETER - ProtocolBuffer is NULL.
1081 EFI_INVALID_PARAMETER - ProtocolBufferCount is NULL.
1082 EFI_OUT_OF_RESOURCES - There is not enough pool memory to store the results.
1090 CoreRegisterProtocolNotify (
1091 IN EFI_GUID
*Protocol
,
1093 OUT VOID
**Registration
1097 Routine Description:
1099 Add a new protocol notification record for the request protocol.
1103 Protocol - The requested protocol to add the notify registration
1105 Event - The event to signal
1107 Registration - Returns the registration record
1112 EFI_INVALID_PARAMETER - Invalid parameter
1114 EFI_SUCCESS - Successfully returned the registration record that has been added
1123 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1124 IN EFI_GUID
*Protocol OPTIONAL
,
1125 IN VOID
*SearchKey OPTIONAL
,
1126 IN OUT UINTN
*BufferSize
,
1127 OUT EFI_HANDLE
*Buffer
1131 Routine Description:
1133 Locates the requested handle(s) and returns them in Buffer.
1137 SearchType - The type of search to perform to locate the handles
1139 Protocol - The protocol to search for
1141 SearchKey - Dependant on SearchType
1143 BufferSize - On input the size of Buffer. On output the
1144 size of data returned.
1146 Buffer - The buffer to return the results in
1151 EFI_BUFFER_TOO_SMALL - Buffer too small, required buffer size is returned in BufferSize.
1153 EFI_INVALID_PARAMETER - Invalid parameter
1155 EFI_SUCCESS - Successfully found the requested handle(s) and returns them in Buffer.
1163 CoreLocateDevicePath (
1164 IN EFI_GUID
*Protocol
,
1165 IN OUT EFI_DEVICE_PATH_PROTOCOL
**FilePath
,
1166 OUT EFI_HANDLE
*Device
1170 Routine Description:
1172 Locates the handle to a device on the device path that supports the specified protocol.
1176 Protocol - The protocol to search for.
1177 FilePath - On input, a pointer to a pointer to the device path. On output, the device
1178 path pointer is modified to point to the remaining part of the devicepath.
1179 Device - A pointer to the returned device handle.
1183 EFI_SUCCESS - The resulting handle was returned.
1184 EFI_NOT_FOUND - No handles matched the search.
1185 EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
1193 CoreLocateHandleBuffer (
1194 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
1195 IN EFI_GUID
*Protocol OPTIONAL
,
1196 IN VOID
*SearchKey OPTIONAL
,
1197 IN OUT UINTN
*NumberHandles
,
1198 OUT EFI_HANDLE
**Buffer
1202 Routine Description:
1204 Function returns an array of handles that support the requested protocol
1205 in a buffer allocated from pool. This is a version of CoreLocateHandle()
1206 that allocates a buffer for the caller.
1210 SearchType - Specifies which handle(s) are to be returned.
1211 Protocol - Provides the protocol to search by.
1212 This parameter is only valid for SearchType ByProtocol.
1213 SearchKey - Supplies the search key depending on the SearchType.
1214 NumberHandles - The number of handles returned in Buffer.
1215 Buffer - A pointer to the buffer to return the requested array of
1216 handles that support Protocol.
1220 EFI_SUCCESS - The result array of handles was returned.
1221 EFI_NOT_FOUND - No handles match the search.
1222 EFI_OUT_OF_RESOURCES - There is not enough pool memory to store the matching results.
1223 EFI_INVALID_PARAMETER - Invalid parameter
1231 CoreLocateProtocol (
1232 IN EFI_GUID
*Protocol
,
1233 IN VOID
*Registration OPTIONAL
,
1234 OUT VOID
**Interface
1238 Routine Description:
1240 Return the first Protocol Interface that matches the Protocol GUID. If
1241 Registration is pasased in return a Protocol Instance that was just add
1242 to the system. If Retistration is NULL return the first Protocol Interface
1247 Protocol - The protocol to search for
1249 Registration - Optional Registration Key returned from RegisterProtocolNotify()
1251 Interface - Return the Protocol interface (instance).
1255 EFI_SUCCESS - If a valid Interface is returned
1257 EFI_INVALID_PARAMETER - Invalid parameter
1259 EFI_NOT_FOUND - Protocol interface not found
1265 CoreGetHandleDatabaseKey (
1270 Routine Description:
1272 return handle database key.
1280 Handle database key.
1286 CoreConnectHandlesByKey (
1291 Routine Description:
1293 Go connect any handles that were created or modified while a image executed.
1297 Key - The Key to show that the handle has been created/modified
1308 CoreConnectController (
1309 IN EFI_HANDLE ControllerHandle
,
1310 IN EFI_HANDLE
*DriverImageHandle OPTIONAL
,
1311 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
,
1312 IN BOOLEAN Recursive
1316 Routine Description:
1318 Connects one or more drivers to a controller.
1322 ControllerHandle - Handle of the controller to be connected.
1324 DriverImageHandle - DriverImageHandle A pointer to an ordered list of driver image handles.
1326 RemainingDevicePath - RemainingDevicePath A pointer to the device path that specifies a child of the
1327 controller specified by ControllerHandle.
1329 Recursive - - Whether the function would be called recursively or not.
1341 CoreDisconnectController (
1342 IN EFI_HANDLE ControllerHandle
,
1343 IN EFI_HANDLE DriverImageHandle OPTIONAL
,
1344 IN EFI_HANDLE ChildHandle OPTIONAL
1348 Routine Description:
1350 Disonnects a controller from a driver
1354 ControllerHandle - ControllerHandle The handle of the controller from which driver(s)
1355 are to be disconnected.
1356 DriverImageHandle - DriverImageHandle The driver to disconnect from ControllerHandle.
1357 ChildHandle - ChildHandle The handle of the child to destroy.
1361 EFI_SUCCESS - One or more drivers were disconnected from the controller.
1362 EFI_SUCCESS - On entry, no drivers are managing ControllerHandle.
1363 EFI_SUCCESS - DriverImageHandle is not NULL, and on entry DriverImageHandle is not managing ControllerHandle.
1364 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
1365 EFI_INVALID_PARAMETER - DriverImageHandle is not NULL, and it is not a valid EFI_HANDLE.
1366 EFI_INVALID_PARAMETER - ChildHandle is not NULL, and it is not a valid EFI_HANDLE.
1367 EFI_OUT_OF_RESOURCES - There are not enough resources available to disconnect any drivers from ControllerHandle.
1368 EFI_DEVICE_ERROR - The controller could not be disconnected because of a device error.
1377 IN EFI_ALLOCATE_TYPE Type
,
1378 IN EFI_MEMORY_TYPE MemoryType
,
1379 IN UINTN NumberOfPages
,
1380 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
1384 Routine Description:
1386 Allocates pages from the memory map.
1390 Type - The type of allocation to perform
1392 MemoryType - The type of memory to turn the allocated pages into
1394 NumberOfPages - The number of pages to allocate
1396 Memory - A pointer to receive the base allocated memory address
1400 Status. On success, Memory is filled in with the base address allocated
1402 EFI_INVALID_PARAMETER - Parameters violate checking rules defined in spec.
1404 EFI_NOT_FOUND - Could not allocate pages match the requirement.
1406 EFI_OUT_OF_RESOURCES - No enough pages to allocate.
1408 EFI_SUCCESS - Pages successfully allocated.
1417 IN EFI_PHYSICAL_ADDRESS Memory
,
1418 IN UINTN NumberOfPages
1422 Routine Description:
1424 Frees previous allocated pages.
1428 Memory - Base address of memory being freed
1430 NumberOfPages - The number of pages to free
1434 EFI_NOT_FOUND - Could not find the entry that covers the range
1436 EFI_INVALID_PARAMETER - Address not aligned
1438 EFI_SUCCESS -Pages successfully freed.
1447 IN OUT UINTN
*MemoryMapSize
,
1448 IN OUT EFI_MEMORY_DESCRIPTOR
*Desc
,
1450 OUT UINTN
*DescriptorSize
,
1451 OUT UINT32
*DescriptorVersion
1455 Routine Description:
1457 Returns the current memory map.
1461 MemoryMapSize - On input the buffer size of MemoryMap allocated by caller
1462 On output the required buffer size to contain the memory map
1464 Desc - The buffer to return the current memory map
1466 MapKey - The address to return the current map key
1468 DescriptorSize - The size in bytes for an individual EFI_MEMORY_DESCRIPTOR
1470 DescriptorVersion - The version number associated with the EFI_MEMORY_DESCRIPTOR
1474 EFI_SUCCESS The current memory map was returned successfully
1476 EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small
1478 EFI_INVALID_PARAMETER One of the parameters has an invalid value
1487 IN EFI_MEMORY_TYPE PoolType
,
1493 Routine Description:
1495 Allocate pool of a particular type.
1499 PoolType - Type of pool to allocate
1501 Size - The amount of pool to allocate
1503 Buffer - The address to return a pointer to the allocated pool
1507 EFI_INVALID_PARAMETER - PoolType not valid
1509 EFI_OUT_OF_RESOURCES - Size exceeds max pool size or allocation failed.
1511 EFI_SUCCESS - Pool successfully allocated.
1524 Routine Description:
1530 Buffer - The allocated pool entry to free
1534 EFI_INVALID_PARAMETER - Buffer is not a valid value.
1536 EFI_SUCCESS - Pool successfully freed.
1545 IN BOOLEAN BootPolicy
,
1546 IN EFI_HANDLE ParentImageHandle
,
1547 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
1548 IN VOID
*SourceBuffer OPTIONAL
,
1549 IN UINTN SourceSize
,
1550 OUT EFI_HANDLE
*ImageHandle
1554 Routine Description:
1556 Loads an EFI image into memory and returns a handle to the image.
1560 BootPolicy - If TRUE, indicates that the request originates from the boot manager,
1561 and that the boot manager is attempting to load FilePath as a boot selection.
1562 ParentImageHandle - The caller's image handle.
1563 FilePath - The specific file path from which the image is loaded.
1564 SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
1565 the image to be loaded.
1566 SourceSize - The size in bytes of SourceBuffer.
1567 ImageHandle - Pointer to the returned image handle that is created when the image
1568 is successfully loaded.
1572 EFI_SUCCESS - The image was loaded into memory.
1573 EFI_NOT_FOUND - The FilePath was not found.
1574 EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
1575 EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
1576 parsed to locate the proper protocol for loading the file.
1577 EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
1585 IN EFI_HANDLE ImageHandle
1589 Routine Description:
1591 Unload the specified image.
1595 ImageHandle - The specified image handle.
1599 EFI_INVALID_PARAMETER - Image handle is NULL.
1601 EFI_UNSUPPORTED - Attempt to unload an unsupported image.
1603 EFI_SUCCESS - Image successfully unloaded.
1612 IN EFI_HANDLE ImageHandle
,
1613 OUT UINTN
*ExitDataSize
,
1614 OUT CHAR16
**ExitData OPTIONAL
1618 Routine Description:
1620 Transfer control to a loaded image's entry point.
1624 ImageHandle - Handle of image to be started.
1626 ExitDataSize - Pointer of the size to ExitData
1628 ExitData - Pointer to a pointer to a data buffer that includes a Null-terminated
1629 Unicode string, optionally followed by additional binary data. The string
1630 is a description that the caller may use to further indicate the reason for
1635 EFI_INVALID_PARAMETER - Invalid parameter
1637 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
1639 EFI_SUCCESS - Successfully transfer control to the image's entry point.
1648 IN EFI_HANDLE ImageHandle
,
1649 IN EFI_STATUS Status
,
1650 IN UINTN ExitDataSize
,
1651 IN CHAR16
*ExitData OPTIONAL
1655 Routine Description:
1657 Terminates the currently loaded EFI image and returns control to boot services.
1661 ImageHandle - Handle that identifies the image. This parameter is passed to the image
1663 Status - The image's exit code.
1664 ExitDataSize - The size, in bytes, of ExitData. Ignored if ExitStatus is
1666 ExitData - Pointer to a data buffer that includes a Null-terminated Unicode string,
1667 optionally followed by additional binary data. The string is a
1668 description that the caller may use to further indicate the reason for
1673 EFI_INVALID_PARAMETER - Image handle is NULL or it is not current image.
1675 EFI_SUCCESS - Successfully terminates the currently loaded EFI image.
1677 EFI_ACCESS_DENIED - Should never reach there.
1687 IN EFI_TPL NotifyTpl
,
1688 IN EFI_EVENT_NOTIFY NotifyFunction
,
1689 IN VOID
*NotifyContext
,
1690 OUT EFI_EVENT
*pEvent
1694 Routine Description:
1696 Creates a general-purpose event structure
1700 Type - The type of event to create and its mode and attributes
1701 NotifyTpl - The task priority level of event notifications
1702 NotifyFunction - Pointer to the event's notification function
1703 NotifyContext - Pointer to the notification function's context; corresponds to
1704 parameter "Context" in the notification function
1705 pEvent - Pointer to the newly created event if the call succeeds; undefined otherwise
1709 EFI_SUCCESS - The event structure was created
1710 EFI_INVALID_PARAMETER - One of the parameters has an invalid value
1711 EFI_OUT_OF_RESOURCES - The event could not be allocated
1721 IN EFI_TPL NotifyTpl
,
1722 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1723 IN CONST VOID
*NotifyContext
, OPTIONAL
1724 IN CONST EFI_GUID
*EventGroup
, OPTIONAL
1725 OUT EFI_EVENT
*Event
1729 Routine Description:
1730 Creates a general-purpose event structure
1733 Type - The type of event to create and its mode and attributes
1734 NotifyTpl - The task priority level of event notifications
1735 NotifyFunction - Pointer to the events notification function
1736 NotifyContext - Pointer to the notification functions context; corresponds to
1737 parameter "Context" in the notification function
1738 EventGrout - GUID for EventGroup if NULL act the same as gBS->CreateEvent().
1739 Event - Pointer to the newly created event if the call succeeds; undefined otherwise
1742 EFI_SUCCESS - The event structure was created
1743 EFI_INVALID_PARAMETER - One of the parameters has an invalid value
1744 EFI_OUT_OF_RESOURCES - The event could not be allocated
1754 IN EFI_TIMER_DELAY Type
,
1755 IN UINT64 TriggerTime
1759 Routine Description:
1761 Sets the type of timer and the trigger time for a timer event.
1765 UserEvent - The timer event that is to be signaled at the specified time
1766 Type - The type of time that is specified in TriggerTime
1767 TriggerTime - The number of 100ns units until the timer expires
1771 EFI_SUCCESS - The event has been set to be signaled at the requested time
1772 EFI_INVALID_PARAMETER - Event or Type is not valid
1785 Routine Description:
1787 Signals the event. Queues the event to be notified if needed
1791 Event - The event to signal
1795 EFI_INVALID_PARAMETER - Parameters are not valid.
1797 EFI_SUCCESS - The event was signaled.
1806 IN UINTN NumberOfEvents
,
1807 IN EFI_EVENT
*UserEvents
,
1808 OUT UINTN
*UserIndex
1812 Routine Description:
1814 Stops execution until an event is signaled.
1818 NumberOfEvents - The number of events in the UserEvents array
1819 UserEvents - An array of EFI_EVENT
1820 UserIndex - Pointer to the index of the event which satisfied the wait condition
1824 EFI_SUCCESS - The event indicated by Index was signaled.
1825 EFI_INVALID_PARAMETER - The event indicated by Index has a notification function or
1826 Event was not a valid type
1827 EFI_UNSUPPORTED - The current TPL is not TPL_APPLICATION
1840 Routine Description:
1842 Closes an event and frees the event structure.
1846 UserEvent - Event to close
1850 EFI_INVALID_PARAMETER - Parameters are not valid.
1852 EFI_SUCCESS - The event has been closed
1865 Routine Description:
1867 Check the status of an event
1871 UserEvent - The event to check
1875 EFI_SUCCESS - The event is in the signaled state
1876 EFI_NOT_READY - The event is not in the signaled state
1877 EFI_INVALID_PARAMETER - Event is of type EVT_NOTIFY_SIGNAL
1883 CoreAddMemorySpace (
1884 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1885 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1887 IN UINT64 Capabilities
1891 Routine Description:
1893 Add a segment of memory space to GCD map and add all available pages in this segment
1894 as memory descriptors.
1898 GcdMemoryType - Memory type of the segment.
1900 BaseAddress - Base address of the segment.
1902 Length - Length of the segment.
1904 Capabilities - alterable attributes of the segment.
1908 EFI_SUCCESS - Merged this segment into GCD map.
1914 CoreAllocateMemorySpace (
1915 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
1916 IN EFI_GCD_MEMORY_TYPE GcdMemoryType
,
1919 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
1920 IN EFI_HANDLE ImageHandle
,
1921 IN EFI_HANDLE DeviceHandle OPTIONAL
1925 Routine Description:
1927 Allocate memory space on GCD map.
1931 GcdAllocateType - The type of allocate operation
1933 GcdMemoryType - The desired memory type
1935 Alignment - Align with 2^Alignment
1937 Length - Length to allocate
1939 BaseAddress - Base address to allocate
1941 ImageHandle - The image handle consume the allocated space.
1943 DeviceHandle - The device handle consume the allocated space.
1947 EFI_INVALID_PARAMETER - Invalid parameter.
1949 EFI_NOT_FOUND - No descriptor contains the desired space.
1951 EFI_SUCCESS - Memory space successfully allocated.
1957 CoreFreeMemorySpace (
1958 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1963 Routine Description:Routine Description:
1965 Free a segment of memory space in GCD map.
1969 BaseAddress - Base address of the segment.
1971 Length - Length of the segment.
1975 EFI_SUCCESS - Space successfully freed.
1981 CoreRemoveMemorySpace (
1982 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
1987 Routine Description:Routine Description:
1989 Remove a segment of memory space in GCD map.
1993 BaseAddress - Base address of the segment.
1995 Length - Length of the segment.
1999 EFI_SUCCESS - Successfully a segment of memory space.
2005 CoreGetMemorySpaceDescriptor (
2006 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2007 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*Descriptor
2011 Routine Description:
2013 Search all entries in GCD map which contains specified segment and build it to a descriptor.
2017 BaseAddress - Specified start address
2019 Descriptor - Specified length
2023 EFI_INVALID_PARAMETER - Invalid parameter
2025 EFI_SUCCESS - Successfully get memory space descriptor.
2031 CoreSetMemorySpaceAttributes (
2032 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2034 IN UINT64 Attributes
2038 Routine Description:
2040 Set memory space with specified attributes.
2044 BaseAddress - Specified start address
2046 Length - Specified length
2048 Attributes - Specified attributes
2052 EFI_SUCCESS - Successfully set attribute of a segment of memory space.
2058 CoreGetMemorySpaceMap (
2059 OUT UINTN
*NumberOfDescriptors
,
2060 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR
**MemorySpaceMap
2064 Routine Description:
2066 Transer all entries of GCD memory map into memory descriptors and pass to caller.
2070 NumberOfDescriptors - Number of descriptors.
2072 MemorySpaceMap - Descriptor array
2076 EFI_INVALID_PARAMETER - Invalid parameter
2078 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
2080 EFI_SUCCESS - Successfully get memory space map.
2087 IN EFI_GCD_IO_TYPE GcdIoType
,
2088 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2093 Routine Description:
2095 Add a segment of IO space to GCD map.
2099 GcdIoType - IO type of the segment.
2101 BaseAddress - Base address of the segment.
2103 Length - Length of the segment.
2107 EFI_SUCCESS - Merged this segment into GCD map.
2113 CoreAllocateIoSpace (
2114 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType
,
2115 IN EFI_GCD_IO_TYPE GcdIoType
,
2118 IN OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
2119 IN EFI_HANDLE ImageHandle
,
2120 IN EFI_HANDLE DeviceHandle OPTIONAL
2124 Routine Description:
2126 Allocate IO space on GCD map.
2130 GcdAllocateType - The type of allocate operation
2132 GcdIoType - The desired IO type
2134 Alignment - Align with 2^Alignment
2136 Length - Length to allocate
2138 BaseAddress - Base address to allocate
2140 ImageHandle - The image handle consume the allocated space.
2142 DeviceHandle - The device handle consume the allocated space.
2146 EFI_INVALID_PARAMETER - Invalid parameter.
2148 EFI_NOT_FOUND - No descriptor contains the desired space.
2150 EFI_SUCCESS - IO space successfully allocated.
2157 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2162 Routine Description:Routine Description:
2164 Free a segment of IO space in GCD map.
2168 BaseAddress - Base address of the segment.
2170 Length - Length of the segment.
2174 EFI_SUCCESS - Space successfully freed.
2181 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2186 Routine Description:Routine Description:
2188 Remove a segment of IO space in GCD map.
2192 BaseAddress - Base address of the segment.
2194 Length - Length of the segment.
2198 EFI_SUCCESS - Successfully removed a segment of IO space.
2204 CoreGetIoSpaceDescriptor (
2205 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
2206 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
*Descriptor
2210 Routine Description:
2212 Search all entries in GCD map which contains specified segment and build it to a descriptor.
2216 BaseAddress - Specified start address
2218 Descriptor - Specified length
2222 EFI_INVALID_PARAMETER - Descriptor is NULL.
2224 EFI_SUCCESS - Successfully get the IO space descriptor.
2231 OUT UINTN
*NumberOfDescriptors
,
2232 OUT EFI_GCD_IO_SPACE_DESCRIPTOR
**IoSpaceMap
2236 Routine Description:
2238 Transer all entries of GCD IO map into IO descriptors and pass to caller.
2242 NumberOfDescriptors - Number of descriptors.
2244 IoSpaceMap - Descriptor array
2248 EFI_INVALID_PARAMETER - Invalid parameter
2250 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
2252 EFI_SUCCESS - Successfully get IO space map.
2265 Routine Description:
2267 This is the main Dispatcher for DXE and it exits when there are no more
2268 drivers to run. Drain the mScheduledQueue and load and start a PE
2269 image for each driver. Search the mDiscoveredList to see if any driver can
2270 be placed on the mScheduledQueue. If no drivers are placed on the
2271 mScheduledQueue exit the function. On exit it is assumed the Bds()
2272 will be called, and when the Bds() exits the Dispatcher will be called
2281 EFI_ALREADY_STARTED - The DXE Dispatcher is already running
2283 EFI_NOT_FOUND - No DXE Drivers were dispatched
2285 EFI_SUCCESS - One or more DXE Drivers were dispatched
2293 IN EFI_HANDLE FirmwareVolumeHandle
,
2294 IN EFI_GUID
*DriverName
2298 Routine Description:
2300 Check every driver and locate a matching one. If the driver is found, the Unrequested
2301 state flag is cleared.
2305 FirmwareVolumeHandle - The handle of the Firmware Volume that contains the firmware
2306 file specified by DriverName.
2308 DriverName - The Driver name to put in the Dependent state.
2312 EFI_SUCCESS - The DriverName was found and it's SOR bit was cleared
2314 EFI_NOT_FOUND - The DriverName does not exist or it's SOR bit was not set.
2323 IN EFI_HANDLE FirmwareVolumeHandle
,
2324 IN EFI_GUID
*DriverName
2328 Routine Description:
2330 Convert a driver from the Untrused back to the Scheduled state
2334 FirmwareVolumeHandle - The handle of the Firmware Volume that contains the firmware
2335 file specified by DriverName.
2337 DriverName - The Driver name to put in the Scheduled state
2341 EFI_SUCCESS - The file was found in the untrusted state, and it was promoted
2342 to the trusted state.
2344 EFI_NOT_FOUND - The file was not found in the untrusted state.
2351 IN OUT EFI_STATUS
*Status
,
2352 IN OUT VOID
**Buffer
,
2357 Routine Description:
2359 Helper function called as part of the code needed
2360 to allocate the proper sized buffer for various
2365 Status - Current status
2367 Buffer - Current allocated buffer, or NULL
2369 BufferSize - Current buffer size needed
2373 TRUE - if the buffer was reallocated and the caller
2374 should try the API again.
2376 FALSE - buffer could not be allocated and the caller
2377 should not try the API again.
2385 IN EFI_HANDLE ImageHandle
,
2386 IN EFI_SYSTEM_TABLE
*SystemTable
2390 Routine Description:
2391 This routine is the driver initialization entry point. It initializes the
2392 libraries, and registers two notification functions. These notification
2393 functions are responsible for building the FV stack dynamically.
2396 ImageHandle - The image handle.
2397 SystemTable - The system table.
2400 EFI_SUCCESS - Function successfully returned.
2407 InitializeSectionExtraction (
2408 IN EFI_HANDLE ImageHandle
,
2409 IN EFI_SYSTEM_TABLE
*SystemTable
2413 Routine Description:
2414 Entry point of the section extraction code. Initializes an instance of the
2415 section extraction interface and installs it on a new handle.
2418 ImageHandle EFI_HANDLE: A handle for the image that is initializing this driver
2419 SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table
2422 EFI_SUCCESS: Driver initialized successfully
2423 EFI_OUT_OF_RESOURCES: Could not allocate needed resources
2429 CoreProcessFirmwareVolume (
2432 OUT EFI_HANDLE
*FVProtocolHandle
2436 Routine Description:
2437 This DXE service routine is used to process a firmware volume. In
2438 particular, it can be called by BDS to process a single firmware
2439 volume found in a capsule.
2442 FvHeader - pointer to a firmware volume header
2443 Size - the size of the buffer pointed to by FvHeader
2444 FVProtocolHandle - the handle on which a firmware volume protocol
2445 was produced for the firmware volume passed in.
2448 EFI_OUT_OF_RESOURCES - if an FVB could not be produced due to lack of
2450 EFI_VOLUME_CORRUPTED - if the volume was corrupted
2451 EFI_SUCCESS - a firmware volume protocol was produced for the
2458 //Functions used during debug buils
2461 CoreDisplayMissingArchProtocols (
2466 Routine Description:
2467 Displays Architectural protocols that were not loaded and are required for DXE core to function
2468 Only used in Debug Builds
2479 CoreDisplayDiscoveredNotDispatched (
2484 Routine Description:
2486 Traverse the discovered list for any drivers that were discovered but not loaded
2487 because the dependency experessions evaluated to false