[AMD Official Use Only - General]
> -Original Message-
> From: Zhai, MingXin (Duke)
> Sent: Friday, January 26, 2024 2:01 PM
> To: devel@edk2.groups.io
> Cc: Xing, Eric ; Zhai, MingXin (Duke)
> ; Fu, Igniculus ; Chang,
> Abner
> Subject: [PATCH V2 21/32] AMD/VanGoghBoard: Check in SignedCapsule
>
> From: Duke Zhai
>
> BZ #:4640
> In V2: Improve coding style.
> 1.Remove the leading underscore and use double underscore at trailing in C
> header files.
> 2.Remove old tianocore licenses and redundant license description.
> 3.Improve coding style. For example: remove space between @param.
>
> In V1:
> Initial SignedCapsule module for Signed Capsule.
> Produce FMP instance to update system firmware.
>
> Signed-off-by: Ken Yao
> Cc: Eric Xing
> Cc: Duke Zhai
> Cc: Igniculus Fu
> Cc: Abner Chang
> ---
> .../BaseTools/Source/Python/GenFds/Capsule.py | 253 +++
> .../SystemFirmwareUpdate/ParseConfigProfile.c | 231 +++
> .../SystemFirmwareCommonDxe.c | 371 +
> .../SystemFirmwareUpdate/SystemFirmwareDxe.h | 421 +
> .../SystemFirmwareUpdateDxe.c | 1426 +
> .../SystemFirmwareUpdateDxe.inf | 91 ++
> .../SystemFirmwareUpdateDxe.uni | 15 +
> .../SystemFirmwareUpdateDxeExtra.uni | 15 +
> 8 files changed, 2823 insertions(+)
> create mode 100644
> Platform/AMD/VanGoghBoard/Override/edk2/BaseTools/Source/Python/Ge
> nFds/Capsule.py
> create mode 100644
> Platform/AMD/VanGoghBoard/Override/edk2/SignedCapsulePkg/Universal/S
> ystemFirmwareUpdate/ParseConfigProfile.c
> create mode 100644
> Platform/AMD/VanGoghBoard/Override/edk2/SignedCapsulePkg/Universal/S
> ystemFirmwareUpdate/SystemFirmwareCommonDxe.c
> create mode 100644
> Platform/AMD/VanGoghBoard/Override/edk2/SignedCapsulePkg/Universal/S
> ystemFirmwareUpdate/SystemFirmwareDxe.h
> create mode 100644
> Platform/AMD/VanGoghBoard/Override/edk2/SignedCapsulePkg/Universal/S
> ystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
> create mode 100644
> Platform/AMD/VanGoghBoard/Override/edk2/SignedCapsulePkg/Universal/S
> ystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf
> create mode 100644
> Platform/AMD/VanGoghBoard/Override/edk2/SignedCapsulePkg/Universal/S
> ystemFirmwareUpdate/SystemFirmwareUpdateDxe.uni
> create mode 100644
> Platform/AMD/VanGoghBoard/Override/edk2/SignedCapsulePkg/Universal/S
> ystemFirmwareUpdate/SystemFirmwareUpdateDxeExtra.uni
>
> diff --git
> a/Platform/AMD/VanGoghBoard/Override/edk2/BaseTools/Source/Python/G
> enFds/Capsule.py
> b/Platform/AMD/VanGoghBoard/Override/edk2/BaseTools/Source/Python/G
> enFds/Capsule.py
> new file mode 100644
> index 00..0ec0b3ca43
> --- /dev/null
> +++
> b/Platform/AMD/VanGoghBoard/Override/edk2/BaseTools/Source/Python/G
> enFds/Capsule.py
> @@ -0,0 +1,253 @@
> +## @file
> +# generate capsule
> +#
> +# Copyright (C) 2024 Advanced Micro Devices, Inc.
> +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +
> +##
> +# Import Modules
> +#
> +from __future__ import absolute_import
> +from .GenFdsGlobalVariable import GenFdsGlobalVariable, FindExtendTool
> +from CommonDataClass.FdfClass import CapsuleClassObject
> +import Common.LongFilePathOs as os
> +from io import BytesIO
> +from Common.Misc import SaveFileOnChange, PackGUID
> +import uuid
> +from struct import pack
> +from Common import EdkLogger
> +from Common.BuildToolError import GENFDS_ERROR
> +from Common.DataType import TAB_LINE_BREAK
> +
> +WIN_CERT_REVISION = 0x0200
> +WIN_CERT_TYPE_EFI_GUID = 0x0EF1
> +EFI_CERT_TYPE_PKCS7_GUID = uuid.UUID('{4aafd29d-68df-49ee-8aa9-
> 347d375665a7}')
> +EFI_CERT_TYPE_RSA2048_SHA256_GUID = uuid.UUID('{a7717414-c616-
> 4977-9420-844712a735bf}')
> +
> +## create inf file describes what goes into capsule and call GenFv to
> generate
> capsule
> +#
> +#
> +class Capsule (CapsuleClassObject):
> +## The constructor
> +#
> +# @param selfThe object pointer
> +#
> +def __init__(self):
> +CapsuleClassObject.__init__(self)
> +# For GenFv
> +self.BlockSize = None
> +# For GenFv
> +self.BlockNum = None
> +self.CapsuleName = None
> +
> +## Generate FMP capsule
> +#
> +# @retval string Generated Capsule file path
> +#
> +def GenFmpCapsule(self):
> +#
> +# Generate capsule header
> +# typedef struct {
> +# EFI_GUID CapsuleGuid;
> +# UINT32HeaderSize;
> +# UINT32Flags;
> +# UINT32CapsuleImageSize;
> +# } EFI_CAPSULE_HEADER;
> +#
> +Header = BytesIO()
> +#
> +# Use FMP capsule GUID: 6DCBD5ED-E82D-4C44-BDA1-7194199AD92A
> +#
> +Header.write(PackGUID('6DCBD5ED-E82D-4C44-BDA1-
> 7194199AD92A'.split('-')))
> +HdrSize = 0
> +if