mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
MdeModulePkg: Load the native Option ROM image if the native one exists
Issue:https://github.com/tianocore/edk2/issues/11800 If there are multiple Option ROM images existed, current code will load the first image that the emulator supports. Usually, x86 ROM image is the first one and non-x86 ROM image is behind x86 ROM image. When the emulator is introduced, x86 ROM image instead of native image is loaded on non-x86 platforms. This patch introduces a mechanism to prioritize the loading of native images. Firstly, search the native image. If the native one is found, just finish the process since the goal is reached. Otherwise, search the foriegn images that the platform may support. Signed-off-by: Qihang Gao <gaoqihang@loongson.cn> Signed-off-by: Chao Li <lichao@loongson.cn> Suggested-by: Ard Biesheuvel <ardb@kernel.org> Tested-by: Chen Zhang <zhangchen@loongson.cn> Cc: Dongyan Qian <qiandongyan@loongson.cn>
This commit is contained in:
parent
c20483b928
commit
ff3c1adf20
3 changed files with 24 additions and 3 deletions
|
|
@ -329,7 +329,16 @@ RegisterPciDevice (
|
|||
// or loaded from device in the previous round of bus enumeration
|
||||
//
|
||||
if (HasEfiImage) {
|
||||
ProcessOpRomImage (PciIoDevice);
|
||||
//
|
||||
// Try to searching native OpRom first
|
||||
//
|
||||
Status = ProcessOpRomImage (PciIoDevice, TRUE);
|
||||
//
|
||||
// If the native OpRom is not found, try to searching foreign OpRom
|
||||
//
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
ProcessOpRomImage (PciIoDevice, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -642,6 +642,7 @@ RomDecode (
|
|||
Load and start the Option Rom image.
|
||||
|
||||
@param PciDevice Pci device instance.
|
||||
@param NativeOnly Whether to consider only the native image.
|
||||
|
||||
@retval EFI_SUCCESS Successfully loaded and started PCI Option Rom image.
|
||||
@retval EFI_NOT_FOUND Failed to process PCI Option Rom image.
|
||||
|
|
@ -649,7 +650,8 @@ RomDecode (
|
|||
**/
|
||||
EFI_STATUS
|
||||
ProcessOpRomImage (
|
||||
IN PCI_IO_DEVICE *PciDevice
|
||||
IN PCI_IO_DEVICE *PciDevice,
|
||||
IN BOOLEAN NativeOnly
|
||||
)
|
||||
{
|
||||
UINT8 Indicator;
|
||||
|
|
@ -700,6 +702,14 @@ ProcessOpRomImage (
|
|||
goto NextImage;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip the EFI PCI Option ROM image if it's machine type is not supported
|
||||
// and the native image is only considered.
|
||||
//
|
||||
if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (EfiRomHeader->EfiMachineType) && (NativeOnly == TRUE)) {
|
||||
goto NextImage;
|
||||
}
|
||||
|
||||
//
|
||||
// Ignore the EFI PCI Option ROM image if it is an EFI application
|
||||
//
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ RomDecode (
|
|||
Load and start the Option Rom image.
|
||||
|
||||
@param PciDevice Pci device instance.
|
||||
@param NativeOnly Whether to consider only the native image.
|
||||
|
||||
@retval EFI_SUCCESS Successfully loaded and started PCI Option Rom image.
|
||||
@retval EFI_NOT_FOUND Failed to process PCI Option Rom image.
|
||||
|
|
@ -129,7 +130,8 @@ RomDecode (
|
|||
**/
|
||||
EFI_STATUS
|
||||
ProcessOpRomImage (
|
||||
IN PCI_IO_DEVICE *PciDevice
|
||||
IN PCI_IO_DEVICE *PciDevice,
|
||||
IN BOOLEAN NativeOnly
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue