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 - 2008 Intel Corporation. <BR>
18 All rights reserved. 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 FfsHeadher The FFS file header
164 @param PeiServices General purpose services available to every PEIM.
167 @retval EFI_SUCCESS if the interface could be successfully
173 PeimInitializePciCfg (
174 IN EFI_PEI_FILE_HANDLE FfsHeader
,
175 IN CONST EFI_PEI_SERVICES
**PeiServices
179 // Publish the PciCfgToPciCfg2 Thunk capability to other modules
181 return (*PeiServices
)->InstallPpi (PeiServices
, &mPpiListPciCfg
);
185 Reads from a given location in the PCI configuration space.
187 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
189 @param This Pointer to local data for the interface.
191 @param Width The width of the access. Enumerated in bytes.
192 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
194 @param Address The physical address of the access. The format of
195 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
197 @param Buffer A pointer to the buffer of data..
200 @retval EFI_SUCCESS The function completed successfully.
202 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
204 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
211 IN EFI_PEI_SERVICES
**PeiServices
,
212 IN EFI_PEI_PCI_CFG_PPI
*This
,
213 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
218 EFI_PEI_PCI_CFG2_PPI
*PciCfg2
;
220 PciCfg2
= (*PeiServices
)->PciCfg
;
222 return PciCfg2
->Read ((CONST EFI_PEI_SERVICES
**)PeiServices
, PciCfg2
, Width
, Address
, Buffer
);
227 Write to a given location in the PCI configuration space.
229 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
231 @param This Pointer to local data for the interface.
233 @param Width The width of the access. Enumerated in bytes.
234 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
236 @param Address The physical address of the access. The format of
237 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
239 @param Buffer A pointer to the buffer of data..
242 @retval EFI_SUCCESS The function completed successfully.
244 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
246 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
253 IN EFI_PEI_SERVICES
**PeiServices
,
254 IN EFI_PEI_PCI_CFG_PPI
*This
,
255 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
260 EFI_PEI_PCI_CFG2_PPI
*PciCfg2
;
262 PciCfg2
= (*PeiServices
)->PciCfg
;
264 return PciCfg2
->Write ((CONST EFI_PEI_SERVICES
**)PeiServices
, PciCfg2
, Width
, Address
, Buffer
);
268 PCI read-modify-write operation.
270 @param PeiServices An indirect pointer to the PEI Services Table
271 published by the PEI Foundation.
273 @param This Pointer to local data for the interface.
275 @param Width The width of the access. Enumerated in bytes. Type
276 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
278 @param Address The physical address of the access.
280 @param SetBits Points to value to bitwise-OR with the read configuration value.
281 The size of the value is determined by Width.
283 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
284 The size of the value is determined by Width.
287 @retval EFI_SUCCESS The function completed successfully.
289 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
291 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting
292 the operation at this time.
298 IN EFI_PEI_SERVICES
**PeiServices
,
299 IN EFI_PEI_PCI_CFG_PPI
*This
,
300 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
306 EFI_PEI_PCI_CFG2_PPI
*PciCfg2
;
308 PciCfg2
= (*PeiServices
)->PciCfg
;
310 return PciCfg2
->Modify ((CONST EFI_PEI_SERVICES
**)PeiServices
, PciCfg2
, Width
, Address
, &SetBits
, &ClearBits
);