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