public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Kubacki, Michael A" <michael.a.kubacki@intel.com>
To: "Ni, Ray" <ray.ni@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Chaganty, Rangasai V" <rangasai.v.chaganty@intel.com>
Subject: Re: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/BootMediaLib: Reduce library API
Date: Tue, 15 Oct 2019 02:21:35 +0000	[thread overview]
Message-ID: <DM6PR11MB383466AF267D2ED341F769C1B5930@DM6PR11MB3834.namprd11.prod.outlook.com> (raw)
In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5C322E81@SHSMSX104.ccr.corp.intel.com>

The two library instances work within the constraints of PEI, DXE, Runtime DXE, and SMM.

I cannot find how a single instance can support all these environments (in as clean a manner) as
is done with the two instances.

Relevant constraints:
* PEI: Cannot write to global variable
* Runtime DXE / SMM: Boot Services are not available outside module entry point

Solution:
* PEI instance: Always retrieve the value from a HOB (use heap for R/W).
* DXE, Runtime DXE, SMM instance: Retrieve the value from the HOB in the entry point
(constructor) when the driver is dispatched and Boot Services are available and store
the value in a global variable so it can be accessed in Runtime DXE and SMM.

Two separate instances resolve these requirements quite naturally.

How would you propose meeting the same level of support with one instance?

Thanks,
Michael

> -----Original Message-----
> From: Ni, Ray <ray.ni@intel.com>
> Sent: Monday, October 14, 2019 6:30 PM
> To: Kubacki, Michael A <michael.a.kubacki@intel.com>;
> devel@edk2.groups.io
> Cc: Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>
> Subject: RE: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/BootMediaLib:
> Reduce library API
> 
> Reviewed-by: Ray Ni <ray.ni@intel.com>
> 
> Mike,
> Thanks for reducing the API.
> 
> For the other comments I raised (single library instance usable for PEI and
> DXE), do you have any comments?
> 
> 
> > -----Original Message-----
> > From: Kubacki, Michael A <michael.a.kubacki@intel.com>
> > Sent: Tuesday, October 15, 2019 5:26 AM
> > To: devel@edk2.groups.io
> > Cc: Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>; Ni, Ray
> > <ray.ni@intel.com>
> > Subject: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/BootMediaLib:
> > Reduce library API
> >
> > Removes the following functions from FirmwareBootMediaLib.h:
> >  * FirmwareBootMediaIsSpi ()
> >  * FirmwareBootMediaIsUfs ()
> >  * FirmwareBootMediaIsEmmc ()
> >  * FirmwareBootMediaIsNvme ()
> >
> > It is preferred to have a single method to retrieve the firmware boot
> media.
> > To reduce overall maintenance effort over time, the
> > FirmwareBootMediaIsXxx () pattern is removed in favor of returning the
> > firmware boot media type via GetFirmwareBootMediaType ().
> >
> > Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
> > Cc: Ray Ni <ray.ni@intel.com>
> > Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com>
> > ---
> >
> >
> Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFirm
> > wareBootMediaLib.inf |   1 -
> >
> >
> Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwareB
> > ootMediaLib.inf    |   1 -
> >  Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib.h
> > |  48 ---------
> >
> >
> Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/FirmwareBoo
> > tMediaLib.c         | 109 --------------------
> >  4 files changed, 159 deletions(-)
> >
> > diff --git
> >
> a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFi
> > r
> > mwareBootMediaLib.inf
> >
> b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFi
> > r
> > mwareBootMediaLib.inf
> > index 83ed5f04af..7e10b5f7a7 100644
> > ---
> >
> a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFi
> > r
> > mwareBootMediaLib.inf
> > +++
> > b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmm
> > +++ FirmwareBootMediaLib.inf
> > @@ -27,7 +27,6 @@
> >  #
> >
> >  [Sources]
> > -  FirmwareBootMediaLib.c
> >    DxeSmmFirmwareBootMediaLib.c
> >
> >  [Packages]
> > diff --git
> > a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmw
> > ar
> > eBootMediaLib.inf
> > b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmw
> > ar
> > eBootMediaLib.inf
> > index 063c4027d3..ff1da31387 100644
> > ---
> > a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmw
> > ar
> > eBootMediaLib.inf
> > +++ b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiF
> > +++ ir
> > +++ mwareBootMediaLib.inf
> > @@ -22,7 +22,6 @@
> >    LIBRARY_CLASS        = FirmwareBootMediaLib
> >
> >  [Sources]
> > -  FirmwareBootMediaLib.c
> >    PeiFirmwareBootMediaLib.c
> >
> >  [Packages]
> > diff --git
> > a/Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib.h
> > b/Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib.h
> > index aca9593a84..b36ebacf30 100644
> > ---
> > a/Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib.h
> > +++ b/Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaL
> > +++ ib
> > +++ .h
> > @@ -55,52 +55,4 @@ FirmwareBootMediaIsKnown (
> >    VOID
> >    );
> >
> > -/**
> > -  Determines if the platform firmware is booting from SPI.
> > -
> > -  @retval TRUE        Platform firmware is booting from SPI
> > -  @retval FALSE       Platform firmware is booting from a non-SPI device or
> the
> > boot media is unknown
> > -**/
> > -BOOLEAN
> > -EFIAPI
> > -FirmwareBootMediaIsSpi (
> > -  VOID
> > -  );
> > -
> > -/**
> > -  Determines if the platform firmware is booting from UFS.
> > -
> > -  @retval TRUE        Platform firmware is booting from UFS
> > -  @retval FALSE       Platform firmware is booting from a non-UFS device or
> > the boot media is unknown
> > -**/
> > -BOOLEAN
> > -EFIAPI
> > -FirmwareBootMediaIsUfs (
> > -  VOID
> > -  );
> > -
> > -/**
> > -  Determines if the platform firmware is booting from eMMC.
> > -
> > -  @retval TRUE        Platform firmware is booting from eMMC
> > -  @retval FALSE       Platform firmware is booting from a non-eMMC device
> or
> > the boot media is unknown
> > -**/
> > -BOOLEAN
> > -EFIAPI
> > -FirmwareBootMediaIsEmmc (
> > -  VOID
> > -  );
> > -
> > -/**
> > -  Determines if the platform firmware is booting from NVMe.
> > -
> > -  @retval TRUE        Platform firmware is booting from NVMe.
> > -  @retval FALSE       Platform firmware is booting from a non-NVMe device
> or
> > the boot media is unknown
> > -**/
> > -BOOLEAN
> > -EFIAPI
> > -FirmwareBootMediaIsNvme (
> > -  VOID
> > -  );
> > -
> >  #endif
> > diff --git
> > a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/Firmware
> > B
> > ootMediaLib.c
> > b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/Firmware
> > B
> > ootMediaLib.c
> > deleted file mode 100644
> > index 11a14d172d..0000000000
> > ---
> > a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/Firmware
> > B
> > ootMediaLib.c
> > +++ /dev/null
> > @@ -1,109 +0,0 @@
> > -/** @file
> > -  This library identifies the firmware boot media device.
> > -
> > -  The firmware boot media device is used to make system
> > initialization decisions in the boot flow dependent
> > -  upon firmware boot media. Note that the firmware boot media is the
> > storage media that the boot firmware is stored on.
> > -  It is not the OS storage media which may be stored upon a different
> > non- volatile storage device.
> > -
> > -  This file contains library implementation common to all boot phases.
> > -
> > -Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > -SPDX-License-Identifier: BSD-2-Clause-Patent
> > -
> > -**/
> > -
> > -#include <Library/BaseLib.h>
> > -#include <Library/DebugLib.h>
> > -#include <Library/FirmwareBootMediaLib.h>
> > -
> > -/**
> > -  Determines if the platform firmware is booting from SPI.
> > -
> > -  @retval TRUE        Platform firmware is booting from SPI
> > -  @retval FALSE       Platform firmware is booting from a non-SPI device or
> the
> > boot media is unknown
> > -**/
> > -BOOLEAN
> > -EFIAPI
> > -FirmwareBootMediaIsSpi (
> > -  VOID
> > -  )
> > -{
> > -  EFI_STATUS          Status;
> > -  FW_BOOT_MEDIA_TYPE  BootMedia;
> > -
> > -  Status = GetFirmwareBootMediaType (&BootMedia);
> > -  if (EFI_ERROR (Status) || BootMedia != FwBootMediaSpi) {
> > -    return FALSE;
> > -  } else {
> > -    return TRUE;
> > -  }
> > -}
> > -
> > -/**
> > -  Determines if the platform firmware is booting from UFS.
> > -
> > -  @retval TRUE        Platform firmware is booting from UFS
> > -  @retval FALSE       Platform firmware is booting from a non-UFS device or
> > the boot media is unknown
> > -**/
> > -BOOLEAN
> > -EFIAPI
> > -FirmwareBootMediaIsUfs (
> > -  VOID
> > -  )
> > -{
> > -  EFI_STATUS          Status;
> > -  FW_BOOT_MEDIA_TYPE  BootMedia;
> > -
> > -  Status = GetFirmwareBootMediaType (&BootMedia);
> > -  if (EFI_ERROR (Status) || BootMedia != FwBootMediaUfs) {
> > -    return FALSE;
> > -  } else {
> > -    return TRUE;
> > -  }
> > -}
> > -
> > -/**
> > -  Determines if the platform firmware is booting from eMMC.
> > -
> > -  @retval TRUE        Platform firmware is booting from eMMC
> > -  @retval FALSE       Platform firmware is booting from a non-eMMC device
> or
> > the boot media is unknown
> > -**/
> > -BOOLEAN
> > -EFIAPI
> > -FirmwareBootMediaIsEmmc (
> > -  VOID
> > -  )
> > -{
> > -  EFI_STATUS          Status;
> > -  FW_BOOT_MEDIA_TYPE  BootMedia;
> > -
> > -  Status = GetFirmwareBootMediaType (&BootMedia);
> > -  if (EFI_ERROR (Status) || BootMedia != FwBootMediaEmmc) {
> > -    return FALSE;
> > -  } else {
> > -    return TRUE;
> > -  }
> > -}
> > -
> > -/**
> > -  Determines if the platform firmware is booting from NVMe.
> > -
> > -  @retval TRUE        Platform firmware is booting from NVMe.
> > -  @retval FALSE       Platform firmware is booting from a non-NVMe device
> or
> > the boot media is unknown
> > -**/
> > -BOOLEAN
> > -EFIAPI
> > -FirmwareBootMediaIsNvme (
> > -  VOID
> > -  )
> > -{
> > -  EFI_STATUS          Status;
> > -  FW_BOOT_MEDIA_TYPE  BootMedia;
> > -
> > -  Status = GetFirmwareBootMediaType (&BootMedia);
> > -  if (EFI_ERROR (Status) || BootMedia != FwBootMediaNvme) {
> > -    return FALSE;
> > -  } else {
> > -    return TRUE;
> > -  }
> > -}
> > --
> > 2.16.2.windows.1
> 


  reply	other threads:[~2019-10-15  2:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 21:26 [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/BootMediaLib: Reduce library API Kubacki, Michael A
2019-10-15  1:29 ` Ni, Ray
2019-10-15  2:21   ` Kubacki, Michael A [this message]
2019-10-15  4:59     ` Ni, Ray
2019-10-15 16:55       ` Kubacki, Michael A
2019-10-16  6:30         ` Ni, Ray
2019-10-16 17:38           ` Kubacki, Michael A
2019-10-17  7:26           ` [edk2-devel] " Nate DeSimone
2019-10-17  7:37             ` Ni, Ray
2019-10-15 17:20 ` Chaganty, Rangasai V
2019-10-17  7:25 ` [edk2-devel] " Nate DeSimone

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=DM6PR11MB383466AF267D2ED341F769C1B5930@DM6PR11MB3834.namprd11.prod.outlook.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