Minor code enhancement.
[mirror_edk2.git] / IntelFrameworkPkg / Include / Ppi / PciCfg.h
1 /** @file
2 This file declares the PciCfg PPI used to access the PCI configuration space in PEI
3
4 Copyright (c) 2006 - 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 @par Revision Reference:
14 This PPI is defined in PEI CIS
15 Version 0.91.
16
17 **/
18
19 #ifndef __PEI_PCI_CFG_H__
20 #define __PEI_PCI_CFG_H__
21
22 #include <Ppi/PciCfg2.h>
23 //
24 // Get the common definitions for EFI_PEI_PCI_CFG_PPI_WIDTH.
25 //
26
27 #define EFI_PEI_PCI_CFG_PPI_INSTALLED_GUID \
28 { \
29 0xe1f2eba0, 0xf7b9, 0x4a26, {0x86, 0x20, 0x13, 0x12, 0x21, 0x64, 0x2a, 0x90 } \
30 }
31
32 typedef struct _EFI_PEI_PCI_CFG_PPI EFI_PEI_PCI_CFG_PPI;
33
34 #define PEI_PCI_CFG_ADDRESS(bus, dev, func, reg) ( \
35 (UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg)) \
36 ) & 0x00000000ffffffff
37
38 /**
39 PCI read and write operation.
40
41 @param PeiServices An indirect pointer to the PEI Services Table
42 published by the PEI Foundation.
43 @param This Pointer to local data for the interface.
44 @param Width The width of the access. Enumerated in bytes.
45 @param Address The physical address of the access.
46 @param Buffer A pointer to the buffer of data.
47
48 @retval EFI_SUCCESS The function completed successfully.
49 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
50
51 **/
52 typedef
53 EFI_STATUS
54 (EFIAPI *EFI_PEI_PCI_CFG_PPI_IO)(
55 IN EFI_PEI_SERVICES **PeiServices,
56 IN EFI_PEI_PCI_CFG_PPI *This,
57 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
58 IN UINT64 Address,
59 IN OUT VOID *Buffer
60 );
61
62 /**
63 PCI read-modify-write operation.
64
65 @param PeiServices An indirect pointer to the PEI Services Table
66 published by the PEI Foundation.
67 @param This Pointer to local data for the interface.
68 @param Width The width of the access. Enumerated in bytes.
69 @param Address The physical address of the access.
70 @param SetBits Value of the bits to set.
71 @param ClearBits Value of the bits to clear.
72
73 @retval EFI_SUCCESS The function completed successfully.
74
75 **/
76 typedef
77 EFI_STATUS
78 (EFIAPI *EFI_PEI_PCI_CFG_PPI_RW)(
79 IN EFI_PEI_SERVICES **PeiServices,
80 IN EFI_PEI_PCI_CFG_PPI *This,
81 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
82 IN UINT64 Address,
83 IN UINTN SetBits,
84 IN UINTN ClearBits
85 );
86
87 /**
88 The EFI_PEI_PCI_CFG_PPI interfaces are used to abstract accesses to PCI
89 controllers behind a PCI root bridge controller.
90 **/
91 struct _EFI_PEI_PCI_CFG_PPI {
92 ///
93 /// PCI read services. See the Read() function description.
94 ///
95 EFI_PEI_PCI_CFG_PPI_IO Read;
96
97 ///
98 /// PCI write services. See the Write() function description.
99 ///
100 EFI_PEI_PCI_CFG_PPI_IO Write;
101
102 ///
103 /// PCI read-modify-write services. See the Modify() function description.
104 ///
105 EFI_PEI_PCI_CFG_PPI_RW Modify;
106 };
107
108 extern EFI_GUID gEfiPciCfgPpiInServiceTableGuid;
109
110 #endif