MdeModulePkg/PciBus: Refine EFI_PCI_ROM_IMAGE_MAPPING

The patch doesn't impact real functionality.
It only renames EFI_PCI_ROM_IMAGE_MAPPING to PCI_ROM_IMAGE,
and changes prototype of PciRomAddImageMapping so that
no explicit type cast is needed when calling this function.

It also removes unused field RomBase from PCI_IO_DEVICE structure.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Ruiyu Ni 2017-10-26 15:54:30 +08:00
parent af807bb986
commit 221c8fd512
5 changed files with 35 additions and 45 deletions

View File

@ -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 - 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2017, 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
@ -239,11 +239,6 @@ struct _PCI_IO_DEVICE {
// //
UINT64 RomSize; UINT64 RomSize;
//
// The OptionRom Size
//
UINT64 RomBase;
// //
// TRUE if all OpROM (in device or in platform specific position) have been processed // TRUE if all OpROM (in device or in platform specific position) have been processed
// //

View File

@ -282,7 +282,7 @@ RegisterPciDevice (
PciIoDevice->BusNumber, PciIoDevice->BusNumber,
PciIoDevice->DeviceNumber, PciIoDevice->DeviceNumber,
PciIoDevice->FunctionNumber, PciIoDevice->FunctionNumber,
(UINT64) (UINTN) PciIoDevice->PciIo.RomImage, PciIoDevice->PciIo.RomImage,
PciIoDevice->PciIo.RomSize PciIoDevice->PciIo.RomSize
); );
} }
@ -308,7 +308,7 @@ RegisterPciDevice (
PciIoDevice->BusNumber, PciIoDevice->BusNumber,
PciIoDevice->DeviceNumber, PciIoDevice->DeviceNumber,
PciIoDevice->FunctionNumber, PciIoDevice->FunctionNumber,
(UINT64) (UINTN) PciIoDevice->PciIo.RomImage, PciIoDevice->PciIo.RomImage,
PciIoDevice->PciIo.RomSize PciIoDevice->PciIo.RomSize
); );
} }

View File

@ -551,7 +551,7 @@ LoadOpRomImage (
PciDevice->BusNumber, PciDevice->BusNumber,
PciDevice->DeviceNumber, PciDevice->DeviceNumber,
PciDevice->FunctionNumber, PciDevice->FunctionNumber,
(UINT64) (UINTN) PciDevice->PciIo.RomImage, PciDevice->PciIo.RomImage,
PciDevice->PciIo.RomSize PciDevice->PciIo.RomSize
); );
@ -766,7 +766,7 @@ ProcessOpRomImage (
PciDevice->BusNumber, PciDevice->BusNumber,
PciDevice->DeviceNumber, PciDevice->DeviceNumber,
PciDevice->FunctionNumber, PciDevice->FunctionNumber,
(UINT64) (UINTN) PciDevice->PciIo.RomImage, PciDevice->PciIo.RomImage,
PciDevice->PciIo.RomSize PciDevice->PciIo.RomSize
); );
RetStatus = EFI_SUCCESS; RetStatus = EFI_SUCCESS;

View File

@ -1,7 +1,7 @@
/** @file /** @file
Set up ROM Table for PCI Bus module. Set up ROM Table for PCI Bus module.
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2017, 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
@ -23,13 +23,13 @@ typedef struct {
UINT8 Bus; UINT8 Bus;
UINT8 Dev; UINT8 Dev;
UINT8 Func; UINT8 Func;
UINT64 RomAddress; VOID *RomImage;
UINT64 RomLength; UINT64 RomSize;
} EFI_PCI_ROM_IMAGE_MAPPING; } PCI_ROM_IMAGE;
UINTN mNumberOfPciRomImages = 0; UINTN mNumberOfPciRomImages = 0;
UINTN mMaxNumberOfPciRomImages = 0; UINTN mMaxNumberOfPciRomImages = 0;
EFI_PCI_ROM_IMAGE_MAPPING *mRomImageTable = NULL; PCI_ROM_IMAGE *mRomImageTable = NULL;
/** /**
Add the Rom Image to internal database for later PCI light enumeration. Add the Rom Image to internal database for later PCI light enumeration.
@ -39,9 +39,8 @@ EFI_PCI_ROM_IMAGE_MAPPING *mRomImageTable = NULL;
@param Bus Bus NO of PCI space. @param Bus Bus NO of PCI space.
@param Dev Dev NO of PCI space. @param Dev Dev NO of PCI space.
@param Func Func NO of PCI space. @param Func Func NO of PCI space.
@param RomAddress Base address of OptionRom. @param RomImage Option Rom buffer.
@param RomLength Length of rom image. @param RomSize Size of Option Rom buffer.
**/ **/
VOID VOID
PciRomAddImageMapping ( PciRomAddImageMapping (
@ -50,29 +49,25 @@ PciRomAddImageMapping (
IN UINT8 Bus, IN UINT8 Bus,
IN UINT8 Dev, IN UINT8 Dev,
IN UINT8 Func, IN UINT8 Func,
IN UINT64 RomAddress, IN VOID *RomImage,
IN UINT64 RomLength IN UINT64 RomSize
) )
{ {
EFI_PCI_ROM_IMAGE_MAPPING *TempMapping; PCI_ROM_IMAGE *NewTable;
if (mNumberOfPciRomImages >= mMaxNumberOfPciRomImages) { if (mNumberOfPciRomImages == mMaxNumberOfPciRomImages) {
mMaxNumberOfPciRomImages += 0x20; NewTable = ReallocatePool (
mMaxNumberOfPciRomImages * sizeof (PCI_ROM_IMAGE),
TempMapping = NULL; (mMaxNumberOfPciRomImages + 0x20) * sizeof (PCI_ROM_IMAGE),
TempMapping = AllocatePool (mMaxNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING)); mRomImageTable
if (TempMapping == NULL) { );
if (NewTable == NULL) {
return ; return ;
} }
CopyMem (TempMapping, mRomImageTable, mNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING)); mRomImageTable = NewTable;
mMaxNumberOfPciRomImages += 0x20;
if (mRomImageTable != NULL) {
FreePool (mRomImageTable);
}
mRomImageTable = TempMapping;
} }
mRomImageTable[mNumberOfPciRomImages].ImageHandle = ImageHandle; mRomImageTable[mNumberOfPciRomImages].ImageHandle = ImageHandle;
@ -80,8 +75,8 @@ PciRomAddImageMapping (
mRomImageTable[mNumberOfPciRomImages].Bus = Bus; mRomImageTable[mNumberOfPciRomImages].Bus = Bus;
mRomImageTable[mNumberOfPciRomImages].Dev = Dev; mRomImageTable[mNumberOfPciRomImages].Dev = Dev;
mRomImageTable[mNumberOfPciRomImages].Func = Func; mRomImageTable[mNumberOfPciRomImages].Func = Func;
mRomImageTable[mNumberOfPciRomImages].RomAddress = RomAddress; mRomImageTable[mNumberOfPciRomImages].RomImage = RomImage;
mRomImageTable[mNumberOfPciRomImages].RomLength = RomLength; mRomImageTable[mNumberOfPciRomImages].RomSize = RomSize;
mNumberOfPciRomImages++; mNumberOfPciRomImages++;
} }
@ -116,8 +111,8 @@ PciRomGetImageMapping (
if (mRomImageTable[Index].ImageHandle != NULL) { if (mRomImageTable[Index].ImageHandle != NULL) {
AddDriver (PciIoDevice, mRomImageTable[Index].ImageHandle); AddDriver (PciIoDevice, mRomImageTable[Index].ImageHandle);
} else { } else {
PciIoDevice->PciIo.RomImage = (VOID *) (UINTN) mRomImageTable[Index].RomAddress; PciIoDevice->PciIo.RomImage = mRomImageTable[Index].RomImage;
PciIoDevice->PciIo.RomSize = (UINTN) mRomImageTable[Index].RomLength; PciIoDevice->PciIo.RomSize = mRomImageTable[Index].RomSize;
} }
} }
} }

View File

@ -1,7 +1,7 @@
/** @file /** @file
Set up ROM Table for PCI Bus module. Set up ROM Table for PCI Bus module.
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2017, 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
@ -23,8 +23,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@param Bus Bus NO of PCI space. @param Bus Bus NO of PCI space.
@param Dev Dev NO of PCI space. @param Dev Dev NO of PCI space.
@param Func Func NO of PCI space. @param Func Func NO of PCI space.
@param RomAddress Base address of OptionRom. @param RomImage Option ROM buffer.
@param RomLength Length of rom image. @param RomSize Size of Option ROM buffer.
**/ **/
VOID VOID
@ -34,8 +34,8 @@ PciRomAddImageMapping (
IN UINT8 Bus, IN UINT8 Bus,
IN UINT8 Dev, IN UINT8 Dev,
IN UINT8 Func, IN UINT8 Func,
IN UINT64 RomAddress, IN VOID *RomImage,
IN UINT64 RomLength IN UINT64 RomSize
); );
/** /**