[edk2-devel] 回复: [edk2][PATCH V3] MdePkg : Add IPMI Macro and Structure Defintions to resolve build errors

2021-06-20 Thread gaoliming
Thanks for you update. 

Reviewed-by: Liming Gao 

Thanks
Liming
> -邮件原件-
> 发件人: manickavasakam karpagavinayagam 
> 发送时间: 2021年6月18日 23:38
> 收件人: devel@edk2.groups.io
> 抄送: isaac.w.o...@intel.com; nathaniel.l.desim...@intel.com;
> fel...@ami.com; harikrish...@ami.com; mani...@ami.com;
> zacha...@ami.com; manickavasak...@ami.com;
> gaolim...@byosoft.com.cn
> 主题: [edk2][PATCH V3] MdePkg : Add IPMI Macro and Structure Defintions
> to resolve build errors
> 
> Build error reported for missing structures
> IPMI_SET_BOOT_OPTIONS_RESPONSE,
> EFI_IPMI_MSG_GET_BMC_EXEC_RSP and
> macros EFI_FIRMWARE_GET_BMC_EXECUTION_CONTEXT
> EFI_FIRMWARE_BMC_IN_FULL_RUNTIME/EFI_FIRMWARE_BMC_IN_FORCE
> D_UPDATE_MODE
> when using
> edk2-platforms\Features\Intel\OutOfBandManagement\IpmiFeaturePkg
> 
> MdePkg : Rename IPMI Macro and Structure Defintions
> 
> Rename the EFI_IPMI_MSG_GET_BMC_EXEC_RSPB,
> EFI_FIRMWARE_GET_BMC_EXECUTION_CONTEXT
> EFI_FIRMWARE_BMC_IN_FORCED_UPDATE_MODE to
> IPMI_MSG_GET_BMC_EXEC_RSPB,IPMI_GET_BMC_EXECUTION_CONTEXT
> IPMI_BMC_IN_FORCED_UPDATE_MODE
> 
> Notes:
> V1 :
> Rename the EFI_IPMI_MSG_GET_BMC_EXEC_RSPB,
> EFI_FIRMWARE_GET_BMC_EXECUTION_CONTEXT
> EFI_FIRMWARE_BMC_IN_FORCED_UPDATE_MODE to
> IPMI_MSG_GET_BMC_EXEC_RSPB,IPMI_GET_BMC_EXECUTION_CONTEXT
> IPMI_BMC_IN_FORCED_UPDATE_MODE
> 
> V2:
> 
> Remove 0001-MdePkg-Add-IPMI-Macro-and-Structure-Defintions-to-re.patch
> 
> V3:
> 
> Add Signed-off-by information
> 
> Signed-off-by: Manickavasakam Karpagavinayagam
> 
> ---
>  .../IndustryStandard/IpmiNetFnChassis.h|  4 
>  .../IndustryStandard/IpmiNetFnFirmware.h   | 18
> ++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h
> b/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h
> index 79db55523d..d7cdd3a865 100644
> --- a/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h
> +++ b/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h
> @@ -186,6 +186,10 @@ typedef struct {
>UINT8  ParameterData[0];
> 
>  } IPMI_SET_BOOT_OPTIONS_REQUEST;
> 
> 
> 
> +typedef struct {
> 
> +  UINT8   CompletionCode:8;
> 
> +} IPMI_SET_BOOT_OPTIONS_RESPONSE;
> 
> +
> 
>  //
> 
>  //  Definitions for Get System Boot options command
> 
>  //
> 
> diff --git a/MdePkg/Include/IndustryStandard/IpmiNetFnFirmware.h
> b/MdePkg/Include/IndustryStandard/IpmiNetFnFirmware.h
> index 2d892dbd5a..c4cbe2349b 100644
> --- a/MdePkg/Include/IndustryStandard/IpmiNetFnFirmware.h
> +++ b/MdePkg/Include/IndustryStandard/IpmiNetFnFirmware.h
> @@ -17,4 +17,22 @@
>  // All Firmware commands and their structure definitions to follow here
> 
>  //
> 
> 
> 
> +//


> 
> +//Definitions for Get BMC Execution Context
> 
> +//


> 
> +#define IPMI_GET_BMC_EXECUTION_CONTEXT  0x23
> 
> +
> 
> +//
> 
> +//  Constants and Structure definitions for "Get Device ID" command to
> follow here
> 
> +//
> 
> +typedef struct {
> 
> +  UINT8   CurrentExecutionContext;
> 
> +  UINT8   PartitionPointer;
> 
> +} IPMI_MSG_GET_BMC_EXEC_RSP;
> 
> +
> 
> +//
> 
> +// Current Execution Context responses
> 
> +//
> 
> +#define IPMI_BMC_IN_FORCED_UPDATE_MODE  0x11
> 
> +
> 
>  #endif
> 
> --
> 2.25.0.windows.1
> 
> 
> Please consider the environment before printing this email.
> 
> The information contained in this message may be confidential and
> proprietary to American Megatrends (AMI).  This communication is intended
> to be read only by the individual or entity to whom it is addressed or by
their
> designee. If the reader of this message is not the intended recipient, you
are
> on notice that any distribution of this message, in any form, is strictly
> prohibited.  Please promptly notify the sender by reply e-mail or by
> telephone at 770-246-8600, and then delete or destroy all copies of the
> transmission.




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76797): https://edk2.groups.io/g/devel/message/76797
Mute This Topic: https://groups.io/mt/83679773/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




回复: [edk2-devel] [PATCH v6 0/2] CryptoPkg/OpensslLib: Add native instruction support for X64

2021-06-20 Thread gaoliming
Christopher:
  Nasm should support GCC tool chain. Do you meet with the problem on nasm
version assembly code?
  So, you have to add GAS assembly code. This topic may be discussed last
year. Can you give some detail for it?

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Christopher
> Zurcher
> 发送时间: 2021年6月19日 10:09
> 收件人: devel@edk2.groups.io
> 抄送: Jiewen Yao ; Jian J Wang
> ; Xiaoyu Lu ; Mike Kinney
> ; Ard Biesheuvel 
> 主题: [edk2-devel] [PATCH v6 0/2] CryptoPkg/OpensslLib: Add native
> instruction support for X64
> 
> From: Christopher Zurcher 
> 
> V6 Changes:
>   Add GCC-compatible version of these modifications. Supporting GCC build
of
> native OpenSSL .S files requires removal of *(COMMON) from the
> /DISCARD/
> section of the GCC linker script.
>   The VS/CLANG portion of the patch is unchanged from the
> previously-approved
> patchset.
> 
> V5 Changes:
>   Move ApiHooks.c into X64 folder
>   Update process_files.pl to clean architecture-specific subfolders
without
> removing them
>   Rebased INF file to merge latest changes regarding RngLib vs. TimerLib
> 
> V4 Changes:
>   Add copyright header to uefi-asm.conf
>   Move [Sources.X64] block to cover entire X64-specific config
> 
> V3 Changes:
>   Added definitions for ptrdiff_t and wchar_t to CrtLibSupport.h for
> LLVM/Clang build support.
>   Added -UWIN32 to GCC Flags for LLVM/Clang build support.
>   Added missing AES GCM assembly file.
> 
> V2 Changes:
>   Limit scope of assembly config to SHA and AES functions.
>   Removed IA32 native support (reduced config was causing build failure
and
> can be added in a later patch).
>   Removed XMM instructions from assembly generation.
>   Added automatic copyright header porting for generated assembly files.
> 
> This patch adds support for building the native instruction algorithms for
> the X64 architecture in OpensslLib. The process_files.pl script was
modified
> to parse the .asm file targets from the OpenSSL build config data struct,
and
> generate the necessary assembly files for the EDK2 build environment.
> 
> For the X64 variant, OpenSSL includes calls to a Windows error handling
API,
> and that function has been stubbed out in ApiHooks.c.
> 
> For all variants, a constructor is added to call the required CPUID
function
> within OpenSSL to facilitate processor capability checks in the native
> algorithms.
> 
> Additional native architecture variants should be simple to add by
following
> the changes made for this architecture.
> 
> The OpenSSL assembly files are traditionally generated at build time using
a
> perl script. To avoid that burden on EDK2 users, these end-result assembly
> files are generated during the configuration steps performed by the
package
> maintainer (through process_files.pl). The perl generator scripts inside
> OpenSSL do not parse file comments as they are only meant to create
> intermediate build files, so process_files.pl contains additional hooks to
> preserve the copyright headers as well as clean up tabs and line endings
to
> comply with EDK2 coding standards. The resulting file headers align with
> the generated .h files which are already included in the EDK2 repository.
> 
> Cc: Jiewen Yao 
> Cc: Jian J Wang 
> Cc: Xiaoyu Lu 
> Cc: Mike Kinney 
> Cc: Ard Biesheuvel 
> 
> Christopher Zurcher (2):
>   CryptoPkg/OpensslLib: Add native instruction support for X64
>   CryptoPkg/OpensslLib: Commit the auto-generated assembly files for X64
> 
>  BaseTools/Scripts/GccBase.lds
> |1 -
>  CryptoPkg/CryptoPkg.ci.yaml
> |   21 +-
>  CryptoPkg/Library/Include/CrtLibSupport.h
> |2 +
>  CryptoPkg/Library/Include/openssl/opensslconf.h
> |3 -
>  CryptoPkg/Library/OpensslLib/OpensslLib.inf
> |2 +-
>  CryptoPkg/Library/OpensslLib/OpensslLibConstructor.c
> |   44 +
>  CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
> |2 +-
>  CryptoPkg/Library/OpensslLib/OpensslLibX64.inf
> |  653 +++
>  CryptoPkg/Library/OpensslLib/OpensslLibX64Gcc.inf
> |  653 +++
>  CryptoPkg/Library/OpensslLib/UefiAsm.conf
> |   30 +
>  CryptoPkg/Library/OpensslLib/X64/ApiHooks.c
> |   22 +
>  CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-mb-x86_64.nasm
> |  732 +++
>  CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-sha1-x86_64.nasm
> | 1916 
>  CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-sha256-x86_64.nasm
> |   78 +
>  CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-x86_64.nasm
> | 5103 
>  CryptoPkg/Library/OpensslLib/X64/crypto/aes/vpaes-x86_64.nasm
> | 1173 +
>  CryptoPkg/Library/OpensslLib/X64/crypto/modes/aesni-gcm-x86_64.nasm
> |   34 +
>  CryptoPkg/Library/OpensslLib/X64/crypto/modes/ghash-x86_64.nasm
> | 1569 ++
>  CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha1-mb-x86_64.nasm
> | 3137 
>  CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha1-x86_64.nasm
> | 2884 +++
>  CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha256-mb-x86_64.nasm
> | 3461 +
>  CryptoPkg/Librar

Re: [edk2-devel] [PATCH v2 1/1] ArmPkg: Move cache defs used in Universal/Smbios into ArmCache.h

2021-06-20 Thread wenyi,xie via groups.io
OK,I will handle this later.

Thanks
Wenyi

On 2021/6/18 23:54, Leif Lindholm wrote:
> Agh. *Actually* cc Wenyi.
> 
> On Fri, Jun 18, 2021 at 16:53:38 +0100, Leif Lindholm wrote:
>> +Wenyi
>>
>> On Mon, Jun 14, 2021 at 12:57:49 -0600, Rebecca Cran wrote:
>>> Many of the cache definitions in ArmLibPrivate.h are being used outside
>>> of ArmLib, in Universal/Smbios. Move them into ArmCache.h to make them
>>> public, and remove the include of ArmLibPrivate.h from files in
>>> Universal/Smbios.
>>>
>>> Signed-off-by: Rebecca Cran 
>>
>> Reviewed-by: Leif Lindholm 
>> Pushed as a63914d3f603. Thanks!
>>
>> I will note that this change breaks Silicon/Hisilicon/Hi1616 and
>> Silicon/Hisilicon/Hi1620, which use some of the macros moved by this
>> patch.
>> However, I am unable to build these anyway with recent iasl/gcc.
>>
>> Wenyi: can you have a look at making these platforms build?
>> This will now also involve dropping use of
>> Library/ArmLib/ArmLibPrivate.h.
>>
>> /
>> Leif
>>
>>> ---
>>>  ArmPkg/Include/IndustryStandard/ArmCache.h  | 
>>> 112 ++
>>>  ArmPkg/Include/Library/ArmLib.h |  
>>> 36 +-
>>>  ArmPkg/Library/ArmLib/ArmLibPrivate.h   | 
>>> 123 
>>>  ArmPkg/Universal/Smbios/ProcessorSubClassDxe/ProcessorSubClass.c|  
>>>  2 +-
>>>  ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorAArch64.c   |  
>>>  2 +-
>>>  ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArm.c   |  
>>>  2 +-
>>>  ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c |  
>>>  2 +-
>>>  7 files changed, 148 insertions(+), 131 deletions(-)
>>>
>>> diff --git a/ArmPkg/Include/IndustryStandard/ArmCache.h 
>>> b/ArmPkg/Include/IndustryStandard/ArmCache.h
>>> new file mode 100644
>>> index ..f9de46b5bffd
>>> --- /dev/null
>>> +++ b/ArmPkg/Include/IndustryStandard/ArmCache.h
>>> @@ -0,0 +1,112 @@
>>> +/** @file
>>> +
>>> +  Copyright (c) 2020 - 2021, NUVIA Inc. All rights reserved.
>>> +
>>> +  SPDX-License-Identifier: BSD-2-Clause-Patent
>>> +
>>> +**/
>>> +
>>> +#ifndef ARM_CACHE_H_
>>> +#define ARM_CACHE_H_
>>> +
>>> +#include 
>>> +
>>> +// The ARM Architecture Reference Manual for ARMv8-A defines up
>>> +// to 7 levels of cache, L1 through L7.
>>> +#define MAX_ARM_CACHE_LEVEL   7
>>> +
>>> +/// Defines the structure of the CSSELR (Cache Size Selection) register
>>> +typedef union {
>>> +  struct {
>>> +UINT32InD   :1;  ///< Instruction not Data bit
>>> +UINT32Level :3;  ///< Cache level (zero based)
>>> +UINT32TnD   :1;  ///< Allocation not Data bit
>>> +UINT32Reserved  :27; ///< Reserved, RES0
>>> +  } Bits; ///< Bitfield definition of the register
>>> +  UINT32 Data; ///< The entire 32-bit value
>>> +} CSSELR_DATA;
>>> +
>>> +/// The cache type values for the InD field of the CSSELR register
>>> +typedef enum
>>> +{
>>> +  /// Select the data or unified cache
>>> +  CsselrCacheTypeDataOrUnified = 0,
>>> +  /// Select the instruction cache
>>> +  CsselrCacheTypeInstruction,
>>> +  CsselrCacheTypeMax
>>> +} CSSELR_CACHE_TYPE;
>>> +
>>> +/// Defines the structure of the CCSIDR (Current Cache Size ID) register
>>> +typedef union {
>>> +  struct {
>>> +UINT64LineSize   :3;  ///< Line size (Log2(Num bytes in 
>>> cache) - 4)
>>> +UINT64Associativity  :10; ///< Associativity - 1
>>> +UINT64NumSets:15; ///< Number of sets in the cache -1
>>> +UINT64Unknown:4;  ///< Reserved, UNKNOWN
>>> +UINT64Reserved   :32; ///< Reserved, RES0
>>> +  } BitsNonCcidx; ///< Bitfield definition of the register when FEAT_CCIDX 
>>> is not supported.
>>> +  struct {
>>> +UINT64LineSize   :3;  ///< Line size (Log2(Num bytes in 
>>> cache) - 4)
>>> +UINT64Associativity  :21; ///< Associativity - 1
>>> +UINT64Reserved1  :8;  ///< Reserved, RES0
>>> +UINT64NumSets:24; ///< Number of sets in the cache -1
>>> +UINT64Reserved2  :8;  ///< Reserved, RES0
>>> +  } BitsCcidxAA64; ///< Bitfield definition of the register when FEAT_IDX 
>>> is supported.
>>> +  struct {
>>> +UINT64LineSize   : 3;
>>> +UINT64Associativity  : 21;
>>> +UINT64Reserved   : 8;
>>> +UINT64Unallocated: 32;
>>> +  } BitsCcidxAA32;
>>> +  UINT64 Data; ///< The entire 64-bit value
>>> +} CCSIDR_DATA;
>>> +
>>> +/// Defines the structure of the AARCH32 CCSIDR2 register.
>>> +typedef union {
>>> +  struct {
>>> +UINT32 NumSets   :24; ///< Number of sets in the cache - 1
>>> +UINT32 Reserved  :8;  ///< Reserved, RES0
>>> +  } Bits; ///< Bitfield definition of the register
>>> +  UINT32 Data; ///< The entire 32-bit value
>>> +} CCSIDR2_DATA;
>>> +
>>> +/** Defines the structure of the CLIDR (Cache Level ID

回复: [edk2-devel] [PATCH v1 1/2] MdePkg: MmConfiguration: Moved EFI_MM_RESERVED_MMRAM_REGION to PiMmCis.h

2021-06-20 Thread gaoliming
Kun:
  There is one header file edk2\MdePkg\Include\PiMultiPhase.h for this
purpose. Can you place the common definition to it?

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Kun Qin
> 发送时间: 2021年6月18日 17:48
> 收件人: devel@edk2.groups.io
> 抄送: Michael D Kinney ; Liming Gao
> ; Zhiguang Liu ;
> Michael Kubacki 
> 主题: [edk2-devel] [PATCH v1 1/2] MdePkg: MmConfiguration: Moved
> EFI_MM_RESERVED_MMRAM_REGION to PiMmCis.h
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3440
> 
> The definition of EFI_MM_RESERVED_MMRAM_REGION, according to PI Spec
> 1.5
> is also referenced in EFI_PEI_MM_CONFIGURATION_PPI. Defining this
> structure as is will enforce any potential usage of MM Configuration PPI
> interface to include .
> 
> This change moves EFI_MM_RESERVED_MMRAM_REGION definition into
> PiMmCis.h,
> which is already included in Protocol/MmConfiguration.h. It also paves
> way for introducing Ppi/MmConfiguration.h with proper dependency.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Cc: Michael Kubacki 
> 
> Signed-off-by: Kun Qin 
> ---
>  MdePkg/Include/Pi/PiMmCis.h   | 16 
>  MdePkg/Include/Protocol/MmConfiguration.h | 16 
>  2 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/MdePkg/Include/Pi/PiMmCis.h b/MdePkg/Include/Pi/PiMmCis.h
> index fdf0591a03d6..422a3ea6c2bb 100644
> --- a/MdePkg/Include/Pi/PiMmCis.h
> +++ b/MdePkg/Include/Pi/PiMmCis.h
> @@ -242,6 +242,22 @@ VOID
>IN CONST EFI_MM_ENTRY_CONTEXT  *MmEntryContext
>);
> 
> +///
> +/// Structure describing a MMRAM region which cannot be used for the
> MMRAM heap.
> +///
> +typedef struct _EFI_MM_RESERVED_MMRAM_REGION {
> +  ///
> +  /// Starting address of the reserved MMRAM area, as it appears while
> MMRAM is open.
> +  /// Ignored if MmramReservedSize is 0.
> +  ///
> +  EFI_PHYSICAL_ADDRESSMmramReservedStart;
> +  ///
> +  /// Number of bytes occupied by the reserved MMRAM area. A size of
> zero indicates the
> +  /// last MMRAM area.
> +  ///
> +  UINT64  MmramReservedSize;
> +} EFI_MM_RESERVED_MMRAM_REGION;
> +
>  ///
>  /// Management Mode System Table (MMST)
>  ///
> diff --git a/MdePkg/Include/Protocol/MmConfiguration.h
> b/MdePkg/Include/Protocol/MmConfiguration.h
> index eeb94f64bdf7..d2fb6a13d4af 100644
> --- a/MdePkg/Include/Protocol/MmConfiguration.h
> +++ b/MdePkg/Include/Protocol/MmConfiguration.h
> @@ -21,22 +21,6 @@
>  0x26eeb3de, 0xb689, 0x492e, {0x80, 0xf0, 0xbe, 0x8b, 0xd7, 0xda,
0x4b,
> 0xa7 }  \
>}
> 
> -///
> -/// Structure describing a MMRAM region which cannot be used for the
> MMRAM heap.
> -///
> -typedef struct _EFI_MM_RESERVED_MMRAM_REGION {
> -  ///
> -  /// Starting address of the reserved MMRAM area, as it appears while
> MMRAM is open.
> -  /// Ignored if MmramReservedSize is 0.
> -  ///
> -  EFI_PHYSICAL_ADDRESSMmramReservedStart;
> -  ///
> -  /// Number of bytes occupied by the reserved MMRAM area. A size of
> zero indicates the
> -  /// last MMRAM area.
> -  ///
> -  UINT64  MmramReservedSize;
> -} EFI_MM_RESERVED_MMRAM_REGION;
> -
>  typedef struct _EFI_MM_CONFIGURATION_PROTOCOL
> EFI_MM_CONFIGURATION_PROTOCOL;
> 
>  /**
> --
> 2.31.1.windows.1
> 
> 
> 
> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76794): https://edk2.groups.io/g/devel/message/76794
Mute This Topic: https://groups.io/mt/83679481/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




回复: [edk2-devel] [PATCH] MdePkg/Include: Smbios Specification 3.4.0 changes

2021-06-20 Thread gaoliming
Gopi:

 Can you highlight this change in the commit message? Do you find any platform 
is required to be updated for this update?

 

Thanks

Liming

发件人: Thotala, Gopi  
发送时间: 2021年6月17日 11:53
收件人: gaoliming ; devel@edk2.groups.io; 'Rebecca Cran' 

主题: RE: [edk2-devel] [PATCH] MdePkg/Include: Smbios Specification 3.4.0 changes

 

These changes were requested in smbios spec version 3.4.0.

 

>From smbios specs 3.4.0 table 51 – BIT 5&6.  This field is moved from specific 
>MemoryArrayLocationCXLFlexbus10AddonCard to generic 
>MemoryArrayLocationCXLAddonCard to address both CXL1.0 and 2.0 CXL 
>revisions.(including backward compatible, not specific to CXL1.0)

 

>From smbios specs 3.4.0 table 79.  The memory technology name changed from 
>MemoryTechnologyIntelPersistentMemory to 
>MemoryTechnologyIntelOptanePersistentMemory.

 

Attached smbios specs here for reference.

 

 

From: gaoliming mailto:gaolim...@byosoft.com.cn> > 
Sent: Wednesday, June 16, 2021 7:10 PM
To: devel@edk2.groups.io  ; Thotala, Gopi 
mailto:gopi.thot...@intel.com> >; 'Rebecca Cran' 
mailto:rebe...@bsdio.com> >
Subject: 回复: [edk2-devel] [PATCH] MdePkg/Include: Smbios Specification 3.4.0 
changes

 

Gopi:

 Could you let me know why changes below field name?

 

MemoryArrayLocationCXLFlexbus10AddonCard ==> MemoryArrayLocationCXLAddonCard

MemoryTechnologyIntelPersistentMemory ==> 
MemoryTechnologyIntelOptanePersistentMemory

 

Thanks

Liming

发件人: devel@edk2.groups.io   mailto:devel@edk2.groups.io> > 代表 Thotala, Gopi
发送时间: 2021年6月14日 23:40
收件人: Rebecca Cran mailto:rebe...@bsdio.com> >; 
devel@edk2.groups.io  
主题: Re: [edk2-devel] [PATCH] MdePkg/Include: Smbios Specification 3.4.0 changes

 

Attached V2 patch after typo correction.

 

Thanks

Gopi

 

From: Rebecca Cran mailto:rebe...@bsdio.com> > 
Sent: Sunday, June 13, 2021 9:34 AM
To: devel@edk2.groups.io  ; Thotala, Gopi 
mailto:gopi.thot...@intel.com> >
Subject: Re: [edk2-devel] [PATCH] MdePkg/Include: Smbios Specification 3.4.0 
changes

 

There’s a typo of ‘persistent’ in: 

 

// Optane DC Presistent Memory in SMBIOS spec 3.4.0

 

Rebecca Cran

 

 

On Jun 2, 2021, at 10:46 AM, Thotala, Gopi mailto:gopi.thot...@intel.com> > wrote:

 

Initial patch submitted for review.



 

 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76793): https://edk2.groups.io/g/devel/message/76793
Mute This Topic: https://groups.io/mt/83679240/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] 回复: [PATCH v3] BaseTools GenFw: Add support for RISCV GOT/PLT relocations

2021-06-20 Thread gaoliming
Reviewed-by: Liming Gao 

> -邮件原件-
> 发件人: Sunil V L 
> 发送时间: 2021年6月17日 13:57
> 收件人: devel@edk2.groups.io
> 抄送: Sunil V L ; Abner Chang
> ; Daniel Schaefer ; Bob
> Feng ; Liming Gao ;
> Yuwei Chen ; Heinrich Schuchardt
> 
> 主题: [PATCH v3] BaseTools GenFw: Add support for RISCV GOT/PLT
> relocations
> 
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3096
> 
> This patch adds support for R_RISCV_CALL_PLT and R_RISCV_GOT_HI20
> relocations generated by PIE enabled compiler. This also needed
> changes to R_RISCV_32 and R_RISCV_64 relocations as explained in
> https://github.com/riscv/riscv-gnu-toolchain/issues/905#issuecomment-8466
> 82710
> 
> Changes in v3:
>   - Added the comments to address Liming's feedback.
> 
> Changes in v2:
>   - Addressed Daniel's comment on formatting
> 
> Testing:
> 1) Debian GCC 8.3.0 and booted sifive_u and QMEU virt models.
> 2) Debian 10.2.0 and booted QEMU virt model.
> 3) riscv-gnu-tool chain 9.2 and booted QEMU virt model.
> 
> Signed-off-by: Sunil V L 
> 
> Acked-by: Abner Chang 
> Reviewed-by: Daniel Schaefer 
> Tested-by: Daniel Schaefer 
> 
> Cc: Bob Feng 
> Cc: Liming Gao 
> Cc: Yuwei Chen 
> Cc: Heinrich Schuchardt 
> ---
>  BaseTools/Source/C/GenFw/Elf64Convert.c | 58
> ++---
>  1 file changed, 52 insertions(+), 6 deletions(-)
> 
> diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c
> b/BaseTools/Source/C/GenFw/Elf64Convert.c
> index d097db8632..310ad38f90 100644
> --- a/BaseTools/Source/C/GenFw/Elf64Convert.c
> +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
> @@ -129,6 +129,8 @@ STATIC UINT32 mDebugOffset;
>  STATIC UINT8   *mRiscVPass1Targ = NULL;
> 
>  STATIC Elf_Shdr*mRiscVPass1Sym = NULL;
> 
>  STATIC Elf64_Half  mRiscVPass1SymSecIndex = 0;
> 
> +STATIC INT32   mRiscVPass1Offset;
> 
> +STATIC INT32   mRiscVPass1GotFixup;
> 
> 
> 
>  //
> 
>  // Initialization Function
> 
> @@ -479,11 +481,11 @@ WriteSectionRiscV64 (
>  break;
> 
> 
> 
>case R_RISCV_32:
> 
> -*(UINT32 *)Targ = (UINT32)((UINT64)(*(UINT32 *)Targ) -
> SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx]);
> 
> +*(UINT64 *)Targ = Sym->st_value + Rel->r_addend;
> 
>  break;
> 
> 
> 
>case R_RISCV_64:
> 
> -*(UINT64 *)Targ = *(UINT64 *)Targ - SymShdr->sh_addr +
> mCoffSectionsOffset[Sym->st_shndx];
> 
> +*(UINT64 *)Targ = Sym->st_value + Rel->r_addend;
> 
>  break;
> 
> 
> 
>case R_RISCV_HI20:
> 
> @@ -533,6 +535,18 @@ WriteSectionRiscV64 (
>  mRiscVPass1SymSecIndex = 0;
> 
>  break;
> 
> 
> 
> +  case R_RISCV_GOT_HI20:
> 
> +Value = (Sym->st_value - Rel->r_offset);
> 
> +mRiscVPass1Offset = RV_X(Value, 0, 12);
> 
> +Value = RV_X(Value, 12, 20);
> 
> +*(UINT32 *)Targ = (Value << 12) | (RV_X(*(UINT32*)Targ, 0, 12));
> 
> +
> 
> +mRiscVPass1Targ = Targ;
> 
> +mRiscVPass1Sym = SymShdr;
> 
> +mRiscVPass1SymSecIndex = Sym->st_shndx;
> 
> +mRiscVPass1GotFixup = 1;
> 
> +break;
> 
> +
> 
>case R_RISCV_PCREL_HI20:
> 
>  mRiscVPass1Targ = Targ;
> 
>  mRiscVPass1Sym = SymShdr;
> 
> @@ -545,11 +559,17 @@ WriteSectionRiscV64 (
>  if (mRiscVPass1Targ != NULL && mRiscVPass1Sym != NULL &&
> mRiscVPass1SymSecIndex != 0) {
> 
>int i;
> 
>Value2 = (UINT32)(RV_X(*(UINT32 *)mRiscVPass1Targ, 12, 20));
> 
> -  Value = (UINT32)(RV_X(*(UINT32 *)Targ, 20, 12));
> 
> -  if(Value & (RISCV_IMM_REACH/2)) {
> 
> -Value |= ~(RISCV_IMM_REACH-1);
> 
> +
> 
> +  if(mRiscVPass1GotFixup) {
> 
> +Value = (UINT32)(mRiscVPass1Offset);
> 
> +  } else {
> 
> +Value = (UINT32)(RV_X(*(UINT32 *)Targ, 20, 12));
> 
> +if(Value & (RISCV_IMM_REACH/2)) {
> 
> +  Value |= ~(RISCV_IMM_REACH-1);
> 
> +}
> 
>}
> 
>Value = Value - (UINT32)mRiscVPass1Sym->sh_addr +
> mCoffSectionsOffset[mRiscVPass1SymSecIndex];
> 
> +
> 
>if(-2048 > (INT32)Value) {
> 
>  i = (((INT32)Value * -1) / 4096);
> 
>  Value2 -= i;
> 
> @@ -569,12 +589,35 @@ WriteSectionRiscV64 (
>  }
> 
>}
> 
> 
> 
> -  *(UINT32 *)Targ = (RV_X(Value, 0, 12) << 20) |
(RV_X(*(UINT32*)Targ,
> 0, 20));
> 
> +  if(mRiscVPass1GotFixup) {
> 
> +*(UINT32 *)Targ = (RV_X((UINT32)Value, 0, 12) << 20)
> 
> +| (RV_X(*(UINT32*)Targ, 0, 20));
> 
> +// Convert LD instruction to ADDI
> 
> +//
> 
> +// |31  20|19  15|14  12|11   7|6   0|
> 
> +// |-|
> 
> +// |imm[11:0] | rs1  | 011  |  rd  | 011 | LD
> 
> +//  -
> 
> +
> 
> +// |-|
> 
> +// |imm[11:0] | rs1  | 000  |  rd  | 0010011 | ADDI
> 
> +//  -
> 
> +
> 
> +// To convert, let's first reset bits 12-14 and 0-6 using ~0x707f
> 
> +// Then modify the opcode to ADDI (0010011)
> 
> +  

[edk2-devel] [PATCH v6 1/2] CryptoPkg/OpensslLib: Add native instruction support for X64

2021-06-20 Thread Christopher Zurcher
From: Christopher Zurcher 

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2507

Adding OpensslLibX64.inf and modifying process_files.pl to process this
file and generate the necessary assembly files.
Adding OpensslLibX64Gcc.inf to allow building with GCC toolchain.
ApiHooks.c contains a stub function for a Windows API call.
uefi-asm.conf contains the limited assembly configurations for OpenSSL.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Mike Kinney 
Cc: Ard Biesheuvel 
Signed-off-by: Christopher Zurcher 
---
 BaseTools/Scripts/GccBase.lds|   1 -
 CryptoPkg/CryptoPkg.ci.yaml  |  21 +-
 CryptoPkg/Library/Include/CrtLibSupport.h|   2 +
 CryptoPkg/Library/Include/openssl/opensslconf.h  |   3 -
 CryptoPkg/Library/OpensslLib/OpensslLib.inf  |   2 +-
 CryptoPkg/Library/OpensslLib/OpensslLibConstructor.c |  44 ++
 CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf|   2 +-
 CryptoPkg/Library/OpensslLib/OpensslLibX64.inf   | 653 
 CryptoPkg/Library/OpensslLib/OpensslLibX64Gcc.inf| 653 
 CryptoPkg/Library/OpensslLib/UefiAsm.conf|  30 +
 CryptoPkg/Library/OpensslLib/X64/ApiHooks.c  |  22 +
 CryptoPkg/Library/OpensslLib/process_files.pl| 241 ++--
 12 files changed, 1619 insertions(+), 55 deletions(-)

diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds
index a9dd2138d4..83cebd29d5 100644
--- a/BaseTools/Scripts/GccBase.lds
+++ b/BaseTools/Scripts/GccBase.lds
@@ -74,6 +74,5 @@ SECTIONS {
 *(.dynamic)
 *(.hash .gnu.hash)
 *(.comment)
-*(COMMON)
   }
 }
diff --git a/CryptoPkg/CryptoPkg.ci.yaml b/CryptoPkg/CryptoPkg.ci.yaml
index 5d7c340ae5..1448299073 100644
--- a/CryptoPkg/CryptoPkg.ci.yaml
+++ b/CryptoPkg/CryptoPkg.ci.yaml
@@ -7,7 +7,11 @@
 ##
 {
 "LicenseCheck": {
-"IgnoreFiles": []
+"IgnoreFiles": [
+# These directories contain auto-generated OpenSSL content
+"Library/OpensslLib/X64",
+"Library/OpensslLib/X64Gcc"
+]
 },
 "EccCheck": {
 ## Exception sample looks like below:
@@ -23,8 +27,13 @@
 "Test/UnitTest",
 # This has OpenSSL interfaces that aren't UEFI spec compliant
 "Library/BaseCryptLib/SysCall/UnitTestHostCrtWrapper.c",
-# this has OpenSSL interfaces that aren't UEFI spec compliant
-"Library/OpensslLib/rand_pool.c"
+# This has OpenSSL interfaces that aren't UEFI spec compliant
+"Library/OpensslLib/rand_pool.c",
+# This has OpenSSL interfaces that aren't UEFI spec compliant
+"Library/Include/CrtLibSupport.h",
+# These directories contain auto-generated OpenSSL content
+"Library/OpensslLib/X64",
+"Library/OpensslLib/X64Gcc"
 ]
 },
 "CompilerPlugin": {
@@ -51,7 +60,11 @@
 },
 "DscCompleteCheck": {
 "DscPath": "CryptoPkg.dsc",
-"IgnoreInf": []
+"IgnoreInf": [
+# These are alternatives to OpensslLib.inf
+"CryptoPkg/Library/OpensslLib/OpensslLibX64.inf",
+"CryptoPkg/Library/OpensslLib/OpensslLibX64Gcc.inf"
+]
 },
 "GuidCheck": {
 "IgnoreGuidName": [],
diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h 
b/CryptoPkg/Library/Include/CrtLibSupport.h
index b1dff03bdc..17d7f29ba2 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -102,6 +102,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 //
 typedef UINTN  size_t;
 typedef UINTN  u_int;
+typedef INTN   ptrdiff_t;
 typedef INTN   ssize_t;
 typedef INT32  time_t;
 typedef UINT8  __uint8_t;
@@ -109,6 +110,7 @@ typedef UINT8  sa_family_t;
 typedef UINT8  u_char;
 typedef UINT32 uid_t;
 typedef UINT32 gid_t;
+typedef CHAR16 wchar_t;
 
 //
 // File operations are not required for EFI building,
diff --git a/CryptoPkg/Library/Include/openssl/opensslconf.h 
b/CryptoPkg/Library/Include/openssl/opensslconf.h
index e5652be5ca..b8d59aebe8 100644
--- a/CryptoPkg/Library/Include/openssl/opensslconf.h
+++ b/CryptoPkg/Library/Include/openssl/opensslconf.h
@@ -112,9 +112,6 @@ extern "C" {
 #ifndef OPENSSL_NO_ASAN
 # define OPENSSL_NO_ASAN
 #endif
-#ifndef OPENSSL_NO_ASM
-# define OPENSSL_NO_ASM
-#endif
 #ifndef OPENSSL_NO_ASYNC
 # define OPENSSL_NO_ASYNC
 #endif
diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf 
b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
index b00bb74ce6..d84bde056a 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
@@ -16,7 +16,7 @@
   VERSION_STRING = 1.0
   LIBRARY_CLASS  = OpensslLib
   DEFINE OPENSSL_PATH= openssl
-  DEFINE OPENSSL_FLAGS   = -DL_ENDIAN -DOPENSSL_SMALL_FOOTP

[edk2-devel] [PATCH] NetworkPkg: Addressed static code analyzer issues

2021-06-20 Thread INDIA\sivaramann
Issue on the PxeBcDhcp4CallBack() functions of UEFIPXEBC Driver.
In this function allowed events are Dhcp4RcvdOffer, Dhcp4SelectOffer,
Dhcp4SendDiscover, Dhcp4RcvdAck. If any other event comes as input
it will exit in beginning itself.

Later below switch case handling the default case which is not reachable.
I assume this code is a not reachable code and can be removed

Signed-off-by: Sivaraman 
---
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
index fb63cf61a9..c0d8211ea0 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
@@ -1331,8 +1331,6 @@ PxeBcDhcp4CallBack (
 }
 break;
 
-  default:
-break;
   }
 
   return Status;
-- 
2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76788): https://edk2.groups.io/g/devel/message/76788
Mute This Topic: https://groups.io/mt/83671978/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v6 0/2] CryptoPkg/OpensslLib: Add native instruction support for X64

2021-06-20 Thread Christopher Zurcher
From: Christopher Zurcher 

V6 Changes:
  Add GCC-compatible version of these modifications. Supporting GCC build of
native OpenSSL .S files requires removal of *(COMMON) from the /DISCARD/
section of the GCC linker script.
  The VS/CLANG portion of the patch is unchanged from the previously-approved
patchset.

V5 Changes:
  Move ApiHooks.c into X64 folder
  Update process_files.pl to clean architecture-specific subfolders without
removing them
  Rebased INF file to merge latest changes regarding RngLib vs. TimerLib

V4 Changes:
  Add copyright header to uefi-asm.conf
  Move [Sources.X64] block to cover entire X64-specific config

V3 Changes:
  Added definitions for ptrdiff_t and wchar_t to CrtLibSupport.h for
LLVM/Clang build support.
  Added -UWIN32 to GCC Flags for LLVM/Clang build support.
  Added missing AES GCM assembly file.

V2 Changes:
  Limit scope of assembly config to SHA and AES functions.
  Removed IA32 native support (reduced config was causing build failure and
can be added in a later patch).
  Removed XMM instructions from assembly generation.
  Added automatic copyright header porting for generated assembly files.

This patch adds support for building the native instruction algorithms for
the X64 architecture in OpensslLib. The process_files.pl script was modified
to parse the .asm file targets from the OpenSSL build config data struct, and
generate the necessary assembly files for the EDK2 build environment.

For the X64 variant, OpenSSL includes calls to a Windows error handling API,
and that function has been stubbed out in ApiHooks.c.

For all variants, a constructor is added to call the required CPUID function
within OpenSSL to facilitate processor capability checks in the native
algorithms.

Additional native architecture variants should be simple to add by following
the changes made for this architecture.

The OpenSSL assembly files are traditionally generated at build time using a
perl script. To avoid that burden on EDK2 users, these end-result assembly
files are generated during the configuration steps performed by the package
maintainer (through process_files.pl). The perl generator scripts inside
OpenSSL do not parse file comments as they are only meant to create
intermediate build files, so process_files.pl contains additional hooks to
preserve the copyright headers as well as clean up tabs and line endings to
comply with EDK2 coding standards. The resulting file headers align with
the generated .h files which are already included in the EDK2 repository.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Mike Kinney 
Cc: Ard Biesheuvel 

Christopher Zurcher (2):
  CryptoPkg/OpensslLib: Add native instruction support for X64
  CryptoPkg/OpensslLib: Commit the auto-generated assembly files for X64

 BaseTools/Scripts/GccBase.lds|1 -
 CryptoPkg/CryptoPkg.ci.yaml  |   21 +-
 CryptoPkg/Library/Include/CrtLibSupport.h|2 +
 CryptoPkg/Library/Include/openssl/opensslconf.h  |3 -
 CryptoPkg/Library/OpensslLib/OpensslLib.inf  |2 +-
 CryptoPkg/Library/OpensslLib/OpensslLibConstructor.c |   44 +
 CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf|2 +-
 CryptoPkg/Library/OpensslLib/OpensslLibX64.inf   |  653 +++
 CryptoPkg/Library/OpensslLib/OpensslLibX64Gcc.inf|  653 +++
 CryptoPkg/Library/OpensslLib/UefiAsm.conf|   30 +
 CryptoPkg/Library/OpensslLib/X64/ApiHooks.c  |   22 +
 CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-mb-x86_64.nasm |  732 +++
 CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-sha1-x86_64.nasm   | 1916 

 CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-sha256-x86_64.nasm |   78 +
 CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-x86_64.nasm| 5103 

 CryptoPkg/Library/OpensslLib/X64/crypto/aes/vpaes-x86_64.nasm| 1173 
+
 CryptoPkg/Library/OpensslLib/X64/crypto/modes/aesni-gcm-x86_64.nasm  |   34 +
 CryptoPkg/Library/OpensslLib/X64/crypto/modes/ghash-x86_64.nasm  | 1569 
++
 CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha1-mb-x86_64.nasm  | 3137 

 CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha1-x86_64.nasm | 2884 
+++
 CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha256-mb-x86_64.nasm| 3461 
+
 CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha256-x86_64.nasm   | 3313 
+
 CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha512-x86_64.nasm   | 1938 

 CryptoPkg/Library/OpensslLib/X64/crypto/x86_64cpuid.nasm |  491 ++
 CryptoPkg/Library/OpensslLib/X64Gcc/crypto/aes/aesni-mb-x86_64.S |  552 +++
 CryptoPkg/Library/OpensslLib/X64Gcc/crypto/aes/aesni-sha1-x86_64.S   | 1719 
+++
 CryptoPkg/Library/OpensslL

[edk2-devel] [PATCH 12/12] UefiPayloadPkg: Add PcdResetOnMemoryTypeInformationChange in UefiPayloadPkg

2021-06-20 Thread Zhiguang Liu
This PCD will be consumed by Universal Payload

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 930831d30c..f1bf80bc6d 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -362,6 +362,7 @@
 

 
 [PcdsDynamicExDefault]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76787): https://edk2.groups.io/g/devel/message/76787
Mute This Topic: https://groups.io/mt/83669568/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 11/12] UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol feature in UefiPayloadPkg

2021-06-20 Thread Zhiguang Liu
To install ACPI SDT protocol, define PcdInstallAcpiSdtProtocol as TRUE.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 

Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 99b0e49d46..930831d30c 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -290,6 +290,8 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
+  ## This PCD specified whether ACPI SDT protocol is installed.
+  gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 
 [PcdsFixedAtBuild]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x1
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76786): https://edk2.groups.io/g/devel/message/76786
Mute This Topic: https://groups.io/mt/83669566/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 10/12] UefiPayloadPkg: Add macro to disable some drivers

2021-06-20 Thread Zhiguang Liu
Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 11 ++-
 UefiPayloadPkg/UefiPayloadPkg.fdf |  7 +++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 155aea4bc4..99b0e49d46 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -87,6 +87,12 @@
   #
   DEFINE SHELL_TYPE   = BUILD_SHELL
 
+  #
+  # Disable features
+  #
+  DEFINE DISABLE_VARIABLE  = FALSE
+  DEFINE DISABLE_RESET_SYSTEM  = FALSE
+
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
   GCC:*_UNIXGCC_*_CC_FLAGS   = -DMDEPKG_NDEBUG
@@ -431,10 +437,13 @@
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+!if $(DISABLE_RESET_SYSTEM) == FALSE
   MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+!endif
   PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
+!if $(DISABLE_VARIABLE) == FALSE
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
-
+!endif
   #
   # Following are the DXE drivers
   #
diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf 
b/UefiPayloadPkg/UefiPayloadPkg.fdf
index 6073f9c1b4..3b6adc2cfe 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -105,9 +105,16 @@ INF 
MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
 INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
 INF 
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+
+!if $(DISABLE_RESET_SYSTEM) == FALSE
 INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+!endif
+
 INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
+
+!if $(DISABLE_VARIABLE) == FALSE
 INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+!endif
 
 INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
 INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76785): https://edk2.groups.io/g/devel/message/76785
Mute This Topic: https://groups.io/mt/83669565/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 09/12] UefiPayloadPkg: Remove assert when reserve MMIO/IO resource for devices

2021-06-20 Thread Zhiguang Liu
Some boot loader may already reserve MMIO/IO resource for IOAPIC and HPET,
so remove the assert when reserve MMIO/IO resource for IOAPIC and HPET

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c 
b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
index ffd3427fb3..04e968a232 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
@@ -41,13 +41,12 @@ ReserveResourceInGcd (
 );
 if (EFI_ERROR (Status)) {
   DEBUG ((
-DEBUG_ERROR,
+DEBUG_WARN,
 "Failed to add memory space :0x%lx 0x%lx\n",
 BaseAddress,
 Length
 ));
 }
-ASSERT_EFI_ERROR (Status);
 Status = gDS->AllocateMemorySpace (
 EfiGcdAllocateAddress,
 GcdType,
@@ -57,14 +56,20 @@ ReserveResourceInGcd (
 ImageHandle,
 NULL
 );
-ASSERT_EFI_ERROR (Status);
   } else {
 Status = gDS->AddIoSpace (
 GcdType,
 BaseAddress,
 Length
 );
-ASSERT_EFI_ERROR (Status);
+if (EFI_ERROR (Status)) {
+  DEBUG ((
+DEBUG_WARN,
+"Failed to add IO space :0x%lx 0x%lx\n",
+BaseAddress,
+Length
+));
+}
 Status = gDS->AllocateIoSpace (
 EfiGcdAllocateAddress,
 GcdType,
@@ -74,7 +79,6 @@ ReserveResourceInGcd (
 ImageHandle,
 NULL
 );
-ASSERT_EFI_ERROR (Status);
   }
   return Status;
 }
@@ -106,11 +110,9 @@ BlDxeEntryPoint (
   //
   // Report MMIO/IO Resources
   //
-  Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 
0xFEC0, SIZE_4KB, 0, ImageHandle); // IOAPIC
-  ASSERT_EFI_ERROR (Status);
+  ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC0, 
SIZE_4KB, 0, ImageHandle); // IOAPIC
 
-  Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 
0xFED0, SIZE_1KB, 0, ImageHandle); // HPET
-  ASSERT_EFI_ERROR (Status);
+  ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED0, 
SIZE_1KB, 0, ImageHandle); // HPET
 
   //
   // Find the frame buffer information and update PCDs
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76784): https://edk2.groups.io/g/devel/message/76784
Mute This Topic: https://groups.io/mt/83669563/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 06/12] UefiPayloadPkg: Get and enter DxeCore for Universal Payload

2021-06-20 Thread Zhiguang Liu
>From gUniversalPayloadExtraDataGuid Guid Hob, get the Dxe FV information,
and get the Dxe Core from the FV.
Also, make sure if there are muliple FV hob, the FV hob pointing to this FV
will be the first in the hob list.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c | 47 
+++
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h| 17 
+
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c   | 44 
++--
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf |  1 +
 UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c |  4 ++--
 5 files changed, 109 insertions(+), 4 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c 
b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
index de9dbb0b0e..f5d70c59f8 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
@@ -305,3 +305,50 @@ LoadDxeCore (
 
   return EFI_SUCCESS;
 }
+
+/**
+  Find DXE core from FV and build DXE core HOBs.
+
+  @param[in]   DxeFv The FV where to find the DXE core.
+  @param[out]  DxeCoreEntryPoint DXE core entry point
+
+  @retval EFI_SUCCESSIf it completed successfully.
+  @retval EFI_NOT_FOUND  If it failed to load DXE FV.
+**/
+EFI_STATUS
+UniversalLoadDxeCore (
+  IN  EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
+  OUT PHYSICAL_ADDRESS   *DxeCoreEntryPoint
+  )
+{
+  EFI_STATUS  Status;
+  EFI_FFS_FILE_HEADER *FileHeader;
+  VOID*PeCoffImage;
+  EFI_PHYSICAL_ADDRESSImageAddress;
+  UINT64  ImageSize;
+
+  //
+  // Find DXE core file from DXE FV
+  //
+  Status = FvFindFile (DxeFv, EFI_FV_FILETYPE_DXE_CORE, &FileHeader);
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  Status = FileFindSection (FileHeader, EFI_SECTION_PE32, (VOID 
**)&PeCoffImage);
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  //
+  // Get DXE core info
+  //
+  Status = LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize, 
DxeCoreEntryPoint);
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  BuildModuleHob (&FileHeader->Name, ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) 
ImageSize) * EFI_PAGE_SIZE, *DxeCoreEntryPoint);
+
+  return EFI_SUCCESS;
+}
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index e9c3ec3073..35098f5141 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -33,6 +33,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define LEGACY_8259_MASK_REGISTER_MASTER  0x21
 #define LEGACY_8259_MASK_REGISTER_SLAVE   0xA1
@@ -117,6 +119,21 @@ LoadDxeCore (
   OUT PHYSICAL_ADDRESS*DxeCoreEntryPoint
   );
 
+/**
+  Find DXE core from FV and build DXE core HOBs.
+
+  @param[in]   DxeFv The FV where to find the DXE core.
+  @param[out]  DxeCoreEntryPoint DXE core entry point
+
+  @retval EFI_SUCCESSIf it completed successfully.
+  @retval EFI_NOT_FOUND  If it failed to load DXE FV.
+**/
+EFI_STATUS
+UniversalLoadDxeCore (
+  IN  EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
+  OUT PHYSICAL_ADDRESS   *DxeCoreEntryPoint
+  );
+
 /**
Transfers control to DxeCore.
 
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
index 66e87bcb9b..9d59454486 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -179,7 +179,8 @@ FindAnotherHighestBelow4GResourceDescriptor (
 **/
 EFI_STATUS
 BuildHobs (
-  IN UINTN BootloaderParameter
+  IN  UINTN   BootloaderParameter,
+  OUT EFI_FIRMWARE_VOLUME_HEADER  **DxeFv
   )
 {
   EFI_PEI_HOB_POINTERS Hob;
@@ -190,6 +191,10 @@ BuildHobs (
   EFI_PHYSICAL_ADDRESS MemoryTop;
   EFI_HOB_RESOURCE_DESCRIPTOR  *PhitResourceHob;
   EFI_HOB_RESOURCE_DESCRIPTOR  *ResourceHob;
+  UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;
+  UINT8*GuidHob;
+  EFI_HOB_FIRMWARE_VOLUME  *FvHob;
+  UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
 
   Hob.Raw = (UINT8 *) BootloaderParameter;
   MinimalNeededSize = FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
@@ -254,6 +259,10 @@ BuildHobs (
   // From now on, mHobList will point to the new Hob range.
   //
 
+  //
+  // Create an empty FvHob for the DXE FV that contains DXE core.
+  //
+  BuildFvHob ((EFI_PHYSICAL_ADDRESS) 0, 0);
   //
   // Since payload created new Hob, move all hobs except PHIT from boot loader 
hob list.
   //
@@ -265,6 +274,29 @@ BuildHobs (
 Hob.Raw = GET_NEXT_HOB (Hob);
   }
 
+  //
+  // Get DXE FV location
+  //
+  GuidHob = GetFirs

[edk2-devel] [PATCH 07/12] UefiPayloadPkg: Fix up UPL Pcd database

2021-06-20 Thread Zhiguang Liu
Edk2 bootloader will pass the pei pcd database, and UPL also contain a
PCD database.
Dxe PCD driver has the assumption that the two PCD database can be
catenated and the local token number should be successive。
This patch will manually fix up the UPL PCD database to meet that
assumption.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c | 18 
--
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h| 45 
+
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c   | 55 
+++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf |  2 ++
 UefiPayloadPkg/UefiPayloadPkg.dec |  2 ++
 UefiPayloadPkg/UefiPayloadPkg.dsc |  1 +
 6 files changed, 117 insertions(+), 6 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c 
b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
index f5d70c59f8..f943a2632c 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
@@ -114,20 +114,23 @@ LoadPeCoffImage (
 }

 

 /**

-  This function searchs a given file type within a valid FV.

+  This function searchs a given file type with a given Guid within a valid FV.

+  If input Guid is NULL, will locate the first section having the given file 
type

 

   @param FvHeaderA pointer to firmware volume header that contains the 
set of files

  to be searched.

   @param FileTypeFile type to be searched.

+  @param GuidWill ignore if it is NULL.

   @param FileHeader  A pointer to the discovered file, if successful.

 

   @retval EFI_SUCCESSSuccessfully found FileType

   @retval EFI_NOT_FOUND  File type can't be found.

 **/

 EFI_STATUS

-FvFindFile (

+FvFindFileByTypeGuid (

   IN  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader,

   IN  EFI_FV_FILETYPE FileType,

+  IN  EFI_GUID*Guid   OPTIONAL,

   OUT EFI_FFS_FILE_HEADER **FileHeader

   )

 {

@@ -172,7 +175,10 @@ FvFindFile (
 //

 if (File->Type == FileType) {

   *FileHeader = File;

-  return EFI_SUCCESS;

+  if (Guid == NULL || CompareGuid(&File->Name, Guid)) {

+*FileHeader = File;

+return EFI_SUCCESS;

+  }

 }

   }

 

@@ -266,7 +272,7 @@ LoadDxeCore (
   //

   // DXE FV is inside Payload FV. Here find DXE FV from Payload FV

   //

-  Status = FvFindFile (PayloadFv, EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, 
&FileHeader);

+  Status = FvFindFileByTypeGuid (PayloadFv, 
EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, NULL, &FileHeader);

   if (EFI_ERROR (Status)) {

 return Status;

   }

@@ -283,7 +289,7 @@ LoadDxeCore (
   //

   // Find DXE core file from DXE FV

   //

-  Status = FvFindFile (DxeCoreFv, EFI_FV_FILETYPE_DXE_CORE, &FileHeader);

+  Status = FvFindFileByTypeGuid (DxeCoreFv, EFI_FV_FILETYPE_DXE_CORE, NULL, 
&FileHeader);

   if (EFI_ERROR (Status)) {

 return Status;

   }

@@ -330,7 +336,7 @@ UniversalLoadDxeCore (
   //

   // Find DXE core file from DXE FV

   //

-  Status = FvFindFile (DxeFv, EFI_FV_FILETYPE_DXE_CORE, &FileHeader);

+  Status = FvFindFileByTypeGuid (DxeFv, EFI_FV_FILETYPE_DXE_CORE, NULL, 
&FileHeader);

   if (EFI_ERROR (Status)) {

 return Status;

   }

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index 35098f5141..78a67fa1a5 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -35,6 +35,7 @@
 #include 

 #include 

 #include 

+#include 

 

 #define LEGACY_8259_MASK_REGISTER_MASTER  0x21

 #define LEGACY_8259_MASK_REGISTER_SLAVE   0xA1

@@ -149,4 +150,48 @@ HandOffToDxeCore (
   IN EFI_PEI_HOB_POINTERS   HobList

   );

 

+EFI_STATUS

+FixUpPcdDatabase (

+  IN  EFI_FIRMWARE_VOLUME_HEADER *DxeFv

+  );

+

+/**

+  This function searchs a given section type within a valid FFS file.

+

+  @param  FileHeaderA pointer to the file header that contains the 
set of sections to

+be searched.

+  @param  SearchTypeThe value of the section type to search.

+  @param  SectionData   A pointer to the discovered section, if 
successful.

+

+  @retval EFI_SUCCESS   The section was found.

+  @retval EFI_NOT_FOUND The section was not found.

+

+**/

+EFI_STATUS

+FileFindSection (

+  IN EFI_FFS_FILE_HEADER*FileHeader,

+  IN EFI_SECTION_TYPE   SectionType,

+  OUT VOID  **SectionData

+  );

+

+/**

+  This function searchs a given file type with a given Guid within a valid FV.

+  If input Guid is NULL, will locate the first section having the given file 
type

+

+  @param FvHeaderA pointer to firmware volu

[edk2-devel] [PATCH 05/12] UefiPayloadPkg: Create separate Payload Entry for UniversalPayload

2021-06-20 Thread Zhiguang Liu
This patch create the UniversalPayload Entry based on the UefiPayload
Entry. It implements the logic to find a proper memory range to create the
new Hob and migrate the Hobs from Bootloader.
To make the change history clear, the logic to get the DxeCore will be in
the next patch.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c   | 311 
+++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf |  91 
+++
 2 files changed, 402 insertions(+)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
new file mode 100644
index 00..66e87bcb9b
--- /dev/null
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -0,0 +1,311 @@
+/** @file
+
+  Copyright (c) 2021, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "UefiPayloadEntry.h"
+
+#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT  
   | \
+   EFI_RESOURCE_ATTRIBUTE_INITIALIZED  
   | \
+   EFI_RESOURCE_ATTRIBUTE_TESTED   
   | \
+   EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED   
   | \
+   EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED  
   | \
+   
EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED | \
+   
EFI_RESOURCE_ATTRIBUTE_READ_ONLY_PROTECTED | \
+   EFI_RESOURCE_ATTRIBUTE_16_BIT_IO
   | \
+   EFI_RESOURCE_ATTRIBUTE_32_BIT_IO
   | \
+   EFI_RESOURCE_ATTRIBUTE_64_BIT_IO
   | \
+   EFI_RESOURCE_ATTRIBUTE_PERSISTENT   
   )
+
+#define TESTED_MEMORY_ATTRIBUTES  (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
+   EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
+   EFI_RESOURCE_ATTRIBUTE_TESTED  )
+
+extern VOID  *mHobList;
+
+/**
+  Add HOB into HOB list
+
+  @param[in]  HobThe HOB to be added into the HOB list.
+**/
+VOID
+AddNewHob (
+  IN EFI_PEI_HOB_POINTERS*Hob
+  )
+{
+  EFI_PEI_HOB_POINTERSNewHob;
+
+  if (Hob->Raw == NULL) {
+return;
+  }
+  NewHob.Header = CreateHob (Hob->Header->HobType, Hob->Header->HobLength);
+
+  if (NewHob.Header != NULL) {
+CopyMem (NewHob.Header + 1, Hob->Header + 1, Hob->Header->HobLength - 
sizeof (EFI_HOB_GENERIC_HEADER));
+  }
+}
+
+/**
+  Found the Resource Descriptor HOB that contains a range
+
+  @param[in] Base   Memory start address
+  @param[in] TopMemory Top.
+
+  @return The pointer to the Resource Descriptor HOB.
+**/
+EFI_HOB_RESOURCE_DESCRIPTOR *
+FindResourceDescriptorByRange (
+  VOID  *HobList,
+  EFI_PHYSICAL_ADDRESS  Base,
+  EFI_PHYSICAL_ADDRESS  Top
+  )
+{
+  EFI_PEI_HOB_POINTERS Hob;
+  EFI_HOB_RESOURCE_DESCRIPTOR  *ResourceHob;
+
+  for (Hob.Raw = (UINT8 *) HobList; !END_OF_HOB_LIST(Hob); Hob.Raw = 
GET_NEXT_HOB(Hob)) {
+//
+// Skip all HOBs except Resource Descriptor HOBs
+//
+if (GET_HOB_TYPE (Hob) != EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
+  continue;
+}
+
+//
+// Skip Resource Descriptor HOBs that do not describe tested system memory
+//
+ResourceHob = Hob.ResourceDescriptor;
+if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
+  continue;
+}
+if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != 
TESTED_MEMORY_ATTRIBUTES) {
+  continue;
+}
+
+//
+// Skip Resource Descriptor HOBs that do not contain the PHIT range 
EfiFreeMemoryBottom..EfiFreeMemoryTop
+//
+if (Base < ResourceHob->PhysicalStart) {
+  continue;
+}
+if (Top > (ResourceHob->PhysicalStart + ResourceHob->ResourceLength)) {
+  continue;
+}
+return ResourceHob;
+  }
+  return NULL;
+}
+
+/**
+  Find the highest below 4G memory resource descriptor, except the input 
Resource Descriptor.
+
+  @param[in] HobList Hob start address
+  @param[in] MinimalNeededSize   Minimal needed size.
+  @param[in] ExceptResourceHob   Ignore this Resource Descriptor.
+
+  @return The pointer to the Resource Descriptor HOB.
+**/
+EFI_HOB_RESOURCE_DESCRIPTOR *
+FindAnotherHighestBelow4GResourceDescriptor (
+  IN VOID*HobLi

[edk2-devel] [PATCH 04/12] UefiPayloadPkg: Update the function definition of HobConstructor

2021-06-20 Thread Zhiguang Liu
Update the function defination of HobConstructor to align the Phit Hob
structure.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c| 26 
+-
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c |  5 +
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 16 
 3 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c 
b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
index 23a749edf1..768c3db770 100644
--- a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
+++ b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
@@ -39,14 +39,14 @@ GetHobList (
 /**
   Build a Handoff Information Table HOB
 
-  This function initialize a HOB region from EfiMemoryBegin with length
-  EfiMemoryLength. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
+  This function initialize a HOB region from EfiMemoryBegin to
+  EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
   be inside the HOB region.
 
-  @param[in] EfiMemoryBegin   Total memory start address
-  @param[in] EfiMemoryLength  Total memory length reported in handoff HOB.
-  @param[in] EfiFreeMemoryBottom  Free memory start address
-  @param[in] EfiFreeMemoryTop Free memory end address.
+  @param[in] EfiMemoryBottom   Total memory start address
+  @param[in] EfiMemoryTop  Total memory end address.
+  @param[in] EfiFreeMemoryBottom   Free memory start address
+  @param[in] EfiFreeMemoryTop  Free memory end address.
 
   @return   The pointer to the handoff HOB table.
 
@@ -54,8 +54,8 @@ GetHobList (
 EFI_HOB_HANDOFF_INFO_TABLE*
 EFIAPI
 HobConstructor (
-  IN VOID   *EfiMemoryBegin,
-  IN UINTN  EfiMemoryLength,
+  IN VOID   *EfiMemoryBottom,
+  IN VOID   *EfiMemoryTop,
   IN VOID   *EfiFreeMemoryBottom,
   IN VOID   *EfiFreeMemoryTop
   )
@@ -77,11 +77,11 @@ HobConstructor (
   Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
   Hob->BootMode= BOOT_WITH_FULL_CONFIGURATION;
 
-  Hob->EfiMemoryTop= (UINTN)EfiMemoryBegin + EfiMemoryLength;
-  Hob->EfiMemoryBottom = (UINTN)EfiMemoryBegin;
-  Hob->EfiFreeMemoryTop= (UINTN)EfiFreeMemoryTop;
-  Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd+1);
-  Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
+  Hob->EfiMemoryTop= (EFI_PHYSICAL_ADDRESS) EfiMemoryTop;
+  Hob->EfiMemoryBottom = (EFI_PHYSICAL_ADDRESS) EfiMemoryBottom;
+  Hob->EfiFreeMemoryTop= (EFI_PHYSICAL_ADDRESS) EfiFreeMemoryTop;
+  Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) (HobEnd+1);
+  Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
 
   mHobList = Hob;
   return Hob;
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 8c6f7e326f..4308936d63 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -382,7 +382,6 @@ PayloadEntry (
   PHYSICAL_ADDRESS  DxeCoreEntryPoint;
   EFI_HOB_HANDOFF_INFO_TABLE*HandoffHobTable;
   UINTN MemBase;
-  UINTN MemSize;
   UINTN HobMemBase;
   UINTN HobMemTop;
   EFI_PEI_HOB_POINTERS  Hob;
@@ -401,9 +400,7 @@ PayloadEntry (
   HobMemBase = ALIGN_VALUE (MemBase + PcdGet32 (PcdPayloadFdMemSize), 
SIZE_1MB);
   HobMemTop  = HobMemBase + FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
 
-  // DXE core assumes the memory below HOB region could be used, so include 
the FV region memory into HOB range.
-  MemSize= HobMemTop - MemBase;
-  HandoffHobTable = HobConstructor ((VOID *)MemBase, MemSize, (VOID 
*)HobMemBase, (VOID *)HobMemTop);
+  HobConstructor ((VOID *)MemBase, (VOID *)HobMemTop, (VOID *)HobMemBase, 
(VOID *)HobMemTop);
 
   // Build HOB based on information from Bootloader
   Status = BuildHobFromBl ();
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index a4c9da128e..e9c3ec3073 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -83,14 +83,14 @@ UpdateStackHob (
 /**
   Build a Handoff Information Table HOB
 
-  This function initialize a HOB region from EfiMemoryBegin with length
-  EfiMemoryLength. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
+  This function initialize a HOB region from EfiMemoryBegin to
+  EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
   be inside the HOB region.
 
-  @param[in] EfiMemoryBegin   Total memory start address
-  @param[in] EfiMemoryLength  Total memory length reported in handoff HOB.
-  @param[in] EfiFreeMemoryBottom  Free memory start address
-  @param[in] EfiFreeMemoryTop Free memory end address.
+  @param[in] EfiMemoryBottom

[edk2-devel] [PATCH 08/12] UefiPayloadPkg: Include UniversalPayLoad modules in UefiPayloadPkg.dsc

2021-06-20 Thread Zhiguang Liu
Add a new macro "UNIVERSAL_PAYLOAD" to build Universal Payload.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 

Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 22 ++
 UefiPayloadPkg/UefiPayloadPkg.fdf |  3 ++-
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index e3d669a6d6..155aea4bc4 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -196,7 +196,11 @@
   TimerLib|UefiPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
   ResetSystemLib|UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf
   
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
+!if $(UNIVERSAL_PAYLOAD) == TRUE
+  
PlatformHookLib|UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf
+!else
   PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf
+!endif
   
PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
   IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf
 
@@ -213,10 +217,12 @@
   DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
 !endif
   
PlatformSupportLib|UefiPayloadPkg/Library/PlatformSupportLibNull/PlatformSupportLibNull.inf
-!if $(BOOTLOADER) == "COREBOOT"
-  BlParseLib|UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf
-!else
-  BlParseLib|UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
+!if $(UNIVERSAL_PAYLOAD) == FALSE
+  !if $(BOOTLOADER) == "COREBOOT"
+BlParseLib|UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf
+  !else
+BlParseLib|UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
+  !endif
 !endif
 
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
@@ -383,10 +389,18 @@
 
 !if "IA32" in $(ARCH)
   [Components.IA32]
+  !if $(UNIVERSAL_PAYLOAD) == TRUE
+UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+  !else
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+  !endif
 !else
   [Components.X64]
+  !if $(UNIVERSAL_PAYLOAD) == TRUE
+UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+  !else
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+  !endif
 !endif
 
 [Components.X64]
diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf 
b/UefiPayloadPkg/UefiPayloadPkg.fdf
index ed7fbcaddb..6073f9c1b4 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -52,8 +52,9 @@ READ_STATUS= TRUE
 READ_LOCK_CAP  = TRUE
 READ_LOCK_STATUS   = TRUE
 
+!if $(UNIVERSAL_PAYLOAD) == FALSE
 INF UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
-
+!endif
 FILE FV_IMAGE = 4E35FD93-9C72-4c15-8C4B-E77F1DB2D793 {
 SECTION FV_IMAGE = DXEFV
 }
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76783): https://edk2.groups.io/g/devel/message/76783
Mute This Topic: https://groups.io/mt/83669562/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 02/12] MdeModulePkg: Add new structure for the Universal Payload Serial Port Info

2021-06-20 Thread Zhiguang Liu
Add Universal Payload Serial Port Info definition header file according to
Universal Payload's documentation as below:
https://universalpayload.github.io/documentation/

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Ray Ni 
Signed-off-by: Zhiguang Liu 
---
 MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h | 30 
++
 MdeModulePkg/MdeModulePkg.dec  |  3 +++
 2 files changed, 33 insertions(+)

diff --git a/MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h 
b/MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h
new file mode 100644
index 00..87181f7634
--- /dev/null
+++ b/MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h
@@ -0,0 +1,30 @@
+/** @file
+  This file defines the structure for serial port info.
+
+  Copyright (c) 2021, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Revision Reference:
+- Universal Payload Specification 0.75 
(https://universalpayload.github.io/documentation/)
+**/
+
+#ifndef UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_H_
+#define UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_H_
+
+#include 
+
+#pragma pack(1)
+typedef struct {
+  UNIVERSAL_PAYLOAD_GENERIC_HEADER   Header;
+  BOOLEANUseMmio;
+  UINT8  RegisterStride;
+  UINT32 BaudRate;
+  EFI_PHYSICAL_ADDRESS   RegisterBase;
+} UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO;
+#pragma pack()
+
+#define UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION 1
+
+extern GUID gUniversalPayloadSerialPortInfoGuid;
+
+#endif //  UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_H_
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 10602a8f79..ad84421cf3 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -422,6 +422,9 @@
   ## Include/UniversalPayload/ExtraData.h
   gUniversalPayloadExtraDataGuid = {0x15a5baf6, 0x1c91, 0x467d, {0x9d, 0xfb, 
0x31, 0x9d, 0x17, 0x8d, 0x4b, 0xb4}}
 
+  ## Include/UniversalPayload/SerialPortInfo.h
+  gUniversalPayloadSerialPortInfoGuid = { 0xaa7e190d, 0xbe21, 0x4409, { 0x8e, 
0x67, 0xa2, 0xcd, 0xf, 0x61, 0xe1, 0x70 } }
+
 [Ppis]
   ## Include/Ppi/AtaController.h
   gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 
0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76777): https://edk2.groups.io/g/devel/message/76777
Mute This Topic: https://groups.io/mt/83669553/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 00/12] Enable Universal Payload in UefiPayloadPkg

2021-06-20 Thread Zhiguang Liu
This whole patch set will enable some basic feature of Universal Payload
in UefiPayloadPkg.

Zhiguang Liu (12):
  UefiPayloadPkg: Add HobLib for UniversalPayload
  MdeModulePkg: Add new structure for the Universal Payload Serial Port
Info
  UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload
  UefiPayloaPkg: Update the function definition of HobConstructor
  UefiPayloadPkg: Create separate Payload Entry for UniversalPayload
  UefiPayloadPkg: Get and enter DxeCore for Universal Payload
  UefiPayloadPkg: Fix up UPL Pcd database
  UefiPayloadPkg: Include UniversalPayLoad modules in UefiPayloadPkg.dsc
  UefiPayloadPkg: Remove assert when reserve MMIO/IO resource for
devices
  UefiPayloadPkg: Add macro to disable some drivers
  UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol feature in
UefiPayloadPkg
  UefiPayloadPkg: Add PcdResetOnMemoryTypeInformationChange in
UefiPayloadPkg

 MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h |  
30 ++
 MdeModulePkg/MdeModulePkg.dec  |   
3 +++
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c |  
20 +++-
 UefiPayloadPkg/Include/Library/DxeHobListLib.h |  
27 +++
 UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf |  
40 
 UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni |  
17 +
 UefiPayloadPkg/Library/DxeHobLib/HobLib.c  | 
597 
+
 UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c   |  
66 ++
 UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf |  
35 +++
 UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.c   |  
20 
 UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf |  
28 
 UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/Hob.c|  
28 ++--
 UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/HobLib.inf   |   
2 +-
 UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c   |  
82 
++
 UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf |  
41 +
 UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c  |  
63 ++-
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c |   
5 +
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h |  
78 
++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c| 
406 
++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf  |  
94 
++
 UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c  |   
4 ++--
 UefiPayloadPkg/UefiPayloadPkg.dec  |   
2 ++
 UefiPayloadPkg/UefiPayloadPkg.dsc  |  
52 +++-
 UefiPayloadPkg/UefiPayloadPkg.fdf  |  
10 +-
 24 files changed, 1697 insertions(+), 53 deletions(-)
 create mode 100644 MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h
 create mode 100644 UefiPayloadPkg/Include/Library/DxeHobListLib.h
 create mode 100644 UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
 create mode 100644 UefiPayloadPkg/Library/DxeH

[edk2-devel] [PATCH 03/12] UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload

2021-06-20 Thread Zhiguang Liu
Add a new separate PlatformHookLib for Universal Payload to consume Guid
Hob gUniversalPayloadSerialPortInfoGuid to get serial port information

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c   | 
82 
++
 UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf | 
41 +
 2 files changed, 123 insertions(+)

diff --git 
a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c 
b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c
new file mode 100644
index 00..6705f29505
--- /dev/null
+++ b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c
@@ -0,0 +1,82 @@
+/** @file
+  Platform Hook Library instance for UART device.
+
+  Copyright (c) 2021, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+  Performs platform specific initialization required for the CPU to access
+  the hardware associated with a SerialPortLib instance.  This function does
+  not initialize the serial port hardware itself.  Instead, it initializes
+  hardware devices that are required for the CPU to access the serial port
+  hardware.  This function may be called more than once.
+
+  @retval RETURN_SUCCESS   The platform specific initialization succeeded.
+  @retval RETURN_DEVICE_ERROR  The platform specific initialization could not 
be completed.
+
+**/
+RETURN_STATUS
+EFIAPI
+PlatformHookSerialPortInitialize (
+  VOID
+  )
+{
+  RETURN_STATUS   Status;
+  UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO  *SerialPortInfo;
+  UINT8   *GuidHob;
+  UNIVERSAL_PAYLOAD_GENERIC_HEADER*GenericHeader;
+
+  GuidHob = GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid);
+  if (GuidHob == NULL) {
+return EFI_NOT_FOUND;
+  }
+
+  GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA 
(GuidHob);
+  if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE 
(GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) {
+return EFI_NOT_FOUND;
+  }
+
+  if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION) {
+SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB_DATA 
(GuidHob);
+if (GenericHeader->Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD 
(UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO, RegisterBase)) {
+  //
+  // Return if can't find the Serial Port Info Hob with enough length
+  //
+  return EFI_NOT_FOUND;
+}
+
+Status = PcdSetBoolS (PcdSerialUseMmio, SerialPortInfo->UseMmio);
+if (RETURN_ERROR (Status)) {
+  return Status;
+}
+Status = PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterBase);
+if (RETURN_ERROR (Status)) {
+  return Status;
+}
+Status = PcdSet32S (PcdSerialRegisterStride, 
SerialPortInfo->RegisterStride);
+if (RETURN_ERROR (Status)) {
+  return Status;
+}
+Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate);
+if (RETURN_ERROR (Status)) {
+  return Status;
+}
+Status = PcdSet64S (PcdUartDefaultBaudRate, SerialPortInfo->BaudRate);
+if (RETURN_ERROR (Status)) {
+  return Status;
+}
+
+return RETURN_SUCCESS;
+  }
+
+  return EFI_NOT_FOUND;
+}
diff --git 
a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf 
b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf
new file mode 100644
index 00..41e05ddf54
--- /dev/null
+++ b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf
@@ -0,0 +1,41 @@
+## @file
+#  Platform Hook Library instance for UART device for Universal Payload.
+#
+#  Copyright (c) 2021, Intel Corporation. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = PlatformHookLib
+  FILE_GUID  = 807E05AB-9411-429F-97F0-FE425BF6B094
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = PlatformHookLib
+  CONSTRUCTOR= PlatformHookSerialPortInitialize
+
+[Sources]
+  PlatformHookLib.c
+
+[LibraryClasses]
+  PcdLib
+  BaseLib
+  HobLib
+  DxeHobListLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  UefiPayloadPkg/UefiPayloadPkg.dec
+
+[Guids]
+  gUniversalPayloadSerialPortInfoGuid
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## PRODUCES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase## PRODUCES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate## PRODUCES
+  gEfiMdeModulePkgTokenSpaceGuid.Pc

[edk2-devel] [PATCH 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload

2021-06-20 Thread Zhiguang Liu
For payload entry, use PayloadEntryHobLib as HobLib and payload entry
should initialize hob base.
For DxeCore, use new added DxeHobLib as HobLib, and DxeCore will
initialize hob base.
For Dxe Driver, use new added DxeHobLib as HobLib, and use DxeHobListLib
to initialize hob base.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Ray Ni 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/Include/Library/DxeHobListLib.h   |  27 
+++
 UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf   |  40 

 UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni   |  17 
+
 UefiPayloadPkg/Library/DxeHobLib/HobLib.c| 597 
+
 UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c |  66 
++
 UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf   |  35 
+++
 UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.c |  20 

 UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf   |  28 

 UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/Hob.c  |   2 +-
 UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/HobLib.inf |   2 +-
 UefiPayloadPkg/UefiPayloadPkg.dsc|  15 
+++
 11 files changed, 843 insertions(+), 6 deletions(-)

diff --git a/UefiPayloadPkg/Include/Library/DxeHobListLib.h 
b/UefiPayloadPkg/Include/Library/DxeHobListLib.h
new file mode 100644
index 00..7e9b23f6d7
--- /dev/null
+++ b/UefiPayloadPkg/Include/Library/DxeHobListLib.h
@@ -0,0 +1,27 @@
+/** @file
+  Provides a service to retrieve a pointer to the start of HOB list.
+  Only available to DXE module types.
+
+  This library does not contain any functions or macros.  It simply exports a 
global
+  pointer to the start of HOB list as defined in the Platform Initialization 
Driver
+  Execution Environment Core Interface Specification.  The library constructor 
must
+  initialize this global pointer to the start of HOB list, so it is available 
at the
+  module's entry point.  Since there is overhead in looking up the pointer to 
the start
+  of HOB list, only those modules that actually require access to the HOB list
+  should use this library.
+
+Copyright (c) 2021, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __DXE_HOB_LIST_LIB_H__
+#define __DXE_HOB_LIST_LIB_H__
+
+///
+/// Cache copy of the start of HOB list
+///
+extern VOID  *gHobList;
+
+#endif
+
diff --git a/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf 
b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
new file mode 100644
index 00..a146befd25
--- /dev/null
+++ b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
@@ -0,0 +1,40 @@
+## @file
+# Instance of HOB Library using HOB list from EFI Configuration Table.
+#
+# HOB Library implementation that retrieves the HOB List
+#  from the System Configuration Table in the EFI System Table.
+#
+# Copyright (c) 2021, Intel Corporation. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = DxeHobLib
+  MODULE_UNI_FILE= DxeHobLib.uni
+  FILE_GUID  = 1a15b8b3-3e8a-4698-87b9-65aad9993b52
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = HobLib|DXE_DRIVER DXE_RUNTIME_DRIVER 
SMM_CORE DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
+
+#
+#  VALID_ARCHITECTURES   = IA32 X64 EBC
+#
+
+[Sources]
+  HobLib.c
+
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiPayloadPkg/UefiPayloadPkg.dec
+
+
+[LibraryClasses]
+  BaseMemoryLib
+  DebugLib
+  UefiLib
+  DxeHobListLib
diff --git a/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni 
b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni
new file mode 100644
index 00..f1a18b7984
--- /dev/null
+++ b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni
@@ -0,0 +1,17 @@
+// /** @file
+// Instance of HOB Library using HOB list from EFI Configuration Table.
+//
+// HOB Library implementation that retrieves the HOB List
+// from the System Configuration Table in the EFI System Table.

Re: [edk2-devel] OvmfPkgIa32X64.dsc is broken: OvmfPkg/Sec/SecMain.inf NOT found in DSC file; Is it really a binary module?

2021-06-20 Thread Lendacky, Thomas via groups.io
On 6/16/21 11:15 PM, Rebecca Cran via groups.io wrote:
> Is OvmfPkg/OvmfPkgIa32X64.dsc still supposed to work after the recent
> changes in OvmfPkg? I realized it's currently broken.
> 
> 
> bcran@photon:~/src/uefi/edk2> build -p OvmfPkg/OvmfPkgIa32X64.dsc -a X64

You need to also have "-a IA32" when building this version of the DSC.

Thanks,
Tom



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76774): https://edk2.groups.io/g/devel/message/76774
Mute This Topic: https://groups.io/mt/83597788/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-