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) PI module is present that produces PCI CFG2 but not PCI CFG
12 The Usage of this module is rare since EDK II module IntelFrameworkModulePkg\Universal\PcatSingleSegmentPciCfgPei\PcatSingleSegmentPciCfgPei.inf
13 that produce PCI CFG2 can also produce PCI CFG by setting Pcd Feature Flag gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPciCfgDisable
17 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
18 This program and the accompanying materials
19 are licensed and made available under the terms and conditions of the BSD License
20 which accompanies this distribution. The full text of the license may be found at
21 http://opensource.org/licenses/bsd-license.php
23 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
24 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
29 #include <Ppi/PciCfg.h>
30 #include <Ppi/PciCfg2.h>
31 #include <Library/DebugLib.h>
34 // Function Prototypes
38 Reads from a given location in the PCI configuration space.
40 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
42 @param This Pointer to local data for the interface.
44 @param Width The width of the access. Enumerated in bytes.
45 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
47 @param Address The physical address of the access. The format of
48 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
50 @param Buffer A pointer to the buffer of data..
53 @retval EFI_SUCCESS The function completed successfully.
55 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
57 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
64 IN EFI_PEI_SERVICES
**PeiServices
,
65 IN EFI_PEI_PCI_CFG_PPI
*This
,
66 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
72 Write to a given location in the PCI configuration space.
74 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
76 @param This Pointer to local data for the interface.
78 @param Width The width of the access. Enumerated in bytes.
79 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
81 @param Address The physical address of the access. The format of
82 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
84 @param Buffer A pointer to the buffer of data..
87 @retval EFI_SUCCESS The function completed successfully.
89 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
91 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
98 IN EFI_PEI_SERVICES
**PeiServices
,
99 IN EFI_PEI_PCI_CFG_PPI
*This
,
100 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
106 PCI read-modify-write operation.
108 @param PeiServices An indirect pointer to the PEI Services Table
109 published by the PEI Foundation.
111 @param This Pointer to local data for the interface.
113 @param Width The width of the access. Enumerated in bytes. Type
114 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
116 @param Address The physical address of the access.
118 @param SetBits Points to value to bitwise-OR with the read configuration value.
119 The size of the value is determined by Width.
121 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
122 The size of the value is determined by Width.
125 @retval EFI_SUCCESS The function completed successfully.
127 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
129 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting
130 the operation at this time.
136 IN EFI_PEI_SERVICES
**PeiServices
,
137 IN EFI_PEI_PCI_CFG_PPI
*This
,
138 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
147 EFI_PEI_PCI_CFG_PPI mPciCfgPpi
= {
153 EFI_PEI_PPI_DESCRIPTOR mPpiListPciCfg
= {
154 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
155 &gEfiPciCfgPpiInServiceTableGuid
,
161 Standard PEIM entry point.
163 @param FileHandle Handle of the file being invoked.
164 @param PeiServices General purpose services available to every PEIM.
166 @retval EFI_SUCCESS The interface could be successfully installed.
171 PeimInitializePciCfg (
172 IN EFI_PEI_FILE_HANDLE FileHandle
,
173 IN CONST EFI_PEI_SERVICES
**PeiServices
177 // Publish the PciCfgToPciCfg2 Thunk capability to other modules
179 return (*PeiServices
)->InstallPpi (PeiServices
, &mPpiListPciCfg
);
183 Reads from a given location in the PCI configuration space.
185 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
187 @param This Pointer to local data for the interface.
189 @param Width The width of the access. Enumerated in bytes.
190 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
192 @param Address The physical address of the access. The format of
193 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
195 @param Buffer A pointer to the buffer of data..
198 @retval EFI_SUCCESS The function completed successfully.
200 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
202 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
209 IN EFI_PEI_SERVICES
**PeiServices
,
210 IN EFI_PEI_PCI_CFG_PPI
*This
,
211 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
216 EFI_PEI_PCI_CFG2_PPI
*PciCfg2
;
218 PciCfg2
= (*PeiServices
)->PciCfg
;
220 return PciCfg2
->Read ((CONST EFI_PEI_SERVICES
**)PeiServices
, PciCfg2
, Width
, Address
, Buffer
);
225 Write to a given location in the PCI configuration space.
227 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
229 @param This Pointer to local data for the interface.
231 @param Width The width of the access. Enumerated in bytes.
232 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
234 @param Address The physical address of the access. The format of
235 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
237 @param Buffer A pointer to the buffer of data..
240 @retval EFI_SUCCESS The function completed successfully.
242 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
244 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
251 IN EFI_PEI_SERVICES
**PeiServices
,
252 IN EFI_PEI_PCI_CFG_PPI
*This
,
253 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
258 EFI_PEI_PCI_CFG2_PPI
*PciCfg2
;
260 PciCfg2
= (*PeiServices
)->PciCfg
;
262 return PciCfg2
->Write ((CONST EFI_PEI_SERVICES
**)PeiServices
, PciCfg2
, Width
, Address
, Buffer
);
266 PCI read-modify-write operation.
268 @param PeiServices An indirect pointer to the PEI Services Table
269 published by the PEI Foundation.
271 @param This Pointer to local data for the interface.
273 @param Width The width of the access. Enumerated in bytes. Type
274 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
276 @param Address The physical address of the access.
278 @param SetBits Points to value to bitwise-OR with the read configuration value.
279 The size of the value is determined by Width.
281 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
282 The size of the value is determined by Width.
285 @retval EFI_SUCCESS The function completed successfully.
287 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
289 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting
290 the operation at this time.
296 IN EFI_PEI_SERVICES
**PeiServices
,
297 IN EFI_PEI_PCI_CFG_PPI
*This
,
298 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
304 EFI_PEI_PCI_CFG2_PPI
*PciCfg2
;
306 PciCfg2
= (*PeiServices
)->PciCfg
;
308 return PciCfg2
->Modify ((CONST EFI_PEI_SERVICES
**)PeiServices
, PciCfg2
, Width
, Address
, &SetBits
, &ClearBits
);