Is it possible to manually (from code) load 'Realtek UEFI UNDI Driver' from firmware?


alexey3nemckovich@...
 

I am developing efi application that should work with network.
I found, that some drivers (including 'Realtek UEFI UNDI Driver') are not loaded, when BIOS option 'Fast boot' is on.
I'v tried to load it using EFI_FIRMWARE_VOLUME2_PROTOCOL, enumerating files of type EFI_FV_FILETYPE_DRIVER and loading them, in such way

Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiFirmwareVolumeProtocolGuid, NULL, &NoHandles, &Buffer);
if (!EFI_ERROR(Status)) {
for (Index = 0; Index < NoHandles; Index++) {
Status = gBS->HandleProtocol(Buffer[Index], &gEfiFirmwareVolumeProtocolGuid, (VOID **)&Fv);
if (!EFI_ERROR(Status)) {

for (Index2 = 0; Index2 < sizeof(FileTypes)/sizeof(EFI_FV_FILETYPE); Index2++) {

FileType = FileTypes[Index2];

Key = AllocatePool(Fv->KeySize);
ASSERT(Key != NULL);
ZeroMem(Key, Fv->KeySize);

Index3 = 0;

do {
NextStatus = Fv->GetNextFile(Fv, Key, &FileType, &NameGuid, &Attributes, &Size);

if (EFI_SUCCESS == NextStatus/* && Index3 < 50*/) {

Print(L"1\n");

UiSection = NULL;
Status = Fv->ReadSection(
Fv,
&NameGuid,
EFI_SECTION_USER_INTERFACE,
0,
(VOID **)&UiSection,
&Size,
&Authentication
);

Print(L"3\n");

if (!EFI_ERROR(Status)) {

Print(L"4\n");

Print(L"%d) Found driver image '%s'\n", Index3, UiSection);

EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_HANDLE ImageHandle;

DevicePath = FvFileDevicePath(Buffer[Index], &NameGuid);

Status = gBS->LoadImage(FALSE, gImageHandle, DevicePath, NULL, 0, &ImageHandle);
if (!EFI_ERROR(Status)) {
//PERF_END(NULL, "BDS", NULL, 0);

Print(L"%d) Load image success '%s'\n", Index3, UiSection);

Status = gBS->StartImage(ImageHandle, NULL, NULL);

Some drivers were loaded, but there was not 'Realtek UEFI UNDI Driver' among them.
Maybe somebody knows from where I can load this UNDI driver?


Laszlo Ersek
 

On 05/07/21 09:13, alexey3nemckovich@gmail.com wrote:
I am developing efi application that should work with network.
I found, that some drivers (including 'Realtek UEFI UNDI Driver') are not loaded, when BIOS option 'Fast boot' is on.
I'v tried to load it using EFI_FIRMWARE_VOLUME2_PROTOCOL, enumerating files of type EFI_FV_FILETYPE_DRIVER and loading them, in such way
That will only load drivers that are part of the platform firmware. It
will not load drivers from the disk (which could otherwise be loaded via
Driver#### options), or from the ROM BARs of PCI cards. (The PCI bus
driver installs EFI_LOAD_FILE2_PROTOCOL on the handle that carries
EFI_PCI_IO_PROTOCOL too, for exposing the UEFI driver.) See also
EFI_PCI_IO_PROTOCOL.{RomSize,RomImage}.

... TBH I'm doubtful a UEFI application is supposed to load option ROM
drivers. That's the job of platform BDS. If "fast boot" is selected,
then the system seems to work as intended -- I'm doubtful that running
your application qualifies as "fast boot" either. I'd suggest disabling
fast boot in the first place.

Laszlo


Sean
 

The uefi spec defined method to request the bds connect something is using https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Protocol/BootManagerPolicy.h

We have been trying to move partners away from hacky solutions and to this method.

Thanks
Sean

Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: discuss@edk2.groups.io <discuss@edk2.groups.io> on behalf of Laszlo Ersek <lersek@redhat.com>
Sent: Friday, May 7, 2021 9:08:17 PM
To: discuss@edk2.groups.io <discuss@edk2.groups.io>; alexey3nemckovich@gmail.com <alexey3nemckovich@gmail.com>
Subject: Re: [edk2-discuss] Is it possible to manually (from code) load 'Realtek UEFI UNDI Driver' from firmware?

On 05/07/21 09:13, alexey3nemckovich@gmail.com wrote:
I am developing efi application that should work with network.
I found, that some drivers (including 'Realtek UEFI UNDI Driver') are not loaded, when BIOS option 'Fast boot' is on.
I'v tried to load it using EFI_FIRMWARE_VOLUME2_PROTOCOL, enumerating files of type EFI_FV_FILETYPE_DRIVER and loading them, in such way
That will only load drivers that are part of the platform firmware. It
will not load drivers from the disk (which could otherwise be loaded via
Driver#### options), or from the ROM BARs of PCI cards. (The PCI bus
driver installs EFI_LOAD_FILE2_PROTOCOL on the handle that carries
EFI_PCI_IO_PROTOCOL too, for exposing the UEFI driver.) See also
EFI_PCI_IO_PROTOCOL.{RomSize,RomImage}.

... TBH I'm doubtful a UEFI application is supposed to load option ROM
drivers. That's the job of platform BDS. If "fast boot" is selected,
then the system seems to work as intended -- I'm doubtful that running
your application qualifies as "fast boot" either. I'd suggest disabling
fast boot in the first place.

Laszlo


Michael Brown
 

On 07/05/2021 13:08, Laszlo Ersek wrote:
On 05/07/21 09:13, alexey3nemckovich@gmail.com wrote:
I am developing efi application that should work with network.
I found, that some drivers (including 'Realtek UEFI UNDI Driver') are not loaded, when BIOS option 'Fast boot' is on.
I'v tried to load it using EFI_FIRMWARE_VOLUME2_PROTOCOL, enumerating files of type EFI_FV_FILETYPE_DRIVER and loading them, in such way
That will only load drivers that are part of the platform firmware. It
will not load drivers from the disk (which could otherwise be loaded via
Driver#### options), or from the ROM BARs of PCI cards. (The PCI bus
driver installs EFI_LOAD_FILE2_PROTOCOL on the handle that carries
EFI_PCI_IO_PROTOCOL too, for exposing the UEFI driver.) See also
EFI_PCI_IO_PROTOCOL.{RomSize,RomImage}.
... TBH I'm doubtful a UEFI application is supposed to load option ROM
drivers. That's the job of platform BDS. If "fast boot" is selected,
then the system seems to work as intended -- I'm doubtful that running
your application qualifies as "fast boot" either. I'd suggest disabling
fast boot in the first place.
There is also the possibility that the "fast boot" option is implemented by having the Realtek UEFI UNDI Driver itself check for the "fast boot" setting, and refusing to be loaded (i.e. returning an error from the entry point) if fast boot is enabled. I've seen some vendor drivers using that kind of hack.

Michael