xil_io.h 6.3 KB

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