]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Bus/Pci/PciBus/Dxe/PciRomTable.c
Remove some unused internal functions.
[mirror_edk2.git] / EdkModulePkg / Bus / Pci / PciBus / Dxe / PciRomTable.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 PciRomTable.c
15
16 Abstract:
17
18 Option Rom Support for PCI Bus Driver
19
20 Revision History
21
22 --*/
23
24 #include "pcibus.h"
25 #include "PciRomTable.h"
26
27 typedef struct {
28 EFI_HANDLE ImageHandle;
29 UINTN Seg;
30 UINT8 Bus;
31 UINT8 Dev;
32 UINT8 Func;
33 UINT64 RomAddress;
34 UINT64 RomLength;
35 } EFI_PCI_ROM_IMAGE_MAPPING;
36
37 static UINTN mNumberOfPciRomImages = 0;
38 static UINTN mMaxNumberOfPciRomImages = 0;
39 static EFI_PCI_ROM_IMAGE_MAPPING *mRomImageTable = NULL;
40
41 VOID
42 PciRomAddImageMapping (
43 IN EFI_HANDLE ImageHandle,
44 IN UINTN Seg,
45 IN UINT8 Bus,
46 IN UINT8 Dev,
47 IN UINT8 Func,
48 IN UINT64 RomAddress,
49 IN UINT64 RomLength
50 )
51 /*++
52
53 Routine Description:
54
55 TODO: Add function description
56
57 Arguments:
58
59 ImageHandle - TODO: add argument description
60 Seg - TODO: add argument description
61 Bus - TODO: add argument description
62 Dev - TODO: add argument description
63 Func - TODO: add argument description
64 RomAddress - TODO: add argument description
65 RomLength - TODO: add argument description
66
67 Returns:
68
69 TODO: add return values
70
71 --*/
72 {
73 EFI_PCI_ROM_IMAGE_MAPPING *TempMapping;
74
75 if (mNumberOfPciRomImages >= mMaxNumberOfPciRomImages) {
76
77 mMaxNumberOfPciRomImages += 0x20;
78
79 TempMapping = NULL;
80 TempMapping = AllocatePool (mMaxNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING));
81 if (TempMapping == NULL) {
82 return ;
83 }
84
85 CopyMem (TempMapping, mRomImageTable, mNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING));
86
87 if (mRomImageTable != NULL) {
88 gBS->FreePool (mRomImageTable);
89 }
90
91 mRomImageTable = TempMapping;
92 }
93
94 mRomImageTable[mNumberOfPciRomImages].ImageHandle = ImageHandle;
95 mRomImageTable[mNumberOfPciRomImages].Seg = Seg;
96 mRomImageTable[mNumberOfPciRomImages].Bus = Bus;
97 mRomImageTable[mNumberOfPciRomImages].Dev = Dev;
98 mRomImageTable[mNumberOfPciRomImages].Func = Func;
99 mRomImageTable[mNumberOfPciRomImages].RomAddress = RomAddress;
100 mRomImageTable[mNumberOfPciRomImages].RomLength = RomLength;
101 mNumberOfPciRomImages++;
102 }
103
104 EFI_STATUS
105 PciRomGetRomResourceFromPciOptionRomTable (
106 IN EFI_DRIVER_BINDING_PROTOCOL *This,
107 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
108 PCI_IO_DEVICE *PciIoDevice
109 )
110 /*++
111
112 Routine Description:
113
114 Arguments:
115
116 Returns:
117
118 --*/
119 // TODO: This - add argument and description to function comment
120 // TODO: PciRootBridgeIo - add argument and description to function comment
121 // TODO: PciIoDevice - add argument and description to function comment
122 // TODO: EFI_NOT_FOUND - add return value to function comment
123 // TODO: EFI_SUCCESS - add return value to function comment
124 {
125 EFI_STATUS Status;
126 EFI_PCI_OPTION_ROM_TABLE *PciOptionRomTable;
127 EFI_PCI_OPTION_ROM_DESCRIPTOR *PciOptionRomDescriptor;
128 UINTN Index;
129
130 Status = EfiGetSystemConfigurationTable (&gEfiPciOptionRomTableGuid, (VOID **) &PciOptionRomTable);
131 if (EFI_ERROR (Status)) {
132 return EFI_NOT_FOUND;
133 }
134
135 for (Index = 0; Index < PciOptionRomTable->PciOptionRomCount; Index++) {
136 PciOptionRomDescriptor = &PciOptionRomTable->PciOptionRomDescriptors[Index];
137 if (PciOptionRomDescriptor->Seg == PciRootBridgeIo->SegmentNumber &&
138 PciOptionRomDescriptor->Bus == PciIoDevice->BusNumber &&
139 PciOptionRomDescriptor->Dev == PciIoDevice->DeviceNumber &&
140 PciOptionRomDescriptor->Func == PciIoDevice->FunctionNumber ) {
141
142 PciIoDevice->PciIo.RomImage = (VOID *) (UINTN) PciOptionRomDescriptor->RomAddress;
143 PciIoDevice->PciIo.RomSize = (UINTN) PciOptionRomDescriptor->RomLength;
144 }
145 }
146
147 for (Index = 0; Index < mNumberOfPciRomImages; Index++) {
148 if (mRomImageTable[Index].Seg == PciRootBridgeIo->SegmentNumber &&
149 mRomImageTable[Index].Bus == PciIoDevice->BusNumber &&
150 mRomImageTable[Index].Dev == PciIoDevice->DeviceNumber &&
151 mRomImageTable[Index].Func == PciIoDevice->FunctionNumber ) {
152
153 AddDriver (PciIoDevice, mRomImageTable[Index].ImageHandle);
154 }
155 }
156
157 return EFI_SUCCESS;
158 }
159
160 EFI_STATUS
161 PciRomGetImageMapping (
162 PCI_IO_DEVICE *PciIoDevice
163 )
164 /*++
165
166 Routine Description:
167
168 Arguments:
169
170 Returns:
171
172 --*/
173 // TODO: PciIoDevice - add argument and description to function comment
174 // TODO: EFI_SUCCESS - add return value to function comment
175 {
176 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
177 UINTN Index;
178
179 PciRootBridgeIo = PciIoDevice->PciRootBridgeIo;
180
181 for (Index = 0; Index < mNumberOfPciRomImages; Index++) {
182 if (mRomImageTable[Index].Seg == PciRootBridgeIo->SegmentNumber &&
183 mRomImageTable[Index].Bus == PciIoDevice->BusNumber &&
184 mRomImageTable[Index].Dev == PciIoDevice->DeviceNumber &&
185 mRomImageTable[Index].Func == PciIoDevice->FunctionNumber ) {
186
187 if (mRomImageTable[Index].ImageHandle != NULL) {
188 AddDriver (PciIoDevice, mRomImageTable[Index].ImageHandle);
189 } else {
190 PciIoDevice->PciIo.RomImage = (VOID *) (UINTN) mRomImageTable[Index].RomAddress;
191 PciIoDevice->PciIo.RomSize = (UINTN) mRomImageTable[Index].RomLength;
192 }
193 }
194 }
195
196 return EFI_SUCCESS;
197 }