]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.h
2 PCI command register operations supporting functions declaration for PCI Bus module.
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _EFI_PCI_COMMAND_H_
10 #define _EFI_PCI_COMMAND_H_
13 // The PCI Command register bits owned by PCI Bus driver.
15 // They should be cleared at the beginning. The other registers
16 // are owned by chipset, we should not touch them.
18 #define EFI_PCI_COMMAND_BITS_OWNED ( \
19 EFI_PCI_COMMAND_IO_SPACE | \
20 EFI_PCI_COMMAND_MEMORY_SPACE | \
21 EFI_PCI_COMMAND_BUS_MASTER | \
22 EFI_PCI_COMMAND_MEMORY_WRITE_AND_INVALIDATE | \
23 EFI_PCI_COMMAND_VGA_PALETTE_SNOOP | \
24 EFI_PCI_COMMAND_FAST_BACK_TO_BACK \
28 // The PCI Bridge Control register bits owned by PCI Bus driver.
30 // They should be cleared at the beginning. The other registers
31 // are owned by chipset, we should not touch them.
33 #define EFI_PCI_BRIDGE_CONTROL_BITS_OWNED ( \
34 EFI_PCI_BRIDGE_CONTROL_ISA | \
35 EFI_PCI_BRIDGE_CONTROL_VGA | \
36 EFI_PCI_BRIDGE_CONTROL_VGA_16 | \
37 EFI_PCI_BRIDGE_CONTROL_FAST_BACK_TO_BACK \
41 // The PCCard Bridge Control register bits owned by PCI Bus driver.
43 // They should be cleared at the beginning. The other registers
44 // are owned by chipset, we should not touch them.
46 #define EFI_PCCARD_BRIDGE_CONTROL_BITS_OWNED ( \
47 EFI_PCI_BRIDGE_CONTROL_ISA | \
48 EFI_PCI_BRIDGE_CONTROL_VGA | \
49 EFI_PCI_BRIDGE_CONTROL_FAST_BACK_TO_BACK \
52 #define EFI_GET_REGISTER 1
53 #define EFI_SET_REGISTER 2
54 #define EFI_ENABLE_REGISTER 3
55 #define EFI_DISABLE_REGISTER 4
58 Operate the PCI register via PciIo function interface.
60 @param PciIoDevice Pointer to instance of PCI_IO_DEVICE.
61 @param Command Operator command.
62 @param Offset The address within the PCI configuration space for the PCI controller.
63 @param Operation Type of Operation.
64 @param PtrCommand Return buffer holding old PCI command, if operation is not EFI_SET_REGISTER.
66 @return Status of PciIo operation.
71 IN PCI_IO_DEVICE
*PciIoDevice
,
75 OUT UINT16
*PtrCommand
79 Check the capability supporting by given device.
81 @param PciIoDevice Pointer to instance of PCI_IO_DEVICE.
83 @retval TRUE Capability supported.
84 @retval FALSE Capability not supported.
88 PciCapabilitySupport (
89 IN PCI_IO_DEVICE
*PciIoDevice
93 Locate capability register block per capability ID.
95 @param PciIoDevice A pointer to the PCI_IO_DEVICE.
96 @param CapId The capability ID.
97 @param Offset A pointer to the offset returned.
98 @param NextRegBlock A pointer to the next block returned.
100 @retval EFI_SUCCESS Successfully located capability register block.
101 @retval EFI_UNSUPPORTED Pci device does not support capability.
102 @retval EFI_NOT_FOUND Pci device support but can not find register block.
106 LocateCapabilityRegBlock (
107 IN PCI_IO_DEVICE
*PciIoDevice
,
109 IN OUT UINT8
*Offset
,
110 OUT UINT8
*NextRegBlock OPTIONAL
114 Locate PciExpress capability register block per capability ID.
116 @param PciIoDevice A pointer to the PCI_IO_DEVICE.
117 @param CapId The capability ID.
118 @param Offset A pointer to the offset returned.
119 @param NextRegBlock A pointer to the next block returned.
121 @retval EFI_SUCCESS Successfully located capability register block.
122 @retval EFI_UNSUPPORTED Pci device does not support capability.
123 @retval EFI_NOT_FOUND Pci device support but can not find register block.
127 LocatePciExpressCapabilityRegBlock (
128 IN PCI_IO_DEVICE
*PciIoDevice
,
130 IN OUT UINT32
*Offset
,
131 OUT UINT32
*NextRegBlock OPTIONAL
135 Macro that reads command register.
137 @param a[in] Pointer to instance of PCI_IO_DEVICE.
138 @param b[out] Pointer to the 16-bit value read from command register.
140 @return status of PciIo operation
143 #define PCI_READ_COMMAND_REGISTER(a, b) \
144 PciOperateRegister (a, 0, PCI_COMMAND_OFFSET, EFI_GET_REGISTER, b)
147 Macro that writes command register.
149 @param a[in] Pointer to instance of PCI_IO_DEVICE.
150 @param b[in] The 16-bit value written into command register.
152 @return status of PciIo operation
155 #define PCI_SET_COMMAND_REGISTER(a, b) \
156 PciOperateRegister (a, b, PCI_COMMAND_OFFSET, EFI_SET_REGISTER, NULL)
159 Macro that enables command register.
161 @param a[in] Pointer to instance of PCI_IO_DEVICE.
162 @param b[in] The enabled value written into command register.
164 @return status of PciIo operation
167 #define PCI_ENABLE_COMMAND_REGISTER(a, b) \
168 PciOperateRegister (a, b, PCI_COMMAND_OFFSET, EFI_ENABLE_REGISTER, NULL)
171 Macro that disables command register.
173 @param a[in] Pointer to instance of PCI_IO_DEVICE.
174 @param b[in] The disabled value written into command register.
176 @return status of PciIo operation
179 #define PCI_DISABLE_COMMAND_REGISTER(a, b) \
180 PciOperateRegister (a, b, PCI_COMMAND_OFFSET, EFI_DISABLE_REGISTER, NULL)
183 Macro that reads PCI bridge control register.
185 @param a[in] Pointer to instance of PCI_IO_DEVICE.
186 @param b[out] The 16-bit value read from control register.
188 @return status of PciIo operation
191 #define PCI_READ_BRIDGE_CONTROL_REGISTER(a, b) \
192 PciOperateRegister (a, 0, PCI_BRIDGE_CONTROL_REGISTER_OFFSET, EFI_GET_REGISTER, b)
195 Macro that writes PCI bridge control register.
197 @param a[in] Pointer to instance of PCI_IO_DEVICE.
198 @param b[in] The 16-bit value written into control register.
200 @return status of PciIo operation
203 #define PCI_SET_BRIDGE_CONTROL_REGISTER(a, b) \
204 PciOperateRegister (a, b, PCI_BRIDGE_CONTROL_REGISTER_OFFSET, EFI_SET_REGISTER, NULL)
207 Macro that enables PCI bridge control register.
209 @param a[in] Pointer to instance of PCI_IO_DEVICE.
210 @param b[in] The enabled value written into command register.
212 @return status of PciIo operation
215 #define PCI_ENABLE_BRIDGE_CONTROL_REGISTER(a, b) \
216 PciOperateRegister (a, b, PCI_BRIDGE_CONTROL_REGISTER_OFFSET, EFI_ENABLE_REGISTER, NULL)
219 Macro that disables PCI bridge control register.
221 @param a[in] Pointer to instance of PCI_IO_DEVICE.
222 @param b[in] The disabled value written into command register.
224 @return status of PciIo operation
227 #define PCI_DISABLE_BRIDGE_CONTROL_REGISTER(a, b) \
228 PciOperateRegister (a, b, PCI_BRIDGE_CONTROL_REGISTER_OFFSET, EFI_DISABLE_REGISTER, NULL)