TianoCore EDK2 master
CpuS3.c File Reference
#include "PiSmmCpuDxeSmm.h"

Go to the source code of this file.

Data Structures

struct  MP_CPU_EXCHANGE_INFO
 
struct  MP_ASSEMBLY_ADDRESS_MAP
 
struct  PROGRAM_CPU_REGISTER_FLAGS
 

Macros

#define LEGACY_REGION_SIZE   (2 * 0x1000)
 
#define LEGACY_REGION_BASE   (0xA0000 - LEGACY_REGION_SIZE)
 

Functions

VOID *EFIAPI AsmGetAddressMap (MP_ASSEMBLY_ADDRESS_MAP *AddressMap)
 
VOID EFIAPI LoadMtrrData (EFI_PHYSICAL_ADDRESS MtrrTable)
 
VOID S3ReleaseSemaphore (IN OUT volatile UINT32 *Sem)
 
VOID S3WaitForSemaphore (IN OUT volatile UINT32 *Sem)
 
UINTN ReadWriteCr (IN UINT32 CrIndex, IN BOOLEAN Read, IN OUT UINTN *CrValue)
 
VOID ProgramProcessorRegister (IN CPU_REGISTER_TABLE *RegisterTable, IN EFI_CPU_PHYSICAL_LOCATION *ApLocation, IN CPU_STATUS_INFORMATION *CpuStatus, IN PROGRAM_CPU_REGISTER_FLAGS *CpuFlags)
 
VOID SetRegister (IN BOOLEAN PreSmmRegisterTable)
 
VOID InitializeAp (VOID)
 
VOID PrepareApStartupVector (EFI_PHYSICAL_ADDRESS WorkingBuffer)
 
VOID InitializeCpuBeforeRebase (VOID)
 
VOID InitializeCpuAfterRebase (VOID)
 
VOID RestoreSmmConfigurationInS3 (VOID)
 
VOID EFIAPI SmmRestoreCpu (VOID)
 
VOID InitSmmS3ResumeState (IN UINT32 Cr3)
 
VOID CopyRegisterTable (IN CPU_REGISTER_TABLE *DestinationRegisterTableList, IN CPU_REGISTER_TABLE *SourceRegisterTableList, IN UINT32 NumberOfCpus)
 
BOOLEAN IsRegisterTableEmpty (IN CPU_REGISTER_TABLE *RegisterTable, IN UINT32 NumberOfCpus)
 
VOID CopyCpuFeatureInitDatatoSmram (IN OUT CPU_FEATURE_INIT_DATA *CpuFeatureInitDataDst, IN CPU_FEATURE_INIT_DATA *CpuFeatureInitDataSrc)
 
VOID GetAcpiCpuData (VOID)
 
VOID GetAcpiS3EnableFlag (VOID)
 

Variables

volatile BOOLEAN mInitApsAfterSmmBaseReloc
 
PROGRAM_CPU_REGISTER_FLAGS mCpuFlags
 
ACPI_CPU_DATA mAcpiCpuData
 
volatile UINT32 mNumberToFinish
 
MP_CPU_EXCHANGE_INFOmExchangeInfo
 
BOOLEAN mRestoreSmmConfigurationInS3 = FALSE
 
BOOLEAN mSmmS3Flag = FALSE
 
SMM_S3_RESUME_STATEmSmmS3ResumeState = NULL
 
BOOLEAN mAcpiS3Enable = TRUE
 
UINT8mApHltLoopCode = NULL
 
UINT8 mApHltLoopCodeTemplate []
 

Detailed Description

Code for Processor S3 restoration

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

Definition in file CpuS3.c.

Macro Definition Documentation

◆ LEGACY_REGION_BASE

#define LEGACY_REGION_BASE   (0xA0000 - LEGACY_REGION_SIZE)

Definition at line 63 of file CpuS3.c.

◆ LEGACY_REGION_SIZE

#define LEGACY_REGION_SIZE   (2 * 0x1000)

Definition at line 62 of file CpuS3.c.

Function Documentation

◆ AsmGetAddressMap()

VOID *EFIAPI AsmGetAddressMap ( MP_ASSEMBLY_ADDRESS_MAP AddressMap)

Get starting address and size of the rendezvous entry for APs. Information for fixing a jump instruction in the code is also returned.

Parameters
AddressMapOutput buffer for address map information.

◆ CopyCpuFeatureInitDatatoSmram()

VOID CopyCpuFeatureInitDatatoSmram ( IN OUT CPU_FEATURE_INIT_DATA CpuFeatureInitDataDst,
IN CPU_FEATURE_INIT_DATA CpuFeatureInitDataSrc 
)

Copy the data used to initialize processor register into SMRAM.

Parameters
[in,out]CpuFeatureInitDataDstPointer to the destination CPU_FEATURE_INIT_DATA structure.
[in]CpuFeatureInitDataSrcPointer to the source CPU_FEATURE_INIT_DATA structure.

Definition at line 1042 of file CpuS3.c.

◆ CopyRegisterTable()

VOID CopyRegisterTable ( IN CPU_REGISTER_TABLE DestinationRegisterTableList,
IN CPU_REGISTER_TABLE SourceRegisterTableList,
IN UINT32  NumberOfCpus 
)

Copy register table from non-SMRAM into SMRAM.

Parameters
[in]DestinationRegisterTableListPoints to destination register table.
[in]SourceRegisterTableListPoints to source register table.
[in]NumberOfCpusNumber of CPUs.

Definition at line 983 of file CpuS3.c.

◆ GetAcpiCpuData()

VOID GetAcpiCpuData ( VOID  )

Get ACPI CPU data.

Definition at line 1104 of file CpuS3.c.

◆ GetAcpiS3EnableFlag()

VOID GetAcpiS3EnableFlag ( VOID  )

Get ACPI S3 enable flag.

Definition at line 1205 of file CpuS3.c.

◆ InitializeAp()

VOID InitializeAp ( VOID  )

AP initialization before then after SMBASE relocation in the S3 boot path.

Definition at line 545 of file CpuS3.c.

◆ InitializeCpuAfterRebase()

VOID InitializeCpuAfterRebase ( VOID  )

The function is invoked after SMBASE relocation in S3 path to restores CPU status.

The function is invoked after SMBASE relocation in S3 path. It restores configuration according to data saved by normal boot path for both BSP and APs.

Definition at line 684 of file CpuS3.c.

◆ InitializeCpuBeforeRebase()

VOID InitializeCpuBeforeRebase ( VOID  )

The function is invoked before SMBASE relocation in S3 path to restores CPU status.

The function is invoked before SMBASE relocation in S3 path. It does first time microcode load and restores MTRRs for both BSP and APs.

Definition at line 640 of file CpuS3.c.

◆ InitSmmS3ResumeState()

VOID InitSmmS3ResumeState ( IN UINT32  Cr3)

Initialize SMM S3 resume state structure used during S3 Resume.

Parameters
[in]Cr3The base address of the page tables to use in SMM.

Definition at line 898 of file CpuS3.c.

◆ IsRegisterTableEmpty()

BOOLEAN IsRegisterTableEmpty ( IN CPU_REGISTER_TABLE RegisterTable,
IN UINT32  NumberOfCpus 
)

Check whether the register table is empty or not.

Parameters
[in]RegisterTablePoint to the register table.
[in]NumberOfCpusNumber of CPUs.
Return values
TRUEThe register table is empty.
FALSEThe register table is not empty.

Definition at line 1016 of file CpuS3.c.

◆ LoadMtrrData()

VOID EFIAPI LoadMtrrData ( EFI_PHYSICAL_ADDRESS  MtrrTable)

Sync up the MTRR values for all processors.

Parameters
MtrrTableTable holding fixed/variable MTRR values to be loaded.

Definition at line 99 of file CpuS3.c.

◆ PrepareApStartupVector()

VOID PrepareApStartupVector ( EFI_PHYSICAL_ADDRESS  WorkingBuffer)

Prepares startup vector for APs.

This function prepares startup vector for APs.

Parameters
WorkingBufferThe address of the work buffer.

Definition at line 590 of file CpuS3.c.

◆ ProgramProcessorRegister()

VOID ProgramProcessorRegister ( IN CPU_REGISTER_TABLE RegisterTable,
IN EFI_CPU_PHYSICAL_LOCATION ApLocation,
IN CPU_STATUS_INFORMATION CpuStatus,
IN PROGRAM_CPU_REGISTER_FLAGS CpuFlags 
)

Initialize the CPU registers from a register table.

Parameters
[in]RegisterTableThe register table for this AP.
[in]ApLocationAP location info for this ap.
[in]CpuStatusCPU status info for this CPU.
[in]CpuFlagsFlags data structure used when program the register.
Note
This service could be called by BSP/APs.

Definition at line 230 of file CpuS3.c.

◆ ReadWriteCr()

UINTN ReadWriteCr ( IN UINT32  CrIndex,
IN BOOLEAN  Read,
IN OUT UINTN CrValue 
)

Read / write CR value.

Parameters
[in]CrIndexThe CR index which need to read/write.
[in]ReadRead or write. TRUE is read.
[in,out]CrValueCR value.
Return values
EFI_SUCCESSmeans read/write success, else return EFI_UNSUPPORTED.

Definition at line 173 of file CpuS3.c.

◆ RestoreSmmConfigurationInS3()

VOID RestoreSmmConfigurationInS3 ( VOID  )

Restore SMM Configuration in S3 boot path.

Definition at line 722 of file CpuS3.c.

◆ S3ReleaseSemaphore()

VOID S3ReleaseSemaphore ( IN OUT volatile UINT32 Sem)

Increment semaphore by 1.

Parameters
SemIN: 32-bit unsigned integer

Definition at line 129 of file CpuS3.c.

◆ S3WaitForSemaphore()

VOID S3WaitForSemaphore ( IN OUT volatile UINT32 Sem)

Decrement the semaphore by 1 if it is not zero.

Performs an atomic decrement operation for semaphore. The compare exchange operation must be performed using MP safe mechanisms.

Parameters
SemIN: 32-bit unsigned integer

Definition at line 147 of file CpuS3.c.

◆ SetRegister()

VOID SetRegister ( IN BOOLEAN  PreSmmRegisterTable)

Set Processor register for one AP.

Parameters
PreSmmRegisterTableUse pre Smm register table or register table.

Definition at line 488 of file CpuS3.c.

◆ SmmRestoreCpu()

VOID EFIAPI SmmRestoreCpu ( VOID  )

Perform SMM initialization for all processors in the S3 boot path.

For a native platform, MP initialization in the S3 boot path is also performed in this function.

Definition at line 761 of file CpuS3.c.

Variable Documentation

◆ mAcpiCpuData

ACPI_CPU_DATA mAcpiCpuData

Definition at line 66 of file CpuS3.c.

◆ mAcpiS3Enable

BOOLEAN mAcpiS3Enable = TRUE

Definition at line 81 of file CpuS3.c.

◆ mApHltLoopCode

UINT8* mApHltLoopCode = NULL

Definition at line 83 of file CpuS3.c.

◆ mApHltLoopCodeTemplate

UINT8 mApHltLoopCodeTemplate[]
Initial value:
= {
0x8B, 0x44, 0x24, 0x04,
0xF0, 0xFF, 0x08,
0xFA,
0xF4,
0xEB, 0xFC
}

Definition at line 84 of file CpuS3.c.

◆ mCpuFlags

Definition at line 65 of file CpuS3.c.

◆ mExchangeInfo

MP_CPU_EXCHANGE_INFO* mExchangeInfo

Definition at line 68 of file CpuS3.c.

◆ mInitApsAfterSmmBaseReloc

volatile BOOLEAN mInitApsAfterSmmBaseReloc

Definition at line 48 of file CpuS3.c.

◆ mNumberToFinish

volatile UINT32 mNumberToFinish

Definition at line 67 of file CpuS3.c.

◆ mRestoreSmmConfigurationInS3

BOOLEAN mRestoreSmmConfigurationInS3 = FALSE

Definition at line 69 of file CpuS3.c.

◆ mSmmS3Flag

BOOLEAN mSmmS3Flag = FALSE

Definition at line 74 of file CpuS3.c.

◆ mSmmS3ResumeState

SMM_S3_RESUME_STATE* mSmmS3ResumeState = NULL

Definition at line 79 of file CpuS3.c.