UefiCpuPkg/MtrrLib: Fix some typo and clean up code format

Fixed some typo. Removed some trailing spaces and TAB key. Clean up code format.

Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19152 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Michael Kinney 2015-12-08 05:20:44 +00:00 committed by vanjeff
parent 46309b1101
commit 76b4cae357
2 changed files with 121 additions and 111 deletions

View File

@ -84,8 +84,8 @@ typedef struct {
// Structure to hold base and mask pair for variable MTRR register
//
typedef struct _MTRR_VARIABLE_SETTING_ {
UINT64 Base;
UINT64 Mask;
UINT64 Base;
UINT64 Mask;
} MTRR_VARIABLE_SETTING;
//
@ -115,11 +115,11 @@ typedef struct _MTRR_SETTINGS_ {
// Memory cache types
//
typedef enum {
CacheUncacheable = 0,
CacheWriteCombining = 1,
CacheWriteThrough = 4,
CacheWriteProtected = 5,
CacheWriteBack = 6
CacheUncacheable = 0,
CacheWriteCombining = 1,
CacheWriteThrough = 4,
CacheWriteProtected = 5,
CacheWriteBack = 6
} MTRR_MEMORY_CACHE_TYPE;
#define MTRR_CACHE_UNCACHEABLE 0
@ -156,20 +156,27 @@ GetFirmwareVariableMtrrCount (
/**
This function attempts to set the attributes for a memory range.
@param BaseAddress The physical address that is the start address of a memory region.
@param Length The size in bytes of the memory region.
@param Attributes The bit mask of attributes to set for the memory region.
@param[in] BaseAddress The physical address that is the start
address of a memory region.
@param[in] Length The size in bytes of the memory region.
@param[in] Attribute The bit mask of attributes to set for the
memory region.
@retval RETURN_SUCCESS The attributes were set for the memory region.
@retval RETURN_SUCCESS The attributes were set for the memory
region.
@retval RETURN_INVALID_PARAMETER Length is zero.
@retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the
memory resource range specified by BaseAddress and Length.
@retval RETURN_UNSUPPORTED The bit mask of attributes is not support for the memory resource
range specified by BaseAddress and Length.
@retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by
BaseAddress and Length cannot be modified.
@retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of
the memory resource range.
@retval RETURN_UNSUPPORTED The processor does not support one or
more bytes of the memory resource range
specified by BaseAddress and Length.
@retval RETURN_UNSUPPORTED The bit mask of attributes is not support
for the memory resource range specified
by BaseAddress and Length.
@retval RETURN_ACCESS_DENIED The attributes for the memory resource
range specified by BaseAddress and Length
cannot be modified.
@retval RETURN_OUT_OF_RESOURCES There are not enough system resources to
modify the attributes of the memory
resource range.
**/
RETURN_STATUS
@ -185,7 +192,7 @@ MtrrSetMemoryAttribute (
This function will get the memory cache type of the specific address.
This function is mainly for debugging purposes.
@param Address The specific address
@param[in] Address The specific address
@return The memory cache type of the specific address
@ -200,7 +207,7 @@ MtrrGetMemoryAttribute (
/**
This function will get the raw value in variable MTRRs
@param VariableSettings A buffer to hold variable MTRRs content.
@param[out] VariableSettings A buffer to hold variable MTRRs content.
@return The buffer point to MTRR_VARIABLE_SETTINGS in which holds the content of the variable mtrr
@ -215,7 +222,7 @@ MtrrGetVariableMtrr (
/**
This function sets fixed MTRRs
@param VariableSettings A buffer to hold variable MTRRs content.
@param[in] VariableSettings A buffer to hold variable MTRRs content.
@return The pointer of VariableSettings
@ -230,7 +237,7 @@ MtrrSetVariableMtrr (
/**
This function gets the content in fixed MTRRs
@param FixedSettings A buffer to hold fixed MTRRs content.
@param[out] FixedSettings A buffer to hold fixed MTRRs content.
@return The pointer of FixedSettings
@ -245,7 +252,7 @@ MtrrGetFixedMtrr (
/**
This function sets fixed MTRRs
@param FixedSettings A buffer holding fixed MTRRs content.
@param[in] FixedSettings A buffer holding fixed MTRRs content.
@return The pointer of FixedSettings
@ -260,7 +267,7 @@ MtrrSetFixedMtrr (
/**
This function gets the content in all MTRRs (variable and fixed)
@param MtrrSetting A buffer to hold all MTRRs content.
@param[out] MtrrSetting A buffer to hold all MTRRs content.
@return The pointer of MtrrSetting
@ -275,7 +282,7 @@ MtrrGetAllMtrrs (
/**
This function sets all MTRRs (variable and fixed)
@param MtrrSetting A buffer to hold all MTRRs content.
@param[in] MtrrSetting A buffer to hold all MTRRs content.
@return The pointer of MtrrSetting
@ -293,11 +300,12 @@ MtrrSetAllMtrrs (
This function shadows the content of variable MTRRs into
an internal array: VariableMtrr
@param MtrrValidBitsMask The mask for the valid bit of the MTRR
@param MtrrValidAddressMask The valid address mask for MTRR since the base address in
MTRR must align to 4K, so valid address mask equal to
MtrrValidBitsMask & 0xfffffffffffff000ULL
@param VariableMtrr The array to shadow variable MTRRs content
@param[in] MtrrValidBitsMask The mask for the valid bit of the MTRR
@param[in] MtrrValidAddressMask The valid address mask for MTRR since the base address in
MTRR must align to 4K, so valid address mask equal to
MtrrValidBitsMask & 0xfffffffffffff000ULL
@param[out] VariableMtrr The array to shadow variable MTRRs content
@return The ruturn value of this paramter indicates the number of
MTRRs which has been used.
**/

View File

@ -86,7 +86,7 @@ CONST FIXED_MTRR mMtrrLibFixedMtrrTable[] = {
MTRR_LIB_IA32_MTRR_FIX4K_F8000,
0xF8000,
SIZE_4KB
},
}
};
//
@ -188,7 +188,7 @@ PreMtrrChange (
// Disable interrupts and save current interrupt state
//
MtrrContext->InterruptState = SaveAndDisableInterrupts();
//
// Enter no fill cache mode, CD=1(Bit30), NW=0 (Bit29)
//
@ -206,7 +206,7 @@ PreMtrrChange (
CpuFlushTlb ();
//
// Disable Mtrrs
// Disable MTRRs
//
AsmMsrBitFieldWrite64 (MTRR_LIB_IA32_MTRR_DEF_TYPE, 10, 11, 0);
}
@ -226,7 +226,7 @@ PostMtrrChangeEnableCache (
)
{
//
// Flush all TLBs
// Flush all TLBs
//
CpuFlushTlb ();
@ -239,7 +239,7 @@ PostMtrrChangeEnableCache (
// Restore original CR4 value
//
AsmWriteCr4 (MtrrContext->Cr4);
//
// Restore original interrupt state
//
@ -272,9 +272,9 @@ PostMtrrChange (
/**
Programs fixed MTRRs registers.
@param MemoryCacheType The memory type to set.
@param Base The base address of memory range.
@param Length The length of memory range.
@param[in] MemoryCacheType The memory type to set.
@param[in, out] Base The base address of memory range.
@param[in, out] Length The length of memory range.
@retval RETURN_SUCCESS The cache type was updated successfully
@retval RETURN_UNSUPPORTED The requested range or cache type was invalid
@ -356,14 +356,14 @@ ProgramFixedMtrr (
/**
Get the attribute of variable MTRRs.
Gets the attribute of variable MTRRs.
This function shadows the content of variable MTRRs into an
internal array: VariableMtrr.
@param MtrrValidBitsMask The mask for the valid bit of the MTRR
@param MtrrValidAddressMask The valid address mask for MTRR
@param VariableMtrr The array to shadow variable MTRRs content
@param[in] MtrrValidBitsMask The mask for the valid bit of the MTRR
@param[in] MtrrValidAddressMask The valid address mask for MTRR
@param[out] VariableMtrr The array to shadow variable MTRRs content
@return The return value of this paramter indicates the
number of MTRRs which has been used.
@ -423,9 +423,9 @@ MtrrGetMemoryAttributeInVariableMtrr (
/**
Checks overlap between given memory range and MTRRs.
@param Start The start address of memory range.
@param End The end address of memory range.
@param VariableMtrr The array to shadow variable MTRRs content
@param[in] Start The start address of memory range.
@param[in] End The end address of memory range.
@param[in] VariableMtrr The array to shadow variable MTRRs content
@retval TRUE Overlap exists.
@retval FALSE No overlap.
@ -461,9 +461,9 @@ CheckMemoryAttributeOverlap (
/**
Marks a variable MTRR as non-valid.
@param Index The index of the array VariableMtrr to be invalidated
@param VariableMtrr The array to shadow variable MTRRs content
@param UsedMtrr The number of MTRRs which has already been used
@param[in] Index The index of the array VariableMtrr to be invalidated
@param[in] VariableMtrr The array to shadow variable MTRRs content
@param[out] UsedMtrr The number of MTRRs which has already been used
**/
VOID
@ -479,16 +479,16 @@ InvalidateShadowMtrr (
/**
Combine memory attributes.
Combines memory attributes.
If overlap exists between given memory range and MTRRs, try to combine them.
@param Attributes The memory type to set.
@param Base The base address of memory range.
@param Length The length of memory range.
@param VariableMtrr The array to shadow variable MTRRs content
@param UsedMtrr The number of MTRRs which has already been used
@param OverwriteExistingMtrr Returns whether an existing MTRR was used
@param[in] Attributes The memory type to set.
@param[in, out] Base The base address of memory range.
@param[in, out] Length The length of memory range.
@param[in] VariableMtrr The array to shadow variable MTRRs content
@param[in, out] UsedMtrr The number of MTRRs which has already been used
@param[out] OverwriteExistingMtrr Returns whether an existing MTRR was used
@retval EFI_SUCCESS Memory region successfully combined.
@retval EFI_ACCESS_DENIED Memory region cannot be combined.
@ -536,7 +536,7 @@ CombineMemoryAttribute (
//
if (Attributes == VariableMtrr[Index].Type) {
//
// if the Mtrr range contain the request range, set a flag, then continue to
// if the MTRR range contain the request range, set a flag, then continue to
// invalidate any MTRR of the same request range with higher priority cache type.
//
if (VariableMtrr[Index].BaseAddress <= *Base && MtrrEnd >= EndAddress) {
@ -597,9 +597,10 @@ CombineMemoryAttribute (
/**
Calculate the maximum value which is a power of 2, but less the MemoryLength.
Calculates the maximum value which is a power of 2, but less the MemoryLength.
@param[in] MemoryLength The number to pass in.
@param MemoryLength The number to pass in.
@return The maximum value which is align to power of 2 and less the MemoryLength
**/
@ -626,21 +627,22 @@ Power2MaxMemory (
/**
Determine the MTRR numbers used to program a memory range.
Determines the MTRR numbers used to program a memory range.
This function first checks the alignment of the base address. If the alignment of the base address <= Length,
cover the memory range (BaseAddress, alignment) by a MTRR, then BaseAddress += alignment and Length -= alignment.
Repeat the step until alignment > Length.
This function first checks the alignment of the base address.
If the alignment of the base address <= Length, cover the memory range
(BaseAddress, alignment) by a MTRR, then BaseAddress += alignment and
Length -= alignment. Repeat the step until alignment > Length.
Then this function determines which direction of programming the variable MTRRs for the remaining length
will use fewer MTRRs.
Then this function determines which direction of programming the variable
MTRRs for the remaining length will use fewer MTRRs.
@param BaseAddress Length of Memory to program MTRR
@param Length Length of Memory to program MTRR
@param MtrrNumber Pointer to the number of necessary MTRRs
@param[in] BaseAddress Length of Memory to program MTRR
@param[in] Length Length of Memory to program MTRR
@param[in] MtrrNumber Pointer to the number of necessary MTRRs
@retval TRUE Positive direction is better.
FALSE Negtive direction is better.
FALSE Negative direction is better.
**/
BOOLEAN
@ -709,13 +711,13 @@ GetMtrrNumberAndDirection (
This function programs MTRRs according to the values specified
in the shadow array.
@param VariableMtrr The array to shadow variable MTRRs content
@param[in, out] VariableMtrr Shadow of variable MTRR contents
**/
VOID
InvalidateMtrr (
IN VARIABLE_MTRR *VariableMtrr
)
IN OUT VARIABLE_MTRR *VariableMtrr
)
{
UINTN Index;
UINTN VariableMtrrCount;
@ -741,11 +743,11 @@ InvalidateMtrr (
This function programs variable MTRRs
@param MtrrNumber Index of MTRR to program.
@param BaseAddress Base address of memory region.
@param Length Length of memory region.
@param MemoryCacheType Memory type to set.
@param MtrrValidAddressMask The valid address mask for MTRR
@param[in] MtrrNumber Index of MTRR to program.
@param[in] BaseAddress Base address of memory region.
@param[in] Length Length of memory region.
@param[in] MemoryCacheType Memory type to set.
@param[in] MtrrValidAddressMask The valid address mask for MTRR
**/
VOID
@ -782,9 +784,9 @@ ProgramVariableMtrr (
/**
Convert the Memory attibute value to MTRR_MEMORY_CACHE_TYPE.
Converts the Memory attribute value to MTRR_MEMORY_CACHE_TYPE.
@param MtrrType MTRR memory type
@param[in] MtrrType MTRR memory type
@return The enum item in MTRR_MEMORY_CACHE_TYPE
@ -808,7 +810,7 @@ GetMemoryCacheTypeFromMtrrType (
default:
//
// MtrrType is MTRR_CACHE_INVALID_TYPE, that means
// no mtrr covers the range
// no MTRR covers the range
//
return MtrrGetDefaultMemoryType ();
}
@ -819,8 +821,8 @@ GetMemoryCacheTypeFromMtrrType (
This function initializes the valid bits mask and valid address mask for MTRRs.
@param MtrrValidBitsMask The mask for the valid bit of the MTRR
@param MtrrValidAddressMask The valid address mask for the MTRR
@param[out] MtrrValidBitsMask The mask for the valid bit of the MTRR
@param[out] MtrrValidAddressMask The valid address mask for the MTRR
**/
VOID
@ -849,21 +851,21 @@ MtrrLibInitializeMtrrMask (
/**
Determing the real attribute of a memory range.
Determines the real attribute of a memory range.
This function is to arbitrate the real attribute of the memory when
there are 2 MTRR covers the same memory range. For further details,
there are 2 MTRRs covers the same memory range. For further details,
please refer the IA32 Software Developer's Manual, Volume 3,
Section 10.11.4.1.
@param MtrrType1 the first kind of Memory type
@param MtrrType2 the second kind of memory type
@param[in] MtrrType1 The first kind of Memory type
@param[in] MtrrType2 The second kind of memory type
**/
UINT64
MtrrPrecedence (
UINT64 MtrrType1,
UINT64 MtrrType2
IN UINT64 MtrrType1,
IN UINT64 MtrrType2
)
{
UINT64 MtrrType;
@ -923,11 +925,11 @@ MtrrPrecedence (
/**
This function attempts to set the attributes for a memory range.
@param BaseAddress The physical address that is the start
address of a memory region.
@param Length The size in bytes of the memory region.
@param Attributes The bit mask of attributes to set for the
memory region.
@param[in] BaseAddress The physical address that is the start
address of a memory region.
@param[in] Length The size in bytes of the memory region.
@param[in] Attribute The bit mask of attributes to set for the
memory region.
@retval RETURN_SUCCESS The attributes were set for the memory
region.
@ -1198,9 +1200,9 @@ Done:
This function is mainly for debug purpose.
@param Address The specific address
@param[in] Address The specific address
@return Memory cache type of the sepcific address
@return Memory cache type of the specific address
**/
MTRR_MEMORY_CACHE_TYPE
@ -1290,7 +1292,7 @@ MtrrGetMemoryAttribute (
/**
This function will get the raw value in variable MTRRs
@param VariableSettings A buffer to hold variable MTRRs content.
@param[out] FixedSettings A buffer to hold fixed MTRRs content.
@return The VariableSettings input pointer
@ -1325,7 +1327,7 @@ MtrrGetVariableMtrr (
/**
Worker function setting variable MTRRs
@param VariableSettings A buffer to hold variable MTRRs content.
@param[in] VariableSettings A buffer to hold variable MTRRs content.
**/
VOID
@ -1355,7 +1357,7 @@ MtrrSetVariableMtrrWorker (
/**
This function sets variable MTRRs
@param VariableSettings A buffer to hold variable MTRRs content.
@param[in] VariableSettings A buffer to hold variable MTRRs content.
@return The pointer of VariableSettings
@ -1382,7 +1384,7 @@ MtrrSetVariableMtrr (
/**
This function gets the content in fixed MTRRs
@param FixedSettings A buffer to hold fixed Mtrrs content.
@param[out] FixedSettings A buffer to hold fixed Mtrrs content.
@retval The pointer of FixedSettings
@ -1410,7 +1412,7 @@ MtrrGetFixedMtrr (
/**
Worker function setting fixed MTRRs
@param FixedSettings A buffer to hold fixed Mtrrs content.
@param[in] FixedSettings A buffer to hold fixed Mtrrs content.
**/
VOID
@ -1432,7 +1434,7 @@ MtrrSetFixedMtrrWorker (
/**
This function sets fixed MTRRs
@param FixedSettings A buffer to hold fixed Mtrrs content.
@param[in] FixedSettings A buffer to hold fixed Mtrrs content.
@retval The pointer of FixedSettings
@ -1460,7 +1462,7 @@ MtrrSetFixedMtrr (
/**
This function gets the content in all MTRRs (variable and fixed)
@param MtrrSetting A buffer to hold all Mtrrs content.
@param[out] MtrrSetting A buffer to hold all Mtrrs content.
@retval the pointer of MtrrSetting
@ -1497,7 +1499,7 @@ MtrrGetAllMtrrs (
/**
This function sets all MTRRs (variable and fixed)
@param MtrrSetting A buffer holding all MTRRs content.
@param[in] MtrrSetting A buffer holding all MTRRs content.
@retval The pointer of MtrrSetting
@ -1569,7 +1571,7 @@ MtrrDebugPrintAllMtrrs (
DEBUG((DEBUG_CACHE, "MTRR Settings\n"));
DEBUG((DEBUG_CACHE, "=============\n"));
MtrrGetAllMtrrs (&MtrrSettings);
DEBUG((DEBUG_CACHE, "MTRR Default Type: %016lx\n", MtrrSettings.MtrrDefType));
for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) {
@ -1596,7 +1598,7 @@ MtrrDebugPrintAllMtrrs (
MemoryType = (UINTN)(RShiftU64 (MtrrSettings.Fixed.Mtrr[Index], Index1 * 8) & 0xff);
if (MemoryType > CacheWriteBack) {
MemoryType = MTRR_CACHE_INVALID_TYPE;
}
}
if (MemoryType != PreviousMemoryType) {
if (PreviousMemoryType != MTRR_CACHE_INVALID_TYPE) {
DEBUG((DEBUG_CACHE, "%016lx\n", Base - 1));
@ -1632,12 +1634,12 @@ MtrrDebugPrintAllMtrrs (
PreviousMemoryType = MemoryType;
DEBUG((DEBUG_CACHE, "%a:%016lx-", mMtrrMemoryCacheTypeShortName[MemoryType], Base));
}
RangeBase = BASE_1MB;
RangeBase = BASE_1MB;
NoRangeBase = BASE_1MB;
RangeLimit = Limit;
NoRangeLimit = Limit;
for (Index = 0, Found = FALSE; Index < VariableMtrrCount; Index++) {
if ((MtrrSettings.Variables.Mtrr[Index].Mask & BIT11) == 0) {
//
@ -1651,7 +1653,7 @@ MtrrDebugPrintAllMtrrs (
if (Base >= MtrrBase && Base < MtrrLimit) {
Found = TRUE;
}
if (Base >= MtrrBase && MtrrBase > RangeBase) {
RangeBase = MtrrBase;
}
@ -1664,7 +1666,7 @@ MtrrDebugPrintAllMtrrs (
if (Base < MtrrLimit && MtrrLimit <= RangeLimit) {
RangeLimit = MtrrLimit;
}
if (Base > MtrrLimit && NoRangeBase < MtrrLimit) {
NoRangeBase = MtrrLimit + 1;
}
@ -1672,7 +1674,7 @@ MtrrDebugPrintAllMtrrs (
NoRangeLimit = MtrrBase - 1;
}
}
if (Found) {
Base = RangeLimit + 1;
} else {