1 /******************************************************************************
3 * Copyright (C) 2009 - 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 * 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
52 ******************************************************************************/
54 #ifndef XIL_IO_H /* prevent circular inclusions */
55 #define XIL_IO_H /* by using protection macros */
61 /***************************** Include Files *********************************/
63 #include "xil_types.h"
64 #include "xpseudo_asm.h"
65 #include "xil_printf.h"
67 /************************** Constant Definitions *****************************/
69 /**************************** Type Definitions *******************************/
71 /***************** Macros (Inline Functions) Definitions *********************/
74 # define SYNCHRONIZE_IO dmb()
75 # define INST_SYNC isb()
76 # define DATA_SYNC dsb()
78 # define SYNCHRONIZE_IO
83 /*****************************************************************************/
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
90 * @param Addr contains the address to perform the input operation at.
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
100 ******************************************************************************/
101 #define Xil_In16LE(Addr) Xil_In16((Addr))
103 /*****************************************************************************/
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
110 * @param Addr contains the address to perform the input operation at.
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
121 ******************************************************************************/
122 #define Xil_In32LE(Addr) Xil_In32((Addr))
124 /*****************************************************************************/
127 * Perform a big-endian output operation for a 16-bit memory location
128 * by writing the specified Value to the specified address.
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.
141 ******************************************************************************/
142 #define Xil_Out16LE(Addr, Value) Xil_Out16((Addr), (Value))
144 /*****************************************************************************/
147 * Perform a big-endian output operation for a 32-bit memory location
148 * by writing the specified Value to the specified address.
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.
160 ******************************************************************************/
161 #define Xil_Out32LE(Addr, Value) Xil_Out32((Addr), (Value))
163 /*****************************************************************************/
166 * Convert a 32-bit number from host byte order to network byte order.
168 * @param Data the 32-bit number to be converted.
170 * @return The converted 32-bit number in network byte order.
174 ******************************************************************************/
175 #define Xil_Htonl(Data) Xil_EndianSwap32((Data))
177 /*****************************************************************************/
180 * Convert a 16-bit number from host byte order to network byte order.
182 * @param Data the 16-bit number to be converted.
184 * @return The converted 16-bit number in network byte order.
188 ******************************************************************************/
189 #define Xil_Htons(Data) Xil_EndianSwap16((Data))
191 /*****************************************************************************/
194 * Convert a 32-bit number from network byte order to host byte order.
196 * @param Data the 32-bit number to be converted.
198 * @return The converted 32-bit number in host byte order.
202 ******************************************************************************/
203 #define Xil_Ntohl(Data) Xil_EndianSwap32((Data))
205 /*****************************************************************************/
208 * Convert a 16-bit number from network byte order to host byte order.
210 * @param Data the 16-bit number to be converted.
212 * @return The converted 16-bit number in host byte order.
216 ******************************************************************************/
217 #define Xil_Ntohs(Data) Xil_EndianSwap16((Data))
219 /************************** Function Prototypes ******************************/
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.
225 u8 Xil_In8(INTPTR Addr);
226 u16 Xil_In16(INTPTR Addr);
227 u32 Xil_In32(UINTPTR Addr);
229 void Xil_Out8(INTPTR Addr, u8 Value);
230 void Xil_Out16(INTPTR Addr, u16 Value);
231 void Xil_Out32(UINTPTR Addr, u32 Value);
234 u16 Xil_In16BE(INTPTR Addr);
235 u32 Xil_In32BE(INTPTR Addr);
236 void Xil_Out16BE(INTPTR Addr, u16 Value);
237 void Xil_Out32BE(INTPTR Addr, u32 Value);
239 u16 Xil_EndianSwap16(u16 Data);
240 u32 Xil_EndianSwap32(u32 Data);
246 #endif /* end of protection macro */