summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus
diff options
context:
space:
mode:
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2012-09-07 03:15:25 +0000
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2012-09-07 03:15:25 +0000
commit7d921075b454dcd4af7b8b2dc705bff83edb2275 (patch)
treef999a0f94457d6e908fe31c63b7e0ef13cfa84bf /MdeModulePkg/Bus
parentf480fdc0f93d1c20f6e1460d0301fa1386359cde (diff)
downloadedk2-7d921075b454dcd4af7b8b2dc705bff83edb2275.zip
edk2-7d921075b454dcd4af7b8b2dc705bff83edb2275.tar.gz
edk2-7d921075b454dcd4af7b8b2dc705bff83edb2275.tar.bz2
Cache the state whether the ROM image contains EFI Option ROM when loading the ROM content from PCI device to memory to avoid re-parsing the ROM image to check the EFI Option ROM.
Signed-off-by: Ruiyu Ni<ruiyu.ni@intel.com> Reviewed-by: Elvin Li<elvin.li@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13707 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Bus')
-rw-r--r--MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h7
-rw-r--r--MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c14
-rw-r--r--MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c50
-rw-r--r--MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.h19
4 files changed, 16 insertions, 74 deletions
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
index d591f0a..348ce39 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
@@ -1,7 +1,7 @@
/** @file
Header files and data structures needed by PCI Bus module.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
@@ -251,6 +251,11 @@ struct _PCI_IO_DEVICE {
BOOLEAN AllOpRomProcessed;
//
+ // TRUE if the ROM image contains EFI OpROM
+ //
+ BOOLEAN HasEfiOpRom;
+
+ //
// TRUE if there is any EFI driver in the OptionRom
//
BOOLEAN BusOverride;
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
index 8ba5fc5..0ff39a5 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
@@ -1,7 +1,7 @@
/** @file
Supporting functions implementaion for PCI devices management.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
@@ -214,7 +214,6 @@ RegisterPciDevice (
UINT8 PciExpressCapRegOffset;
EFI_PCI_IO_PROTOCOL *PciIo;
UINT8 Data8;
- BOOLEAN HasEfiImage;
//
// Install the pciio protocol, device path protocol
@@ -315,12 +314,7 @@ RegisterPciDevice (
}
}
- //
- // Determine if there are EFI images in the option rom
- //
- HasEfiImage = ContainEfiImage (PciIoDevice->PciIo.RomImage, PciIoDevice->PciIo.RomSize);
-
- if (HasEfiImage) {
+ if (PciIoDevice->HasEfiOpRom) {
Status = gBS->InstallMultipleProtocolInterfaces (
&PciIoDevice->Handle,
&gEfiLoadFile2ProtocolGuid,
@@ -350,7 +344,7 @@ RegisterPciDevice (
// The OpRom is got from platform in the above code
// or loaded from device in the previous round of bus enumeration
//
- if (HasEfiImage) {
+ if (PciIoDevice->HasEfiOpRom) {
ProcessOpRomImage (PciIoDevice);
}
}
@@ -374,7 +368,7 @@ RegisterPciDevice (
&PciIoDevice->PciIo,
NULL
);
- if (HasEfiImage) {
+ if (PciIoDevice->HasEfiOpRom) {
gBS->UninstallMultipleProtocolInterfaces (
&PciIoDevice->Handle,
&gEfiLoadFile2ProtocolGuid,
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
index 84c6f21..33dbfa4 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
@@ -310,51 +310,6 @@ GetOpRomInfo (
}
/**
- 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;
-
- RomHeader = RomImage;
- if (RomHeader == NULL) {
- return FALSE;
- }
- ASSERT (RomHeader->Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE);
-
- while ((UINT8 *) RomHeader < (UINT8 *) RomImage + RomSize) {
- if (RomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
- RomHeader = (PCI_EXPANSION_ROM_HEADER *) ((UINT8 *) RomHeader + 512);
- continue;
- }
-
- RomPcir = (PCI_DATA_STRUCTURE *) ((UINT8 *) RomHeader + RomHeader->PcirOffset);
- ASSERT (RomPcir->Signature == PCI_DATA_STRUCTURE_SIGNATURE);
-
- if (RomPcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) {
- return TRUE;
- }
-
- RomHeader = (PCI_EXPANSION_ROM_HEADER *) ((UINT8 *) RomHeader + RomPcir->Length * 512);
- }
-
- return FALSE;
-}
-
-
-/**
Load Option Rom image for specified PCI device.
@param PciDevice Pci device instance.
@@ -385,6 +340,7 @@ LoadOpRomImage (
UINT32 LegacyImageLength;
UINT8 *RomInMemory;
UINT8 CodeType;
+ BOOLEAN HasEfiOpRom;
RomSize = PciDevice->RomSize;
@@ -436,6 +392,7 @@ LoadOpRomImage (
RetStatus = EFI_NOT_FOUND;
FirstCheck = TRUE;
LegacyImageLength = 0;
+ HasEfiOpRom = FALSE;
do {
PciDevice->PciRootBridgeIo->Mem.Read (
@@ -486,6 +443,8 @@ LoadOpRomImage (
if (RomPcir->CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {
CodeType = PCI_CODE_TYPE_PCAT_IMAGE;
LegacyImageLength = ((UINT32)((EFI_LEGACY_EXPANSION_ROM_HEADER *)RomHeader)->Size512) * 512;
+ } else if (RomPcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) {
+ HasEfiOpRom = TRUE;
}
Indicator = RomPcir->Indicator;
RomImageSize = RomImageSize + RomPcir->ImageLength * 512;
@@ -525,6 +484,7 @@ LoadOpRomImage (
RomDecode (PciDevice, RomBarIndex, RomBar, FALSE);
+ PciDevice->HasEfiOpRom = HasEfiOpRom;
PciDevice->EmbeddedRom = TRUE;
PciDevice->PciIo.RomSize = RomImageSize;
PciDevice->PciIo.RomImage = RomInMemory;
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.h
index 2105fde..6a7f0e3 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.h
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.h
@@ -1,7 +1,7 @@
/** @file
PCI Rom supporting funtions declaration for PCI Bus module.
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
@@ -61,23 +61,6 @@ LoadFile2 (
);
/**
- 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.
@param PciIoDevice Input Pci device instance.