From patchwork Thu Nov 10 13:52:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 81668 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp742780qge; Thu, 10 Nov 2016 06:08:11 -0800 (PST) X-Received: by 10.37.108.8 with SMTP id h8mr5435367ybc.77.1478786891749; Thu, 10 Nov 2016 06:08:11 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t7si3440626qtc.66.2016.11.10.06.08.11; Thu, 10 Nov 2016 06:08:11 -0800 (PST) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 5806260E42; Thu, 10 Nov 2016 14:08:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 54B2D60E9D; Thu, 10 Nov 2016 13:59:21 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id D3F3B60E82; Thu, 10 Nov 2016 13:59:00 +0000 (UTC) Received: from mail-pf0-f177.google.com (mail-pf0-f177.google.com [209.85.192.177]) by lists.linaro.org (Postfix) with ESMTPS id 7A41360E34 for ; Thu, 10 Nov 2016 13:54:03 +0000 (UTC) Received: by mail-pf0-f177.google.com with SMTP id n85so147125669pfi.1 for ; Thu, 10 Nov 2016 05:54:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Cdu/vEf5uLFgBnWCxvkgtviTBkOb41fmAlnjUKTFCvM=; b=DjYSnIV86eebW3eBzzEGPHM7j5WFn4/WiJWvTmKgMKNS2WWKzzFFLoOo6J6JDLGDmw 5BXR6JaL/Ojfu0f942jnsnuX10rysDCF0zOVyLiyxqYTdzp9ZbjvXbYCXhCzeeyJENH/ V+EJPcDjLPuTK909vq74TzL4MfjGHmJIqSYOiYkVkuUGq2NQGy28IM/TCIT7E4lCXfK3 xwgwS+I7aqIt7whjwBdW5rvCZlw3w8y9QSUCRICWJkOguLy5cMW6qesBiXFsMaRERvLx KHriqrb8k3By92Z48WbNCLgpHpKhmiZMo0biFrjr0fPheNJ6p32m+M4jkG4pFx6/8o/j LFgQ== X-Gm-Message-State: ABUngvdXJklLFvfchhdBEKM+NblybUzjuYNwXaVVB2MlzftabO5izJe8vCf3BNLwfsl4D+WSOr0= X-Received: by 10.99.164.9 with SMTP id c9mr36232507pgf.141.1478786042624; Thu, 10 Nov 2016 05:54:02 -0800 (PST) Received: from localhost.localdomain ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id g78sm7625705pfe.19.2016.11.10.05.54.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Nov 2016 05:54:02 -0800 (PST) From: Heyi Guo To: linaro-uefi@lists.linaro.org Date: Thu, 10 Nov 2016 21:52:25 +0800 Message-Id: <1478785950-24197-22-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1478785950-24197-1-git-send-email-heyi.guo@linaro.org> References: <1478785950-24197-1-git-send-email-heyi.guo@linaro.org> Cc: Chenhui Sun Subject: [Linaro-uefi] [PATCH 21/27] Hisilicon: perform memorytest to promote reserved memory X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" 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 Signed-off-by: Heyi Guo --- .../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 +#include +#include +#include + +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