public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Andrew Fish <afish@apple.com>
To: Mike Kinney <michael.d.kinney@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>,
	"Ni, Ruiyu" <ruiyu.ni@intel.com>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"Carsey, Jaben" <jaben.carsey@intel.com>,
	Alexander Graf <agraf@suse.de>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	AKASHI Takahiro <takahiro.akashi@linaro.org>
Subject: Re: portability of ShellPkg
Date: Thu, 06 Sep 2018 15:31:29 -0700	[thread overview]
Message-ID: <8D1E7796-B9F4-49B4-B0D1-43956930D10B@apple.com> (raw)
In-Reply-To: <E92EE9817A31E24EB0585FDF735412F5B8AD314F@ORSMSX113.amr.corp.intel.com>

Mike,

More possible ideas

I think from a 10,000 foot level the issue is the Public definition of the HOB lib calls out the ASSERT behavior 

5) Make the ASSERT() conditional via a PCD and update the HOB lib definition. For platforms that make HOBs options GetHobList() must be called 1st, and non of the other APIs can be called on platforms that don't support HOBs. That has the upside of only needing to make the Lib constructor and GetHobList() ASSERTs conditional onPCDs. 

6) Split the existing UefiBootManagerLib in a backwards compatible way by making a new UefiBootLib. UefiBootManagerLib.h can include UefiBootLib.h and UefiBootManagerLib.inf could depend on UefiBootLib. This would only require adding UefiBootLib to the library class of existing DSC files. 

Thanks,

Andrew Fish

> On Sep 6, 2018, at 10:17 AM, Kinney, Michael D <michael.d.kinney@intel.com> wrote:
> 
> Ray,
> 
> I have a few ideas here.
> 
> 1) Add a new UefiHobLib instance that is only for 
>   use by UEFI Drivers and UEFI Applications.  It fails
>   gracefully if the HOB List is not in the UEFI System
>   Configuration Table.  BootMode if HobList is not present
>   can be BOOT_WITH_FULL_CONFIGURATION.
> 
> 2) Remove ASSERT() from the CONSTRUCTOR and a return
>   NULL from the Get*() functions if mHobList is NULL.
>   BootMode can be BOOT_WITH_FULL_CONFIGURATION if
>   mHobList is NULL.
> 
> 3) Update UEFI Shell to not use the UefiBootManagerLib.
>   This would add duplicate code to the UEFI Shell.
> 
> 4) Update UefiBootManagerLib to not use the HobLib.
>   Instead look for HobList in UEFI System Configuration
>   Table and fail gracefully if it is not present.
>   This would add some duplicate code to the 
>   UefiBootManagerLib to parse the Hob List.
> 
> Best regards,
> 
> Mike
> 
>> -----Original Message-----
>> From: Laszlo Ersek [mailto:lersek@redhat.com]
>> Sent: Thursday, September 6, 2018 2:57 AM
>> To: Ni, Ruiyu <ruiyu.ni@intel.com>; Andrew Fish
>> <afish@apple.com>
>> Cc: Leif Lindholm <leif.lindholm@linaro.org>; edk2-
>> devel@lists.01.org; Carsey, Jaben
>> <jaben.carsey@intel.com>; Alexander Graf
>> <agraf@suse.de>; Heinrich Schuchardt
>> <xypron.glpk@gmx.de>; AKASHI Takahiro
>> <takahiro.akashi@linaro.org>; Kinney, Michael D
>> <michael.d.kinney@intel.com>
>> Subject: Re: portability of ShellPkg
>> 
>> On 09/06/18 04:34, Ni, Ruiyu wrote:
>>> On 9/6/2018 3:47 AM, Andrew Fish wrote:
>>>> 
>>>> Laszlo,
>>>> 
>>>> gEfiMemoryTypeInformationGuid is an edk2/MdeModulePkg
>> concept used to
>>>> give the DXE Core hints on how to reduce
>> fragmentation in the memory
>>>> map. Typically there is code in PEI that creates a
>> HOB and may consume
>>>> a variable written by the BDS. This library seems to
>> be the generic
>>>> way to do it on an edk2 platform.
>>>> 
>>>> Thus this library is not just PI but edk2
>> MdeModulePkg specific in
>>>> some of its assumptions. In general this
>> UefiBootManagerLib seems
>>>> focused on construction and edk2 BDS. It would
>> probably make more
>>>> sense to break out the UEFI Spec related bits so they
>> could be used in
>>>> generic UEFI Applications.
>>>> 
>>>> Thanks,
>>>> 
>>>> Andrew Fish
>>>> 
>>>> 
>>> 
>>> Andrew,
>>> I agree refactoring UefiBootManagerLib to separate the
>> pure UEFI, pure
>>> PI and EDKII specific looks much more cleaner.
>>> So far the PI related bits in UefiBootManagerLib may
>> include:
>>> 1. Hob access for S4 support (memory type information
>> HOB).
>>> 2. Boot from Firmware Volume support.
>>> 
>>> But that requires introducing two or more library
>> classes so affecting
>>> all existing platforms. EfiCreateEventLegacyBootEx()
>> in UefiLib also
>>> touches PI event gEfiEventLegacyBootGuid.
>>> 
>>> And I think the value of refactor might be small.
>>> 
>>> I think root cause of this problem is not
>> UefiBootManagerLib includes
>>> PI, it's the assertion in DxeHobLib.
>>> So I am thinking maybe a very light fix is to remove
>> the constructor of
>>> DxeHobLib.
>>> 
>>> I talked with Liming about this and he suggested that
>> instead of
>>> removing the constructor, it's safer to just remove
>> the assertion in the
>>> constructor. Because removing the constructor of
>> HobLib may cause
>>> AutoGen process generates a different order of library
>> constructors
>>> calling sequence, which may break the platform.
>>> 
>>> So I propose to just remove the assertion in DxeHobLib
>> constructor.
>>> Thoughts?
>> 
>> I think keeping the constructor itself is important and
>> a good idea.
>> 
>> I also think that we should *perhaps* keep the assertion
>> *somewhere*,
>> just not in the constructor. Because, at least some of
>> the HobLib APIs
>> cannot return errors (and their callers expect them to
>> succeed at all
>> times). This suggests we should still trip assertions
>> when a HobLib API
>> is called *in practice* on a non-PI UEFI platform.
>> 
>> Thanks
>> Laszlo



      reply	other threads:[~2018-09-06 22:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05 17:25 portability of ShellPkg Leif Lindholm
2018-09-05 17:30 ` Carsey, Jaben
2018-09-05 17:41   ` Leif Lindholm
2018-09-05 18:03   ` Andrew Fish
2018-09-05 18:05     ` Carsey, Jaben
2018-09-05 18:20       ` Andrew Fish
2018-09-05 18:23         ` Carsey, Jaben
2018-09-05 18:33           ` Andrew Fish
2018-09-05 18:53             ` Carsey, Jaben
2018-09-05 18:43 ` Laszlo Ersek
2018-09-05 19:47   ` Andrew Fish
2018-09-06  2:34     ` Ni, Ruiyu
2018-09-06  9:56       ` Laszlo Ersek
2018-09-06 17:17         ` Kinney, Michael D
2018-09-06 22:31           ` Andrew Fish [this message]

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=8D1E7796-B9F4-49B4-B0D1-43956930D10B@apple.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