Search code examples
biosuefi

How do I get my UEFI EDK2 based BIOS to automatically load a driver located in its own firmware volume?


I am using the UEFI EDK2 to create a BIOS. I have modified the FDF to move a driver (both UEFI and legacy versions) from the main firmware volume into a separate firmware volume (FV) that I created strictly to hold the driver.

Before I moved the driver from the main FV, I would see the legacy OROM sign-on during POST. However, since I have moved the driver to the new FV, I no longer see the legacy OROM sign-on. It would seem the legacy OROM is no longer being loaded.

It seems that EDK2 "automatically" loads only certain FVs and then dispatches their drivers, but I can't figure out how these particular FVs are identified in EDK2.

I have searched the EDK2 code for several hours trying to find out where/how the FV HOB is created/initialized, but I cannot find this code. I'm guessing I need to add the new FV's GUID to some list or data structure, but I'm really guessing at this point.

Any pointers would be greatly appreciated.


Solution

  • I found the location in the BIOS where the firmware volume HOBs are created (in a proprietary file). I added code there to create a FV HOB for my new firmware volume.

    After that, I had to install a PPI that could process the new firmware volume. Here is the PPI creation code:

        static EFI_PEI_FIRMWARE_VOLUME_INFO_PPI mNewFvPpiInfo = {
          EFI_FIRMWARE_FILESYSTEM2_GUID,
          (VOID*) <Starting address of new FV in the ROM>,
          <size of the new FV in the ROM>,
          NULL,
          NULL
        };
    
        static EFI_PEI_PPI_DESCTRIPTOR mNewFvPpi = {
          (EFI_PEI_PPI_DESCTRIPTOR_PPI | EFI_PEI_PPI_DESCTRIPTOR_TERMINATE_LIST),
          &gEfiPeiFirmwareVolumeInfoPpiGuid,
          &mNewFvPpiInfo
        };
    

    Here is the code that installs the PPI (placed after the new FV HOB is added to the FV HOB list):

        (*ppPeiServices)->InstallPpi(ppPeiServices, &mNewPvPpi);