]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/include/xil_io.h
85464228d6480c7c493cd972a0a0ea6c21881975
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / include / 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 *
42 * <pre>
43 * MODIFICATION HISTORY:
44 *
45 * Ver   Who      Date     Changes
46 * ----- -------- -------- -----------------------------------------------
47 * 1.00a ecm/sdm  10/24/09 First release
48 * 1.00a sdm      07/21/10 Added Xil_Htonl/s, Xil_Ntohl/s
49 * 3.07a asa          08/31/12 Added xil_printf.h include
50 * 3.08a sgd          11/05/12 Reverted SYNC macros definitions
51 * </pre>
52 ******************************************************************************/
53
54 #ifndef XIL_IO_H           /* prevent circular inclusions */
55 #define XIL_IO_H           /* by using protection macros */
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
61 /***************************** Include Files *********************************/
62
63 #include "xil_types.h"
64 #include "xpseudo_asm.h"
65 #include "xil_printf.h"
66
67 /************************** Constant Definitions *****************************/
68
69 /**************************** Type Definitions *******************************/
70
71 /***************** Macros (Inline Functions) Definitions *********************/
72
73 #if defined __GNUC__
74 #  define SYNCHRONIZE_IO        dmb()
75 #  define INST_SYNC             isb()
76 #  define DATA_SYNC             dsb()
77 #else
78 #  define SYNCHRONIZE_IO
79 #  define INST_SYNC
80 #  define DATA_SYNC
81 #endif /* __GNUC__ */
82
83 /*****************************************************************************/
84 /**
85 *
86 * Perform an big-endian input operation for a 16-bit memory location
87 * by reading from the specified address and returning the Value read from
88 * that address.
89 *
90 * @param        Addr contains the address to perform the input operation at.
91 *
92 * @return       The Value read from the specified input address with the
93 *               proper endianness. The return Value has the same endianness
94 *               as that of the processor, i.e. if the processor is
95 *               little-engian, the return Value is the byte-swapped Value read
96 *               from the address.
97 *
98 * @note         None.
99 *
100 ******************************************************************************/
101 #define Xil_In16LE(Addr) Xil_In16(Addr)
102
103 /*****************************************************************************/
104 /**
105 *
106 * Perform a big-endian input operation for a 32-bit memory location
107 * by reading from the specified address and returning the Value read from
108 * that address.
109 *
110 * @param        Addr contains the address to perform the input operation at.
111 *
112 * @return       The Value read from the specified input address with the
113 *               proper endianness. The return Value has the same endianness
114 *               as that of the processor, i.e. if the processor is
115 *               little-engian, the return Value is the byte-swapped Value read
116 *               from the address.
117 *
118 *
119 * @note         None.
120 *
121 ******************************************************************************/
122 #define Xil_In32LE(Addr) Xil_In32(Addr)
123
124 /*****************************************************************************/
125 /**
126 *
127 * Perform a big-endian output operation for a 16-bit memory location
128 * by writing the specified Value to the specified address.
129 *
130 * @param        Addr contains the address to perform the output operation at.
131 * @param        Value contains the Value to be output at the specified address.
132 *               The Value has the same endianness as that of the processor.
133 *               If the processor is little-endian, the byte-swapped Value is
134 *               written to the address.
135 *
136 *
137 * @return       None
138 *
139 * @note         None.
140 *
141 ******************************************************************************/
142 #define Xil_Out16LE(Addr, Value) Xil_Out16(Addr, Value)
143
144 /*****************************************************************************/
145 /**
146 *
147 * Perform a big-endian output operation for a 32-bit memory location
148 * by writing the specified Value to the specified address.
149 *
150 * @param        Addr contains the address to perform the output operation at.
151 * @param        Value contains the Value to be output at the specified address.
152 *               The Value has the same endianness as that of the processor.
153 *               If the processor is little-endian, the byte-swapped Value is
154 *               written to the address.
155 *
156 * @return       None
157 *
158 * @note         None.
159 *
160 ******************************************************************************/
161 #define Xil_Out32LE(Addr, Value) Xil_Out32(Addr, Value)
162
163 /*****************************************************************************/
164 /**
165 *
166 * Convert a 32-bit number from host byte order to network byte order.
167 *
168 * @param        Data the 32-bit number to be converted.
169 *
170 * @return       The converted 32-bit number in network byte order.
171 *
172 * @note         None.
173 *
174 ******************************************************************************/
175 #define Xil_Htonl(Data) Xil_EndianSwap32(Data)
176
177 /*****************************************************************************/
178 /**
179 *
180 * Convert a 16-bit number from host byte order to network byte order.
181 *
182 * @param        Data the 16-bit number to be converted.
183 *
184 * @return       The converted 16-bit number in network byte order.
185 *
186 * @note         None.
187 *
188 ******************************************************************************/
189 #define Xil_Htons(Data) Xil_EndianSwap16(Data)
190
191 /*****************************************************************************/
192 /**
193 *
194 * Convert a 32-bit number from network byte order to host byte order.
195 *
196 * @param        Data the 32-bit number to be converted.
197 *
198 * @return       The converted 32-bit number in host byte order.
199 *
200 * @note         None.
201 *
202 ******************************************************************************/
203 #define Xil_Ntohl(Data) Xil_EndianSwap32(Data)
204
205 /*****************************************************************************/
206 /**
207 *
208 * Convert a 16-bit number from network byte order to host byte order.
209 *
210 * @param        Data the 16-bit number to be converted.
211 *
212 * @return       The converted 16-bit number in host byte order.
213 *
214 * @note         None.
215 *
216 ******************************************************************************/
217 #define Xil_Ntohs(Data) Xil_EndianSwap16(Data)
218
219 /************************** Function Prototypes ******************************/
220
221 /* The following functions allow the software to be transportable across
222  * processors which may use memory mapped I/O or I/O which is mapped into a
223  * seperate address space.
224  */
225 u8 Xil_In8(u32 Addr);
226 u16 Xil_In16(u32 Addr);
227 u32 Xil_In32(u32 Addr);
228
229 void Xil_Out8(u32 Addr, u8 Value);
230 void Xil_Out16(u32 Addr, u16 Value);
231 void Xil_Out32(u32 Addr, u32 Value);
232
233 u16 Xil_In16BE(u32 Addr);
234 u32 Xil_In32BE(u32 Addr);
235 void Xil_Out16BE(u32 Addr, u16 Value);
236 void Xil_Out32BE(u32 Addr, u32 Value);
237
238 u16 Xil_EndianSwap16(u16 Data);
239 u32 Xil_EndianSwap32(u32 Data);
240
241 #ifdef __cplusplus
242 }
243 #endif
244
245 #endif /* end of protection macro */