Re: [edk2] DevicePath for the Boot Services Driver flashed on the Controller Flash.

Subject: Re: [edk2] DevicePath for the Boot Services Driver flashed on the Controller Flash.

From: Andrew Fish <afish@apple.com>

To: edk2-devel@lists.sourceforge.net

Date: 2014-12-05 17:10:17


On Dec 5, 2014, at 7:18 AM, Sathya Prakash <sathya.prakash@avagotech.com> wrote:

I have a boot services driver programmed on the flash of our add-on
controller, when the BSD gets executed from flash, I am trying to identify
form where it is loaded (from flash/shell) and for that I have used  the
below condition and if it is met,

Why do you need to know? 

I assume it is loaded from Shell, if not
I assume it loaded from Flash.  Is there anything wrong in that, in
certain system BIOS implementation even for drivers loaded from flash, the
devicepath is set as FILEPATH.  Any help on this?



The edk2 PCI Bus driver does this.


https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c

    //
    // Create Pci Option Rom Image device path header
    //
    EfiOpRomImageNode.Header.Type     = MEDIA_DEVICE_PATH;
    EfiOpRomImageNode.Header.SubType  = MEDIA_RELATIVE_OFFSET_RANGE_DP;
    SetDevicePathNodeLength (&EfiOpRomImageNode.Header, sizeof (EfiOpRomImageNode));
    EfiOpRomImageNode.StartingOffset  = (UINTN) RomBarOffset - (UINTN) RomBar;
    EfiOpRomImageNode.EndingOffset    = (UINTN) RomBarOffset + ImageSize - 1 - (UINTN) RomBar;

    PciOptionRomImageDevicePath = AppendDevicePathNode (PciDevice->DevicePath, &EfiOpRomImageNode.Header);
    ASSERT (PciOptionRomImageDevicePath != NULL);

    //
    // load image and start image
    //
    BufferSize  = 0;
    Buffer      = NULL;
    ImageHandle = NULL;

    Status = gBS->LoadImage (
                    FALSE,
                    gPciBusDriverBinding.DriverBindingHandle,
                    PciOptionRomImageDevicePath,
                    Buffer,
                    BufferSize,
                    &ImageHandle
                    );

    FreePool (PciOptionRomImageDevicePath);

If it is loaded from the ROM there is going to be a node in the device path (likely 2nd to last) that contains PCI_DEVICE_PATH. You could always look for that.

In the Example below PciDevice->DevicePath is going to be the same device path that has the PCI IO protocol sitting on it. You should be able to dump it from the shell.

Thanks,

Andrew Fish


DevicePathType(LoadedImage->FilePath) == MEDIA_FILEPATH_DP


Thanks
Sathya

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel