Re: [edk2-devel] [edk2-platforms] [PATCH 2/5] KabylakeOpenBoardPkg/KabylakeRvp3: Add BIOS Info PEIM

2019-10-07 Thread Kubacki, Michael A
Please also fix the typo in the commit message "publishs".

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Kubacki,
> Michael A
> Sent: Monday, October 7, 2019 6:31 PM
> To: Agyeman, Prince ; devel@edk2.groups.io
> Cc: Sinha, Ankit ; Desimone, Nathaniel L
> 
> Subject: Re: [edk2-devel] [edk2-platforms] [PATCH 2/5]
> KabylakeOpenBoardPkg/KabylakeRvp3: Add BIOS Info PEIM
> 
> BiosInfo.c:
> 
> BiosInfoEntryPoint () function description should be updated. The function
> installs the BiosInfo PPI  but also produces the BiosInfo HOB.
> 
> It also looks like you can remove the following macros:
> #define INDEXPORT_TO_ADDRESS(x) (x)
> #define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
> #define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
> #define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
> #define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
> 
> > -Original Message-
> > From: Agyeman, Prince 
> > Sent: Thursday, October 3, 2019 2:13 PM
> > To: devel@edk2.groups.io
> > Cc: Sinha, Ankit ; Desimone, Nathaniel L
> > ; Kubacki, Michael A
> > 
> > Subject: [edk2-platforms] [PATCH 2/5]
> > KabylakeOpenBoardPkg/KabylakeRvp3: Add BIOS Info PEIM
> >
> > Added BIOS Info PEIM to KabylakeRvp3 to publish the BIOS info HOB.
> > This PEIM currently publishs the board's microcode region info.
> >
> > Cc: Ankit Sinha 
> > Cc: Nate DeSimone 
> > Cc: Kubacki Michael A 
> >
> > Signed-off-by: Prince Agyeman 
> > ---
> >  .../KabylakeRvp3/BiosInfo/BiosInfo.c  | 93 +++
> >  .../KabylakeRvp3/BiosInfo/BiosInfo.inf| 48 ++
> >  .../KabylakeRvp3/OpenBoardPkg.dsc |  2 +
> >  .../KabylakeRvp3/OpenBoardPkg.fdf |  1 +
> >  4 files changed, 144 insertions(+)
> >  create mode 100644
> > Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
> >  create mode 100644
> >
> Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.inf
> >
> > diff --git
> >
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
> >
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
> > new file mode 100644
> > index 00..6a058a0fc2
> > --- /dev/null
> > +++
> > b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo
> > +++ .c
> > @@ -0,0 +1,93 @@
> > +/** @file
> > +  Driver for BIOS Info support.
> > +
> > +  Copyright (c) 2019, Intel Corporation. All rights reserved.
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define INDEXPORT_TO_ADDRESS(x) (x)
> > +#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
> > +#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
> > +#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
> > +#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
> > +
> > +//
> > +// Internal
> > +//
> > +#pragma pack (1)
> > +
> > +typedef struct {
> > +  BIOS_INFO_HEADER  Header;
> > +  BIOS_INFO_STRUCT  Entry[1];
> > +} BIOS_INFO;
> > +#pragma pack ()
> > +
> > +GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
> > +  {
> > +BIOS_INFO_SIGNATURE,
> > +1,
> > +0,
> > +  },
> > +  {
> > +{
> > +  FIT_TYPE_01_MICROCODE,
> > +  BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
> > +  0x0100,
> > +  FixedPcdGet32 (PcdFlashMicrocodeFvSize),
> > +  FixedPcdGet32 (PcdFlashMicrocodeFvBase)
> > +}
> > +  }
> > +};
> > +
> > +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR
> > mBiosInfoPpiList
> > += {
> > +  EFI_PEI_PPI_DESCRIPTOR_PPI |
> > EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
> > +  ,
> > +  
> > +};
> > +
> > +/**
> > +  Installs BiosInfo Ppi.
> > +
> > +  @param  FileHandle  Handle of the file being invoked.
> > +  @param  PeiServices Describes the list of possible PEI Services.
> > +
> > +  @retval EFI_SUCCESS   Install the BiosInfo Ppi successfully.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +BiosInfoEntryPoint (
> > +  IN   EFI_PEI_FILE_HANDLE  FileHandle,
> > +  IN CONST EFI_PEI_SERVICES **PeiServices
> > +  )
&

Re: [edk2-devel] [edk2-platforms] [PATCH 2/5] KabylakeOpenBoardPkg/KabylakeRvp3: Add BIOS Info PEIM

2019-10-07 Thread Kubacki, Michael A
BiosInfo.c:

BiosInfoEntryPoint () function description should be updated. The function 
installs the BiosInfo PPI
 but also produces the BiosInfo HOB.

It also looks like you can remove the following macros:
#define INDEXPORT_TO_ADDRESS(x) (x)
#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)

> -Original Message-
> From: Agyeman, Prince 
> Sent: Thursday, October 3, 2019 2:13 PM
> To: devel@edk2.groups.io
> Cc: Sinha, Ankit ; Desimone, Nathaniel L
> ; Kubacki, Michael A
> 
> Subject: [edk2-platforms] [PATCH 2/5]
> KabylakeOpenBoardPkg/KabylakeRvp3: Add BIOS Info PEIM
> 
> Added BIOS Info PEIM to KabylakeRvp3 to publish the BIOS info HOB. This
> PEIM currently publishs the board's microcode region info.
> 
> Cc: Ankit Sinha 
> Cc: Nate DeSimone 
> Cc: Kubacki Michael A 
> 
> Signed-off-by: Prince Agyeman 
> ---
>  .../KabylakeRvp3/BiosInfo/BiosInfo.c  | 93 +++
>  .../KabylakeRvp3/BiosInfo/BiosInfo.inf| 48 ++
>  .../KabylakeRvp3/OpenBoardPkg.dsc |  2 +
>  .../KabylakeRvp3/OpenBoardPkg.fdf |  1 +
>  4 files changed, 144 insertions(+)
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.inf
> 
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
> new file mode 100644
> index 00..6a058a0fc2
> --- /dev/null
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo
> +++ .c
> @@ -0,0 +1,93 @@
> +/** @file
> +  Driver for BIOS Info support.
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define INDEXPORT_TO_ADDRESS(x) (x)
> +#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
> +#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
> +#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
> +#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
> +
> +//
> +// Internal
> +//
> +#pragma pack (1)
> +
> +typedef struct {
> +  BIOS_INFO_HEADER  Header;
> +  BIOS_INFO_STRUCT  Entry[1];
> +} BIOS_INFO;
> +#pragma pack ()
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
> +  {
> +BIOS_INFO_SIGNATURE,
> +1,
> +0,
> +  },
> +  {
> +{
> +  FIT_TYPE_01_MICROCODE,
> +  BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
> +  0x0100,
> +  FixedPcdGet32 (PcdFlashMicrocodeFvSize),
> +  FixedPcdGet32 (PcdFlashMicrocodeFvBase)
> +}
> +  }
> +};
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR
> mBiosInfoPpiList
> += {
> +  EFI_PEI_PPI_DESCRIPTOR_PPI |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
> +  ,
> +  
> +};
> +
> +/**
> +  Installs BiosInfo Ppi.
> +
> +  @param  FileHandle  Handle of the file being invoked.
> +  @param  PeiServices Describes the list of possible PEI Services.
> +
> +  @retval EFI_SUCCESS   Install the BiosInfo Ppi successfully.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +BiosInfoEntryPoint (
> +  IN   EFI_PEI_FILE_HANDLE  FileHandle,
> +  IN CONST EFI_PEI_SERVICES **PeiServices
> +  )
> +{
> +  EFI_STATUS  Status;
> +  VOID*HobData;
> +
> +  //
> +  // Install PPI, so that other PEI module can add dependency.
> +  //
> +  Status = PeiServicesInstallPpi ();  ASSERT_EFI_ERROR
> + (Status);
> +
> +  //
> +  // Build hob, so that DXE module can also get the data.
> +  //
> +  HobData = BuildGuidHob (, sizeof (mBiosInfo));  ASSERT
> + (HobData != NULL);  if (HobData == NULL) {
> +return EFI_OUT_OF_RESOURCES;
> +  }
> +  CopyMem (HobData, , sizeof (mBiosInfo));
> +
> +  return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.i
> nf
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.i
> nf
> new file mode 100644
> index 00..94543408b1
> --- /dev/null
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo
> +++ .inf
> @@ -0,0 +1,48 @@
> +### @file
> +#  Module Information description file for BIOS Info Driver # #
> +Copyright (c) 2019, Intel Corporation. All rights reserved. #
> +SPDX-License-Identifier: BSD-2-Clause-Patent ###
> +
> +[Defines]
> +  INF_VERSION= 0x00010017
> +  BASE_NAME  = BiosInfo
> +  FILE_GUID  = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
> +  VERSION_STRING = 1.0
> +  MODULE_TYPE= PEIM
> +  ENTRY_POINT= BiosInfoEntryPoint
> +#
> +# The following information is for reference only and not 

Re: [edk2-devel] [edk2-platforms] [PATCH 2/5] KabylakeOpenBoardPkg/KabylakeRvp3: Add BIOS Info PEIM

2019-10-07 Thread Kubacki, Michael A
For now, this is definitely possible.

It may also be viable long term. The table is closely tied to the FV layout 
which is
standardized under Minimum Platform. Firmware volumes that may come and go like 
those for
a particular advanced feature would end up as child FVs under a FvAdvanced 
parent that
would be covered in the BIOS Info table. It seems that the FVs that will 
eventually be described in
the table will remain fixed while their contents are customized by individual 
boards. 

Also due to the FV standardization, the FVs that compose the IBB segment 
definition in the table
for S-ACM verification/measurement can likely be consistent across the boards 
in addition to the
post-IBB FVs which leads to a standardized IBB/OBB definition. Some boards 
within a package may
have Boot Guard enabled while others don't but having the FVs identified as 
IBB, post-IBB, or
exclude from FIT in the table will not negatively impact the Boot Guard 
disabled case.

I agree we should start with KabylakeOpenBoardPkg having a single copy of the 
PEIM used for
all boards.

Thanks,
Michael

> -Original Message-
> From: Desimone, Nathaniel L 
> Sent: Monday, October 7, 2019 3:27 PM
> To: Agyeman, Prince ; devel@edk2.groups.io
> Cc: Sinha, Ankit ; Kubacki, Michael A
> 
> Subject: RE: [edk2-platforms] [PATCH 2/5]
> KabylakeOpenBoardPkg/KabylakeRvp3: Add BIOS Info PEIM
> 
> Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
> and Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/BiosInfo/BiosInfo.c
> are identical files. Can we move this up to the parent KabylakeOpenBoardPkg
> and use one PEIM for both platforms?
> 
> -Original Message-
> From: Agyeman, Prince 
> Sent: Thursday, October 3, 2019 2:13 PM
> To: devel@edk2.groups.io
> Cc: Sinha, Ankit ; Desimone, Nathaniel L
> ; Kubacki, Michael A
> 
> Subject: [edk2-platforms] [PATCH 2/5]
> KabylakeOpenBoardPkg/KabylakeRvp3: Add BIOS Info PEIM
> 
> Added BIOS Info PEIM to KabylakeRvp3 to publish the BIOS info HOB. This
> PEIM currently publishs the board's microcode region info.
> 
> Cc: Ankit Sinha 
> Cc: Nate DeSimone 
> Cc: Kubacki Michael A 
> 
> Signed-off-by: Prince Agyeman 
> ---
>  .../KabylakeRvp3/BiosInfo/BiosInfo.c  | 93 +++
>  .../KabylakeRvp3/BiosInfo/BiosInfo.inf| 48 ++
>  .../KabylakeRvp3/OpenBoardPkg.dsc |  2 +
>  .../KabylakeRvp3/OpenBoardPkg.fdf |  1 +
>  4 files changed, 144 insertions(+)
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.inf
> 
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
> new file mode 100644
> index 00..6a058a0fc2
> --- /dev/null
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo
> +++ .c
> @@ -0,0 +1,93 @@
> +/** @file
> +  Driver for BIOS Info support.
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define INDEXPORT_TO_ADDRESS(x) (x)
> +#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
> +#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
> +#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
> +#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
> +
> +//
> +// Internal
> +//
> +#pragma pack (1)
> +
> +typedef struct {
> +  BIOS_INFO_HEADER  Header;
> +  BIOS_INFO_STRUCT  Entry[1];
> +} BIOS_INFO;
> +#pragma pack ()
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
> +  {
> +BIOS_INFO_SIGNATURE,
> +1,
> +0,
> +  },
> +  {
> +{
> +  FIT_TYPE_01_MICROCODE,
> +  BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
> +  0x0100,
> +  FixedPcdGet32 (PcdFlashMicrocodeFvSize),
> +  FixedPcdGet32 (PcdFlashMicrocodeFvBase)
> +}
> +  }
> +};
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR
> mBiosInfoPpiList
> += {
> +  EFI_PEI_PPI_DESCRIPTOR_PPI |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
> +  ,
> +  
> +};
> +
> +/**
> +  Installs BiosInfo Ppi.
> +
> +  @param  FileHandle  Handle of the file being invoked.
> +  @param  PeiServices Describes the list of possible PEI Services.
> +
> +  @retval EFI_SUCCESS   Install the BiosInfo Ppi successfully.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +BiosInfoEntryPoint (
> +  IN   EFI_PEI_FILE_HANDLE  FileHandle,
> +  IN CONST EFI_PEI_SERVICES **PeiServices
> +  )
> +{
> +  EFI_STATUS  Status;
> +  VOID*HobData;
> +
> +  //
> +  // Install PPI, so that other PEI module can add dependency.
> +  //
> +  Status = PeiServicesInstallPpi ();  ASSERT_EFI_ERROR
> + (Status);
> +
> +  //
> +  // Build hob, so that DXE module can also get the data.
> +  //
> +  

Re: [edk2-devel] [edk2-platforms] [PATCH 2/5] KabylakeOpenBoardPkg/KabylakeRvp3: Add BIOS Info PEIM

2019-10-07 Thread Nate DeSimone
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c and 
Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/BiosInfo/BiosInfo.c are 
identical files. Can we move this up to the parent KabylakeOpenBoardPkg and use 
one PEIM for both platforms?

-Original Message-
From: Agyeman, Prince  
Sent: Thursday, October 3, 2019 2:13 PM
To: devel@edk2.groups.io
Cc: Sinha, Ankit ; Desimone, Nathaniel L 
; Kubacki, Michael A 

Subject: [edk2-platforms] [PATCH 2/5] KabylakeOpenBoardPkg/KabylakeRvp3: Add 
BIOS Info PEIM

Added BIOS Info PEIM to KabylakeRvp3 to publish the BIOS info HOB. This PEIM 
currently publishs the board's microcode region info.

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Kubacki Michael A 

Signed-off-by: Prince Agyeman 
---
 .../KabylakeRvp3/BiosInfo/BiosInfo.c  | 93 +++
 .../KabylakeRvp3/BiosInfo/BiosInfo.inf| 48 ++
 .../KabylakeRvp3/OpenBoardPkg.dsc |  2 +
 .../KabylakeRvp3/OpenBoardPkg.fdf |  1 +
 4 files changed, 144 insertions(+)
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.inf

diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c 
b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
new file mode 100644
index 00..6a058a0fc2
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo
+++ .c
@@ -0,0 +1,93 @@
+/** @file
+  Driver for BIOS Info support.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define INDEXPORT_TO_ADDRESS(x) (x)
+#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
+#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
+#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
+#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
+
+//
+// Internal
+//
+#pragma pack (1)
+
+typedef struct {
+  BIOS_INFO_HEADER  Header;
+  BIOS_INFO_STRUCT  Entry[1];
+} BIOS_INFO;
+#pragma pack ()
+
+GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
+  {
+BIOS_INFO_SIGNATURE,
+1,
+0,
+  },
+  {
+{
+  FIT_TYPE_01_MICROCODE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
+  0x0100,
+  FixedPcdGet32 (PcdFlashMicrocodeFvSize),
+  FixedPcdGet32 (PcdFlashMicrocodeFvBase)
+}
+  }
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR  mBiosInfoPpiList 
+= {
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+  ,
+  
+};
+
+/**
+  Installs BiosInfo Ppi.
+
+  @param  FileHandle  Handle of the file being invoked.
+  @param  PeiServices Describes the list of possible PEI Services.
+
+  @retval EFI_SUCCESS   Install the BiosInfo Ppi successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+BiosInfoEntryPoint (
+  IN   EFI_PEI_FILE_HANDLE  FileHandle,
+  IN CONST EFI_PEI_SERVICES **PeiServices
+  )
+{
+  EFI_STATUS  Status;
+  VOID*HobData;
+
+  //
+  // Install PPI, so that other PEI module can add dependency.
+  //
+  Status = PeiServicesInstallPpi ();  ASSERT_EFI_ERROR 
+ (Status);
+
+  //
+  // Build hob, so that DXE module can also get the data.
+  //
+  HobData = BuildGuidHob (, sizeof (mBiosInfo));  ASSERT 
+ (HobData != NULL);  if (HobData == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+  CopyMem (HobData, , sizeof (mBiosInfo));
+
+  return EFI_SUCCESS;
+}
diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.inf 
b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.inf
new file mode 100644
index 00..94543408b1
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo
+++ .inf
@@ -0,0 +1,48 @@
+### @file
+#  Module Information description file for BIOS Info Driver # #
+Copyright (c) 2019, Intel Corporation. All rights reserved. #
+SPDX-License-Identifier: BSD-2-Clause-Patent ###
+
+[Defines]
+  INF_VERSION= 0x00010017
+  BASE_NAME  = BiosInfo
+  FILE_GUID  = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
+  VERSION_STRING = 1.0
+  MODULE_TYPE= PEIM
+  ENTRY_POINT= BiosInfoEntryPoint
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+# VALID_ARCHITECTURES IA32 X64
+#
+
+[LibraryClasses]
+  PeimEntryPoint
+  PeiServicesLib
+  HobLib
+  BaseMemoryLib
+  DebugLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  IntelSiliconPkg/IntelSiliconPkg.dec
+  KabylakeSiliconPkg/SiPkg.dec
+  KabylakeFspBinPkg/KabylakeFspBinPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
+  MinPlatformPkg/MinPlatformPkg.dec
+
+[Pcd]
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvBase## CONSUMES
+  

[edk2-devel] [edk2-platforms] [PATCH 2/5] KabylakeOpenBoardPkg/KabylakeRvp3: Add BIOS Info PEIM

2019-10-03 Thread Agyeman, Prince
Added BIOS Info PEIM to KabylakeRvp3 to publish
the BIOS info HOB. This PEIM currently publishs
the board's microcode region info.

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Kubacki Michael A 

Signed-off-by: Prince Agyeman 
---
 .../KabylakeRvp3/BiosInfo/BiosInfo.c  | 93 +++
 .../KabylakeRvp3/BiosInfo/BiosInfo.inf| 48 ++
 .../KabylakeRvp3/OpenBoardPkg.dsc |  2 +
 .../KabylakeRvp3/OpenBoardPkg.fdf |  1 +
 4 files changed, 144 insertions(+)
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.inf

diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c 
b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
new file mode 100644
index 00..6a058a0fc2
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.c
@@ -0,0 +1,93 @@
+/** @file
+  Driver for BIOS Info support.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define INDEXPORT_TO_ADDRESS(x) (x)
+#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
+#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
+#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
+#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
+
+//
+// Internal
+//
+#pragma pack (1)
+
+typedef struct {
+  BIOS_INFO_HEADER  Header;
+  BIOS_INFO_STRUCT  Entry[1];
+} BIOS_INFO;
+#pragma pack ()
+
+GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
+  {
+BIOS_INFO_SIGNATURE,
+1,
+0,
+  },
+  {
+{
+  FIT_TYPE_01_MICROCODE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
+  0x0100,
+  FixedPcdGet32 (PcdFlashMicrocodeFvSize),
+  FixedPcdGet32 (PcdFlashMicrocodeFvBase)
+}
+  }
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR  mBiosInfoPpiList = {
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+  ,
+  
+};
+
+/**
+  Installs BiosInfo Ppi.
+
+  @param  FileHandle  Handle of the file being invoked.
+  @param  PeiServices Describes the list of possible PEI Services.
+
+  @retval EFI_SUCCESS   Install the BiosInfo Ppi successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+BiosInfoEntryPoint (
+  IN   EFI_PEI_FILE_HANDLE  FileHandle,
+  IN CONST EFI_PEI_SERVICES **PeiServices
+  )
+{
+  EFI_STATUS  Status;
+  VOID*HobData;
+
+  //
+  // Install PPI, so that other PEI module can add dependency.
+  //
+  Status = PeiServicesInstallPpi ();
+  ASSERT_EFI_ERROR (Status);
+
+  //
+  // Build hob, so that DXE module can also get the data.
+  //
+  HobData = BuildGuidHob (, sizeof (mBiosInfo));
+  ASSERT (HobData != NULL);
+  if (HobData == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+  CopyMem (HobData, , sizeof (mBiosInfo));
+
+  return EFI_SUCCESS;
+}
diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.inf 
b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.inf
new file mode 100644
index 00..94543408b1
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/BiosInfo/BiosInfo.inf
@@ -0,0 +1,48 @@
+### @file
+#  Module Information description file for BIOS Info Driver
+#
+#  Copyright (c) 2019, Intel Corporation. All rights reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+###
+
+[Defines]
+  INF_VERSION= 0x00010017
+  BASE_NAME  = BiosInfo
+  FILE_GUID  = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
+  VERSION_STRING = 1.0
+  MODULE_TYPE= PEIM
+  ENTRY_POINT= BiosInfoEntryPoint
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+# VALID_ARCHITECTURES IA32 X64
+#
+
+[LibraryClasses]
+  PeimEntryPoint
+  PeiServicesLib
+  HobLib
+  BaseMemoryLib
+  DebugLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  IntelSiliconPkg/IntelSiliconPkg.dec
+  KabylakeSiliconPkg/SiPkg.dec
+  KabylakeFspBinPkg/KabylakeFspBinPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
+  MinPlatformPkg/MinPlatformPkg.dec
+
+[Pcd]
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvBase## CONSUMES
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize## CONSUMES
+
+[Sources]
+  BiosInfo.c
+
+[Guids]
+  gBiosInfoGuid ## PRODUCES
+
+[Depex]
+  TRUE
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc 
b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
index 7090852192..ef69a19aa4 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
@@ -324,6 +324,8 @@
   }
 !endif
 
+