From: Marcin Wojtas <mw@semihalf.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
"Leif Lindholm" <leif.lindholm@linaro.org>,
"Jan Dąbroś" <jsd@semihalf.com>, "Hua Jing" <jinghua@marvell.com>,
"Grzegorz Jaszczyk" <jaz@semihalf.com>,
"David Sniatkiwicz" <davidsn@marvell.com>
Subject: Re: [platforms PATCH 3/4] Marvell/Armada7k8k: Introduce capsule FW update implementation
Date: Fri, 1 Jun 2018 18:02:04 +0200 [thread overview]
Message-ID: <CAPv3WKeOrhe3B-z4+Uz26xKvU3Zb8bfdBShFT9YvWDAqRYOeJQ@mail.gmail.com> (raw)
In-Reply-To: <CAKv+Gu_QM+v04E90MP4_2abg_VDeUg=hs6F6MX3N+2YdSSJ0kw@mail.gmail.com>
Hi Ard,
2018-06-01 17:32 GMT+02:00 Ard Biesheuvel <ard.biesheuvel@linaro.org>:
> On 1 June 2018 at 16:32, Marcin Wojtas <mw@semihalf.com> wrote:
>> From: David Sniatkiwicz <davidsn@marvell.com>
>>
>> This patch adds necessary code that allows to update
>> firmware on Armada7k8k platforms, using generic gRT->UpdateCapsule,
>> i.e.
>> * PlatformFlashAccessLib implementation to write data to SPI flash
>> * SystemFirmwareDescriptor for FMP protocol
>> * SystemFirmwareUpdateConfig to specify binary description
>> within SystemFirmwareFile
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: David Sniatkiwicz <davidsn@marvell.com>
>> Signed-off-by: Marcin Wojtas <mw@semihalf.com>
>
> Please take the [very recent] changes made in
> 550de36633fec97d4f7467c02a33b3217f440ae9 into account here.
> Unfortunately, there is no loop in your code from which you can report
> progress, but you should at least implement the new entry point.
>
Actually there is a loop and current % of progress printed when
updating data in the SPI.
It is implemented in the SPI flash protocol callback.
https://github.com/tianocore/edk2-platforms/blob/master/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c#L382
What would you recommend me to do in such case?
Thanks,
Marcin
>
>> ---
>> Silicon/Marvell/Armada7k8k/Feature/Capsule/PlatformFlashAccessLib/PlatformFlashAccessLib.c | 261 ++++++++++++++++++++
>> Silicon/Marvell/Armada7k8k/Feature/Capsule/PlatformFlashAccessLib/PlatformFlashAccessLib.inf | 52 ++++
>> Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc | 81 ++++++
>> Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf | 50 ++++
>> Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c | 74 ++++++
>> Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini | 26 ++
>> 6 files changed, 544 insertions(+)
>>
>> diff --git a/Silicon/Marvell/Armada7k8k/Feature/Capsule/PlatformFlashAccessLib/PlatformFlashAccessLib.c b/Silicon/Marvell/Armada7k8k/Feature/Capsule/PlatformFlashAccessLib/PlatformFlashAccessLib.c
>> new file mode 100644
>> index 0000000..47d3205
>> --- /dev/null
>> +++ b/Silicon/Marvell/Armada7k8k/Feature/Capsule/PlatformFlashAccessLib/PlatformFlashAccessLib.c
>> @@ -0,0 +1,261 @@
>> +/** @file
>> + Platform flash device access library for Marvell Armada 7k8k Platforms
>> +
>> + Copyright (c) 2018 Marvell International Ltd.<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/BaseMemoryLib.h>
>> +#include <Library/DebugLib.h>
>> +#include <Library/DxeServicesTableLib.h>
>> +#include <Library/MemoryAllocationLib.h>
>> +#include <Library/PlatformFlashAccessLib.h>
>> +#include <Library/UefiBootServicesTableLib.h>
>> +#include <Library/UefiLib.h>
>> +
>> +#include <Protocol/Spi.h>
>> +#include <Protocol/SpiFlash.h>
>> +
>> +#define MAIN_HDR_MAGIC 0xB105B002
>> +
>> +STATIC MARVELL_SPI_FLASH_PROTOCOL *SpiFlashProtocol;
>> +STATIC MARVELL_SPI_MASTER_PROTOCOL *SpiMasterProtocol;
>> +
>> +typedef struct { // Bytes
>> + UINT32 Magic; // 0-3
>> + UINT32 PrologSize; // 4-7
>> + UINT32 PrologChecksum; // 8-11
>> + UINT32 BootImageSize; // 12-15
>> + UINT32 BootImageChecksum; // 16-19
>> + UINT32 Reserved0; // 20-23
>> + UINT32 LoadAddr; // 24-27
>> + UINT32 ExecAddr; // 28-31
>> + UINT8 UartConfig; // 32
>> + UINT8 Baudrate; // 33
>> + UINT8 ExtCount; // 34
>> + UINT8 AuxFlags; // 35
>> + UINT32 IoArg0; // 36-39
>> + UINT32 IoArg1; // 40-43
>> + UINT32 IoArg2; // 43-47
>> + UINT32 IoArg3; // 48-51
>> + UINT32 Reserved1; // 52-55
>> + UINT32 Reserved2; // 56-59
>> + UINT32 Reserved3; // 60-63
>> +} MV_FIRMWARE_IMAGE_HEADER;
>> +
>> +STATIC
>> +EFI_STATUS
>> +SpiFlashProbe (
>> + IN SPI_DEVICE *SpiFlash
>> + )
>> +{
>> + EFI_STATUS Status;
>> +
>> + // Read SPI flash ID
>> + Status = SpiFlashProtocol->ReadId (SpiFlash, FALSE);
>> + if (EFI_ERROR (Status)) {
>> + return Status;
>> + }
>> +
>> + Status = SpiFlashProtocol->Init (SpiFlashProtocol, SpiFlash);
>> + if (EFI_ERROR (Status)) {
>> + DEBUG ((DEBUG_ERROR, "%a: Cannot initialize flash device\n", __FUNCTION__));
>> + return Status;
>> + }
>> +
>> + return EFI_SUCCESS;
>> +}
>> +
>> +STATIC
>> +EFI_STATUS
>> +CheckImageHeader (
>> + IN OUT VOID *ImageBuffer
>> + )
>> +{
>> + MV_FIRMWARE_IMAGE_HEADER *Header;
>> + UINT32 HeaderLength, Checksum, ChecksumBackup;
>> +
>> + Header = (MV_FIRMWARE_IMAGE_HEADER *)ImageBuffer;
>> + HeaderLength = Header->PrologSize;
>> + ChecksumBackup = Header->PrologChecksum;
>> +
>> + // Compare magic number
>> + if (Header->Magic != MAIN_HDR_MAGIC) {
>> + DEBUG ((DEBUG_ERROR,
>> + "%a: Bad Image magic 0x%08x != 0x%08x\n",
>> + __FUNCTION__,
>> + Header->Magic,
>> + MAIN_HDR_MAGIC));
>> + return EFI_VOLUME_CORRUPTED;
>> + }
>> +
>> + // The checksum field is discarded from calculation
>> + Header->PrologChecksum = 0;
>> +
>> + Checksum = CalculateSum32 ((UINT32 *)Header, HeaderLength);
>> + if (Checksum != ChecksumBackup) {
>> + DEBUG ((DEBUG_ERROR,
>> + "%a: Bad Image checksum. 0x%x != 0x%x\n",
>> + __FUNCTION__,
>> + Checksum,
>> + ChecksumBackup));
>> + return EFI_VOLUME_CORRUPTED;
>> + }
>> +
>> + // Restore checksum backup
>> + Header->PrologChecksum = ChecksumBackup;
>> +
>> + return EFI_SUCCESS;
>> +}
>> +
>> +
>> +/**
>> + Perform flash write operation.
>> +
>> + @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
>> + )
>> +{
>> + EFI_STATUS Status;
>> + VOID *ImageBuffer;
>> + SPI_DEVICE *SpiFlash = NULL;
>> + BOOLEAN BufferAligned = TRUE;
>> +
>> + // Verify Firmware data
>> + if (FlashAddressType != FlashAddressTypeAbsoluteAddress) {
>> + DEBUG ((DEBUG_ERROR,
>> + "%a: only FlashAddressTypeAbsoluteAddress supported\n",
>> + __FUNCTION__));
>> +
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + if (FirmwareType != PlatformFirmwareTypeSystemFirmware) {
>> + DEBUG ((DEBUG_ERROR,
>> + "%a: only PlatformFirmwareTypeSystemFirmware supported\n",
>> + __FUNCTION__));
>> +
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + // Locate SPI protocols
>> + Status = gBS->LocateProtocol (&gMarvellSpiFlashProtocolGuid,
>> + NULL,
>> + (VOID **)&SpiFlashProtocol);
>> + if (EFI_ERROR (Status)) {
>> + DEBUG ((DEBUG_ERROR,
>> + "%a: Cannot locate SpiFlash protocol\n",
>> + __FUNCTION__));
>> + return Status;
>> + }
>> +
>> + Status = gBS->LocateProtocol (&gMarvellSpiMasterProtocolGuid,
>> + NULL,
>> + (VOID **)&SpiMasterProtocol);
>> + if (EFI_ERROR (Status)) {
>> + DEBUG ((DEBUG_ERROR,
>> + "%a: Cannot locate SpiMaster protocol\n",
>> + __FUNCTION__));
>> + return Status;
>> + }
>> +
>> + //
>> + // Counting checksum in the header verification requires
>> + // the buffer address alignment.
>> + // It is not guaranteed by the generic capsule handling code,
>> + // so use an auxiliary buffer in such case.
>> + //
>> + if (((UINTN) Buffer & 0x3) != 0) {
>> + ImageBuffer = AllocateCopyPool (Length, Buffer);
>> + if (ImageBuffer == NULL) {
>> + return EFI_OUT_OF_RESOURCES;
>> + }
>> + BufferAligned = FALSE;
>> + } else {
>> + ImageBuffer = Buffer;
>> + }
>> +
>> + // Check image checksum and magic
>> + Status = CheckImageHeader (ImageBuffer);
>> + if (EFI_ERROR (Status)) {
>> + goto HeaderError;
>> + }
>> +
>> + // Setup and probe SPI flash
>> + SpiFlash = SpiMasterProtocol->SetupDevice (SpiMasterProtocol,
>> + SpiFlash,
>> + PcdGet32 (PcdSpiFlashCs),
>> + PcdGet32 (PcdSpiFlashMode));
>> + if (SpiFlash == NULL) {
>> + DEBUG ((DEBUG_ERROR, "%a: Cannot allocate SPI device!\n", __FUNCTION__));
>> + Status = EFI_DEVICE_ERROR;
>> + goto HeaderError;
>> + }
>> +
>> + Status = SpiFlashProbe (SpiFlash);
>> + if (EFI_ERROR (Status)) {
>> + DEBUG ((DEBUG_ERROR,
>> + "%a: Error while performing SPI flash probe\n",
>> + __FUNCTION__));
>> + goto FlashProbeError;
>> + }
>> +
>> + // Update firmware image in flash at offset 0x0
>> + Status = SpiFlashProtocol->Update (SpiFlash, 0, Length, (UINT8 *)ImageBuffer);
>> + if (EFI_ERROR (Status)) {
>> + DEBUG ((DEBUG_ERROR,
>> + "%a: Error while performing flash update\n",
>> + __FUNCTION__));
>> + goto FlashProbeError;
>> + }
>> +
>> + DEBUG ((DEBUG_ERROR,
>> + "%a: Update %d bytes at offset 0x0 succeeded!\n",
>> + __FUNCTION__,
>> + Length));
>> +
>> + // Release resources
>> + SpiMasterProtocol->FreeDevice (SpiFlash);
>> +
>> + if (!BufferAligned) {
>> + FreePool (ImageBuffer);
>> + }
>> +
>> + return EFI_SUCCESS;
>> +
>> +FlashProbeError:
>> + SpiMasterProtocol->FreeDevice (SpiFlash);
>> +HeaderError:
>> + if (!BufferAligned) {
>> + FreePool (ImageBuffer);
>> + }
>> +
>> + return Status;
>> +}
>> diff --git a/Silicon/Marvell/Armada7k8k/Feature/Capsule/PlatformFlashAccessLib/PlatformFlashAccessLib.inf b/Silicon/Marvell/Armada7k8k/Feature/Capsule/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
>> new file mode 100644
>> index 0000000..fd94759
>> --- /dev/null
>> +++ b/Silicon/Marvell/Armada7k8k/Feature/Capsule/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
>> @@ -0,0 +1,52 @@
>> +## @file
>> +# Platform flash device access library.
>> +#
>> +# Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
>> +# Copyright (c) 2018, Marvell International, Ltd. 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 = 0x00010019
>> + BASE_NAME = PlatformFlashAccessLib
>> + FILE_GUID = c3f314d8-2995-4f0c-a8d6-e10298de4bde
>> + MODULE_TYPE = BASE
>> + VERSION_STRING = 1.0
>> + LIBRARY_CLASS = PlatformFlashAccessLib|DXE_DRIVER
>> +
>> +[Sources]
>> + PlatformFlashAccessLib.c
>> +
>> +[Packages]
>> + ArmPkg/ArmPkg.dec
>> + EmbeddedPkg/EmbeddedPkg.dec
>> + MdeModulePkg/MdeModulePkg.dec
>> + MdePkg/MdePkg.dec
>> + SignedCapsulePkg/SignedCapsulePkg.dec
>> + Silicon/Marvell/Marvell.dec
>> +
>> +[LibraryClasses]
>> + BaseLib
>> + BaseMemoryLib
>> + DebugLib
>> + DxeServicesTableLib
>> + MemoryAllocationLib
>> + PcdLib
>> + UefiBootServicesTableLib
>> + UefiLib
>> + UefiRuntimeServicesTableLib
>> +
>> +[Pcd]
>> + gMarvellTokenSpaceGuid.PcdSpiFlashCs
>> + gMarvellTokenSpaceGuid.PcdSpiFlashMode
>> +
>> +[Protocols]
>> + gMarvellSpiFlashProtocolGuid
>> + gMarvellSpiMasterProtocolGuid
>> diff --git a/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc b/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc
>> new file mode 100644
>> index 0000000..fbccdc2
>> --- /dev/null
>> +++ b/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc
>> @@ -0,0 +1,81 @@
>> +/** @file
>> + System Firmware descriptor.
>> +
>> + Copyright (c) 2018, Marvell International 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('M','V','E', 'B', 'U', '_', 'I', 'D')
>> +#define IMAGE_ID_STRING L"MvebuPlatform"
>> +
>> +// PcdSystemFmpCapsuleImageTypeIdGuid
>> +#define IMAGE_TYPE_ID_GUID { 0x757fc475, 0x6b22, 0x4482, { 0x86, 0x8e, 0xde, 0xd2, 0x86, 0xf3, 0x09, 0x40 } }
>> +
>> +typedef struct {
>> + EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR Descriptor;
>> + // real string data
>> + CHAR16 ImageIdNameStr[ARRAY_SIZE (IMAGE_ID_STRING)];
>> + CHAR16 VersionNameStr[ARRAY_SIZE (CURRENT_FIRMWARE_VERSION_STRING)];
>> + CHAR16 PackageVersionNameStr[ARRAY_SIZE (PACKAGE_VERSION_STRING)];
>> +} 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/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf b/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
>> new file mode 100644
>> index 0000000..e6967b2
>> --- /dev/null
>> +++ b/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
>> @@ -0,0 +1,50 @@
>> +## @file
>> +# System Firmware descriptor.
>> +#
>> +# Copyright (c) 2018, Marvell International 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 = 0x0001001A
>> + 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/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c b/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c
>> new file mode 100644
>> index 0000000..c55c4d9
>> --- /dev/null
>> +++ b/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c
>> @@ -0,0 +1,74 @@
>> +/** @file
>> + System Firmware descriptor producer.
>> +
>> + Copyright (c) 2018, Marvell International, Ltd. 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.
>> + ASSERT(FALSE);
>> + 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/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini b/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini
>> new file mode 100644
>> index 0000000..fb0bd0b
>> --- /dev/null
>> +++ b/Silicon/Marvell/Armada7k8k/Feature/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini
>> @@ -0,0 +1,26 @@
>> +## @file
>> +#
>> +# Copyright (c) 2018, Marvell International Ltd.<BR>
>> +# 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 = 1
>> +NumOfRecovery = 0
>> +Update0 = MvFvMain
>> +
>> +[MvFvMain]
>> +FirmwareType = 0 # SystemFirmware
>> +AddressType = 1 # 0 - relative address, 1 - absolute address.
>> +BaseAddress = 0x0 # Base address offset on flash
>> +Length = 0x00300000 # Length, need to fix the length
>> +ImageOffset = 0x00100000 # Image offset of this SystemFirmware image
>> +FileGuid = b3890e02-c46b-4970-9536-57787a9e06c7 # PcdEdkiiSystemFirmwareFileGuid
>> --
>> 2.7.4
>>
next prev parent reply other threads:[~2018-06-01 16:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-01 14:32 [platforms PATCH 0/4] Armada capsule support Marcin Wojtas
2018-06-01 14:32 ` [platforms PATCH 1/4] Marvell/Armada70x0Db: Shift main FV from 0x0 address Marcin Wojtas
2018-06-01 15:26 ` Ard Biesheuvel
2018-06-01 14:32 ` [platforms PATCH 2/4] Marvell/Aramda7k8k: Enable PEI booting stage Marcin Wojtas
2018-06-01 15:30 ` Ard Biesheuvel
2018-06-01 16:43 ` Marcin Wojtas
2018-06-01 16:57 ` Ard Biesheuvel
2018-06-01 17:18 ` Marcin Wojtas
2018-06-01 14:32 ` [platforms PATCH 3/4] Marvell/Armada7k8k: Introduce capsule FW update implementation Marcin Wojtas
2018-06-01 15:32 ` Ard Biesheuvel
2018-06-01 16:02 ` Marcin Wojtas [this message]
2018-06-01 16:08 ` Ard Biesheuvel
2018-06-01 16:20 ` Marcin Wojtas
2018-06-01 14:32 ` [platforms PATCH 4/4] Marvell/Armada7k8k: Wire up capsule support Marcin Wojtas
2018-06-01 15:34 ` [platforms PATCH 0/4] Armada " Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPv3WKeOrhe3B-z4+Uz26xKvU3Zb8bfdBShFT9YvWDAqRYOeJQ@mail.gmail.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox