From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::242; helo=mail-it0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x242.google.com (mail-it0-x242.google.com [IPv6:2607:f8b0:4001:c0b::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3ED952034A8A2 for ; Tue, 23 Jan 2018 01:27:37 -0800 (PST) Received: by mail-it0-x242.google.com with SMTP id b5so255233itc.3 for ; Tue, 23 Jan 2018 01:33:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Wseq1jlaH+f805NZkriy9DqYjks01e7+ypYv5NVP7p4=; b=FQa7EgVmGJjYa22ZvtjlFQ31yxmtVncOnxtczvra/k8Dw4UX1CDQkKgzDnpusGbTeZ bqu2/jCaIVspOuzdiwfeECcJKDgdUY5eMmpcNYismSfK91EpsQoYyac8bRZOZ91uDRxT YjaBg8rpeoCUioT965/LOFD4FWVBkW+JhJ89o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Wseq1jlaH+f805NZkriy9DqYjks01e7+ypYv5NVP7p4=; b=HPR8sqD/Se3xtSoOIWI3LDHAcnkwu/p16QalyfimeDVlQX3r3zdkDxnFsAPRTWQ4x/ DWqQgotN/dV8XJ34thZasLM/6DkD9B7r0GaQv5sQmi/VSFfgrt/dc731rgwET9bEBOy7 3GnxMDp6gTaKopdupWNC3RHdXDG1TtAOJVwryz0tV95Pi+5ClxKyubpdsrOvSgyG78ZR bdWDWYP6rbIkOP8eK3mH8+dQ8hPmm7OywyjMSdn5psLxtMlRYR7hLm8wePBHftXjCTWL gRHGT+54T/ivOJTmK0f+1KH2qqBFdp+LSINp+Ay93PNS9wto+TERkC45b5pxRzrQkv0Q gPKg== X-Gm-Message-State: AKwxytdhLBcVpwG4UeLmfYdAt/+yiN4q8G/hAi9nKe1ejkkN01FmIDgq /glpCIQpKKl52uowsJv9pm3nXqoLliOjlEgvp4HVaQ== X-Google-Smtp-Source: AH8x227LZTzp7a2J6B6cFBTdYdscOBO8eGDe7kDD3/qop6L5ZExQc2fr94XNavNFoidkWeCmhYLaXy7F3fVuhXihm2g= X-Received: by 10.36.128.5 with SMTP id g5mr2832164itd.17.1516699984034; Tue, 23 Jan 2018 01:33:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.112.13 with HTTP; Tue, 23 Jan 2018 01:33:03 -0800 (PST) In-Reply-To: <9ea4e05c-c407-4b41-a900-5c12373781a7@huawei.com> References: <1516287703-35516-1-git-send-email-huangming23@huawei.com> <1516287703-35516-5-git-send-email-huangming23@huawei.com> <9ea4e05c-c407-4b41-a900-5c12373781a7@huawei.com> From: Ard Biesheuvel Date: Tue, 23 Jan 2018 09:33:03 +0000 Message-ID: To: "Huangming (Mark)" Cc: Ming Huang , "edk2-devel@lists.01.org" , Leif Lindholm , Mengfanrong , Jason Zhang , linaro-uefi , guoheyi@huawei.com, waip23@126.com, wanghuiqiang Subject: Re: [PATCH edk2-platforms v1 04/14] Hisilicon D03/D05: Add capsule upgrade support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jan 2018 09:27:38 -0000 Content-Type: text/plain; charset="UTF-8" On 23 January 2018 at 08:53, Huangming (Mark) wrote: > > > On 2018/1/20 18:50, Ard Biesheuvel wrote: >> On 18 January 2018 at 15:01, Ming Huang wrote: >>> From: Jason Zhang >>> >>> Contributed-under: TianoCore Contribution Agreement 1.1 >>> Signed-off-by: Jason Zhang >>> Signed-off-by: Ming Huang >>> Signed-off-by: Heyi Guo >>> --- >>> Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini | 45 +++++++++ >>> Platform/Hisilicon/D03/D03.dsc | 17 +++- >>> Platform/Hisilicon/D03/D03.fdf | 70 +++++++++++++ >>> Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini | 45 +++++++++ >>> Platform/Hisilicon/D05/D05.dsc | 19 +++- >>> Platform/Hisilicon/D05/D05.fdf | 70 +++++++++++++ >>> Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc | 81 +++++++++++++++ >>> Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf | 50 +++++++++ >>> Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c | 70 +++++++++++++ >>> Silicon/Hisilicon/Hisilicon.dsc.inc | 11 +- >>> Silicon/Hisilicon/Hisilicon.fdf.inc | 9 ++ >>> Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.c | 106 ++++++++++++++++++++ >>> Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.inf | 51 ++++++++++ >>> 13 files changed, 641 insertions(+), 3 deletions(-) >>> >> >> Excellent!! Very happy to see this added. >> ... >>> diff --git a/Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.c b/Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.c >>> new file mode 100644 >>> index 0000000..db5725d >>> --- /dev/null >>> +++ b/Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.c >>> @@ -0,0 +1,106 @@ >>> +/** @file >>> + Platform Flash Access library. >>> + >>> + Copyright (c) 2018, Hisilicon Limited. All rights reserved. >>> + Copyright (c) 2018, Linaro Limited. All rights reserved. >>> + Copyright (c) 2016, Intel Corporation. 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 >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +STATIC EFI_PHYSICAL_ADDRESS mInternalFdAddress; >>> +STATIC EFI_PHYSICAL_ADDRESS mSFCMEM0BaseAddress; >>> + >>> +HISI_SPI_FLASH_PROTOCOL *mSpiProtocol; >> >> STATIC >> > > I agree with all of your comments except this one. > PerformFlashWrite is called in SystemFirmwareUpdateDxe module, > so STATIC can not be added. > I meant mSpiProtocol not PerformFlashWrite >>> + >>> +/** >>> + Perform flash write opreation. >>> + >>> + @param[in] FirmwareType The type of firmware. >>> + @param[in] FlashAddress The address of flash device to be accessed. >>> + @param[in] FlashAddressType The type of flash device address. >>> + @param[in] Buffer The pointer to the data buffer. >>> + @param[in] Length The length of data buffer in bytes. >>> + >>> + @retval EFI_SUCCESS The operation returns successfully. >>> + @retval EFI_WRITE_PROTECTED The flash device is read only. >>> + @retval EFI_UNSUPPORTED The flash device access is unsupported. >>> + @retval EFI_INVALID_PARAMETER The input parameter is not valid. >>> +**/ >>> +EFI_STATUS >>> +EFIAPI >>> +PerformFlashWrite ( >>> + IN PLATFORM_FIRMWARE_TYPE FirmwareType, >>> + IN EFI_PHYSICAL_ADDRESS FlashAddress, >>> + IN FLASH_ADDRESS_TYPE FlashAddressType, >>> + IN VOID *Buffer, >>> + IN UINTN Length >>> + ) >>> +{ >>> + UINT32 RomAddress; >>> + EFI_STATUS Status; >>> + >>> + DEBUG ((DEBUG_INFO, "PerformFlashWrite - 0x%x(%x) - 0x%x\n", (UINTN)FlashAddress, (UINTN)FlashAddressType, Length)); >>> + >> >> Line length >> >>> + if (FlashAddressType == FlashAddressTypeAbsoluteAddress) { >>> + FlashAddress = FlashAddress - mInternalFdAddress; >>> + } >>> + >>> + RomAddress = (UINT32)FlashAddress + (mInternalFdAddress - mSFCMEM0BaseAddress); >>> + >>> + DEBUG ((DEBUG_INFO, "Erase and Write Flash Start\n")); >>> + >>> + Status = mSpiProtocol->EraseWrite (mSpiProtocol, (UINT32) RomAddress, (UINT8 *)Buffer, (UINT32) Length); >> >> Line length >> >>> + if (EFI_ERROR (Status)) { >>> + DEBUG ((DEBUG_ERROR, "Erase and Write Status = %r \n", Status)); >>> + } >>> + >>> + return Status; >>> +} >>> + >>> +/** >>> + Platform Flash Access Lib Constructor. >>> + >>> + @param[in] ImageHandle The firmware allocated handle for the EFI image. >>> + @param[in] SystemTable A pointer to the EFI System Table. >>> + >>> + @retval EFI_SUCCESS Constructor returns successfully. >>> +**/ >>> +EFI_STATUS >>> +EFIAPI >>> +PerformFlashAccessLibConstructor ( >>> + IN EFI_HANDLE ImageHandle, >>> + IN EFI_SYSTEM_TABLE *SystemTable >>> + ) >>> +{ >>> + EFI_STATUS Status; >>> + >>> + mInternalFdAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet64 (PcdFdBaseAddress); >>> + >>> + mSFCMEM0BaseAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet64 (PcdSFCMEM0BaseAddress); >>> + >> >> Drop the (UINTN) cast, EFI_PHYSICAL_ADDRESS is always 64 bits. >> >>> + DEBUG ((DEBUG_INFO, "PcdFlashAreaBaseAddress - 0x%x, PcdSFCMEM0BaseAddress - 0x%x \n", mInternalFdAddress, mSFCMEM0BaseAddress)); >>> + >>> + Status = gBS->LocateProtocol (&gHisiSpiFlashProtocolGuid, NULL, (VOID **)&mSpiProtocol); >>> + if (EFI_ERROR (Status)) { >>> + DEBUG ((DEBUG_ERROR, "LocateProtocol gHisiSpiFlashProtocolGuid Status = %r \n", Status)); >>> + } >>> + >> >> Line length >> >>> + return Status; >>> +} >>> diff --git a/Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.inf b/Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.inf >>> new file mode 100644 >>> index 0000000..f4533ac >>> --- /dev/null >>> +++ b/Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.inf >>> @@ -0,0 +1,51 @@ >>> +## @file >>> +# Platform Flash Access library. >>> +# >>> +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. >>> +# Copyright (c) 2018, Linaro Limited. All rights reserved. >>> +# Copyright (c) 2016, Intel Corporation. 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 = 0x00010005 >> >> 0x0000001A >> >>> + BASE_NAME = PlatformFlashAccessLibDxe >>> + FILE_GUID = 9168384A-5F66-4CF7-AEB6-845BDEBD3012 >> >> Use a fresh GUID >> >>> + MODULE_TYPE = DXE_DRIVER >>> + VERSION_STRING = 1.0 >>> + LIBRARY_CLASS = PlatformFlashAccessLib|DXE_DRIVER >>> + CONSTRUCTOR = PerformFlashAccessLibConstructor >>> + >>> +[Sources] >>> + PlatformFlashAccessLibDxe.c >>> + >>> +[Packages] >>> + ArmPkg/ArmPkg.dec >>> + MdeModulePkg/MdeModulePkg.dec >>> + MdePkg/MdePkg.dec >>> + SignedCapsulePkg/SignedCapsulePkg.dec >>> + Silicon/Hisilicon/HisiPkg.dec >>> + >>> +[LibraryClasses] >>> + BaseMemoryLib >>> + DebugLib >>> + PcdLib >>> + UefiBootServicesTableLib >>> + >>> +[Protocols] >>> + gHisiSpiFlashProtocolGuid >>> + >>> +[FixedPcd] >>> + gArmTokenSpaceGuid.PcdFdBaseAddress >>> + gHisiTokenSpaceGuid.PcdSFCMEM0BaseAddress >>> + >>> +[Depex] >>> + gHisiSpiFlashProtocolGuid >>> -- >>> 1.9.1 >>> >> >> . >> > > -- > Best Regards, > > Ming > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel