2 Module produce PciCfgPpi on top of PciCfgPpi2.
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
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
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.
25 #include <Ppi/PciCfg.h>
26 #include <Ppi/PciCfg2.h>
27 #include <Library/DebugLib.h>
30 // Function Prototypes
34 Reads from a given location in the PCI configuration space.
36 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
38 @param This Pointer to local data for the interface.
40 @param Width The width of the access. Enumerated in bytes.
41 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
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.
46 @param Buffer A pointer to the buffer of data..
49 @retval EFI_SUCCESS The function completed successfully.
51 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
53 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
60 IN EFI_PEI_SERVICES
**PeiServices
,
61 IN EFI_PEI_PCI_CFG_PPI
*This
,
62 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
68 Write to a given location in the PCI configuration space.
70 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
72 @param This Pointer to local data for the interface.
74 @param Width The width of the access. Enumerated in bytes.
75 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
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.
80 @param Buffer A pointer to the buffer of data..
83 @retval EFI_SUCCESS The function completed successfully.
85 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
87 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
94 IN EFI_PEI_SERVICES
**PeiServices
,
95 IN EFI_PEI_PCI_CFG_PPI
*This
,
96 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
102 PCI read-modify-write operation.
104 @param PeiServices An indirect pointer to the PEI Services Table
105 published by the PEI Foundation.
107 @param This Pointer to local data for the interface.
109 @param Width The width of the access. Enumerated in bytes. Type
110 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
112 @param Address The physical address of the access.
114 @param SetBits Points to value to bitwise-OR with the read configuration value.
115 The size of the value is determined by Width.
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.
121 @retval EFI_SUCCESS The function completed successfully.
123 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
125 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting
126 the operation at this time.
132 IN EFI_PEI_SERVICES
**PeiServices
,
133 IN EFI_PEI_PCI_CFG_PPI
*This
,
134 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
143 EFI_PEI_PCI_CFG_PPI mPciCfgPpi
= {
149 EFI_PEI_PPI_DESCRIPTOR mPpiListPciCfg
= {
150 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
151 &gEfiPciCfgPpiInServiceTableGuid
,
157 Standard PEIM entry point.
159 @param FfsHeadher The FFS file header
160 @param PeiServices General purpose services available to every PEIM.
163 @retval EFI_SUCCESS if the interface could be successfully
169 PeimInitializePciCfg (
170 IN EFI_PEI_FILE_HANDLE FfsHeader
,
171 IN CONST EFI_PEI_SERVICES
**PeiServices
175 // Publish the PciCfgToPciCfg2 Thunk capability to other modules
177 return (*PeiServices
)->InstallPpi (PeiServices
, &mPpiListPciCfg
);
181 Reads from a given location in the PCI configuration space.
183 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
185 @param This Pointer to local data for the interface.
187 @param Width The width of the access. Enumerated in bytes.
188 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
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.
193 @param Buffer A pointer to the buffer of data..
196 @retval EFI_SUCCESS The function completed successfully.
198 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
200 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
207 IN EFI_PEI_SERVICES
**PeiServices
,
208 IN EFI_PEI_PCI_CFG_PPI
*This
,
209 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
214 EFI_PEI_PCI_CFG2_PPI
*PciCfg2
;
216 PciCfg2
= (*PeiServices
)->PciCfg
;
218 return PciCfg2
->Read ((CONST EFI_PEI_SERVICES
**)PeiServices
, PciCfg2
, Width
, Address
, Buffer
);
223 Write to a given location in the PCI configuration space.
225 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
227 @param This Pointer to local data for the interface.
229 @param Width The width of the access. Enumerated in bytes.
230 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
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.
235 @param Buffer A pointer to the buffer of data..
238 @retval EFI_SUCCESS The function completed successfully.
240 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
242 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
249 IN EFI_PEI_SERVICES
**PeiServices
,
250 IN EFI_PEI_PCI_CFG_PPI
*This
,
251 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
256 EFI_PEI_PCI_CFG2_PPI
*PciCfg2
;
258 PciCfg2
= (*PeiServices
)->PciCfg
;
260 return PciCfg2
->Write ((CONST EFI_PEI_SERVICES
**)PeiServices
, PciCfg2
, Width
, Address
, Buffer
);
264 PCI read-modify-write operation.
266 @param PeiServices An indirect pointer to the PEI Services Table
267 published by the PEI Foundation.
269 @param This Pointer to local data for the interface.
271 @param Width The width of the access. Enumerated in bytes. Type
272 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
274 @param Address The physical address of the access.
276 @param SetBits Points to value to bitwise-OR with the read configuration value.
277 The size of the value is determined by Width.
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.
283 @retval EFI_SUCCESS The function completed successfully.
285 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
287 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting
288 the operation at this time.
294 IN EFI_PEI_SERVICES
**PeiServices
,
295 IN EFI_PEI_PCI_CFG_PPI
*This
,
296 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
302 EFI_PEI_PCI_CFG2_PPI
*PciCfg2
;
304 PciCfg2
= (*PeiServices
)->PciCfg
;
306 return PciCfg2
->Modify ((CONST EFI_PEI_SERVICES
**)PeiServices
, PciCfg2
, Width
, Address
, &SetBits
, &ClearBits
);