]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/standalone_v4_2/src/xil_io.h
Update some more standard demos for use on 64-bit architectures.
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / BSP / microblaze_0 / libsrc / standalone_v4_2 / src / xil_io.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2009 - 2014 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 *
35 * @file xil_io.h
36 *
37 * This file contains the interface for the general IO component, which
38 * encapsulates the Input/Output functions for processors that do not
39 * require any special I/O handling.
40 *
41 * <pre>
42 * MODIFICATION HISTORY:
43 *
44 * Ver   Who  Date     Changes
45 * ----- ---- -------- -------------------------------------------------------
46 * 3.00a hbm  07/28/09 Initial release
47 * 3.00a hbm  07/21/10 Added Xil_EndianSwap32/16, Xil_Htonl/s, Xil_Ntohl/s
48 * 3.03a sdm  08/18/11 Added INST_SYNC and DATA_SYNC macros.
49 * 3.07a asa  08/31/12 Added xil_printf.h include
50 *
51 * </pre>
52 *
53 * @note
54 *
55 * This file may contain architecture-dependent items.
56 *
57 ******************************************************************************/
58
59 #ifndef XIL_IO_H                        /* prevent circular inclusions */
60 #define XIL_IO_H                        /* by using protection macros */
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66 /***************************** Include Files *********************************/
67
68 #include "xil_types.h"
69 #include "mb_interface.h"
70 #include "xil_printf.h"
71
72 /************************** Constant Definitions *****************************/
73
74 /**************************** Type Definitions *******************************/
75
76 /***************** Macros (Inline Functions) Definitions *********************/
77
78 #if defined __GNUC__
79 #  define INST_SYNC             mbar(0)
80 #  define DATA_SYNC             mbar(1)
81 #else
82 #  define INST_SYNC
83 #  define DATA_SYNC
84 #endif /* __GNUC__ */
85
86 /*
87  * The following macros allow optimized I/O operations for memory mapped I/O.
88  * It should be noted that macros cannot be used if synchronization of the I/O
89  * operation is needed as it will likely break some code.
90  */
91
92 /*****************************************************************************/
93 /**
94 *
95 * Perform an input operation for an 8-bit memory location by reading from the
96 * specified address and returning the value read from that address.
97 *
98 * @param        Addr contains the address to perform the input operation at.
99 *
100 * @return       The value read from the specified input address.
101 *
102 * @note         None.
103 *
104 ******************************************************************************/
105 #define Xil_In8(Addr)  (*(volatile u8  *)(Addr))
106
107 /*****************************************************************************/
108 /**
109 *
110 * Perform an input operation for a 16-bit memory location by reading from the
111 * specified address and returning the value read from that address.
112 *
113 * @param        Addr contains the address to perform the input operation at.
114 *
115 * @return       The value read from the specified input address.
116 *
117 * @note         None.
118 *
119 ******************************************************************************/
120 #define Xil_In16(Addr) (*(volatile u16 *)(Addr))
121
122 /*****************************************************************************/
123 /**
124 *
125 * Perform an input operation for a 32-bit memory location by reading from the
126 * specified address and returning the value read from that address.
127 *
128 * @param        Addr contains the address to perform the input operation at.
129 *
130 * @return       The value read from the specified input address.
131 *
132 * @note         None.
133 *
134 ******************************************************************************/
135 #define Xil_In32(Addr)  (*(volatile u32 *)(Addr))
136
137
138 /*****************************************************************************/
139 /**
140 *
141 * Perform an output operation for an 8-bit memory location by writing the
142 * specified value to the specified address.
143 *
144 * @param        Addr contains the address to perform the output operation at.
145 * @param        value contains the value to be output at the specified address.
146 *
147 * @return       None
148 *
149 * @note         None.
150 *
151 ******************************************************************************/
152 #define Xil_Out8(Addr, Value)  \
153         (*(volatile u8  *)((Addr)) = (Value))
154
155 /*****************************************************************************/
156 /**
157 *
158 * Perform an output operation for a 16-bit memory location by writing the
159 * specified value to the specified address.
160 *
161 * @param        Addr contains the address to perform the output operation at.
162 * @param        value contains the value to be output at the specified address.
163 *
164 * @return       None
165 *
166 * @note         None.
167 *
168 ******************************************************************************/
169 #define Xil_Out16(Addr, Value) \
170         (*(volatile u16 *)((Addr)) = (Value))
171
172 /*****************************************************************************/
173 /**
174 *
175 * Perform an output operation for a 32-bit memory location by writing the
176 * specified value to the specified address.
177 *
178 * @param        addr contains the address to perform the output operation at.
179 * @param        value contains the value to be output at the specified address.
180 *
181 * @return       None
182 *
183 * @note         None.
184 *
185 ******************************************************************************/
186 #define Xil_Out32(Addr, Value) \
187         (*(volatile u32 *)((Addr)) = (Value))
188
189
190 extern u16 Xil_EndianSwap16(u16 Data);
191 extern u32 Xil_EndianSwap32(u32 Data);
192
193 #ifndef __LITTLE_ENDIAN__
194 extern u16 Xil_In16LE(u32 Addr);
195 extern u32 Xil_In32LE(u32 Addr);
196 extern void Xil_Out16LE(u32 Addr, u16 Value);
197 extern void Xil_Out32LE(u32 Addr, u32 Value);
198
199 /**
200 *
201 * Perform an big-endian input operation for a 16-bit memory location
202 * by reading from the specified address and returning the value read from
203 * that address.
204 *
205 * @param        addr contains the address to perform the input operation at.
206 *
207 * @return       The value read from the specified input address with the
208 *               proper endianness. The return value has the same endianness
209 *               as that of the processor, i.e. if the processor is
210 *               little-engian, the return value is the byte-swapped value read
211 *               from the address.
212 *
213 * @note         None.
214 *
215 ******************************************************************************/
216 #define Xil_In16BE(Addr) Xil_In16(Addr)
217
218 /**
219 *
220 * Perform a big-endian input operation for a 32-bit memory location
221 * by reading from the specified address and returning the value read from
222 * that address.
223 *
224 * @param        Addr contains the address to perform the input operation at.
225 *
226 * @return       The value read from the specified input address with the
227 *               proper endianness. The return value has the same endianness
228 *               as that of the processor, i.e. if the processor is
229 *               little-engian, the return value is the byte-swapped value read
230 *               from the address.
231 *
232 *
233 * @note         None.
234 *
235 ******************************************************************************/
236 #define Xil_In32BE(Addr) Xil_In32(Addr)
237
238 /*****************************************************************************/
239 /**
240 *
241 * Perform a big-endian output operation for a 16-bit memory location
242 * by writing the specified value to the specified address.
243 *
244 * @param        Addr contains the address to perform the output operation at.
245 * @param        Value contains the value to be output at the specified address.
246 *               The value has the same endianness as that of the processor.
247 *               If the processor is little-endian, the byte-swapped value is
248 *               written to the address.
249 *
250 *
251 * @return       None
252 *
253 * @note         None.
254 *
255 ******************************************************************************/
256 #define Xil_Out16BE(Addr, Value) Xil_Out16(Addr, Value)
257
258 /*****************************************************************************/
259 /**
260 *
261 * Perform a big-endian output operation for a 32-bit memory location
262 * by writing the specified value to the specified address.
263 *
264 * @param        Addr contains the address to perform the output operation at.
265 * @param        Value contains the value to be output at the specified address.
266 *               The value has the same endianness as that of the processor.
267 *               If the processor is little-endian, the byte-swapped value is
268 *               written to the address.
269 *
270 * @return       None
271 *
272 * @note         None.
273 *
274 ******************************************************************************/
275 #define Xil_Out32BE(Addr, Value) Xil_Out32(Addr, Value)
276
277 #define Xil_Htonl(Data) (Data)
278 #define Xil_Htons(Data) (Data)
279 #define Xil_Ntohl(Data) (Data)
280 #define Xil_Ntohs(Data) (Data)
281
282 #else
283
284 extern u16 Xil_In16BE(u32 Addr);
285 extern u32 Xil_In32BE(u32 Addr);
286 extern void Xil_Out16BE(u32 Addr, u16 Value);
287 extern void Xil_Out32BE(u32 Addr, u32 Value);
288
289 #define Xil_In16LE(Addr) Xil_In16(Addr)
290 #define Xil_In32LE(Addr) Xil_In32(Addr)
291 #define Xil_Out16LE(Addr, Value) Xil_Out16(Addr, Value)
292 #define Xil_Out32LE(Addr, Value) Xil_Out32(Addr, Value)
293
294
295 /*****************************************************************************/
296 /**
297 *
298 * Convert a 32-bit number from host byte order to network byte order.
299 *
300 * @param        Data the 32-bit number to be converted.
301 *
302 * @return       The converted 32-bit number in network byte order.
303 *
304 * @note         None.
305 *
306 ******************************************************************************/
307 #define Xil_Htonl(Data) Xil_EndianSwap32(Data)
308
309 /*****************************************************************************/
310 /**
311 *
312 * Convert a 16-bit number from host byte order to network byte order.
313 *
314 * @param        Data the 16-bit number to be converted.
315 *
316 * @return       The converted 16-bit number in network byte order.
317 *
318 * @note         None.
319 *
320 ******************************************************************************/
321 #define Xil_Htons(Data) Xil_EndianSwap16(Data)
322
323 /*****************************************************************************/
324 /**
325 *
326 * Convert a 32-bit number from network byte order to host byte order.
327 *
328 * @param        Value the 32-bit number to be converted.
329 *
330 * @return       The converted 32-bit number in host byte order.
331 *
332 * @note         None.
333 *
334 ******************************************************************************/
335 #define Xil_Ntohl(Data) Xil_EndianSwap32(Data)
336
337 /*****************************************************************************/
338 /**
339 *
340 * Convert a 16-bit number from network byte order to host byte order.
341 *
342 * @param        Value the 16-bit number to be converted.
343 *
344 * @return       The converted 16-bit number in host byte order.
345 *
346 * @note         None.
347 *
348 ******************************************************************************/
349 #define Xil_Ntohs(Data) Xil_EndianSwap16(Data)
350
351 #endif
352
353 #ifdef __cplusplus
354 }
355 #endif
356
357 #endif /* end of protection macro */