TianoCore EDK2 master
Loading...
Searching...
No Matches
RegisterCpuFeaturesLib.c File Reference

Go to the source code of this file.

Functions

VOID DumpCpuFeatureMask (IN UINT8 *FeatureMask, IN UINT32 BitMaskSize)
 
VOID DumpCpuFeature (IN CPU_FEATURES_ENTRY *CpuFeature, IN UINT32 BitMaskSize)
 
BOOLEAN IsBitMaskMatchCheck (IN UINT8 *FeatureMask, IN UINT8 *DependentBitMask)
 
BOOLEAN FindSpecifyFeature (IN LIST_ENTRY *FeatureList, IN LIST_ENTRY *CurrentEntry, IN BOOLEAN SearchFormer, IN UINT8 *FeatureMask)
 
CPU_FEATURE_DEPENDENCE_TYPE DetectFeatureScope (IN CPU_FEATURES_ENTRY *CpuFeature, IN BOOLEAN Before, IN UINT8 *NextCpuFeatureMask)
 
CPU_FEATURE_DEPENDENCE_TYPE DetectNoneNeighborhoodFeatureScope (IN CPU_FEATURES_ENTRY *CpuFeature, IN BOOLEAN Before, IN LIST_ENTRY *FeatureList)
 
BOOLEAN AdjustFeaturesDependence (IN OUT CPU_FEATURES_ENTRY *PreviousFeature, IN OUT CPU_FEATURES_ENTRY *CurrentFeature, IN CPU_FEATURES_ENTRY *FindFeature, IN BOOLEAN Before)
 
VOID AdjustEntry (IN LIST_ENTRY *FeatureList, IN OUT LIST_ENTRY *FindEntry, IN OUT LIST_ENTRY *CurrentEntry, IN BOOLEAN Before)
 
BOOLEAN InsertToBeforeEntry (IN LIST_ENTRY *FeatureList, IN LIST_ENTRY *CurrentEntry, IN UINT8 *FeatureMask)
 
BOOLEAN InsertToAfterEntry (IN LIST_ENTRY *FeatureList, IN LIST_ENTRY *CurrentEntry, IN UINT8 *FeatureMask)
 
VOID CheckCpuFeaturesDependency (IN LIST_ENTRY *FeatureList)
 
RETURN_STATUS RegisterCpuFeatureWorker (IN CPU_FEATURES_DATA *CpuFeaturesData, IN CPU_FEATURES_ENTRY *CpuFeature)
 
VOID SetCpuFeaturesBitMask (IN UINT8 **FeaturesBitMask, IN UINT32 Feature, IN UINTN BitMaskSize)
 
RETURN_STATUS EFIAPI RegisterCpuFeature (IN CHAR8 *FeatureName OPTIONAL, IN CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc OPTIONAL, IN CPU_FEATURE_SUPPORT SupportFunc OPTIONAL, IN CPU_FEATURE_INITIALIZE InitializeFunc OPTIONAL,...)
 
ACPI_CPU_DATAGetAcpiCpuData (VOID)
 
STATIC VOID EnlargeRegisterTable (IN OUT CPU_REGISTER_TABLE *RegisterTable)
 
VOID CpuRegisterTableWriteWorker (IN BOOLEAN PreSmmFlag, IN UINTN ProcessorNumber, IN REGISTER_TYPE RegisterType, IN UINT64 Index, IN UINT8 ValidBitStart, IN UINT8 ValidBitLength, IN UINT64 Value, IN BOOLEAN TestThenWrite)
 
VOID EFIAPI CpuRegisterTableWrite (IN UINTN ProcessorNumber, IN REGISTER_TYPE RegisterType, IN UINT64 Index, IN UINT64 ValueMask, IN UINT64 Value)
 
VOID EFIAPI CpuRegisterTableTestThenWrite (IN UINTN ProcessorNumber, IN REGISTER_TYPE RegisterType, IN UINT64 Index, IN UINT64 ValueMask, IN UINT64 Value)
 
VOID EFIAPI PreSmmCpuRegisterTableWrite (IN UINTN ProcessorNumber, IN REGISTER_TYPE RegisterType, IN UINT64 Index, IN UINT64 ValueMask, IN UINT64 Value)
 
BOOLEAN IsCpuFeatureSetInCpuPcd (IN UINT8 *CpuBitMask, IN UINTN CpuBitMaskSize, IN UINT32 Feature)
 
BOOLEAN EFIAPI IsCpuFeatureSupported (IN UINT32 Feature)
 
BOOLEAN EFIAPI IsCpuFeatureInSetting (IN UINT32 Feature)
 
VOID EFIAPI SwitchBspAfterFeaturesInitialize (IN UINTN ProcessorNumber)
 

Detailed Description

CPU Register Table Library functions.

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

Definition in file RegisterCpuFeaturesLib.c.

Function Documentation

◆ AdjustEntry()

VOID AdjustEntry ( IN LIST_ENTRY FeatureList,
IN OUT LIST_ENTRY FindEntry,
IN OUT LIST_ENTRY CurrentEntry,
IN BOOLEAN  Before 
)

Base on dependence relationship to asjust feature order.

Parameters
[in]FeatureListPointer to CPU feature list
[in,out]FindEntryThe entry this feature depend on.
[in,out]CurrentEntryThe entry for this feature.
[in]BeforeBefore or after dependence relationship.

Definition at line 351 of file RegisterCpuFeaturesLib.c.

◆ AdjustFeaturesDependence()

BOOLEAN AdjustFeaturesDependence ( IN OUT CPU_FEATURES_ENTRY PreviousFeature,
IN OUT CPU_FEATURES_ENTRY CurrentFeature,
IN CPU_FEATURES_ENTRY FindFeature,
IN BOOLEAN  Before 
)

Base on dependence relationship to asjust feature dependence.

ONLY when the feature before(or after) the find feature also has dependence with the find feature. In this case, driver need to base on dependce relationship to decide how to insert current feature and adjust the feature dependence.

Parameters
[in,out]PreviousFeatureCPU feature current before the find one.
[in,out]CurrentFeatureCpu feature need to adjust.
[in]FindFeatureCpu feature which current feature depends.
[in]BeforeBefore or after dependence relationship.
Return values
TRUEmeans the current feature dependence has been adjusted.
FALSEmeans the previous feature dependence has been adjusted. or previous feature has no dependence with the find one.

Definition at line 309 of file RegisterCpuFeaturesLib.c.

◆ CheckCpuFeaturesDependency()

VOID CheckCpuFeaturesDependency ( IN LIST_ENTRY FeatureList)

Checks and adjusts CPU features order per dependency relationship.

Parameters
[in]FeatureListPointer to CPU feature list

Definition at line 508 of file RegisterCpuFeaturesLib.c.

◆ CpuRegisterTableTestThenWrite()

VOID EFIAPI CpuRegisterTableTestThenWrite ( IN UINTN  ProcessorNumber,
IN REGISTER_TYPE  RegisterType,
IN UINT64  Index,
IN UINT64  ValueMask,
IN UINT64  Value 
)

Adds an entry in specified register table.

This function adds an entry in specified register table, with given register type, register index, bit section and value.

Parameters
[in]ProcessorNumberThe index of the CPU to add a register table entry
[in]RegisterTypeType of the register to program
[in]IndexIndex of the register to program
[in]ValueMaskMask of bits in register to write
[in]ValueValue to write
Note
This service could be called by BSP only.

Definition at line 1194 of file RegisterCpuFeaturesLib.c.

◆ CpuRegisterTableWrite()

VOID EFIAPI CpuRegisterTableWrite ( IN UINTN  ProcessorNumber,
IN REGISTER_TYPE  RegisterType,
IN UINT64  Index,
IN UINT64  ValueMask,
IN UINT64  Value 
)

Adds an entry in specified register table.

This function adds an entry in specified register table, with given register type, register index, bit section and value.

Parameters
[in]ProcessorNumberThe index of the CPU to add a register table entry
[in]RegisterTypeType of the register to program
[in]IndexIndex of the register to program
[in]ValueMaskMask of bits in register to write
[in]ValueValue to write
Note
This service could be called by BSP only.

Definition at line 1160 of file RegisterCpuFeaturesLib.c.

◆ CpuRegisterTableWriteWorker()

VOID CpuRegisterTableWriteWorker ( IN BOOLEAN  PreSmmFlag,
IN UINTN  ProcessorNumber,
IN REGISTER_TYPE  RegisterType,
IN UINT64  Index,
IN UINT8  ValidBitStart,
IN UINT8  ValidBitLength,
IN UINT64  Value,
IN BOOLEAN  TestThenWrite 
)

Add an entry in specified register table.

This function adds an entry in specified register table, with given register type, register index, bit section and value.

Parameters
[in]PreSmmFlagIf TRUE, entry will be added into PreSmm register table If FALSE, entry will be added into register table
[in]ProcessorNumberThe index of the CPU to add a register table entry
[in]RegisterTypeType of the register to program
[in]IndexIndex of the register to program
[in]ValidBitStartStart of the bit section
[in]ValidBitLengthLength of the bit section
[in]ValueValue to write
[in]TestThenWriteWhether need to test current Value before writing.

Definition at line 1095 of file RegisterCpuFeaturesLib.c.

◆ DetectFeatureScope()

CPU_FEATURE_DEPENDENCE_TYPE DetectFeatureScope ( IN CPU_FEATURES_ENTRY CpuFeature,
IN BOOLEAN  Before,
IN UINT8 *  NextCpuFeatureMask 
)

Return feature dependence result.

Parameters
[in]CpuFeaturePointer to CPU feature.
[in]BeforeCheck before dependence or after.
[in]NextCpuFeatureMaskPointer to next CPU feature Mask.
Return values
returnthe dependence result.

Definition at line 168 of file RegisterCpuFeaturesLib.c.

◆ DetectNoneNeighborhoodFeatureScope()

CPU_FEATURE_DEPENDENCE_TYPE DetectNoneNeighborhoodFeatureScope ( IN CPU_FEATURES_ENTRY CpuFeature,
IN BOOLEAN  Before,
IN LIST_ENTRY FeatureList 
)

Return feature dependence result.

Parameters
[in]CpuFeaturePointer to CPU feature.
[in]BeforeCheck before dependence or after.
[in]FeatureListPointer to CPU feature list.
Return values
returnthe dependence result.

Definition at line 240 of file RegisterCpuFeaturesLib.c.

◆ DumpCpuFeature()

VOID DumpCpuFeature ( IN CPU_FEATURES_ENTRY CpuFeature,
IN UINT32  BitMaskSize 
)

Dump CPU feature name or CPU feature bit mask.

Parameters
[in]CpuFeaturePointer to CPU_FEATURES_ENTRY
[in]BitMaskSizeCPU feature bits mask buffer size.

Definition at line 43 of file RegisterCpuFeaturesLib.c.

◆ DumpCpuFeatureMask()

VOID DumpCpuFeatureMask ( IN UINT8 *  FeatureMask,
IN UINT32  BitMaskSize 
)

Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask.

Parameters
[in]FeatureMaskA pointer to the CPU feature bit mask.
[in]BitMaskSizeCPU feature bits mask buffer size.

Definition at line 19 of file RegisterCpuFeaturesLib.c.

◆ EnlargeRegisterTable()

STATIC VOID EnlargeRegisterTable ( IN OUT CPU_REGISTER_TABLE RegisterTable)

Enlarges CPU register table for each processor.

Parameters
[in,out]RegisterTablePointer processor's CPU register table

Definition at line 1045 of file RegisterCpuFeaturesLib.c.

◆ FindSpecifyFeature()

BOOLEAN FindSpecifyFeature ( IN LIST_ENTRY FeatureList,
IN LIST_ENTRY CurrentEntry,
IN BOOLEAN  SearchFormer,
IN UINT8 *  FeatureMask 
)

Try to find the specify cpu featuren in former/after feature list.

Parameters
[in]FeatureListPointer to dependent CPU feature list
[in]CurrentEntryPointer to current CPU feature entry.
[in]SearchFormerFind in former feature or after features.
[in]FeatureMaskPointer to CPU feature bit mask
Return values
TRUEThe feature bit mask is in dependent CPU feature bit mask buffer.
FALSEThe feature bit mask is not in dependent CPU feature bit mask buffer.

Definition at line 101 of file RegisterCpuFeaturesLib.c.

◆ GetAcpiCpuData()

ACPI_CPU_DATA * GetAcpiCpuData ( VOID  )

Return ACPI_CPU_DATA data.

Returns
Pointer to ACPI_CPU_DATA data.

Definition at line 971 of file RegisterCpuFeaturesLib.c.

◆ InsertToAfterEntry()

BOOLEAN InsertToAfterEntry ( IN LIST_ENTRY FeatureList,
IN LIST_ENTRY CurrentEntry,
IN UINT8 *  FeatureMask 
)

Checks and adjusts current CPU features per dependency relationship.

Parameters
[in]FeatureListPointer to CPU feature list
[in]CurrentEntryPointer to current checked CPU feature
[in]FeatureMaskThe feature bit mask.
Return values
returnSwapped info.

Definition at line 472 of file RegisterCpuFeaturesLib.c.

◆ InsertToBeforeEntry()

BOOLEAN InsertToBeforeEntry ( IN LIST_ENTRY FeatureList,
IN LIST_ENTRY CurrentEntry,
IN UINT8 *  FeatureMask 
)

Checks and adjusts current CPU features per dependency relationship.

Parameters
[in]FeatureListPointer to CPU feature list
[in]CurrentEntryPointer to current checked CPU feature
[in]FeatureMaskThe feature bit mask.
Return values
returnSwapped info.

Definition at line 432 of file RegisterCpuFeaturesLib.c.

◆ IsBitMaskMatchCheck()

BOOLEAN IsBitMaskMatchCheck ( IN UINT8 *  FeatureMask,
IN UINT8 *  DependentBitMask 
)

Determines if the feature bit mask is in dependent CPU feature bit mask buffer.

Parameters
[in]FeatureMaskPointer to CPU feature bit mask
[in]DependentBitMaskPointer to dependent CPU feature bit mask buffer
Return values
TRUEThe feature bit mask is in dependent CPU feature bit mask buffer.
FALSEThe feature bit mask is not in dependent CPU feature bit mask buffer.

Definition at line 66 of file RegisterCpuFeaturesLib.c.

◆ IsCpuFeatureInSetting()

BOOLEAN EFIAPI IsCpuFeatureInSetting ( IN UINT32  Feature)

Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask.

Parameters
[in]FeatureThe bit number of the CPU feature to check in the PCD PcdCpuFeaturesSetting
Return values
TRUEThe CPU feature is set in PcdCpuFeaturesSetting.
FALSEThe CPU feature is not set in PcdCpuFeaturesSetting.
Note
This service could be called by BSP only.

Definition at line 1311 of file RegisterCpuFeaturesLib.c.

◆ IsCpuFeatureSetInCpuPcd()

BOOLEAN IsCpuFeatureSetInCpuPcd ( IN UINT8 *  CpuBitMask,
IN UINTN  CpuBitMaskSize,
IN UINT32  Feature 
)

Worker function to determine if a CPU feature is set in input CPU feature bit mask buffer.

Parameters
[in]CpuBitMaskCPU feature bit mask buffer
[in]CpuBitMaskSizeThe size of CPU feature bit mask buffer
[in]FeatureThe bit number of the CPU feature
Return values
TRUEThe CPU feature is set in CpuBitMask.
FALSEThe CPU feature is not set in CpuBitMask.

Definition at line 1258 of file RegisterCpuFeaturesLib.c.

◆ IsCpuFeatureSupported()

BOOLEAN EFIAPI IsCpuFeatureSupported ( IN UINT32  Feature)

Determines if a CPU feature is enabled in PcdCpuFeaturesSupport bit mask. If a CPU feature is disabled in PcdCpuFeaturesSupport then all the code/data associated with that feature should be optimized away if compiler optimizations are enabled.

Parameters
[in]FeatureThe bit number of the CPU feature to check in the PCD PcdCpuFeaturesSupport
Return values
TRUEThe CPU feature is set in PcdCpuFeaturesSupport.
FALSEThe CPU feature is not set in PcdCpuFeaturesSupport.
Note
This service could be called by BSP only.

Definition at line 1287 of file RegisterCpuFeaturesLib.c.

◆ PreSmmCpuRegisterTableWrite()

VOID EFIAPI PreSmmCpuRegisterTableWrite ( IN UINTN  ProcessorNumber,
IN REGISTER_TYPE  RegisterType,
IN UINT64  Index,
IN UINT64  ValueMask,
IN UINT64  Value 
)

Adds an entry in specified Pre-SMM register table.

This function adds an entry in specified register table, with given register type, register index, bit section and value.

Parameters
[in]ProcessorNumberThe index of the CPU to add a register table entry.
[in]RegisterTypeType of the register to program
[in]IndexIndex of the register to program
[in]ValueMaskMask of bits in register to write
[in]ValueValue to write
Note
This service could be called by BSP only.

Definition at line 1228 of file RegisterCpuFeaturesLib.c.

◆ RegisterCpuFeature()

RETURN_STATUS EFIAPI RegisterCpuFeature ( IN CHAR8 *FeatureName  OPTIONAL,
IN CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc  OPTIONAL,
IN CPU_FEATURE_SUPPORT SupportFunc  OPTIONAL,
IN CPU_FEATURE_INITIALIZE InitializeFunc  OPTIONAL,
  ... 
)

Registers a CPU Feature.

Parameters
[in]FeatureNameA Null-terminated Ascii string indicates CPU feature name.
[in]GetConfigDataFuncCPU feature get configuration data function. This is an optional parameter that may be NULL. If NULL, then the most recently registered function for the CPU feature is used. If no functions are registered for a CPU feature, then the CPU configuration data for the registered feature is NULL.
[in]SupportFuncCPU feature support function. This is an optional parameter that may be NULL. If NULL, then the most recently registered function for the CPU feature is used. If no functions are registered for a CPU feature, then the CPU feature is assumed to be supported by all CPUs.
[in]InitializeFuncCPU feature initialize function. This is an optional parameter that may be NULL. If NULL, then the most recently registered function for the CPU feature is used. If no functions are registered for a CPU feature, then the CPU feature initialization is skipped.
[in]...Variable argument list of UINT32 CPU feature value. Values with no modifiers are the features provided by the registered functions. Values with CPU_FEATURE_BEFORE modifier are features that must be initialized after the features provided by the registered functions are used. Values with CPU_FEATURE_AFTER modifier are features that must be initialized before the features provided by the registered functions are used. The last argument in this variable argument list must always be CPU_FEATURE_END.
Return values
RETURN_SUCCESSThe CPU feature was successfully registered.
RETURN_OUT_OF_RESOURCESThere are not enough resources to register the CPU feature.
RETURN_UNSUPPORTEDRegistration of the CPU feature is not supported due to a circular dependency between BEFORE and AFTER features.
RETURN_NOT_READYCPU feature PCD PcdCpuFeaturesUserConfiguration not updated by Platform driver yet.
Note
This service could be called by BSP only.

Definition at line 840 of file RegisterCpuFeaturesLib.c.

◆ RegisterCpuFeatureWorker()

RETURN_STATUS RegisterCpuFeatureWorker ( IN CPU_FEATURES_DATA CpuFeaturesData,
IN CPU_FEATURES_ENTRY CpuFeature 
)

Worker function to register CPU Feature.

Parameters
[in]CpuFeaturesDataPointer to CPU feature data structure.
[in]CpuFeaturePointer to CPU feature entry
Return values
RETURN_SUCCESSThe CPU feature was successfully registered.
RETURN_OUT_OF_RESOURCESThere are not enough resources to register the CPU feature.
RETURN_UNSUPPORTEDRegistration of the CPU feature is not supported due to a circular dependency between BEFORE and AFTER features.

Definition at line 641 of file RegisterCpuFeaturesLib.c.

◆ SetCpuFeaturesBitMask()

VOID SetCpuFeaturesBitMask ( IN UINT8 **  FeaturesBitMask,
IN UINT32  Feature,
IN UINTN  BitMaskSize 
)

Sets CPU feature bit mask in CPU feature bit mask buffer.

Parameters
[in]FeaturesBitMaskPointer to CPU feature bit mask buffer
[in]FeatureThe bit number of the CPU feature
[in]BitMaskSizeCPU feature bit mask buffer size

Definition at line 772 of file RegisterCpuFeaturesLib.c.

◆ SwitchBspAfterFeaturesInitialize()

VOID EFIAPI SwitchBspAfterFeaturesInitialize ( IN UINTN  ProcessorNumber)

Switches to assigned BSP after CPU features initialization.

Parameters
[in]ProcessorNumberThe index of the CPU executing this function.
Note
This service could be called by BSP only.

Definition at line 1331 of file RegisterCpuFeaturesLib.c.