The Hisilicon platforms only have 1GB memroy tested before BDS phase, and our platforms require uefi not using memory above 4GB. In order to promote the memory above 4GB,we need to perform MemoryTest.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chenhui Sun sunchenhui@huawei.com Signed-off-by: Heyi Guo heyi.guo@linaro.org --- .../Hisilicon/Drivers/PlatformBoot/PlatformBoot.c | 58 ++++++++++++++++++++++ .../Drivers/PlatformBoot/PlatformBoot.inf | 42 ++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 Chips/Hisilicon/Drivers/PlatformBoot/PlatformBoot.c create mode 100644 Chips/Hisilicon/Drivers/PlatformBoot/PlatformBoot.inf
diff --git a/Chips/Hisilicon/Drivers/PlatformBoot/PlatformBoot.c b/Chips/Hisilicon/Drivers/PlatformBoot/PlatformBoot.c new file mode 100644 index 0000000..9f977e6 --- /dev/null +++ b/Chips/Hisilicon/Drivers/PlatformBoot/PlatformBoot.c @@ -0,0 +1,58 @@ +/** @file +* +* Copyright (c) 2016, Hisilicon Limited. All rights reserved. +* Copyright (c) 2016, Linaro Limited. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the BSD License +* which accompanies this distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +**/ + +#include <Uefi.h> +#include <Library/DebugLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Protocol/GenericMemoryTest.h> + +EFI_STATUS +EFIAPI PlatformBootInit( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status = EFI_SUCCESS; + EFI_GENERIC_MEMORY_TEST_PROTOCOL* MemoryTest = NULL; + BOOLEAN RequireSoftECCInit = FALSE; + UINT64 TestedMemorySize; + UINT64 TotalMemorySize; + BOOLEAN TestAbort = FALSE; + BOOLEAN ErrorOut; + + //The Hisilicon platforms only have 1GB memroy tested before BDS phase, and our platforms require + //uefi not using memory above 4GB. + //In order to promote the memory above 4GB,we need to perform MemoryTest. + Status = gBS->LocateProtocol(&gEfiGenericMemTestProtocolGuid, NULL, (VOID**)&MemoryTest); + if (!EFI_ERROR(Status)) { + (VOID)MemoryTest->MemoryTestInit (MemoryTest, IGNORE, &RequireSoftECCInit); + DEBUG ((DEBUG_INFO,"MemoryTestInit done.\n")); + } + Status = MemoryTest->PerformMemoryTest ( + MemoryTest, + &TestedMemorySize, + &TotalMemorySize, + &ErrorOut, + TestAbort + ); + if (ErrorOut && (Status == EFI_DEVICE_ERROR)) { + DEBUG((DEBUG_INFO, "PerformMemoryTest error occur!\n")); + return Status; + } else { + DEBUG ((DEBUG_INFO, "%d bytes of system memory tested OK\r\n", TotalMemorySize)); + } + Status = MemoryTest->Finished (MemoryTest); + return Status; +} diff --git a/Chips/Hisilicon/Drivers/PlatformBoot/PlatformBoot.inf b/Chips/Hisilicon/Drivers/PlatformBoot/PlatformBoot.inf new file mode 100644 index 0000000..4763cc4 --- /dev/null +++ b/Chips/Hisilicon/Drivers/PlatformBoot/PlatformBoot.inf @@ -0,0 +1,42 @@ +## @file +# +# Copyright (c) 2016, Hisilicon Limited. All rights reserved. +# Copyright (c) 2016, Linaro Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010019 + BASE_NAME = PlatformBoot + FILE_GUID = 9A6C7020-12E8-4198-9BE2-1785ABC8CA8B + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = PlatformBootInit + +[Sources] + PlatformBoot.c + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Protocols] + gEfiGenericMemTestProtocolGuid + +[Guids] + +[Depex] + gEfiGenericMemTestProtocolGuid