EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index
Data Structures | Defines | Functions | Variables

MdeModulePkg/Core/PiSmmCore/Dispatcher.c File Reference

#include "PiSmmCore.h"

Go to the source code of this file.

Data Structures

struct  KNOWN_HANDLE
struct  FV_FILEPATH_DEVICE_PATH

Defines

#define KNOWN_HANDLE_SIGNATURE   SIGNATURE_32('k','n','o','w')

Functions

VOID SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (IN EFI_SMM_DRIVER_ENTRY *InsertedDriverEntry)
EFI_STATUS CheckAndMarkFixLoadingMemoryUsageBitMap (IN EFI_PHYSICAL_ADDRESS ImageBase, IN UINTN ImageSize)
EFI_STATUS GetPeCoffImageFixLoadingAssignedAddress (IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
EFI_STATUS EFIAPI SmmLoadImage (IN OUT EFI_SMM_DRIVER_ENTRY *DriverEntry)
EFI_STATUS SmmPreProcessDepex (IN EFI_SMM_DRIVER_ENTRY *DriverEntry)
EFI_STATUS SmmGetDepexSectionAndPreProccess (IN EFI_SMM_DRIVER_ENTRY *DriverEntry)
EFI_STATUS SmmDispatcher (VOID)
BOOLEAN FvHasBeenProcessed (IN EFI_HANDLE FvHandle)
VOID FvIsBeingProcesssed (IN EFI_HANDLE FvHandle)
EFI_DEVICE_PATH_PROTOCOLSmmFvToDevicePath (IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv, IN EFI_HANDLE FvHandle, IN EFI_GUID *DriverName)
EFI_STATUS SmmAddToDriverList (IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv, IN EFI_HANDLE FvHandle, IN EFI_GUID *DriverName)
EFI_STATUS EFIAPI SmmDriverDispatchHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context, OPTIONAL IN OUT VOID *CommBuffer, OPTIONAL IN OUT UINTN *CommBufferSize OPTIONAL)
VOID SmmDisplayDiscoveredNotDispatched (VOID)

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)
BOOLEAN gDispatcherRunning = FALSE
BOOLEAN gRequestDispatch = FALSE
EFI_FV_FILETYPE mSmmFileTypes []
FV_FILEPATH_DEVICE_PATH mFvDevicePath
EFI_SECURITY_ARCH_PROTOCOLmSecurity = NULL
GLOBAL_REMOVE_IF_UNREFERENCED
UINT64
mSmmCodeMemoryRangeUsageBitMap = NULL

Detailed Description

SMM Driver Dispatcher.

Step #1 - When a FV protocol is added to the system every driver in the FV is added to the mDiscoveredList. The 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 similar to the DXE dispatcher.

The rules for DXE dispatcher are in chapter 10 of the DXE CIS. Figure 10-3 is the state diagram for the DXE dispatcher

Depex - Dependency Expresion.

Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file Dispatcher.c.


Define Documentation

#define KNOWN_HANDLE_SIGNATURE   SIGNATURE_32('k','n','o','w')

Definition at line 46 of file Dispatcher.c.


Function Documentation

EFI_STATUS CheckAndMarkFixLoadingMemoryUsageBitMap ( IN EFI_PHYSICAL_ADDRESS  ImageBase,
IN UINTN  ImageSize 
)

To check memory usage bit map array to figure out if the memory range in which the image will be loaded is available or not. If memory range is avaliable, the function will mark the correponding bits to 1 which indicates the memory range is used. The function is only invoked when load modules at fixed address feature is enabled.

Parameters:
ImageBaseThe base addres the image will be loaded at.
ImageSizeThe size of the image
Return values:
EFI_SUCCESSThe memory range the image will be loaded in is available
EFI_NOT_FOUNDThe memory range the image will be loaded in is not available

Definition at line 143 of file Dispatcher.c.

BOOLEAN FvHasBeenProcessed ( IN EFI_HANDLE  FvHandle)

Return TRUE if the Fv has been processed, FALSE if not.

Parameters:
FvHandleThe handle of a FV that's being tested
Return values:
TRUEFv protocol on FvHandle has been processed
FALSEFv protocol on FvHandle has not yet been processed

Definition at line 990 of file Dispatcher.c.

VOID FvIsBeingProcesssed ( 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. Items are never removed/freed from the mFvHandleList.

Parameters:
FvHandleThe handle of a FV that has been processed

Definition at line 1015 of file Dispatcher.c.

EFI_STATUS GetPeCoffImageFixLoadingAssignedAddress ( IN OUT PE_COFF_LOADER_IMAGE_CONTEXT ImageContext)

Get the fixed loadding address from image header assigned by build tool. This function only be called when Loading module at Fixed address feature enabled.

Parameters:
ImageContextPointer to the image context structure that describes the PE/COFF image that needs to be examined by this function.
Return values:
EFI_SUCCESSAn fixed loading address is assigned to this image by build tools .
EFI_NOT_FOUNDThe image has no assigned fixed loadding address.

Definition at line 213 of file Dispatcher.c.

EFI_STATUS SmmAddToDriverList ( IN EFI_FIRMWARE_VOLUME2_PROTOCOL Fv,
IN EFI_HANDLE  FvHandle,
IN EFI_GUID DriverName 
)

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 Before and After state. The Discovered list is never free'ed and contains booleans that represent the other possible SMM driver states.

Parameters:
FvFv protocol, needed to read Depex info out of FLASH.
FvHandleHandle for Fv, needed in the EFI_SMM_DRIVER_ENTRY so that the PE image can be read out of the FV at a later time.
DriverNameName of driver to add to mDiscoveredList.
Return values:
EFI_SUCCESSIf driver was added to the mDiscoveredList.
EFI_ALREADY_STARTEDThe driver has already been started. Only one DriverName may be active in the system at any one time.

Definition at line 1098 of file Dispatcher.c.

EFI_STATUS SmmDispatcher ( VOID  )

This is the main Dispatcher for SMM 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.

Return values:
EFI_SUCCESSAll of the SMM Drivers that could be dispatched have been run and the SMM Entry Point has been registered.
EFI_NOT_READYThe SMM Driver that registered the SMM Entry Point was just dispatched.
EFI_NOT_FOUNDThere are no SMM Drivers available to be dispatched.
EFI_ALREADY_STARTEDThe SMM Dispatcher is already running

Definition at line 758 of file Dispatcher.c.

VOID SmmDisplayDiscoveredNotDispatched ( VOID  )

Traverse the discovered list for any drivers that were discovered but not loaded because the dependency experessions evaluated to false.

Definition at line 1366 of file Dispatcher.c.

EFI_STATUS EFIAPI SmmDriverDispatchHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *  Context,
OPTIONAL IN OUT VOID *  CommBuffer,
OPTIONAL IN OUT UINTN *CommBufferSize  OPTIONAL 
)

This function is the main entry point for an SMM handler dispatch or communicate-based callback.

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 SmmLocateHandle () 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 SMM 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.

Parameters:
DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment.
CommBufferSizeThe size of the CommBuffer.
Returns:
Status Code

Definition at line 1154 of file Dispatcher.c.

EFI_DEVICE_PATH_PROTOCOL* SmmFvToDevicePath ( IN EFI_FIRMWARE_VOLUME2_PROTOCOL Fv,
IN EFI_HANDLE  FvHandle,
IN EFI_GUID DriverName 
)

Convert FvHandle and DriverName into an EFI device path

Parameters:
FvFv protocol, needed to read Depex info out of FLASH.
FvHandleHandle for Fv, needed in the EFI_SMM_DRIVER_ENTRY so that the PE image can be read out of the FV at a later time.
DriverNameName of driver to add to mDiscoveredList.
Returns:
Pointer to device path constructed from FvHandle and DriverName

Definition at line 1043 of file Dispatcher.c.

EFI_STATUS SmmGetDepexSectionAndPreProccess ( IN EFI_SMM_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.

Parameters:
DriverEntryDriver to work on.
Return values:
EFI_SUCCESSDepex read and preprossesed
EFI_PROTOCOL_ERRORThe section extraction protocol returned an error and Depex reading needs to be retried.
ErrorDEPEX not found.

Definition at line 690 of file Dispatcher.c.

VOID SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter ( IN EFI_SMM_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.

Parameters:
InsertedDriverEntryThe driver to insert on the ScheduledLink Queue

Definition at line 922 of file Dispatcher.c.

EFI_STATUS EFIAPI SmmLoadImage ( IN OUT EFI_SMM_DRIVER_ENTRY DriverEntry)

Loads an EFI image into SMRAM.

Parameters:
DriverEntryEFI_SMM_DRIVER_ENTRY instance
Returns:
EFI_STATUS

Definition at line 304 of file Dispatcher.c.

EFI_STATUS SmmPreProcessDepex ( IN EFI_SMM_DRIVER_ENTRY DriverEntry)

Preprocess dependency expression and update DriverEntry to reflect the state of Before and After dependencies. If DriverEntry->Before or DriverEntry->After is set it will never be cleared.

Parameters:
DriverEntryDriverEntry element to update .
Return values:
EFI_SUCCESSIt always works.

Definition at line 655 of file Dispatcher.c.


Variable Documentation

Definition at line 93 of file Dispatcher.c.

Definition at line 98 of file Dispatcher.c.

LIST_ENTRY mDiscoveredList = INITIALIZE_LIST_HEAD_VARIABLE (mDiscoveredList)

Definition at line 77 of file Dispatcher.c.

Definition at line 117 of file Dispatcher.c.

LIST_ENTRY mFvHandleList = INITIALIZE_LIST_HEAD_VARIABLE (mFvHandleList)

Definition at line 88 of file Dispatcher.c.

LIST_ENTRY mScheduledQueue = INITIALIZE_LIST_HEAD_VARIABLE (mScheduledQueue)

Definition at line 83 of file Dispatcher.c.

Definition at line 122 of file Dispatcher.c.

GLOBAL_REMOVE_IF_UNREFERENCED UINT64* mSmmCodeMemoryRangeUsageBitMap = NULL

Definition at line 129 of file Dispatcher.c.

Initial value:

Definition at line 103 of file Dispatcher.c.

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines