]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/cpu_v2_2/src/xio.h
Common scheduler code:
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / BSP / microblaze_0 / libsrc / cpu_v2_2 / src / xio.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2007 - 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 xio.h
36 *
37 * This file contains the interface for the XIo component, which encapsulates
38 * the Input/Output functions for processors that do not require any special
39 * I/O handling.
40 *
41 * <pre>
42 * MODIFICATION HISTORY:
43 *
44 * Ver   Who  Date     Changes
45 * ----- ---- -------- -------------------------------------------------------
46 * 1.00a rpm  11/07/03 Added InSwap/OutSwap routines for endian conversion
47 * 1.00a xd   11/04/04 Improved support for doxygen
48 * 1.01a ecm  02/24/06 CR225908 corrected the extra curly braces in macros
49 *                     and bumped version to 1.01.a.
50 * 1.11a mta  03/21/07 Updated to new coding style.
51 * 1.11b va   04/17/08 Updated Tcl for better CORE_CLOCK_FREQ_HZ definition
52 * 1.11a sdm  03/12/09 Updated Tcl to define correct value for CORE_CLOCK_FREQ_HZ
53 *                     (CR  #502010)
54 * 1.13a sdm  03/12/09 Updated the Tcl to pull appropriate libraries for Little
55 *                     Endian Microblaze
56 * 2.0   adk  19/12/13 Updated as per the New Tcl API's
57 * 2.1   bss  04/14/14 Updated tcl to copy libgloss.a and libgcc.a libraries
58 * 2.1   bss  04/29/14 Updated to copy libgloss.a if exists otherwise libxil.a
59 *                       CR#794205
60 * 2.2   bss  08/04/14 Updated driver tcl to add protection macros for
61 *                     xparameters.h (CR#802257).
62 *
63 * </pre>
64 *
65 * @note
66 *
67 * This file may contain architecture-dependent items (memory-mapped or
68 * non-memory-mapped I/O).
69 *
70 ******************************************************************************/
71
72 #ifndef XIO_H                   /* prevent circular inclusions */
73 #define XIO_H                   /* by using protection macros */
74
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78
79 /***************************** Include Files *********************************/
80
81 #include "xil_types.h"
82 #include "xil_assert.h"
83
84 /************************** Constant Definitions *****************************/
85
86
87 /**************************** Type Definitions *******************************/
88
89 /**
90  * Typedef for an I/O address.  Typically correlates to the width of the
91  * address bus.
92  */
93 typedef u32 XIo_Address;
94
95 /***************** Macros (Inline Functions) Definitions *********************/
96
97 /*
98  * The following macros allow optimized I/O operations for memory mapped I/O.
99  * It should be noted that macros cannot be used if synchronization of the I/O
100  * operation is needed as it will likely break some code.
101  */
102
103 /*****************************************************************************/
104 /**
105 *
106 * Performs an input operation for an 8-bit memory location by reading from the
107 * specified address and returning the value read from that address.
108 *
109 * @param        InputPtr contains the address to perform the input operation at.
110 *
111 * @return       The value read from the specified input address.
112 *
113 * @note         None.
114 *
115 ******************************************************************************/
116 #define XIo_In8(InputPtr)  (*(volatile u8  *)(InputPtr))
117
118 /*****************************************************************************/
119 /**
120 *
121 * Performs an input operation for a 16-bit memory location by reading from the
122 * specified address and returning the value read from that address.
123 *
124 * @param        InputPtr contains the address to perform the input operation at.
125 *
126 * @return       The value read from the specified input address.
127 *
128 * @note         None.
129 *
130 ******************************************************************************/
131 #define XIo_In16(InputPtr) (*(volatile u16 *)(InputPtr))
132
133 /*****************************************************************************/
134 /**
135 *
136 * Performs an input operation for a 32-bit memory location by reading from the
137 * specified address and returning the value read from that address.
138 *
139 * @param        InputPtr contains the address to perform the input operation at.
140 *
141 * @return       The value read from the specified input address.
142 *
143 * @note         None.
144 *
145 ******************************************************************************/
146 #define XIo_In32(InputPtr)  (*(volatile u32 *)(InputPtr))
147
148
149 /*****************************************************************************/
150 /**
151 *
152 * Performs an output operation for an 8-bit memory location by writing the
153 * specified value to the the specified address.
154 *
155 * @param        OutputPtr contains the address to perform the output operation
156 *               at.
157 * @param        Value contains the value to be output at the specified address.
158 *
159 * @return       None
160 *
161 * @note         None.
162 *
163 ******************************************************************************/
164 #define XIo_Out8(OutputPtr, Value)  \
165         (*(volatile u8  *)((OutputPtr)) = (Value))
166
167 /*****************************************************************************/
168 /**
169 *
170 * Performs an output operation for a 16-bit memory location by writing the
171 * specified value to the the specified address.
172 *
173 * @param        OutputPtr contains the address to perform the output operation
174 *               at.
175 * @param        Value contains the value to be output at the specified address.
176 *
177 * @return       None
178 *
179 * @note         None.
180 *
181 ******************************************************************************/
182 #define XIo_Out16(OutputPtr, Value) \
183         (*(volatile u16 *)((OutputPtr)) = (Value))
184
185 /*****************************************************************************/
186 /**
187 *
188 * Performs an output operation for a 32-bit memory location by writing the
189 * specified value to the the specified address.
190 *
191 * @param        OutputPtr contains the address to perform the output operation
192 *               at.
193 * @param        Value contains the value to be output at the specified address.
194 *
195 * @return       None
196 *
197 * @note         None.
198 *
199 ******************************************************************************/
200 #define XIo_Out32(OutputPtr, Value) \
201         (*(volatile u32 *)((OutputPtr)) = (Value))
202
203
204 /* The following macros allow the software to be transportable across
205  * processors which use big or little endian memory models.
206  *
207  * Defined first is a no-op endian conversion macro. This macro is not to
208  * be used directly by software. Instead, the XIo_To/FromLittleEndianXX and
209  * XIo_To/FromBigEndianXX macros below are to be used to allow the endian
210  * conversion to only be performed when necessary
211  */
212 #define XIo_EndianNoop(Source, DestPtr)         (*DestPtr = Source)
213
214 #ifdef XLITTLE_ENDIAN
215
216 #define XIo_ToLittleEndian16                    XIo_EndianNoop
217 #define XIo_ToLittleEndian32                    XIo_EndianNoop
218 #define XIo_FromLittleEndian16                  XIo_EndianNoop
219 #define XIo_FromLittleEndian32                  XIo_EndianNoop
220
221 #define XIo_ToBigEndian16(Source, DestPtr) XIo_EndianSwap16(Source, DestPtr)
222 #define XIo_ToBigEndian32(Source, DestPtr) XIo_EndianSwap32(Source, DestPtr)
223 #define XIo_FromBigEndian16                     XIo_ToBigEndian16
224 #define XIo_FromBigEndian32                     XIo_ToBigEndian32
225
226 #else
227
228 #define XIo_ToLittleEndian16(Source, DestPtr) XIo_EndianSwap16(Source, DestPtr)
229 #define XIo_ToLittleEndian32(Source, DestPtr) XIo_EndianSwap32(Source, DestPtr)
230 #define XIo_FromLittleEndian16                  XIo_ToLittleEndian16
231 #define XIo_FromLittleEndian32                  XIo_ToLittleEndian32
232
233 #define XIo_ToBigEndian16                       XIo_EndianNoop
234 #define XIo_ToBigEndian32                       XIo_EndianNoop
235 #define XIo_FromBigEndian16                     XIo_EndianNoop
236 #define XIo_FromBigEndian32                     XIo_EndianNoop
237
238 #endif
239
240 /************************** Function Prototypes ******************************/
241
242 /* The following functions allow the software to be transportable across
243  * processors which use big or little endian memory models. These functions
244  * should not be directly called, but the macros XIo_To/FromLittleEndianXX and
245  * XIo_To/FromBigEndianXX should be used to allow the endian conversion to only
246  * be performed when necessary.
247  */
248 void XIo_EndianSwap16(u16 Source, u16 *DestPtr);
249 void XIo_EndianSwap32(u32 Source, u32 *DestPtr);
250
251 /* The following functions handle IO addresses where data must be swapped
252  * They cannot be implemented as macros
253  */
254 u16 XIo_InSwap16(XIo_Address InAddress);
255 u32 XIo_InSwap32(XIo_Address InAddress);
256 void XIo_OutSwap16(XIo_Address OutAddress, u16 Value);
257 void XIo_OutSwap32(XIo_Address OutAddress, u32 Value);
258
259 #ifdef __cplusplus
260 }
261 #endif
262
263 #endif /* end of protection macro */