]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c
add function header for SIGNATURE_XX, according to MDE Spec, 0.61e-7
[mirror_edk2.git] / MdeModulePkg / Universal / MemoryTest / NullMemoryTestDxe / NullMemoryTest.c
CommitLineData
674dced3 1/** @file\r
2 Intall memory test protocol and bypass the real memory test procedure.\r
05177bef 3\r
674dced3 4Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
05177bef 9\r
674dced3 10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
05177bef 12\r
674dced3 13**/\r
05177bef 14\r
15\r
16#include "NullMemoryTest.h"\r
17\r
18//\r
19// Module global members\r
20//\r
21UINT64 mTestedSystemMemory = 0;\r
22UINT64 mTotalSystemMemory = 0;\r
23EFI_HANDLE mGenericMemoryTestHandle;\r
24\r
25//\r
26// Driver entry here\r
27//\r
28EFI_GENERIC_MEMORY_TEST_PROTOCOL mGenericMemoryTest = {\r
29 InitializeMemoryTest,\r
30 GenPerformMemoryTest,\r
31 GenMemoryTestFinished,\r
32 GenCompatibleRangeTest\r
33};\r
34\r
35EFI_STATUS\r
36EFIAPI\r
37GenericMemoryTestEntryPoint (\r
38 IN EFI_HANDLE ImageHandle,\r
39 IN EFI_SYSTEM_TABLE *SystemTable\r
40 )\r
41/*++\r
42\r
43Routine Description:\r
44\r
45 The generic memory test driver's entry point, it can initialize private data\r
46 to default value\r
47\r
48Arguments:\r
49\r
50 ImageHandle of the loaded driver\r
51 Pointer to the System Table\r
52\r
53Returns:\r
54\r
55 Status\r
56\r
57 EFI_SUCCESS - Protocol successfully installed\r
58 EFI_OUT_OF_RESOURCES - Can not allocate protocol data structure in base\r
59 memory\r
60\r
61--*/\r
62{\r
63 EFI_STATUS Status;\r
64\r
65 //\r
66 // Install the protocol\r
67 //\r
68 Status = gBS->InstallProtocolInterface (\r
69 &mGenericMemoryTestHandle,\r
70 &gEfiGenericMemTestProtocolGuid,\r
71 EFI_NATIVE_INTERFACE,\r
72 &mGenericMemoryTest\r
73 );\r
74\r
75 return Status;\r
76}\r
77//\r
78// EFI_GENERIC_MEMORY_TEST_PROTOCOL implementation\r
79//\r
80EFI_STATUS\r
81EFIAPI\r
82InitializeMemoryTest (\r
83 IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,\r
84 IN EXTENDMEM_COVERAGE_LEVEL Level,\r
85 OUT BOOLEAN *RequireSoftECCInit\r
86 )\r
87/*++\r
88\r
89Routine Description:\r
90\r
91Arguments:\r
92\r
93Returns:\r
94\r
95--*/\r
96{\r
97 UINTN NumberOfDescriptors;\r
98 EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;\r
99 UINTN Index;\r
100\r
101 gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);\r
102 for (Index = 0; Index < NumberOfDescriptors; Index++) {\r
103 if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeReserved &&\r
104 (MemorySpaceMap[Index].Capabilities & (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED)) ==\r
105 (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED)\r
106 ) {\r
107 gDS->RemoveMemorySpace (\r
108 MemorySpaceMap[Index].BaseAddress,\r
109 MemorySpaceMap[Index].Length\r
110 );\r
111\r
112 gDS->AddMemorySpace (\r
113 EfiGcdMemoryTypeSystemMemory,\r
114 MemorySpaceMap[Index].BaseAddress,\r
115 MemorySpaceMap[Index].Length,\r
116 MemorySpaceMap[Index].Capabilities &~\r
117 (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)\r
118 );\r
119\r
120 mTestedSystemMemory += MemorySpaceMap[Index].Length;\r
121 mTotalSystemMemory += MemorySpaceMap[Index].Length;\r
122 } else if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {\r
123 mTotalSystemMemory += MemorySpaceMap[Index].Length;\r
124 }\r
125 }\r
126\r
127 FreePool (MemorySpaceMap);\r
128\r
129 *RequireSoftECCInit = FALSE;\r
130 return EFI_SUCCESS;\r
131}\r
132\r
133EFI_STATUS\r
134EFIAPI\r
135GenPerformMemoryTest (\r
136 IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,\r
137 IN OUT UINT64 *TestedMemorySize,\r
138 OUT UINT64 *TotalMemorySize,\r
139 OUT BOOLEAN *ErrorOut,\r
140 IN BOOLEAN TestAbort\r
141 )\r
142/*++\r
143\r
144Routine Description:\r
145\r
146Arguments:\r
147\r
148Returns:\r
149\r
150--*/\r
151{\r
152 *ErrorOut = FALSE;\r
153 *TestedMemorySize = mTestedSystemMemory;\r
154 *TotalMemorySize = mTotalSystemMemory;\r
155\r
156 return EFI_NOT_FOUND;\r
157\r
158}\r
159\r
160EFI_STATUS\r
161EFIAPI\r
162GenMemoryTestFinished (\r
163 IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This\r
164 )\r
165/*++\r
166\r
167Routine Description:\r
168\r
169Arguments:\r
170\r
171Returns:\r
172\r
173--*/\r
174{\r
175 return EFI_SUCCESS;\r
176}\r
177\r
178EFI_STATUS\r
179EFIAPI\r
180GenCompatibleRangeTest (\r
181 IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,\r
182 IN EFI_PHYSICAL_ADDRESS StartAddress,\r
183 IN UINT64 Length\r
184 )\r
185/*++\r
186\r
187Routine Description:\r
188\r
189Arguments:\r
190\r
191Returns:\r
192\r
193--*/\r
194{\r
195 EFI_GCD_MEMORY_SPACE_DESCRIPTOR descriptor;\r
196\r
197 gDS->GetMemorySpaceDescriptor (StartAddress, &descriptor);\r
198\r
199 gDS->RemoveMemorySpace (StartAddress, Length);\r
200\r
201 gDS->AddMemorySpace (\r
202 EfiGcdMemoryTypeSystemMemory,\r
203 StartAddress,\r
204 Length,\r
205 descriptor.Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)\r
206 );\r
207\r
208 return EFI_SUCCESS;\r
209}\r