Re: [edk2-devel] [Patch v2 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI

2019-07-22 Thread Ni, Ray
Reviewed-by: Ray Ni 

> -Original Message-
> From: Dong, Eric
> Sent: Monday, July 22, 2019 3:14 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray ; Laszlo Ersek ; Kumar,
> Chandana C ; Zeng, Star
> 
> Subject: [Patch v2 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
> 
> Add definition for new EDKII_PEI_MP_SERVICES2_PPI.
> 
> It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI and add new API
> EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS.
> 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Chandana Kumar 
> Cc: Star Zeng 
> Signed-off-by: Eric Dong 
> ---
>  UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h | 72
> +++
>  UefiCpuPkg/UefiCpuPkg.dec |  3 +
>  2 files changed, 75 insertions(+)
>  create mode 100644 UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h
> 
> diff --git a/UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h
> b/UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h
> new file mode 100644
> index 00..c6b9712cc0
> --- /dev/null
> +++ b/UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h
> @@ -0,0 +1,72 @@
> +/** @file
> +  This file declares edkii Multi-processor service PPI.
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef __EDKII_PEI_MP_SERVICES2_PPI_H__ #define
> +__EDKII_PEI_MP_SERVICES2_PPI_H__
> +
> +#include 
> +
> +#define EDKII_PEI_MP_SERVICES2_PPI_GUID \
> +  { \
> +0x5cb9cb3d, 0x31a4, 0x480c, { 0x94, 0x98, 0x29, 0xd2, 0x69, 0xba,
> +0xcf, 0xba} \
> +  }
> +
> +typedef struct _EDKII_PEI_MP_SERVICES2_PPI
> EDKII_PEI_MP_SERVICES2_PPI;
> +
> +typedef EFI_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS
> EDKII_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS;
> +typedef EFI_PEI_MP_SERVICES_GET_PROCESSOR_INFO
> EDKII_PEI_MP_SERVICES_GET_PROCESSOR_INFO;
> +typedef EFI_PEI_MP_SERVICES_STARTUP_ALL_APS
> EDKII_PEI_MP_SERVICES_STARTUP_ALL_APS;
> +typedef EFI_PEI_MP_SERVICES_STARTUP_THIS_AP
> EDKII_PEI_MP_SERVICES_STARTUP_THIS_AP;
> +typedef EFI_PEI_MP_SERVICES_SWITCH_BSP
> EDKII_PEI_MP_SERVICES_SWITCH_BSP;
> +typedef EFI_PEI_MP_SERVICES_ENABLEDISABLEAP
> EDKII_PEI_MP_SERVICES_ENABLEDISABLEAP;
> +typedef EFI_PEI_MP_SERVICES_WHOAMI
> EDKII_PEI_MP_SERVICES_WHOAMI;
> +
> +/**
> +  Activate all of the application proessors.
> +
> +  @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI
> instance.
> +  @param[in] ProcedureA pointer to the function to be run on
> enabled APs of
> +  the system.
> +  @param[in] TimeoutInMicroSeconds
> +  Indicates the time limit in microseconds 
> for APs to
> +  return from Procedure, for blocking mode 
> only. Zero
> +  means infinity.  If the timeout expires in 
> blocking
> +  mode, BSP returns EFI_TIMEOUT.
> +  @param[in] ProcedureArgumentThe parameter passed into Procedure
> for all CPUs.
> +
> +  @retval EFI_SUCCESS In blocking mode, all APs have finished 
> before
> the
> +  timeout expired.
> +  @retval EFI_DEVICE_ERRORCaller processor is AP.
> +  @retval EFI_NOT_READY   Any enabled APs are busy.
> +  @retval EFI_TIMEOUT In blocking mode, the timeout expired 
> before
> all
> +  enabled APs have finished.
> +  @retval EFI_INVALID_PARAMETER   Procedure is NULL.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS) (
> +  IN  EDKII_PEI_MP_SERVICES2_PPI *This,
> +  IN  EFI_AP_PROCEDURE   Procedure,
> +  IN  UINTN  TimeoutInMicroSeconds,
> +  IN  VOID   *ProcedureArgument  OPTIONAL
> +  );
> +
> +struct _EDKII_PEI_MP_SERVICES2_PPI {
> +  EDKII_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS
> GetNumberOfProcessors;
> +  EDKII_PEI_MP_SERVICES_GET_PROCESSOR_INFOGetProcessorInfo;
> +  EDKII_PEI_MP_SERVICES_STARTUP_ALL_APS   StartupAllAPs;
> +  EDKII_PEI_MP_SERVICES_STARTUP_THIS_AP   StartupThisAP;
> +  EDKII_PEI_MP_SERVICES_SWITCH_BSPSwitchBSP;
> +  EDKII_PEI_MP_SERVICES_ENABLEDISABLEAP   EnableDisableAP;
> +  EDKII_PEI_MP_SERVICES_WHOAMIWhoAmI;
> +  EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS  StartupAllCPUs;
> +};
> +
> +extern EFI_GUID gEdkiiPeiMpServices2PpiGuid;
> +
> +#endif
> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
> index 6ddf0cd224..5a555644b7 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dec
> +++ b/UefiCpuPkg/UefiCpuPkg.dec
> @@ -75,6 +75,9 @@
>  #   0x8001 | Invalid value provided.
>  #
> 
> +[Ppis]
> +  gEdkiiPeiMpServices2PpiGuid ={ 0x5cb9cb3d, 0x31a4, 0x480c, { 0x94,
> 0x98, 0x29, 0xd2, 0x69, 0xba, 0xcf, 0xba}}
> +
>  [PcdsFeatureFlag]
>## Indicates if SMM Profile will be enabled.
>#  If enabled, instruction 

Re: [edk2-devel] [Patch v2 3/6] UefiCpuPkg/MpInitLibUp: Add MpInitLibStartupAllCPUs API.

2019-07-22 Thread Ni, Ray
Please add:
1. parameter check "if (Procedure == NULL) return EFI_INVALID_PARAMETER".
2. comments in function body saying TimeoutInMicroseconds is ignored for BSP.


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Dong,
> Eric
> Sent: Monday, July 22, 2019 3:14 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray ; Laszlo Ersek ; Kumar,
> Chandana C ; Zeng, Star
> 
> Subject: [edk2-devel] [Patch v2 3/6] UefiCpuPkg/MpInitLibUp: Add
> MpInitLibStartupAllCPUs API.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
> 
> Add new MpInitLibStartupAllCPUs API uses to start all processors at the same
> time.
> 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Chandana Kumar 
> Cc: Star Zeng 
> Signed-off-by: Eric Dong 
> ---
>  UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c | 38
> 
>  1 file changed, 38 insertions(+)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> index 36c2bb5326..849600d5c2 100644
> --- a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> +++ b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> @@ -405,3 +405,41 @@ MpInitLibWhoAmI (
>*ProcessorNumber = 0;
>return EFI_SUCCESS;
>  }
> +
> +/**
> +  This service executes a caller provided function on all enabled CPUs.
> +
> +  @param[in]  Procedure   A pointer to the function to be run on
> +  enabled APs of the system. See type
> +  EFI_AP_PROCEDURE.
> +  @param[in]  TimeoutInMicroseconds   Indicates the time limit in
> microseconds for
> +  APs to return from Procedure, either 
> for
> +  blocking or non-blocking mode. Zero 
> means
> +  infinity.
> +  @param[in]  ProcedureArgument   The parameter passed into
> Procedure for
> +  all APs.
> +
> +  @retval EFI_SUCCESS In blocking mode, all CPUs have finished
> before
> +  the timeout expired.
> +  @retval EFI_SUCCESS In non-blocking mode, function has been
> dispatched
> +  to all enabled CPUs.
> +  @retval EFI_DEVICE_ERRORCaller processor is AP.
> +  @retval EFI_NOT_READY   Any enabled APs are busy.
> +  @retval EFI_NOT_READY   MP Initialize Library is not initialized.
> +  @retval EFI_TIMEOUT In blocking mode, the timeout expired 
> before
> +  all enabled APs have finished.
> +  @retval EFI_INVALID_PARAMETER   Procedure is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MpInitLibStartupAllCPUs (
> +  IN  EFI_AP_PROCEDURE  Procedure,
> +  IN  UINTN TimeoutInMicroseconds,
> +  IN  VOID  *ProcedureArgument  OPTIONAL
> +  )
> +{
> +  Procedure (ProcedureArgument);
> +
> +  return EFI_SUCCESS;
> +}
> --
> 2.21.0.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44213): https://edk2.groups.io/g/devel/message/44213
Mute This Topic: https://groups.io/mt/32556152/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [Patch v2 2/6] UefiCpuPkg/MpInitLib: Add MpInitLibStartupAllCPUs API.

2019-07-22 Thread Ni, Ray
"CPU"  is used in MpInitLibStartupAllCPUs() and StartupAllCpusWorker().
Can you please follow today's capital rule of "AP" to update
StartupAllCpusWorker() to StartupAllCPUsWorker()?

And with the copyright year update to 2019, Reviewed-by: Ray Ni 


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Dong,
> Eric
> Sent: Monday, July 22, 2019 3:14 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray ; Laszlo Ersek ; Kumar,
> Chandana C ; Zeng, Star
> 
> Subject: [edk2-devel] [Patch v2 2/6] UefiCpuPkg/MpInitLib: Add
> MpInitLibStartupAllCPUs API.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
> 
> Add new MpInitLibStartupAllCPUs API uses to start all processors at the same
> time.
> 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Chandana Kumar 
> Cc: Star Zeng 
> Signed-off-by: Eric Dong 
> ---
>  UefiCpuPkg/Library/MpInitLib/DxeMpLib.c |  3 +-
>  UefiCpuPkg/Library/MpInitLib/MpLib.c| 60 +++-
> -
>  UefiCpuPkg/Library/MpInitLib/MpLib.h|  4 +-
>  UefiCpuPkg/Library/MpInitLib/PeiMpLib.c |  3 +-
>  4 files changed, 63 insertions(+), 7 deletions(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> index 6be1bae464..23adfd0625 100644
> --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> @@ -568,9 +568,10 @@ MpInitLibStartupAllAPs (
>//
>mStopCheckAllApsStatus = TRUE;
> 
> -  Status = StartupAllAPsWorker (
> +  Status = StartupAllCpusWorker (
>   Procedure,
>   SingleThread,
> + TRUE,
>   WaitEvent,
>   TimeoutInMicroseconds,
>   ProcedureArgument,
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 6f51bc4ebf..51e63e14a3 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -2130,6 +2130,7 @@ MpInitLibGetNumberOfProcessors (
>number.  If FALSE, then all the 
> enabled APs
>execute the function specified by 
> Procedure
>simultaneously.
> +  @param[in]  ExcludeBsp  Whether let BSP also trig this task.
>@param[in]  WaitEvent   The event created by the caller with
> CreateEvent()
>service.
>@param[in]  TimeoutInMicroseconds   Indicates the time limit in
> microseconds for
> @@ -2151,9 +2152,10 @@ MpInitLibGetNumberOfProcessors (
> 
>  **/
>  EFI_STATUS
> -StartupAllAPsWorker (
> +StartupAllCpusWorker (
>IN  EFI_AP_PROCEDURE  Procedure,
>IN  BOOLEAN   SingleThread,
> +  IN  BOOLEAN   ExcludeBsp,
>IN  EFI_EVENT WaitEvent   OPTIONAL,
>IN  UINTN TimeoutInMicroseconds,
>IN  VOID  *ProcedureArgument  OPTIONAL,
> @@ -2175,7 +2177,7 @@ StartupAllAPsWorker (
>  *FailedCpuList = NULL;
>}
> 
> -  if (CpuMpData->CpuCount == 1) {
> +  if (CpuMpData->CpuCount == 1 && ExcludeBsp) {
>  return EFI_NOT_STARTED;
>}
> 
> @@ -2218,9 +2220,9 @@ StartupAllAPsWorker (
>  }
>}
> 
> -  if (!HasEnabledAp) {
> +  if (!HasEnabledAp && ExcludeBsp) {
>  //
> -// If no enabled AP exists, return EFI_NOT_STARTED.
> +// If no enabled AP exists and not include Bsp to do the procedure, 
> return
> EFI_NOT_STARTED.
>  //
>  return EFI_NOT_STARTED;
>}
> @@ -2266,6 +2268,13 @@ StartupAllAPsWorker (
>  }
>}
> 
> +  if (!ExcludeBsp) {
> +//
> +// Start BSP.
> +//
> +Procedure (ProcedureArgument);
> +  }
> +
>Status = EFI_SUCCESS;
>if (WaitEvent == NULL) {
>  do {
> @@ -2411,3 +2420,46 @@ GetCpuMpDataFromGuidedHob (
>return CpuMpData;
>  }
> 
> +/**
> +  This service executes a caller provided function on all enabled CPUs.
> +
> +  @param[in]  Procedure   A pointer to the function to be run on
> +  enabled APs of the system. See type
> +  EFI_AP_PROCEDURE.
> +  @param[in]  TimeoutInMicroseconds   Indicates the time limit in
> microseconds for
> +  APs to return from Procedure, either 
> for
> +  blocking or non-blocking mode. Zero 
> means
> +  infinity.
> +  @param[in]  ProcedureArgument   The parameter passed into
> Procedure for
> +  all APs.
> +
> +  @retval EFI_SUCCESS In blocking mode, all CPUs have finished
> before
> +  the timeout expired.
> +  @retval EFI_SUCCESS In non-blocking mode, function has been
> dispatched
> +  to all enabled CPUs.
> +  @retval EFI_DEVICE_ERRORCaller processor is AP.
> +  

Re: [edk2-devel] [PATCH 1/1] CryptoPkg/BaseCryptLib: Wrap OpenSSL HKDF algorithm

2019-07-22 Thread Wang, Jian J
Gary,

Mailing list edk2-de...@lists.01.org is not used any more. Please subscribe and 
 send review emails to devel@edk2.groups.io

Regards,
Jian


> -Original Message-
> From: Wang, Jian J
> Sent: Tuesday, July 23, 2019 12:53 PM
> To: West, Gary ; edk2-de...@lists.01.org
> Cc: Ye, Ting 
> Subject: RE: [PATCH 1/1] CryptoPkg/BaseCryptLib: Wrap OpenSSL HKDF
> algorithm
> 
> Gary,
> 
> (see my embedded comment below)
> 
> > -Original Message-
> > From: West, Gary
> > Sent: Tuesday, July 23, 2019 2:23 AM
> > To: edk2-de...@lists.01.org
> > Cc: West, Gary ; West, Gary
> ;
> > Wang, Jian J ; Ye, Ting 
> > Subject: [PATCH 1/1] CryptoPkg/BaseCryptLib: Wrap OpenSSL HKDF
> > algorithm
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1928
> >
> > 1. Implement OpenSSL HKDF wrapped function in CryptHkdf.c file.
> > 2. Implement stub implementation function in CryptHkdfNull.c file.
> > 3. Add wrapped HKDF function declaration to BaseCryptLib.h file.
> > 4. Add CryptHkdf.c to module information BaseCryptLib.inf file.
> > 5. Add CryptHkdfNull.c to module information PeiCryptLib.inf,
> >RuntimeCryptLib.inf and SmmCryptLib.inf
> >
> > Signed-off-by: Gary West 
> > Cc: Jian Wang 
> > Cc: Ting Ye 
> > ---
> >  .../Library/BaseCryptLib/BaseCryptLib.inf |  1 +
> >  .../Library/BaseCryptLib/PeiCryptLib.inf  |  4 +-
> >  .../Library/BaseCryptLib/RuntimeCryptLib.inf  |  1 +
> >  .../Library/BaseCryptLib/SmmCryptLib.inf  |  1 +
> >  CryptoPkg/Include/Library/BaseCryptLib.h  | 33 
> >  .../Library/BaseCryptLib/Kdf/CryptHkdf.c  | 80 +++
> >  .../Library/BaseCryptLib/Kdf/CryptHkdfNull.c  | 43 ++
> >  7 files changed, 160 insertions(+), 3 deletions(-)
> >  create mode 100644 CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdf.c
> >  create mode 100644
> CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdfNull.c
> >
> > diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> > b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> > index 020df3c19b3c..8d4988e8c6b4 100644
> > --- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> > +++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> > @@ -37,6 +37,7 @@ [Sources]
> >Hmac/CryptHmacMd5.c
> >Hmac/CryptHmacSha1.c
> >Hmac/CryptHmacSha256.c
> > +  Kdf/CryptHkdf.c
> >Cipher/CryptAes.c
> >Cipher/CryptTdes.c
> >Cipher/CryptArc4.c
> > diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > index 4c4353747622..d26161d79ae5 100644
> > --- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > +++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > @@ -43,10 +43,10 @@ [Sources]
> >Hmac/CryptHmacMd5Null.c
> >Hmac/CryptHmacSha1Null.c
> >Hmac/CryptHmacSha256Null.c
> > +  Kdf/CryptHkdfNull.c
> >Cipher/CryptAesNull.c
> >Cipher/CryptTdesNull.c
> >Cipher/CryptArc4Null.c
> > -
> >Pk/CryptRsaBasic.c
> >Pk/CryptRsaExtNull.c
> >Pk/CryptPkcs1OaepNull.c
> > @@ -55,13 +55,11 @@ [Sources]
> >Pk/CryptPkcs7VerifyCommon.c
> >Pk/CryptPkcs7VerifyBase.c
> >Pk/CryptPkcs7VerifyEku.c
> > -
> >Pk/CryptDhNull.c
> >Pk/CryptX509Null.c
> >Pk/CryptAuthenticodeNull.c
> >Pk/CryptTsNull.c
> >Pem/CryptPemNull.c
> > -
> >Rand/CryptRandNull.c
> >
> >SysCall/CrtWrapper.c
> > diff --git a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> > b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> > index a59079d99e05..e99c046be29b 100644
> > --- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> > +++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> > @@ -42,6 +42,7 @@ [Sources]
> >Hmac/CryptHmacMd5Null.c
> >Hmac/CryptHmacSha1Null.c
> >Hmac/CryptHmacSha256Null.c
> > +  Kdf/CryptHkdfNull.c
> >Cipher/CryptAesNull.c
> >Cipher/CryptTdesNull.c
> >Cipher/CryptArc4Null.c
> > diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > index 3fd7d65abfca..fc217938825d 100644
> > --- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > +++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > @@ -42,6 +42,7 @@ [Sources]
> >Hmac/CryptHmacMd5Null.c
> >Hmac/CryptHmacSha1Null.c
> >Hmac/CryptHmacSha256.c
> > +  Kdf/CryptHkdfNull.c
> >Cipher/CryptAes.c
> >Cipher/CryptTdesNull.c
> >Cipher/CryptArc4Null.c
> > diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h
> > b/CryptoPkg/Include/Library/BaseCryptLib.h
> > index 19d1afe3c8c0..da32bb2444fd 100644
> > --- a/CryptoPkg/Include/Library/BaseCryptLib.h
> > +++ b/CryptoPkg/Include/Library/BaseCryptLib.h
> > @@ -3122,4 +3122,37 @@ RandomBytes (
> >IN   UINTN  Size
> >);
> >
> >
> +//
> > =
> > +//Key Derivation Function Primitive
> >
> +//
> > =
> > +
> > +/**
> > +  Derive key data 

Re: [edk2-devel] [edk2-non-osi/devel-MinPlatform] [PATCH] ClevoOpenBoardBinPkg: Add Vbt binary

2019-07-22 Thread Nate DeSimone
GOP config settings look good!

I don't think this will work with the galp-3 design however. If you can find 
the time please also create a VBT for galp-3.

Reviewed-by: Nate DeSimone 

-Original Message-
From: Agyeman, Prince 
Sent: Monday, July 22, 2019 2:17 PM
To: devel@edk2.groups.io
Cc: Gao, Liming ; Sinha, Ankit ; 
Desimone, Nathaniel L ; Kubacki, Michael A 
; Kinney, Michael D ; 
Yao, Jiewen ; Agyeman, Prince 
Subject: [edk2-non-osi/devel-MinPlatform] [PATCH] ClevoOpenBoardBinPkg: Add Vbt 
binary

Added N1xxWU's Vbt.bin

Cc: Liming Gao 
Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Michael Kubacki 
Cc: Michael D Kinney 
Cc: Jiewen Yao 

Signed-off-by: Prince Agyeman 
---
 .../ClevoOpenBoardBinPkg/N1xxWU/Gop/Vbt.bin  | Bin 0 -> 4608 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)  create mode 100644 
Platform/Intel/ClevoOpenBoardBinPkg/N1xxWU/Gop/Vbt.bin

diff --git a/Platform/Intel/ClevoOpenBoardBinPkg/N1xxWU/Gop/Vbt.bin 
b/Platform/Intel/ClevoOpenBoardBinPkg/N1xxWU/Gop/Vbt.bin
new file mode 100644
index 
..3431b7dc750c5be0f6b1d64c4bff7d978841119d
GIT binary patch
literal 4608
zcmeHKU2GIp6h1SvKeKmcwzE?L%YyZY2-^bfY=H{3%4~NFUAm>a-BL?5VGFxx<3dYY
zO!1F3mW0Hg?1LIKM4R|x@P)+qWQ@ERNr*~};-kEnDAB}3j4!}==4V?%1Kp5-U^v@z
z&%I}Ezd7gJbMHN~a+Z$ON-w9=m*+elr#J=WH~akIjbU5UQl
zOe!58NcHW%ma`9ZQtG6?~3p4$F-KoyhKvz;>vu-3t#}1E=JoD@%MiY(LO7B=_
zgW4uzVsw108RMlA_FHo%u)jD_9Dlx8XjYg7avDSr2f%rurwWG(bcURqz<#
zLGY+xAQ=09zyLr1)iOc_ej~?|Zj}hWu%)RI!3%cZuqL~N9yp%|RTVE1l0|+1
zuia5OBugAZ1HQLsU3O>j_G_(&98%vQL>DUtKB
zH{!pDuMqov3_`@qh#w(tA>K@!Anql8l6aWdcL*+n71YXREKbWo;@%
zsIxZcO(+_HAWY1gaFPh1@of+uV>ryT3C3P#_z}}SW9&8)E$x7_?iX*)ufz2!VteO!b}}PY-l+~%Zr>CHMAXZu02{SI?fkH
zC@cjd4y*L=u{H-G+;&88>N7GEJQhL+)l4_`LT`fOSHnPeXIzDFuSMk|47`{_A*wDSj(D$5bHH_192tKC*k_WxD
zL~`FlgD11lpl_|XYhgvQV&9!)N-c4Cskt(fk2DxMx@$qJ>8aS*Eg;zhKhJTrFc
zVM1t{TZ@War^qwj=^FCk{l=Md+36K}=Dj7e2m;upv26HiLC~9wGx_O)9?m-TAdnXV
zr6bX;=A@0FI0#;>!HbI#n91N0UDgwGUQ}p5k_~15COaRjB)@T1^X=vE!A=a>
zAwZpD1AWmfye}FJ$d{o$ud1Or8|VHopgB>U@iA9{3<}R%+x;MH`u)cU-QY_i25z
J)xRsA{Rhttps://edk2.groups.io/g/devel/message/44210
Mute This Topic: https://groups.io/mt/32563934/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch 07/10 V3] BaseTools: Add LogAgent to support multiple process Autogen

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

AutoGen processes race the logfile. To resolve this issue,
this patch create a LogAgent thread in main process to write
the log content to console or file, Other process will send
the log content to the LogAgent.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 .../Source/Python/AutoGen/AutoGenWorker.py| 86 +++
 BaseTools/Source/Python/AutoGen/DataPipe.py   |  2 +-
 BaseTools/Source/Python/AutoGen/GenMake.py|  3 +-
 BaseTools/Source/Python/Common/EdkLogger.py   | 33 ++-
 BaseTools/Source/Python/build/build.py| 27 --
 5 files changed, 122 insertions(+), 29 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py 
b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
index 1419d92b5e39..f5bc705fbd04 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
@@ -19,52 +19,111 @@ from Workspace.WorkspaceDatabase import BuildDB
 import time
 from queue import Empty
 import traceback
 import sys
 from AutoGen.DataPipe import MemoryDataPipe
+import logging
+
+class LogAgent(threading.Thread):
+def __init__(self,log_q,log_level,log_file=None):
+super(LogAgent,self).__init__()
+self.log_q = log_q
+self.log_level = log_level
+self.log_file = log_file
+def InitLogger(self):
+# For DEBUG level (All DEBUG_0~9 are applicable)
+self._DebugLogger_agent = logging.getLogger("tool_debug_agent")
+_DebugFormatter = logging.Formatter("[%(asctime)s.%(msecs)d]: 
%(message)s", datefmt="%H:%M:%S")
+self._DebugLogger_agent.setLevel(self.log_level)
+_DebugChannel = logging.StreamHandler(sys.stdout)
+_DebugChannel.setFormatter(_DebugFormatter)
+self._DebugLogger_agent.addHandler(_DebugChannel)
+
+# For VERBOSE, INFO, WARN level
+self._InfoLogger_agent = logging.getLogger("tool_info_agent")
+_InfoFormatter = logging.Formatter("%(message)s")
+self._InfoLogger_agent.setLevel(self.log_level)
+_InfoChannel = logging.StreamHandler(sys.stdout)
+_InfoChannel.setFormatter(_InfoFormatter)
+self._InfoLogger_agent.addHandler(_InfoChannel)
+
+# For ERROR level
+self._ErrorLogger_agent = logging.getLogger("tool_error_agent")
+_ErrorFormatter = logging.Formatter("%(message)s")
+self._ErrorLogger_agent.setLevel(self.log_level)
+_ErrorCh = logging.StreamHandler(sys.stderr)
+_ErrorCh.setFormatter(_ErrorFormatter)
+self._ErrorLogger_agent.addHandler(_ErrorCh)
+
+if self.log_file:
+if os.path.exists(self.log_file):
+os.remove(self.log_file)
+_Ch = logging.FileHandler(self.log_file)
+_Ch.setFormatter(_DebugFormatter)
+self._DebugLogger_agent.addHandler(_Ch)
+
+_Ch= logging.FileHandler(self.log_file)
+_Ch.setFormatter(_InfoFormatter)
+self._InfoLogger_agent.addHandler(_Ch)
+
+_Ch = logging.FileHandler(self.log_file)
+_Ch.setFormatter(_ErrorFormatter)
+self._ErrorLogger_agent.addHandler(_Ch)
+
+def run(self):
+self.InitLogger()
+while True:
+log_message = self.log_q.get()
+if log_message is None:
+break
+if log_message.name == "tool_error":
+
self._ErrorLogger_agent.log(log_message.levelno,log_message.getMessage())
+elif log_message.name == "tool_info":
+
self._InfoLogger_agent.log(log_message.levelno,log_message.getMessage())
+elif log_message.name == "tool_debug":
+
self._DebugLogger_agent.log(log_message.levelno,log_message.getMessage())
+else:
+
self._InfoLogger_agent.log(log_message.levelno,log_message.getMessage())
+
+def kill(self):
+self.log_q.put(None)
 class AutoGenManager(threading.Thread):
 def __init__(self,autogen_workers, feedback_q):
 super(AutoGenManager,self).__init__()
 self.autogen_workers = autogen_workers
 self.feedback_q = feedback_q
-self.terminate = False
 self.Status = True
 def run(self):
 try:
 while True:
-if self.terminate:
-break
-if self.feedback_q.empty():
-time.sleep(1)
-continue
-badnews = self.feedback_q.get(False)
-if badnews:
-print(badnews)
+badnews = self.feedback_q.get()
+if badnews is None:
 self.Status = False
 self.TerminateWorkers()
 break
 except Exception:
 return
 
 def kill(self):
-self.terminate = True
+self.feedback_q.put(None)
 
 def TerminateWorkers(self):
 for w 

[edk2-devel] [Patch 10/10 V3] BaseTools: Enable block queue log agent.

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

To support Ctrl+S and Ctrl+Q, we enable block queue
for log.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 BaseTools/Source/Python/Common/EdkLogger.py | 10 ++
 BaseTools/Source/Python/build/build.py  |  8 +---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/Common/EdkLogger.py 
b/BaseTools/Source/Python/Common/EdkLogger.py
index 15fd1458a95a..06da4a9d0a1d 100644
--- a/BaseTools/Source/Python/Common/EdkLogger.py
+++ b/BaseTools/Source/Python/Common/EdkLogger.py
@@ -93,11 +93,13 @@ except:
 """
 try:
 self.enqueue(self.prepare(record))
 except Exception:
 self.handleError(record)
-
+class BlockQueueHandler(QueueHandler):
+def enqueue(self, record):
+self.queue.put(record,True)
 ## Log level constants
 DEBUG_0 = 1
 DEBUG_1 = 2
 DEBUG_2 = 3
 DEBUG_3 = 4
@@ -290,23 +292,23 @@ def LogClientInitialize(log_q):
 # Since we use different format to log different levels of message into 
different
 # place (stdout or stderr), we have to use different "Logger" objects to 
do this.
 #
 # For DEBUG level (All DEBUG_0~9 are applicable)
 _DebugLogger.setLevel(INFO)
-_DebugChannel = QueueHandler(log_q)
+_DebugChannel = BlockQueueHandler(log_q)
 _DebugChannel.setFormatter(_DebugFormatter)
 _DebugLogger.addHandler(_DebugChannel)
 
 # For VERBOSE, INFO, WARN level
 _InfoLogger.setLevel(INFO)
-_InfoChannel = QueueHandler(log_q)
+_InfoChannel = BlockQueueHandler(log_q)
 _InfoChannel.setFormatter(_InfoFormatter)
 _InfoLogger.addHandler(_InfoChannel)
 
 # For ERROR level
 _ErrorLogger.setLevel(INFO)
-_ErrorCh = QueueHandler(log_q)
+_ErrorCh = BlockQueueHandler(log_q)
 _ErrorCh.setFormatter(_ErrorFormatter)
 _ErrorLogger.addHandler(_ErrorCh)
 
 ## Set log level
 #
diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index 4125b2832946..603d3aa6dad4 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -2046,14 +2046,15 @@ class Build():
 for m in Pa.GetAllModuleInfo:
 mqueue.put(m)
 data_pipe_file = os.path.join(Pa.BuildDir, 
"GlobalVar_%s_%s.bin" % (str(Pa.Guid),Pa.Arch))
 Pa.DataPipe.dump(data_pipe_file)
 autogen_rt = self.StartAutoGen(mqueue, Pa.DataPipe, 
self.SkipAutoGen, PcdMaList,self.share_data)
-self.Progress.Stop("done!")
-self.AutoGenTime += int(round((time.time() - 
AutoGenStart)))
+
 if not autogen_rt:
 return
+self.AutoGenTime += int(round((time.time() - AutoGenStart)))
+self.Progress.Stop("done!")
 for Arch in Wa.ArchList:
 MakeStart = time.time()
 for Ma in BuildModules:
 # Generate build task for the module
 if not Ma.IsBinaryModule:
@@ -2294,17 +2295,18 @@ def LogBuildTime(Time):
 # if it's executed successfully or not.
 #
 #   @retval 0 Tool was successful
 #   @retval 1 Tool failed
 #
+LogQMaxSize = 60
 def Main():
 StartTime = time.time()
 
 #
 # Create a log Queue
 #
-LogQ = mp.Queue()
+LogQ = mp.Queue(LogQMaxSize)
 # Initialize log system
 EdkLogger.LogClientInitialize(LogQ)
 GlobalData.gCommand = sys.argv[1:]
 #
 # Parse the options and args
-- 
2.20.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44209): https://edk2.groups.io/g/devel/message/44209
Mute This Topic: https://groups.io/mt/32567325/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch 05/10 V3] BaseTools: Enable Multiple Process AutoGen

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

Assign the Module AutoGen tasks into multiple
sub process.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 .../Source/Python/AutoGen/AutoGenWorker.py| 162 ++
 BaseTools/Source/Python/AutoGen/DataPipe.py   |   6 +
 BaseTools/Source/Python/AutoGen/GenC.py   |   4 +-
 .../Source/Python/AutoGen/ModuleAutoGen.py|   7 +-
 .../Source/Python/AutoGen/PlatformAutoGen.py  |   4 +-
 BaseTools/Source/Python/build/build.py| 114 +++-
 6 files changed, 243 insertions(+), 54 deletions(-)
 create mode 100644 BaseTools/Source/Python/AutoGen/AutoGenWorker.py

diff --git a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py 
b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
new file mode 100644
index ..edec346abd06
--- /dev/null
+++ b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
@@ -0,0 +1,162 @@
+## @file
+# Create makefile for MS nmake and GNU make
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+from __future__ import absolute_import
+import multiprocessing as mp
+import threading
+from Common.Misc import PathClass
+from AutoGen.ModuleAutoGen import ModuleAutoGen
+from AutoGen.ModuleAutoGenHelper import WorkSpaceInfo,AutoGenInfo
+import Common.GlobalData as GlobalData
+import Common.EdkLogger as EdkLogger
+import os
+from Common.MultipleWorkspace import MultipleWorkspace as mws
+from AutoGen.AutoGen import AutoGen
+from Workspace.WorkspaceDatabase import BuildDB
+import time
+from queue import Empty
+import traceback
+import sys
+from AutoGen.DataPipe import MemoryDataPipe
+class AutoGenManager(threading.Thread):
+def __init__(self,autogen_workers, feedback_q):
+super(AutoGenManager,self).__init__()
+self.autogen_workers = autogen_workers
+self.feedback_q = feedback_q
+self.terminate = False
+self.Status = True
+def run(self):
+try:
+while True:
+if self.terminate:
+break
+if self.feedback_q.empty():
+time.sleep(1)
+continue
+badnews = self.feedback_q.get(False)
+if badnews:
+print(badnews)
+self.Status = False
+self.TerminateWorkers()
+break
+except Exception:
+return
+
+def kill(self):
+self.terminate = True
+
+def TerminateWorkers(self):
+for w in self.autogen_workers:
+if w.is_alive():
+w.terminate()
+
+class AutoGenWorkerInProcess(mp.Process):
+def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock):
+mp.Process.__init__(self)
+self.module_queue = module_queue
+self.data_pipe_file_path =data_pipe_file_path
+self.data_pipe = None
+self.feedback_q = feedback_q
+self.PlatformMetaFileSet = {}
+self.file_lock = file_lock
+def GetPlatformMetaFile(self,filepath,root):
+try:
+return self.PlatformMetaFileSet[(filepath,root)]
+except:
+self.PlatformMetaFileSet[(filepath,root)]  = filepath
+return self.PlatformMetaFileSet[(filepath,root)]
+def run(self):
+try:
+taskname = "Init"
+with self.file_lock:
+if not os.path.exists(self.data_pipe_file_path):
+self.feedback_q.put(taskname + ":" + "load data pipe %s 
failed." % self.data_pipe_file_path)
+self.data_pipe = MemoryDataPipe()
+self.data_pipe.load(self.data_pipe_file_path)
+EdkLogger.Initialize()
+loglevel = self.data_pipe.Get("LogLevel")
+if not loglevel:
+loglevel = EdkLogger.INFO
+EdkLogger.SetLevel(loglevel)
+logfile = self.data_pipe.Get("LogFile")
+if logfile:
+EdkLogger.SetLogFile(logfile)
+target = self.data_pipe.Get("P_Info").get("Target")
+toolchain = self.data_pipe.Get("P_Info").get("ToolChain")
+archlist = self.data_pipe.Get("P_Info").get("ArchList")
+
+active_p = self.data_pipe.Get("P_Info").get("ActivePlatform")
+workspacedir = self.data_pipe.Get("P_Info").get("WorkspaceDir")
+PackagesPath = os.getenv("PACKAGES_PATH")
+mws.setWs(workspacedir, PackagesPath)
+self.Wa = WorkSpaceInfo(
+workspacedir,active_p,target,toolchain,archlist
+)
+self.Wa._SrcTimeStamp = self.data_pipe.Get("Workspace_timestamp")
+GlobalData.gGlobalDefines = self.data_pipe.Get("G_defines")
+GlobalData.gCommandLineDefines = self.data_pipe.Get("CL_defines")
+os.environ._data = self.data_pipe.Get("Env_Var")
+GlobalData.gWorkspace = workspacedir
+

[edk2-devel] [Patch 02/10 V3] BaseTools: Split WorkspaceAutoGen._InitWorker into multiple functions

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

The WorkspaceAutoGen.__InitWorker function is too long, it's hard
to read and understand.
This patch is to separate the __InitWorker into multiple small ones.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 247 +
 1 file changed, 152 insertions(+), 95 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index c5b3fbb0a87f..9e06bb942126 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -333,13 +333,58 @@ class WorkspaceAutoGen(AutoGen):
 self._GuidDict = {}
 
 # there's many relative directory operations, so ...
 os.chdir(self.WorkspaceDir)
 
+self.MergeArch()
+self.ValidateBuildTarget()
+
+EdkLogger.info("")
+if self.ArchList:
+EdkLogger.info('%-16s = %s' % ("Architecture(s)", ' 
'.join(self.ArchList)))
+EdkLogger.info('%-16s = %s' % ("Build target", self.BuildTarget))
+EdkLogger.info('%-16s = %s' % ("Toolchain", self.ToolChain))
+
+EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.Platform))
+if BuildModule:
+EdkLogger.info('%-24s = %s' % ("Active Module", BuildModule))
+
+if self.FdfFile:
+EdkLogger.info('%-24s = %s' % ("Flash Image Definition", 
self.FdfFile))
+
+EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile)
+
+if Progress:
+Progress.Start("\nProcessing meta-data")
 #
-# Merge Arch
+# Mark now build in AutoGen Phase
 #
+GlobalData.gAutoGenPhase = True
+self.ProcessModuleFromPdf()
+self.ProcessPcdType()
+self.ProcessMixedPcd()
+self.GetPcdsFromFDF()
+self.CollectAllPcds()
+self.GeneratePkgLevelHash()
+#
+# Check PCDs token value conflict in each DEC file.
+#
+self._CheckAllPcdsTokenValueConflict()
+#
+# Check PCD type and definition between DSC and DEC
+#
+self._CheckPcdDefineAndType()
+
+self.CreateBuildOptionsFile()
+self.CreatePcdTokenNumberFile()
+self.CreateModuleHashInfo()
+GlobalData.gAutoGenPhase = False
+
+#
+# Merge Arch
+#
+def MergeArch(self):
 if not self.ArchList:
 ArchList = set(self.Platform.SupArchList)
 else:
 ArchList = set(self.ArchList) & set(self.Platform.SupArchList)
 if not ArchList:
@@ -349,57 +394,49 @@ class WorkspaceAutoGen(AutoGen):
 SkippedArchList = 
set(self.ArchList).symmetric_difference(set(self.Platform.SupArchList))
 EdkLogger.verbose("\nArch [%s] is ignored because the platform 
supports [%s] only!"
   % (" ".join(SkippedArchList), " 
".join(self.Platform.SupArchList)))
 self.ArchList = tuple(ArchList)
 
-# Validate build target
+# Validate build target
+def ValidateBuildTarget(self):
 if self.BuildTarget not in self.Platform.BuildTargets:
 EdkLogger.error("build", PARAMETER_INVALID,
 ExtraData="Build target [%s] is not supported by 
the platform. [Valid target: %s]"
   % (self.BuildTarget, " 
".join(self.Platform.BuildTargets)))
-
-
-# parse FDF file to get PCDs in it, if any
+@cached_property
+def FdfProfile(self):
 if not self.FdfFile:
 self.FdfFile = self.Platform.FlashDefinition
 
-EdkLogger.info("")
-if self.ArchList:
-EdkLogger.info('%-16s = %s' % ("Architecture(s)", ' 
'.join(self.ArchList)))
-EdkLogger.info('%-16s = %s' % ("Build target", self.BuildTarget))
-EdkLogger.info('%-16s = %s' % ("Toolchain", self.ToolChain))
-
-EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.Platform))
-if BuildModule:
-EdkLogger.info('%-24s = %s' % ("Active Module", BuildModule))
-
+FdfProfile = None
 if self.FdfFile:
-EdkLogger.info('%-24s = %s' % ("Flash Image Definition", 
self.FdfFile))
-
-EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile)
-
-if Progress:
-Progress.Start("\nProcessing meta-data")
-
-if self.FdfFile:
-#
-# Mark now build in AutoGen Phase
-#
-GlobalData.gAutoGenPhase = True
 Fdf = FdfParser(self.FdfFile.Path)
 Fdf.ParseFile()
 GlobalData.gFdfParser = Fdf
-GlobalData.gAutoGenPhase = False
-PcdSet = Fdf.Profile.PcdDict
 if Fdf.CurrentFdName and Fdf.CurrentFdName in Fdf.Profile.FdDict:
 FdDict = Fdf.Profile.FdDict[Fdf.CurrentFdName]
 for FdRegion in FdDict.RegionList:
 if 

[edk2-devel] [Patch 08/10 V3] BaseTools: Move BuildOption parser out of build.py

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

Build tool supports user to specify the conf folder.
To make the build options be evaluated at the beginning
of launching build, extract the buildoption function
from build.py to a new .py file.

Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 .../Python/Common/TargetTxtClassObject.py |  28 -
 BaseTools/Source/Python/build/build.py| 108 +-
 BaseTools/Source/Python/build/buildoptions.py |  92 +++
 3 files changed, 121 insertions(+), 107 deletions(-)
 create mode 100644 BaseTools/Source/Python/build/buildoptions.py

diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py 
b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
index 79a5acc01074..16cc75ccb7c8 100644
--- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py
+++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
@@ -8,16 +8,19 @@
 ##
 # Import Modules
 #
 from __future__ import print_function
 from __future__ import absolute_import
+from buildoptions import BuildOption,BuildTarget
+import Common.GlobalData as GlobalData
 import Common.LongFilePathOs as os
 from . import EdkLogger
 from . import DataType
 from .BuildToolError import *
-from . import GlobalData
+
 from Common.LongFilePathSupport import OpenLongFilePath as open
+from Common.MultipleWorkspace import MultipleWorkspace as mws
 
 gDefaultTargetTxtFile = "target.txt"
 
 ## TargetTxtClassObject
 #
@@ -139,16 +142,33 @@ class TargetTxtClassObject(object):
 #
 # @param ConfDir:  Conf dir
 #
 # @retval Target An instance of TargetTxtClassObject() with loaded target.txt
 #
-def TargetTxtDict(ConfDir):
+def TargetTxtDict():
 Target = TargetTxtClassObject()
-Target.LoadTargetTxtFile(os.path.normpath(os.path.join(ConfDir, 
gDefaultTargetTxtFile)))
+if BuildOption.ConfDirectory:
+# Get alternate Conf location, if it is absolute, then just use the 
absolute directory name
+ConfDirectoryPath = os.path.normpath(BuildOption.ConfDirectory)
+
+if not os.path.isabs(ConfDirectoryPath):
+# Since alternate directory name is not absolute, the alternate 
directory is located within the WORKSPACE
+# This also handles someone specifying the Conf directory in the 
workspace. Using --conf=Conf
+ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], 
ConfDirectoryPath)
+else:
+if "CONF_PATH" in os.environ:
+ConfDirectoryPath = 
os.path.normcase(os.path.normpath(os.environ["CONF_PATH"]))
+else:
+# Get standard WORKSPACE/Conf use the absolute path to the 
WORKSPACE/Conf
+ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], 'Conf')
+GlobalData.gConfDirectory = ConfDirectoryPath
+targettxt = os.path.normpath(os.path.join(ConfDirectoryPath, 
gDefaultTargetTxtFile))
+if os.path.exists(targettxt):
+Target.LoadTargetTxtFile(targettxt)
 return Target
 
-TargetTxt = TargetTxtDict(os.path.join(os.getenv("WORKSPACE"),"Conf"))
+TargetTxt = TargetTxtDict()
 
 ##
 #
 # This acts like the main() function for the script, unless it is 'import'ed 
into another
 # script.
diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index 74df68350434..4125b2832946 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -24,11 +24,11 @@ import traceback
 import multiprocessing
 from threading import Thread,Event,BoundedSemaphore
 import threading
 from subprocess import Popen,PIPE
 from collections import OrderedDict, defaultdict
-from optparse import OptionParser
+from buildoptions import BuildOption,BuildTarget
 from AutoGen.PlatformAutoGen import PlatformAutoGen
 from AutoGen.ModuleAutoGen import ModuleAutoGen
 from AutoGen.WorkspaceAutoGen import WorkspaceAutoGen
 from AutoGen.AutoGenWorker import AutoGenWorkerInProcess,AutoGenManager,\
 LogAgent
@@ -41,11 +41,11 @@ from Common.Misc import 
PathClass,SaveFileOnChange,RemoveDirectory
 from Common.StringUtils import NormPath
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 from Common.BuildToolError import *
 from Common.DataType import *
 import Common.EdkLogger as EdkLogger
-from Common.BuildVersion import gBUILD_VERSION
+
 from Workspace.WorkspaceDatabase import BuildDB
 
 from BuildReport import BuildReport
 from GenPatchPcdTable.GenPatchPcdTable import 
PeImageClass,parsePcdInfoFromMapFile
 from PatchPcdValue.PatchPcdValue import PatchBinaryFile
@@ -53,14 +53,10 @@ from PatchPcdValue.PatchPcdValue import PatchBinaryFile
 import Common.GlobalData as GlobalData
 from GenFds.GenFds import GenFds, GenFdsApi
 import multiprocessing as mp
 from multiprocessing import Manager
 
-# Version and Copyright
-VersionNumber = "0.60" + ' ' + gBUILD_VERSION
-__version__ = "%prog Version " + VersionNumber
-__copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation  All rights 
reserved."
 
 ## standard targets of build 

[edk2-devel] [Patch 03/10 V3] BaseTools: Add functions to get platform scope build options

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

These functions are used for get platform scope
build options. They will be used in later patches.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py| 10 +-
 .../Source/Python/Workspace/DscBuildData.py   | 20 +++
 .../Source/Python/Workspace/InfBuildData.py   | 10 ++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 9e06bb942126..792beed65e6b 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2485,11 +2485,19 @@ class PlatformAutoGen(AutoGen):
 if Attr != 'PATH':
 BuildOptions[Tool][Attr] += " " + Options[Key]
 else:
 BuildOptions[Tool][Attr] = Options[Key]
 return BuildOptions
-
+def GetGlobalBuildOptions(self,Module):
+ModuleTypeOptions = self.Platform.GetBuildOptionsByPkg(Module, 
Module.ModuleType)
+ModuleTypeOptions = self._ExpandBuildOption(ModuleTypeOptions)
+if Module in self.Platform.Modules:
+PlatformModule = self.Platform.Modules[str(Module)]
+PlatformModuleOptions = 
self._ExpandBuildOption(PlatformModule.BuildOptions)
+else:
+PlatformModuleOptions = {}
+return ModuleTypeOptions, PlatformModuleOptions
 ## Append build options in platform to a module
 #
 #   @param  Module  The module to which the build options will be appended
 #
 #   @retval options The options appended with build options in platform
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index e7ec2aba57d2..dd5c3c2bd1f2 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1222,11 +1222,31 @@ class DscBuildData(PlatformBuildClassObject):
 self._BuildOptions[CurKey] = Option
 else:
 if ' ' + Option not in self._BuildOptions[CurKey]:
 self._BuildOptions[CurKey] += ' ' + Option
 return self._BuildOptions
+def GetBuildOptionsByPkg(self, Module, ModuleType):
 
+local_pkg = os.path.split(Module.LocalPkg())[0]
+if self._ModuleTypeOptions is None:
+self._ModuleTypeOptions = OrderedDict()
+if ModuleType not in self._ModuleTypeOptions:
+options = OrderedDict()
+self._ModuleTypeOptions[ ModuleType] = options
+RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, 
self._Arch]
+for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, 
Dummy4, Dummy5 in RecordList:
+if Dummy2 not in (TAB_COMMON,local_pkg.upper(),"EDKII"):
+continue
+Type = Dummy3
+if Type.upper() == ModuleType.upper():
+Key = (ToolChainFamily, ToolChain)
+if Key not in options or not ToolChain.endswith('_FLAGS') 
or Option.startswith('='):
+options[Key] = Option
+else:
+if ' ' + Option not in options[Key]:
+options[Key] += ' ' + Option
+return self._ModuleTypeOptions[ModuleType]
 def GetBuildOptionsByModuleType(self, Edk, ModuleType):
 if self._ModuleTypeOptions is None:
 self._ModuleTypeOptions = OrderedDict()
 if (Edk, ModuleType) not in self._ModuleTypeOptions:
 options = OrderedDict()
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py 
b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 60970cd92836..da35391d3aff 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -817,11 +817,21 @@ class InfBuildData(ModuleBuildClassObject):
 for Token in TokenList:
 TemporaryDictionary[Arch, ModuleType] = 
TemporaryDictionary[Arch, ModuleType] + Token.strip() + ' '
 for Arch, ModuleType in TemporaryDictionary:
 RetVal[Arch, ModuleType] = TemporaryDictionary[Arch, ModuleType]
 return RetVal
+def LocalPkg(self):
+module_path = self.MetaFile.File
+subdir = os.path.split(module_path)[0]
+TopDir = ""
+while subdir:
+subdir,TopDir = os.path.split(subdir)
 
+for file_name in os.listdir(os.path.join(self.MetaFile.Root,TopDir)):
+if file_name.upper().endswith("DEC"):
+pkg = os.path.join(TopDir,file_name)
+return pkg
 @cached_class_function
 def GetGuidsUsedByPcd(self):
 self.Pcds
 return self._GuidsUsedByPcd
 
-- 
2.20.1.windows.1



[edk2-devel] [Patch 09/10 V3] BaseTools: Add the support for python 2

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

python3 change the module name of Queue to queue.
python3 add a new log handler of QueueHandler.

This patch is to make Multiple process AutoGen
feature work for python2

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 .../Source/Python/AutoGen/AutoGenWorker.py|  5 +-
 BaseTools/Source/Python/Common/EdkLogger.py   | 92 ++-
 2 files changed, 92 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py 
b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
index f5bc705fbd04..d1c55cffa8d0 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
@@ -15,11 +15,14 @@ import Common.EdkLogger as EdkLogger
 import os
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 from AutoGen.AutoGen import AutoGen
 from Workspace.WorkspaceDatabase import BuildDB
 import time
-from queue import Empty
+try:
+from queue import Empty
+except:
+from Queue import Empty
 import traceback
 import sys
 from AutoGen.DataPipe import MemoryDataPipe
 import logging
 
diff --git a/BaseTools/Source/Python/Common/EdkLogger.py 
b/BaseTools/Source/Python/Common/EdkLogger.py
index f6a5e3b4daf9..15fd1458a95a 100644
--- a/BaseTools/Source/Python/Common/EdkLogger.py
+++ b/BaseTools/Source/Python/Common/EdkLogger.py
@@ -3,16 +3,100 @@
 #
 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 
+# Copyright 2001-2016 by Vinay Sajip. All Rights Reserved.
+#
+# Permission to use, copy, modify, and distribute this software and its
+# documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies and that
+# both that copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Vinay Sajip
+# not be used in advertising or publicity pertaining to distribution
+# of the software without specific, written prior permission.
+# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+# This copyright is for QueueHandler.
+
 ## Import modules
 from __future__ import absolute_import
 import Common.LongFilePathOs as os, sys, logging
 import traceback
 from  .BuildToolError import *
-import logging.handlers
+try:
+from logging.handlers import QueueHandler
+except:
+class QueueHandler(logging.Handler):
+"""
+This handler sends events to a queue. Typically, it would be used 
together
+with a multiprocessing Queue to centralise logging to file in one 
process
+(in a multi-process application), so as to avoid file write contention
+between processes.
+
+This code is new in Python 3.2, but this class can be copy pasted into
+user code for use with earlier Python versions.
+"""
+
+def __init__(self, queue):
+"""
+Initialise an instance, using the passed queue.
+"""
+logging.Handler.__init__(self)
+self.queue = queue
+
+def enqueue(self, record):
+"""
+Enqueue a record.
+
+The base implementation uses put_nowait. You may want to override
+this method if you want to use blocking, timeouts or custom queue
+implementations.
+"""
+self.queue.put_nowait(record)
+
+def prepare(self, record):
+"""
+Prepares a record for queuing. The object returned by this method 
is
+enqueued.
+
+The base implementation formats the record to merge the message
+and arguments, and removes unpickleable items from the record
+in-place.
+
+You might want to override this method if you want to convert
+the record to a dict or JSON string, or send a modified copy
+of the record while leaving the original intact.
+"""
+# The format operation gets traceback text into record.exc_text
+# (if there's exception data), and also returns the formatted
+# message. We can then use this to replace the original
+# msg + args, as these might be unpickleable. We also zap the
+# exc_info and exc_text attributes, as they are no longer
+# needed and, if not None, will typically not be pickleable.
+msg = self.format(record)
+record.message = msg
+record.msg = msg
+record.args = None
+   

[edk2-devel] [Patch 06/10 V3] BaseTools: Add shared data for processes

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

Add shared data for autogen processes.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 BaseTools/Source/Python/AutoGen/AutoGenWorker.py |  3 ++-
 BaseTools/Source/Python/build/build.py   | 10 ++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py 
b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
index edec346abd06..1419d92b5e39 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
@@ -52,18 +52,19 @@ class AutoGenManager(threading.Thread):
 for w in self.autogen_workers:
 if w.is_alive():
 w.terminate()
 
 class AutoGenWorkerInProcess(mp.Process):
-def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock):
+def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock, 
share_data):
 mp.Process.__init__(self)
 self.module_queue = module_queue
 self.data_pipe_file_path =data_pipe_file_path
 self.data_pipe = None
 self.feedback_q = feedback_q
 self.PlatformMetaFileSet = {}
 self.file_lock = file_lock
+self.share_data = share_data
 def GetPlatformMetaFile(self,filepath,root):
 try:
 return self.PlatformMetaFileSet[(filepath,root)]
 except:
 self.PlatformMetaFileSet[(filepath,root)]  = filepath
diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index 590584b3c67f..d49554ec0282 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -50,10 +50,11 @@ from GenPatchPcdTable.GenPatchPcdTable import 
PeImageClass,parsePcdInfoFromMapFi
 from PatchPcdValue.PatchPcdValue import PatchBinaryFile
 
 import Common.GlobalData as GlobalData
 from GenFds.GenFds import GenFds, GenFdsApi
 import multiprocessing as mp
+from multiprocessing import Manager
 
 # Version and Copyright
 VersionNumber = "0.60" + ' ' + gBUILD_VERSION
 __version__ = "%prog Version " + VersionNumber
 __copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation  All rights 
reserved."
@@ -826,16 +827,17 @@ class Build():
 self.InitBuild()
 
 self.AutoGenMgr = None
 EdkLogger.info("")
 os.chdir(self.WorkspaceDir)
-def StartAutoGen(self,mqueue, DataPipe,SkipAutoGen,PcdMaList):
+self.share_data = Manager().dict()
+def StartAutoGen(self,mqueue, DataPipe,SkipAutoGen,PcdMaList,share_data):
 if SkipAutoGen:
 return
 feedback_q = mp.Queue()
 file_lock = mp.Lock()
-auto_workers = 
[AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,file_lock) for _ 
in range(self.ThreadNumber)]
+auto_workers = 
[AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,file_lock,share_data)
 for _ in range(self.ThreadNumber)]
 self.AutoGenMgr = AutoGenManager(auto_workers,feedback_q)
 self.AutoGenMgr.start()
 for w in auto_workers:
 w.start()
 if PcdMaList is not None:
@@ -1228,11 +1230,11 @@ class Build():
 
 AutoGenObject.DataPipe.DataContainer = {"FfsCommand":FfsCommand}
 self.Progress.Start("Generating makefile and code")
 data_pipe_file = os.path.join(AutoGenObject.BuildDir, 
"GlobalVar_%s_%s.bin" % (str(AutoGenObject.Guid),AutoGenObject.Arch))
 AutoGenObject.DataPipe.dump(data_pipe_file)
-autogen_rt = self.StartAutoGen(mqueue, AutoGenObject.DataPipe, 
self.SkipAutoGen, PcdMaList)
+autogen_rt = self.StartAutoGen(mqueue, AutoGenObject.DataPipe, 
self.SkipAutoGen, PcdMaList,self.share_data)
 self.Progress.Stop("done!")
 return autogen_rt
 else:
 # always recreate top/platform makefile when clean, just in case 
of inconsistency
 AutoGenObject.CreateCodeFile(False)
@@ -2060,11 +2062,11 @@ class Build():
 mqueue = mp.Queue()
 for m in Pa.GetAllModuleInfo:
 mqueue.put(m)
 data_pipe_file = os.path.join(Pa.BuildDir, 
"GlobalVar_%s_%s.bin" % (str(Pa.Guid),Pa.Arch))
 Pa.DataPipe.dump(data_pipe_file)
-autogen_rt = self.StartAutoGen(mqueue, Pa.DataPipe, 
self.SkipAutoGen, PcdMaList)
+autogen_rt = self.StartAutoGen(mqueue, Pa.DataPipe, 
self.SkipAutoGen, PcdMaList,self.share_data)
 self.Progress.Stop("done!")
 self.AutoGenTime += int(round((time.time() - 
AutoGenStart)))
 if not autogen_rt:
 return
 for Arch in Wa.ArchList:
-- 
2.20.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44205): https://edk2.groups.io/g/devel/message/44205
Mute This 

[edk2-devel] [Patch 00/10 V3] Enable multiple process AutoGen

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

In order to improve the build performance, we implemented
multiple-processes AutoGen. This change will reduce 20% time
for AutoGen phase.

The design document can be got from:
https://edk2.groups.io/g/devel/files/Designs/2019/0627/Multiple-thread-AutoGen.pdf

This patch serial pass the build of Ovmf, MinKabylake, MinPurley, packages
under Edk2 repository and intel client and server platforms.

V3:
1. Fixed incremental build issue.
2. Set AutoGen worker number to be align with "-n THREADNUMBER"
3. Enable block log queue.
V2: 
1. The first version missed autogen related commit 
from e812a812c1a0800c49e11507cb46222351520cc7. V2 add those commit
back.
2. Move CreateAsBuildInf into AutoGenWorker process
3. Save GlobalVar__.bin to build folder.
4. Regenerate patches based on master bb824f685d


Feng, Bob C (10):
  BaseTools: Singleton the object to handle build conf file
  BaseTools: Split WorkspaceAutoGen._InitWorker into multiple functions
  BaseTools: Add functions to get platform scope build options
  BaseTools: Decouple AutoGen Objects
  BaseTools: Enable Multiple Process AutoGen
  BaseTools: Add shared data for processes
  BaseTools: Add LogAgent to support multiple process Autogen
  BaseTools: Move BuildOption parser out of build.py
  BaseTools: Add the support for python 2
  BaseTools: Enable block queue log agent.

 BaseTools/Source/Python/AutoGen/AutoGen.py| 4227 +
 .../Source/Python/AutoGen/AutoGenWorker.py|  222 +
 .../Source/Python/AutoGen/BuildEngine.py  |   22 +
 BaseTools/Source/Python/AutoGen/DataPipe.py   |  153 +
 BaseTools/Source/Python/AutoGen/GenC.py   |6 +-
 BaseTools/Source/Python/AutoGen/GenMake.py|3 +-
 .../Source/Python/AutoGen/ModuleAutoGen.py| 1903 
 .../Python/AutoGen/ModuleAutoGenHelper.py |  616 +++
 .../Source/Python/AutoGen/PlatformAutoGen.py  | 1493 ++
 .../Source/Python/AutoGen/WorkspaceAutoGen.py |  905 
 BaseTools/Source/Python/Common/EdkLogger.py   |  119 +-
 BaseTools/Source/Python/Common/Misc.py|1 -
 .../Python/Common/TargetTxtClassObject.py |   28 +-
 .../Python/Common/ToolDefClassObject.py   |6 +-
 BaseTools/Source/Python/GenFds/GenFds.py  |4 +-
 .../Python/GenFds/GenFdsGlobalVariable.py |   54 +-
 .../Python/PatchPcdValue/PatchPcdValue.py |1 -
 .../Source/Python/Workspace/DscBuildData.py   |   38 +-
 .../Source/Python/Workspace/InfBuildData.py   |   39 +
 .../Python/Workspace/WorkspaceCommon.py   |4 +
 .../Python/Workspace/WorkspaceDatabase.py |3 +
 BaseTools/Source/Python/build/BuildReport.py  |4 +-
 BaseTools/Source/Python/build/build.py|  333 +-
 BaseTools/Source/Python/build/buildoptions.py |   92 +
 24 files changed, 5834 insertions(+), 4442 deletions(-)
 create mode 100644 BaseTools/Source/Python/AutoGen/AutoGenWorker.py
 create mode 100644 BaseTools/Source/Python/AutoGen/DataPipe.py
 create mode 100644 BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
 create mode 100644 BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
 create mode 100644 BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
 create mode 100644 BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py
 create mode 100644 BaseTools/Source/Python/build/buildoptions.py

-- 
2.20.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44199): https://edk2.groups.io/g/devel/message/44199
Mute This Topic: https://groups.io/mt/32567312/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch 01/10 V3] BaseTools: Singleton the object to handle build conf file

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

The build config files are target.txt, build rule, tooldef
During a build, the config is not changed, so the object to
handle them need to be singleton.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py| 33 ++--
 .../Source/Python/AutoGen/BuildEngine.py  | 22 
 .../Python/Common/TargetTxtClassObject.py |  2 +
 .../Python/Common/ToolDefClassObject.py   |  6 ++-
 BaseTools/Source/Python/GenFds/GenFds.py  |  4 +-
 .../Python/GenFds/GenFdsGlobalVariable.py | 54 ---
 .../Source/Python/Workspace/DscBuildData.py   |  8 +--
 BaseTools/Source/Python/build/build.py| 29 +++---
 8 files changed, 62 insertions(+), 96 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 2df055a109f7..c5b3fbb0a87f 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -22,11 +22,12 @@ from . import GenC
 from . import GenMake
 from . import GenDepex
 from io import BytesIO
 
 from .StrGather import *
-from .BuildEngine import BuildRule
+from .BuildEngine import BuildRuleObj as BuildRule
+from .BuildEngine import gDefaultBuildRuleFile,AutoGenReqBuildRuleVerNum
 import shutil
 from Common.LongFilePathSupport import CopyLongFilePath
 from Common.BuildToolError import *
 from Common.DataType import *
 from Common.Misc import *
@@ -76,16 +77,10 @@ gEfiVarStoreGuidPattern = 
re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
 
 ## Mapping Makefile type
 gMakeTypeMap = {TAB_COMPILER_MSFT:"nmake", "GCC":"gmake"}
 
 
-## Build rule configuration file
-gDefaultBuildRuleFile = 'build_rule.txt'
-
-## Build rule default version
-AutoGenReqBuildRuleVerNum = "0.1"
-
 ## default file name for AutoGen
 gAutoGenCodeFileName = "AutoGen.c"
 gAutoGenHeaderFileName = "AutoGen.h"
 gAutoGenStringFileName = "%(module_name)sStrDefs.h"
 gAutoGenStringFormFileName = "%(module_name)sStrDefs.hpk"
@@ -1970,32 +1965,10 @@ class PlatformAutoGen(AutoGen):
 ## Return the build options specific for EDKII modules in this platform
 @cached_property
 def EdkIIBuildOption(self):
 return self._ExpandBuildOption(self.Platform.BuildOptions, EDKII_NAME)
 
-## Parse build_rule.txt in Conf Directory.
-#
-#   @retval BuildRule object
-#
-@cached_property
-def BuildRule(self):
-BuildRuleFile = None
-if TAB_TAT_DEFINES_BUILD_RULE_CONF in 
self.Workspace.TargetTxt.TargetTxtDictionary:
-BuildRuleFile = 
self.Workspace.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]
-if not BuildRuleFile:
-BuildRuleFile = gDefaultBuildRuleFile
-RetVal = BuildRule(BuildRuleFile)
-if RetVal._FileVersion == "":
-RetVal._FileVersion = AutoGenReqBuildRuleVerNum
-else:
-if RetVal._FileVersion < AutoGenReqBuildRuleVerNum :
-# If Build Rule's version is less than the version number 
required by the tools, halting the build.
-EdkLogger.error("build", AUTOGEN_ERROR,
-ExtraData="The version number [%s] of 
build_rule.txt is less than the version number required by the AutoGen.(the 
minimum required version number is [%s])"\
- % (RetVal._FileVersion, 
AutoGenReqBuildRuleVerNum))
-return RetVal
-
 ## Summarize the packages used by modules in this platform
 @cached_property
 def PackageList(self):
 RetVal = set()
 for La in self.LibraryAutoGenList:
@@ -3149,11 +3122,11 @@ class ModuleAutoGen(AutoGen):
 return RetVal
 
 @cached_property
 def BuildRules(self):
 RetVal = {}
-BuildRuleDatabase = self.PlatformInfo.BuildRule
+BuildRuleDatabase = BuildRule
 for Type in BuildRuleDatabase.FileTypeList:
 #first try getting build rule by BuildRuleFamily
 RuleObject = BuildRuleDatabase[Type, self.BuildType, self.Arch, 
self.BuildRuleFamily]
 if not RuleObject:
 # build type is always module type, but ...
diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py 
b/BaseTools/Source/Python/AutoGen/BuildEngine.py
index 14e61140e7ba..bb9153447793 100644
--- a/BaseTools/Source/Python/AutoGen/BuildEngine.py
+++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py
@@ -18,10 +18,13 @@ from Common.LongFilePathSupport import OpenLongFilePath as 
open
 from Common.GlobalData import *
 from Common.BuildToolError import *
 from Common.Misc import tdict, PathClass
 from Common.StringUtils import NormPath
 from Common.DataType import *
+from Common.TargetTxtClassObject import TargetTxt
+gDefaultBuildRuleFile = 'build_rule.txt'
+AutoGenReqBuildRuleVerNum = '0.1'
 
 import Common.EdkLogger as EdkLogger
 
 ## Convert file type to file list macro name
 #
@@ -581,10 +584,29 @@ class BuildRule:

Re: [edk2-devel] [PATCH 2/5] MdeModulePkg/SecurityLockAuditDebugLib: Add lib instance

2019-07-22 Thread Wu, Hao A
> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Tuesday, July 23, 2019 4:34 AM
> To: devel@edk2.groups.io; Gao, Zhichao
> Cc: Bret Barkelew; Wang, Jian J; Wu, Hao A; Ni, Ray; Zeng, Star; Gao, Liming;
> Sean Brogan; Michael Turner
> Subject: Re: [edk2-devel] [PATCH 2/5]
> MdeModulePkg/SecurityLockAuditDebugLib: Add lib instance
> 
> On 07/22/19 06:02, Gao, Zhichao wrote:
> > From: Bret Barkelew 
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2006
> >
> > Add the instance of SecurityLockAuditLib. This instance
> > has one interface SecurityLockReportEvent to log hardware
> > and software security locks info.
> >
> > Cc: Jian J Wang 
> > Cc: Hao A Wu 
> > Cc: Ray Ni 
> > Cc: Star Zeng 
> > Cc: Liming gao 
> > Cc: Sean Brogan 
> > Cc: Michael Turner 
> > Cc: Bret Barkelew 
> > Signed-off-by: Zhichao Gao 
> > ---
> >  .../SecurityLockAuditDebugLib.c   | 53 +++
> >  .../SecurityLockAuditDebugLib.inf | 29 ++
> >  2 files changed, 82 insertions(+)
> >  create mode 100644
> MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDebu
> gLib.c
> >  create mode 100644
> MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDebu
> gLib.inf
> >
> > diff --git
> a/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDe
> bugLib.c
> b/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDe
> bugLib.c
> > new file mode 100644
> > index 00..c1872bc023
> > --- /dev/null
> > +++
> b/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDe
> bugLib.c
> > @@ -0,0 +1,53 @@
> > +/** @file
> > +  This library implements the necessary functions
> > +  to log hardware and software security locks for post-processing
> > +
> > +  Copyright (c) 2018, Microsoft Corporation
> > +
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +//
> > +// Used to look up lock name from LOCK_TYPE enum
> > +//
> > +CHAR8* mLockName[] = {
> > +  "SOFTWARE_LOCK",
> > +  "HARDWARE_LOCK"
> > +};
> > +
> > +
> > +/**
> > +  Function for security Lock event logging and reporting
> > +
> > +  @param[in] Module   GUID of calling module
> > +  @param[in] Function Name of calling function
> > +  @param[in] LockEventTextDebug message explaining what is
> locked
> > +  @param[in] LockType Enumerated lock type for 
> > differentiation
> > +
> > +**/
> > +VOID
> > +EFIAPI
> > +SecurityLockReportEvent (
> > +  IN GUID   *Module,
> > +  IN CONST CHAR8*Function,
> > +  IN CONST CHAR8*LockEventText,
> > +  IN LOCK_TYPE  LockType
> > +  )
> > +{
> > +  UINTN LockTypeIndex;
> > +  UINTN LockNameCount;
> > +
> > +  LockTypeIndex = (UINTN)LockType;
> > +  LockNameCount = sizeof (mLockName) / sizeof (mLockName[0]);
> > +
> > +  if (LockTypeIndex < LockNameCount) {
> > +DEBUG ((DEBUG_ERROR, "SecurityLock::LockType: %a, Module: %g,
> Function: %a, Output: %a\n", mLockName[LockTypeIndex], Module,
> Function, LockEventText));
> > +  } else {
> > +DEBUG ((DEBUG_ERROR, "SecurityLock::LockType: %d, Module: %g,
> Function: %a, Output: %a\n", LockType, Module, Function, LockEventText));
> > +  }
> > +}
> 
> I disagree with this implementation. Security log messages are
> important, but they are not necessarily errors. DEBUG_ERROR should be
> used for errors, preferably for such that cannot be recovered from
> (DEBUG_WARN is OK for recoverable errors).


Agree that using 'DEBUG_ERROR' is improper here.


> 
> If DEBUG_INFO is deemed too "quiet" for logging security events, then we
> should introduce a new bit value for the debug bitmask, such as
> DEBUG_SECURITY. We have a number of "special purpose" bits already:
> 
> - DEBUG_LOAD
> - DEBUG_FS
> - DEBUG_POOL
> - DEBUG_PAGE
> - DEBUG_DISPATCH
> - etc
> 
> and I think we have room for DEBUG_SECURITY.


Not sure if 'DEBUG_EVENT' can be used in this case.

I think this bit is added for event-related services in the UEFI/PI core
system. However, I do not see any usage of 'DEBUG_EVENT' or 'EFI_D_EVENT'
(at least within the edk2 repository). So I am thinking whether we can
extend this bit to match this case here.

I am also fine with adding a new bit.

Best Regards,
Hao Wu


> 
> (1) And then, the log mask in this library instance should be
> 
>   DEBUG_SECURITY | DEBUG_INFO
> 
> I believe.
> 
> Thanks
> Laszlo
> 
> 
> 
> > diff --git
> a/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDe
> bugLib.inf
> b/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDe
> bugLib.inf
> > new file mode 100644
> > index 00..b641016087
> > --- /dev/null
> > +++
> b/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDe
> bugLib.inf
> > @@ -0,0 +1,29 @@
> > +## @file
> > +#
> > +# Library that implements logging and reporting for security locks
> > +# Using DebugLib
> > +#
> > +#
> > +# 

Re: [edk2-devel] [PATCH 4/4] MdeModulePkg/DxeIpl: Create 5-level page table for long mode

2019-07-22 Thread Wu, Hao A
> -Original Message-
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Ni,
> Ray
> Sent: Monday, July 22, 2019 4:16 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric; Laszlo Ersek
> Subject: [edk2-devel] [PATCH 4/4] MdeModulePkg/DxeIpl: Create 5-level
> page table for long mode
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2008
> 
> DxeIpl is responsible to create page table for DXE phase running
> either in long mode or in 32bit mode with certain protection
> mechanism enabled (refer to ToBuildPageTable()).
> 
> The patch updates DxeIpl to create 5-level page table for DXE phase
> running in long mode when PcdUse5LevelPageTable is TRUE and CPU
> supports 5-level page table.
> 
> Signed-off-by: Ray Ni 
> Cc: Eric Dong 
> Cc: Laszlo Ersek 
> ---
>  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf   |   1 +
>  .../Core/DxeIplPeim/X64/VirtualMemory.c   | 227 --
>  2 files changed, 151 insertions(+), 77 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> index abc3217b01..98bc17fc9d 100644
> --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> @@ -110,6 +110,7 @@ [Pcd.IA32,Pcd.X64]
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask
> ## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask
> ## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard   ##
> CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable  ##
> SOMETIMES_CONSUMES
> 
>  [Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64]
>gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack   ##
> SOMETIMES_CONSUMES
> diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> index edc38e4525..a5bcdcc734 100644
> --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> @@ -15,7 +15,7 @@
>  2) IA-32 Intel(R) Architecture Software Developer's Manual Volume
> 2:Instruction Set Reference, Intel
>  3) IA-32 Intel(R) Architecture Software Developer's Manual Volume
> 3:System Programmer's Guide, Intel
> 
> -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>  Copyright (c) 2017, AMD Incorporated. All rights reserved.
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -626,14 +626,19 @@ CreateIdentityMappingPageTables (
>)
>  {
>UINT32RegEax;
> +  UINT32RegEbx;
> +  UINT32RegEcx;
>UINT32RegEdx;
>UINT8 PhysicalAddressBits;
>EFI_PHYSICAL_ADDRESS  PageAddress;
> +  UINTN IndexOfPml5Entries;
>UINTN IndexOfPml4Entries;
>UINTN IndexOfPdpEntries;
>UINTN IndexOfPageDirectoryEntries;
> +  UINT32NumberOfPml5EntriesNeeded;
>UINT32NumberOfPml4EntriesNeeded;
>UINT32NumberOfPdpEntriesNeeded;
> +  PAGE_MAP_AND_DIRECTORY_POINTER*PageMapLevel5Entry;
>PAGE_MAP_AND_DIRECTORY_POINTER*PageMapLevel4Entry;
>PAGE_MAP_AND_DIRECTORY_POINTER*PageMap;
>PAGE_MAP_AND_DIRECTORY_POINTER
> *PageDirectoryPointerEntry;
> @@ -641,9 +646,11 @@ CreateIdentityMappingPageTables (
>UINTN TotalPagesNum;
>UINTN BigPageAddress;
>VOID  *Hob;
> +  BOOLEAN   Page5LevelSupport;
>BOOLEAN   Page1GSupport;
>PAGE_TABLE_1G_ENTRY   *PageDirectory1GEntry;
>UINT64AddressEncMask;
> +  IA32_CR4  Cr4;
> 
>//
>// Make sure AddressEncMask is contained to smallest supported address
> field
> @@ -677,33 +684,66 @@ CreateIdentityMappingPageTables (
>  }
>}
> 
> +  Page5LevelSupport = FALSE;
> +  if (PcdGetBool (PcdUse5LevelPageTable)) {
> +AsmCpuidEx (0x7, 0, , , , );
> +DEBUG ((DEBUG_INFO, "Cpuid(7/0): %08x/%08x/%08x/%08x\n", RegEax,
> RegEbx, RegEcx, RegEdx));
> +if ((RegEcx & BIT16) != 0) {
> +  Page5LevelSupport = TRUE;
> +}
> +  }
> +
> +  DEBUG ((DEBUG_INFO, "AddressBits/5LevelPaging/1GPage
> = %d/%d/%d\n", PhysicalAddressBits, Page5LevelSupport, Page1GSupport));
> +
>//
> -  // IA-32e paging translates 48-bit linear 

Re: [edk2-devel] [PATCH 3/4] MdeModulePkg/DxeIpl: Introduce PCD PcdUse5LevelPageTable

2019-07-22 Thread Wu, Hao A
> -Original Message-
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Ni,
> Ray
> Sent: Monday, July 22, 2019 4:16 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric; Laszlo Ersek
> Subject: [edk2-devel] [PATCH 3/4] MdeModulePkg/DxeIpl: Introduce PCD
> PcdUse5LevelPageTable
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2008
> 
> The PCD indicates if 5-Level Paging will be enabled in long mode.
> 5-Level Paging will not be enabled when the PCD is TRUE but CPU
> doesn't support 5-Level Paging.
> 
> Signed-off-by: Ray Ni 
> Cc: Eric Dong 
> Cc: Laszlo Ersek 
> ---
>  MdeModulePkg/MdeModulePkg.dec | 7 +++


Hello,

Please help to add the PCD description string definitions in MdeModulePkg.uni.

One question, is this PCD introduced for the consideration of memory
consumption by the page table entries? Or is there any other purpose?

Best Regards,
Hao Wu


>  1 file changed, 7 insertions(+)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 12e0bbf579..21388595a9 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -1991,6 +1991,13 @@ [PcdsFixedAtBuild, PcdsPatchableInModule,
> PcdsDynamic, PcdsDynamicEx]
># @Prompt The address mask when memory encryption is enabled.
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrM
> ask|0x0|UINT64|0x30001047
> 
> +  ## Indicates if 5-Level Paging will be enabled in long mode. 5-Level Paging
> will not be enabled
> +  #  when the PCD is TRUE but CPU doesn't support 5-Level Paging.
> +  #   TRUE  - 5-Level Paging will be enabled.
> +  #   FALSE - 5-Level Paging will not be enabled.
> +  # @Prompt Enable 5-Level Paging support in long mode.
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable|FALSE|BOOLE
> AN|0x0001105F
> +
>## Capsule In Ram is to use memory to deliver the capsules that will be
> processed after system
>#  reset.
>#  This PCD indicates if the Capsule In Ram is supported.
> --
> 2.21.0.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44196): https://edk2.groups.io/g/devel/message/44196
Mute This Topic: https://groups.io/mt/32556534/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms Patch V3 10/12] Vlv2TbltDevicePkg: Fix XCODE5 build errors

2019-07-22 Thread Sun, Zailiang
Reviewed-by: Zailiang Sun 

> -Original Message-
> From: Kinney, Michael D
> Sent: Tuesday, July 23, 2019 6:59 AM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang ; Qian, Yi ;
> Gary Lin 
> Subject: [edk2-platforms Patch V3 10/12] Vlv2TbltDevicePkg: Fix XCODE5
> build errors
> 
> * Remove extra parenthesis in if statements
> * Remove local variable structure initialization
>   that adds use of memcpy() on XCODE X64 builds.
>   Move per-initialize structure to a module global.
> 
> Cc: Zailiang Sun 
> Cc: Yi Qian 
> Cc: Gary Lin 
> Signed-off-by: Michael D Kinney 
> ---
>  .../Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c| 12 ++--
>  .../Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c  |  2 +-
>  .../Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c  |  2 +-
>  .../VlvPlatformInitDxe/IgdOpRegion.c |  2 +-
>  4 files changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
> b/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
> index 479ffa61a0..3e0b978120 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
> @@ -63,6 +63,15 @@ SYSTEM_CONFIGURATION  mSystemConfig;
>  UINT8 mSmbusRsvdAddresses[] = PLATFORM_SMBUS_RSVD_ADDRESSES;
>  UINT8 mNumberSmbusAddress = sizeof( mSmbusRsvdAddresses ) /
> sizeof( mSmbusRsvdAddresses[0] );
> 
> +EFI_ACPI_OSFR_OCUR_OBJECT  mOcurObjectTemplate = {
> +  {0xB46F133D, 0x235F, 0x4634, 0x9F, 0x03, 0xB1, 0xC0, 0x1C, 0x54,
> +0x78, 0x5B},
> +  0,
> +  0,
> +  0,
> +  0,
> +  0
> +};
> +
>  /**
>Locate the first instance of a protocol.  If the protocol requested is an
>FV protocol, then it will return the first FV that contains the ACPI table 
> @@ -
> 203,7 +212,6 @@ PlatformUpdateTables (
>EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE   *Facp;
>EFI_ACPI_OSFR_TABLE *OsfrTable;
>EFI_ACPI_OSFR_OCUR_OBJECT   *pOcurObject;
> -  EFI_ACPI_OSFR_OCUR_OBJECT   OcurObject =
> {{0xB46F133D, 0x235F, 0x4634, 0x9F, 0x03, 0xB1, 0xC0, 0x1C, 0x54, 0x78, 0x5B},
> 0, 0, 0, 0, 0};
>CHAR16  
> *OcurMfgStringBuffer = NULL;
>CHAR16  
> *OcurModelStringBuffer = NULL;
>UINT8   
> *OcurRefDataBlockBuffer = NULL;
> @@ -554,7 +562,7 @@ PlatformUpdateTables (
>  (UINT32) (sizeof (EFI_ACPI_OSFR_TABLE_FIXED_PORTION) + sizeof
> (UINT32));
>pOcurObject = (EFI_ACPI_OSFR_OCUR_OBJECT *)((UINTN) OsfrTable +
> sizeof (EFI_ACPI_OSFR_TABLE_FIXED_PORTION) + \
>  sizeof (UINT32));
> -  CopyMem (pOcurObject, , sizeof
> (EFI_ACPI_OSFR_OCUR_OBJECT));
> +  CopyMem (pOcurObject, , sizeof
> + (EFI_ACPI_OSFR_OCUR_OBJECT));
>pOcurObject->ManufacturerNameStringOffset = (UINT32)((UINTN)
> pOcurObject - (UINTN) OsfrTable + \
>  sizeof (EFI_ACPI_OSFR_OCUR_OBJECT));
>pOcurObject->ModelNameStringOffset = (UINT32)((UINTN)
> pOcurObject - (UINTN) OsfrTable + \ diff --git
> a/Platform/Intel/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c
> b/Platform/Intel/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c
> index b1c01afc16..69ced08a58 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c
> @@ -250,7 +250,7 @@ GetPciRom (
>  //
>  // Do not run RAID or AHCI Option ROM if IDE
>  //
> -if ( (DeviceClass == ((PCI_CLASS_MASS_STORAGE << 8 ) |
> PCI_CLASS_MASS_STORAGE_IDE)) ) {
> +if (DeviceClass == ((PCI_CLASS_MASS_STORAGE << 8 ) |
> + PCI_CLASS_MASS_STORAGE_IDE)) {
>return EFI_NOT_FOUND;
>  }
> 
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
> index 71d6cb7c15..0b5d7f76a1 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
> @@ -514,7 +514,7 @@ IchRcrbInit (
>//
>// Initial RCBA according to the PeiRCBA table
>//
> -  if ((BootMode == BOOT_ON_S3_RESUME)) {
> +  if (BootMode == BOOT_ON_S3_RESUME) {
>  //
>  // We are resuming from S3
>  // Enable HPET if enabled in Setup
> diff --git
> a/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegion.c
> b/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegion.c
> index dad27f130d..fcd9e566ae 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegion.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegion.c
> @@ -573,7 +573,7 @@ GetVBiosVbtCallback (
>  return EFI_SUCCESS;
>}
>  }
> -if ((VBiosPtr == NULL) ) {
> +

Re: [edk2-devel] [edk2-platforms Patch V3 11/12] Vlv2TbltDevicePkg: Remove __GNUC__ specific #ifdefs

2019-07-22 Thread Sun, Zailiang
Reviewed-by: Zailiang Sun 

> -Original Message-
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Michael D Kinney
> Sent: Tuesday, July 23, 2019 6:59 AM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang ; Qian, Yi ;
> Gary Lin 
> Subject: [edk2-devel] [edk2-platforms Patch V3 11/12] Vlv2TbltDevicePkg:
> Remove __GNUC__ specific #ifdefs
> 
> Remove #ifdefs for __GNUC__, so the builds are the same for GCC, VS20xx,
> and XCODE5.  This resolves an
> XCODE5 build break for an unsupported pragma.
> 
> Cc: Zailiang Sun 
> Cc: Yi Qian 
> Cc: Gary Lin 
> Signed-off-by: Michael D Kinney 
> ---
>  .../AcpiPlatform/AcpiPlatform.c   |  3 --
>  .../BoardClkGens/BoardClkGens.c   |  8 
>  .../PlatformInitPei/CpuInitPeim.c | 12 -
>  .../PlatformInitPei/PlatformEarlyInit.c   | 46 ---
>  .../PlatformInitPei/PlatformEarlyInit.h   |  6 ---
>  5 files changed, 75 deletions(-)
> 
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
> b/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
> index 3e0b978120..37f899d7f5 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
> @@ -51,9 +51,6 @@ CHAR16gACPIOSFRRefDataBlockVariableName[] =
> ACPI_OSFR_REF_DATA_BLOCK_VARIABL
>  CHAR16gACPIOSFRMfgStringVariableName[] =
> ACPI_OSFR_MFG_STRING_VARIABLE_NAME;
> 
>  EFI_GLOBAL_NVS_AREA_PROTOCOLmGlobalNvsArea;
> -#ifndef __GNUC__
> -#pragma optimize("", off)
> -#endif
>  BOOLEAN   mFirstNotify;
>  EFI_PLATFORM_INFO_HOB *mPlatformInfo;
>  EFI_GUID  mSystemConfigurationGuid =
> SYSTEM_CONFIGURATION_GUID;
> diff --git
> a/Platform/Intel/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens
> /BoardClkGens.c
> b/Platform/Intel/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens
> /BoardClkGens.c
> index 4356f7b366..f00f10cfcc 100644
> ---
> a/Platform/Intel/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens
> /BoardClkGens.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClk
> +++ Gens/BoardClkGens.c
> @@ -12,10 +12,6 @@
>  #include 
>  #include 
> 
> -#ifndef __GNUC__
> -#pragma optimize( "", off )
> -#endif
> -
>  #define CLKGEN_EN 1
>  #define EFI_DEBUG 1
> 
> @@ -415,7 +411,3 @@ InstallPlatformClocksNotify (
>return EFI_SUCCESS;
> 
>  }
> -
> -#ifndef __GNUC__
> -#pragma optimize( "", on )
> -#endif
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/CpuInitPeim.c
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/CpuInitPeim.c
> index a3a3d5cbc9..d52c449318 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/CpuInitPeim.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/CpuInitPeim.c
> @@ -28,17 +28,5 @@ PlatformCpuInit (
>IN EFI_PLATFORM_CPU_INFO   *PlatformCpuInfo
>)
>  {
> -  BOOLEAN ResetRequired;
> -
> -  //
> -  // Variable initialization
> -  //
> -  ResetRequired = FALSE;
> -
> -
> -  if (ResetRequired) {
> -CpuOnlyReset(PeiServices);
> -  }
> -
>return EFI_SUCCESS;
>  }
> diff --git
> a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c
> index d3e62e3bd0..59845a69c4 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit
> +++ .c
> @@ -17,15 +17,6 @@ Abstract:
> 
>  #include "PlatformEarlyInit.h"
> 
> -#ifdef __GNUC__
> -#pragma GCC push_options
> -#pragma GCC optimize ("O0")
> -#else
> -#pragma optimize ("", off)
> -#endif
> -
> -
> -
>  static EFI_PEI_STALL_PPI  mStallPpi = {
>PEI_STALL_RESOLUTION,
>Stall
> @@ -963,40 +954,3 @@ PlatformEarlyInitEntry (
> 
>return Status;
>  }
> -
> -EFI_STATUS
> -EFIAPI
> -CpuOnlyReset (
> -  IN CONST EFI_PEI_SERVICES   **PeiServices
> -  )
> -{
> -//  MsgBus32Write(CDV_UNIT_PUNIT, PUNIT_CPU_RST, 0x01) -#ifdef
> __GNUC__
> -  __asm__
> -  (
> -   "xorl %ecx, %ecx\n"
> -   "1:hlt; hlt; hlt\n"
> -   "jmp 1b\n"
> -  );
> -#else
> -  _asm {
> -xor   ecx, ecx
> -  HltLoop:
> -hlt
> -hlt
> -hlt
> -loop  HltLoop
> -  }
> -#endif
> -  //
> -  // If we get here we need to mark it as a failure.
> -  //
> -  return EFI_UNSUPPORTED;
> -}
> -
> -
> -#ifdef __GNUC__
> -#pragma GCC pop_options
> -#else
> -#pragma optimize ("", on)
> -#endif
> diff --git
> a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h
> index 8c02adba64..4c6b0795ec 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit
> +++ .h
> @@ -1375,12 +1375,6 @@ BOOLEAN
>  IsA16Inverted (
>);
> 
> -EFI_STATUS
> -EFIAPI
> -CpuOnlyReset (
> -  IN 

Re: [edk2-devel] [edk2-platforms Patch V3 09/12] Vlv2TbltDevicePkg: Add XCODE5 4K alignment DLINK_FLAGS

2019-07-22 Thread Sun, Zailiang
Reviewed-by: Zailiang Sun 

> -Original Message-
> From: Kinney, Michael D
> Sent: Tuesday, July 23, 2019 6:59 AM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang ; Qian, Yi ;
> Gary Lin 
> Subject: [edk2-platforms Patch V3 09/12] Vlv2TbltDevicePkg: Add XCODE5 4K
> alignment DLINK_FLAGS
> 
> Cc: Zailiang Sun 
> Cc: Yi Qian 
> Cc: Gary Lin 
> Signed-off-by: Michael D Kinney 
> ---
>  Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 2 ++
> Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc  | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> index 5149dd5aa4..30b47d8f32 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> @@ -1248,6 +1248,7 @@ [BuildOptions]
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +  XCODE:*_*_*_DLINK_FLAGS = -segalign 0x1000
> 
>  #
>  # Force PE/COFF sections to be aligned at 4KB boundaries to support page
> level @@ -1256,6 +1257,7 @@
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>  [BuildOptions.common.EDKII.DXE_SMM_DRIVER,
> BuildOptions.common.EDKII.SMM_CORE]
>MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +  XCODE:*_*_*_DLINK_FLAGS = -segalign 0x1000
> 
>  [BuildOptions.Common.EDKII]
>  !if $(CLKGEN_CONFIG_EXTRA_ENABLE) == TRUE diff --git
> a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> index 466512242c..57316d487b 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> @@ -1263,6 +1263,7 @@ [BuildOptions]
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +  XCODE:*_*_*_DLINK_FLAGS = -segalign 0x1000
> 
>  #
>  # Force PE/COFF sections to be aligned at 4KB boundaries to support page
> level @@ -1271,6 +1272,7 @@
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
>  [BuildOptions.common.EDKII.DXE_SMM_DRIVER,
> BuildOptions.common.EDKII.SMM_CORE]
>MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> +  XCODE:*_*_*_DLINK_FLAGS = -segalign 0x1000
> 
>  [BuildOptions.Common.EDKII]
>  !if $(CLKGEN_CONFIG_EXTRA_ENABLE) == TRUE
> --
> 2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44192): https://edk2.groups.io/g/devel/message/44192
Mute This Topic: https://groups.io/mt/32564744/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms Patch V3 12/12] Vlv2TbltDevicePkg/PlatformDxe: Use S3BootScriptWidth enums

2019-07-22 Thread Sun, Zailiang
Reviewed-by: Zailiang Sun 

> -Original Message-
> From: Kinney, Michael D
> Sent: Tuesday, July 23, 2019 6:59 AM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang ; Qian, Yi ;
> Gary Lin 
> Subject: [edk2-platforms Patch V3 12/12] Vlv2TbltDevicePkg/PlatformDxe:
> Use S3BootScriptWidth enums
> 
> Update to use S3BootScriptWidth enum values instead of EfiBootScriptWidth
> enum values when calling S3BootScriptLib services.  This fixes an XCODE5
> build failure.
> 
> Cc: Zailiang Sun 
> Cc: Yi Qian 
> Cc: Gary Lin 
> Signed-off-by: Michael D Kinney 
> ---
>  .../Intel/Vlv2TbltDevicePkg/PlatformDxe/Platform.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/Platform.c
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/Platform.c
> index 0bc3f44c49..d9782aafba 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/Platform.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/Platform.c
> @@ -968,25 +968,25 @@ PchInitBeforeBoot()
>// Saved SPI Opcode menu to fix EFI variable unable to write after S3
> resume.
>//
>S3BootScriptSaveMemWrite (
> - EfiBootScriptWidthUint32,
> + S3BootScriptWidthUint32,
>   (UINTN)(SPI_BASE_ADDRESS + (R_PCH_SPI_OPMENU0)),
>   1,
>   (VOID *)(UINTN)(SPI_BASE_ADDRESS +
> (R_PCH_SPI_OPMENU0)));
> 
>S3BootScriptSaveMemWrite (
> - EfiBootScriptWidthUint32,
> + S3BootScriptWidthUint32,
>   (UINTN)(SPI_BASE_ADDRESS + (R_PCH_SPI_OPMENU1)),
>   1,
>   (VOID *)(UINTN)(SPI_BASE_ADDRESS +
> (R_PCH_SPI_OPMENU1)));
> 
>S3BootScriptSaveMemWrite (
> - EfiBootScriptWidthUint16,
> + S3BootScriptWidthUint16,
>   (UINTN)(SPI_BASE_ADDRESS + R_PCH_SPI_OPTYPE),
>   1,
>   (VOID *)(UINTN)(SPI_BASE_ADDRESS + 
> R_PCH_SPI_OPTYPE));
> 
>S3BootScriptSaveMemWrite (
> - EfiBootScriptWidthUint16,
> + S3BootScriptWidthUint16,
>   (UINTN)(SPI_BASE_ADDRESS + R_PCH_SPI_PREOP),
>   1,
>   (VOID *)(UINTN)(SPI_BASE_ADDRESS + 
> R_PCH_SPI_PREOP));
> @@ -995,7 +995,7 @@ PchInitBeforeBoot()
>// Saved MTPMC_1 for S3 resume.
>//
>S3BootScriptSaveMemWrite (
> - EfiBootScriptWidthUint32,
> + S3BootScriptWidthUint32,
>   (UINTN)(PMC_BASE_ADDRESS + R_PCH_PMC_MTPMC1),
>   1,
>   (VOID *)(UINTN)(PMC_BASE_ADDRESS +
> R_PCH_PMC_MTPMC1));
> --
> 2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44195): https://edk2.groups.io/g/devel/message/44195
Mute This Topic: https://groups.io/mt/32564739/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms Patch V3 05/12] Vlv2Tbl2DevicePkg: Convert BAT/sh Build scripts to Python

2019-07-22 Thread Sun, Zailiang
Reviewed-by: Zailiang Sun 

> -Original Message-
> From: Kinney, Michael D
> Sent: Tuesday, July 23, 2019 6:59 AM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang ; Qian, Yi ;
> Gary Lin 
> Subject: [edk2-platforms Patch V3 05/12] Vlv2Tbl2DevicePkg: Convert BAT/sh
> Build scripts to Python
> 
> Convert Build_IFWI and bld_vlv BAT/sh scripts to OS
> independent python script PeBuild.py.  This script
> generates the BiosId file.  Standard EDK II build
> commands are used to build FW images and capsules.
> 
> * Sample VS2015x86 commands for IA32/X64 and DEBUG/RELEASE
>   build -a IA32 -a X64 -t VS2015x86 -p Vlv2TbltDevicePkg\PlatformPkgX64.dsc
>   build -a IA32 -a X64 -t VS2015x86 -p Vlv2TbltDevicePkg\PlatformPkgX64.dsc
>   build -a IA32-t VS2015x86 -p Vlv2TbltDevicePkg\PlatformPkgIA32.dsc
>   build -a IA32-t VS2015x86 -p Vlv2TbltDevicePkg\PlatformPkgIA32.dsc
> 
> * Sample GCC5 commands for IA32/X64 and DEBUG/RELEASE
>   build -a IA32 -a X64 -n 5 -t GCC5 -p Vlv2TbltDevicePkg/PlatformPkgX64.dsc
>   build -a IA32 -a X64 -n 5 -t GCC5 -p Vlv2TbltDevicePkg/PlatformPkgX64.dsc
>   build -a IA32-n 5 -t GCC5 -p Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
>   build -a IA32-n 5 -t GCC5 -p Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> 
> Cc: Zailiang Sun 
> Cc: Yi Qian 
> Cc: Gary Lin 
> Signed-off-by: Michael D Kinney 
> ---
>  .../Intel/Vlv2TbltDevicePkg/Build_IFWI.bat| 118 --
>  .../Intel/Vlv2TbltDevicePkg/Build_IFWI.sh | 100 -
>  .../Vlv2TbltDevicePkg/PlatformCapsule.fdf |  48 ---
>  .../Vlv2TbltDevicePkg/PlatformCapsuleIA32.dsc |  39 --
>  .../Vlv2TbltDevicePkg/PlatformCapsuleX64.dsc  |  39 --
>  .../Intel/Vlv2TbltDevicePkg/PlatformPkg.fdf   |  30 +-
>  .../Vlv2TbltDevicePkg/PlatformPkgIA32.dsc |  13 +-
>  .../Vlv2TbltDevicePkg/PlatformPkgX64.dsc  |  13 +-
>  Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py  | 348 ++
>  Platform/Intel/Vlv2TbltDevicePkg/Readme.md|  64 ++--
>  Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.bat  | 303 ---
>  Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.sh   | 222 ---
>  12 files changed, 433 insertions(+), 904 deletions(-)
>  delete mode 100644 Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat
>  delete mode 100755 Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.sh
>  delete mode 100644 Platform/Intel/Vlv2TbltDevicePkg/PlatformCapsule.fdf
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/PlatformCapsuleIA32.dsc
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/PlatformCapsuleX64.dsc
>  create mode 100644 Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py
>  delete mode 100644 Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.bat
>  delete mode 100755 Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.sh
> 
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat
> b/Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat
> deleted file mode 100644
> index f65aa61f4a..00
> --- a/Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat
> +++ /dev/null
> @@ -1,118 +0,0 @@
> -@REM @file
> -@REM   Windows batch file to build BIOS ROM
> -@REM
> -@REM Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> -@REM SPDX-License-Identifier: BSD-2-Clause-Patent
> -@REM
> -
> -@echo off
> -
> -SetLocal EnableDelayedExpansion EnableExtensions
> -
> -:: Assign initial values
> -set exitCode=0
> -set "Build_Flags= "
> -set PLATFORM_PACKAGE=Vlv2TbltDevicePkg
> -
> -set PLATFORM_PATH=%WORKSPACE%
> -if not exist %PLATFORM_PATH%\%PLATFORM_PACKAGE% (
> -  if defined PACKAGES_PATH (
> -for %%i IN (%PACKAGES_PATH%) DO (
> -  if exist %%~fi\%PLATFORM_PACKAGE% (
> -set PLATFORM_PATH=%%~fi
> -goto PlatformPackageFound
> -  )
> -)
> -  ) else (
> -echo.
> -echo !!! ERROR !!! Cannot find %PLATFORM_PACKAGE% !!!
> -echo.
> -goto Exit
> -  )
> -)
> -:PlatformPackageFound
> -
> -:: Parse Optional arguments
> -:OptLoop
> -if /i "%~1"=="/?" goto Usage
> -
> -if /i "%~1"=="/l" (
> -set Build_Flags=%Build_Flags% /l
> -shift
> -goto OptLoop
> -)
> -if /i "%~1"=="/y" (
> -set Build_Flags=%Build_Flags% /y
> -shift
> -goto OptLoop
> -)
> -if /i "%~1"=="/m" (
> -set Build_Flags=%Build_Flags% /m
> -shift
> -goto OptLoop
> -)
> -if /i "%~1" == "/c" (
> -set Build_Flags=%Build_Flags% /c
> -shift
> -goto OptLoop
> -)
> -if /i "%~1"=="/x64" (
> -set Build_Flags=%Build_Flags% /x64
> -shift
> -goto OptLoop
> -)
> -if /i "%~1"=="/IA32" (
> -set Build_Flags=%Build_Flags% /IA32
> -shift
> -goto OptLoop
> -)
> -
> -:: Require 2 input parameters
> -if "%~2"=="" goto Usage
> -
> -:: Assign required arguments
> -set Platform_Type=%~1
> -set Build_Target=%~2
> -
> -:: Build BIOS
> -echo
> ==
> 
> -echo Build_IFWI:  Calling BIOS build Script...
> -
> -
> call %PLATFORM_PATH%\%PLATFORM_PACKAGE%\bld_vlv.bat %Build_Flag
> s% %Platform_Type% %Build_Target%
> -
> -if %ERRORLEVEL% NEQ 0 (
> 

Re: [edk2-devel] [edk2-platforms Patch V3 07/12] Vlv2Tbl2DevicePkg/EfiRegTableLib: Use S3_BOOT_SCRIPT_LIB_WIDTH

2019-07-22 Thread Sun, Zailiang
Reviewed-by: Zailiang Sun 

> -Original Message-
> From: Kinney, Michael D
> Sent: Tuesday, July 23, 2019 6:59 AM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang ; Qian, Yi ;
> Gary Lin 
> Subject: [edk2-platforms Patch V3 07/12] Vlv2Tbl2DevicePkg/EfiRegTableLib:
> Use S3_BOOT_SCRIPT_LIB_WIDTH
> 
> Update calls to S3BootScriptxxx() services to use type
> S3_BOOT_SCRIPT_LIB_WIDTH instead of EFI_BOOT_SCRIPT_WIDTH.
> Fixes XCODE5 build failures.
> 
> Cc: Zailiang Sun 
> Cc: Yi Qian 
> Cc: Gary Lin 
> Signed-off-by: Michael D Kinney 
> ---
>  .../Library/EfiRegTableLib/EfiRegTableLib.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git
> a/Platform/Intel/Vlv2TbltDevicePkg/Library/EfiRegTableLib/EfiRegTableLib.c
> b/Platform/Intel/Vlv2TbltDevicePkg/Library/EfiRegTableLib/EfiRegTableLib.c
> index d698f3ada9..8b16585337 100644
> ---
> a/Platform/Intel/Vlv2TbltDevicePkg/Library/EfiRegTableLib/EfiRegTableLib.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/Library/EfiRegTableLib/EfiRegTabl
> +++ eLib.c
> @@ -55,7 +55,7 @@ PciWrite (
> 
>if (OPCODE_FLAGS (Entry->OpCode) & OPCODE_FLAG_S3SAVE) {
>  Status = S3BootScriptSavePciCfgWrite (
> -  (EFI_BOOT_SCRIPT_WIDTH) (OPCODE_EXTRA_DATA (Entry-
> >OpCode)),
> +  (S3_BOOT_SCRIPT_LIB_WIDTH) (OPCODE_EXTRA_DATA
> + (Entry->OpCode)),
>(UINT64) Entry->PciAddress,
>1,
>>Data
> @@ -111,7 +111,7 @@ PciReadModifyWrite (
> 
>if (OPCODE_FLAGS (Entry->OpCode) & OPCODE_FLAG_S3SAVE) {
>  Status = S3BootScriptSavePciCfgReadWrite (
> -  (EFI_BOOT_SCRIPT_WIDTH) (OPCODE_EXTRA_DATA (Entry-
> >OpCode)),
> +  (S3_BOOT_SCRIPT_LIB_WIDTH) (OPCODE_EXTRA_DATA
> + (Entry->OpCode)),
>(UINT64) Entry->PciAddress,
>>OrMask,
>>AndMask
> @@ -167,7 +167,7 @@ MemReadModifyWrite (
> 
>if (OPCODE_FLAGS (Entry->OpCode) & OPCODE_FLAG_S3SAVE) {
>  Status = S3BootScriptSaveMemReadWrite (
> -  (EFI_BOOT_SCRIPT_WIDTH) (OPCODE_EXTRA_DATA (Entry-
> >OpCode)),
> +  (S3_BOOT_SCRIPT_LIB_WIDTH) (OPCODE_EXTRA_DATA
> + (Entry->OpCode)),
>Entry->MemAddress,
>>OrMask,
>>AndMask
> --
> 2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44190): https://edk2.groups.io/g/devel/message/44190
Mute This Topic: https://groups.io/mt/32564742/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms Patch V3 08/12] Vlv2TbltDevicePkg/PlatformDxe: Add missing #if

2019-07-22 Thread Sun, Zailiang
Reviewed-by: Zailiang Sun 

> -Original Message-
> From: Kinney, Michael D
> Sent: Tuesday, July 23, 2019 6:59 AM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang ; Qian, Yi ;
> Gary Lin 
> Subject: [edk2-platforms Patch V3 08/12] Vlv2TbltDevicePkg/PlatformDxe:
> Add missing #if
> 
> Add missing #if for SENSOR_INFO_VAR_SUPPORT around the function
> InitializeSensorInfoVariable().  This function is referencing 2 global 
> variables
> that are not defined, and this breaks VS2017 for undefined global variables.
> 
> Cc: Zailiang Sun 
> Cc: Yi Qian 
> Cc: Gary Lin 
> Signed-off-by: Michael D Kinney 
> ---
>  Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/SensorVar.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/SensorVar.c
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/SensorVar.c
> index 5d13e99443..6efb989bc0 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/SensorVar.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/SensorVar.c
> @@ -85,6 +85,7 @@ SENSOR_INFO_VAR   mSensorInfoData =
>  }
>  };
> 
> +#if defined(SENSOR_INFO_VAR_SUPPORT) &&
> SENSOR_INFO_VAR_SUPPORT != 0
>  /**
> 
>Write the Sensor Info variable if it does not already exist.
> @@ -109,4 +110,5 @@ InitializeSensorInfoVariable (
>   
>   );
>  }
> +#endif
> 
> --
> 2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44191): https://edk2.groups.io/g/devel/message/44191
Mute This Topic: https://groups.io/mt/32564738/21656
Mute #if: https://groups.io/mk?hashtag=if=3846945
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms Patch V3 06/12] Vlv2TbltDevicePkg: Remove non ASCII characters from source files

2019-07-22 Thread Sun, Zailiang
Reviewed-by: Zailiang Sun 

> -Original Message-
> From: Kinney, Michael D
> Sent: Tuesday, July 23, 2019 6:59 AM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang ; Qian, Yi ;
> Gary Lin 
> Subject: [edk2-platforms Patch V3 06/12] Vlv2TbltDevicePkg: Remove non
> ASCII characters from source files
> 
> Remove non-ASCII characters from comments in source files.  These are
> preventing the build tool from generating report files on Linux systems.
> 
> Cc: Zailiang Sun 
> Cc: Yi Qian 
> Cc: Gary Lin 
> Signed-off-by: Michael D Kinney 
> ---
>  .../Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c | 2 +-
>  Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c   | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
> index 4a51a47e36..71d6cb7c15 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
> @@ -461,7 +461,7 @@ UARTInit (
>if (SystemConfiguration->LpssHsuart0Enabled == 1){
>  //
>  //Valleyview BIOS Specification Vol2,17.2
> -//LPSS_UART1  C set each pad PAD_CONF0.Func_Pin_Mux to function 1:
> +//LPSS_UART1 C set each pad PAD_CONF0.Func_Pin_Mux to function 1:
>  //
>  MmioAnd8 (IO_BASE_ADDRESS + 0x0090, (UINT8)~0x07);
>  MmioOr8 (IO_BASE_ADDRESS + 0x0090, 0x01); diff --git
> a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
> index 4c0e660b7f..2061b8d559 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
> @@ -205,9 +205,9 @@ GetSleepTypeAfterWakeup (
>// VLV BIOS Specification 0.6.2 - Section 18.4, "Power Failure 
> Consideration"
>//
>// When the SUS_PWR_FLR bit is set, it indicates the SUS well power is 
> lost.
> -  // This bit is in the SUS Well and defaults to 1 b1 based on RSMRST#
> assertion (not cleared by any type of reset).
> +  // This bit is in the SUS Well and defaults to 1'b1 based on RSMRST#
> assertion (not cleared by any type of reset).
>// System BIOS should follow cold boot path if SUS_PWR_FLR (PBASE +
> 0x20[14]),
> -  // GEN_RST_STS (PBASE + 0x20[9]) or PWRBTNOR_STS (ABASE + 0x00[11])
> is set to 1 b1
> +  // GEN_RST_STS (PBASE + 0x20[9]) or PWRBTNOR_STS (ABASE + 0x00[11])
> + is set to 1'b1
>// regardless of the value in the SLP_TYP (ABASE + 0x04[12:10]) field.
>//
>GenPmCon1 = MmioRead16 (PMC_BASE_ADDRESS +
> R_PCH_PMC_GEN_PMCON_1);
> --
> 2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44189): https://edk2.groups.io/g/devel/message/44189
Mute This Topic: https://groups.io/mt/32564740/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms Patch V3 04/12] Vlv2TbltDevicePkg: Convert BAT/sh Capsule scripts to Python

2019-07-22 Thread Sun, Zailiang
Reviewed-by: Zailiang Sun 

> -Original Message-
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Michael D Kinney
> Sent: Tuesday, July 23, 2019 6:59 AM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang ; Qian, Yi ;
> Gary Lin 
> Subject: [edk2-devel] [edk2-platforms Patch V3 04/12] Vlv2TbltDevicePkg:
> Convert BAT/sh Capsule scripts to Python
> 
> Convert all the BAT/sh files used to generate capsules to
> OS independent Python script.
> 
> Cc: Zailiang Sun 
> Cc: Yi Qian 
> Cc: Gary Lin 
> Signed-off-by: Michael D Kinney 
> Reviewed-by: Zailiang Sun 
> ---
>  .../Capsule/GenerateCapsule/GenCapsuleAll.bat |  35 --
>  .../Capsule/GenerateCapsule/GenCapsuleAll.py  | 397
> ++
>  .../Capsule/GenerateCapsule/GenCapsuleAll.sh  |  33 --
>  .../GenerateCapsule/GenCapsuleMinnowMax.bat   | 131 --
>  .../GenerateCapsule/GenCapsuleMinnowMax.sh|  59 ---
>  .../GenCapsuleMinnowMaxRelease.bat| 131 --
>  .../GenCapsuleMinnowMaxRelease.sh |  64 ---
>  .../GenerateCapsule/GenCapsuleSampleColor.bat | 137 --
>  .../GenerateCapsule/GenCapsuleSampleColor.sh  |  70 ---
>  .../Feature/Capsule/GenerateCapsule/Lvfs.ddf  |  14 -
>  .../LvfsGenCapsuleMinnowMax.bat   | 139 --
>  .../LvfsGenCapsuleMinnowMaxRelease.bat| 139 --
>  .../LvfsGenCapsuleSampleColor.bat | 145 ---
>  .../GenerateCapsule/template.metainfo.xml |  27 --
>  .../Vlv2TbltDevicePkg/PlatformCapsuleIA32.dsc |   2 +-
>  .../Vlv2TbltDevicePkg/PlatformCapsuleX64.dsc  |   2 +-
>  16 files changed, 399 insertions(+), 1126 deletions(-)
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenC
> apsuleAll.bat
>  create mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenC
> apsuleAll.py
>  delete mode 100755
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenC
> apsuleAll.sh
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenC
> apsuleMinnowMax.bat
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenC
> apsuleMinnowMax.sh
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenC
> apsuleMinnowMaxRelease.bat
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenC
> apsuleMinnowMaxRelease.sh
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenC
> apsuleSampleColor.bat
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenC
> apsuleSampleColor.sh
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/Lvfs.d
> df
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/LvfsG
> enCapsuleMinnowMax.bat
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/LvfsG
> enCapsuleMinnowMaxRelease.bat
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/LvfsG
> enCapsuleSampleColor.bat
>  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/templ
> ate.metainfo.xml
> 
> diff --git
> a/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/Ge
> nCapsuleAll.bat
> b/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/Ge
> nCapsuleAll.bat
> deleted file mode 100644
> index 8f589565fa..00
> ---
> a/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/Ge
> nCapsuleAll.bat
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -@REM @file
> -@REM   Windows batch file to generate UEFI capsules for system firmware
> and
> -@REM   firmware for sample devices
> -@REM
> -@REM Copyright (c) 2018, Intel Corporation. All rights reserved.
> -@REM SPDX-License-Identifier: BSD-2-Clause-Patent
> -@REM
> -
> -@echo off
> -setlocal
> -cd /d %~dp0
> -
> -rmdir /s /q %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules
> -mkdir %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules
> -
> mkdir %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\SampleDevelopm
> ent
> -mkdir %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\NewCert
> -mkdir %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\TestCert
> -
> copy %WORKSPACE%\Build\Vlv2TbltDevicePkg\DEBUG_VS2015x86\X64\Cap
> suleApp.efi %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\SampleDeve
> lopment\CapsuleApp.efi
> -
> copy %WORKSPACE%\Build\Vlv2TbltDevicePkg\RELEASE_VS2015x86\X64\Ca
> psuleApp.efi %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\SampleDev
> elopment\CapsuleAppRelease.efi
> -
> copy %WORKSPACE%\Build\Vlv2TbltDevicePkg\DEBUG_VS2015x86\X64\Cap
> suleApp.efi %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\NewCert\Ca
> psuleApp.efi
> -
> copy %WORKSPACE%\Build\Vlv2TbltDevicePkg\RELEASE_VS2015x86\X64\Ca
> psuleApp.efi %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\NewCert\C
> apsuleAppRelease.efi
> -
> copy 

Re: [edk2-devel] [edk2-platforms Patch V3 01/12] Vlv2TbltDevicePkg/PlatformPei: Add boot mode detection

2019-07-22 Thread Sun, Zailiang
Reviewed-by: Zailiang Sun 

> -Original Message-
> From: Kinney, Michael D
> Sent: Tuesday, July 23, 2019 6:59 AM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang ; Qian, Yi ;
> Gary Lin 
> Subject: [edk2-platforms Patch V3 01/12] Vlv2TbltDevicePkg/PlatformPei:
> Add boot mode detection
> 
> Add boot mode detection back into PlatformPei that was inadvertently
> removed in the following commit:
> 
> https://github.com/tianocore/edk2-
> platforms/commit/d6211390793fbd0a89b14001c43e0ef942c85425
> 
> Boot mode detection at this point is required to detect the boot mode of
> BOOT_ON_FLASH_UPDATE that is required to detect, coalesce, and process
> UEFI Capsules.
> 
> Cc: Zailiang Sun 
> Cc: Yi Qian 
> Cc: Gary Lin 
> Signed-off-by: Michael D Kinney 
> Reviewed-by: Zailiang Sun 
> ---
>  .../Vlv2TbltDevicePkg/PlatformPei/BootMode.c  | 92
> ++-  .../Vlv2TbltDevicePkg/PlatformPei/Platform.c  |  6
> ++  .../Vlv2TbltDevicePkg/PlatformPei/Platform.h  | 17 
>  3 files changed, 114 insertions(+), 1 deletion(-)
> 
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
> index 5269b1ed39..4c0e660b7f 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
> @@ -82,7 +82,7 @@ CapsulePpiNotifyCallback (
>  if (Status == EFI_SUCCESS) {
>if (Capsule->CheckCapsuleUpdate ((EFI_PEI_SERVICES**)PeiServices) ==
> EFI_SUCCESS) {
>  BootMode = BOOT_ON_FLASH_UPDATE;
> -DEBUG ((EFI_D_ERROR, "Setting BootMode to
> BOOT_ON_FLASH_UPDATE\n"));
> +DEBUG ((DEBUG_ERROR, "Setting BootMode to
> + BOOT_ON_FLASH_UPDATE\n"));
>  Status = (*PeiServices)->SetBootMode((const EFI_PEI_SERVICES
> **)PeiServices, BootMode);
>  ASSERT_EFI_ERROR (Status);
>}
> @@ -92,6 +92,96 @@ CapsulePpiNotifyCallback (
>return Status;
>  }
> 
> +EFI_STATUS
> +UpdateBootMode (
> +  IN CONST EFI_PEI_SERVICES **PeiServices
> +  )
> +{
> +  EFI_STATUS  Status;
> +  EFI_BOOT_MODE   BootMode;
> +  UINT16  SleepType;
> +  CHAR16  *strBootMode;
> +
> +  Status = (*PeiServices)->GetBootMode(PeiServices, );
> + ASSERT_EFI_ERROR (Status);  if (BootMode  ==
> BOOT_IN_RECOVERY_MODE){
> +return Status;
> +  }
> +
> +  //
> +  // Let's assume things are OK if not told otherwise  //  BootMode =
> + BOOT_WITH_FULL_CONFIGURATION;
> +
> +  if (GetSleepTypeAfterWakeup (PeiServices, )) {
> +switch (SleepType) {
> +  case V_PCH_ACPI_PM1_CNT_S3:
> +BootMode = BOOT_ON_S3_RESUME;
> +Status = (*PeiServices)->NotifyPpi (PeiServices,
> [0]);
> +ASSERT_EFI_ERROR (Status);
> +break;
> +
> +  case V_PCH_ACPI_PM1_CNT_S4:
> +BootMode = BOOT_ON_S4_RESUME;
> +break;
> +
> +  case V_PCH_ACPI_PM1_CNT_S5:
> +BootMode = BOOT_ON_S5_RESUME;
> +break;
> +} // switch (SleepType)
> +  }
> +
> +  if (IsFastBootEnabled (PeiServices)) {
> +DEBUG ((DEBUG_INFO, "Prioritizing Boot mode to
> BOOT_WITH_MINIMAL_CONFIGURATION\n"));
> +PrioritizeBootMode (,
> BOOT_WITH_MINIMAL_CONFIGURATION);  }
> +
> +  switch (BootMode) {
> +case BOOT_WITH_FULL_CONFIGURATION:
> +  strBootMode = L"BOOT_WITH_FULL_CONFIGURATION";
> +  break;
> +case BOOT_WITH_MINIMAL_CONFIGURATION:
> +  strBootMode = L"BOOT_WITH_MINIMAL_CONFIGURATION";
> +  break;
> +case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
> +  strBootMode = L"BOOT_ASSUMING_NO_CONFIGURATION_CHANGES";
> +  break;
> +case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
> +  strBootMode =
> L"BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS";
> +  break;
> +case BOOT_WITH_DEFAULT_SETTINGS:
> +  strBootMode = L"BOOT_WITH_DEFAULT_SETTINGS";
> +  break;
> +case BOOT_ON_S4_RESUME:
> +  strBootMode = L"BOOT_ON_S4_RESUME";
> +  break;
> +case BOOT_ON_S5_RESUME:
> +  strBootMode = L"BOOT_ON_S5_RESUME";
> +  break;
> +case BOOT_ON_S2_RESUME:
> +  strBootMode = L"BOOT_ON_S2_RESUME";
> +  break;
> +case BOOT_ON_S3_RESUME:
> +  strBootMode = L"BOOT_ON_S3_RESUME";
> +
> +  break;
> +case BOOT_ON_FLASH_UPDATE:
> +  strBootMode = L"BOOT_ON_FLASH_UPDATE";
> +  break;
> +case BOOT_IN_RECOVERY_MODE:
> +  strBootMode = L"BOOT_IN_RECOVERY_MODE";
> +  break;
> +default:
> +  strBootMode = L"Unknown boot mode";  } // switch (BootMode)
> +
> +  DEBUG ((DEBUG_ERROR, "Setting BootMode to %s\n", strBootMode));
> + Status = (*PeiServices)->SetBootMode(PeiServices, BootMode);
> + ASSERT_EFI_ERROR (Status);
> +
> +  return Status;
> +}
> +
>  /**
>Get sleep type after wakeup
> 
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/Platform.c
> b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/Platform.c
> index 90998871dc..1b23bc9740 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/Platform.c
> +++ 

Re: [edk2-devel] [edk2-platforms Patch V3 00/12] Vlv2Tbl2DevicePkg: Remove Linux/Windows differences

2019-07-22 Thread Sun, Zailiang
Reviewed-by: Zailiang Sun 

> -Original Message-
> From: Kinney, Michael D
> Sent: Tuesday, July 23, 2019 6:59 AM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang ; Qian, Yi ;
> Gary Lin 
> Subject: [edk2-platforms Patch V3 00/12] Vlv2Tbl2DevicePkg: Remove
> Linux/Windows differences
> 
> New in V3
> -
> * Fix Readme.md for Linux in PACKAGES_PATH setting and edksetup.sh
> invocation.
> * Remove non-ASCII characters from source files that is preventing build
> report
>   generation on Linux systems.
> * Fix XCODE5 build break in Vlv2TbltDevicePkg/Library/EfiRegTableLib due
>   to use of EFI_BOOT_SCRIPT_WIDTH instead of
> S3_BOOT_SCRIPT_LIB_WIDTH.
> * Add missing #ifdef around InitializeSensorInfoVariable() in PlatformDxe.
> * Add XCODE5 specific DLINK_FLAGS for 4KB aligned sections.
> * Remove extra sets of parenthesis in if statements to resolve XCODE5
>   build failures.
> * Move a local variable declaration structure init to a module global
>   variable to avoid use of memcpy() by XCODE5.
> * Remove use of #ifdefs on __GNUC__ to make builds the same for all
>   toolchains.  This resolves an XCODE5 build failure due to an unsupported
>   pragma.
> * Replace the use of EfiBootScriptWidth enum values with S3BootScriptWidth
>   enum values when calling S3BootScriptLib services.  This resolves an
>   XCODE5 build failure.
> 
> New in V2
> --
> * Remove MANUFACTURING defaults from DSC file.  They are the same as
> STANDARD
>   defaults, so there is not need to add a MANUFACTURING default section
> unless
>   there are differences.
> * Update PlatformSetupDxe to return EFI_UNSUPPORTED from the
> RouteConfig() and
>   ExtractConfig() services of the HII_CONFIG_ACCESS_PROTOCOL.
> 
> Branch for review:
> 
> https://github.com/mdkinney/edk2-
> platforms/tree/Bug_xxx_Vlv2_Remove_FCE_BAT_sh_V3
> 
> Remove all BAT/sh scripts and use OS independent python scripts for
> PREBULD and POSTBUILD operations and use standard EDK II build command
> to build MinnowMax FW images and capsules.
> 
> The use of FCE has also been removed and replaced with a Structured PCD.
> The default values for Setup forms are now in the file
> PlatformSetupDefaults.dsc.
> 
> A regression bug introduced by a recent commit that broke the detection of
> the BOOT_ON_FLASH_UPDATE boot mode has also been fixed.  Capsules are
> detected and processed correctly again.
> 
> Cc: Zailiang Sun 
> Cc: Yi Qian 
> Cc: Gary Lin 
> Signed-off-by: Michael D Kinney 
> 
> Michael D Kinney (12):
>   Vlv2TbltDevicePkg/PlatformPei: Add boot mode detection
>   Vlv2TbltDevicePkg: Convert use of FCE tool to Structured PCD
>   Vlv2TbltDevicePkg: Remove Linux/GCC specific DSC/FDF files
>   Vlv2TbltDevicePkg: Convert BAT/sh Capsule scripts to Python
>   Vlv2Tbl2DevicePkg: Convert BAT/sh Build scripts to Python
>   Vlv2TbltDevicePkg: Remove non ASCII characters from source files
>   Vlv2Tbl2DevicePkg/EfiRegTableLib: Use S3_BOOT_SCRIPT_LIB_WIDTH
>   Vlv2TbltDevicePkg/PlatformDxe: Add missing #if
>   Vlv2TbltDevicePkg: Add XCODE5 4K alignment DLINK_FLAGS
>   Vlv2TbltDevicePkg: Fix XCODE5 build errors
>   Vlv2TbltDevicePkg: Remove __GNUC__ specific #ifdefs
>   Vlv2TbltDevicePkg/PlatformDxe: Use S3BootScriptWidth enums
> 
>  .../AcpiPlatform/AcpiPlatform.c   |   15 +-
>  Platform/Intel/Vlv2TbltDevicePkg/BfmLib.exe   |  Bin 499712 -> 0 bytes
>  .../Intel/Vlv2TbltDevicePkg/Build_IFWI.bat|  118 --
>  .../Intel/Vlv2TbltDevicePkg/Build_IFWI.sh |  100 --
>  Platform/Intel/Vlv2TbltDevicePkg/FCE.exe  |  Bin 632832 -> 0 bytes
>  .../Capsule/GenerateCapsule/GenCapsuleAll.bat |   35 -
>  .../Capsule/GenerateCapsule/GenCapsuleAll.py  |  397 +
>  .../Capsule/GenerateCapsule/GenCapsuleAll.sh  |   33 -
>  .../GenerateCapsule/GenCapsuleMinnowMax.bat   |  131 --
>  .../GenerateCapsule/GenCapsuleMinnowMax.sh|   59 -
>  .../GenCapsuleMinnowMaxRelease.bat|  131 --
>  .../GenCapsuleMinnowMaxRelease.sh |   64 -
>  .../GenerateCapsule/GenCapsuleSampleColor.bat |  137 --
>  .../GenerateCapsule/GenCapsuleSampleColor.sh  |   70 -
>  .../Feature/Capsule/GenerateCapsule/Lvfs.ddf  |   14 -
>  .../LvfsGenCapsuleMinnowMax.bat   |  139 --
>  .../LvfsGenCapsuleMinnowMaxRelease.bat|  139 --
>  .../LvfsGenCapsuleSampleColor.bat |  145 --
>  .../GenerateCapsule/template.metainfo.xml |   27 -
>  .../SystemFirmwareDescriptor.aslc |   83 --
>  .../SystemFirmwareDescriptor.inf  |   40 -
>  .../SystemFirmwareDescriptorPei.c |   60 -
>  .../SystemFirmwareUpdateConfig.ini|   66 -
>  .../SystemFirmwareUpdateConfigGcc.ini |   66 -
>  .../Library/EfiRegTableLib/EfiRegTableLib.c   |6 +-
>  .../BoardClkGens/BoardClkGens.c   |8 -
>  .../PciPlatform/PciPlatform.c |2 +-
>  .../Vlv2TbltDevicePkg/PlatformCapsule.dsc |   39 -
>  .../Vlv2TbltDevicePkg/PlatformCapsule.fdf |   52 -
>  

[edk2-devel] [PATCH] BaseTools:Fix GenFds multi-thread build fails if enable build cache

2019-07-22 Thread Fan, ZhijuX
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1923

The GenFds multi-thread will build fail if enable the build cache.
1. First, produce the build cache:
edk2>build -p OvmfPkg\OvmfPkgIa32X64.dsc -a IA32 -a X64 -t VS2015x86 -n 5
--genfds-multi-thread --hash --binary-destination=BinCache

2. Remove the build folder:
edk2>rmdir Build /s /q

3. Clean build with build cache and GenFds multi-thread enabled together:
edk2>build -p OvmfPkg\OvmfPkgIa32X64.dsc -a IA32 -a X64 -t VS2015x86 -n 5
--genfds-multi-thread --hash --binary-source=BinCache

If disable GenFds multi-thread, the build cache can work well

This patch is going to fix that issue.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Shi, Steven 
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 41 ++
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index e8e09dc8a3..77eca79fc2 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -3584,6 +3584,7 @@ class ModuleAutoGen(AutoGen):
 retVal = set()
 OutputDir = self.OutputDir.replace('\\', '/').strip('/')
 DebugDir = self.DebugDir.replace('\\', '/').strip('/')
+FfsOutputDir = self.FfsOutputDir.replace('\\', '/').rstrip('/')
 for Item in self.CodaTargetList:
 File = Item.Target.Path.replace('\\', 
'/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/')
 retVal.add(File)
@@ -3599,6 +3600,11 @@ class ModuleAutoGen(AutoGen):
 if File.lower().endswith('.pdb'):
 retVal.add(File)
 
+for Root, Dirs, Files in os.walk(FfsOutputDir):
+for File in Files:
+if File.lower().endswith('.ffs'):
+retVal.add(File)
+
 return retVal
 
 ## Create AsBuilt INF file the module
@@ -3929,8 +3935,16 @@ class ModuleAutoGen(AutoGen):
 
 self.IsAsBuiltInfCreated = True
 
+def CacheCopyFile(self, OriginDir, CopyDir, File):
+sub_dir = os.path.relpath(File, CopyDir)
+destination_file = os.path.join(OriginDir, sub_dir)
+destination_dir = os.path.dirname(destination_file)
+CreateDirectory(destination_dir)
+CopyFileOnChange(File, destination_dir)
+
 def CopyModuleToCache(self):
 FileDir = path.join(GlobalData.gBinCacheDest, 
self.PlatformInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, 
self.Arch, self.SourceDir, self.MetaFile.BaseName)
+FfsDir = path.join(GlobalData.gBinCacheDest, 
self.PlatformInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, 
TAB_FV_DIRECTORY, "Ffs", self.Guid + self.Name)
 CreateDirectory (FileDir)
 HashFile = path.join(self.BuildDir, self.Name + '.hash')
 if os.path.exists(HashFile):
@@ -3946,13 +3960,15 @@ class ModuleAutoGen(AutoGen):
 for File in self.OutputFile:
 File = str(File)
 if not os.path.isabs(File):
-File = os.path.join(self.OutputDir, File)
+NewFile = os.path.join(self.OutputDir, File)
+if not os.path.exists(NewFile):
+NewFile = os.path.join(self.FfsOutputDir, File)
+File = NewFile
 if os.path.exists(File):
-sub_dir = os.path.relpath(File, self.OutputDir)
-destination_file = os.path.join(FileDir, sub_dir)
-destination_dir = os.path.dirname(destination_file)
-CreateDirectory(destination_dir)
-CopyFileOnChange(File, destination_dir)
+if File.endswith('.ffs'):
+self.CacheCopyFile(FfsDir, self.FfsOutputDir, File)
+else:
+self.CacheCopyFile(FileDir, self.OutputDir, File)
 
 def AttemptModuleCacheCopy(self):
 # If library or Module is binary do not skip by hash
@@ -3963,6 +3979,7 @@ class ModuleAutoGen(AutoGen):
 if '.inc' in str(f_ext):
 return False
 FileDir = path.join(GlobalData.gBinCacheSource, 
self.PlatformInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, 
self.Arch, self.SourceDir, self.MetaFile.BaseName)
+FfsDir = path.join(GlobalData.gBinCacheSource, 
self.PlatformInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, 
TAB_FV_DIRECTORY, "Ffs", self.Guid + self.Name)
 HashFile = path.join(FileDir, self.Name + '.hash')
 if os.path.exists(HashFile):
 f = open(HashFile, 'r')
@@ -3977,11 +3994,13 @@ class ModuleAutoGen(AutoGen):
 CopyFileOnChange(HashFile, self.BuildDir)
 else:
 File = path.join(root, f)
-sub_dir = os.path.relpath(File, FileDir)
-destination_file = 
os.path.join(self.OutputDir, sub_dir)

[edk2-devel] [PATCH v2] OvmfPkg/build.sh: enable multitheaded build by default

2019-07-22 Thread rebecca
Enable multithreaded builds by default when building OvmfPkg
using build.sh.
This can drastically reduce build times. For example, on a
modern ThreadRipper system the time required to build decreases
from 3 minutes to 1 minute.

Signed-off-by: Rebecca Cran 
---
 OvmfPkg/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/OvmfPkg/build.sh b/OvmfPkg/build.sh
index 4fcbdd2bc9..bacab5e22a 100755
--- a/OvmfPkg/build.sh
+++ b/OvmfPkg/build.sh
@@ -40,7 +40,7 @@ ARCH_X64=no
 BUILDTARGET=DEBUG
 BUILD_OPTIONS=
 PLATFORMFILE=
-THREADNUMBER=1
+THREADNUMBER=0
 LAST_ARG=
 RUN_QEMU=no
 ENABLE_FLASH=no
-- 
2.22.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44181): https://edk2.groups.io/g/devel/message/44181
Mute This Topic: https://groups.io/mt/32565505/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] OvmfPkg: enable multiprocessor builds when using build.sh

2019-07-22 Thread rebecca
On 2019-07-22 17:14, Jordan Justen wrote:
>
> I was suggesting that if they didn't specify -n as a param to
> build.sh, then build.sh should not send -n to the edk2 build command.
> The effect would be for the edk2 build command to check
> Conf/target.txt. By default, I think target.txt will not set
> THREADNUMBER, so "0" would still be the result.
>
> Yet, it would give them the option to set it in Conf/target.txt.
> Today, since we always use the -n param, target.txt is always ignored
> for this parameter.


On a related topic, I wonder if we should add a "-j" parameter if we
build BaseTools for users (e.g. "make -j4 -C BaseTools")? I've found
that it can be pretty slow without it: on my system adding -j4 reduces
build time from 55 seconds to 15. Going higher doesn't seem to produce
much more benefit: -j32 (on a ThreadRipper system) reduces it to 12 seconds.


-- 
Rebecca Cran


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44180): https://edk2.groups.io/g/devel/message/44180
Mute This Topic: https://groups.io/mt/32553200/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] OvmfPkg: enable multiprocessor builds when using build.sh

2019-07-22 Thread rebecca
On 2019-07-22 17:14, Jordan Justen wrote:
>
> But, personally, I don't think the Conf directory is useful. I'd like
> to see us deprecate it entirely, or at least make it optional.
> Therefore, I think the best use of our time is to just set it to 0 as
> you suggest. :)


Thanks, I'll send a v2 patch in a while.


-- 
Rebecca Cran


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44179): https://edk2.groups.io/g/devel/message/44179
Mute This Topic: https://groups.io/mt/32553200/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] OvmfPkg: enable multiprocessor builds when using build.sh

2019-07-22 Thread Jordan Justen
On 2019-07-22 13:06:03, Laszlo Ersek wrote:
> On 07/22/19 09:11, Jordan Justen wrote:
> 
> > It looks like if we tweaked things more, and omitted adding the -n
> > parameter to the build command by default, then it would use the
> > Conf/target.txt value, which by default appears to also be 0, so this
> > could accomplish the same thing, but also let a user set it in
> > target.txt.
> 
> I assume that users prefer passing a simple command line parameter to
> editing a text file. IOW I believe "THREADNUMBER=0" would be the best
> solution.
> 

TL;DR: I agree with you. :)

I think they prefer to do neither, and get the same result as "0". :)

I was suggesting that if they didn't specify -n as a param to
build.sh, then build.sh should not send -n to the edk2 build command.
The effect would be for the edk2 build command to check
Conf/target.txt. By default, I think target.txt will not set
THREADNUMBER, so "0" would still be the result.

Yet, it would give them the option to set it in Conf/target.txt.
Today, since we always use the -n param, target.txt is always ignored
for this parameter.

But, personally, I don't think the Conf directory is useful. I'd like
to see us deprecate it entirely, or at least make it optional.
Therefore, I think the best use of our time is to just set it to 0 as
you suggest. :)

-Jordan

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44178): https://edk2.groups.io/g/devel/message/44178
Mute This Topic: https://groups.io/mt/32553200/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v3 24/35] OvmfPkg/XenPlatformPei: Rework memory detection

2019-07-22 Thread Laszlo Ersek
On 07/22/19 21:45, Laszlo Ersek wrote:

> we place the 32-bit PCI IOMMU aperture based on [...]

Do I get a medal for this hugely confusing typo? :)

In earnest, I'm sorry about it -- my comment had nothing to do with
"IOMMU"; I meant "MMIO". (At least I got it right in the rest of the email.)

Sorry!
Laszlo

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44177): https://edk2.groups.io/g/devel/message/44177
Mute This Topic: https://groups.io/mt/32308708/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms Patch V3 11/12] Vlv2TbltDevicePkg: Remove __GNUC__ specific #ifdefs

2019-07-22 Thread Michael D Kinney
Remove #ifdefs for __GNUC__, so the builds are the
same for GCC, VS20xx, and XCODE5.  This resolves an
XCODE5 build break for an unsupported pragma.

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Gary Lin 
Signed-off-by: Michael D Kinney 
---
 .../AcpiPlatform/AcpiPlatform.c   |  3 --
 .../BoardClkGens/BoardClkGens.c   |  8 
 .../PlatformInitPei/CpuInitPeim.c | 12 -
 .../PlatformInitPei/PlatformEarlyInit.c   | 46 ---
 .../PlatformInitPei/PlatformEarlyInit.h   |  6 ---
 5 files changed, 75 deletions(-)

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c 
b/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
index 3e0b978120..37f899d7f5 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
@@ -51,9 +51,6 @@ CHAR16gACPIOSFRRefDataBlockVariableName[] = 
ACPI_OSFR_REF_DATA_BLOCK_VARIABL
 CHAR16gACPIOSFRMfgStringVariableName[] = 
ACPI_OSFR_MFG_STRING_VARIABLE_NAME;
 
 EFI_GLOBAL_NVS_AREA_PROTOCOLmGlobalNvsArea;
-#ifndef __GNUC__
-#pragma optimize("", off)
-#endif
 BOOLEAN   mFirstNotify;
 EFI_PLATFORM_INFO_HOB *mPlatformInfo;
 EFI_GUID  mSystemConfigurationGuid = SYSTEM_CONFIGURATION_GUID;
diff --git 
a/Platform/Intel/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c
 
b/Platform/Intel/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c
index 4356f7b366..f00f10cfcc 100644
--- 
a/Platform/Intel/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c
+++ 
b/Platform/Intel/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c
@@ -12,10 +12,6 @@
 #include 
 #include 
 
-#ifndef __GNUC__
-#pragma optimize( "", off )
-#endif
-
 #define CLKGEN_EN 1
 #define EFI_DEBUG 1
 
@@ -415,7 +411,3 @@ InstallPlatformClocksNotify (
   return EFI_SUCCESS;
 
 }
-
-#ifndef __GNUC__
-#pragma optimize( "", on )
-#endif
diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/CpuInitPeim.c 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/CpuInitPeim.c
index a3a3d5cbc9..d52c449318 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/CpuInitPeim.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/CpuInitPeim.c
@@ -28,17 +28,5 @@ PlatformCpuInit (
   IN EFI_PLATFORM_CPU_INFO   *PlatformCpuInfo
   )
 {
-  BOOLEAN ResetRequired;
-
-  //
-  // Variable initialization
-  //
-  ResetRequired = FALSE;
-
-
-  if (ResetRequired) {
-CpuOnlyReset(PeiServices);
-  }
-
   return EFI_SUCCESS;
 }
diff --git 
a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c
index d3e62e3bd0..59845a69c4 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c
@@ -17,15 +17,6 @@ Abstract:
 
 #include "PlatformEarlyInit.h"
 
-#ifdef __GNUC__
-#pragma GCC push_options
-#pragma GCC optimize ("O0")
-#else
-#pragma optimize ("", off)
-#endif
-
-
-
 static EFI_PEI_STALL_PPI  mStallPpi = {
   PEI_STALL_RESOLUTION,
   Stall
@@ -963,40 +954,3 @@ PlatformEarlyInitEntry (
 
   return Status;
 }
-
-EFI_STATUS
-EFIAPI
-CpuOnlyReset (
-  IN CONST EFI_PEI_SERVICES   **PeiServices
-  )
-{
-//  MsgBus32Write(CDV_UNIT_PUNIT, PUNIT_CPU_RST, 0x01)
-#ifdef __GNUC__
-  __asm__
-  (
-   "xorl %ecx, %ecx\n"
-   "1:hlt; hlt; hlt\n"
-   "jmp 1b\n"
-  );
-#else
-  _asm {
-xor   ecx, ecx
-  HltLoop:
-hlt
-hlt
-hlt
-loop  HltLoop
-  }
-#endif
-  //
-  // If we get here we need to mark it as a failure.
-  //
-  return EFI_UNSUPPORTED;
-}
-
-
-#ifdef __GNUC__
-#pragma GCC pop_options
-#else
-#pragma optimize ("", on)
-#endif
diff --git 
a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h
index 8c02adba64..4c6b0795ec 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.h
@@ -1375,12 +1375,6 @@ BOOLEAN
 IsA16Inverted (
   );
 
-EFI_STATUS
-EFIAPI
-CpuOnlyReset (
-  IN CONST EFI_PEI_SERVICES   **PeiServices
-  );
-
 EFI_STATUS
 EFIAPI
 InitLan (
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44170): https://edk2.groups.io/g/devel/message/44170
Mute This Topic: https://groups.io/mt/32564737/21656
Mute #ifdefs: https://groups.io/mk?hashtag=ifdefs=3846945
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms Patch V3 09/12] Vlv2TbltDevicePkg: Add XCODE5 4K alignment DLINK_FLAGS

2019-07-22 Thread Michael D Kinney
Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Gary Lin 
Signed-off-by: Michael D Kinney 
---
 Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 2 ++
 Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index 5149dd5aa4..30b47d8f32 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -1248,6 +1248,7 @@ [BuildOptions]
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+  XCODE:*_*_*_DLINK_FLAGS = -segalign 0x1000
 
 #
 # Force PE/COFF sections to be aligned at 4KB boundaries to support page level
@@ -1256,6 +1257,7 @@ [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
 [BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
   MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+  XCODE:*_*_*_DLINK_FLAGS = -segalign 0x1000
 
 [BuildOptions.Common.EDKII]
 !if $(CLKGEN_CONFIG_EXTRA_ENABLE) == TRUE
diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index 466512242c..57316d487b 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -1263,6 +1263,7 @@ [BuildOptions]
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+  XCODE:*_*_*_DLINK_FLAGS = -segalign 0x1000
 
 #
 # Force PE/COFF sections to be aligned at 4KB boundaries to support page level
@@ -1271,6 +1272,7 @@ [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
 [BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
   MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+  XCODE:*_*_*_DLINK_FLAGS = -segalign 0x1000
 
 [BuildOptions.Common.EDKII]
 !if $(CLKGEN_CONFIG_EXTRA_ENABLE) == TRUE
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44176): https://edk2.groups.io/g/devel/message/44176
Mute This Topic: https://groups.io/mt/32564744/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms Patch V3 08/12] Vlv2TbltDevicePkg/PlatformDxe: Add missing #if

2019-07-22 Thread Michael D Kinney
Add missing #if for SENSOR_INFO_VAR_SUPPORT around
the function InitializeSensorInfoVariable().  This
function is referencing 2 global variables that are
not defined, and this breaks VS2017 for undefined
global variables.

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Gary Lin 
Signed-off-by: Michael D Kinney 
---
 Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/SensorVar.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/SensorVar.c 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/SensorVar.c
index 5d13e99443..6efb989bc0 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/SensorVar.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/SensorVar.c
@@ -85,6 +85,7 @@ SENSOR_INFO_VAR   mSensorInfoData =
 }
 };
 
+#if defined(SENSOR_INFO_VAR_SUPPORT) && SENSOR_INFO_VAR_SUPPORT != 0
 /**
 
   Write the Sensor Info variable if it does not already exist.
@@ -109,4 +110,5 @@ InitializeSensorInfoVariable (
  
  );
 }
+#endif
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44171): https://edk2.groups.io/g/devel/message/44171
Mute This Topic: https://groups.io/mt/32564738/21656
Mute #if: https://groups.io/mk?hashtag=if=3846945
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms Patch V3 07/12] Vlv2Tbl2DevicePkg/EfiRegTableLib: Use S3_BOOT_SCRIPT_LIB_WIDTH

2019-07-22 Thread Michael D Kinney
Update calls to S3BootScriptxxx() services to use type
S3_BOOT_SCRIPT_LIB_WIDTH instead of EFI_BOOT_SCRIPT_WIDTH.
Fixes XCODE5 build failures.

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Gary Lin 
Signed-off-by: Michael D Kinney 
---
 .../Library/EfiRegTableLib/EfiRegTableLib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/Platform/Intel/Vlv2TbltDevicePkg/Library/EfiRegTableLib/EfiRegTableLib.c 
b/Platform/Intel/Vlv2TbltDevicePkg/Library/EfiRegTableLib/EfiRegTableLib.c
index d698f3ada9..8b16585337 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/Library/EfiRegTableLib/EfiRegTableLib.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/Library/EfiRegTableLib/EfiRegTableLib.c
@@ -55,7 +55,7 @@ PciWrite (
 
   if (OPCODE_FLAGS (Entry->OpCode) & OPCODE_FLAG_S3SAVE) {
 Status = S3BootScriptSavePciCfgWrite (
-  (EFI_BOOT_SCRIPT_WIDTH) (OPCODE_EXTRA_DATA (Entry->OpCode)),
+  (S3_BOOT_SCRIPT_LIB_WIDTH) (OPCODE_EXTRA_DATA (Entry->OpCode)),
   (UINT64) Entry->PciAddress,
   1,
   >Data
@@ -111,7 +111,7 @@ PciReadModifyWrite (
 
   if (OPCODE_FLAGS (Entry->OpCode) & OPCODE_FLAG_S3SAVE) {
 Status = S3BootScriptSavePciCfgReadWrite (
-  (EFI_BOOT_SCRIPT_WIDTH) (OPCODE_EXTRA_DATA (Entry->OpCode)),
+  (S3_BOOT_SCRIPT_LIB_WIDTH) (OPCODE_EXTRA_DATA (Entry->OpCode)),
   (UINT64) Entry->PciAddress,
   >OrMask,
   >AndMask
@@ -167,7 +167,7 @@ MemReadModifyWrite (
 
   if (OPCODE_FLAGS (Entry->OpCode) & OPCODE_FLAG_S3SAVE) {
 Status = S3BootScriptSaveMemReadWrite (
-  (EFI_BOOT_SCRIPT_WIDTH) (OPCODE_EXTRA_DATA (Entry->OpCode)),
+  (S3_BOOT_SCRIPT_LIB_WIDTH) (OPCODE_EXTRA_DATA (Entry->OpCode)),
   Entry->MemAddress,
   >OrMask,
   >AndMask
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44174): https://edk2.groups.io/g/devel/message/44174
Mute This Topic: https://groups.io/mt/32564742/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms Patch V3 04/12] Vlv2TbltDevicePkg: Convert BAT/sh Capsule scripts to Python

2019-07-22 Thread Michael D Kinney
Convert all the BAT/sh files used to generate capsules to
OS independent Python script.

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Gary Lin 
Signed-off-by: Michael D Kinney 
Reviewed-by: Zailiang Sun 
---
 .../Capsule/GenerateCapsule/GenCapsuleAll.bat |  35 --
 .../Capsule/GenerateCapsule/GenCapsuleAll.py  | 397 ++
 .../Capsule/GenerateCapsule/GenCapsuleAll.sh  |  33 --
 .../GenerateCapsule/GenCapsuleMinnowMax.bat   | 131 --
 .../GenerateCapsule/GenCapsuleMinnowMax.sh|  59 ---
 .../GenCapsuleMinnowMaxRelease.bat| 131 --
 .../GenCapsuleMinnowMaxRelease.sh |  64 ---
 .../GenerateCapsule/GenCapsuleSampleColor.bat | 137 --
 .../GenerateCapsule/GenCapsuleSampleColor.sh  |  70 ---
 .../Feature/Capsule/GenerateCapsule/Lvfs.ddf  |  14 -
 .../LvfsGenCapsuleMinnowMax.bat   | 139 --
 .../LvfsGenCapsuleMinnowMaxRelease.bat| 139 --
 .../LvfsGenCapsuleSampleColor.bat | 145 ---
 .../GenerateCapsule/template.metainfo.xml |  27 --
 .../Vlv2TbltDevicePkg/PlatformCapsuleIA32.dsc |   2 +-
 .../Vlv2TbltDevicePkg/PlatformCapsuleX64.dsc  |   2 +-
 16 files changed, 399 insertions(+), 1126 deletions(-)
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.bat
 create mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py
 delete mode 100755 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.sh
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleMinnowMax.bat
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleMinnowMax.sh
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleMinnowMaxRelease.bat
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleMinnowMaxRelease.sh
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleSampleColor.bat
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleSampleColor.sh
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/Lvfs.ddf
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/LvfsGenCapsuleMinnowMax.bat
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/LvfsGenCapsuleMinnowMaxRelease.bat
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/LvfsGenCapsuleSampleColor.bat
 delete mode 100644 
Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/template.metainfo.xml

diff --git 
a/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.bat
 
b/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.bat
deleted file mode 100644
index 8f589565fa..00
--- 
a/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.bat
+++ /dev/null
@@ -1,35 +0,0 @@
-@REM @file
-@REM   Windows batch file to generate UEFI capsules for system firmware and
-@REM   firmware for sample devices
-@REM
-@REM Copyright (c) 2018, Intel Corporation. All rights reserved.
-@REM SPDX-License-Identifier: BSD-2-Clause-Patent
-@REM
-
-@echo off
-setlocal
-cd /d %~dp0
-
-rmdir /s /q %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules
-mkdir %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules
-mkdir %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\SampleDevelopment
-mkdir %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\NewCert
-mkdir %WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\TestCert
-copy %WORKSPACE%\Build\Vlv2TbltDevicePkg\DEBUG_VS2015x86\X64\CapsuleApp.efi 
%WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\SampleDevelopment\CapsuleApp.efi
-copy %WORKSPACE%\Build\Vlv2TbltDevicePkg\RELEASE_VS2015x86\X64\CapsuleApp.efi 
%WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\SampleDevelopment\CapsuleAppRelease.efi
-copy %WORKSPACE%\Build\Vlv2TbltDevicePkg\DEBUG_VS2015x86\X64\CapsuleApp.efi 
%WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\NewCert\CapsuleApp.efi
-copy %WORKSPACE%\Build\Vlv2TbltDevicePkg\RELEASE_VS2015x86\X64\CapsuleApp.efi 
%WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\NewCert\CapsuleAppRelease.efi
-copy %WORKSPACE%\Build\Vlv2TbltDevicePkg\DEBUG_VS2015x86\X64\CapsuleApp.efi 
%WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\TestCert\CapsuleApp.efi
-copy %WORKSPACE%\Build\Vlv2TbltDevicePkg\RELEASE_VS2015x86\X64\CapsuleApp.efi 
%WORKSPACE%\Build\Vlv2TbltDevicePkg\Capsules\TestCert\CapsuleAppRelease.efi
-
-call GenCapsuleMinnowMax.bat
-call GenCapsuleMinnowMaxRelease.bat
-call GenCapsuleSampleColor.bat Blue  149da854-7d19-4faa-a91e-862ea1324be6
-call GenCapsuleSampleColor.bat Green 79179bfd-704d-4c90-9e02-0ab8d968c18a
-call GenCapsuleSampleColor.bat Red   72e2945a-00da-448e-9aa7-075ad840f9d4
-
-call LvfsGenCapsuleMinnowMax.bat
-call LvfsGenCapsuleMinnowMaxRelease.bat
-call 

[edk2-devel] [edk2-platforms Patch V3 06/12] Vlv2TbltDevicePkg: Remove non ASCII characters from source files

2019-07-22 Thread Michael D Kinney
Remove non-ASCII characters from comments in source files.  These
are preventing the build tool from generating report files on
Linux systems.

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Gary Lin 
Signed-off-by: Michael D Kinney 
---
 .../Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c | 2 +-
 Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
index 4a51a47e36..71d6cb7c15 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
@@ -461,7 +461,7 @@ UARTInit (
   if (SystemConfiguration->LpssHsuart0Enabled == 1){
 //
 //Valleyview BIOS Specification Vol2,17.2
-//LPSS_UART1 �C set each pad PAD_CONF0.Func_Pin_Mux to function 1:
+//LPSS_UART1 C set each pad PAD_CONF0.Func_Pin_Mux to function 1:
 //
 MmioAnd8 (IO_BASE_ADDRESS + 0x0090, (UINT8)~0x07);
 MmioOr8 (IO_BASE_ADDRESS + 0x0090, 0x01);
diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
index 4c0e660b7f..2061b8d559 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
@@ -205,9 +205,9 @@ GetSleepTypeAfterWakeup (
   // VLV BIOS Specification 0.6.2 - Section 18.4, "Power Failure Consideration"
   //
   // When the SUS_PWR_FLR bit is set, it indicates the SUS well power is lost.
-  // This bit is in the SUS Well and defaults to 1�b1 based on RSMRST# 
assertion (not cleared by any type of reset).
+  // This bit is in the SUS Well and defaults to 1'b1 based on RSMRST# 
assertion (not cleared by any type of reset).
   // System BIOS should follow cold boot path if SUS_PWR_FLR (PBASE + 
0x20[14]),
-  // GEN_RST_STS (PBASE + 0x20[9]) or PWRBTNOR_STS (ABASE + 0x00[11]) is set 
to 1�b1
+  // GEN_RST_STS (PBASE + 0x20[9]) or PWRBTNOR_STS (ABASE + 0x00[11]) is set 
to 1'b1
   // regardless of the value in the SLP_TYP (ABASE + 0x04[12:10]) field.
   //
   GenPmCon1 = MmioRead16 (PMC_BASE_ADDRESS + R_PCH_PMC_GEN_PMCON_1);
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44173): https://edk2.groups.io/g/devel/message/44173
Mute This Topic: https://groups.io/mt/32564740/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms Patch V3 12/12] Vlv2TbltDevicePkg/PlatformDxe: Use S3BootScriptWidth enums

2019-07-22 Thread Michael D Kinney
Update to use S3BootScriptWidth enum values instead of
EfiBootScriptWidth enum values when calling S3BootScriptLib
services.  This fixes an XCODE5 build failure.

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Gary Lin 
Signed-off-by: Michael D Kinney 
---
 .../Intel/Vlv2TbltDevicePkg/PlatformDxe/Platform.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/Platform.c 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/Platform.c
index 0bc3f44c49..d9782aafba 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/Platform.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformDxe/Platform.c
@@ -968,25 +968,25 @@ PchInitBeforeBoot()
   // Saved SPI Opcode menu to fix EFI variable unable to write after S3 resume.
   //
   S3BootScriptSaveMemWrite (
- EfiBootScriptWidthUint32,
+ S3BootScriptWidthUint32,
  (UINTN)(SPI_BASE_ADDRESS + (R_PCH_SPI_OPMENU0)),
  1,
  (VOID *)(UINTN)(SPI_BASE_ADDRESS + 
(R_PCH_SPI_OPMENU0)));
 
   S3BootScriptSaveMemWrite (
- EfiBootScriptWidthUint32,
+ S3BootScriptWidthUint32,
  (UINTN)(SPI_BASE_ADDRESS + (R_PCH_SPI_OPMENU1)),
  1,
  (VOID *)(UINTN)(SPI_BASE_ADDRESS + 
(R_PCH_SPI_OPMENU1)));
 
   S3BootScriptSaveMemWrite (
- EfiBootScriptWidthUint16,
+ S3BootScriptWidthUint16,
  (UINTN)(SPI_BASE_ADDRESS + R_PCH_SPI_OPTYPE),
  1,
  (VOID *)(UINTN)(SPI_BASE_ADDRESS + R_PCH_SPI_OPTYPE));
 
   S3BootScriptSaveMemWrite (
- EfiBootScriptWidthUint16,
+ S3BootScriptWidthUint16,
  (UINTN)(SPI_BASE_ADDRESS + R_PCH_SPI_PREOP),
  1,
  (VOID *)(UINTN)(SPI_BASE_ADDRESS + R_PCH_SPI_PREOP));
@@ -995,7 +995,7 @@ PchInitBeforeBoot()
   // Saved MTPMC_1 for S3 resume.
   //
   S3BootScriptSaveMemWrite (
- EfiBootScriptWidthUint32,
+ S3BootScriptWidthUint32,
  (UINTN)(PMC_BASE_ADDRESS + R_PCH_PMC_MTPMC1),
  1,
  (VOID *)(UINTN)(PMC_BASE_ADDRESS + R_PCH_PMC_MTPMC1));
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44172): https://edk2.groups.io/g/devel/message/44172
Mute This Topic: https://groups.io/mt/32564739/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms Patch V3 05/12] Vlv2Tbl2DevicePkg: Convert BAT/sh Build scripts to Python

2019-07-22 Thread Michael D Kinney
Convert Build_IFWI and bld_vlv BAT/sh scripts to OS
independent python script PeBuild.py.  This script
generates the BiosId file.  Standard EDK II build
commands are used to build FW images and capsules.

* Sample VS2015x86 commands for IA32/X64 and DEBUG/RELEASE
  build -a IA32 -a X64 -t VS2015x86 -p Vlv2TbltDevicePkg\PlatformPkgX64.dsc
  build -a IA32 -a X64 -t VS2015x86 -p Vlv2TbltDevicePkg\PlatformPkgX64.dsc
  build -a IA32-t VS2015x86 -p Vlv2TbltDevicePkg\PlatformPkgIA32.dsc
  build -a IA32-t VS2015x86 -p Vlv2TbltDevicePkg\PlatformPkgIA32.dsc

* Sample GCC5 commands for IA32/X64 and DEBUG/RELEASE
  build -a IA32 -a X64 -n 5 -t GCC5 -p Vlv2TbltDevicePkg/PlatformPkgX64.dsc
  build -a IA32 -a X64 -n 5 -t GCC5 -p Vlv2TbltDevicePkg/PlatformPkgX64.dsc
  build -a IA32-n 5 -t GCC5 -p Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
  build -a IA32-n 5 -t GCC5 -p Vlv2TbltDevicePkg/PlatformPkgIA32.dsc

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Gary Lin 
Signed-off-by: Michael D Kinney 
---
 .../Intel/Vlv2TbltDevicePkg/Build_IFWI.bat| 118 --
 .../Intel/Vlv2TbltDevicePkg/Build_IFWI.sh | 100 -
 .../Vlv2TbltDevicePkg/PlatformCapsule.fdf |  48 ---
 .../Vlv2TbltDevicePkg/PlatformCapsuleIA32.dsc |  39 --
 .../Vlv2TbltDevicePkg/PlatformCapsuleX64.dsc  |  39 --
 .../Intel/Vlv2TbltDevicePkg/PlatformPkg.fdf   |  30 +-
 .../Vlv2TbltDevicePkg/PlatformPkgIA32.dsc |  13 +-
 .../Vlv2TbltDevicePkg/PlatformPkgX64.dsc  |  13 +-
 Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py  | 348 ++
 Platform/Intel/Vlv2TbltDevicePkg/Readme.md|  64 ++--
 Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.bat  | 303 ---
 Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.sh   | 222 ---
 12 files changed, 433 insertions(+), 904 deletions(-)
 delete mode 100644 Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat
 delete mode 100755 Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.sh
 delete mode 100644 Platform/Intel/Vlv2TbltDevicePkg/PlatformCapsule.fdf
 delete mode 100644 Platform/Intel/Vlv2TbltDevicePkg/PlatformCapsuleIA32.dsc
 delete mode 100644 Platform/Intel/Vlv2TbltDevicePkg/PlatformCapsuleX64.dsc
 create mode 100644 Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py
 delete mode 100644 Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.bat
 delete mode 100755 Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.sh

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat 
b/Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat
deleted file mode 100644
index f65aa61f4a..00
--- a/Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat
+++ /dev/null
@@ -1,118 +0,0 @@
-@REM @file
-@REM   Windows batch file to build BIOS ROM
-@REM
-@REM Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
-@REM SPDX-License-Identifier: BSD-2-Clause-Patent
-@REM
-
-@echo off
-
-SetLocal EnableDelayedExpansion EnableExtensions
-
-:: Assign initial values
-set exitCode=0
-set "Build_Flags= "
-set PLATFORM_PACKAGE=Vlv2TbltDevicePkg
-
-set PLATFORM_PATH=%WORKSPACE%
-if not exist %PLATFORM_PATH%\%PLATFORM_PACKAGE% (
-  if defined PACKAGES_PATH (
-for %%i IN (%PACKAGES_PATH%) DO (
-  if exist %%~fi\%PLATFORM_PACKAGE% (
-set PLATFORM_PATH=%%~fi
-goto PlatformPackageFound
-  )
-)
-  ) else (
-echo.
-echo !!! ERROR !!! Cannot find %PLATFORM_PACKAGE% !!!
-echo.
-goto Exit
-  )
-)
-:PlatformPackageFound
-
-:: Parse Optional arguments
-:OptLoop
-if /i "%~1"=="/?" goto Usage
-
-if /i "%~1"=="/l" (
-set Build_Flags=%Build_Flags% /l
-shift
-goto OptLoop
-)
-if /i "%~1"=="/y" (
-set Build_Flags=%Build_Flags% /y
-shift
-goto OptLoop
-)
-if /i "%~1"=="/m" (
-set Build_Flags=%Build_Flags% /m
-shift
-goto OptLoop
-)
-if /i "%~1" == "/c" (
-set Build_Flags=%Build_Flags% /c
-shift
-goto OptLoop
-)
-if /i "%~1"=="/x64" (
-set Build_Flags=%Build_Flags% /x64
-shift
-goto OptLoop
-)
-if /i "%~1"=="/IA32" (
-set Build_Flags=%Build_Flags% /IA32
-shift
-goto OptLoop
-)
-
-:: Require 2 input parameters
-if "%~2"=="" goto Usage
-
-:: Assign required arguments
-set Platform_Type=%~1
-set Build_Target=%~2
-
-:: Build BIOS
-echo ==
-echo Build_IFWI:  Calling BIOS build Script...
-
-call %PLATFORM_PATH%\%PLATFORM_PACKAGE%\bld_vlv.bat %Build_Flags% 
%Platform_Type% %Build_Target%
-
-if %ERRORLEVEL% NEQ 0 (
-echo echo  -- Error Building BIOS  & echo.
-set exitCode=1
-goto exit
-)
-echo.
-echo Finished Building BIOS.
-goto Exit
-
-:Usage
-echo Script to build BIOS firmware and stitch the entire IFWI.
-echo.
-echo Usage: Build_IFWI.bat [options]  PlatformType  BuildTarget
-echo.
-echo/cCleanAll
-echo/lGenerate build log file
-echo/yGenerate build report file
-echo/mEnable multi-processor build
-echo/IA32 Set Arch to IA32 (default: X64)
-echo/X64  Set Arch to X64 (default: X64)
-echo.
-echoPlatform Types:  MNW2
-echo

[edk2-devel] [edk2-platforms Patch V3 10/12] Vlv2TbltDevicePkg: Fix XCODE5 build errors

2019-07-22 Thread Michael D Kinney
* Remove extra parenthesis in if statements
* Remove local variable structure initialization
  that adds use of memcpy() on XCODE X64 builds.
  Move per-initialize structure to a module global.

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Gary Lin 
Signed-off-by: Michael D Kinney 
---
 .../Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c| 12 ++--
 .../Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c  |  2 +-
 .../Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c  |  2 +-
 .../VlvPlatformInitDxe/IgdOpRegion.c |  2 +-
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c 
b/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
index 479ffa61a0..3e0b978120 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
@@ -63,6 +63,15 @@ SYSTEM_CONFIGURATION  mSystemConfig;
 UINT8 mSmbusRsvdAddresses[] = PLATFORM_SMBUS_RSVD_ADDRESSES;
 UINT8 mNumberSmbusAddress = sizeof( mSmbusRsvdAddresses ) / sizeof( 
mSmbusRsvdAddresses[0] );
 
+EFI_ACPI_OSFR_OCUR_OBJECT  mOcurObjectTemplate = {
+  {0xB46F133D, 0x235F, 0x4634, 0x9F, 0x03, 0xB1, 0xC0, 0x1C, 0x54, 0x78, 0x5B},
+  0,
+  0,
+  0,
+  0,
+  0
+};
+
 /**
   Locate the first instance of a protocol.  If the protocol requested is an
   FV protocol, then it will return the first FV that contains the ACPI table
@@ -203,7 +212,6 @@ PlatformUpdateTables (
   EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE   *Facp;
   EFI_ACPI_OSFR_TABLE *OsfrTable;
   EFI_ACPI_OSFR_OCUR_OBJECT   *pOcurObject;
-  EFI_ACPI_OSFR_OCUR_OBJECT   OcurObject = 
{{0xB46F133D, 0x235F, 0x4634, 0x9F, 0x03, 0xB1, 0xC0, 0x1C, 0x54, 0x78, 0x5B}, 
0, 0, 0, 0, 0};
   CHAR16  
*OcurMfgStringBuffer = NULL;
   CHAR16  
*OcurModelStringBuffer = NULL;
   UINT8   
*OcurRefDataBlockBuffer = NULL;
@@ -554,7 +562,7 @@ PlatformUpdateTables (
 (UINT32) (sizeof (EFI_ACPI_OSFR_TABLE_FIXED_PORTION) + sizeof 
(UINT32));
   pOcurObject = (EFI_ACPI_OSFR_OCUR_OBJECT *)((UINTN) OsfrTable + 
sizeof (EFI_ACPI_OSFR_TABLE_FIXED_PORTION) + \
 sizeof (UINT32));
-  CopyMem (pOcurObject, , sizeof 
(EFI_ACPI_OSFR_OCUR_OBJECT));
+  CopyMem (pOcurObject, , sizeof 
(EFI_ACPI_OSFR_OCUR_OBJECT));
   pOcurObject->ManufacturerNameStringOffset = (UINT32)((UINTN) 
pOcurObject - (UINTN) OsfrTable + \
 sizeof (EFI_ACPI_OSFR_OCUR_OBJECT));
   pOcurObject->ModelNameStringOffset = (UINT32)((UINTN) pOcurObject - 
(UINTN) OsfrTable + \
diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c 
b/Platform/Intel/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c
index b1c01afc16..69ced08a58 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c
@@ -250,7 +250,7 @@ GetPciRom (
 //
 // Do not run RAID or AHCI Option ROM if IDE
 //
-if ( (DeviceClass == ((PCI_CLASS_MASS_STORAGE << 8 ) | 
PCI_CLASS_MASS_STORAGE_IDE)) ) {
+if (DeviceClass == ((PCI_CLASS_MASS_STORAGE << 8 ) | 
PCI_CLASS_MASS_STORAGE_IDE)) {
   return EFI_NOT_FOUND;
 }
 
diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
index 71d6cb7c15..0b5d7f76a1 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PchInitPeim.c
@@ -514,7 +514,7 @@ IchRcrbInit (
   //
   // Initial RCBA according to the PeiRCBA table
   //
-  if ((BootMode == BOOT_ON_S3_RESUME)) {
+  if (BootMode == BOOT_ON_S3_RESUME) {
 //
 // We are resuming from S3
 // Enable HPET if enabled in Setup
diff --git a/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegion.c 
b/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegion.c
index dad27f130d..fcd9e566ae 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegion.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegion.c
@@ -573,7 +573,7 @@ GetVBiosVbtCallback (
 return EFI_SUCCESS;
   }
 }
-if ((VBiosPtr == NULL) ) {
+if (VBiosPtr == NULL) {
   //
   // Intel video BIOS not found.
   //
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44175): https://edk2.groups.io/g/devel/message/44175
Mute This Topic: https://groups.io/mt/32564743/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms Patch V3 00/12] Vlv2Tbl2DevicePkg: Remove Linux/Windows differences

2019-07-22 Thread Michael D Kinney
New in V3
-
* Fix Readme.md for Linux in PACKAGES_PATH setting and edksetup.sh invocation.
* Remove non-ASCII characters from source files that is preventing build report
  generation on Linux systems.
* Fix XCODE5 build break in Vlv2TbltDevicePkg/Library/EfiRegTableLib due
  to use of EFI_BOOT_SCRIPT_WIDTH instead of S3_BOOT_SCRIPT_LIB_WIDTH.
* Add missing #ifdef around InitializeSensorInfoVariable() in PlatformDxe.
* Add XCODE5 specific DLINK_FLAGS for 4KB aligned sections.
* Remove extra sets of parenthesis in if statements to resolve XCODE5
  build failures.
* Move a local variable declaration structure init to a module global
  variable to avoid use of memcpy() by XCODE5.
* Remove use of #ifdefs on __GNUC__ to make builds the same for all
  toolchains.  This resolves an XCODE5 build failure due to an unsupported
  pragma.
* Replace the use of EfiBootScriptWidth enum values with S3BootScriptWidth
  enum values when calling S3BootScriptLib services.  This resolves an
  XCODE5 build failure.

New in V2
--
* Remove MANUFACTURING defaults from DSC file.  They are the same as STANDARD
  defaults, so there is not need to add a MANUFACTURING default section unless
  there are differences.
* Update PlatformSetupDxe to return EFI_UNSUPPORTED from the RouteConfig() and
  ExtractConfig() services of the HII_CONFIG_ACCESS_PROTOCOL.

Branch for review:

https://github.com/mdkinney/edk2-platforms/tree/Bug_xxx_Vlv2_Remove_FCE_BAT_sh_V3

Remove all BAT/sh scripts and use OS independent python scripts for PREBULD and
POSTBUILD operations and use standard EDK II build command to build MinnowMax FW
images and capsules.

The use of FCE has also been removed and replaced with a Structured PCD.  The
default values for Setup forms are now in the file PlatformSetupDefaults.dsc.

A regression bug introduced by a recent commit that broke the detection of the
BOOT_ON_FLASH_UPDATE boot mode has also been fixed.  Capsules are detected and
processed correctly again.

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Gary Lin 
Signed-off-by: Michael D Kinney 

Michael D Kinney (12):
  Vlv2TbltDevicePkg/PlatformPei: Add boot mode detection
  Vlv2TbltDevicePkg: Convert use of FCE tool to Structured PCD
  Vlv2TbltDevicePkg: Remove Linux/GCC specific DSC/FDF files
  Vlv2TbltDevicePkg: Convert BAT/sh Capsule scripts to Python
  Vlv2Tbl2DevicePkg: Convert BAT/sh Build scripts to Python
  Vlv2TbltDevicePkg: Remove non ASCII characters from source files
  Vlv2Tbl2DevicePkg/EfiRegTableLib: Use S3_BOOT_SCRIPT_LIB_WIDTH
  Vlv2TbltDevicePkg/PlatformDxe: Add missing #if
  Vlv2TbltDevicePkg: Add XCODE5 4K alignment DLINK_FLAGS
  Vlv2TbltDevicePkg: Fix XCODE5 build errors
  Vlv2TbltDevicePkg: Remove __GNUC__ specific #ifdefs
  Vlv2TbltDevicePkg/PlatformDxe: Use S3BootScriptWidth enums

 .../AcpiPlatform/AcpiPlatform.c   |   15 +-
 Platform/Intel/Vlv2TbltDevicePkg/BfmLib.exe   |  Bin 499712 -> 0 bytes
 .../Intel/Vlv2TbltDevicePkg/Build_IFWI.bat|  118 --
 .../Intel/Vlv2TbltDevicePkg/Build_IFWI.sh |  100 --
 Platform/Intel/Vlv2TbltDevicePkg/FCE.exe  |  Bin 632832 -> 0 bytes
 .../Capsule/GenerateCapsule/GenCapsuleAll.bat |   35 -
 .../Capsule/GenerateCapsule/GenCapsuleAll.py  |  397 +
 .../Capsule/GenerateCapsule/GenCapsuleAll.sh  |   33 -
 .../GenerateCapsule/GenCapsuleMinnowMax.bat   |  131 --
 .../GenerateCapsule/GenCapsuleMinnowMax.sh|   59 -
 .../GenCapsuleMinnowMaxRelease.bat|  131 --
 .../GenCapsuleMinnowMaxRelease.sh |   64 -
 .../GenerateCapsule/GenCapsuleSampleColor.bat |  137 --
 .../GenerateCapsule/GenCapsuleSampleColor.sh  |   70 -
 .../Feature/Capsule/GenerateCapsule/Lvfs.ddf  |   14 -
 .../LvfsGenCapsuleMinnowMax.bat   |  139 --
 .../LvfsGenCapsuleMinnowMaxRelease.bat|  139 --
 .../LvfsGenCapsuleSampleColor.bat |  145 --
 .../GenerateCapsule/template.metainfo.xml |   27 -
 .../SystemFirmwareDescriptor.aslc |   83 --
 .../SystemFirmwareDescriptor.inf  |   40 -
 .../SystemFirmwareDescriptorPei.c |   60 -
 .../SystemFirmwareUpdateConfig.ini|   66 -
 .../SystemFirmwareUpdateConfigGcc.ini |   66 -
 .../Library/EfiRegTableLib/EfiRegTableLib.c   |6 +-
 .../BoardClkGens/BoardClkGens.c   |8 -
 .../PciPlatform/PciPlatform.c |2 +-
 .../Vlv2TbltDevicePkg/PlatformCapsule.dsc |   39 -
 .../Vlv2TbltDevicePkg/PlatformCapsule.fdf |   52 -
 .../Vlv2TbltDevicePkg/PlatformCapsuleGcc.dsc  |   38 -
 .../Vlv2TbltDevicePkg/PlatformCapsuleGcc.fdf  |   52 -
 .../Vlv2TbltDevicePkg/PlatformDxe/Platform.c  |   10 +-
 .../Vlv2TbltDevicePkg/PlatformDxe/SensorVar.c |2 +
 .../PlatformInitPei/CpuInitPeim.c |   12 -
 .../PlatformInitPei/PchInitPeim.c |4 +-
 .../PlatformInitPei/PlatformEarlyInit.c   |   86 +-
 .../PlatformInitPei/PlatformEarlyInit.h   |6 -
 .../PlatformInitPei/PlatformInitPei.inf   |2 +
 

[edk2-devel] [edk2-platforms Patch V3 01/12] Vlv2TbltDevicePkg/PlatformPei: Add boot mode detection

2019-07-22 Thread Michael D Kinney
Add boot mode detection back into PlatformPei that was
inadvertently removed in the following commit:

https://github.com/tianocore/edk2-platforms/commit/d6211390793fbd0a89b14001c43e0ef942c85425

Boot mode detection at this point is required to detect
the boot mode of BOOT_ON_FLASH_UPDATE that is required
to detect, coalesce, and process UEFI Capsules.

Cc: Zailiang Sun 
Cc: Yi Qian 
Cc: Gary Lin 
Signed-off-by: Michael D Kinney 
Reviewed-by: Zailiang Sun 
---
 .../Vlv2TbltDevicePkg/PlatformPei/BootMode.c  | 92 ++-
 .../Vlv2TbltDevicePkg/PlatformPei/Platform.c  |  6 ++
 .../Vlv2TbltDevicePkg/PlatformPei/Platform.h  | 17 
 3 files changed, 114 insertions(+), 1 deletion(-)

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
index 5269b1ed39..4c0e660b7f 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
@@ -82,7 +82,7 @@ CapsulePpiNotifyCallback (
 if (Status == EFI_SUCCESS) {
   if (Capsule->CheckCapsuleUpdate ((EFI_PEI_SERVICES**)PeiServices) == 
EFI_SUCCESS) {
 BootMode = BOOT_ON_FLASH_UPDATE;
-DEBUG ((EFI_D_ERROR, "Setting BootMode to BOOT_ON_FLASH_UPDATE\n"));
+DEBUG ((DEBUG_ERROR, "Setting BootMode to BOOT_ON_FLASH_UPDATE\n"));
 Status = (*PeiServices)->SetBootMode((const EFI_PEI_SERVICES 
**)PeiServices, BootMode);
 ASSERT_EFI_ERROR (Status);
   }
@@ -92,6 +92,96 @@ CapsulePpiNotifyCallback (
   return Status;
 }
 
+EFI_STATUS
+UpdateBootMode (
+  IN CONST EFI_PEI_SERVICES **PeiServices
+  )
+{
+  EFI_STATUS  Status;
+  EFI_BOOT_MODE   BootMode;
+  UINT16  SleepType;
+  CHAR16  *strBootMode;
+
+  Status = (*PeiServices)->GetBootMode(PeiServices, );
+  ASSERT_EFI_ERROR (Status);
+  if (BootMode  == BOOT_IN_RECOVERY_MODE){
+return Status;
+  }
+
+  //
+  // Let's assume things are OK if not told otherwise
+  //
+  BootMode = BOOT_WITH_FULL_CONFIGURATION;
+
+  if (GetSleepTypeAfterWakeup (PeiServices, )) {
+switch (SleepType) {
+  case V_PCH_ACPI_PM1_CNT_S3:
+BootMode = BOOT_ON_S3_RESUME;
+Status = (*PeiServices)->NotifyPpi (PeiServices, 
[0]);
+ASSERT_EFI_ERROR (Status);
+break;
+
+  case V_PCH_ACPI_PM1_CNT_S4:
+BootMode = BOOT_ON_S4_RESUME;
+break;
+
+  case V_PCH_ACPI_PM1_CNT_S5:
+BootMode = BOOT_ON_S5_RESUME;
+break;
+} // switch (SleepType)
+  }
+
+  if (IsFastBootEnabled (PeiServices)) {
+DEBUG ((DEBUG_INFO, "Prioritizing Boot mode to 
BOOT_WITH_MINIMAL_CONFIGURATION\n"));
+PrioritizeBootMode (, BOOT_WITH_MINIMAL_CONFIGURATION);
+  }
+
+  switch (BootMode) {
+case BOOT_WITH_FULL_CONFIGURATION:
+  strBootMode = L"BOOT_WITH_FULL_CONFIGURATION";
+  break;
+case BOOT_WITH_MINIMAL_CONFIGURATION:
+  strBootMode = L"BOOT_WITH_MINIMAL_CONFIGURATION";
+  break;
+case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
+  strBootMode = L"BOOT_ASSUMING_NO_CONFIGURATION_CHANGES";
+  break;
+case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
+  strBootMode = L"BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS";
+  break;
+case BOOT_WITH_DEFAULT_SETTINGS:
+  strBootMode = L"BOOT_WITH_DEFAULT_SETTINGS";
+  break;
+case BOOT_ON_S4_RESUME:
+  strBootMode = L"BOOT_ON_S4_RESUME";
+  break;
+case BOOT_ON_S5_RESUME:
+  strBootMode = L"BOOT_ON_S5_RESUME";
+  break;
+case BOOT_ON_S2_RESUME:
+  strBootMode = L"BOOT_ON_S2_RESUME";
+  break;
+case BOOT_ON_S3_RESUME:
+  strBootMode = L"BOOT_ON_S3_RESUME";
+
+  break;
+case BOOT_ON_FLASH_UPDATE:
+  strBootMode = L"BOOT_ON_FLASH_UPDATE";
+  break;
+case BOOT_IN_RECOVERY_MODE:
+  strBootMode = L"BOOT_IN_RECOVERY_MODE";
+  break;
+default:
+  strBootMode = L"Unknown boot mode";
+  } // switch (BootMode)
+
+  DEBUG ((DEBUG_ERROR, "Setting BootMode to %s\n", strBootMode));
+  Status = (*PeiServices)->SetBootMode(PeiServices, BootMode);
+  ASSERT_EFI_ERROR (Status);
+
+  return Status;
+}
+
 /**
   Get sleep type after wakeup
 
diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/Platform.c 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/Platform.c
index 90998871dc..1b23bc9740 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/Platform.c
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/Platform.c
@@ -813,6 +813,12 @@ PeiInitPlatform (
 sizeof (EFI_PLATFORM_INFO_HOB)
 );
 
+  //
+  // Set the new boot mode for MRC
+  //
+  Status = UpdateBootMode (PeiServices);
+  ASSERT_EFI_ERROR (Status);
+
   DEBUG((EFI_D_INFO, "Setup MMIO size ... \n\n"));
 
   //
diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/Platform.h 
b/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/Platform.h
index 4f71e519e0..e2e07dc446 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformPei/Platform.h
+++ 

Re: [edk2-devel] [PATCH 0/4] Arm, ArmPlatform, Crypto, Embedded: list internal headers in [Sources]

2019-07-22 Thread Laszlo Ersek
Hi Mike,

On 07/22/19 20:47, Michael D Kinney wrote:
> We could consider checking for these type of issues in
> the ECC tool instead of build and make it an error from
> ECC instead of a warning.

I'm sorry, my reply to Leif was ambiguous (or worse).

I meant that the issues underlying the specific warnings (emitted by the
feature from TianoCore#1804) were annoying -- the reports were valid,
and what "annoyed" me was that the INF files had not been in order (i.e.
that they had missed some internal header files).

I wasn't annoyed at the feature itself -- if it helps developers catch
unlisted headers as soon as incomplete INF files are introduced, then
it's not a bad feature IMO.

I'd make a *light* argument for keeping the feature in "build", as
opposed to ECC:

- ECC performs a very deep investigation (and used to produce a number
of false positives / noise).

- Since commit c60377d7f9ec ("BaseTools: ECC tool Python3 adaption",
2019-02-01), ECC has been incompatible with Python2 (and requires
antlr4, rather than antlr3). Thus, "build" works on more systems than ECC.

- I think "unlisted internal headers in INF files" is a problem defined
at the level of "build".

That said, I don't feel strongly about these general questions; I just
wanted to fix the actual warnings, because they were valid.

Thanks
Laszlo

>> -Original Message-
>> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io]
>> On Behalf Of Laszlo Ersek
>> Sent: Monday, July 22, 2019 10:33 AM
>> To: Leif Lindholm 
>> Cc: edk2-devel-groups-io ; Ard
>> Biesheuvel ; Wang, Jian J
>> ; Ye, Ting 
>> Subject: Re: [edk2-devel] [PATCH 0/4] Arm, ArmPlatform,
>> Crypto, Embedded: list internal headers in [Sources]
>>
>> On 07/22/19 12:37, Leif Lindholm wrote:
>>> On Fri, Jul 19, 2019 at 06:43:15PM +0200, Laszlo Ersek
>> wrote:
 Repo:   https://github.com/lersek/edk2.git
 Branch: internal_hdrs

 The BaseTools build feature introduced for
>> TianoCore#1804 / in commit
 1fa6699e6cd4 ("BaseTools: Add a checking for Sources
>> section in INF
 file", 2019-06-10) logs some (non-fatal) warnings
>> about unlisted
 internal header files. List those files explicitly.
>>>
>>> Urgh.
>>> Yeah. I'm still not super comfortable with this
>> duplication of
>>> dependency scanning (as discussed in
>>> https://edk2.groups.io/g/devel/topic/31866190), but I
>> have to confess
>>> I also don't really care enough to do anything about
>> it.
>>>
>>> So, while I'm tempted to keep the warnings around as a
>> reminder, if
>>> you prefer to get rid of them - for the pat of the
>> series I was cc:d on:
>>> Reviewed-by: Leif Lindholm 
>>
>> Thanks!
>>
>> Yes, the warnings are an annoyance, and they are valid
>> too. How the INF files are caught / reported is a
>> separate question IMO.
>>
>> Thanks!
>> Laszlo

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44163): https://edk2.groups.io/g/devel/message/44163
Mute This Topic: https://groups.io/mt/32529014/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v4 1/6] edksetup.sh: Use bash variable $PWD instead of executing pwd command

2019-07-22 Thread rebecca
On 2019-07-22 16:16, Laszlo Ersek wrote:
>
> should we push patches #1 through #4 from this series?
>
> They are independent of python detection (which is still being discussed).


I think that's a good idea.


-- 
Rebecca Cran


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44162): https://edk2.groups.io/g/devel/message/44162
Mute This Topic: https://groups.io/mt/32493796/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v4 1/6] edksetup.sh: Use bash variable $PWD instead of executing pwd command

2019-07-22 Thread Laszlo Ersek
Hi All,

On 07/16/19 18:55, rebe...@bsdio.com wrote:
> This is a (very minor) optimization: `pwd` runs the command (even as a
> built-in), whereas $PWD simply evaluates the value of the variable.
> 
> ALso, modern scripts should generally use $(...) to run commands,
> instead of `...`.
> 
> Signed-off-by: Rebecca Cran 
> Reviewed-by: Laszlo Ersek 
> Reviewed-by: Leif Lindholm 
> ---
>  edksetup.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/edksetup.sh b/edksetup.sh
> index 12a3e26a67..ab58fe4a6e 100755
> --- a/edksetup.sh
> +++ b/edksetup.sh
> @@ -71,7 +71,7 @@ function SetWorkspace()
>#
># Set $WORKSPACE
>#
> -  export WORKSPACE=`pwd`
> +  export WORKSPACE=$PWD
>return 0
>  }
>  
> 

should we push patches #1 through #4 from this series?

They are independent of python detection (which is still being discussed).

Thanks
Laszlo

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44160): https://edk2.groups.io/g/devel/message/44160
Mute This Topic: https://groups.io/mt/32493796/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-non-osi/devel-MinPlatform] [PATCH] ClevoOpenBoardBinPkg: Add Vbt binary

2019-07-22 Thread Agyeman, Prince
Added N1xxWU's Vbt.bin

Cc: Liming Gao 
Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Michael Kubacki 
Cc: Michael D Kinney 
Cc: Jiewen Yao 

Signed-off-by: Prince Agyeman 
---
 .../ClevoOpenBoardBinPkg/N1xxWU/Gop/Vbt.bin  | Bin 0 -> 4608 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 Platform/Intel/ClevoOpenBoardBinPkg/N1xxWU/Gop/Vbt.bin

diff --git a/Platform/Intel/ClevoOpenBoardBinPkg/N1xxWU/Gop/Vbt.bin 
b/Platform/Intel/ClevoOpenBoardBinPkg/N1xxWU/Gop/Vbt.bin
new file mode 100644
index 
..3431b7dc750c5be0f6b1d64c4bff7d978841119d
GIT binary patch
literal 4608
zcmeHKU2GIp6h1SvKeKmcwzE?L%YyZY2-^bfY=H{3%4~NFUAm>a-BL?5VGFxx<3dYY
zO!1F3mW0Hg?1LIKM4R|x@P)+qWQ@ERNr*~};-kEnDAB}3j4!}==4V?%1Kp5-U^v@z
z&%I}Ezd7gJbMHN~a+Z$ON-w9=m*+elr#J=WH~akIjbU5UQl
zOe!58NcHW%ma`9ZQtG6?~3p4$F-KoyhKvz;>vu-3t#}1E=JoD@%MiY(LO7B=_
zgW4uzVsw108RMlA_FHo%u)jD_9Dlx8XjYg7avDSr2f%rurwWG(bcURqz<#
zLGY+xAQ=09zyLr1)iOc_ej~?|Zj}hWu%)RI!3%cZuqL~N9yp%|RTVE1l0|+1
zuia5OBugAZ1HQLsU3O>j_G_(&98%vQL>DUtKB
zH{!pDuMqov3_`@qh#w(tA>K@!Anql8l6aWdcL*+n71YXREKbWo;@%
zsIxZcO(+_HAWY1gaFPh1@of+uV>ryT3C3P#_z}}SW9&8)E$x7_?iX*)ufz2!VteO!b}}PY-l+~%Zr>CHMAXZu02{SI?fkH
zC@cjd4y*L=u{H-G+;&88>N7GEJQhL+)l4_`LT`fOSHnPeXIzDFuSMk|47`{_A*wDSj(D$5bHH_192tKC*k_WxD
zL~`FlgD11lpl_|XYhgvQV&9!)N-c4Cskt(fk2DxMx@$qJ>8aS*Eg;zhKhJTrFc
zVM1t{TZ@War^qwj=^FCk{l=Md+36K}=Dj7e2m;upv26HiLC~9wGx_O)9?m-TAdnXV
zr6bX;=A@0FI0#;>!HbI#n91N0UDgwGUQ}p5k_~15COaRjB)@T1^X=vE!A=a>
zAwZpD1AWmfye}FJ$d{o$ud1Or8|VHopgB>U@iA9{3<}R%+x;MH`u)cU-QY_i25z
J)xRsA{Rhttps://edk2.groups.io/g/devel/message/44159
Mute This Topic: https://groups.io/mt/32563934/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 2/5] MdeModulePkg/SecurityLockAuditDebugLib: Add lib instance

2019-07-22 Thread Michael D Kinney
Laszlo,

I agree the lib instance should use the lib class name.
This one should be SecurityLockAuditLibDebug.

Mike

> -Original Message-
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io]
> On Behalf Of Laszlo Ersek
> Sent: Monday, July 22, 2019 1:45 PM
> To: devel@edk2.groups.io; Gao, Zhichao
> 
> Cc: Bret Barkelew ; Wang,
> Jian J ; Wu, Hao A
> ; Ni, Ray ; Zeng,
> Star ; Gao, Liming
> ; Sean Brogan
> ; Michael Turner
> 
> Subject: Re: [edk2-devel] [PATCH 2/5]
> MdeModulePkg/SecurityLockAuditDebugLib: Add lib instance
> 
> (apologies for the separate message, for this patch:)
> 
> On 07/22/19 22:34, Laszlo Ersek wrote:
> > On 07/22/19 06:02, Gao, Zhichao wrote:
> >> From: Bret Barkelew 
> >>
> >> REF:
> https://bugzilla.tianocore.org/show_bug.cgi?id=2006
> >>
> >> Add the instance of SecurityLockAuditLib. This
> instance has one
> >> interface SecurityLockReportEvent to log hardware and
> software
> >> security locks info.
> >>
> >> Cc: Jian J Wang 
> >> Cc: Hao A Wu 
> >> Cc: Ray Ni 
> >> Cc: Star Zeng 
> >> Cc: Liming gao 
> >> Cc: Sean Brogan 
> >> Cc: Michael Turner 
> >> Cc: Bret Barkelew 
> >> Signed-off-by: Zhichao Gao 
> >> ---
> >>  .../SecurityLockAuditDebugLib.c   | 53
> +++
> >>  .../SecurityLockAuditDebugLib.inf | 29
> ++
> >>  2 files changed, 82 insertions(+)
> >>  create mode 100644
> >>
> MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLo
> ckAuditDebug
> >> Lib.c  create mode 100644
> >>
> MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLo
> ckAuditDebug
> >> Lib.inf
> 
> The edk2 nomenclature usually puts the "implementation
> hints" of a library instance after the "Lib" word. For
> example, in "SecurityLockAuditLibNull", the word "Null"
> comes after "Lib" -- and that's correct. (From patch#3.)
> 
> (2) In order to stick with this naming, I'd suggest
> renaming this lib instance to
> "SecurityLockAuditLibDebug". (Note that commit messages
> and subject lines should be updated too, not just code,
> and file names.)
> 
> If the MdeModulePkg maintainers think the current name is
> OK, I won't insist on the rename.
> 
> Thanks!
> Laszlo
> 
> >>
> >> diff --git
> >>
> a/MdeModulePkg/Library/SecurityLockAuditDebugLib/Security
> LockAuditDeb
> >> ugLib.c
> >>
> b/MdeModulePkg/Library/SecurityLockAuditDebugLib/Security
> LockAuditDeb
> >> ugLib.c
> >> new file mode 100644
> >> index 00..c1872bc023
> >> --- /dev/null
> >> +++
> b/MdeModulePkg/Library/SecurityLockAuditDebugLib/Security
> LockAudi
> >> +++ tDebugLib.c
> >> @@ -0,0 +1,53 @@
> >> +/** @file
> >> +  This library implements the necessary functions
> >> +  to log hardware and software security locks for
> post-processing
> >> +
> >> +  Copyright (c) 2018, Microsoft Corporation
> >> +
> >> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> >> +
> >> +**/
> >> +
> >> +#include 
> >> +#include  #include
> >> +
> >> +
> >> +//
> >> +// Used to look up lock name from LOCK_TYPE enum //
> >> +CHAR8* mLockName[] = {
> >> +  "SOFTWARE_LOCK",
> >> +  "HARDWARE_LOCK"
> >> +};
> >> +
> >> +
> >> +/**
> >> +  Function for security Lock event logging and
> reporting
> >> +
> >> +  @param[in] Module   GUID of calling
> module
> >> +  @param[in] Function Name of calling
> function
> >> +  @param[in] LockEventTextDebug message
> explaining what is locked
> >> +  @param[in] LockType Enumerated lock
> type for differentiation
> >> +
> >> +**/
> >> +VOID
> >> +EFIAPI
> >> +SecurityLockReportEvent (
> >> +  IN GUID   *Module,
> >> +  IN CONST CHAR8*Function,
> >> +  IN CONST CHAR8*LockEventText,
> >> +  IN LOCK_TYPE  LockType
> >> +  )
> >> +{
> >> +  UINTN LockTypeIndex;
> >> +  UINTN LockNameCount;
> >> +
> >> +  LockTypeIndex = (UINTN)LockType;
> >> +  LockNameCount = sizeof (mLockName) / sizeof
> (mLockName[0]);
> >> +
> >> +  if (LockTypeIndex < LockNameCount) {
> >> +DEBUG ((DEBUG_ERROR, "SecurityLock::LockType: %a,
> Module: %g,
> >> +Function: %a, Output: %a\n",
> mLockName[LockTypeIndex], Module,
> >> +Function, LockEventText));
> >> +  } else {
> >> +DEBUG ((DEBUG_ERROR, "SecurityLock::LockType: %d,
> Module: %g,
> >> +Function: %a, Output: %a\n", LockType, Module,
> Function,
> >> +LockEventText));
> >> +  }
> >> +}
> >
> > I disagree with this implementation. Security log
> messages are
> > important, but they are not necessarily errors.
> DEBUG_ERROR should be
> > used for errors, preferably for such that cannot be
> recovered from
> > (DEBUG_WARN is OK for recoverable errors).
> >
> > If DEBUG_INFO is deemed too "quiet" for logging
> security events, then
> > we should introduce a new bit value for the debug
> bitmask, such as
> > DEBUG_SECURITY. We have a number of "special purpose"
> bits already:
> >
> > - DEBUG_LOAD
> > - DEBUG_FS
> > - DEBUG_POOL
> > - DEBUG_PAGE
> > - DEBUG_DISPATCH
> > - etc
> >
> > and I think we have room for DEBUG_SECURITY.
> >
> > (1) And 

Re: [edk2-devel] [Patch 0/9 V2] Enable multiple process AutoGen

2019-07-22 Thread Laszlo Ersek
Bob,

On 07/22/19 10:50, Bob Feng wrote:
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875
> 
> In order to improve the build performance, we implemented
> multiple-processes AutoGen. This change will reduce 20% time
> for AutoGen phase.
> 
> The design document can be got from:
> https://edk2.groups.io/g/devel/files/Designs/2019/0627/Multiple-thread-AutoGen.pdf
> 
> This patch serial pass the build of Ovmf, MinKabylake, MinPurley, packages
> under Edk2 repository and intel client and server platforms.
> 
> V2: 
> 1. The first version missed autogen related commit 
> from e812a812c1a0800c49e11507cb46222351520cc7. V2 add those commit
> back.

> 2. Move CreateAsBuildInf into AutoGenWorker process
> 3. Save GlobalVar__.bin to build folder.
> 4. Regenerate patches based on master bb824f685d

whenever someone posts a patch set (brand new patch set, or v2, v3, ...
of a previously posted patch set), I suggest capturing a mailing list
URL in the TianoCore Bugzilla, as a new comment.

This way someone interested in the evolution of the feature can approach
the mailing list postings from the Bugzilla, and get links to all
versions ever posted.

I've done this for your v1 posting; please add the v2 and v3 links.

(NB this request is for everyone.)

Thanks
Laszlo

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44157): https://edk2.groups.io/g/devel/message/44157
Mute This Topic: https://groups.io/mt/32556734/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 2/5] MdeModulePkg/SecurityLockAuditDebugLib: Add lib instance

2019-07-22 Thread Laszlo Ersek
(apologies for the separate message, for this patch:)

On 07/22/19 22:34, Laszlo Ersek wrote:
> On 07/22/19 06:02, Gao, Zhichao wrote:
>> From: Bret Barkelew 
>>
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2006
>>
>> Add the instance of SecurityLockAuditLib. This instance
>> has one interface SecurityLockReportEvent to log hardware
>> and software security locks info.
>>
>> Cc: Jian J Wang 
>> Cc: Hao A Wu 
>> Cc: Ray Ni 
>> Cc: Star Zeng 
>> Cc: Liming gao 
>> Cc: Sean Brogan 
>> Cc: Michael Turner 
>> Cc: Bret Barkelew 
>> Signed-off-by: Zhichao Gao 
>> ---
>>  .../SecurityLockAuditDebugLib.c   | 53 +++
>>  .../SecurityLockAuditDebugLib.inf | 29 ++
>>  2 files changed, 82 insertions(+)
>>  create mode 100644 
>> MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDebugLib.c
>>  create mode 100644 
>> MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDebugLib.inf

The edk2 nomenclature usually puts the "implementation hints" of a
library instance after the "Lib" word. For example, in
"SecurityLockAuditLibNull", the word "Null" comes after "Lib" -- and
that's correct. (From patch#3.)

(2) In order to stick with this naming, I'd suggest renaming this lib
instance to "SecurityLockAuditLibDebug". (Note that commit messages and
subject lines should be updated too, not just code, and file names.)

If the MdeModulePkg maintainers think the current name is OK, I won't
insist on the rename.

Thanks!
Laszlo

>>
>> diff --git 
>> a/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDebugLib.c 
>> b/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDebugLib.c
>> new file mode 100644
>> index 00..c1872bc023
>> --- /dev/null
>> +++ 
>> b/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDebugLib.c
>> @@ -0,0 +1,53 @@
>> +/** @file
>> +  This library implements the necessary functions
>> +  to log hardware and software security locks for post-processing
>> +
>> +  Copyright (c) 2018, Microsoft Corporation
>> +
>> +  SPDX-License-Identifier: BSD-2-Clause-Patent
>> +
>> +**/
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +//
>> +// Used to look up lock name from LOCK_TYPE enum
>> +//
>> +CHAR8* mLockName[] = {
>> +  "SOFTWARE_LOCK",
>> +  "HARDWARE_LOCK"
>> +};
>> +
>> +
>> +/**
>> +  Function for security Lock event logging and reporting
>> +
>> +  @param[in] Module   GUID of calling module
>> +  @param[in] Function Name of calling function
>> +  @param[in] LockEventTextDebug message explaining what is 
>> locked
>> +  @param[in] LockType Enumerated lock type for 
>> differentiation
>> +
>> +**/
>> +VOID
>> +EFIAPI
>> +SecurityLockReportEvent (
>> +  IN GUID   *Module,
>> +  IN CONST CHAR8*Function,
>> +  IN CONST CHAR8*LockEventText,
>> +  IN LOCK_TYPE  LockType
>> +  )
>> +{
>> +  UINTN LockTypeIndex;
>> +  UINTN LockNameCount;
>> +
>> +  LockTypeIndex = (UINTN)LockType;
>> +  LockNameCount = sizeof (mLockName) / sizeof (mLockName[0]);
>> +
>> +  if (LockTypeIndex < LockNameCount) {
>> +DEBUG ((DEBUG_ERROR, "SecurityLock::LockType: %a, Module: %g, Function: 
>> %a, Output: %a\n", mLockName[LockTypeIndex], Module, Function, 
>> LockEventText));
>> +  } else {
>> +DEBUG ((DEBUG_ERROR, "SecurityLock::LockType: %d, Module: %g, Function: 
>> %a, Output: %a\n", LockType, Module, Function, LockEventText));
>> +  }
>> +}
> 
> I disagree with this implementation. Security log messages are
> important, but they are not necessarily errors. DEBUG_ERROR should be
> used for errors, preferably for such that cannot be recovered from
> (DEBUG_WARN is OK for recoverable errors).
> 
> If DEBUG_INFO is deemed too "quiet" for logging security events, then we
> should introduce a new bit value for the debug bitmask, such as
> DEBUG_SECURITY. We have a number of "special purpose" bits already:
> 
> - DEBUG_LOAD
> - DEBUG_FS
> - DEBUG_POOL
> - DEBUG_PAGE
> - DEBUG_DISPATCH
> - etc
> 
> and I think we have room for DEBUG_SECURITY.
> 
> (1) And then, the log mask in this library instance should be
> 
>   DEBUG_SECURITY | DEBUG_INFO
> 
> I believe.
> 
> Thanks
> Laszlo
> 
> 
> 
>> diff --git 
>> a/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDebugLib.inf
>>  
>> b/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDebugLib.inf
>> new file mode 100644
>> index 00..b641016087
>> --- /dev/null
>> +++ 
>> b/MdeModulePkg/Library/SecurityLockAuditDebugLib/SecurityLockAuditDebugLib.inf
>> @@ -0,0 +1,29 @@
>> +## @file
>> +#
>> +# Library that implements logging and reporting for security locks
>> +# Using DebugLib
>> +#
>> +#
>> +# Copyright (c) 2018, Microsoft Corporation
>> +#
>> +# SPDX-License-Identifier: BSD-2-Clause-Patent
>> +##
>> +
>> +[Defines]
>> +  INF_VERSION= 0x00010005
>> +  BASE_NAME  = SecurityLockAuditDebugLib
>> +  FILE_GUID

Re: [edk2-devel] [PATCH 5/5] MdeModulePkg/PiSmmIpl: Use SecurityLockAuditLib for debug

2019-07-22 Thread Laszlo Ersek
On 07/22/19 06:02, Gao, Zhichao wrote:
> From: Bret Barkelew 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2006
> 
> Use SecurityLockAuditLib in PiSmmIpl to output debug message
> while lock the SMRAM.
> 
> Cc: Jian J Wang 
> Cc: Hao A Wu 
> Cc: Ray Ni 
> Cc: Star Zeng 
> Cc: Liming gao 
> Cc: Sean Brogan 
> Cc: Michael Turner 
> Cc: Bret Barkelew 
> Signed-off-by: Zhichao Gao 
> ---
>  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c   | 2 ++
>  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf | 1 +
>  2 files changed, 3 insertions(+)
> 
> diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c 
> b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
> index 1cf8c93227..604eb1b98e 100644
> --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
> +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
> @@ -33,6 +33,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "PiSmmCorePrivateData.h"
>  
> @@ -780,6 +781,7 @@ SmmIplReadyToLockEventNotify (
>// Lock the SMRAM (Note: Locking SMRAM may not be supported on all 
> platforms)
>//
>mSmmAccess->Lock (mSmmAccess);
> +  SECURITY_LOCK_REPORT_EVENT ("Lock SMRAM", HARDWARE_LOCK);
>  
>//
>// Close protocol and event notification events that do not apply after the
> diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf 
> b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
> index b6b1bbcdac..2240ab3c5f 100644
> --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
> +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
> @@ -46,6 +46,7 @@
>DxeServicesLib
>PcdLib
>ReportStatusCodeLib
> +  SecurityLockAuditLib
>  
>  [Protocols]
>gEfiSmmBase2ProtocolGuid  ## PRODUCES
> 

Here a new lib class dependency is being introduced to "PiSmmIpl.inf".
In addition, the new lib class itself is introduced as a new feature, to
"MdeModulePkg.dec", in patch #1.

This means that every platform DSC that currently consumes
"PiSmmIpl.inf" will fail to build, after this patch set is merged.

That is fine for platform DSCs that live outside of the edk2 repository.
It is not fine for platform DSCs that live inside edk2.

Whenever implementing such patches, please always grep the entire edk2
repo for matches, and implement the necessary updates (you can of course
ask for details before submitting v1).

In the present case, we have

$ git grep -F PiSmmIpl.inf -- '*dsc*'
MdeModulePkg/MdeModulePkg.dsc:  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
OvmfPkg/OvmfPkgIa32.dsc:  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
OvmfPkg/OvmfPkgIa32X64.dsc:  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
OvmfPkg/OvmfPkgX64.dsc:  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf

MdeModulePkg.dsc is updated in patch #4.

(1) Thus, please *prepend* a patch to patch#5, for OvmfPkg:

In the [LibraryClasses] section of all three DSC files, please resolve
the SecurityLockAuditLib class to the SecurityLockAuditDebugLib instance.

Doing things in this order will keep the tree bisectable -- at no stage
of the patch series will OVMF fail to build.

Thanks
Laszlo

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44155): https://edk2.groups.io/g/devel/message/44155
Mute This Topic: https://groups.io/mt/32555410/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] OvmfPkg: enable multiprocessor builds when using build.sh

2019-07-22 Thread Laszlo Ersek
On 07/22/19 09:11, Jordan Justen wrote:
> Maybe a commit message tweak would be:
> 
> OvmfPkg/build.sh: enable multithreaded build by default
> 
> On 2019-07-21 17:58:16, Rebecca Cran wrote:
>> When building both BaseTools and OvmfPkg, enable multiprocessor builds,
>> using up to the number of cores available in the system. This can
>> drastically reduce build times.
>> For example, on a modern ThreadRipper system the
>> time required to build decreases from 3 minutes to 1 minute.
>>
>> Signed-off-by: Rebecca Cran 
>> ---
>>  OvmfPkg/build.sh | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/OvmfPkg/build.sh b/OvmfPkg/build.sh
>> index 4fcbdd2bc9..5d3a672bd2 100755
>> --- a/OvmfPkg/build.sh
>> +++ b/OvmfPkg/build.sh
>> @@ -40,7 +40,7 @@ ARCH_X64=no
>>  BUILDTARGET=DEBUG
>>  BUILD_OPTIONS=
>>  PLATFORMFILE=
>> -THREADNUMBER=1
>> +THREADNUMBER=$(getconf _NPROCESSORS_ONLN)
> 
> Based on OvmfPkg/build.sh --help, I think initializing THREADNUMBER to
> 0 might have the same effect, but not depend on getconf. Does that
> work?

My understanding is the same. The zero value causes the edk2 "build"
utility to fetch the logical CPU count with Python's
multiprocessing.cpu_count() method:

[Source/Python/build/build.py]

if self.ThreadNumber == 0:
try:
self.ThreadNumber = multiprocessing.cpu_count()
except (ImportError, NotImplementedError):
self.ThreadNumber = 1

> I'm not sure why I defaulted this to single threaded build way back in
> 578630802e.

Your commit 578630802ee5 ("accept "-n THREADNUMBER" in OvmfPkg build
script", 2012-07-10) predates the now-default invocation of
multiprocessing.cpu_count() in "build.py".

The latter was added in 29af38b0f8f2 ("BaseTools: Enable
MAX_CONCURRENT_THREAD_NUMBER = 0 feature", 2018-01-15).

Therefore, your patch was consistent with the BaseTools behavior, at the
time you wrote it. We can consider Rebecca's patch to restore the
consistency between "OvmfPkg/build.sh" and the BaseTools default behavior.

> It looks like if we tweaked things more, and omitted adding the -n
> parameter to the build command by default, then it would use the
> Conf/target.txt value, which by default appears to also be 0, so this
> could accomplish the same thing, but also let a user set it in
> target.txt.

I assume that users prefer passing a simple command line parameter to
editing a text file. IOW I believe "THREADNUMBER=0" would be the best
solution.

Thanks
Laszlo

> 
> -Jordan
> 
>>  LAST_ARG=
>>  RUN_QEMU=no
>>  ENABLE_FLASH=no
>> -- 
>> 2.22.0
>>
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44151): https://edk2.groups.io/g/devel/message/44151
Mute This Topic: https://groups.io/mt/32553200/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [Patch 0/9] Enable multiple process AutoGen

2019-07-22 Thread Laszlo Ersek
On 07/22/19 11:11, Feng, Bob C wrote:
> Hi Laszlo,
> 
> Thanks for your detailed testing and comments.
> 
> I send out patch serial V2 to resolve comment 1#.  V2 also fixed some issues 
> found by others and was generated based on master latest version.
> 
> For 3#, I can reproduce the issue, I'll fix it in patch serial V3.  My 
> understanding is that when I fix 3#, 2# will be resolved accordingly. Right? 

Yes. I first discovered the problem with (2), but then I wanted to
reproduce the issue in isolation from QEMU. That is section (3). So if
you fix (3), I expect the build will work just fine as part of the QEMU
tree (2) as well.

> For 5#-2,  When using "-n 1", Autogen should start one worker subprocess to 
> generate autogen files that will be the same as run in serial.
> I'll make the change in patches V3

OK, sounds good.

Thank you,
Laszlo

> 
> For the keyboard interrupt handling mentioned in 4# and 5#-1, I'll do more 
> testing on it. And do the fix in V3.
> Before sending the patches, I tested Ctrl+C to stop the build but not the 
> "pick up".
> 
> Thanks,
> Bob
> 
> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com] 
> Sent: Sunday, July 21, 2019 8:26 PM
> To: Feng, Bob C 
> Cc: devel@edk2.groups.io; Philippe Mathieu-Daudé 
> Subject: Re: [edk2-devel] [Patch 0/9] Enable multiple process AutoGen
> 
> Hi Bob,
> 
> On 07/18/19 08:14, Bob Feng wrote:
>> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875
>>
>> In order to improve the build performance, we implemented 
>> multiple-processes AutoGen. This change will reduce 20% time for 
>> AutoGen phase.
>>
>> The design document can be got from:
>> https://edk2.groups.io/g/devel/files/Designs/2019/0627/Multiple-thread
>> -AutoGen.pdf
>>
>> This patch serial pass the build of Ovmf, MinKabylake, MinPurley, 
>> packages under Edk2 repository and intel client and server platforms.
> 
> I've done some basic regression-testing with this set, applied on top of 
> current master (= commit 8ff68cd5e4c9, "ShellPkg: acpiview: DBG2: Remove 
> redundant forward declarations", 2019-07-19).
> 
> (1) The build process now seems to produce files called
> 
>   GlobalVar_37d7e986-f7e9-45c2-8067-e371421a626c_AARCH64.bin
>   GlobalVar_37d7e986-f7e9-45c2-8067-e371421a626c_ARM.bin
>   GlobalVar_5a9e7754-d81b-49ea-85ad-69eaa7b1539b_IA32.bin
>   GlobalVar_5a9e7754-d81b-49ea-85ad-69eaa7b1539b_X64.bin
> 
> in the project root directory. (The GUIDs match the PLATFORM_GUID
> values from ArmVirtQemu.dsc and OvmfPkg*.dsc.)
> 
> They seem to come from patch "BaseTools: Enable Multiple Process
> AutoGen".
> 
> Can we place these files under the Build/ directory somewhere,
> instead?
> 
> (2) The QEMU project now bundles edk2 (as a git submodule for the edk2
> tree, and some firmware binaries built from that). The build scripts
> carried by QEMU set PYTHON_COMMAND to python2, in order to work
> around TianoCore BZ#1607.
> 
> For regression-testing this set, I ran
> 
> $ make -C roms efi
> 
> with QEMU's edk2 submodule advanced to commit 8ff68cd5e4c9, plus
> this set applied (see above), and with QEMU itself being at
> e2b47666fe15.
> 
> The build itself passes fine, so that's good.
> 
> But, some (not all) of the firmware binaries are *misbuilt*. I'll
> elaborate below (independently of QEMU).
> 
> (3) Consider the following test. (Note that this is independent of the
> QEMU project entirely.)
> 
> (3a) Set up a pristine build environment:
> 
>  # Open a new shell, then:
>  $ git clean -ffdx
>  $ git reset --hard
>  $ git submodule deinit --force --all
>  $ git checkout master
>  $ git submodule update --init
>  $ export PYTHON_COMMAND=python2
>  $ source edksetup.sh
>  $ nice make -C "$EDK_TOOLS_PATH" \
>  -j $(getconf _NPROCESSORS_ONLN)
> 
> (3b) Build OvmfPkgIA32 with one set of features, and capture a
>  checksum of the resultant firmware binary:
> 
>  $ nice build -a IA32 -b NOOPT -p OvmfPkg/OvmfPkgIA32.dsc \
>  -t GCC48
>  $ md5sum Build/OvmfIa32/NOOPT_GCC48/FV/OVMF_CODE.fd
>  8d56575dd3b5c89ac6f1829ae4f41b55
> 
> (3c) *Re*build the same platform with a different set of features,
>  and capture a checksum again:
> 
>  $ nice build -a IA32 -b NOOPT -p OvmfPkg/OvmfPkgIA32.dsc \
>  -t GCC48 -D SECURE_BOOT_ENABLE -D SMM_REQUIRE
>  $ md5sum Build/OvmfIa32/NOOPT_GCC48/FV/OVMF_CODE.fd
>  ed79052e9add242174ccefc78a5bddb3
> 
> Okay, now repeat all three steps from zero, but with the present
> feature patch set applied:
> 
> (3d) Repeat (3a), but rather than checking out the master branch
>  with "git checkout", check out the topic branch that is the
>  same "master" commit, *plus* the present series applied on top.
> 
>  Don't forget 

Re: [edk2-devel] [PATCH v3 24/35] OvmfPkg/XenPlatformPei: Rework memory detection

2019-07-22 Thread Laszlo Ersek
On 07/22/19 16:53, Anthony PERARD wrote:
> On Mon, Jul 15, 2019 at 04:15:21PM +0200, Roger Pau Monné wrote:
>> On Thu, Jul 04, 2019 at 03:42:22PM +0100, Anthony PERARD wrote:
>>> When running as a Xen PVH guest, there is no CMOS to read the memory
>>> size from.  Rework GetSystemMemorySize(Below|Above)4gb() so they can
>>> works without CMOS by reading the e820 table.
>>>
>>> Rework XenPublishRamRegions for PVH, handle the Reserve type and explain
>>> about the ACPI type. MTRR settings aren't modified anymore, on HVM, it's
>>> already done by hvmloader, on PVH it is supposed to have sane default.
>>>
>>> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
>>> Signed-off-by: Anthony PERARD 
>>> Acked-by: Laszlo Ersek 
>>> ---
>>>
>>> Notes:
>>> Comment for Xen people:
>>> About MTRR, should we redo the setting in OVMF? Even if in both case of
>>> PVH and HVM, something would have setup the default type to write back
>>> and handle a few other ranges like PCI hole, hvmloader for HVM or and
>>> libxc I think for PVH.
>>
>> That's a tricky question. Ideally we would like the firmware (OVMF) to
>> take care of that, because it already has code to do so. Problem here
>> is that PVH can also be booted without firmware, in which case it
>> needs the hypervisor to have setup some sane initial MTRR state.
>>
>> The statement in the PVH document about initial MTRR state is vague
>> enough that allows Xen to boot into the guest with a minimal MTRR
>> state, that can for example not contain UC regions for the MMIO
>> regions of passed through devices, hence I think OVMF should be in
>> charge of creating a more complete MTRR state if possible.
>>
>> Is this something OVMF already has logic for?
> 
> Well, there are some logic but it's for QEMU (and uses an interface that
> isn't available when running on Xen, fwcfg).
> 
> The logic that was there for Xen HVM was very simple, a single set
> cache-write-back for the RAM, that's why I remove it (and because I'm
> not sure yet I figured out how to run the mtrr functions correctly in
> OVMF).
> 
> I probably going to have to write a new logic which would rewrite the
> MTRR from scratch instead of relying on the existing setup.

MTRR setup is complex in OVMF, in comparison to firmware that runs on
physical machines, because:

- the physical RAM size can change from boot to boot, with almost total
freedom, and that can incur some unexpected changes in the physical RAM
map too (i.e. affect not just the end, but holes)

- the number of variable MTRRs is severely limited and can't cover an
arbitrary physical RAM map. And, some platform-independent modules in
edk2 consume variable MTRRs too, via gDS->SetMemorySpaceAttributes(), so
we have to be very conservative with even those variable MTRRs that exist.

Even on QEMU i440fx & pc, we've *just* made OVMF cope with an arbitrary
guest RAM size (that is, beyond 128MB), and that logic relies on some
open-coded board-specific knowledge about low (<4G) RAM size. So much so
that, on i440fx, we place the 32-bit PCI IOMMU aperture based on what we
can configure with a minimal amount of variable MTRRs, and not vice
versa (i.e. we don't first set the 32-bit MMIO aperture and then attempt
to mark it as uncached). Please see:

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

This is one of the nastiest parts of OVMF. (PlatformPei is, in general.)

Thanks
Laszlo

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44149): https://edk2.groups.io/g/devel/message/44149
Mute This Topic: https://groups.io/mt/32308708/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v3 09/35] OvmfPkg/OvmfXen: use a TimerLib instance that depends only on the CPU

2019-07-22 Thread Laszlo Ersek
On 07/22/19 15:49, Anthony PERARD wrote:
> On Mon, Jul 15, 2019 at 04:22:19PM +0200, Roger Pau Monné wrote:
>> On Thu, Jul 04, 2019 at 03:42:07PM +0100, Anthony PERARD wrote:
>>> ACPI Timer does not work in a PVH guest, but local APIC works on both
>>
>> This is not accurate. It's not that the ACPI timer doesn't work, it's
>> just that it's not present. The PM_TMR_BLK should be set to 0 to
>> indicate the lack of PM timer support, or else there's something
>> broken.
> 
> I'll reword that first sentence.
> 
> OVMF doesn't look at the PM_TMR_BLK value when initializing that timer,
> it only looks at the PCI host bridge device ID because OVMF is built
> with QEMU in mind and there are only two possibles choices, QEMU is
> running with a piix or q35 machine type, I think.

We should split this statement in two. :)

OVMF doesn't look at ACPI payload because it is a design goal to keep
the guest firmware un-enlightened about such ACPI contents that arrive
from the hypervisor. Parsing ACPI in firmware always looks attractive
until someone actually writes the code, and then it always ends in
misery -- at the latest when people realize they have to parse AML.
Parsing ACPI is only feasible when you have a full-blown ACPICA (or
similar) subsystem, and edk2 doesn't. Therefore, OVMF looks at either
hardware, or specialized paravirt information channels such as fw_cfg
files, that are easy to parse by design.

Second, within the above design guidelines (i.e. "don't try to parse
ACPI", and "cook your paravirt info if you want the firmware to eat
it"), OVMF looks at such artifacts to steer its behavior for which
patches have been submitted & merged. OVMF is integrated with Xen to the
extent of patches merged from the Xen community. Thus, in my opinion,
"OVMF is built with QEMU in mind" is a stretch -- perhaps it is so in
*my* mind personally, but that's just me. We have designated reviewers
for Xen-related code, and this series certainly builds OVMF with Xen in
mind. :)

If we reworded the statement, e.g. as "the present code targets QEMU and
is unsuitable when running on Xen", then I would not object.

Thanks!
Laszlo

>>> PVH and HVM.
>>>
>>> Note that the use of SecPeiDxeTimerLibCpu might be an issue with a
>>> driver of type DXE_RUNTIME_DRIVER. I've attemptde to find out which of
>>   ^ attempted
>>> the DXE_RUNTIME_DRIVER uses the TimerLib at runtime. I've done that by
>>> replacing the TimerLib evaluation in
>>> [LibraryClasses.common.DXE_RUNTIME_DRIVER] by a different one and
>>> check every module that uses it (with the --report-file=report build
>>   ^ checking
>>> option).
>>>
>>> ResetSystemRuntimeDxe is calling the TimerLib API at runtime to do the
>>> operation "EfiResetCold", so this may never complete if the OS have
>>> disabled the Local APIC Timer.
>>
>> Thanks, Roger.
> 
> Thanks,
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44148): https://edk2.groups.io/g/devel/message/44148
Mute This Topic: https://groups.io/mt/32308573/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v3 00/35] Specific platform to run OVMF in Xen PVH and HVM guests

2019-07-22 Thread Laszlo Ersek
On 07/19/19 18:42, Anthony PERARD wrote:
> On Fri, Jul 05, 2019 at 02:21:13PM +0200, Laszlo Ersek wrote:
>> The patches on the list are malformed. They have
>>
>> Content-Transfer-Encoding: quoted-printable
>>
>> which is fine, in itself; however, they have CR-CR-LF line terminators.
>>
>> For example, from the first patch:
>>
>> diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf b/OvmfPkg/L=
>> ibrary/ResetSystemLib/ResetSystemLib.inf
>> index 7c44f99a5c..2f24dac87f 100644
>> --- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
>> +++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
>> @@ -30,4 +30,5 @@ [Packages]
>>  [LibraryClasses]=0D=0D
>>DebugLib=0D=0D
>>IoLib=0D=0D
>> +  PciLib=0D=0D
>>TimerLib=0D=0D
>>
>> Note "=0D=0D".
>>
>> Now, if I try to apply this full set with git-am like that, the first
>> patch in the series applies, but the second still fails:
>>
>>> error: corrupt patch at line 23
>>> Patch failed at 0002 OvmfPkg: Create platform OvmfXen
>>
>> Based on the email headers, the "iphmx.com" references suggest (via a
>> google search) "Cisco's Ironport Cloud email service".
>>
>> I think that email service (MTA) is broken.
>>
>> If you could use a different MTA (or get the current one fixed), that
>> would be helpful. (Yes, yes: if the edk2 project didn't use CRLF line
>> terminators, that would be *even more* helpful.)
> 
> I'm not sure that using a different MTA is going to help. I don't think
> I can find a patch on the list that I can apply (without using unix2dos).
> I did send a patch to my gmail address, and it looks fine (=0D in the
> expected places and nowhere else). So maybe when a patch is sent through
> a mailing list, some more formating is done?
> 
> Anyway, can I try sending patch encoded in base64 instead of
> quoted-printable? That would probably work better.
> 
> I found <20190704040731.5303-1-g...@suse.com> on the list that is base64
> encoded, that I can easily apply and patchew too.

That patch ("[edk2-devel] [PATCH v2] OvmfPkg: use DxeTpmMeasurementLib
if and only if TPM2_ENABLE") worked fine for me as well.

However, Gary confirmed elsewhere that he had to tweak the posting
process manually, for that patch:

http://mid.mail-archive.com/20190704085826.GD32340@GaryWorkstation

Thanks
Laszlo

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44147): https://edk2.groups.io/g/devel/message/44147
Mute This Topic: https://groups.io/mt/32308564/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 0/4] Arm, ArmPlatform, Crypto, Embedded: list internal headers in [Sources]

2019-07-22 Thread Michael D Kinney
We could consider checking for these type of issues in
the ECC tool instead of build and make it an error from
ECC instead of a warning.

Mike

> -Original Message-
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io]
> On Behalf Of Laszlo Ersek
> Sent: Monday, July 22, 2019 10:33 AM
> To: Leif Lindholm 
> Cc: edk2-devel-groups-io ; Ard
> Biesheuvel ; Wang, Jian J
> ; Ye, Ting 
> Subject: Re: [edk2-devel] [PATCH 0/4] Arm, ArmPlatform,
> Crypto, Embedded: list internal headers in [Sources]
> 
> On 07/22/19 12:37, Leif Lindholm wrote:
> > On Fri, Jul 19, 2019 at 06:43:15PM +0200, Laszlo Ersek
> wrote:
> >> Repo:   https://github.com/lersek/edk2.git
> >> Branch: internal_hdrs
> >>
> >> The BaseTools build feature introduced for
> TianoCore#1804 / in commit
> >> 1fa6699e6cd4 ("BaseTools: Add a checking for Sources
> section in INF
> >> file", 2019-06-10) logs some (non-fatal) warnings
> about unlisted
> >> internal header files. List those files explicitly.
> >
> > Urgh.
> > Yeah. I'm still not super comfortable with this
> duplication of
> > dependency scanning (as discussed in
> > https://edk2.groups.io/g/devel/topic/31866190), but I
> have to confess
> > I also don't really care enough to do anything about
> it.
> >
> > So, while I'm tempted to keep the warnings around as a
> reminder, if
> > you prefer to get rid of them - for the pat of the
> series I was cc:d on:
> > Reviewed-by: Leif Lindholm 
> 
> Thanks!
> 
> Yes, the warnings are an annoyance, and they are valid
> too. How the INF files are caught / reported is a
> separate question IMO.
> 
> Thanks!
> Laszlo
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44146): https://edk2.groups.io/g/devel/message/44146
Mute This Topic: https://groups.io/mt/32529014/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 0/4] Arm, ArmPlatform, Crypto, Embedded: list internal headers in [Sources]

2019-07-22 Thread Laszlo Ersek
On 07/22/19 12:37, Leif Lindholm wrote:
> On Fri, Jul 19, 2019 at 06:43:15PM +0200, Laszlo Ersek wrote:
>> Repo:   https://github.com/lersek/edk2.git
>> Branch: internal_hdrs
>>
>> The BaseTools build feature introduced for TianoCore#1804 / in commit
>> 1fa6699e6cd4 ("BaseTools: Add a checking for Sources section in INF
>> file", 2019-06-10) logs some (non-fatal) warnings about unlisted
>> internal header files. List those files explicitly.
> 
> Urgh.
> Yeah. I'm still not super comfortable with this duplication of
> dependency scanning (as discussed in
> https://edk2.groups.io/g/devel/topic/31866190), but I have to confess
> I also don't really care enough to do anything about it.
> 
> So, while I'm tempted to keep the warnings around as a reminder, if
> you prefer to get rid of them - for the pat of the series I was cc:d on:
> Reviewed-by: Leif Lindholm 

Thanks!

Yes, the warnings are an annoyance, and they are valid too. How the INF
files are caught / reported is a separate question IMO.

Thanks!
Laszlo

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44145): https://edk2.groups.io/g/devel/message/44145
Mute This Topic: https://groups.io/mt/32529014/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH V2 0/4] Add a pcd PcdBootManagerInBootOrder to control whether BootManager is in BootOrder

2019-07-22 Thread Laszlo Ersek
On 07/22/19 05:17, Gao, Zhichao wrote:
> Hi Laszlo,
> 
>> -Original Message-
>> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>> Laszlo Ersek
>> Sent: Friday, July 19, 2019 10:15 PM
>> To: Gao, Zhichao ; devel@edk2.groups.io
>> Cc: Kinney, Michael D ; Gao, Liming
>> ; Wang, Jian J ; Wu, Hao A
>> ; Ni, Ray ; Zeng, Star
>> ; Sean Brogan ;
>> Michael Turner ; Bret Barkelew
>> 
>> Subject: Re: [edk2-devel] [PATCH V2 0/4] Add a pcd
>> PcdBootManagerInBootOrder to control whether BootManager is in
>> BootOrder

>> (3) If a platform links DxeCapsuleLibNull into CapsuleRuntimeDxe, that has
>> the following consequences:
>>
>> - QueryCapsuleCapabilities()
>>   [MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c] calls
>>   SupportCapsuleImage()
>>   [MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.c].
>>
>>   The return status is EFI_UNSUPPORTED, consistently.
>>
>> - UpdateCapsule()
>>   [MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c] calls
>> both
>>   SupportCapsuleImage() -- see above -- and ProcessCapsuleImage()
>>   [MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.c].
>>
>>   The return status is EFI_UNSUPPORTED, consistently.
>>
>> Meaning that, if a platform uses DxeCapsuleLibNull, it *must* clear the
>> EFI_RT_SUPPORTED_UPDATE_CAPSULE and
>> EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES bits in the
>> "RuntimeServicesSupported" variable.
>>
>> Now, your patch introduces "PcdRuntimeServicesSupport" in the
>> [PcdsFixedAtBuild] section of "MdePkg.dec". Based on that, I think we
>> should add a CONSTRUCTOR function to DxeCapsuleLibNull, as a separate
>> patch.
>>
>> The constructor function should do:
>>
>>   if (((FixedPcdGet16 (PcdRuntimeServicesSupport) &
>> EFI_RT_SUPPORTED_UPDATE_CAPSULE) != 0) ||
>>   ((FixedPcdGet16 (PcdRuntimeServicesSupport) &
>> EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES) != 0)) {
>> //
>> // This library instance is unsuitable for implementing the
>> // UpdateCapsule() and SupportCapsuleImage() runtime services.
>> //
>> return EFI_UNSUPPORTED;
>>   }
>>   return EFI_SUCCESS;
>>
>> Why is this important? Because it will *force* platforms to expose their lack
>> of capsule support in the new PCD. Otherwise, the firmware will not boot --
>> and that is impossible to miss.
> 
> I see your point. The platforms which use null version CapsuleLib should 
> setting the related bit in the new PCD. That's right.
> But changing the whole related platforms which use the null version is a 
> challenge.

You don't have to change all platforms in existence, in this patch
series, just those that live inside the core edk2 repository.


> If I missed some, those platforms would not boot because of the patch.

Yes, and that's exactly the point.

The above code will cause an assertion failure for such platforms.
People will look at the error message, will locate the relevant source
code, will run "git blame" and "git log" on the source file, and they
will learn about the subject TianoCore BZ, and the new responsibility
for their platform DSC.

Openly forcing downstream platforms to implement a very simple change (a
PCD setting in the platform DSC) is a whole lot better than silently
breaking spec conformance for them.

(Obviously, it would even be better if we could write code that kept
those platforms spec-conformant by default. But that's not possible,
because the change in UEFI-2.8 spells out a new requirement.)


> And I think miss this change for DxeCapsuleLibNull wouldn't violate the spec.

Well, I disagree. :)


> I'd better to hear more comments about this.

Sure, absolutely! Feedback is welcome, like always.


>> (4) The situation is somewhat similar with "PcdCapsuleInRamSupport". If
>> "PcdCapsuleInRamSupport" is FALSE, then UpdateCapsule() will always
>> return EFI_UNSUPPORTED.
>>
>> Therefore, the entry point function of CapsuleRuntimeDxe --
>> CapsuleServiceInitialize() -- should get the following assertion:
>>
>>   ASSERT (
>> PcdGetBool (PcdCapsuleInRamSupport) ||
>> ((FixedPcdGet16 (PcdRuntimeServicesSupport) &
>>   EFI_RT_SUPPORTED_UPDATE_CAPSULE) == 0)
>> );
>>
>>
>> (5) For each platform in the edk2 tree that either uses DxeCapsuleLibNull or
>> sets "PcdCapsuleInRamSupport" to FALSE, the corresponding bits should be
>> cleared in "PcdRuntimeServicesSupport", in the platform DSC files.
>>
>> This would mean a number of new patches for this series.
> 
> (4) and (5) would force the platform to set PcdRuntimeServicesSupport base on 
> PcdCapsuleInRamSupport. That' fine. But I should know the specific platforms 
> that already set "PcdCapsuleInRamSupport". If the PcdCapsuleInRamSupport is 
> only an introduction, that means no platform sets it, no patch is required.

Even if no platform sets PcdCapsuleInRamSupport to FALSE at this time, a
platform can choose to do so later. And, at that later point, any
inconsistency between PcdCapsuleInRamSupport and

Re: [edk2-devel] [edk2-platforms Patch V2 5/5] Vlv2Tbl2DevicePkg: Convert BAT/sh Build scripts to Python

2019-07-22 Thread Michael D Kinney
Gary,

Thanks for the feedback.  I will send out a V3.

I have fixed the source files with non-ASCII characters that
are preventing the reports from being generated on Linux 
systems.  I will enter a BZ to update the build tools to 
be more resilient for this case.  Non-ASCII characters should
not be present in source files, but presence of non-ASCII
characters should not break the build with a python stack trace.
The report should still be generated correctly.

Thanks,

Mike

> -Original Message-
> From: Gary Lin [mailto:g...@suse.com]
> Sent: Sunday, July 21, 2019 9:09 PM
> To: devel@edk2.groups.io; Kinney, Michael D
> 
> Cc: Qian, Yi ; Sun, Zailiang
> 
> Subject: Re: [edk2-devel] [edk2-platforms Patch V2 5/5]
> Vlv2Tbl2DevicePkg: Convert BAT/sh Build scripts to Python
> 
> On Thu, Jul 18, 2019 at 11:02:47PM -0700,  Michael D
> Kinney  wrote:
> > Convert Build_IFWI and bld_vlv BAT/sh scripts to OS
> > independent python script PeBuild.py.  This script
> > generates the BiosId file.  Standard EDK II build
> > commands are used to build FW images and capsules.
> >
> > * Sample VS2015x86 commands for IA32/X64 and
> DEBUG/RELEASE
> >   build -a IA32 -a X64 -t VS2015x86 -p
> Vlv2TbltDevicePkg\PlatformPkgX64.dsc
> >   build -a IA32 -a X64 -t VS2015x86 -p
> Vlv2TbltDevicePkg\PlatformPkgX64.dsc
> >   build -a IA32-t VS2015x86 -p
> Vlv2TbltDevicePkg\PlatformPkgIA32.dsc
> >   build -a IA32-t VS2015x86 -p
> Vlv2TbltDevicePkg\PlatformPkgIA32.dsc
> >
> > * Sample GCC5 commands for IA32/X64 and DEBUG/RELEASE
> >   build -a IA32 -a X64 -n 5 -t GCC5 -p
> Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> >   build -a IA32 -a X64 -n 5 -t GCC5 -p
> Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> >   build -a IA32-n 5 -t GCC5 -p
> Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> >   build -a IA32-n 5 -t GCC5 -p
> Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> >
> Hi Mike,
> 
> I found some errors in Readme.md
> 
> > Cc: Zailiang Sun 
> > Cc: Yi Qian 
> > Cc: Gary Lin 
> > Signed-off-by: Michael D Kinney
> 
> > ---
> >  .../Intel/Vlv2TbltDevicePkg/Build_IFWI.bat| 118 --
> 
> >  .../Intel/Vlv2TbltDevicePkg/Build_IFWI.sh | 100 --
> ---
> >  .../Vlv2TbltDevicePkg/PlatformCapsule.fdf |  48 --
> -
> >  .../Vlv2TbltDevicePkg/PlatformCapsuleIA32.dsc |  39 --
> >  .../Vlv2TbltDevicePkg/PlatformCapsuleX64.dsc  |  39 --
> >  .../Intel/Vlv2TbltDevicePkg/PlatformPkg.fdf   |  30 +-
> >  .../Vlv2TbltDevicePkg/PlatformPkgIA32.dsc |  13 +-
> >  .../Vlv2TbltDevicePkg/PlatformPkgX64.dsc  |  13 +-
> >  Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py  | 348
> ++
> >  Platform/Intel/Vlv2TbltDevicePkg/Readme.md|  62
> ++--
> >  Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.bat  | 303 --
> -
> >  Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.sh   | 222 --
> -
> >  12 files changed, 432 insertions(+), 903 deletions(-)
> >  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat
> >  delete mode 100755
> Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.sh
> >  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/PlatformCapsule.fdf
> >  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/PlatformCapsuleIA32.dsc
> >  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/PlatformCapsuleX64.dsc
> >  create mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py
> >  delete mode 100644
> Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.bat
> >  delete mode 100755
> Platform/Intel/Vlv2TbltDevicePkg/bld_vlv.sh
> >
> > diff --git
> a/Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat
> b/Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat
> > deleted file mode 100644
> > index f65aa61f4a..00
> > --- a/Platform/Intel/Vlv2TbltDevicePkg/Build_IFWI.bat
> > +++ /dev/null
> > @@ -1,118 +0,0 @@
> > -@REM @file
> > -@REM   Windows batch file to build BIOS ROM
> > -@REM
> > -@REM Copyright (c) 2006 - 2019, Intel Corporation. All
> rights reserved.
> > -@REM SPDX-License-Identifier: BSD-2-Clause-Patent
> > -@REM
> > -
> > -@echo off
> > -
> > -SetLocal EnableDelayedExpansion EnableExtensions
> > -
> > -:: Assign initial values
> > -set exitCode=0
> > -set "Build_Flags= "
> > -set PLATFORM_PACKAGE=Vlv2TbltDevicePkg
> > -
> > -set PLATFORM_PATH=%WORKSPACE%
> > -if not exist %PLATFORM_PATH%\%PLATFORM_PACKAGE% (
> > -  if defined PACKAGES_PATH (
> > -for %%i IN (%PACKAGES_PATH%) DO (
> > -  if exist %%~fi\%PLATFORM_PACKAGE% (
> > -set PLATFORM_PATH=%%~fi
> > -goto PlatformPackageFound
> > -  )
> > -)
> > -  ) else (
> > -echo.
> > -echo !!! ERROR !!! Cannot find %PLATFORM_PACKAGE%
> !!!
> > -echo.
> > -goto Exit
> > -  )
> > -)
> > -:PlatformPackageFound
> > -
> > -:: Parse Optional arguments
> > -:OptLoop
> > -if /i "%~1"=="/?" goto Usage
> > -
> > -if /i "%~1"=="/l" (
> > -set Build_Flags=%Build_Flags% /l
> > -shift
> > -goto OptLoop
> > -)
> > -if /i "%~1"=="/y" (
> > -set Build_Flags=%Build_Flags% /y
> > -shift
> > -goto OptLoop
> > 

Re: [edk2-devel] [PATCH v3 32/35] OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn

2019-07-22 Thread Anthony PERARD
On Wed, Jul 10, 2019 at 12:48:57PM +0200, Laszlo Ersek wrote:
> On 07/04/19 16:42, Anthony PERARD wrote:
> > On a Xen PVH guest, none of the existing serial or console interface
> > works, so we add a new one, based on XenConsoleSerialPortLib, and
> > implemented via SerialDxe.
> > 
> > That is a simple console implementation that can works on both PVH
> > guest and HVM guests, even if it rarely going to be use on HVM.
> > 
> > Have PlatformBootManagerLib look for the new console, when running as a
> > Xen guest.
> > 
> > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
> > Signed-off-by: Anthony PERARD 
> > ---

> > diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c 
> > b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c
> > index 36aab784d7..a9b1fe274a 100644
> > --- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c
> > +++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c
> > @@ -9,18 +9,19 @@
> >  
> >  #include "BdsPlatform.h"
> >  #include 
> > +#include 
> >  
> >  //
> >  // Debug Agent UART Device Path structure
> >  //
> > -#pragma pack(1)
> > +#pragma pack (1)
> >  typedef struct {
> >VENDOR_DEVICE_PATHVendorHardware;
> >UART_DEVICE_PATH  Uart;
> >VENDOR_DEVICE_PATHTerminalType;
> >EFI_DEVICE_PATH_PROTOCOL  End;
> >  } VENDOR_UART_DEVICE_PATH;
> > -#pragma pack()
> > +#pragma pack ()
> >  
> >  //
> >  // USB Keyboard Device Path structure
> > @@ -43,6 +44,18 @@ typedef struct {
> >  } VENDOR_RAMFB_DEVICE_PATH;
> >  #pragma pack ()
> >  
> > +//
> > +// Xen Console Device Path structure
> > +//
> > +#pragma pack(1)
> > +typedef struct {
> > +  VENDOR_DEVICE_PATHVendorHardware;
> > +  UART_DEVICE_PATH  Uart;
> > +  VENDOR_DEVICE_PATHTerminalType;
> > +  EFI_DEVICE_PATH_PROTOCOL  End;
> > +} XEN_CONSOLE_DEVICE_PATH;
> > +#pragma pack()
> > +
> 
> This version of the patch addresses all of my v2 review comments (either
> by code changes or by explanations in the Notes section) -- thanks for that.
> 
> However, when you arrived at my reuqest (6) in
> ,
> and searched the source file for "pack(" -- in order to insert a space
> character before the opening paren --, the match was *not* around the
> new XEN_CONSOLE_DEVICE_PATH structure. Instead, it was around the
> preexistent VENDOR_UART_DEVICE_PATH structure. And so you fixed the
> style for the old code, and not the new code.
> 
> But: that's actually useful. Because now that I'm looking at
> VENDOR_UART_DEVICE_PATH, it seems that we don't need the new type
> XEN_CONSOLE_DEVICE_PATH at all. Is that right? So:
> 
> (1) Please drop XEN_CONSOLE_DEVICE_PATH.
> 
> (2) Please replace the comment
> 
>   Debug Agent UART Device Path structure
> 
> with
> 
>   Vendor UART Device Path structure
> 
> on VENDOR_UART_DEVICE_PATH.
> 
> (3) Please preserve the "misplaced" whitespace fix, for "pack(", around
> VENDOR_UART_DEVICE_PATH.
> 
> (4) Please use VENDOR_UART_DEVICE_PATH as the type of gXenConsoleDevicePath.
> 
> With those:
> 
> Reviewed-by: Laszlo Ersek 

I'm going to add the following to the commit message:

  Since we use VENDOR_UART_DEVICE_PATH, fix its description and
  coding style.


-- 
Anthony PERARD

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44142): https://edk2.groups.io/g/devel/message/44142
Mute This Topic: https://groups.io/mt/32308731/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v3 24/35] OvmfPkg/XenPlatformPei: Rework memory detection

2019-07-22 Thread Anthony PERARD
On Mon, Jul 15, 2019 at 04:15:21PM +0200, Roger Pau Monné wrote:
> On Thu, Jul 04, 2019 at 03:42:22PM +0100, Anthony PERARD wrote:
> > When running as a Xen PVH guest, there is no CMOS to read the memory
> > size from.  Rework GetSystemMemorySize(Below|Above)4gb() so they can
> > works without CMOS by reading the e820 table.
> > 
> > Rework XenPublishRamRegions for PVH, handle the Reserve type and explain
> > about the ACPI type. MTRR settings aren't modified anymore, on HVM, it's
> > already done by hvmloader, on PVH it is supposed to have sane default.
> > 
> > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
> > Signed-off-by: Anthony PERARD 
> > Acked-by: Laszlo Ersek 
> > ---
> > 
> > Notes:
> > Comment for Xen people:
> > About MTRR, should we redo the setting in OVMF? Even if in both case of
> > PVH and HVM, something would have setup the default type to write back
> > and handle a few other ranges like PCI hole, hvmloader for HVM or and
> > libxc I think for PVH.
> 
> That's a tricky question. Ideally we would like the firmware (OVMF) to
> take care of that, because it already has code to do so. Problem here
> is that PVH can also be booted without firmware, in which case it
> needs the hypervisor to have setup some sane initial MTRR state.
> 
> The statement in the PVH document about initial MTRR state is vague
> enough that allows Xen to boot into the guest with a minimal MTRR
> state, that can for example not contain UC regions for the MMIO
> regions of passed through devices, hence I think OVMF should be in
> charge of creating a more complete MTRR state if possible.
> 
> Is this something OVMF already has logic for?

Well, there are some logic but it's for QEMU (and uses an interface that
isn't available when running on Xen, fwcfg).

The logic that was there for Xen HVM was very simple, a single set
cache-write-back for the RAM, that's why I remove it (and because I'm
not sure yet I figured out how to run the mtrr functions correctly in
OVMF).

I probably going to have to write a new logic which would rewrite the
MTRR from scratch instead of relying on the existing setup.

> Also accounting for the MMIO regions of devices?

I'll have to dig deeper into OVMF codes, and PCI device handling. On
HVM, we have a different logic than the one for QEMU, OVMF only scan
what hvmloader have done instead of re-setup the pci devices. I'm
probably missing other stuff.

> > diff --git a/OvmfPkg/XenPlatformPei/MemDetect.c 
> > b/OvmfPkg/XenPlatformPei/MemDetect.c
> > index cb7dd93ad6..3e33e7f414 100644
> > --- a/OvmfPkg/XenPlatformPei/MemDetect.c
> > +++ b/OvmfPkg/XenPlatformPei/MemDetect.c
> > @@ -96,6 +96,47 @@ Q35TsegMbytesInitialization (
> >mQ35TsegMbytes = ExtendedTsegMbytes;
> >  }
> >  
> > +STATIC
> > +UINT64
> > +GetHighestSystemMemoryAddress (
> > +  BOOLEAN   Below4gb
> > +  )
> > +{
> > +  EFI_E820_ENTRY64*E820Map;
> > +  UINT32  E820EntriesCount;
> > +  EFI_E820_ENTRY64*Entry;
> > +  EFI_STATUS  Status;
> > +  UINT32  Loop;
> > +  UINT64  HighestAddress;
> > +  UINT64  EntryEnd;
> > +
> > +  HighestAddress = 0;
> > +
> > +  Status = XenGetE820Map (, );
> 
> You could maybe initialize this as a global to avoid having to issue
> a hypercall each time you need to get something from the memory map.

That function does that, it only make the hypercall once. (The hypercall
can only be made once anyway, the second time Xen doesn't return the
map.)

> > +  ASSERT_EFI_ERROR (Status);
> > +
> > +  for (Loop = 0; Loop < E820EntriesCount; Loop++) {
> > +Entry = E820Map + Loop;
> > +EntryEnd = Entry->BaseAddr + Entry->Length;
> > +
> > +if (Entry->Type == EfiAcpiAddressRangeMemory &&
> > +EntryEnd > HighestAddress) {
> > +
> > +  if (Below4gb && (EntryEnd <= BASE_4GB)) {
> > +HighestAddress = EntryEnd;
> > +  } else if (!Below4gb && (EntryEnd >= BASE_4GB)) {
> > +HighestAddress = EntryEnd;
> > +  }
> > +}
> > +  }
> > +
> > +  //
> > +  // Round down the end address.
> > +  //
> > +  HighestAddress &= ~(UINT64)EFI_PAGE_MASK;
> > +
> > +  return HighestAddress;
> 
> You could do the rounding on the return statement.

Yes, I think that can be done.

> > +}
> >  
> >  UINT32
> >  GetSystemMemorySizeBelow4gb (
> > @@ -105,6 +146,19 @@ GetSystemMemorySizeBelow4gb (
> >UINT8 Cmos0x34;
> >UINT8 Cmos0x35;
> >  
> > +  //
> > +  // In PVH case, there is no CMOS, we have to calculate the memory size
> > +  // from parsing the E820
> > +  //
> > +  if (XenPvhDetected ()) {
> 
> IIRC on HVM you can also get the memory map from the hypercall, in
> which case you could use the same code path for both HVM and PVH.

I think that wouldn't work because in my experiment, the hypercall would
only return the map the first time (at least on PVH). hvmloader already
make the hypercall so OVMF can't.

On the other hand, XenGetE820Map() return an E820 map, it doesn't matter
if 

Re: [edk2-devel] [PATCH v3 09/35] OvmfPkg/OvmfXen: use a TimerLib instance that depends only on the CPU

2019-07-22 Thread Anthony PERARD
On Mon, Jul 15, 2019 at 04:22:19PM +0200, Roger Pau Monné wrote:
> On Thu, Jul 04, 2019 at 03:42:07PM +0100, Anthony PERARD wrote:
> > ACPI Timer does not work in a PVH guest, but local APIC works on both
> 
> This is not accurate. It's not that the ACPI timer doesn't work, it's
> just that it's not present. The PM_TMR_BLK should be set to 0 to
> indicate the lack of PM timer support, or else there's something
> broken.

I'll reword that first sentence.

OVMF doesn't look at the PM_TMR_BLK value when initializing that timer,
it only looks at the PCI host bridge device ID because OVMF is built
with QEMU in mind and there are only two possibles choices, QEMU is
running with a piix or q35 machine type, I think.

> > PVH and HVM.
> > 
> > Note that the use of SecPeiDxeTimerLibCpu might be an issue with a
> > driver of type DXE_RUNTIME_DRIVER. I've attemptde to find out which of
>   ^ attempted
> > the DXE_RUNTIME_DRIVER uses the TimerLib at runtime. I've done that by
> > replacing the TimerLib evaluation in
> > [LibraryClasses.common.DXE_RUNTIME_DRIVER] by a different one and
> > check every module that uses it (with the --report-file=report build
>   ^ checking
> > option).
> > 
> > ResetSystemRuntimeDxe is calling the TimerLib API at runtime to do the
> > operation "EfiResetCold", so this may never complete if the OS have
> > disabled the Local APIC Timer.
> 
> Thanks, Roger.

Thanks,

-- 
Anthony PERARD

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44140): https://edk2.groups.io/g/devel/message/44140
Mute This Topic: https://groups.io/mt/32308573/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms PATCH v1 3/3] NetsecDxe: SnpInitialize() waits for media linking up

2019-07-22 Thread Masahisa Kojima
The latest NetsecDxe requires issueing phy reset at the
last stage of initialization to safely exit loopback mode.
However, as a result, it takes a couple of seconds for link state
to get stable, which could cause auto-chosen pxeboot to fail
due to MediaPresent check error.

This patch adds link state check with 5s timeout in NetsecDxe
initialization. The timeout value can be adjustable via
configuration file.

Signed-off-by: Masahisa Kojima 
Signed-off-by: Satoru Okamoto 
---
 .../Socionext/DeveloperBox/DeveloperBox.dsc   |   1 +
 .../Drivers/Net/NetsecDxe/NetsecDxe.c | 232 --
 .../Drivers/Net/NetsecDxe/NetsecDxe.dec   |   1 +
 .../Drivers/Net/NetsecDxe/NetsecDxe.inf   |   1 +
 4 files changed, 110 insertions(+), 125 deletions(-)

diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc 
b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
index 97fb8c410c60..af149607f3ce 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
@@ -138,6 +138,7 @@
   gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStartThreshold|36
   gNetsecDxeTokenSpaceGuid.PcdFlowCtrlStopThreshold|48
   gNetsecDxeTokenSpaceGuid.PcdPauseTime|256
+  gNetsecDxeTokenSpaceGuid.PcdMediaDetectTimeoutOnBoot|5
 
   gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase|0x0808
   gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress|7
diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c 
b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c
index 0b91d4af44a3..a304e02208fa 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c
@@ -169,6 +169,98 @@ ExitUnlock:
   return Status;
 }
 
+EFI_STATUS
+EFIAPI
+NetsecUpdateLink (
+  IN  EFI_SIMPLE_NETWORK_PROTOCOL*Snp
+  )
+{
+  NETSEC_DRIVER *LanDriver;
+  ogma_phy_link_status_tphy_link_status;
+  ogma_gmac_mode_t  ogma_gmac_mode;
+  ogma_err_togma_err;
+  BOOLEAN   ValidFlag;
+  ogma_gmac_mode_t  GmacMode;
+  BOOLEAN   RxRunningFlag;
+  BOOLEAN   TxRunningFlag;
+  EFI_STATUSErrorStatus;
+
+  LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
+
+  // Update the media status
+  ogma_err = ogma_get_phy_link_status (LanDriver->Handle,
+   _link_status);
+  if (ogma_err != OGMA_ERR_OK) {
+DEBUG ((DEBUG_ERROR,
+  "NETSEC: ogma_get_phy_link_status failed with error code: %d\n",
+  (INT32)ogma_err));
+ErrorStatus = EFI_DEVICE_ERROR;
+goto Fail;
+  }
+
+  // Update the GMAC status
+  ogma_err = ogma_get_gmac_status (LanDriver->Handle, , ,
+   , );
+  if (ogma_err != OGMA_ERR_OK) {
+DEBUG ((DEBUG_ERROR,
+  "NETSEC: ogma_get_gmac_status failed with error code: %d\n",
+  (INT32)ogma_err));
+ErrorStatus = EFI_DEVICE_ERROR;
+goto Fail;
+  }
+
+  // Stop GMAC when GMAC is running and physical link is down
+  if (RxRunningFlag && TxRunningFlag && !phy_link_status.up_flag) {
+ogma_err = ogma_stop_gmac (LanDriver->Handle, OGMA_TRUE, OGMA_TRUE);
+if (ogma_err != OGMA_ERR_OK) {
+  DEBUG ((DEBUG_ERROR,
+"NETSEC: ogma_stop_gmac() failed with error status %d\n",
+ogma_err));
+  ErrorStatus = EFI_DEVICE_ERROR;
+  goto Fail;
+}
+  }
+
+  // Start GMAC when GMAC is stopped and physical link is up
+  if (!RxRunningFlag && !TxRunningFlag && phy_link_status.up_flag) {
+ZeroMem (_gmac_mode, sizeof (ogma_gmac_mode_t));
+ogma_gmac_mode.link_speed = phy_link_status.link_speed;
+ogma_gmac_mode.half_duplex_flag = 
(ogma_bool)phy_link_status.half_duplex_flag;
+if (!phy_link_status.half_duplex_flag && FixedPcdGet8 (PcdFlowCtrl)) {
+  ogma_gmac_mode.flow_ctrl_enable_flag = FixedPcdGet8 (PcdFlowCtrl);
+  ogma_gmac_mode.flow_ctrl_start_threshold = FixedPcdGet16 
(PcdFlowCtrlStartThreshold);
+  ogma_gmac_mode.flow_ctrl_stop_threshold  = FixedPcdGet16 
(PcdFlowCtrlStopThreshold);
+  ogma_gmac_mode.pause_time= FixedPcdGet16 (PcdPauseTime);
+}
+
+ogma_err = ogma_set_gmac_mode (LanDriver->Handle, _gmac_mode);
+if (ogma_err != OGMA_ERR_OK) {
+  DEBUG ((DEBUG_ERROR,
+"NETSEC: ogma_set_gmac() failed with error status %d\n",
+(INT32)ogma_err));
+  ErrorStatus = EFI_DEVICE_ERROR;
+  goto Fail;
+}
+
+ogma_err = ogma_start_gmac (LanDriver->Handle, OGMA_TRUE, OGMA_TRUE);
+if (ogma_err != OGMA_ERR_OK) {
+  DEBUG ((DEBUG_ERROR,
+"NETSEC: ogma_start_gmac() failed with error status %d\n",
+(INT32)ogma_err));
+  ErrorStatus = EFI_DEVICE_ERROR;
+  goto Fail;
+}
+  }
+
+  /* Updating link status for external guery */
+  Snp->Mode->MediaPresent = phy_link_status.up_flag;
+  return EFI_SUCCESS;
+
+Fail:
+  Snp->Mode->MediaPresent = FALSE;
+  return ErrorStatus;
+}
+
 /*
  *  UEFI Initialize() function
 

[edk2-devel] [edk2-platforms PATCH v1 2/3] NetsecDxe: put phy in loopback mode in order to guarantee stable RXCLK input

2019-07-22 Thread Masahisa Kojima
NETSEC hardware requires stable RXCLK input upon initialization
triggered with DISCORE = 0.
However, RXCLK input could be unstable depending on phy chipset
and deployed network environment, which could cause NETSEC to
hang up during initialization.

We solve this platform/environment dependent issue by temporarily
putting phy in loopback mode, then we can expect the stable RXCLK input.

Signed-off-by: Masahisa Kojima 
Signed-off-by: Satoru Okamoto 
---
 .../netsec_sdk/src/ogma_misc.c| 72 ++-
 .../netsec_for_uefi/netsec_sdk/src/ogma_reg.h |  4 ++
 2 files changed, 75 insertions(+), 1 deletion(-)

diff --git 
a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc.c
 
b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc.c
index 7481d2da2d24..07308d38a5c2 100644
--- 
a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc.c
+++ 
b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_misc.c
@@ -35,7 +35,6 @@ static const ogma_uint32 
desc_ring_config_reg_addr[OGMA_DESC_RING_ID_MAX + 1] =
 
 };
 
-
 /* Internal function definition*/
 #ifndef OGMA_CONFIG_DISABLE_CLK_CTRL
 STATIC void ogma_set_clk_en_reg (
@@ -327,6 +326,60 @@ STATIC ogma_uint32 ogma_calc_pkt_ctrl_reg_param (
 return param;
 }
 
+STATIC
+void
+ogma_pre_init_microengine (
+  ogma_handle_t ogma_handle
+  )
+{
+  UINT16 Data;
+
+  /* Remove dormant settings */
+  Data = ogma_get_phy_reg (ogma_handle, OGMA_PHY_REG_ADDR_CONTROL) &
+~((1U << OGMA_PHY_CONTROL_REG_POWER_DOWN) |
+  (1U << OGMA_PHY_CONTROL_REG_ISOLATE));
+
+  ogma_set_phy_reg (ogma_handle, OGMA_PHY_REG_ADDR_CONTROL, Data);
+
+  while ((ogma_get_phy_reg (ogma_handle, OGMA_PHY_REG_ADDR_CONTROL) &
+  ((1U << OGMA_PHY_CONTROL_REG_POWER_DOWN) |
+   (1U << OGMA_PHY_CONTROL_REG_ISOLATE))) != 0);
+
+  /* Put phy in loopback mode to guarantee RXCLK input */
+  Data |= (1U << OGMA_PHY_CONTROL_REG_LOOPBACK);
+  
+  ogma_set_phy_reg (ogma_handle, OGMA_PHY_REG_ADDR_CONTROL, Data);
+
+  while ((ogma_get_phy_reg (ogma_handle, OGMA_PHY_REG_ADDR_CONTROL) &
+  (1U << OGMA_PHY_CONTROL_REG_LOOPBACK)) == 0);
+}
+
+STATIC
+void
+ogma_post_init_microengine (
+  IN ogma_handle_t ogma_handle
+  )
+{
+  UINT16 Data;
+
+  /* Get phy back to normal operation */
+  Data = ogma_get_phy_reg (ogma_handle, OGMA_PHY_REG_ADDR_CONTROL) &
+~(1U << OGMA_PHY_CONTROL_REG_LOOPBACK);
+
+  ogma_set_phy_reg (ogma_handle, OGMA_PHY_REG_ADDR_CONTROL, Data);
+
+  while ((ogma_get_phy_reg (ogma_handle, OGMA_PHY_REG_ADDR_CONTROL) &
+  (1U << OGMA_PHY_CONTROL_REG_LOOPBACK)) != 0);
+
+  Data |= (1U << OGMA_PHY_CONTROL_REG_RESET);
+  
+  /* Apply software reset */
+  ogma_set_phy_reg (ogma_handle, OGMA_PHY_REG_ADDR_CONTROL, Data);
+
+  while ((ogma_get_phy_reg (ogma_handle, OGMA_PHY_REG_ADDR_CONTROL) &
+  (1U << OGMA_PHY_CONTROL_REG_RESET)) != 0);
+}
+
 ogma_err_t ogma_init (
 void *base_addr,
 pfdep_dev_handle_t dev_handle,
@@ -551,6 +604,16 @@ ogma_err_t ogma_init (
 ogma_write_reg( ctrl_p, OGMA_REG_ADDR_DMA_TMR_CTRL,
 ( ogma_uint32)( ( OGMA_CONFIG_CLK_HZ / OGMA_CLK_MHZ) - 1) 
);
 
+/*
+ * Do pre-initialization tasks for microengine
+ *
+ * In particular, we put phy in loopback mode
+ * in order to make sure RXCLK keeps provided to mac
+ * irrespective of phy link status,
+ * which is required for microengine intialization.
+ */
+ogma_pre_init_microengine (ctrl_p);
+
 /* start microengines */
 ogma_write_reg( ctrl_p, OGMA_REG_ADDR_DIS_CORE, 0);
 
@@ -573,6 +636,13 @@ ogma_err_t ogma_init (
 goto err;
 }
 
+/*
+ * Do post-initialization tasks for microengine
+ *
+ * We put phy in normal mode and apply reset.
+ */
+ogma_post_init_microengine (ctrl_p);
+
 /* clear microcode load end status */
 ogma_write_reg( ctrl_p, OGMA_REG_ADDR_TOP_STATUS,
 OGMA_TOP_IRQ_REG_ME_START);
diff --git 
a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg.h
 
b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg.h
index 30c716352b37..ca769084cb31 100644
--- 
a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg.h
+++ 
b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/src/ogma_reg.h
@@ -138,8 +138,12 @@
 /* bit fields for PHY CONTROL Register */
 #define OGMA_PHY_CONTROL_REG_SPEED_SELECTION_MSB (6)
 #define OGMA_PHY_CONTROL_REG_DUPLEX_MODE (8)
+#define OGMA_PHY_CONTROL_REG_ISOLATE (10)
+#define OGMA_PHY_CONTROL_REG_POWER_DOWN  (11)
 #define OGMA_PHY_CONTROL_REG_AUTO_NEGO_ENABLE(12)
 #define OGMA_PHY_CONTROL_REG_SPEED_SELECTION_LSB (13)
+#define OGMA_PHY_CONTROL_REG_LOOPBACK(14)
+#define 

[edk2-devel] [edk2-platforms PATCH v1 1/3] NetsecDxe: embed phy address into NETSEC SDK internal structure

2019-07-22 Thread Masahisa Kojima
This is a refactoring of phy address handling in Netsec driver.
NETSEC SDK, low level driver for NetsecDxe, did not store phy address.
User should specify the phy address as an argument to
the SDK public functions.
It prevented NETSEC SDK from internally controlling phy,
and it also bothers user application with phy address management.

With that, we encapsulate the phy address into NETSEC SDK.

Signed-off-by: Masahisa Kojima 
Signed-off-by: Satoru Okamoto 
---
 .../Drivers/Net/NetsecDxe/NetsecDxe.c | 10 +--
 .../Drivers/Net/NetsecDxe/NetsecDxe.h |  2 -
 .../netsec_sdk/include/ogma_api.h |  6 +-
 .../netsec_sdk/src/ogma_gmac_access.c | 61 +--
 .../netsec_sdk/src/ogma_internal.h|  2 +
 .../netsec_sdk/src/ogma_misc.c|  6 ++
 6 files changed, 28 insertions(+), 59 deletions(-)

diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c 
b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c
index 160bb08a4632..0b91d4af44a3 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c
@@ -59,6 +59,8 @@ Probe (
   // phy-interface
   Param.gmac_config.phy_interface = OGMA_PHY_INTERFACE_RGMII;
 
+  Param.phy_addr = LanDriver->Dev->Resources[2].AddrRangeMin;
+
   // Read and save the Permanent MAC Address
   EepromBase = LanDriver->Dev->Resources[1].AddrRangeMin;
   GetCurrentMacAddress (EepromBase, LanDriver->SnpMode.PermanentAddress.Addr);
@@ -107,8 +109,6 @@ Probe (
 return EFI_DEVICE_ERROR;
   }
 
-  LanDriver->PhyAddress = LanDriver->Dev->Resources[2].AddrRangeMin;
-
   ogma_enable_top_irq (LanDriver->Handle,
OGMA_TOP_IRQ_REG_NRM_RX | OGMA_TOP_IRQ_REG_NRM_TX);
 
@@ -280,7 +280,7 @@ SnpInitialize (
 ReturnUnlock (EFI_DEVICE_ERROR);
   }
 
-  ogma_err = ogma_get_phy_link_status (LanDriver->Handle, 
LanDriver->PhyAddress,
+  ogma_err = ogma_get_phy_link_status (LanDriver->Handle,
_link_status);
   if (ogma_err != OGMA_ERR_OK) {
 DEBUG ((DEBUG_ERROR,
@@ -438,7 +438,7 @@ NetsecPollPhyStatus (
   LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
 
   // Update the media status
-  ogma_err = ogma_get_phy_link_status (LanDriver->Handle, 
LanDriver->PhyAddress,
+  ogma_err = ogma_get_phy_link_status (LanDriver->Handle,
_link_status);
   if (ogma_err != OGMA_ERR_OK) {
 DEBUG ((DEBUG_ERROR,
@@ -662,7 +662,7 @@ SnpGetStatus (
   LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
 
   // Update the media status
-  ogma_err = ogma_get_phy_link_status (LanDriver->Handle, 
LanDriver->PhyAddress,
+  ogma_err = ogma_get_phy_link_status (LanDriver->Handle,
_link_status);
   if (ogma_err != OGMA_ERR_OK) {
 DEBUG ((DEBUG_ERROR,
diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.h 
b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.h
index 870833c8d31c..c95ff215199d 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.h
+++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.h
@@ -70,8 +70,6 @@ typedef struct {
   NON_DISCOVERABLE_DEVICE   *Dev;
 
   NETSEC_DEVICE_PATHDevicePath;
-
-  UINTN PhyAddress;
 } NETSEC_DRIVER;
 
 #define NETSEC_SIGNATURESIGNATURE_32('n', 't', 's', 'c')
diff --git 
a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_api.h
 
b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_api.h
index 66f39150430b..be80dd9ae1fd 100644
--- 
a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_api.h
+++ 
b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/netsec_for_uefi/netsec_sdk/include/ogma_api.h
@@ -318,6 +318,7 @@ struct ogma_param_s{
 ogma_desc_ring_param_t desc_ring_param[OGMA_DESC_RING_ID_MAX+1];
 ogma_gmac_config_t gmac_config;
 ogma_uint8 mac_addr[6];
+ogma_uint8 phy_addr;
 };
 
 struct ogma_tx_pkt_ctrl_s{
@@ -412,14 +413,12 @@ ogma_err_t ogma_set_gmac_mode (
 
 void ogma_set_phy_reg (
 ogma_handle_t ogma_handle,
-ogma_uint8 phy_addr,
 ogma_uint8 reg_addr,
 ogma_uint16 value
 );
 
 ogma_uint16 ogma_get_phy_reg (
 ogma_handle_t ogma_handle,
-ogma_uint8 phy_addr,
 ogma_uint8 reg_addr
 );
 
@@ -660,7 +659,6 @@ ogma_err_t ogma_get_gmac_lpitimer_reg (
 
 void ogma_set_phy_mmd_reg (
 ogma_handle_t ogma_handle,
-ogma_uint8 phy_addr,
 ogma_uint8 dev_addr,
 ogma_uint16 reg_addr,
 ogma_uint16 value
@@ -668,14 +666,12 @@ void ogma_set_phy_mmd_reg (
 
 ogma_uint16 ogma_get_phy_mmd_reg (
 ogma_handle_t ogma_handle,
-ogma_uint8 phy_addr,
 ogma_uint8 dev_addr,
 ogma_uint16 reg_addr
 );
 
 ogma_err_t ogma_get_phy_link_status (
 ogma_handle_t ogma_handle,
-ogma_uint8 phy_addr,
 ogma_phy_link_status_t *phy_link_status_p
 );
 

[edk2-devel] [edk2-platforms PATCH v1 0/3] Robust Netsec Initialiation

2019-07-22 Thread Masahisa Kojima
This patch series is bugfix for the hang-up issue in Netsec driver.

Some linux distributions such as Ubuntu power down the ethernet phy
in reboot. In this case, Netsec initialization fails and
system hungs.

This patch series add the robust netsec initialization,
set ethernet phy as loopback mode to expect stable RXCLK,
and wait for media link up.

The disadvantage of this patch series is that user has to wait
several seconds until netsec driver gives up ethernet link-up
if the ethernet cable is not connected.

Masahisa Kojima (3):
  NetsecDxe: embed phy address into NETSEC SDK internal structure
  NetsecDxe: put phy in loopback mode in order to guarantee stable RXCLK
input
  NetsecDxe: SnpInitialize() waits for media linking up

 .../Socionext/DeveloperBox/DeveloperBox.dsc   |   1 +
 .../Drivers/Net/NetsecDxe/NetsecDxe.c | 236 --
 .../Drivers/Net/NetsecDxe/NetsecDxe.dec   |   1 +
 .../Drivers/Net/NetsecDxe/NetsecDxe.h |   2 -
 .../Drivers/Net/NetsecDxe/NetsecDxe.inf   |   1 +
 .../netsec_sdk/include/ogma_api.h |   6 +-
 .../netsec_sdk/src/ogma_gmac_access.c |  61 ++---
 .../netsec_sdk/src/ogma_internal.h|   2 +
 .../netsec_sdk/src/ogma_misc.c|  78 +-
 .../netsec_for_uefi/netsec_sdk/src/ogma_reg.h |   4 +
 10 files changed, 210 insertions(+), 182 deletions(-)

-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44136): https://edk2.groups.io/g/devel/message/44136
Mute This Topic: https://groups.io/mt/32557829/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 0/4] Arm, ArmPlatform, Crypto, Embedded: list internal headers in [Sources]

2019-07-22 Thread Leif Lindholm
On Fri, Jul 19, 2019 at 06:43:15PM +0200, Laszlo Ersek wrote:
> Repo:   https://github.com/lersek/edk2.git
> Branch: internal_hdrs
> 
> The BaseTools build feature introduced for TianoCore#1804 / in commit
> 1fa6699e6cd4 ("BaseTools: Add a checking for Sources section in INF
> file", 2019-06-10) logs some (non-fatal) warnings about unlisted
> internal header files. List those files explicitly.

Urgh.
Yeah. I'm still not super comfortable with this duplication of
dependency scanning (as discussed in
https://edk2.groups.io/g/devel/topic/31866190), but I have to confess
I also don't really care enough to do anything about it.

So, while I'm tempted to keep the warnings around as a reminder, if
you prefer to get rid of them - for the pat of the series I was cc:d on:
Reviewed-by: Leif Lindholm 

/
Leif

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44135): https://edk2.groups.io/g/devel/message/44135
Mute This Topic: https://groups.io/mt/32529014/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v2 0/6] Acpiview table parsers code style enhancements and refactoring

2019-07-22 Thread Gao, Zhichao
Series: Reviewed-by: Zhichao Gao 

> -Original Message-
> From: Krzysztof Koch [mailto:krzysztof.k...@arm.com]
> Sent: Monday, July 22, 2019 3:50 PM
> To: devel@edk2.groups.io
> Cc: Carsey, Jaben ; Ni, Ray ; Gao,
> Zhichao ; sami.muja...@arm.com;
> matteo.carl...@arm.com; n...@arm.com
> Subject: [PATCH v2 0/6] Acpiview table parsers code style enhancements and
> refactoring
> 
> This set of patches consists of a number of changes which make the code
> structure consistent across the existing ACPI table parsers. These are all
> refactoring changes which do not modify the existing functionality of the
> acpiview UEFI shell tool.
> 
> Changes can be seen at:
> https://github.com/KrzysztofKoch1/edk2/tree/612_acpiview_code_style_enhan
> ce_v2
> 
> Krzysztof Koch (6):
>   ShellPkg: acpiview: Allow passing buffer length to DumpGasStruct()
>   ShellPkg: acpiview: XSDT: Remove redundant ParseAcpi() call
>   ShellPkg: acpiview: RSDP: Make code consistent with other parsers
>   ShellPkg: acpiview: SRAT: Minor code style enhancements
>   ShellPkg: acpiview: MADT: Split structure length validation
>   ShellPkg: acpiview: IORT: Refactor PMCG node mapping count validation
> 
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c  | 26
> +---
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h  |  8
> +++--
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c |
> 2 +-  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
> | 32 ++--
> ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c |
> 30 +-
> ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c |
> 11 +--
> ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c |  3
> +-  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
> | 18 +++
>  8 files changed, 82 insertions(+), 48 deletions(-)
> 
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44134): https://edk2.groups.io/g/devel/message/44134
Mute This Topic: https://groups.io/mt/32556317/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [Patch 0/9] Enable multiple process AutoGen

2019-07-22 Thread Bob Feng
Hi Laszlo,

Thanks for your detailed testing and comments.

I send out patch serial V2 to resolve comment 1#.  V2 also fixed some issues 
found by others and was generated based on master latest version.

For 3#, I can reproduce the issue, I'll fix it in patch serial V3.  My 
understanding is that when I fix 3#, 2# will be resolved accordingly. Right? 
For 5#-2,  When using "-n 1", Autogen should start one worker subprocess to 
generate autogen files that will be the same as run in serial.
I'll make the change in patches V3

For the keyboard interrupt handling mentioned in 4# and 5#-1, I'll do more 
testing on it. And do the fix in V3.  
Before sending the patches, I tested Ctrl+C to stop the build but not the "pick 
up".

Thanks,
Bob

-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Sunday, July 21, 2019 8:26 PM
To: Feng, Bob C 
Cc: devel@edk2.groups.io; Philippe Mathieu-Daudé 
Subject: Re: [edk2-devel] [Patch 0/9] Enable multiple process AutoGen

Hi Bob,

On 07/18/19 08:14, Bob Feng wrote:
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875
>
> In order to improve the build performance, we implemented 
> multiple-processes AutoGen. This change will reduce 20% time for 
> AutoGen phase.
>
> The design document can be got from:
> https://edk2.groups.io/g/devel/files/Designs/2019/0627/Multiple-thread
> -AutoGen.pdf
>
> This patch serial pass the build of Ovmf, MinKabylake, MinPurley, 
> packages under Edk2 repository and intel client and server platforms.

I've done some basic regression-testing with this set, applied on top of 
current master (= commit 8ff68cd5e4c9, "ShellPkg: acpiview: DBG2: Remove 
redundant forward declarations", 2019-07-19).

(1) The build process now seems to produce files called

  GlobalVar_37d7e986-f7e9-45c2-8067-e371421a626c_AARCH64.bin
  GlobalVar_37d7e986-f7e9-45c2-8067-e371421a626c_ARM.bin
  GlobalVar_5a9e7754-d81b-49ea-85ad-69eaa7b1539b_IA32.bin
  GlobalVar_5a9e7754-d81b-49ea-85ad-69eaa7b1539b_X64.bin

in the project root directory. (The GUIDs match the PLATFORM_GUID
values from ArmVirtQemu.dsc and OvmfPkg*.dsc.)

They seem to come from patch "BaseTools: Enable Multiple Process
AutoGen".

Can we place these files under the Build/ directory somewhere,
instead?

(2) The QEMU project now bundles edk2 (as a git submodule for the edk2
tree, and some firmware binaries built from that). The build scripts
carried by QEMU set PYTHON_COMMAND to python2, in order to work
around TianoCore BZ#1607.

For regression-testing this set, I ran

$ make -C roms efi

with QEMU's edk2 submodule advanced to commit 8ff68cd5e4c9, plus
this set applied (see above), and with QEMU itself being at
e2b47666fe15.

The build itself passes fine, so that's good.

But, some (not all) of the firmware binaries are *misbuilt*. I'll
elaborate below (independently of QEMU).

(3) Consider the following test. (Note that this is independent of the
QEMU project entirely.)

(3a) Set up a pristine build environment:

 # Open a new shell, then:
 $ git clean -ffdx
 $ git reset --hard
 $ git submodule deinit --force --all
 $ git checkout master
 $ git submodule update --init
 $ export PYTHON_COMMAND=python2
 $ source edksetup.sh
 $ nice make -C "$EDK_TOOLS_PATH" \
 -j $(getconf _NPROCESSORS_ONLN)

(3b) Build OvmfPkgIA32 with one set of features, and capture a
 checksum of the resultant firmware binary:

 $ nice build -a IA32 -b NOOPT -p OvmfPkg/OvmfPkgIA32.dsc \
 -t GCC48
 $ md5sum Build/OvmfIa32/NOOPT_GCC48/FV/OVMF_CODE.fd
 8d56575dd3b5c89ac6f1829ae4f41b55

(3c) *Re*build the same platform with a different set of features,
 and capture a checksum again:

 $ nice build -a IA32 -b NOOPT -p OvmfPkg/OvmfPkgIA32.dsc \
 -t GCC48 -D SECURE_BOOT_ENABLE -D SMM_REQUIRE
 $ md5sum Build/OvmfIa32/NOOPT_GCC48/FV/OVMF_CODE.fd
 ed79052e9add242174ccefc78a5bddb3

Okay, now repeat all three steps from zero, but with the present
feature patch set applied:

(3d) Repeat (3a), but rather than checking out the master branch
 with "git checkout", check out the topic branch that is the
 same "master" commit, *plus* the present series applied on top.

 Don't forget to start a new shell first!

(3e) Repeat (3b):

 $ nice build -a IA32 -b NOOPT -p OvmfPkg/OvmfPkgIA32.dsc \
 -t GCC48
 $ md5sum Build/OvmfIa32/NOOPT_GCC48/FV/OVMF_CODE.fd
 8d56575dd3b5c89ac6f1829ae4f41b55

 Notice that the checksum is identical to that from (3b), so
 all's good.

(3f) Repeat (3c):

 $ nice build -a IA32 -b NOOPT -p OvmfPkg/OvmfPkgIA32.dsc \
 -t GCC48 -D SECURE_BOOT_ENABLE -D SMM_REQUIRE
 $ md5sum 

[edk2-devel] [Patch 2/9 V2] BaseTools: Split WorkspaceAutoGen._InitWorker into multiple functions

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

The WorkspaceAutoGen.__InitWorker function is too long, it's hard
to read and understand.
This patch is to separate the __InitWorker into multiple small ones.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 247 +
 1 file changed, 152 insertions(+), 95 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index c5b3fbb0a87f..9e06bb942126 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -333,13 +333,58 @@ class WorkspaceAutoGen(AutoGen):
 self._GuidDict = {}
 
 # there's many relative directory operations, so ...
 os.chdir(self.WorkspaceDir)
 
+self.MergeArch()
+self.ValidateBuildTarget()
+
+EdkLogger.info("")
+if self.ArchList:
+EdkLogger.info('%-16s = %s' % ("Architecture(s)", ' 
'.join(self.ArchList)))
+EdkLogger.info('%-16s = %s' % ("Build target", self.BuildTarget))
+EdkLogger.info('%-16s = %s' % ("Toolchain", self.ToolChain))
+
+EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.Platform))
+if BuildModule:
+EdkLogger.info('%-24s = %s' % ("Active Module", BuildModule))
+
+if self.FdfFile:
+EdkLogger.info('%-24s = %s' % ("Flash Image Definition", 
self.FdfFile))
+
+EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile)
+
+if Progress:
+Progress.Start("\nProcessing meta-data")
 #
-# Merge Arch
+# Mark now build in AutoGen Phase
 #
+GlobalData.gAutoGenPhase = True
+self.ProcessModuleFromPdf()
+self.ProcessPcdType()
+self.ProcessMixedPcd()
+self.GetPcdsFromFDF()
+self.CollectAllPcds()
+self.GeneratePkgLevelHash()
+#
+# Check PCDs token value conflict in each DEC file.
+#
+self._CheckAllPcdsTokenValueConflict()
+#
+# Check PCD type and definition between DSC and DEC
+#
+self._CheckPcdDefineAndType()
+
+self.CreateBuildOptionsFile()
+self.CreatePcdTokenNumberFile()
+self.CreateModuleHashInfo()
+GlobalData.gAutoGenPhase = False
+
+#
+# Merge Arch
+#
+def MergeArch(self):
 if not self.ArchList:
 ArchList = set(self.Platform.SupArchList)
 else:
 ArchList = set(self.ArchList) & set(self.Platform.SupArchList)
 if not ArchList:
@@ -349,57 +394,49 @@ class WorkspaceAutoGen(AutoGen):
 SkippedArchList = 
set(self.ArchList).symmetric_difference(set(self.Platform.SupArchList))
 EdkLogger.verbose("\nArch [%s] is ignored because the platform 
supports [%s] only!"
   % (" ".join(SkippedArchList), " 
".join(self.Platform.SupArchList)))
 self.ArchList = tuple(ArchList)
 
-# Validate build target
+# Validate build target
+def ValidateBuildTarget(self):
 if self.BuildTarget not in self.Platform.BuildTargets:
 EdkLogger.error("build", PARAMETER_INVALID,
 ExtraData="Build target [%s] is not supported by 
the platform. [Valid target: %s]"
   % (self.BuildTarget, " 
".join(self.Platform.BuildTargets)))
-
-
-# parse FDF file to get PCDs in it, if any
+@cached_property
+def FdfProfile(self):
 if not self.FdfFile:
 self.FdfFile = self.Platform.FlashDefinition
 
-EdkLogger.info("")
-if self.ArchList:
-EdkLogger.info('%-16s = %s' % ("Architecture(s)", ' 
'.join(self.ArchList)))
-EdkLogger.info('%-16s = %s' % ("Build target", self.BuildTarget))
-EdkLogger.info('%-16s = %s' % ("Toolchain", self.ToolChain))
-
-EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.Platform))
-if BuildModule:
-EdkLogger.info('%-24s = %s' % ("Active Module", BuildModule))
-
+FdfProfile = None
 if self.FdfFile:
-EdkLogger.info('%-24s = %s' % ("Flash Image Definition", 
self.FdfFile))
-
-EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile)
-
-if Progress:
-Progress.Start("\nProcessing meta-data")
-
-if self.FdfFile:
-#
-# Mark now build in AutoGen Phase
-#
-GlobalData.gAutoGenPhase = True
 Fdf = FdfParser(self.FdfFile.Path)
 Fdf.ParseFile()
 GlobalData.gFdfParser = Fdf
-GlobalData.gAutoGenPhase = False
-PcdSet = Fdf.Profile.PcdDict
 if Fdf.CurrentFdName and Fdf.CurrentFdName in Fdf.Profile.FdDict:
 FdDict = Fdf.Profile.FdDict[Fdf.CurrentFdName]
 for FdRegion in FdDict.RegionList:
 if 

[edk2-devel] [Patch 7/9 V2] BaseTools: Add LogAgent to support multiple process Autogen

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

AutoGen processes race the logfile. To resolve this issue,
this patch create a LogAgent thread in main process to write
the log content to console or file, Other process will send
the log content to the LogAgent.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 .../Source/Python/AutoGen/AutoGenWorker.py| 86 +++
 BaseTools/Source/Python/AutoGen/DataPipe.py   |  2 +-
 BaseTools/Source/Python/AutoGen/GenMake.py|  3 +-
 BaseTools/Source/Python/Common/EdkLogger.py   | 33 ++-
 BaseTools/Source/Python/build/build.py| 27 --
 5 files changed, 122 insertions(+), 29 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py 
b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
index 824237d2ec49..03139ffcc19a 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
@@ -19,52 +19,111 @@ from Workspace.WorkspaceDatabase import BuildDB
 import time
 from queue import Empty
 import traceback
 import sys
 from AutoGen.DataPipe import MemoryDataPipe
+import logging
+
+class LogAgent(threading.Thread):
+def __init__(self,log_q,log_level,log_file=None):
+super(LogAgent,self).__init__()
+self.log_q = log_q
+self.log_level = log_level
+self.log_file = log_file
+def InitLogger(self):
+# For DEBUG level (All DEBUG_0~9 are applicable)
+self._DebugLogger_agent = logging.getLogger("tool_debug_agent")
+_DebugFormatter = logging.Formatter("[%(asctime)s.%(msecs)d]: 
%(message)s", datefmt="%H:%M:%S")
+self._DebugLogger_agent.setLevel(self.log_level)
+_DebugChannel = logging.StreamHandler(sys.stdout)
+_DebugChannel.setFormatter(_DebugFormatter)
+self._DebugLogger_agent.addHandler(_DebugChannel)
+
+# For VERBOSE, INFO, WARN level
+self._InfoLogger_agent = logging.getLogger("tool_info_agent")
+_InfoFormatter = logging.Formatter("%(message)s")
+self._InfoLogger_agent.setLevel(self.log_level)
+_InfoChannel = logging.StreamHandler(sys.stdout)
+_InfoChannel.setFormatter(_InfoFormatter)
+self._InfoLogger_agent.addHandler(_InfoChannel)
+
+# For ERROR level
+self._ErrorLogger_agent = logging.getLogger("tool_error_agent")
+_ErrorFormatter = logging.Formatter("%(message)s")
+self._ErrorLogger_agent.setLevel(self.log_level)
+_ErrorCh = logging.StreamHandler(sys.stderr)
+_ErrorCh.setFormatter(_ErrorFormatter)
+self._ErrorLogger_agent.addHandler(_ErrorCh)
+
+if self.log_file:
+if os.path.exists(self.log_file):
+os.remove(self.log_file)
+_Ch = logging.FileHandler(self.log_file)
+_Ch.setFormatter(_DebugFormatter)
+self._DebugLogger_agent.addHandler(_Ch)
+
+_Ch= logging.FileHandler(self.log_file)
+_Ch.setFormatter(_InfoFormatter)
+self._InfoLogger_agent.addHandler(_Ch)
+
+_Ch = logging.FileHandler(self.log_file)
+_Ch.setFormatter(_ErrorFormatter)
+self._ErrorLogger_agent.addHandler(_Ch)
+
+def run(self):
+self.InitLogger()
+while True:
+log_message = self.log_q.get()
+if log_message is None:
+break
+if log_message.name == "tool_error":
+
self._ErrorLogger_agent.log(log_message.levelno,log_message.getMessage())
+elif log_message.name == "tool_info":
+
self._InfoLogger_agent.log(log_message.levelno,log_message.getMessage())
+elif log_message.name == "tool_debug":
+
self._DebugLogger_agent.log(log_message.levelno,log_message.getMessage())
+else:
+
self._InfoLogger_agent.log(log_message.levelno,log_message.getMessage())
+
+def kill(self):
+self.log_q.put(None)
 class AutoGenManager(threading.Thread):
 def __init__(self,autogen_workers, feedback_q):
 super(AutoGenManager,self).__init__()
 self.autogen_workers = autogen_workers
 self.feedback_q = feedback_q
-self.terminate = False
 self.Status = True
 def run(self):
 try:
 while True:
-if self.terminate:
-break
-if self.feedback_q.empty():
-time.sleep(1)
-continue
-badnews = self.feedback_q.get(False)
-if badnews:
-print(badnews)
+badnews = self.feedback_q.get()
+if badnews is None:
 self.Status = False
 self.TerminateWorkers()
 break
 except Exception:
 return
 
 def kill(self):
-self.terminate = True
+self.feedback_q.put(None)
 
 def TerminateWorkers(self):
 for w 

[edk2-devel] [Patch 5/9 V2] BaseTools: Enable Multiple Process AutoGen

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

Assign the Module AutoGen tasks into multiple
sub process.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 .../Source/Python/AutoGen/AutoGenWorker.py| 161 ++
 BaseTools/Source/Python/AutoGen/DataPipe.py   |   6 +
 BaseTools/Source/Python/AutoGen/GenC.py   |   4 +-
 .../Source/Python/AutoGen/ModuleAutoGen.py|   7 +-
 .../Source/Python/AutoGen/PlatformAutoGen.py  |   4 +-
 BaseTools/Source/Python/build/build.py| 112 +++-
 6 files changed, 240 insertions(+), 54 deletions(-)
 create mode 100644 BaseTools/Source/Python/AutoGen/AutoGenWorker.py

diff --git a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py 
b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
new file mode 100644
index ..bb6545288ffc
--- /dev/null
+++ b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
@@ -0,0 +1,161 @@
+## @file
+# Create makefile for MS nmake and GNU make
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+from __future__ import absolute_import
+import multiprocessing as mp
+import threading
+from Common.Misc import PathClass
+from AutoGen.ModuleAutoGen import ModuleAutoGen
+from AutoGen.ModuleAutoGenHelper import WorkSpaceInfo,AutoGenInfo
+import Common.GlobalData as GlobalData
+import Common.EdkLogger as EdkLogger
+import os
+from Common.MultipleWorkspace import MultipleWorkspace as mws
+from AutoGen.AutoGen import AutoGen
+from Workspace.WorkspaceDatabase import BuildDB
+import time
+from queue import Empty
+import traceback
+import sys
+from AutoGen.DataPipe import MemoryDataPipe
+class AutoGenManager(threading.Thread):
+def __init__(self,autogen_workers, feedback_q):
+super(AutoGenManager,self).__init__()
+self.autogen_workers = autogen_workers
+self.feedback_q = feedback_q
+self.terminate = False
+self.Status = True
+def run(self):
+try:
+while True:
+if self.terminate:
+break
+if self.feedback_q.empty():
+time.sleep(1)
+continue
+badnews = self.feedback_q.get(False)
+if badnews:
+print(badnews)
+self.Status = False
+self.TerminateWorkers()
+break
+except Exception:
+return
+
+def kill(self):
+self.terminate = True
+
+def TerminateWorkers(self):
+for w in self.autogen_workers:
+if w.is_alive():
+w.terminate()
+
+class AutoGenWorkerInProcess(mp.Process):
+def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock):
+mp.Process.__init__(self)
+self.module_queue = module_queue
+self.data_pipe_file_path =data_pipe_file_path
+self.data_pipe = None
+self.feedback_q = feedback_q
+self.PlatformMetaFileSet = {}
+self.file_lock = file_lock
+def GetPlatformMetaFile(self,filepath,root):
+try:
+return self.PlatformMetaFileSet[(filepath,root)]
+except:
+self.PlatformMetaFileSet[(filepath,root)]  = filepath
+return self.PlatformMetaFileSet[(filepath,root)]
+def run(self):
+try:
+taskname = "Init"
+with self.file_lock:
+if not os.path.exists(self.data_pipe_file_path):
+self.feedback_q.put(taskname + ":" + "load data pipe %s 
failed." % self.data_pipe_file_path)
+self.data_pipe = MemoryDataPipe()
+self.data_pipe.load(self.data_pipe_file_path)
+EdkLogger.Initialize()
+loglevel = self.data_pipe.Get("LogLevel")
+if not loglevel:
+loglevel = EdkLogger.INFO
+EdkLogger.SetLevel(loglevel)
+logfile = self.data_pipe.Get("LogFile")
+if logfile:
+EdkLogger.SetLogFile(logfile)
+target = self.data_pipe.Get("P_Info").get("Target")
+toolchain = self.data_pipe.Get("P_Info").get("ToolChain")
+archlist = self.data_pipe.Get("P_Info").get("ArchList")
+
+active_p = self.data_pipe.Get("P_Info").get("ActivePlatform")
+workspacedir = self.data_pipe.Get("P_Info").get("WorkspaceDir")
+PackagesPath = os.getenv("PACKAGES_PATH")
+mws.setWs(workspacedir, PackagesPath)
+self.Wa = WorkSpaceInfo(
+workspacedir,active_p,target,toolchain,archlist
+)
+GlobalData.gGlobalDefines = self.data_pipe.Get("G_defines")
+GlobalData.gCommandLineDefines = self.data_pipe.Get("CL_defines")
+os.environ._data = self.data_pipe.Get("Env_Var")
+GlobalData.gWorkspace = workspacedir
+GlobalData.gDisableIncludePathCheck = False
+GlobalData.gFdfParser = 

[edk2-devel] [Patch 8/9 V2] BaseTools: Move BuildOption parser out of build.py

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

Build tool supports user to specify the conf folder.
To make the build options be evaluated at the beginning
of launching build, extract the buildoption function
from build.py to a new .py file.

Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 .../Python/Common/TargetTxtClassObject.py |  28 -
 BaseTools/Source/Python/build/build.py| 108 +-
 BaseTools/Source/Python/build/buildoptions.py |  92 +++
 3 files changed, 121 insertions(+), 107 deletions(-)
 create mode 100644 BaseTools/Source/Python/build/buildoptions.py

diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py 
b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
index 79a5acc01074..16cc75ccb7c8 100644
--- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py
+++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
@@ -8,16 +8,19 @@
 ##
 # Import Modules
 #
 from __future__ import print_function
 from __future__ import absolute_import
+from buildoptions import BuildOption,BuildTarget
+import Common.GlobalData as GlobalData
 import Common.LongFilePathOs as os
 from . import EdkLogger
 from . import DataType
 from .BuildToolError import *
-from . import GlobalData
+
 from Common.LongFilePathSupport import OpenLongFilePath as open
+from Common.MultipleWorkspace import MultipleWorkspace as mws
 
 gDefaultTargetTxtFile = "target.txt"
 
 ## TargetTxtClassObject
 #
@@ -139,16 +142,33 @@ class TargetTxtClassObject(object):
 #
 # @param ConfDir:  Conf dir
 #
 # @retval Target An instance of TargetTxtClassObject() with loaded target.txt
 #
-def TargetTxtDict(ConfDir):
+def TargetTxtDict():
 Target = TargetTxtClassObject()
-Target.LoadTargetTxtFile(os.path.normpath(os.path.join(ConfDir, 
gDefaultTargetTxtFile)))
+if BuildOption.ConfDirectory:
+# Get alternate Conf location, if it is absolute, then just use the 
absolute directory name
+ConfDirectoryPath = os.path.normpath(BuildOption.ConfDirectory)
+
+if not os.path.isabs(ConfDirectoryPath):
+# Since alternate directory name is not absolute, the alternate 
directory is located within the WORKSPACE
+# This also handles someone specifying the Conf directory in the 
workspace. Using --conf=Conf
+ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], 
ConfDirectoryPath)
+else:
+if "CONF_PATH" in os.environ:
+ConfDirectoryPath = 
os.path.normcase(os.path.normpath(os.environ["CONF_PATH"]))
+else:
+# Get standard WORKSPACE/Conf use the absolute path to the 
WORKSPACE/Conf
+ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], 'Conf')
+GlobalData.gConfDirectory = ConfDirectoryPath
+targettxt = os.path.normpath(os.path.join(ConfDirectoryPath, 
gDefaultTargetTxtFile))
+if os.path.exists(targettxt):
+Target.LoadTargetTxtFile(targettxt)
 return Target
 
-TargetTxt = TargetTxtDict(os.path.join(os.getenv("WORKSPACE"),"Conf"))
+TargetTxt = TargetTxtDict()
 
 ##
 #
 # This acts like the main() function for the script, unless it is 'import'ed 
into another
 # script.
diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index 094b1934fd53..d0d20a9afe51 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -24,11 +24,11 @@ import traceback
 import multiprocessing
 from threading import Thread,Event,BoundedSemaphore
 import threading
 from subprocess import Popen,PIPE
 from collections import OrderedDict, defaultdict
-from optparse import OptionParser
+from buildoptions import BuildOption,BuildTarget
 from AutoGen.PlatformAutoGen import PlatformAutoGen
 from AutoGen.ModuleAutoGen import ModuleAutoGen
 from AutoGen.WorkspaceAutoGen import WorkspaceAutoGen
 from AutoGen.AutoGenWorker import AutoGenWorkerInProcess,AutoGenManager,\
 LogAgent
@@ -41,11 +41,11 @@ from Common.Misc import 
PathClass,SaveFileOnChange,RemoveDirectory
 from Common.StringUtils import NormPath
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 from Common.BuildToolError import *
 from Common.DataType import *
 import Common.EdkLogger as EdkLogger
-from Common.BuildVersion import gBUILD_VERSION
+
 from Workspace.WorkspaceDatabase import BuildDB
 
 from BuildReport import BuildReport
 from GenPatchPcdTable.GenPatchPcdTable import 
PeImageClass,parsePcdInfoFromMapFile
 from PatchPcdValue.PatchPcdValue import PatchBinaryFile
@@ -53,14 +53,10 @@ from PatchPcdValue.PatchPcdValue import PatchBinaryFile
 import Common.GlobalData as GlobalData
 from GenFds.GenFds import GenFds, GenFdsApi
 import multiprocessing as mp
 from multiprocessing import Manager
 
-# Version and Copyright
-VersionNumber = "0.60" + ' ' + gBUILD_VERSION
-__version__ = "%prog Version " + VersionNumber
-__copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation  All rights 
reserved."
 
 ## standard targets of build 

[edk2-devel] [Patch 1/9 V2] BaseTools: Singleton the object to handle build conf file

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

The build config files are target.txt, build rule, tooldef
During a build, the config is not changed, so the object to
handle them need to be singleton.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py| 33 ++--
 .../Source/Python/AutoGen/BuildEngine.py  | 22 
 .../Python/Common/TargetTxtClassObject.py |  2 +
 .../Python/Common/ToolDefClassObject.py   |  6 ++-
 BaseTools/Source/Python/GenFds/GenFds.py  |  4 +-
 .../Python/GenFds/GenFdsGlobalVariable.py | 54 ---
 .../Source/Python/Workspace/DscBuildData.py   |  8 +--
 BaseTools/Source/Python/build/build.py| 29 +++---
 8 files changed, 62 insertions(+), 96 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 2df055a109f7..c5b3fbb0a87f 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -22,11 +22,12 @@ from . import GenC
 from . import GenMake
 from . import GenDepex
 from io import BytesIO
 
 from .StrGather import *
-from .BuildEngine import BuildRule
+from .BuildEngine import BuildRuleObj as BuildRule
+from .BuildEngine import gDefaultBuildRuleFile,AutoGenReqBuildRuleVerNum
 import shutil
 from Common.LongFilePathSupport import CopyLongFilePath
 from Common.BuildToolError import *
 from Common.DataType import *
 from Common.Misc import *
@@ -76,16 +77,10 @@ gEfiVarStoreGuidPattern = 
re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
 
 ## Mapping Makefile type
 gMakeTypeMap = {TAB_COMPILER_MSFT:"nmake", "GCC":"gmake"}
 
 
-## Build rule configuration file
-gDefaultBuildRuleFile = 'build_rule.txt'
-
-## Build rule default version
-AutoGenReqBuildRuleVerNum = "0.1"
-
 ## default file name for AutoGen
 gAutoGenCodeFileName = "AutoGen.c"
 gAutoGenHeaderFileName = "AutoGen.h"
 gAutoGenStringFileName = "%(module_name)sStrDefs.h"
 gAutoGenStringFormFileName = "%(module_name)sStrDefs.hpk"
@@ -1970,32 +1965,10 @@ class PlatformAutoGen(AutoGen):
 ## Return the build options specific for EDKII modules in this platform
 @cached_property
 def EdkIIBuildOption(self):
 return self._ExpandBuildOption(self.Platform.BuildOptions, EDKII_NAME)
 
-## Parse build_rule.txt in Conf Directory.
-#
-#   @retval BuildRule object
-#
-@cached_property
-def BuildRule(self):
-BuildRuleFile = None
-if TAB_TAT_DEFINES_BUILD_RULE_CONF in 
self.Workspace.TargetTxt.TargetTxtDictionary:
-BuildRuleFile = 
self.Workspace.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]
-if not BuildRuleFile:
-BuildRuleFile = gDefaultBuildRuleFile
-RetVal = BuildRule(BuildRuleFile)
-if RetVal._FileVersion == "":
-RetVal._FileVersion = AutoGenReqBuildRuleVerNum
-else:
-if RetVal._FileVersion < AutoGenReqBuildRuleVerNum :
-# If Build Rule's version is less than the version number 
required by the tools, halting the build.
-EdkLogger.error("build", AUTOGEN_ERROR,
-ExtraData="The version number [%s] of 
build_rule.txt is less than the version number required by the AutoGen.(the 
minimum required version number is [%s])"\
- % (RetVal._FileVersion, 
AutoGenReqBuildRuleVerNum))
-return RetVal
-
 ## Summarize the packages used by modules in this platform
 @cached_property
 def PackageList(self):
 RetVal = set()
 for La in self.LibraryAutoGenList:
@@ -3149,11 +3122,11 @@ class ModuleAutoGen(AutoGen):
 return RetVal
 
 @cached_property
 def BuildRules(self):
 RetVal = {}
-BuildRuleDatabase = self.PlatformInfo.BuildRule
+BuildRuleDatabase = BuildRule
 for Type in BuildRuleDatabase.FileTypeList:
 #first try getting build rule by BuildRuleFamily
 RuleObject = BuildRuleDatabase[Type, self.BuildType, self.Arch, 
self.BuildRuleFamily]
 if not RuleObject:
 # build type is always module type, but ...
diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py 
b/BaseTools/Source/Python/AutoGen/BuildEngine.py
index 14e61140e7ba..bb9153447793 100644
--- a/BaseTools/Source/Python/AutoGen/BuildEngine.py
+++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py
@@ -18,10 +18,13 @@ from Common.LongFilePathSupport import OpenLongFilePath as 
open
 from Common.GlobalData import *
 from Common.BuildToolError import *
 from Common.Misc import tdict, PathClass
 from Common.StringUtils import NormPath
 from Common.DataType import *
+from Common.TargetTxtClassObject import TargetTxt
+gDefaultBuildRuleFile = 'build_rule.txt'
+AutoGenReqBuildRuleVerNum = '0.1'
 
 import Common.EdkLogger as EdkLogger
 
 ## Convert file type to file list macro name
 #
@@ -581,10 +584,29 @@ class BuildRule:

[edk2-devel] [Patch 6/9 V2] BaseTools: Add shared data for processes

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

Add shared data for autogen processes.

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 BaseTools/Source/Python/AutoGen/AutoGenWorker.py |  3 ++-
 BaseTools/Source/Python/build/build.py   | 10 ++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py 
b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
index bb6545288ffc..824237d2ec49 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
@@ -52,18 +52,19 @@ class AutoGenManager(threading.Thread):
 for w in self.autogen_workers:
 if w.is_alive():
 w.terminate()
 
 class AutoGenWorkerInProcess(mp.Process):
-def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock):
+def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock, 
share_data):
 mp.Process.__init__(self)
 self.module_queue = module_queue
 self.data_pipe_file_path =data_pipe_file_path
 self.data_pipe = None
 self.feedback_q = feedback_q
 self.PlatformMetaFileSet = {}
 self.file_lock = file_lock
+self.share_data = share_data
 def GetPlatformMetaFile(self,filepath,root):
 try:
 return self.PlatformMetaFileSet[(filepath,root)]
 except:
 self.PlatformMetaFileSet[(filepath,root)]  = filepath
diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index db210428e84c..71040e748b39 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -50,10 +50,11 @@ from GenPatchPcdTable.GenPatchPcdTable import 
PeImageClass,parsePcdInfoFromMapFi
 from PatchPcdValue.PatchPcdValue import PatchBinaryFile
 
 import Common.GlobalData as GlobalData
 from GenFds.GenFds import GenFds, GenFdsApi
 import multiprocessing as mp
+from multiprocessing import Manager
 
 # Version and Copyright
 VersionNumber = "0.60" + ' ' + gBUILD_VERSION
 __version__ = "%prog Version " + VersionNumber
 __copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation  All rights 
reserved."
@@ -826,16 +827,17 @@ class Build():
 self.InitBuild()
 
 self.AutoGenMgr = None
 EdkLogger.info("")
 os.chdir(self.WorkspaceDir)
-def StartAutoGen(self,mqueue, DataPipe,SkipAutoGen,PcdMaList):
+self.share_data = Manager().dict()
+def StartAutoGen(self,mqueue, DataPipe,SkipAutoGen,PcdMaList,share_data):
 if SkipAutoGen:
 return
 feedback_q = mp.Queue()
 file_lock = mp.Lock()
-auto_workers = 
[AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,file_lock) for _ 
in range(mp.cpu_count())]
+auto_workers = 
[AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,file_lock,share_data)
 for _ in range(mp.cpu_count())]
 self.AutoGenMgr = AutoGenManager(auto_workers,feedback_q)
 self.AutoGenMgr.start()
 for w in auto_workers:
 w.start()
 if PcdMaList is not None:
@@ -1228,11 +1230,11 @@ class Build():
 
 AutoGenObject.DataPipe.DataContainer = {"FfsCommand":FfsCommand}
 self.Progress.Start("Generating makefile and code")
 data_pipe_file = os.path.join(AutoGenObject.BuildDir, 
"GlobalVar_%s_%s.bin" % (str(AutoGenObject.Guid),AutoGenObject.Arch))
 AutoGenObject.DataPipe.dump(data_pipe_file)
-autogen_rt = self.StartAutoGen(mqueue, AutoGenObject.DataPipe, 
self.SkipAutoGen, PcdMaList)
+autogen_rt = self.StartAutoGen(mqueue, AutoGenObject.DataPipe, 
self.SkipAutoGen, PcdMaList,self.share_data)
 self.Progress.Stop("done!")
 return autogen_rt
 else:
 # always recreate top/platform makefile when clean, just in case 
of inconsistency
 AutoGenObject.CreateCodeFile(False)
@@ -2058,11 +2060,11 @@ class Build():
 for m in Pa.GetAllModuleInfo:
 mqueue.put(m)
 Pa.DataPipe.DataContainer = {"FfsCommand":CmdListDict}
 data_pipe_file = os.path.join(Pa.BuildDir, 
"GlobalVar_%s_%s.bin" % (str(Pa.Guid),Pa.Arch))
 Pa.DataPipe.dump(data_pipe_file)
-autogen_rt = self.StartAutoGen(mqueue, Pa.DataPipe, 
self.SkipAutoGen, PcdMaList)
+autogen_rt = self.StartAutoGen(mqueue, Pa.DataPipe, 
self.SkipAutoGen, PcdMaList,self.share_data)
 self.Progress.Stop("done!")
 self.AutoGenTime += int(round((time.time() - 
AutoGenStart)))
 if not autogen_rt:
 return
 for Arch in Wa.ArchList:
-- 
2.20.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44131): 

[edk2-devel] [Patch 9/9 V2] BaseTools: Add the support for python 2

2019-07-22 Thread Bob Feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

python3 change the module name of Queue to queue.
python3 add a new log handler of QueueHandler.

This patch is to make Multiple process AutoGen
feature work for python2

Cc: Liming Gao 
Signed-off-by: Bob Feng 
---
 .../Source/Python/AutoGen/AutoGenWorker.py|  5 +-
 BaseTools/Source/Python/Common/EdkLogger.py   | 92 ++-
 2 files changed, 92 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py 
b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
index 03139ffcc19a..5508d92cd9c8 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
@@ -15,11 +15,14 @@ import Common.EdkLogger as EdkLogger
 import os
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 from AutoGen.AutoGen import AutoGen
 from Workspace.WorkspaceDatabase import BuildDB
 import time
-from queue import Empty
+try:
+from queue import Empty
+except:
+from Queue import Empty
 import traceback
 import sys
 from AutoGen.DataPipe import MemoryDataPipe
 import logging
 
diff --git a/BaseTools/Source/Python/Common/EdkLogger.py 
b/BaseTools/Source/Python/Common/EdkLogger.py
index f6a5e3b4daf9..15fd1458a95a 100644
--- a/BaseTools/Source/Python/Common/EdkLogger.py
+++ b/BaseTools/Source/Python/Common/EdkLogger.py
@@ -3,16 +3,100 @@
 #
 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 
+# Copyright 2001-2016 by Vinay Sajip. All Rights Reserved.
+#
+# Permission to use, copy, modify, and distribute this software and its
+# documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies and that
+# both that copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Vinay Sajip
+# not be used in advertising or publicity pertaining to distribution
+# of the software without specific, written prior permission.
+# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+# This copyright is for QueueHandler.
+
 ## Import modules
 from __future__ import absolute_import
 import Common.LongFilePathOs as os, sys, logging
 import traceback
 from  .BuildToolError import *
-import logging.handlers
+try:
+from logging.handlers import QueueHandler
+except:
+class QueueHandler(logging.Handler):
+"""
+This handler sends events to a queue. Typically, it would be used 
together
+with a multiprocessing Queue to centralise logging to file in one 
process
+(in a multi-process application), so as to avoid file write contention
+between processes.
+
+This code is new in Python 3.2, but this class can be copy pasted into
+user code for use with earlier Python versions.
+"""
+
+def __init__(self, queue):
+"""
+Initialise an instance, using the passed queue.
+"""
+logging.Handler.__init__(self)
+self.queue = queue
+
+def enqueue(self, record):
+"""
+Enqueue a record.
+
+The base implementation uses put_nowait. You may want to override
+this method if you want to use blocking, timeouts or custom queue
+implementations.
+"""
+self.queue.put_nowait(record)
+
+def prepare(self, record):
+"""
+Prepares a record for queuing. The object returned by this method 
is
+enqueued.
+
+The base implementation formats the record to merge the message
+and arguments, and removes unpickleable items from the record
+in-place.
+
+You might want to override this method if you want to convert
+the record to a dict or JSON string, or send a modified copy
+of the record while leaving the original intact.
+"""
+# The format operation gets traceback text into record.exc_text
+# (if there's exception data), and also returns the formatted
+# message. We can then use this to replace the original
+# msg + args, as these might be unpickleable. We also zap the
+# exc_info and exc_text attributes, as they are no longer
+# needed and, if not None, will typically not be pickleable.
+msg = self.format(record)
+record.message = msg
+record.msg = msg
+record.args = None
+   

Re: [edk2-devel] [PATCH 4/4] MdeModulePkg/DxeIpl: Create 5-level page table for long mode

2019-07-22 Thread Ni, Ray
Forgot to include MdeModulePkg maintainers for review.

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ni, Ray
> Sent: Monday, July 22, 2019 4:16 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Laszlo Ersek 
> Subject: [edk2-devel] [PATCH 4/4] MdeModulePkg/DxeIpl: Create 5-level
> page table for long mode
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2008
> 
> DxeIpl is responsible to create page table for DXE phase running either in
> long mode or in 32bit mode with certain protection mechanism enabled
> (refer to ToBuildPageTable()).
> 
> The patch updates DxeIpl to create 5-level page table for DXE phase running
> in long mode when PcdUse5LevelPageTable is TRUE and CPU supports 5-
> level page table.
> 
> Signed-off-by: Ray Ni 
> Cc: Eric Dong 
> Cc: Laszlo Ersek 
> ---
>  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf   |   1 +
>  .../Core/DxeIplPeim/X64/VirtualMemory.c   | 227 --
>  2 files changed, 151 insertions(+), 77 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> index abc3217b01..98bc17fc9d 100644
> --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> @@ -110,6 +110,7 @@ [Pcd.IA32,Pcd.X64]
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask
> ## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask
> ## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard   ##
> CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable  ##
> SOMETIMES_CONSUMES
> 
>  [Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64]
>gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack   ##
> SOMETIMES_CONSUMES
> diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> index edc38e4525..a5bcdcc734 100644
> --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> @@ -15,7 +15,7 @@
>  2) IA-32 Intel(R) Architecture Software Developer's Manual Volume
> 2:Instruction Set Reference, Intel
>  3) IA-32 Intel(R) Architecture Software Developer's Manual Volume
> 3:System Programmer's Guide, Intel
> 
> -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>  Copyright (c) 2017, AMD Incorporated. All rights reserved.
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent @@ -626,14 +626,19 @@
> CreateIdentityMappingPageTables (
>)
>  {
>UINT32RegEax;
> +  UINT32RegEbx;
> +  UINT32RegEcx;
>UINT32RegEdx;
>UINT8 PhysicalAddressBits;
>EFI_PHYSICAL_ADDRESS  PageAddress;
> +  UINTN IndexOfPml5Entries;
>UINTN IndexOfPml4Entries;
>UINTN IndexOfPdpEntries;
>UINTN IndexOfPageDirectoryEntries;
> +  UINT32NumberOfPml5EntriesNeeded;
>UINT32NumberOfPml4EntriesNeeded;
>UINT32NumberOfPdpEntriesNeeded;
> +  PAGE_MAP_AND_DIRECTORY_POINTER*PageMapLevel5Entry;
>PAGE_MAP_AND_DIRECTORY_POINTER*PageMapLevel4Entry;
>PAGE_MAP_AND_DIRECTORY_POINTER*PageMap;
>PAGE_MAP_AND_DIRECTORY_POINTER
> *PageDirectoryPointerEntry;
> @@ -641,9 +646,11 @@ CreateIdentityMappingPageTables (
>UINTN TotalPagesNum;
>UINTN BigPageAddress;
>VOID  *Hob;
> +  BOOLEAN   Page5LevelSupport;
>BOOLEAN   Page1GSupport;
>PAGE_TABLE_1G_ENTRY   *PageDirectory1GEntry;
>UINT64AddressEncMask;
> +  IA32_CR4  Cr4;
> 
>//
>// Make sure AddressEncMask is contained to smallest supported address
> field @@ -677,33 +684,66 @@ CreateIdentityMappingPageTables (
>  }
>}
> 
> +  Page5LevelSupport = FALSE;
> +  if (PcdGetBool (PcdUse5LevelPageTable)) {
> +AsmCpuidEx (0x7, 0, , , , );
> +DEBUG ((DEBUG_INFO, "Cpuid(7/0): %08x/%08x/%08x/%08x\n", RegEax,
> RegEbx, RegEcx, RegEdx));
> +if ((RegEcx & BIT16) != 0) {
> +  Page5LevelSupport = TRUE;
> +}
> +  }
> +
> +  DEBUG ((DEBUG_INFO, "AddressBits/5LevelPaging/1GPage
> = %d/%d/%d\n",
> + PhysicalAddressBits, Page5LevelSupport, Page1GSupport));
> +
>//
> -  // IA-32e paging 

[edk2-devel] [edk2-platform patch] Silicon/Intel/Tools: Add .gitignore file to ignore the generated .o/.obj

2019-07-22 Thread Liming Gao
C tools are compiled first. Their generation files .o/.obj/.d/.pdb should be 
ignored.

Signed-off-by: Liming Gao 
Cc: Bob Feng 
---
 Silicon/Intel/Tools/.gitignore | 4 
 1 file changed, 4 insertions(+)
 create mode 100644 Silicon/Intel/Tools/.gitignore

diff --git a/Silicon/Intel/Tools/.gitignore b/Silicon/Intel/Tools/.gitignore
new file mode 100644
index 00..5cb8105f17
--- /dev/null
+++ b/Silicon/Intel/Tools/.gitignore
@@ -0,0 +1,4 @@
+*.d
+*.o
+*.obj
+*.pdb
-- 
2.13.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44120): https://edk2.groups.io/g/devel/message/44120
Mute This Topic: https://groups.io/mt/32556620/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 3/4] MdeModulePkg/DxeIpl: Introduce PCD PcdUse5LevelPageTable

2019-07-22 Thread Ni, Ray
Forgot to include MdeModulePkg maintainers for review.

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ni, Ray
> Sent: Monday, July 22, 2019 4:16 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Laszlo Ersek 
> Subject: [edk2-devel] [PATCH 3/4] MdeModulePkg/DxeIpl: Introduce PCD
> PcdUse5LevelPageTable
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2008
> 
> The PCD indicates if 5-Level Paging will be enabled in long mode.
> 5-Level Paging will not be enabled when the PCD is TRUE but CPU doesn't
> support 5-Level Paging.
> 
> Signed-off-by: Ray Ni 
> Cc: Eric Dong 
> Cc: Laszlo Ersek 
> ---
>  MdeModulePkg/MdeModulePkg.dec | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec index 12e0bbf579..21388595a9
> 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -1991,6 +1991,13 @@ [PcdsFixedAtBuild, PcdsPatchableInModule,
> PcdsDynamic, PcdsDynamicEx]
># @Prompt The address mask when memory encryption is enabled.
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrM
> ask|0x0|UINT64|0x30001047
> 
> +  ## Indicates if 5-Level Paging will be enabled in long mode. 5-Level
> + Paging will not be enabled  #  when the PCD is TRUE but CPU doesn't
> support 5-Level Paging.
> +  #   TRUE  - 5-Level Paging will be enabled.
> +  #   FALSE - 5-Level Paging will not be enabled.
> +  # @Prompt Enable 5-Level Paging support in long mode.
> +
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable|FALSE|BOOLE
> AN|0x0
> + 001105F
> +
>## Capsule In Ram is to use memory to deliver the capsules that will be
> processed after system
>#  reset.
>#  This PCD indicates if the Capsule In Ram is supported.
> --
> 2.21.0.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44121): https://edk2.groups.io/g/devel/message/44121
Mute This Topic: https://groups.io/mt/32556623/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v2 0/6] Acpiview table parsers code style enhancements and refactoring

2019-07-22 Thread Krzysztof Koch
Hi Everyone,

Just to let you know, only "ShellPkg: acpiview: Allow passing buffer length to 
DumpGasStruct()" is changed compared to v1. I had a wrong understanding of how 
to post revised patches to the upstream community.

Kind regards,

Krzysztof

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Krzysztof Koch 
via Groups.Io
Sent: Monday, July 22, 2019 8:50
To: devel@edk2.groups.io
Cc: jaben.car...@intel.com; ray...@intel.com; zhichao@intel.com; Sami 
Mujawar ; Matteo Carlini ; nd 

Subject: [edk2-devel] [PATCH v2 0/6] Acpiview table parsers code style 
enhancements and refactoring

This set of patches consists of a number of changes which make the code 
structure consistent across the existing ACPI table parsers. These are all 
refactoring changes which do not modify the existing functionality of the 
acpiview UEFI shell tool.

Changes can be seen at: 
https://github.com/KrzysztofKoch1/edk2/tree/612_acpiview_code_style_enhance_v2

Krzysztof Koch (6):
  ShellPkg: acpiview: Allow passing buffer length to DumpGasStruct()
  ShellPkg: acpiview: XSDT: Remove redundant ParseAcpi() call
  ShellPkg: acpiview: RSDP: Make code consistent with other parsers
  ShellPkg: acpiview: SRAT: Minor code style enhancements
  ShellPkg: acpiview: MADT: Split structure length validation
  ShellPkg: acpiview: IORT: Refactor PMCG node mapping count validation

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c  | 26 
+---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h  |  8 
+++--
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c |  2 +- 
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c | 32 
++--  
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c | 30 
+-  
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c | 11 
+--  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c 
|  3 +-  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c 
| 18 +++
 8 files changed, 82 insertions(+), 48 deletions(-)

--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'






-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44119): https://edk2.groups.io/g/devel/message/44119
Mute This Topic: https://groups.io/mt/32556317/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 4/4] MdeModulePkg/DxeIpl: Create 5-level page table for long mode

2019-07-22 Thread Ni, Ray
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2008

DxeIpl is responsible to create page table for DXE phase running
either in long mode or in 32bit mode with certain protection
mechanism enabled (refer to ToBuildPageTable()).

The patch updates DxeIpl to create 5-level page table for DXE phase
running in long mode when PcdUse5LevelPageTable is TRUE and CPU
supports 5-level page table.

Signed-off-by: Ray Ni 
Cc: Eric Dong 
Cc: Laszlo Ersek 
---
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf   |   1 +
 .../Core/DxeIplPeim/X64/VirtualMemory.c   | 227 --
 2 files changed, 151 insertions(+), 77 deletions(-)

diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf 
b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index abc3217b01..98bc17fc9d 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -110,6 +110,7 @@ [Pcd.IA32,Pcd.X64]
   gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask   ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard   ## 
CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable  ## 
SOMETIMES_CONSUMES
 
 [Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64]
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack   ## 
SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c 
b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
index edc38e4525..a5bcdcc734 100644
--- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
+++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
@@ -15,7 +15,7 @@
 2) IA-32 Intel(R) Architecture Software Developer's Manual Volume 
2:Instruction Set Reference, Intel
 3) IA-32 Intel(R) Architecture Software Developer's Manual Volume 3:System 
Programmer's Guide, Intel
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
 Copyright (c) 2017, AMD Incorporated. All rights reserved.
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -626,14 +626,19 @@ CreateIdentityMappingPageTables (
   )
 {
   UINT32RegEax;
+  UINT32RegEbx;
+  UINT32RegEcx;
   UINT32RegEdx;
   UINT8 PhysicalAddressBits;
   EFI_PHYSICAL_ADDRESS  PageAddress;
+  UINTN IndexOfPml5Entries;
   UINTN IndexOfPml4Entries;
   UINTN IndexOfPdpEntries;
   UINTN IndexOfPageDirectoryEntries;
+  UINT32NumberOfPml5EntriesNeeded;
   UINT32NumberOfPml4EntriesNeeded;
   UINT32NumberOfPdpEntriesNeeded;
+  PAGE_MAP_AND_DIRECTORY_POINTER*PageMapLevel5Entry;
   PAGE_MAP_AND_DIRECTORY_POINTER*PageMapLevel4Entry;
   PAGE_MAP_AND_DIRECTORY_POINTER*PageMap;
   PAGE_MAP_AND_DIRECTORY_POINTER*PageDirectoryPointerEntry;
@@ -641,9 +646,11 @@ CreateIdentityMappingPageTables (
   UINTN TotalPagesNum;
   UINTN BigPageAddress;
   VOID  *Hob;
+  BOOLEAN   Page5LevelSupport;
   BOOLEAN   Page1GSupport;
   PAGE_TABLE_1G_ENTRY   *PageDirectory1GEntry;
   UINT64AddressEncMask;
+  IA32_CR4  Cr4;
 
   //
   // Make sure AddressEncMask is contained to smallest supported address field
@@ -677,33 +684,66 @@ CreateIdentityMappingPageTables (
 }
   }
 
+  Page5LevelSupport = FALSE;
+  if (PcdGetBool (PcdUse5LevelPageTable)) {
+AsmCpuidEx (0x7, 0, , , , );
+DEBUG ((DEBUG_INFO, "Cpuid(7/0): %08x/%08x/%08x/%08x\n", RegEax, RegEbx, 
RegEcx, RegEdx));
+if ((RegEcx & BIT16) != 0) {
+  Page5LevelSupport = TRUE;
+}
+  }
+
+  DEBUG ((DEBUG_INFO, "AddressBits/5LevelPaging/1GPage = %d/%d/%d\n", 
PhysicalAddressBits, Page5LevelSupport, Page1GSupport));
+
   //
-  // IA-32e paging translates 48-bit linear addresses to 52-bit physical 
addresses.
+  // IA-32e paging translates 48-bit linear addresses to 52-bit physical 
addresses
+  //  when 5-Level Paging is disabled,
+  //  due to either unsupported by HW, or disabled by PCD.
   //
   ASSERT (PhysicalAddressBits <= 52);
-  if (PhysicalAddressBits > 48) {
+  if (!Page5LevelSupport && PhysicalAddressBits > 48) {
 PhysicalAddressBits = 48;
   }
 
   //
   // Calculate the table entries needed.
   //
-  if 

[edk2-devel] [PATCH 2/4] UefiCpuPkg/CpuDxe: Support parsing 5-level page table

2019-07-22 Thread Ni, Ray
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2008

Signed-off-by: Ray Ni 
Cc: Eric Dong 
Cc: Laszlo Ersek 
---
 UefiCpuPkg/CpuDxe/CpuPageTable.c | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTable.c
index c369b44f12..8e959eb2b7 100644
--- a/UefiCpuPkg/CpuDxe/CpuPageTable.c
+++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c
@@ -1,7 +1,7 @@
 /** @file
   Page table management support.
 
-  Copyright (c) 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
   Copyright (c) 2017, AMD Incorporated. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -276,25 +276,43 @@ GetPageTableEntry (
   UINTN Index2;
   UINTN Index3;
   UINTN Index4;
+  UINTN Index5;
   UINT64*L1PageTable;
   UINT64*L2PageTable;
   UINT64*L3PageTable;
   UINT64*L4PageTable;
+  UINT64*L5PageTable;
   UINT64AddressEncMask;
+  IA32_CR4  Cr4;
+  BOOLEAN   Enable5LevelPaging;
 
   ASSERT (PagingContext != NULL);
 
+  Index5 = ((UINTN)RShiftU64 (Address, 48)) & PAGING_PAE_INDEX_MASK;
   Index4 = ((UINTN)RShiftU64 (Address, 39)) & PAGING_PAE_INDEX_MASK;
   Index3 = ((UINTN)Address >> 30) & PAGING_PAE_INDEX_MASK;
   Index2 = ((UINTN)Address >> 21) & PAGING_PAE_INDEX_MASK;
   Index1 = ((UINTN)Address >> 12) & PAGING_PAE_INDEX_MASK;
 
+  Cr4.UintN = AsmReadCr4 ();
+  Enable5LevelPaging = (BOOLEAN) (Cr4.Bits.LA57 == 1);
+
   // Make sure AddressEncMask is contained to smallest supported address field.
   //
   AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & 
PAGING_1G_ADDRESS_MASK_64;
 
   if (PagingContext->MachineType == IMAGE_FILE_MACHINE_X64) {
-L4PageTable = (UINT64 
*)(UINTN)PagingContext->ContextData.X64.PageTableBase;
+if (Enable5LevelPaging) {
+  L5PageTable = (UINT64 
*)(UINTN)PagingContext->ContextData.X64.PageTableBase;
+  if (L5PageTable[Index5] == 0) {
+*PageAttribute = PageNone;
+return NULL;
+  }
+
+  L4PageTable = (UINT64 *)(UINTN)(L5PageTable[Index5] & ~AddressEncMask & 
PAGING_4K_ADDRESS_MASK_64);
+} else {
+  L4PageTable = (UINT64 
*)(UINTN)PagingContext->ContextData.X64.PageTableBase;
+}
 if (L4PageTable[Index4] == 0) {
   *PageAttribute = PageNone;
   return NULL;
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44116): https://edk2.groups.io/g/devel/message/44116
Mute This Topic: https://groups.io/mt/32556533/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 0/4] Support 5-level paging in DXE long mode

2019-07-22 Thread Ni, Ray


Ray Ni (4):
  UefiCpuPkg/MpInitLib: Enable 5-level paging for AP when BSP's enabled
  UefiCpuPkg/CpuDxe: Support parsing 5-level page table
  MdeModulePkg/DxeIpl: Introduce PCD PcdUse5LevelPageTable
  MdeModulePkg/DxeIpl: Create 5-level page table for long mode

 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf   |   1 +
 .../Core/DxeIplPeim/X64/VirtualMemory.c   | 227 --
 MdeModulePkg/MdeModulePkg.dec |   7 +
 UefiCpuPkg/CpuDxe/CpuPageTable.c  |  22 +-
 UefiCpuPkg/Library/MpInitLib/MpLib.c  |  11 +
 UefiCpuPkg/Library/MpInitLib/MpLib.h  |   6 +-
 UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc|   3 +-
 UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm |  14 +-
 8 files changed, 209 insertions(+), 82 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44114): https://edk2.groups.io/g/devel/message/44114
Mute This Topic: https://groups.io/mt/32556531/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 1/4] UefiCpuPkg/MpInitLib: Enable 5-level paging for AP when BSP's enabled

2019-07-22 Thread Ni, Ray
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2008

MpInitLib is the library that's responsible to wake up APs to provide
MP PPI and Protocol services.

The patch synchronizes BSP's CR4.LA57 to each AP's CR4.LA57.
Without this change, AP may enter to GP fault when BSP's 5-level page
table is set to AP during AP wakes up.

Signed-off-by: Ray Ni 
Cc: Eric Dong 
Cc: Laszlo Ersek 
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c  | 11 +++
 UefiCpuPkg/Library/MpInitLib/MpLib.h  |  6 +-
 UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc|  3 ++-
 UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 14 +-
 4 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 6f51bc4ebf..e4691315e9 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -790,6 +790,7 @@ FillExchangeInfoData (
   volatile MP_CPU_EXCHANGE_INFO*ExchangeInfo;
   UINTNSize;
   IA32_SEGMENT_DESCRIPTOR  *Selector;
+  IA32_CR4 Cr4;
 
   ExchangeInfo  = CpuMpData->MpCpuExchangeInfo;
   ExchangeInfo->Lock= 0;
@@ -814,6 +815,16 @@ FillExchangeInfoData (
 
   ExchangeInfo->InitializeFloatingPointUnitsAddress = 
(UINTN)InitializeFloatingPointUnits;
 
+  //
+  // We can check either CPUID(7).ECX[bit16] or check CR4.LA57[bit12]
+  //  to determin whether 5-Level Paging is enabled.
+  // Using latter way is simpler because it also eliminates the needs to
+  //  check whether platform wants to enable it.
+  //
+  Cr4.UintN = AsmReadCr4 ();
+  ExchangeInfo->Enable5LevelPaging = (BOOLEAN) (Cr4.Bits.LA57 == 1);
+  DEBUG ((DEBUG_INFO, "CpuMp: 5-Level Paging = %d\n", 
ExchangeInfo->Enable5LevelPaging));
+
   //
   // Get the BSP's data of GDT and IDT
   //
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h 
b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index f89037c59e..fa7d6b32e9 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -1,7 +1,7 @@
 /** @file
   Common header file for MP Initialize Library.
 
-  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -185,6 +185,10 @@ typedef struct {
   UINT16ModeTransitionSegment;
   UINT32ModeHighMemory;
   UINT16ModeHighSegment;
+  //
+  // Enable5LevelPaging indicates whether 5-level paging is enabled in long 
mode.
+  //
+  UINTN Enable5LevelPaging;
 } MP_CPU_EXCHANGE_INFO;
 
 #pragma pack()
diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc 
b/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc
index 467f54a860..58ef369342 100644
--- a/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc
+++ b/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+; Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
 ; SPDX-License-Identifier: BSD-2-Clause-Patent
 ;
 ; Module Name:
@@ -40,3 +40,4 @@ ModeTransitionMemoryLocationequ  LockLocation + 94h
 ModeTransitionSegmentLocation   equ  LockLocation + 98h
 ModeHighMemoryLocation  equ  LockLocation + 9Ah
 ModeHighSegmentLocation equ  LockLocation + 9Eh
+Enable5LevelPagingLocation  equ  LockLocation + 0A0h
diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm 
b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
index cea90f3d4d..b563c2ed3e 100644
--- a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
+++ b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
@@ -1,5 +1,5 @@
 
;-- 
;
-; Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+; Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
 ; SPDX-License-Identifier: BSD-2-Clause-Patent
 ;
 ; Module Name:
@@ -100,6 +100,18 @@ SkipEnableExecuteDisableBit:
 ;
 moveax, cr4
 btseax, 5
+
+movesi, Enable5LevelPagingLocation
+cmpbyte [ebx + esi], 0
+jz SkipEnable5Paging
+
+;
+; Enable 5 Level Paging
+;
+btseax, 12 ; Set LA57=1.
+
+SkipEnable5Paging:
+
 movcr4, eax
 
 ;
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44115): https://edk2.groups.io/g/devel/message/44115
Mute This Topic: https://groups.io/mt/32556532/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 3/4] MdeModulePkg/DxeIpl: Introduce PCD PcdUse5LevelPageTable

2019-07-22 Thread Ni, Ray
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2008

The PCD indicates if 5-Level Paging will be enabled in long mode.
5-Level Paging will not be enabled when the PCD is TRUE but CPU
doesn't support 5-Level Paging.

Signed-off-by: Ray Ni 
Cc: Eric Dong 
Cc: Laszlo Ersek 
---
 MdeModulePkg/MdeModulePkg.dec | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 12e0bbf579..21388595a9 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1991,6 +1991,13 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, 
PcdsDynamicEx]
   # @Prompt The address mask when memory encryption is enabled.
   
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0|UINT64|0x30001047
 
+  ## Indicates if 5-Level Paging will be enabled in long mode. 5-Level Paging 
will not be enabled
+  #  when the PCD is TRUE but CPU doesn't support 5-Level Paging.
+  #   TRUE  - 5-Level Paging will be enabled.
+  #   FALSE - 5-Level Paging will not be enabled.
+  # @Prompt Enable 5-Level Paging support in long mode. 
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable|FALSE|BOOLEAN|0x0001105F
+
   ## Capsule In Ram is to use memory to deliver the capsules that will be 
processed after system
   #  reset.
   #  This PCD indicates if the Capsule In Ram is supported.
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44117): https://edk2.groups.io/g/devel/message/44117
Mute This Topic: https://groups.io/mt/32556534/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 5/6] ShellPkg: acpiview: MADT: Split structure length validation

2019-07-22 Thread Krzysztof Koch
Split the Interrupt Controller Structure length validation in the
acpiview UEFI shell tool into two logical parts:
1. Ensuring MADT table parser forward progress.
2. Preventing MADT table buffer overruns.

Also, make the condition for infinite loop detection applicable to
all types of Interrupt Controller Structures (for all interrupt models
which can be represented in MADT). Check if the controller length
specified is shorter than the byte size of the first two fields
('Type' and 'Length') present in every valid Interrupt Controller
Structure.

Signed-off-by: Krzysztof Koch 
---

Notes:
v1:
- split MADT structure length validation [Krzysztof]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c | 30 
++--
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
index 
338295d30e35c366a60505225cf57145a8e73d93..d80ebd1a2bae7a4acffe687ca5ee7b4090f0e223
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
@@ -260,16 +260,30 @@ ParseAcpiMadt (
   PARSER_PARAMS (MadtInterruptControllerHeaderParser)
   );
 
-if (((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength) ||
-(*MadtInterruptControllerLength < 4)) {
+// Make sure forward progress is made.
+if (*MadtInterruptControllerLength < 2) {
   IncrementErrorCount ();
   Print (
- L"ERROR: Invalid Interrupt Controller Length,"
-  L" Type = %d, Length = %d\n",
- *MadtInterruptControllerType,
- *MadtInterruptControllerLength
- );
-  break;
+L"ERROR: Structure length is too small: " \
+  L"MadtInterruptControllerLength = %d. " \
+  L"MadtInterruptControllerType = %d. MADT parsing aborted.\n",
+*MadtInterruptControllerLength,
+*MadtInterruptControllerType
+);
+  return;
+}
+
+// Make sure the MADT structure lies inside the table
+if ((Offset + *MadtInterruptControllerLength) > AcpiTableLength) {
+  IncrementErrorCount ();
+  Print (
+L"ERROR: Invalid MADT structure length. " \
+  L"MadtInterruptControllerLength = %d. " \
+  L"RemainingTableBufferLength = %d. MADT parsing aborted.\n",
+*MadtInterruptControllerLength,
+AcpiTableLength - Offset
+);
+  return;
 }
 
 switch (*MadtInterruptControllerType) {
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44113): https://edk2.groups.io/g/devel/message/44113
Mute This Topic: https://groups.io/mt/32556349/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 6/6] ShellPkg: acpiview: IORT: Refactor PMCG node mapping count validation

2019-07-22 Thread Krzysztof Koch
Move Performance Monitoring Counter Group (PMCG) node ID mapping count
validation from the core IORT acpiview parser logic to a dedicated
function. Now, the pointer to the validation function is passed to the
IortNodePmcgParser[] ACPI_PARSER array.

This check does not affect the flow of IORT parsing and is limited to
a single table field in scope, therefore, it is better to keep it away
from the code responsible for traversing the table.

Signed-off-by: Krzysztof Koch 
---

Notes:
v1:
- refactor PMCG node mapping count validation [Krzysztof]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c | 32 
++--
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
index 
0461205b4f8bc02aa11ab1db1d0deb73bce053b7..7c850b3813d5204775e2cc247cabf42358b25769
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
@@ -53,6 +53,28 @@ ValidateItsIdMappingCount (
   }
 }
 
+/**
+  This function validates the ID Mapping array count for the Performance
+  Monitoring Counter Group (PMCG) node.
+
+  @param [in] Ptr Pointer to the start of the field data.
+  @param [in] Context Pointer to context specific information e.g. this
+  could be a pointer to the ACPI table header.
+**/
+STATIC
+VOID
+EFIAPI
+ValidatePmcgIdMappingCount (
+  IN UINT8* Ptr,
+  IN VOID*  Context
+  )
+{
+  if (*(UINT32*)Ptr > 1) {
+IncrementErrorCount ();
+Print (L"\nERROR: IORT ID Mapping count must not be greater than 1.");
+  }
+}
+
 /**
   This function validates the ID Mapping array offset for the ITS node.
 
@@ -216,7 +238,7 @@ STATIC CONST ACPI_PARSER IortNodeRootComplexParser[] = {
   An ACPI_PARSER array describing the IORT PMCG node.
 **/
 STATIC CONST ACPI_PARSER IortNodePmcgParser[] = {
-  PARSE_IORT_NODE_HEADER (NULL, NULL),
+  PARSE_IORT_NODE_HEADER (ValidatePmcgIdMappingCount, NULL),
   {L"Base Address", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL},
   {L"Overflow interrupt GSIV", 4, 24, L"0x%x", NULL, NULL, NULL, NULL},
   {L"Node reference", 4, 28, L"0x%x", NULL, NULL, NULL, NULL},
@@ -537,14 +559,6 @@ DumpIortNodePmcg (
   if (*IortIdMappingCount != 0) {
 DumpIortNodeIdMappings (Ptr, MappingCount, MappingOffset);
   }
-
-  if (*IortIdMappingCount > 1) {
-IncrementErrorCount ();
-Print (
-  L"ERROR: ID mapping must not be greater than 1. Id Mapping Count =%d\n",
-  *IortIdMappingCount
-  );
-  }
 }
 
 /**
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44111): https://edk2.groups.io/g/devel/message/44111
Mute This Topic: https://groups.io/mt/32556344/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 4/6] ShellPkg: acpiview: SRAT: Minor code style enhancements

2019-07-22 Thread Krzysztof Koch
Minor changes to the SRAT parser code to conform with the EDKII coding
style and to make it consistent with other ACPI table parsers.

Signed-off-by: Krzysztof Koch 
---

Notes:
v1:
- minor code style enhancements [Krzysztof]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
index 
03d28d52842040e4872e204fc10ae3dba7861936..59c77401eaab32b73a9f83fd4d63785221b3c222
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
@@ -206,6 +206,7 @@ ParseAcpiSrat (
  AcpiTableLength,
  PARSER_PARAMS (SratParser)
  );
+
   ResourcePtr = Ptr + Offset;
 
   while (Offset < AcpiTableLength) {
@@ -250,7 +251,7 @@ ParseAcpiSrat (
   ResourcePtr,
   *SratRALength,
   PARSER_PARAMS (SratGicITSAffinityParser)
-);
+  );
 break;
 
   case EFI_ACPI_6_2_MEMORY_AFFINITY:
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44112): https://edk2.groups.io/g/devel/message/44112
Mute This Topic: https://groups.io/mt/32556345/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 3/6] ShellPkg: acpiview: RSDP: Make code consistent with other parsers

2019-07-22 Thread Krzysztof Koch
List ParseAcpi() function arguments one per line in order to make this
function call consistent with ParseAcpi() calls in other ACPI table
parsers.

Also, notify the user that XsdtAddress value of 0 results in RSDP
parsing being terminated and that the XSDT table will not be processed.

This effectively means that no more ACPI tables will be parsed because
of this RSDP table content error.

Signed-off-by: Krzysztof Koch 
---

Notes:
v1:
- minor code style enhancements [Krzysztof]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c | 11 
+--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
index 
4bf928139a507d0b8f203ed0cbf0863cc2ec5de5..5a5c4b50c12e6eb0aa0efb1765df7e123f614da3
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
@@ -129,7 +129,14 @@ ParseAcpiRsdp (
 VerifyChecksum (TRUE, Ptr, AcpiTableLength);
   }
 
-  ParseAcpi (Trace, 0, "RSDP", Ptr, AcpiTableLength, PARSER_PARAMS 
(RsdpParser));
+  ParseAcpi (
+Trace,
+0,
+"RSDP",
+Ptr,
+AcpiTableLength,
+PARSER_PARAMS (RsdpParser)
+);
 
   // This code currently supports parsing of XSDT table only
   // and does not parse the RSDT table. Platforms provide the
@@ -137,7 +144,7 @@ ParseAcpiRsdp (
   // Therefore the RSDT should not be used on ARM platforms.
   if ((*XsdtAddress) == 0) {
 IncrementErrorCount ();
-Print (L"ERROR: XSDT Pointer is not set.\n");
+Print (L"ERROR: XSDT Pointer is not set. RSDP parsing aborted.\n");
 return;
   }
 
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44110): https://edk2.groups.io/g/devel/message/44110
Mute This Topic: https://groups.io/mt/32556319/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 0/6] Acpiview table parsers code style enhancements and refactoring

2019-07-22 Thread Krzysztof Koch
This set of patches consists of a number of changes which make the code
structure consistent across the existing ACPI table parsers. These are
all refactoring changes which do not modify the existing functionality
of the acpiview UEFI shell tool.

Changes can be seen at: 
https://github.com/KrzysztofKoch1/edk2/tree/612_acpiview_code_style_enhance_v2

Krzysztof Koch (6):
  ShellPkg: acpiview: Allow passing buffer length to DumpGasStruct()
  ShellPkg: acpiview: XSDT: Remove redundant ParseAcpi() call
  ShellPkg: acpiview: RSDP: Make code consistent with other parsers
  ShellPkg: acpiview: SRAT: Minor code style enhancements
  ShellPkg: acpiview: MADT: Split structure length validation
  ShellPkg: acpiview: IORT: Refactor PMCG node mapping count validation

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c  | 26 
+---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h  |  8 
+++--
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c |  2 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c | 32 
++--
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c | 30 
+-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c | 11 
+--
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c |  3 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c | 18 
+++
 8 files changed, 82 insertions(+), 48 deletions(-)

--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44108): https://edk2.groups.io/g/devel/message/44108
Mute This Topic: https://groups.io/mt/32556317/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 1/6] ShellPkg: acpiview: Allow passing buffer length to DumpGasStruct()

2019-07-22 Thread Krzysztof Koch
Modify the signature of the DumpGasStruct() function to include the
buffer length parameter and to return the number of bytes parsed by
the function.

This way it becomes possible to prevent buffer overruns when dumping
Generic Address Structure's (GAS) fields in the acpiview table
parsers.

Update all existing DumpGasStruct() calls in acpiview to add the
length argument.

Signed-off-by: Krzysztof Koch 
---

Notes:
v2:
- Pass GAS_LENGTH to DumpGasStruct() in DBG2 parser [Zhichao]

v1:
- Modify DumpGasStruct() signature [Krzysztof]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c  | 26 
+++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h  |  8 
--
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c |  2 +-
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
index 
8b3153516d2b7d9b920ab2de0344c17798ac572c..2d6ff80e299eebe7853061d3db89332197c0dc0e
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
@@ -589,23 +589,27 @@ STATIC CONST ACPI_PARSER GasParser[] = {
 
   @param [in] Ptr Pointer to the start of the buffer.
   @param [in] Indent  Number of spaces to indent the output.
+  @param [in] Length  Length of the GAS structure buffer.
+
+  @retval Number of bytes parsed.
 **/
-VOID
+UINT32
 EFIAPI
 DumpGasStruct (
   IN UINT8*Ptr,
-  IN UINT32Indent
+  IN UINT32Indent,
+  IN UINT32Length
   )
 {
   Print (L"\n");
-  ParseAcpi (
-TRUE,
-Indent,
-NULL,
-Ptr,
-GAS_LENGTH,
-PARSER_PARAMS (GasParser)
-);
+  return ParseAcpi (
+   TRUE,
+   Indent,
+   NULL,
+   Ptr,
+   Length,
+   PARSER_PARAMS (GasParser)
+   );
 }
 
 /**
@@ -621,7 +625,7 @@ DumpGas (
   IN UINT8*Ptr
   )
 {
-  DumpGasStruct (Ptr, 2);
+  DumpGasStruct (Ptr, 2, GAS_LENGTH);
 }
 
 /**
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 
7657892d9fd2e2e14c6578611ff0cf1b6f6cd750..20ca358bddfa5953bfb1d1bebaebbf3079eaba01
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -405,12 +405,16 @@ ParseAcpi (
 
   @param [in] Ptr Pointer to the start of the buffer.
   @param [in] Indent  Number of spaces to indent the output.
+  @param [in] Length  Length of the GAS structure buffer.
+
+  @retval Number of bytes parsed.
 **/
-VOID
+UINT32
 EFIAPI
 DumpGasStruct (
   IN UINT8*Ptr,
-  IN UINT32Indent
+  IN UINT32Indent,
+  IN UINT32Length
   );
 
 /**
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
index 
1efcbd40f86efdabed2152540a415db8a950fb71..c6929695a1032c57761ef85002d6c51b7800ce23
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
@@ -134,7 +134,7 @@ DumpDbgDeviceInfo (
   AddrSize = (UINT32*)(Ptr + (*AddrSizeOffset));
   while (Index < (*GasCount)) {
 PrintFieldName (4, L"BaseAddressRegister");
-DumpGasStruct (DataPtr, 4);
+DumpGasStruct (DataPtr, 4, GAS_LENGTH);
 PrintFieldName (4, L"Address Size");
 Print (L"0x%x\n", AddrSize[Index]);
 DataPtr += GAS_LENGTH;
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44109): https://edk2.groups.io/g/devel/message/44109
Mute This Topic: https://groups.io/mt/32556318/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 2/6] ShellPkg: acpiview: XSDT: Remove redundant ParseAcpi() call

2019-07-22 Thread Krzysztof Koch
Remove a call to ParseAcpi() responsible for getting the XSDT table
length. This call is not needed because the ACPI table buffer length is
provided as an input argument to the ParseAcpiXsdt() function.

Modify remaining code to use the AcpiTableLength argument of the
ParseAcpiXsdt() function instead of a global static variable.

Signed-off-by: Krzysztof Koch 
---

Notes:
v1:
- remove redundant ParseAcpi() call [Krzysztof]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c | 18 
--
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
index 
4196168bff47d70c67f79f3fc1f4cdee302d460e..e39061f8e2612f2cce4aebf51a511b63b703662b
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
@@ -1,7 +1,7 @@
 /** @file
   XSDT table parser
 
-  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
   @par Reference(s):
@@ -60,22 +60,12 @@ ParseAcpiXsdt (
   UINTN EntryIndex;
   CHAR16Buffer[32];
 
-  // Parse the ACPI header to get the length
-  ParseAcpi (
-FALSE,
-0,
-"XSDT",
-Ptr,
-ACPI_DESCRIPTION_HEADER_LENGTH,
-PARSER_PARAMS (XsdtParser)
-);
-
   Offset = ParseAcpi (
  Trace,
  0,
  "XSDT",
  Ptr,
- *AcpiHdrInfo.Length,
+ AcpiTableLength,
  PARSER_PARAMS (XsdtParser)
  );
 
@@ -84,7 +74,7 @@ ParseAcpiXsdt (
   if (Trace) {
 EntryIndex = 0;
 TablePointer = (UINT64*)(Ptr + TableOffset);
-while (Offset < (*AcpiHdrInfo.Length)) {
+while (Offset < AcpiTableLength) {
   CONST UINT32* Signature;
   CONST UINT32* Length;
   CONST UINT8*  Revision;
@@ -140,7 +130,7 @@ ParseAcpiXsdt (
   // Process the tables
   Offset = TableOffset;
   TablePointer = (UINT64*)(Ptr + TableOffset);
-  while (Offset < (*AcpiHdrInfo.Length)) {
+  while (Offset < AcpiTableLength) {
 if ((UINT64*)(UINTN)(*TablePointer) != NULL) {
   ProcessAcpiTable ((UINT8*)(UINTN)(*TablePointer));
 }
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44107): https://edk2.groups.io/g/devel/message/44107
Mute This Topic: https://groups.io/mt/32556316/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [Patch v2 1/6] UefiCpuPkg/Include/MpInitLib.h: Add MpInitLibStartupAllCPUs API.

2019-07-22 Thread Ni, Ray
Reviewed-by: Ray Ni 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Dong,
> Eric
> Sent: Monday, July 22, 2019 3:14 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray ; Laszlo Ersek ; Kumar,
> Chandana C ; Zeng, Star
> 
> Subject: [edk2-devel] [Patch v2 1/6] UefiCpuPkg/Include/MpInitLib.h: Add
> MpInitLibStartupAllCPUs API.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
> 
> Add new MpInitLibStartupAllCPUs API uses to start all processors at the same
> time.
> 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Chandana Kumar 
> Cc: Star Zeng 
> Signed-off-by: Eric Dong 
> ---
>  UefiCpuPkg/Include/Library/MpInitLib.h | 33
> ++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/UefiCpuPkg/Include/Library/MpInitLib.h
> b/UefiCpuPkg/Include/Library/MpInitLib.h
> index fa82529373..a943fbd9bc 100644
> --- a/UefiCpuPkg/Include/Library/MpInitLib.h
> +++ b/UefiCpuPkg/Include/Library/MpInitLib.h
> @@ -344,4 +344,37 @@ MpInitLibWhoAmI (
>OUT UINTN*ProcessorNumber
>);
> 
> +/**
> +  This service executes a caller provided function on all enabled CPUs.
> +
> +  @param[in]  Procedure   A pointer to the function to be run on
> +  enabled APs of the system. See type
> +  EFI_AP_PROCEDURE.
> +  @param[in]  TimeoutInMicroseconds   Indicates the time limit in
> microseconds for
> +  APs to return from Procedure, either 
> for
> +  blocking or non-blocking mode. Zero 
> means
> +  infinity.
> +  @param[in]  ProcedureArgument   The parameter passed into
> Procedure for
> +  all APs.
> +
> +  @retval EFI_SUCCESS In blocking mode, all CPUs have finished
> before
> +  the timeout expired.
> +  @retval EFI_SUCCESS In non-blocking mode, function has been
> dispatched
> +  to all enabled CPUs.
> +  @retval EFI_DEVICE_ERRORCaller processor is AP.
> +  @retval EFI_NOT_READY   Any enabled APs are busy.
> +  @retval EFI_NOT_READY   MP Initialize Library is not initialized.
> +  @retval EFI_TIMEOUT In blocking mode, the timeout expired 
> before
> +  all enabled APs have finished.
> +  @retval EFI_INVALID_PARAMETER   Procedure is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MpInitLibStartupAllCPUs (
> +  IN  EFI_AP_PROCEDURE  Procedure,
> +  IN  UINTN TimeoutInMicroseconds,
> +  IN  VOID  *ProcedureArgument  OPTIONAL
> +  );
> +
>  #endif
> --
> 2.21.0.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44106): https://edk2.groups.io/g/devel/message/44106
Mute This Topic: https://groups.io/mt/32556151/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch v2 1/6] UefiCpuPkg/Include/MpInitLib.h: Add MpInitLibStartupAllCPUs API.

2019-07-22 Thread Dong, Eric
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973

Add new MpInitLibStartupAllCPUs API uses to start all processors
at the same time.

Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Chandana Kumar 
Cc: Star Zeng 
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/Include/Library/MpInitLib.h | 33 ++
 1 file changed, 33 insertions(+)

diff --git a/UefiCpuPkg/Include/Library/MpInitLib.h 
b/UefiCpuPkg/Include/Library/MpInitLib.h
index fa82529373..a943fbd9bc 100644
--- a/UefiCpuPkg/Include/Library/MpInitLib.h
+++ b/UefiCpuPkg/Include/Library/MpInitLib.h
@@ -344,4 +344,37 @@ MpInitLibWhoAmI (
   OUT UINTN*ProcessorNumber
   );
 
+/**
+  This service executes a caller provided function on all enabled CPUs.
+
+  @param[in]  Procedure   A pointer to the function to be run on
+  enabled APs of the system. See type
+  EFI_AP_PROCEDURE.
+  @param[in]  TimeoutInMicroseconds   Indicates the time limit in microseconds 
for
+  APs to return from Procedure, either for
+  blocking or non-blocking mode. Zero means
+  infinity.
+  @param[in]  ProcedureArgument   The parameter passed into Procedure for
+  all APs.
+
+  @retval EFI_SUCCESS In blocking mode, all CPUs have finished 
before
+  the timeout expired.
+  @retval EFI_SUCCESS In non-blocking mode, function has been 
dispatched
+  to all enabled CPUs.
+  @retval EFI_DEVICE_ERRORCaller processor is AP.
+  @retval EFI_NOT_READY   Any enabled APs are busy.
+  @retval EFI_NOT_READY   MP Initialize Library is not initialized.
+  @retval EFI_TIMEOUT In blocking mode, the timeout expired before
+  all enabled APs have finished.
+  @retval EFI_INVALID_PARAMETER   Procedure is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+MpInitLibStartupAllCPUs (
+  IN  EFI_AP_PROCEDURE  Procedure,
+  IN  UINTN TimeoutInMicroseconds,
+  IN  VOID  *ProcedureArgument  OPTIONAL
+  );
+
 #endif
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44100): https://edk2.groups.io/g/devel/message/44100
Mute This Topic: https://groups.io/mt/32556151/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch v2 2/6] UefiCpuPkg/MpInitLib: Add MpInitLibStartupAllCPUs API.

2019-07-22 Thread Dong, Eric
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973

Add new MpInitLibStartupAllCPUs API uses to start all processors
at the same time.

Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Chandana Kumar 
Cc: Star Zeng 
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c |  3 +-
 UefiCpuPkg/Library/MpInitLib/MpLib.c| 60 +++--
 UefiCpuPkg/Library/MpInitLib/MpLib.h|  4 +-
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c |  3 +-
 4 files changed, 63 insertions(+), 7 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 6be1bae464..23adfd0625 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -568,9 +568,10 @@ MpInitLibStartupAllAPs (
   //
   mStopCheckAllApsStatus = TRUE;
 
-  Status = StartupAllAPsWorker (
+  Status = StartupAllCpusWorker (
  Procedure,
  SingleThread,
+ TRUE,
  WaitEvent,
  TimeoutInMicroseconds,
  ProcedureArgument,
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 6f51bc4ebf..51e63e14a3 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -2130,6 +2130,7 @@ MpInitLibGetNumberOfProcessors (
   number.  If FALSE, then all the enabled 
APs
   execute the function specified by 
Procedure
   simultaneously.
+  @param[in]  ExcludeBsp  Whether let BSP also trig this task.
   @param[in]  WaitEvent   The event created by the caller with 
CreateEvent()
   service.
   @param[in]  TimeoutInMicroseconds   Indicates the time limit in microseconds 
for
@@ -2151,9 +2152,10 @@ MpInitLibGetNumberOfProcessors (
 
 **/
 EFI_STATUS
-StartupAllAPsWorker (
+StartupAllCpusWorker (
   IN  EFI_AP_PROCEDURE  Procedure,
   IN  BOOLEAN   SingleThread,
+  IN  BOOLEAN   ExcludeBsp,
   IN  EFI_EVENT WaitEvent   OPTIONAL,
   IN  UINTN TimeoutInMicroseconds,
   IN  VOID  *ProcedureArgument  OPTIONAL,
@@ -2175,7 +2177,7 @@ StartupAllAPsWorker (
 *FailedCpuList = NULL;
   }
 
-  if (CpuMpData->CpuCount == 1) {
+  if (CpuMpData->CpuCount == 1 && ExcludeBsp) {
 return EFI_NOT_STARTED;
   }
 
@@ -2218,9 +2220,9 @@ StartupAllAPsWorker (
 }
   }
 
-  if (!HasEnabledAp) {
+  if (!HasEnabledAp && ExcludeBsp) {
 //
-// If no enabled AP exists, return EFI_NOT_STARTED.
+// If no enabled AP exists and not include Bsp to do the procedure, return 
EFI_NOT_STARTED.
 //
 return EFI_NOT_STARTED;
   }
@@ -2266,6 +2268,13 @@ StartupAllAPsWorker (
 }
   }
 
+  if (!ExcludeBsp) {
+//
+// Start BSP.
+//
+Procedure (ProcedureArgument);
+  }
+
   Status = EFI_SUCCESS;
   if (WaitEvent == NULL) {
 do {
@@ -2411,3 +2420,46 @@ GetCpuMpDataFromGuidedHob (
   return CpuMpData;
 }
 
+/**
+  This service executes a caller provided function on all enabled CPUs.
+
+  @param[in]  Procedure   A pointer to the function to be run on
+  enabled APs of the system. See type
+  EFI_AP_PROCEDURE.
+  @param[in]  TimeoutInMicroseconds   Indicates the time limit in microseconds 
for
+  APs to return from Procedure, either for
+  blocking or non-blocking mode. Zero means
+  infinity.
+  @param[in]  ProcedureArgument   The parameter passed into Procedure for
+  all APs.
+
+  @retval EFI_SUCCESS In blocking mode, all CPUs have finished 
before
+  the timeout expired.
+  @retval EFI_SUCCESS In non-blocking mode, function has been 
dispatched
+  to all enabled CPUs.
+  @retval EFI_DEVICE_ERRORCaller processor is AP.
+  @retval EFI_NOT_READY   Any enabled APs are busy.
+  @retval EFI_NOT_READY   MP Initialize Library is not initialized.
+  @retval EFI_TIMEOUT In blocking mode, the timeout expired before
+  all enabled APs have finished.
+  @retval EFI_INVALID_PARAMETER   Procedure is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+MpInitLibStartupAllCPUs (
+  IN  EFI_AP_PROCEDURE  Procedure,
+  IN  UINTN TimeoutInMicroseconds,
+  IN  VOID  *ProcedureArgument  OPTIONAL
+  )
+{
+  return StartupAllCpusWorker (
+   Procedure,
+   FALSE,
+   FALSE,
+   NULL,
+   TimeoutInMicroseconds,
+   ProcedureArgument,
+   NULL
+   );
+}
diff --git 

[edk2-devel] [Patch v2 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI.

2019-07-22 Thread Dong, Eric
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973

Produce new EDKII_PEI_MP_SERVICES2_PPI service.

It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI
and add new API EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS.

Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Chandana Kumar 
Cc: Star Zeng 
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.c   | 72 +---
 UefiCpuPkg/CpuMpPei/CpuMpPei.h   | 35 +++-
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  1 +
 3 files changed, 101 insertions(+), 7 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
index 926541c937..c2f42d5016 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
@@ -1,7 +1,7 @@
 /** @file
   CPU PEI Module installs CPU Multiple Processor PPI.
 
-  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -21,10 +21,31 @@ EFI_PEI_MP_SERVICES_PPImMpServicesPpi = {
   PeiWhoAmI,
 };
 
-EFI_PEI_PPI_DESCRIPTOR   mPeiCpuMpPpiDesc = {
-  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
-  ,
-  
+//
+// CPU MP2 PPI to be installed
+//
+EDKII_PEI_MP_SERVICES2_PPImMpServices2Ppi = {
+  PeiGetNumberOfProcessors,
+  PeiGetProcessorInfo,
+  PeiStartupAllAPs,
+  PeiStartupThisAP,
+  PeiSwitchBSP,
+  PeiEnableDisableAP,
+  PeiWhoAmI,
+  PeiStartupAllCPUs
+};
+
+EFI_PEI_PPI_DESCRIPTOR   mPeiCpuMpPpiList[] = {
+  {
+EFI_PEI_PPI_DESCRIPTOR_PPI,
+,
+
+  },
+  {
+(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+,
+
+  }
 };
 
 /**
@@ -402,6 +423,45 @@ PeiWhoAmI (
   return MpInitLibWhoAmI (ProcessorNumber);
 }
 
+/**
+  This service executes a caller provided function on all enabled CPUs. CPUs 
can
+  run either simultaneously or one at a time in sequence. This service may only
+  be called from the BSP.
+
+  @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI 
instance.
+  @param[in] ProcedureA pointer to the function to be run on 
enabled APs of
+  the system.
+  @param[in] TimeoutInMicroSeconds
+  Indicates the time limit in microseconds for 
APs to
+  return from Procedure, for blocking mode 
only. Zero
+  means infinity.  If the timeout expires in 
blocking
+  mode, BSP returns EFI_TIMEOUT.
+  @param[in] ProcedureArgumentThe parameter passed into Procedure for all 
CPUs.
+
+  @retval EFI_SUCCESS In blocking mode, all APs have finished 
before the
+  timeout expired.
+  @retval EFI_DEVICE_ERRORCaller processor is AP.
+  @retval EFI_NOT_READY   Any enabled APs are busy.
+  @retval EFI_TIMEOUT In blocking mode, the timeout expired before 
all
+  enabled APs have finished.
+  @retval EFI_INVALID_PARAMETER   Procedure is NULL.
+**/
+EFI_STATUS
+EFIAPI
+PeiStartupAllCPUs (
+  IN  EDKII_PEI_MP_SERVICES2_PPI   *This,
+  IN  EFI_AP_PROCEDURE Procedure,
+  IN  UINTNTimeoutInMicroSeconds,
+  IN  VOID *ProcedureArgument  OPTIONAL
+  )
+{
+  return MpInitLibStartupAllCPUs (
+   Procedure,
+   TimeoutInMicroSeconds,
+   ProcedureArgument
+   );
+}
+
 /**
   Get GDT register value.
 
@@ -667,7 +727,7 @@ InitializeCpuMpWorker (
   //
   // Install CPU MP PPI
   //
-  Status = PeiServicesInstallPpi();
+  Status = PeiServicesInstallPpi(mPeiCpuMpPpiList);
   ASSERT_EFI_ERROR (Status);
 
   return Status;
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index a5d8a755b2..b385c5088b 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -1,7 +1,7 @@
 /** @file
   Definitions to install Multiple Processor PPI.
 
-  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -431,6 +432,38 @@ MemoryDiscoveredPpiNotifyCallback (
   IN VOID   *Ppi
   );
 
+/**
+  This service executes a caller provided function on all enabled CPUs. CPUs 
can
+  run either simultaneously or one at a time in sequence. This service may only
+  be called from the BSP.
+
+  @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI 
instance.
+  @param[in] ProcedureA pointer to the function to be run on 
enabled APs of
+  the system.
+  @param[in] TimeoutInMicroSeconds
+  Indicates the time 

  1   2   >