2 Module produces PciCfgPpi2 on top of PciCfgPpi. It also updates the
3 PciCfg2Ppi pointer in the EFI_PEI_SERVICES upon a installation of
6 EcpPeiPciCfgPpi is installed by a framework module which
7 produce PciCfgPpi originally. Such framework module is updated based on the
8 following rule to install EcpPeiPciCfgPpi instead of updating the PciCfg pointer
9 in the Framework PeiServicesTable:
12 PeiServices->PciCfg = <*>;
15 static EFI_PEI_PPI_DESCRIPTOR gEcpPeiPciCfgPpiList = {
16 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
17 &gEcpPeiPciCfgPpiGuid,
20 (**PeiServices).InstallPpi (PeiServices, gEcpPeiPciCfgPpiList);
23 In addition, the PeiServicesTable definition in PeiApi.h is updated to
25 struct _EFI_PEI_SERVICES {
30 // Pointer to PPI interface
32 if (PI_SPECIFICATION_VERSION < 0x00010000)
34 PEI_CPU_IO_PPI *CpuIo;
35 ECP_PEI_PCI_CFG_PPI *PciCfg; //Changed.
42 This change enable the detection of code segment which invokes PeiServices->PciCfg->Modify.
43 Such code causes a build break as ECP_PEI_PCI_CFG_PPI does not has "Modify" field.
44 This should be updated to a call to PeiLibPciCfgModify as shown below:
49 PeiLibPciCfgModify(<*>);
53 PIWG's PI specification replaces Inte's EFI Specification 1.10.
54 EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by
55 EFI_PEI_PCI_CFG2_PPI in PI 1.0.
56 This module produces PciCfgPpi on top of PciCfgPpi2. This module is used on platform when both of
57 these two conditions are true:
58 1) Framework module present that produces PCI CFG PPI AND
59 2) PI module that produces PCI CFG2 is not present
61 Copyright (c) 2006 - 2008 Intel Corporation. <BR>
62 All rights reserved. This program and the accompanying materials
63 are licensed and made available under the terms and conditions of the BSD License
64 which accompanies this distribution. The full text of the license may be found at
65 http://opensource.org/licenses/bsd-license.php
67 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
68 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
73 #include <Ppi/PciCfg.h>
74 #include <Ppi/PciCfg2.h>
75 #include <Ppi/EcpPciCfg.h>
76 #include <Library/DebugLib.h>
79 // Function Prototypes
83 Notification service to be called when gEcpPeiPciCfgPpiGuid is installed.
85 @param PeiServices Indirect reference to the PEI Services Table.
86 @param NotifyDescriptor Address of the notification descriptor data structure. Type
87 EFI_PEI_NOTIFY_DESCRIPTOR is defined above.
88 @param Ppi Address of the PPI that was installed.
90 @retval EFI_STATUS This function will install a PPI to PPI database. The status
91 code will be the code for (*PeiServices)->InstallPpi.
96 EcpPciCfgPpiNotifyCallback (
97 IN EFI_PEI_SERVICES
**PeiServices
,
98 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
103 // Function Prototypes
106 Reads from a given location in the PCI configuration space.
108 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
110 @param This Pointer to local data for the interface.
112 @param Width The width of the access. Enumerated in bytes.
113 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
115 @param Address The physical address of the access. The format of
116 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
118 @param Buffer A pointer to the buffer of data..
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 the operation at this
132 IN CONST EFI_PEI_SERVICES
**PeiServices
,
133 IN CONST EFI_PEI_PCI_CFG2_PPI
*This
,
134 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
140 Write to a given location in the PCI configuration space.
142 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
144 @param This Pointer to local data for the interface.
146 @param Width The width of the access. Enumerated in bytes.
147 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
149 @param Address The physical address of the access. The format of
150 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
152 @param Buffer A pointer to the buffer of data..
155 @retval EFI_SUCCESS The function completed successfully.
157 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
159 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
166 IN CONST EFI_PEI_SERVICES
**PeiServices
,
167 IN CONST EFI_PEI_PCI_CFG2_PPI
*This
,
168 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
174 PCI read-modify-write operation.
176 @param PeiServices An indirect pointer to the PEI Services Table
177 published by the PEI Foundation.
179 @param This Pointer to local data for the interface.
181 @param Width The width of the access. Enumerated in bytes. Type
182 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
184 @param Address The physical address of the access.
186 @param SetBits Points to value to bitwise-OR with the read configuration value.
187 The size of the value is determined by Width.
189 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
190 The size of the value is determined by Width.
193 @retval EFI_SUCCESS The function completed successfully.
195 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
197 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting
198 the operation at this time.
204 IN CONST EFI_PEI_SERVICES
**PeiServices
,
205 IN CONST EFI_PEI_PCI_CFG2_PPI
*This
,
206 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
215 EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnEcpPciCfgList
= {
216 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
217 &gEcpPeiPciCfgPpiGuid
,
218 EcpPciCfgPpiNotifyCallback
221 EFI_PEI_PCI_CFG2_PPI mPciCfg2Ppi
= {
228 EFI_PEI_PPI_DESCRIPTOR mPpiListPciCfg2
= {
229 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
237 Standard PEIM entry point.
239 @param FfsHeadher The FFS file header
240 @param PeiServices General purpose services available to every PEIM.
243 @retval EFI_SUCCESS if the interface could be successfully
249 PeimInitializePciCfg2 (
250 IN EFI_PEI_FILE_HANDLE FfsHeader
,
251 IN CONST EFI_PEI_SERVICES
**PeiServices
258 // Make sure no other module has install the first instance of gEfiPciCfg2PpiGuid.
260 Status
= (*PeiServices
)->LocatePpi (PeiServices
, &gEfiPciCfg2PpiGuid
, 0, NULL
, &Ppi
);
261 ASSERT (Status
== EFI_NOT_FOUND
);
264 // Register a notification for ECP PCI CFG PPI
266 Status
= (*PeiServices
)->NotifyPpi (PeiServices
, &mNotifyOnEcpPciCfgList
);
267 ASSERT_EFI_ERROR (Status
);
273 Notification service to be called when gEcpPeiPciCfgPpiGuid is installed.
275 @param PeiServices Indirect reference to the PEI Services Table.
276 @param NotifyDescriptor Address of the notification descriptor data structure. Type
277 EFI_PEI_NOTIFY_DESCRIPTOR is defined above.
278 @param Ppi Address of the PPI that was installed.
280 @retval EFI_STATUS This function will install a PPI to PPI database. The status
281 code will be the code for (*PeiServices)->InstallPpi.
286 EcpPciCfgPpiNotifyCallback (
287 IN EFI_PEI_SERVICES
**PeiServices
,
288 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
293 // When ECP PCI CFG PPI is installed, publish the PCI CFG2 PPI in the
294 // PEI Services Table and the PPI database
296 (*PeiServices
)->PciCfg
= &mPciCfg2Ppi
;
297 return (*PeiServices
)->InstallPpi ((CONST EFI_PEI_SERVICES
**)PeiServices
, &mPpiListPciCfg2
);
301 Reads from a given location in the PCI configuration space.
303 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
305 @param This Pointer to local data for the interface.
307 @param Width The width of the access. Enumerated in bytes.
308 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
310 @param Address The physical address of the access. The format of
311 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
313 @param Buffer A pointer to the buffer of data..
316 @retval EFI_SUCCESS The function completed successfully.
318 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
320 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
327 IN CONST EFI_PEI_SERVICES
**PeiServices
,
328 IN CONST EFI_PEI_PCI_CFG2_PPI
*This
,
329 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
335 EFI_PEI_PCI_CFG_PPI
*PciCfg
;
337 Status
= (*PeiServices
)->LocatePpi (
339 &gEcpPeiPciCfgPpiGuid
,
344 ASSERT_EFI_ERROR (Status
);
346 return PciCfg
->Read ((EFI_PEI_SERVICES
**)PeiServices
, PciCfg
, Width
, Address
, Buffer
);
350 Write to a given location in the PCI configuration space.
352 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
354 @param This Pointer to local data for the interface.
356 @param Width The width of the access. Enumerated in bytes.
357 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
359 @param Address The physical address of the access. The format of
360 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
362 @param Buffer A pointer to the buffer of data..
365 @retval EFI_SUCCESS The function completed successfully.
367 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
369 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
376 IN CONST EFI_PEI_SERVICES
**PeiServices
,
377 IN CONST EFI_PEI_PCI_CFG2_PPI
*This
,
378 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
384 EFI_PEI_PCI_CFG_PPI
*PciCfg
;
386 Status
= (*PeiServices
)->LocatePpi (
388 &gEcpPeiPciCfgPpiGuid
,
393 ASSERT_EFI_ERROR (Status
);
395 return PciCfg
->Write ((EFI_PEI_SERVICES
**)PeiServices
, PciCfg
, Width
, Address
, Buffer
);
399 PCI read-modify-write operation.
401 @param PeiServices An indirect pointer to the PEI Services Table
402 published by the PEI Foundation.
404 @param This Pointer to local data for the interface.
406 @param Width The width of the access. Enumerated in bytes. Type
407 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
409 @param Address The physical address of the access.
411 @param SetBits Points to value to bitwise-OR with the read configuration value.
412 The size of the value is determined by Width.
414 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
415 The size of the value is determined by Width.
418 @retval EFI_SUCCESS The function completed successfully.
420 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
422 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting
423 the operation at this time.
429 IN CONST EFI_PEI_SERVICES
**PeiServices
,
430 IN CONST EFI_PEI_PCI_CFG2_PPI
*This
,
431 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
438 EFI_PEI_PCI_CFG_PPI
*PciCfg
;
440 Status
= (*PeiServices
)->LocatePpi (
442 &gEfiPciCfgPpiInServiceTableGuid
,
447 ASSERT_EFI_ERROR (Status
);
449 return PciCfg
->Modify ((EFI_PEI_SERVICES
**)PeiServices
, PciCfg
, Width
, Address
, *(UINTN
*)SetBits
, *(UINTN
*)ClearBits
);