PiSmmCore.h revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
The internal header file includes the common header files, defines
internal structure and functions used by SmmCore module.
Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
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
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _SMM_CORE_H_
#define _SMM_CORE_H_
#include <PiSmm.h>
#include <Protocol/DxeSmmReadyToLock.h>
#include <Protocol/SmmReadyToLock.h>
#include <Protocol/SmmCommunication.h>
#include <Protocol/SmmAccess2.h>
#include <Protocol/FirmwareVolume2.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/DevicePath.h>
#include <Protocol/Security.h>
#include <Guid/EventGroup.h>
#include <Guid/EventLegacyBios.h>
#include <Library/BaseMemoryLib.h>
#include <Library/PeCoffLib.h>
#include <Library/CacheMaintenanceLib.h>
#include <Library/DebugLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DevicePathLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/SmmCorePlatformHookLib.h>
#include <Library/PerformanceLib.h>
#include <Library/TimerLib.h>
#include "PiSmmCorePrivateData.h"
//
// Used to build a table of SMI Handlers that the SMM Core registers
//
typedef struct {
//
// Structure for recording the state of an SMM Driver
//
typedef struct {
//
// Image EntryPoint in SMRAM
//
//
// Image Buffer in SMRAM
//
//
// Image Page Number
//
///
/// IHANDLE - contains a list of protocol handles
///
typedef struct {
/// All handles list of IHANDLE
/// List of PROTOCOL_INTERFACE's for this handle
} IHANDLE;
///
/// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
/// database. Each handler that supports this protocol is listed, along
/// with a list of registered notifies.
///
typedef struct {
/// Link Entry inserted to mProtocolDatabase
/// ID of the protocol
/// All protocol interfaces
/// Registerd notification handlers
///
/// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked
/// with a protocol interface structure
///
typedef struct {
/// Link on IHANDLE.Protocols
/// Back pointer
/// Link on PROTOCOL_ENTRY.Protocols
/// The protocol ID
/// The interface value
///
/// PROTOCOL_NOTIFY - used for each register notification for a protocol
///
typedef struct {
/// All notifications for this protocol
/// Notification function
/// Last position notified
//
// SMM Core Global Variables
//
extern SMM_CORE_PRIVATE_DATA *gSmmCorePrivate;
extern EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst;
extern LIST_ENTRY gHandleList;
/**
Called to initialize the memory service.
@param SmramRangeCount Number of SMRAM Regions
@param SmramRanges Pointer to SMRAM Descriptors
**/
);
/**
The SmmInstallConfigurationTable() function is used to maintain the list
of configuration tables that are stored in the System Management System
Table. The list is stored as an array of (GUID, Pointer) pairs. The list
must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
@param SystemTable A pointer to the SMM System Table (SMST).
@param Guid A pointer to the GUID for the entry to add, update, or remove.
@param Table A pointer to the buffer of the table to add.
@param TableSize The size of the table to install.
@retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
@retval EFI_INVALID_PARAMETER Guid is not valid.
@retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
@retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
**/
);
/**
Wrapper function to SmmInstallProtocolInterfaceNotify. This is the public API which
Calls the private one which contains a BOOLEAN parameter for notifications
@param UserHandle The handle to install the protocol handler on,
or NULL if a new handle is to be allocated
@param Protocol The protocol to add to the handle
@param InterfaceType Indicates whether Interface is supplied in
native form.
@param Interface The interface for the protocol being added
@return Status code
**/
);
/**
Allocates pages from the memory map.
@param Type The type of allocation to perform
@param MemoryType The type of memory to turn the allocated pages
into
@param NumberOfPages The number of pages to allocate
@param Memory A pointer to receive the base allocated memory
address
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
@retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
@retval EFI_SUCCESS Pages successfully allocated.
**/
);
/**
Frees previous allocated pages.
@param Memory Base address of memory being freed
@param NumberOfPages The number of pages to free
@retval EFI_NOT_FOUND Could not find the entry that covers the range
@retval EFI_INVALID_PARAMETER Address not aligned
@return EFI_SUCCESS Pages successfully freed.
**/
);
/**
Allocate pool of a particular type.
@param PoolType Type of pool to allocate
@param Size The amount of pool to allocate
@param Buffer The address to return a pointer to the allocated
pool
@retval EFI_INVALID_PARAMETER PoolType not valid
@retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
@retval EFI_SUCCESS Pool successfully allocated.
**/
);
/**
Frees pool.
@param Buffer The allocated pool entry to free
@retval EFI_INVALID_PARAMETER Buffer is not a valid value.
@retval EFI_SUCCESS Pool successfully freed.
**/
);
/**
Installs a protocol interface into the boot services environment.
@param UserHandle The handle to install the protocol handler on,
or NULL if a new handle is to be allocated
@param Protocol The protocol to add to the handle
@param InterfaceType Indicates whether Interface is supplied in
native form.
@param Interface The interface for the protocol being added
@param Notify indicates whether notify the notification list
for this protocol
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
@retval EFI_SUCCESS Protocol interface successfully installed
**/
);
/**
Uninstalls all instances of a protocol:interfacer from a handle.
If the last protocol interface is remove from the handle, the
handle is freed.
@param UserHandle The handle to remove the protocol handler from
@param Protocol The protocol, of protocol:interface, to remove
@param Interface The interface, of protocol:interface, to remove
@retval EFI_INVALID_PARAMETER Protocol is NULL.
@retval EFI_SUCCESS Protocol interface successfully uninstalled.
**/
);
/**
Queries a handle to determine if it supports a specified protocol.
@param UserHandle The handle being queried.
@param Protocol The published unique identifier of the protocol.
@param Interface Supplies the address where a pointer to the
corresponding Protocol Interface is returned.
@return The requested protocol interface for the handle
**/
);
/**
Add a new protocol notification record for the request protocol.
@param Protocol The requested protocol to add the notify
registration
@param Function Points to the notification function
@param Registration Returns the registration record
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_SUCCESS Successfully returned the registration record
that has been added
**/
);
/**
Locates the requested handle(s) and returns them in Buffer.
@param SearchType The type of search to perform to locate the
handles
@param Protocol The protocol to search for
@param SearchKey Dependant on SearchType
@param BufferSize On input the size of Buffer. On output the
size of data returned.
@param Buffer The buffer to return the results in
@retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
returned in BufferSize.
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_SUCCESS Successfully found the requested handle(s) and
returns them in Buffer.
**/
);
/**
Return the first Protocol Interface that matches the Protocol GUID. If
Registration is pasased in return a Protocol Instance that was just add
to the system. If Retistration is NULL return the first Protocol Interface
you find.
@param Protocol The protocol to search for
@param Registration Optional Registration Key returned from
RegisterProtocolNotify()
@param Interface Return the Protocol interface (instance).
@retval EFI_SUCCESS If a valid Interface is returned
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_NOT_FOUND Protocol interface not found
**/
);
/**
Manage SMI of a particular type.
@param HandlerType Points to the handler type or NULL for root SMI handlers.
@param Context Points to an optional context buffer.
@param CommBuffer Points to the optional communication buffer.
@param CommBufferSize Points to the size of the optional communication buffer.
@retval EFI_SUCCESS Interrupt source was processed successfully but not quiesced.
@retval EFI_INTERRUPT_PENDING One or more SMI sources could not be quiesced.
@retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was not handled or quiesced.
@retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.
**/
);
/**
Registers a handler to execute within SMM.
@param Handler Handler service funtion pointer.
@param HandlerType Points to the handler type or NULL for root SMI handlers.
@param DispatchHandle On return, contains a unique handle which can be used to later unregister the handler function.
@retval EFI_SUCCESS Handler register success.
@retval EFI_INVALID_PARAMETER Handler or DispatchHandle is NULL.
**/
);
/**
Unregister a handler in SMM.
@param DispatchHandle The handle that was specified when the handler was registered.
@retval EFI_SUCCESS Handler function was successfully unregistered.
@retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.
**/
);
/**
This function is the main entry point for an SMM handler dispatch
or communicate-based callback.
@param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
@param Context Points to an optional handler context which was specified when the handler was registered.
@param CommBuffer A pointer to a collection of data in memory that will
be conveyed from a non-SMM environment into an SMM environment.
@param CommBufferSize The size of the CommBuffer.
@return Status Code
**/
);
/**
This function is the main entry point for an SMM handler dispatch
or communicate-based callback.
@param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
@param Context Points to an optional handler context which was specified when the handler was registered.
@param CommBuffer A pointer to a collection of data in memory that will
be conveyed from a non-SMM environment into an SMM environment.
@param CommBufferSize The size of the CommBuffer.
@return Status Code
**/
);
/**
This function is the main entry point for an SMM handler dispatch
or communicate-based callback.
@param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
@param Context Points to an optional handler context which was specified when the handler was registered.
@param CommBuffer A pointer to a collection of data in memory that will
be conveyed from a non-SMM environment into an SMM environment.
@param CommBufferSize The size of the CommBuffer.
@return Status Code
**/
);
/**
Place holder function until all the SMM System Table Service are available.
@param Arg1 Undefined
@param Arg2 Undefined
@param Arg3 Undefined
@param Arg4 Undefined
@param Arg5 Undefined
@return EFI_NOT_AVAILABLE_YET
**/
);
//
//Functions used during debug buils
//
/**
Traverse the discovered list for any drivers that were discovered but not loaded
because the dependency experessions evaluated to false.
**/
);
/**
Add free SMRAM region for use by memory service.
@param MemBase Base address of memory region.
@param MemLength Length of the memory region.
@param Type Memory type.
@param Attributes Memory region state.
**/
);
/**
Finds the protocol entry for the requested protocol.
@param Protocol The ID of the protocol
@param Create Create a new entry if not found
@return Protocol entry
**/
);
/**
Signal event for every protocol in protocol entry.
@param Prot Protocol interface
**/
);
/**
Finds the protocol instance for the requested handle and protocol.
Note: This function doesn't do parameters checking, it's caller's responsibility
to pass in valid parameters.
@param Handle The handle to search the protocol on
@param Protocol GUID of the protocol
@param Interface The interface for the protocol being searched
@return Protocol instance (NULL: Not found)
**/
);
/**
Removes Protocol from the protocol list (but not the handle list).
@param Handle The handle to remove protocol on.
@param Protocol GUID of the protocol to be moved
@param Interface The interface of the protocol
@return Protocol Entry
**/
);
/**
This is the POSTFIX version of the dependency evaluator. This code does
not need to handle Before or After, as it is not valid to call this
routine in this case. POSTFIX means all the math is done on top of the stack.
@param DriverEntry DriverEntry element to update.
@retval TRUE If driver is ready to run.
@retval FALSE If driver is not ready to run or some fatal error
was found.
**/
);
#endif