TianoCore EDK2 master
Loading...
Searching...
No Matches
MtrrLibUnitTest.h
Go to the documentation of this file.
1
8#ifndef _MTRR_SUPPORT_H_
9#define _MTRR_SUPPORT_H_
10
11#include <stdio.h>
12#include <stdlib.h>
13#include <string.h>
14#include <stdarg.h>
15#include <stddef.h>
16#include <setjmp.h>
17#include <cmocka.h>
18#include <time.h>
19
20#include <Uefi.h>
21#include <Library/BaseLib.h>
23#include <Library/DebugLib.h>
24#include <Library/UnitTestLib.h>
25#include <Library/MtrrLib.h>
27
29#include <Register/Cpuid.h>
30#include <Register/Msr.h>
31
32#define UNIT_TEST_APP_NAME "MtrrLib Unit Tests"
33#define UNIT_TEST_APP_VERSION "1.0"
34
35#define SCRATCH_BUFFER_SIZE SIZE_16KB
36
37typedef struct {
38 UINT8 PhysicalAddressBits;
39 BOOLEAN MtrrSupported;
40 BOOLEAN FixedMtrrSupported;
41 MTRR_MEMORY_CACHE_TYPE DefaultCacheType;
42 UINT32 VariableMtrrCount;
43 UINT8 MkTmeKeyidBits;
45
46extern UINT32 mFixedMtrrsIndex[];
47extern BOOLEAN mRandomInput;
48
55EFIAPI
57 IN MTRR_LIB_SYSTEM_PARAMETER *SystemParameter
58 );
59
66EFIAPI
68 IN UNIT_TEST_CONTEXT Context
69 );
70
74MTRR_MEMORY_CACHE_TYPE
76 VOID
77 );
78
90VOID
92 IN UINT32 PhysicalAddressBits,
93 IN OUT MTRR_MEMORY_RANGE *RawMemoryRanges,
94 IN UINT32 UcCount,
95 IN UINT32 WtCount,
96 IN UINT32 WbCount,
97 IN UINT32 WpCount,
98 IN UINT32 WcCount
99 );
100
111VOID
113 IN MTRR_MEMORY_CACHE_TYPE DefaultType,
114 IN UINT32 PhysicalAddressBits,
115 IN MTRR_MEMORY_RANGE *RawMemoryRanges,
116 IN UINT32 RawMemoryRangeCount,
117 OUT MTRR_MEMORY_RANGE *MemoryRanges,
118 OUT UINTN *MemoryRangeCount
119 );
120
129VOID
131 IN UINT32 PhysicalAddressBits,
132 IN MTRR_MEMORY_CACHE_TYPE CacheType,
133 OUT MTRR_VARIABLE_SETTING *MtrrPair OPTIONAL,
134 OUT MTRR_MEMORY_RANGE *MtrrMemoryRange OPTIONAL
135 );
136
148VOID
150 IN MTRR_MEMORY_CACHE_TYPE DefaultType,
151 IN UINT32 PhysicalAddressBits,
152 IN UINT32 VariableMtrrCount,
153 IN MTRR_SETTINGS *Mtrrs,
154 OUT MTRR_MEMORY_RANGE *Ranges,
155 IN OUT UINTN *RangeCount,
156 OUT UINT32 *MtrrCount
157 );
158
166UINT64
167Random64 (
168 UINT64 Start,
169 UINT64 Limit
170 );
171
179UINT32
180Random32 (
181 UINT32 Start,
182 UINT32 Limit
183 );
184
191VOID
193 CHAR8 *FilePath,
194 UINTN Count
195 );
196
197#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
UINT64 Random64(UINT64 Start, UINT64 Limit)
Definition: RandomTest.c:111
VOID CollectTestResult(IN MTRR_MEMORY_CACHE_TYPE DefaultType, IN UINT32 PhysicalAddressBits, IN UINT32 VariableMtrrCount, IN MTRR_SETTINGS *Mtrrs, OUT MTRR_MEMORY_RANGE *Ranges, IN OUT UINTN *RangeCount, OUT UINT32 *MtrrCount)
Definition: Support.c:437
VOID GenerateValidAndConfigurableMtrrPairs(IN UINT32 PhysicalAddressBits, IN OUT MTRR_MEMORY_RANGE *RawMemoryRanges, IN UINT32 UcCount, IN UINT32 WtCount, IN UINT32 WbCount, IN UINT32 WpCount, IN UINT32 WcCount)
Definition: Support.c:606
VOID GenerateRandomNumbers(CHAR8 *FilePath, UINTN Count)
Definition: Support.c:68
UNIT_TEST_STATUS EFIAPI InitializeMtrrRegs(IN MTRR_LIB_SYSTEM_PARAMETER *SystemParameter)
Definition: Support.c:358
UINT32 Random32(UINT32 Start, UINT32 Limit)
Definition: RandomTest.c:92
MTRR_MEMORY_CACHE_TYPE GenerateRandomCacheType(VOID)
Definition: Support.c:658
UNIT_TEST_STATUS EFIAPI InitializeSystem(IN UNIT_TEST_CONTEXT Context)
Definition: Support.c:418
VOID GetEffectiveMemoryRanges(IN MTRR_MEMORY_CACHE_TYPE DefaultType, IN UINT32 PhysicalAddressBits, IN MTRR_MEMORY_RANGE *RawMemoryRanges, IN UINT32 RawMemoryRangeCount, OUT MTRR_MEMORY_RANGE *MemoryRanges, OUT UINTN *MemoryRangeCount)
Definition: Support.c:1009
VOID GenerateRandomMtrrPair(IN UINT32 PhysicalAddressBits, IN MTRR_MEMORY_CACHE_TYPE CacheType, OUT MTRR_VARIABLE_SETTING *MtrrPair OPTIONAL, OUT MTRR_MEMORY_RANGE *MtrrMemoryRange OPTIONAL)
Definition: Support.c:514
VOID * UNIT_TEST_CONTEXT
Definition: UnitTestLib.h:54
UINT32 UNIT_TEST_STATUS
Definition: UnitTestLib.h:16