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 - 2010, Intel Corporation. All rights reserved.<BR>
62 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 time.
165 IN CONST EFI_PEI_SERVICES
**PeiServices
,
166 IN CONST EFI_PEI_PCI_CFG2_PPI
*This
,
167 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
173 PCI read-modify-write operation.
175 @param PeiServices An indirect pointer to the PEI Services Table
176 published by the PEI Foundation.
178 @param This Pointer to local data for the interface.
180 @param Width The width of the access. Enumerated in bytes. Type
181 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
183 @param Address The physical address of the access.
185 @param SetBits Points to value to bitwise-OR with the read configuration value.
186 The size of the value is determined by Width.
188 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
189 The size of the value is determined by Width.
192 @retval EFI_SUCCESS The function completed successfully.
194 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
196 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting
197 the operation at this time.
203 IN CONST EFI_PEI_SERVICES
**PeiServices
,
204 IN CONST EFI_PEI_PCI_CFG2_PPI
*This
,
205 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
214 EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnEcpPciCfgList
= {
215 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
216 &gEcpPeiPciCfgPpiGuid
,
217 EcpPciCfgPpiNotifyCallback
220 EFI_PEI_PCI_CFG2_PPI mPciCfg2Ppi
= {
227 EFI_PEI_PPI_DESCRIPTOR mPpiListPciCfg2
= {
228 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
236 Standard PEIM entry point.
238 @param FileHandle Handle of the file being invoked.
239 @param PeiServices General purpose services available to every PEIM.
241 @retval EFI_SUCCESS The interface could be successfully installed.
246 PeimInitializePciCfg2 (
247 IN EFI_PEI_FILE_HANDLE FileHandle
,
248 IN CONST EFI_PEI_SERVICES
**PeiServices
255 // Make sure no other module has install the first instance of gEfiPciCfg2PpiGuid.
257 Status
= (*PeiServices
)->LocatePpi (PeiServices
, &gEfiPciCfg2PpiGuid
, 0, NULL
, &Ppi
);
258 ASSERT (Status
== EFI_NOT_FOUND
);
261 // Register a notification for ECP PCI CFG PPI
263 Status
= (*PeiServices
)->NotifyPpi (PeiServices
, &mNotifyOnEcpPciCfgList
);
264 ASSERT_EFI_ERROR (Status
);
270 Notification service to be called when gEcpPeiPciCfgPpiGuid is installed.
272 @param PeiServices Indirect reference to the PEI Services Table.
273 @param NotifyDescriptor Address of the notification descriptor data structure. Type
274 EFI_PEI_NOTIFY_DESCRIPTOR is defined above.
275 @param Ppi Address of the PPI that was installed.
277 @retval EFI_STATUS This function will install a PPI to PPI database. The status
278 code will be the code for (*PeiServices)->InstallPpi.
283 EcpPciCfgPpiNotifyCallback (
284 IN EFI_PEI_SERVICES
**PeiServices
,
285 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
290 // When ECP PCI CFG PPI is installed, publish the PCI CFG2 PPI in the
291 // PEI Services Table and the PPI database
293 (*PeiServices
)->PciCfg
= &mPciCfg2Ppi
;
294 return (*PeiServices
)->InstallPpi ((CONST EFI_PEI_SERVICES
**)PeiServices
, &mPpiListPciCfg2
);
298 Reads from a given location in the PCI configuration space.
300 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
302 @param This Pointer to local data for the interface.
304 @param Width The width of the access. Enumerated in bytes.
305 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
307 @param Address The physical address of the access. The format of
308 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
310 @param Buffer A pointer to the buffer of data..
313 @retval EFI_SUCCESS The function completed successfully.
315 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
317 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
324 IN CONST EFI_PEI_SERVICES
**PeiServices
,
325 IN CONST EFI_PEI_PCI_CFG2_PPI
*This
,
326 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
332 EFI_PEI_PCI_CFG_PPI
*PciCfg
;
334 Status
= (*PeiServices
)->LocatePpi (
336 &gEcpPeiPciCfgPpiGuid
,
341 ASSERT_EFI_ERROR (Status
);
343 return PciCfg
->Read ((EFI_PEI_SERVICES
**)PeiServices
, PciCfg
, Width
, Address
, Buffer
);
347 Write to a given location in the PCI configuration space.
349 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
351 @param This Pointer to local data for the interface.
353 @param Width The width of the access. Enumerated in bytes.
354 See EFI_PEI_PCI_CFG_PPI_WIDTH above.
356 @param Address The physical address of the access. The format of
357 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.
359 @param Buffer A pointer to the buffer of data..
362 @retval EFI_SUCCESS The function completed successfully.
364 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
366 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this
373 IN CONST EFI_PEI_SERVICES
**PeiServices
,
374 IN CONST EFI_PEI_PCI_CFG2_PPI
*This
,
375 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
381 EFI_PEI_PCI_CFG_PPI
*PciCfg
;
383 Status
= (*PeiServices
)->LocatePpi (
385 &gEcpPeiPciCfgPpiGuid
,
390 ASSERT_EFI_ERROR (Status
);
392 return PciCfg
->Write ((EFI_PEI_SERVICES
**)PeiServices
, PciCfg
, Width
, Address
, Buffer
);
396 PCI read-modify-write operation.
398 @param PeiServices An indirect pointer to the PEI Services Table
399 published by the PEI Foundation.
401 @param This Pointer to local data for the interface.
403 @param Width The width of the access. Enumerated in bytes. Type
404 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
406 @param Address The physical address of the access.
408 @param SetBits Points to value to bitwise-OR with the read configuration value.
409 The size of the value is determined by Width.
411 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
412 The size of the value is determined by Width.
415 @retval EFI_SUCCESS The function completed successfully.
417 @retval EFI_DEVICE_ERROR There was a problem with the transaction.
419 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting
420 the operation at this time.
426 IN CONST EFI_PEI_SERVICES
**PeiServices
,
427 IN CONST EFI_PEI_PCI_CFG2_PPI
*This
,
428 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width
,
435 EFI_PEI_PCI_CFG_PPI
*PciCfg
;
437 Status
= (*PeiServices
)->LocatePpi (
439 &gEfiPciCfgPpiInServiceTableGuid
,
444 ASSERT_EFI_ERROR (Status
);
446 return PciCfg
->Modify ((EFI_PEI_SERVICES
**)PeiServices
, PciCfg
, Width
, Address
, *(UINTN
*)SetBits
, *(UINTN
*)ClearBits
);