]>
Commit | Line | Data |
---|---|---|
7c636bd0 | 1 | /** @file\r |
2 | The generic memory test driver definition\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions\r | |
8 | of the BSD License which accompanies this distribution. The\r | |
9 | full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef _GENERIC_MEMORY_TEST_H_\r | |
18 | #define _GENERIC_MEMORY_TEST_H_\r | |
19 | \r | |
20 | #include <Guid/StatusCodeDataTypeId.h>\r | |
21 | #include <Protocol/GenericMemoryTest.h>\r | |
22 | #include <Protocol/Cpu.h>\r | |
23 | \r | |
24 | #include <Library/DebugLib.h>\r | |
25 | #include <Library/UefiDriverEntryPoint.h>\r | |
26 | #include <Library/HobLib.h>\r | |
27 | #include <Library/DxeServicesTableLib.h>\r | |
28 | #include <Library/ReportStatusCodeLib.h>\r | |
29 | #include <Library/BaseLib.h>\r | |
30 | #include <Library/BaseMemoryLib.h>\r | |
31 | #include <Library/MemoryAllocationLib.h>\r | |
32 | #include <Library/UefiBootServicesTableLib.h>\r | |
33 | \r | |
34 | //\r | |
35 | // Some global define\r | |
36 | //\r | |
37 | #define GENERIC_CACHELINE_SIZE 0x40\r | |
38 | \r | |
39 | //\r | |
40 | // attributes for reserved memory before it is promoted to system memory\r | |
41 | //\r | |
42 | #define EFI_MEMORY_PRESENT 0x0100000000000000ULL\r | |
43 | #define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL\r | |
44 | #define EFI_MEMORY_TESTED 0x0400000000000000ULL\r | |
45 | \r | |
46 | //\r | |
47 | // The SPARSE_SPAN_SIZE size can not small then the MonoTestSize\r | |
48 | //\r | |
49 | #define TEST_BLOCK_SIZE 0x2000000\r | |
50 | #define QUICK_SPAN_SIZE (TEST_BLOCK_SIZE >> 2)\r | |
51 | #define SPARSE_SPAN_SIZE (TEST_BLOCK_SIZE >> 4)\r | |
52 | \r | |
53 | //\r | |
54 | // This structure records every nontested memory range parsed through GCD\r | |
55 | // service.\r | |
56 | //\r | |
57 | #define EFI_NONTESTED_MEMORY_RANGE_SIGNATURE SIGNATURE_32 ('N', 'T', 'M', 'E')\r | |
58 | \r | |
59 | typedef struct {\r | |
60 | UINTN Signature;\r | |
61 | LIST_ENTRY Link;\r | |
62 | EFI_PHYSICAL_ADDRESS StartAddress;\r | |
63 | UINT64 Length;\r | |
64 | UINT64 Capabilities;\r | |
65 | BOOLEAN Above4G;\r | |
66 | BOOLEAN AlreadyMapped;\r | |
67 | } NONTESTED_MEMORY_RANGE;\r | |
68 | \r | |
69 | #define NONTESTED_MEMORY_RANGE_FROM_LINK(link) \\r | |
70 | CR ( \\r | |
71 | link, \\r | |
72 | NONTESTED_MEMORY_RANGE, \\r | |
73 | Link, \\r | |
74 | EFI_NONTESTED_MEMORY_RANGE_SIGNATURE \\r | |
75 | )\r | |
76 | \r | |
77 | //\r | |
78 | // This is the memory test driver's structure definition\r | |
79 | //\r | |
80 | #define EFI_GENERIC_MEMORY_TEST_PRIVATE_SIGNATURE SIGNATURE_32 ('G', 'E', 'M', 'T')\r | |
81 | \r | |
82 | typedef struct {\r | |
83 | \r | |
84 | UINTN Signature;\r | |
85 | EFI_HANDLE Handle;\r | |
86 | \r | |
87 | //\r | |
88 | // Cpu arch protocol's pointer\r | |
89 | //\r | |
90 | EFI_CPU_ARCH_PROTOCOL *Cpu;\r | |
91 | \r | |
92 | //\r | |
93 | // generic memory test driver's protocol\r | |
94 | //\r | |
95 | EFI_GENERIC_MEMORY_TEST_PROTOCOL GenericMemoryTest;\r | |
96 | \r | |
97 | //\r | |
98 | // memory test covered spans\r | |
99 | //\r | |
100 | EXTENDMEM_COVERAGE_LEVEL CoverLevel;\r | |
101 | UINTN CoverageSpan;\r | |
102 | UINT64 BdsBlockSize;\r | |
103 | \r | |
104 | //\r | |
105 | // the memory test pattern and size every time R/W/V memory\r | |
106 | //\r | |
107 | VOID *MonoPattern;\r | |
108 | UINTN MonoTestSize;\r | |
109 | \r | |
110 | //\r | |
111 | // base memory's size which tested in PEI phase\r | |
112 | //\r | |
113 | UINT64 BaseMemorySize;\r | |
114 | \r | |
115 | //\r | |
116 | // memory range list\r | |
117 | //\r | |
118 | LIST_ENTRY NonTestedMemRanList;\r | |
119 | \r | |
120 | } GENERIC_MEMORY_TEST_PRIVATE;\r | |
121 | \r | |
122 | #define GENERIC_MEMORY_TEST_PRIVATE_FROM_THIS(a) \\r | |
123 | CR ( \\r | |
124 | a, \\r | |
125 | GENERIC_MEMORY_TEST_PRIVATE, \\r | |
126 | GenericMemoryTest, \\r | |
127 | EFI_GENERIC_MEMORY_TEST_PRIVATE_SIGNATURE \\r | |
128 | )\r | |
129 | \r | |
130 | //\r | |
131 | // Function Prototypes\r | |
132 | //\r | |
133 | \r | |
134 | /**\r | |
135 | Construct the system base memory range through GCD service.\r | |
136 | \r | |
137 | @param[in] Private Point to generic memory test driver's private data.\r | |
138 | \r | |
139 | @retval EFI_SUCCESS Successful construct the base memory range through GCD service.\r | |
140 | @retval EFI_OUT_OF_RESOURCE Could not allocate needed resource from base memory.\r | |
141 | @retval Others Failed to construct base memory range through GCD service.\r | |
142 | \r | |
143 | **/\r | |
144 | EFI_STATUS\r | |
145 | ConstructBaseMemoryRange (\r | |
146 | IN GENERIC_MEMORY_TEST_PRIVATE *Private\r | |
147 | );\r | |
148 | \r | |
149 | /**\r | |
150 | Construct the system non-tested memory range through GCD service.\r | |
151 | \r | |
152 | @param[in] Private Point to generic memory test driver's private data.\r | |
153 | \r | |
154 | @retval EFI_SUCCESS Successful construct the non-tested memory range through GCD service.\r | |
155 | @retval EFI_OUT_OF_RESOURCE Could not allocate needed resource from base memory.\r | |
156 | @retval Others Failed to construct non-tested memory range through GCD service.\r | |
157 | \r | |
158 | **/\r | |
159 | EFI_STATUS\r | |
160 | ConstructNonTestedMemoryRange (\r | |
161 | IN GENERIC_MEMORY_TEST_PRIVATE *Private\r | |
162 | );\r | |
163 | \r | |
164 | /**\r | |
165 | Perform the address line walking ones test.\r | |
166 | \r | |
167 | @param[in] Private Point to generic memory test driver's private data.\r | |
168 | \r | |
169 | @retval EFI_SUCCESS Successful finished walking ones test. \r | |
170 | @retval EFI_OUT_OF_RESOURCE Could not get resource in base memory. \r | |
171 | @retval EFI_ACCESS_DENIED Code may can not run here because if walking one test\r | |
172 | failed, system may be already halt.\r | |
173 | \r | |
174 | **/\r | |
175 | EFI_STATUS\r | |
176 | PerformAddressDataLineTest (\r | |
177 | IN GENERIC_MEMORY_TEST_PRIVATE *Private\r | |
178 | );\r | |
179 | \r | |
180 | /**\r | |
181 | Destroy the link list base on the correspond link list type.\r | |
182 | \r | |
183 | @param[in] Private Point to generic memory test driver's private data.\r | |
184 | \r | |
185 | **/\r | |
186 | VOID\r | |
187 | DestroyLinkList (\r | |
188 | IN GENERIC_MEMORY_TEST_PRIVATE *Private\r | |
189 | );\r | |
190 | \r | |
191 | /**\r | |
192 | Add the extened memory to whole system memory map.\r | |
193 | \r | |
194 | @param[in] Private Point to generic memory test driver's private data.\r | |
195 | \r | |
196 | @retval EFI_SUCCESS Successful add all the extended memory to system memory map.\r | |
197 | @retval Others Failed to add the tested extended memory.\r | |
198 | \r | |
199 | **/\r | |
200 | EFI_STATUS\r | |
201 | UpdateMemoryMap (\r | |
202 | IN GENERIC_MEMORY_TEST_PRIVATE *Private\r | |
203 | );\r | |
204 | \r | |
205 | /**\r | |
206 | Write the memory test pattern into a range of physical memory.\r | |
207 | \r | |
208 | @param[in] Private Point to generic memory test driver's private data.\r | |
209 | @param[in] Start The memory range's start address.\r | |
210 | @param[in] Size The memory range's size.\r | |
211 | \r | |
212 | @retval EFI_SUCCESS Successful write the test pattern into the non-tested memory.\r | |
213 | @retval Others The test pattern may not really write into the physical memory.\r | |
214 | \r | |
215 | **/\r | |
216 | EFI_STATUS\r | |
217 | WriteMemory (\r | |
218 | IN GENERIC_MEMORY_TEST_PRIVATE *Private,\r | |
219 | IN EFI_PHYSICAL_ADDRESS Start,\r | |
220 | IN UINT64 Size\r | |
221 | );\r | |
222 | \r | |
223 | /**\r | |
224 | Verify the range of physical memory which covered by memory test pattern.\r | |
225 | \r | |
226 | This function will also do not return any informatin just cause system reset,\r | |
227 | because the handle error encount fatal error and disable the bad DIMMs.\r | |
228 | \r | |
229 | @param[in] Private Point to generic memory test driver's private data.\r | |
230 | @param[in] Start The memory range's start address.\r | |
231 | @param[in] Size The memory range's size.\r | |
232 | \r | |
233 | @retval EFI_SUCCESS Successful verify the range of memory, no errors' location found.\r | |
234 | @retval Others The range of memory have errors contained.\r | |
235 | \r | |
236 | **/\r | |
237 | EFI_STATUS\r | |
238 | VerifyMemory (\r | |
239 | IN GENERIC_MEMORY_TEST_PRIVATE *Private,\r | |
240 | IN EFI_PHYSICAL_ADDRESS Start,\r | |
241 | IN UINT64 Size\r | |
242 | );\r | |
243 | \r | |
244 | /**\r | |
245 | Test a range of the memory directly .\r | |
246 | \r | |
247 | @param[in] Private Point to generic memory test driver's private data.\r | |
248 | @param[in] StartAddress Starting address of the memory range to be tested.\r | |
249 | @param[in] Length Length in bytes of the memory range to be tested.\r | |
250 | @param[in] Capabilities The bit mask of attributes that the memory range supports.\r | |
251 | \r | |
252 | @retval EFI_SUCCESS Successful test the range of memory.\r | |
253 | @retval Others Failed to test the range of memory.\r | |
254 | \r | |
255 | **/\r | |
256 | EFI_STATUS\r | |
257 | DirectRangeTest (\r | |
258 | IN GENERIC_MEMORY_TEST_PRIVATE *Private,\r | |
259 | IN EFI_PHYSICAL_ADDRESS StartAddress,\r | |
260 | IN UINT64 Length,\r | |
261 | IN UINT64 Capabilities\r | |
262 | );\r | |
263 | \r | |
264 | /**\r | |
265 | Initialize the generic memory test.\r | |
266 | \r | |
267 | @param[in] This The protocol instance pointer. \r | |
268 | @param[in] Level The coverage level of the memory test. \r | |
269 | @param[out] RequireSoftECCInit Indicate if the memory need software ECC init. \r | |
270 | \r | |
271 | @retval EFI_SUCCESS The generic memory test is initialized correctly. \r | |
272 | @retval EFI_NO_MEDIA The system had no memory to be tested. \r | |
273 | \r | |
274 | **/\r | |
275 | EFI_STATUS\r | |
276 | EFIAPI\r | |
277 | InitializeMemoryTest (\r | |
278 | IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,\r | |
279 | IN EXTENDMEM_COVERAGE_LEVEL Level,\r | |
280 | OUT BOOLEAN *RequireSoftECCInit\r | |
281 | );\r | |
282 | \r | |
283 | /**\r | |
284 | Perform the memory test.\r | |
285 | \r | |
286 | @param[in] This The protocol instance pointer. \r | |
287 | @param[out] TestedMemorySize Return the tested extended memory size. \r | |
288 | @param[out] TotalMemorySize Return the whole system physical memory size. \r | |
289 | The total memory size does not include memory in a slot with a disabled DIMM. \r | |
290 | @param[out] ErrorOut TRUE if the memory error occured.\r | |
291 | @param[in] IfTestAbort Indicates that the user pressed "ESC" to skip the memory test. \r | |
292 | \r | |
293 | @retval EFI_SUCCESS One block of memory passed the test.\r | |
294 | @retval EFI_NOT_FOUND All memory blocks have already been tested.\r | |
295 | @retval EFI_DEVICE_ERROR Memory device error occured, and no agent can handle it.\r | |
296 | \r | |
297 | **/\r | |
298 | EFI_STATUS\r | |
299 | EFIAPI\r | |
300 | GenPerformMemoryTest (\r | |
301 | IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,\r | |
302 | OUT UINT64 *TestedMemorySize,\r | |
303 | OUT UINT64 *TotalMemorySize,\r | |
304 | OUT BOOLEAN *ErrorOut,\r | |
305 | IN BOOLEAN TestAbort\r | |
306 | );\r | |
307 | \r | |
308 | /**\r | |
309 | Finish the memory test.\r | |
310 | \r | |
311 | @param[in] This The protocol instance pointer. \r | |
312 | \r | |
313 | @retval EFI_SUCCESS Success. All resources used in the memory test are freed.\r | |
314 | \r | |
315 | **/\r | |
316 | EFI_STATUS\r | |
317 | EFIAPI\r | |
318 | GenMemoryTestFinished (\r | |
319 | IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This\r | |
320 | );\r | |
321 | \r | |
322 | /**\r | |
323 | Provides the capability to test the compatible range used by some special drivers.\r | |
324 | \r | |
325 | @param[in] This The protocol instance pointer. \r | |
326 | @param[in] StartAddress The start address of the compatible memory range that\r | |
327 | must be below 16M.\r | |
328 | @param[in] Length The compatible memory range's length. \r | |
329 | \r | |
330 | @retval EFI_SUCCESS The compatible memory range pass the memory test. \r | |
331 | @retval EFI_INVALID_PARAMETER The compatible memory range are not below Low 16M.\r | |
332 | \r | |
333 | **/\r | |
334 | EFI_STATUS\r | |
335 | EFIAPI\r | |
336 | GenCompatibleRangeTest (\r | |
337 | IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,\r | |
338 | IN EFI_PHYSICAL_ADDRESS StartAddress,\r | |
339 | IN UINT64 Length\r | |
340 | );\r | |
341 | \r | |
342 | #endif\r |