public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: Rebecca Cran <rebecca@bsdio.com>, devel@edk2.groups.io
Cc: Jordan Justen <jordan.l.justen@intel.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [PATCH v2 (add signed-off-by)] OvmfPkg: Add bhyve support into AcpiTimerLib
Date: Thu, 9 Apr 2020 08:40:12 +0200	[thread overview]
Message-ID: <fe6b3acb-ffb9-d0ad-ed6d-78174626663a@redhat.com> (raw)
In-Reply-To: <040c7e56-cb2f-b0ae-736c-0e1a804946f1@bsdio.com>

On 04/09/20 07:26, Rebecca Cran wrote:
> On 3/27/2020 1:01 PM, Laszlo Ersek wrote:
>>
>> I'm quite happy about this patch, but perhaps for an unexpected reason:
>> namely, because it showcases how non-intuitive and unpredictable it can
>> be to customize existent code for a new platform.
> 
> Thanks! I was wondering if I should try and add new code into OvmfPkg,
> or keep it separate. Also, good point about the commit message: I get
> frustrated when people don't write proper/full messages, so I'm happy
> you called me out on it.
> 
> 
> The existing bhyve port removes everything related to QemuFwCfgLib, such
> as calls to QemuFwCfgFindFile in PciHostBridgeLib.c. I'm not sure how I
> should proceed given that there's so much commonality between the ovmf
> and bhyve versions of the file: currently calls to QemuFwCfgFindFile
> don't resolve since references are absent from the .dsc file, so I'm
> wondering if I should re-add it, add a "#ifndef BHYVE" or similar to
> avoid attempting to compile that code, or duplicate the file with that
> code removed?

I'd recommend the following approaches for your consideration:


(1) Yubo Miao is in the process of factoring out logic that is shared
between ArmVirtPkg's and OvmfPkg's PciHostBridgeLib instances:

http://mid.mail-archive.com/57fd0043-d63a-55b0-9c55-4ca079331885@redhat.com

https://edk2.groups.io/g/devel/message/57062

I proposed that the new lib class be called PciHostBridgeUtilityLib.

You could follow that development, with the intent of building
BhyvePkg's PciHostBridgeLib instance in terms of the new
PciHostBridgeUtilityLib. That would decrease code duplication in BhyvePkg.


(2) If OvmfPkg's PciHostBridgeLib already does the right thing for
BhyvePkg, assuming the

  QemuFwCfgFindFile ("etc/extra-pci-roots", &FwCfgItem, &FwCfgSize)

call returns an error code, then you could introduce a Null instance of
the QemuFwCfgLib class, under OvmfPkg/Library/QemuFwCfgLib. The new INF
file could be called "QemuFwCfgLibNull.inf". There would be a new source
file called "QemuFwCfgLibNull.c", with the following function definitions:

- QemuFwCfgIsAvailable: return constant FALSE
- QemuFwCfgSelectItem, QemuFwCfgReadBytes, QemuFwCfgWriteBytes,
QemuFwCfgSkipBytes: do nothing
- QemuFwCfgRead8, QemuFwCfgRead16, QemuFwCfgRead32, QemuFwCfgRead64:
return 0
- QemuFwCfgFindFile: return RETURN_UNSUPPORTED

Then you could resolve QemuFwCfgLib to this Null instance in the bhyve
DSC file.

(This approach might help you reuse further OvmfPkg modules in BhyvePkg.
A new QemuFwCfgLibNull instance could simplify the existent
"OvmfPkg/OvmfXen.dsc" platform too.)

Thanks
Laszlo


      reply	other threads:[~2020-04-09  6:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 20:16 [PATCH v2 (add signed-off-by)] OvmfPkg: Add bhyve support into AcpiTimerLib Rebecca Cran
2020-03-27 19:01 ` Laszlo Ersek
2020-04-09  5:26   ` Rebecca Cran
2020-04-09  6:40     ` Laszlo Ersek [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=fe6b3acb-ffb9-d0ad-ed6d-78174626663a@redhat.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