]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Ppi/PciCfg2.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Ppi / PciCfg2.h
CommitLineData
5879b875 1/** @file\r
d7132512 2 This file declares PciCfg2 PPI.\r
5879b875 3\r
9095d37b 4 This ppi Provides platform or chipset-specific access to\r
d7132512
LG
5 the PCI configuration space for a specific PCI segment.\r
6\r
9095d37b 7 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
5879b875 9\r
5879b875 10 @par Revision Reference:\r
0047820e 11 This PPI is introduced in PI Version 1.0.\r
5879b875 12\r
13**/\r
14\r
15#ifndef __PEI_PCI_CFG2_H__\r
16#define __PEI_PCI_CFG2_H__\r
17\r
de1fad68
LG
18#include <Library/BaseLib.h>\r
19\r
5879b875 20#define EFI_PEI_PCI_CFG2_PPI_GUID \\r
21 { 0x57a449a, 0x1fdc, 0x4c06, { 0xbf, 0xc9, 0xf5, 0x3f, 0x6a, 0x99, 0xbb, 0x92 } }\r
22\r
5879b875 23typedef struct _EFI_PEI_PCI_CFG2_PPI EFI_PEI_PCI_CFG2_PPI;\r
24\r
25#define EFI_PEI_PCI_CFG_ADDRESS(bus,dev,func,reg) \\r
de1fad68
LG
26 (UINT64) ( \\r
27 (((UINTN) bus) << 24) | \\r
28 (((UINTN) dev) << 16) | \\r
29 (((UINTN) func) << 8) | \\r
fbd26c4b 30 (((UINTN) (reg)) < 256 ? ((UINTN) (reg)) : (UINT64) (LShiftU64 ((UINT64) (reg), 32))))\r
5879b875 31\r
06889842 32///\r
33/// EFI_PEI_PCI_CFG_PPI_WIDTH\r
34///\r
5879b875 35typedef enum {\r
97c4afff 36 ///\r
37 /// 8-bit access\r
38 ///\r
5879b875 39 EfiPeiPciCfgWidthUint8 = 0,\r
97c4afff 40 ///\r
41 /// 16-bit access\r
42 ///\r
5879b875 43 EfiPeiPciCfgWidthUint16 = 1,\r
97c4afff 44 ///\r
45 /// 32-bit access\r
46 ///\r
5879b875 47 EfiPeiPciCfgWidthUint32 = 2,\r
97c4afff 48 ///\r
49 /// 64-bit access\r
50 ///\r
5879b875 51 EfiPeiPciCfgWidthUint64 = 3,\r
52 EfiPeiPciCfgWidthMaximum\r
53} EFI_PEI_PCI_CFG_PPI_WIDTH;\r
54\r
06889842 55///\r
56/// EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS\r
57///\r
5879b875 58typedef struct {\r
11227adb 59 ///\r
60 /// 8-bit register offset within the PCI configuration space for a given device's function\r
61 /// space.\r
62 ///\r
5879b875 63 UINT8 Register;\r
11227adb 64 ///\r
65 /// Only the 3 least-significant bits are used to encode one of 8 possible functions within a\r
66 /// given device.\r
67 ///\r
5879b875 68 UINT8 Function;\r
11227adb 69 ///\r
70 /// Only the 5 least-significant bits are used to encode one of 32 possible devices.\r
71 ///\r
5879b875 72 UINT8 Device;\r
11227adb 73 ///\r
74 /// 8-bit value to encode between 0 and 255 buses.\r
75 ///\r
5879b875 76 UINT8 Bus;\r
11227adb 77 ///\r
78 /// Register number in PCI configuration space. If this field is zero, then Register is used\r
79 /// for the register number. If this field is non-zero, then Register is ignored and this field\r
80 /// is used for the register number.\r
81 ///\r
5879b875 82 UINT32 ExtendedRegister;\r
83} EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS;\r
84\r
85/**\r
86 Reads from or write to a given location in the PCI configuration space.\r
87\r
88 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
89\r
90 @param This Pointer to local data for the interface.\r
91\r
845effb3 92 @param Width The width of the access. Enumerated in bytes.\r
5879b875 93 See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
94\r
845effb3 95 @param Address The physical address of the access. The format of\r
5879b875 96 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
97\r
98 @param Buffer A pointer to the buffer of data..\r
99\r
100\r
101 @retval EFI_SUCCESS The function completed successfully.\r
102\r
103 @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
104\r
105 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this\r
106 time.\r
107\r
108**/\r
109typedef\r
110EFI_STATUS\r
8b13229b 111(EFIAPI *EFI_PEI_PCI_CFG2_PPI_IO)(\r
00edb218
A
112 IN CONST EFI_PEI_SERVICES **PeiServices,\r
113 IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
ef4fa1a4 114 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
115 IN UINT64 Address,\r
5879b875 116 IN OUT VOID *Buffer\r
117);\r
118\r
119\r
120/**\r
9095d37b 121 Performs a read-modify-write operation on the contents\r
d7132512 122 from a given location in the PCI configuration space.\r
5879b875 123\r
845effb3 124 @param PeiServices An indirect pointer to the PEI Services Table\r
5879b875 125 published by the PEI Foundation.\r
126\r
127 @param This Pointer to local data for the interface.\r
128\r
129 @param Width The width of the access. Enumerated in bytes. Type\r
130 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().\r
131\r
132 @param Address The physical address of the access.\r
133\r
845effb3 134 @param SetBits Points to value to bitwise-OR with the read configuration value.\r
5879b875 135\r
136 The size of the value is determined by Width.\r
137\r
845effb3 138 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.\r
5879b875 139 The size of the value is determined by Width.\r
140\r
141\r
142 @retval EFI_SUCCESS The function completed successfully.\r
143\r
144 @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
145\r
845effb3 146 @retval EFI_DEVICE_NOT_READY The device is not capable of supporting\r
5879b875 147 the operation at this time.\r
148\r
149**/\r
150typedef\r
151EFI_STATUS\r
8b13229b 152(EFIAPI *EFI_PEI_PCI_CFG2_PPI_RW)(\r
5879b875 153 IN CONST EFI_PEI_SERVICES **PeiServices,\r
154 IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
ef4fa1a4 155 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
156 IN UINT64 Address,\r
11227adb 157 IN VOID *SetBits,\r
158 IN VOID *ClearBits\r
5879b875 159);\r
160\r
44717a39 161///\r
162/// The EFI_PEI_PCI_CFG_PPI interfaces are used to abstract accesses to PCI\r
163/// controllers behind a PCI root bridge controller.\r
164///\r
5879b875 165struct _EFI_PEI_PCI_CFG2_PPI {\r
845effb3 166 EFI_PEI_PCI_CFG2_PPI_IO Read;\r
167 EFI_PEI_PCI_CFG2_PPI_IO Write;\r
168 EFI_PEI_PCI_CFG2_PPI_RW Modify;\r
44717a39 169 ///\r
170 /// The PCI bus segment which the specified functions will access.\r
171 ///\r
5879b875 172 UINT16 Segment;\r
173};\r
174\r
175\r
176extern EFI_GUID gEfiPciCfg2PpiGuid;\r
177\r
178#endif\r