UefiCpuPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the UefiCpuPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
91415a36ae
commit
053e878bfb
@@ -8,11 +8,11 @@
|
||||
|
||||
#include "MtrrLibUnitTest.h"
|
||||
|
||||
STATIC CONST MTRR_LIB_SYSTEM_PARAMETER mDefaultSystemParameter = {
|
||||
STATIC CONST MTRR_LIB_SYSTEM_PARAMETER mDefaultSystemParameter = {
|
||||
42, TRUE, TRUE, CacheUncacheable, 12
|
||||
};
|
||||
|
||||
STATIC MTRR_LIB_SYSTEM_PARAMETER mSystemParameters[] = {
|
||||
STATIC MTRR_LIB_SYSTEM_PARAMETER mSystemParameters[] = {
|
||||
{ 38, TRUE, TRUE, CacheUncacheable, 12 },
|
||||
{ 38, TRUE, TRUE, CacheWriteBack, 12 },
|
||||
{ 38, TRUE, TRUE, CacheWriteThrough, 12 },
|
||||
@@ -32,7 +32,7 @@ STATIC MTRR_LIB_SYSTEM_PARAMETER mSystemParameters[] = {
|
||||
{ 48, TRUE, TRUE, CacheWriteCombining, 12 },
|
||||
};
|
||||
|
||||
UINT32 mFixedMtrrsIndex[] = {
|
||||
UINT32 mFixedMtrrsIndex[] = {
|
||||
MSR_IA32_MTRR_FIX64K_00000,
|
||||
MSR_IA32_MTRR_FIX16K_80000,
|
||||
MSR_IA32_MTRR_FIX16K_A0000,
|
||||
@@ -54,18 +54,18 @@ STATIC_ASSERT (
|
||||
// Context structure to be used for most of the test cases.
|
||||
//
|
||||
typedef struct {
|
||||
CONST MTRR_LIB_SYSTEM_PARAMETER *SystemParameter;
|
||||
CONST MTRR_LIB_SYSTEM_PARAMETER *SystemParameter;
|
||||
} MTRR_LIB_TEST_CONTEXT;
|
||||
|
||||
//
|
||||
// Context structure to be used for GetFirmwareVariableMtrrCount() test.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 NumberOfReservedVariableMtrrs;
|
||||
CONST MTRR_LIB_SYSTEM_PARAMETER *SystemParameter;
|
||||
UINT32 NumberOfReservedVariableMtrrs;
|
||||
CONST MTRR_LIB_SYSTEM_PARAMETER *SystemParameter;
|
||||
} MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT;
|
||||
|
||||
STATIC CHAR8 *mCacheDescription[] = { "UC", "WC", "N/A", "N/A", "WT", "WP", "WB" };
|
||||
STATIC CHAR8 *mCacheDescription[] = { "UC", "WC", "N/A", "N/A", "WT", "WP", "WB" };
|
||||
|
||||
/**
|
||||
Compare the actual memory ranges against expected memory ranges and return PASS when they match.
|
||||
@@ -87,6 +87,7 @@ VerifyMemoryRanges (
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
UT_ASSERT_EQUAL (ExpectedMemoryRangeCount, ActualRangeCount);
|
||||
for (Index = 0; Index < ExpectedMemoryRangeCount; Index++) {
|
||||
UT_ASSERT_EQUAL (ExpectedMemoryRanges[Index].BaseAddress, ActualRanges[Index].BaseAddress);
|
||||
@@ -105,11 +106,12 @@ VerifyMemoryRanges (
|
||||
**/
|
||||
VOID
|
||||
DumpMemoryRanges (
|
||||
MTRR_MEMORY_RANGE *Ranges,
|
||||
UINTN RangeCount
|
||||
MTRR_MEMORY_RANGE *Ranges,
|
||||
UINTN RangeCount
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < RangeCount; Index++) {
|
||||
UT_LOG_INFO ("\t{ 0x%016llx, 0x%016llx, %a },\n", Ranges[Index].BaseAddress, Ranges[Index].Length, mCacheDescription[Ranges[Index].Type]);
|
||||
}
|
||||
@@ -130,17 +132,17 @@ DumpMemoryRanges (
|
||||
**/
|
||||
VOID
|
||||
GenerateRandomMemoryTypeCombination (
|
||||
IN UINT32 TotalCount,
|
||||
OUT UINT32 *UcCount,
|
||||
OUT UINT32 *WtCount,
|
||||
OUT UINT32 *WbCount,
|
||||
OUT UINT32 *WpCount,
|
||||
OUT UINT32 *WcCount
|
||||
IN UINT32 TotalCount,
|
||||
OUT UINT32 *UcCount,
|
||||
OUT UINT32 *WtCount,
|
||||
OUT UINT32 *WbCount,
|
||||
OUT UINT32 *WpCount,
|
||||
OUT UINT32 *WcCount
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINT32 TotalMtrrCount;
|
||||
UINT32 *CountPerType[5];
|
||||
UINTN Index;
|
||||
UINT32 TotalMtrrCount;
|
||||
UINT32 *CountPerType[5];
|
||||
|
||||
CountPerType[0] = UcCount;
|
||||
CountPerType[1] = WtCount;
|
||||
@@ -183,38 +185,47 @@ UnitTestMtrrSetMemoryAttributesInMtrrSettings (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
CONST MTRR_LIB_SYSTEM_PARAMETER *SystemParameter;
|
||||
RETURN_STATUS Status;
|
||||
UINT32 UcCount;
|
||||
UINT32 WtCount;
|
||||
UINT32 WbCount;
|
||||
UINT32 WpCount;
|
||||
UINT32 WcCount;
|
||||
CONST MTRR_LIB_SYSTEM_PARAMETER *SystemParameter;
|
||||
RETURN_STATUS Status;
|
||||
UINT32 UcCount;
|
||||
UINT32 WtCount;
|
||||
UINT32 WbCount;
|
||||
UINT32 WpCount;
|
||||
UINT32 WcCount;
|
||||
|
||||
UINT32 MtrrIndex;
|
||||
UINT8 *Scratch;
|
||||
UINTN ScratchSize;
|
||||
MTRR_SETTINGS LocalMtrrs;
|
||||
UINT32 MtrrIndex;
|
||||
UINT8 *Scratch;
|
||||
UINTN ScratchSize;
|
||||
MTRR_SETTINGS LocalMtrrs;
|
||||
|
||||
MTRR_MEMORY_RANGE RawMtrrRange[MTRR_NUMBER_OF_VARIABLE_MTRR];
|
||||
MTRR_MEMORY_RANGE ExpectedMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR * sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
|
||||
UINT32 ExpectedVariableMtrrUsage;
|
||||
UINTN ExpectedMemoryRangesCount;
|
||||
MTRR_MEMORY_RANGE RawMtrrRange[MTRR_NUMBER_OF_VARIABLE_MTRR];
|
||||
MTRR_MEMORY_RANGE ExpectedMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR * sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
|
||||
UINT32 ExpectedVariableMtrrUsage;
|
||||
UINTN ExpectedMemoryRangesCount;
|
||||
|
||||
MTRR_MEMORY_RANGE ActualMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR * sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
|
||||
UINT32 ActualVariableMtrrUsage;
|
||||
UINTN ActualMemoryRangesCount;
|
||||
MTRR_MEMORY_RANGE ActualMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR * sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
|
||||
UINT32 ActualVariableMtrrUsage;
|
||||
UINTN ActualMemoryRangesCount;
|
||||
|
||||
MTRR_SETTINGS *Mtrrs[2];
|
||||
MTRR_SETTINGS *Mtrrs[2];
|
||||
|
||||
SystemParameter = (MTRR_LIB_SYSTEM_PARAMETER *) Context;
|
||||
SystemParameter = (MTRR_LIB_SYSTEM_PARAMETER *)Context;
|
||||
GenerateRandomMemoryTypeCombination (
|
||||
SystemParameter->VariableMtrrCount - PatchPcdGet32 (PcdCpuNumberOfReservedVariableMtrrs),
|
||||
&UcCount, &WtCount, &WbCount, &WpCount, &WcCount
|
||||
&UcCount,
|
||||
&WtCount,
|
||||
&WbCount,
|
||||
&WpCount,
|
||||
&WcCount
|
||||
);
|
||||
GenerateValidAndConfigurableMtrrPairs (
|
||||
SystemParameter->PhysicalAddressBits, RawMtrrRange,
|
||||
UcCount, WtCount, WbCount, WpCount, WcCount
|
||||
SystemParameter->PhysicalAddressBits,
|
||||
RawMtrrRange,
|
||||
UcCount,
|
||||
WtCount,
|
||||
WbCount,
|
||||
WpCount,
|
||||
WcCount
|
||||
);
|
||||
|
||||
ExpectedVariableMtrrUsage = UcCount + WtCount + WbCount + WpCount + WcCount;
|
||||
@@ -222,13 +233,20 @@ UnitTestMtrrSetMemoryAttributesInMtrrSettings (
|
||||
GetEffectiveMemoryRanges (
|
||||
SystemParameter->DefaultCacheType,
|
||||
SystemParameter->PhysicalAddressBits,
|
||||
RawMtrrRange, ExpectedVariableMtrrUsage,
|
||||
ExpectedMemoryRanges, &ExpectedMemoryRangesCount
|
||||
RawMtrrRange,
|
||||
ExpectedVariableMtrrUsage,
|
||||
ExpectedMemoryRanges,
|
||||
&ExpectedMemoryRangesCount
|
||||
);
|
||||
|
||||
UT_LOG_INFO (
|
||||
"Total MTRR [%d]: UC=%d, WT=%d, WB=%d, WP=%d, WC=%d\n",
|
||||
ExpectedVariableMtrrUsage, UcCount, WtCount, WbCount, WpCount, WcCount
|
||||
ExpectedVariableMtrrUsage,
|
||||
UcCount,
|
||||
WtCount,
|
||||
WbCount,
|
||||
WpCount,
|
||||
WcCount
|
||||
);
|
||||
UT_LOG_INFO ("--- Expected Memory Ranges [%d] ---\n", ExpectedMemoryRangesCount);
|
||||
DumpMemoryRanges (ExpectedMemoryRanges, ExpectedMemoryRangesCount);
|
||||
@@ -244,21 +262,28 @@ UnitTestMtrrSetMemoryAttributesInMtrrSettings (
|
||||
|
||||
for (MtrrIndex = 0; MtrrIndex < ARRAY_SIZE (Mtrrs); MtrrIndex++) {
|
||||
Scratch = calloc (ScratchSize, sizeof (UINT8));
|
||||
Status = MtrrSetMemoryAttributesInMtrrSettings (Mtrrs[MtrrIndex], Scratch, &ScratchSize, ExpectedMemoryRanges, ExpectedMemoryRangesCount);
|
||||
Status = MtrrSetMemoryAttributesInMtrrSettings (Mtrrs[MtrrIndex], Scratch, &ScratchSize, ExpectedMemoryRanges, ExpectedMemoryRangesCount);
|
||||
if (Status == RETURN_BUFFER_TOO_SMALL) {
|
||||
Scratch = realloc (Scratch, ScratchSize);
|
||||
Status = MtrrSetMemoryAttributesInMtrrSettings (Mtrrs[MtrrIndex], Scratch, &ScratchSize, ExpectedMemoryRanges, ExpectedMemoryRangesCount);
|
||||
Status = MtrrSetMemoryAttributesInMtrrSettings (Mtrrs[MtrrIndex], Scratch, &ScratchSize, ExpectedMemoryRanges, ExpectedMemoryRangesCount);
|
||||
}
|
||||
|
||||
UT_ASSERT_STATUS_EQUAL (Status, RETURN_SUCCESS);
|
||||
|
||||
if (Mtrrs[MtrrIndex] == NULL) {
|
||||
ZeroMem (&LocalMtrrs, sizeof (LocalMtrrs));
|
||||
MtrrGetAllMtrrs (&LocalMtrrs);
|
||||
}
|
||||
|
||||
ActualMemoryRangesCount = ARRAY_SIZE (ActualMemoryRanges);
|
||||
CollectTestResult (
|
||||
SystemParameter->DefaultCacheType, SystemParameter->PhysicalAddressBits, SystemParameter->VariableMtrrCount,
|
||||
&LocalMtrrs, ActualMemoryRanges, &ActualMemoryRangesCount, &ActualVariableMtrrUsage
|
||||
SystemParameter->DefaultCacheType,
|
||||
SystemParameter->PhysicalAddressBits,
|
||||
SystemParameter->VariableMtrrCount,
|
||||
&LocalMtrrs,
|
||||
ActualMemoryRanges,
|
||||
&ActualMemoryRangesCount,
|
||||
&ActualVariableMtrrUsage
|
||||
);
|
||||
|
||||
UT_LOG_INFO ("--- Actual Memory Ranges [%d] ---\n", ActualMemoryRangesCount);
|
||||
@@ -284,20 +309,20 @@ UnitTestMtrrSetMemoryAttributesInMtrrSettings (
|
||||
UNIT_TEST_STATUS
|
||||
EFIAPI
|
||||
UnitTestInvalidMemoryLayouts (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
CONST MTRR_LIB_SYSTEM_PARAMETER *SystemParameter;
|
||||
MTRR_MEMORY_RANGE Ranges[MTRR_NUMBER_OF_VARIABLE_MTRR * 2 + 1];
|
||||
UINTN RangeCount;
|
||||
UINT64 MaxAddress;
|
||||
UINT32 Index;
|
||||
UINT64 BaseAddress;
|
||||
UINT64 Length;
|
||||
RETURN_STATUS Status;
|
||||
UINTN ScratchSize;
|
||||
CONST MTRR_LIB_SYSTEM_PARAMETER *SystemParameter;
|
||||
MTRR_MEMORY_RANGE Ranges[MTRR_NUMBER_OF_VARIABLE_MTRR * 2 + 1];
|
||||
UINTN RangeCount;
|
||||
UINT64 MaxAddress;
|
||||
UINT32 Index;
|
||||
UINT64 BaseAddress;
|
||||
UINT64 Length;
|
||||
RETURN_STATUS Status;
|
||||
UINTN ScratchSize;
|
||||
|
||||
SystemParameter = (MTRR_LIB_SYSTEM_PARAMETER *) Context;
|
||||
SystemParameter = (MTRR_LIB_SYSTEM_PARAMETER *)Context;
|
||||
|
||||
RangeCount = Random32 (1, ARRAY_SIZE (Ranges));
|
||||
MaxAddress = 1ull << SystemParameter->PhysicalAddressBits;
|
||||
@@ -313,13 +338,15 @@ UnitTestInvalidMemoryLayouts (
|
||||
Ranges[Index].Type = GenerateRandomCacheType ();
|
||||
|
||||
Status = MtrrSetMemoryAttribute (
|
||||
Ranges[Index].BaseAddress, Ranges[Index].Length, Ranges[Index].Type
|
||||
);
|
||||
Ranges[Index].BaseAddress,
|
||||
Ranges[Index].Length,
|
||||
Ranges[Index].Type
|
||||
);
|
||||
UT_ASSERT_TRUE (RETURN_ERROR (Status));
|
||||
}
|
||||
|
||||
ScratchSize = 0;
|
||||
Status = MtrrSetMemoryAttributesInMtrrSettings (NULL, NULL, &ScratchSize, Ranges, RangeCount);
|
||||
Status = MtrrSetMemoryAttributesInMtrrSettings (NULL, NULL, &ScratchSize, Ranges, RangeCount);
|
||||
UT_ASSERT_TRUE (RETURN_ERROR (Status));
|
||||
|
||||
return UNIT_TEST_PASSED;
|
||||
@@ -344,7 +371,7 @@ UnitTestIsMtrrSupported (
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *) Context;
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *)Context;
|
||||
|
||||
CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
|
||||
//
|
||||
@@ -357,8 +384,8 @@ UnitTestIsMtrrSupported (
|
||||
//
|
||||
// MTRR capability on in CPUID leaf, but no variable or fixed MTRRs.
|
||||
//
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = 0;
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = 0;
|
||||
SystemParameter.FixedMtrrSupported = FALSE;
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
UT_ASSERT_FALSE (IsMtrrSupported ());
|
||||
@@ -366,8 +393,8 @@ UnitTestIsMtrrSupported (
|
||||
//
|
||||
// MTRR capability on in CPUID leaf, but no variable MTRRs.
|
||||
//
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = 0;
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = 0;
|
||||
SystemParameter.FixedMtrrSupported = TRUE;
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
UT_ASSERT_FALSE (IsMtrrSupported ());
|
||||
@@ -375,8 +402,8 @@ UnitTestIsMtrrSupported (
|
||||
//
|
||||
// MTRR capability on in CPUID leaf, but no fixed MTRRs.
|
||||
//
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = 7;
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = 7;
|
||||
SystemParameter.FixedMtrrSupported = FALSE;
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
UT_ASSERT_FALSE (IsMtrrSupported ());
|
||||
@@ -384,8 +411,8 @@ UnitTestIsMtrrSupported (
|
||||
//
|
||||
// MTRR capability on in CPUID leaf with both variable and fixed MTRRs.
|
||||
//
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = 7;
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = 7;
|
||||
SystemParameter.FixedMtrrSupported = TRUE;
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
UT_ASSERT_TRUE (IsMtrrSupported ());
|
||||
@@ -409,11 +436,11 @@ UnitTestGetVariableMtrrCount (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
UINT32 Result;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
UINT32 Result;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *) Context;
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *)Context;
|
||||
|
||||
CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
|
||||
//
|
||||
@@ -445,7 +472,7 @@ UnitTestGetVariableMtrrCount (
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
UT_EXPECT_ASSERT_FAILURE (GetVariableMtrrCount (), NULL);
|
||||
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = MAX_UINT8;
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
UT_EXPECT_ASSERT_FAILURE (GetVariableMtrrCount (), NULL);
|
||||
@@ -469,12 +496,12 @@ UnitTestGetFirmwareVariableMtrrCount (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
UINT32 Result;
|
||||
UINT32 ReservedMtrrs;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT *LocalContext;
|
||||
UINT32 Result;
|
||||
UINT32 ReservedMtrrs;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT *LocalContext;
|
||||
|
||||
LocalContext = (MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT *) Context;
|
||||
LocalContext = (MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT *)Context;
|
||||
|
||||
CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
|
||||
|
||||
@@ -516,7 +543,7 @@ UnitTestGetFirmwareVariableMtrrCount (
|
||||
//
|
||||
// Negative test case when Fixed MTRRs are not supported
|
||||
//
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.FixedMtrrSupported = FALSE;
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
PatchPcdSet32 (PcdCpuNumberOfReservedVariableMtrrs, 2);
|
||||
@@ -527,7 +554,7 @@ UnitTestGetFirmwareVariableMtrrCount (
|
||||
// Expect ASSERT() if variable MTRR count is > MTRR_NUMBER_OF_VARIABLE_MTRR
|
||||
//
|
||||
SystemParameter.FixedMtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = MTRR_NUMBER_OF_VARIABLE_MTRR + 1;
|
||||
SystemParameter.VariableMtrrCount = MTRR_NUMBER_OF_VARIABLE_MTRR + 1;
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
UT_EXPECT_ASSERT_FAILURE (GetFirmwareVariableMtrrCount (), NULL);
|
||||
|
||||
@@ -569,17 +596,17 @@ UnitTestMtrrGetFixedMtrr (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
MTRR_FIXED_SETTINGS *Result;
|
||||
MTRR_FIXED_SETTINGS ExpectedFixedSettings;
|
||||
MTRR_FIXED_SETTINGS FixedSettings;
|
||||
UINTN Index;
|
||||
UINTN MsrIndex;
|
||||
UINTN ByteIndex;
|
||||
UINT64 MsrValue;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
MTRR_FIXED_SETTINGS *Result;
|
||||
MTRR_FIXED_SETTINGS ExpectedFixedSettings;
|
||||
MTRR_FIXED_SETTINGS FixedSettings;
|
||||
UINTN Index;
|
||||
UINTN MsrIndex;
|
||||
UINTN ByteIndex;
|
||||
UINT64 MsrValue;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *) Context;
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *)Context;
|
||||
|
||||
CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
@@ -594,6 +621,7 @@ UnitTestMtrrGetFixedMtrr (
|
||||
for (ByteIndex = 0; ByteIndex < sizeof (UINT64); ByteIndex++) {
|
||||
MsrValue = MsrValue | LShiftU64 (GenerateRandomCacheType (), ByteIndex * 8);
|
||||
}
|
||||
|
||||
ExpectedFixedSettings.Mtrr[MsrIndex] = MsrValue;
|
||||
AsmWriteMsr64 (mFixedMtrrsIndex[MsrIndex], MsrValue);
|
||||
}
|
||||
@@ -631,18 +659,18 @@ UnitTestMtrrGetFixedMtrr (
|
||||
UNIT_TEST_STATUS
|
||||
EFIAPI
|
||||
UnitTestMtrrGetAllMtrrs (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
MTRR_SETTINGS *Result;
|
||||
MTRR_SETTINGS Mtrrs;
|
||||
MTRR_SETTINGS ExpectedMtrrs;
|
||||
MTRR_VARIABLE_SETTING VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR];
|
||||
UINT32 Index;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
MTRR_SETTINGS *Result;
|
||||
MTRR_SETTINGS Mtrrs;
|
||||
MTRR_SETTINGS ExpectedMtrrs;
|
||||
MTRR_VARIABLE_SETTING VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR];
|
||||
UINT32 Index;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *) Context;
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *)Context;
|
||||
|
||||
CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
@@ -652,6 +680,7 @@ UnitTestMtrrGetAllMtrrs (
|
||||
AsmWriteMsr64 (MSR_IA32_MTRR_PHYSBASE0 + (Index << 1), VariableMtrr[Index].Base);
|
||||
AsmWriteMsr64 (MSR_IA32_MTRR_PHYSMASK0 + (Index << 1), VariableMtrr[Index].Mask);
|
||||
}
|
||||
|
||||
Result = MtrrGetAllMtrrs (&Mtrrs);
|
||||
UT_ASSERT_EQUAL ((UINTN)Result, (UINTN)&Mtrrs);
|
||||
UT_ASSERT_MEM_EQUAL (Mtrrs.Variables.Mtrr, VariableMtrr, sizeof (MTRR_VARIABLE_SETTING) * SystemParameter.VariableMtrrCount);
|
||||
@@ -671,7 +700,7 @@ UnitTestMtrrGetAllMtrrs (
|
||||
//
|
||||
// Expect ASSERT() if variable MTRR count is > MTRR_NUMBER_OF_VARIABLE_MTRR
|
||||
//
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = MTRR_NUMBER_OF_VARIABLE_MTRR + 1;
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
UT_EXPECT_ASSERT_FAILURE (MtrrGetAllMtrrs (&Mtrrs), NULL);
|
||||
@@ -695,21 +724,21 @@ UnitTestMtrrSetAllMtrrs (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
MTRR_SETTINGS *Result;
|
||||
MTRR_SETTINGS Mtrrs;
|
||||
UINT32 Index;
|
||||
MSR_IA32_MTRR_DEF_TYPE_REGISTER Default;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
MTRR_SETTINGS *Result;
|
||||
MTRR_SETTINGS Mtrrs;
|
||||
UINT32 Index;
|
||||
MSR_IA32_MTRR_DEF_TYPE_REGISTER Default;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *) Context;
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *)Context;
|
||||
|
||||
CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
|
||||
Default.Uint64 = 0;
|
||||
Default.Bits.E = 1;
|
||||
Default.Bits.FE = 1;
|
||||
Default.Uint64 = 0;
|
||||
Default.Bits.E = 1;
|
||||
Default.Bits.FE = 1;
|
||||
Default.Bits.Type = GenerateRandomCacheType ();
|
||||
|
||||
ZeroMem (&Mtrrs, sizeof (Mtrrs));
|
||||
@@ -717,6 +746,7 @@ UnitTestMtrrSetAllMtrrs (
|
||||
for (Index = 0; Index < SystemParameter.VariableMtrrCount; Index++) {
|
||||
GenerateRandomMtrrPair (SystemParameter.PhysicalAddressBits, GenerateRandomCacheType (), &Mtrrs.Variables.Mtrr[Index], NULL);
|
||||
}
|
||||
|
||||
Result = MtrrSetAllMtrrs (&Mtrrs);
|
||||
UT_ASSERT_EQUAL ((UINTN)Result, (UINTN)&Mtrrs);
|
||||
|
||||
@@ -745,18 +775,18 @@ UnitTestMtrrGetMemoryAttributeInVariableMtrr (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
UINT32 Result;
|
||||
MTRR_VARIABLE_SETTING VariableSetting[MTRR_NUMBER_OF_VARIABLE_MTRR];
|
||||
VARIABLE_MTRR VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR];
|
||||
UINT64 ValidMtrrBitsMask;
|
||||
UINT64 ValidMtrrAddressMask;
|
||||
UINT32 Index;
|
||||
MSR_IA32_MTRR_PHYSBASE_REGISTER Base;
|
||||
MSR_IA32_MTRR_PHYSMASK_REGISTER Mask;
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
UINT32 Result;
|
||||
MTRR_VARIABLE_SETTING VariableSetting[MTRR_NUMBER_OF_VARIABLE_MTRR];
|
||||
VARIABLE_MTRR VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR];
|
||||
UINT64 ValidMtrrBitsMask;
|
||||
UINT64 ValidMtrrAddressMask;
|
||||
UINT32 Index;
|
||||
MSR_IA32_MTRR_PHYSBASE_REGISTER Base;
|
||||
MSR_IA32_MTRR_PHYSMASK_REGISTER Mask;
|
||||
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *) Context;
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *)Context;
|
||||
|
||||
CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
|
||||
|
||||
@@ -770,16 +800,17 @@ UnitTestMtrrGetMemoryAttributeInVariableMtrr (
|
||||
AsmWriteMsr64 (MSR_IA32_MTRR_PHYSBASE0 + (Index << 1), VariableSetting[Index].Base);
|
||||
AsmWriteMsr64 (MSR_IA32_MTRR_PHYSMASK0 + (Index << 1), VariableSetting[Index].Mask);
|
||||
}
|
||||
|
||||
Result = MtrrGetMemoryAttributeInVariableMtrr (ValidMtrrBitsMask, ValidMtrrAddressMask, VariableMtrr);
|
||||
UT_ASSERT_EQUAL (Result, SystemParameter.VariableMtrrCount);
|
||||
|
||||
for (Index = 0; Index < SystemParameter.VariableMtrrCount; Index++) {
|
||||
Base.Uint64 = VariableMtrr[Index].BaseAddress;
|
||||
Base.Bits.Type = (UINT32) VariableMtrr[Index].Type;
|
||||
Base.Bits.Type = (UINT32)VariableMtrr[Index].Type;
|
||||
UT_ASSERT_EQUAL (Base.Uint64, VariableSetting[Index].Base);
|
||||
|
||||
Mask.Uint64 = ~(VariableMtrr[Index].Length - 1) & ValidMtrrBitsMask;
|
||||
Mask.Bits.V = 1;
|
||||
Mask.Uint64 = ~(VariableMtrr[Index].Length - 1) & ValidMtrrBitsMask;
|
||||
Mask.Bits.V = 1;
|
||||
UT_ASSERT_EQUAL (Mask.Uint64, VariableSetting[Index].Mask);
|
||||
}
|
||||
|
||||
@@ -794,7 +825,7 @@ UnitTestMtrrGetMemoryAttributeInVariableMtrr (
|
||||
//
|
||||
// Expect ASSERT() if variable MTRR count is > MTRR_NUMBER_OF_VARIABLE_MTRR
|
||||
//
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = MTRR_NUMBER_OF_VARIABLE_MTRR + 1;
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
UT_EXPECT_ASSERT_FAILURE (MtrrGetMemoryAttributeInVariableMtrr (ValidMtrrBitsMask, ValidMtrrAddressMask, VariableMtrr), NULL);
|
||||
@@ -837,11 +868,11 @@ UnitTestMtrrGetDefaultMemoryType (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
UINTN Index;
|
||||
MTRR_MEMORY_CACHE_TYPE Result;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_MEMORY_CACHE_TYPE CacheType[5];
|
||||
MTRR_LIB_TEST_CONTEXT *LocalContext;
|
||||
UINTN Index;
|
||||
MTRR_MEMORY_CACHE_TYPE Result;
|
||||
MTRR_LIB_SYSTEM_PARAMETER SystemParameter;
|
||||
MTRR_MEMORY_CACHE_TYPE CacheType[5];
|
||||
|
||||
CacheType[0] = CacheUncacheable;
|
||||
CacheType[1] = CacheWriteCombining;
|
||||
@@ -849,7 +880,7 @@ UnitTestMtrrGetDefaultMemoryType (
|
||||
CacheType[3] = CacheWriteProtected;
|
||||
CacheType[4] = CacheWriteBack;
|
||||
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *) Context;
|
||||
LocalContext = (MTRR_LIB_TEST_CONTEXT *)Context;
|
||||
|
||||
CopyMem (&SystemParameter, LocalContext->SystemParameter, sizeof (SystemParameter));
|
||||
//
|
||||
@@ -871,15 +902,15 @@ UnitTestMtrrGetDefaultMemoryType (
|
||||
Result = MtrrGetDefaultMemoryType ();
|
||||
UT_ASSERT_EQUAL (Result, CacheUncacheable);
|
||||
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.FixedMtrrSupported = FALSE;
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
Result = MtrrGetDefaultMemoryType ();
|
||||
UT_ASSERT_EQUAL (Result, CacheUncacheable);
|
||||
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.MtrrSupported = TRUE;
|
||||
SystemParameter.FixedMtrrSupported = TRUE;
|
||||
SystemParameter.VariableMtrrCount = 0;
|
||||
SystemParameter.VariableMtrrCount = 0;
|
||||
InitializeMtrrRegs (&SystemParameter);
|
||||
Result = MtrrGetDefaultMemoryType ();
|
||||
UT_ASSERT_EQUAL (Result, CacheUncacheable);
|
||||
@@ -903,37 +934,46 @@ UnitTestMtrrSetMemoryAttributeInMtrrSettings (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
CONST MTRR_LIB_SYSTEM_PARAMETER *SystemParameter;
|
||||
RETURN_STATUS Status;
|
||||
UINT32 UcCount;
|
||||
UINT32 WtCount;
|
||||
UINT32 WbCount;
|
||||
UINT32 WpCount;
|
||||
UINT32 WcCount;
|
||||
CONST MTRR_LIB_SYSTEM_PARAMETER *SystemParameter;
|
||||
RETURN_STATUS Status;
|
||||
UINT32 UcCount;
|
||||
UINT32 WtCount;
|
||||
UINT32 WbCount;
|
||||
UINT32 WpCount;
|
||||
UINT32 WcCount;
|
||||
|
||||
UINTN MtrrIndex;
|
||||
UINTN Index;
|
||||
MTRR_SETTINGS LocalMtrrs;
|
||||
UINTN MtrrIndex;
|
||||
UINTN Index;
|
||||
MTRR_SETTINGS LocalMtrrs;
|
||||
|
||||
MTRR_MEMORY_RANGE RawMtrrRange[MTRR_NUMBER_OF_VARIABLE_MTRR];
|
||||
MTRR_MEMORY_RANGE ExpectedMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR * sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
|
||||
UINT32 ExpectedVariableMtrrUsage;
|
||||
UINTN ExpectedMemoryRangesCount;
|
||||
MTRR_MEMORY_RANGE RawMtrrRange[MTRR_NUMBER_OF_VARIABLE_MTRR];
|
||||
MTRR_MEMORY_RANGE ExpectedMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR * sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
|
||||
UINT32 ExpectedVariableMtrrUsage;
|
||||
UINTN ExpectedMemoryRangesCount;
|
||||
|
||||
MTRR_MEMORY_RANGE ActualMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR * sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
|
||||
UINT32 ActualVariableMtrrUsage;
|
||||
UINTN ActualMemoryRangesCount;
|
||||
MTRR_MEMORY_RANGE ActualMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR * sizeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1];
|
||||
UINT32 ActualVariableMtrrUsage;
|
||||
UINTN ActualMemoryRangesCount;
|
||||
|
||||
MTRR_SETTINGS *Mtrrs[2];
|
||||
MTRR_SETTINGS *Mtrrs[2];
|
||||
|
||||
SystemParameter = (MTRR_LIB_SYSTEM_PARAMETER *) Context;
|
||||
SystemParameter = (MTRR_LIB_SYSTEM_PARAMETER *)Context;
|
||||
GenerateRandomMemoryTypeCombination (
|
||||
SystemParameter->VariableMtrrCount - PatchPcdGet32 (PcdCpuNumberOfReservedVariableMtrrs),
|
||||
&UcCount, &WtCount, &WbCount, &WpCount, &WcCount
|
||||
&UcCount,
|
||||
&WtCount,
|
||||
&WbCount,
|
||||
&WpCount,
|
||||
&WcCount
|
||||
);
|
||||
GenerateValidAndConfigurableMtrrPairs (
|
||||
SystemParameter->PhysicalAddressBits, RawMtrrRange,
|
||||
UcCount, WtCount, WbCount, WpCount, WcCount
|
||||
SystemParameter->PhysicalAddressBits,
|
||||
RawMtrrRange,
|
||||
UcCount,
|
||||
WtCount,
|
||||
WbCount,
|
||||
WpCount,
|
||||
WcCount
|
||||
);
|
||||
|
||||
ExpectedVariableMtrrUsage = UcCount + WtCount + WbCount + WpCount + WcCount;
|
||||
@@ -941,8 +981,10 @@ UnitTestMtrrSetMemoryAttributeInMtrrSettings (
|
||||
GetEffectiveMemoryRanges (
|
||||
SystemParameter->DefaultCacheType,
|
||||
SystemParameter->PhysicalAddressBits,
|
||||
RawMtrrRange, ExpectedVariableMtrrUsage,
|
||||
ExpectedMemoryRanges, &ExpectedMemoryRangesCount
|
||||
RawMtrrRange,
|
||||
ExpectedVariableMtrrUsage,
|
||||
ExpectedMemoryRanges,
|
||||
&ExpectedMemoryRangesCount
|
||||
);
|
||||
|
||||
UT_LOG_INFO ("--- Expected Memory Ranges [%d] ---\n", ExpectedMemoryRangesCount);
|
||||
@@ -964,7 +1006,7 @@ UnitTestMtrrSetMemoryAttributeInMtrrSettings (
|
||||
ExpectedMemoryRanges[Index].Type
|
||||
);
|
||||
UT_ASSERT_TRUE (Status == RETURN_SUCCESS || Status == RETURN_OUT_OF_RESOURCES || Status == RETURN_BUFFER_TOO_SMALL);
|
||||
if (Status == RETURN_OUT_OF_RESOURCES || Status == RETURN_BUFFER_TOO_SMALL) {
|
||||
if ((Status == RETURN_OUT_OF_RESOURCES) || (Status == RETURN_BUFFER_TOO_SMALL)) {
|
||||
return UNIT_TEST_SKIPPED;
|
||||
}
|
||||
}
|
||||
@@ -973,10 +1015,16 @@ UnitTestMtrrSetMemoryAttributeInMtrrSettings (
|
||||
ZeroMem (&LocalMtrrs, sizeof (LocalMtrrs));
|
||||
MtrrGetAllMtrrs (&LocalMtrrs);
|
||||
}
|
||||
|
||||
ActualMemoryRangesCount = ARRAY_SIZE (ActualMemoryRanges);
|
||||
CollectTestResult (
|
||||
SystemParameter->DefaultCacheType, SystemParameter->PhysicalAddressBits, SystemParameter->VariableMtrrCount,
|
||||
&LocalMtrrs, ActualMemoryRanges, &ActualMemoryRangesCount, &ActualVariableMtrrUsage
|
||||
SystemParameter->DefaultCacheType,
|
||||
SystemParameter->PhysicalAddressBits,
|
||||
SystemParameter->VariableMtrrCount,
|
||||
&LocalMtrrs,
|
||||
ActualMemoryRanges,
|
||||
&ActualMemoryRangesCount,
|
||||
&ActualVariableMtrrUsage
|
||||
);
|
||||
UT_LOG_INFO ("--- Actual Memory Ranges [%d] ---\n", ActualMemoryRangesCount);
|
||||
DumpMemoryRanges (ActualMemoryRanges, ActualMemoryRangesCount);
|
||||
@@ -989,7 +1037,6 @@ UnitTestMtrrSetMemoryAttributeInMtrrSettings (
|
||||
return UNIT_TEST_PASSED;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Prep routine for UnitTestGetFirmwareVariableMtrrCount().
|
||||
|
||||
@@ -1003,7 +1050,7 @@ SavePcdValue (
|
||||
{
|
||||
MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT *LocalContext;
|
||||
|
||||
LocalContext = (MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT *) Context;
|
||||
LocalContext = (MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT *)Context;
|
||||
LocalContext->NumberOfReservedVariableMtrrs = PatchPcdGet32 (PcdCpuNumberOfReservedVariableMtrrs);
|
||||
return UNIT_TEST_PASSED;
|
||||
}
|
||||
@@ -1021,7 +1068,7 @@ RestorePcdValue (
|
||||
{
|
||||
MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT *LocalContext;
|
||||
|
||||
LocalContext = (MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT *) Context;
|
||||
LocalContext = (MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT *)Context;
|
||||
PatchPcdSet32 (PcdCpuNumberOfReservedVariableMtrrs, LocalContext->NumberOfReservedVariableMtrrs);
|
||||
}
|
||||
|
||||
@@ -1040,20 +1087,20 @@ STATIC
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UnitTestingEntry (
|
||||
UINTN Iteration
|
||||
UINTN Iteration
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UNIT_TEST_FRAMEWORK_HANDLE Framework;
|
||||
UNIT_TEST_SUITE_HANDLE MtrrApiTests;
|
||||
UINTN Index;
|
||||
UINTN SystemIndex;
|
||||
MTRR_LIB_TEST_CONTEXT Context;
|
||||
MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT GetFirmwareVariableMtrrCountContext;
|
||||
EFI_STATUS Status;
|
||||
UNIT_TEST_FRAMEWORK_HANDLE Framework;
|
||||
UNIT_TEST_SUITE_HANDLE MtrrApiTests;
|
||||
UINTN Index;
|
||||
UINTN SystemIndex;
|
||||
MTRR_LIB_TEST_CONTEXT Context;
|
||||
MTRR_LIB_GET_FIRMWARE_VARIABLE_MTRR_COUNT_CONTEXT GetFirmwareVariableMtrrCountContext;
|
||||
|
||||
Context.SystemParameter = &mDefaultSystemParameter;
|
||||
GetFirmwareVariableMtrrCountContext.SystemParameter = &mDefaultSystemParameter;
|
||||
Framework = NULL;
|
||||
Framework = NULL;
|
||||
|
||||
//
|
||||
// Setup the test framework for running the tests.
|
||||
@@ -1077,24 +1124,26 @@ UnitTestingEntry (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto EXIT;
|
||||
}
|
||||
AddTestCase (MtrrApiTests, "Test IsMtrrSupported", "MtrrSupported", UnitTestIsMtrrSupported, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test GetVariableMtrrCount", "GetVariableMtrrCount", UnitTestGetVariableMtrrCount, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test GetFirmwareVariableMtrrCount", "GetFirmwareVariableMtrrCount", UnitTestGetFirmwareVariableMtrrCount, SavePcdValue, RestorePcdValue, &GetFirmwareVariableMtrrCountContext);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrGetMemoryAttribute", "MtrrGetMemoryAttribute", UnitTestMtrrGetMemoryAttribute, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrGetFixedMtrr", "MtrrGetFixedMtrr", UnitTestMtrrGetFixedMtrr, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrGetAllMtrrs", "MtrrGetAllMtrrs", UnitTestMtrrGetAllMtrrs, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrSetAllMtrrs", "MtrrSetAllMtrrs", UnitTestMtrrSetAllMtrrs, NULL, NULL, &Context);
|
||||
|
||||
AddTestCase (MtrrApiTests, "Test IsMtrrSupported", "MtrrSupported", UnitTestIsMtrrSupported, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test GetVariableMtrrCount", "GetVariableMtrrCount", UnitTestGetVariableMtrrCount, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test GetFirmwareVariableMtrrCount", "GetFirmwareVariableMtrrCount", UnitTestGetFirmwareVariableMtrrCount, SavePcdValue, RestorePcdValue, &GetFirmwareVariableMtrrCountContext);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrGetMemoryAttribute", "MtrrGetMemoryAttribute", UnitTestMtrrGetMemoryAttribute, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrGetFixedMtrr", "MtrrGetFixedMtrr", UnitTestMtrrGetFixedMtrr, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrGetAllMtrrs", "MtrrGetAllMtrrs", UnitTestMtrrGetAllMtrrs, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrSetAllMtrrs", "MtrrSetAllMtrrs", UnitTestMtrrSetAllMtrrs, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrGetMemoryAttributeInVariableMtrr", "MtrrGetMemoryAttributeInVariableMtrr", UnitTestMtrrGetMemoryAttributeInVariableMtrr, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrDebugPrintAllMtrrs", "MtrrDebugPrintAllMtrrs", UnitTestMtrrDebugPrintAllMtrrs, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrGetDefaultMemoryType", "MtrrGetDefaultMemoryType", UnitTestMtrrGetDefaultMemoryType, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrDebugPrintAllMtrrs", "MtrrDebugPrintAllMtrrs", UnitTestMtrrDebugPrintAllMtrrs, NULL, NULL, &Context);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrGetDefaultMemoryType", "MtrrGetDefaultMemoryType", UnitTestMtrrGetDefaultMemoryType, NULL, NULL, &Context);
|
||||
|
||||
for (SystemIndex = 0; SystemIndex < ARRAY_SIZE (mSystemParameters); SystemIndex++) {
|
||||
for (Index = 0; Index < Iteration; Index++) {
|
||||
AddTestCase (MtrrApiTests, "Test InvalidMemoryLayouts", "InvalidMemoryLayouts", UnitTestInvalidMemoryLayouts, InitializeSystem, NULL, &mSystemParameters[SystemIndex]);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrSetMemoryAttributeInMtrrSettings", "MtrrSetMemoryAttributeInMtrrSettings", UnitTestMtrrSetMemoryAttributeInMtrrSettings, InitializeSystem, NULL, &mSystemParameters[SystemIndex]);
|
||||
AddTestCase (MtrrApiTests, "Test InvalidMemoryLayouts", "InvalidMemoryLayouts", UnitTestInvalidMemoryLayouts, InitializeSystem, NULL, &mSystemParameters[SystemIndex]);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrSetMemoryAttributeInMtrrSettings", "MtrrSetMemoryAttributeInMtrrSettings", UnitTestMtrrSetMemoryAttributeInMtrrSettings, InitializeSystem, NULL, &mSystemParameters[SystemIndex]);
|
||||
AddTestCase (MtrrApiTests, "Test MtrrSetMemoryAttributesInMtrrSettings", "MtrrSetMemoryAttributesInMtrrSettings", UnitTestMtrrSetMemoryAttributesInMtrrSettings, InitializeSystem, NULL, &mSystemParameters[SystemIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Execute the tests.
|
||||
//
|
||||
@@ -1118,14 +1167,14 @@ EXIT:
|
||||
**/
|
||||
INT32
|
||||
main (
|
||||
INT32 Argc,
|
||||
CHAR8 *Argv[]
|
||||
INT32 Argc,
|
||||
CHAR8 *Argv[]
|
||||
)
|
||||
{
|
||||
UINTN Count;
|
||||
UINTN Count;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION));
|
||||
srand ((unsigned int) time (NULL));
|
||||
srand ((unsigned int)time (NULL));
|
||||
|
||||
//
|
||||
// MtrrLibUnitTest generate-random-numbers <path to MtrrLib/UnitTest/RandomNumber.c> <random-number count>
|
||||
|
Reference in New Issue
Block a user