]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/PciCfgToPciCfg2Thunk/PciCfgToPciCfg2Thunk.c
Update doxygen comments.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / PciCfgToPciCfg2Thunk / PciCfgToPciCfg2Thunk.c
1 /**
2 Module produce PciCfgPpi on top of PciCfgPpi2.
3
4 PIWG's PI specification replaces Inte's EFI Specification 1.10.
5 EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by
6 EFI_PEI_PCI_CFG2_PPI in PI 1.0.
7 This module produces PciCfgPpi on top of PciCfgPpi2. This module is used on platform when both of
8 these two conditions are true:
9 1) Framework module is present that consumes PCI CFG AND
10 2) R9 module is present that produces PCI CFG2 but not PCI CFG
11
12
13 Copyright (c) 2006 - 2008 Intel Corporation. <BR>
14 All rights reserved. This program and the accompanying materials
15 are licensed and made available under the terms and conditions of the BSD License
16 which accompanies this distribution. The full text of the license may be found at
17 http://opensource.org/licenses/bsd-license.php
18
19 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
20 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 Module Name:
22 **/
23
24 #include <PiPei.h>
25 #include <Ppi/PciCfg.h>
26 #include <Ppi/PciCfg2.h>
27 #include <Library/DebugLib.h>
28
29 //
30 // Function Prototypes
31 //
32
33 /**
34 Reads from a given location in the PCI configuration space.
35
36 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
37
38 @param This Pointer to local data for the interface.
39
40 @param Width The width of the access. Enumerated in bytes.
41 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
42
43 @param Address The physical address of the access. The format of
44 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
45
46 @param Buffer A pointer to the buffer of data..
47
48
49 @retval EFI_SUCCESS The function completed successfully.
50
51 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
52
53 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
54 time.
55
56 **/
57 EFI_STATUS
58 EFIAPI
59 PciCfgRead (
60 IN EFI_PEI_SERVICES **PeiServices,
61 IN EFI_PEI_PCI_CFG_PPI *This,
62 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
63 IN UINT64 Address,
64 IN OUT VOID *Buffer
65 );
66
67 /**
68 Write to a given location in the PCI configuration space.
69
70 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
71
72 @param This Pointer to local data for the interface.
73
74 @param Width The width of the access. Enumerated in bytes.
75 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
76
77 @param Address The physical address of the access. The format of
78 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
79
80 @param Buffer A pointer to the buffer of data..
81
82
83 @retval EFI_SUCCESS The function completed successfully.
84
85 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
86
87 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
88 time.
89
90 **/
91 EFI_STATUS
92 EFIAPI
93 PciCfgWrite (
94 IN EFI_PEI_SERVICES **PeiServices,
95 IN EFI_PEI_PCI_CFG_PPI *This,
96 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
97 IN UINT64 Address,
98 IN OUT VOID *Buffer
99 );
100
101 /**
102 PCI read-modify-write operation.
103
104 @param PeiServices An indirect pointer to the PEI Services Table
105 published by the PEI Foundation.
106
107 @param This Pointer to local data for the interface.
108
109 @param Width The width of the access. Enumerated in bytes. Type
110 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
111
112 @param Address The physical address of the access.
113
114 @param SetBits Points to value to bitwise-OR with the read configuration value.
115 The size of the value is determined by Width.
116
117 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
118 The size of the value is determined by Width.
119
120
121 @retval EFI_SUCCESS The function completed successfully.
122
123 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
124
125 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting
126 the operation at this time.
127
128 **/
129 EFI_STATUS
130 EFIAPI
131 PciCfgModify (
132 IN EFI_PEI_SERVICES **PeiServices,
133 IN EFI_PEI_PCI_CFG_PPI *This,
134 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
135 IN UINT64 Address,
136 IN UINTN SetBits,
137 IN UINTN ClearBits
138 );
139
140 //
141 // Module globals
142 //
143 EFI_PEI_PCI_CFG_PPI mPciCfgPpi = {
144 PciCfgRead,
145 PciCfgWrite,
146 PciCfgModify,
147 };
148
149 EFI_PEI_PPI_DESCRIPTOR mPpiListPciCfg = {
150 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
151 &gEfiPciCfgPpiInServiceTableGuid,
152 &mPciCfgPpi
153 };
154
155 /**
156
157 Standard PEIM entry point.
158
159 @param FfsHeadher The FFS file header
160 @param PeiServices General purpose services available to every PEIM.
161
162
163 @retval EFI_SUCCESS if the interface could be successfully
164 installed
165
166 --*/
167 EFI_STATUS
168 EFIAPI
169 PeimInitializePciCfg (
170 IN EFI_PEI_FILE_HANDLE FfsHeader,
171 IN CONST EFI_PEI_SERVICES **PeiServices
172 )
173 {
174 //
175 // Publish the PciCfgToPciCfg2 Thunk capability to other modules
176 //
177 return (*PeiServices)->InstallPpi (PeiServices, &mPpiListPciCfg);
178 }
179
180 /**
181 Reads from a given location in the PCI configuration space.
182
183 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
184
185 @param This Pointer to local data for the interface.
186
187 @param Width The width of the access. Enumerated in bytes.
188 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
189
190 @param Address The physical address of the access. The format of
191 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
192
193 @param Buffer A pointer to the buffer of data..
194
195
196 @retval EFI_SUCCESS The function completed successfully.
197
198 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
199
200 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
201 time.
202
203 **/
204 EFI_STATUS
205 EFIAPI
206 PciCfgRead (
207 IN EFI_PEI_SERVICES **PeiServices,
208 IN EFI_PEI_PCI_CFG_PPI *This,
209 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
210 IN UINT64 Address,
211 IN OUT VOID *Buffer
212 )
213 {
214 EFI_PEI_PCI_CFG2_PPI *PciCfg2;
215
216 PciCfg2 = (*PeiServices)->PciCfg;
217
218 return PciCfg2->Read ((CONST EFI_PEI_SERVICES **)PeiServices, PciCfg2, Width, Address, Buffer);
219 }
220
221
222 /**
223 Write to a given location in the PCI configuration space.
224
225 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
226
227 @param This Pointer to local data for the interface.
228
229 @param Width The width of the access. Enumerated in bytes.
230 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
231
232 @param Address The physical address of the access. The format of
233 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
234
235 @param Buffer A pointer to the buffer of data..
236
237
238 @retval EFI_SUCCESS The function completed successfully.
239
240 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
241
242 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
243 time.
244
245 **/
246 EFI_STATUS
247 EFIAPI
248 PciCfgWrite (
249 IN EFI_PEI_SERVICES **PeiServices,
250 IN EFI_PEI_PCI_CFG_PPI *This,
251 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
252 IN UINT64 Address,
253 IN OUT VOID *Buffer
254 )
255 {
256 EFI_PEI_PCI_CFG2_PPI *PciCfg2;
257
258 PciCfg2 = (*PeiServices)->PciCfg;
259
260 return PciCfg2->Write ((CONST EFI_PEI_SERVICES **)PeiServices, PciCfg2, Width, Address, Buffer);
261 }
262
263 /**
264 PCI read-modify-write operation.
265
266 @param PeiServices An indirect pointer to the PEI Services Table
267 published by the PEI Foundation.
268
269 @param This Pointer to local data for the interface.
270
271 @param Width The width of the access. Enumerated in bytes. Type
272 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
273
274 @param Address The physical address of the access.
275
276 @param SetBits Points to value to bitwise-OR with the read configuration value.
277 The size of the value is determined by Width.
278
279 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
280 The size of the value is determined by Width.
281
282
283 @retval EFI_SUCCESS The function completed successfully.
284
285 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
286
287 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting
288 the operation at this time.
289
290 **/
291 EFI_STATUS
292 EFIAPI
293 PciCfgModify (
294 IN EFI_PEI_SERVICES **PeiServices,
295 IN EFI_PEI_PCI_CFG_PPI *This,
296 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
297 IN UINT64 Address,
298 IN UINTN SetBits,
299 IN UINTN ClearBits
300 )
301 {
302 EFI_PEI_PCI_CFG2_PPI *PciCfg2;
303
304 PciCfg2 = (*PeiServices)->PciCfg;
305
306 return PciCfg2->Modify ((CONST EFI_PEI_SERVICES **)PeiServices, PciCfg2, Width, Address, &SetBits, &ClearBits);
307 }