Message ID | 1516287703-35516-5-git-send-email-huangming23@huawei.com |
---|---|
State | New |
Headers | show |
Series | Improve D0x platforms and bug fix | expand |
On 18 January 2018 at 15:01, Ming Huang <heyi.guo@linaro.org> wrote: > From: Jason Zhang <zhangjinsong2@huawei.com> > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jason Zhang <zhangjinsong2@huawei.com> > Signed-off-by: Ming Huang <huangming23@huawei.com> > Signed-off-by: Heyi Guo <heyi.guo@linaro.org> > --- > 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/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini > new file mode 100644 > index 0000000..fc834d9 > --- /dev/null > +++ b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini > @@ -0,0 +1,45 @@ > +# > +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. > +# Copyright (c) 2018, Linaro Limited. All rights reserved. > +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> > +# > +# 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. > +# > +## > + > +[Head] > +NumOfUpdate = 3 > +NumOfRecovery = 0 > +Update0 = SysFvMain > +Update1 = SysCustom > +Update2 = SysNvRam > + > +[SysFvMain] > +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam > +AddressType = 0 # 0 - relative address, 1 - absolute address. > +BaseAddress = 0x00000000 # Base address offset on flash > +Length = 0x002D0000 # Length > +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image > +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid > + > +[SysCustom] > +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam > +AddressType = 0 # 0 - relative address, 1 - absolute address. > +BaseAddress = 0x002F0000 # Base address offset on flash > +Length = 0x00010000 # Length > +ImageOffset = 0x002F0000 # Image offset of this SystemFirmware image > +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid > + > +[SysNvRam] > +FirmwareType = 1 # 0 - SystemFirmware, 1 - NvRam > +AddressType = 0 # 0 - relative address, 1 - absolute address. > +BaseAddress = 0x002D0000 # Base address offset on flash > +Length = 0x00020000 # Length > +ImageOffset = 0x002D0000 # Image offset of this SystemFirmware image > +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid > diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc > index b2eae7d..69bc7b4 100644 > --- a/Platform/Hisilicon/D03/D03.dsc > +++ b/Platform/Hisilicon/D03/D03.dsc > @@ -66,7 +66,6 @@ > OemAddressMapLib|Platform/Hisilicon/D03/Library/OemAddressMap2P/OemAddressMap2PHi1610.inf > PlatformSysCtrlLib|Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.inf > > - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf > GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf > PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf > !if $(GENERIC_BDS) == TRUE > @@ -117,6 +116,11 @@ > gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE > gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE > > +[PcdsDynamicExDefault.common.DEFAULT] > + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 > + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x29, 0x3d, 0x4b, 0xd3, 0x85, 0x00, 0xb3, 0x4a, 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89} > + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xcf, 0x4f, 0x2e, 0x64, 0xf7, 0x2d, 0x15, 0x44, 0x8b, 0x70, 0xa0, 0x39, 0x09, 0xc5, 0x7b, 0x55} > + > [PcdsFixedAtBuild.common] > gArmPlatformTokenSpaceGuid.PcdCoreCount|8 > > @@ -310,6 +314,8 @@ > Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf > Silicon/Hisilicon/Drivers/VersionInfoPeim/VersionInfoPeim.inf > > + Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf > + > MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { > <LibraryClasses> > NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf > @@ -410,6 +416,9 @@ > > Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf > > + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf > + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf > + > # > # FAT filesystem + GPT/MBR partitioning > # > @@ -483,6 +492,12 @@ > !else > IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf > !endif > + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf { > + <LibraryClasses> > + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf > + } > + > + MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > > # > # UEFI application (Shell Embedded Boot Loader) > diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf > index 0d704b5..ffddd2d 100644 > --- a/Platform/Hisilicon/D03/D03.fdf > +++ b/Platform/Hisilicon/D03/D03.fdf > @@ -275,6 +275,8 @@ READ_LOCK_STATUS = TRUE > INF Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf > INF Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf > > + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf > + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf > # > # Build Shell from latest source code instead of prebuilt binary > # > @@ -336,12 +338,80 @@ READ_LOCK_STATUS = TRUE > > INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > > + INF RuleOverride = FMP_IMAGE_DESC Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf > + > FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { > SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { > SECTION FV_IMAGE = FVMAIN > } > } > > +[FV.CapsuleDispatchFv] > +FvAlignment = 16 > +ERASE_POLARITY = 1 > +MEMORY_MAPPED = TRUE > +STICKY_WRITE = TRUE > +LOCK_CAP = TRUE > +LOCK_STATUS = TRUE > +WRITE_DISABLED_CAP = TRUE > +WRITE_ENABLED_CAP = TRUE > +WRITE_STATUS = TRUE > +WRITE_LOCK_CAP = TRUE > +WRITE_LOCK_STATUS = TRUE > +READ_DISABLED_CAP = TRUE > +READ_ENABLED_CAP = TRUE > +READ_STATUS = TRUE > +READ_LOCK_CAP = TRUE > +READ_LOCK_STATUS = TRUE > + > + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf > + > +[FV.SystemFirmwareUpdateCargo] > +FvAlignment = 16 > +ERASE_POLARITY = 1 > +MEMORY_MAPPED = TRUE > +STICKY_WRITE = TRUE > +LOCK_CAP = TRUE > +LOCK_STATUS = TRUE > +WRITE_DISABLED_CAP = TRUE > +WRITE_ENABLED_CAP = TRUE > +WRITE_STATUS = TRUE > +WRITE_LOCK_CAP = TRUE > +WRITE_LOCK_STATUS = TRUE > +READ_DISABLED_CAP = TRUE > +READ_ENABLED_CAP = TRUE > +READ_STATUS = TRUE > +READ_LOCK_CAP = TRUE > +READ_LOCK_STATUS = TRUE > + > + FILE RAW = 642e4fcf-2df7-4415-8b70-a03909c57b55 { # PcdEdkiiSystemFirmwareFileGuid > + FD = D03 > + } > + > + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid > + FV = CapsuleDispatchFv > + } > + > + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid > + Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini > + } > + > +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] > +IMAGE_HEADER_INIT_VERSION = 0x02 > +IMAGE_TYPE_ID = d34b3d29-0085-4ab3-8be8-84188cc50489 # PcdSystemFmpCapsuleImageTypeIdGuid Use a fresh GUID here, and make sure you use a different one for D03/D05 etc. This is what identifies the platform when using fwupdmgr etc. > +IMAGE_INDEX = 0x1 > +HARDWARE_INSTANCE = 0x0 > +MONOTONIC_COUNT = 0x1 > +CERTIFICATE_GUID = 4AAFD29D-68DF-49EE-8AA9-347D375665A7 # PKCS7 > + > + FV = SystemFirmwareUpdateCargo > + > +[Capsule.StyxFirmwareUpdateCapsuleFmpPkcs7] > +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # gEfiFmpCapsuleGuid > +CAPSULE_HEADER_SIZE = 0x20 > +CAPSULE_HEADER_INIT_VERSION = 0x1 > + > + FMP_PAYLOAD = FmpPayloadSystemFirmwarePkcs7 > > !include Silicon/Hisilicon/Hisilicon.fdf.inc > > diff --git a/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini > new file mode 100644 > index 0000000..fc834d9 > --- /dev/null > +++ b/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini > @@ -0,0 +1,45 @@ > +# > +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. > +# Copyright (c) 2018, Linaro Limited. All rights reserved. > +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> > +# > +# 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. > +# > +## > + > +[Head] > +NumOfUpdate = 3 > +NumOfRecovery = 0 > +Update0 = SysFvMain > +Update1 = SysCustom > +Update2 = SysNvRam > + > +[SysFvMain] > +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam > +AddressType = 0 # 0 - relative address, 1 - absolute address. > +BaseAddress = 0x00000000 # Base address offset on flash > +Length = 0x002D0000 # Length > +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image > +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid > + > +[SysCustom] > +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam > +AddressType = 0 # 0 - relative address, 1 - absolute address. > +BaseAddress = 0x002F0000 # Base address offset on flash > +Length = 0x00010000 # Length > +ImageOffset = 0x002F0000 # Image offset of this SystemFirmware image > +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid > + > +[SysNvRam] > +FirmwareType = 1 # 0 - SystemFirmware, 1 - NvRam > +AddressType = 0 # 0 - relative address, 1 - absolute address. > +BaseAddress = 0x002D0000 # Base address offset on flash > +Length = 0x00020000 # Length > +ImageOffset = 0x002D0000 # Image offset of this SystemFirmware image > +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid > diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc > index b89cea3..b99cda5 100644 > --- a/Platform/Hisilicon/D05/D05.dsc > +++ b/Platform/Hisilicon/D05/D05.dsc > @@ -81,7 +81,6 @@ > OemAddressMapLib|Platform/Hisilicon/D05/Library/OemAddressMapD05/OemAddressMapD05.inf > PlatformSysCtrlLib|Silicon/Hisilicon/Hi1616/Library/PlatformSysCtrlLibHi1616/PlatformSysCtrlLibHi1616.inf > > - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf > GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf > PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf > !if $(GENERIC_BDS) == TRUE > @@ -130,6 +129,11 @@ > gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE > gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE > > +[PcdsDynamicExDefault.common.DEFAULT] > + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 > + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x29, 0x3d, 0x4b, 0xd3, 0x85, 0x00, 0xb3, 0x4a, 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89} > + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xcf, 0x4f, 0x2e, 0x64, 0xf7, 0x2d, 0x15, 0x44, 0x8b, 0x70, 0xa0, 0x39, 0x09, 0xc5, 0x7b, 0x55} > + > [PcdsFixedAtBuild.common] > gArmPlatformTokenSpaceGuid.PcdCoreCount|8 > > @@ -448,6 +452,8 @@ > Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf > Silicon/Hisilicon/Drivers/VersionInfoPeim/VersionInfoPeim.inf > > + Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf > + > MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { > <LibraryClasses> > NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf > @@ -564,6 +570,9 @@ > > Platform/Hisilicon/D05/Drivers/Sas/SasDxeDriver.inf > > + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf > + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf > + > # > # FAT filesystem + GPT/MBR partitioning > # > @@ -635,6 +644,14 @@ > !else > IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf > !endif > + > + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf { > + <LibraryClasses> > + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf > + } > + > + MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > + > # > # UEFI application (Shell Embedded Boot Loader) > # > diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.fdf > index d209210..9a61c52 100644 > --- a/Platform/Hisilicon/D05/D05.fdf > +++ b/Platform/Hisilicon/D05/D05.fdf > @@ -297,6 +297,8 @@ READ_LOCK_STATUS = TRUE > INF Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf > INF Platform/Hisilicon/D05/Drivers/Sas/SasDxeDriver.inf > > + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf > + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf > # > # Build Shell from latest source code instead of prebuilt binary > # > @@ -361,12 +363,80 @@ READ_LOCK_STATUS = TRUE > > INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > > + INF RuleOverride = FMP_IMAGE_DESC Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf > + > FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { > SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { > SECTION FV_IMAGE = FVMAIN > } > } > > +[FV.CapsuleDispatchFv] > +FvAlignment = 16 > +ERASE_POLARITY = 1 > +MEMORY_MAPPED = TRUE > +STICKY_WRITE = TRUE > +LOCK_CAP = TRUE > +LOCK_STATUS = TRUE > +WRITE_DISABLED_CAP = TRUE > +WRITE_ENABLED_CAP = TRUE > +WRITE_STATUS = TRUE > +WRITE_LOCK_CAP = TRUE > +WRITE_LOCK_STATUS = TRUE > +READ_DISABLED_CAP = TRUE > +READ_ENABLED_CAP = TRUE > +READ_STATUS = TRUE > +READ_LOCK_CAP = TRUE > +READ_LOCK_STATUS = TRUE > + > + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf > + > +[FV.SystemFirmwareUpdateCargo] > +FvAlignment = 16 > +ERASE_POLARITY = 1 > +MEMORY_MAPPED = TRUE > +STICKY_WRITE = TRUE > +LOCK_CAP = TRUE > +LOCK_STATUS = TRUE > +WRITE_DISABLED_CAP = TRUE > +WRITE_ENABLED_CAP = TRUE > +WRITE_STATUS = TRUE > +WRITE_LOCK_CAP = TRUE > +WRITE_LOCK_STATUS = TRUE > +READ_DISABLED_CAP = TRUE > +READ_ENABLED_CAP = TRUE > +READ_STATUS = TRUE > +READ_LOCK_CAP = TRUE > +READ_LOCK_STATUS = TRUE > + > + FILE RAW = 642e4fcf-2df7-4415-8b70-a03909c57b55 { # PcdEdkiiSystemFirmwareFileGuid > + FD = D05 > + } > + > + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid > + FV = CapsuleDispatchFv > + } > + > + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid > + Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini > + } > + > +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] > +IMAGE_HEADER_INIT_VERSION = 0x02 > +IMAGE_TYPE_ID = d34b3d29-0085-4ab3-8be8-84188cc50489 # PcdSystemFmpCapsuleImageTypeIdGuid > +IMAGE_INDEX = 0x1 > +HARDWARE_INSTANCE = 0x0 > +MONOTONIC_COUNT = 0x1 > +CERTIFICATE_GUID = 4AAFD29D-68DF-49EE-8AA9-347D375665A7 # PKCS7 > + > + FV = SystemFirmwareUpdateCargo > + > +[Capsule.StyxFirmwareUpdateCapsuleFmpPkcs7] > +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # gEfiFmpCapsuleGuid > +CAPSULE_HEADER_SIZE = 0x20 > +CAPSULE_HEADER_INIT_VERSION = 0x1 > + > + FMP_PAYLOAD = FmpPayloadSystemFirmwarePkcs7 > > !include Silicon/Hisilicon/Hisilicon.fdf.inc > > diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc > new file mode 100644 > index 0000000..465535e > --- /dev/null > +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc > @@ -0,0 +1,81 @@ > +/** @file > + System Firmware descriptor. > + > + Copyright (c) 2018, Hisilicon Limited. All rights reserved. > + Copyright (c) 2018, Linaro Limited. All rights reserved. > + Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> > + > + 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 <PiPei.h> > +#include <Guid/EdkiiSystemFmpCapsule.h> > +#include <Protocol/FirmwareManagement.h> > + > +#define PACKAGE_VERSION 0xFFFFFFFF > +#define PACKAGE_VERSION_STRING L"Unknown" > + > +#define CURRENT_FIRMWARE_VERSION 0x00000002 > +#define CURRENT_FIRMWARE_VERSION_STRING L"0x00000002" > +#define LOWEST_SUPPORTED_FIRMWARE_VERSION 0x00000001 > + > +#define IMAGE_ID SIGNATURE_64('H','W','A', 'R', 'M', '_', 'F', 'd') > +#define IMAGE_ID_STRING L"ARMPlatformFd" > + > +// PcdSystemFmpCapsuleImageTypeIdGuid > +#define IMAGE_TYPE_ID_GUID { 0xd34b3d29, 0x0085, 0x4ab3, { 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89 } } > + > +typedef struct { > + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR Descriptor; > + // real string data > + CHAR16 ImageIdNameStr[sizeof(IMAGE_ID_STRING) / sizeof(CHAR16)]; > + CHAR16 VersionNameStr[sizeof(CURRENT_FIRMWARE_VERSION_STRING) / sizeof(CHAR16)]; > + CHAR16 PackageVersionNameStr[sizeof(PACKAGE_VERSION_STRING) / sizeof(CHAR16)]; > +} IMAGE_DESCRIPTOR; > + > +IMAGE_DESCRIPTOR mImageDescriptor = > +{ > + { > + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE, > + sizeof (EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR), > + sizeof (IMAGE_DESCRIPTOR), > + PACKAGE_VERSION, // PackageVersion > + OFFSET_OF (IMAGE_DESCRIPTOR, PackageVersionNameStr), // PackageVersionName > + 1, // ImageIndex; > + {0x0}, // Reserved > + IMAGE_TYPE_ID_GUID, // ImageTypeId; > + IMAGE_ID, // ImageId; > + OFFSET_OF (IMAGE_DESCRIPTOR, ImageIdNameStr), // ImageIdName; > + CURRENT_FIRMWARE_VERSION, // Version; > + OFFSET_OF (IMAGE_DESCRIPTOR, VersionNameStr), // VersionName; > + {0x0}, // Reserved2 > + FixedPcdGet32 (PcdFdSize), // Size; > + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | > + IMAGE_ATTRIBUTE_RESET_REQUIRED | > + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | > + IMAGE_ATTRIBUTE_IN_USE, // AttributesSupported; > + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | > + IMAGE_ATTRIBUTE_RESET_REQUIRED | > + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | > + IMAGE_ATTRIBUTE_IN_USE, // AttributesSetting; > + 0x0, // Compatibilities; > + LOWEST_SUPPORTED_FIRMWARE_VERSION, // LowestSupportedImageVersion; > + 0x00000000, // LastAttemptVersion; > + 0, // LastAttemptStatus; > + {0x0}, // Reserved3 > + 0, // HardwareInstance; > + }, > + // real string data > + {IMAGE_ID_STRING}, > + {CURRENT_FIRMWARE_VERSION_STRING}, > + {PACKAGE_VERSION_STRING}, > +}; > + > +VOID* CONST ReferenceAcpiTable = &mImageDescriptor; > diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf > new file mode 100644 > index 0000000..c38a809 > --- /dev/null > +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf > @@ -0,0 +1,50 @@ > +## @file > +# System Firmware descriptor. > +# > +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. > +# Copyright (c) 2018, Linaro Limited. All rights reserved. > +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> > +# > +# 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 > + BASE_NAME = SystemFirmwareDescriptor > + FILE_GUID = 90B2B846-CA6D-4D6E-A8D3-C140A8E110AC > + MODULE_TYPE = PEIM > + VERSION_STRING = 1.0 > + ENTRY_POINT = SystemFirmwareDescriptorPeimEntry > + > +[Sources] > + SystemFirmwareDescriptorPei.c > + SystemFirmwareDescriptor.aslc > + > +[Packages] > + ArmPkg/ArmPkg.dec > + ArmPlatformPkg/ArmPlatformPkg.dec > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + SignedCapsulePkg/SignedCapsulePkg.dec > + > +[LibraryClasses] > + DebugLib > + PcdLib > + PeimEntryPoint > + PeiServicesLib > + > +[FixedPcd] > + gArmTokenSpaceGuid.PcdFdSize > + > +[Pcd] > + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor > + > +[Depex] > + TRUE > diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c > new file mode 100644 > index 0000000..27c0a71 > --- /dev/null > +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c > @@ -0,0 +1,70 @@ > +/** @file > + System Firmware descriptor producer. > + > + Copyright (c) 2018, Hisilicon Limited. All rights reserved. > + Copyright (c) 2018, Linaro Limited. All rights reserved. > + Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> > + > + 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 <PiPei.h> > +#include <Guid/EdkiiSystemFmpCapsule.h> > +#include <Library/DebugLib.h> > +#include <Library/PcdLib.h> > +#include <Library/PeiServicesLib.h> > +#include <Protocol/FirmwareManagement.h> > + > +/** > + Entrypoint for SystemFirmwareDescriptor PEIM. > + > + @param[in] FileHandle Handle of the file being invoked. > + @param[in] PeiServices Describes the list of possible PEI Services. > + > + @retval EFI_SUCCESS PPI successfully installed. > +**/ > +EFI_STATUS > +EFIAPI > +SystemFirmwareDescriptorPeimEntry ( > + IN EFI_PEI_FILE_HANDLE FileHandle, > + IN CONST EFI_PEI_SERVICES **PeiServices > + ) > +{ > + EFI_STATUS Status; > + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *Descriptor; > + UINTN Size; > + UINTN Index; > + UINT32 AuthenticationStatus; > + > + // > + // Search RAW section. > + // > + > + Index = 0; > + while (TRUE) { > + Status = PeiServicesFfsFindSectionData3 (EFI_SECTION_RAW, Index, FileHandle, (VOID **)&Descriptor, &AuthenticationStatus); > + if (EFI_ERROR (Status)) { > + // Should not happen, must something wrong in FDF. > + DEBUG ((DEBUG_ERROR, "Not found SystemFirmwareDescriptor in fdf !\n")); > + return EFI_NOT_FOUND; > + } > + if (Descriptor->Signature == EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) { > + break; > + } > + Index++; > + } > + > + DEBUG ((DEBUG_INFO, "EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR size - 0x%x\n", Descriptor->Length)); > + > + Size = Descriptor->Length; > + PcdSetPtrS (PcdEdkiiSystemFirmwareImageDescriptor, &Size, Descriptor); > + > + return EFI_SUCCESS; > +} > diff --git a/Silicon/Hisilicon/Hisilicon.dsc.inc b/Silicon/Hisilicon/Hisilicon.dsc.inc > index 308064b..dfa11d1 100644 > --- a/Silicon/Hisilicon/Hisilicon.dsc.inc > +++ b/Silicon/Hisilicon/Hisilicon.dsc.inc > @@ -104,6 +104,15 @@ > ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf > SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf > > + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf > + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf > + IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf > + BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf > + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf > + EdkiiSystemCapsuleLib|SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.inf > + IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf > + PlatformFlashAccessLib|Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.inf > + > # > # It is not possible to prevent the ARM compiler for generic intrinsic functions. > # This library provides the instrinsic functions generate by a given compiler. > @@ -198,7 +207,7 @@ > HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf > MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf > ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf > - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf > + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf > SerialPortLib|Silicon/Hisilicon/Library/Dw8250SerialPortRuntimeLib/Dw8250SerialPortRuntimeLib.inf > DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf > > diff --git a/Silicon/Hisilicon/Hisilicon.fdf.inc b/Silicon/Hisilicon/Hisilicon.fdf.inc > index ee87cd1..986dd75 100644 > --- a/Silicon/Hisilicon/Hisilicon.fdf.inc > +++ b/Silicon/Hisilicon/Hisilicon.fdf.inc > @@ -76,6 +76,15 @@ > } > } > > +[Rule.Common.PEIM.FMP_IMAGE_DESC] > + FILE PEIM = $(NAMED_GUID) { > + RAW BIN |.acpi > + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex > + PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi > + UI STRING="$(MODULE_NAME)" Optional > + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) > + } > + > [Rule.Common.DXE_CORE] > FILE DXE_CORE = $(NAMED_GUID) { > PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi > 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.<BR> > + > + 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 <PiDxe.h> > +#include <Library/BaseLib.h> > +#include <Library/BaseMemoryLib.h> > +#include <Library/DebugLib.h> > +#include <Library/PcdLib.h> > +#include <Library/PlatformFlashAccessLib.h> > +#include <Library/UefiBootServicesTableLib.h> > +#include <Protocol/HisiSpiFlashProtocol.h> > + > +STATIC EFI_PHYSICAL_ADDRESS mInternalFdAddress; > +STATIC EFI_PHYSICAL_ADDRESS mSFCMEM0BaseAddress; > + > +HISI_SPI_FLASH_PROTOCOL *mSpiProtocol; STATIC > + > +/** > + 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.<BR> > +# > +# 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 > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
On 2018/1/20 18:50, Ard Biesheuvel wrote: > On 18 January 2018 at 15:01, Ming Huang <heyi.guo@linaro.org> wrote: >> From: Jason Zhang <zhangjinsong2@huawei.com> >> >> Contributed-under: TianoCore Contribution Agreement 1.1 >> Signed-off-by: Jason Zhang <zhangjinsong2@huawei.com> >> Signed-off-by: Ming Huang <huangming23@huawei.com> >> Signed-off-by: Heyi Guo <heyi.guo@linaro.org> >> --- >> 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/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> new file mode 100644 >> index 0000000..fc834d9 >> --- /dev/null >> +++ b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> @@ -0,0 +1,45 @@ >> +# >> +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. >> +# Copyright (c) 2018, Linaro Limited. All rights reserved. >> +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >> +# >> +# 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. >> +# >> +## >> + >> +[Head] >> +NumOfUpdate = 3 >> +NumOfRecovery = 0 >> +Update0 = SysFvMain >> +Update1 = SysCustom >> +Update2 = SysNvRam >> + >> +[SysFvMain] >> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x00000000 # Base address offset on flash >> +Length = 0x002D0000 # Length >> +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> + >> +[SysCustom] >> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x002F0000 # Base address offset on flash >> +Length = 0x00010000 # Length >> +ImageOffset = 0x002F0000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> + >> +[SysNvRam] >> +FirmwareType = 1 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x002D0000 # Base address offset on flash >> +Length = 0x00020000 # Length >> +ImageOffset = 0x002D0000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc >> index b2eae7d..69bc7b4 100644 >> --- a/Platform/Hisilicon/D03/D03.dsc >> +++ b/Platform/Hisilicon/D03/D03.dsc >> @@ -66,7 +66,6 @@ >> OemAddressMapLib|Platform/Hisilicon/D03/Library/OemAddressMap2P/OemAddressMap2PHi1610.inf >> PlatformSysCtrlLib|Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.inf >> >> - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf >> GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf >> PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf >> !if $(GENERIC_BDS) == TRUE >> @@ -117,6 +116,11 @@ >> gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE >> gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE >> >> +[PcdsDynamicExDefault.common.DEFAULT] >> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 >> + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x29, 0x3d, 0x4b, 0xd3, 0x85, 0x00, 0xb3, 0x4a, 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89} >> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xcf, 0x4f, 0x2e, 0x64, 0xf7, 0x2d, 0x15, 0x44, 0x8b, 0x70, 0xa0, 0x39, 0x09, 0xc5, 0x7b, 0x55} >> + >> [PcdsFixedAtBuild.common] >> gArmPlatformTokenSpaceGuid.PcdCoreCount|8 >> >> @@ -310,6 +314,8 @@ >> Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf >> Silicon/Hisilicon/Drivers/VersionInfoPeim/VersionInfoPeim.inf >> >> + Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> + >> MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { >> <LibraryClasses> >> NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf >> @@ -410,6 +416,9 @@ >> >> Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf >> >> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >> + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >> + >> # >> # FAT filesystem + GPT/MBR partitioning >> # >> @@ -483,6 +492,12 @@ >> !else >> IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf >> !endif >> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf { >> + <LibraryClasses> >> + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf >> + } >> + >> + MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf >> >> # >> # UEFI application (Shell Embedded Boot Loader) >> diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf >> index 0d704b5..ffddd2d 100644 >> --- a/Platform/Hisilicon/D03/D03.fdf >> +++ b/Platform/Hisilicon/D03/D03.fdf >> @@ -275,6 +275,8 @@ READ_LOCK_STATUS = TRUE >> INF Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf >> INF Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf >> >> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >> + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >> # >> # Build Shell from latest source code instead of prebuilt binary >> # >> @@ -336,12 +338,80 @@ READ_LOCK_STATUS = TRUE >> >> INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf >> >> + INF RuleOverride = FMP_IMAGE_DESC Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> + >> FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { >> SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { >> SECTION FV_IMAGE = FVMAIN >> } >> } >> >> +[FV.CapsuleDispatchFv] >> +FvAlignment = 16 >> +ERASE_POLARITY = 1 >> +MEMORY_MAPPED = TRUE >> +STICKY_WRITE = TRUE >> +LOCK_CAP = TRUE >> +LOCK_STATUS = TRUE >> +WRITE_DISABLED_CAP = TRUE >> +WRITE_ENABLED_CAP = TRUE >> +WRITE_STATUS = TRUE >> +WRITE_LOCK_CAP = TRUE >> +WRITE_LOCK_STATUS = TRUE >> +READ_DISABLED_CAP = TRUE >> +READ_ENABLED_CAP = TRUE >> +READ_STATUS = TRUE >> +READ_LOCK_CAP = TRUE >> +READ_LOCK_STATUS = TRUE >> + >> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf >> + >> +[FV.SystemFirmwareUpdateCargo] >> +FvAlignment = 16 >> +ERASE_POLARITY = 1 >> +MEMORY_MAPPED = TRUE >> +STICKY_WRITE = TRUE >> +LOCK_CAP = TRUE >> +LOCK_STATUS = TRUE >> +WRITE_DISABLED_CAP = TRUE >> +WRITE_ENABLED_CAP = TRUE >> +WRITE_STATUS = TRUE >> +WRITE_LOCK_CAP = TRUE >> +WRITE_LOCK_STATUS = TRUE >> +READ_DISABLED_CAP = TRUE >> +READ_ENABLED_CAP = TRUE >> +READ_STATUS = TRUE >> +READ_LOCK_CAP = TRUE >> +READ_LOCK_STATUS = TRUE >> + >> + FILE RAW = 642e4fcf-2df7-4415-8b70-a03909c57b55 { # PcdEdkiiSystemFirmwareFileGuid >> + FD = D03 >> + } >> + >> + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid >> + FV = CapsuleDispatchFv >> + } >> + >> + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid >> + Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> + } >> + >> +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] >> +IMAGE_HEADER_INIT_VERSION = 0x02 >> +IMAGE_TYPE_ID = d34b3d29-0085-4ab3-8be8-84188cc50489 # PcdSystemFmpCapsuleImageTypeIdGuid > > Use a fresh GUID here, and make sure you use a different one for D03/D05 etc. > > This is what identifies the platform when using fwupdmgr etc. > > >> +IMAGE_INDEX = 0x1 >> +HARDWARE_INSTANCE = 0x0 >> +MONOTONIC_COUNT = 0x1 >> +CERTIFICATE_GUID = 4AAFD29D-68DF-49EE-8AA9-347D375665A7 # PKCS7 >> + >> + FV = SystemFirmwareUpdateCargo >> + >> +[Capsule.StyxFirmwareUpdateCapsuleFmpPkcs7] >> +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # gEfiFmpCapsuleGuid >> +CAPSULE_HEADER_SIZE = 0x20 >> +CAPSULE_HEADER_INIT_VERSION = 0x1 >> + >> + FMP_PAYLOAD = FmpPayloadSystemFirmwarePkcs7 >> >> !include Silicon/Hisilicon/Hisilicon.fdf.inc >> >> diff --git a/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> new file mode 100644 >> index 0000000..fc834d9 >> --- /dev/null >> +++ b/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> @@ -0,0 +1,45 @@ >> +# >> +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. >> +# Copyright (c) 2018, Linaro Limited. All rights reserved. >> +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >> +# >> +# 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. >> +# >> +## >> + >> +[Head] >> +NumOfUpdate = 3 >> +NumOfRecovery = 0 >> +Update0 = SysFvMain >> +Update1 = SysCustom >> +Update2 = SysNvRam >> + >> +[SysFvMain] >> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x00000000 # Base address offset on flash >> +Length = 0x002D0000 # Length >> +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> + >> +[SysCustom] >> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x002F0000 # Base address offset on flash >> +Length = 0x00010000 # Length >> +ImageOffset = 0x002F0000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> + >> +[SysNvRam] >> +FirmwareType = 1 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x002D0000 # Base address offset on flash >> +Length = 0x00020000 # Length >> +ImageOffset = 0x002D0000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc >> index b89cea3..b99cda5 100644 >> --- a/Platform/Hisilicon/D05/D05.dsc >> +++ b/Platform/Hisilicon/D05/D05.dsc >> @@ -81,7 +81,6 @@ >> OemAddressMapLib|Platform/Hisilicon/D05/Library/OemAddressMapD05/OemAddressMapD05.inf >> PlatformSysCtrlLib|Silicon/Hisilicon/Hi1616/Library/PlatformSysCtrlLibHi1616/PlatformSysCtrlLibHi1616.inf >> >> - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf >> GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf >> PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf >> !if $(GENERIC_BDS) == TRUE >> @@ -130,6 +129,11 @@ >> gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE >> gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE >> >> +[PcdsDynamicExDefault.common.DEFAULT] >> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 >> + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x29, 0x3d, 0x4b, 0xd3, 0x85, 0x00, 0xb3, 0x4a, 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89} >> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xcf, 0x4f, 0x2e, 0x64, 0xf7, 0x2d, 0x15, 0x44, 0x8b, 0x70, 0xa0, 0x39, 0x09, 0xc5, 0x7b, 0x55} >> + >> [PcdsFixedAtBuild.common] >> gArmPlatformTokenSpaceGuid.PcdCoreCount|8 >> >> @@ -448,6 +452,8 @@ >> Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf >> Silicon/Hisilicon/Drivers/VersionInfoPeim/VersionInfoPeim.inf >> >> + Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> + >> MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { >> <LibraryClasses> >> NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf >> @@ -564,6 +570,9 @@ >> >> Platform/Hisilicon/D05/Drivers/Sas/SasDxeDriver.inf >> >> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >> + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >> + >> # >> # FAT filesystem + GPT/MBR partitioning >> # >> @@ -635,6 +644,14 @@ >> !else >> IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf >> !endif >> + >> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf { >> + <LibraryClasses> >> + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf >> + } >> + >> + MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf >> + >> # >> # UEFI application (Shell Embedded Boot Loader) >> # >> diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.fdf >> index d209210..9a61c52 100644 >> --- a/Platform/Hisilicon/D05/D05.fdf >> +++ b/Platform/Hisilicon/D05/D05.fdf >> @@ -297,6 +297,8 @@ READ_LOCK_STATUS = TRUE >> INF Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf >> INF Platform/Hisilicon/D05/Drivers/Sas/SasDxeDriver.inf >> >> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >> + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >> # >> # Build Shell from latest source code instead of prebuilt binary >> # >> @@ -361,12 +363,80 @@ READ_LOCK_STATUS = TRUE >> >> INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf >> >> + INF RuleOverride = FMP_IMAGE_DESC Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> + >> FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { >> SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { >> SECTION FV_IMAGE = FVMAIN >> } >> } >> >> +[FV.CapsuleDispatchFv] >> +FvAlignment = 16 >> +ERASE_POLARITY = 1 >> +MEMORY_MAPPED = TRUE >> +STICKY_WRITE = TRUE >> +LOCK_CAP = TRUE >> +LOCK_STATUS = TRUE >> +WRITE_DISABLED_CAP = TRUE >> +WRITE_ENABLED_CAP = TRUE >> +WRITE_STATUS = TRUE >> +WRITE_LOCK_CAP = TRUE >> +WRITE_LOCK_STATUS = TRUE >> +READ_DISABLED_CAP = TRUE >> +READ_ENABLED_CAP = TRUE >> +READ_STATUS = TRUE >> +READ_LOCK_CAP = TRUE >> +READ_LOCK_STATUS = TRUE >> + >> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf >> + >> +[FV.SystemFirmwareUpdateCargo] >> +FvAlignment = 16 >> +ERASE_POLARITY = 1 >> +MEMORY_MAPPED = TRUE >> +STICKY_WRITE = TRUE >> +LOCK_CAP = TRUE >> +LOCK_STATUS = TRUE >> +WRITE_DISABLED_CAP = TRUE >> +WRITE_ENABLED_CAP = TRUE >> +WRITE_STATUS = TRUE >> +WRITE_LOCK_CAP = TRUE >> +WRITE_LOCK_STATUS = TRUE >> +READ_DISABLED_CAP = TRUE >> +READ_ENABLED_CAP = TRUE >> +READ_STATUS = TRUE >> +READ_LOCK_CAP = TRUE >> +READ_LOCK_STATUS = TRUE >> + >> + FILE RAW = 642e4fcf-2df7-4415-8b70-a03909c57b55 { # PcdEdkiiSystemFirmwareFileGuid >> + FD = D05 >> + } >> + >> + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid >> + FV = CapsuleDispatchFv >> + } >> + >> + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid >> + Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> + } >> + >> +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] >> +IMAGE_HEADER_INIT_VERSION = 0x02 >> +IMAGE_TYPE_ID = d34b3d29-0085-4ab3-8be8-84188cc50489 # PcdSystemFmpCapsuleImageTypeIdGuid >> +IMAGE_INDEX = 0x1 >> +HARDWARE_INSTANCE = 0x0 >> +MONOTONIC_COUNT = 0x1 >> +CERTIFICATE_GUID = 4AAFD29D-68DF-49EE-8AA9-347D375665A7 # PKCS7 >> + >> + FV = SystemFirmwareUpdateCargo >> + >> +[Capsule.StyxFirmwareUpdateCapsuleFmpPkcs7] >> +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # gEfiFmpCapsuleGuid >> +CAPSULE_HEADER_SIZE = 0x20 >> +CAPSULE_HEADER_INIT_VERSION = 0x1 >> + >> + FMP_PAYLOAD = FmpPayloadSystemFirmwarePkcs7 >> >> !include Silicon/Hisilicon/Hisilicon.fdf.inc >> >> diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc >> new file mode 100644 >> index 0000000..465535e >> --- /dev/null >> +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc >> @@ -0,0 +1,81 @@ >> +/** @file >> + System Firmware descriptor. >> + >> + Copyright (c) 2018, Hisilicon Limited. All rights reserved. >> + Copyright (c) 2018, Linaro Limited. All rights reserved. >> + Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >> + >> + 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 <PiPei.h> >> +#include <Guid/EdkiiSystemFmpCapsule.h> >> +#include <Protocol/FirmwareManagement.h> >> + >> +#define PACKAGE_VERSION 0xFFFFFFFF >> +#define PACKAGE_VERSION_STRING L"Unknown" >> + >> +#define CURRENT_FIRMWARE_VERSION 0x00000002 >> +#define CURRENT_FIRMWARE_VERSION_STRING L"0x00000002" >> +#define LOWEST_SUPPORTED_FIRMWARE_VERSION 0x00000001 >> + >> +#define IMAGE_ID SIGNATURE_64('H','W','A', 'R', 'M', '_', 'F', 'd') >> +#define IMAGE_ID_STRING L"ARMPlatformFd" >> + >> +// PcdSystemFmpCapsuleImageTypeIdGuid >> +#define IMAGE_TYPE_ID_GUID { 0xd34b3d29, 0x0085, 0x4ab3, { 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89 } } >> + >> +typedef struct { >> + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR Descriptor; >> + // real string data >> + CHAR16 ImageIdNameStr[sizeof(IMAGE_ID_STRING) / sizeof(CHAR16)]; >> + CHAR16 VersionNameStr[sizeof(CURRENT_FIRMWARE_VERSION_STRING) / sizeof(CHAR16)]; >> + CHAR16 PackageVersionNameStr[sizeof(PACKAGE_VERSION_STRING) / sizeof(CHAR16)]; >> +} IMAGE_DESCRIPTOR; >> + >> +IMAGE_DESCRIPTOR mImageDescriptor = >> +{ >> + { >> + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE, >> + sizeof (EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR), >> + sizeof (IMAGE_DESCRIPTOR), >> + PACKAGE_VERSION, // PackageVersion >> + OFFSET_OF (IMAGE_DESCRIPTOR, PackageVersionNameStr), // PackageVersionName >> + 1, // ImageIndex; >> + {0x0}, // Reserved >> + IMAGE_TYPE_ID_GUID, // ImageTypeId; >> + IMAGE_ID, // ImageId; >> + OFFSET_OF (IMAGE_DESCRIPTOR, ImageIdNameStr), // ImageIdName; >> + CURRENT_FIRMWARE_VERSION, // Version; >> + OFFSET_OF (IMAGE_DESCRIPTOR, VersionNameStr), // VersionName; >> + {0x0}, // Reserved2 >> + FixedPcdGet32 (PcdFdSize), // Size; >> + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | >> + IMAGE_ATTRIBUTE_RESET_REQUIRED | >> + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | >> + IMAGE_ATTRIBUTE_IN_USE, // AttributesSupported; >> + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | >> + IMAGE_ATTRIBUTE_RESET_REQUIRED | >> + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | >> + IMAGE_ATTRIBUTE_IN_USE, // AttributesSetting; >> + 0x0, // Compatibilities; >> + LOWEST_SUPPORTED_FIRMWARE_VERSION, // LowestSupportedImageVersion; >> + 0x00000000, // LastAttemptVersion; >> + 0, // LastAttemptStatus; >> + {0x0}, // Reserved3 >> + 0, // HardwareInstance; >> + }, >> + // real string data >> + {IMAGE_ID_STRING}, >> + {CURRENT_FIRMWARE_VERSION_STRING}, >> + {PACKAGE_VERSION_STRING}, >> +}; >> + >> +VOID* CONST ReferenceAcpiTable = &mImageDescriptor; >> diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> new file mode 100644 >> index 0000000..c38a809 >> --- /dev/null >> +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> @@ -0,0 +1,50 @@ >> +## @file >> +# System Firmware descriptor. >> +# >> +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. >> +# Copyright (c) 2018, Linaro Limited. All rights reserved. >> +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >> +# >> +# 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 >> + BASE_NAME = SystemFirmwareDescriptor >> + FILE_GUID = 90B2B846-CA6D-4D6E-A8D3-C140A8E110AC >> + MODULE_TYPE = PEIM >> + VERSION_STRING = 1.0 >> + ENTRY_POINT = SystemFirmwareDescriptorPeimEntry >> + >> +[Sources] >> + SystemFirmwareDescriptorPei.c >> + SystemFirmwareDescriptor.aslc >> + >> +[Packages] >> + ArmPkg/ArmPkg.dec >> + ArmPlatformPkg/ArmPlatformPkg.dec >> + MdeModulePkg/MdeModulePkg.dec >> + MdePkg/MdePkg.dec >> + SignedCapsulePkg/SignedCapsulePkg.dec >> + >> +[LibraryClasses] >> + DebugLib >> + PcdLib >> + PeimEntryPoint >> + PeiServicesLib >> + >> +[FixedPcd] >> + gArmTokenSpaceGuid.PcdFdSize >> + >> +[Pcd] >> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor >> + >> +[Depex] >> + TRUE >> diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c >> new file mode 100644 >> index 0000000..27c0a71 >> --- /dev/null >> +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c >> @@ -0,0 +1,70 @@ >> +/** @file >> + System Firmware descriptor producer. >> + >> + Copyright (c) 2018, Hisilicon Limited. All rights reserved. >> + Copyright (c) 2018, Linaro Limited. All rights reserved. >> + Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >> + >> + 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 <PiPei.h> >> +#include <Guid/EdkiiSystemFmpCapsule.h> >> +#include <Library/DebugLib.h> >> +#include <Library/PcdLib.h> >> +#include <Library/PeiServicesLib.h> >> +#include <Protocol/FirmwareManagement.h> >> + >> +/** >> + Entrypoint for SystemFirmwareDescriptor PEIM. >> + >> + @param[in] FileHandle Handle of the file being invoked. >> + @param[in] PeiServices Describes the list of possible PEI Services. >> + >> + @retval EFI_SUCCESS PPI successfully installed. >> +**/ >> +EFI_STATUS >> +EFIAPI >> +SystemFirmwareDescriptorPeimEntry ( >> + IN EFI_PEI_FILE_HANDLE FileHandle, >> + IN CONST EFI_PEI_SERVICES **PeiServices >> + ) >> +{ >> + EFI_STATUS Status; >> + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *Descriptor; >> + UINTN Size; >> + UINTN Index; >> + UINT32 AuthenticationStatus; >> + >> + // >> + // Search RAW section. >> + // >> + >> + Index = 0; >> + while (TRUE) { >> + Status = PeiServicesFfsFindSectionData3 (EFI_SECTION_RAW, Index, FileHandle, (VOID **)&Descriptor, &AuthenticationStatus); >> + if (EFI_ERROR (Status)) { >> + // Should not happen, must something wrong in FDF. >> + DEBUG ((DEBUG_ERROR, "Not found SystemFirmwareDescriptor in fdf !\n")); >> + return EFI_NOT_FOUND; >> + } >> + if (Descriptor->Signature == EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) { >> + break; >> + } >> + Index++; >> + } >> + >> + DEBUG ((DEBUG_INFO, "EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR size - 0x%x\n", Descriptor->Length)); >> + >> + Size = Descriptor->Length; >> + PcdSetPtrS (PcdEdkiiSystemFirmwareImageDescriptor, &Size, Descriptor); >> + >> + return EFI_SUCCESS; >> +} >> diff --git a/Silicon/Hisilicon/Hisilicon.dsc.inc b/Silicon/Hisilicon/Hisilicon.dsc.inc >> index 308064b..dfa11d1 100644 >> --- a/Silicon/Hisilicon/Hisilicon.dsc.inc >> +++ b/Silicon/Hisilicon/Hisilicon.dsc.inc >> @@ -104,6 +104,15 @@ >> ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf >> SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf >> >> + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf >> + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf >> + IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf >> + BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf >> + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf >> + EdkiiSystemCapsuleLib|SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.inf >> + IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf >> + PlatformFlashAccessLib|Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.inf >> + >> # >> # It is not possible to prevent the ARM compiler for generic intrinsic functions. >> # This library provides the instrinsic functions generate by a given compiler. >> @@ -198,7 +207,7 @@ >> HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf >> MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf >> ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf >> - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf >> + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf >> SerialPortLib|Silicon/Hisilicon/Library/Dw8250SerialPortRuntimeLib/Dw8250SerialPortRuntimeLib.inf >> DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf >> >> diff --git a/Silicon/Hisilicon/Hisilicon.fdf.inc b/Silicon/Hisilicon/Hisilicon.fdf.inc >> index ee87cd1..986dd75 100644 >> --- a/Silicon/Hisilicon/Hisilicon.fdf.inc >> +++ b/Silicon/Hisilicon/Hisilicon.fdf.inc >> @@ -76,6 +76,15 @@ >> } >> } >> >> +[Rule.Common.PEIM.FMP_IMAGE_DESC] >> + FILE PEIM = $(NAMED_GUID) { >> + RAW BIN |.acpi >> + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex >> + PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi >> + UI STRING="$(MODULE_NAME)" Optional >> + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) >> + } >> + >> [Rule.Common.DXE_CORE] >> FILE DXE_CORE = $(NAMED_GUID) { >> PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi >> 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.<BR> >> + >> + 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 <PiDxe.h> >> +#include <Library/BaseLib.h> >> +#include <Library/BaseMemoryLib.h> >> +#include <Library/DebugLib.h> >> +#include <Library/PcdLib.h> >> +#include <Library/PlatformFlashAccessLib.h> >> +#include <Library/UefiBootServicesTableLib.h> >> +#include <Protocol/HisiSpiFlashProtocol.h> >> + >> +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. >> + >> +/** >> + 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.<BR> >> +# >> +# 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
On 23 January 2018 at 08:53, Huangming (Mark) <huangming23@huawei.com> wrote: > > > On 2018/1/20 18:50, Ard Biesheuvel wrote: >> On 18 January 2018 at 15:01, Ming Huang <heyi.guo@linaro.org> wrote: >>> From: Jason Zhang <zhangjinsong2@huawei.com> >>> >>> Contributed-under: TianoCore Contribution Agreement 1.1 >>> Signed-off-by: Jason Zhang <zhangjinsong2@huawei.com> >>> Signed-off-by: Ming Huang <huangming23@huawei.com> >>> Signed-off-by: Heyi Guo <heyi.guo@linaro.org> >>> --- >>> 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.<BR> >>> + >>> + 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 <PiDxe.h> >>> +#include <Library/BaseLib.h> >>> +#include <Library/BaseMemoryLib.h> >>> +#include <Library/DebugLib.h> >>> +#include <Library/PcdLib.h> >>> +#include <Library/PlatformFlashAccessLib.h> >>> +#include <Library/UefiBootServicesTableLib.h> >>> +#include <Protocol/HisiSpiFlashProtocol.h> >>> + >>> +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.<BR> >>> +# >>> +# 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 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
On Thu, Jan 18, 2018 at 11:01:33PM +0800, Ming Huang wrote:
> From: Jason Zhang <zhangjinsong2@huawei.com>
Can you add a description of this support to the commit message?
For example, does this support updating the boot CPU firmware only, or
does it also permit system controllers and BMC?
Other than that, I have no comments beyond Ard's.
/
Leif
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
On 2018/1/20 18:50, Ard Biesheuvel wrote: > On 18 January 2018 at 15:01, Ming Huang <heyi.guo@linaro.org> wrote: >> From: Jason Zhang <zhangjinsong2@huawei.com> >> >> Contributed-under: TianoCore Contribution Agreement 1.1 >> Signed-off-by: Jason Zhang <zhangjinsong2@huawei.com> >> Signed-off-by: Ming Huang <huangming23@huawei.com> >> Signed-off-by: Heyi Guo <heyi.guo@linaro.org> >> --- >> 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/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> new file mode 100644 >> index 0000000..fc834d9 >> --- /dev/null >> +++ b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> @@ -0,0 +1,45 @@ >> +# >> +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. >> +# Copyright (c) 2018, Linaro Limited. All rights reserved. >> +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >> +# >> +# 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. >> +# >> +## >> + >> +[Head] >> +NumOfUpdate = 3 >> +NumOfRecovery = 0 >> +Update0 = SysFvMain >> +Update1 = SysCustom >> +Update2 = SysNvRam >> + >> +[SysFvMain] >> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x00000000 # Base address offset on flash >> +Length = 0x002D0000 # Length >> +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> + >> +[SysCustom] >> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x002F0000 # Base address offset on flash >> +Length = 0x00010000 # Length >> +ImageOffset = 0x002F0000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> + >> +[SysNvRam] >> +FirmwareType = 1 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x002D0000 # Base address offset on flash >> +Length = 0x00020000 # Length >> +ImageOffset = 0x002D0000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc >> index b2eae7d..69bc7b4 100644 >> --- a/Platform/Hisilicon/D03/D03.dsc >> +++ b/Platform/Hisilicon/D03/D03.dsc >> @@ -66,7 +66,6 @@ >> OemAddressMapLib|Platform/Hisilicon/D03/Library/OemAddressMap2P/OemAddressMap2PHi1610.inf >> PlatformSysCtrlLib|Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.inf >> >> - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf >> GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf >> PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf >> !if $(GENERIC_BDS) == TRUE >> @@ -117,6 +116,11 @@ >> gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE >> gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE >> >> +[PcdsDynamicExDefault.common.DEFAULT] >> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 >> + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x29, 0x3d, 0x4b, 0xd3, 0x85, 0x00, 0xb3, 0x4a, 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89} >> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xcf, 0x4f, 0x2e, 0x64, 0xf7, 0x2d, 0x15, 0x44, 0x8b, 0x70, 0xa0, 0x39, 0x09, 0xc5, 0x7b, 0x55} >> + >> [PcdsFixedAtBuild.common] >> gArmPlatformTokenSpaceGuid.PcdCoreCount|8 >> >> @@ -310,6 +314,8 @@ >> Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf >> Silicon/Hisilicon/Drivers/VersionInfoPeim/VersionInfoPeim.inf >> >> + Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> + >> MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { >> <LibraryClasses> >> NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf >> @@ -410,6 +416,9 @@ >> >> Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf >> >> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >> + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >> + >> # >> # FAT filesystem + GPT/MBR partitioning >> # >> @@ -483,6 +492,12 @@ >> !else >> IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf >> !endif >> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf { >> + <LibraryClasses> >> + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf >> + } >> + >> + MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf >> >> # >> # UEFI application (Shell Embedded Boot Loader) >> diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf >> index 0d704b5..ffddd2d 100644 >> --- a/Platform/Hisilicon/D03/D03.fdf >> +++ b/Platform/Hisilicon/D03/D03.fdf >> @@ -275,6 +275,8 @@ READ_LOCK_STATUS = TRUE >> INF Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf >> INF Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf >> >> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >> + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >> # >> # Build Shell from latest source code instead of prebuilt binary >> # >> @@ -336,12 +338,80 @@ READ_LOCK_STATUS = TRUE >> >> INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf >> >> + INF RuleOverride = FMP_IMAGE_DESC Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> + >> FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { >> SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { >> SECTION FV_IMAGE = FVMAIN >> } >> } >> >> +[FV.CapsuleDispatchFv] >> +FvAlignment = 16 >> +ERASE_POLARITY = 1 >> +MEMORY_MAPPED = TRUE >> +STICKY_WRITE = TRUE >> +LOCK_CAP = TRUE >> +LOCK_STATUS = TRUE >> +WRITE_DISABLED_CAP = TRUE >> +WRITE_ENABLED_CAP = TRUE >> +WRITE_STATUS = TRUE >> +WRITE_LOCK_CAP = TRUE >> +WRITE_LOCK_STATUS = TRUE >> +READ_DISABLED_CAP = TRUE >> +READ_ENABLED_CAP = TRUE >> +READ_STATUS = TRUE >> +READ_LOCK_CAP = TRUE >> +READ_LOCK_STATUS = TRUE >> + >> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf >> + >> +[FV.SystemFirmwareUpdateCargo] >> +FvAlignment = 16 >> +ERASE_POLARITY = 1 >> +MEMORY_MAPPED = TRUE >> +STICKY_WRITE = TRUE >> +LOCK_CAP = TRUE >> +LOCK_STATUS = TRUE >> +WRITE_DISABLED_CAP = TRUE >> +WRITE_ENABLED_CAP = TRUE >> +WRITE_STATUS = TRUE >> +WRITE_LOCK_CAP = TRUE >> +WRITE_LOCK_STATUS = TRUE >> +READ_DISABLED_CAP = TRUE >> +READ_ENABLED_CAP = TRUE >> +READ_STATUS = TRUE >> +READ_LOCK_CAP = TRUE >> +READ_LOCK_STATUS = TRUE >> + >> + FILE RAW = 642e4fcf-2df7-4415-8b70-a03909c57b55 { # PcdEdkiiSystemFirmwareFileGuid >> + FD = D03 >> + } >> + >> + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid >> + FV = CapsuleDispatchFv >> + } >> + >> + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid >> + Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> + } >> + >> +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] >> +IMAGE_HEADER_INIT_VERSION = 0x02 >> +IMAGE_TYPE_ID = d34b3d29-0085-4ab3-8be8-84188cc50489 # PcdSystemFmpCapsuleImageTypeIdGuid > > Use a fresh GUID here, and make sure you use a different one for D03/D05 etc. > > This is what identifies the platform when using fwupdmgr etc. > > IMAGE_TYPE_ID in D0x.fdf is need to equal to IMAGE_TYPE_ID_GUID in Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc, so D0x is used the same guid. I will change the guid to a fresh one. Thanks. >> +IMAGE_INDEX = 0x1 >> +HARDWARE_INSTANCE = 0x0 >> +MONOTONIC_COUNT = 0x1 >> +CERTIFICATE_GUID = 4AAFD29D-68DF-49EE-8AA9-347D375665A7 # PKCS7 >> + >> + FV = SystemFirmwareUpdateCargo >> + >> +[Capsule.StyxFirmwareUpdateCapsuleFmpPkcs7] >> +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # gEfiFmpCapsuleGuid >> +CAPSULE_HEADER_SIZE = 0x20 >> +CAPSULE_HEADER_INIT_VERSION = 0x1 >> + >> + FMP_PAYLOAD = FmpPayloadSystemFirmwarePkcs7 >> >> !include Silicon/Hisilicon/Hisilicon.fdf.inc >> >> diff --git a/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> new file mode 100644 >> index 0000000..fc834d9 >> --- /dev/null >> +++ b/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> @@ -0,0 +1,45 @@ >> +# >> +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. >> +# Copyright (c) 2018, Linaro Limited. All rights reserved. >> +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >> +# >> +# 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. >> +# >> +## >> + >> +[Head] >> +NumOfUpdate = 3 >> +NumOfRecovery = 0 >> +Update0 = SysFvMain >> +Update1 = SysCustom >> +Update2 = SysNvRam >> + >> +[SysFvMain] >> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x00000000 # Base address offset on flash >> +Length = 0x002D0000 # Length >> +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> + >> +[SysCustom] >> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x002F0000 # Base address offset on flash >> +Length = 0x00010000 # Length >> +ImageOffset = 0x002F0000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> + >> +[SysNvRam] >> +FirmwareType = 1 # 0 - SystemFirmware, 1 - NvRam >> +AddressType = 0 # 0 - relative address, 1 - absolute address. >> +BaseAddress = 0x002D0000 # Base address offset on flash >> +Length = 0x00020000 # Length >> +ImageOffset = 0x002D0000 # Image offset of this SystemFirmware image >> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >> diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc >> index b89cea3..b99cda5 100644 >> --- a/Platform/Hisilicon/D05/D05.dsc >> +++ b/Platform/Hisilicon/D05/D05.dsc >> @@ -81,7 +81,6 @@ >> OemAddressMapLib|Platform/Hisilicon/D05/Library/OemAddressMapD05/OemAddressMapD05.inf >> PlatformSysCtrlLib|Silicon/Hisilicon/Hi1616/Library/PlatformSysCtrlLibHi1616/PlatformSysCtrlLibHi1616.inf >> >> - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf >> GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf >> PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf >> !if $(GENERIC_BDS) == TRUE >> @@ -130,6 +129,11 @@ >> gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE >> gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE >> >> +[PcdsDynamicExDefault.common.DEFAULT] >> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 >> + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x29, 0x3d, 0x4b, 0xd3, 0x85, 0x00, 0xb3, 0x4a, 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89} >> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xcf, 0x4f, 0x2e, 0x64, 0xf7, 0x2d, 0x15, 0x44, 0x8b, 0x70, 0xa0, 0x39, 0x09, 0xc5, 0x7b, 0x55} >> + >> [PcdsFixedAtBuild.common] >> gArmPlatformTokenSpaceGuid.PcdCoreCount|8 >> >> @@ -448,6 +452,8 @@ >> Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf >> Silicon/Hisilicon/Drivers/VersionInfoPeim/VersionInfoPeim.inf >> >> + Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> + >> MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { >> <LibraryClasses> >> NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf >> @@ -564,6 +570,9 @@ >> >> Platform/Hisilicon/D05/Drivers/Sas/SasDxeDriver.inf >> >> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >> + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >> + >> # >> # FAT filesystem + GPT/MBR partitioning >> # >> @@ -635,6 +644,14 @@ >> !else >> IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf >> !endif >> + >> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf { >> + <LibraryClasses> >> + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf >> + } >> + >> + MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf >> + >> # >> # UEFI application (Shell Embedded Boot Loader) >> # >> diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.fdf >> index d209210..9a61c52 100644 >> --- a/Platform/Hisilicon/D05/D05.fdf >> +++ b/Platform/Hisilicon/D05/D05.fdf >> @@ -297,6 +297,8 @@ READ_LOCK_STATUS = TRUE >> INF Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf >> INF Platform/Hisilicon/D05/Drivers/Sas/SasDxeDriver.inf >> >> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >> + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >> # >> # Build Shell from latest source code instead of prebuilt binary >> # >> @@ -361,12 +363,80 @@ READ_LOCK_STATUS = TRUE >> >> INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf >> >> + INF RuleOverride = FMP_IMAGE_DESC Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> + >> FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { >> SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { >> SECTION FV_IMAGE = FVMAIN >> } >> } >> >> +[FV.CapsuleDispatchFv] >> +FvAlignment = 16 >> +ERASE_POLARITY = 1 >> +MEMORY_MAPPED = TRUE >> +STICKY_WRITE = TRUE >> +LOCK_CAP = TRUE >> +LOCK_STATUS = TRUE >> +WRITE_DISABLED_CAP = TRUE >> +WRITE_ENABLED_CAP = TRUE >> +WRITE_STATUS = TRUE >> +WRITE_LOCK_CAP = TRUE >> +WRITE_LOCK_STATUS = TRUE >> +READ_DISABLED_CAP = TRUE >> +READ_ENABLED_CAP = TRUE >> +READ_STATUS = TRUE >> +READ_LOCK_CAP = TRUE >> +READ_LOCK_STATUS = TRUE >> + >> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf >> + >> +[FV.SystemFirmwareUpdateCargo] >> +FvAlignment = 16 >> +ERASE_POLARITY = 1 >> +MEMORY_MAPPED = TRUE >> +STICKY_WRITE = TRUE >> +LOCK_CAP = TRUE >> +LOCK_STATUS = TRUE >> +WRITE_DISABLED_CAP = TRUE >> +WRITE_ENABLED_CAP = TRUE >> +WRITE_STATUS = TRUE >> +WRITE_LOCK_CAP = TRUE >> +WRITE_LOCK_STATUS = TRUE >> +READ_DISABLED_CAP = TRUE >> +READ_ENABLED_CAP = TRUE >> +READ_STATUS = TRUE >> +READ_LOCK_CAP = TRUE >> +READ_LOCK_STATUS = TRUE >> + >> + FILE RAW = 642e4fcf-2df7-4415-8b70-a03909c57b55 { # PcdEdkiiSystemFirmwareFileGuid >> + FD = D05 >> + } >> + >> + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid >> + FV = CapsuleDispatchFv >> + } >> + >> + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid >> + Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >> + } >> + >> +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] >> +IMAGE_HEADER_INIT_VERSION = 0x02 >> +IMAGE_TYPE_ID = d34b3d29-0085-4ab3-8be8-84188cc50489 # PcdSystemFmpCapsuleImageTypeIdGuid >> +IMAGE_INDEX = 0x1 >> +HARDWARE_INSTANCE = 0x0 >> +MONOTONIC_COUNT = 0x1 >> +CERTIFICATE_GUID = 4AAFD29D-68DF-49EE-8AA9-347D375665A7 # PKCS7 >> + >> + FV = SystemFirmwareUpdateCargo >> + >> +[Capsule.StyxFirmwareUpdateCapsuleFmpPkcs7] >> +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # gEfiFmpCapsuleGuid >> +CAPSULE_HEADER_SIZE = 0x20 >> +CAPSULE_HEADER_INIT_VERSION = 0x1 >> + >> + FMP_PAYLOAD = FmpPayloadSystemFirmwarePkcs7 >> >> !include Silicon/Hisilicon/Hisilicon.fdf.inc >> >> diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc >> new file mode 100644 >> index 0000000..465535e >> --- /dev/null >> +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc >> @@ -0,0 +1,81 @@ >> +/** @file >> + System Firmware descriptor. >> + >> + Copyright (c) 2018, Hisilicon Limited. All rights reserved. >> + Copyright (c) 2018, Linaro Limited. All rights reserved. >> + Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >> + >> + 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 <PiPei.h> >> +#include <Guid/EdkiiSystemFmpCapsule.h> >> +#include <Protocol/FirmwareManagement.h> >> + >> +#define PACKAGE_VERSION 0xFFFFFFFF >> +#define PACKAGE_VERSION_STRING L"Unknown" >> + >> +#define CURRENT_FIRMWARE_VERSION 0x00000002 >> +#define CURRENT_FIRMWARE_VERSION_STRING L"0x00000002" >> +#define LOWEST_SUPPORTED_FIRMWARE_VERSION 0x00000001 >> + >> +#define IMAGE_ID SIGNATURE_64('H','W','A', 'R', 'M', '_', 'F', 'd') >> +#define IMAGE_ID_STRING L"ARMPlatformFd" >> + >> +// PcdSystemFmpCapsuleImageTypeIdGuid >> +#define IMAGE_TYPE_ID_GUID { 0xd34b3d29, 0x0085, 0x4ab3, { 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89 } } >> + >> +typedef struct { >> + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR Descriptor; >> + // real string data >> + CHAR16 ImageIdNameStr[sizeof(IMAGE_ID_STRING) / sizeof(CHAR16)]; >> + CHAR16 VersionNameStr[sizeof(CURRENT_FIRMWARE_VERSION_STRING) / sizeof(CHAR16)]; >> + CHAR16 PackageVersionNameStr[sizeof(PACKAGE_VERSION_STRING) / sizeof(CHAR16)]; >> +} IMAGE_DESCRIPTOR; >> + >> +IMAGE_DESCRIPTOR mImageDescriptor = >> +{ >> + { >> + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE, >> + sizeof (EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR), >> + sizeof (IMAGE_DESCRIPTOR), >> + PACKAGE_VERSION, // PackageVersion >> + OFFSET_OF (IMAGE_DESCRIPTOR, PackageVersionNameStr), // PackageVersionName >> + 1, // ImageIndex; >> + {0x0}, // Reserved >> + IMAGE_TYPE_ID_GUID, // ImageTypeId; >> + IMAGE_ID, // ImageId; >> + OFFSET_OF (IMAGE_DESCRIPTOR, ImageIdNameStr), // ImageIdName; >> + CURRENT_FIRMWARE_VERSION, // Version; >> + OFFSET_OF (IMAGE_DESCRIPTOR, VersionNameStr), // VersionName; >> + {0x0}, // Reserved2 >> + FixedPcdGet32 (PcdFdSize), // Size; >> + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | >> + IMAGE_ATTRIBUTE_RESET_REQUIRED | >> + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | >> + IMAGE_ATTRIBUTE_IN_USE, // AttributesSupported; >> + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | >> + IMAGE_ATTRIBUTE_RESET_REQUIRED | >> + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | >> + IMAGE_ATTRIBUTE_IN_USE, // AttributesSetting; >> + 0x0, // Compatibilities; >> + LOWEST_SUPPORTED_FIRMWARE_VERSION, // LowestSupportedImageVersion; >> + 0x00000000, // LastAttemptVersion; >> + 0, // LastAttemptStatus; >> + {0x0}, // Reserved3 >> + 0, // HardwareInstance; >> + }, >> + // real string data >> + {IMAGE_ID_STRING}, >> + {CURRENT_FIRMWARE_VERSION_STRING}, >> + {PACKAGE_VERSION_STRING}, >> +}; >> + >> +VOID* CONST ReferenceAcpiTable = &mImageDescriptor; >> diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> new file mode 100644 >> index 0000000..c38a809 >> --- /dev/null >> +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >> @@ -0,0 +1,50 @@ >> +## @file >> +# System Firmware descriptor. >> +# >> +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. >> +# Copyright (c) 2018, Linaro Limited. All rights reserved. >> +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >> +# >> +# 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 >> + BASE_NAME = SystemFirmwareDescriptor >> + FILE_GUID = 90B2B846-CA6D-4D6E-A8D3-C140A8E110AC >> + MODULE_TYPE = PEIM >> + VERSION_STRING = 1.0 >> + ENTRY_POINT = SystemFirmwareDescriptorPeimEntry >> + >> +[Sources] >> + SystemFirmwareDescriptorPei.c >> + SystemFirmwareDescriptor.aslc >> + >> +[Packages] >> + ArmPkg/ArmPkg.dec >> + ArmPlatformPkg/ArmPlatformPkg.dec >> + MdeModulePkg/MdeModulePkg.dec >> + MdePkg/MdePkg.dec >> + SignedCapsulePkg/SignedCapsulePkg.dec >> + >> +[LibraryClasses] >> + DebugLib >> + PcdLib >> + PeimEntryPoint >> + PeiServicesLib >> + >> +[FixedPcd] >> + gArmTokenSpaceGuid.PcdFdSize >> + >> +[Pcd] >> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor >> + >> +[Depex] >> + TRUE >> diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c >> new file mode 100644 >> index 0000000..27c0a71 >> --- /dev/null >> +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c >> @@ -0,0 +1,70 @@ >> +/** @file >> + System Firmware descriptor producer. >> + >> + Copyright (c) 2018, Hisilicon Limited. All rights reserved. >> + Copyright (c) 2018, Linaro Limited. All rights reserved. >> + Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >> + >> + 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 <PiPei.h> >> +#include <Guid/EdkiiSystemFmpCapsule.h> >> +#include <Library/DebugLib.h> >> +#include <Library/PcdLib.h> >> +#include <Library/PeiServicesLib.h> >> +#include <Protocol/FirmwareManagement.h> >> + >> +/** >> + Entrypoint for SystemFirmwareDescriptor PEIM. >> + >> + @param[in] FileHandle Handle of the file being invoked. >> + @param[in] PeiServices Describes the list of possible PEI Services. >> + >> + @retval EFI_SUCCESS PPI successfully installed. >> +**/ >> +EFI_STATUS >> +EFIAPI >> +SystemFirmwareDescriptorPeimEntry ( >> + IN EFI_PEI_FILE_HANDLE FileHandle, >> + IN CONST EFI_PEI_SERVICES **PeiServices >> + ) >> +{ >> + EFI_STATUS Status; >> + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *Descriptor; >> + UINTN Size; >> + UINTN Index; >> + UINT32 AuthenticationStatus; >> + >> + // >> + // Search RAW section. >> + // >> + >> + Index = 0; >> + while (TRUE) { >> + Status = PeiServicesFfsFindSectionData3 (EFI_SECTION_RAW, Index, FileHandle, (VOID **)&Descriptor, &AuthenticationStatus); >> + if (EFI_ERROR (Status)) { >> + // Should not happen, must something wrong in FDF. >> + DEBUG ((DEBUG_ERROR, "Not found SystemFirmwareDescriptor in fdf !\n")); >> + return EFI_NOT_FOUND; >> + } >> + if (Descriptor->Signature == EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) { >> + break; >> + } >> + Index++; >> + } >> + >> + DEBUG ((DEBUG_INFO, "EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR size - 0x%x\n", Descriptor->Length)); >> + >> + Size = Descriptor->Length; >> + PcdSetPtrS (PcdEdkiiSystemFirmwareImageDescriptor, &Size, Descriptor); >> + >> + return EFI_SUCCESS; >> +} >> diff --git a/Silicon/Hisilicon/Hisilicon.dsc.inc b/Silicon/Hisilicon/Hisilicon.dsc.inc >> index 308064b..dfa11d1 100644 >> --- a/Silicon/Hisilicon/Hisilicon.dsc.inc >> +++ b/Silicon/Hisilicon/Hisilicon.dsc.inc >> @@ -104,6 +104,15 @@ >> ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf >> SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf >> >> + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf >> + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf >> + IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf >> + BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf >> + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf >> + EdkiiSystemCapsuleLib|SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.inf >> + IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf >> + PlatformFlashAccessLib|Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.inf >> + >> # >> # It is not possible to prevent the ARM compiler for generic intrinsic functions. >> # This library provides the instrinsic functions generate by a given compiler. >> @@ -198,7 +207,7 @@ >> HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf >> MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf >> ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf >> - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf >> + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf >> SerialPortLib|Silicon/Hisilicon/Library/Dw8250SerialPortRuntimeLib/Dw8250SerialPortRuntimeLib.inf >> DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf >> >> diff --git a/Silicon/Hisilicon/Hisilicon.fdf.inc b/Silicon/Hisilicon/Hisilicon.fdf.inc >> index ee87cd1..986dd75 100644 >> --- a/Silicon/Hisilicon/Hisilicon.fdf.inc >> +++ b/Silicon/Hisilicon/Hisilicon.fdf.inc >> @@ -76,6 +76,15 @@ >> } >> } >> >> +[Rule.Common.PEIM.FMP_IMAGE_DESC] >> + FILE PEIM = $(NAMED_GUID) { >> + RAW BIN |.acpi >> + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex >> + PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi >> + UI STRING="$(MODULE_NAME)" Optional >> + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) >> + } >> + >> [Rule.Common.DXE_CORE] >> FILE DXE_CORE = $(NAMED_GUID) { >> PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi >> 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.<BR> >> + >> + 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 <PiDxe.h> >> +#include <Library/BaseLib.h> >> +#include <Library/BaseMemoryLib.h> >> +#include <Library/DebugLib.h> >> +#include <Library/PcdLib.h> >> +#include <Library/PlatformFlashAccessLib.h> >> +#include <Library/UefiBootServicesTableLib.h> >> +#include <Protocol/HisiSpiFlashProtocol.h> >> + >> +STATIC EFI_PHYSICAL_ADDRESS mInternalFdAddress; >> +STATIC EFI_PHYSICAL_ADDRESS mSFCMEM0BaseAddress; >> + >> +HISI_SPI_FLASH_PROTOCOL *mSpiProtocol; > > STATIC > >> + >> +/** >> + 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.<BR> >> +# >> +# 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
On 24 January 2018 at 11:10, Huangming (Mark) <huangming23@huawei.com> wrote: > > > On 2018/1/20 18:50, Ard Biesheuvel wrote: >> On 18 January 2018 at 15:01, Ming Huang <heyi.guo@linaro.org> wrote: >>> From: Jason Zhang <zhangjinsong2@huawei.com> >>> >>> Contributed-under: TianoCore Contribution Agreement 1.1 >>> Signed-off-by: Jason Zhang <zhangjinsong2@huawei.com> >>> Signed-off-by: Ming Huang <huangming23@huawei.com> >>> Signed-off-by: Heyi Guo <heyi.guo@linaro.org> >>> --- >>> 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/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >>> new file mode 100644 >>> index 0000000..fc834d9 >>> --- /dev/null >>> +++ b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >>> @@ -0,0 +1,45 @@ >>> +# >>> +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. >>> +# Copyright (c) 2018, Linaro Limited. All rights reserved. >>> +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >>> +# >>> +# 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. >>> +# >>> +## >>> + >>> +[Head] >>> +NumOfUpdate = 3 >>> +NumOfRecovery = 0 >>> +Update0 = SysFvMain >>> +Update1 = SysCustom >>> +Update2 = SysNvRam >>> + >>> +[SysFvMain] >>> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >>> +AddressType = 0 # 0 - relative address, 1 - absolute address. >>> +BaseAddress = 0x00000000 # Base address offset on flash >>> +Length = 0x002D0000 # Length >>> +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image >>> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >>> + >>> +[SysCustom] >>> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >>> +AddressType = 0 # 0 - relative address, 1 - absolute address. >>> +BaseAddress = 0x002F0000 # Base address offset on flash >>> +Length = 0x00010000 # Length >>> +ImageOffset = 0x002F0000 # Image offset of this SystemFirmware image >>> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >>> + >>> +[SysNvRam] >>> +FirmwareType = 1 # 0 - SystemFirmware, 1 - NvRam >>> +AddressType = 0 # 0 - relative address, 1 - absolute address. >>> +BaseAddress = 0x002D0000 # Base address offset on flash >>> +Length = 0x00020000 # Length >>> +ImageOffset = 0x002D0000 # Image offset of this SystemFirmware image >>> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >>> diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc >>> index b2eae7d..69bc7b4 100644 >>> --- a/Platform/Hisilicon/D03/D03.dsc >>> +++ b/Platform/Hisilicon/D03/D03.dsc >>> @@ -66,7 +66,6 @@ >>> OemAddressMapLib|Platform/Hisilicon/D03/Library/OemAddressMap2P/OemAddressMap2PHi1610.inf >>> PlatformSysCtrlLib|Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.inf >>> >>> - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf >>> GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf >>> PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf >>> !if $(GENERIC_BDS) == TRUE >>> @@ -117,6 +116,11 @@ >>> gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE >>> gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE >>> >>> +[PcdsDynamicExDefault.common.DEFAULT] >>> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 >>> + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x29, 0x3d, 0x4b, 0xd3, 0x85, 0x00, 0xb3, 0x4a, 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89} >>> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xcf, 0x4f, 0x2e, 0x64, 0xf7, 0x2d, 0x15, 0x44, 0x8b, 0x70, 0xa0, 0x39, 0x09, 0xc5, 0x7b, 0x55} >>> + >>> [PcdsFixedAtBuild.common] >>> gArmPlatformTokenSpaceGuid.PcdCoreCount|8 >>> >>> @@ -310,6 +314,8 @@ >>> Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf >>> Silicon/Hisilicon/Drivers/VersionInfoPeim/VersionInfoPeim.inf >>> >>> + Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >>> + >>> MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { >>> <LibraryClasses> >>> NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf >>> @@ -410,6 +416,9 @@ >>> >>> Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf >>> >>> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >>> + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >>> + >>> # >>> # FAT filesystem + GPT/MBR partitioning >>> # >>> @@ -483,6 +492,12 @@ >>> !else >>> IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf >>> !endif >>> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf { >>> + <LibraryClasses> >>> + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf >>> + } >>> + >>> + MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf >>> >>> # >>> # UEFI application (Shell Embedded Boot Loader) >>> diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf >>> index 0d704b5..ffddd2d 100644 >>> --- a/Platform/Hisilicon/D03/D03.fdf >>> +++ b/Platform/Hisilicon/D03/D03.fdf >>> @@ -275,6 +275,8 @@ READ_LOCK_STATUS = TRUE >>> INF Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf >>> INF Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf >>> >>> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >>> + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >>> # >>> # Build Shell from latest source code instead of prebuilt binary >>> # >>> @@ -336,12 +338,80 @@ READ_LOCK_STATUS = TRUE >>> >>> INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf >>> >>> + INF RuleOverride = FMP_IMAGE_DESC Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >>> + >>> FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { >>> SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { >>> SECTION FV_IMAGE = FVMAIN >>> } >>> } >>> >>> +[FV.CapsuleDispatchFv] >>> +FvAlignment = 16 >>> +ERASE_POLARITY = 1 >>> +MEMORY_MAPPED = TRUE >>> +STICKY_WRITE = TRUE >>> +LOCK_CAP = TRUE >>> +LOCK_STATUS = TRUE >>> +WRITE_DISABLED_CAP = TRUE >>> +WRITE_ENABLED_CAP = TRUE >>> +WRITE_STATUS = TRUE >>> +WRITE_LOCK_CAP = TRUE >>> +WRITE_LOCK_STATUS = TRUE >>> +READ_DISABLED_CAP = TRUE >>> +READ_ENABLED_CAP = TRUE >>> +READ_STATUS = TRUE >>> +READ_LOCK_CAP = TRUE >>> +READ_LOCK_STATUS = TRUE >>> + >>> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf >>> + >>> +[FV.SystemFirmwareUpdateCargo] >>> +FvAlignment = 16 >>> +ERASE_POLARITY = 1 >>> +MEMORY_MAPPED = TRUE >>> +STICKY_WRITE = TRUE >>> +LOCK_CAP = TRUE >>> +LOCK_STATUS = TRUE >>> +WRITE_DISABLED_CAP = TRUE >>> +WRITE_ENABLED_CAP = TRUE >>> +WRITE_STATUS = TRUE >>> +WRITE_LOCK_CAP = TRUE >>> +WRITE_LOCK_STATUS = TRUE >>> +READ_DISABLED_CAP = TRUE >>> +READ_ENABLED_CAP = TRUE >>> +READ_STATUS = TRUE >>> +READ_LOCK_CAP = TRUE >>> +READ_LOCK_STATUS = TRUE >>> + >>> + FILE RAW = 642e4fcf-2df7-4415-8b70-a03909c57b55 { # PcdEdkiiSystemFirmwareFileGuid >>> + FD = D03 >>> + } >>> + >>> + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid >>> + FV = CapsuleDispatchFv >>> + } >>> + >>> + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid >>> + Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >>> + } >>> + >>> +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] >>> +IMAGE_HEADER_INIT_VERSION = 0x02 >>> +IMAGE_TYPE_ID = d34b3d29-0085-4ab3-8be8-84188cc50489 # PcdSystemFmpCapsuleImageTypeIdGuid >> >> Use a fresh GUID here, and make sure you use a different one for D03/D05 etc. >> >> This is what identifies the platform when using fwupdmgr etc. >> >> > > IMAGE_TYPE_ID in D0x.fdf is need to equal to IMAGE_TYPE_ID_GUID in > Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc, > so D0x is used the same guid. No. Instead, you need a different version of SystemFirmwareDescriptor.aslc for D03 and D05, and use different GUIDs for each. _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
On 2018/1/24 19:21, Ard Biesheuvel wrote: > On 24 January 2018 at 11:10, Huangming (Mark) <huangming23@huawei.com> wrote: >> >> >> On 2018/1/20 18:50, Ard Biesheuvel wrote: >>> On 18 January 2018 at 15:01, Ming Huang <heyi.guo@linaro.org> wrote: >>>> From: Jason Zhang <zhangjinsong2@huawei.com> >>>> >>>> Contributed-under: TianoCore Contribution Agreement 1.1 >>>> Signed-off-by: Jason Zhang <zhangjinsong2@huawei.com> >>>> Signed-off-by: Ming Huang <huangming23@huawei.com> >>>> Signed-off-by: Heyi Guo <heyi.guo@linaro.org> >>>> --- >>>> 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/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >>>> new file mode 100644 >>>> index 0000000..fc834d9 >>>> --- /dev/null >>>> +++ b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >>>> @@ -0,0 +1,45 @@ >>>> +# >>>> +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. >>>> +# Copyright (c) 2018, Linaro Limited. All rights reserved. >>>> +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> >>>> +# >>>> +# 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. >>>> +# >>>> +## >>>> + >>>> +[Head] >>>> +NumOfUpdate = 3 >>>> +NumOfRecovery = 0 >>>> +Update0 = SysFvMain >>>> +Update1 = SysCustom >>>> +Update2 = SysNvRam >>>> + >>>> +[SysFvMain] >>>> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >>>> +AddressType = 0 # 0 - relative address, 1 - absolute address. >>>> +BaseAddress = 0x00000000 # Base address offset on flash >>>> +Length = 0x002D0000 # Length >>>> +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image >>>> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >>>> + >>>> +[SysCustom] >>>> +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam >>>> +AddressType = 0 # 0 - relative address, 1 - absolute address. >>>> +BaseAddress = 0x002F0000 # Base address offset on flash >>>> +Length = 0x00010000 # Length >>>> +ImageOffset = 0x002F0000 # Image offset of this SystemFirmware image >>>> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >>>> + >>>> +[SysNvRam] >>>> +FirmwareType = 1 # 0 - SystemFirmware, 1 - NvRam >>>> +AddressType = 0 # 0 - relative address, 1 - absolute address. >>>> +BaseAddress = 0x002D0000 # Base address offset on flash >>>> +Length = 0x00020000 # Length >>>> +ImageOffset = 0x002D0000 # Image offset of this SystemFirmware image >>>> +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid >>>> diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc >>>> index b2eae7d..69bc7b4 100644 >>>> --- a/Platform/Hisilicon/D03/D03.dsc >>>> +++ b/Platform/Hisilicon/D03/D03.dsc >>>> @@ -66,7 +66,6 @@ >>>> OemAddressMapLib|Platform/Hisilicon/D03/Library/OemAddressMap2P/OemAddressMap2PHi1610.inf >>>> PlatformSysCtrlLib|Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.inf >>>> >>>> - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf >>>> GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf >>>> PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf >>>> !if $(GENERIC_BDS) == TRUE >>>> @@ -117,6 +116,11 @@ >>>> gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE >>>> gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE >>>> >>>> +[PcdsDynamicExDefault.common.DEFAULT] >>>> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 >>>> + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x29, 0x3d, 0x4b, 0xd3, 0x85, 0x00, 0xb3, 0x4a, 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89} >>>> + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xcf, 0x4f, 0x2e, 0x64, 0xf7, 0x2d, 0x15, 0x44, 0x8b, 0x70, 0xa0, 0x39, 0x09, 0xc5, 0x7b, 0x55} >>>> + >>>> [PcdsFixedAtBuild.common] >>>> gArmPlatformTokenSpaceGuid.PcdCoreCount|8 >>>> >>>> @@ -310,6 +314,8 @@ >>>> Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf >>>> Silicon/Hisilicon/Drivers/VersionInfoPeim/VersionInfoPeim.inf >>>> >>>> + Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >>>> + >>>> MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { >>>> <LibraryClasses> >>>> NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf >>>> @@ -410,6 +416,9 @@ >>>> >>>> Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf >>>> >>>> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >>>> + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >>>> + >>>> # >>>> # FAT filesystem + GPT/MBR partitioning >>>> # >>>> @@ -483,6 +492,12 @@ >>>> !else >>>> IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf >>>> !endif >>>> + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf { >>>> + <LibraryClasses> >>>> + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf >>>> + } >>>> + >>>> + MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf >>>> >>>> # >>>> # UEFI application (Shell Embedded Boot Loader) >>>> diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf >>>> index 0d704b5..ffddd2d 100644 >>>> --- a/Platform/Hisilicon/D03/D03.fdf >>>> +++ b/Platform/Hisilicon/D03/D03.fdf >>>> @@ -275,6 +275,8 @@ READ_LOCK_STATUS = TRUE >>>> INF Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf >>>> INF Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf >>>> >>>> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf >>>> + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf >>>> # >>>> # Build Shell from latest source code instead of prebuilt binary >>>> # >>>> @@ -336,12 +338,80 @@ READ_LOCK_STATUS = TRUE >>>> >>>> INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf >>>> >>>> + INF RuleOverride = FMP_IMAGE_DESC Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf >>>> + >>>> FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { >>>> SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { >>>> SECTION FV_IMAGE = FVMAIN >>>> } >>>> } >>>> >>>> +[FV.CapsuleDispatchFv] >>>> +FvAlignment = 16 >>>> +ERASE_POLARITY = 1 >>>> +MEMORY_MAPPED = TRUE >>>> +STICKY_WRITE = TRUE >>>> +LOCK_CAP = TRUE >>>> +LOCK_STATUS = TRUE >>>> +WRITE_DISABLED_CAP = TRUE >>>> +WRITE_ENABLED_CAP = TRUE >>>> +WRITE_STATUS = TRUE >>>> +WRITE_LOCK_CAP = TRUE >>>> +WRITE_LOCK_STATUS = TRUE >>>> +READ_DISABLED_CAP = TRUE >>>> +READ_ENABLED_CAP = TRUE >>>> +READ_STATUS = TRUE >>>> +READ_LOCK_CAP = TRUE >>>> +READ_LOCK_STATUS = TRUE >>>> + >>>> + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf >>>> + >>>> +[FV.SystemFirmwareUpdateCargo] >>>> +FvAlignment = 16 >>>> +ERASE_POLARITY = 1 >>>> +MEMORY_MAPPED = TRUE >>>> +STICKY_WRITE = TRUE >>>> +LOCK_CAP = TRUE >>>> +LOCK_STATUS = TRUE >>>> +WRITE_DISABLED_CAP = TRUE >>>> +WRITE_ENABLED_CAP = TRUE >>>> +WRITE_STATUS = TRUE >>>> +WRITE_LOCK_CAP = TRUE >>>> +WRITE_LOCK_STATUS = TRUE >>>> +READ_DISABLED_CAP = TRUE >>>> +READ_ENABLED_CAP = TRUE >>>> +READ_STATUS = TRUE >>>> +READ_LOCK_CAP = TRUE >>>> +READ_LOCK_STATUS = TRUE >>>> + >>>> + FILE RAW = 642e4fcf-2df7-4415-8b70-a03909c57b55 { # PcdEdkiiSystemFirmwareFileGuid >>>> + FD = D03 >>>> + } >>>> + >>>> + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid >>>> + FV = CapsuleDispatchFv >>>> + } >>>> + >>>> + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid >>>> + Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini >>>> + } >>>> + >>>> +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] >>>> +IMAGE_HEADER_INIT_VERSION = 0x02 >>>> +IMAGE_TYPE_ID = d34b3d29-0085-4ab3-8be8-84188cc50489 # PcdSystemFmpCapsuleImageTypeIdGuid >>> >>> Use a fresh GUID here, and make sure you use a different one for D03/D05 etc. >>> >>> This is what identifies the platform when using fwupdmgr etc. >>> >>> >> >> IMAGE_TYPE_ID in D0x.fdf is need to equal to IMAGE_TYPE_ID_GUID in >> Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc, >> so D0x is used the same guid. > > No. Instead, you need a different version of > SystemFirmwareDescriptor.aslc for D03 and D05, and use different GUIDs > for each. > > . > OK,I will move the SystemFirmwareDescriptor from Silicon/Hisilicon/Drivers/ to Platform/Hisilicon/D03/Drivers/and Platform/Hisilicon/D05/Drivers/. and use different guids for each. Thanks. -- Best Regards, Ming _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
diff --git a/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini new file mode 100644 index 0000000..fc834d9 --- /dev/null +++ b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini @@ -0,0 +1,45 @@ +# +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. +# Copyright (c) 2018, Linaro Limited. All rights reserved. +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> +# +# 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. +# +## + +[Head] +NumOfUpdate = 3 +NumOfRecovery = 0 +Update0 = SysFvMain +Update1 = SysCustom +Update2 = SysNvRam + +[SysFvMain] +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam +AddressType = 0 # 0 - relative address, 1 - absolute address. +BaseAddress = 0x00000000 # Base address offset on flash +Length = 0x002D0000 # Length +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid + +[SysCustom] +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam +AddressType = 0 # 0 - relative address, 1 - absolute address. +BaseAddress = 0x002F0000 # Base address offset on flash +Length = 0x00010000 # Length +ImageOffset = 0x002F0000 # Image offset of this SystemFirmware image +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid + +[SysNvRam] +FirmwareType = 1 # 0 - SystemFirmware, 1 - NvRam +AddressType = 0 # 0 - relative address, 1 - absolute address. +BaseAddress = 0x002D0000 # Base address offset on flash +Length = 0x00020000 # Length +ImageOffset = 0x002D0000 # Image offset of this SystemFirmware image +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc index b2eae7d..69bc7b4 100644 --- a/Platform/Hisilicon/D03/D03.dsc +++ b/Platform/Hisilicon/D03/D03.dsc @@ -66,7 +66,6 @@ OemAddressMapLib|Platform/Hisilicon/D03/Library/OemAddressMap2P/OemAddressMap2PHi1610.inf PlatformSysCtrlLib|Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.inf - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf !if $(GENERIC_BDS) == TRUE @@ -117,6 +116,11 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE +[PcdsDynamicExDefault.common.DEFAULT] + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x29, 0x3d, 0x4b, 0xd3, 0x85, 0x00, 0xb3, 0x4a, 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89} + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xcf, 0x4f, 0x2e, 0x64, 0xf7, 0x2d, 0x15, 0x44, 0x8b, 0x70, 0xa0, 0x39, 0x09, 0xc5, 0x7b, 0x55} + [PcdsFixedAtBuild.common] gArmPlatformTokenSpaceGuid.PcdCoreCount|8 @@ -310,6 +314,8 @@ Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf Silicon/Hisilicon/Drivers/VersionInfoPeim/VersionInfoPeim.inf + Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf + MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { <LibraryClasses> NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf @@ -410,6 +416,9 @@ Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf + # # FAT filesystem + GPT/MBR partitioning # @@ -483,6 +492,12 @@ !else IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf !endif + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf { + <LibraryClasses> + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf + } + + MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf # # UEFI application (Shell Embedded Boot Loader) diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf index 0d704b5..ffddd2d 100644 --- a/Platform/Hisilicon/D03/D03.fdf +++ b/Platform/Hisilicon/D03/D03.fdf @@ -275,6 +275,8 @@ READ_LOCK_STATUS = TRUE INF Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf INF Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf # # Build Shell from latest source code instead of prebuilt binary # @@ -336,12 +338,80 @@ READ_LOCK_STATUS = TRUE INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf + INF RuleOverride = FMP_IMAGE_DESC Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf + FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { SECTION FV_IMAGE = FVMAIN } } +[FV.CapsuleDispatchFv] +FvAlignment = 16 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf + +[FV.SystemFirmwareUpdateCargo] +FvAlignment = 16 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + FILE RAW = 642e4fcf-2df7-4415-8b70-a03909c57b55 { # PcdEdkiiSystemFirmwareFileGuid + FD = D03 + } + + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid + FV = CapsuleDispatchFv + } + + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid + Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini + } + +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] +IMAGE_HEADER_INIT_VERSION = 0x02 +IMAGE_TYPE_ID = d34b3d29-0085-4ab3-8be8-84188cc50489 # PcdSystemFmpCapsuleImageTypeIdGuid +IMAGE_INDEX = 0x1 +HARDWARE_INSTANCE = 0x0 +MONOTONIC_COUNT = 0x1 +CERTIFICATE_GUID = 4AAFD29D-68DF-49EE-8AA9-347D375665A7 # PKCS7 + + FV = SystemFirmwareUpdateCargo + +[Capsule.StyxFirmwareUpdateCapsuleFmpPkcs7] +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # gEfiFmpCapsuleGuid +CAPSULE_HEADER_SIZE = 0x20 +CAPSULE_HEADER_INIT_VERSION = 0x1 + + FMP_PAYLOAD = FmpPayloadSystemFirmwarePkcs7 !include Silicon/Hisilicon/Hisilicon.fdf.inc diff --git a/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini new file mode 100644 index 0000000..fc834d9 --- /dev/null +++ b/Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini @@ -0,0 +1,45 @@ +# +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. +# Copyright (c) 2018, Linaro Limited. All rights reserved. +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> +# +# 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. +# +## + +[Head] +NumOfUpdate = 3 +NumOfRecovery = 0 +Update0 = SysFvMain +Update1 = SysCustom +Update2 = SysNvRam + +[SysFvMain] +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam +AddressType = 0 # 0 - relative address, 1 - absolute address. +BaseAddress = 0x00000000 # Base address offset on flash +Length = 0x002D0000 # Length +ImageOffset = 0x00000000 # Image offset of this SystemFirmware image +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid + +[SysCustom] +FirmwareType = 0 # 0 - SystemFirmware, 1 - NvRam +AddressType = 0 # 0 - relative address, 1 - absolute address. +BaseAddress = 0x002F0000 # Base address offset on flash +Length = 0x00010000 # Length +ImageOffset = 0x002F0000 # Image offset of this SystemFirmware image +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid + +[SysNvRam] +FirmwareType = 1 # 0 - SystemFirmware, 1 - NvRam +AddressType = 0 # 0 - relative address, 1 - absolute address. +BaseAddress = 0x002D0000 # Base address offset on flash +Length = 0x00020000 # Length +ImageOffset = 0x002D0000 # Image offset of this SystemFirmware image +FileGuid = 642e4fcf-2df7-4415-8b70-a03909c57b55 # PcdEdkiiSystemFirmwareFileGuid diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc index b89cea3..b99cda5 100644 --- a/Platform/Hisilicon/D05/D05.dsc +++ b/Platform/Hisilicon/D05/D05.dsc @@ -81,7 +81,6 @@ OemAddressMapLib|Platform/Hisilicon/D05/Library/OemAddressMapD05/OemAddressMapD05.inf PlatformSysCtrlLib|Silicon/Hisilicon/Hi1616/Library/PlatformSysCtrlLibHi1616/PlatformSysCtrlLibHi1616.inf - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf !if $(GENERIC_BDS) == TRUE @@ -130,6 +129,11 @@ gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE +[PcdsDynamicExDefault.common.DEFAULT] + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor|{0x0}|VOID*|0x100 + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x29, 0x3d, 0x4b, 0xd3, 0x85, 0x00, 0xb3, 0x4a, 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89} + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareFileGuid|{0xcf, 0x4f, 0x2e, 0x64, 0xf7, 0x2d, 0x15, 0x44, 0x8b, 0x70, 0xa0, 0x39, 0x09, 0xc5, 0x7b, 0x55} + [PcdsFixedAtBuild.common] gArmPlatformTokenSpaceGuid.PcdCoreCount|8 @@ -448,6 +452,8 @@ Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf Silicon/Hisilicon/Drivers/VersionInfoPeim/VersionInfoPeim.inf + Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf + MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { <LibraryClasses> NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf @@ -564,6 +570,9 @@ Platform/Hisilicon/D05/Drivers/Sas/SasDxeDriver.inf + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf + MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf + # # FAT filesystem + GPT/MBR partitioning # @@ -635,6 +644,14 @@ !else IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf !endif + + SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf { + <LibraryClasses> + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf + } + + MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf + # # UEFI application (Shell Embedded Boot Loader) # diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.fdf index d209210..9a61c52 100644 --- a/Platform/Hisilicon/D05/D05.fdf +++ b/Platform/Hisilicon/D05/D05.fdf @@ -297,6 +297,8 @@ READ_LOCK_STATUS = TRUE INF Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf INF Platform/Hisilicon/D05/Drivers/Sas/SasDxeDriver.inf + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf + INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf # # Build Shell from latest source code instead of prebuilt binary # @@ -361,12 +363,80 @@ READ_LOCK_STATUS = TRUE INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf + INF RuleOverride = FMP_IMAGE_DESC Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf + FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { SECTION FV_IMAGE = FVMAIN } } +[FV.CapsuleDispatchFv] +FvAlignment = 16 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + INF SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf + +[FV.SystemFirmwareUpdateCargo] +FvAlignment = 16 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + FILE RAW = 642e4fcf-2df7-4415-8b70-a03909c57b55 { # PcdEdkiiSystemFirmwareFileGuid + FD = D05 + } + + FILE RAW = ce57b167-b0e4-41e8-a897-5f4feb781d40 { # gEdkiiSystemFmpCapsuleDriverFvFileGuid + FV = CapsuleDispatchFv + } + + FILE RAW = 812136D3-4D3A-433A-9418-29BB9BF78F6E { # gEdkiiSystemFmpCapsuleConfigFileGuid + Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini + } + +[FmpPayload.FmpPayloadSystemFirmwarePkcs7] +IMAGE_HEADER_INIT_VERSION = 0x02 +IMAGE_TYPE_ID = d34b3d29-0085-4ab3-8be8-84188cc50489 # PcdSystemFmpCapsuleImageTypeIdGuid +IMAGE_INDEX = 0x1 +HARDWARE_INSTANCE = 0x0 +MONOTONIC_COUNT = 0x1 +CERTIFICATE_GUID = 4AAFD29D-68DF-49EE-8AA9-347D375665A7 # PKCS7 + + FV = SystemFirmwareUpdateCargo + +[Capsule.StyxFirmwareUpdateCapsuleFmpPkcs7] +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # gEfiFmpCapsuleGuid +CAPSULE_HEADER_SIZE = 0x20 +CAPSULE_HEADER_INIT_VERSION = 0x1 + + FMP_PAYLOAD = FmpPayloadSystemFirmwarePkcs7 !include Silicon/Hisilicon/Hisilicon.fdf.inc diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc new file mode 100644 index 0000000..465535e --- /dev/null +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc @@ -0,0 +1,81 @@ +/** @file + System Firmware descriptor. + + Copyright (c) 2018, Hisilicon Limited. All rights reserved. + Copyright (c) 2018, Linaro Limited. All rights reserved. + Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> + + 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 <PiPei.h> +#include <Guid/EdkiiSystemFmpCapsule.h> +#include <Protocol/FirmwareManagement.h> + +#define PACKAGE_VERSION 0xFFFFFFFF +#define PACKAGE_VERSION_STRING L"Unknown" + +#define CURRENT_FIRMWARE_VERSION 0x00000002 +#define CURRENT_FIRMWARE_VERSION_STRING L"0x00000002" +#define LOWEST_SUPPORTED_FIRMWARE_VERSION 0x00000001 + +#define IMAGE_ID SIGNATURE_64('H','W','A', 'R', 'M', '_', 'F', 'd') +#define IMAGE_ID_STRING L"ARMPlatformFd" + +// PcdSystemFmpCapsuleImageTypeIdGuid +#define IMAGE_TYPE_ID_GUID { 0xd34b3d29, 0x0085, 0x4ab3, { 0x8b, 0xe8, 0x84, 0x18, 0x8c, 0xc5, 0x04, 0x89 } } + +typedef struct { + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR Descriptor; + // real string data + CHAR16 ImageIdNameStr[sizeof(IMAGE_ID_STRING) / sizeof(CHAR16)]; + CHAR16 VersionNameStr[sizeof(CURRENT_FIRMWARE_VERSION_STRING) / sizeof(CHAR16)]; + CHAR16 PackageVersionNameStr[sizeof(PACKAGE_VERSION_STRING) / sizeof(CHAR16)]; +} IMAGE_DESCRIPTOR; + +IMAGE_DESCRIPTOR mImageDescriptor = +{ + { + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE, + sizeof (EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR), + sizeof (IMAGE_DESCRIPTOR), + PACKAGE_VERSION, // PackageVersion + OFFSET_OF (IMAGE_DESCRIPTOR, PackageVersionNameStr), // PackageVersionName + 1, // ImageIndex; + {0x0}, // Reserved + IMAGE_TYPE_ID_GUID, // ImageTypeId; + IMAGE_ID, // ImageId; + OFFSET_OF (IMAGE_DESCRIPTOR, ImageIdNameStr), // ImageIdName; + CURRENT_FIRMWARE_VERSION, // Version; + OFFSET_OF (IMAGE_DESCRIPTOR, VersionNameStr), // VersionName; + {0x0}, // Reserved2 + FixedPcdGet32 (PcdFdSize), // Size; + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | + IMAGE_ATTRIBUTE_RESET_REQUIRED | + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | + IMAGE_ATTRIBUTE_IN_USE, // AttributesSupported; + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | + IMAGE_ATTRIBUTE_RESET_REQUIRED | + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED | + IMAGE_ATTRIBUTE_IN_USE, // AttributesSetting; + 0x0, // Compatibilities; + LOWEST_SUPPORTED_FIRMWARE_VERSION, // LowestSupportedImageVersion; + 0x00000000, // LastAttemptVersion; + 0, // LastAttemptStatus; + {0x0}, // Reserved3 + 0, // HardwareInstance; + }, + // real string data + {IMAGE_ID_STRING}, + {CURRENT_FIRMWARE_VERSION_STRING}, + {PACKAGE_VERSION_STRING}, +}; + +VOID* CONST ReferenceAcpiTable = &mImageDescriptor; diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf new file mode 100644 index 0000000..c38a809 --- /dev/null +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf @@ -0,0 +1,50 @@ +## @file +# System Firmware descriptor. +# +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. +# Copyright (c) 2018, Linaro Limited. All rights reserved. +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> +# +# 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 + BASE_NAME = SystemFirmwareDescriptor + FILE_GUID = 90B2B846-CA6D-4D6E-A8D3-C140A8E110AC + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + ENTRY_POINT = SystemFirmwareDescriptorPeimEntry + +[Sources] + SystemFirmwareDescriptorPei.c + SystemFirmwareDescriptor.aslc + +[Packages] + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + SignedCapsulePkg/SignedCapsulePkg.dec + +[LibraryClasses] + DebugLib + PcdLib + PeimEntryPoint + PeiServicesLib + +[FixedPcd] + gArmTokenSpaceGuid.PcdFdSize + +[Pcd] + gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor + +[Depex] + TRUE diff --git a/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c new file mode 100644 index 0000000..27c0a71 --- /dev/null +++ b/Silicon/Hisilicon/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c @@ -0,0 +1,70 @@ +/** @file + System Firmware descriptor producer. + + Copyright (c) 2018, Hisilicon Limited. All rights reserved. + Copyright (c) 2018, Linaro Limited. All rights reserved. + Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> + + 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 <PiPei.h> +#include <Guid/EdkiiSystemFmpCapsule.h> +#include <Library/DebugLib.h> +#include <Library/PcdLib.h> +#include <Library/PeiServicesLib.h> +#include <Protocol/FirmwareManagement.h> + +/** + Entrypoint for SystemFirmwareDescriptor PEIM. + + @param[in] FileHandle Handle of the file being invoked. + @param[in] PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCCESS PPI successfully installed. +**/ +EFI_STATUS +EFIAPI +SystemFirmwareDescriptorPeimEntry ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *Descriptor; + UINTN Size; + UINTN Index; + UINT32 AuthenticationStatus; + + // + // Search RAW section. + // + + Index = 0; + while (TRUE) { + Status = PeiServicesFfsFindSectionData3 (EFI_SECTION_RAW, Index, FileHandle, (VOID **)&Descriptor, &AuthenticationStatus); + if (EFI_ERROR (Status)) { + // Should not happen, must something wrong in FDF. + DEBUG ((DEBUG_ERROR, "Not found SystemFirmwareDescriptor in fdf !\n")); + return EFI_NOT_FOUND; + } + if (Descriptor->Signature == EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) { + break; + } + Index++; + } + + DEBUG ((DEBUG_INFO, "EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR size - 0x%x\n", Descriptor->Length)); + + Size = Descriptor->Length; + PcdSetPtrS (PcdEdkiiSystemFirmwareImageDescriptor, &Size, Descriptor); + + return EFI_SUCCESS; +} diff --git a/Silicon/Hisilicon/Hisilicon.dsc.inc b/Silicon/Hisilicon/Hisilicon.dsc.inc index 308064b..dfa11d1 100644 --- a/Silicon/Hisilicon/Hisilicon.dsc.inc +++ b/Silicon/Hisilicon/Hisilicon.dsc.inc @@ -104,6 +104,15 @@ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf + IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf + BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf + FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf + EdkiiSystemCapsuleLib|SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.inf + IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf + PlatformFlashAccessLib|Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.inf + # # It is not possible to prevent the ARM compiler for generic intrinsic functions. # This library provides the instrinsic functions generate by a given compiler. @@ -198,7 +207,7 @@ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf SerialPortLib|Silicon/Hisilicon/Library/Dw8250SerialPortRuntimeLib/Dw8250SerialPortRuntimeLib.inf DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf diff --git a/Silicon/Hisilicon/Hisilicon.fdf.inc b/Silicon/Hisilicon/Hisilicon.fdf.inc index ee87cd1..986dd75 100644 --- a/Silicon/Hisilicon/Hisilicon.fdf.inc +++ b/Silicon/Hisilicon/Hisilicon.fdf.inc @@ -76,6 +76,15 @@ } } +[Rule.Common.PEIM.FMP_IMAGE_DESC] + FILE PEIM = $(NAMED_GUID) { + RAW BIN |.acpi + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) + } + [Rule.Common.DXE_CORE] FILE DXE_CORE = $(NAMED_GUID) { PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi 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.<BR> + + 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 <PiDxe.h> +#include <Library/BaseLib.h> +#include <Library/BaseMemoryLib.h> +#include <Library/DebugLib.h> +#include <Library/PcdLib.h> +#include <Library/PlatformFlashAccessLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Protocol/HisiSpiFlashProtocol.h> + +STATIC EFI_PHYSICAL_ADDRESS mInternalFdAddress; +STATIC EFI_PHYSICAL_ADDRESS mSFCMEM0BaseAddress; + +HISI_SPI_FLASH_PROTOCOL *mSpiProtocol; + +/** + 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)); + + 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); + 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); + + 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)); + } + + 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.<BR> +# +# 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 + BASE_NAME = PlatformFlashAccessLibDxe + FILE_GUID = 9168384A-5F66-4CF7-AEB6-845BDEBD3012 + 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