TianoCore EDK2 master
Loading...
Searching...
No Matches
BlSupportSmm.c File Reference
#include <BlSupportSmm.h>

Go to the source code of this file.

Functions

EFI_STATUS SaveSmmInfoForS3 (IN UINT8 BlSwSmiHandlerInput)
 
PLD_GENERIC_REGISTERGetRegisterById (UINT64 Id)
 
VOID LockSmiGlobalEn (VOID)
 
VOID SmmFeatureLockOnS3 (VOID)
 
VOID EFIAPI SetSmrr (IN VOID *ProcedureArgument)
 
VOID SetSmrrOnS3 (VOID)
 
EFI_STATUS EFIAPI BlSwSmiHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context, IN OUT VOID *CommBuffer, IN OUT UINTN *CommBufferSize)
 
EFI_STATUS EFIAPI BlSupportSmmReadyToLockCallback (IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
 
EFI_STATUS EFIAPI BlSupportSmm (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

PLD_S3_COMMUNICATION mPldS3Hob
 
EFI_SMRAM_HOB_DESCRIPTOR_BLOCKmSmramHob = NULL
 
PLD_SMM_REGISTERSmSmmRegisterHob = NULL
 
UINT64 mSmmFeatureControl = 0
 

Detailed Description

This driver is used for SMM S3 support for the bootloader that doesn't support SMM. The payload would save SMM rebase info to SMM communication area. The bootloader is expected to rebase the SMM and trigger SMI by writting 0xB2 port with given value from SMM communication area. The paylaod SMM handler got chance to restore regs in S3 path.

Copyright (c) 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file BlSupportSmm.c.

Function Documentation

◆ BlSupportSmm()

EFI_STATUS EFIAPI BlSupportSmm ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The driver's entry point.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.
OthersSome error occurs when executing this entry point.

Definition at line 345 of file BlSupportSmm.c.

◆ BlSupportSmmReadyToLockCallback()

EFI_STATUS EFIAPI BlSupportSmmReadyToLockCallback ( IN CONST EFI_GUID Protocol,
IN VOID *  Interface,
IN EFI_HANDLE  Handle 
)

Lock SMI in this SMM ready to lock event.

Parameters
ProtocolPoints to the protocol's unique identifier
InterfacePoints to the interface instance
HandleThe handle on which the interface was installed
Return values
EFI_SUCCESSSmmEventCallback runs successfully
EFI_NOT_FOUNDThe Fvb protocol for variable is not found.

Definition at line 320 of file BlSupportSmm.c.

◆ BlSwSmiHandler()

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

Software SMI callback for restoring SMRR base and mask in S3 path.

Parameters
[in]DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
[in]ContextPoints to an optional handler context which was specified when the handler was registered.
[in,out]CommBufferA pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment.
[in,out]CommBufferSizeThe size of the CommBuffer.
Return values
EFI_SUCCESSThe interrupt was handled successfully.

Definition at line 294 of file BlSupportSmm.c.

◆ GetRegisterById()

PLD_GENERIC_REGISTER * GetRegisterById ( UINT64  Id)

Get specified SMI register based on given register ID

Parameters
[in]IdThe register ID to get.
Return values
NULLThe register is not found
Returns
smi register

Definition at line 112 of file BlSupportSmm.c.

◆ LockSmiGlobalEn()

VOID LockSmiGlobalEn ( VOID  )

Set SMM SMI Global enable lock

Definition at line 132 of file BlSupportSmm.c.

◆ SaveSmmInfoForS3()

EFI_STATUS SaveSmmInfoForS3 ( IN UINT8  BlSwSmiHandlerInput)

Save SMM rebase and SMI handler information to SMM communication area

The function detects SMM communication region for boot loader, if it is detected, it will save SMM rebase information and S3 SMI handler information to SMM communication region. Bootloader should consume these information in S3 path to restore smm base, and write the 0xB2 port to trigger SMI so that payload could resume S3 registers.

Parameters
[in]BlSwSmiHandlerInputValue written to 0xB2 to trigger SMI handler.
Return values
EFI_SUCCESSSave SMM info success.
OthersFailed to save SMM info.

Definition at line 35 of file BlSupportSmm.c.

◆ SetSmrr()

VOID EFIAPI SetSmrr ( IN VOID *  ProcedureArgument)

Function to program SMRR base and mask.

Parameters
[in]ProcedureArgumentPointer to SMRR_BASE_MASK structure.

Definition at line 195 of file BlSupportSmm.c.

◆ SetSmrrOnS3()

VOID SetSmrrOnS3 ( VOID  )

Set SMRR in S3 path.

Definition at line 210 of file BlSupportSmm.c.

◆ SmmFeatureLockOnS3()

VOID SmmFeatureLockOnS3 ( VOID  )

Check and set SMM feature lock bit and code check enable bit in S3 path.

Definition at line 169 of file BlSupportSmm.c.

Variable Documentation

◆ mPldS3Hob

Definition at line 16 of file BlSupportSmm.c.

◆ mSmmFeatureControl

UINT64 mSmmFeatureControl = 0

Definition at line 19 of file BlSupportSmm.c.

◆ mSmmRegisterHob

PLD_SMM_REGISTERS* mSmmRegisterHob = NULL

Definition at line 18 of file BlSupportSmm.c.

◆ mSmramHob

Definition at line 17 of file BlSupportSmm.c.