|
TianoCore EDK2 master
|
#include "DxeMain.h"Go to the source code of this file.
Data Structures | |
| struct | FV_FILEPATH_DEVICE_PATH |
Variables | |
| LIST_ENTRY | mDiscoveredList = INITIALIZE_LIST_HEAD_VARIABLE (mDiscoveredList) |
| LIST_ENTRY | mScheduledQueue = INITIALIZE_LIST_HEAD_VARIABLE (mScheduledQueue) |
| LIST_ENTRY | mFvHandleList = INITIALIZE_LIST_HEAD_VARIABLE (mFvHandleList) |
| EFI_LOCK | mDispatcherLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_HIGH_LEVEL) |
| BOOLEAN | gDispatcherRunning = FALSE |
| EFI_EVENT | mFwVolEvent |
| VOID * | mFwVolEventRegistration |
| EFI_FV_FILETYPE | mDxeFileTypes [] |
| FV_FILEPATH_DEVICE_PATH | mFvDevicePath |
DXE Dispatcher.
Step #1 - When a FV protocol is added to the system every driver in the FV is added to the mDiscoveredList. The SOR, Before, and After Depex are pre-processed as drivers are added to the mDiscoveredList. If an Apriori file exists in the FV those drivers are addeded to the mScheduledQueue. The mFvHandleList is used to make sure a FV is only processed once.
Step #2 - Dispatch. Remove driver from the mScheduledQueue and load and start it. After mScheduledQueue is drained check the mDiscoveredList to see if any item has a Depex that is ready to be placed on the mScheduledQueue.
Step #3 - Adding to the mScheduledQueue requires that you process Before and After dependencies. This is done recursively as the call to add to the mScheduledQueue checks for Before and recursively adds all Befores. It then addes the item that was passed in and then processess the After dependecies by recursively calling the routine.
Dispatcher Rules: The rules for the dispatcher are in chapter 10 of the DXE CIS. Figure 10-3 is the state diagram for the DXE dispatcher
Depex - Dependency Expresion. SOR - Schedule On Request - Don't schedule if this bit is set.
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Dispatcher.c.
Enter critical section by gaining lock on mDispatcherLock.
Definition at line 203 of file Dispatcher.c.
| EFI_STATUS CoreAddToDriverList | ( | IN EFI_FIRMWARE_VOLUME2_PROTOCOL * | Fv, |
| IN EFI_HANDLE | FvHandle, | ||
| IN EFI_GUID * | DriverName, | ||
| IN EFI_FV_FILETYPE | Type | ||
| ) |
Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry, and initilize any state variables. Read the Depex from the FV and store it in DriverEntry. Pre-process the Depex to set the SOR, Before and After state. The Discovered list is never free'ed and contains booleans that represent the other possible DXE driver states.
| Fv | Fv protocol, needed to read Depex info out of FLASH. |
| FvHandle | Handle for Fv, needed in the EFI_CORE_DRIVER_ENTRY so that the PE image can be read out of the FV at a later time. |
| DriverName | Name of driver to add to mDiscoveredList. |
| Type | Fv File Type of file to add to mDiscoveredList. |
| EFI_SUCCESS | If driver was added to the mDiscoveredList. |
| EFI_ALREADY_STARTED | The driver has already been started. Only one DriverName may be active in the system at any one time. |
Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry, and initilize any state variables. Read the Depex from the FV and store it in DriverEntry. Pre-process the Depex to set the SOR, Before and After state. The Discovered list is never free'ed and contains booleans that represent the other possible DXE driver states.
| Fv | Fv protocol, needed to read Depex info out of FLASH. |
| FvHandle | Handle for Fv, needed in the EFI_CORE_DRIVER_ENTRY so that the PE image can be read out of the FV at a later time. |
| DriverName | Name of driver to add to mDiscoveredList. |
| Type | Fv File Type of file to add to mDiscoveredList. |
| EFI_SUCCESS | If driver was added to the mDiscoveredList. |
| EFI_ALREADY_STARTED | The driver has already been started. Only one DriverName may be active in the system at any one time. |
| EFI_OUT_OF_RESOURCES | If memory could not be allocated for the DriverEntry. |
Definition at line 860 of file Dispatcher.c.
| EFI_STATUS EFIAPI CoreDispatcher | ( | VOID | ) |
This is the main Dispatcher for DXE and it exits when there are no more drivers to run. Drain the mScheduledQueue and load and start a PE image for each driver. Search the mDiscoveredList to see if any driver can be placed on the mScheduledQueue. If no drivers are placed on the mScheduledQueue exit the function. On exit it is assumed the Bds() will be called, and when the Bds() exits the Dispatcher will be called again.
| EFI_ALREADY_STARTED | The DXE Dispatcher is already running |
| EFI_NOT_FOUND | No DXE Drivers were dispatched |
| EFI_SUCCESS | One or more DXE Drivers were dispatched |
Definition at line 400 of file Dispatcher.c.
Traverse the discovered list for any drivers that were discovered but not loaded because the dependency experessions evaluated to false.
Definition at line 1481 of file Dispatcher.c.
| EFI_DEVICE_PATH_PROTOCOL * CoreFvToDevicePath | ( | IN EFI_FIRMWARE_VOLUME2_PROTOCOL * | Fv, |
| IN EFI_HANDLE | FvHandle, | ||
| IN EFI_GUID * | DriverName | ||
| ) |
Convert FvHandle and DriverName into an EFI device path
| Fv | Fv protocol, needed to read Depex info out of FLASH. |
| FvHandle | Handle for Fv, needed in the EFI_CORE_DRIVER_ENTRY so that the PE image can be read out of the FV at a later time. |
| DriverName | Name of driver to add to mDiscoveredList. |
Definition at line 805 of file Dispatcher.c.
Event notification that is fired every time a FV dispatch protocol is added. More than one protocol may have been added when this event is fired, so you must loop on CoreLocateHandle () to see how many protocols were added and do the following to each FV: If the Fv has already been processed, skip it. If the Fv has not been processed then mark it as being processed, as we are about to process it. Read the Fv and add any driver in the Fv to the mDiscoveredList.The mDiscoveredList is never free'ed and contains variables that define the other states the DXE driver transitions to.. While you are at it read the A Priori file into memory. Place drivers in the A Priori list onto the mScheduledQueue.
| Event | The Event that is being processed, not used. |
| Context | Event Context, not used. |
Definition at line 1209 of file Dispatcher.c.
| EFI_STATUS CoreGetDepexSectionAndPreProccess | ( | IN EFI_CORE_DRIVER_ENTRY * | DriverEntry | ) |
Read Depex and pre-process the Depex for Before and After. If Section Extraction protocol returns an error via ReadSection defer the reading of the Depex.
| DriverEntry | Driver to work on. |
| EFI_SUCCESS | Depex read and preprossesed |
| EFI_PROTOCOL_ERROR | The section extraction protocol returned an error and Depex reading needs to be retried. |
| Error | DEPEX not found. |
Definition at line 235 of file Dispatcher.c.
Initialize the dispatcher. Initialize the notification function that runs when an FV2 protocol is added to the system.
Definition at line 1454 of file Dispatcher.c.
| VOID CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter | ( | IN EFI_CORE_DRIVER_ENTRY * | InsertedDriverEntry | ) |
Insert InsertedDriverEntry onto the mScheduledQueue. To do this you must add any driver with a before dependency on InsertedDriverEntry first. You do this by recursively calling this routine. After all the Befores are processed you can add InsertedDriverEntry to the mScheduledQueue. Then you can add any driver with an After dependency on InsertedDriverEntry by recursively calling this routine.
| InsertedDriverEntry | The driver to insert on the ScheduledLink Queue |
Definition at line 593 of file Dispatcher.c.
| EFI_STATUS CoreProcessFvImageFile | ( | IN EFI_FIRMWARE_VOLUME2_PROTOCOL * | Fv, |
| IN EFI_HANDLE | FvHandle, | ||
| IN EFI_GUID * | FileName | ||
| ) |
Get Fv image(s) from the FV through file name, and produce FVB protocol for every Fv image(s).
| Fv | The FIRMWARE_VOLUME protocol installed on the FV. |
| FvHandle | The handle which FVB protocol installed on. |
| FileName | The file name guid specified. |
| EFI_OUT_OF_RESOURCES | No enough memory or other resource. |
| EFI_SUCCESS | Function successfully returned. |
Definition at line 1014 of file Dispatcher.c.
Exit critical section by releasing lock on mDispatcherLock.
Definition at line 215 of file Dispatcher.c.
| EFI_STATUS EFIAPI CoreSchedule | ( | IN EFI_HANDLE | FirmwareVolumeHandle, |
| IN EFI_GUID * | DriverName | ||
| ) |
Check every driver and locate a matching one. If the driver is found, the Unrequested state flag is cleared.
| FirmwareVolumeHandle | The handle of the Firmware Volume that contains the firmware file specified by DriverName. |
| DriverName | The Driver name to put in the Dependent state. |
| EFI_SUCCESS | The DriverName was found and it's SOR bit was cleared |
| EFI_NOT_FOUND | The DriverName does not exist or it's SOR bit was not set. |
Definition at line 301 of file Dispatcher.c.
| EFI_STATUS EFIAPI CoreTrust | ( | IN EFI_HANDLE | FirmwareVolumeHandle, |
| IN EFI_GUID * | DriverName | ||
| ) |
Convert a driver from the Untrused back to the Scheduled state.
| FirmwareVolumeHandle | The handle of the Firmware Volume that contains the firmware file specified by DriverName. |
| DriverName | The Driver name to put in the Scheduled state |
| EFI_SUCCESS | The file was found in the untrusted state, and it was promoted to the trusted state. |
| EFI_NOT_FOUND | The file was not found in the untrusted state. |
Definition at line 351 of file Dispatcher.c.
Check if a FV Image type file (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) is described by a EFI_HOB_FIRMWARE_VOLUME2 Hob.
| FvNameGuid | The FV image guid specified. |
| DriverName | The driver guid specified. |
| TRUE | This file is found in a EFI_HOB_FIRMWARE_VOLUME2 Hob. |
| FALSE | Not found. |
Definition at line 913 of file Dispatcher.c.
| BOOLEAN FvHasBeenProcessed | ( | IN EFI_HANDLE | FvHandle | ) |
Return TRUE if the Fv has been processed, FALSE if not.
| FvHandle | The handle of a FV that's being tested |
| TRUE | Fv protocol on FvHandle has been processed |
| FALSE | Fv protocol on FvHandle has not yet been processed |
Definition at line 662 of file Dispatcher.c.
| KNOWN_HANDLE * FvIsBeingProcessed | ( | IN EFI_HANDLE | FvHandle | ) |
Remember that Fv protocol on FvHandle has had it's drivers placed on the mDiscoveredList. This fucntion adds entries on the mFvHandleList if new entry is different from one in mFvHandleList by checking FvImage Guid. Items are never removed/freed from the mFvHandleList.
| FvHandle | The handle of a FV that has been processed |
Definition at line 692 of file Dispatcher.c.
| BOOLEAN GetFvUsedSize | ( | IN EFI_FIRMWARE_VOLUME_HEADER * | FvHeader, |
| OUT UINT32 * | FvUsedSize, | ||
| OUT UINT8 * | EraseByte | ||
| ) |
Find USED_SIZE FV_EXT_TYPE entry in FV extension header and get the FV used size.
| [in] | FvHeader | Pointer to FV header. |
| [out] | FvUsedSize | Pointer to FV used size returned, only valid if USED_SIZE FV_EXT_TYPE entry is found. |
| [out] | EraseByte | Pointer to erase byte returned, only valid if USED_SIZE FV_EXT_TYPE entry is found. |
| TRUE | USED_SIZE FV_EXT_TYPE entry is found, FV used size and erase byte are returned. |
| FALSE | No USED_SIZE FV_EXT_TYPE entry found. |
Definition at line 953 of file Dispatcher.c.
| BOOLEAN gDispatcherRunning = FALSE |
Definition at line 61 of file Dispatcher.c.
| LIST_ENTRY mDiscoveredList = INITIALIZE_LIST_HEAD_VARIABLE (mDiscoveredList) |
Definition at line 40 of file Dispatcher.c.
| EFI_LOCK mDispatcherLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_HIGH_LEVEL) |
Definition at line 56 of file Dispatcher.c.
| EFI_FV_FILETYPE mDxeFileTypes[] |
Definition at line 72 of file Dispatcher.c.
| FV_FILEPATH_DEVICE_PATH mFvDevicePath |
Definition at line 85 of file Dispatcher.c.
| LIST_ENTRY mFvHandleList = INITIALIZE_LIST_HEAD_VARIABLE (mFvHandleList) |
Definition at line 51 of file Dispatcher.c.
| EFI_EVENT mFwVolEvent |
Definition at line 66 of file Dispatcher.c.
| VOID* mFwVolEventRegistration |
Definition at line 67 of file Dispatcher.c.
| LIST_ENTRY mScheduledQueue = INITIALIZE_LIST_HEAD_VARIABLE (mScheduledQueue) |
Definition at line 46 of file Dispatcher.c.