]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaIo.h
Merge 3 PCDs for the ISA Bus Driver to a single PCD that is a bitmask of features.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaBusDxe / InternalIsaIo.h
1 /** @file
2 The header file for EFI_ISA_IO protocol implementation.
3
4 Copyright (c) 2006 - 2009, Intel Corporation.<BR>
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 **/
14
15 #ifndef _INTERNAL_ISA_IO_H_
16 #define _INTERNAL_ISA_IO_H_
17
18 #include "InternalIsaBus.h"
19
20 //
21 // Bits definition of PcdIsaBusSupportedFeatures
22 //
23 #define PCD_ISA_BUS_SUPPORT_DMA BIT0
24 #define PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA BIT1
25 #define PCD_ISA_BUS_SUPPORT_ISA_MEMORY BIT2
26
27 //
28 // ISA I/O Support Function Prototypes
29 //
30
31 /**
32 Verifies access to an ISA device
33
34 @param[in] IsaIoDevice The ISA device to be verified.
35 @param[in] Type The Access type. The input must be either IsaAccessTypeMem or IsaAccessTypeIo.
36 @param[in] Width The width of the memory operation.
37 @param[in] Count The number of memory operations to perform.
38 @param[in] Offset The offset in ISA memory space to start the memory operation.
39
40 @retval EFI_SUCCESS Verify success.
41 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
42 @retval EFI_UNSUPPORTED The device ont support the access type.
43 **/
44 EFI_STATUS
45 IsaIoVerifyAccess (
46 IN ISA_IO_DEVICE *IsaIoDevice,
47 IN ISA_ACCESS_TYPE Type,
48 IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
49 IN UINTN Count,
50 IN UINT32 Offset
51 );
52
53 /**
54 Performs an ISA I/O Read Cycle
55
56 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
57 @param[in] Width Specifies the width of the I/O operation.
58 @param[in] Offset The offset in ISA I/O space to start the I/O operation.
59 @param[in] Count The number of I/O operations to perform.
60 @param[out] Buffer The destination buffer to store the results
61
62 @retval EFI_SUCCESS The data was read from the device sucessfully.
63 @retval EFI_UNSUPPORTED The Offset is not valid for this device.
64 @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
65 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
66 **/
67 EFI_STATUS
68 EFIAPI
69 IsaIoIoRead (
70 IN EFI_ISA_IO_PROTOCOL *This,
71 IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
72 IN UINT32 Offset,
73 IN UINTN Count,
74 OUT VOID *Buffer
75 );
76
77 /**
78 Performs an ISA I/O Write Cycle
79
80 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
81 @param[in] Width Specifies the width of the I/O operation.
82 @param[in] Offset The offset in ISA I/O space to start the I/O operation.
83 @param[in] Count The number of I/O operations to perform.
84 @param[in] Buffer The source buffer to write data from
85
86 @retval EFI_SUCCESS The data was writen to the device sucessfully.
87 @retval EFI_UNSUPPORTED The Offset is not valid for this device.
88 @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
89 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
90 **/
91 EFI_STATUS
92 EFIAPI
93 IsaIoIoWrite (
94 IN EFI_ISA_IO_PROTOCOL *This,
95 IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
96 IN UINT32 Offset,
97 IN UINTN Count,
98 IN VOID *Buffer
99 );
100
101 /**
102 Maps a memory region for DMA
103
104 @param This A pointer to the EFI_ISA_IO_PROTOCOL instance.
105 @param Operation Indicates the type of DMA (slave or bus master), and if
106 the DMA operation is going to read or write to system memory.
107 @param ChannelNumber The slave channel number to use for this DMA operation.
108 If Operation and ChannelAttributes shows that this device
109 performs bus mastering DMA, then this field is ignored.
110 The legal range for this field is 0..7.
111 @param ChannelAttributes The attributes of the DMA channel to use for this DMA operation
112 @param HostAddress The system memory address to map to the device.
113 @param NumberOfBytes On input the number of bytes to map. On output the number
114 of bytes that were mapped.
115 @param DeviceAddress The resulting map address for the bus master device to use
116 to access the hosts HostAddress.
117 @param Mapping A resulting value to pass to EFI_ISA_IO.Unmap().
118
119 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
120 @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.
121 @retval EFI_UNSUPPORTED The HostAddress can not be mapped as a common buffer.
122 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
123 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
124 **/
125 EFI_STATUS
126 EFIAPI
127 IsaIoMap (
128 IN EFI_ISA_IO_PROTOCOL *This,
129 IN EFI_ISA_IO_PROTOCOL_OPERATION Operation,
130 IN UINT8 ChannelNumber OPTIONAL,
131 IN UINT32 ChannelAttributes,
132 IN VOID *HostAddress,
133 IN OUT UINTN *NumberOfBytes,
134 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
135 OUT VOID **Mapping
136 );
137
138 /**
139 Unmaps a memory region for DMA
140
141 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
142 @param[in] Mapping The mapping value returned from EFI_ISA_IO.Map().
143
144 @retval EFI_SUCCESS The range was unmapped.
145 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
146 **/
147 EFI_STATUS
148 EFIAPI
149 IsaIoUnmap (
150 IN EFI_ISA_IO_PROTOCOL *This,
151 IN VOID *Mapping
152 );
153
154 /**
155 Flushes any posted write data to the system memory.
156
157 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
158
159 @retval EFI_SUCCESS The buffers were flushed.
160 @retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error.
161 **/
162 EFI_STATUS
163 EFIAPI
164 IsaIoFlush (
165 IN EFI_ISA_IO_PROTOCOL *This
166 );
167
168 /**
169 report a error Status code
170
171 @param Code The error status code.
172
173 @return EFI_SUCCESS Success to report status code.
174 **/
175 EFI_STATUS
176 ReportErrorStatusCode (
177 EFI_STATUS_CODE_VALUE Code
178 );
179
180 /**
181 Writes I/O operation base address and count number to a 8 bit I/O Port.
182
183 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
184 @param[in] AddrOffset The address' offset.
185 @param[in] PageOffset The page's offest.
186 @param[in] CountOffset The count's offset.
187 @param[in] BaseAddress The base address.
188 @param[in] Count The number of I/O operations to perform.
189
190 @retval EFI_SUCCESS Success.
191 @retval EFI_INVALID_PARAMETER Parameter is invalid.
192 @retval EFI_UNSUPPORTED The address range specified by these Offsets and Count is not valid.
193 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
194 **/
195 EFI_STATUS
196 WriteDmaPort (
197 IN EFI_ISA_IO_PROTOCOL *This,
198 IN UINT32 AddrOffset,
199 IN UINT32 PageOffset,
200 IN UINT32 CountOffset,
201 IN UINT32 BaseAddress,
202 IN UINT16 Count
203 );
204
205 /**
206 Writes an 8-bit I/O Port
207
208 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
209 @param[in] Offset The offset in ISA IO space to start the IO operation.
210 @param[in] Value The data to write port.
211
212 @retval EFI_SUCCESS Success.
213 @retval EFI_INVALID_PARAMETER Parameter is invalid.
214 @retval EFI_UNSUPPORTED The address range specified by Offset is not valid.
215 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
216 **/
217 EFI_STATUS
218 WritePort (
219 IN EFI_ISA_IO_PROTOCOL *This,
220 IN UINT32 Offset,
221 IN UINT8 Value
222 );
223
224 /**
225 Performs an ISA Memory Read Cycle
226
227 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
228 @param[in] Width Specifies the width of the memory operation.
229 @param[in] Offset The offset in ISA memory space to start the memory operation.
230 @param[in] Count The number of memory operations to perform.
231 @param[out] Buffer The destination buffer to store the results
232
233 @retval EFI_SUCCESS The data was read from the device successfully.
234 @retval EFI_UNSUPPORTED The Offset is not valid for this device.
235 @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
236 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
237 **/
238 EFI_STATUS
239 EFIAPI
240 IsaIoMemRead (
241 IN EFI_ISA_IO_PROTOCOL *This,
242 IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
243 IN UINT32 Offset,
244 IN UINTN Count,
245 OUT VOID *Buffer
246 );
247
248
249 /**
250 Performs an ISA Memory Write Cycle
251
252 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
253 @param[in] Width Specifies the width of the memory operation.
254 @param[in] Offset The offset in ISA memory space to start the memory operation.
255 @param[in] Count The number of memory operations to perform.
256 @param[in] Buffer The source buffer to write data from
257
258 @retval EFI_SUCCESS The data was written to the device sucessfully.
259 @retval EFI_UNSUPPORTED The Offset is not valid for this device.
260 @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
261 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
262 **/
263 EFI_STATUS
264 EFIAPI
265 IsaIoMemWrite (
266 IN EFI_ISA_IO_PROTOCOL *This,
267 IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
268 IN UINT32 Offset,
269 IN UINTN Count,
270 IN VOID *Buffer
271 );
272
273 /**
274 Copy one region of ISA memory space to another region of ISA memory space on the ISA controller.
275
276 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
277 @param[in] Width Specifies the width of the memory copy operation.
278 @param[in] DestOffset The offset of the destination
279 @param[in] SrcOffset The offset of the source
280 @param[in] Count The number of memory copy operations to perform
281
282 @retval EFI_SUCCESS The data was copied sucessfully.
283 @retval EFI_UNSUPPORTED The DestOffset or SrcOffset is not valid for this device.
284 @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
285 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
286 **/
287 EFI_STATUS
288 EFIAPI
289 IsaIoCopyMem (
290 IN EFI_ISA_IO_PROTOCOL *This,
291 IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
292 IN UINT32 DestOffset,
293 IN UINT32 SrcOffset,
294 IN UINTN Count
295 );
296
297 /**
298 Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer mapping.
299
300 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
301 @param[in] Type The type allocation to perform.
302 @param[in] MemoryType The type of memory to allocate.
303 @param[in] Pages The number of pages to allocate.
304 @param[out] HostAddress A pointer to store the base address of the allocated range.
305 @param[in] Attributes The requested bit mask of attributes for the allocated range.
306
307 @retval EFI_SUCCESS The requested memory pages were allocated.
308 @retval EFI_INVALID_PARAMETER Type is invalid or MemoryType is invalid or HostAddress is NULL
309 @retval EFI_UNSUPPORTED Attributes is unsupported or the memory range specified
310 by HostAddress, Pages, and Type is not available for common buffer use.
311 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
312 **/
313 EFI_STATUS
314 EFIAPI
315 IsaIoAllocateBuffer (
316 IN EFI_ISA_IO_PROTOCOL *This,
317 IN EFI_ALLOCATE_TYPE Type,
318 IN EFI_MEMORY_TYPE MemoryType,
319 IN UINTN Pages,
320 OUT VOID **HostAddress,
321 IN UINT64 Attributes
322 );
323
324 /**
325 Frees memory that was allocated with EFI_ISA_IO.AllocateBuffer().
326
327 @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
328 @param[in] Pages The number of pages to free.
329 @param[in] HostAddress The base address of the allocated range.
330
331 @retval EFI_SUCCESS The requested memory pages were freed.
332 @retval EFI_INVALID_PARAMETER The memory was not allocated with EFI_ISA_IO.AllocateBufer().
333 **/
334 EFI_STATUS
335 EFIAPI
336 IsaIoFreeBuffer (
337 IN EFI_ISA_IO_PROTOCOL *This,
338 IN UINTN Pages,
339 IN VOID *HostAddress
340 );
341
342 #endif
343