public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Star Zeng <star.zeng@intel.com>
Subject: [PATCH 1/3] MdeModulePkg/PciBus: Refine EFI_PCI_ROM_IMAGE_MAPPING
Date: Fri, 27 Oct 2017 14:54:36 +0800	[thread overview]
Message-ID: <20171027065438.284440-2-ruiyu.ni@intel.com> (raw)
In-Reply-To: <20171027065438.284440-1-ruiyu.ni@intel.com>

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>
Cc: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h            |  7 +--
 MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c  |  4 +-
 .../Bus/Pci/PciBusDxe/PciOptionRomSupport.c        |  4 +-
 MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.c       | 55 ++++++++++------------
 MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.h       | 10 ++--
 5 files changed, 35 insertions(+), 45 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
index 3bcc134d0b..55eb3a5a80 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 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, 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
@@ -240,11 +240,6 @@ struct _PCI_IO_DEVICE {
   UINT64                                    RomSize;
 
   //
-  // The OptionRom Size
-  //
-  UINT64                                    RomBase;
-
-  //
   // TRUE if all OpROM (in device or in platform specific position) have been processed
   //
   BOOLEAN                                   AllOpRomProcessed;
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
index 359b9ded6d..97bb971a59 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
@@ -282,7 +282,7 @@ RegisterPciDevice (
           PciIoDevice->BusNumber,
           PciIoDevice->DeviceNumber,
           PciIoDevice->FunctionNumber,
-          (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,
+          PciIoDevice->PciIo.RomImage,
           PciIoDevice->PciIo.RomSize
           );
       }
@@ -308,7 +308,7 @@ RegisterPciDevice (
           PciIoDevice->BusNumber,
           PciIoDevice->DeviceNumber,
           PciIoDevice->FunctionNumber,
-          (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,
+          PciIoDevice->PciIo.RomImage,
           PciIoDevice->PciIo.RomSize
           );
       }   
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
index 3713c07844..4382d79c2d 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
@@ -551,7 +551,7 @@ LoadOpRomImage (
     PciDevice->BusNumber,
     PciDevice->DeviceNumber,
     PciDevice->FunctionNumber,
-    (UINT64) (UINTN) PciDevice->PciIo.RomImage,
+    PciDevice->PciIo.RomImage,
     PciDevice->PciIo.RomSize
     );
 
@@ -766,7 +766,7 @@ ProcessOpRomImage (
           PciDevice->BusNumber,
           PciDevice->DeviceNumber,
           PciDevice->FunctionNumber,
-          (UINT64) (UINTN) PciDevice->PciIo.RomImage,
+          PciDevice->PciIo.RomImage,
           PciDevice->PciIo.RomSize
           );
         RetStatus = EFI_SUCCESS;
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.c
index f48c3a0c59..0eef41739c 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.c
@@ -1,7 +1,7 @@
 /** @file
   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
 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
@@ -23,13 +23,13 @@ typedef struct {
   UINT8       Bus;
   UINT8       Dev;
   UINT8       Func;
-  UINT64      RomAddress;
-  UINT64      RomLength;
-} EFI_PCI_ROM_IMAGE_MAPPING;
+  VOID        *RomImage;
+  UINT64      RomSize;
+} PCI_ROM_IMAGE;
 
-UINTN                      mNumberOfPciRomImages     = 0;
-UINTN                      mMaxNumberOfPciRomImages  = 0;
-EFI_PCI_ROM_IMAGE_MAPPING  *mRomImageTable           = NULL;
+UINTN          mNumberOfPciRomImages     = 0;
+UINTN          mMaxNumberOfPciRomImages  = 0;
+PCI_ROM_IMAGE  *mRomImageTable           = NULL;
 
 /**
   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 Dev            Dev NO of PCI space.
   @param Func           Func NO of PCI space.
-  @param RomAddress     Base address of OptionRom.
-  @param RomLength      Length of rom image.
-
+  @param RomImage       Option Rom buffer.
+  @param RomSize        Size of Option Rom buffer.
 **/
 VOID
 PciRomAddImageMapping (
@@ -50,29 +49,25 @@ PciRomAddImageMapping (
   IN  UINT8       Bus,
   IN  UINT8       Dev,
   IN  UINT8       Func,
-  IN  UINT64      RomAddress,
-  IN  UINT64      RomLength
+  IN  VOID        *RomImage,
+  IN  UINT64      RomSize
   )
 {
-  EFI_PCI_ROM_IMAGE_MAPPING *TempMapping;
-
-  if (mNumberOfPciRomImages >= mMaxNumberOfPciRomImages) {
+  PCI_ROM_IMAGE   *NewTable;
 
-    mMaxNumberOfPciRomImages += 0x20;
+  if (mNumberOfPciRomImages == mMaxNumberOfPciRomImages) {
 
-    TempMapping = NULL;
-    TempMapping = AllocatePool (mMaxNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING));
-    if (TempMapping == NULL) {
+    NewTable = ReallocatePool (
+                 mMaxNumberOfPciRomImages * sizeof (PCI_ROM_IMAGE),
+                 (mMaxNumberOfPciRomImages + 0x20) * sizeof (PCI_ROM_IMAGE),
+                 mRomImageTable
+                 );
+    if (NewTable == NULL) {
       return ;
     }
 
-    CopyMem (TempMapping, mRomImageTable, mNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING));
-
-    if (mRomImageTable != NULL) {
-      FreePool (mRomImageTable);
-    }
-
-    mRomImageTable = TempMapping;
+    mRomImageTable            = NewTable;
+    mMaxNumberOfPciRomImages += 0x20;
   }
 
   mRomImageTable[mNumberOfPciRomImages].ImageHandle = ImageHandle;
@@ -80,8 +75,8 @@ PciRomAddImageMapping (
   mRomImageTable[mNumberOfPciRomImages].Bus         = Bus;
   mRomImageTable[mNumberOfPciRomImages].Dev         = Dev;
   mRomImageTable[mNumberOfPciRomImages].Func        = Func;
-  mRomImageTable[mNumberOfPciRomImages].RomAddress  = RomAddress;
-  mRomImageTable[mNumberOfPciRomImages].RomLength   = RomLength;
+  mRomImageTable[mNumberOfPciRomImages].RomImage    = RomImage;
+  mRomImageTable[mNumberOfPciRomImages].RomSize     = RomSize;
   mNumberOfPciRomImages++;
 }
 
@@ -116,8 +111,8 @@ PciRomGetImageMapping (
       if (mRomImageTable[Index].ImageHandle != NULL) {
         AddDriver (PciIoDevice, mRomImageTable[Index].ImageHandle);
       } else {
-        PciIoDevice->PciIo.RomImage = (VOID *) (UINTN) mRomImageTable[Index].RomAddress;
-        PciIoDevice->PciIo.RomSize  = (UINTN) mRomImageTable[Index].RomLength;
+        PciIoDevice->PciIo.RomImage = mRomImageTable[Index].RomImage;
+        PciIoDevice->PciIo.RomSize  = mRomImageTable[Index].RomSize;
       }
     }
   }
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.h
index d443f83336..a7a1ed4ce3 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.h
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.h
@@ -1,7 +1,7 @@
 /** @file
   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
 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
@@ -23,8 +23,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @param Bus            Bus NO of PCI space.
   @param Dev            Dev NO of PCI space.
   @param Func           Func NO of PCI space.
-  @param RomAddress     Base address of OptionRom.
-  @param RomLength      Length of rom image.
+  @param RomImage       Option ROM buffer.
+  @param RomSize        Size of Option ROM buffer.
 
 **/
 VOID
@@ -34,8 +34,8 @@ PciRomAddImageMapping (
   IN  UINT8       Bus,
   IN  UINT8       Dev,
   IN  UINT8       Func,
-  IN  UINT64      RomAddress,
-  IN  UINT64      RomLength
+  IN  VOID        *RomImage,
+  IN  UINT64      RomSize
   );
 
 /**
-- 
2.12.2.windows.2



  reply	other threads:[~2017-10-27  6:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-27  6:54 [PATCH 0/3] MdeModulePkg/PciBus: Fix bug that doesn't produce BusOverride Ruiyu Ni
2017-10-27  6:54 ` Ruiyu Ni [this message]
2017-10-27  6:54 ` [PATCH 2/3] MdeModulePkg/PciBus: Don't create entry when recording ImageHandle Ruiyu Ni
2017-10-27  6:54 ` [PATCH 3/3] MdeModulePkg/PciBus: Fix bug that doesn't produce BusOverride Ruiyu Ni
2017-10-30  8:42 ` [PATCH 0/3] " Zeng, Star

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171027065438.284440-2-ruiyu.ni@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox