Re: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for enable GPT support

2019-01-24 Thread Wu, Hao A
> -Original Message-
> From: Chen, Chen A
> Sent: Friday, January 25, 2019 3:45 PM
> To: Wu, Hao A; Gao, Liming; edk2-devel@lists.01.org
> Cc: Kinney, Michael D; Zhang, Chao B
> Subject: RE: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for
> enable GPT support
> 
> 
> 
> -Original Message-
> From: Wu, Hao A
> Sent: Friday, January 25, 2019 3:27 PM
> To: Chen, Chen A ; Gao, Liming
> ; edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Zhang, Chao B
> 
> Subject: RE: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for
> enable GPT support
> 
> > -Original Message-
> > From: Chen, Chen A
> > Sent: Friday, January 25, 2019 3:16 PM
> > To: Wu, Hao A; edk2-devel@lists.01.org
> > Cc: Kinney, Michael D; Zhang, Chao B; Gao, Liming
> > Subject: RE: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition
> > for enable GPT support
> >
> >
> >
> > -Original Message-
> > From: Wu, Hao A
> > Sent: Friday, January 25, 2019 11:04 AM
> > To: Chen, Chen A ; edk2-devel@lists.01.org
> > Cc: Kinney, Michael D ; Zhang, Chao B
> > ; Gao, Liming 
> > Subject: RE: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition
> > for enable GPT support
> >
> > > -Original Message-
> > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf
> > > Of Chen A Chen
> > > Sent: Thursday, January 17, 2019 10:03 AM
> > > To: edk2-devel@lists.01.org
> > > Cc: Kinney, Michael D; Zhang, Chao B; Gao, Liming
> > > Subject: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for
> > > enable GPT support
> > >
> > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1470
> > > This two new definitions are defined for GPT in FatPei diver.
> > >
> > > Cc: Liming Gao 
> > > Cc: Michael D Kinney 
> > > Cc: Zhang Chao B 
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Chen A Chen 
> > > ---
> > >  MdePkg/Include/Uefi/UefiGpt.h | 16 
> > >  1 file changed, 16 insertions(+)
> > >
> > > diff --git a/MdePkg/Include/Uefi/UefiGpt.h
> > > b/MdePkg/Include/Uefi/UefiGpt.h index f635b05390..8665c8cbc9 100644
> > > --- a/MdePkg/Include/Uefi/UefiGpt.h
> > > +++ b/MdePkg/Include/Uefi/UefiGpt.h
> > > @@ -24,9 +24,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF
> > ANY KIND,
> > > EITHER EXPRESS OR IMPLIED.
> > >  /// EFI Partition Table Signature: "EFI PART".
> > >  ///
> > >  #define EFI_PTAB_HEADER_ID  SIGNATURE_64 ('E','F','I',' 
> > > ','P','A','R','T')
> > > +///
> > > +/// Minimum bytes reserve for EFI entry array buffer.
> > > +///
> > > +#define GPT_PART_ENTRY_MIN_SIZE 16384
> >
> > May I know where this definition comes from?
> > Does it come from the UEFI spec?
> >
> > Chen: The MACRO is not explicitly defined in UEFI Spec, But UEFI Spec
> > specifies a minimum value for GPT entry araray.
> 
> Does it comes from the below content within the UEFI spec?
> 
> > A minimum of 16,384 bytes of space must be reserved for the GPT
> > Partition Entry Array.
> 
> If so, I am not sure whether 'EFI_' prefix should be added before
> 'GPT_PART_ENTRY_MIN_SIZE'.
> 
> Liming, could you help to confirm?
> 
> Chen: I have no strong opinion on ' GPT_PART_ENTRY_MIN_SIZE' and
> 'EFI_GPT_PART_ENTRY_MIN_SIZE'.
> 
> >
> > >
> > >  #pragma pack(1)
> > >
> > > +///
> > > +/// MBR Partition Entry
> > > +///
> > > +typedef struct {
> > > +  UINT8   BootIndicator;
> > > +  UINT8   StartingCHS[3];
> > > +  UINT8   OSType;
> > > +  UINT8   EndingCHS[3];
> > > +  UINT32  StartingLBA;
> > > +  UINT32  SizeInLBA;
> > > +} MBR_PARTITION_ENTRY;
> > > +
> >
> > What about using the 'MBR_PARTITION_RECORD' definition within
> > edk2/MdePkg/Include/IndustryStandard/Mbr.h
> >
> > and thus get rid of adding this one?
> >
> > Chen: This structure defined as the following format in Mbr.h
> >
> > typedef struct {
> >   ..
> >   UINT8 StartingLBA[4];
> >   UINT8 SizeInLBA[4];
> > } MBR_PARTITION_RECORD;
> >
> > For StartingLBA, this field is represented the LBA, so I think it
> > should be
> > UINT32 type not an array type.
> 
> I do not get your point, what prevents you from getting the LBA information
> for the byte array?
> 
> Chen: Yes, GPT DXE driver use UNPACK_UINT32 macro to extract UINT32
>   from array. But I thought use UINT32 type get the value more directly.

I would suggest to use the existing definition and avoid adding a
'duplicated' definition.

Best Regards,
Hao Wu

> 
> Best Regards,
> Hao Wu
> 
> >
> > The same meaning is also for SizeInLba.
> >
> > Best Regards,
> > Hao Wu
> >
> > >  ///
> > >  /// GPT Partition Table Header.
> > >  ///
> > > --
> > > 2.16.2.windows.1
> > >
> > > ___
> > > edk2-devel mailing list
> > > edk2-devel@lists.01.org
> > > https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for enable GPT support

2019-01-24 Thread Chen, Chen A



-Original Message-
From: Wu, Hao A 
Sent: Friday, January 25, 2019 3:27 PM
To: Chen, Chen A ; Gao, Liming ; 
edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Zhang, Chao B 

Subject: RE: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for enable 
GPT support

> -Original Message-
> From: Chen, Chen A
> Sent: Friday, January 25, 2019 3:16 PM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Kinney, Michael D; Zhang, Chao B; Gao, Liming
> Subject: RE: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition 
> for enable GPT support
> 
> 
> 
> -Original Message-
> From: Wu, Hao A
> Sent: Friday, January 25, 2019 11:04 AM
> To: Chen, Chen A ; edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Zhang, Chao B 
> ; Gao, Liming 
> Subject: RE: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition 
> for enable GPT support
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf 
> > Of Chen A Chen
> > Sent: Thursday, January 17, 2019 10:03 AM
> > To: edk2-devel@lists.01.org
> > Cc: Kinney, Michael D; Zhang, Chao B; Gao, Liming
> > Subject: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for 
> > enable GPT support
> >
> > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1470
> > This two new definitions are defined for GPT in FatPei diver.
> >
> > Cc: Liming Gao 
> > Cc: Michael D Kinney 
> > Cc: Zhang Chao B 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Chen A Chen 
> > ---
> >  MdePkg/Include/Uefi/UefiGpt.h | 16 
> >  1 file changed, 16 insertions(+)
> >
> > diff --git a/MdePkg/Include/Uefi/UefiGpt.h 
> > b/MdePkg/Include/Uefi/UefiGpt.h index f635b05390..8665c8cbc9 100644
> > --- a/MdePkg/Include/Uefi/UefiGpt.h
> > +++ b/MdePkg/Include/Uefi/UefiGpt.h
> > @@ -24,9 +24,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF
> ANY KIND,
> > EITHER EXPRESS OR IMPLIED.
> >  /// EFI Partition Table Signature: "EFI PART".
> >  ///
> >  #define EFI_PTAB_HEADER_ID  SIGNATURE_64 ('E','F','I',' 
> > ','P','A','R','T')
> > +///
> > +/// Minimum bytes reserve for EFI entry array buffer.
> > +///
> > +#define GPT_PART_ENTRY_MIN_SIZE 16384
> 
> May I know where this definition comes from?
> Does it come from the UEFI spec?
> 
> Chen: The MACRO is not explicitly defined in UEFI Spec, But UEFI Spec 
> specifies a minimum value for GPT entry araray.

Does it comes from the below content within the UEFI spec?

> A minimum of 16,384 bytes of space must be reserved for the GPT 
> Partition Entry Array.

If so, I am not sure whether 'EFI_' prefix should be added before 
'GPT_PART_ENTRY_MIN_SIZE'.

Liming, could you help to confirm?

Chen: I have no strong opinion on ' GPT_PART_ENTRY_MIN_SIZE' and 
'EFI_GPT_PART_ENTRY_MIN_SIZE'. 

> 
> >
> >  #pragma pack(1)
> >
> > +///
> > +/// MBR Partition Entry
> > +///
> > +typedef struct {
> > +  UINT8   BootIndicator;
> > +  UINT8   StartingCHS[3];
> > +  UINT8   OSType;
> > +  UINT8   EndingCHS[3];
> > +  UINT32  StartingLBA;
> > +  UINT32  SizeInLBA;
> > +} MBR_PARTITION_ENTRY;
> > +
> 
> What about using the 'MBR_PARTITION_RECORD' definition within 
> edk2/MdePkg/Include/IndustryStandard/Mbr.h
> 
> and thus get rid of adding this one?
> 
> Chen: This structure defined as the following format in Mbr.h
> 
> typedef struct {
>   ..
>   UINT8 StartingLBA[4];
>   UINT8 SizeInLBA[4];
> } MBR_PARTITION_RECORD;
> 
> For StartingLBA, this field is represented the LBA, so I think it 
> should be
> UINT32 type not an array type.

I do not get your point, what prevents you from getting the LBA information for 
the byte array?

Chen: Yes, GPT DXE driver use UNPACK_UINT32 macro to extract UINT32 from 
array. But I thought use UINT32 type get the value more directly.

Best Regards,
Hao Wu

> 
> The same meaning is also for SizeInLba.
> 
> Best Regards,
> Hao Wu
> 
> >  ///
> >  /// GPT Partition Table Header.
> >  ///
> > --
> > 2.16.2.windows.1
> >
> > ___
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for enable GPT support

2019-01-24 Thread Wu, Hao A
> -Original Message-
> From: Chen, Chen A
> Sent: Friday, January 25, 2019 3:16 PM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Kinney, Michael D; Zhang, Chao B; Gao, Liming
> Subject: RE: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for
> enable GPT support
> 
> 
> 
> -Original Message-
> From: Wu, Hao A
> Sent: Friday, January 25, 2019 11:04 AM
> To: Chen, Chen A ; edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Zhang, Chao B
> ; Gao, Liming 
> Subject: RE: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for
> enable GPT support
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > Chen A Chen
> > Sent: Thursday, January 17, 2019 10:03 AM
> > To: edk2-devel@lists.01.org
> > Cc: Kinney, Michael D; Zhang, Chao B; Gao, Liming
> > Subject: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for
> > enable GPT support
> >
> > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1470
> > This two new definitions are defined for GPT in FatPei diver.
> >
> > Cc: Liming Gao 
> > Cc: Michael D Kinney 
> > Cc: Zhang Chao B 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Chen A Chen 
> > ---
> >  MdePkg/Include/Uefi/UefiGpt.h | 16 
> >  1 file changed, 16 insertions(+)
> >
> > diff --git a/MdePkg/Include/Uefi/UefiGpt.h
> > b/MdePkg/Include/Uefi/UefiGpt.h index f635b05390..8665c8cbc9 100644
> > --- a/MdePkg/Include/Uefi/UefiGpt.h
> > +++ b/MdePkg/Include/Uefi/UefiGpt.h
> > @@ -24,9 +24,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF
> ANY KIND,
> > EITHER EXPRESS OR IMPLIED.
> >  /// EFI Partition Table Signature: "EFI PART".
> >  ///
> >  #define EFI_PTAB_HEADER_ID  SIGNATURE_64 ('E','F','I',' 
> > ','P','A','R','T')
> > +///
> > +/// Minimum bytes reserve for EFI entry array buffer.
> > +///
> > +#define GPT_PART_ENTRY_MIN_SIZE 16384
> 
> May I know where this definition comes from?
> Does it come from the UEFI spec?
> 
> Chen: The MACRO is not explicitly defined in UEFI Spec, But UEFI Spec
> specifies a minimum value for GPT entry araray.

Does it comes from the below content within the UEFI spec?

> A minimum of 16,384 bytes of space must be reserved for the GPT
> Partition Entry Array.

If so, I am not sure whether 'EFI_' prefix should be added before
'GPT_PART_ENTRY_MIN_SIZE'.

Liming, could you help to confirm?

> 
> >
> >  #pragma pack(1)
> >
> > +///
> > +/// MBR Partition Entry
> > +///
> > +typedef struct {
> > +  UINT8   BootIndicator;
> > +  UINT8   StartingCHS[3];
> > +  UINT8   OSType;
> > +  UINT8   EndingCHS[3];
> > +  UINT32  StartingLBA;
> > +  UINT32  SizeInLBA;
> > +} MBR_PARTITION_ENTRY;
> > +
> 
> What about using the 'MBR_PARTITION_RECORD' definition within
> edk2/MdePkg/Include/IndustryStandard/Mbr.h
> 
> and thus get rid of adding this one?
> 
> Chen: This structure defined as the following format in Mbr.h
> 
> typedef struct {
>   ..
>   UINT8 StartingLBA[4];
>   UINT8 SizeInLBA[4];
> } MBR_PARTITION_RECORD;
> 
> For StartingLBA, this field is represented the LBA, so I think it should be
> UINT32 type not an array type.

I do not get your point, what prevents you from getting the LBA
information for the byte array?

Best Regards,
Hao Wu

> 
> The same meaning is also for SizeInLba.
> 
> Best Regards,
> Hao Wu
> 
> >  ///
> >  /// GPT Partition Table Header.
> >  ///
> > --
> > 2.16.2.windows.1
> >
> > ___
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code logic of parsing parameter.

2019-01-24 Thread Zhang, Chao B
Jiewen & Liming:
   It is a problem. Unlike UiApp. CapsuleApp is supposed to run in Shell.  
ShellLib provides standard parameter parsing support.
Any suggestion on this?

From: Yao, Jiewen
Sent: Friday, January 25, 2019 2:25 PM
To: Chen, Chen A ; edk2-devel@lists.01.org
Cc: Wu, Hao A ; Zhang, Chao B 
Subject: RE: [edk2] [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code logic of 
parsing parameter.

Hey
I don't think MdeModulePkg can depend on ShellPkg.

That is why we do not use ShellLib in the first version.

Do we change the package dependency rule?

Thank you
Yao Jiewen

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Chen A Chen
> Sent: Friday, January 25, 2019 2:14 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A mailto:hao.a...@intel.com>>; Zhang, Chao B
> mailto:chao.b.zh...@intel.com>>
> Subject: [edk2] [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code logic
> of parsing parameter.
>
> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1482
>
> No change functionality, use ShellLib to parsing command line.
>
> Cc: Jian J Wang mailto:jian.j.w...@intel.com>>
> Cc: Hao Wu mailto:hao.a...@intel.com>>
> Cc: Zhang Chao B mailto:chao.b.zh...@intel.com>>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chen A Chen 
> mailto:chen.a.c...@intel.com>>
> ---
>  MdeModulePkg/Application/CapsuleApp/CapsuleApp.c   | 433
> +++--
>  MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf |   2 +
>  2 files changed, 236 insertions(+), 199 deletions(-)
>
> diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> index 4d907242f3..acae0fe261 100644
> --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #define CAPSULE_HEADER_SIZE  0x20
>
> @@ -39,15 +40,27 @@
>
>  #define MAX_CAPSULE_NUM 10
>
> -extern UINTN  Argc;
> -extern CHAR16 **Argv;
> -
>  //
>  // Define how many block descriptors we want to test with.
>  //
>  UINTN  NumberOfDescriptors = 1;
> -UINTN  CapsuleFirstIndex;
> -UINTN  CapsuleLastIndex;
> +
> +STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
> +  {L"-C", TypeFlag},
> +  {L"-E", TypeFlag},
> +  {L"-S", TypeFlag},
> +
> +  {L"-NR", TypeFlag},
> +
> +  {L"-G", TypeValue},
> +  {L"-O", TypeValue},
> +  {L"-N", TypeValue},
> +  {L"-D", TypeValue},
> +  {L"-P", TypeValue},
> +  {L"-I", TypeValue},
> +
> +  {NULL, TypeMax}
> +  };
>
>  /**
>Dump capsule information
> @@ -161,13 +174,12 @@ GetArg (
>  **/
>  EFI_STATUS
>  CreateBmpFmp (
> -  VOID
> +  IN CHAR16 *BmpName,
> +  IN CHAR16
> *OutputCapsuleName
>)
>  {
> -  CHAR16
> *OutputCapsuleName;
>VOID  *BmpBuffer;
>UINTN FileSize;
> -  CHAR16*BmpName;
>UINT8
> *FullCapsuleBuffer;
>UINTN
> FullCapsuleBufferSize;
>EFI_DISPLAY_CAPSULE   *DisplayCapsule;
> @@ -191,22 +203,10 @@ CreateBmpFmp (
>// HorizontalResolution >= BMP_IMAGE_HEADER.PixelWidth
>// VerticalResolution   >= BMP_IMAGE_HEADER.PixelHeight
>
> -  if (Argc != 5) {
> -Print(L"CapsuleApp: Incorrect parameter count.\n");
> -return EFI_UNSUPPORTED;
> -  }
> -
> -  if (StrCmp(Argv[3], L"-O") != 0) {
> -Print(L"CapsuleApp: NO output capsule name.\n");
> -return EFI_UNSUPPORTED;
> -  }
> -  OutputCapsuleName = Argv[4];
> -
>BmpBuffer = NULL;
>FileSize = 0;
>FullCapsuleBuffer = NULL;
>
> -  BmpName = Argv[2];
>Status = ReadFileToBuffer(BmpName, &FileSize, &BmpBuffer);
>if (EFI_ERROR(Status)) {
>  Print(L"CapsuleApp: BMP image (%s) is not found.\n", BmpName);
> @@ -425,13 +425,12 @@ IsFmpCapsuleGuid (
>  **/
>  EFI_STATUS
>  CreateNestedFmp (
> -  VOID
> +  IN CHAR16 *CapsuleName,
> +  IN CHAR16
> *OutputCapsuleName
>)
>  {
> -  CHAR16
> *OutputCapsuleName;
>VOID  *CapsuleBuffer;
>UINTN FileSize;
> -  CHAR16*CapsuleName;
>UINT8
> *FullCapsuleBuffer;
>UINTN
> FullCapsuleBufferSize;
>EFI_CAPSULE_HEADER
> *NestedCapsuleHeader;
> @@ -439,22 +438,10 @@ CreateNestedFmp (
>UINT32FwType;
>EFI_STATUSStatus;
>
> -  if (Argc != 5) {
> -Print(L"CapsuleApp: Incorrect parameter count.\n");
> -return EFI_UNSUPPORTED;
> -  }
> -
> -  if (StrCmp(Argv[3], L"-O") != 0) {
> -Print(L"CapsuleApp: NO output capsule name.\n");
> -return EFI_UNSUPPORTED;
> -  }
> -  OutputCapsuleName = Argv[4];
> -
>CapsuleBuffer = NULL;
>FileSize = 0;
>FullCapsuleBuffer = NULL;
>
> -  CapsuleName =

Re: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for enable GPT support

2019-01-24 Thread Chen, Chen A



-Original Message-
From: Wu, Hao A 
Sent: Friday, January 25, 2019 11:04 AM
To: Chen, Chen A ; edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Zhang, Chao B 
; Gao, Liming 
Subject: RE: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for enable 
GPT support

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Chen A Chen
> Sent: Thursday, January 17, 2019 10:03 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D; Zhang, Chao B; Gao, Liming
> Subject: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for 
> enable GPT support
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1470
> This two new definitions are defined for GPT in FatPei diver.
> 
> Cc: Liming Gao 
> Cc: Michael D Kinney 
> Cc: Zhang Chao B 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chen A Chen 
> ---
>  MdePkg/Include/Uefi/UefiGpt.h | 16 
>  1 file changed, 16 insertions(+)
> 
> diff --git a/MdePkg/Include/Uefi/UefiGpt.h 
> b/MdePkg/Include/Uefi/UefiGpt.h index f635b05390..8665c8cbc9 100644
> --- a/MdePkg/Include/Uefi/UefiGpt.h
> +++ b/MdePkg/Include/Uefi/UefiGpt.h
> @@ -24,9 +24,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, 
> EITHER EXPRESS OR IMPLIED.
>  /// EFI Partition Table Signature: "EFI PART".
>  ///
>  #define EFI_PTAB_HEADER_ID  SIGNATURE_64 ('E','F','I',' 
> ','P','A','R','T')
> +///
> +/// Minimum bytes reserve for EFI entry array buffer.
> +///
> +#define GPT_PART_ENTRY_MIN_SIZE 16384

May I know where this definition comes from?
Does it come from the UEFI spec?

Chen: The MACRO is not explicitly defined in UEFI Spec, But UEFI Spec specifies 
a minimum value for GPT entry araray.

> 
>  #pragma pack(1)
> 
> +///
> +/// MBR Partition Entry
> +///
> +typedef struct {
> +  UINT8   BootIndicator;
> +  UINT8   StartingCHS[3];
> +  UINT8   OSType;
> +  UINT8   EndingCHS[3];
> +  UINT32  StartingLBA;
> +  UINT32  SizeInLBA;
> +} MBR_PARTITION_ENTRY;
> +

What about using the 'MBR_PARTITION_RECORD' definition within 
edk2/MdePkg/Include/IndustryStandard/Mbr.h

and thus get rid of adding this one?

Chen: This structure defined as the following format in Mbr.h

typedef struct {
  ..
  UINT8 StartingLBA[4];
  UINT8 SizeInLBA[4];
} MBR_PARTITION_RECORD;

For StartingLBA, this field is represented the LBA, so I think it should be 
UINT32 type not an array type.

The same meaning is also for SizeInLba.

Best Regards,
Hao Wu

>  ///
>  /// GPT Partition Table Header.
>  ///
> --
> 2.16.2.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms] Platform/ARM/SgiPkg: Include HobLib, MmServicesTableLib and MemoryAllocationLib

2019-01-24 Thread Jagadeesh Ujja
Include the HobLib, MmServicesTableLib and MemoryAllocationLib libraries on
Sgi platforms. These will be consumed by MM_STANDALONE drivers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jagadeesh Ujja 
---
 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc 
b/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
index 2a17e9f..65dd6ac 100644
--- a/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
+++ b/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
@@ -71,6 +71,11 @@
 
   
StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
 
+[LibraryClasses.common.MM_STANDALONE]
+  HobLib|StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
+  
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
+  
MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
+
 

 #
 # Pcd Section - list of all EDK II PCD Entries defined by this Platform
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code logic of parsing parameter.

2019-01-24 Thread Yao, Jiewen
Hey
I don't think MdeModulePkg can depend on ShellPkg.

That is why we do not use ShellLib in the first version.

Do we change the package dependency rule?

Thank you
Yao Jiewen

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Chen A Chen
> Sent: Friday, January 25, 2019 2:14 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Zhang, Chao B
> 
> Subject: [edk2] [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code logic
> of parsing parameter.
> 
> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1482
> 
> No change functionality, use ShellLib to parsing command line.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Zhang Chao B 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chen A Chen 
> ---
>  MdeModulePkg/Application/CapsuleApp/CapsuleApp.c   | 433
> +++--
>  MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf |   2 +
>  2 files changed, 236 insertions(+), 199 deletions(-)
> 
> diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> index 4d907242f3..acae0fe261 100644
> --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  #define CAPSULE_HEADER_SIZE  0x20
> 
> @@ -39,15 +40,27 @@
> 
>  #define MAX_CAPSULE_NUM 10
> 
> -extern UINTN  Argc;
> -extern CHAR16 **Argv;
> -
>  //
>  // Define how many block descriptors we want to test with.
>  //
>  UINTN  NumberOfDescriptors = 1;
> -UINTN  CapsuleFirstIndex;
> -UINTN  CapsuleLastIndex;
> +
> +STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
> +  {L"-C", TypeFlag},
> +  {L"-E", TypeFlag},
> +  {L"-S", TypeFlag},
> +
> +  {L"-NR", TypeFlag},
> +
> +  {L"-G", TypeValue},
> +  {L"-O", TypeValue},
> +  {L"-N", TypeValue},
> +  {L"-D", TypeValue},
> +  {L"-P", TypeValue},
> +  {L"-I", TypeValue},
> +
> +  {NULL, TypeMax}
> +  };
> 
>  /**
>Dump capsule information
> @@ -161,13 +174,12 @@ GetArg (
>  **/
>  EFI_STATUS
>  CreateBmpFmp (
> -  VOID
> +  IN CHAR16 *BmpName,
> +  IN CHAR16
> *OutputCapsuleName
>)
>  {
> -  CHAR16
> *OutputCapsuleName;
>VOID  *BmpBuffer;
>UINTN FileSize;
> -  CHAR16*BmpName;
>UINT8
> *FullCapsuleBuffer;
>UINTN
> FullCapsuleBufferSize;
>EFI_DISPLAY_CAPSULE   *DisplayCapsule;
> @@ -191,22 +203,10 @@ CreateBmpFmp (
>// HorizontalResolution >= BMP_IMAGE_HEADER.PixelWidth
>// VerticalResolution   >= BMP_IMAGE_HEADER.PixelHeight
> 
> -  if (Argc != 5) {
> -Print(L"CapsuleApp: Incorrect parameter count.\n");
> -return EFI_UNSUPPORTED;
> -  }
> -
> -  if (StrCmp(Argv[3], L"-O") != 0) {
> -Print(L"CapsuleApp: NO output capsule name.\n");
> -return EFI_UNSUPPORTED;
> -  }
> -  OutputCapsuleName = Argv[4];
> -
>BmpBuffer = NULL;
>FileSize = 0;
>FullCapsuleBuffer = NULL;
> 
> -  BmpName = Argv[2];
>Status = ReadFileToBuffer(BmpName, &FileSize, &BmpBuffer);
>if (EFI_ERROR(Status)) {
>  Print(L"CapsuleApp: BMP image (%s) is not found.\n", BmpName);
> @@ -425,13 +425,12 @@ IsFmpCapsuleGuid (
>  **/
>  EFI_STATUS
>  CreateNestedFmp (
> -  VOID
> +  IN CHAR16 *CapsuleName,
> +  IN CHAR16
> *OutputCapsuleName
>)
>  {
> -  CHAR16
> *OutputCapsuleName;
>VOID  *CapsuleBuffer;
>UINTN FileSize;
> -  CHAR16*CapsuleName;
>UINT8
> *FullCapsuleBuffer;
>UINTN
> FullCapsuleBufferSize;
>EFI_CAPSULE_HEADER
> *NestedCapsuleHeader;
> @@ -439,22 +438,10 @@ CreateNestedFmp (
>UINT32FwType;
>EFI_STATUSStatus;
> 
> -  if (Argc != 5) {
> -Print(L"CapsuleApp: Incorrect parameter count.\n");
> -return EFI_UNSUPPORTED;
> -  }
> -
> -  if (StrCmp(Argv[3], L"-O") != 0) {
> -Print(L"CapsuleApp: NO output capsule name.\n");
> -return EFI_UNSUPPORTED;
> -  }
> -  OutputCapsuleName = Argv[4];
> -
>CapsuleBuffer = NULL;
>FileSize = 0;
>FullCapsuleBuffer = NULL;
> 
> -  CapsuleName = Argv[2];
>Status = ReadFileToBuffer(CapsuleName, &FileSize, &CapsuleBuffer);
>if (EFI_ERROR(Status)) {
>  Print(L"CapsuleApp: Capsule image (%s) is not found.\n",
> CapsuleName);
> @@ -807,7 +794,7 @@ PrintUsage (
>Print(L"  CapsuleApp -G  -O \n");
>Print(L"  CapsuleApp -N  -O \n");
>Print(L"  CapsuleApp -D \n");
> -  Print(L"  CapsuleApp -P GET   -O \n");
> +  Print(L"  CapsuleApp -P  -I  -O \n");
>Print(L"Parameter:\n");
>Print(L"  -NR: No reset will be triggered for the capsule with\n");
>Print(L"   CAPSULE_FLAGS_PERSIST_ACROSS_RESET and
> without\n"

[edk2] [PATCH 3/3] MdeModulePkg/CapsuleApp: Enhance CapsuleApp to support Capsule-on-Disk.

2019-01-24 Thread Chen A Chen
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1482

CapsuleApp is used for trigger capsule update.
Add -OD option in CapsuleApp to support doing capsule update via storage.
Add -F and -L options to support dumping information feature.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Zhang Chao B 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen 
---
 MdeModulePkg/Application/CapsuleApp/CapsuleApp.c   | 103 ++-
 MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf |   8 +
 MdeModulePkg/Application/CapsuleApp/CapsuleDump.c  | 535 +-
 .../Application/CapsuleApp/CapsuleOnDisk.c | 802 +
 MdeModulePkg/Include/Library/UefiBootManagerLib.h  |  19 +
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   |  23 +
 6 files changed, 1487 insertions(+), 3 deletions(-)
 create mode 100644 MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c

diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c 
b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
index acae0fe261..522ba40311 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -48,6 +49,7 @@ UINTN  NumberOfDescriptors = 1;
 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {L"-C", TypeFlag},
   {L"-E", TypeFlag},
+  {L"-F", TypeFlag},
   {L"-S", TypeFlag},
 
   {L"-NR", TypeFlag},
@@ -58,6 +60,9 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {L"-D", TypeValue},
   {L"-P", TypeValue},
   {L"-I", TypeValue},
+  {L"-L", TypeValue},
+
+  {L"-OD", TypeValue},
 
   {NULL, TypeMax}
   };
@@ -118,6 +123,44 @@ DumpEsrtData (
   VOID
   );
 
+/**
+  Dump Provisioned Capsule.
+
+  @param[in]  DumpCapsuleInfo  The flag to indicate whether to dump the 
capsule inforomation.
+**/
+VOID
+DumpProvisionedCapsule (
+  IN BOOLEAN  DumpCapsuleInfo
+  );
+
+/**
+  Dump all EFI System Parition.
+**/
+VOID
+DumpAllEfiSysPartition (
+  VOID
+  );
+
+/**
+  Process Capsule On Disk.
+
+  @param[in]  CapsuleBufferAn array of pointer to capsule images
+  @param[in]  FileSize An array of UINTN to capsule images size
+  @param[in]  OrgFileName  An array of orginal capsule images name
+  @param[in]  NewFileName  An array of new capsule images name
+  @param[in]  CapsuleNum   The count of capsule images
+
+  @retval EFI_SUCCESS   Capsule on disk secceed.
+**/
+EFI_STATUS
+ProcessCapsuleOnDisk (
+  IN VOID  **CapsuleBuffer,
+  IN UINTN *CapsuleBufferSize,
+  IN CHAR16*Map,
+  IN CHAR16**OutputCapsuleNames,
+  IN UINTN CapsuleNum
+  );
+
 /**
   Read a file.
 
@@ -786,11 +829,14 @@ PrintUsage (
   )
 {
   Print(L"CapsuleApp:  usage\n");
-  Print(L"  CapsuleApp  [-NR]\n");
+  Print(L"  CapsuleApp  [-NR] [-OD [FS]]\n");
   Print(L"  CapsuleApp -S\n");
   Print(L"  CapsuleApp -C\n");
   Print(L"  CapsuleApp -P\n");
   Print(L"  CapsuleApp -E\n");
+  Print(L"  CapsuleApp -L\n");
+  Print(L"  CapsuleApp -L INFO\n");
+  Print(L"  CapsuleApp -F\n");
   Print(L"  CapsuleApp -G  -O \n");
   Print(L"  CapsuleApp -N  -O \n");
   Print(L"  CapsuleApp -D \n");
@@ -806,6 +852,8 @@ PrintUsage (
   Print(L"  -P:  Dump UEFI FMP protocol info, or get image with specified\n");
   Print(L"   ImageTypeId and Index (decimal format) to a file\n");
   Print(L"  -E:  Dump UEFI ESRT table info.\n");
+  Print(L"  -L:  Dump provisioned capsule image information.\n");
+  Print(L"  -F:  Dump all EFI System Partition.\n");
   Print(L"  -G:  Convert a BMP file to be an UX capsule,\n");
   Print(L"   according to Windows Firmware Update document\n");
   Print(L"  -N:  Append a Capsule Header to an existing FMP capsule image\n");
@@ -815,6 +863,7 @@ PrintUsage (
   Print(L"  -D:  Dump Capsule image header information, image payload\n");
   Print(L"   information if it is an UX capsule and FMP header\n");
   Print(L"   information if it is a FMP capsule.\n");
+  Print(L"  -OD: Do update capsule via storage.\n");
 }
 
 /**
@@ -846,12 +895,16 @@ UefiMain (
   CHAR16*ProblemParam;
   CHAR16*BmpFileName;
   CHAR16*CapsuleFileName;
+  CHAR16*CapsuleFileNames[MAX_CAPSULE_NUM];
   CHAR16*OutputFileName;
   CHAR16*GuidStr;
   CHAR16*IndexStr;
+  CHAR16*DumpInfoStr;
+  CHAR16*FsMapStr;
   EFI_GUID  ImageTypeGuid;  
   BOOLEAN   NoResetFlag;
   BOOLEAN   NeedReset;
+  BOOLEAN   CapsuleOnDisk;
   UINTN CapsuleBufferSize[MAX_CAPSULE_NUM];
   UINTN CapsuleNum;
   UINTN ImageIndex;
@@ 

[edk2] [PATCH 2/3] MdePkg/UefiSpec.h: Add definition to support Capsule-on-Disk feature.

2019-01-24 Thread Chen A Chen
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1482

UEFI Spec define this definition to support Capsule-on-Disk.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhang Chao B 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen 
---
 MdePkg/Include/Uefi/UefiSpec.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h
index 75af99de50..9d3d7a9a63 100644
--- a/MdePkg/Include/Uefi/UefiSpec.h
+++ b/MdePkg/Include/Uefi/UefiSpec.h
@@ -2201,6 +2201,11 @@ typedef struct {
   #error Unknown Processor Type
 #endif
 
+//
+// The directory within the active EFI System Partition defined for delivery 
of capsule to firmware
+//
+#define EFI_CAPSULE_FROM_FILE_DIRL"\\EFI\\UpdateCapsule\\"
+
 #include 
 #include 
 #include 
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code logic of parsing parameter.

2019-01-24 Thread Chen A Chen
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1482

No change functionality, use ShellLib to parsing command line.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Zhang Chao B 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen 
---
 MdeModulePkg/Application/CapsuleApp/CapsuleApp.c   | 433 +++--
 MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf |   2 +
 2 files changed, 236 insertions(+), 199 deletions(-)

diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c 
b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
index 4d907242f3..acae0fe261 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define CAPSULE_HEADER_SIZE  0x20
 
@@ -39,15 +40,27 @@
 
 #define MAX_CAPSULE_NUM 10
 
-extern UINTN  Argc;
-extern CHAR16 **Argv;
-
 //
 // Define how many block descriptors we want to test with.
 //
 UINTN  NumberOfDescriptors = 1;
-UINTN  CapsuleFirstIndex;
-UINTN  CapsuleLastIndex;
+
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+  {L"-C", TypeFlag},
+  {L"-E", TypeFlag},
+  {L"-S", TypeFlag},
+
+  {L"-NR", TypeFlag},
+
+  {L"-G", TypeValue},
+  {L"-O", TypeValue},
+  {L"-N", TypeValue},
+  {L"-D", TypeValue},
+  {L"-P", TypeValue},
+  {L"-I", TypeValue},
+
+  {NULL, TypeMax}
+  };
 
 /**
   Dump capsule information
@@ -161,13 +174,12 @@ GetArg (
 **/
 EFI_STATUS
 CreateBmpFmp (
-  VOID
+  IN CHAR16 *BmpName,
+  IN CHAR16 *OutputCapsuleName
   )
 {
-  CHAR16*OutputCapsuleName;
   VOID  *BmpBuffer;
   UINTN FileSize;
-  CHAR16*BmpName;
   UINT8 *FullCapsuleBuffer;
   UINTN FullCapsuleBufferSize;
   EFI_DISPLAY_CAPSULE   *DisplayCapsule;
@@ -191,22 +203,10 @@ CreateBmpFmp (
   // HorizontalResolution >= BMP_IMAGE_HEADER.PixelWidth
   // VerticalResolution   >= BMP_IMAGE_HEADER.PixelHeight
 
-  if (Argc != 5) {
-Print(L"CapsuleApp: Incorrect parameter count.\n");
-return EFI_UNSUPPORTED;
-  }
-
-  if (StrCmp(Argv[3], L"-O") != 0) {
-Print(L"CapsuleApp: NO output capsule name.\n");
-return EFI_UNSUPPORTED;
-  }
-  OutputCapsuleName = Argv[4];
-
   BmpBuffer = NULL;
   FileSize = 0;
   FullCapsuleBuffer = NULL;
 
-  BmpName = Argv[2];
   Status = ReadFileToBuffer(BmpName, &FileSize, &BmpBuffer);
   if (EFI_ERROR(Status)) {
 Print(L"CapsuleApp: BMP image (%s) is not found.\n", BmpName);
@@ -425,13 +425,12 @@ IsFmpCapsuleGuid (
 **/
 EFI_STATUS
 CreateNestedFmp (
-  VOID
+  IN CHAR16 *CapsuleName,
+  IN CHAR16 *OutputCapsuleName
   )
 {
-  CHAR16*OutputCapsuleName;
   VOID  *CapsuleBuffer;
   UINTN FileSize;
-  CHAR16*CapsuleName;
   UINT8 *FullCapsuleBuffer;
   UINTN FullCapsuleBufferSize;
   EFI_CAPSULE_HEADER*NestedCapsuleHeader;
@@ -439,22 +438,10 @@ CreateNestedFmp (
   UINT32FwType;
   EFI_STATUSStatus;
 
-  if (Argc != 5) {
-Print(L"CapsuleApp: Incorrect parameter count.\n");
-return EFI_UNSUPPORTED;
-  }
-
-  if (StrCmp(Argv[3], L"-O") != 0) {
-Print(L"CapsuleApp: NO output capsule name.\n");
-return EFI_UNSUPPORTED;
-  }
-  OutputCapsuleName = Argv[4];
-
   CapsuleBuffer = NULL;
   FileSize = 0;
   FullCapsuleBuffer = NULL;
 
-  CapsuleName = Argv[2];
   Status = ReadFileToBuffer(CapsuleName, &FileSize, &CapsuleBuffer);
   if (EFI_ERROR(Status)) {
 Print(L"CapsuleApp: Capsule image (%s) is not found.\n", CapsuleName);
@@ -807,7 +794,7 @@ PrintUsage (
   Print(L"  CapsuleApp -G  -O \n");
   Print(L"  CapsuleApp -N  -O \n");
   Print(L"  CapsuleApp -D \n");
-  Print(L"  CapsuleApp -P GET   -O \n");
+  Print(L"  CapsuleApp -P  -I  -O \n");
   Print(L"Parameter:\n");
   Print(L"  -NR: No reset will be triggered for the capsule with\n");
   Print(L"   CAPSULE_FLAGS_PERSIST_ACROSS_RESET and without\n");
@@ -817,8 +804,7 @@ PrintUsage (
   Print(L"  -C:  Clear capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");
   Print(L"   which is defined in UEFI specification.\n");
   Print(L"  -P:  Dump UEFI FMP protocol info, or get image with specified\n");
-  Print(L"   ImageTypeId and Index (decimal format) to a file if 'GET'\n");
-  Print(L"   option is used.\n");
+  Print(L"   ImageTypeId and Index (decimal format) to a file\n");
   Print(L"  -E:  Dum

Re: [edk2] [PATCH] ShellPkg/TftpDynamicCommand: Return proper status

2019-01-24 Thread Li, Songpeng
Reviewed-by: Songpeng Li 

Sorry, the previous email did not include edk2 mailing list.

Best,
Songpeng


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Vladimir Olovyannikov via edk2-devel
> Sent: Thursday, January 24, 2019 2:26 AM
> To: Carsey, Jaben ; Ni, Ray ;
> edk2-devel@lists.01.org
> Cc: Vladimir Olovyannikov 
> Subject: [edk2] [PATCH] ShellPkg/TftpDynamicCommand: Return proper
> status
> 
> Tftp command always returned "SHELL_NOT_FOUND" which is treated as an
> error by callers. Add missing line to clean the ShellStatus on
> successful operation. If operation has failed, return the error status
> if available.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vladimir Olovyannikov
> 
> ---
>  ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
> b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
> index ba753a279b00..88e3988a554e 100644
> --- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
> +++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
> @@ -548,6 +548,8 @@ RunTftp (
>goto NextHandle;
>  }
> 
> +ShellStatus = SHELL_SUCCESS;
> +
>  NextHandle:
> 
>  CloseProtocolAndDestroyServiceChild (
> @@ -575,6 +577,10 @@ RunTftp (
>  FreePool (Handles);
>}
> 
> +  if ((ShellStatus != SHELL_SUCCESS) && (EFI_ERROR(Status))) {
> +ShellStatus = Status & ~MAX_BIT;
> +  }
> +
>return ShellStatus;
>  }
> 
> --
> 2.20.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 1/2] FatPkg: Break down Part.c file.

2019-01-24 Thread Wu, Hao A
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Chen A Chen
> Sent: Thursday, January 17, 2019 10:03 AM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ray; Zhang, Chao B
> Subject: [edk2] [PATCH 1/2] FatPkg: Break down Part.c file.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1470
> Break down partition parsing logic to 2 parts, Eltorito and MBR.
> 
> Cc: Ruiyu Ni 
> Cc: Zhang Chao B 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chen A Chen 
> ---
>  FatPkg/FatPei/Eltorito.c | 239 +
>  FatPkg/FatPei/FatPei.inf |   2 +
>  FatPkg/FatPei/Mbr.c  | 182 ++
>  FatPkg/FatPei/Part.c | 385 
> +--
>  4 files changed, 424 insertions(+), 384 deletions(-)
>  create mode 100644 FatPkg/FatPei/Eltorito.c
>  create mode 100644 FatPkg/FatPei/Mbr.c
> 
> diff --git a/FatPkg/FatPei/Eltorito.c b/FatPkg/FatPei/Eltorito.c
> new file mode 100644
> index 00..ffaef51860
> --- /dev/null
> +++ b/FatPkg/FatPei/Eltorito.c
> @@ -0,0 +1,239 @@
> +/** @file
> +  Routines supporting partition discovery and
> +  logical device reading
> +
> +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> +
> +This program and the accompanying materials are licensed and made
> available
> +under the terms and conditions of the BSD License which accompanies this
> +distribution. The full text of the license may be found at
> +http://opensource.org/licenses/bsd-license.php
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include 
> +#include "FatLitePeim.h"
> +
> +/**
> +  This function finds Eltorito partitions. Main algorithm
> +  is ported from DXE partition driver.
> +
> +  @param  PrivateData   The global memory map
> +  @param  ParentBlockDevNo  The parent block device
> +
> +  @retval TRUE  New partitions are detected and logical block 
> devices
> +are  added to block device array
> +  @retval FALSE No New partitions are added;
> +
> +**/
> +BOOLEAN
> +FatFindEltoritoPartitions (
> +  IN  PEI_FAT_PRIVATE_DATA *PrivateData,
> +  IN  UINTNParentBlockDevNo
> +  )
> +{
> +  EFI_STATUS  Status;
> +  BOOLEAN Found;
> +  PEI_FAT_BLOCK_DEVICE*BlockDev;
> +  PEI_FAT_BLOCK_DEVICE*ParentBlockDev;
> +  UINT32  VolDescriptorLba;
> +  UINT32  Lba;
> +  CDROM_VOLUME_DESCRIPTOR *VolDescriptor;
> +  ELTORITO_CATALOG*Catalog;
> +  UINTN   Check;
> +  UINTN   Index;
> +  UINTN   MaxIndex;
> +  UINT16  *CheckBuffer;
> +  UINT32  SubBlockSize;
> +  UINT32  SectorCount;
> +  UINT32  VolSpaceSize;
> +
> +  if (ParentBlockDevNo > PEI_FAT_MAX_BLOCK_DEVICE - 1) {
> +return FALSE;
> +  }
> +
> +  Found   = FALSE;
> +  ParentBlockDev  = &(PrivateData->BlockDevice[ParentBlockDevNo]);
> +  VolSpaceSize= 0;
> +
> +  //
> +  // CD_ROM has the fixed block size as 2048 bytes
> +  //
> +  if (ParentBlockDev->BlockSize != 2048) {
> +return FALSE;
> +  }
> +
> +  VolDescriptor = (CDROM_VOLUME_DESCRIPTOR *) PrivateData-
> >BlockData;
> +  Catalog   = (ELTORITO_CATALOG *) VolDescriptor;
> +
> +  //
> +  // the ISO-9660 volume descriptor starts at 32k on the media
> +  // and CD_ROM has the fixed block size as 2048 bytes, so...
> +  //
> +  VolDescriptorLba = 15;
> +  //
> +  // ((16*2048) / Media->BlockSize) - 1;
> +  //
> +  // Loop: handle one volume descriptor per time
> +  //
> +  while (TRUE) {
> +
> +VolDescriptorLba += 1;
> +if (VolDescriptorLba > ParentBlockDev->LastBlock) {
> +  //
> +  // We are pointing past the end of the device so exit
> +  //
> +  break;
> +}
> +
> +Status = FatReadBlock (
> +  PrivateData,
> +  ParentBlockDevNo,
> +  VolDescriptorLba,
> +  ParentBlockDev->BlockSize,
> +  VolDescriptor
> +  );
> +if (EFI_ERROR (Status)) {
> +  break;
> +}
> +//
> +// Check for valid volume descriptor signature
> +//
> +if (VolDescriptor->Unknown.Type == CDVOL_TYPE_END ||
> +CompareMem (VolDescriptor->Unknown.Id, CDVOL_ID, sizeof
> (VolDescriptor->Unknown.Id)) != 0
> +) {
> +  //
> +  // end of Volume descriptor list
> +  //
> +  break;
> +}
> +//
> +// Read the Volume Space Size from Primary Volume Descriptor 81-88
> byte
> +//
> +if (VolDescriptor->Unknown.Type == CDVOL_TYPE_CODED) {
> +  VolSpaceSize = VolDescriptor->PrimaryVolume.VolSpaceSize[1];
> +}
> +//
> +// Is it an El Torito volume descriptor?
> +//
> +if (CompareMem (
> +  VolDescri

[edk2] [Patch 31/33] BaseTools: Handle the bytes and str difference

2019-01-24 Thread Feng, Bob C
Deal with bytes and str is different, remove the unicode(),
correct open file parameter.
Using utcfromtimestamp instead of fromtimestamp.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 42 
--
 BaseTools/Source/Python/AutoGen/GenC.py|  6 
+++---
 BaseTools/Source/Python/AutoGen/GenMake.py | 14 
+-
 BaseTools/Source/Python/AutoGen/GenPcdDb.py| 29 
+++--
 BaseTools/Source/Python/AutoGen/GenVar.py  | 34 
++
 BaseTools/Source/Python/AutoGen/InfSectionParser.py|  2 +-
 BaseTools/Source/Python/AutoGen/StrGather.py   |  5 
-
 BaseTools/Source/Python/AutoGen/UniClassObject.py  |  4 
++--
 BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py |  2 +-
 BaseTools/Source/Python/BPDG/GenVpd.py |  8 

 BaseTools/Source/Python/Common/LongFilePathOs.py   |  3 +--
 BaseTools/Source/Python/Common/LongFilePathSupport.py  | 12 

 BaseTools/Source/Python/Common/Misc.py | 48 

 BaseTools/Source/Python/Common/StringUtils.py  | 10 
++
 BaseTools/Source/Python/Common/VpdInfoFile.py  | 10 
+-
 BaseTools/Source/Python/GenFds/AprioriSection.py   |  2 +-
 BaseTools/Source/Python/GenFds/Capsule.py  | 15 
+++
 BaseTools/Source/Python/GenFds/CapsuleData.py  |  2 +-
 BaseTools/Source/Python/GenFds/Fd.py   |  4 
++--
 BaseTools/Source/Python/GenFds/FdfParser.py|  4 
++--
 BaseTools/Source/Python/GenFds/FfsFileStatement.py | 16 

 BaseTools/Source/Python/GenFds/FfsInfStatement.py  | 12 
+---
 BaseTools/Source/Python/GenFds/Fv.py   | 48 

 BaseTools/Source/Python/GenFds/FvImageSection.py   |  2 +-
 BaseTools/Source/Python/GenFds/GenFds.py   | 22 
+++---
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  4 
++--
 BaseTools/Source/Python/GenFds/Region.py   |  6 
+++---
 BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py |  2 +-
 BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py | 14 
+++---
 BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py |  7 
---
 BaseTools/Source/Python/Trim/Trim.py   | 18 
--
 BaseTools/Source/Python/UPT/Library/StringUtils.py |  4 
+---
 BaseTools/Source/Python/Workspace/BuildClassObject.py  |  4 
++--
 BaseTools/Source/Python/Workspace/DscBuildData.py  | 13 
++---
 BaseTools/Source/Python/Workspace/MetaFileParser.py|  4 
++--
 BaseTools/Source/Python/build/BuildReport.py   | 15 
+++
 BaseTools/Source/Python/build/build.py | 44 
+---
 37 files changed, 247 insertions(+), 244 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index baa1842667..a95d2c710e 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -724,15 +724,15 @@ class WorkspaceAutoGen(AutoGen):
 if GlobalData.gUseHashCache:
 m = hashlib.md5()
 for files in AllWorkSpaceMetaFiles:
 if files.endswith('.dec'):
 continue
-f = open(files, 'r')
+f = open(files, 'rb')
 Content = f.read()
 f.close()
 m.update(Content)
-SaveFileOnChange(os.path.join(self.BuildDir, 'AutoGen.hash'), 
m.hexdigest(), True)
+SaveFileOnChange(os.path.join(self.BuildDir, 'AutoGen.hash'), 
m.hexdigest(), False)
 GlobalData.gPlatformHash = m.hexdigest()
 
 #
 # Write metafile list to build directory
 #
@@ -753,25 +753,25 @@ class WorkspaceAutoGen(AutoGen):
 PkgDir = os.path.join(self.BuildDir, Pkg.Arch, Pkg.PackageName)
 CreateDirectory(PkgDir)
 HashFile = os.path.join(PkgDir, Pkg.PackageName + '.hash')
 m = hashlib.md5()
 # Get .dec file's

[edk2] [Patch 18/33] BaseTools:TestTools character encoding issue

2019-01-24 Thread Feng, Bob C
From: Zhiju Fan 

Specifies encoding when opening a file using codecs

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Tests/TestTools.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py
index 4332dcdaac..ace92992fc 100644
--- a/BaseTools/Tests/TestTools.py
+++ b/BaseTools/Tests/TestTools.py
@@ -22,10 +22,11 @@ import os.path
 import random
 import shutil
 import subprocess
 import sys
 import unittest
+import codecs
 
 TestsDir = os.path.realpath(os.path.split(sys.argv[0])[0])
 BaseToolsDir = os.path.realpath(os.path.join(TestsDir, '..'))
 CSourceDir = os.path.join(BaseToolsDir, 'Source', 'C')
 PythonSourceDir = os.path.join(BaseToolsDir, 'Source', 'Python')
@@ -148,11 +149,11 @@ class BaseToolsTest(unittest.TestCase):
 def WriteTmpFile(self, fileName, data):
 if isinstance(data, bytes):
 with open(self.GetTmpFilePath(fileName), 'wb') as f:
 f.write(data)
 else:
-with open(self.GetTmpFilePath(fileName), 'w') as f:
+with codecs.open(self.GetTmpFilePath(fileName), 'w', 
encoding='utf-8') as f:
 f.write(data)
 
 def GenRandomFileData(self, fileName, minlen = None, maxlen = None):
 if maxlen is None: maxlen = minlen
 f = self.OpenTmpFile(fileName, 'w')
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 26/33] BaseTools:Linux Python highest version check.

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

Linux Python highest version check.
The path of Python interpreter assign values to PYTHON_COMMAND

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 edksetup.sh | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/edksetup.sh b/edksetup.sh
index 06f95f4b9c..bfa54ddf70 100755
--- a/edksetup.sh
+++ b/edksetup.sh
@@ -113,15 +113,18 @@ function SetupEnv()
 
 function SetupPython()
 {
   if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ]
   then
-for python in $(which python3)
+if [ $origin_version ];then
+  origin_version=
+fi
+for python in $(whereis python3)
 do
   python=$(echo $python | grep "[[:digit:]]$" || true)
   python_version=${python##*python}
-  if [ -z "${python_version}" ];then
+  if [ -z "${python_version}" ] || (! command -v $python >/dev/null 
2>&1);then
 continue
   fi
   if [ -z $origin_version ];then
 origin_version=$python_version
 export PYTHON=$python
@@ -135,18 +138,21 @@ function SetupPython()
 done
   fi
   
   if [ -z $PYTHON3_ENABLE ] || [ $PYTHON3_ENABLE != TRUE ]
   then
-for python in $(which python2)
+if [ $origin_version ];then
+  origin_version=
+fi
+for python in $(whereis python2)
 do
   python=$(echo $python | grep "[[:digit:]]$" || true)
   python_version=${python##*python}
-  if [ -z "${python_version}" ];then
+  if [ -z "${python_version}" ] || (! command -v $python >/dev/null 
2>&1);then
 continue
   fi
-  if [ -z $origin_version ] || [ $origin_version -ge 3 ]
+  if [ -z $origin_version ]
   then
 origin_version=$python_version
 export PYTHON=$python
 continue
   fi
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 17/33] BaseTools: Make sure AllPcdList valid.

2019-01-24 Thread Feng, Bob C
This patch is to make sure the AllPcdList is always evaluated.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 00ed804e62..f9ce17cf77 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1142,11 +1142,10 @@ class PlatformAutoGen(AutoGen):
 self.Arch = Arch
 self.SourceDir = PlatformFile.SubDir
 self.SourceOverrideDir = None
 self.FdTargetList = self.Workspace.FdTargetList
 self.FvTargetList = self.Workspace.FvTargetList
-self.AllPcdList = []
 # get the original module/package/platform objects
 self.BuildDatabase = Workspace.BuildDatabase
 self.DscBuildDataObj = Workspace.Platform
 
 # flag indicating if the makefile/C-code file has been created or not
@@ -1223,10 +1222,13 @@ class PlatformAutoGen(AutoGen):
 self.LibraryBuildDirectoryList = 
Makefile.GetLibraryBuildDirectoryList()
 self.ModuleBuildDirectoryList = Makefile.GetModuleBuildDirectoryList()
 
 self.IsMakeFileCreated = True
 
+@property
+def AllPcdList(self):
+return self.DynamicPcdList + self.NonDynamicPcdList
 ## Deal with Shared FixedAtBuild Pcds
 #
 def CollectFixedAtBuildPcds(self):
 for LibAuto in self.LibraryAutoGenList:
 FixedAtBuildPcds = {}
@@ -1737,11 +1739,10 @@ class PlatformAutoGen(AutoGen):
 if type(SkuId) in (str, unicode) and eval(SkuId) == 0 or 
SkuId == 0:
 continue
 pcd.SkuInfoList[SkuName] = 
copy.deepcopy(pcd.SkuInfoList[TAB_DEFAULT])
 pcd.SkuInfoList[SkuName].SkuId = SkuId
 pcd.SkuInfoList[SkuName].SkuIdName = SkuName
-self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList
 
 def FixVpdOffset(self, VpdFile ):
 FvPath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY)
 if not os.path.exists(FvPath):
 try:
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 16/33] BaseTools:Fv BaseAddress must set If it not set

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

If ForceRebase is not set, and FV is specified in FD region,
 it should have FvBaseAddress

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/GenFds/FvImageSection.py | 2 ++
 BaseTools/Source/Python/GenFds/GenFds.py | 5 +
 2 files changed, 7 insertions(+)

diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py 
b/BaseTools/Source/Python/GenFds/FvImageSection.py
index d6e1f3315b..7f277ddef2 100644
--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
@@ -101,10 +101,12 @@ class FvImageSection(FvImageSectionClassObject):
 if self.FvName is not None:
 Buffer = BytesIO('')
 Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName)
 if Fv is not None:
 self.Fv = Fv
+if not self.FvAddr and self.Fv.BaseAddress:
+self.FvAddr = self.Fv.BaseAddress
 FvFileName = Fv.AddToBuffer(Buffer, self.FvAddr, MacroDict = 
Dict, Flag=IsMakefile)
 if Fv.FvAlignment is not None:
 if self.Alignment is None:
 self.Alignment = Fv.FvAlignment
 else:
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py 
b/BaseTools/Source/Python/GenFds/GenFds.py
index ae5d7fd26d..f1ce527f88 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -360,10 +360,12 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=None):
 for RegionObj in FdObj.RegionList:
 if RegionObj.RegionType != BINARY_FILE_TYPE_FV:
 continue
 for RegionData in RegionObj.RegionDataList:
 if FvObj.UiFvName.upper() == RegionData.upper():
+if not FvObj.BaseAddress:
+FvObj.BaseAddress = '0x%x' % 
(int(FdObj.BaseAddress, 0) + RegionObj.Offset)
 if FvObj.FvRegionInFD:
 if FvObj.FvRegionInFD != RegionObj.Size:
 EdkLogger.error("GenFds", 
FORMAT_INVALID, "The FV %s's region is specified in multiple FD with different 
value." %FvObj.UiFvName)
 else:
 FvObj.FvRegionInFD = RegionObj.Size
@@ -674,20 +676,23 @@ class GenFds(object):
 GuidXRefFile = BytesIO('')
 PkgGuidDict = {}
 GuidDict = {}
 ModuleList = []
 FileGuidList = []
+VariableGuidSet = set()
 for Arch in ArchList:
 PlatformDataBase = 
BuildDb.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, 
GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
 PkgList = 
GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform,
 Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag)
 for P in PkgList:
 PkgGuidDict.update(P.Guids)
 for Name, Guid in PlatformDataBase.Pcds:
 Pcd = PlatformDataBase.Pcds[Name, Guid]
 if Pcd.Type in [TAB_PCDS_DYNAMIC_HII, TAB_PCDS_DYNAMIC_EX_HII]:
 for SkuId in Pcd.SkuInfoList:
 Sku = Pcd.SkuInfoList[SkuId]
+if Sku.VariableGuid in VariableGuidSet:continue
+VariableGuidSet.add(Sku.VariableGuid)
 if Sku.VariableGuid and Sku.VariableGuid in 
PkgGuidDict.keys():
 GuidDict[Sku.VariableGuid] = 
PkgGuidDict[Sku.VariableGuid]
 for ModuleFile in PlatformDataBase.Modules:
 Module = BuildDb.BuildObject[ModuleFile, Arch, 
GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
 if Module in ModuleList:
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 22/33] BaseTools:There is extra blank line in datalog

2019-01-24 Thread Feng, Bob C
From: Zhiju Fan 

There should be no blank line across every
line in datalog if open it with Notepad++.

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/build/BuildReport.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/build/BuildReport.py 
b/BaseTools/Source/Python/build/BuildReport.py
index 2f2c3b2d83..6d1a733e15 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -248,11 +248,11 @@ def FileLinesSplit(Content=None, MaxLength=None):
 if Line:
 NewContentList.append(Line)
 for NewLine in NewContentList:
 NewContent += NewLine + TAB_LINE_BREAK
 
-NewContent = NewContent.replace(TAB_LINE_BREAK, 
gEndOfLine).replace('\r\r\n', gEndOfLine)
+NewContent = NewContent.replace(gEndOfLine, 
TAB_LINE_BREAK).replace('\r\r\n', gEndOfLine)
 return NewContent
 
 
 
 ##
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 23/33] BaseTools: Similar to octal data rectification

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

In python3, if Value is octal data, the int(Value, 0) report an error

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/GenC.py  |  2 +-
 BaseTools/Source/Python/Common/Misc.py   |  2 +-
 BaseTools/Source/Python/build/BuildReport.py | 17 +++--
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index e46942a3e2..f1f3b6f359 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1008,11 +1008,11 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
 
 if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES:
 try:
 if Value.upper().endswith('L'):
 Value = Value[:-1]
-if Value.startswith('0') and not 
Value.lower().startswith('0x') and len(Value) > 2:
+if Value.startswith('0') and not 
Value.lower().startswith('0x') and len(Value) > 1 and Value.lstrip('0'):
 Value = Value.lstrip('0')
 ValueNumber = int (Value, 0)
 except:
 EdkLogger.error("build", AUTOGEN_ERROR,
 "PCD value is not valid dec or hex number for 
datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, 
TokenCName),
diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index 1bc3ba60ea..f29bc604a0 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1373,11 +1373,11 @@ def CheckPcdDatum(Type, Value):
 elif Type == 'BOOLEAN':
 if Value not in ['TRUE', 'True', 'true', '0x1', '0x01', '1', 'FALSE', 
'False', 'false', '0x0', '0x00', '0']:
 return False, "Invalid value [%s] of type [%s]; must be one of 
TRUE, True, true, 0x1, 0x01, 1"\
   ", FALSE, False, false, 0x0, 0x00, 0" % (Value, Type)
 elif Type in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64]:
-if Value.startswith('0') and not Value.lower().startswith('0x') and 
len(Value) > 2:
+if Value.startswith('0') and not Value.lower().startswith('0x') and 
len(Value) > 1 and Value.lstrip('0'):
 Value = Value.lstrip('0')
 try:
 if Value and int(Value, 0) < 0:
 return False, "PCD can't be set to negative value[%s] for 
datum type [%s]" % (Value, Type)
 Value = int(Value, 0)
diff --git a/BaseTools/Source/Python/build/BuildReport.py 
b/BaseTools/Source/Python/build/BuildReport.py
index 6d1a733e15..ffc5c237a2 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -1024,33 +1024,37 @@ class PcdReport(object):
 FileWrite(File, Key)
 First = False
 
 
 if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES:
-if PcdValue.startswith('0') and not 
PcdValue.lower().startswith('0x') and len(PcdValue) > 2:
+if PcdValue.startswith('0') and not 
PcdValue.lower().startswith('0x') and \
+len(PcdValue) > 1 and PcdValue.lstrip('0'):
 PcdValue = PcdValue.lstrip('0')
 PcdValueNumber = int(PcdValue.strip(), 0)
 if DecDefaultValue is None:
 DecMatch = True
 else:
-if DecDefaultValue.startswith('0') and not 
DecDefaultValue.lower().startswith('0x') and len(DecDefaultValue) > 2:
+if DecDefaultValue.startswith('0') and not 
DecDefaultValue.lower().startswith('0x') and \
+len(DecDefaultValue) > 1 and 
DecDefaultValue.lstrip('0'):
 DecDefaultValue = DecDefaultValue.lstrip('0')
 DecDefaultValueNumber = int(DecDefaultValue.strip(), 0)
 DecMatch = (DecDefaultValueNumber == PcdValueNumber)
 
 if InfDefaultValue is None:
 InfMatch = True
 else:
-if InfDefaultValue.startswith('0') and not 
InfDefaultValue.lower().startswith('0x') and len(InfDefaultValue) > 2:
+if InfDefaultValue.startswith('0') and not 
InfDefaultValue.lower().startswith('0x') and \
+len(InfDefaultValue) > 1 and 
InfDefaultValue.lstrip('0'):
 InfDefaultValue = InfDefaultValue.lstrip('0')
 InfDefaultValueNumber = int(InfDefaultValue.strip(), 0)
 InfMatch = (InfDefaultValueNumber == PcdValueNumber)
 
 if DscDefaultValue is None:
 DscMatch = True
 else:
- 

[edk2] [Patch 24/33] BaseTools: Update windows and linux run scripts file to use Python3

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

Modify windows script, PosixLike script, edksetup.sh, edksetup.bat to
use Python3 based on PYTHON3_ENABLE environment.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc|  6 +++---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex   |  6 +++---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds |  6 +++---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool |  6 +++---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim   |  6 +++---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/build  |  6 +++---
 BaseTools/BinWrappers/PosixLike/BPDG|  6 +++---
 BaseTools/BinWrappers/PosixLike/Ecc |  6 +++---
 BaseTools/BinWrappers/PosixLike/GenDepex|  6 +++---
 BaseTools/BinWrappers/PosixLike/GenFds  |  6 +++---
 BaseTools/BinWrappers/PosixLike/GenPatchPcdTable|  6 +++---
 BaseTools/BinWrappers/PosixLike/GenerateCapsule |  6 +++---
 BaseTools/BinWrappers/PosixLike/PatchPcdValue   |  6 +++---
 BaseTools/BinWrappers/PosixLike/Pkcs7Sign   |  6 +++---
 BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys   |  6 +++---
 BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign   |  6 +++---
 BaseTools/BinWrappers/PosixLike/TargetTool  |  6 +++---
 BaseTools/BinWrappers/PosixLike/Trim|  6 +++---
 BaseTools/BinWrappers/PosixLike/UPT |  6 +++---
 BaseTools/BinWrappers/PosixLike/build   |  6 +++---
 BaseTools/BinWrappers/WindowsLike/BPDG.bat  |  2 +-
 BaseTools/BinWrappers/WindowsLike/Ecc.bat   |  2 +-
 BaseTools/BinWrappers/WindowsLike/GenDepex.bat  |  2 +-
 BaseTools/BinWrappers/WindowsLike/GenFds.bat|  2 +-
 BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat  |  2 +-
 BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat   |  2 +-
 BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat |  2 +-
 BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat |  2 +-
 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat |  2 +-
 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat |  2 +-
 BaseTools/BinWrappers/WindowsLike/TargetTool.bat|  2 +-
 BaseTools/BinWrappers/WindowsLike/Trim.bat  |  2 +-
 BaseTools/BinWrappers/WindowsLike/UPT.bat   |  2 +-
 BaseTools/BinWrappers/WindowsLike/build.bat |  2 +-
 BaseTools/Makefile  |  8 
 BaseTools/Source/C/Makefile |  8 
 BaseTools/Tests/GNUmakefile |  2 +-
 BaseTools/toolsetup.bat | 53 
-
 edksetup.sh | 51 
++-
 39 files changed, 177 insertions(+), 93 deletions(-)

diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc 
b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc
index 214d88fff1..8532fe510d 100755
--- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc
@@ -1,11 +1,11 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
-# If a python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
-python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+python_exe=${PYTHON}
 fi
 
 full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a 
discussion of why $0 is not a good choice here
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex 
b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex
index 214d88fff1..8532fe510d 100755
--- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex
@@ -1,11 +1,11 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
-# If a python2 command is available, use it in preference to python
-if command -v python2 >/dev/null 2>&1; then
-python_exe=python2
+# If a ${PYTHON} command is available, use it in preference to python
+if command -v ${PYTHON} >/dev/null 2>&1; then
+python_exe=${PYTHON}
 fi
 
 full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a 
discussion of why $0 is not a good choice here
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds 

[edk2] [Patch 19/33] BaseTools:Double carriage return inserted from Trim.py on Python3

2019-01-24 Thread Feng, Bob C
From: Zhiju Fan 

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

Line 208 of BaseTools/Source/Python/Trim/Trim.py uses
'NewLines.append(os.linesep)' to insert a new line into
the list that will be written to the output file.
This causes the '\r\n' inserted with os.linesep to be
written as '\r\r\n', causing some assemblers to error.

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/Trim/Trim.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Trim/Trim.py 
b/BaseTools/Source/Python/Trim/Trim.py
index 4b3091bec3..51010bf326 100644
--- a/BaseTools/Source/Python/Trim/Trim.py
+++ b/BaseTools/Source/Python/Trim/Trim.py
@@ -203,11 +203,11 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, 
TrimLong):
 # possible?
 NewLines[LineNumber - 1] = Line
 else:
 if LineNumber > (len(NewLines) + 1):
 for LineIndex in range(len(NewLines), LineNumber-1):
-NewLines.append(os.linesep)
+NewLines.append(TAB_LINE_BREAK)
 NewLines.append(Line)
 LineNumber = None
 EdkLogger.verbose("Now we have lines: %d" % len(NewLines))
 else:
 NewLines.append(Line)
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 27/33] BaseTools: Update PYTHON env to PYTHON_COMMAND

2019-01-24 Thread Feng, Bob C
From: Liming Gao 

Update PYTHON env to PYTHON_COMMAND.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc|  6 +++---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex   |  6 +++---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds |  6 +++---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool |  6 +++---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim   |  6 +++---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/build  |  6 +++---
 BaseTools/BinWrappers/PosixLike/BPDG|  6 +++---
 BaseTools/BinWrappers/PosixLike/Ecc |  6 +++---
 BaseTools/BinWrappers/PosixLike/GenDepex|  6 +++---
 BaseTools/BinWrappers/PosixLike/GenFds  |  6 +++---
 BaseTools/BinWrappers/PosixLike/GenPatchPcdTable|  6 +++---
 BaseTools/BinWrappers/PosixLike/GenerateCapsule |  6 +++---
 BaseTools/BinWrappers/PosixLike/PatchPcdValue   |  6 +++---
 BaseTools/BinWrappers/PosixLike/Pkcs7Sign   |  6 +++---
 BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys   |  6 +++---
 BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign   |  6 +++---
 BaseTools/BinWrappers/PosixLike/TargetTool  |  6 +++---
 BaseTools/BinWrappers/PosixLike/Trim|  6 +++---
 BaseTools/BinWrappers/PosixLike/UPT |  6 +++---
 BaseTools/BinWrappers/PosixLike/build   |  6 +++---
 BaseTools/BinWrappers/WindowsLike/BPDG.bat  |  2 +-
 BaseTools/BinWrappers/WindowsLike/Ecc.bat   |  2 +-
 BaseTools/BinWrappers/WindowsLike/GenDepex.bat  |  2 +-
 BaseTools/BinWrappers/WindowsLike/GenFds.bat|  2 +-
 BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat  |  2 +-
 BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat   |  2 +-
 BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat |  2 +-
 BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat |  2 +-
 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat |  2 +-
 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat |  2 +-
 BaseTools/BinWrappers/WindowsLike/TargetTool.bat|  2 +-
 BaseTools/BinWrappers/WindowsLike/Trim.bat  |  2 +-
 BaseTools/BinWrappers/WindowsLike/UPT.bat   |  2 +-
 BaseTools/BinWrappers/WindowsLike/build.bat |  2 +-
 BaseTools/Makefile  | 12 

 BaseTools/Source/C/Makefile | 12 

 BaseTools/Source/Python/build/build.py  |  3 ++-
 BaseTools/Tests/GNUmakefile |  2 +-
 BaseTools/Tests/PythonTest.py   | 15 
+++
 BaseTools/toolsetup.bat | 80 

 edksetup.sh | 42 
++
 41 files changed, 194 insertions(+), 120 deletions(-)

diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc 
b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc
index 8532fe510d..1ba451cf5e 100755
--- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc
@@ -1,11 +1,11 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
-python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+python_exe=${PYTHON_COMMAND}
 fi
 
 full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a 
discussion of why $0 is not a good choice here
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex 
b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex
index 8532fe510d..1ba451cf5e 100755
--- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex
@@ -1,11 +1,11 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
-# If a ${PYTHON} command is available, use it in preference to python
-if command -v ${PYTHON} >/dev/null 2>&1; then
-python_exe=${PYTHON}
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+python_exe=${PYTHON_COMMAND}
 fi
 
 full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a 
discussion of why $0 is not a

[edk2] [Patch 30/33] BaseTools: the list and iterator translation

2019-01-24 Thread Feng, Bob C
In python3,The keys of the dictionary not a list,It needs to be converted

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 26 
+-
 BaseTools/Source/Python/AutoGen/GenC.py|  2 +-
 BaseTools/Source/Python/AutoGen/GenMake.py | 16 
 BaseTools/Source/Python/AutoGen/GenPcdDb.py|  4 ++--
 BaseTools/Source/Python/AutoGen/StrGather.py   |  4 ++--
 BaseTools/Source/Python/Common/Misc.py |  5 +++--
 BaseTools/Source/Python/Common/StringUtils.py  |  6 +++---
 BaseTools/Source/Python/GenFds/FfsInfStatement.py  |  2 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py  | 16 
 BaseTools/Source/Python/Workspace/InfBuildData.py  |  4 ++--
 BaseTools/Source/Python/Workspace/MetaDataTable.py |  2 +-
 BaseTools/Source/Python/build/BuildReport.py   |  4 ++--
 BaseTools/Source/Python/build/build.py |  2 +-
 13 files changed, 47 insertions(+), 46 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 5f0da5a815..baa1842667 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -927,11 +927,11 @@ class WorkspaceAutoGen(AutoGen):
 # @return  None
 #
 def _CheckAllPcdsTokenValueConflict(self):
 for Pa in self.AutoGenObjectList:
 for Package in Pa.PackageList:
-PcdList = Package.Pcds.values()
+PcdList = list(Package.Pcds.values())
 PcdList.sort(key=lambda x: int(x.TokenValue, 0))
 Count = 0
 while (Count < len(PcdList) - 1) :
 Item = PcdList[Count]
 ItemNext = PcdList[Count + 1]
@@ -973,11 +973,11 @@ class WorkspaceAutoGen(AutoGen):
 )
 SameTokenValuePcdListCount += 1
 Count += SameTokenValuePcdListCount
 Count += 1
 
-PcdList = Package.Pcds.values()
+PcdList = list(Package.Pcds.values())
 PcdList.sort(key=lambda x: "%s.%s" % (x.TokenSpaceGuidCName, 
x.TokenCName))
 Count = 0
 while (Count < len(PcdList) - 1) :
 Item = PcdList[Count]
 ItemNext = PcdList[Count + 1]
@@ -1298,11 +1298,11 @@ class PlatformAutoGen(AutoGen):
 
 if PcdNvStoreDfBuffer:
 if os.path.exists(VpdMapFilePath):
 OrgVpdFile.Read(VpdMapFilePath)
 PcdItems = OrgVpdFile.GetOffset(PcdNvStoreDfBuffer[0])
-NvStoreOffset = PcdItems.values()[0].strip() if PcdItems 
else '0'
+NvStoreOffset = list(PcdItems.values())[0].strip() if 
PcdItems else '0'
 else:
 EdkLogger.error("build", FILE_READ_FAILURE, "Can not find 
VPD map file %s to fix up VPD offset." % VpdMapFilePath)
 
 NvStoreOffset = int(NvStoreOffset, 16) if 
NvStoreOffset.upper().startswith("0X") else int(NvStoreOffset)
 default_skuobj = 
PcdNvStoreDfBuffer[0].SkuInfoList.get(TAB_DEFAULT)
@@ -1497,11 +1497,11 @@ class PlatformAutoGen(AutoGen):
 self._PlatformPcds[item].DatumType = TAB_VOID
 
 if (self.Workspace.ArchList[-1] == self.Arch):
 for Pcd in self._DynamicPcdList:
 # just pick the a value to determine whether is unicode string 
type
-Sku = Pcd.SkuInfoList.values()[0]
+Sku = Pcd.SkuInfoList.get(TAB_DEFAULT)
 Sku.VpdOffset = Sku.VpdOffset.strip()
 
 if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, 
TAB_UINT64, TAB_VOID, "BOOLEAN"]:
 Pcd.DatumType = TAB_VOID
 
@@ -1603,11 +1603,11 @@ class PlatformAutoGen(AutoGen):
 
 # Not found, it should be signature
 if not FoundFlag :
 # just pick the a value to determine whether is 
unicode string type
 SkuValueMap = {}
-SkuObjList = DscPcdEntry.SkuInfoList.items()
+SkuObjList = list(DscPcdEntry.SkuInfoList.items())
 DefaultSku = 
DscPcdEntry.SkuInfoList.get(TAB_DEFAULT)
 if DefaultSku:
 defaultindex = SkuObjList.index((TAB_DEFAULT, 
DefaultSku))
 SkuObjList[0], SkuObjList[defaultindex] = 
SkuObjList[defaultindex], SkuObjList[0]
 for (SkuName, Sku) in SkuObjList:
@@ -1629,11 +1629,11 @@ class PlatformAutoGen(AutoGen):
 DscPcdEntry.DefaultValue = 
DecPcdE

[edk2] [Patch 28/33] BaseTools:Fixed Rsa issue and a set define issue.

2019-01-24 Thread Feng, Bob C
ValueError: non-hexadecimal number found in
 fromhex() arg at position 0

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py 
b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
index d2bb0c998c..c285a69ec0 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
@@ -154,11 +154,11 @@ if __name__ == '__main__':
   #
   Process = subprocess.Popen('%s rsa -in "%s" -modulus -noout' % 
(OpenSslCommand, args.PrivateKeyFileName), stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, shell=True)
   PublicKeyHexString = Process.communicate()[0].split('=')[1].strip()
   PublicKey = ''
   while len(PublicKeyHexString) > 0:
-PublicKey = PublicKey + chr(int(PublicKeyHexString[0:2], 16))
+PublicKey = PublicKey + PublicKeyHexString[0:2]
 PublicKeyHexString=PublicKeyHexString[2:]
   if Process.returncode != 0:
 sys.exit(Process.returncode)
 
   if args.MonotonicCountStr:
@@ -186,11 +186,11 @@ if __name__ == '__main__':
 #
 # Write output file that contains hash GUID, Public Key, Signature, and 
Input data
 #
 args.OutputFile = open(args.OutputFileName, 'wb')
 args.OutputFile.write(EFI_HASH_ALGORITHM_SHA256_GUID.bytes_le)
-args.OutputFile.write(PublicKey)
+args.OutputFile.write(bytearray.fromhex(str(PublicKey)))
 args.OutputFile.write(Signature)
 args.OutputFile.write(args.InputFileBuffer)
 args.OutputFile.close()
 
   if args.Decode:
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 21/33] BaseTools: change the Division Operator

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

PEP 238 -- Changing the Division Operator
x/y to return a reasonable approximation of the mathematical result
of the division ("true division")
x//y to return the floor ("floor division")

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py |  2 +-
 BaseTools/Source/Python/AutoGen/GenC.py|  8 
 BaseTools/Source/Python/BPDG/GenVpd.py |  8 
 BaseTools/Source/Python/Common/Expression.py   |  9 -
 BaseTools/Source/Python/Common/Misc.py |  6 +++---
 BaseTools/Source/Python/GenFds/DataSection.py  |  4 ++--
 BaseTools/Source/Python/GenFds/EfiSection.py   |  4 ++--
 BaseTools/Source/Python/GenFds/FfsInfStatement.py  |  8 
 BaseTools/Source/Python/GenFds/Fv.py   |  4 ++--
 BaseTools/Source/Python/GenFds/FvImageSection.py   | 10 +-
 BaseTools/Source/Python/GenFds/GenFds.py   |  2 +-
 BaseTools/Source/Python/GenFds/Region.py   |  4 ++--
 BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py |  4 ++--
 BaseTools/Source/Python/build/build.py | 18 +-
 14 files changed, 49 insertions(+), 42 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index f9ce17cf77..5f0da5a815 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -3812,11 +3812,11 @@ class ModuleAutoGen(AutoGen):
 else:
 NewValue = NewValue + '0x%02x' % 
(ord(PcdValue[Index]) % 0x100) + ', '
 Padding = '0x00, '
 if Unicode:
 Padding = Padding * 2
-ArraySize = ArraySize / 2
+ArraySize = ArraySize // 2
 if ArraySize < (len(PcdValue) + 1):
 if Pcd.MaxSizeUserSet:
 EdkLogger.error("build", AUTOGEN_ERROR,
 "The maximum size of VOID* type 
PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, 
TokenCName)
 )
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index 915ba2e235..e46942a3e2 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1051,21 +1051,21 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
 if Unicode:
 NewValue = NewValue + str(ord(Value[Index]) % 0x1) 
+ ', '
 else:
 NewValue = NewValue + str(ord(Value[Index]) % 0x100) + 
', '
 if Unicode:
-ArraySize = ArraySize / 2
+ArraySize = ArraySize // 2
 Value = NewValue + '0 }'
 if ArraySize < ValueSize:
 if Pcd.MaxSizeUserSet:
 EdkLogger.error("build", AUTOGEN_ERROR,
 "The maximum size of VOID* type PCD '%s.%s' is 
less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName),
 ExtraData="[%s]" % str(Info))
 else:
 ArraySize = Pcd.GetPcdSize()
 if Unicode:
-ArraySize = ArraySize / 2
+ArraySize = ArraySize // 2
 Array = '[%d]' % ArraySize
 #
 # skip casting for fixed at build since it breaks ARM assembly.
 # Long term we need PCD macros that work in assembly
 #
@@ -1904,20 +1904,20 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, 
TransParent):
 if TransParent:
 ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_1BIT_TRANS)
 else:
 ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_1BIT)
 ImageBuffer += pack('B', PaletteIndex)
-Width = (BmpHeader.biWidth + 7)/8
+Width = (BmpHeader.biWidth + 7)//8
 if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2:
 PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : 
BmpHeader.bfOffBits]
 elif BmpHeader.biBitCount == 4:
 if TransParent:
 ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_4BIT_TRANS)
 else:
 ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_4BIT)
 ImageBuffer += pack('B', PaletteIndex)
-Width = (BmpHeader.biWidth + 1)/2
+Width = (BmpHeader.biWidth + 1)//2
 if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2:
 PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : 
BmpHeader.bfOffBits]
 elif BmpHeader.biBitCount == 8

[edk2] [Patch 25/33] BaseTools:Update build tool to print python version information

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

print PYTHON3_ENABLE and PYTHON_COMMAND in build tool

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/build/build.py | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index e4dc9664f6..4276f4ab9c 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -826,10 +826,16 @@ class Build():
 EdkLogger.quiet("%-16s = %s" % ("EDK_TOOLS_PATH", 
os.environ["EDK_TOOLS_PATH"]))
 if "EDK_TOOLS_BIN" in os.environ:
 # Print the same path style with WORKSPACE env.
 EdkLogger.quiet("%-16s = %s" % ("EDK_TOOLS_BIN", 
os.path.normcase(os.path.normpath(os.environ["EDK_TOOLS_BIN"]
 EdkLogger.quiet("%-16s = %s" % ("CONF_PATH", 
GlobalData.gConfDirectory))
+if "PYTHON3_ENABLE" in os.environ:
+PYTHON3_ENABLE = os.environ["PYTHON3_ENABLE"]
+if PYTHON3_ENABLE != "TRUE":
+PYTHON3_ENABLE = "FALSE"
+EdkLogger.quiet("%-16s = %s" % ("PYTHON3_ENABLE", PYTHON3_ENABLE))
+EdkLogger.quiet("%-16s = %s" % ("PYTHON", os.environ["PYTHON"]))
 self.InitPreBuild()
 self.InitPostBuild()
 if self.Prebuild:
 EdkLogger.quiet("%-16s = %s" % ("PREBUILD", self.Prebuild))
 if self.Postbuild:
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 29/33] BaseTools:ord() don't match in py2 and py3

2019-01-24 Thread Feng, Bob C
In python2, the FvHeaderBuffer Type is a str
In python3, the FvHeaderBuffer Type is a bytes

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/GenFds/FvImageSection.py | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py 
b/BaseTools/Source/Python/GenFds/FvImageSection.py
index 535b86ab5e..7ea931e1b5 100644
--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
@@ -69,11 +69,14 @@ class FvImageSection(FvImageSectionClassObject):
 FvFileObj = open (FvFileName, 'rb')
 FvFileObj.seek(0)
 # PI FvHeader is 0x48 byte
 FvHeaderBuffer = FvFileObj.read(0x48)
 # FV alignment position.
-FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)
+if isinstance(FvHeaderBuffer[0x2E], str):
+FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 
0x1F)
+else:
+FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)
 FvFileObj.close()
 if FvAlignmentValue > MaxFvAlignment:
 MaxFvAlignment = FvAlignmentValue
 
 OutputFile = os.path.join(OutputPath, ModuleName + 
SUP_MODULE_SEC + Num + SectionSuffix.get("FV_IMAGE"))
@@ -119,11 +122,14 @@ class FvImageSection(FvImageSectionClassObject):
 FvFileObj = open (FvFileName, 'rb')
 FvFileObj.seek(0)
 # PI FvHeader is 0x48 byte
 FvHeaderBuffer = FvFileObj.read(0x48)
 # FV alignment position.
-FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 
0x1F)
+if isinstance(FvHeaderBuffer[0x2E], str):
+FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) 
& 0x1F)
+else:
+FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 
0x1F)
 # FvAlignmentValue is larger than or equal to 1K
 if FvAlignmentValue >= 0x400:
 if FvAlignmentValue >= 0x10:
 #The max alignment supported by FFS is 16M.
 if FvAlignmentValue >= 0x100:
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 20/33] BaseTools:File open failed for VPD MapFile

2019-01-24 Thread Feng, Bob C
correct open MapFile support python2 and python3

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/BPDG/GenVpd.py | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py 
b/BaseTools/Source/Python/BPDG/GenVpd.py
index b91837d3d6..71fcfc5ac3 100644
--- a/BaseTools/Source/Python/BPDG/GenVpd.py
+++ b/BaseTools/Source/Python/BPDG/GenVpd.py
@@ -649,11 +649,11 @@ class GenVPD :
 except:
 # Open failed
 EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File 
open failed for %s" % self.VpdFileName, None)
 
 try :
-fMapFile = open(MapFileName, "w", 0)
+fMapFile = open(MapFileName, "w")
 except:
 # Open failed
 EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File 
open failed for %s" % self.MapFileName, None)
 
 # Use a instance of BytesIO to cache data
@@ -673,12 +673,16 @@ class GenVPD :
 EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, 
"Write data to file %s failed, please check whether the file been locked or 
using by other applications." % self.MapFileName, None)
 
 # Write Vpd binary file
 fStringIO.seek (eachPcd.PcdBinOffset)
 if isinstance(eachPcd.PcdValue, list):
-ValueList = [chr(Item) for Item in eachPcd.PcdValue]
-fStringIO.write(''.join(ValueList))
+for i in range(len(eachPcd.PcdValue)):
+Value = eachPcd.PcdValue[i:i + 1]
+if isinstance(bytes(Value), str):
+fStringIO.write(chr(Value[0]))
+else:
+fStringIO.write(bytes(Value))
 else:
 fStringIO.write (eachPcd.PcdValue)
 
 try :
 fVpdFile.write (fStringIO.getvalue())
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 14/33] BaseTools/Scripts: Porting PackageDocumentTools code to use Python3

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

Porting PackageDocumentTools code to support python2 and python3

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Scripts/ConvertFceToStructurePcd.py  
 |  2 +-
 BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py   
 |  6 +++---
 BaseTools/Scripts/PackageDocumentTools/packagedocapp.pyw   
 | 14 +++---
 BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py 
 |  4 ++--
 
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/baseobject.py
  | 16 
 BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/dec.py
 |  4 ++--
 
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen.py
  | 12 ++--
 
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen_spec.py
 | 12 ++--
 BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/dsc.py
 |  4 ++--
 BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/inf.py
 |  4 ++--
 10 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/BaseTools/Scripts/ConvertFceToStructurePcd.py 
b/BaseTools/Scripts/ConvertFceToStructurePcd.py
index 59eec28d5e..1495ac34d6 100644
--- a/BaseTools/Scripts/ConvertFceToStructurePcd.py
+++ b/BaseTools/Scripts/ConvertFceToStructurePcd.py
@@ -133,11 +133,11 @@ class parser_lst(object):
   offset = int(offset, 10)
   tmp_name = pcdname2_re.findall(t_name)[0] + '[0]'
   tmp_dict[offset] = tmp_name
   pcdname_num = int(pcdname_num_re.findall(t_name)[0],10)
   uint = int(unit_num.findall(uint)[0],10)
-  bit = uint / 8
+  bit = uint // 8
   for i in range(1, pcdname_num):
 offset += bit
 tmp_name = pcdname2_re.findall(t_name)[0] + '[%s]' % i
 tmp_dict[offset] = tmp_name
 else:
diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py 
b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
index 4d01a5..e404a07cd7 100644
--- a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
+++ b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
@@ -14,12 +14,12 @@
 
 from __future__ import print_function
 import os, sys, logging, traceback, subprocess
 from optparse import OptionParser
 
-import plugins.EdkPlugins.edk2.model.baseobject as baseobject
-import plugins.EdkPlugins.edk2.model.doxygengen as doxygengen
+from .plugins.EdkPlugins.edk2.model import baseobject
+from .plugins.EdkPlugins.edk2.model import doxygengen
 
 gArchMarcoDict = {'ALL'  : 'MDE_CPU_IA32 MDE_CPU_X64 MDE_CPU_EBC 
MDE_CPU_IPF _MSC_EXTENSIONS __GNUC__ __INTEL_COMPILER',
   'IA32_MSFT': 'MDE_CPU_IA32 _MSC_EXTENSIONS',
   'IA32_GNU' : 'MDE_CPU_IA32 __GNUC__',
   'X64_MSFT' : 'MDE_CPU_X64 _MSC_EXTENSIONS  ASM_PFX= 
OPTIONAL= ',
@@ -36,11 +36,11 @@ def parseCmdArgs():
   help='Specify the absolute path for package DEC file. 
For example: c:\\tianocore\\MdePkg\\MdePkg.dec')
 parser.add_option('-x', '--doxygen', action='store', dest='DoxygenPath',
   help='Specify the absolute path of doxygen tools 
installation. For example: C:\\Program Files\\doxygen\bin\doxygen.exe')
 parser.add_option('-o', '--output', action='store', dest='OutputPath',
   help='Specify the document output path. For example: 
c:\\docoutput')
-parser.add_option('-a', '--arch', action='store', dest='Arch', 
choices=gArchMarcoDict.keys(),
+parser.add_option('-a', '--arch', action='store', dest='Arch', 
choices=list(gArchMarcoDict.keys()),
   help='Specify the architecture used in preprocess 
package\'s source. For example: -a IA32_MSFT')
 parser.add_option('-m', '--mode', action='store', dest='DocumentMode', 
choices=['CHM', 'HTML'],
   help='Specify the document mode from : CHM or HTML')
 parser.add_option('-i', '--includeonly', action='store_true', 
dest='IncludeOnly',
   help='Only generate document for package\'s public 
interfaces produced by include folder. ')
diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedocapp.pyw 
b/BaseTools/Scripts/PackageDocumentTools/packagedocapp.pyw
index 28f6f9bf5c..2998db3915 100644
--- a/BaseTools/Scripts/PackageDocumentTools/packagedocapp.pyw
+++ b/BaseTools/Scripts/PackageDocumentTools/packagedocapp.pyw
@@ -16,12 +16,12 @@
 import os, sys, wx, logging
 
 import wx.stc
 import wx.lib.newevent
 import wx.lib.agw.genericmessagedialog as GMD
-import plugins.EdkPlugins.edk2.mode

[edk2] [Patch 04/33] BaseTools: replace get_bytes_le() to bytes_le

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

UUID does not have the get_bytes_le() in python3

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/Common/Misc.py | 2 +-
 BaseTools/Source/Python/GenFds/CapsuleData.py  | 2 +-
 BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index 2045fd98ba..2aef8bbe87 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1245,11 +1245,11 @@ def ParseFieldValue (Value):
 raise BadExpression("Invalid GUID value string %s" % Value)
 Value = TmpValue
 if Value[0] == '"' and Value[-1] == '"':
 Value = Value[1:-1]
 try:
-Value = "'" + uuid.UUID(Value).get_bytes_le() + "'"
+Value = "'" + uuid.UUID(Value).bytes_le + "'"
 except ValueError as Message:
 raise BadExpression(Message)
 Value, Size = ParseFieldValue(Value)
 return Value, 16
 if Value.startswith('L"') and Value.endswith('"'):
diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py 
b/BaseTools/Source/Python/GenFds/CapsuleData.py
index 6071e9f4a5..db201c074b 100644
--- a/BaseTools/Source/Python/GenFds/CapsuleData.py
+++ b/BaseTools/Source/Python/GenFds/CapsuleData.py
@@ -227,11 +227,11 @@ class CapsulePayload(CapsuleData):
VendorFileSize,
int(self.HardwareInstance, 16)
)
 if AuthData:
 Buffer += pack('QIHH', AuthData[0], AuthData[1], AuthData[2], 
AuthData[3])
-Buffer += uuid.UUID(AuthData[4]).get_bytes_le()
+Buffer += uuid.UUID(AuthData[4]).bytes_le
 
 #
 # Append file content to the structure
 #
 ImageFile = open(self.ImageFile, 'rb')
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py 
b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
index 3fd7eefd6a..370ae2e3fa 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
@@ -184,11 +184,11 @@ if __name__ == '__main__':
 
 #
 # Write output file that contains hash GUID, Public Key, Signature, and 
Input data
 #
 args.OutputFile = open(args.OutputFileName, 'wb')
-args.OutputFile.write(EFI_HASH_ALGORITHM_SHA256_GUID.get_bytes_le())
+args.OutputFile.write(EFI_HASH_ALGORITHM_SHA256_GUID.bytes_le)
 args.OutputFile.write(PublicKey)
 args.OutputFile.write(Signature)
 args.OutputFile.write(args.InputFileBuffer)
 args.OutputFile.close()
 
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 05/33] BaseTools: use OrderedDict instead of sdict

2019-01-24 Thread Feng, Bob C
From: Yunhua Feng 

use OrderedDict instead of sdict, and delete sdict

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng 
---
 BaseTools/Source/Python/Common/Misc.py | 127 
++-
 1 file changed, 2 insertions(+), 125 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index 2aef8bbe87..a4aaff0837 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -24,13 +24,11 @@ import re
 import pickle
 import array
 import shutil
 from random import sample
 from struct import pack
-from UserDict import IterableUserDict
-from UserList import UserList
-
+from collections import OrderedDict
 from Common import EdkLogger as EdkLogger
 from Common import GlobalData as GlobalData
 from .DataType import *
 from .BuildToolError import *
 from CommonDataClass.DataClass import *
@@ -849,131 +847,10 @@ class Progressor:
 Progressor._StopFlag.set()
 if Progressor._ProgressThread is not None:
 Progressor._ProgressThread.join()
 Progressor._ProgressThread = None
 
-## A dict which can access its keys and/or values orderly
-#
-#  The class implements a new kind of dict which its keys or values can be
-#  accessed in the order they are added into the dict. It guarantees the order
-#  by making use of an internal list to keep a copy of keys.
-#
-class sdict(IterableUserDict):
-## Constructor
-def __init__(self):
-IterableUserDict.__init__(self)
-self._key_list = []
-
-## [] operator
-def __setitem__(self, key, value):
-if key not in self._key_list:
-self._key_list.append(key)
-IterableUserDict.__setitem__(self, key, value)
-
-## del operator
-def __delitem__(self, key):
-self._key_list.remove(key)
-IterableUserDict.__delitem__(self, key)
-
-## used in "for k in dict" loop to ensure the correct order
-def __iter__(self):
-return self.iterkeys()
-
-## len() support
-def __len__(self):
-return len(self._key_list)
-
-## "in" test support
-def __contains__(self, key):
-return key in self._key_list
-
-## indexof support
-def index(self, key):
-return self._key_list.index(key)
-
-## insert support
-def insert(self, key, newkey, newvalue, order):
-index = self._key_list.index(key)
-if order == 'BEFORE':
-self._key_list.insert(index, newkey)
-IterableUserDict.__setitem__(self, newkey, newvalue)
-elif order == 'AFTER':
-self._key_list.insert(index + 1, newkey)
-IterableUserDict.__setitem__(self, newkey, newvalue)
-
-## append support
-def append(self, sdict):
-for key in sdict:
-if key not in self._key_list:
-self._key_list.append(key)
-IterableUserDict.__setitem__(self, key, sdict[key])
-
-def has_key(self, key):
-return key in self._key_list
-
-## Empty the dict
-def clear(self):
-self._key_list = []
-IterableUserDict.clear(self)
-
-## Return a copy of keys
-def keys(self):
-keys = []
-for key in self._key_list:
-keys.append(key)
-return keys
-
-## Return a copy of values
-def values(self):
-values = []
-for key in self._key_list:
-values.append(self[key])
-return values
-
-## Return a copy of (key, value) list
-def items(self):
-items = []
-for key in self._key_list:
-items.append((key, self[key]))
-return items
-
-## Iteration support
-def iteritems(self):
-return iter(self.items())
-
-## Keys interation support
-def iterkeys(self):
-return iter(self.keys())
-
-## Values interation support
-def itervalues(self):
-return iter(self.values())
-
-## Return value related to a key, and remove the (key, value) from the dict
-def pop(self, key, *dv):
-value = None
-if key in self._key_list:
-value = self[key]
-self.__delitem__(key)
-elif len(dv) != 0 :
-value = kv[0]
-return value
-
-## Return (key, value) pair, and remove the (key, value) from the dict
-def popitem(self):
-key = self._key_list[-1]
-value = self[key]
-self.__delitem__(key)
-return key, value
-
-def update(self, dict=None, **kwargs):
-if dict is not None:
-for k, v in dict.items():
-self[k] = v
-if len(kwargs):
-for k, v in kwargs.items():
-self[k] = v
 
 ## Dictionary with restricted keys
 #
 class rdict(dict):
 ## Constructor
@@ -1785,11 +1662,11 @@ clas

[edk2] [Patch 02/33] BaseTools:use iterate list to replace the itertools

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

itertools.imap() replace map(), itertools.ifilter() replace filter

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/build/build.py | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index 44ad86b780..3266333cc4 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -25,11 +25,10 @@ import sys
 import glob
 import time
 import platform
 import traceback
 import encodings.ascii
-import itertools
 import multiprocessing
 
 from struct import *
 from threading import *
 import threading
@@ -1137,13 +1136,12 @@ class Build():
 
 if os.path.exists(PrebuildEnvFile):
 f = open(PrebuildEnvFile)
 envs = f.readlines()
 f.close()
-envs = itertools.imap(lambda l: l.split('=', 1), envs)
-envs = itertools.ifilter(lambda l: len(l) == 2, envs)
-envs = itertools.imap(lambda l: [i.strip() for i in l], envs)
+envs = [l.split("=", 1) for l in envs ]
+envs = [[I.strip() for I in item] for item in envs if 
len(item) == 2]
 os.environ.update(dict(envs))
 EdkLogger.info("\n- Prebuild Done -\n")
 
 def LaunchPostbuild(self):
 if self.Postbuild:
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 12/33] BaseTools/UPT:merge UPT Tool use Python2 and Python3

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

In UPT Tool,merge python2 and python3

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/UPT/Core/IpiDb.py |   4 ++--
 BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py |   6 +++---
 BaseTools/Source/Python/UPT/Library/CommentGenerating.py  |   6 ++
 BaseTools/Source/Python/UPT/Library/CommentParsing.py |  10 --
 BaseTools/Source/Python/UPT/Library/Misc.py   | 190 
++
 BaseTools/Source/Python/UPT/Library/ParserValidate.py |   2 +-
 BaseTools/Source/Python/UPT/Library/Parsing.py|   2 +-
 BaseTools/Source/Python/UPT/Library/StringUtils.py|  36 
++--
 BaseTools/Source/Python/UPT/Library/UniClassObject.py |   6 --
 BaseTools/Source/Python/UPT/Library/Xml/XmlRoutines.py|   2 +-
 BaseTools/Source/Python/UPT/Logger/StringTable.py |   2 +-
 BaseTools/Source/Python/UPT/Parser/DecParser.py   |   4 ++--
 BaseTools/Source/Python/UPT/Parser/DecParserMisc.py   |  30 
+-
 BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py   |   4 ++--
 BaseTools/Source/Python/UPT/Parser/InfParser.py   |   4 ++--
 BaseTools/Source/Python/UPT/Parser/InfSectionParser.py|   4 ++--
 BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py |   2 +-
 BaseTools/Source/Python/UPT/UPT.py|   1 +
 BaseTools/Source/Python/UPT/Xml/IniToXml.py   |   2 +-
 BaseTools/Source/Python/UPT/Xml/XmlParserMisc.py  |   2 +-
 20 files changed, 84 insertions(+), 235 deletions(-)

diff --git a/BaseTools/Source/Python/UPT/Core/IpiDb.py 
b/BaseTools/Source/Python/UPT/Core/IpiDb.py
index a781d358c8..48defeac7e 100644
--- a/BaseTools/Source/Python/UPT/Core/IpiDb.py
+++ b/BaseTools/Source/Python/UPT/Core/IpiDb.py
@@ -42,11 +42,11 @@ import platform as pf
 class IpiDatabase(object):
 def __init__(self, DbPath, Workspace):
 Dir = os.path.dirname(DbPath)
 if not os.path.isdir(Dir):
 os.mkdir(Dir)
-self.Conn = sqlite3.connect(unicode(DbPath), 
isolation_level='DEFERRED')
+self.Conn = sqlite3.connect(u''.join(DbPath), 
isolation_level='DEFERRED')
 self.Conn.execute("PRAGMA page_size=4096")
 self.Conn.execute("PRAGMA synchronous=OFF")
 self.Cur = self.Conn.cursor()
 self.DpTable = 'DpInfo'
 self.PkgTable = 'PkgInfo'
@@ -919,10 +919,10 @@ class IpiDatabase(object):
 # @param StringList:  A list for strings to be converted
 #
 def __ConvertToSqlString(self, StringList):
 if self.DpTable:
 pass
-return map(lambda s: s.replace("'", "''"), StringList)
+return list(map(lambda s: s.replace("'", "''"), StringList))
 
 
 
 
diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py 
b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
index c2a240a884..1f8b3f163e 100644
--- a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
+++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
@@ -272,11 +272,11 @@ def GenDefines(ModuleObject):
 for UserExtension in ModuleObject.GetUserExtensionList():
 DefinesDict = UserExtension.GetDefinesDict()
 if not DefinesDict:
 continue
 for Statement in DefinesDict:
-if Statement.split(DT.TAB_EQUAL_SPLIT) > 1:
+if len(Statement.split(DT.TAB_EQUAL_SPLIT)) > 1:
 Statement = (u'%s ' % Statement.split(DT.TAB_EQUAL_SPLIT, 
1)[0]).ljust(LeftOffset) \
  + u'= %s' % Statement.split(DT.TAB_EQUAL_SPLIT, 
1)[1].lstrip()
 SortedArch = DT.TAB_ARCH_COMMON
 if 
Statement.strip().startswith(DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE):
 pos = Statement.find(DT.TAB_VALUE_SPLIT)
@@ -407,11 +407,11 @@ def GenLibraryClasses(ModuleObject):
 Statement += Name
 if FFE:
 Statement += '|' + FFE
 ModuleList = LibraryClass.GetSupModuleList()
 ArchList = LibraryClass.GetSupArchList()
-for Index in xrange(0, len(ArchList)):
+for Index in range(0, len(ArchList)):
 ArchList[Index] = ConvertArchForInstall(ArchList[Index])
 ArchList.sort()
 SortedArch = ' '.join(ArchList)
 KeyList = []
 if not ModuleList or IsAllModuleList(ModuleList):
@@ -570,11 +570,11 @@ def GenUserExtensions(ModuleObject):
 Statement = UserExtension.GetStatement()
 # Comment the code to support user extension without any statement just the 
section header in []
 # if not Statement:
 # continue
 ArchList = UserE

[edk2] [Patch 01/33] BaseTool:Rename xrange() to range()

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

Because the xrange() was not exist in Python3

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/GenPcdDb.py | 22 +++---
 BaseTools/Source/Python/BPDG/GenVpd.py  |  6 +++---
 BaseTools/Source/Python/Common/Misc.py  |  2 +-
 BaseTools/Source/Python/GenFds/Region.py|  2 +-
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py 
b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index a9068d2d7a..d3e85293d2 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -259,11 +259,11 @@ class DbItemList:
 if self.ItemSize == 0:
 #
 # Variable length, need to calculate one by one
 #
 assert(Index < len(self.RawDataList))
-for ItemIndex in xrange(Index):
+for ItemIndex in range(Index):
 Offset += len(self.RawDataList[ItemIndex])
 else:
 Offset = self.ItemSize * Index
 
 return Offset
@@ -346,11 +346,11 @@ class DbComItemList (DbItemList):
 # The only variable table is stringtable, it is not Composite 
item, should not reach here
 #
 assert(False)
 else:
 assert(Index < len(self.RawDataList))
-for ItemIndex in xrange(Index):
+for ItemIndex in range(Index):
 Offset += len(self.RawDataList[ItemIndex]) * self.ItemSize
 
 return Offset
 
 def GetListSize(self):
@@ -412,11 +412,11 @@ class DbStringHeadTableItemList(DbItemList):
 if self.ItemSize == 0:
 #
 # Variable length, need to calculate one by one
 #
 assert(Index < len(self.RawDataList))
-for ItemIndex in xrange(Index):
+for ItemIndex in range(Index):
 Offset += len(self.RawDataList[ItemIndex])
 else:
 for innerIndex in range(Index):
 if type(self.RawDataList[innerIndex]) in (list, tuple):
 Offset += len(self.RawDataList[innerIndex]) * self.ItemSize
@@ -496,27 +496,27 @@ class DbStringItemList (DbComItemList):
 LenList = []
 
 assert(len(RawDataList) == len(LenList))
 DataList = []
 # adjust DataList according to the LenList
-for Index in xrange(len(RawDataList)):
+for Index in range(len(RawDataList)):
 Len = LenList[Index]
 RawDatas = RawDataList[Index]
 assert(Len >= len(RawDatas))
 ActualDatas = []
-for i in xrange(len(RawDatas)):
+for i in range(len(RawDatas)):
 ActualDatas.append(RawDatas[i])
-for i in xrange(len(RawDatas), Len):
+for i in range(len(RawDatas), Len):
 ActualDatas.append(0)
 DataList.append(ActualDatas)
 self.LenList = LenList
 DbComItemList.__init__(self, ItemSize, DataList, RawDataList)
 def GetInterOffset(self, Index):
 Offset = 0
 
 assert(Index < len(self.LenList))
-for ItemIndex in xrange(Index):
+for ItemIndex in range(Index):
 Offset += self.LenList[ItemIndex]
 
 return Offset
 
 def GetListSize(self):
@@ -700,11 +700,11 @@ def BuildExDataBase(Dict):
 # The FixedHeader length of the PCD_DATABASE_INIT, from Signature to Pad
 FixedHeaderLen = 80
 
 # Get offset of SkuId table in the database
 SkuIdTableOffset = FixedHeaderLen
-for DbIndex in xrange(len(DbTotal)):
+for DbIndex in range(len(DbTotal)):
 if DbTotal[DbIndex] is SkuidValue:
 break
 SkuIdTableOffset += DbItemTotal[DbIndex].GetListSize()
 
 
@@ -712,11 +712,11 @@ def BuildExDataBase(Dict):
 
 # Fix up the LocalTokenNumberTable, SkuHeader table
 for (LocalTokenNumberTableIndex, (Offset, Table)) in 
enumerate(LocalTokenNumberTable):
 DbIndex = 0
 DbOffset = FixedHeaderLen
-for DbIndex in xrange(len(DbTotal)):
+for DbIndex in range(len(DbTotal)):
 if DbTotal[DbIndex] is Table:
 DbOffset += DbItemTotal[DbIndex].GetInterOffset(Offset)
 break
 DbOffset += DbItemTotal[DbIndex].GetListSize()
 if DbIndex + 1 == InitTableNum:
@@ -738,11 +738,11 @@ def BuildExDataBase(Dict):
 skuindex = 0
 for VariableEntryPerSku in VariableEntries:
 (VariableHeadGuidIndex, VariableHeadStringIndex, 
SKUVariableOffset, VariableOffset, VariableRefTable, VariableAttribute) = 
VariableEntryPerSku[:]
 DbIndex = 0
 DbOffset = FixedHeaderLen
-for DbIndex in xrange(len(DbTotal)):
+for DbIndex in range(len(DbTotal)):
 if DbTotal[DbIndex] is VariableRefTable:
   

[edk2] [Patch 10/33] BaseTools: Update argparse arguments since it not have version now

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

argparse.ArgumentParser not have version parameter

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py | 3 ++-
 BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py | 3 ++-
 BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py 
b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
index c5c99d94ef..2a7c308895 100644
--- a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
+++ b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
@@ -74,14 +74,15 @@ TEST_TRUSTED_PUBLIC_CERT_FILENAME = 'TestRoot.pub.pem'
 
 if __name__ == '__main__':
   #
   # Create command line argument parser object
   #
-  parser = argparse.ArgumentParser(prog=__prog__, version=__version__, 
usage=__usage__, description=__copyright__, conflict_handler='resolve')
+  parser = argparse.ArgumentParser(prog=__prog__, usage=__usage__, 
description=__copyright__, conflict_handler='resolve')
   group = parser.add_mutually_exclusive_group(required=True)
   group.add_argument("-e", action="store_true", dest='Encode', help='encode 
file')
   group.add_argument("-d", action="store_true", dest='Decode', help='decode 
file')
+  group.add_argument("--version", action='version', version=__version__)
   parser.add_argument("-o", "--output", dest='OutputFile', type=str, 
metavar='filename', help="specify the output filename", required=True)
   parser.add_argument("--signer-private-cert", dest='SignerPrivateCertFile', 
type=argparse.FileType('rb'), help="specify the signer private cert filename.  
If not specified, a test signer private cert is used.")
   parser.add_argument("--other-public-cert", dest='OtherPublicCertFile', 
type=argparse.FileType('rb'), help="specify the other public cert filename.  If 
not specified, a test other public cert is used.")
   parser.add_argument("--trusted-public-cert", dest='TrustedPublicCertFile', 
type=argparse.FileType('rb'), help="specify the trusted public cert filename.  
If not specified, a test trusted public cert is used.")
   parser.add_argument("--monotonic-count", dest='MonotonicCountStr', type=str, 
help="specify the MonotonicCount in FMP capsule.  If not specified, 0 is used.")
diff --git 
a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py 
b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
index a34dac423b..f96ceb2637 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
@@ -41,12 +41,13 @@ __usage__ = '%s [options]' % (__prog__)
 
 if __name__ == '__main__':
   #
   # Create command line argument parser object
   #
-  parser = argparse.ArgumentParser(prog=__prog__, version=__version__, 
usage=__usage__, description=__copyright__, conflict_handler='resolve')
+  parser = argparse.ArgumentParser(prog=__prog__, usage=__usage__, 
description=__copyright__, conflict_handler='resolve')
   group = parser.add_mutually_exclusive_group(required=True)
+  group.add_argument("--version", action='version', version=__version__)
   group.add_argument("-o", "--output", dest='OutputFile', 
type=argparse.FileType('wb'), metavar='filename', nargs='*', help="specify the 
output private key filename in PEM format")
   group.add_argument("-i", "--input", dest='InputFile', 
type=argparse.FileType('rb'), metavar='filename', nargs='*', help="specify the 
input private key filename in PEM format")
   parser.add_argument("--public-key-hash", dest='PublicKeyHashFile', 
type=argparse.FileType('wb'), help="specify the public key hash filename that 
is SHA 256 hash of 2048 bit RSA public key in binary format")
   parser.add_argument("--public-key-hash-c", dest='PublicKeyHashCFile', 
type=argparse.FileType('wb'), help="specify the public key hash filename that 
is SHA 256 hash of 2048 bit RSA public key in C structure format")
   parser.add_argument("-v", "--verbose", dest='Verbose', action="store_true", 
help="increase output messages")
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py 
b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
index 3a1a2dff00..d2bb0c998c 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
@@ -60,14 +60,15 @@ TEST_SIGNING_PRIVATE_KEY_FILENAME = 
'TestSigningPrivateKey.pem'
 
 if __name__ == '__main__':
   #
   # Create command line argument parser object
   #
-  parser = argparse.ArgumentParser(prog=__prog__, version=__version__, 
usage=__usage__, description=__copyright__, conflict_handler='resolve')
+  parser = argparse.ArgumentParser(prog=__prog__, usage=__usage__, 
description=__copyright__, conflict_handler='resolve'

[edk2] [Patch 13/33] BaseTools: update Test scripts support python3

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

update Test scripts support python2 and python3

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Tests/CToolsTests.py |  2 +-
 BaseTools/Tests/CheckUnicodeSourceFiles.py |  6 +++---
 BaseTools/Tests/TestTools.py   | 13 -
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/BaseTools/Tests/CToolsTests.py b/BaseTools/Tests/CToolsTests.py
index ab75d9a7dc..f0de44b141 100644
--- a/BaseTools/Tests/CToolsTests.py
+++ b/BaseTools/Tests/CToolsTests.py
@@ -24,11 +24,11 @@ modules = (
 TianoCompress,
 )
 
 
 def TheTestSuite():
-suites = map(lambda module: module.TheTestSuite(), modules)
+suites = list(map(lambda module: module.TheTestSuite(), modules))
 return unittest.TestSuite(suites)
 
 if __name__ == '__main__':
 allTests = TheTestSuite()
 unittest.TextTestRunner().run(allTests)
diff --git a/BaseTools/Tests/CheckUnicodeSourceFiles.py 
b/BaseTools/Tests/CheckUnicodeSourceFiles.py
index 6ae62f180a..c76b2bc20e 100644
--- a/BaseTools/Tests/CheckUnicodeSourceFiles.py
+++ b/BaseTools/Tests/CheckUnicodeSourceFiles.py
@@ -108,11 +108,11 @@ class Tests(TestTools.BaseToolsTest):
 # with the Surrogate Pair code point.
 #
 # This test makes sure that BaseTools rejects these characters
 # if seen in a .uni file.
 #
-data = codecs.BOM_UTF16_LE + '//\x01\xd8 '
+data = codecs.BOM_UTF16_LE + b'//\x01\xd8 '
 
 self.CheckFile(encoding=None, shouldPass=False, string=data)
 
 def testValidUtf8File(self):
 self.CheckFile(encoding='utf_8', shouldPass=True)
@@ -159,20 +159,20 @@ class Tests(TestTools.BaseToolsTest):
 # UTF-16 Surrogate Pairs.
 #
 # This test makes sure that BaseTools rejects these characters
 # if seen in a .uni file.
 #
-data = '\xed\xa0\x81'
+data = b'\xed\xa0\x81'
 
 self.CheckFile(encoding=None, shouldPass=False, string=data)
 
 def testSurrogatePairUnicodeCharInUtf8FileWithBom(self):
 #
 # Same test as testSurrogatePairUnicodeCharInUtf8File, but add
 # the UTF-8 BOM
 #
-data = codecs.BOM_UTF8 + '\xed\xa0\x81'
+data = codecs.BOM_UTF8 + b'\xed\xa0\x81'
 
 self.CheckFile(encoding=None, shouldPass=False, string=data)
 
 TheTestSuite = TestTools.MakeTheTestSuite(locals())
 
diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py
index e16e993048..4332dcdaac 100644
--- a/BaseTools/Tests/TestTools.py
+++ b/BaseTools/Tests/TestTools.py
@@ -38,11 +38,11 @@ if PythonSourceDir not in sys.path:
 #
 sys.path.append(PythonSourceDir)
 
 def MakeTheTestSuite(localItems):
 tests = []
-for name, item in localItems.iteritems():
+for name, item in localItems.items():
 if isinstance(item, type):
 if issubclass(item, unittest.TestCase):
 tests.append(unittest.TestLoader().loadTestsFromTestCase(item))
 elif issubclass(item, unittest.TestSuite):
 tests.append(item())
@@ -144,13 +144,16 @@ class BaseToolsTest(unittest.TestCase):
 data = f.read()
 f.close()
 return data
 
 def WriteTmpFile(self, fileName, data):
-f = open(self.GetTmpFilePath(fileName), 'w')
-f.write(data)
-f.close()
+if isinstance(data, bytes):
+with open(self.GetTmpFilePath(fileName), 'wb') as f:
+f.write(data)
+else:
+with open(self.GetTmpFilePath(fileName), 'w') as f:
+f.write(data)
 
 def GenRandomFileData(self, fileName, minlen = None, maxlen = None):
 if maxlen is None: maxlen = minlen
 f = self.OpenTmpFile(fileName, 'w')
 f.write(self.GetRandomString(minlen, maxlen))
@@ -159,11 +162,11 @@ class BaseToolsTest(unittest.TestCase):
 def GetRandomString(self, minlen = None, maxlen = None):
 if minlen is None: minlen = 1024
 if maxlen is None: maxlen = minlen
 return ''.join(
 [chr(random.randint(0, 255))
- for x in xrange(random.randint(minlen, maxlen))
+ for x in range(random.randint(minlen, maxlen))
 ])
 
 def setUp(self):
 self.savedEnvPath = os.environ['PATH']
 self.savedSysPath = sys.path[:]
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 06/33] BaseTools: nametuple not have verbose parameter in python3

2019-01-24 Thread Feng, Bob C
From: Yunhua Feng 

nametuple not have verbose parameter in python3

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng 
---
 BaseTools/Source/Python/Workspace/BuildClassObject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py 
b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index 73920c5153..b67414b930 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -353,11 +353,11 @@ class StructurePcd(PcdClassObject):
 new_pcd.PcdFieldValueFromComm = CopyDict(self.PcdFieldValueFromComm)
 new_pcd.PcdFieldValueFromFdf = CopyDict(self.PcdFieldValueFromFdf)
 new_pcd.ValueChain = {item for item in self.ValueChain}
 return new_pcd
 
-LibraryClassObject = namedtuple('LibraryClassObject', 
['LibraryClass','SupModList'], verbose=False)
+LibraryClassObject = namedtuple('LibraryClassObject', 
['LibraryClass','SupModList'])
 
 ## ModuleBuildClassObject
 #
 # This Class defines ModuleBuildClass
 #
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 15/33] Basetools: It went wrong when use os.linesep

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

in python2 and python3,use of line breaks

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 10 +-
 BaseTools/Source/Python/AutoGen/GenMake.py |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 0bed416c52..00ed804e62 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -679,31 +679,31 @@ class WorkspaceAutoGen(AutoGen):
 #
 # Create BuildOptions Macro & PCD metafile, also add the Active 
Platform and FDF file.
 #
 content = 'gCommandLineDefines: '
 content += str(GlobalData.gCommandLineDefines)
-content += os.linesep
+content += TAB_LINE_BREAK
 content += 'BuildOptionPcd: '
 content += str(GlobalData.BuildOptionPcd)
-content += os.linesep
+content += TAB_LINE_BREAK
 content += 'Active Platform: '
 content += str(self.Platform)
-content += os.linesep
+content += TAB_LINE_BREAK
 if self.FdfFile:
 content += 'Flash Image Definition: '
 content += str(self.FdfFile)
-content += os.linesep
+content += TAB_LINE_BREAK
 SaveFileOnChange(os.path.join(self.BuildDir, 'BuildOptions'), content, 
False)
 
 #
 # Create PcdToken Number file for Dynamic/DynamicEx Pcd.
 #
 PcdTokenNumber = 'PcdTokenNumber: '
 if Pa.PcdTokenNumber:
 if Pa.DynamicPcdList:
 for Pcd in Pa.DynamicPcdList:
-PcdTokenNumber += os.linesep
+PcdTokenNumber += TAB_LINE_BREAK
 PcdTokenNumber += str((Pcd.TokenCName, 
Pcd.TokenSpaceGuidCName))
 PcdTokenNumber += ' : '
 PcdTokenNumber += str(Pa.PcdTokenNumber[Pcd.TokenCName, 
Pcd.TokenSpaceGuidCName])
 SaveFileOnChange(os.path.join(self.BuildDir, 'PcdTokenNumber'), 
PcdTokenNumber, False)
 
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py 
b/BaseTools/Source/Python/AutoGen/GenMake.py
index 0e886967cc..3094a555e0 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -546,12 +546,12 @@ cleanlib:
 NewStr.append(Str)
 UnexpandMacroStr = ' '.join(UnexpandMacro)
 NewRespStr = ' '.join(NewStr)
 SaveFileOnChange(RespFile, NewRespStr, False)
 ToolsDef.append("%s = %s" % (Resp, UnexpandMacroStr + ' @' + 
RespFile))
-RespFileListContent += '@' + RespFile + os.linesep
-RespFileListContent += NewRespStr + os.linesep
+RespFileListContent += '@' + RespFile + TAB_LINE_BREAK
+RespFileListContent += NewRespStr + TAB_LINE_BREAK
 SaveFileOnChange(RespFileList, RespFileListContent, False)
 else:
 if os.path.exists(RespFileList):
 os.remove(RespFileList)
 
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 08/33] BaseTools: replace long by int

2019-01-24 Thread Feng, Bob C
From: Yunhua Feng 

replace long by int
Because the long() was not exist in Python3

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng 
---
 BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py |  4 ++--
 BaseTools/Source/Python/Common/Misc.py |  2 +-
 BaseTools/Source/Python/GenFds/AprioriSection.py   |  2 +-
 BaseTools/Source/Python/GenFds/FdfParser.py| 18 
+-
 BaseTools/Source/Python/GenFds/GenFds.py   |  8 
 BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py | 10 +-
 BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py |  4 ++--
 BaseTools/Source/Python/UPT/Parser/DecParser.py|  6 +++---
 8 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py 
b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
index edd40a1498..6ddf38fd0d 100644
--- a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
+++ b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
@@ -55,11 +55,11 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object):
 itemIndex = 0
 for item in var_check_tab.validtab:
 itemIndex += 1
 realLength += 5
 for v_data in item.data:
-if type(v_data) in (int, long):
+if isinstance(v_data, int):
 realLength += item.StorageWidth
 else:
 realLength += item.StorageWidth
 realLength += item.StorageWidth
 if (index == len(self.var_check_info)) :
@@ -135,11 +135,11 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object):
 
 b = pack("=B", item.StorageWidth)
 Buffer += b
 realLength += 1
 for v_data in item.data:
-if type(v_data) in (int, long):
+if isinstance(v_data, int):
 b = pack(PACK_CODE_BY_SIZE[item.StorageWidth], v_data)
 Buffer += b
 realLength += item.StorageWidth
 else:
 b = pack(PACK_CODE_BY_SIZE[item.StorageWidth], 
v_data[0])
diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index a4aaff0837..83dabc9393 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1376,11 +1376,11 @@ def CheckPcdDatum(Type, Value):
   ", FALSE, False, false, 0x0, 0x00, 0" % (Value, Type)
 elif Type in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64]:
 if Value and int(Value, 0) < 0:
 return False, "PCD can't be set to negative value[%s] for datum 
type [%s]" % (Value, Type)
 try:
-Value = long(Value, 0)
+Value = int(Value, 0)
 if Value > MAX_VAL_TYPE[Type]:
 return False, "Too large PCD value[%s] for datum type [%s]" % 
(Value, Type)
 except:
 return False, "Invalid value [%s] of type [%s];"\
   " must be a hexadecimal, decimal or octal in C 
language format." % (Value, Type)
diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py 
b/BaseTools/Source/Python/GenFds/AprioriSection.py
index e7b856a115..55d99320c7 100644
--- a/BaseTools/Source/Python/GenFds/AprioriSection.py
+++ b/BaseTools/Source/Python/GenFds/AprioriSection.py
@@ -95,11 +95,11 @@ class AprioriSection (object):
 EdkLoggerError("GenFds", RESOURCE_NOT_AVAILABLE,
 "INF %s not found in build ARCH %s!" \
 % (InfFileName, 
GenFdsGlobalVariable.ArchList))
 
 GuidPart = Guid.split('-')
-Buffer.write(pack('I', long(GuidPart[0], 16)))
+Buffer.write(pack('I', int(GuidPart[0], 16)))
 Buffer.write(pack('H', int(GuidPart[1], 16)))
 Buffer.write(pack('H', int(GuidPart[2], 16)))
 
 for Num in range(2):
 Char = GuidPart[3][Num*2:Num*2+2]
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index 3bcfd2d42a..69cb7de8e5 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1560,11 +1560,11 @@ class FdfParser:
 Obj.SizePcd = pcdPair
 self.Profile.PcdDict[pcdPair] = Size
 self.SetPcdLocalation(pcdPair)
 FileLineTuple = GetRealFileLine(self.FileName, 
self.CurrentLineNumber)
 self.Profile.PcdFileLineDict[pcdPair] = FileLineTuple
-Obj.Size = long(Size, 0)
+Obj.Size = int(Size, 0)
 return

[edk2] [Patch 09/33] BaseTools:Solve the data sorting problem use python3

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

set PYTHONHASHSEED
Specifying the value 0 will disable hash randomization.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/toolsetup.bat | 1 +
 edksetup.sh | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat
index b58560d4d7..1cac3105c2 100755
--- a/BaseTools/toolsetup.bat
+++ b/BaseTools/toolsetup.bat
@@ -272,10 +272,11 @@ goto check_build_environment
   echo.
   echo !!! ERROR !!! Binary C tools are missing. They are requried to be built 
from BaseTools Source.
   echo.
 
 :check_build_environment
+  set PYTHONHASHSEED=0
   if defined BASETOOLS_PYTHON_SOURCE goto VisualStudioAvailable
 
   if not defined BASE_TOOLS_PATH (
  if not exist "Source\C\Makefile" (
if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files
diff --git a/edksetup.sh b/edksetup.sh
index 93d6525758..3dee8c5d61 100755
--- a/edksetup.sh
+++ b/edksetup.sh
@@ -75,11 +75,11 @@ function SetWorkspace()
 
   #
   # Set $WORKSPACE
   #
   export WORKSPACE=`pwd`
-
+  export PYTHONHASHSEED=0
   return 0
 }
 
 function SetupEnv()
 {
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 07/33] BaseTools: Remove unnecessary super function

2019-01-24 Thread Feng, Bob C
From: Yunhua Feng 

Remove unnecessary super function

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 5 -
 1 file changed, 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index f4cfb0830d..0bed416c52 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -267,12 +267,10 @@ class AutoGen(object):
 return cls.__ObjectCache[Key]
 # it didnt exist. create it, cache it, then return it
 RetVal = cls.__ObjectCache[Key] = super(AutoGen, cls).__new__(cls)
 return RetVal
 
-def __init__ (self, Workspace, MetaFile, Target, Toolchain, Arch, *args, 
**kwargs):
-super(AutoGen, self).__init__(self, Workspace, MetaFile, Target, 
Toolchain, Arch, *args, **kwargs)
 
 ## hash() operator
 #
 #  The file path of platform file will be used to represent hash value of 
this object
 #
@@ -301,11 +299,10 @@ class AutoGen(object):
 #
 class WorkspaceAutoGen(AutoGen):
 # call super().__init__ then call the worker function with different 
parameter count
 def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, 
**kwargs):
 if not hasattr(self, "_Init"):
-super(WorkspaceAutoGen, self).__init__(Workspace, MetaFile, 
Target, Toolchain, Arch, *args, **kwargs)
 self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, 
*args, **kwargs)
 self._Init = True
 
 ## Initialize WorkspaceAutoGen
 #
@@ -1092,11 +1089,10 @@ class WorkspaceAutoGen(AutoGen):
 #
 class PlatformAutoGen(AutoGen):
 # call super().__init__ then call the worker function with different 
parameter count
 def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, 
**kwargs):
 if not hasattr(self, "_Init"):
-super(PlatformAutoGen, self).__init__(self, Workspace, MetaFile, 
Target, Toolchain, Arch, *args, **kwargs)
 self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch)
 self._Init = True
 #
 # Used to store all PCDs for both PEI and DXE phase, in order to generate
 # correct PCD database
@@ -2524,11 +2520,10 @@ def _MakeDir(PathList):
 #
 class ModuleAutoGen(AutoGen):
 # call super().__init__ then call the worker function with different 
parameter count
 def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, 
**kwargs):
 if not hasattr(self, "_Init"):
-super(ModuleAutoGen, self).__init__(Workspace, MetaFile, Target, 
Toolchain, Arch, *args, **kwargs)
 self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, 
*args)
 self._Init = True
 
 ## Cache the timestamps of metafiles of every module in a class attribute
 #
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 03/33] BaseTools: Rename iteritems to items

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

replace the list iteritems by items in Python3.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/GenMake.py| 6 +++---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 2 +-
 BaseTools/Source/Python/build/build.py| 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py 
b/BaseTools/Source/Python/AutoGen/GenMake.py
index 4da10e3950..0e886967cc 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -483,11 +483,11 @@ cleanlib:
 ImageEntryPoint = "EfiStart"
 else:
 # EdkII modules always use "_ModuleEntryPoint" as entry point
 ImageEntryPoint = "_ModuleEntryPoint"
 
-for k, v in MyAgo.Module.Defines.iteritems():
+for k, v in MyAgo.Module.Defines.items():
 if k not in MyAgo.Macros:
 MyAgo.Macros[k] = v
 
 if 'MODULE_ENTRY_POINT' not in MyAgo.Macros:
 MyAgo.Macros['MODULE_ENTRY_POINT'] = ModuleEntryPoint
@@ -495,11 +495,11 @@ cleanlib:
 MyAgo.Macros['ARCH_ENTRY_POINT'] = ArchEntryPoint
 if 'IMAGE_ENTRY_POINT' not in MyAgo.Macros:
 MyAgo.Macros['IMAGE_ENTRY_POINT'] = ImageEntryPoint
 
 PCI_COMPRESS_Flag = False
-for k, v in MyAgo.Module.Defines.iteritems():
+for k, v in MyAgo.Module.Defines.items():
 if 'PCI_COMPRESS' == k and 'TRUE' == v:
 PCI_COMPRESS_Flag = True
 
 # tools definitions
 ToolsDef = []
@@ -659,11 +659,11 @@ cleanlib:
 "module_file"   : MyAgo.MetaFile.Name,
 "module_file_base_name" : MyAgo.MetaFile.BaseName,
 "module_relative_directory" : MyAgo.SourceDir,
 "module_dir": mws.join (self.Macros["WORKSPACE"], 
MyAgo.SourceDir),
 "package_relative_directory": package_rel_dir,
-"module_extra_defines"  : ["%s = %s" % (k, v) for k, v in 
MyAgo.Module.Defines.iteritems()],
+"module_extra_defines"  : ["%s = %s" % (k, v) for k, v in 
MyAgo.Module.Defines.items()],
 
 "architecture"  : MyAgo.Arch,
 "toolchain_tag" : MyAgo.ToolChain,
 "build_target"  : MyAgo.BuildTarget,
 
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 0dad04212e..9c5596927f 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1674,11 +1674,11 @@ class DscBuildData(PlatformBuildClassObject):
 if (PcdCName, TokenSpaceGuid) in PcdValueDict:
 PcdValueDict[PcdCName, TokenSpaceGuid][SkuName] = (PcdValue, 
DatumType, MaxDatumSize)
 else:
 PcdValueDict[PcdCName, TokenSpaceGuid] = {SkuName:(PcdValue, 
DatumType, MaxDatumSize)}
 
-for ((PcdCName, TokenSpaceGuid), PcdSetting) in 
PcdValueDict.iteritems():
+for ((PcdCName, TokenSpaceGuid), PcdSetting) in PcdValueDict.items():
 if self.SkuIdMgr.SystemSkuId in PcdSetting:
 PcdValue, DatumType, MaxDatumSize = 
PcdSetting[self.SkuIdMgr.SystemSkuId]
 elif TAB_DEFAULT in PcdSetting:
 PcdValue, DatumType, MaxDatumSize = PcdSetting[TAB_DEFAULT]
 elif TAB_COMMON in PcdSetting:
diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index 3266333cc4..b7aefc9ae7 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -2123,11 +2123,11 @@ class Build():
 # Build up the list of supported architectures for this 
build
 prefix = '%s_%s_%s_' % (BuildTarget, ToolChain, Arch)
 
 # Look through the tool definitions for GUIDed tools
 guidAttribs = []
-for (attrib, value) in 
self.ToolDef.ToolsDefTxtDictionary.iteritems():
+for (attrib, value) in 
self.ToolDef.ToolsDefTxtDictionary.items():
 if attrib.upper().endswith('_GUID'):
 split = attrib.split('_')
 thisPrefix = '_'.join(split[0:3]) + '_'
 if thisPrefix == prefix:
 guid = 
self.ToolDef.ToolsDefTxtDictionary[attrib]
-- 
2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 11/33] BaseTools:Similar to octal data rectification

2019-01-24 Thread Feng, Bob C
From: Zhijux Fan 

In python3, if Value is octal data, the int(Value, 0) report an error

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/GenC.py   |  2 ++
 BaseTools/Source/Python/Common/Misc.py|  6 --
 BaseTools/Source/Python/Workspace/DscBuildData.py |  3 ++-
 BaseTools/Source/Python/build/BuildReport.py  | 12 
 4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index 500a78f058..915ba2e235 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1008,10 +1008,12 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
 
 if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES:
 try:
 if Value.upper().endswith('L'):
 Value = Value[:-1]
+if Value.startswith('0') and not 
Value.lower().startswith('0x') and len(Value) > 2:
+Value = Value.lstrip('0')
 ValueNumber = int (Value, 0)
 except:
 EdkLogger.error("build", AUTOGEN_ERROR,
 "PCD value is not valid dec or hex number for 
datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, 
TokenCName),
 ExtraData="[%s]" % str(Info))
diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index 83dabc9393..4c7eb449ca 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1373,13 +1373,15 @@ def CheckPcdDatum(Type, Value):
 elif Type == 'BOOLEAN':
 if Value not in ['TRUE', 'True', 'true', '0x1', '0x01', '1', 'FALSE', 
'False', 'false', '0x0', '0x00', '0']:
 return False, "Invalid value [%s] of type [%s]; must be one of 
TRUE, True, true, 0x1, 0x01, 1"\
   ", FALSE, False, false, 0x0, 0x00, 0" % (Value, Type)
 elif Type in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64]:
-if Value and int(Value, 0) < 0:
-return False, "PCD can't be set to negative value[%s] for datum 
type [%s]" % (Value, Type)
+if Value.startswith('0') and not Value.lower().startswith('0x') and 
len(Value) > 2:
+Value = Value.lstrip('0')
 try:
+if Value and int(Value, 0) < 0:
+return False, "PCD can't be set to negative value[%s] for 
datum type [%s]" % (Value, Type)
 Value = int(Value, 0)
 if Value > MAX_VAL_TYPE[Type]:
 return False, "Too large PCD value[%s] for datum type [%s]" % 
(Value, Type)
 except:
 return False, "Invalid value [%s] of type [%s];"\
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 9c5596927f..c2bc705091 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -37,10 +37,11 @@ from Common.Misc import ProcessDuplicatedInf,RemoveCComments
 import re
 from Common.Parsing import IsValidWord
 from Common.VariableAttributes import VariableAttributes
 import Common.GlobalData as GlobalData
 import subprocess
+from functools import reduce
 from Common.Misc import SaveFileOnChange
 from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, 
PcdClassObject, ModuleBuildClassObject
 from collections import OrderedDict, defaultdict
 from .BuildClassObject import ArrayIndex
 
@@ -1926,11 +1927,11 @@ class DscBuildData(PlatformBuildClassObject):
 index_elements = ArrayIndex.findall(index)
 pcd_capacity = Pcd.Capacity
 if index:
 indicator = "(Pcd"
 if len(pcd_capacity)>2:
-for i in xrange(0,len(index_elements)):
+for i in range(0,len(index_elements)):
 index_ele = index_elements[i]
 index_num = index_ele.strip("[").strip("]").strip()
 if i == len(index_elements) -2:
 indicator += "+ %d*Size/sizeof(%s)/%d + %s)" 
%(int(cleanupindex(index_elements[i+1])),Pcd.BaseDatumType,reduce(lambda x,y: 
int(x)*int(y),pcd_capacity[:-1]), cleanupindex(index_elements[i]))
 break
diff --git a/BaseTools/Source/Python/build/BuildReport.py 
b/BaseTools/Source/Python/build/BuildReport.py
index ae37a6ce0e..2f2c3b2d83 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -1024,26 +1024,34 @@ class PcdReport(object):
 FileWrite(File, Key)
 First = False
 
 
 if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES:
+if PcdValue.startswith('0') and not 
PcdValue.lower().startswith('0x') and le

[edk2] [Patch 00/33] BaseTools python3 migration patch set

2019-01-24 Thread Feng, Bob C
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=55

This patch set is to enable python3 on BaseTools. Basetools code will be
compatible with both python3 and python2.

We will have two envs PYTHON3_ENABLE and PYTHON_COMMAND. The behavior can be 
combined as the below to support this usage.
If user wants the specific python interpreter, he only needs to set 
PYTHON_COMMAND env.
If PYTHON3_ENABLE is set, PYTHON_COMMAND will be set to the found one by edk2 
scripts based on PYTHON3_ENABLE value. 
If PYTHON3_ENABLE is not set, but PYTHON_COMMAND is set, then PYTHON_COMMAND 
will be used to run python script. No version check here. 
If PYTHON3_ENABLE is not set, but PYTHON_COMMAND is not set, PYTHON_COMMAND 
will be set to the high version python installed in OS. 

This patch set is verified by basic testing on Ovmf, MinKabylake and MinPurley 
platform with Python3.7.1 and 
minimal testing on Ovmf, MinKabylake and MinPurley with Python2.7.15. 

After this change, we will focus on the Python3 validation.

You can also review and try the patch set at https://github.com/BobCF/edk2.git 
branch py3basetools

Feng, Bob C (8):
  BaseTools: Make sure AllPcdList valid.
  BaseTools:File open failed for VPD MapFile
  BaseTools:Fixed Rsa issue and a set define issue.
  BaseTools:ord() don't match in py2 and py3
  BaseTools: the list and iterator translation
  BaseTools: Handle the bytes and str difference
  BaseTools: ECC tool Python3 adaption
  BaseTools: Eot tool Python3 adaption

Liming Gao (1):
  BaseTools: Update PYTHON env to the specific one PYTHON_COMMAND

Yunhua Feng (4):
  BaseTools: use OrderedDict instead of sdict
  BaseTools: nametuple not have verbose parameter in python3
  BaseTools: Remove unnecessary super function
  BaseTools: replace long by int

Zhiju Fan (3):
  BaseTools:TestTools character encoding issue
  BaseTools:Double carriage return inserted from Trim.py on Python3
  BaseTools:There is extra blank line in datalog

Zhijux Fan (17):
  BaseTool:Rename xrange() to range()
  BaseTools:use iterate list to replace the itertools
  BaseTools: Rename iteritems to items
  BaseTools: replace get_bytes_le() to bytes_le
  BaseTools:Solve the data sorting problem use python3
  BaseTools: Update argparse arguments since it not have version now
  BaseTools:Similar to octal data rectification
  BaseTools/UPT:merge UPT Tool use Python2 and Python3
  BaseTools: update Test scripts support python3
  BaseTools/Scripts: Porting PackageDocumentTools code to use Python3
  Basetools: It went wrong when use os.linesep
  BaseTools:Fv BaseAddress must set If it not set
  BaseTools: change the Division Operator
  BaseTools: Similar to octal data rectification
  BaseTools: Update windows and linux run scripts file to use Python3
  BaseTools:Update build tool to print python version information
  BaseTools:Linux Python highest version check.

 BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc   
 |6 +-
 BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex  
 |6 +-
 BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds
 |6 +-
 BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool
 |6 +-
 BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim  
 |6 +-
 BaseTools/Bin/CYGWIN_NT-5.1-i686/build 
 |6 +-
 BaseTools/BinWrappers/PosixLike/BPDG   
 |6 +-
 BaseTools/BinWrappers/PosixLike/Ecc
 |6 +-
 BaseTools/BinWrappers/PosixLike/GenDepex   
 |6 +-
 BaseTools/BinWrappers/PosixLike/GenFds 
 |6 +-
 BaseTools/BinWrappers/PosixLike/GenPatchPcdTable   
 |6 +-
 BaseTools/BinWrappers/PosixLike/GenerateCapsule
 |6 +-
 BaseTools/BinWrappers/PosixLike/PatchPcdValue  
 |6 +-
 BaseTools/BinWrappers/PosixLike/Pkcs7Sign  
 |6 +-
 BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys  
 |6 +-
 BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign  
 |6 +-
 BaseTools/BinWrappers/PosixLike/TargetTool 
 |6 +-
 BaseTools/BinWrappers/PosixLike/Trim   
 |6 +-
 BaseTools/BinWrappers/PosixLike/UPT
 |6 +-
 BaseTools/BinWrappers/PosixLike/build  
 |6 +-
 BaseTools/BinWrappers/WindowsLike/BPDG.bat 
 |2 +-
 BaseTools/BinWrappers

Re: [edk2] [PATCH] MdeModulePkg VariableStandaloneMm: Add PcdEmuVariableNvModeEnable in inf

2019-01-24 Thread Zeng, Star
Thanks.

I just pushed it at 9084239f3440369fcb5ff0476d9bdd9442a03258 since it is a 
build failure.


Star
-Original Message-
From: Wang, Jian J 
Sent: Friday, January 25, 2019 9:42 AM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Wu, Hao A ; Ard Biesheuvel ; 
Bi, Dandan 
Subject: RE: [PATCH] MdeModulePkg VariableStandaloneMm: Add 
PcdEmuVariableNvModeEnable in inf


Reviewed-by: Jian J Wang 


> -Original Message-
> From: Zeng, Star
> Sent: Friday, January 25, 2019 9:23 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Wang, Jian J 
> ; Wu, Hao A ; Ard 
> Biesheuvel ; Bi, Dandan 
> 
> Subject: [PATCH] MdeModulePkg VariableStandaloneMm: Add 
> PcdEmuVariableNvModeEnable in inf
> 
> It was missed in 7cd69959463ac9c761163ed8e8a93907b68e70da when 
> rebasing the patches after 688b2cad7b712493f2cf8b6948ab795545e13961 
> added VariableStandaloneMm.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Ard Biesheuvel 
> Cc: Dandan Bi 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 
> 4
> +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> index efb84ed87832..07436d3cb6ae 100644
> ---
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> +++
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> @@ -18,7 +18,7 @@
>  #  may not be modified without authorization. If platform fails to 
> protect these resources,  #  the authentication service provided in 
> this driver will be broken, and the behavior is undefined.
>  #
> -# Copyright (c) 2010 - 2016, Intel Corporation. All rights 
> reserved.
> +# Copyright (c) 2010 - 2019, Intel Corporation. All rights 
> +reserved.
>  # Copyright (c) 2018, Linaro, Ltd. All rights reserved.  # This 
> program and the accompanying materials  # are licensed and made 
> available under the terms and conditions of the BSD License @@ -127,6 
> +127,8 @@ [FixedPcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdMaxUserNvVariableSpaceSize   ##
> CONSUMES
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdBoottimeReservedNvVariableSpaceSize
> ## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdReclaimVariableSpaceAtEndOfDxe   ##
> CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable  ##
> SOMETIMES_CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved   ##
> SOMETIMES_CONSUMES
> 
>  [FeaturePcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics##
> CONSUMES  # statistic the information of variable.
> --
> 2.13.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] Do python3 supported in edk2 shell now?

2019-01-24 Thread wang xiaofeng
HI All,
   I only see AppPkg/Applications/Python/2.7.10 in latest edk2 tree. Do edk2 
plan to support python3 in shell ?
  Thanks!
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [question] A piece of log.txt showed in uefi shell is not the same as showed in notepad++

2019-01-24 Thread krishnaLee
Andrew Fish,
Yes,I know it ,from a terminal's view,the 0x0C/0x0D/0x0E/...,some invisible 
chars like this have special means,
and I also think from a text-editor's view, I think the text-editor just do not 
show them,and should make sure all visible chars can visible,
but I think I am wrong.


> How did you dump the log?
I got a piece of buffer from uefi-shell's screen-buffer,when I output my 
buffer,I find it is not correctly aligned as history output.
because the screen-buffer's width is 'terminal_column_size + 2',the last extra 
two UINT16 maked this question,
I think when the terminal output a full line(terminal_column_size),it will 
automatically go to new line's begin,
CR is means go to most left corner of screen,,so I make the last two char with 
"CR+CR",the cursor will stay at the new line's begin;
and make the (CHAR16==0) to (CHAR16==SPACE),so all lines are (full 
line+CR+CR),except last line end is (CR+LF),
 and the result is aligned as the history showed.
but some times the result is missed some strings...


I may got what happened,the question is "...make the (CHAR16==0) to 
(CHAR16==SPACE),so all lines are (full line+CR+CR)",
the lines may not all full line because some invisible will taken no space in 
terminal,it is not a full line,so CR+CR will make the line 
overlapped/disappeared.
I had mixed using text-editor's view and terminal's view in uefi,it's my fault.
I can duplicate this fault by follow test code:
//test-code-start
EFI_STATUS
EFIAPI
UefiMain (
  IN EFI_HANDLEImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  EFI_STATUS status;
  EFI_SHELL_PROTOCOL* shell;
  EFI_SHELL_PARAMETERS_PROTOCOL*  param;
#defineONE_LINE (100+2)
  CHAR16 buffer[ONE_LINE];
  UINTN bufferSize = ONE_LINE *sizeof(CHAR16);


for(UINTN i=0;iLocateProtocol(&gEfiShellProtocolGuid,NULL,&(shell));
if(status!=EFI_SUCCESS)
  {
return0;
  }


  
status=gBS->HandleProtocol(gImageHandle,&gEfiShellParametersProtocolGuid,&(param));
if(status!=EFI_SUCCESS)
  {
return0;
  }


Print(L"test1:\n");
  shell->WriteFile(param->StdOut,&bufferSize,buffer);
  shell->FlushFile(param->StdOut);


Print(L"test2:\n");
  buffer[ONE_LINE-9]=0x000D;
  buffer[ONE_LINE-5]=0x000D;
  shell->WriteFile(param->StdOut,&bufferSize,buffer);
  shell->FlushFile(param->StdOut);


return EFI_SUCCESS;
}
//test-code-end
thank you,
krishna.



At 2019-01-25 01:45:00, "Andrew Fish"  wrote:
Krishna,


From an EFI point of view BackSpace 0x08, LF 0x0A, and CR 0xD are defined for a 
ConOut device. 


From Ascii Control Codes:
0x0C - Form Feed
0x0E - Shift Out


The Shift Out is used with graphics characters. 


How did you dump the log? If EFI sends data to a serial terminal then it would 
use terminal emulation and the output stream would look different. 


Thanks,


Andrew Fish



On Jan 23, 2019, at 11:07 PM, krishnaLee  wrote:


Andrew Fish,
thank you,in this case,you are right.
but I think there may be other case that the user data just contain some 
nosense-data
such as { UINT16 MyData[]={0x000c,0x000d,0x000d,0x000e}  } to the editor, 
the uefi editor may also meet this question,the editor may do not need output 
this,
but the editor should make sure other visible chars can output normal...


I don't know if it is a bug or not.


Thank you very much.
krishna.





在 2019-01-24 12:13:50,"Andrew Fish"  写道:

On Jan 23, 2019, at 7:17 PM, krishnaLee  wrote:


Hi,
I dumped a small log.txt from my work,but the log.txt showed in uefi shell,is 
not the same as it showed in notepad++.
I had upload the log here:
https://github.com/krishna116/test/blob/master/log.zip


it seems the log showed in uefi shell had missed some strings...I don't know 
why,please help,




Krishna,


Your log.txt looks like a normal UTF-16 Unicode file. The leading  FF FE is the 
Byte order mark for UTF-16 Little Endian [1].  The file looks like it has CR 
line endings [2] so maybe that is confusing your editor? There seems to be a CR 
LF at the end, so the mixture of line ending may even be more likely confusing 
the editor. The byte order mark should let your editor know it is 16-bit 
Unicode and the correct endian. Hope this helps...



$ hexdump -C /Users/andrewfish/Downloads/log/log.txt 
  ff fe 20 00 20 00 20 00  4d 00 58 00 32 00 35 00  |.. . . .M.X.2.5.|
0010  4c 00 31 00 32 00 38 00  37 00 35 00 46 00 20 00  |L.1.2.8.7.5.F. .|
0020  20 00 20 00 20 00 49 00  44 00 3a 00 30 00 78 00  | . . .I.D.:.0.x.|
0030  43 00 32 00 32 00 30 00  31 00 38 00 20 00 20 00  |C.2.2.0.1.8. . .|
0040  20 00 20 00 53 00 69 00  7a 00 65 00 3a 00 20 00  | . .S.i.z.e.:. .|
0050  31 00 36 00 33 00 38 00  34 00 4b 00 42 00 20 00  |1.6.3.8.4.K.B. .|
0060  28 00 31 00 33 00 31 00  30 00 37 00 32 00 4b 00  |(.1.3.1.0.7.2.K.|
0070  62 00 29 00 20 00 20 00  20 00 20 00 20 00 20 00  |b.). . . . . . .|
0080  20 00 20 00 20 00 20 00  20 00 20 00 20 00 20 00  | . . . . . . . .|
*
00c0  20 00 20 00 20 00 20 00  0d 00 0d 00 20 00 20 00 

Re: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for enable GPT support

2019-01-24 Thread Wu, Hao A
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Chen A Chen
> Sent: Thursday, January 17, 2019 10:03 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D; Zhang, Chao B; Gao, Liming
> Subject: [edk2] [PATCH 2/2] MdePkg/UefiGpt.h: Add new definition for
> enable GPT support
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1470
> This two new definitions are defined for GPT in FatPei diver.
> 
> Cc: Liming Gao 
> Cc: Michael D Kinney 
> Cc: Zhang Chao B 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chen A Chen 
> ---
>  MdePkg/Include/Uefi/UefiGpt.h | 16 
>  1 file changed, 16 insertions(+)
> 
> diff --git a/MdePkg/Include/Uefi/UefiGpt.h
> b/MdePkg/Include/Uefi/UefiGpt.h
> index f635b05390..8665c8cbc9 100644
> --- a/MdePkg/Include/Uefi/UefiGpt.h
> +++ b/MdePkg/Include/Uefi/UefiGpt.h
> @@ -24,9 +24,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
>  /// EFI Partition Table Signature: "EFI PART".
>  ///
>  #define EFI_PTAB_HEADER_ID  SIGNATURE_64 ('E','F','I',' 
> ','P','A','R','T')
> +///
> +/// Minimum bytes reserve for EFI entry array buffer.
> +///
> +#define GPT_PART_ENTRY_MIN_SIZE 16384

May I know where this definition comes from?
Does it come from the UEFI spec?

> 
>  #pragma pack(1)
> 
> +///
> +/// MBR Partition Entry
> +///
> +typedef struct {
> +  UINT8   BootIndicator;
> +  UINT8   StartingCHS[3];
> +  UINT8   OSType;
> +  UINT8   EndingCHS[3];
> +  UINT32  StartingLBA;
> +  UINT32  SizeInLBA;
> +} MBR_PARTITION_ENTRY;
> +

What about using the 'MBR_PARTITION_RECORD' definition within
edk2/MdePkg/Include/IndustryStandard/Mbr.h

and thus get rid of adding this one?

Best Regards,
Hao Wu

>  ///
>  /// GPT Partition Table Header.
>  ///
> --
> 2.16.2.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] IntelFsp2Pkg: FSP can utilize bootloader stack

2019-01-24 Thread Zeng, Star

On 2019/1/23 17:33, Chasel, Chiu wrote:

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

Current FSP utilizes pre-allocated temporary memory from
boot loader for both heap and stack. To reduce overall
temporary memory usage FSP may share the same stack with
boot loader and only needs a smaller memory for heap,
no separate memory required for stack.
Setting PcdFspHeapSizePercentage to 0 to enable FSP sharing
stack with boot loader, in this case boot loader stack
has to be large enough for FSP to use. Default is 50
(half memory heap and half memory stack) for backward
compatible with original model.

Test: Verified on internal platform and booting successfully
   with both modes.

Cc: Nate DeSimone 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 


Minor comments below. With them addressed, Reviewed-by: Star Zeng 
.



---
  IntelFsp2Pkg/FspSecCore/SecMain.c  | 86 
++
  IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf|  3 ++-
  IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm | 52 
++--
  IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm  | 28 

  IntelFsp2Pkg/IntelFsp2Pkg.dec  |  4 
  5 files changed, 154 insertions(+), 19 deletions(-)

diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c 
b/IntelFsp2Pkg/FspSecCore/SecMain.c
index 70460a3c8b..b0b5dda711 100644
--- a/IntelFsp2Pkg/FspSecCore/SecMain.c
+++ b/IntelFsp2Pkg/FspSecCore/SecMain.c
@@ -1,6 +1,6 @@
  /** @file
  
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.

+  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD 
License
which accompanies this distribution.  The full text of the license may be 
found at
@@ -38,6 +38,19 @@ UINT64  mIdtEntryTemplate = 0x8e08ffe4ULL;
  
  /**
  
+  Return value of esp

+
+  @return  value of esp
+
+**/
+UINT32
+EFIAPI
+AsmReadEsp (
+  VOID
+  );
+
+/**
+
Entry point to the C language phase of SEC. After the SEC assembly
code has initialized some temporary memory and set up the stack,
the control is transferred to this function.
@@ -83,7 +96,26 @@ SecStartup (
//
InitializeFloatingPointUnits ();
  
+  //

+  // Scenario 1 memory map when running on bootloader stack
+  //
+  // |---|>
+  // |Idt Table  |
+  // |---|
+  // |PeiService Pointer |
+  // |---|
+  // |   |
+  // |   |
+  // |  Heap |
+  // |   |
+  // |   |
+  // |---|>  TempRamBase
+  // |Bootloader stack   |
+  // |---|


The Bootloader stack range and TempRam range should be separated and 
should be not adjacent. How about drawing them separated here to remove 
the confusion?


Another, maybe we can propose AsmReadEsp to BaseLib for long term. :)


Thanks,
Star

  
+  //

+  // Scenario 2 memory map when running FSP on a separate stack
+  //
// |---|>
// |Idt Table  |
// |---|
@@ -135,11 +167,19 @@ SecStartup (
SecCoreData.BootFirmwareVolumeSize = (UINT32)((EFI_FIRMWARE_VOLUME_HEADER 
*)BootFirmwareVolume)->FvLength;
  
SecCoreData.TemporaryRamBase   = (VOID*)(UINTN) TempRamBase;

-  SecCoreData.TemporaryRamSize   = SizeOfRam;
-  SecCoreData.PeiTemporaryRamBase= SecCoreData.TemporaryRamBase;
-  SecCoreData.PeiTemporaryRamSize= SecCoreData.TemporaryRamSize * PcdGet8 
(PcdFspHeapSizePercentage) / 100;
-  SecCoreData.StackBase  = 
(VOID*)(UINTN)((UINTN)SecCoreData.TemporaryRamBase + 
SecCoreData.PeiTemporaryRamSize);
-  SecCoreData.StackSize  = SecCoreData.TemporaryRamSize - 
SecCoreData.PeiTemporaryRamSize;
+  if (PcdGet8 (PcdFspHeapSizePercentage) == 0) {
+SecCoreData.TemporaryRamSize   = SizeOfRam; // stack size that is 
going to be copied to the permanent memory
+SecCoreData.PeiTemporaryRamBase= SecCoreData.TemporaryRamBase;
+SecCoreData.PeiTemporaryRamSize= SecCoreData.TemporaryRamSize;
+SecCoreData.StackBase  = (VOID *)GetFspEntryStack(); // Share 
the same boot loader stack
+SecCoreData.StackSize  = 0;
+  } else {
+SecCoreData.TemporaryRamSize   = SizeOfRam;
+SecCoreData.PeiTemporaryRamBase= SecCoreData.TemporaryRamBase;
+SecCoreData.PeiTemporaryRamSize= SecCoreData.TemporaryRamSize * 
PcdGet8 (PcdFspHeapSizePercentage) / 100;
+SecCoreData.StackBase  = 
(VOID*)(UINTN)((UINTN)SecCoreData.TemporaryRamBase + 
SecCoreData.PeiTemporaryRamSize);
+SecCoreData.StackSize  = SecCoreData.TemporaryRamSize - 
SecCoreData.PeiTemporaryRamSize;
+  }
  
   

Re: [edk2] [PATCH] MdeModulePkg VariableStandaloneMm: Add PcdEmuVariableNvModeEnable in inf

2019-01-24 Thread Wang, Jian J


Reviewed-by: Jian J Wang 


> -Original Message-
> From: Zeng, Star
> Sent: Friday, January 25, 2019 9:23 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Wang, Jian J ;
> Wu, Hao A ; Ard Biesheuvel ;
> Bi, Dandan 
> Subject: [PATCH] MdeModulePkg VariableStandaloneMm: Add
> PcdEmuVariableNvModeEnable in inf
> 
> It was missed in 7cd69959463ac9c761163ed8e8a93907b68e70da when rebasing
> the patches after 688b2cad7b712493f2cf8b6948ab795545e13961 added
> VariableStandaloneMm.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Ard Biesheuvel 
> Cc: Dandan Bi 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 4
> +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> index efb84ed87832..07436d3cb6ae 100644
> ---
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> +++
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> @@ -18,7 +18,7 @@
>  #  may not be modified without authorization. If platform fails to protect 
> these
> resources,
>  #  the authentication service provided in this driver will be broken, and the
> behavior is undefined.
>  #
> -# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
> +# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
>  # Copyright (c) 2018, Linaro, Ltd. All rights reserved.
>  # This program and the accompanying materials
>  # are licensed and made available under the terms and conditions of the BSD
> License
> @@ -127,6 +127,8 @@ [FixedPcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdMaxUserNvVariableSpaceSize   ##
> CONSUMES
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdBoottimeReservedNvVariableSpaceSize
> ## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdReclaimVariableSpaceAtEndOfDxe   ##
> CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable  ##
> SOMETIMES_CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved   ##
> SOMETIMES_CONSUMES
> 
>  [FeaturePcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics##
> CONSUMES  # statistic the information of variable.
> --
> 2.13.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2] MinPlatformPkg: Support TCO base locked by FSP

2019-01-24 Thread Kubacki, Michael A
Reviewed-by: Michael Kubacki  

> -Original Message-
> From: Chiu, Chasel
> Sent: Wednesday, January 16, 2019 11:16 PM
> To: edk2-devel@lists.01.org
> Cc: Kubacki, Michael A ; Yao, Jiewen
> ; Chiu, Chasel 
> Subject: [PATCH v2] MinPlatformPkg: Support TCO base locked by FSP
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1457
> 
> Per security recommendation TCO Base should be initialized and locked by
> FSP and MinPlatform should support both TCO Base locked and not locked
> scenarios.
> 
> Cc: Michael A Kubacki 
> Cc: Jiewen Yao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chasel Chiu 
> ---
>  Silicon/Intel/KabylakeSiliconPkg/Library/SiliconInitLib/SiliconInitPreMem.c
> |  8 +---
> 
> Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodingLi
> b/PchCycleDecodingLib.c | 48
> 
>  Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Library/PchCycleDecodingLib.h
> | 18 +-
>  3 files changed, 62 insertions(+), 12 deletions(-)
> 
> diff --git
> a/Silicon/Intel/KabylakeSiliconPkg/Library/SiliconInitLib/SiliconInitPreMem.c
> b/Silicon/Intel/KabylakeSiliconPkg/Library/SiliconInitLib/SiliconInitPreMem.c
> index 616584ffe7..bb21872e1e 100644
> ---
> a/Silicon/Intel/KabylakeSiliconPkg/Library/SiliconInitLib/SiliconInitPreMem.c
> +++ b/Silicon/Intel/KabylakeSiliconPkg/Library/SiliconInitLib/SiliconIni
> +++ tPreMem.c
> @@ -1,7 +1,7 @@
>  /** @file
>Source code file for Platform Init Pre-Memory PEI module
> 
> -Copyright (c) 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
>  This program and the accompanying materials are licensed and made
> available under  the terms and conditions of the BSD License that
> accompanies this distribution.
>  The full text of the license may be found at @@ -80,9 +80,11 @@
> EarlySiliconInit (
>PchPwrmBaseSet (PCH_PWRM_BASE_ADDRESS);
> 
>///
> -  /// Program TCO BASE
> +  /// Program TCO BASE if it is present and not locked
>///
> -  PchTcoBaseSet (PcdGet16 (PcdTcoBaseAddress));
> +  if (PchIsTcoBaseSetValid ()) {
> +PchTcoBaseSet (PcdGet16 (PcdTcoBaseAddress));  }
> 
>///
>/// LPC I/O Configuration
> diff --git
> a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodin
> gLib/PchCycleDecodingLib.c
> b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodin
> gLib/PchCycleDecodingLib.c
> index 68b0b5dd4b..d7e91f947b 100644
> ---
> a/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDecodin
> gLib/PchCycleDecodingLib.c
> +++
> b/Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiDxeSmmPchCycleDeco
> +++ dingLib/PchCycleDecodingLib.c
> @@ -1,7 +1,7 @@
>  /** @file
>PCH cycle deocding configuration and query library.
> 
> -Copyright (c) 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
>  This program and the accompanying materials are licensed and made
> available under  the terms and conditions of the BSD License that
> accompanies this distribution.
>  The full text of the license may be found at @@ -306,6 +306,36 @@
> PchPwrmBaseGet (  }
> 
>  /**
> +  Check if TCO Base register is present and unlocked.
> +  This should be called before calling PchTcoBaseSet ()
> +
> +  @retval BOOLEAN   FALSE = Either TCO base is locked or 
> Smbus
> not present
> +TRUE  = TCO base is not locked
> +
> +**/
> +BOOLEAN
> +EFIAPI
> +PchIsTcoBaseSetValid (
> +  VOID
> +  )
> +{
> +  UINTN SmbusBase;
> +
> +  SmbusBase = MmPciBase (
> +DEFAULT_PCI_BUS_NUMBER_PCH,
> +PCI_DEVICE_NUMBER_PCH_SMBUS,
> +PCI_FUNCTION_NUMBER_PCH_SMBUS
> +);
> +  if (MmioRead16 (SmbusBase) == 0x) {
> +return FALSE;
> +  }
> +  //
> +  // Verify TCO base is not locked.
> +  //
> +  return ((MmioRead8 (SmbusBase + R_PCH_SMBUS_TCOCTL) &
> +B_PCH_SMBUS_TCOCTL_TCO_BASE_LOCK) == 0); }
> +
> +/**
>Set PCH TCO base address.
>This cycle decoding is allowed to set when DMIC.SRL is 0.
>Programming steps:
> @@ -318,7 +348,8 @@ PchPwrmBaseGet (
> 
>@retval EFI_SUCCESS   Successfully completed.
>@retval EFI_INVALID_PARAMETER Invalid base address passed.
> -  @retval EFI_UNSUPPORTED   DMIC.SRL is set.
> +  @retval EFI_UNSUPPORTED   DMIC.SRL is set, or Smbus device not
> present
> +  @retval EFI_DEVICE_ERROR  TCO Base register is locked already
>  **/
>  EFI_STATUS
>  EFIAPI
> @@ -353,16 +384,17 @@ PchTcoBaseSet (
>//
>// Verify TCO base is not locked.
>//
> -  if ((MmioRead8 (SmbusBase + R_PCH_SMBUS_TCOCTL) &
> B_PCH_SMBUS_TCOCTL_TCO_BASE_LOCK) != 0) {
> +  if (!PchIsTcoBaseSetValid ()) {
>  ASSERT (FALSE);
>  return EFI_DEVICE_ERROR;
>}
>//
>// Disable

Re: [edk2] [PATCH] IntelFsp2Pkg: Add function to get bootloader stack pointer

2019-01-24 Thread Zeng, Star

On 2019/1/23 13:36, Chasel, Chiu wrote:

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

FSP on-going enhancement for stack utilization required
to know bootloader stack pointer and this pointer can be
retrieved by first input parameter address when FSP-M
entry API invoked by bootloader.

Test: Verified on internal platform and booting successfully

Cc: Nate DeSimone 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 


Minor comments below, with them addressed, Reviewed-by: Star Zeng 
.



---
  IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c | 27 
++-
  IntelFsp2Pkg/Include/Library/FspCommonLib.h  | 21 
-
  2 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c 
b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
index 64ffba1d16..2f2861281c 100644
--- a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
+++ b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
@@ -1,6 +1,6 @@
  /** @file
  
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.

+  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD 
License
which accompanies this distribution.  The full text of the license may be 
found at
@@ -87,9 +87,9 @@ GetFspGlobalDataPointer (
  }
  
  /**

-  This function gets back the FSP API first parameter passed by the bootlaoder.
+  This function gets back the FSP API first parameter passed by the bootloader.
  
-  @retval ApiParameter FSP API first parameter passed by the bootlaoder.

+  @retval ApiParameter FSP API first parameter passed by the bootloader.
  **/
  UINT32
  EFIAPI
@@ -104,9 +104,26 @@ GetFspApiParameter (
  }
  
  /**

-  This function gets back the FSP API second parameter passed by the 
bootlaoder.
+  This function returns the FSP entry stack pointer from address of the first 
API parameter
  
-  @retval ApiParameter FSP API second parameter passed by the bootlaoder.

+  @retval FSP entry stack pointer.
+**/
+VOID*
+EFIAPI
+GetFspEntryStack (
+  VOID
+  )
+{
+  FSP_GLOBAL_DATA  *FspData;
+
+  FspData  = GetFspGlobalDataPointer ();
+  return (VOID*)(FspData->CoreStack + CONTEXT_STACK_OFFSET(ApiParam[0]));
+}
+
+/**
+  This function gets back the FSP API second parameter passed by the 
bootloader.
+
+  @retval ApiParameter FSP API second parameter passed by the bootloader.
  **/
  UINT32
  EFIAPI
diff --git a/IntelFsp2Pkg/Include/Library/FspCommonLib.h 
b/IntelFsp2Pkg/Include/Library/FspCommonLib.h
index 1c99be3b1f..e98b180fca 100644
--- a/IntelFsp2Pkg/Include/Library/FspCommonLib.h
+++ b/IntelFsp2Pkg/Include/Library/FspCommonLib.h
@@ -1,6 +1,6 @@
  /** @file
  
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.

+  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD 
License
which accompanies this distribution.  The full text of the license may be 
found at
@@ -40,9 +40,9 @@ GetFspGlobalDataPointer (
);
  
  /**

-  This function gets back the FSP API first parameter passed by the bootlaoder.
+  This function gets back the FSP API first parameter passed by the bootloader.
  
-  @retval ApiParameter FSP API first parameter passed by the bootlaoder.

+  @retval ApiParameter FSP API first parameter passed by the bootloader.
  **/
  UINT32
  EFIAPI
@@ -51,9 +51,9 @@ GetFspApiParameter (
);
  
  /**

-  This function gets back the FSP API second parameter passed by the 
bootlaoder.
+  This function gets back the FSP API second parameter passed by the 
bootloader.
  
-  @retval ApiParameter FSP API second parameter passed by the bootlaoder.

+  @retval ApiParameter FSP API second parameter passed by the bootloader.
  **/
  UINT32
  EFIAPI
@@ -61,6 +61,17 @@ GetFspApiParameter2 (
VOID
);
  
+


Remove this new line?


+/**
+  This function returns the FSP entry stack pointer from address of the first 
API parameter
+
+  @retval FSP entry stack pointer.
+**/
+VOID*
+EFIAPI
+GetFspEntryStack (
+  VOID
+  );


Add a new line?


Thanks,
Star


  /**
This function sets the FSP API parameter in the stack.
  



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MdeModulePkg VariableStandaloneMm: Add PcdEmuVariableNvModeEnable in inf

2019-01-24 Thread Bi, Dandan
Reviewed-by: Bi Dandan 


Thanks,
Dandan
> -Original Message-
> From: Zeng, Star
> Sent: Friday, January 25, 2019 9:23 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Wang, Jian J ;
> Wu, Hao A ; Ard Biesheuvel
> ; Bi, Dandan 
> Subject: [PATCH] MdeModulePkg VariableStandaloneMm: Add
> PcdEmuVariableNvModeEnable in inf
> 
> It was missed in 7cd69959463ac9c761163ed8e8a93907b68e70da when
> rebasing the patches after 688b2cad7b712493f2cf8b6948ab795545e13961
> added VariableStandaloneMm.
> 
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Ard Biesheuvel 
> Cc: Dandan Bi 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
> 
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.i
> nf
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.
> inf
> index efb84ed87832..07436d3cb6ae 100644
> ---
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.i
> nf
> +++
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.
> in
> +++ f
> @@ -18,7 +18,7 @@
>  #  may not be modified without authorization. If platform fails to protect
> these resources,  #  the authentication service provided in this driver will 
> be
> broken, and the behavior is undefined.
>  #
> -# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
> +# Copyright (c) 2010 - 2019, Intel Corporation. All rights
> +reserved.
>  # Copyright (c) 2018, Linaro, Ltd. All rights reserved.  # This program 
> and
> the accompanying materials  # are licensed and made available under the
> terms and conditions of the BSD License @@ -127,6 +127,8 @@ [FixedPcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdMaxUserNvVariableSpaceSize
> ## CONSUMES
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdBoottimeReservedNvVariableSpace
> Size  ## CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdReclaimVariableSpaceAtEndOfDxe
> ## CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable
> ## SOMETIMES_CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved
> ## SOMETIMES_CONSUMES
> 
>  [FeaturePcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics##
> CONSUMES  # statistic the information of variable.
> --
> 2.13.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] MdeModulePkg VariableStandaloneMm: Add PcdEmuVariableNvModeEnable in inf

2019-01-24 Thread Star Zeng
It was missed in 7cd69959463ac9c761163ed8e8a93907b68e70da when rebasing
the patches after 688b2cad7b712493f2cf8b6948ab795545e13961 added
VariableStandaloneMm.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Ard Biesheuvel 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
index efb84ed87832..07436d3cb6ae 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
@@ -18,7 +18,7 @@
 #  may not be modified without authorization. If platform fails to protect 
these resources,
 #  the authentication service provided in this driver will be broken, and the 
behavior is undefined.
 #
-# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
 # Copyright (c) 2018, Linaro, Ltd. All rights reserved.
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
@@ -127,6 +127,8 @@ [FixedPcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxUserNvVariableSpaceSize   ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdBoottimeReservedNvVariableSpaceSize  ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdReclaimVariableSpaceAtEndOfDxe   ## 
CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable  ## 
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved   ## 
SOMETIMES_CONSUMES
 
 [FeaturePcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics## 
CONSUMES  # statistic the information of variable.
-- 
2.13.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] IntelFsp2Pkg: Add function to get bootloader stack pointer

2019-01-24 Thread Desimone, Nathaniel L
Reviewed-by: Nate DeSimone 

-Original Message-
From: Chiu, Chasel 
Sent: Tuesday, January 22, 2019 9:36 PM
To: edk2-devel@lists.01.org
Cc: Desimone, Nathaniel L ; Zeng, Star 
; Chiu, Chasel 
Subject: [PATCH] IntelFsp2Pkg: Add function to get bootloader stack pointer

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

FSP on-going enhancement for stack utilization required to know bootloader 
stack pointer and this pointer can be retrieved by first input parameter 
address when FSP-M entry API invoked by bootloader.

Test: Verified on internal platform and booting successfully

Cc: Nate DeSimone 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu 
---
 IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c | 27 
++-
 IntelFsp2Pkg/Include/Library/FspCommonLib.h  | 21 -
 2 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c 
b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
index 64ffba1d16..2f2861281c 100644
--- a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
+++ b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2014 - 2019, Intel Corporation. All rights 
+ reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at @@ -87,9 +87,9 @@ GetFspGlobalDataPointer (  }
 
 /**
-  This function gets back the FSP API first parameter passed by the bootlaoder.
+  This function gets back the FSP API first parameter passed by the bootloader.
 
-  @retval ApiParameter FSP API first parameter passed by the bootlaoder.
+  @retval ApiParameter FSP API first parameter passed by the bootloader.
 **/
 UINT32
 EFIAPI
@@ -104,9 +104,26 @@ GetFspApiParameter (  }
 
 /**
-  This function gets back the FSP API second parameter passed by the 
bootlaoder.
+  This function returns the FSP entry stack pointer from address of the 
+ first API parameter
 
-  @retval ApiParameter FSP API second parameter passed by the bootlaoder.
+  @retval FSP entry stack pointer.
+**/
+VOID*
+EFIAPI
+GetFspEntryStack (
+  VOID
+  )
+{
+  FSP_GLOBAL_DATA  *FspData;
+
+  FspData  = GetFspGlobalDataPointer ();
+  return (VOID*)(FspData->CoreStack + 
+CONTEXT_STACK_OFFSET(ApiParam[0]));
+}
+
+/**
+  This function gets back the FSP API second parameter passed by the 
bootloader.
+
+  @retval ApiParameter FSP API second parameter passed by the bootloader.
 **/
 UINT32
 EFIAPI
diff --git a/IntelFsp2Pkg/Include/Library/FspCommonLib.h 
b/IntelFsp2Pkg/Include/Library/FspCommonLib.h
index 1c99be3b1f..e98b180fca 100644
--- a/IntelFsp2Pkg/Include/Library/FspCommonLib.h
+++ b/IntelFsp2Pkg/Include/Library/FspCommonLib.h
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2014 - 2019, Intel Corporation. All rights 
+ reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at @@ -40,9 +40,9 @@ GetFspGlobalDataPointer (
   );
 
 /**
-  This function gets back the FSP API first parameter passed by the bootlaoder.
+  This function gets back the FSP API first parameter passed by the bootloader.
 
-  @retval ApiParameter FSP API first parameter passed by the bootlaoder.
+  @retval ApiParameter FSP API first parameter passed by the bootloader.
 **/
 UINT32
 EFIAPI
@@ -51,9 +51,9 @@ GetFspApiParameter (
   );
 
 /**
-  This function gets back the FSP API second parameter passed by the 
bootlaoder.
+  This function gets back the FSP API second parameter passed by the 
bootloader.
 
-  @retval ApiParameter FSP API second parameter passed by the bootlaoder.
+  @retval ApiParameter FSP API second parameter passed by the bootloader.
 **/
 UINT32
 EFIAPI
@@ -61,6 +61,17 @@ GetFspApiParameter2 (
   VOID
   );
 
+
+/**
+  This function returns the FSP entry stack pointer from address of the 
+first API parameter
+
+  @retval FSP entry stack pointer.
+**/
+VOID*
+EFIAPI
+GetFspEntryStack (
+  VOID
+  );
 /**
   This function sets the FSP API parameter in the stack.
 
--
2.13.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if relocation info is invalid.

2019-01-24 Thread Neo Hsueh
1.Skip runtime relocation for PE images that provide invalid relocation
  infomation (ex: RelocDir->Size = 0) to fix a hang observed while booting
  Windows.
2.Add a magic number check for PE32+ image.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Neo Hsueh 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Dandan Bi 
---
 MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c 
b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index 1bd079ad6a..6477ef0759 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -1725,11 +1725,18 @@ PeCoffLoaderRelocateImageForRuntime (
 NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
 DataDirectory = (EFI_IMAGE_DATA_DIRECTORY 
*)&(Hdr.Pe32->OptionalHeader.DataDirectory[0]);
   } else {
+if (Hdr.Pe32Plus->OptionalHeader.Magic == 
EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
+  //
+  // Use PE32+ offset
+  //
+  NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+  DataDirectory = (EFI_IMAGE_DATA_DIRECTORY 
*)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[0]);
+} else {
 //
-// Use PE32+ offset
+// Not a valid PE image so Exit
 //
-NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
-DataDirectory = (EFI_IMAGE_DATA_DIRECTORY 
*)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[0]);
+return;
+}
   }
 
   //
@@ -1746,6 +1753,12 @@ PeCoffLoaderRelocateImageForRuntime (
 
RelocDir->VirtualAddress + RelocDir->Size - 1,
 0
 );
+if (RelocBase == NULL || RelocBaseEnd == NULL || RelocBaseEnd < RelocBase) 
{
+  //
+  // relocation block is not valid, just return
+  //
+  return;
+}
   } else {
 //
 // Cannot find relocations, cannot continue to relocate the image, ASSERT 
for this invalid image.
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Network Stack Budgeting

2019-01-24 Thread Tomas Pilar (tpilar)



On 24/01/2019 16:49, Laszlo Ersek wrote:
> On 01/24/19 14:25, Tomas Pilar (tpilar) wrote:
>> Hmm,
>>
>> Mnp->Configure() will eventually call MnpStartSnp().
>>
>> A grep for Mnp->Configure shows that:
>> * ArpDxe performs this on DriverBinding.Start()
>> * Ip6Dxe performs this on DriverBinding.Start()
>>
>> Ipv4 and DnsDhcp do this as a part of their Configure() they expose in the 
>> API.
> Yes, that makes sense. All of the above drivers are UEFI drivers that
> follow the UEFI driver model, AIUI. As long as the controller is not
> connected from BDS, no BindingStart() function should be called in these.
Ah, but I would expect the BDS to call ConnectController() on the NIC, but I 
would not expect the network stack to be started unless the device is actually 
chosen for PXE booting. In other words, the above protocols should follow the 
example of EFI_DNS4_PROTOCOL that binds against the device during BDS but 
.Configure() is not automatically called by DriverBinding.Start().

.Configure() should be called by the BootManager if networking is actually to 
be done. That in turn will configure Mnp and start Snp.

Cheers,
Tom

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Text attachments

2019-01-24 Thread Laszlo Ersek
On 01/24/19 12:38, Tomas Pilar (tpilar) wrote:
> Hi,
> 
> Does the mailing list support plaintext attachments?

No, it doesn't forward any attachments. People that you CC directly will
get the attachment, but the list will not reflect any attachments to
subscribers, nor will the list archive carry the attached files.

I suggest the following: if it is just a text file (log etc), simply
paste it into the email. (Does not apply to patches, of course.) For
binary files, I suggest (a) creating a zip file or a compressed tarball,
(b) putting that through "uuencode --base64", and (c) pasting the result
at the end of the email.

Thanks
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [question] A piece of log.txt showed in uefi shell is not the same as showed in notepad++

2019-01-24 Thread Andrew Fish via edk2-devel
Krishna,

From an EFI point of view BackSpace 0x08, LF 0x0A, and CR 0xD are defined for a 
ConOut device. 

From Ascii Control Codes:
0x0C - Form Feed
0x0E - Shift Out

The Shift Out is used with graphics characters. 

How did you dump the log? If EFI sends data to a serial terminal then it would 
use terminal emulation and the output stream would look different. 

Thanks,

Andrew Fish

> On Jan 23, 2019, at 11:07 PM, krishnaLee  wrote:
> 
> Andrew Fish,
> thank you,in this case,you are right.
> but I think there may be other case that the user data just contain some 
> nosense-data
> such as { UINT16 MyData[]={0x000c,0x000d,0x000d,0x000e}  } to the editor, 
> the uefi editor may also meet this question,the editor may do not need output 
> this,
> but the editor should make sure other visible chars can output normal...
> 
> I don't know if it is a bug or not.
> 
> Thank you very much.
> krishna.
> 
> 
> 
> 
> 在 2019-01-24 12:13:50,"Andrew Fish"  写道:
>> On Jan 23, 2019, at 7:17 PM, krishnaLee > > wrote:
>> 
>> Hi,
>> I dumped a small log.txt from my work,but the log.txt showed in uefi 
>> shell,is not the same as it showed in notepad++.
>> I had upload the log here:
>> https://github.com/krishna116/test/blob/master/log.zip 
>> 
>> 
>> 
>> it seems the log showed in uefi shell had missed some strings...I don't know 
>> why,please help,
>> 
> 
> Krishna,
> 
> Your log.txt looks like a normal UTF-16 Unicode file. The leading  FF FE is 
> the Byte order mark for UTF-16 Little Endian [1].  The file looks like it has 
> CR line endings [2] so maybe that is confusing your editor? There seems to be 
> a CR LF at the end, so the mixture of line ending may even be more likely 
> confusing the editor. The byte order mark should let your editor know it is 
> 16-bit Unicode and the correct endian. Hope this helps...
> 
> $ hexdump -C /Users/andrewfish/Downloads/log/log.txt 
>   ff fe 20 00 20 00 20 00  4d 00 58 00 32 00 35 00  |.. . . .M.X.2.5.|
> 0010  4c 00 31 00 32 00 38 00  37 00 35 00 46 00 20 00  |L.1.2.8.7.5.F. .|
> 0020  20 00 20 00 20 00 49 00  44 00 3a 00 30 00 78 00  | . . .I.D.:.0.x.|
> 0030  43 00 32 00 32 00 30 00  31 00 38 00 20 00 20 00  |C.2.2.0.1.8. . .|
> 0040  20 00 20 00 53 00 69 00  7a 00 65 00 3a 00 20 00  | . .S.i.z.e.:. .|
> 0050  31 00 36 00 33 00 38 00  34 00 4b 00 42 00 20 00  |1.6.3.8.4.K.B. .|
> 0060  28 00 31 00 33 00 31 00  30 00 37 00 32 00 4b 00  |(.1.3.1.0.7.2.K.|
> 0070  62 00 29 00 20 00 20 00  20 00 20 00 20 00 20 00  |b.). . . . . . .|
> 0080  20 00 20 00 20 00 20 00  20 00 20 00 20 00 20 00  | . . . . . . . .|
> *
> 00c0  20 00 20 00 20 00 20 00  0d 00 0d 00 20 00 20 00  | . . . . . .|
> 00d0  20 00 20 00 20 00 20 00  20 00 20 00 20 00 20 00  | . . . . . . . .|
> *
> 0190  20 00 20 00 0d 00 0d 00  20 00 20 00 20 00 20 00  | . . . . . .|
> 01a0  4d 00 58 00 32 00 35 00  4c 00 36 00 34 00 37 00  |M.X.2.5.L.6.4.7.|
> 01b0  33 00 45 00 20 00 20 00  20 00 20 00 49 00 44 00  |3.E. . . . .I.D.|
> 01c0  3a 00 30 00 78 00 43 00  32 00 32 00 30 00 31 00  |:.0.x.C.2.2.0.1.|
> 01d0  37 00 20 00 20 00 20 00  20 00 53 00 69 00 7a 00  |7. . . . .S.i.z.|
> 01e0  65 00 3a 00 20 00 38 00  31 00 39 00 32 00 4b 00  |e.:. .8.1.9.2.K.|
> 01f0  42 00 20 00 28 00 36 00  35 00 35 00 33 00 36 00  |B. .(.6.5.5.3.6.|
> 0200  4b 00 62 00 29 00 20 00  20 00 20 00 20 00 20 00  |K.b.). . . . . .|
> 0210  20 00 20 00 20 00 20 00  20 00 20 00 20 00 20 00  | . . . . . . . .|
> *
> 0260  0d 00 0d 00 20 00 20 00  20 00 20 00 20 00 20 00  | . . . . . .|
> 0270  20 00 20 00 20 00 20 00  20 00 20 00 20 00 20 00  | . . . . . . . .|
> *
> 0320  20 00 20 00 20 00 20 00  20 00 20 00 0d 00 0d 00  | . . . . . .|
> 0330  53 00 50 00 49 00 20 00  42 00 41 00 52 00 3a 00  |S.P.I. .B.A.R.:.|
> 0340  20 00 46 00 45 00 30 00  31 00 30 00 30 00 30 00  | .F.E.0.1.0.0.0.|
> 0350  30 00 20 00 20 00 20 00  20 00 20 00 20 00 20 00  |0. . . . . . . .|
> 0360  20 00 20 00 20 00 20 00  20 00 20 00 20 00 20 00  | . . . . . . . .|
> *
> 03f0  20 00 20 00 20 00 20 00  0d 00 0d 00 20 00 20 00  | . . . . . .|
> 0400  20 00 20 00 20 00 20 00  20 00 20 00 20 00 20 00  | . . . . . . . .|
> *
> 04c0  20 00 20 00 0d 00 0d 00  46 00 50 00 54 00 20 00  | . .F.P.T. .|
> 04d0  4f 00 70 00 65 00 72 00  61 00 74 00 69 00 6f 00  |O.p.e.r.a.t.i.o.|
> 04e0  6e 00 20 00 53 00 75 00  63 00 63 00 65 00 73 00  |n. .S.u.c.c.e.s.|
> 04f0  73 00 66 00 75 00 6c 00  2e 00 20 00 20 00 20 00  |s.f.u.l... . . .|
> 0500  20 00 20 00 20 00 20 00  20 00 20 00 20 00 20 00  | . . . . . . . .|
> *
> 0590  0d 00 0d 00 20 00 20 00  20 00 20 00 20 00 20 00  | . . . . . .|
> 05a0  20 00 20 00 20 00 20 00  20 00 20 00 20 00 20 00  | . . . . . . . .|
> *
> 0650  20 00 20 00 20 00 20 00  20 00 20 00 0d 00 0d 00  | . . . . . ...

[edk2] [PATCH v2 17/22] DynamicTablesPkg: Arm ACPI MADT Generator

2019-01-24 Thread Sami Mujawar
The MADT generator uses the configuration manager protocol to
obtain information about the Arm interrupt controllers (GICC,
GICD, etc.) and generates the ACPI MADT table. This table data
is then used by the Table Manager to install the MADT table.

The Table Manager then invokes the generator interface to free
any resources allocated by the MADT table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf |  42 ++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c| 745 

 3 files changed, 788 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
ffdf4f13bbc88c7d4ef97d15583c951a4c9ff599..cf86f2e6a05216236c4b773190d13779e86bbd3e
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -28,6 +28,7 @@ [Components.common]
   DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf {
 
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
   }
 
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
new file mode 100644
index 
..6ba8af4632c25e97b948893c344517ac447ce01a
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  MADT Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiMadtLibArm
+  FILE_GUID  = AF76C93B-41B5-454D-83CD-D2A80A1C1E38
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiMadtLibConstructor
+  DESTRUCTOR = AcpiMadtLibDestructor
+
+[Sources]
+  MadtGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c
new file mode 100644
index 
..06794758308e028b7d8da06670b1793cbdb3ae81
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c
@@ -0,0 +1,745 @@
+/** @file
+  MADT Table Generator
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - ACPI 6.2 Specification - Errata A, September 2017
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard MADT Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjGicCInfo
+  - EArmObjGicDInfo
+  - EArmObjGicMsiFrameInfo (OPTIONAL)
+  - EArmObjGicRedistributorInfo (OPTIONAL)
+  - EArmObjGicItsInfo (OPTIONAL)
+*/
+
+/** This macro expands to a function that retrieves the GIC
+CPU interface Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjGicCInfo,
+  CM_ARM_GICC_INFO
+  );
+
+/** This macro expands to a function that retrieves the GIC
+Distributor Information from the Configuration Manager.
+*/
+
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjGicDInfo,
+  CM_ARM_GICD_INFO
+  );
+
+/** This macro expands to a function that retrieves the GIC
+MSI Frame Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjGicMsiFrameInfo,
+  CM_ARM_GIC_MSI_FRAME_INFO
+  );
+
+/** This macro expands to a function that retrieves the GIC
+R

Re: [edk2] Network Stack Budgeting

2019-01-24 Thread Laszlo Ersek
On 01/24/19 14:25, Tomas Pilar (tpilar) wrote:
> Hmm,
> 
> Mnp->Configure() will eventually call MnpStartSnp().
> 
> A grep for Mnp->Configure shows that:
> * ArpDxe performs this on DriverBinding.Start()
> * Ip6Dxe performs this on DriverBinding.Start()
> 
> Ipv4 and DnsDhcp do this as a part of their Configure() they expose in the 
> API.

Yes, that makes sense. All of the above drivers are UEFI drivers that
follow the UEFI driver model, AIUI. As long as the controller is not
connected from BDS, no BindingStart() function should be called in these.

E.g. EFI_DNS4_PROTOCOL.Configure() can only be called if an instance of
that protocol exists (... for the NIC in question), but the protocol
instance won't exist unless BDS (or some other agent such as the shell
or the boot menu app) called ConnectController().

Thanks,
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 16/22] DynamicTablesPkg: Arm ACPI FADT Generator

2019-01-24 Thread Sami Mujawar
The FADT generator collates the relevant information required
for generating a FADT table from configuration manager using
the configuration manager protocol. It then updates a template
FADT table structure. This table data is used by the Table
Manager to install the FADT table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf |  42 ++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c| 689 

 3 files changed, 732 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
1dde21f393e9717c1d5adfbebe8dd8840da418c3..ffdf4f13bbc88c7d4ef97d15583c951a4c9ff599
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -27,6 +27,7 @@ [Components.common]
   #
   DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf {
 
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
   }
 
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
new file mode 100644
index 
..e772409069caad8563e37be43ec2841f9d22e62d
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  FADT Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiFadtLibArm
+  FILE_GUID  = 686FE5FE-B944-485F-8B1C-7D60E0056487
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiFadtLibConstructor
+  DESTRUCTOR = AcpiFadtLibDestructor
+
+[Sources]
+  FadtGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c
new file mode 100644
index 
..62927b51d6d7c1585da1cb0d59785e2382639002
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c
@@ -0,0 +1,689 @@
+/** @file
+  FADT Table Generator
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - ACPI 6.2 Specification - Errata A, September 2017
+
+**/
+
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard FADT Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjPowerManagementProfileInfo
+  - EArmObjBootArchInfo
+  - EArmObjHypervisorVendorIdentity (OPTIONAL)
+*/
+
+/** This macro defines the FADT flag options for ARM Platforms.
+*/
+#define FADT_FLAGS  (EFI_ACPI_6_2_HW_REDUCED_ACPI |  \
+ EFI_ACPI_6_2_LOW_POWER_S0_IDLE_CAPABLE)
+
+/** This macro defines the valid mask for the FADT flag option
+if HW_REDUCED_ACPI flag in the table is set.
+
+  Invalid bits are: 1, 2, 3,7, 8, 13, 14,16, 17 and
+22-31 (reserved).
+
+  Valid bits are:
+EFI_ACPI_6_2_WBINVD   BIT0
+EFI_ACPI_6_2_PWR_BUTTON   BIT4
+EFI_ACPI_6_2_SLP_BUTTON   BIT5
+EFI_ACPI_6_2_FIX_RTC  BIT6
+EFI_ACPI_6_2_DCK_CAP  BIT9
+EFI_ACPI_6_2_RESET_REG_SUPBIT10
+EFI_ACPI_6_2_SEALED_CASE  BIT11
+EFI_ACPI_6_2_HEADLESS BIT12
+EFI_ACPI_6_2_USE_PLATFORM_CLOCK

[edk2] [PATCH v2 03/22] DynamicTablesPkg: Acpi Table Generator

2019-01-24 Thread Sami Mujawar
This patch introduces the required interfaces and definitions
for implementing an ACPI table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/AcpiTableGenerator.h | 360 
 1 file changed, 360 insertions(+)

diff --git a/DynamicTablesPkg/Include/AcpiTableGenerator.h 
b/DynamicTablesPkg/Include/AcpiTableGenerator.h
new file mode 100644
index 
..639d243eb5a61b7e3dbadb1f281bb76f5239d911
--- /dev/null
+++ b/DynamicTablesPkg/Include/AcpiTableGenerator.h
@@ -0,0 +1,360 @@
+/** @file
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+- Std or STD - Standard
+**/
+
+#ifndef ACPI_TABLE_GENERATOR_H_
+#define ACPI_TABLE_GENERATOR_H_
+
+#include 
+
+// Module specific include files.
+#include 
+
+#pragma pack(1)
+
+/**
+The Dynamic Tables Framework provisions two classes of ACPI table
+generators.
+ - Standard generators: The ACPI table generators implemented by the
+Dynamic Tables Framework.
+ - OEM generators:  The ACPI table generators customized by the OEM.
+
+The Dynamic Tables Framework implements the following ACPI table generators:
+  - RAW   : This is the simplest ACPI table generator. It simply installs
+the ACPI table provided in the AcpiTableData member of the
+CM_STD_OBJ_ACPI_TABLE_INFO. The ACPI table data is provided by
+the Configuration Manager and is generated using an implementation
+defined mechanism.
+  - DSDT  : The DSDT generator is a clone of the RAW generator. The difference
+is in the way the ACPI Table Data is generated from an AML file.
+  - SSDT  : The SSDT generator is a clone of the RAW generator. The difference
+is in the way the ACPI Table Data is generated from an AML file.
+  - FADT  : The FADT generator collates the required platform information from
+the Configuration Manager and builds the FADT table.
+  - MADT  : The MADT generator collates the GIC information  from the
+Configuration Manager and builds the MADT table.
+  - GTDT  : The GTDT generator collates the Timer information from the
+Configuration Manager and builds the GTDT table.
+  - DBG2  : The DBG2 generator collates the debug serial port information from
+the Configuration Manager and builds the DBG2 table.
+  - SPCR  : The SPCR generator collates the serial port information from the
+Configuration Manager and builds the SPCR table.
+  - MCFG  : The MCFG generator collates the PCI configuration space information
+from the Configuration Manager and builds the MCFG table.
+  - IORT  : The IORT generator collates the IO Topology information from the
+Configuration Manager and builds the IORT table.
+*/
+
+/** The ACPI_TABLE_GENERATOR_ID type describes ACPI table generator ID.
+*/
+typedef TABLE_GENERATOR_ID ACPI_TABLE_GENERATOR_ID;
+
+/** The ESTD_ACPI_TABLE_ID enum describes the ACPI table IDs reserved for
+  the standard generators.
+*/
+typedef enum StdAcpiTableId {
+  EStdAcpiTableIdReserved = 0x, ///< Reserved
+  EStdAcpiTableIdRaw,   ///< RAW Generator
+  EStdAcpiTableIdDsdt = EStdAcpiTableIdRaw, ///< DSDT Generator
+  EStdAcpiTableIdSsdt = EStdAcpiTableIdRaw, ///< SSDT Generator
+  EStdAcpiTableIdFadt,  ///< FADT Generator
+  EStdAcpiTableIdMadt,  ///< MADT Generator
+  EStdAcpiTableIdGtdt,  ///< GTDT Generator
+  EStdAcpiTableIdDbg2,  ///< DBG2 Generator
+  EStdAcpiTableIdSpcr,  ///< SPCR Generator
+  EStdAcpiTableIdMcfg,  ///< MCFG Generator
+  EStdAcpiTableIdIort,  ///< IORT Generator
+  EStdAcpiTableIdMax
+} ESTD_ACPI_TABLE_ID;
+
+/** This macro checks if the Table Generator ID is for an ACPI Table Generator.
+
+  @param [in] TableGeneratorId  The table generator ID.
+
+  @return TRUE if the table generator ID is for an ACPI Table
+Generator.
+**/
+#define IS_GENERATOR_TYPE_ACPI(TableGeneratorId) \
+  (GET_TABLE_TYPE (TableGeneratorId) == ETableGeneratorTypeAcpi)
+
+/** This macro checks if the Table Generator ID is for a standard ACPI
+Table Generator.
+
+  @param [in] TableGeneratorId  The table generator ID.
+
+  @return TRUE if the t

[edk2] [PATCH v2 11/22] DynamicTablesPkg: Table Helper Library

2019-01-24 Thread Sami Mujawar
A helper library that implements common functionality
for use by table generators.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc|  20 +++
 DynamicTablesPkg/Include/Library/TableHelperLib.h |  68 

 DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c  | 176 

 DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf |  36 
 4 files changed, 300 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
new file mode 100644
index 
..1cac3e649afebb06190fb5bf6387857437706404
--- /dev/null
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -0,0 +1,20 @@
+## @file
+#  Dsc include file for Dynamic Tables Framework.
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+##
+
+[Defines]
+
+[LibraryClasses.common]
+  
TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
+
diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h 
b/DynamicTablesPkg/Include/Library/TableHelperLib.h
new file mode 100644
index 
..3c4e1d23d2e6955388ab0b51fb57779f2225beb2
--- /dev/null
+++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h
@@ -0,0 +1,68 @@
+/** @file
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef TABLE_HELPER_LIB_H_
+#define TABLE_HELPER_LIB_H_
+
+/** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
+object from the Configuration Manager.
+
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager protocol
+  interface.
+  @param [out] CfgMfrInfo Pointer to the Configuration Manager Info
+  object structure.
+
+  @retval EFI_SUCCESS   The object is returned.
+  @retval EFI_INVALID_PARAMETER The Object ID is invalid.
+  @retval EFI_NOT_FOUND The requested Object is not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+Manager is less than the Object size.
+**/
+EFI_STATUS
+EFIAPI
+GetCgfMgrInfo (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST  CfgMgrProtocol,
+  OUT   CM_STD_OBJ_CONFIGURATION_MANAGER_INFO**CfgMfrInfo
+  );
+
+/** The AddAcpiHeader function updates the ACPI header structure. It uses the
+ACPI table Generator and the Configuration Manager protocol to obtain the
+information required for constructing the header.
+
+  @param [in] CfgMgrProtocol Pointer to the Configuration Manager
+ protocol interface.
+  @param [in] Generator  Pointer to the ACPI table Generator.
+  @param [in,out] AcpiHeader Pointer to the ACPI table header to be
+ updated.
+  @param [in] Revision   Revision of the ACPI table.
+  @param [in] Length Length of the ACPI table.
+
+  @retval EFI_SUCCESS   The ACPI table is updated successfully.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object information is not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+Manager is less than the Object size for the
+requested object.
+**/
+EFI_STATUS
+EFIAPI
+AddAcpiHeader (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol,
+  IN  CONST ACPI_TABLE_GENERATOR  * CONST Generator,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER * CONST AcpiHeader,
+  IN  CONST UINT32Revision,
+  IN  CONST UINT32Length
+  );
+
+#endif // TABLE_HELPER_LIB_H_
diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c 
b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
new file mode 100644
index 

[edk2] [PATCH v2 12/22] DynamicTablesPkg: Dynamic Table Factory Protocol

2019-01-24 Thread Sami Mujawar
This patch introduces the dynamic table factory protocol
that provides an interface to register and retrieve
registered generators.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTablesPkg.dec   |   3 +
 DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h | 269 

 2 files changed, 272 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec
index 
e5e731085a721f5f2a0129b4678dedbb0c7b985a..3137c14247920974082bd74173cab4e7ac02b3f7
 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dec
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -27,3 +27,6 @@ [Protocols]
   # Configuration Manager Protocol GUID
   gEdkiiConfigurationManagerProtocolGuid = { 0xd85a4835, 0x5a82, 0x4894, { 
0xac, 0x2, 0x70, 0x6f, 0x43, 0xd5, 0x97, 0x8e } }
 
+  # Dynamic Table Factory Protocol GUID
+  gEdkiiDynamicTableFactoryProtocolGuid = { 0x91d1e327, 0xfe5a, 0x49b8, { 
0xab, 0x65, 0xe, 0xce, 0x2d, 0xdb, 0x45, 0xec } }
+
diff --git a/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h 
b/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h
new file mode 100644
index 
..55d62c9e7244c1cca35aaa6c7e3b1dbf9125c3b5
--- /dev/null
+++ b/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h
@@ -0,0 +1,269 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- ACPI   - Advanced Configuration and Power Interface
+- SMBIOS - System Management BIOS
+- DT - Device Tree
+**/
+
+#ifndef DYNAMIC_TABLE_FACTORY_PROTOCOL_H_
+#define DYNAMIC_TABLE_FACTORY_PROTOCOL_H_
+
+#include 
+#include 
+#include 
+
+/** This macro defines the Dynamic Table Factory Protocol GUID.
+
+  GUID: {91D1E327-FE5A-49B8-AB65-0ECE2DDB45EC}
+*/
+#define EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL_GUID   \
+  { 0x91d1e327, 0xfe5a, 0x49b8, \
+{ 0xab, 0x65, 0xe, 0xce, 0x2d, 0xdb, 0x45, 0xec }   \
+  };
+
+/** This macro defines the Configuration Manager Protocol Revision.
+*/
+#define EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL_REVISION  CREATE_REVISION (1, 0)
+
+#pragma pack(1)
+
+/**
+  Forward declarations:
+*/
+typedef struct DynamicTableFactoryProtocol 
EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL;
+typedef struct DynamicTableFactoryInfo EDKII_DYNAMIC_TABLE_FACTORY_INFO;
+
+/** Return a pointer to the ACPI table generator.
+
+  @param [in]  This   Pointer to the Dynamic Table Factory Protocol.
+  @param [in]  TableIdThe ACPI table generator ID for the
+  requested generator.
+  @param [out] Generator  Pointer to the requested ACPI table
+  generator.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The requested generator is not found
+in the list of registered generators.
+**/
+typedef
+EFI_STATUS
+EFIAPI
+(EFIAPI * EDKII_DYNAMIC_TABLE_FACTORY_GET_ACPI_TABLE_GENERATOR) (
+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  * CONST This,
+  IN  CONST ACPI_TABLE_GENERATOR_ID   GeneratorId,
+  OUT CONST ACPI_TABLE_GENERATOR ** CONST Generator
+  );
+
+/** Registers an ACPI table generator.
+
+  @param [in]  GeneratorPointer to the ACPI table generator.
+
+  @retval EFI_SUCCESS   The Generator was registered
+successfully.
+  @retval EFI_INVALID_PARAMETER The Generator ID is invalid or
+the Generator pointer is NULL.
+  @retval EFI_ALREADY_STARTED   The Generator for the Table ID is
+already registered.
+**/
+typedef
+EFI_STATUS
+EFIAPI
+(EFIAPI * EDKII_DYNAMIC_TABLE_FACTORY_REGISTER_ACPI_TABLE_GENERATOR) (
+  IN  CONST ACPI_TABLE_GENERATOR* CONST Generator
+  );
+
+/** Deregister an ACPI table generator.
+
+  @param [in]  Generator   Pointer to the ACPI table generator.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER The generator is invalid.
+  @retval EFI_NOT_FOUND The requested generator is not found
+in the list of registered generators.
+**/
+typedef
+EFI_STATUS
+EFIAPI
+(EFIAPI * EDKII_DYNAMIC_TABLE_FACTORY_DEREGISTER_ACPI_TABLE_GENERATOR) (
+  IN  CONST ACPI_TABLE_GENERATOR* CONST Generator
+  );
+
+/** Return a pointer to the SMB

[edk2] [PATCH v2 10/22] DynamicTablesPkg: Configuration Manager Helper

2019-01-24 Thread Sami Mujawar
This patch defines a helper macro 'GET_OBJECT_LIST()' that
expands to a function that uses the configuration manager
protocol to retrieve configuration manager object(s).

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/ConfigurationManagerHelper.h | 132 

 1 file changed, 132 insertions(+)

diff --git a/DynamicTablesPkg/Include/ConfigurationManagerHelper.h 
b/DynamicTablesPkg/Include/ConfigurationManagerHelper.h
new file mode 100644
index 
..cf9960040908d4aeb540714c1a4cf3d720c27029
--- /dev/null
+++ b/DynamicTablesPkg/Include/ConfigurationManagerHelper.h
@@ -0,0 +1,132 @@
+/** @file
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+**/
+
+#ifndef CONFIGURATION_MANAGER_HELPER_H_
+#define CONFIGURATION_MANAGER_HELPER_H_
+
+/** The GET_OBJECT_LIST macro expands to a function that is used to retrieve
+an object or an object list from the Configuration Manager using the
+Configuration Manager Protocol interface.
+
+  The macro expands to a function which has the following prototype:
+
+  STATIC
+  EFI_STATUS
+  EFIAPI
+  Get (
+IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
+IN  CONST CM_OBJECT_TOKEN  Token OPTIONAL,
+OUT   Type**   List,
+OUT   UINT32   *   Count OPTIONAL
+);
+
+  Generated function parameters:
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager protocol
+  interface.
+  @param [in]  Token  Reference token for the Object.
+  @param [out] List   Pointer to the Object list.
+  @param [out] Count  Count of the objects returned in the list.
+
+  Macro Parameters:
+  @param [in] CmObjectNameSpace The Object Namespace
+  @param [in] CmObjectIdObject Id.
+  @param [in] Type  Structure used to describe the Object.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object information is not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+Manager is less than the Object size for the
+requested object.
+**/
+#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type)  \
+STATIC\
+EFI_STATUS\
+EFIAPI\
+Get##CmObjectId ( \
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol, \
+  IN  CONST CM_OBJECT_TOKEN   Token OPTIONAL, \
+  OUT   Type **   List,   \
+  OUT   UINT32* CONST Count OPTIONAL  \
+  )   \
+{ \
+  EFI_STATUS Status;  \
+  CM_OBJ_DESCRIPTOR  CmObjectDesc;\
+  UINT32 ObjCount = 0;\
+  if (List == NULL) { \
+Status = EFI_INVALID_PARAMETER;   \
+DEBUG ((  \
+  DEBUG_ERROR,\
+  "ERROR: Get" #CmObjectId ": Invalid out parameter for"  \
+  " object list. Status = %r\n",  \
+  Status  \
+  )); \
+goto error_handler;   \
+  }   \
+  Status = CfgMgrProtocol->GetObject (\
+ CfgMg

[edk2] [PATCH v2 15/22] DynamicTablesPkg: Arm Raw/DSDT/SSDT Generator

2019-01-24 Thread Sami Mujawar
A Raw generator is a simple generator. This generator provides
the ability to install a binary blob (that contains ACPI table
data) as an ACPI table. The binary blob could be pre-generated
ACPI table data or it may be the pre-compiled output from an
iAsl compiler for a DSDT or SSDT table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc|   8 +-
 DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf |  42 ++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c| 150 

 3 files changed, 199 insertions(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
0c47e85b88d737a914514be123e23370ee69e311..1dde21f393e9717c1d5adfbebe8dd8840da418c3
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -15,6 +15,9 @@
 
 [Defines]
 
+[BuildOptions]
+  *_*_*_ASL_FLAGS  = -tc -li -so
+
 [LibraryClasses.common]
   
TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
 
@@ -22,7 +25,10 @@ [Components.common]
   #
   # Dynamic Table Factory Dxe
   #
-  DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf
+  DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf {
+
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
+  }
 
   #
   # Dynamic Tables Manager Dxe
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
new file mode 100644
index 
..213dbd1cd7b69b3088afb09bdaaf1355c81d8f35
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  Raw Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiRawLibArm
+  FILE_GUID  = 20F31568-D687-49BA-B326-CCD9D38EDE16
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiRawLibConstructor
+  DESTRUCTOR = AcpiRawLibDestructor
+
+[Sources]
+  RawGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c
new file mode 100644
index 
..ae3d3eca1d2f64cfc101fdd0b18da5019bdfe32e
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c
@@ -0,0 +1,150 @@
+/** @file
+  MCFG Table Generator
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** Construct the ACPI table using the ACPI table data provided.
+
+  This function invokes the Configuration Manager protocol interface
+  to get the required hardware information for generating the ACPI
+  table.
+
+  If this function allocates any resources then they must be freed
+  in the FreeTableResources function.
+
+  @param [in]  This   Pointer to the table generator.
+  @param [in]  AcpiTableInfo  Pointer to the ACPI Table Info.
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+  Protocol Interface.
+  @param [out] Table  Pointer to the constructed ACPI Table.
+
+  @retval EFI_SUCCESS   Table generated successfully.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+BuildRawTable (
+  IN  CONST ACPI_TABLE_GENERATOR  * CONST This,
+  IN  CONST CM_STD_OBJ_ACPI_TABLE_INFO* CONST AcpiTableInfo,
+  IN  CONST EDKII_CONFIGURATION_MANAG

[edk2] [PATCH v2 05/22] DynamicTablesPkg: DT Table Generator

2019-01-24 Thread Sami Mujawar
This patch introduces the interfaces and definitions for
implementing a Device Tree table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/DeviceTreeTableGenerator.h | 182 
 1 file changed, 182 insertions(+)

diff --git a/DynamicTablesPkg/Include/DeviceTreeTableGenerator.h 
b/DynamicTablesPkg/Include/DeviceTreeTableGenerator.h
new file mode 100644
index 
..c2066c9f46d12442dd7e8c0ad63bd44d31705dbc
--- /dev/null
+++ b/DynamicTablesPkg/Include/DeviceTreeTableGenerator.h
@@ -0,0 +1,182 @@
+/** @file
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+- Std or STD - Standard
+**/
+
+#ifndef DEVICETREE_TABLE_GENERATOR_H_
+#define DEVICETREE_TABLE_GENERATOR_H_
+
+#include 
+
+#pragma pack(1)
+
+/** The DT_TABLE_GENERATOR_ID type describes Device Tree table generator ID.
+*/
+typedef TABLE_GENERATOR_ID DT_TABLE_GENERATOR_ID;
+
+/** The ESTD_DT_TABLE_ID enum describes the DT table IDs reserved for
+  the standard generators.
+*/
+typedef enum StdDtTableId {
+  EStdDtTableIdReserved = 0x, ///< Reserved.
+  EStdDtTableIdRaw,   ///< RAW Generator.
+  EStdDtTableIdMax
+} ESTD_DT_TABLE_ID;
+
+/** This macro checks if the Table Generator ID is for an DT Table Generator.
+
+  @param [in] TableGeneratorId  The table generator ID.
+
+  @return TRUE if the table generator ID is for an DT Table
+Generator.
+**/
+#define IS_GENERATOR_TYPE_DT(TableGeneratorId) \
+  (GET_TABLE_TYPE(TableGeneratorId) == ETableGeneratorTypeDt)
+
+/** This macro checks if the Table Generator ID is for a standard DT
+Table Generator.
+
+  @param [in] TableGeneratorId  The table generator ID.
+
+  @return TRUE if the table generator ID is for a standard DT
+Table Generator.
+**/
+#define IS_VALID_STD_DT_GENERATOR_ID(TableGeneratorId)   \
+  (  \
+  IS_GENERATOR_NAMESPACE_STD(TableGeneratorId) &&\
+  IS_GENERATOR_TYPE_DT(TableGeneratorId)   &&\
+  ((GET_TABLE_ID(GeneratorId) >= EStdDtTableIdRaw) &&\
+   (GET_TABLE_ID(GeneratorId) < EStdDtTableIdMax))   \
+  )
+
+/** This macro creates a standard DT Table Generator ID.
+
+  @param [in] TableId  The table generator ID.
+
+  @return a standard DT table generator ID.
+**/
+#define CREATE_STD_DT_TABLE_GEN_ID(TableId) \
+  CREATE_TABLE_GEN_ID ( \
+ETableGeneratorTypeDt,  \
+ETableGeneratorNameSpaceStd,\
+TableId \
+)
+
+/** Forward declarations.
+*/
+typedef struct ConfigurationManagerProtocol 
EDKII_CONFIGURATION_MANAGER_PROTOCOL;
+typedef struct CmAStdObjDtTableInfo CM_STD_OBJ_DT_TABLE_INFO;
+typedef struct DtTableGenerator DT_TABLE_GENERATOR;
+
+/** This function pointer describes the interface to DT table build
+functions provided by the DT table generator and called by the
+Table Manager to build an DT table.
+
+  @param [in]  Generator   Pointer to the DT table generator.
+  @param [in]  DtTableInfo Pointer to the DT table information.
+  @param [in]  CfgMgrProtocol  Pointer to the Configuration Manager
+   Protocol interface.
+  @param [out] Table   Pointer to the generated DT table.
+
+  @return EFI_SUCCESS  If the table is generated successfully or other
+failure codes as returned by the generator.
+**/
+typedef EFI_STATUS (*DT_TABLE_GENERATOR_BUILD_TABLE) (
+  IN  CONST DT_TABLE_GENERATOR*   Generator,
+  IN  CONST CM_STD_OBJ_DT_TABLE_INFO  * CONST DtTableInfo,
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol,
+  OUT   VOID **   Table
+  );
+
+/** This function pointer describes the interface to used by the
+Table Manager to give the generator an opportunity to free
+any resources allocated for building the DT table.
+
+  @param [in]  Generator   Pointer to the DT table generator.
+  @param [in]  DtTableInfo Pointer to the DT table information.
+  @param [in]  CfgMgrProtocol  Pointer to the Configuration Manager
+   Protocol interface.
+  @param [in]  Table   Pointer to the generate

Re: [edk2] [PATCH v1 1/1] ShellPkg/UefiShellAcpiViewCommandLib: Add support for PPTT

2019-01-24 Thread Sami Mujawar
Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar

-Original Message-
From: Carsey, Jaben  
Sent: 22 January 2019 05:47 PM
To: Krzysztof Koch ; edk2-devel@lists.01.org
Cc: leif.lindh...@linaro.org; Matteo Carlini ; 
Stephanie Hughes-Fitt ; Ni, Ray 
; Sami Mujawar ; nd 
Subject: RE: [PATCH v1 1/1] ShellPkg/UefiShellAcpiViewCommandLib: Add support 
for PPTT

Reviewed-by: Jaben Carsey 

Note: I am not pushing this to allow proper time for other to review/comment. 
The code looks good to me.

Jaben

> -Original Message-
> From: Krzysztof Koch [mailto:krzysztof.k...@arm.com]
> Sent: Tuesday, January 22, 2019 9:06 AM
> To: edk2-devel@lists.01.org
> Cc: leif.lindh...@linaro.org; matteo.carl...@arm.com; 
> Stephanie.Hughes- f...@arm.com; Carsey, Jaben 
> ; Ni, Ray ; 
> sami.muja...@arm.com; n...@arm.com
> Subject: [PATCH v1 1/1] ShellPkg/UefiShellAcpiViewCommandLib: Add 
> support for PPTT
> Importance: High
> 
> Added the acpiview parser for the PPTT table.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Krzysztof Koch 
> ---
> The changes can be seen at:
> https://github.com/KrzysztofKoch1/edk2/tree/woa_390_pptt_acpiview_v1
> 
> Notes:
> v1:
> - add PPTT parser to acpiview   [Krzysztof]
> 
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> |  23
> +-
>  
> ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
> | 362 
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman
> dLib.c   |   4 +-
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman
> dLib.inf |   3 +-
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman
> dLib.uni |   3 +-
>  5 files changed, 391 insertions(+), 4 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> index
> ecf7dae9038a4ebcb3e3764964f0c16ca3ef51f6..a42450c1431be343870dabb4e
> 03f64ed1cf78afc 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> @@ -1,7 +1,7 @@
>  /** @file
>Header file for ACPI parser
> 
> -  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
> +  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
>This program and the accompanying materials
>are licensed and made available under the terms and conditions of 
> the BSD License
>which accompanies this distribution.  The full text of the license 
> may be found at @@ -655,6 +655,27 @@ ParseAcpiMcfg (
>IN UINT8   AcpiTableRevision
>);
> 
> +/**
> +  This function parses the ACPI PPTT table.
> +  When trace is enabled this function parses the PPTT table and
> +  traces the ACPI table fields.
> +
> +  This function also performs validation of the ACPI table fields.
> +
> +  @param [in] Trace  If TRUE, trace the ACPI fields.
> +  @param [in] PtrPointer to the start of the buffer.
> +  @param [in] AcpiTableLengthLength of the ACPI table.
> +  @param [in] AcpiTableRevision  Revision of the ACPI table.
> +**/
> +VOID
> +EFIAPI
> +ParseAcpiPptt (
> +  IN BOOLEAN Trace,
> +  IN UINT8*  Ptr,
> +  IN UINT32  AcpiTableLength,
> +  IN UINT8   AcpiTableRevision
> +  );
> +
>  /**
>This function parses the ACPI RSDP table.
> 
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.
> c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.
> c
> new file mode 100644
> index
> ..d97ddf8e925d30917f888bf33
> e2c1346cd330663
> --- /dev/null
> +++
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.
> c
> @@ -0,0 +1,362 @@
> +/** @file
> +  PPTT table parser
> +
> +  Copyright (c) 2019, ARM Limited. All rights reserved.
> +  This program and the accompanying materials  are licensed and made 
> + available under the terms and conditions of the BSD
> License
> +  which accompanies this distribution.  The full text of the license 
> + may be
> found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +  @par Reference(s):
> +- ACPI 6.2 Specification - Errata A, September 2017 **/
> +
> +#include 
> +#include 
> +#include "AcpiParser.h"
> +
> +// Local variables
> +STATIC CONST UINT8*  ProcessorTopologyStructureType; STATIC CONST 
> +UINT8*  ProcessorTopologyStructureLength; STATIC CONST UINT32* 
> +NumberOfPrivateResources; STATIC ACPI_DESCRIPTION_HEADER_INFO 
> +AcpiHdrInfo;
> +
> +/**
> +  An ACPI_PARSER array describing the ACPI PPTT Table.
> +**/
> +STATIC CONST ACPI_PARSER PpttParser[] = {
> +  PARSE_ACPI_HEADER (&AcpiHdrInfo)
> +};
> +
> +/**
> +  This function validates the Cache Ty

[edk2] [Patch v1 4/4] BaseTools/build/build: delete variable

2019-01-24 Thread Jaben Carsey
delete the shared global variable from Common.Misc
delete the uncalled users of the variable from build.build

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/Common/Misc.py |  3 -
 BaseTools/Source/Python/build/build.py | 60 +---
 2 files changed, 1 insertion(+), 62 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index e8be8f866511..0b4dd7a7c162 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -54,9 +54,6 @@ secReGeneral = re.compile('^([\da-fA-F]+):([\da-fA-F]+) 
+([\da-fA-F]+)[Hh]? +([.
 
 StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')
 
-## Dictionary used to store file time stamp for quick re-access
-gFileTimeStampCache = {}# {file path : file time stamp}
-
 ## Dictionary used to store dependencies of files
 gDependencyDatabase = {}# arch : {file path : [dependent files list]}
 
diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index 44ad86b780da..e79949fa28f9 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -2,7 +2,7 @@
 # build a platform or a module
 #
 #  Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
-#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
 #  Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.
 #
 #  This program and the accompanying materials
@@ -72,43 +72,6 @@ gToolsDefinition = "tools_def.txt"
 TemporaryTablePattern = re.compile(r'^_\d+_\d+_[a-fA-F0-9]+$')
 TmpTableDict = {}
 
-## Make a Python object persistent on file system
-#
-#   @param  DataThe object to be stored in file
-#   @param  FileThe path of file to store the object
-#
-def _DataDump(Data, File):
-Fd = None
-try:
-Fd = open(File, 'wb')
-pickle.dump(Data, Fd, pickle.HIGHEST_PROTOCOL)
-except:
-EdkLogger.error("", FILE_OPEN_FAILURE, ExtraData=File, 
RaiseError=False)
-finally:
-if Fd is not None:
-Fd.close()
-
-## Restore a Python object from a file
-#
-#   @param  FileThe path of file stored the object
-#
-#   @retval object  A python object
-#   @retval NoneIf failure in file operation
-#
-def _DataRestore(File):
-Data = None
-Fd = None
-try:
-Fd = open(File, 'rb')
-Data = pickle.load(Fd)
-except Exception as e:
-EdkLogger.verbose("Failed to load [%s]\n\t%s" % (File, str(e)))
-Data = None
-finally:
-if Fd is not None:
-Fd.close()
-return Data
-
 ## Check environment PATH variable to make sure the specified tool is found
 #
 #   If the tool is found in the PATH, then True is returned
@@ -2192,31 +2155,11 @@ class Build():
 def Relinquish(self):
 OldLogLevel = EdkLogger.GetLevel()
 EdkLogger.SetLevel(EdkLogger.ERROR)
-#self.DumpBuildData()
 Utils.Progressor.Abort()
 if self.SpawnMode == True:
 BuildTask.Abort()
 EdkLogger.SetLevel(OldLogLevel)
 
-def DumpBuildData(self):
-CacheDirectory = os.path.dirname(GlobalData.gDatabasePath)
-Utils.CreateDirectory(CacheDirectory)
-Utils._DataDump(Utils.gFileTimeStampCache, 
os.path.join(CacheDirectory, "gFileTimeStampCache"))
-Utils._DataDump(Utils.gDependencyDatabase, 
os.path.join(CacheDirectory, "gDependencyDatabase"))
-
-def RestoreBuildData(self):
-FilePath = os.path.join(os.path.dirname(GlobalData.gDatabasePath), 
"gFileTimeStampCache")
-if Utils.gFileTimeStampCache == {} and os.path.isfile(FilePath):
-Utils.gFileTimeStampCache = Utils._DataRestore(FilePath)
-if Utils.gFileTimeStampCache is None:
-Utils.gFileTimeStampCache = {}
-
-FilePath = os.path.join(os.path.dirname(GlobalData.gDatabasePath), 
"gDependencyDatabase")
-if Utils.gDependencyDatabase == {} and os.path.isfile(FilePath):
-Utils.gDependencyDatabase = Utils._DataRestore(FilePath)
-if Utils.gDependencyDatabase is None:
-Utils.gDependencyDatabase = {}
-
 def ParseDefines(DefineList=[]):
 DefineDict = {}
 if DefineList is not None:
@@ -2440,7 +2383,6 @@ def Main():
 if not (MyBuild.LaunchPrebuildFlag and 
os.path.exists(MyBuild.PlatformBuildPath)):
 MyBuild.Launch()
 
-#MyBuild.DumpBuildData()
 #
 # All job done, no error found and no exception raised
 #
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v1 2/4] BaseTools/Common/Misc: remove uncalled code

2019-01-24 Thread Jaben Carsey
no use for this code content.

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/Common/Misc.py | 46 
 1 file changed, 46 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index c547c2f8e43a..65ccba36b2e9 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -947,44 +947,6 @@ class sdict(IterableUserDict):
 for k, v in kwargs.items():
 self[k] = v
 
-## Dictionary with restricted keys
-#
-class rdict(dict):
-## Constructor
-def __init__(self, KeyList):
-for Key in KeyList:
-dict.__setitem__(self, Key, "")
-
-## []= operator
-def __setitem__(self, key, value):
-if key not in self:
-EdkLogger.error("RestrictedDict", ATTRIBUTE_SET_FAILURE, "Key [%s] 
is not allowed" % key,
-ExtraData=", ".join(dict.keys(self)))
-dict.__setitem__(self, key, value)
-
-## =[] operator
-def __getitem__(self, key):
-if key not in self:
-return ""
-return dict.__getitem__(self, key)
-
-## del operator
-def __delitem__(self, key):
-EdkLogger.error("RestrictedDict", ATTRIBUTE_ACCESS_DENIED, 
ExtraData="del")
-
-## Empty the dict
-def clear(self):
-for Key in self:
-self.__setitem__(Key, "")
-
-## Return value related to a key, and remove the (key, value) from the dict
-def pop(self, key, *dv):
-EdkLogger.error("RestrictedDict", ATTRIBUTE_ACCESS_DENIED, 
ExtraData="pop")
-
-## Return (key, value) pair, and remove the (key, value) from the dict
-def popitem(self):
-EdkLogger.error("RestrictedDict", ATTRIBUTE_ACCESS_DENIED, 
ExtraData="popitem")
-
 ## Dictionary using prioritized list as key
 #
 class tdict:
@@ -1987,11 +1949,3 @@ def CopyDict(ori_dict):
 #
 def RemoveCComments(ctext):
 return re.sub('//.*?\n|/\*.*?\*/', '\n', ctext, flags=re.S)
-##
-#
-# This acts like the main() function for the script, unless it is 'import'ed 
into another
-# script.
-#
-if __name__ == '__main__':
-pass
-
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v1 0/4] Cleanup the Common.misc file

2019-01-24 Thread Jaben Carsey
move functions and remove unused content from common.misc

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 

Jaben Carsey (4):
  BaseTools/Common/Misc: move private functions
  BaseTools/Common/Misc: remove uncalled code
  BaseTools/Common/Misc: Cleanup the imports
  BaseTools/build/build: delete variable

 BaseTools/Source/Python/Common/Misc.py | 175 +++-
 BaseTools/Source/Python/build/build.py |  60 +--
 2 files changed, 64 insertions(+), 171 deletions(-)

-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v1 1/1] ShellPkg/UefiShellAcpiViewCommandLib: Add support for PPTT

2019-01-24 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

And pushed.

> -Original Message-
> From: Sami Mujawar [mailto:sami.muja...@arm.com]
> Sent: Thursday, January 24, 2019 8:05 AM
> To: Carsey, Jaben ; Krzysztof Koch
> ; edk2-devel@lists.01.org
> Cc: leif.lindh...@linaro.org; Matteo Carlini ;
> Stephanie Hughes-Fitt ; Ni, Ray
> ; nd 
> Subject: RE: [PATCH v1 1/1] ShellPkg/UefiShellAcpiViewCommandLib: Add
> support for PPTT
> Importance: High
> 
> Reviewed-by: Sami Mujawar 
> 
> Regards,
> 
> Sami Mujawar
> 
> -Original Message-
> From: Carsey, Jaben 
> Sent: 22 January 2019 05:47 PM
> To: Krzysztof Koch ; edk2-devel@lists.01.org
> Cc: leif.lindh...@linaro.org; Matteo Carlini ;
> Stephanie Hughes-Fitt ; Ni, Ray
> ; Sami Mujawar ; nd
> 
> Subject: RE: [PATCH v1 1/1] ShellPkg/UefiShellAcpiViewCommandLib: Add
> support for PPTT
> 
> Reviewed-by: Jaben Carsey 
> 
> Note: I am not pushing this to allow proper time for other to
> review/comment. The code looks good to me.
> 
> Jaben
> 
> > -Original Message-
> > From: Krzysztof Koch [mailto:krzysztof.k...@arm.com]
> > Sent: Tuesday, January 22, 2019 9:06 AM
> > To: edk2-devel@lists.01.org
> > Cc: leif.lindh...@linaro.org; matteo.carl...@arm.com;
> > Stephanie.Hughes- f...@arm.com; Carsey, Jaben
> > ; Ni, Ray ;
> > sami.muja...@arm.com; n...@arm.com
> > Subject: [PATCH v1 1/1] ShellPkg/UefiShellAcpiViewCommandLib: Add
> > support for PPTT
> > Importance: High
> >
> > Added the acpiview parser for the PPTT table.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Krzysztof Koch 
> > ---
> > The changes can be seen at:
> >
> https://github.com/KrzysztofKoch1/edk2/tree/woa_390_pptt_acpiview_v1
> >
> > Notes:
> > v1:
> > - add PPTT parser to acpiview   [Krzysztof]
> >
> >  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h  
> >   |
> 23
> > +-
> >
> >
> ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
> > | 362 
> >
> >
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman
> > dLib.c   |   4 +-
> >
> >
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman
> > dLib.inf |   3 +-
> >
> >
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman
> > dLib.uni |   3 +-
> >  5 files changed, 391 insertions(+), 4 deletions(-)
> >
> > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> > index
> >
> ecf7dae9038a4ebcb3e3764964f0c16ca3ef51f6..a42450c1431be343870dabb4e
> > 03f64ed1cf78afc 100644
> > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> > @@ -1,7 +1,7 @@
> >  /** @file
> >Header file for ACPI parser
> >
> > -  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
> > +  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
> >This program and the accompanying materials
> >are licensed and made available under the terms and conditions of
> > the BSD License
> >which accompanies this distribution.  The full text of the license
> > may be found at @@ -655,6 +655,27 @@ ParseAcpiMcfg (
> >IN UINT8   AcpiTableRevision
> >);
> >
> > +/**
> > +  This function parses the ACPI PPTT table.
> > +  When trace is enabled this function parses the PPTT table and
> > +  traces the ACPI table fields.
> > +
> > +  This function also performs validation of the ACPI table fields.
> > +
> > +  @param [in] Trace  If TRUE, trace the ACPI fields.
> > +  @param [in] PtrPointer to the start of the buffer.
> > +  @param [in] AcpiTableLengthLength of the ACPI table.
> > +  @param [in] AcpiTableRevision  Revision of the ACPI table.
> > +**/
> > +VOID
> > +EFIAPI
> > +ParseAcpiPptt (
> > +  IN BOOLEAN Trace,
> > +  IN UINT8*  Ptr,
> > +  IN UINT32  AcpiTableLength,
> > +  IN UINT8   AcpiTableRevision
> > +  );
> > +
> >  /**
> >This function parses the ACPI RSDP table.
> >
> > diff --git
> >
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.
> > c
> >
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.
> > c
> > new file mode 100644
> > index
> >
> ..d97ddf8e925d30917f888bf33
> > e2c1346cd330663
> > --- /dev/null
> > +++
> >
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.
> > c
> > @@ -0,0 +1,362 @@
> > +/** @file
> > +  PPTT table parser
> > +
> > +  Copyright (c) 2019, ARM Limited. All rights reserved.
> > +  This program and the accompanying materials  are licensed and made
> > + available under the terms and conditions of the BSD
> > License
> > +  which accompanies this distribution.  The full text of the license
> > + may be
> > found at
> > +  http://opensource.org/licenses/bsd-license.php
> > +
> > +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> 

[edk2] [Patch v1 1/4] BaseTools/Common/Misc: move private functions

2019-01-24 Thread Jaben Carsey
These 2 functions are only used internally.  move them to the smallest
scope and use them.

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/Common/Misc.py | 92 ++--
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index 8e4217a4f6e5..c547c2f8e43a 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -566,32 +566,6 @@ def RealPath(File, Dir='', OverrideDir=''):
 NewFile = GlobalData.gAllFiles[NewFile]
 return NewFile
 
-def RealPath2(File, Dir='', OverrideDir=''):
-NewFile = None
-if OverrideDir:
-NewFile = 
GlobalData.gAllFiles[os.path.normpath(os.path.join(OverrideDir, File))]
-if NewFile:
-if OverrideDir[-1] == os.path.sep:
-return NewFile[len(OverrideDir):], NewFile[0:len(OverrideDir)]
-else:
-return NewFile[len(OverrideDir) + 1:], 
NewFile[0:len(OverrideDir)]
-if GlobalData.gAllFiles:
-NewFile = GlobalData.gAllFiles[os.path.normpath(os.path.join(Dir, 
File))]
-if not NewFile:
-NewFile = os.path.normpath(os.path.join(Dir, File))
-if not os.path.exists(NewFile):
-return None, None
-if NewFile:
-if Dir:
-if Dir[-1] == os.path.sep:
-return NewFile[len(Dir):], NewFile[0:len(Dir)]
-else:
-return NewFile[len(Dir) + 1:], NewFile[0:len(Dir)]
-else:
-return NewFile, ''
-
-return None, None
-
 ## Get GUID value from given packages
 #
 #   @param  CName   The CName of the GUID
@@ -1189,27 +1163,27 @@ def AnalyzePcdExpression(Setting):
 FieldList[i] = ch.replace(RanStr,'')
 return FieldList
 
-def ParseDevPathValue (Value):
-if '\\' in Value:
-Value.replace('\\', '/').replace(' ', '')
-
-Cmd = 'DevicePath ' + '"' + Value + '"'
-try:
-p = subprocess.Popen(Cmd, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, shell=True)
-out, err = p.communicate()
-except Exception as X:
-raise BadExpression("DevicePath: %s" % (str(X)) )
-finally:
-subprocess._cleanup()
-p.stdout.close()
-p.stderr.close()
-if err:
-raise BadExpression("DevicePath: %s" % str(err))
-Size = len(out.split())
-out = ','.join(out.split())
-return '{' + out + '}', Size
-
 def ParseFieldValue (Value):
+def ParseDevPathValue (Value):
+if '\\' in Value:
+Value.replace('\\', '/').replace(' ', '')
+
+Cmd = 'DevicePath ' + '"' + Value + '"'
+try:
+p = subprocess.Popen(Cmd, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, shell=True)
+out, err = p.communicate()
+except Exception as X:
+raise BadExpression("DevicePath: %s" % (str(X)) )
+finally:
+subprocess._cleanup()
+p.stdout.close()
+p.stderr.close()
+if err:
+raise BadExpression("DevicePath: %s" % str(err))
+Size = len(out.split())
+out = ','.join(out.split())
+return '{' + out + '}', Size
+
 if "{CODE(" in Value:
 return Value, len(Value.split(","))
 if isinstance(Value, type(0)):
@@ -1625,6 +1599,32 @@ class PathClass(object):
 return os.stat(self.Path)[8]
 
 def Validate(self, Type='', CaseSensitive=True):
+def RealPath2(File, Dir='', OverrideDir=''):
+NewFile = None
+if OverrideDir:
+NewFile = 
GlobalData.gAllFiles[os.path.normpath(os.path.join(OverrideDir, File))]
+if NewFile:
+if OverrideDir[-1] == os.path.sep:
+return NewFile[len(OverrideDir):], 
NewFile[0:len(OverrideDir)]
+else:
+return NewFile[len(OverrideDir) + 1:], 
NewFile[0:len(OverrideDir)]
+if GlobalData.gAllFiles:
+NewFile = 
GlobalData.gAllFiles[os.path.normpath(os.path.join(Dir, File))]
+if not NewFile:
+NewFile = os.path.normpath(os.path.join(Dir, File))
+if not os.path.exists(NewFile):
+return None, None
+if NewFile:
+if Dir:
+if Dir[-1] == os.path.sep:
+return NewFile[len(Dir):], NewFile[0:len(Dir)]
+else:
+return NewFile[len(Dir) + 1:], NewFile[0:len(Dir)]
+else:
+return NewFile, ''
+
+return None, None
+
 if GlobalData.gCaseInsensitive:
 CaseSensitive = False
 if Type and Type.lower() != self.Type:
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01

[edk2] [Patch v1 3/4] BaseTools/Common/Misc: Cleanup the imports

2019-01-24 Thread Jaben Carsey
Refactor to 'dict' from 'IterableUserDict' which was only required for old
python interpreter.
Sort imports according to PEP8
Remove those we dont need.

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/Common/Misc.py | 34 ++--
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py 
b/BaseTools/Source/Python/Common/Misc.py
index 65ccba36b2e9..e8be8f866511 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -15,7 +15,7 @@
 # Import Modules
 #
 from __future__ import absolute_import
-import Common.LongFilePathOs as os
+
 import sys
 import string
 import threading
@@ -26,22 +26,22 @@ import array
 import shutil
 from random import sample
 from struct import pack
-from UserDict import IterableUserDict
-from UserList import UserList
+import uuid
+import subprocess
+from collections import OrderedDict
 
+import Common.LongFilePathOs as os
 from Common import EdkLogger as EdkLogger
 from Common import GlobalData as GlobalData
-from .DataType import *
-from .BuildToolError import *
+from Common.DataType import *
+from Common.BuildToolError import *
 from CommonDataClass.DataClass import *
-from .Parsing import GetSplitValueList
+from Common.Parsing import GetSplitValueList
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.MultipleWorkspace import MultipleWorkspace as mws
-import uuid
 from CommonDataClass.Exceptions import BadExpression
 from Common.caching import cached_property
-import subprocess
-from collections import OrderedDict
+
 ## Regular expression used to find out place holders in string template
 gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | 
re.UNICODE)
 
@@ -831,22 +831,22 @@ class Progressor:
 #  accessed in the order they are added into the dict. It guarantees the order
 #  by making use of an internal list to keep a copy of keys.
 #
-class sdict(IterableUserDict):
+class sdict(dict):
 ## Constructor
 def __init__(self):
-IterableUserDict.__init__(self)
+dict.__init__(self)
 self._key_list = []
 
 ## [] operator
 def __setitem__(self, key, value):
 if key not in self._key_list:
 self._key_list.append(key)
-IterableUserDict.__setitem__(self, key, value)
+dict.__setitem__(self, key, value)
 
 ## del operator
 def __delitem__(self, key):
 self._key_list.remove(key)
-IterableUserDict.__delitem__(self, key)
+dict.__delitem__(self, key)
 
 ## used in "for k in dict" loop to ensure the correct order
 def __iter__(self):
@@ -869,17 +869,17 @@ class sdict(IterableUserDict):
 index = self._key_list.index(key)
 if order == 'BEFORE':
 self._key_list.insert(index, newkey)
-IterableUserDict.__setitem__(self, newkey, newvalue)
+dict.__setitem__(self, newkey, newvalue)
 elif order == 'AFTER':
 self._key_list.insert(index + 1, newkey)
-IterableUserDict.__setitem__(self, newkey, newvalue)
+dict.__setitem__(self, newkey, newvalue)
 
 ## append support
 def append(self, sdict):
 for key in sdict:
 if key not in self._key_list:
 self._key_list.append(key)
-IterableUserDict.__setitem__(self, key, sdict[key])
+dict.__setitem__(self, key, sdict[key])
 
 def has_key(self, key):
 return key in self._key_list
@@ -887,7 +887,7 @@ class sdict(IterableUserDict):
 ## Empty the dict
 def clear(self):
 self._key_list = []
-IterableUserDict.clear(self)
+dict.clear(self)
 
 ## Return a copy of keys
 def keys(self):
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v3 3/4] Platform/ARM: Configuration Manager for FVP

2019-01-24 Thread Sami Mujawar
The dynamic tables framework utilizes the configuration manager
protocol to get the platform specific information required for
building the firmware tables.

The configuration manager is a platform specific component that
collates the platform hardware information and builds an abstract
platform configuration repository. The configuration manager also
implements the configuration manager protocol which returns the
hardware information requested by the table generators.

This patch implements the configuration manager support for the
FVP platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
   |  31 +
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
  | 684 
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
  | 181 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 |  79 +++
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/Platform.h
  |  99 +++
 Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
   |  73 +++
 
Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
   |  35 +
 7 files changed, 1182 insertions(+)

diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc
new file mode 100644
index 
..788b145b273fd49da7fb5d238491aef956977e61
--- /dev/null
+++ b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc
@@ -0,0 +1,31 @@
+## @file
+#  dsc include file for Configuration Manager
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+
+[BuildOptions]
+# Required for pre-processing ASL files that include ArmPlatform.h
+  *_*_*_ASLPP_FLAGS= $(PLATFORM_FLAGS)
+
+[LibraryClasses.common]
+
+[Components.common]
+  # Configuration Manager
+  
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 {
+
+# Platform ASL Tables
+
PlatformAslTablesLib|Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
+  
+   *_*_*_PLATFORM_FLAGS = 
-I$(BIN_DIR)/Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib/OUTPUT
+  }
diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
new file mode 100644
index 
..66ee79341dfeceff1dc70c32b308056d87b99540
--- /dev/null
+++ 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
@@ -0,0 +1,684 @@
+/** @file
+  Configuration Manager Dxe
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "ConfigurationManager.h"
+#include "Platform.h"
+
+// AML Code Include files generated by iASL Compiler
+#include 
+
+/** The platform configuration repository information.
+*/
+STATIC
+EDKII_PLATFORM_REPOSITORY_INFO VExpressPlatRepositoryInfo = {
+  /// Configuration Manager information
+  { CONFIGURATION_MANAGER_REVISION, CFG_MGR_OEM_ID },
+
+  // ACPI Table List
+  {
+// FADT Table
+{
+  EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
+  EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_REVISION,
+  CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt),
+  NULL
+},
+// GTDT Table
+{
+  EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
+  EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_T

[edk2] [PATCH edk2-platforms v3 1/4] Platform/ARM: Configuration Manager for Juno

2019-01-24 Thread Sami Mujawar
The dynamic tables framework utilizes the configuration manager
protocol to get the platform specific information required for
building the firmware tables.

The configuration manager is a platform specific component that
collates the platform hardware information and builds an abstract
platform configuration repository. The configuration manager also
implements the configuration manager protocol which returns the
hardware information requested by the table generators.

This patch implements the configuration manager support for the
Juno platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
   |  29 +
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
  | 752 
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
  | 179 +
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 |  86 +++
 Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/Platform.h   
   |  99 +++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
   | 276 +++
 
Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
   |  45 ++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtJunoUsb.asl 
   | 123 
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtPci.asl 
   | 201 ++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtUart.asl
   |  48 ++
 10 files changed, 1838 insertions(+)

diff --git 
a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc
new file mode 100644
index 
..a5fe869483f4a005942006c8ba43d3a5aabad5bb
--- /dev/null
+++ b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc
@@ -0,0 +1,29 @@
+## @file
+#  dsc include file for Configuration Manager
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+
+[BuildOptions]
+
+[LibraryClasses.common]
+
+[Components.common]
+  # Configuration Manager
+  
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 {
+
+# Platform ASL Tables
+
PlatformAslTablesLib|Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
+  
+   *_*_*_PLATFORM_FLAGS = 
-I$(BIN_DIR)/Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib/OUTPUT
+  }
diff --git 
a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
new file mode 100644
index 
..55f0984ee6741f5434dd1ec673281c78e2a576f2
--- /dev/null
+++ 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
@@ -0,0 +1,752 @@
+/** @file
+  Configuration Manager Dxe
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "ConfigurationManager.h"
+#include "Platform.h"
+
+// AML Code Include files generated by iASL Compiler
+#include 
+#include 
+#include 
+#include 
+
+/** The platform configuration repository information.
+*/
+STATIC
+EDKII_PLATFORM_REPOSITORY_INFO ArmJunoPlatformRepositoryInfo = {
+  /// Configuration Manager information
+  { CONFIGURATION_MANAGER_REVISION, CFG_MGR_OEM_ID },
+
+  // ACPI Table List
+  {
+// FADT Table
+{
+  EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
+  EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_REVISION,
+  CREATE_STD_ACPI

[edk2] [PATCH edk2-platforms v3 4/4] Platform/ARM: Dynamic Tables support for FVP

2019-01-24 Thread Sami Mujawar
The dynamic tables framework uses the platform hardware
information described by the configuration manager to
generate ACPI tables. This support is configurable and
can be enabled using the DYNAMIC_TABLES_FRAMEWORK build
option.

When DYNAMIC_TABLES_FRAMEWORK is defined, ACPI tables are
generated and installed by the dynamic table framework.
Therefore, installation of ACPI tables from the Firmware
Volume (FV) is disabled by this option.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc | 15 +++
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf | 16 ++--
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc 
b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
index 
0941edeaf53c236cd69fbb54e47df9bd407a56d8..1cf2ebb58f99899864e3bc90b7a22a75ea9fc29b
 100644
--- a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -38,6 +38,10 @@ [Defines]
   DT_SUPPORT = FALSE
 
 !include Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
+!ifdef DYNAMIC_TABLES_FRAMEWORK
+  !include DynamicTablesPkg/DynamicTables.dsc.inc
+  !include 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc
+!endif
 
 [LibraryClasses.common]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
@@ -128,6 +132,15 @@ [PcdsFixedAtBuild.common]
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x1c0a
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0
+  gArmPlatformTokenSpaceGuid.PL011UartInterrupt|0x25
+
+  ## PL011 Serial Debug UART (DBG2)
+  gArmPlatformTokenSpaceGuid.PcdSerialDbgRegisterBase|0x1c0b
+  gArmPlatformTokenSpaceGuid.PcdSerialDbgUartBaudRate|115200
+  gArmPlatformTokenSpaceGuid.PcdSerialDbgUartClkInHz|2400
+
+  # SBSA Generic Watchdog
+  gArmTokenSpaceGuid.PcdGenericWatchdogEl2IntrNum|59
 
   ## PL031 RealTimeClock
   gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x1C17
@@ -257,8 +270,10 @@ [Components.common]
 !endif
   }
 
+!ifndef DYNAMIC_TABLES_FRAMEWORK
   MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   Platform/ARM/VExpressPkg/AcpiTables/AcpiTables.inf
+!endif
 
   ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
   ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
diff --git a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf 
b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf
index 
c3e573e1bb4fcf7889fefec4d6c919b118b76653..fc998ec746913a98ac6f62c1109b809bb530fb16
 100644
--- a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf
+++ b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2011 - 2015, ARM Limited. All rights reserved.
+#  Copyright (c) 2011 - 2018, ARM Limited. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -97,9 +97,19 @@ [FV.FvMain]
 
   # ACPI Support
   #
-  INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+!ifndef DYNAMIC_TABLES_FRAMEWORK
+  INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   INF RuleOverride=ACPITABLE Platform/ARM/VExpressPkg/AcpiTables/AcpiTables.inf
+!else
+  # Configuration Manager
+  INF 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
+
+  #
+  # Dynamic Table fdf
+  #
+  !include DynamicTablesPkg/DynamicTables.fdf.inc
+!endif
 
   #
   # Multiple Console IO support
@@ -319,8 +329,10 @@ [Rule.Common.UEFI_APPLICATION.BINARY]
 VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
   }
 
+!ifndef DYNAMIC_TABLES_FRAMEWORK
 [Rule.Common.USER_DEFINED.ACPITABLE]
   FILE FREEFORM = $(NAMED_GUID) {
 RAW ACPI   |.acpi
 RAW ASL|.aml
   }
+!endif
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v3 2/4] Platform/ARM: Dynamic Tables support for Juno

2019-01-24 Thread Sami Mujawar
The dynamic tables framework uses the platform hardware
information described by the configuration manager to
generate ACPI tables. This support is configurable and
can be enabled using the DYNAMIC_TABLES_FRAMEWORK build
option.

When DYNAMIC_TABLES_FRAMEWORK is defined, ACPI tables are
generated and installed by the dynamic table framework.
Therefore, installation of ACPI tables from the Firmware
Volume (FV) is disabled by this option.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 Platform/ARM/JunoPkg/ArmJuno.dsc | 12 +++-
 Platform/ARM/JunoPkg/ArmJuno.fdf | 12 
 Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c |  9 +++--
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
index 
3edde5b65be47fe14988940ce2ef31a60f38dd31..a355c1e1d983339b3b461eddbf60e4a31888a361
 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dsc
+++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
@@ -33,6 +33,11 @@ [Defines]
 # On RTSM, most peripherals are VExpress Motherboard peripherals
 !include Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
 
+!ifdef DYNAMIC_TABLES_FRAMEWORK
+!include DynamicTablesPkg/DynamicTables.dsc.inc
+!include Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc
+!endif
+
 [LibraryClasses.common]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
   ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
@@ -79,6 +84,10 @@ [LibraryClasses.common.UEFI_DRIVER, 
LibraryClasses.common.UEFI_APPLICATION, Libr
 [BuildOptions]
   GCC:*_*_ARM_PLATFORM_FLAGS = -march=armv8-a
 
+!ifdef DYNAMIC_TABLES_FRAMEWORK
+  *_*_*_PLATFORM_FLAGS = -DDYNAMIC_TABLES_FRAMEWORK
+!endif
+
 

 #
 # Pcd Section - list of all EDK II PCD Entries defined by this Platform
@@ -266,8 +275,9 @@ [Components.common]
   # ACPI Support
   #
   MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+!ifndef DYNAMIC_TABLES_FRAMEWORK
   Platform/ARM/JunoPkg/AcpiTables/AcpiTables.inf
-
+!endif
   MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
 
   ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
diff --git a/Platform/ARM/JunoPkg/ArmJuno.fdf b/Platform/ARM/JunoPkg/ArmJuno.fdf
index 
0a8b636d0ebd10a7bceb3cbe6ca1bed8688da1a6..b1295a579b094db1433898589a282702ec854bfb
 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.fdf
+++ b/Platform/ARM/JunoPkg/ArmJuno.fdf
@@ -114,7 +114,17 @@ [FV.FvMain]
   # ACPI Support
   #
   INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+!ifndef DYNAMIC_TABLES_FRAMEWORK
   INF RuleOverride=ACPITABLE Platform/ARM/JunoPkg/AcpiTables/AcpiTables.inf
+!else
+  # Configuration Manager
+  INF 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
+
+  #
+  # Dynamic Table fdf
+  #
+  !include DynamicTablesPkg/DynamicTables.fdf.inc
+!endif
 
   INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
 
@@ -378,8 +388,10 @@ [Rule.Common.UEFI_APPLICATION.BINARY]
 VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
   }
 
+!ifndef DYNAMIC_TABLES_FRAMEWORK
 [Rule.Common.USER_DEFINED.ACPITABLE]
   FILE FREEFORM = $(NAMED_GUID) {
 RAW ACPI   |.acpi
 RAW ASL|.aml
   }
+!endif
diff --git a/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c 
b/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
index 
18491c7378523f365644658c270de95e711c5ac1..0a42d21d4e9b60824f1d313a4d5ad9e4bc6db3aa
 100644
--- a/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
+++ b/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
@@ -1,6 +1,6 @@
 /** @file
 *
-*  Copyright (c) 2013-2015, ARM Limited. All rights reserved.
+*  Copyright (c) 2013-2017, ARM Limited. All rights reserved.
 *
 *  This program and the accompanying materials
 *  are licensed and made available under the terms and conditions of the BSD 
License
@@ -33,9 +33,10 @@
 #include 
 #include 
 
-
+#ifndef DYNAMIC_TABLES_FRAMEWORK
 // This GUID must match the FILE_GUID in 
ArmPlatformPkg/ArmJunoPkg/AcpiTables/AcpiTables.inf
 STATIC CONST EFI_GUID mJunoAcpiTableFile = { 0xa1dd808e, 0x1e95, 0x4399, { 
0xab, 0xc0, 0x65, 0x3c, 0x82, 0xe8, 0x53, 0x0c } };
+#endif
 
 typedef struct {
   ACPI_HID_DEVICE_PATH  AcpiDevicePath;
@@ -487,11 +488,13 @@ ArmJunoEntryPoint (
 
   GetJunoRevision(JunoRevision);
 
+#ifndef DYNAMIC_TABLES_FRAMEWORK
   //
   // Try to install the ACPI Tables
   //
   Status = LocateAndInstallAcpiFromFv (&mJunoAcpiTableFile);
   ASSERT_EFI_ERROR (Status);
+#endif
 
   //
   // Setup R1/R2 options if not already done.
@@ -516,6 +519,7 @@ ArmJunoEntryPoint (
 &EndOfDxeEvent
 );
 
+#ifndef DYNAMIC_TABLES_FRAMEWORK
 // Declare the related ACPI Tables
 EfiCreateProtocolNotifyEvent (
 &gEfiAcpiTableProtocolGuid,
@@ -524,6 +528,7 @@ ArmJunoEntryPoint (
 NULL,
   

[edk2] [PATCH edk2-platforms v3 0/4] Platform/ARM: Platform support for Dynamic Tables Framework

2019-01-24 Thread Sami Mujawar
Dynamic Tables Framework aims to reduce the amount of effort
required for porting firmware to new platforms by simplifying
the generation of firmware tables based on hardware description
provided by a platform specific component.
 
The Dynamic Tables Framework core queries the platform specific
component to retrieve the required hardware information for
generating standardised firmware tables at run-time.
 
The platform specific component responsible for collating the
hardware information is called the Configuration Manager. 
 
This patch series introduce the Configuration Manager that
provides the hardware description to Dynamic Tables Framework.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 

The changes can be seen at:
https://github.com/samimujawar/edk2-platforms/tree/365_dynamic_tables_framework_v3

This v3 patch series incorporates:
  * updates corresponding to the dynamic tables framework's change
to support the newer versions of specifications.
  * support for describing the platform GT Block timers on Juno.
  * minor code improvements.

The corresponding edk2 code changes can be seen at:
https://github.com/samimujawar/edk2/tree/365_dynamic_tables_framework_v2

Sami Mujawar (4):
  Platform/ARM: Configuration Manager for Juno
  Platform/ARM: Dynamic Tables support for Juno
  Platform/ARM: Configuration Manager for FVP
  Platform/ARM: Dynamic Tables support for FVP

 Platform/ARM/JunoPkg/ArmJuno.dsc   
   |  12 +-
 Platform/ARM/JunoPkg/ArmJuno.fdf   
   |  12 +
 Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
   |  29 +
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
  | 752 
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
  | 179 +
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 |  86 +++
 Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/Platform.h   
   |  99 +++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
   | 276 +++
 
Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
   |  45 ++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtJunoUsb.asl 
   | 123 
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtPci.asl 
   | 201 ++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtUart.asl
   |  48 ++
 Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c   
   |   9 +-
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc   
   |  15 +
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf   
   |  16 +-
 Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
   |  31 +
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
  | 684 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
  | 181 +
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 |  79 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/Platform.h
  |  99 +++
 Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
   |  73 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
   |  35 +
 22 files changed, 3079 insertions(+), 5 deletions(-)
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/Platform.h
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtJunoUsb.asl
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtPci.asl
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtUart.asl
 create mode 100644 
Platform/A

[edk2] [PATCH v2 22/22] DynamicTablesPkg: Arm IORT Table Generator

2019-01-24 Thread Sami Mujawar
The IORT generator uses the configuration manager protocol
to obtain information about the PCI Root Complex, SMMU,
GIC ITS, Performance Monitoring counters etc. and generates
the IORT table.

The mappings between the components are represented using
tokens. The generator invokes the configuration manager
protocol interfaces and requests for objects referenced by
tokens to establish the link.

This table data is then used by the Table Manager to install
the IORT table.

The Table Manager then invokes the generator interface to free
any resources allocated by the IORT table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/AcpiIortLibArm.inf |   42 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c| 2081 

 DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.h|   50 +
 4 files changed, 2174 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
e60529f75dbce3d2ff6b7c193f134eaf9ee45428..89bb3dddba7ab9666a8aee199b7a7bde23a14dbc
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -30,6 +30,7 @@ [Components.common]
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/AcpiIortLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/AcpiIortLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/AcpiIortLibArm.inf
new file mode 100644
index 
..ce828eb09147d8cc149902c852cc8eaac9b12dc4
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/AcpiIortLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  IORT Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiIortLibArm
+  FILE_GUID  = 25682BA8-B41D-4403-B034-253769E0DAD5
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiIortLibConstructor
+  DESTRUCTOR = AcpiIortLibDestructor
+
+[Sources]
+  IortGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
new file mode 100644
index 
..a3ee60664ecbeb1b12b01683f838e11804884daf
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
@@ -0,0 +1,2081 @@
+/** @file
+  IORT Table Generator
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - IO Remapping Table, Platform Design Document,
+Document number: ARM DEN 0049D, Issue D, March 2018
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "IortGenerator.h"
+
+/** ARM standard IORT Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjItsGroup
+  - EArmObjNamedComponent
+  - EArmObjRootComplex
+  - EArmObjSmmuV1SmmuV2
+  - EArmObjSmmuV3
+  - EArmObjPmcg
+  - EArmObjGicItsIdentifierArray
+  - EArmObjIdMapping
+  - EArmObjGicItsIdentifierArray
+*/
+
+/** This macro expands 

[edk2] [PATCH v2 20/22] DynamicTablesPkg: Arm DBG2 Table Generator

2019-01-24 Thread Sami Mujawar
The DBG2 generator uses the configuration manager protocol
to obtain the debug serial port information from the platform
configuration manager. It then updates a template DBG2 table
structure. This table data is used by the Table Manager to
install the DBG2 table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf |  48 ++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c| 463 

 3 files changed, 512 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
069ce635e5150b5914b3d7ef58d9bcfef229879f..4a9e42728da2c211183be974215c04fdffd31fc4
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -27,6 +27,7 @@ [Components.common]
   #
   DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf {
 
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf
new file mode 100644
index 
..4075862204c9a12cfd26002e359e054c36914ef0
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf
@@ -0,0 +1,48 @@
+## @file
+# DBG2 Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiDbg2LibArm
+  FILE_GUID  = A17BA4F0-3DEB-4FE5-BD27-EC008E541B22
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiDbg2LibConstructor
+  DESTRUCTOR = AcpiDbg2LibDestructor
+
+[Sources]
+  Dbg2Generator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  SerialPortLib
+
+[FixedPcd]
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c
new file mode 100644
index 
..e21e2b660634b1aedce8167b74573694d6df2a3b
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c
@@ -0,0 +1,463 @@
+/** @file
+  DBG2 Table Generator
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard DBG2 Table Generator
+
+  Constructs the DBG2 table for PL011 or SBSA UART peripherals.
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjSerialDebugPortInfo
+*/
+
+#pragma pack(1)
+
+/** The number of debug ports represented by the Table.
+*/
+#define DBG2_NUM_DEBUG_PORTS   1
+
+/** The number of Generic Address Registers
+presented in the debug device information.
+*/
+#define DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS   1
+
+/** The index for the debug port 1 in the Debug port information list.
+*/
+#define DBG_PORT_INDEX_PORT1   0
+
+/** A string representing the name of the debug port 1.
+*/
+#define NAME_ST

[edk2] [PATCH v2 13/22] DynamicTablesPkg: Dynamic Table Factory Dxe

2019-01-24 Thread Sami Mujawar
The dynamic table factory dxe implements the dynamic table
factory protocol. It also implements the ACPI, SMBIOS and
DT table factories. The table generators register themselves
with the respective table factories and the factories are
responsible for instantiating instances of the generators
to build the firmware tables.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/AcpiTableFactory/AcpiTableFactory.c
 | 226 
 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DeviceTreeTableFactory/DeviceTreeTableFactory.c
 | 225 +++
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactory.h  
 | 125 +++
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c   
 |  90 
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf 
 |  60 ++
 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/SmbiosTableFactory/SmbiosTableFactory.c
 | 226 
 DynamicTablesPkg/DynamicTables.dsc.inc 
 |   6 +
 DynamicTablesPkg/{DynamicTables.dsc.inc => DynamicTables.fdf.inc}  
 |  10 +-
 DynamicTablesPkg/DynamicTablesPkg.dec  
 |  11 +
 9 files changed, 974 insertions(+), 5 deletions(-)

diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/AcpiTableFactory/AcpiTableFactory.c
 
b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/AcpiTableFactory/AcpiTableFactory.c
new file mode 100644
index 
..3ebbcda6d360ba7d1d49992e966fbf72bafb4976
--- /dev/null
+++ 
b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/AcpiTableFactory/AcpiTableFactory.c
@@ -0,0 +1,226 @@
+/** @file
+  ACPI Table Factory
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Std - Standard
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+
+#include "DynamicTableFactory.h"
+
+extern EDKII_DYNAMIC_TABLE_FACTORY_INFO TableFactoryInfo;
+
+/** Return a pointer to the ACPI table generator.
+
+  @param [in]  This Pointer to the Dynamic Table Factory Protocol.
+  @param [in]  GeneratorId  The ACPI table generator ID for the
+requested generator.
+  @param [out] GeneratorPointer to the requested ACPI table
+generator.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The requested generator is not found
+in the list of registered generators.
+**/
+EFI_STATUS
+EFIAPI
+GetAcpiTableGenerator (
+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  * CONST This,
+  IN  CONST ACPI_TABLE_GENERATOR_ID   GeneratorId,
+  OUT CONST ACPI_TABLE_GENERATOR ** CONST Generator
+  )
+{
+  UINT16   TableId;
+  EDKII_DYNAMIC_TABLE_FACTORY_INFO * FactoryInfo;
+
+  ASSERT (This != NULL);
+
+  FactoryInfo = This->TableFactoryInfo;
+
+  if (Generator == NULL) {
+DEBUG ((DEBUG_ERROR, "ERROR: Invalid Generator pointer\n"));
+return EFI_INVALID_PARAMETER;
+  }
+
+  if (!IS_GENERATOR_TYPE_ACPI (GeneratorId)) {
+DEBUG ((DEBUG_ERROR, "ERROR: Generator Type is not ACPI\n"));
+return EFI_INVALID_PARAMETER;
+  }
+
+  *Generator = NULL;
+  TableId = GET_TABLE_ID (GeneratorId);
+  if (IS_GENERATOR_NAMESPACE_STD (GeneratorId)) {
+if (TableId >= EStdAcpiTableIdMax) {
+  ASSERT (TableId < EStdAcpiTableIdMax);
+  return EFI_INVALID_PARAMETER;
+}
+if (FactoryInfo->StdAcpiTableGeneratorList[TableId] != NULL) {
+  *Generator = FactoryInfo->StdAcpiTableGeneratorList[TableId];
+} else {
+  return EFI_NOT_FOUND;
+}
+  } else {
+if (TableId > FixedPcdGet16 (PcdMaxCustomACPIGenerators)) {
+  ASSERT (TableId <= FixedPcdGet16 (PcdMaxCustomACPIGenerators));
+  return EFI_INVALID_PARAMETER;
+}
+if (FactoryInfo->CustomAcpiTableGeneratorList[TableId] != NULL) {
+  *Generator = FactoryInfo->CustomAcpiTableGeneratorList[TableId];
+} else {
+  return EFI_NOT_FOUND;
+}
+  }
+  return EFI_SUCCESS;
+}
+
+/** Register ACPI table factory generator.
+
+  The ACPI table factory maintains a list of the Standard and

[edk2] [PATCH v2 21/22] DynamicTablesPkg: Arm PCI MCFG Table Generator

2019-01-24 Thread Sami Mujawar
The MCFG generator uses the configuration manager protocol
to obtain the PCI Configuration space information from the
platform configuration manager and builds the MCFG table.

This table data is then used by the Table Manager to install
the MCFG table.

The Table Manager then invokes the generator interface to free
any resources allocated by the MCFG table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf |  42 +++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c| 370 

 3 files changed, 413 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
4a9e42728da2c211183be974215c04fdffd31fc4..e60529f75dbce3d2ff6b7c193f134eaf9ee45428
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -31,6 +31,7 @@ [Components.common]
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf
   }
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf
new file mode 100644
index 
..e491ad6b24faae24e473f0fd501e06a6f3b456b5
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  MCFG Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiMcfgLibArm
+  FILE_GUID  = 8C9BDCB2-72D4-4F30-A12D-1145C3807FF7
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiMcfgLibConstructor
+  DESTRUCTOR = AcpiMcfgLibDestructor
+
+[Sources]
+  McfgGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c
new file mode 100644
index 
..29eb72bd917227e87b8f126aa098a6e0ff3918cc
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c
@@ -0,0 +1,370 @@
+/** @file
+  MCFG Table Generator
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - PCI Firmware Specification - Revision 3.2, January 26, 2015.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard MCFG Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjPciConfigSpaceInfo
+*/
+
+#pragma pack(1)
+
+/** This typedef is used to shorten the name of the MCFG Table
+header structure.
+*/
+typedef
+  EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER
+  MCFG_TABLE;
+
+/** This typedef is used to shorten the name of the Enhanced
+Configuration Space address structure.
+*/
+typedef
+  
EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE
+  MCFG_CFG_SPACE_ADDR;
+
+#pragma pack()
+
+/** Retrieve the PCI Configuration Space Information.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjPciConfigSpaceInfo,
+  CM_ARM_PCI_CONFIG_SPACE_INFO
+  );
+
+/** Add the PCI Enhanced Configuration Space Info

[edk2] [PATCH v2 18/22] DynamicTablesPkg: Arm ACPI GTDT Generator

2019-01-24 Thread Sami Mujawar
The GTDT generator uses the configuration manager protocol to
obtain information about the architectural and platform timers
available on the platform and generates the ACPI GTDT table.
This table data is then used by the Table Manager to install
the GTDT table.

The Table Manager then invokes the generator interface to free
any resources allocated by the GTDT table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf |  42 ++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c| 700 

 3 files changed, 743 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
cf86f2e6a05216236c4b773190d13779e86bbd3e..ad943bc55dea0c8e813750e6b122f6e899ba12a7
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -28,6 +28,7 @@ [Components.common]
   DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf {
 
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
   }
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
new file mode 100644
index 
..da3db2b1ff882a9e3a71810eff3d76681ec9d208
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  GTDT Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiGtdtLibArm
+  FILE_GUID  = 26490F7A-7FA2-423C-8939-C6206329BC37
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiGtdtLibConstructor
+  DESTRUCTOR = AcpiGtdtLibDestructor
+
+[Sources]
+  GtdtGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[FixedPcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c
new file mode 100644
index 
..70f52507bc7f12a776f76271b3f378bc62e717ba
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c
@@ -0,0 +1,700 @@
+/** @file
+  GTDT Table Generator
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - ACPI 6.2 Specification - Errata A, September 2017
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard GTDT Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjGenericTimerInfo
+  - EArmObjPlatformGenericWatchdogInfo (OPTIONAL)
+  - EArmObjPlatformGTBlockInfo (OPTIONAL)
+  - EArmObjGTBlockTimerFrameInfo (OPTIONAL)
+*/
+
+/** This macro expands to a function that retrieves the Generic
+Timer Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjGenericTimerInfo,
+  CM_ARM_GENERIC_TIMER_INFO
+  );
+
+/** This macro expands to a function that retrieves the SBSA Generic
+Watchdog Timer Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjPlatformGenericWatchdogInfo,
+  CM_ARM_GENERIC_WATCHDOG_INFO
+  );
+
+/** This macro expands to a function that retrieves the Platform Generic
+Timer Block Information from the Configuration Manager.

[edk2] [PATCH v2 14/22] DynamicTablesPkg: Dynamic Table Manager Dxe

2019-01-24 Thread Sami Mujawar
The dynamic table manager implements the top level component
that drives the table generation and installation process.
It uses the configuration manager protocol to get the list
of tables to be installed from the configuration manager.
It iterates through the list of tables, requests the table
factories for corresponding generators and invokes the
generator interface to build the tables.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c   | 
735 
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf |  
50 ++
 DynamicTablesPkg/DynamicTables.dsc.inc |   
5 +
 DynamicTablesPkg/DynamicTables.fdf.inc |   
4 +
 4 files changed, 794 insertions(+)

diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
new file mode 100644
index 
..33f26a2115e0eb7019fcba680ffe57633b69091c
--- /dev/null
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
@@ -0,0 +1,735 @@
+/** @file
+  Dynamic Table Manager Dxe
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** This macro expands to a function that retrieves the ACPI Table
+List from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceStandard,
+  EStdObjAcpiTableList,
+  CM_STD_OBJ_ACPI_TABLE_INFO
+  )
+
+/** A helper function to build and install a single ACPI table.
+
+  This is a helper function that invokes the Table generator interface
+  for building an ACPI table. It uses the AcpiTableProtocol to install the
+  table, then frees the resources allocated for generating it.
+
+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol
+interface.
+  @param [in]  CfgMgrProtocol   Pointer to the Configuration Manager
+Protocol Interface.
+  @param [in]  GeneratorPointer to the AcpiTable generator.
+  @param [in]  AcpiTableProtocolPointer to the AcpiTable protocol.
+  @param [in]  AcpiTableInfoPointer to the ACPI table Info.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND Required object is not found.
+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager
+is less than the Object size for the
+requested object.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+BuildAndInstallSingleAcpiTable (
+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  * CONST TableFactoryProtocol,
+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol,
+  IN CONST ACPI_TABLE_GENERATOR  * CONST Generator,
+  IN   EFI_ACPI_TABLE_PROTOCOL   *   AcpiTableProtocol,
+  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO* CONST AcpiTableInfo
+  )
+{
+  EFI_STATUSStatus;
+  EFI_STATUSStatus1;
+  EFI_ACPI_DESCRIPTION_HEADER * AcpiTable;
+  UINTN TableHandle;
+
+  AcpiTable = NULL;
+  Status = Generator->BuildAcpiTable (
+Generator,
+AcpiTableInfo,
+CfgMgrProtocol,
+&AcpiTable
+);
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "ERROR: Failed to Build Table." \
+  " TableGeneratorId = 0x%x. Status = %r\n",
+  AcpiTableInfo->TableGeneratorId,
+  Status
+  ));
+// Free any allocated resources.
+goto exit_handler;
+  }
+
+  if (AcpiTable == NULL) {
+Status = EFI_NOT_FOUND;
+goto exit_handler;
+  }
+
+  // Dump ACPI Table Header
+  DUMP_ACPI_TABLE_HEADER (AcpiTable);
+
+  // Install ACPI table
+  Status = AcpiTableProtocol->InstallAcpiTable (
+AcpiTableProtocol,
+AcpiTable,
+AcpiTable->Length,
+&TableHandle
+);
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "ERRO

[edk2] [PATCH v2 07/22] DynamicTablesPkg: Arm NameSpace Objects

2019-01-24 Thread Sami Mujawar
The dynamic tables frameworks core communicates with the
platform specific implementation using the configuration
manager protocol interface. The dynamic tables framework
core uses this interface to retrieve information required
for generating the firmware tables. This information is
represented in the form of objects, which are classified
as standard namespace objects, Arm namespace objects or
as Custom/OEM namespace objects.

This patch introduces the definitions for the Arm namespace
objects.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/ArmNameSpaceObjects.h | 591 
 1 file changed, 591 insertions(+)

diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
new file mode 100644
index 
..93cb6949f0eb2ac2ad3524494e4a14c7a6fab4b8
--- /dev/null
+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
@@ -0,0 +1,591 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+- Std or STD - Standard
+**/
+
+#ifndef ARM_NAMESPACE_OBJECTS_H_
+#define ARM_NAMESPACE_OBJECTS_H_
+
+#include 
+
+#pragma pack(1)
+
+/** The EARM_OBJECT_ID enum describes the Object IDs
+in the ARM Namespace
+*/
+typedef enum ArmObjectID {
+  EArmObjReserved,///<  0 - Reserved
+  EArmObjBootArchInfo,///<  1 - Boot Architecture Info
+  EArmObjCpuInfo, ///<  2 - CPU Info
+  EArmObjPowerManagementProfileInfo,  ///<  3 - Power Management Profile Info
+  EArmObjGicCInfo,///<  4 - GIC CPU Interface Info
+  EArmObjGicDInfo,///<  5 - GIC Distributor Info
+  EArmObjGicMsiFrameInfo, ///<  6 - GIC MSI Frame Info
+  EArmObjGicRedistributorInfo,///<  7 - GIC Redistributor Info
+  EArmObjGicItsInfo,  ///<  8 - GIC ITS Info
+  EArmObjSerialConsolePortInfo,   ///<  9 - Serial Console Port Info
+  EArmObjSerialDebugPortInfo, ///< 10 - Serial Debug Port Info
+  EArmObjGenericTimerInfo,///< 11 - Generic Timer Info
+  EArmObjPlatformGTBlockInfo, ///< 12 - Platform GT Block Info
+  EArmObjGTBlockTimerFrameInfo,   ///< 13 - Generic Timer Block Frame Info
+  EArmObjPlatformGenericWatchdogInfo, ///< 14 - Platform Generic Watchdog
+  EArmObjPciConfigSpaceInfo,  ///< 15 - PCI Configuration Space Info
+  EArmObjHypervisorVendorIdentity,///< 16 - Hypervisor Vendor Id
+  EArmObjFixedFeatureFlags,   ///< 17 - Fixed feature flags for FADT
+  EArmObjItsGroup,///< 18 - ITS Group
+  EArmObjNamedComponent,  ///< 19 - Named Component
+  EArmObjRootComplex, ///< 20 - Root Complex
+  EArmObjSmmuV1SmmuV2,///< 21 - SMMUv1 or SMMUv2
+  EArmObjSmmuV3,  ///< 22 - SMMUv3
+  EArmObjPmcg,///< 23 - PMCG
+  EArmObjGicItsIdentifierArray,   ///< 24 - GIC ITS Identifier Array
+  EArmObjIdMapping,   ///< 25 - ID Mapping
+  EArmObjSmmuInterruptArray,  ///< 26 - SMMU Interrupt Array
+  EArmObjMax
+} EARM_OBJECT_ID;
+
+/** A structure that describes the
+ARM Boot Architecture flags.
+*/
+typedef struct CmArmBootArchInfo {
+  /** This is the ARM_BOOT_ARCH flags field of the FADT Table
+  described in the ACPI Table Specification.
+  */
+  UINT32  BootArchFlags;
+} CM_ARM_BOOT_ARCH_INFO;
+
+typedef struct CmArmCpuInfo {
+  // Reserved for use when SMBIOS tables are implemented
+} CM_ARM_CPU_INFO;
+
+typedef struct CmArmCpuInfoList {
+  UINT32 CpuCount;
+  CM_ARM_CPU_INFO  * CpuInfo;
+} CM_ARM_CPU_INFO_LIST;
+
+/** A structure that describes the
+Power Management Profile Information for the Platform.
+*/
+typedef struct CmArmPowerManagementProfileInfo {
+  /** This is the Preferred_PM_Profile field of the FADT Table
+  described in the ACPI Specification
+  */
+  UINT8  PowerManagementProfile;
+} CM_ARM_POWER_MANAGEMENT_PROFILE_INFO;
+
+/** A structure that describes the
+GIC CPU Interface for the Platform.
+*/
+typedef struct CmArmGicCInfo {
+  /// The GIC CPU Interface number.
+  UINT32  CPUInterfaceNumber;
+
+  /** The ACPI Processor UID. This must match the
+  _UID of the CPU Device object information described
+  in the DSDT/SSDT for the CPU.
+  */
+  UINT32  AcpiProcessorUid;
+
+  /** The flags field as described by the

[edk2] [PATCH v2 19/22] DynamicTablesPkg: Arm SPCR Table Generator

2019-01-24 Thread Sami Mujawar
The SPCR generator uses the configuration manager protocol to
obtain the serial port information from the platform configuration
manager. It then updates a template SPCR table structure. This
table data is used by the Table Manager to install the SPCR table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf |  42 +++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c| 347 

 3 files changed, 390 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
ad943bc55dea0c8e813750e6b122f6e899ba12a7..069ce635e5150b5914b3d7ef58d9bcfef229879f
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -31,6 +31,7 @@ [Components.common]
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf
   }
 
   #
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf
new file mode 100644
index 
..8dd94e550b8181dea13d5be81688cc35b8b80eac
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  SPCR Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiSpcrLibArm
+  FILE_GUID  = 55088136-7B78-4974-B1EE-F630150D0DE7
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiSpcrLibConstructor
+  DESTRUCTOR = AcpiSpcrLibDestructor
+
+[Sources]
+  SpcrGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c
new file mode 100644
index 
..23d3a50713d200321e3d93850c1b42e48da2faeb
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c
@@ -0,0 +1,347 @@
+/** @file
+  SPCR Table Generator
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - Microsoft Serial Port Console Redirection Table
+Specification - Version 1.03 - August 10, 2015.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard SPCR Table Generator
+
+  Constructs the SPCR table for PL011 or SBSA UART peripherals.
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjSerialConsolePortInfo
+
+NOTE: This implementation ignores the possibility that the Serial settings may
+  be modified from the UEFI Shell.  A more complex handler would be needed
+  to (e.g.) recover serial port settings from the UART, or non-volatile
+  storage.
+*/
+
+#pragma pack(1)
+
+/** This macro defines the no flow control option.
+*/
+#define SPCR_FLOW_CONTROL_NONE   0
+
+/**A template for generating the SPCR Table.
+
+  Note: fields marked "{Template}" will be updated dynamically.
+*/
+STATIC
+EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE AcpiSpcr = {
+  ACPI_HEADER (
+EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,
+EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE,
+EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_REVISION
+),
+  0, // {Template}: Serial Port Subtype
+  {
+EFI_

[edk2] [PATCH v2 02/22] DynamicTablesPkg: Table Generator definition

2019-01-24 Thread Sami Mujawar
A Table generator is a component that implements the logic
for building a firmware table. This is typically implemented
as a library and registers itself with a table factory.

Table generators are further classified based on type of table
it generates, a namespace that signifies if the implementation
is standard or an OEM specific implementation and a table Id.

This patch introduces the definitions used for describing a
table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTablesPkg.dec |  24 ++
 DynamicTablesPkg/Include/TableGenerator.h | 252 
 2 files changed, 276 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec
new file mode 100644
index 
..b1a6c64948d01426fc95b8599fc17adaa8c35f3d
--- /dev/null
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -0,0 +1,24 @@
+## @file
+# dec file for Dynamic Tables Framework.
+#
+# Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+# This program and the accompanying materials are licensed and made available 
under
+# the terms and conditions of the BSD License that accompanies this 
distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+  DEC_SPECIFICATION  = 0x00010005
+  PACKAGE_NAME   = DynamicTablesPkg
+  PACKAGE_GUID   = 188EB346-8ABA-460E-A105-0F9D76F7324A
+  PACKAGE_VERSION= 1.0
+
+[Includes]
+  Include
+
diff --git a/DynamicTablesPkg/Include/TableGenerator.h 
b/DynamicTablesPkg/Include/TableGenerator.h
new file mode 100644
index 
..ea996085683ff6a783ec9a676efce6604b956d8e
--- /dev/null
+++ b/DynamicTablesPkg/Include/TableGenerator.h
@@ -0,0 +1,252 @@
+/** @file
+
+  Copyright (c) 2017, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- ACPI   - Advanced Configuration and Power Interface
+- SMBIOS - System Management BIOS
+- DT - Device Tree
+**/
+
+#ifndef TABLE_GENERATOR_H_
+#define TABLE_GENERATOR_H_
+
+/** The TABLE_GENERATOR_ID type describes the Table Generator ID
+
+  Table Generator ID
+
+___
+|  31 | 30 |29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17| 16|
+---
+|TNSID|  0 |   TT   |  0 |  0 |  0 |  0 |  0 |  0 |  0 |  0 |  0 |  0 |  0|  0|
+___
+___
+|15 | 14 | 13 | 12 | 11 | 10 |  9 |  8 |  7 |  6 |  5 |  4 |  3 |  2 |  1 |  0|
+---
+| Table ID|
+___
+
+  Bit [31] - Table NameSpace ID (TNSID)
+  0 - Standard
+  1 - Custom/OEM
+
+  Bit [30] - Reserved, Must be Zero
+
+  Bit [29:28] - Table Type (TT)
+   0 - ACPI Table
+   1 - SMBIOS Table
+   2 - DT (Device Tree) Table
+   3 - Reserved (INVALID)
+
+  Bit [27:16] - Reserved, Must Be Zero
+
+  Bit [15:0] - Table ID
+
+Standard ACPI Table IDs:
+   0 - Reserved
+   1 - RAW
+   2 - FADT
+   3 - DSDT
+   4 - SSDT
+   5 - MADT
+   6 - GTDT
+   7 - DBG2
+   8 - SPCR
+   9 - MCFG
+
+Standard SMBIOS Table IDs:
+   0 - Reserved
+   1 - RAW
+   2 - Table Type00
+   3 - Table Type01
+   4 - Table Type02
+   5 - Table Type03
+   6 - Table Type04
+   7 - Table Type05
+   8 - Table Type06
+   9 - Table Type07
+  10 - Table Type08
+  11 - Table Type09
+  12 - Table Type10
+  13 - Table Type11
+  14 - Table Type12
+  15 - Table Type13
+  16 - Table Type14
+  17 - Table Type15
+  18 - Table Type16
+  19 - Table Type17
+  20 - Table Type18
+  21 - Table Type19
+  22 - Table Type20
+  23 - Table Type21
+  24 - Table Type22
+  25 - Table Type23
+  26 - Table Type24
+  27 - Table Type25
+  28 - Table Type26
+  29 - Table Type27
+

[edk2] [PATCH v2 09/22] DynamicTablesPkg: Configuration Manager Protocol

2019-01-24 Thread Sami Mujawar
Introduce configuration manager protocol interface
that is used by the dynamic tables framework core
to communicate with configuration manager.

Configuration manager is a platform specific module
that implements the configuration manager protocol.

Table generators use this interface to retrieve the
hardware information from the configuration manager.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTablesPkg.dec|   5 +
 DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h | 128 

 2 files changed, 133 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec
index 
b1a6c64948d01426fc95b8599fc17adaa8c35f3d..e5e731085a721f5f2a0129b4678dedbb0c7b985a
 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dec
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -22,3 +22,8 @@ [Defines]
 [Includes]
   Include
 
+[Protocols]
+
+  # Configuration Manager Protocol GUID
+  gEdkiiConfigurationManagerProtocolGuid = { 0xd85a4835, 0x5a82, 0x4894, { 
0xac, 0x2, 0x70, 0x6f, 0x43, 0xd5, 0x97, 0x8e } }
+
diff --git a/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h 
b/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h
new file mode 100644
index 
..02c3d22ca7e961058c2c157e7f5a981e1418535e
--- /dev/null
+++ b/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h
@@ -0,0 +1,128 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+**/
+
+#ifndef CONFIGURATION_MANAGER_PROTOCOL_H_
+#define CONFIGURATION_MANAGER_PROTOCOL_H_
+
+#include 
+
+/** This macro defines the Configuration Manager Protocol GUID.
+
+  GUID: {D85A4835-5A82-4894-AC02-706F43D5978E}
+*/
+#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_GUID   \
+  { 0xd85a4835, 0x5a82, 0x4894, \
+{ 0xac, 0x2, 0x70, 0x6f, 0x43, 0xd5, 0x97, 0x8e }   \
+  };
+
+/** This macro defines the Configuration Manager Protocol Revision.
+*/
+#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_REVISION  CREATE_REVISION (1, 0)
+
+#pragma pack(1)
+
+/**
+  Forward declarations:
+*/
+typedef struct ConfigurationManagerProtocol 
EDKII_CONFIGURATION_MANAGER_PROTOCOL;
+typedef struct PlatformRepositoryInfo   EDKII_PLATFORM_REPOSITORY_INFO;
+
+/** The GetObject function defines the interface implemented by the
+Configuration Manager Protocol for returning the Configuration
+Manager Objects.
+
+  @param [in]  ThisPointer to the Configuration Manager Protocol.
+  @param [in]  CmObjectId  The Configuration Manager Object ID.
+  @param [in]  Token   An optional token identifying the object. If
+   unused this must be CM_NULL_TOKEN.
+  @param [out] CmObjectPointer to the Configuration Manager Object
+   descriptor describing the requested Object.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object information is not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration Manager
+is less than the Object size for the requested
+object.
+**/
+typedef
+EFI_STATUS
+(EFIAPI * EDKII_CONFIGURATION_MANAGER_GET_OBJECT) (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST This,
+  IN  CONST CM_OBJECT_ID  CmObjectId,
+  IN  CONST CM_OBJECT_TOKEN   Token OPTIONAL,
+  IN  OUT   CM_OBJ_DESCRIPTOR * CONST CmObject
+  );
+
+/** The SetObject function defines the interface implemented by the
+Configuration Manager Protocol for updating the Configuration
+Manager Objects.
+
+  @param [in]  ThisPointer to the Configuration Manager Protocol.
+  @param [in]  CmObjectId  The Configuration Manager Object ID.
+  @param [in]  Token   An optional token identifying the object. If
+   unused this must be CM_NULL_TOKEN.
+  @param [out] CmObjectPointer to the Configuration Manager Object
+   descriptor describing the Object.
+
+  @retval EFI_SUCCESS   The operation completed successfully.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object information is n

[edk2] [PATCH v2 04/22] DynamicTablesPkg: SMBIOS Table Generator

2019-01-24 Thread Sami Mujawar
This patch introduces the required interfaces and definitions
for implementing a SMBIOS table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/SmbiosTableGenerator.h | 240 
 1 file changed, 240 insertions(+)

diff --git a/DynamicTablesPkg/Include/SmbiosTableGenerator.h 
b/DynamicTablesPkg/Include/SmbiosTableGenerator.h
new file mode 100644
index 
..82b9156ac331d93e31d4c82324a9b38311ddb848
--- /dev/null
+++ b/DynamicTablesPkg/Include/SmbiosTableGenerator.h
@@ -0,0 +1,240 @@
+/** @file
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef SMBIOS_TABLE_GENERATOR_H_
+#define SMBIOS_TABLE_GENERATOR_H_
+
+#include 
+
+#include 
+
+#pragma pack(1)
+
+/** The SMBIOS_TABLE_GENERATOR_ID type describes SMBIOS table generator ID.
+*/
+typedef TABLE_GENERATOR_ID SMBIOS_TABLE_GENERATOR_ID;
+
+/** The ESTD_SMBIOS_TABLE_ID enum describes the SMBIOS table IDs reserved for
+  the standard generators.
+
+  NOTE: The SMBIOS Generator IDs do not match the table type numbers!
+  This allows 0 to be used to catch invalid parameters.
+*/
+typedef enum StdSmbiosTableGeneratorId {
+  EStdSmbiosTableIdReserved = 0x,
+  EStdSmbiosTableIdRAW,
+  EStdSmbiosTableIdType00,
+  EStdSmbiosTableIdType01,
+  EStdSmbiosTableIdType02,
+  EStdSmbiosTableIdType03,
+  EStdSmbiosTableIdType04,
+  EStdSmbiosTableIdType05,
+  EStdSmbiosTableIdType06,
+  EStdSmbiosTableIdType07,
+  EStdSmbiosTableIdType08,
+  EStdSmbiosTableIdType09,
+  EStdSmbiosTableIdType10,
+  EStdSmbiosTableIdType11,
+  EStdSmbiosTableIdType12,
+  EStdSmbiosTableIdType13,
+  EStdSmbiosTableIdType14,
+  EStdSmbiosTableIdType15,
+  EStdSmbiosTableIdType16,
+  EStdSmbiosTableIdType17,
+  EStdSmbiosTableIdType18,
+  EStdSmbiosTableIdType19,
+  EStdSmbiosTableIdType20,
+  EStdSmbiosTableIdType21,
+  EStdSmbiosTableIdType22,
+  EStdSmbiosTableIdType23,
+  EStdSmbiosTableIdType24,
+  EStdSmbiosTableIdType25,
+  EStdSmbiosTableIdType26,
+  EStdSmbiosTableIdType27,
+  EStdSmbiosTableIdType28,
+  EStdSmbiosTableIdType29,
+  EStdSmbiosTableIdType30,
+  EStdSmbiosTableIdType31,
+  EStdSmbiosTableIdType32,
+  EStdSmbiosTableIdType33,
+  EStdSmbiosTableIdType34,
+  EStdSmbiosTableIdType35,
+  EStdSmbiosTableIdType36,
+  EStdSmbiosTableIdType37,
+  EStdSmbiosTableIdType38,
+  EStdSmbiosTableIdType39,
+  EStdSmbiosTableIdType40,
+  EStdSmbiosTableIdType41,
+  EStdSmbiosTableIdType42,
+
+  // IDs 43 - 125 are reserved
+
+  EStdSmbiosTableIdType126 = (EStdSmbiosTableIdType00 + 126),
+  EStdSmbiosTableIdType127,
+  EStdSmbiosTableIdMax
+} ESTD_SMBIOS_TABLE_ID;
+
+/** This macro checks if the Table Generator ID is for an SMBIOS Table
+Generator.
+
+  @param [in] TableGeneratorId  The table generator ID.
+
+  @return  TRUE if the table generator ID is for an SMBIOS Table
+Generator.
+**/
+#define IS_GENERATOR_TYPE_SMBIOS(TableGeneratorId) \
+  (\
+  GET_TABLE_TYPE (TableGeneratorId) == \
+  ETableGeneratorTypeSmbios\
+  )
+
+/** This macro checks if the Table Generator ID is for a standard SMBIOS
+Table Generator.
+
+  @param [in] TableGeneratorId  The table generator ID.
+
+  @return  TRUE if the table generator ID is for a standard SMBIOS
+Table Generator.
+**/
+#define IS_VALID_STD_SMBIOS_GENERATOR_ID(TableGeneratorId)  \
+  ( \
+  IS_GENERATOR_NAMESPACE_STD(TableGeneratorId) &&   \
+  IS_GENERATOR_TYPE_SMBIOS(TableGeneratorId)   &&   \
+  ((GET_TABLE_ID(GeneratorId) >= EStdSmbiosTableIdRaw) &&   \
+   (GET_TABLE_ID(GeneratorId) < EStdSmbiosTableIdMax))  \
+  )
+
+/** This macro creates a standard SMBIOS Table Generator ID.
+
+  @param [in] TableId  The table generator ID.
+
+  @return a standard SMBIOS table generator ID.
+**/
+#define CREATE_STD_SMBIOS_TABLE_GEN_ID(TableId) \
+  CREATE_TABLE_GEN_ID ( \
+ETableGeneratorTypeSmbios,  \
+ETableGeneratorNameSpaceStd,\
+TableId \
+)
+
+/** Forward declarations.
+*/
+typedef struct ConfigurationManagerProtocol 
EDKII_CONFIGURATION_MANAGER_PROTOCOL;
+typedef struct CmStdObjSmbiosTableInfo  CM_STD_OBJ_SMBIOS_TABLE_INFO;
+typedef struct SmbiosTableGenerator SMBIOS_TABLE_GENERATOR;
+

[edk2] [PATCH v2 00/22] DynamicTablesPkg: Introduce Dynamic Tables Framework

2019-01-24 Thread Sami Mujawar
Dynamic Tables Framework aims to reduce the amount of effort
required for porting firmware to new platforms by simplifying
the generation of firmware tables based on hardware description
provided by a platform specific component.
 
The Dynamic Tables Framework core queries the platform specific
component to retrieve the required hardware information for
generating standardised firmware tables at run-time.
 
This patch series introduce the Dynamic Tables Framework.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 

The changes can be seen at:
https://github.com/samimujawar/edk2/tree/365_dynamic_tables_framework_v2

This v2 patch series incorporates:
  * provision for extending the framework to support newer
versions of specifications.
  * minor code improvements.

The corresponding edk2-platform changes can be seen at:
https://github.com/samimujawar/edk2-platforms/tree/365_dynamic_tables_framework_v3

Sami Mujawar (22):
  DynamicTablesPkg: Dynamic Tables Framework
  DynamicTablesPkg: Table Generator definition
  DynamicTablesPkg: Acpi Table Generator
  DynamicTablesPkg: SMBIOS Table Generator
  DynamicTablesPkg: DT Table Generator
  DynamicTablesPkg: Standard NameSpace Objects
  DynamicTablesPkg: Arm NameSpace Objects
  DynamicTablesPkg: Configuration Manager Objects
  DynamicTablesPkg: Configuration Manager Protocol
  DynamicTablesPkg: Configuration Manager Helper
  DynamicTablesPkg: Table Helper Library
  DynamicTablesPkg: Dynamic Table Factory Protocol
  DynamicTablesPkg: Dynamic Table Factory Dxe
  DynamicTablesPkg: Dynamic Table Manager Dxe
  DynamicTablesPkg: Arm Raw/DSDT/SSDT Generator
  DynamicTablesPkg: Arm ACPI FADT Generator
  DynamicTablesPkg: Arm ACPI MADT Generator
  DynamicTablesPkg: Arm ACPI GTDT Generator
  DynamicTablesPkg: Arm SPCR Table Generator
  DynamicTablesPkg: Arm DBG2 Table Generator
  DynamicTablesPkg: Arm PCI MCFG Table Generator
  DynamicTablesPkg: Arm IORT Table Generator

 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/AcpiTableFactory/AcpiTableFactory.c
 |  226 +++
 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DeviceTreeTableFactory/DeviceTreeTableFactory.c
 |  225 +++
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactory.h  
 |  125 ++
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c   
 |   90 +
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf 
 |   60 +
 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/SmbiosTableFactory/SmbiosTableFactory.c
 |  226 +++
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c   
 |  735 +++
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf 
 |   50 +
 DynamicTablesPkg/DynamicTables.dsc.inc 
 |   44 +
 DynamicTablesPkg/DynamicTables.fdf.inc 
 |   24 +
 DynamicTablesPkg/DynamicTablesPkg.dec  
 |   43 +
 DynamicTablesPkg/Include/AcpiTableGenerator.h  
 |  360 
 DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
 |  591 ++
 DynamicTablesPkg/Include/ConfigurationManagerHelper.h  
 |  132 ++
 DynamicTablesPkg/Include/ConfigurationManagerObject.h  
 |  182 ++
 DynamicTablesPkg/Include/DeviceTreeTableGenerator.h
 |  182 ++
 DynamicTablesPkg/Include/Library/TableHelperLib.h  
 |   68 +
 DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h   
 |  128 ++
 DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h
 |  269 +++
 DynamicTablesPkg/Include/SmbiosTableGenerator.h
 |  240 +++
 DynamicTablesPkg/Include/StandardNameSpaceObjects.h
 |  119 ++
 DynamicTablesPkg/Include/TableGenerator.h  
 |  252 +++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf
 |   48 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c   
 |  463 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
 |   42 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c   
 |  689 +++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
 |   42 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c   

[edk2] [PATCH v2 08/22] DynamicTablesPkg: Configuration Manager Objects

2019-01-24 Thread Sami Mujawar
The dynamic tables frameworks core communicates with the
platform specific implementation using the configuration
manager protocol interface. The dynamic tables framework
core uses this interface to retrieve information required
for generating the firmware tables. This information is
represented in the form of objects, which are classified
as standard namespace objects, Arm namespace objects or
as Custom/OEM namespace objects.

The configuration manager objects provides a convenient
way for wrapping up the namespaces using a well defined
configuration manager object Id.

The configuration manager is a platform specific component
that collates the platform information required for generating
firmware tables and represents them as configuration manager
objects.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/ConfigurationManagerObject.h | 182 

 1 file changed, 182 insertions(+)

diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h 
b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
new file mode 100644
index 
..ad67e1ce4536170e8dab8a5453a8571e8af7
--- /dev/null
+++ b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
@@ -0,0 +1,182 @@
+/** @file
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+**/
+
+#ifndef CONFIGURATION_MANAGER_OBJECT_H_
+#define CONFIGURATION_MANAGER_OBJECT_H_
+
+#include 
+#include 
+
+#pragma pack(1)
+
+/** The CM_OBJECT_ID type is used to identify the Configuration Manager
+objects.
+
+ Description of Configuration Manager Object ID
+___
+|31 |30 |29 |28 || 27 | 26 | 25 | 24 || 23 | 22 | 21 | 20 || 19 | 18 | 17 | 16|
+---
+| Name Space ID ||  0 |  0 |  0 |  0 ||  0 |  0 |  0 |  0 ||  0 |  0 |  0 |  0|
+___
+
+Bits: [31:28] - Name Space ID
+ - Standard
+0001 - ARM
+1000 - Custom/OEM
+All other values are reserved.
+
+Bits: [27:16] - Reserved.
+___
+|15 |14 |13 |12 || 11 | 10 |  9 |  8 ||  7 |  6 |  5 |  4 ||  3 |  2 |  1 |  0|
+---
+| 0 | 0 | 0 | 0 ||  0 |  0 |  0 |  0 || Object ID |
+___
+
+Bits: [15:8] - Are reserved and must be zero.
+
+Bits: [7:0] - Object ID
+
+Object ID's in the Standard Namespace:
+  0 - Configuration Manager Revision
+  1 - ACPI Table List
+  2 - SMBIOS Table List
+
+Object ID's in the ARM Namespace:
+   0 - Reserved
+   1 - Boot Architecture Info
+   2 - CPU Info
+   3 - Power Management Profile Info
+   4 - GICC Info
+   5 - GICD Info
+   6 - GIC MSI Frame Info
+   7 - GIC Redistributor Info
+   8 - GIC ITS Info
+   9 - Serial Console Port Info
+  10 - Serial Debug Port Info
+  11 - Generic Timer Info
+  12 - Platform GT Block Info
+  13 - Platform Generic Watchdog
+  14 - PCI Configuration Space Info
+  15 - Hypervisor Vendor Id
+  16 - Fixed feature flags for FADT
+*/
+typedef UINT32  CM_OBJECT_ID;
+
+/** A mask for Object ID
+*/
+#define OBJECT_ID_MASK0xFF
+
+/** A mask for Namespace ID
+*/
+#define NAMESPACE_ID_MASK 0xF
+
+/** Starting bit position for Namespace ID
+*/
+#define NAMESPACE_ID_BIT_SHIFT28
+
+/** The EOBJECT_NAMESPACE_ID enum describes the defined namespaces
+for the Configuration Manager Objects.
+*/
+typedef enum ObjectNameSpaceID {
+  EObjNameSpaceStandard,  ///< Standard Objects Namespace
+  EObjNameSpaceArm,   ///< ARM Objects Namespace
+  EObjNameSpaceOem = 0x8, ///< OEM Objects Namespace
+  EObjNameSpaceMax
+} EOBJECT_NAMESPACE_ID;
+
+/** A descriptor for Configuration Manager Objects.
+
+  The Configuration Manager Protocol interface uses this descriptor
+  to return the Configuration Manager Objects.
+*/
+typedef struct CmObjDescriptor {
+  /// Object Id
+  CM_OBJECT_ID  ObjectId;
+
+  /// Size of the described Object or Object List
+  UINT32Size;
+
+  /// Pointer to the described Object or Object List
+  VOID* Data;
+
+  /// Count of objects in the list

[edk2] [PATCH v2 01/22] DynamicTablesPkg: Dynamic Tables Framework

2019-01-24 Thread Sami Mujawar
The dynamic tables framework is designed to generate standardised
firmware tables that describe the hardware information at
run-time. A goal of standardised firmware is to have a common
firmware for a platform capable of booting both Windows and Linux
operating systems.

Traditionally the firmware tables are handcrafted using ACPI
Source Language (ASL), Table Definition Language (TDL) and
C-code. This approach can be error prone and involves time
consuming debugging.

In addition, it may be desirable to configure platform hardware
at runtime such as: configuring the number of cores available
for use by the OS, or turning SoC features ON or OFF.

This patch introduces Dynamic Tables Framework which also provides
mechanisms to reduce the amount of effort required in porting
firmware to new platforms. A more detailed description is in
the Readme.md file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Readme.md | 139 
 1 file changed, 139 insertions(+)

diff --git a/DynamicTablesPkg/Readme.md b/DynamicTablesPkg/Readme.md
new file mode 100644
index 
..93fd1f313aa5227df5c1ccc82dfe17cb4c8f9e0a
--- /dev/null
+++ b/DynamicTablesPkg/Readme.md
@@ -0,0 +1,139 @@
+Dynamic Tables Framework
+
+
+Dynamic Tables Framework provides mechanisms to reduce the amount
+of effort required in porting firmware to new platforms. The aim is
+to provide an implementation capable of generating the firmware
+tables from an external source.  This is potentially a management
+node, either local or remote, or, where suitable, a file that might
+be generated from the system construction.  This initial release
+does not fully implement that - the configuration is held in local
+UEFI modules.
+
+Feature Summary
+---
+The dynamic tables framework is designed to generate standardised
+firmware tables that describe the hardware information at
+run-time. A goal of standardised firmware is to have a common
+firmware for a platform capable of booting both Windows and Linux
+operating systems.
+
+Traditionally the firmware tables are handcrafted using ACPI
+Source Language (ASL), Table Definition Language (TDL) and
+C-code. This approach can be error prone and involves time
+consuming debugging. In addition, it may be desirable to configure
+platform hardware at runtime such as: configuring the number of
+cores available for use by the OS, or turning SoC features ON or
+OFF.
+
+The dynamic tables framework simplifies this by providing a set
+of standard table generators, that are implemented as libraries.
+These generators query a platform specific component, the
+'Configuration Manager', to collate the information required
+for generating the tables at run-time.
+
+The framework also provides the ability to implement custom/OEM
+generators; thereby facilitating support for custom tables. The
+custom generators can also utilize the existing standard generators
+and override any functionality if needed.
+
+The framework currently implements a set of standard ACPI table
+generators for ARM architecture, that can generate Server Base Boot
+Requirement (SBBR) compliant tables. Although, the set of standard
+generators implement the functionality required for ARM architecture;
+the framework is extensible, and support for other architectures can
+be added easily.
+
+The framework currently supports the following table generators for ARM:
+* DBG2 - Debug Port Table 2
+* DSDT - Differentiated system description table. This is essentially
+ a RAW table generator.
+* FADT - Fixed ACPI Description Table
+* GTDT - Generic Timer Description Table
+* IORT - IO Remapping Table
+* MADT - Multiple APIC Description Table
+* MCFG - PCI Express memory mapped configuration space base address
+ Description Table
+* SPCR - Serial Port Console Redirection Table
+* SSDT - Secondary System Description Table. This is essentially
+ a RAW table generator.
+
+Roadmap
+---
+The current implementation of the Configuration Manager populates the
+platform information statically as a C structure. Further enhancements
+to introduce runtime loading of platform information from a platform
+information file is planned.
+
+Also support for generating SMBIOS tables is planned and will be added
+subsequently.
+
+Related Modules
+---
+
+### ACPICA iASL compiler
+The RAW table generator, used to process the DSDT/SSDT files depends on
+the iASL compiler to convert the DSDT/SSDT ASL files to a C array containing
+the hex AML code. The "-tc" option of the iASL compiler has been enhanced to
+support generation of an AML hex file (C header) with a unique symbol name
+so that it is suitable for inclusion from a C source file.
+
+Related Links
+--
+
+
+
+
+Supported Platforms
+---
+1. Juno
+2. FVP Models
+
+Build Instructions
+-

[edk2] [PATCH v2 06/22] DynamicTablesPkg: Standard NameSpace Objects

2019-01-24 Thread Sami Mujawar
The dynamic tables frameworks core communicates with the
platform specific implementation using the configuration
manager protocol interface. The dynamic tables framework
core uses this interface to retrieve information required
for generating the firmware tables. This information is
represented in the form of objects, which are classified
as standard namespace objects, Arm namespace objects or
as Custom/OEM namespace objects.

This patch introduces the definitions for standard
namespace objects.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/StandardNameSpaceObjects.h | 119 
 1 file changed, 119 insertions(+)

diff --git a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h 
b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
new file mode 100644
index 
..4377ee8f785399b02fec824f3a34d2f4ed3b1c01
--- /dev/null
+++ b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
@@ -0,0 +1,119 @@
+/** @file
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+- Std or STD - Standard
+**/
+
+#ifndef STANDARD_NAMESPACE_OBJECTS_H_
+#define STANDARD_NAMESPACE_OBJECTS_H_
+
+#include 
+#include 
+
+#pragma pack(1)
+
+/** A macro defining a reserved zero/NULL token value that
+does not identify any object.
+*/
+#define CM_NULL_TOKEN  0
+
+/** A reference token that the Configuration Manager can use
+to identify a Configuration Manager object.
+
+  This can be used to differentiate between instances of
+  objects of the same types. The identification scheme is
+  implementation defined and is defined by the Configuration
+  Manager.
+
+  Typically the token is used to identify a specific instance
+  from a set of objects in a call to the GetObject()/SetObject(),
+  implemented by the Configuration Manager protocol.
+
+  Note: The token value 0 is reserved for a NULL token and does
+not identify any object.
+**/
+typedef UINTN   CM_OBJECT_TOKEN;
+
+/** The ESTD_OBJECT_ID enum describes the Object IDs
+in the Standard Namespace.
+*/
+typedef enum StdObjectID {
+  EStdObjCfgMgrInfo = 0x, ///< 0 - Configuration Manager Info
+  EStdObjAcpiTableList,   ///< 1 - ACPI table Info List
+  EStdObjSmbiosTableList, ///< 2 - SMBIOS table Info List
+  EStdObjMax
+} ESTD_OBJECT_ID;
+
+/** A structure that describes the Configuration Manager Information.
+*/
+typedef struct CmStdObjConfigurationManagerInfo {
+  /// The Configuration Manager Revision.
+  UINT32  Revision;
+
+  /** The OEM ID. This information is used to
+  populate the ACPI table header information.
+  */
+  UINT8   OemId[6];
+} CM_STD_OBJ_CONFIGURATION_MANAGER_INFO;
+
+/** A structure used to describe the ACPI table generators to be invoked.
+
+  The AcpiTableData member of this structure may be used to directly provide
+  the binary ACPI table data which is required by the following standard
+  generators:
+- RAW
+- DSDT
+- SSDT
+
+  Providing the ACPI table data is optional and depends on the generator
+  that is being invoked. If unused, set AcpiTableData to NULL.
+*/
+typedef struct CmAStdObjAcpiTableInfo {
+  /// The signature of the ACPI Table to be installed
+  UINT32 AcpiTableSignature;
+
+  /// The ACPI table revision
+  UINT32 AcpiTableRevision;
+
+  /// The ACPI Table Generator ID
+  ACPI_TABLE_GENERATOR_IDTableGeneratorId;
+
+  /// Optional pointer to the ACPI table data
+  EFI_ACPI_DESCRIPTION_HEADER  * AcpiTableData;
+
+} CM_STD_OBJ_ACPI_TABLE_INFO;
+
+/** A structure used to describe the SMBIOS table generators to be invoked.
+
+  The SmbiosTableData member of this structure is used to provide
+  the SMBIOS table data which is required by the following standard
+  generator(s):
+- RAW
+
+  Providing the SMBIOS table data is optional and depends on the
+  generator that is being invoked. If unused, set the SmbiosTableData
+  to NULL.
+*/
+typedef struct CmStdObjSmbiosTableInfo {
+  /// The SMBIOS Table Generator ID
+  SMBIOS_TABLE_GENERATOR_ID   TableGeneratorId;
+
+  /// Optional pointer to the SMBIOS table data
+  SMBIOS_STRUCTURE   * SmbiosTableData;
+} CM_STD_OBJ_SMBIOS_TABLE_INFO;
+
+#pragma pack()
+
+#endif // STANDARD_NAMESPACE_OBJECTS_H_
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


___
edk2-devel mailing list
edk2-devel@lists.

Re: [edk2] Network Stack Budgeting

2019-01-24 Thread Tomas Pilar (tpilar)
Hmm,

Mnp->Configure() will eventually call MnpStartSnp().

A grep for Mnp->Configure shows that:
* ArpDxe performs this on DriverBinding.Start()
* Ip6Dxe performs this on DriverBinding.Start()

Ipv4 and DnsDhcp do this as a part of their Configure() they expose in the API.

Cheers,
Tom


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Network Stack Budgeting

2019-01-24 Thread Tomas Pilar (tpilar)


> This reeks. :)
>
> It looks like some driver in the platform sets up a protocol notify
> callback for SNP, with gBS->CreateEvent() +
> gBS->RegisterProtocolNotify(). Your driver's DriverBindingStart()
> function is called normally from BDS, via ConnectController(). In
> DriverBindingStart(), you install an SNP instance, which signals the
> event (makes it pending / queues the notification function for it). Once
> you drop the TPL again, the notification function is called, on the
> stack of gBS->RestoreTPL().
>
> The event's notification funciton probably uses the "Registration"
> feature of gBS->RegisterProtocolNotify(), together with
> gBS->LocateProtocol(), to process only those SNP instances that it
> hasn't seen yet. In other words, it catches exactly the SNP instance
> that your driver just produced, and then it calls the Start() member of it.

This was my assumption a well. I did not consider that another third party 
driver could be the cause of this.
> I've now run
>
>   git grep -A10 -B10 -w gEfiSimpleNetworkProtocolGuid
>
> on edk2, and then searched the output for "RegisterProtocolNotify".
> There were no hits. So, I don't think anything in edk2 behaves like
> described above (thankfully!).
That's good to know, I was going to have a browse through the edk2 network 
stack but this is reassuring.
>
> You mentioned seeing this on "DELL 13G platforms". I suggest opening a
> support case with Dell.
The problem is much more widespread than that. This log is from a HP gen 10 
server. I am pretty sure the DELL 14G also has the same behaviour. That's what 
originally led me to think it might be in upstream.

Cheers,
Tom

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] UEFI Shell + startup.nsh

2019-01-24 Thread Rafael Machado
Thanks a lot for the help Laszlo!
Will take a look. (Also agree about having a signed UEFI Shell not being a
good idea.)

Best Regards
Rafael

Em qui, 24 de jan de 2019 às 10:47, Laszlo Ersek 
escreveu:

> On 01/24/19 13:22, Rafael Machado wrote:
> > Hi everyone.
> >
> > I have a question.
> > Considering I have a PXE server that my client downloads a shell.efi app.
> > Considering also that  I need to execute a .nsh script, but I their is no
> > media at the system.  (no usb or storage device attached)
> >
> > Is there any way to embed a startup.nsh at the shell.efi application?
> > As far as I know with PXE just one file is downloaded and executed. (I am
> > also checking how to use the EfiRamDisk protocol to create a temporary
> > place for the .nsh generated files.)
> >
> > PS.: I don't know to much about HttpBoot. Does HttpBoot has this
> limitation
> > of downloading a single file at startup?
>
> With HttpBoot, you can solve this. The Wiki article (and the relevant
> section) are at:
>
>
> https://github.com/tianocore/tianocore.github.io/wiki/HTTP-Boot#ram-disk-boot-from-http
>
> Here's how:
>
> (1) First, create a FAT image such that the UEFI shell is in the default
> boot loader location, according to the architecture. (e.g.
> EFI/BOOT/BOOTAA64.EFI). Second, place "startup.nsh" in the FAT image
> such that the shell find it, according to the UEFI shell spec.
>
> For this, you can use "mkdosfs" (for formatting the image) and mmd and
> mcopy (from the mtools package) for copying stuff into the image.
> Alternatively, you can use "guestfish",  or even just loop-mount the FAT
> image on Linux. (If you create the image in the first place, then it's
> trustworthy; no need to worry about filesystem driver attacks.)
>
> (2) Once you have the FAT image, let's call it "fat.img", use
> "genisoimage" to generate an ISO image that has "fat.img" as its
> ElTorito boot image.
>
>   genisoimage -input-charset ASCII -efi-boot fat.img -no-emul-boot \
> -o stuff.iso -- fat.img
>
> (3) Serve "stuff.iso" over HTTP.
>
>
> I really hope you are doing this on a trusted, local network!
>
> Secure Boot wouldn't be of much help here; the UEFI shell binary is not
> signed. (And, signing it would be dumb, given that the shell does not
> check signatures on shell scripts, so the scripts can cause the shell to
> do basically anything at all.) HTTPS would likely count as an improvement.
>
> HTH
> Laszlo
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] UEFI Shell + startup.nsh

2019-01-24 Thread Laszlo Ersek
On 01/24/19 13:22, Rafael Machado wrote:
> Hi everyone.
> 
> I have a question.
> Considering I have a PXE server that my client downloads a shell.efi app.
> Considering also that  I need to execute a .nsh script, but I their is no
> media at the system.  (no usb or storage device attached)
> 
> Is there any way to embed a startup.nsh at the shell.efi application?
> As far as I know with PXE just one file is downloaded and executed. (I am
> also checking how to use the EfiRamDisk protocol to create a temporary
> place for the .nsh generated files.)
> 
> PS.: I don't know to much about HttpBoot. Does HttpBoot has this limitation
> of downloading a single file at startup?

With HttpBoot, you can solve this. The Wiki article (and the relevant
section) are at:

https://github.com/tianocore/tianocore.github.io/wiki/HTTP-Boot#ram-disk-boot-from-http

Here's how:

(1) First, create a FAT image such that the UEFI shell is in the default
boot loader location, according to the architecture. (e.g.
EFI/BOOT/BOOTAA64.EFI). Second, place "startup.nsh" in the FAT image
such that the shell find it, according to the UEFI shell spec.

For this, you can use "mkdosfs" (for formatting the image) and mmd and
mcopy (from the mtools package) for copying stuff into the image.
Alternatively, you can use "guestfish",  or even just loop-mount the FAT
image on Linux. (If you create the image in the first place, then it's
trustworthy; no need to worry about filesystem driver attacks.)

(2) Once you have the FAT image, let's call it "fat.img", use
"genisoimage" to generate an ISO image that has "fat.img" as its
ElTorito boot image.

  genisoimage -input-charset ASCII -efi-boot fat.img -no-emul-boot \
-o stuff.iso -- fat.img

(3) Serve "stuff.iso" over HTTP.


I really hope you are doing this on a trusted, local network!

Secure Boot wouldn't be of much help here; the UEFI shell binary is not
signed. (And, signing it would be dumb, given that the shell does not
check signatures on shell scripts, so the scripts can cause the shell to
do basically anything at all.) HTTPS would likely count as an improvement.

HTH
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] UEFI Shell + startup.nsh

2019-01-24 Thread Paulo Alcantara
Rafael Machado  writes:

> I have a question.
> Considering I have a PXE server that my client downloads a shell.efi app.
> Considering also that  I need to execute a .nsh script, but I their is no
> media at the system.  (no usb or storage device attached)
>
> Is there any way to embed a startup.nsh at the shell.efi application?
> As far as I know with PXE just one file is downloaded and executed. (I am
> also checking how to use the EfiRamDisk protocol to create a temporary
> place for the .nsh generated files.)

You'd probably need to format your UEFI RAM disk with an FAT file
system, download the .nsh script into it, then UEFI shell application
would look for the startup script and then execute it.

Paulo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


  1   2   >