1 /******************************************************************************
2 * Copyright (c) 2014 - 2020 Xilinx, Inc. All rights reserved.
3 * SPDX-License-Identifier: MIT
4 ******************************************************************************/
5
6 /*****************************************************************************/
7 /**
8 *
9 * @file xil_io.h
10 *
11 * @addtogroup common_io_interfacing_apis Register IO interfacing APIs
12 *
13 * The xil_io.h file contains the interface for the general I/O component, which
14 * encapsulates the Input/Output functions for the processors that do not
15 * require any special I/O handling.
16 *
17 * @{
18 * <pre>
19 * MODIFICATION HISTORY:
20 *
21 * Ver Who Date Changes
22 * ----- -------- -------- -----------------------------------------------
23 * 5.00 pkp 05/29/14 First release
24 * 6.00 mus 08/19/16 Remove checking of __LITTLE_ENDIAN__ flag for
25 * ARM processors
26 * 7.20 har 01/03/20 Added Xil_SecureOut32 for avoiding blindwrite for
27 * CR-1049218
28 * </pre>
29 ******************************************************************************/
30
31 #ifndef XIL_IO_H /* prevent circular inclusions */
32 #define XIL_IO_H /* by using protection macros */
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 /***************************** Include Files *********************************/
39
40 #include "xil_types.h"
41 #include "xil_printf.h"
42 #include "xstatus.h"
43
44 #if defined (__GNUC__) || defined (__ICCARM__) || defined (__MICROBLAZE__)
45 #define INLINE inline
46 #else
47 #define INLINE __inline
48 #endif
49
50 /*****************************************************************************/
51 /**
52 *
53 * @brief Performs an input operation for a memory location by reading
54 * from the specified address and returning the 8 bit Value read from
55 * that address.
56 *
57 * @param Addr: contains the address to perform the input operation
58 *
59 * @return The 8 bit Value read from the specified input address.
60
61 *
62 ******************************************************************************/
Xil_In8(UINTPTR Addr)63 static INLINE u8 Xil_In8(UINTPTR Addr)
64 {
65 return *(volatile u8 *) Addr;
66 }
67
68 /*****************************************************************************/
69 /**
70 *
71 * @brief Performs an input operation for a memory location by reading from
72 * the specified address and returning the 16 bit Value read from that
73 * address.
74 *
75 * @param Addr: contains the address to perform the input operation
76 *
77 * @return The 16 bit Value read from the specified input address.
78 *
79 ******************************************************************************/
Xil_In16(UINTPTR Addr)80 static INLINE u16 Xil_In16(UINTPTR Addr)
81 {
82 return *(volatile u16 *) Addr;
83 }
84
85 /*****************************************************************************/
86 /**
87 *
88 * @brief Performs an input operation for a memory location by
89 * reading from the specified address and returning the 32 bit Value
90 * read from that address.
91 *
92 * @param Addr: contains the address to perform the input operation
93 *
94 * @return The 32 bit Value read from the specified input address.
95 *
96 ******************************************************************************/
Xil_In32(UINTPTR Addr)97 static INLINE u32 Xil_In32(UINTPTR Addr)
98 {
99 return *(volatile u32 *) Addr;
100 }
101
102 /*****************************************************************************/
103 /**
104 *
105 * @brief Performs an input operation for a memory location by reading the
106 * 64 bit Value read from that address.
107 *
108 *
109 * @param Addr: contains the address to perform the input operation
110 *
111 * @return The 64 bit Value read from the specified input address.
112 *
113 ******************************************************************************/
Xil_In64(UINTPTR Addr)114 static INLINE u64 Xil_In64(UINTPTR Addr)
115 {
116 return *(volatile u64 *) Addr;
117 }
118
119 /*****************************************************************************/
120 /**
121 *
122 * @brief Performs an output operation for an memory location by
123 * writing the 8 bit Value to the the specified address.
124 *
125 * @param Addr: contains the address to perform the output operation
126 * @param Value: contains the 8 bit Value to be written at the specified
127 * address.
128 *
129 * @return None.
130 *
131 ******************************************************************************/
Xil_Out8(UINTPTR Addr,u8 Value)132 static INLINE void Xil_Out8(UINTPTR Addr, u8 Value)
133 {
134 volatile u8 *LocalAddr = (volatile u8 *)Addr;
135 *LocalAddr = Value;
136 }
137
138 /*****************************************************************************/
139 /**
140 *
141 * @brief Performs an output operation for a memory location by writing the
142 * 16 bit Value to the the specified address.
143 *
144 * @param Addr contains the address to perform the output operation
145 * @param Value contains the Value to be written at the specified address.
146 *
147 * @return None.
148 *
149 ******************************************************************************/
Xil_Out16(UINTPTR Addr,u16 Value)150 static INLINE void Xil_Out16(UINTPTR Addr, u16 Value)
151 {
152 volatile u16 *LocalAddr = (volatile u16 *)Addr;
153 *LocalAddr = Value;
154 }
155
156 /*****************************************************************************/
157 /**
158 *
159 * @brief Performs an output operation for a memory location by writing the
160 * 32 bit Value to the the specified address.
161 *
162 * @param Addr contains the address to perform the output operation
163 * @param Value contains the 32 bit Value to be written at the specified
164 * address.
165 *
166 * @return None.
167 *
168 ******************************************************************************/
Xil_Out32(UINTPTR Addr,u32 Value)169 static INLINE void Xil_Out32(UINTPTR Addr, u32 Value)
170 {
171 #ifndef ENABLE_SAFETY
172 volatile u32 *LocalAddr = (volatile u32 *)Addr;
173 *LocalAddr = Value;
174 #else
175 XStl_RegUpdate(Addr, Value);
176 #endif
177 }
178
179 /*****************************************************************************/
180 /**
181 *
182 * @brief Performs an output operation for a memory location by writing the
183 * 64 bit Value to the the specified address.
184 *
185 * @param Addr contains the address to perform the output operation
186 * @param Value contains 64 bit Value to be written at the specified address.
187 *
188 * @return None.
189 *
190 ******************************************************************************/
Xil_Out64(UINTPTR Addr,u64 Value)191 static INLINE void Xil_Out64(UINTPTR Addr, u64 Value)
192 {
193 volatile u64 *LocalAddr = (volatile u64 *)Addr;
194 *LocalAddr = Value;
195 }
196
197 #ifdef __cplusplus
198 }
199 #endif
200
201 #endif /* end of protection macro */
202 /**
203 * @} End of "addtogroup common_io_interfacing_apis".
204 */
205