1 /******************************************************************************
3 * Copyright (C) 2014 - 2015 Xilinx, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
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
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.
31 ******************************************************************************/
32 /*****************************************************************************/
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.
43 * MODIFICATION HISTORY:
45 * Ver Who Date Changes
46 * ----- -------- -------- -----------------------------------------------
47 * 5.00 pkp 02/20/14 First release
49 ******************************************************************************/
51 #ifndef XIL_IO_H /* prevent circular inclusions */
52 #define XIL_IO_H /* by using protection macros */
58 /***************************** Include Files *********************************/
60 #include "xil_types.h"
61 #include "xpseudo_asm.h"
62 #include "xil_printf.h"
64 /************************** Constant Definitions *****************************/
66 /**************************** Type Definitions *******************************/
68 /***************** Macros (Inline Functions) Definitions *********************/
71 # define SYNCHRONIZE_IO dmb()
72 # define INST_SYNC isb()
73 # define DATA_SYNC dsb()
75 # define SYNCHRONIZE_IO
80 /*****************************************************************************/
83 * Perform an big-endian input operation for a 16-bit memory location
84 * by reading from the specified address and returning the Value read from
87 * @param Addr contains the address to perform the input operation at.
89 * @return The Value read from the specified input address with the
90 * proper endianness. The return Value has the same endianness
91 * as that of the processor, i.e. if the processor is
92 * little-engian, the return Value is the byte-swapped Value read
97 ******************************************************************************/
98 #define Xil_In16LE(Addr) Xil_In16((Addr))
100 /*****************************************************************************/
103 * Perform a big-endian input operation for a 32-bit memory location
104 * by reading from the specified address and returning the Value read from
107 * @param Addr contains the address to perform the input operation at.
109 * @return The Value read from the specified input address with the
110 * proper endianness. The return Value has the same endianness
111 * as that of the processor, i.e. if the processor is
112 * little-engian, the return Value is the byte-swapped Value read
118 ******************************************************************************/
119 #define Xil_In32LE(Addr) Xil_In32((Addr))
121 /*****************************************************************************/
124 * Perform a big-endian output operation for a 16-bit memory location
125 * by writing the specified Value to the specified address.
127 * @param Addr contains the address to perform the output operation at.
128 * @param Value contains the Value to be output at the specified address.
129 * The Value has the same endianness as that of the processor.
130 * If the processor is little-endian, the byte-swapped Value is
131 * written to the address.
138 ******************************************************************************/
139 #define Xil_Out16LE(Addr, Value) Xil_Out16((Addr), (Value))
141 /*****************************************************************************/
144 * Perform a big-endian output operation for a 32-bit memory location
145 * by writing the specified Value to the specified address.
147 * @param Addr contains the address to perform the output operation at.
148 * @param Value contains the Value to be output at the specified address.
149 * The Value has the same endianness as that of the processor.
150 * If the processor is little-endian, the byte-swapped Value is
151 * written to the address.
157 ******************************************************************************/
158 #define Xil_Out32LE(Addr, Value) Xil_Out32((Addr), (Value))
160 /*****************************************************************************/
163 * Convert a 32-bit number from host byte order to network byte order.
165 * @param Data the 32-bit number to be converted.
167 * @return The converted 32-bit number in network byte order.
171 ******************************************************************************/
172 #define Xil_Htonl(Data) Xil_EndianSwap32((Data))
174 /*****************************************************************************/
177 * Convert a 16-bit number from host byte order to network byte order.
179 * @param Data the 16-bit number to be converted.
181 * @return The converted 16-bit number in network byte order.
185 ******************************************************************************/
186 #define Xil_Htons(Data) Xil_EndianSwap16((Data))
188 /*****************************************************************************/
191 * Convert a 32-bit number from network byte order to host byte order.
193 * @param Data the 32-bit number to be converted.
195 * @return The converted 32-bit number in host byte order.
199 ******************************************************************************/
200 #define Xil_Ntohl(Data) Xil_EndianSwap32((Data))
202 /*****************************************************************************/
205 * Convert a 16-bit number from network byte order to host byte order.
207 * @param Data the 16-bit number to be converted.
209 * @return The converted 16-bit number in host byte order.
213 ******************************************************************************/
214 #define Xil_Ntohs(Data) Xil_EndianSwap16((Data))
216 /************************** Function Prototypes ******************************/
218 /* The following functions allow the software to be transportable across
219 * processors which may use memory mapped I/O or I/O which is mapped into a
220 * seperate address space.
222 u8 Xil_In8(INTPTR Addr);
223 u16 Xil_In16(INTPTR Addr);
224 u32 Xil_In32(INTPTR Addr);
225 u64 Xil_In64(INTPTR Addr);
227 void Xil_Out8(INTPTR Addr, u8 Value);
228 void Xil_Out16(INTPTR Addr, u16 Value);
229 void Xil_Out32(INTPTR Addr, u32 Value);
230 void Xil_Out64(INTPTR Addr, u64 Value);
232 u16 Xil_In16BE(INTPTR Addr);
233 u32 Xil_In32BE(INTPTR Addr);
234 void Xil_Out16BE(INTPTR Addr, u16 Value);
235 void Xil_Out32BE(INTPTR Addr, u32 Value);
237 u16 Xil_EndianSwap16(u16 Data);
238 u32 Xil_EndianSwap32(u32 Data);
244 #endif /* end of protection macro */