forked from tianocore/edk2-platforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds the platform specific implemenation required for the capsule update as follows: * SystemFirmwareDescriptor, to determine the current firmware version. * SystemFirmwareUpdateConfig, to provide the inventory of components in the capsule. * PlatformFlashAccessLib, to implement flash write functions via Firmware Update MM services provided by Arm Trusted Firmware. Also, this connects the different modules to implement the signed capsule update. Below is the command to build capsule images: build -a AARCH64 -t GCC -b RELEASE \ -D SCP_IMAGE=path/to/the/jade_scp.slim \ -D UEFI_ATF_IMAGE=path/to/the/jade_tianocore_atf.img \ -p Platform/Ampere/JadePkg/JadeCapsule.dsc Signed-off-by: Nhi Pham <[email protected]>
- Loading branch information
Showing
12 changed files
with
853 additions
and
5 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** @file | ||
System Firmware descriptor. | ||
|
||
Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR> | ||
|
||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
|
||
**/ | ||
|
||
#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 0x00000001 | ||
#define CURRENT_FIRMWARE_VERSION_STRING L"0x00000001" | ||
#define LOWEST_SUPPORTED_FIRMWARE_VERSION 0x00000001 | ||
|
||
#define IMAGE_ID SIGNATURE_64('J', 'A', 'D', 'E', '_', 'F', 'W', ' ') | ||
#define IMAGE_ID_STRING L"Jade System Firmware" | ||
|
||
// PcdSystemFmpCapsuleImageTypeIdGuid | ||
#define IMAGE_TYPE_ID_GUID { 0xf08bca31, 0x542e, 0x4cea, { 0x8b, 0x48, 0x8e, 0x54, 0xf9, 0x42, 0x25, 0x94 } } | ||
|
||
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; | ||
|
||
STATIC 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 | ||
0, // 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; |
40 changes: 40 additions & 0 deletions
40
Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## @file | ||
# System Firmware descriptor. | ||
# | ||
# Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR> | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
[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] | ||
SystemFirmwareDescriptor.aslc | ||
SystemFirmwareDescriptorPei.c | ||
|
||
[Packages] | ||
ArmPkg/ArmPkg.dec | ||
MdeModulePkg/MdeModulePkg.dec | ||
MdePkg/MdePkg.dec | ||
SignedCapsulePkg/SignedCapsulePkg.dec | ||
|
||
[LibraryClasses] | ||
DebugLib | ||
PcdLib | ||
PeiServicesLib | ||
PeimEntryPoint | ||
|
||
[FixedPcd] | ||
|
||
[Pcd] | ||
gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor | ||
|
||
[Depex] | ||
TRUE |
74 changes: 74 additions & 0 deletions
74
Platform/Ampere/JadePkg/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** @file | ||
System Firmware descriptor producer. | ||
Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#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; | ||
} |
20 changes: 20 additions & 0 deletions
20
Platform/Ampere/JadePkg/Capsule/SystemFirmwareUpdateConfig/SCPFirmwareUpdateConfig.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## @file | ||
# | ||
# Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR> | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
[Head] | ||
NumOfUpdate = 1 | ||
NumOfRecovery = 0 | ||
Update0 = JadeSCP | ||
|
||
[JadeSCP] | ||
FirmwareType = 2147483649 # 0x80000001: SMpro/PMpro Firmware | ||
AddressType = 1 # 0 - relative address, 1 - absolute address. | ||
BaseAddress = 0x00000000 # Base address offset on flash | ||
Length = 0x00050000 # Length | ||
ImageOffset = 0x00000000 # Image offset of this SystemFirmware image | ||
FileGuid = 431c06ed-4fe2-438f-98a3-a9b1fd923019 # PcdEdkiiSystemFirmwareFileGuid |
20 changes: 20 additions & 0 deletions
20
Platform/Ampere/JadePkg/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## @file | ||
# | ||
# Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR> | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
[Head] | ||
NumOfUpdate = 1 | ||
NumOfRecovery = 0 | ||
Update0 = JadeUEFIATF | ||
|
||
[JadeUEFIATF] | ||
FirmwareType = 2147483650 # SystemFirmware: 0x80000002 - OEM UEFI and ARM Trusted Firmware | ||
AddressType = 1 # 0 - relative address, 1 - absolute address. | ||
BaseAddress = 0x00000000 # Base address offset on flash | ||
Length = 0x00D10000 # Length | ||
ImageOffset = 0x00000000 # Image offset of this SystemFirmware image | ||
FileGuid = 431c06ed-4fe2-438f-98a3-a9b1fd923019 # PcdEdkiiSystemFirmwareFileGuid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## @file | ||
# | ||
# Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR> | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
################################################################################ | ||
# | ||
# Defines Section - statements that will be processed to create a Makefile. | ||
# | ||
################################################################################ | ||
[Defines] | ||
PLATFORM_NAME = Jade | ||
PLATFORM_GUID = 34C87B13-434A-4767-88FB-2D0CD2AED46F | ||
PLATFORM_VERSION = 0.1 | ||
DSC_SPECIFICATION = 0x0001001B | ||
OUTPUT_DIRECTORY = Build/Jade | ||
SUPPORTED_ARCHITECTURES = AARCH64 | ||
BUILD_TARGETS = DEBUG|RELEASE | ||
SKUID_IDENTIFIER = DEFAULT | ||
FLASH_DEFINITION = Platform/Ampere/JadePkg/JadeCapsule.fdf | ||
|
||
# | ||
# Defines for default states. These can be changed on the command line. | ||
# -D FLAG=VALUE | ||
# | ||
DEFINE UEFI_ATF_IMAGE = Build/Jade/jade_tianocore_atf.img | ||
DEFINE SCP_IMAGE = Build/Jade/jade_scp.slim |
Oops, something went wrong.