+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- BaseMemoryTest.c\r
- \r
-Abstract:\r
- \r
- The PEI memory test support\r
-\r
---*/\r
-\r
-#include <BaseMemoryTest.h>\r
-\r
-static PEI_BASE_MEMORY_TEST_PPI mPeiBaseMemoryTestPpi = { BaseMemoryTest };\r
-\r
-static EFI_PEI_PPI_DESCRIPTOR PpiListPeiBaseMemoryTest = {\r
- (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
- &gPeiBaseMemoryTestPpiGuid,\r
- &mPeiBaseMemoryTestPpi\r
-};\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PeiBaseMemoryTestInit (\r
- IN EFI_FFS_FILE_HEADER *FfsHeader,\r
- IN EFI_PEI_SERVICES **PeiServices\r
- )\r
-/*++\r
-Description:\r
-\r
- Entry point function of BaseMemoryTestInit Peim.\r
-\r
-Arguments:\r
-\r
- PeiServices - General purpose services available to every PEIM.\r
- FfsHeader - Ffs header pointer\r
-\r
-Returns:\r
-\r
- Status - Result of InstallPpi\r
-\r
---*/ \r
-{\r
- EFI_STATUS Status;\r
-\r
- Status = (**PeiServices).InstallPpi (PeiServices, &PpiListPeiBaseMemoryTest);\r
-\r
- return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-BaseMemoryTest (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN PEI_BASE_MEMORY_TEST_PPI *This,\r
- IN EFI_PHYSICAL_ADDRESS BeginAddress,\r
- IN UINT64 MemoryLength,\r
- IN PEI_MEMORY_TEST_OP Operation,\r
- OUT EFI_PHYSICAL_ADDRESS *ErrorAddress\r
- )\r
-/*++\r
-Description:\r
-\r
- Test base memory.\r
-\r
-Arguments:\r
-\r
- PeiServices - General purpose services available to every PEIM.\r
- This - Pei memory test PPI pointer.\r
- BeginAddress - Beginning of the memory address to be checked.\r
- MemoryLength - Bytes of memory range to be checked.\r
- Operation - Type of memory check operation to be performed.\r
- ErrorAddress - Return the address of the error memory address.\r
- ErrorAddress - Address which has error when checked.\r
-\r
-Returns:\r
-\r
- Status - Result of InstallPpi\r
-\r
---*/ \r
-{\r
- UINT32 TestPattern;\r
- EFI_PHYSICAL_ADDRESS TempAddress;\r
- UINT32 SpanSize;\r
-\r
- REPORT_STATUS_CODE (\r
- EFI_PROGRESS_CODE,\r
- EFI_COMPUTING_UNIT_MEMORY + EFI_CU_MEMORY_PC_TEST\r
- );\r
-\r
- TestPattern = TEST_PATTERN;\r
- SpanSize = 0;\r
-\r
- //\r
- // Make sure we don't try and test anything above the max physical address range\r
- //\r
- ASSERT (BeginAddress + MemoryLength < EFI_MAX_ADDRESS);\r
-\r
- switch (Operation) {\r
- case Extensive:\r
- SpanSize = 0x4;\r
- break;\r
-\r
- case Sparse:\r
- case Quick:\r
- SpanSize = COVER_SPAN;\r
- break;\r
-\r
- case Ignore:\r
- goto Done;\r
- break;\r
- }\r
- //\r
- // Write the test pattern into memory range\r
- //\r
- TempAddress = BeginAddress;\r
- while (TempAddress < BeginAddress + MemoryLength) {\r
- (*(UINT32 *) (UINTN) TempAddress) = TestPattern;\r
- TempAddress += SpanSize;\r
- }\r
- //\r
- // Read pattern from memory and compare it\r
- //\r
- TempAddress = BeginAddress;\r
- while (TempAddress < BeginAddress + MemoryLength) {\r
- if ((*(UINT32 *) (UINTN) TempAddress) != TestPattern) {\r
- *ErrorAddress = TempAddress;\r
- REPORT_STATUS_CODE (\r
- EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED,\r
- EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_UNCORRECTABLE\r
- );\r
-\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- TempAddress += SpanSize;\r
- }\r
-\r
-Done:\r
- return EFI_SUCCESS;\r
-}\r