2 Set up ROM Table for PCI Bus module.
4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 // PCI ROM image information
21 EFI_HANDLE ImageHandle
;
28 } EFI_PCI_ROM_IMAGE_MAPPING
;
30 UINTN mNumberOfPciRomImages
= 0;
31 UINTN mMaxNumberOfPciRomImages
= 0;
32 EFI_PCI_ROM_IMAGE_MAPPING
*mRomImageTable
= NULL
;
35 Add the Rom Image to internal database for later PCI light enumeration.
37 @param ImageHandle Option Rom image handle.
38 @param Seg Segment of PCI space.
39 @param Bus Bus NO of PCI space.
40 @param Dev Dev NO of PCI space.
41 @param Func Func NO of PCI space.
42 @param RomAddress Base address of OptionRom.
43 @param RomLength Length of rom image.
47 PciRomAddImageMapping (
48 IN EFI_HANDLE ImageHandle
,
57 EFI_PCI_ROM_IMAGE_MAPPING
*TempMapping
;
59 if (mNumberOfPciRomImages
>= mMaxNumberOfPciRomImages
) {
61 mMaxNumberOfPciRomImages
+= 0x20;
64 TempMapping
= AllocatePool (mMaxNumberOfPciRomImages
* sizeof (EFI_PCI_ROM_IMAGE_MAPPING
));
65 if (TempMapping
== NULL
) {
69 CopyMem (TempMapping
, mRomImageTable
, mNumberOfPciRomImages
* sizeof (EFI_PCI_ROM_IMAGE_MAPPING
));
71 if (mRomImageTable
!= NULL
) {
72 FreePool (mRomImageTable
);
75 mRomImageTable
= TempMapping
;
78 mRomImageTable
[mNumberOfPciRomImages
].ImageHandle
= ImageHandle
;
79 mRomImageTable
[mNumberOfPciRomImages
].Seg
= Seg
;
80 mRomImageTable
[mNumberOfPciRomImages
].Bus
= Bus
;
81 mRomImageTable
[mNumberOfPciRomImages
].Dev
= Dev
;
82 mRomImageTable
[mNumberOfPciRomImages
].Func
= Func
;
83 mRomImageTable
[mNumberOfPciRomImages
].RomAddress
= RomAddress
;
84 mRomImageTable
[mNumberOfPciRomImages
].RomLength
= RomLength
;
85 mNumberOfPciRomImages
++;
89 Get Option rom driver's mapping for PCI device.
91 @param PciIoDevice Device instance.
93 @retval TRUE Found Image mapping.
94 @retval FALSE Cannot found image mapping.
98 PciRomGetImageMapping (
99 IN PCI_IO_DEVICE
*PciIoDevice
102 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
106 PciRootBridgeIo
= PciIoDevice
->PciRootBridgeIo
;
109 for (Index
= 0; Index
< mNumberOfPciRomImages
; Index
++) {
110 if (mRomImageTable
[Index
].Seg
== PciRootBridgeIo
->SegmentNumber
&&
111 mRomImageTable
[Index
].Bus
== PciIoDevice
->BusNumber
&&
112 mRomImageTable
[Index
].Dev
== PciIoDevice
->DeviceNumber
&&
113 mRomImageTable
[Index
].Func
== PciIoDevice
->FunctionNumber
) {
116 if (mRomImageTable
[Index
].ImageHandle
!= NULL
) {
117 AddDriver (PciIoDevice
, mRomImageTable
[Index
].ImageHandle
);
119 PciIoDevice
->PciIo
.RomImage
= (VOID
*) (UINTN
) mRomImageTable
[Index
].RomAddress
;
120 PciIoDevice
->PciIo
.RomSize
= (UINTN
) mRomImageTable
[Index
].RomLength
;