public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Heng Luo" <heng.luo@intel.com>
To: devel@edk2.groups.io
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>,
	Nate DeSimone <nathaniel.l.desimone@intel.com>
Subject: [PATCH 5/8] TigerlakeOpenBoardPkg: Add modules
Date: Sun,  7 Feb 2021 13:38:31 +0800	[thread overview]
Message-ID: <20210207053834.4048-5-heng.luo@intel.com> (raw)
In-Reply-To: <20210207053834.4048-1-heng.luo@intel.com>

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

Adds the following modules:
  * BiosInfo

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Heng Luo <heng.luo@intel.com>
---
 Platform/Intel/TigerlakeOpenBoardPkg/BiosInfo/BiosInfo.c   | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Platform/Intel/TigerlakeOpenBoardPkg/BiosInfo/BiosInfo.inf |  83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 283 insertions(+)

diff --git a/Platform/Intel/TigerlakeOpenBoardPkg/BiosInfo/BiosInfo.c b/Platform/Intel/TigerlakeOpenBoardPkg/BiosInfo/BiosInfo.c
new file mode 100644
index 0000000000..46c3d439c2
--- /dev/null
+++ b/Platform/Intel/TigerlakeOpenBoardPkg/BiosInfo/BiosInfo.c
@@ -0,0 +1,200 @@
+/** @file
+  Driver for BIOS Info support.
+
+  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <PiPei.h>
+#include <Guid/BiosInfo.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/HobLib.h>
+#include <Library/PcdLib.h>
+#include <IndustryStandard/FirmwareInterfaceTable.h>
+#include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>
+#include <Library/MemoryAllocationLib.h>
+
+#define BASE_FV_SIZE 10
+
+#define FSP_WRAPPER_FV_SIZE 3
+
+#define TSN_MAC_ADDRESS_FV_SIZE 0
+
+#define BIOS_INFO_STRUCT_SIZE (BASE_FV_SIZE + FSP_WRAPPER_FV_SIZE + TSN_MAC_ADDRESS_FV_SIZE)
+
+
+/*
+  BIOS_INFO structure is the base of the firmware volume layout for Intel platform BIOS implementation
+  so security checker module can run based on the structure and throw warnings, error or deadloop
+  when any unexpected firmware volumes are detected.
+
+  BIOS_INFO is recommended to support full entries of firmware volumes present in a flash
+  with right type, attribute, version, flash map base address and size,
+  all associated information which is defined by BIOS_INFO_STRUCT structure.
+  - IBB firmware volumes, which are expected to be measured or/and verified
+    by hardware base security solution to meet SecureBoot chain of trust
+    (Intel BootGuard for example), have attribute 0x0.
+  - Post IBB firmware volumes, which are expected to be measured or/and verified
+    by BIOS (TCG code for measurement, RSA2048SHA256Sign algorithm for verification for example),
+    have attribute BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB.
+  - Else, follows Firmware Interface Table specification.
+*/
+#pragma pack (1)
+typedef struct {
+  BIOS_INFO_HEADER  Header;
+  BIOS_INFO_STRUCT  Entry[BIOS_INFO_STRUCT_SIZE];
+} BIOS_INFO;
+#pragma pack ()
+
+GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
+  {
+    BIOS_INFO_SIGNATURE,
+    BIOS_INFO_STRUCT_SIZE,
+    0,
+  },
+  {
+    {
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT,
+      0x0100,
+      FixedPcdGet32 (PcdFlashNvStorageVariableSize) + FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize),
+      FixedPcdGet32 (PcdFlashNvStorageVariableBase)
+    },
+    {
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+      0x0100,
+      FixedPcdGet32 (PcdFlashFvAdvancedSize),
+      FixedPcdGet32 (PcdFlashFvAdvancedBase)
+    },
+    {
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+      0x0100,
+      FixedPcdGet32 (PcdFlashFvOptionalSize),
+      FixedPcdGet32 (PcdFlashFvOptionalBase)
+    },
+    {
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+      0x0100,
+      FixedPcdGet32 (PcdFlashFvOsBootSize),
+      FixedPcdGet32 (PcdFlashFvOsBootBase)
+    },
+    {
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+      0x0100,
+      FixedPcdGet32 (PcdFlashFvUefiBootSize),
+      FixedPcdGet32 (PcdFlashFvUefiBootBase)
+    },
+    {
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+      0x0100,
+      FixedPcdGet32 (PcdFlashFvPostMemorySize),
+      FixedPcdGet32 (PcdFlashFvPostMemoryBase)
+    },
+    {
+      /*
+        Note :
+        Startup ACM is one of the binaries in FvFirmwareBinaries,
+        so put type 07 but not type 02.
+        FIT table will contain a type 02 entry with actual address
+        of ACM binary (it is passed as an input to FitGen tool).
+      */
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT,
+      0x0100,
+      FixedPcdGet32 (PcdFlashFvFirmwareBinariesSize),
+      FixedPcdGet32 (PcdFlashFvFirmwareBinariesBase)
+    },
+    {
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+      0x0100,
+      FixedPcdGet32 (PcdFlashFvFspSSize),
+      FixedPcdGet32 (PcdFlashFvFspSBase)
+    },
+    {
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      0x00,    // IBB FV
+      0x0100,
+      FixedPcdGet32 (PcdFlashFvFspMSize),
+      FixedPcdGet32 (PcdFlashFvFspMBase)
+    },
+    {
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      0x00,    // IBB FV
+      0x0100,
+      FixedPcdGet32 (PcdFlashFvFspTSize),
+      FixedPcdGet32 (PcdFlashFvFspTBase)
+    },
+    {
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      0x00,    // IBB FV
+      0x0100,
+      FixedPcdGet32 (PcdFlashFvSecuritySize),
+      FixedPcdGet32 (PcdFlashFvSecurityBase)
+    },
+    {
+      FIT_TYPE_07_BIOS_STARTUP_MODULE,
+      0x00,    // IBB FV
+      0x0100,
+      FixedPcdGet32 (PcdFlashFvPreMemorySize),
+      FixedPcdGet32 (PcdFlashFvPreMemoryBase)
+    },
+    {
+      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,
+  &gBiosInfoGuid,
+  &mBiosInfo
+};
+
+/**
+  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 (&mBiosInfoPpiList);
+    ASSERT_EFI_ERROR (Status);
+
+    //
+    // Build hob, so that DXE module can also get the data.
+    //
+    HobData = BuildGuidHob (&gBiosInfoGuid, sizeof (mBiosInfo));
+    ASSERT (HobData != NULL);
+    if (HobData == NULL) {
+      return EFI_OUT_OF_RESOURCES;
+    }
+    CopyMem (HobData, &mBiosInfo, sizeof (mBiosInfo));
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/TigerlakeOpenBoardPkg/BiosInfo/BiosInfo.inf b/Platform/Intel/TigerlakeOpenBoardPkg/BiosInfo/BiosInfo.inf
new file mode 100644
index 0000000000..66c8814c97
--- /dev/null
+++ b/Platform/Intel/TigerlakeOpenBoardPkg/BiosInfo/BiosInfo.inf
@@ -0,0 +1,83 @@
+## @file
+#  Module Information description file for BIOS Info Driver
+#
+#  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010017
+  BASE_NAME                      = BiosInfo
+  FILE_GUID                      = 4A4CA1C6-871C-45BB-8801-6910A7AA5807
+  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
+  PeiServicesTablePointerLib
+  HobLib
+  BaseMemoryLib
+  MemoryAllocationLib
+  DebugLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  TigerlakeSiliconPkg/SiPkg.dec
+  IntelSiliconPkg/IntelSiliconPkg.dec
+  MinPlatformPkg/MinPlatformPkg.dec
+  TigerlakeOpenBoardPkg/OpenBoardPkg.dec
+  SecurityPkg/SecurityPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
+
+[Pcd]
+  gSiPkgTokenSpaceGuid.PcdBiosAreaBaseAddress                     ## CONSUMES
+  gSiPkgTokenSpaceGuid.PcdBiosSize                                ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase    ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize    ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase  ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize  ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase    ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize    ## CONSUMES
+  gBoardModuleTokenSpaceGuid.PcdFlashFvFirmwareBinariesBase       ## CONSUMES
+  gBoardModuleTokenSpaceGuid.PcdFlashFvFirmwareBinariesSize       ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedBase            ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize            ## CONSUMES
+  gBoardModuleTokenSpaceGuid.PcdFlashFvOptionalBase               ## CONSUMES
+  gBoardModuleTokenSpaceGuid.PcdFlashFvOptionalSize               ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityBase            ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize            ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootBase              ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize              ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase            ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize            ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryBase          ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemorySize          ## CONSUMES
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvBase                    ## CONSUMES
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize                    ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSBase                ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSSize                ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMBase                ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMSize                ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTBase                ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTSize                ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemoryBase           ## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemorySize           ## CONSUMES
+
+
+[Sources]
+  BiosInfo.c
+
+[Guids]
+  gBiosInfoGuid                                 ## PRODUCES
+
+[Depex]
+  gEfiPeiMasterBootModePpiGuid
-- 
2.24.0.windows.2


  parent reply	other threads:[~2021-02-07  5:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-07  5:38 [PATCH 1/8] TigerlakeOpenBoardPkg: Add package and headers Heng Luo
2021-02-07  5:38 ` [PATCH 2/8] TigerlakeOpenBoardPkg/TigerlakeURvp: Add fdf and header file Heng Luo
2021-02-07  5:38 ` [PATCH 3/8] TigerlakeOpenBoardPkg: Add library instances Heng Luo
2021-02-09  0:42   ` Chaganty, Rangasai V
2021-02-09  0:45     ` Chaganty, Rangasai V
2021-02-09  8:47       ` Heng Luo
2021-02-07  5:38 ` [PATCH 4/8] TigerlakeOpenBoardPkg/TigerlakeURvp: " Heng Luo
2021-02-07  5:38 ` Heng Luo [this message]
2021-02-07  5:38 ` [PATCH 6/8] TigerlakeOpenBoardPkg/TigerlakeURvp: Add DSC and build files Heng Luo
2021-02-07  5:38 ` [PATCH 7/8] Enable build for TigerlakeOpenBoardPkg Heng Luo
2021-02-07  5:38 ` [PATCH 8/8] Update Maintainers.txt " Heng Luo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210207053834.4048-5-heng.luo@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox