Re: Can DXE drivers be included in executable EFI binary?


Laszlo Ersek
 

On 02/23/21 02:22, joseph via [] wrote:
Hello Laszlo,

It has not been checked in detail, but my predictions are this.
1. When a driver is loaded, it calls "InstallMultipleProtocolInterfaces" within that driver.
This applies only to drivers that do not follow the UEFI Driver Model
(considering the protocols that expose the driver's actual business).

NvmExpressDxe is a UEFI_DRIVER that follows the UEFI Driver Model. In
its entry point (i.e., when it is loaded), it does not install BlockIo.
It installs BlockIo only when it binds PciIo, generally due to some
ConnectController() calls.

2. In this process, "CoreNotifyProtocolEntry" is finally called.
Protocol installations always have to trigger notifications that have
been registered with the RegisterProtocolNotify() boot service, but
RegisterProtocolNotify() is again something that a driver following the
UEFI Driver Model would not use. RegisterProtocolNotify() is generally
used by DXE_DRIVER modules and UEFI_DRIVERs that don't follow the UEFI
Driver Model.

I thought this was the cause of the problem solve, so I thought I should "Notify" the filesystem protocol.


The current situation is like this. This is the mapping table in the EFI Shell right after booting:
FS0: ... PciRoot(0x0)/Pci(0x14,0x0)/USB(0x1,0x0)/HD(1,MBR,...)
BLK0: PciRoot(0x0)/Pci(0x14,0x0)/USB(0x1,0x0)
BLK1: PciRoot(0x0)/Pci(0x17,0x0)/Sata(0x0,0x0,0x0)
After `load (anything filesystem driver).efi` and `map -u`:
FS0: ... PciRoot(0x0)/Pci(0x14,0x0)/USB(0x1,0x0)/HD(1,MBR,...)
BLK0: PciRoot(0x0)/Pci(0x14,0x0)/USB(0x1,0x0)
BLK1: PciRoot(0x0)/Pci(0x17,0x0)/Sata(0x0,0x0,0x0)
FS1: PciRoot(0x0)/Pci(0x17,0x0)/Sata(0x0,0x0,0x0)/HD(1,GPT,.....) <= The newly detected one.
Please see the shell spec on the "load" command:

This command loads an driver into memory. It can load multiple files
at one time, and the file name supports wildcards.

If the -nc flag is not specified, this command will try to connect
the driver to a proper device; it may also cause already loaded
drivers be connected to their corresponding devices.

So my impression is that your BDS might not connect the partition driver
(PartitionDxe) to the SATA disk's BlockIo / DiskIo protocol interfaces
[*]. But when you load a filesystem driver, even that kind of connection
could be made.

[*] see e.g. commit b82802b83f069 for the SATA-related protocol stack,
up to and including BlockIo

Laszlo

Join discuss@edk2.groups.io to automatically receive all group messages.