]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Include/Protocol/IsaIo.h
IntelFrameworkModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFrameworkModulePkg / Include / Protocol / IsaIo.h
CommitLineData
8ca67c46 1/** @file\r
0a6f4824 2 ISA I/O Protocol is used by ISA device drivers to perform I/O, MMIO and DMA\r
099fae5d 3 operations on the ISA controllers they manage.\r
0a6f4824
LG
4\r
5Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
c0a00b14 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
c3902377 7\r
3db51098 8**/\r
c3902377 9\r
8ca67c46 10#ifndef _EFI_ISA_IO_H_\r
11#define _EFI_ISA_IO_H_\r
c3902377 12\r
c3902377 13#include <Protocol/IsaAcpi.h>\r
14\r
099fae5d 15///\r
16/// Global ID for the EFI_ISA_IO_PROTOCOL\r
17///\r
c3902377 18#define EFI_ISA_IO_PROTOCOL_GUID \\r
099fae5d 19 { \\r
20 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \\r
21 }\r
c3902377 22\r
099fae5d 23///\r
49fd8a35 24/// Forward declaration for the EFI_ISA_IO_PROTOCOL.\r
099fae5d 25///\r
c3902377 26typedef struct _EFI_ISA_IO_PROTOCOL EFI_ISA_IO_PROTOCOL;\r
27\r
099fae5d 28///\r
49fd8a35 29/// Width of EFI_ISA_IO_PROTOCOL I/O Port and MMIO operations.\r
099fae5d 30///\r
c3902377 31typedef enum {\r
49fd8a35 32 EfiIsaIoWidthUint8 = 0, ///< 8-bit operation.\r
33 EfiIsaIoWidthUint16, ///< 16-bit operation.\r
099fae5d 34 EfiIsaIoWidthUint32, ///< 32-bit operation\r
c3902377 35 EfiIsaIoWidthReserved,\r
49fd8a35 36 EfiIsaIoWidthFifoUint8, ///< 8-bit FIFO operation.\r
37 EfiIsaIoWidthFifoUint16, ///< 16-bit FIFO operation.\r
38 EfiIsaIoWidthFifoUint32, ///< 32-bit FIFO operation.\r
c3902377 39 EfiIsaIoWidthFifoReserved,\r
49fd8a35 40 EfiIsaIoWidthFillUint8, ///< 8-bit Fill operation.\r
41 EfiIsaIoWidthFillUint16, ///< 16-bit Fill operation.\r
42 EfiIsaIoWidthFillUint32, ///< 32-bit Fill operation.\r
c3902377 43 EfiIsaIoWidthFillReserved,\r
44 EfiIsaIoWidthMaximum\r
45} EFI_ISA_IO_PROTOCOL_WIDTH;\r
46\r
099fae5d 47///\r
49fd8a35 48/// Attributes for the EFI_ISA_IO_PROTOCOL common DMA buffer allocations.\r
099fae5d 49///\r
49fd8a35 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
c3902377 53\r
099fae5d 54///\r
55/// Channel attribute for EFI_ISA_IO_PROTOCOL slave DMA requests\r
56///\r
49fd8a35 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
099fae5d 66\r
67///\r
49fd8a35 68/// The DMA opreration type for EFI_ISA_IO_PROTOCOL DMA requests.\r
099fae5d 69///\r
c3902377 70typedef enum {\r
099fae5d 71 ///\r
72 /// A read operation from system memory by a bus master.\r
73 ///\r
c3902377 74 EfiIsaIoOperationBusMasterRead,\r
099fae5d 75 ///\r
76 /// A write operation to system memory by a bus master.\r
77 ///\r
c3902377 78 EfiIsaIoOperationBusMasterWrite,\r
099fae5d 79 ///\r
80 /// Provides both read and write access to system memory by both the processor\r
0a6f4824 81 /// and a bus master. The buffer is coherent from both the processor's and the\r
099fae5d 82 /// bus master's point of view.\r
83 ///\r
c3902377 84 EfiIsaIoOperationBusMasterCommonBuffer,\r
099fae5d 85 ///\r
86 /// A read operation from system memory by a slave device.\r
87 ///\r
c3902377 88 EfiIsaIoOperationSlaveRead,\r
099fae5d 89 ///\r
90 /// A write operation to system memory by a slave master.\r
91 ///\r
c3902377 92 EfiIsaIoOperationSlaveWrite,\r
93 EfiIsaIoOperationMaximum\r
94} EFI_ISA_IO_PROTOCOL_OPERATION;\r
95\r
f4671790 96/**\r
099fae5d 97 Performs ISA I/O and MMIO Read/Write Cycles\r
98\r
0a6f4824 99 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
099fae5d 100 @param[in] Width Specifies the width of the I/O or MMIO operation.\r
0a6f4824
LG
101 @param[in] Offset The offset into the ISA I/O or MMIO space to start the\r
102 operation.\r
099fae5d 103 @param[in] Count The number of I/O or MMIO operations to perform.\r
0a6f4824
LG
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
7b6b7746 108 @retval EFI_SUCCESS The data was successfully read from or written to the device.\r
f4671790
LG
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
c3902377 114typedef\r
115EFI_STATUS\r
099fae5d 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
c3902377 122 );\r
123\r
099fae5d 124///\r
49fd8a35 125/// Structure of functions for accessing ISA I/O and MMIO space.\r
099fae5d 126///\r
c3902377 127typedef struct {\r
099fae5d 128 ///\r
129 /// Read from ISA I/O or MMIO space.\r
130 ///\r
c3902377 131 EFI_ISA_IO_PROTOCOL_IO_MEM Read;\r
099fae5d 132 ///\r
133 /// Write to ISA I/O or MMIO space.\r
134 ///\r
c3902377 135 EFI_ISA_IO_PROTOCOL_IO_MEM Write;\r
136} EFI_ISA_IO_PROTOCOL_ACCESS;\r
137\r
f4671790 138/**\r
099fae5d 139 Copies data from one region of ISA MMIO space to another region of ISA\r
140 MMIO space.\r
f4671790 141\r
099fae5d 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
49fd8a35 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
f4671790
LG
147\r
148 @retval EFI_SUCCESS The data was copied sucessfully.\r
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
c3902377 154typedef\r
155EFI_STATUS\r
099fae5d 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
c3902377 162 );\r
163\r
f4671790 164/**\r
099fae5d 165 Maps a memory region for DMA.\r
166\r
7b6b7746 167 This function returns the device-specific addresses required to access system memory.\r
0a6f4824
LG
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
7b6b7746 170 be freed with EFI_ISA_IO_PROTOCOL.Unmap() after the DMA operation is completed.\r
0a6f4824
LG
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
099fae5d 174 is used and the range is unmapped to complete the operation. If the DMA operation\r
0a6f4824
LG
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
099fae5d 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
0a6f4824
LG
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
099fae5d 198 range for this field is 0..7.\r
199 @param[in] ChannelAttributes A bitmask of the attributes used to configure\r
0a6f4824 200 the slave DMA channel for this DMA operation.\r
099fae5d 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
0a6f4824 204 @param[in, out] NumberOfBytes On input the number of bytes to map. On\r
099fae5d 205 output the number of bytes that were mapped.\r
0a6f4824
LG
206 @param[out] DeviceAddress The resulting map address for the bus master\r
207 device to use to access the hosts HostAddress.\r
099fae5d 208 @param[out] Mapping A returned value that must be passed to into\r
0a6f4824 209 EFI_ISA_IO_PROTOCOL.Unmap() to free all the the\r
099fae5d 210 resources associated with this map request.\r
f4671790
LG
211\r
212 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.\r
099fae5d 213 @retval EFI_INVALID_PARAMETER The Operation is undefined.\r
214 @retval EFI_INVALID_PARAMETER The HostAddress is undefined.\r
f4671790
LG
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
c3902377 220typedef\r
221EFI_STATUS\r
099fae5d 222(EFIAPI *EFI_ISA_IO_PROTOCOL_MAP)(\r
c3902377 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
f4671790 233/**\r
49fd8a35 234 Unmaps a memory region that was previously mapped with EFI_ISA_IO_PROTOCOL.Map().\r
f4671790 235\r
0a6f4824
LG
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
099fae5d 239 Any resources used for the mapping are freed.\r
f4671790 240\r
099fae5d 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
f4671790 243\r
099fae5d 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
f4671790 246**/\r
c3902377 247typedef\r
248EFI_STATUS\r
099fae5d 249(EFIAPI *EFI_ISA_IO_PROTOCOL_UNMAP)(\r
250 IN EFI_ISA_IO_PROTOCOL *This,\r
251 IN VOID *Mapping\r
c3902377 252 );\r
253\r
f4671790 254/**\r
099fae5d 255 Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer\r
0a6f4824 256 mapping.\r
f4671790 257\r
099fae5d 258 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
0a6f4824 259 @param[in] Type The type allocation to perform.\r
099fae5d 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
f4671790
LG
264\r
265 @retval EFI_SUCCESS The requested memory pages were allocated.\r
099fae5d 266 @retval EFI_INVALID_PARAMETER Type is invalid.\r
49fd8a35 267 @retval EFI_INVALID_PARAMETER MemoryType is invalid.\r
268 @retval EFI_INVALID_PARAMETER HostAddress is NULL.\r
099fae5d 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
f4671790
LG
272 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.\r
273\r
274**/\r
c3902377 275typedef\r
276EFI_STATUS\r
099fae5d 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
c3902377 284 );\r
285\r
f4671790 286/**\r
49fd8a35 287 Frees a common buffer that was allocated with EFI_ISA_IO_PROTOCOL.AllocateBuffer().\r
f4671790 288\r
099fae5d 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
f4671790
LG
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
c3902377 298typedef\r
299EFI_STATUS\r
099fae5d 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
c3902377 304 );\r
305\r
f4671790 306/**\r
7b6b7746 307 Flushes a DMA buffer, which forces all DMA posted write transactions to complete.\r
f4671790 308\r
099fae5d 309 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
f4671790 310\r
099fae5d 311 @retval EFI_SUCCESS The DMA buffers were flushed.\r
f4671790
LG
312 @retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error.\r
313\r
314**/\r
c3902377 315typedef\r
316EFI_STATUS\r
099fae5d 317(EFIAPI *EFI_ISA_IO_PROTOCOL_FLUSH)(\r
318 IN EFI_ISA_IO_PROTOCOL *This\r
c3902377 319 );\r
320\r
099fae5d 321///\r
0a6f4824
LG
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
7b6b7746 326/// ISA_PCI_IO_PROTOCOL instance associated with the ISA controller.\r
099fae5d 327///\r
c3902377 328struct _EFI_ISA_IO_PROTOCOL {\r
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
099fae5d 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
c3902377 341 EFI_ISA_ACPI_RESOURCE_LIST *ResourceList;\r
099fae5d 342 ///\r
343 /// The size, in bytes, of the ROM image.\r
344 ///\r
c3902377 345 UINT32 RomSize;\r
099fae5d 346 ///\r
0a6f4824 347 /// A pointer to the in memory copy of the ROM image. The ISA Bus Driver is responsible\r
099fae5d 348 /// for allocating memory for the ROM image, and copying the contents of the ROM to memory\r
349 /// during ISA Bus initialization.\r
0a6f4824 350 ///\r
c3902377 351 VOID *RomImage;\r
352};\r
353\r
354extern EFI_GUID gEfiIsaIoProtocolGuid;\r
355\r
356#endif\r