mirror of https://github.com/acidanthera/audk.git
EdkCompatibilityPkg: Add SmmScriptLib
Signed-off-by: jljusten Reviewed-by: mdkinney Reviewed-by: geekboy15a Reviewed-by: jyao1 Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12032 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
caf93abc43
commit
4851f24430
|
@ -186,6 +186,7 @@ define GCC_MACRO = -DEFI_SPECIFICATION_VERSION=0x00020000 -DPI_S
|
|||
EdkCompatibilityPkg/Foundation/Library/Dxe/Print/PrintLib.inf
|
||||
EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/PrintLib.inf
|
||||
EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf
|
||||
EdkCompatibilityPkg/Foundation/Library/Smm/SmmScriptLib/SmmScriptLib.inf
|
||||
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
|
||||
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf
|
||||
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf
|
||||
|
|
|
@ -0,0 +1,472 @@
|
|||
/** @file
|
||||
Header file to define EFI SMM Base2 Protocol in the PI 1.2 specification.
|
||||
|
||||
The thunk implementation for SmmScriptLib will ultilize the SmmSaveState Protocol to save SMM
|
||||
runtime s3 boot Script. This header file is to definied PI SMM related definition to locate
|
||||
SmmSaveState Protocol
|
||||
|
||||
Copyright (c) 2010, 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
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _PI_SMM_DEFINITION_H_
|
||||
#define _PI_SMM_DEFINITION_H_
|
||||
|
||||
typedef struct _EFI_SMM_CPU_IO_PROTOCOL EFI_SMM_CPU_IO_PROTOCOL;
|
||||
|
||||
///
|
||||
/// Width of the SMM CPU I/O operations
|
||||
///
|
||||
typedef enum {
|
||||
SMM_IO_UINT8 = 0,
|
||||
SMM_IO_UINT16 = 1,
|
||||
SMM_IO_UINT32 = 2,
|
||||
SMM_IO_UINT64 = 3
|
||||
} EFI_SMM_IO_WIDTH;
|
||||
|
||||
/**
|
||||
Provides the basic memory and I/O interfaces used toabstract accesses to devices.
|
||||
|
||||
The I/O operations are carried out exactly as requested. The caller is responsible for any alignment
|
||||
and I/O width issues that the bus, device, platform, or type of I/O might require.
|
||||
|
||||
@param[in] This The EFI_SMM_CPU_IO_PROTOCOL instance.
|
||||
@param[in] Width Signifies the width of the I/O operations.
|
||||
@param[in] Address The base address of the I/O operations.
|
||||
The caller is responsible for aligning the Address if required.
|
||||
@param[in] Count The number of I/O operations to perform.
|
||||
@param[in,out] Buffer For read operations, the destination buffer to store the results.
|
||||
For write operations, the source buffer from which to write data.
|
||||
|
||||
@retval EFI_SUCCESS The data was read from or written to the device.
|
||||
@retval EFI_UNSUPPORTED The Address is not valid for this system.
|
||||
@retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
|
||||
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SMM_CPU_IO2)(
|
||||
IN CONST EFI_SMM_CPU_IO_PROTOCOL *This,
|
||||
IN EFI_SMM_IO_WIDTH Width,
|
||||
IN UINT64 Address,
|
||||
IN UINTN Count,
|
||||
IN OUT VOID *Buffer
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
///
|
||||
/// This service provides the various modalities of memory and I/O read.
|
||||
///
|
||||
EFI_SMM_CPU_IO2 Read;
|
||||
///
|
||||
/// This service provides the various modalities of memory and I/O write.
|
||||
///
|
||||
EFI_SMM_CPU_IO2 Write;
|
||||
} EFI_SMM_IO_ACCESS2;
|
||||
|
||||
///
|
||||
/// SMM CPU I/O Protocol provides CPU I/O and memory access within SMM.
|
||||
///
|
||||
struct _EFI_SMM_CPU_IO_PROTOCOL {
|
||||
EFI_SMM_IO_ACCESS2 Mem; ///< Allows reads and writes to memory-mapped I/O space.
|
||||
EFI_SMM_IO_ACCESS2 Io; ///< Allows reads and writes to I/O space.
|
||||
};
|
||||
typedef struct _EFI_SMM_SYSTEM_TABLE2 EFI_SMM_SYSTEM_TABLE2;
|
||||
/**
|
||||
Adds, updates, or removes a configuration table entry from the System Management System Table.
|
||||
|
||||
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[in] SystemTable A pointer to the SMM System Table (SMST).
|
||||
@param[in] Guid A pointer to the GUID for the entry to add, update, or remove.
|
||||
@param[in] Table A pointer to the buffer of the table to add.
|
||||
@param[in] 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.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE2)(
|
||||
IN CONST EFI_SMM_SYSTEM_TABLE2 *SystemTable,
|
||||
IN CONST EFI_GUID *Guid,
|
||||
IN VOID *Table,
|
||||
IN UINTN TableSize
|
||||
);
|
||||
/**
|
||||
Function prototype for invoking a function on an Application Processor.
|
||||
|
||||
This definition is used by the UEFI MP Serices Protocol, and the
|
||||
PI SMM System Table.
|
||||
|
||||
@param[in,out] Buffer Pointer to private data buffer.
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EFI_AP_PROCEDURE)(
|
||||
IN OUT VOID *Buffer
|
||||
);
|
||||
/**
|
||||
The SmmStartupThisAp() lets the caller to get one distinct application processor
|
||||
(AP) in the enabled processor pool to execute a caller-provided code stream
|
||||
while in SMM. It runs the given code on this processor and reports the status.
|
||||
It must be noted that the supplied code stream will be run only on an enabled
|
||||
processor which has also entered SMM.
|
||||
|
||||
@param[in] Procedure A pointer to the code stream to be run on the designated AP of the system.
|
||||
@param[in] CpuNumber The zero-based index of the processor number of the AP on which the code stream is supposed to run.
|
||||
@param[in,out] ProcArguments Allow the caller to pass a list of parameters to the code that is run by the AP.
|
||||
|
||||
@retval EFI_SUCCESS The call was successful and the return parameters are valid.
|
||||
@retval EFI_INVALID_PARAMETER The input arguments are out of range.
|
||||
@retval EFI_INVALID_PARAMETER The CPU requested is not available on this SMI invocation.
|
||||
@retval EFI_INVALID_PARAMETER The CPU cannot support an additional service invocation.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SMM_STARTUP_THIS_AP)(
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN UINTN CpuNumber,
|
||||
IN OUT VOID *ProcArguments OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Function prototype for protocol install notification.
|
||||
|
||||
@param[in] Protocol Points to the protocol's unique identifier.
|
||||
@param[in] Interface Points to the interface instance.
|
||||
@param[in] Handle The handle on which the interface was installed.
|
||||
|
||||
@return Status Code
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SMM_NOTIFY_FN)(
|
||||
IN CONST EFI_GUID *Protocol,
|
||||
IN VOID *Interface,
|
||||
IN EFI_HANDLE Handle
|
||||
);
|
||||
|
||||
/**
|
||||
Register a callback function be called when a particular protocol interface is installed.
|
||||
|
||||
The SmmRegisterProtocolNotify() function creates a registration Function that is to be
|
||||
called whenever a protocol interface is installed for Protocol by
|
||||
SmmInstallProtocolInterface().
|
||||
|
||||
@param[in] Protocol The unique ID of the protocol for which the event is to be registered.
|
||||
@param[in] Function Points to the notification function.
|
||||
@param[out] Registration A pointer to a memory location to receive the registration value.
|
||||
|
||||
@retval EFI_SUCCESS Successfully returned the registration record that has been added.
|
||||
@retval EFI_INVALID_PARAMETER One or more of Protocol, Function and Registration is NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough memory resource to finish the request.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SMM_REGISTER_PROTOCOL_NOTIFY)(
|
||||
IN CONST EFI_GUID *Protocol,
|
||||
IN EFI_SMM_NOTIFY_FN Function,
|
||||
OUT VOID **Registration
|
||||
);
|
||||
|
||||
/**
|
||||
Manage SMI of a particular type.
|
||||
|
||||
@param[in] HandlerType Points to the handler type or NULL for root SMI handlers.
|
||||
@param[in] Context Points to an optional context buffer.
|
||||
@param[in,out] CommBuffer Points to the optional communication buffer.
|
||||
@param[in,out] 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.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SMM_INTERRUPT_MANAGE)(
|
||||
IN CONST EFI_GUID *HandlerType,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Main entry point for an SMM handler dispatch or communicate-based callback.
|
||||
|
||||
@param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
|
||||
@param[in] Context Points to an optional handler context which was specified when the
|
||||
handler was registered.
|
||||
@param[in,out] CommBuffer A pointer to a collection of data in memory that will
|
||||
be conveyed from a non-SMM environment into an SMM environment.
|
||||
@param[in,out] CommBufferSize The size of the CommBuffer.
|
||||
|
||||
@retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers
|
||||
should still be called.
|
||||
@retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should
|
||||
still be called.
|
||||
@retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still
|
||||
be called.
|
||||
@retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT2)(
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Registers a handler to execute within SMM.
|
||||
|
||||
@param[in] Handler Handler service funtion pointer.
|
||||
@param[in] HandlerType Points to the handler type or NULL for root SMI handlers.
|
||||
@param[out] DispatchHandle On return, contains a unique handle which can be used to later
|
||||
unregister the handler function.
|
||||
|
||||
@retval EFI_SUCCESS SMI handler added successfully.
|
||||
@retval EFI_INVALID_PARAMETER Handler is NULL or DispatchHandle is NULL.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SMM_INTERRUPT_REGISTER)(
|
||||
IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
|
||||
IN CONST EFI_GUID *HandlerType OPTIONAL,
|
||||
OUT EFI_HANDLE *DispatchHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Unregister a handler in SMM.
|
||||
|
||||
@param[in] 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.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SMM_INTERRUPT_UNREGISTER)(
|
||||
IN EFI_HANDLE DispatchHandle
|
||||
);
|
||||
|
||||
///
|
||||
/// Processor information and functionality needed by SMM Foundation.
|
||||
///
|
||||
typedef struct _EFI_SMM_ENTRY_CONTEXT {
|
||||
EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp;
|
||||
///
|
||||
/// A number between zero and the NumberOfCpus field. This field designates which
|
||||
/// processor is executing the SMM Foundation.
|
||||
///
|
||||
UINTN CurrentlyExecutingCpu;
|
||||
///
|
||||
/// The number of current operational processors in the platform. This is a 1 based
|
||||
/// counter. This does not indicate the number of processors that entered SMM.
|
||||
///
|
||||
UINTN NumberOfCpus;
|
||||
///
|
||||
/// Points to an array, where each element describes the number of bytes in the
|
||||
/// corresponding save state specified by CpuSaveState. There are always
|
||||
/// NumberOfCpus entries in the array.
|
||||
///
|
||||
UINTN *CpuSaveStateSize;
|
||||
///
|
||||
/// Points to an array, where each element is a pointer to a CPU save state. The
|
||||
/// corresponding element in CpuSaveStateSize specifies the number of bytes in the
|
||||
/// save state area. There are always NumberOfCpus entries in the array.
|
||||
///
|
||||
VOID **CpuSaveState;
|
||||
} EFI_SMM_ENTRY_CONTEXT;
|
||||
|
||||
/**
|
||||
This function is the main entry point to the SMM Foundation.
|
||||
|
||||
@param[in] SmmEntryContext Processor information and functionality needed by SMM Foundation.
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EFI_SMM_ENTRY_POINT)(
|
||||
IN CONST EFI_SMM_ENTRY_CONTEXT *SmmEntryContext
|
||||
);
|
||||
|
||||
///
|
||||
/// System Management System Table (SMST)
|
||||
///
|
||||
/// The System Management System Table (SMST) is a table that contains a collection of common
|
||||
/// services for managing SMRAM allocation and providing basic I/O services. These services are
|
||||
/// intended for both preboot and runtime usage.
|
||||
///
|
||||
struct _EFI_SMM_SYSTEM_TABLE2 {
|
||||
///
|
||||
/// The table header for the SMST.
|
||||
///
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
///
|
||||
/// A pointer to a NULL-terminated Unicode string containing the vendor name.
|
||||
/// It is permissible for this pointer to be NULL.
|
||||
///
|
||||
CHAR16 *SmmFirmwareVendor;
|
||||
///
|
||||
/// The particular revision of the firmware.
|
||||
///
|
||||
UINT32 SmmFirmwareRevision;
|
||||
|
||||
EFI_SMM_INSTALL_CONFIGURATION_TABLE2 SmmInstallConfigurationTable;
|
||||
|
||||
///
|
||||
/// I/O Service
|
||||
///
|
||||
EFI_SMM_CPU_IO_PROTOCOL SmmIo;
|
||||
|
||||
///
|
||||
/// Runtime memory services
|
||||
///
|
||||
EFI_ALLOCATE_POOL SmmAllocatePool;
|
||||
EFI_FREE_POOL SmmFreePool;
|
||||
EFI_ALLOCATE_PAGES SmmAllocatePages;
|
||||
EFI_FREE_PAGES SmmFreePages;
|
||||
|
||||
///
|
||||
/// MP service
|
||||
///
|
||||
EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp;
|
||||
|
||||
///
|
||||
/// CPU information records
|
||||
///
|
||||
|
||||
///
|
||||
/// A number between zero and and the NumberOfCpus field. This field designates
|
||||
/// which processor is executing the SMM infrastructure.
|
||||
///
|
||||
UINTN CurrentlyExecutingCpu;
|
||||
///
|
||||
/// The number of current operational processors in the platform. This is a 1 based counter.
|
||||
///
|
||||
UINTN NumberOfCpus;
|
||||
///
|
||||
/// Points to an array, where each element describes the number of bytes in the
|
||||
/// corresponding save state specified by CpuSaveState. There are always
|
||||
/// NumberOfCpus entries in the array.
|
||||
///
|
||||
UINTN *CpuSaveStateSize;
|
||||
///
|
||||
/// Points to an array, where each element is a pointer to a CPU save state. The
|
||||
/// corresponding element in CpuSaveStateSize specifies the number of bytes in the
|
||||
/// save state area. There are always NumberOfCpus entries in the array.
|
||||
///
|
||||
VOID **CpuSaveState;
|
||||
|
||||
///
|
||||
/// Extensibility table
|
||||
///
|
||||
|
||||
///
|
||||
/// The number of UEFI Configuration Tables in the buffer SmmConfigurationTable.
|
||||
///
|
||||
UINTN NumberOfTableEntries;
|
||||
///
|
||||
/// A pointer to the UEFI Configuration Tables. The number of entries in the table is
|
||||
/// NumberOfTableEntries.
|
||||
///
|
||||
EFI_CONFIGURATION_TABLE *SmmConfigurationTable;
|
||||
|
||||
///
|
||||
/// Protocol services
|
||||
///
|
||||
EFI_INSTALL_PROTOCOL_INTERFACE SmmInstallProtocolInterface;
|
||||
EFI_UNINSTALL_PROTOCOL_INTERFACE SmmUninstallProtocolInterface;
|
||||
EFI_HANDLE_PROTOCOL SmmHandleProtocol;
|
||||
EFI_SMM_REGISTER_PROTOCOL_NOTIFY SmmRegisterProtocolNotify;
|
||||
EFI_LOCATE_HANDLE SmmLocateHandle;
|
||||
EFI_LOCATE_PROTOCOL SmmLocateProtocol;
|
||||
|
||||
///
|
||||
/// SMI Management functions
|
||||
///
|
||||
EFI_SMM_INTERRUPT_MANAGE SmiManage;
|
||||
EFI_SMM_INTERRUPT_REGISTER SmiHandlerRegister;
|
||||
EFI_SMM_INTERRUPT_UNREGISTER SmiHandlerUnRegister;
|
||||
};
|
||||
|
||||
#define EFI_SMM_BASE2_PROTOCOL_GUID \
|
||||
{ \
|
||||
0xf4ccbfb7, 0xf6e0, 0x47fd, {0x9d, 0xd4, 0x10, 0xa8, 0xf1, 0x50, 0xc1, 0x91 } \
|
||||
}
|
||||
|
||||
typedef struct _EFI_SMM_BASE2_PROTOCOL EFI_SMM_BASE2_PROTOCOL;
|
||||
|
||||
/**
|
||||
Service to indicate whether the driver is currently executing in the SMM Initialization phase.
|
||||
|
||||
This service is used to indicate whether the driver is currently executing in the SMM Initialization
|
||||
phase. For SMM drivers, this will return TRUE in InSmram while inside the driver's entry point and
|
||||
otherwise FALSE. For combination SMM/DXE drivers, this will return FALSE in the DXE launch. For the
|
||||
SMM launch, it behaves as an SMM driver.
|
||||
|
||||
@param[in] This The EFI_SMM_BASE2_PROTOCOL instance.
|
||||
@param[out] InSmram Pointer to a Boolean which, on return, indicates that the driver is
|
||||
currently executing inside of SMRAM (TRUE) or outside of SMRAM (FALSE).
|
||||
|
||||
@retval EFI_SUCCESS The call returned successfully.
|
||||
@retval EFI_INVALID_PARAMETER InSmram was NULL.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SMM_INSIDE_OUT2)(
|
||||
IN CONST EFI_SMM_BASE2_PROTOCOL *This,
|
||||
OUT BOOLEAN *InSmram
|
||||
)
|
||||
;
|
||||
|
||||
/**
|
||||
Returns the location of the System Management Service Table (SMST).
|
||||
|
||||
This function returns the location of the System Management Service Table (SMST). The use of the
|
||||
API is such that a driver can discover the location of the SMST in its entry point and then cache it in
|
||||
some driver global variable so that the SMST can be invoked in subsequent handlers.
|
||||
|
||||
@param[in] This The EFI_SMM_BASE2_PROTOCOL instance.
|
||||
@param[in,out] Smst On return, points to a pointer to the System Management Service Table (SMST).
|
||||
|
||||
@retval EFI_SUCCESS The operation was successful.
|
||||
@retval EFI_INVALID_PARAMETER Smst was invalid.
|
||||
@retval EFI_UNSUPPORTED Not in SMM.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SMM_GET_SMST_LOCATION2)(
|
||||
IN CONST EFI_SMM_BASE2_PROTOCOL *This,
|
||||
IN OUT EFI_SMM_SYSTEM_TABLE2 **Smst
|
||||
)
|
||||
;
|
||||
|
||||
///
|
||||
/// EFI SMM Base2 Protocol is utilized by all SMM drivers to locate the SMM infrastructure
|
||||
/// services and determine whether the driver is being invoked inside SMRAM or outside of SMRAM.
|
||||
///
|
||||
struct _EFI_SMM_BASE2_PROTOCOL {
|
||||
EFI_SMM_INSIDE_OUT2 InSmm;
|
||||
EFI_SMM_GET_SMST_LOCATION2 GetSmstLocation;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
/** @file
|
||||
Header file to define SMM S3 Save State Protocol as in PI1.2 Specification VOLUME 5 Standard.
|
||||
|
||||
The thunk implementation for SmmScriptLib will ultilize the SmmSaveState Protocol to save SMM
|
||||
runtime s3 boot Script. This header file is to definiedSMM S3 Save State Protocol
|
||||
|
||||
Copyright (c) 2010, 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
|
||||
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.
|
||||
|
||||
**/
|
||||
#ifndef __PI_SMM_S3_SAVE_STATE_H__
|
||||
#define __PI_SMM_S3_SAVE_STATE_H__
|
||||
|
||||
#define EFI_S3_SMM_SAVE_STATE_PROTOCOL_GUID \
|
||||
{0x320afe62, 0xe593, 0x49cb, { 0xa9, 0xf1, 0xd4, 0xc2, 0xf4, 0xaf, 0x1, 0x4c }}
|
||||
|
||||
typedef VOID *EFI_S3_BOOT_SCRIPT_POSITION;
|
||||
|
||||
typedef struct _EFI_S3_SMM_SAVE_STATE_PROTOCOL EFI_S3_SAVE_STATE_PROTOCOL;
|
||||
|
||||
/**
|
||||
Record operations that need to be replayed during an S3 resume.
|
||||
|
||||
This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
|
||||
assumed this protocol has platform specific mechanism to store the OpCode set and replay them
|
||||
during the S3 resume.
|
||||
|
||||
@param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
|
||||
@param[in] OpCode The operation code (opcode) number.
|
||||
@param[in] ... Argument list that is specific to each opcode. See the following subsections for the
|
||||
definition of each opcode.
|
||||
|
||||
@retval EFI_SUCCESS The operation succeeded. A record was added into the specified
|
||||
script table.
|
||||
@retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
|
||||
@retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_S3_SAVE_STATE_WRITE)(
|
||||
IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,
|
||||
IN UINT16 OpCode,
|
||||
...
|
||||
);
|
||||
|
||||
/**
|
||||
Record operations that need to be replayed during an S3 resume.
|
||||
|
||||
This function is used to store an OpCode to be replayed as part of the S3 resume boot path. It is
|
||||
assumed this protocol has platform specific mechanism to store the OpCode set and replay them
|
||||
during the S3 resume.
|
||||
The opcode is inserted before or after the specified position in the boot script table. If Position is
|
||||
NULL then that position is after the last opcode in the table (BeforeOrAfter is TRUE) or before
|
||||
the first opcode in the table (BeforeOrAfter is FALSE). The position which is pointed to by
|
||||
Position upon return can be used for subsequent insertions.
|
||||
|
||||
This function has a variable parameter list. The exact parameter list depends on the OpCode that is
|
||||
passed into the function. If an unsupported OpCode or illegal parameter list is passed in, this
|
||||
function returns EFI_INVALID_PARAMETER.
|
||||
If there are not enough resources available for storing more scripts, this function returns
|
||||
EFI_OUT_OF_RESOURCES.
|
||||
OpCode values of 0x80 - 0xFE are reserved for implementation specific functions.
|
||||
|
||||
@param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
|
||||
@param[in] BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position
|
||||
in the boot script table specified by Position. If Position is NULL or points to
|
||||
NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end
|
||||
of the table (if FALSE).
|
||||
@param[in, out] Position On entry, specifies the position in the boot script table where the opcode will be
|
||||
inserted, either before or after, depending on BeforeOrAfter. On exit, specifies
|
||||
the position of the inserted opcode in the boot script table.
|
||||
@param[in] OpCode The operation code (opcode) number. See "Related Definitions" in Write() for the
|
||||
defined opcode types.
|
||||
@param[in] ... Argument list that is specific to each opcode. See the following subsections for the
|
||||
definition of each opcode.
|
||||
|
||||
@retval EFI_SUCCESS The operation succeeded. An opcode was added into the script.
|
||||
@retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value.
|
||||
@retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.
|
||||
@retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script table.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_S3_SAVE_STATE_INSERT)(
|
||||
IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,
|
||||
IN BOOLEAN BeforeOrAfter,
|
||||
IN OUT EFI_S3_BOOT_SCRIPT_POSITION *Position OPTIONAL,
|
||||
IN UINT16 OpCode,
|
||||
...
|
||||
);
|
||||
|
||||
/**
|
||||
Find a label within the boot script table and, if not present, optionally create it.
|
||||
|
||||
If the label Label is already exists in the boot script table, then no new label is created, the
|
||||
position of the Label is returned in *Position and EFI_SUCCESS is returned.
|
||||
If the label Label does not already exist and CreateIfNotFound is TRUE, then it will be
|
||||
created before or after the specified position and EFI_SUCCESS is returned.
|
||||
If the label Label does not already exist and CreateIfNotFound is FALSE, then
|
||||
EFI_NOT_FOUND is returned.
|
||||
|
||||
@param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
|
||||
@param[in] BeforeOrAfter Specifies whether the label is stored before (TRUE) or after (FALSE) the position in
|
||||
the boot script table specified by Position. If Position is NULL or points to
|
||||
NULL then the new label is inserted at the beginning of the table (if TRUE) or end of
|
||||
the table (if FALSE).
|
||||
@param[in] CreateIfNotFound Specifies whether the label will be created if the label does not exists (TRUE) or not (FALSE).
|
||||
@param[in, out] Position On entry, specifies the position in the boot script table where the label will be inserted,
|
||||
either before or after, depending on BeforeOrAfter. On exit, specifies the position
|
||||
of the inserted label in the boot script table.
|
||||
@param[in] Label Points to the label which will be inserted in the boot script table.
|
||||
|
||||
@retval EFI_SUCCESS The label already exists or was inserted.
|
||||
@retval EFI_NOT_FOUND The label did not already exist and CreateifNotFound was FALSE.
|
||||
@retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value.
|
||||
@retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.
|
||||
@retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_S3_SAVE_STATE_LABEL)(
|
||||
IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,
|
||||
IN BOOLEAN BeforeOrAfter,
|
||||
IN BOOLEAN CreateIfNotFound,
|
||||
IN OUT EFI_S3_BOOT_SCRIPT_POSITION *Position OPTIONAL,
|
||||
IN CONST CHAR8 *Label
|
||||
);
|
||||
|
||||
/**
|
||||
Compare two positions in the boot script table and return their relative position.
|
||||
|
||||
This function compares two positions in the boot script table and returns their relative positions. If
|
||||
Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,
|
||||
then 0 is returned. If Position1 is after Position2, then 1 is returned.
|
||||
|
||||
@param[in] This A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.
|
||||
@param[in] Position1 The positions in the boot script table to compare.
|
||||
@param[in] Position2 The positions in the boot script table to compare.
|
||||
@param[out] RelativePosition On return, points to the result of the comparison.
|
||||
|
||||
@retval EFI_SUCCESS The label already exists or was inserted.
|
||||
@retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_S3_SAVE_STATE_COMPARE)(
|
||||
IN CONST EFI_S3_SAVE_STATE_PROTOCOL *This,
|
||||
IN EFI_S3_BOOT_SCRIPT_POSITION Position1,
|
||||
IN EFI_S3_BOOT_SCRIPT_POSITION Position2,
|
||||
OUT UINTN *RelativePosition
|
||||
);
|
||||
|
||||
typedef struct _EFI_S3_SMM_SAVE_STATE_PROTOCOL {
|
||||
EFI_S3_SAVE_STATE_WRITE Write;
|
||||
EFI_S3_SAVE_STATE_INSERT Insert;
|
||||
EFI_S3_SAVE_STATE_LABEL Label;
|
||||
EFI_S3_SAVE_STATE_COMPARE Compare;
|
||||
} EFI_S3_SMM_SAVE_STATE_PROTOCOL;
|
||||
|
||||
|
||||
#endif // __S3_SAVE_STATE_H__
|
|
@ -0,0 +1,498 @@
|
|||
/** @file
|
||||
Thunk implmentation for SmmScriptLib.
|
||||
|
||||
SmmScriptLib in Framework implementation is to save S3 Boot Script in SMM runtime.
|
||||
The thunk implementation for SmmScriptLib will ultilize the SmmSaveState Protocol to save SMM
|
||||
runtime s3 boot Script.
|
||||
|
||||
Copyright (c) 2010, 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
|
||||
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.
|
||||
|
||||
**/
|
||||
#include "SmmScriptLib.h"
|
||||
|
||||
//
|
||||
// Define the SmmS3SaveState Protocol GUID.
|
||||
//
|
||||
EFI_GUID mEfiS3SmmSaveStateProtocolGuid = EFI_S3_SMM_SAVE_STATE_PROTOCOL_GUID;
|
||||
EFI_GUID mEfiSmmBase2ProtocolGuid = EFI_SMM_BASE2_PROTOCOL_GUID;
|
||||
EFI_S3_SMM_SAVE_STATE_PROTOCOL *mS3SmmSaveState = NULL;
|
||||
EFI_SMM_SYSTEM_TABLE2 *gSmst = NULL;
|
||||
|
||||
/**
|
||||
Internal function to add IO write opcode to the table.
|
||||
|
||||
@param Marker The variable argument list to get the opcode
|
||||
and associated attributes.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
|
||||
@retval EFI_SUCCESS Opcode is added.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BootScriptIoWrite (
|
||||
IN VA_LIST Marker
|
||||
)
|
||||
{
|
||||
EFI_BOOT_SCRIPT_WIDTH Width;
|
||||
UINT64 Address;
|
||||
UINTN Count;
|
||||
UINT8 *Buffer;
|
||||
|
||||
Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
|
||||
Address = VA_ARG (Marker, UINT64);
|
||||
Count = VA_ARG (Marker, UINTN);
|
||||
Buffer = VA_ARG (Marker, UINT8 *);
|
||||
|
||||
return mS3SmmSaveState->Write (
|
||||
mS3SmmSaveState,
|
||||
EFI_BOOT_SCRIPT_IO_WRITE_OPCODE,
|
||||
Width,
|
||||
Address,
|
||||
Count,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
/**
|
||||
Internal function to add IO read/write opcode to the table.
|
||||
|
||||
@param Marker The variable argument list to get the opcode
|
||||
and associated attributes.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
|
||||
@retval EFI_SUCCESS Opcode is added.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BootScriptIoReadWrite (
|
||||
IN VA_LIST Marker
|
||||
)
|
||||
{
|
||||
EFI_BOOT_SCRIPT_WIDTH Width;
|
||||
UINT64 Address;
|
||||
UINT8 *Data;
|
||||
UINT8 *DataMask;
|
||||
|
||||
Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
|
||||
Address = VA_ARG (Marker, UINT64);
|
||||
Data = VA_ARG (Marker, UINT8 *);
|
||||
DataMask = VA_ARG (Marker, UINT8 *);
|
||||
|
||||
return mS3SmmSaveState->Write (
|
||||
mS3SmmSaveState,
|
||||
EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE,
|
||||
Width,
|
||||
Address,
|
||||
Data,
|
||||
DataMask
|
||||
);
|
||||
}
|
||||
/**
|
||||
Internal function to add memory read/write opcode to the table.
|
||||
|
||||
@param Marker The variable argument list to get the opcode
|
||||
and associated attributes.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
|
||||
@retval EFI_SUCCESS Opcode is added.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BootScriptMemReadWrite (
|
||||
IN VA_LIST Marker
|
||||
)
|
||||
{
|
||||
EFI_BOOT_SCRIPT_WIDTH Width;
|
||||
UINT64 Address;
|
||||
UINT8 *Data;
|
||||
UINT8 *DataMask;
|
||||
|
||||
Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
|
||||
Address = VA_ARG (Marker, UINT64);
|
||||
Data = VA_ARG (Marker, UINT8 *);
|
||||
DataMask = VA_ARG (Marker, UINT8 *);
|
||||
|
||||
return mS3SmmSaveState->Write (
|
||||
mS3SmmSaveState,
|
||||
EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE,
|
||||
Width,
|
||||
Address,
|
||||
Data,
|
||||
DataMask
|
||||
);
|
||||
}
|
||||
/**
|
||||
Internal function to PciCfg read/write opcode to the table.
|
||||
|
||||
@param Marker The variable argument list to get the opcode
|
||||
and associated attributes.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
|
||||
@retval EFI_SUCCESS Opcode is added.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BootScriptPciCfgReadWrite (
|
||||
IN VA_LIST Marker
|
||||
)
|
||||
{
|
||||
EFI_BOOT_SCRIPT_WIDTH Width;
|
||||
UINT64 Address;
|
||||
UINT8 *Data;
|
||||
UINT8 *DataMask;
|
||||
|
||||
Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
|
||||
Address = VA_ARG (Marker, UINT64);
|
||||
Data = VA_ARG (Marker, UINT8 *);
|
||||
DataMask = VA_ARG (Marker, UINT8 *);
|
||||
|
||||
return mS3SmmSaveState->Write (
|
||||
mS3SmmSaveState,
|
||||
EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE,
|
||||
Width,
|
||||
Address,
|
||||
Data,
|
||||
DataMask
|
||||
);
|
||||
}
|
||||
/**
|
||||
Internal function to add PciCfg write opcode to the table.
|
||||
|
||||
@param Marker The variable argument list to get the opcode
|
||||
and associated attributes.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
|
||||
@retval EFI_SUCCESS Opcode is added.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BootScriptPciCfgWrite (
|
||||
IN VA_LIST Marker
|
||||
)
|
||||
{
|
||||
EFI_BOOT_SCRIPT_WIDTH Width;
|
||||
UINT64 Address;
|
||||
UINTN Count;
|
||||
UINT8 *Buffer;
|
||||
|
||||
Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
|
||||
Address = VA_ARG (Marker, UINT64);
|
||||
Count = VA_ARG (Marker, UINTN);
|
||||
Buffer = VA_ARG (Marker, UINT8 *);
|
||||
|
||||
return mS3SmmSaveState->Write (
|
||||
mS3SmmSaveState,
|
||||
EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE,
|
||||
Width,
|
||||
Address,
|
||||
Count,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
/**
|
||||
Internal function to add stall opcode to the table.
|
||||
|
||||
@param Marker The variable argument list to get the opcode
|
||||
and associated attributes.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
|
||||
@retval EFI_SUCCESS Opcode is added.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BootScriptStall (
|
||||
IN VA_LIST Marker
|
||||
)
|
||||
{
|
||||
UINT32 Duration;
|
||||
|
||||
Duration = VA_ARG (Marker, UINT32);
|
||||
|
||||
return mS3SmmSaveState->Write (
|
||||
mS3SmmSaveState,
|
||||
EFI_BOOT_SCRIPT_STALL_OPCODE,
|
||||
Duration
|
||||
);
|
||||
}
|
||||
/**
|
||||
Internal function to add Save jmp address according to DISPATCH_OPCODE.
|
||||
We ignore "Context" parameter
|
||||
|
||||
@param Marker The variable argument list to get the opcode
|
||||
and associated attributes.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
|
||||
@retval EFI_SUCCESS Opcode is added.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BootScriptDispatch (
|
||||
IN VA_LIST Marker
|
||||
)
|
||||
{
|
||||
VOID *EntryPoint;
|
||||
|
||||
EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);
|
||||
return mS3SmmSaveState->Write (
|
||||
mS3SmmSaveState,
|
||||
EFI_BOOT_SCRIPT_DISPATCH_OPCODE,
|
||||
EntryPoint
|
||||
);
|
||||
}
|
||||
/**
|
||||
Internal function to add memory write opcode to the table.
|
||||
|
||||
@param Marker The variable argument list to get the opcode
|
||||
and associated attributes.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resource to do operation.
|
||||
@retval EFI_SUCCESS Opcode is added.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BootScriptMemWrite (
|
||||
IN VA_LIST Marker
|
||||
)
|
||||
{
|
||||
EFI_BOOT_SCRIPT_WIDTH Width;
|
||||
UINT64 Address;
|
||||
UINTN Count;
|
||||
UINT8 *Buffer;
|
||||
|
||||
Width = VA_ARG (Marker, EFI_BOOT_SCRIPT_WIDTH);
|
||||
Address = VA_ARG (Marker, UINT64);
|
||||
Count = VA_ARG (Marker, UINTN);
|
||||
Buffer = VA_ARG (Marker, UINT8 *);
|
||||
|
||||
return mS3SmmSaveState->Write (
|
||||
mS3SmmSaveState,
|
||||
EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE,
|
||||
Width,
|
||||
Address,
|
||||
Count,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
/**
|
||||
Adds a record into a specified Framework boot script table.
|
||||
|
||||
This function is used to store a boot script record into a given boot
|
||||
script table in SMM runtime. The parameter is the same with definitionin BootScriptSave Protocol.
|
||||
|
||||
@param ScriptTable Pointer to the script table to write to. In the thunk implementation, this parameter is ignored
|
||||
since the boot script table is maintained by BootScriptLib.
|
||||
@param Type Not used.
|
||||
@param OpCode The operation code (opcode) number.
|
||||
@param ... Argument list that is specific to each opcode.
|
||||
|
||||
@retval EFI_SUCCESS The operation succeeded. A record was added into the
|
||||
specified script table.
|
||||
@retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
|
||||
If the opcode is unknow or not supported because of the PCD
|
||||
Feature Flags.
|
||||
@retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmBootScriptWrite (
|
||||
IN OUT EFI_SMM_SCRIPT_TABLE *ScriptTable,
|
||||
IN UINTN Type,
|
||||
IN UINT16 OpCode,
|
||||
...
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VA_LIST Marker;
|
||||
|
||||
if (mS3SmmSaveState == NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Build script according to opcode
|
||||
//
|
||||
switch (OpCode) {
|
||||
|
||||
case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE:
|
||||
VA_START (Marker, OpCode);
|
||||
Status = BootScriptIoWrite (Marker);
|
||||
VA_END (Marker);
|
||||
break;
|
||||
|
||||
case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:
|
||||
VA_START (Marker, OpCode);
|
||||
Status = BootScriptIoReadWrite (Marker);
|
||||
VA_END (Marker);
|
||||
break;
|
||||
|
||||
case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:
|
||||
VA_START (Marker, OpCode);
|
||||
Status = BootScriptMemReadWrite (Marker);
|
||||
VA_END (Marker);
|
||||
break;
|
||||
|
||||
case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:
|
||||
VA_START (Marker, OpCode);
|
||||
Status = BootScriptPciCfgReadWrite (Marker);
|
||||
VA_END (Marker);
|
||||
break;
|
||||
|
||||
case EFI_BOOT_SCRIPT_STALL_OPCODE:
|
||||
VA_START (Marker, OpCode);
|
||||
Status = BootScriptStall (Marker);
|
||||
VA_END (Marker);
|
||||
break;
|
||||
|
||||
case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:
|
||||
VA_START (Marker, OpCode);
|
||||
Status = BootScriptDispatch (Marker);
|
||||
VA_END (Marker);
|
||||
break;
|
||||
|
||||
|
||||
case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE:
|
||||
VA_START (Marker, OpCode);
|
||||
Status = BootScriptPciCfgWrite (Marker);
|
||||
VA_END (Marker);
|
||||
break;
|
||||
|
||||
case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:
|
||||
VA_START (Marker, OpCode);
|
||||
Status = BootScriptMemWrite (Marker);
|
||||
VA_END (Marker);
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
/**
|
||||
Intialize Boot Script table.
|
||||
|
||||
This function should be called in SMM mode. The Thunk implementation is try to
|
||||
locate SmmSaveState protocol.
|
||||
|
||||
@param SystemTable Pointer to the EFI sytem table
|
||||
@param SmmScriptTablePages The expected ScriptTable page number
|
||||
@param SmmScriptTableBase The returned ScriptTable base address
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES No resource to do the initialization.
|
||||
@retval EFI_SUCCESS Function has completed successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeSmmScriptLib (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable,
|
||||
IN UINTN SmmScriptTablePages,
|
||||
OUT EFI_PHYSICAL_ADDRESS *SmmScriptTableBase
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN InSmm;
|
||||
EFI_SMM_BASE2_PROTOCOL *InternalSmmBase2;
|
||||
|
||||
InternalSmmBase2 = NULL;
|
||||
//
|
||||
// The boot Script table is maintained by DxeBootScript Lib. so there is no need to
|
||||
// allocate the table here and directly return zero
|
||||
//
|
||||
if (SmmScriptTableBase == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
*SmmScriptTableBase = 0;
|
||||
//
|
||||
// Retrieve SMM Base2 Protocol
|
||||
//
|
||||
Status = SystemTable->BootServices->LocateProtocol (
|
||||
&mEfiSmmBase2ProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &InternalSmmBase2
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
ASSERT (InternalSmmBase2 != NULL);
|
||||
|
||||
//
|
||||
// Check to see if we are already in SMM
|
||||
//
|
||||
InternalSmmBase2->InSmm (InternalSmmBase2, &InSmm);
|
||||
|
||||
if (!InSmm) {
|
||||
//
|
||||
// We are not in SMM, Directly return;
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// We are in SMM, retrieve the pointer to SMM System Table
|
||||
//
|
||||
InternalSmmBase2->GetSmstLocation (InternalSmmBase2, &gSmst);
|
||||
|
||||
ASSERT (gSmst != NULL);
|
||||
//
|
||||
// Locate Smm S3 Save State protocol to do the boot script save operation.
|
||||
//
|
||||
Status = gSmst->SmmLocateProtocol (
|
||||
&mEfiS3SmmSaveStateProtocolGuid,
|
||||
NULL,
|
||||
(VOID**)&mS3SmmSaveState
|
||||
);
|
||||
return Status;
|
||||
}
|
||||
/**
|
||||
Create Boot Script table.
|
||||
|
||||
It will be ignore and just return EFI_SUCCESS since the boot script table is
|
||||
maintained by DxeBootScriptLib. Create Table is not needed.
|
||||
|
||||
@param ScriptTable Pointer to the boot script table to create.
|
||||
@param Type The type of table to creat.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS Function has completed successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmBootScriptCreateTable (
|
||||
IN OUT EFI_SMM_SCRIPT_TABLE *ScriptTable,
|
||||
IN UINTN Type
|
||||
)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
/**
|
||||
Close Boot Script table.
|
||||
|
||||
It will be ignore and just return EFI_SUCCESS since the boot script table
|
||||
is maintained by DxeBootScriptLib.
|
||||
|
||||
@param ScriptTableBase Pointer to the boot script table to create.
|
||||
@param ScriptTablePtr Pointer to the script table to write to.
|
||||
@param Type The type of table to creat.
|
||||
|
||||
@retval EFI_SUCCESS Function has completed successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmBootScriptCloseTable (
|
||||
IN EFI_SMM_SCRIPT_TABLE ScriptTableBase,
|
||||
IN EFI_SMM_SCRIPT_TABLE ScriptTablePtr,
|
||||
IN UINTN Type
|
||||
)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
/** @file
|
||||
This is an thunk implementation of the BootScript at run time.
|
||||
|
||||
SmmScriptLib in Framework implementation is to save S3 Boot Script in SMM runtime.
|
||||
Here is the header file to define the API in this thunk library.
|
||||
|
||||
Copyright (c) 2010, 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
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SMM_SCRIPT_SAVE_H_
|
||||
#define _SMM_SCRIPT_SAVE_H_
|
||||
|
||||
#include "Tiano.h"
|
||||
#include "EfiBootScript.h"
|
||||
#include "PiSmmDefinition.h"
|
||||
#include "PiSmmS3SaveState.h"
|
||||
|
||||
|
||||
typedef EFI_PHYSICAL_ADDRESS EFI_SMM_SCRIPT_TABLE;
|
||||
/**
|
||||
Intialize Boot Script table.
|
||||
|
||||
This function should be called in SMM mode. The Thunk implementation is try to
|
||||
locate SmmSaveState protocol.
|
||||
|
||||
@param SystemTable Pointer to the EFI sytem table
|
||||
@param SmmScriptTablePages The expected ScriptTable page number
|
||||
@param SmmScriptTableBase The returned ScriptTable base address
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES No resource to do the initialization.
|
||||
@retval EFI_SUCCESS Function has completed successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeSmmScriptLib (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable,
|
||||
IN UINTN SmmScriptTablePages,
|
||||
OUT EFI_PHYSICAL_ADDRESS *SmmScriptTableBase
|
||||
);
|
||||
/**
|
||||
Create Boot Script table.
|
||||
|
||||
It will be ignore and just return EFI_SUCCESS since the boot script table is
|
||||
maintained by DxeBootScriptLib. Create Table is not needed.
|
||||
|
||||
@param ScriptTable Pointer to the boot script table to create.
|
||||
@param Type The type of table to creat.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS Function has completed successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmBootScriptCreateTable (
|
||||
IN OUT EFI_SMM_SCRIPT_TABLE *ScriptTable,
|
||||
IN UINTN Type
|
||||
);
|
||||
/**
|
||||
Adds a record into a specified Framework boot script table.
|
||||
|
||||
This function is used to store a boot script record into a given boot
|
||||
script table in SMM runtime. The parameter is the same with definitionin BootScriptSave Protocol.
|
||||
|
||||
@param ScriptTable Pointer to the script table to write to. In the thunk implementation, this parameter is ignored
|
||||
since the boot script table is maintained by BootScriptLib.
|
||||
@param Type Not used.
|
||||
@param OpCode The operation code (opcode) number.
|
||||
@param ... Argument list that is specific to each opcode.
|
||||
|
||||
@retval EFI_SUCCESS The operation succeeded. A record was added into the
|
||||
specified script table.
|
||||
@retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
|
||||
If the opcode is unknow or not supported because of the PCD
|
||||
Feature Flags.
|
||||
@retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmBootScriptWrite (
|
||||
IN OUT EFI_SMM_SCRIPT_TABLE *ScriptTable,
|
||||
IN UINTN Type,
|
||||
IN UINT16 OpCode,
|
||||
...
|
||||
);
|
||||
/**
|
||||
Close Boot Script table.
|
||||
|
||||
It will be ignore and just return EFI_SUCCESS since the boot script table
|
||||
is maintained by DxeBootScriptLib.
|
||||
|
||||
@param ScriptTableBase Pointer to the boot script table to create.
|
||||
@param ScriptTablePtr Pointer to the script table to write to.
|
||||
@param Type The type of table to creat.
|
||||
|
||||
@retval EFI_SUCCESS - Function has completed successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmBootScriptCloseTable (
|
||||
IN EFI_SMM_SCRIPT_TABLE ScriptTableBase,
|
||||
IN EFI_SMM_SCRIPT_TABLE ScriptTablePtr,
|
||||
IN UINTN Type
|
||||
);
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,43 @@
|
|||
## @file
|
||||
#
|
||||
# Copyright (c) 2010 - 2011, 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
|
||||
# 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.
|
||||
#
|
||||
##
|
||||
|
||||
[defines]
|
||||
BASE_NAME = SmmScriptLib
|
||||
COMPONENT_TYPE = LIBRARY
|
||||
|
||||
[sources.common]
|
||||
SmmScriptLib.c
|
||||
SmmScriptLib.h
|
||||
PiSmmDefinition.h
|
||||
PiSmmS3SaveState.h
|
||||
|
||||
|
||||
[includes.common]
|
||||
$(EDK_SOURCE)/Foundation/Framework
|
||||
$(EDK_SOURCE)/Foundation/Efi
|
||||
.
|
||||
$(EDK_SOURCE)/Foundation/Include
|
||||
$(EDK_SOURCE)/Foundation/Efi/Include
|
||||
$(EDK_SOURCE)/Foundation/Framework/Include
|
||||
$(EDK_SOURCE)/Foundation/Include/IndustryStandard
|
||||
$(EDK_SOURCE)/Foundation/Library/Dxe/Include
|
||||
$(EFI_SOURCE)
|
||||
$(EDK_SOURCE)/Foundation/Core/Dxe
|
||||
$(EFI_SOURCE)/Library/Smm/Include
|
||||
|
||||
[libraries.common]
|
||||
EdkFrameworkProtocolLib
|
||||
GuidLib
|
||||
|
||||
[nmake.common]
|
Loading…
Reference in New Issue