Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | #ifndef __ALT_DMA_H__ #define __ALT_DMA_H__ /****************************************************************************** * * * License Agreement * * * * Copyright (c) 2004-2005 Altera Corporation, San Jose, California, USA. * * All rights reserved. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the "Software"), * * to deal in the Software without restriction, including without limitation * * the rights to use, copy, modify, merge, publish, distribute, sublicense, * * and/or sell copies of the Software, and to permit persons to whom the * * Software is furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included in * * all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * * DEALINGS IN THE SOFTWARE. * * * * * * Altera does not recommend, suggest or require that this reference design * * file be used in conjunction or combination with any other product. * ******************************************************************************/ /****************************************************************************** * * * THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * * * ******************************************************************************/ #include "sys/alt_dma_dev.h" #include "alt_types.h" #include <errno.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* * This header contains the application side interface for accessing DMA * resources. See alt_dma_dev.h for the dma device driver interface. * * The interface model treats a DMA transaction as being composed of two * halves (read and write). * * The application can supply data for transmit using an "alt_dma_txchan" * descriptor. Alternatively an "alt_dma_rxchan" descriptor can be used to * receive data. */ /* * alt_dma_txchan_open() is used to obtain an "alt_dma_txchan" descriptor for * a DMA transmit device. The name is the name of the associated physical * device (e.g. "/dev/dma_0"). * * The return value will be NULL on failure, and non-NULL otherwise. */ extern alt_dma_txchan alt_dma_txchan_open (const char* name); /* * alt_dma_txchan_close() is provided so that an application can notify the * system that it has finished with a given DMA transmit channel. This is only * provided for completness. */ static ALT_INLINE int alt_dma_txchan_close (alt_dma_txchan dma) { return 0; } /* * alt_dma_txchan_send() posts a transmit request to a DMA transmit channel. * The input arguments are: * * dma: the channel to use. * from: a pointer to the start of the data to send. * length: the length of the data to send in bytes. * done: callback function that will be called once the data has been sent. * handle: opaque value passed to "done". * * The return value will be negative if the request cannot be posted, and * zero otherwise. */ static ALT_INLINE int alt_dma_txchan_send (alt_dma_txchan dma, const void* from, alt_u32 length, alt_txchan_done* done, void* handle) { return dma ? dma->dma_send (dma, from, length, done, handle) : -ENODEV; } /* * alt_dma_txchan_space() returns the number of tranmit requests that can be * posted to the specified DMA transmit channel. * * A negative value indicates that the value could not be determined. */ static ALT_INLINE int alt_dma_txchan_space (alt_dma_txchan dma) { return dma ? dma->space (dma) : -ENODEV; } /* * alt_dma_txchan_ioctl() can be used to perform device specific I/O * operations on the indicated DMA transmit channel. For example some drivers * support options to control the width of the transfer operations. See * alt_dma_dev.h for the list of generic requests. * * A negative return value indicates failure, otherwise the interpretation * of the return value is request specific. */ static ALT_INLINE int alt_dma_txchan_ioctl (alt_dma_txchan dma, int req, void* arg) { return dma ? dma->ioctl (dma, req, arg) : -ENODEV; } /* * alt_dma_rxchan_open() is used to obtain an "alt_dma_rxchan" descriptor for * a DMA receive channel. The name is the name of the associated physical * device (e.g. "/dev/dma_0"). * * The return value will be NULL on failure, and non-NULL otherwise. */ extern alt_dma_rxchan alt_dma_rxchan_open (const char* dev); /* * alt_dma_rxchan_close() is provided so that an application can notify the * system that it has finished with a given DMA receive channel. This is only * provided for completness. */ static ALT_INLINE int alt_dma_rxchan_close (alt_dma_rxchan dma) { return 0; } /* * */ /* * alt_dma_rxchan_prepare() posts a receive request to a DMA receive channel. * * The input arguments are: * * dma: the channel to use. * data: a pointer to the location that data is to be received to. * len: the maximum length of the data to receive. * done: callback function that will be called once the data has been * received. * handle: opaque value passed to "done". * * The return value will be negative if the request cannot be posted, and * zero otherwise. */ static ALT_INLINE int alt_dma_rxchan_prepare (alt_dma_rxchan dma, void* data, alt_u32 len, alt_rxchan_done* done, void* handle) { return dma ? dma->prepare (dma, data, len, done, handle) : -ENODEV; } /* * alt_dma_rxchan_ioctl() can be used to perform device specific I/O * operations on the indicated DMA receive channel. For example some drivers * support options to control the width of the transfer operations. See * alt_dma_dev.h for the list of generic requests. * * A negative return value indicates failure, otherwise the interpretation * of the return value is request specific. */ static ALT_INLINE int alt_dma_rxchan_ioctl (alt_dma_rxchan dma, int req, void* arg) { return dma ? dma->ioctl (dma, req, arg) : -ENODEV; } /* * alt_dma_rxchan_depth() returns the depth of the receive FIFO used to store * receive requests. */ static ALT_INLINE alt_u32 alt_dma_rxchan_depth(alt_dma_rxchan dma) { return dma->depth; } /* * */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __ALT_DMA_H__ */ |