public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Michael Zimmermann <sigmaepsilon92@gmail.com>,
	Andrew Fish <afish@apple.com>
Cc: Mike Kinney <michael.d.kinney@intel.com>,
	edk2-devel-01 <edk2-devel@lists.01.org>,
	"Dong, Eric" <eric.dong@intel.com>,
	"Zeng, Star" <star.zeng@intel.com>
Subject: Re: UEFI_DRIVER dependencies
Date: Thu, 18 May 2017 12:07:17 +0200	[thread overview]
Message-ID: <a0ca0a82-0b10-98fd-6d7c-9b5f7ab59aae@redhat.com> (raw)
In-Reply-To: <CAN9vWDLYhHGX9SgVPeGr=NFOsY1bZw+H6Dv5D5-vd3oAAGzMXw@mail.gmail.com>

On 05/18/17 08:25, Michael Zimmermann wrote:
> Andrew, doesn't that only address the case where an UEFI_DRIVER has
> dependencies on certain dxe drivers?(which, as you said will always be
> available).
> It's still unclear to me how an UEFI_DRIVER can depend on another
> UEFI_DRIVER this way without relying on the fdf-order or using the device
> binding mechanism.
> 
> My usecase is that I want to install a protocol from within a uefi driver
> which then can be used by other uefi drivers. It's a pure protocol and thus
> doesn't use the binding mechanism to bind to a device.

I don't see why this should be a problem.

Your first driver should be a DXE driver (a platform driver) that
allocates a handle in its entry point function, installing the protocol
instance in question on it. Optionally, consider installing a device
path proto instalce on it as well, most likely with a single VenHw()
node (into which you can put any kind of administrative data you like,
just make sure you grab a fresh vendor GUID with uuidgen).

In turn, your second driver can be a UEFI driver that conforms to the
UEFI driver model. In the Supported() member of the driver binding
protocol, check for the presence of your custom protocol on the handle.
In ths Start() member, open the protocol "by driver".

In this case, the first driver exposes the protocol immediately at
dispatch, and the second driver consumes the protocol when its
Supported() and Start() members are called from within BDS.

We use the above method in practice for virtio-mmio, on ARM / AARCH64:

- ArmVirtPkg/VirtioFdtDxe is a platform driver that produces instances
  of the VIRTIO_DEVICE_PROTOCOL, using VirtioMmioDeviceLib. It is a DXE
  driver.
- In turn, all of the virtio device drivers consume
  VIRTIO_DEVICE_PROTOCOL.

Virtio-pci looks different. For that, we have VirtioPciDeviceDxe (for
legacy virtio) and Virtio10Dxe (for modern-only virtio). Both are UEFI
drivers themselves (operating on PCI IO protocol instances) and both
produce one VIRTIO_DEVICE_PROTOCOL instance per one PCI B/D/F bound. The
virtio device drivers are none the wiser about the actual virtio transport.


If your first driver *must* be a UEFI driver as well (for whatever
reason) that *also* conforms to the UEFI driver model (for whatever
reason), then in that driver, do two things in the enty point function:

(1) install the driver binding protocol instance that you produce
anyway, for UEFI driver model conformance,

(2) *also* do what I described above, for the DXE driver's entry point
function.

This way, when BDS calls into your second UEFI driver, for binding a
handle, the second driver will find the (singleton) protocol instance in
the protocol database, installed by the first driver's entry point
function at dispatch, *even if* the first UEFI driver hasn't bound any
handles yet.

Thanks
Laszlo


      parent reply	other threads:[~2017-05-18 10:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-18  4:43 UEFI_DRIVER dependencies Michael Zimmermann
2017-05-18  4:51 ` Haojian Zhuang
2017-05-18  5:00 ` Kinney, Michael D
2017-05-18  5:21   ` Andrew Fish
2017-05-18  5:42     ` Michael Zimmermann
2017-05-18  6:09       ` Andrew Fish
2017-05-18  6:16         ` Andrew Fish
2017-05-18  6:25           ` Michael Zimmermann
2017-05-18  6:29             ` Zeng, Star
2017-05-18  6:33             ` Andrew Fish
2017-05-18  6:44               ` peter.kirmeier
2017-05-18  6:56                 ` Andrew Fish
2017-05-18 10:07             ` 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=a0ca0a82-0b10-98fd-6d7c-9b5f7ab59aae@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