mirror of https://github.com/acidanthera/audk.git
Dispatch the UEFI option rom returned from PciPlatform/PciOverride protocol.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16625 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
e8a61b9678
commit
483d0d85a7
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Header files and data structures needed by PCI Bus module.
|
Header files and data structures needed by PCI Bus module.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -249,11 +249,6 @@ struct _PCI_IO_DEVICE {
|
||||||
//
|
//
|
||||||
BOOLEAN AllOpRomProcessed;
|
BOOLEAN AllOpRomProcessed;
|
||||||
|
|
||||||
//
|
|
||||||
// TRUE if the ROM image contains EFI OpROM
|
|
||||||
//
|
|
||||||
BOOLEAN HasEfiOpRom;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// TRUE if there is any EFI driver in the OptionRom
|
// TRUE if there is any EFI driver in the OptionRom
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Supporting functions implementaion for PCI devices management.
|
Supporting functions implementaion for PCI devices management.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -214,6 +214,7 @@ RegisterPciDevice (
|
||||||
UINT8 PciExpressCapRegOffset;
|
UINT8 PciExpressCapRegOffset;
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
UINT8 Data8;
|
UINT8 Data8;
|
||||||
|
BOOLEAN HasEfiImage;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Install the pciio protocol, device path protocol
|
// Install the pciio protocol, device path protocol
|
||||||
|
@ -314,7 +315,12 @@ RegisterPciDevice (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PciIoDevice->HasEfiOpRom) {
|
//
|
||||||
|
// Determine if there are EFI images in the option rom
|
||||||
|
//
|
||||||
|
HasEfiImage = ContainEfiImage (PciIoDevice->PciIo.RomImage, PciIoDevice->PciIo.RomSize);
|
||||||
|
|
||||||
|
if (HasEfiImage) {
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
&PciIoDevice->Handle,
|
&PciIoDevice->Handle,
|
||||||
&gEfiLoadFile2ProtocolGuid,
|
&gEfiLoadFile2ProtocolGuid,
|
||||||
|
@ -344,7 +350,7 @@ RegisterPciDevice (
|
||||||
// The OpRom is got from platform in the above code
|
// The OpRom is got from platform in the above code
|
||||||
// or loaded from device in the previous round of bus enumeration
|
// or loaded from device in the previous round of bus enumeration
|
||||||
//
|
//
|
||||||
if (PciIoDevice->HasEfiOpRom) {
|
if (HasEfiImage) {
|
||||||
ProcessOpRomImage (PciIoDevice);
|
ProcessOpRomImage (PciIoDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,7 +374,7 @@ RegisterPciDevice (
|
||||||
&PciIoDevice->PciIo,
|
&PciIoDevice->PciIo,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
if (PciIoDevice->HasEfiOpRom) {
|
if (HasEfiImage) {
|
||||||
gBS->UninstallMultipleProtocolInterfaces (
|
gBS->UninstallMultipleProtocolInterfaces (
|
||||||
&PciIoDevice->Handle,
|
&PciIoDevice->Handle,
|
||||||
&gEfiLoadFile2ProtocolGuid,
|
&gEfiLoadFile2ProtocolGuid,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
PCI Rom supporting funtions implementation for PCI Bus module.
|
PCI Rom supporting funtions implementation for PCI Bus module.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -309,6 +309,63 @@ GetOpRomInfo (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check if the RomImage contains EFI Images.
|
||||||
|
|
||||||
|
@param RomImage The ROM address of Image for check.
|
||||||
|
@param RomSize Size of ROM for check.
|
||||||
|
|
||||||
|
@retval TRUE ROM contain EFI Image.
|
||||||
|
@retval FALSE ROM not contain EFI Image.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
ContainEfiImage (
|
||||||
|
IN VOID *RomImage,
|
||||||
|
IN UINT64 RomSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PCI_EXPANSION_ROM_HEADER *RomHeader;
|
||||||
|
PCI_DATA_STRUCTURE *RomPcir;
|
||||||
|
UINT8 Indicator;
|
||||||
|
|
||||||
|
Indicator = 0;
|
||||||
|
RomHeader = RomImage;
|
||||||
|
if (RomHeader == NULL) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (RomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
|
||||||
|
RomHeader = (PCI_EXPANSION_ROM_HEADER *) ((UINT8 *) RomHeader + 512);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// The PCI Data Structure must be DWORD aligned.
|
||||||
|
//
|
||||||
|
if (RomHeader->PcirOffset == 0 ||
|
||||||
|
(RomHeader->PcirOffset & 3) != 0 ||
|
||||||
|
(UINT8 *) RomHeader + RomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > (UINT8 *) RomImage + RomSize) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
RomPcir = (PCI_DATA_STRUCTURE *) ((UINT8 *) RomHeader + RomHeader->PcirOffset);
|
||||||
|
if (RomPcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RomPcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Indicator = RomPcir->Indicator;
|
||||||
|
RomHeader = (PCI_EXPANSION_ROM_HEADER *) ((UINT8 *) RomHeader + RomPcir->ImageLength * 512);
|
||||||
|
} while (((UINT8 *) RomHeader < (UINT8 *) RomImage + RomSize) && ((Indicator & 0x80) == 0x00));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Load Option Rom image for specified PCI device.
|
Load Option Rom image for specified PCI device.
|
||||||
|
|
||||||
|
@ -340,7 +397,6 @@ LoadOpRomImage (
|
||||||
UINT32 LegacyImageLength;
|
UINT32 LegacyImageLength;
|
||||||
UINT8 *RomInMemory;
|
UINT8 *RomInMemory;
|
||||||
UINT8 CodeType;
|
UINT8 CodeType;
|
||||||
BOOLEAN HasEfiOpRom;
|
|
||||||
|
|
||||||
RomSize = PciDevice->RomSize;
|
RomSize = PciDevice->RomSize;
|
||||||
|
|
||||||
|
@ -392,7 +448,6 @@ LoadOpRomImage (
|
||||||
RetStatus = EFI_NOT_FOUND;
|
RetStatus = EFI_NOT_FOUND;
|
||||||
FirstCheck = TRUE;
|
FirstCheck = TRUE;
|
||||||
LegacyImageLength = 0;
|
LegacyImageLength = 0;
|
||||||
HasEfiOpRom = FALSE;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
PciDevice->PciRootBridgeIo->Mem.Read (
|
PciDevice->PciRootBridgeIo->Mem.Read (
|
||||||
|
@ -443,8 +498,6 @@ LoadOpRomImage (
|
||||||
if (RomPcir->CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {
|
if (RomPcir->CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {
|
||||||
CodeType = PCI_CODE_TYPE_PCAT_IMAGE;
|
CodeType = PCI_CODE_TYPE_PCAT_IMAGE;
|
||||||
LegacyImageLength = ((UINT32)((EFI_LEGACY_EXPANSION_ROM_HEADER *)RomHeader)->Size512) * 512;
|
LegacyImageLength = ((UINT32)((EFI_LEGACY_EXPANSION_ROM_HEADER *)RomHeader)->Size512) * 512;
|
||||||
} else if (RomPcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) {
|
|
||||||
HasEfiOpRom = TRUE;
|
|
||||||
}
|
}
|
||||||
Indicator = RomPcir->Indicator;
|
Indicator = RomPcir->Indicator;
|
||||||
RomImageSize = RomImageSize + RomPcir->ImageLength * 512;
|
RomImageSize = RomImageSize + RomPcir->ImageLength * 512;
|
||||||
|
@ -484,7 +537,6 @@ LoadOpRomImage (
|
||||||
|
|
||||||
RomDecode (PciDevice, RomBarIndex, RomBar, FALSE);
|
RomDecode (PciDevice, RomBarIndex, RomBar, FALSE);
|
||||||
|
|
||||||
PciDevice->HasEfiOpRom = HasEfiOpRom;
|
|
||||||
PciDevice->EmbeddedRom = TRUE;
|
PciDevice->EmbeddedRom = TRUE;
|
||||||
PciDevice->PciIo.RomSize = RomImageSize;
|
PciDevice->PciIo.RomSize = RomImageSize;
|
||||||
PciDevice->PciIo.RomImage = RomInMemory;
|
PciDevice->PciIo.RomImage = RomInMemory;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
PCI Rom supporting funtions declaration for PCI Bus module.
|
PCI Rom supporting funtions declaration for PCI Bus module.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -60,6 +60,22 @@ LoadFile2 (
|
||||||
IN VOID *Buffer OPTIONAL
|
IN VOID *Buffer OPTIONAL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check if the RomImage contains EFI Images.
|
||||||
|
|
||||||
|
@param RomImage The ROM address of Image for check.
|
||||||
|
@param RomSize Size of ROM for check.
|
||||||
|
|
||||||
|
@retval TRUE ROM contain EFI Image.
|
||||||
|
@retval FALSE ROM not contain EFI Image.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
ContainEfiImage (
|
||||||
|
IN VOID *RomImage,
|
||||||
|
IN UINT64 RomSize
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get Pci device's oprom information.
|
Get Pci device's oprom information.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue