]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Csm/Include/Protocol/IsaIo.h
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Csm / Include / Protocol / IsaIo.h
CommitLineData
b522c77b
HW
1/** @file\r
2 ISA I/O Protocol is used by ISA device drivers to perform I/O, MMIO and DMA\r
3 operations on the ISA controllers they manage.\r
4\r
5Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
6SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
9\r
10#ifndef _EFI_ISA_IO_H_\r
11#define _EFI_ISA_IO_H_\r
12\r
13#include <Protocol/IsaAcpi.h>\r
14\r
15///\r
16/// Global ID for the EFI_ISA_IO_PROTOCOL\r
17///\r
18#define EFI_ISA_IO_PROTOCOL_GUID \\r
19 { \\r
20 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \\r
21 }\r
22\r
23///\r
24/// Forward declaration for the EFI_ISA_IO_PROTOCOL.\r
25///\r
26typedef struct _EFI_ISA_IO_PROTOCOL EFI_ISA_IO_PROTOCOL;\r
27\r
28///\r
29/// Width of EFI_ISA_IO_PROTOCOL I/O Port and MMIO operations.\r
30///\r
31typedef enum {\r
32 EfiIsaIoWidthUint8 = 0, ///< 8-bit operation.\r
33 EfiIsaIoWidthUint16, ///< 16-bit operation.\r
34 EfiIsaIoWidthUint32, ///< 32-bit operation\r
35 EfiIsaIoWidthReserved,\r
36 EfiIsaIoWidthFifoUint8, ///< 8-bit FIFO operation.\r
37 EfiIsaIoWidthFifoUint16, ///< 16-bit FIFO operation.\r
38 EfiIsaIoWidthFifoUint32, ///< 32-bit FIFO operation.\r
39 EfiIsaIoWidthFifoReserved,\r
40 EfiIsaIoWidthFillUint8, ///< 8-bit Fill operation.\r
41 EfiIsaIoWidthFillUint16, ///< 16-bit Fill operation.\r
42 EfiIsaIoWidthFillUint32, ///< 32-bit Fill operation.\r
43 EfiIsaIoWidthFillReserved,\r
44 EfiIsaIoWidthMaximum\r
45} EFI_ISA_IO_PROTOCOL_WIDTH;\r
46\r
47///\r
48/// Attributes for the EFI_ISA_IO_PROTOCOL common DMA buffer allocations.\r
49///\r
50#define EFI_ISA_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x080 ///< Map a memory range so write are combined.\r
51#define EFI_ISA_IO_ATTRIBUTE_MEMORY_CACHED 0x800 ///< Map a memory range so all read and write accesses are cached.\r
52#define EFI_ISA_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 ///< Disable a memory range.\r
53\r
54///\r
55/// Channel attribute for EFI_ISA_IO_PROTOCOL slave DMA requests\r
56///\r
57#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE 0x001 ///< Set the speed of the DMA transfer in compatible mode.\r
58#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A 0x002 ///< Not supported.\r
59#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B 0x004 ///< Not supported.\r
60#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C 0x008 ///< Not supported.\r
61#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8 0x010 ///< Request 8-bit DMA transfers. Only available on channels 0..3.\r
62#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16 0x020 ///< Request 16-bit DMA transfers. Only available on channels 4..7.\r
63#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE 0x040 ///< Request a single DMA transfer.\r
64#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE 0x080 ///< Request multiple DMA transfers until TC (Terminal Count) or EOP (End of Process).\r
65#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_AUTO_INITIALIZE 0x100 ///< Automatically reload base and count at the end of the DMA transfer.\r
66\r
67///\r
68/// The DMA opreration type for EFI_ISA_IO_PROTOCOL DMA requests.\r
69///\r
70typedef enum {\r
71 ///\r
72 /// A read operation from system memory by a bus master.\r
73 ///\r
74 EfiIsaIoOperationBusMasterRead,\r
75 ///\r
76 /// A write operation to system memory by a bus master.\r
77 ///\r
78 EfiIsaIoOperationBusMasterWrite,\r
79 ///\r
80 /// Provides both read and write access to system memory by both the processor\r
81 /// and a bus master. The buffer is coherent from both the processor's and the\r
82 /// bus master's point of view.\r
83 ///\r
84 EfiIsaIoOperationBusMasterCommonBuffer,\r
85 ///\r
86 /// A read operation from system memory by a slave device.\r
87 ///\r
88 EfiIsaIoOperationSlaveRead,\r
89 ///\r
90 /// A write operation to system memory by a slave master.\r
91 ///\r
92 EfiIsaIoOperationSlaveWrite,\r
93 EfiIsaIoOperationMaximum\r
94} EFI_ISA_IO_PROTOCOL_OPERATION;\r
95\r
96/**\r
97 Performs ISA I/O and MMIO Read/Write Cycles\r
98\r
99 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
100 @param[in] Width Specifies the width of the I/O or MMIO operation.\r
101 @param[in] Offset The offset into the ISA I/O or MMIO space to start the\r
102 operation.\r
103 @param[in] Count The number of I/O or MMIO operations to perform.\r
104 @param[in, out] Buffer For read operations, the destination buffer to store\r
105 the results. For write operations, the source buffer to\r
106 write data from.\r
107\r
108 @retval EFI_SUCCESS The data was successfully read from or written to the device.\r
109 @retval EFI_UNSUPPORTED The Offset is not valid for this device.\r
110 @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.\r
111 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
112\r
113**/\r
114typedef\r
115EFI_STATUS\r
116(EFIAPI *EFI_ISA_IO_PROTOCOL_IO_MEM)(\r
117 IN EFI_ISA_IO_PROTOCOL *This,\r
118 IN EFI_ISA_IO_PROTOCOL_WIDTH Width,\r
119 IN UINT32 Offset,\r
120 IN UINTN Count,\r
121 IN OUT VOID *Buffer\r
122 );\r
123\r
124///\r
125/// Structure of functions for accessing ISA I/O and MMIO space.\r
126///\r
127typedef struct {\r
128 ///\r
129 /// Read from ISA I/O or MMIO space.\r
130 ///\r
ac0a286f 131 EFI_ISA_IO_PROTOCOL_IO_MEM Read;\r
b522c77b
HW
132 ///\r
133 /// Write to ISA I/O or MMIO space.\r
134 ///\r
ac0a286f 135 EFI_ISA_IO_PROTOCOL_IO_MEM Write;\r
b522c77b
HW
136} EFI_ISA_IO_PROTOCOL_ACCESS;\r
137\r
138/**\r
139 Copies data from one region of ISA MMIO space to another region of ISA\r
140 MMIO space.\r
141\r
142 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
143 @param[in] Width Specifies the width of the MMIO copy operation.\r
144 @param[in] DestOffset The offset of the destination in ISA MMIO space.\r
145 @param[in] SrcOffset The offset of the source in ISA MMIO space.\r
146 @param[in] Count The number tranfers to perform for this copy operation.\r
147\r
48cf40b8 148 @retval EFI_SUCCESS The data was copied successfully.\r
b522c77b
HW
149 @retval EFI_UNSUPPORTED The DestOffset or SrcOffset is not valid for this device.\r
150 @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.\r
151 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
152\r
153**/\r
154typedef\r
155EFI_STATUS\r
156(EFIAPI *EFI_ISA_IO_PROTOCOL_COPY_MEM)(\r
157 IN EFI_ISA_IO_PROTOCOL *This,\r
158 IN EFI_ISA_IO_PROTOCOL_WIDTH Width,\r
159 IN UINT32 DestOffset,\r
160 IN UINT32 SrcOffset,\r
161 IN UINTN Count\r
162 );\r
163\r
164/**\r
165 Maps a memory region for DMA.\r
166\r
167 This function returns the device-specific addresses required to access system memory.\r
168 This function is used to map system memory for ISA DMA operations. All ISA DMA\r
169 operations must be performed through their mapped addresses, and such mappings must\r
170 be freed with EFI_ISA_IO_PROTOCOL.Unmap() after the DMA operation is completed.\r
171\r
172 If the DMA operation is a single read or write data transfer through an ISA bus\r
173 master, then EfiIsaIoOperationBusMasterRead or EfiIsaIoOperationBusMasterWrite\r
174 is used and the range is unmapped to complete the operation. If the DMA operation\r
175 is a single read or write data transfer through an ISA slave controller, then\r
176 EfiIsaIoOperationSlaveRead or EfiIsaIoOperationSlaveWrite is used and the range\r
177 is unmapped to complete the operation.\r
178\r
179 If performing a DMA read operation, all the data must be present in system memory before the Map() is performed. Similarly,\r
180 if performing a DMA write operation, the data must not be accessed in system\r
181 memory until EFI_ISA_IO_PROTOCOL.Unmap() is performed. Bus master operations that\r
182 require both read and write access or require multiple host device interactions\r
183 within the same mapped region must use EfiIsaIoOperationBusMasterCommonBuffer.\r
184 However, only memory allocated via the EFI_ISA_IO_PROTOCOL.AllocateBuffer() interface\r
185 is guaranteed to be able to be mapped for this operation type. In all mapping\r
186 requests the NumberOfBytes returned may be less than originally requested. It is\r
187 the caller's responsibility to make additional requests to complete the entire\r
188 transfer.\r
189\r
190 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
191 @param[in] Operation Indicates the type of DMA (slave or bus master),\r
192 and if the DMA operation is going to read or\r
193 write to system memory.\r
194 @param[in] ChannelNumber The slave channel number to use for this DMA\r
195 operation. If Operation and ChannelAttributes\r
196 shows that this device performs bus mastering\r
197 DMA, then this field is ignored. The legal\r
198 range for this field is 0..7.\r
199 @param[in] ChannelAttributes A bitmask of the attributes used to configure\r
200 the slave DMA channel for this DMA operation.\r
201 See EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_* for the\r
202 legal bit combinations.\r
203 @param[in] HostAddress The system memory address to map to the device.\r
204 @param[in, out] NumberOfBytes On input the number of bytes to map. On\r
205 output the number of bytes that were mapped.\r
206 @param[out] DeviceAddress The resulting map address for the bus master\r
207 device to use to access the hosts HostAddress.\r
208 @param[out] Mapping A returned value that must be passed to into\r
209 EFI_ISA_IO_PROTOCOL.Unmap() to free all the the\r
210 resources associated with this map request.\r
211\r
212 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.\r
213 @retval EFI_INVALID_PARAMETER The Operation is undefined.\r
214 @retval EFI_INVALID_PARAMETER The HostAddress is undefined.\r
215 @retval EFI_UNSUPPORTED The HostAddress can not be mapped as a common buffer.\r
216 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.\r
217 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.\r
218\r
219**/\r
220typedef\r
221EFI_STATUS\r
222(EFIAPI *EFI_ISA_IO_PROTOCOL_MAP)(\r
223 IN EFI_ISA_IO_PROTOCOL *This,\r
224 IN EFI_ISA_IO_PROTOCOL_OPERATION Operation,\r
225 IN UINT8 ChannelNumber OPTIONAL,\r
226 IN UINT32 ChannelAttributes,\r
227 IN VOID *HostAddress,\r
228 IN OUT UINTN *NumberOfBytes,\r
229 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r
230 OUT VOID **Mapping\r
231 );\r
232\r
233/**\r
234 Unmaps a memory region that was previously mapped with EFI_ISA_IO_PROTOCOL.Map().\r
235\r
236 The EFI_ISA_IO_PROTOCOL.Map() operation is completed and any corresponding\r
237 resources are released. If the operation was EfiIsaIoOperationSlaveWrite\r
238 or EfiIsaIoOperationBusMasterWrite, the data is committed to system memory.\r
239 Any resources used for the mapping are freed.\r
240\r
241 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
242 @param[in] Mapping The mapping value returned from EFI_ISA_IO_PROTOCOL.Map().\r
243\r
244 @retval EFI_SUCCESS The memory region was unmapped.\r
245 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.\r
246**/\r
247typedef\r
248EFI_STATUS\r
249(EFIAPI *EFI_ISA_IO_PROTOCOL_UNMAP)(\r
250 IN EFI_ISA_IO_PROTOCOL *This,\r
251 IN VOID *Mapping\r
252 );\r
253\r
254/**\r
255 Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer\r
256 mapping.\r
257\r
258 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
259 @param[in] Type The type allocation to perform.\r
260 @param[in] MemoryType The type of memory to allocate.\r
261 @param[in] Pages The number of pages to allocate.\r
262 @param[out] HostAddress A pointer to store the base address of the allocated range.\r
263 @param[in] Attributes The requested bit mask of attributes for the allocated range.\r
264\r
265 @retval EFI_SUCCESS The requested memory pages were allocated.\r
266 @retval EFI_INVALID_PARAMETER Type is invalid.\r
267 @retval EFI_INVALID_PARAMETER MemoryType is invalid.\r
268 @retval EFI_INVALID_PARAMETER HostAddress is NULL.\r
269 @retval EFI_UNSUPPORTED Attributes is unsupported.\r
270 @retval EFI_UNSUPPORTED The memory range specified by HostAddress, Pages,\r
271 and Type is not available for common buffer use.\r
272 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.\r
273\r
274**/\r
275typedef\r
276EFI_STATUS\r
277(EFIAPI *EFI_ISA_IO_PROTOCOL_ALLOCATE_BUFFER)(\r
278 IN EFI_ISA_IO_PROTOCOL *This,\r
279 IN EFI_ALLOCATE_TYPE Type,\r
280 IN EFI_MEMORY_TYPE MemoryType,\r
281 IN UINTN Pages,\r
282 OUT VOID **HostAddress,\r
283 IN UINT64 Attributes\r
284 );\r
285\r
286/**\r
287 Frees a common buffer that was allocated with EFI_ISA_IO_PROTOCOL.AllocateBuffer().\r
288\r
289 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
290 @param[in] Pages The number of pages to free from the previously allocated common buffer.\r
291 @param[in] HostAddress The base address of the previously allocated common buffer.\r
292\r
293\r
294 @retval EFI_SUCCESS The requested memory pages were freed.\r
295 @retval EFI_INVALID_PARAMETER The memory was not allocated with EFI_ISA_IO.AllocateBufer().\r
296\r
297**/\r
298typedef\r
299EFI_STATUS\r
300(EFIAPI *EFI_ISA_IO_PROTOCOL_FREE_BUFFER)(\r
301 IN EFI_ISA_IO_PROTOCOL *This,\r
302 IN UINTN Pages,\r
303 IN VOID *HostAddress\r
304 );\r
305\r
306/**\r
307 Flushes a DMA buffer, which forces all DMA posted write transactions to complete.\r
308\r
309 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
310\r
311 @retval EFI_SUCCESS The DMA buffers were flushed.\r
312 @retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error.\r
313\r
314**/\r
315typedef\r
316EFI_STATUS\r
317(EFIAPI *EFI_ISA_IO_PROTOCOL_FLUSH)(\r
318 IN EFI_ISA_IO_PROTOCOL *This\r
319 );\r
320\r
321///\r
322/// The EFI_ISA_IO_PROTOCOL provides the basic Memory, I/O, and DMA interfaces\r
323/// used to abstract accesses to ISA controllers. There is one EFI_ISA_IO_PROTOCOL\r
324/// instance for each ISA controller on a ISA bus. A device driver that wishes\r
325/// to manage an ISA controller in a system will have to retrieve the\r
326/// ISA_PCI_IO_PROTOCOL instance associated with the ISA controller.\r
327///\r
328struct _EFI_ISA_IO_PROTOCOL {\r
ac0a286f
MK
329 EFI_ISA_IO_PROTOCOL_ACCESS Mem;\r
330 EFI_ISA_IO_PROTOCOL_ACCESS Io;\r
331 EFI_ISA_IO_PROTOCOL_COPY_MEM CopyMem;\r
332 EFI_ISA_IO_PROTOCOL_MAP Map;\r
333 EFI_ISA_IO_PROTOCOL_UNMAP Unmap;\r
334 EFI_ISA_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;\r
335 EFI_ISA_IO_PROTOCOL_FREE_BUFFER FreeBuffer;\r
336 EFI_ISA_IO_PROTOCOL_FLUSH Flush;\r
b522c77b
HW
337 ///\r
338 /// The list of I/O , MMIO, DMA, and Interrupt resources associated with the\r
339 /// ISA controller abstracted by this instance of the EFI_ISA_IO_PROTOCOL.\r
340 ///\r
ac0a286f 341 EFI_ISA_ACPI_RESOURCE_LIST *ResourceList;\r
b522c77b
HW
342 ///\r
343 /// The size, in bytes, of the ROM image.\r
344 ///\r
ac0a286f 345 UINT32 RomSize;\r
b522c77b
HW
346 ///\r
347 /// A pointer to the in memory copy of the ROM image. The ISA Bus Driver is responsible\r
348 /// for allocating memory for the ROM image, and copying the contents of the ROM to memory\r
349 /// during ISA Bus initialization.\r
350 ///\r
ac0a286f 351 VOID *RomImage;\r
b522c77b
HW
352};\r
353\r
ac0a286f 354extern EFI_GUID gEfiIsaIoProtocolGuid;\r
b522c77b
HW
355\r
356#endif\r