49#include "xil_printf.h"
52#if defined (__MICROBLAZE__)
53#include "mb_interface.h"
55#include "xpseudo_asm.h"
60extern u32 XStl_RegUpdate(u32 RegAddr, u32 RegVal);
65#if defined (__MICROBLAZE__)
66# define INST_SYNC mbar(0)
67# define DATA_SYNC mbar(1)
69# define SYNCHRONIZE_IO dmb()
70# define INST_SYNC isb()
71# define DATA_SYNC dsb()
74# define SYNCHRONIZE_IO
81#if defined (__GNUC__) || defined (__ICCARM__) || defined (__MICROBLAZE__)
84#define INLINE __inline
100static INLINE u8 Xil_In8(UINTPTR Addr)
102 return *(
volatile u8 *) Addr;
117static INLINE u16 Xil_In16(UINTPTR Addr)
119 return *(
volatile u16 *) Addr;
134static INLINE u32 Xil_In32(UINTPTR Addr)
136 return *(
volatile u32 *) Addr;
151static INLINE u64 Xil_In64(UINTPTR Addr)
153 return *(
volatile u64 *) Addr;
169static INLINE
void Xil_Out8(UINTPTR Addr, u8 Value)
172 volatile u8 *LocalAddr = (
volatile u8 *)Addr;
188static INLINE
void Xil_Out16(UINTPTR Addr, u16 Value)
191 volatile u16 *LocalAddr = (
volatile u16 *)Addr;
208static INLINE
void Xil_Out32(UINTPTR Addr, u32 Value)
212 volatile u32 *LocalAddr = (
volatile u32 *)Addr;
215 XStl_RegUpdate(Addr, Value);
231static INLINE
void Xil_Out64(UINTPTR Addr, u64 Value)
234 volatile u64 *LocalAddr = (
volatile u64 *)Addr;
253static INLINE
int Xil_SecureOut32(UINTPTR Addr, u32 Value)
255 int Status = XST_FAILURE;
260 Xil_Out32(Addr, Value);
263 ReadReg = Xil_In32(Addr);
264 ReadRegTemp = Xil_In32(Addr);
266 if( (ReadReg == Value) && (ReadRegTemp == Value) ) {
267 Status = XST_SUCCESS;
283static INLINE
__attribute__((always_inline)) u16 Xil_EndianSwap16(u16 Data)
285 return (u16) (((Data & 0xFF00U) >> 8U) | ((Data & 0x00FFU) << 8U));
298static INLINE
__attribute__((always_inline)) u32 Xil_EndianSwap32(u32 Data)
305 LoWord = (u16) (Data & 0x0000FFFFU);
306 HiWord = (u16) ((Data & 0xFFFF0000U) >> 16U);
310 LoWord = (u16)(((LoWord & 0xFF00U) >> 8U) | ((LoWord & 0x00FFU) << 8U));
311 HiWord = (u16)(((HiWord & 0xFF00U) >> 8U) | ((HiWord & 0x00FFU) << 8U));
315 return ((((u32)LoWord) << (u32)16U) | (u32)HiWord);
318#if defined (__MICROBLAZE__)
319#ifdef __LITTLE_ENDIAN__
320# define Xil_In16LE Xil_In16
321# define Xil_In32LE Xil_In32
322# define Xil_Out16LE Xil_Out16
323# define Xil_Out32LE Xil_Out32
324# define Xil_Htons Xil_EndianSwap16
325# define Xil_Htonl Xil_EndianSwap32
326# define Xil_Ntohs Xil_EndianSwap16
327# define Xil_Ntohl Xil_EndianSwap32
329# define Xil_In16BE Xil_In16
330# define Xil_In32BE Xil_In32
331# define Xil_Out16BE Xil_Out16
332# define Xil_Out32BE Xil_Out32
333# define Xil_Htons(Data) (Data)
334# define Xil_Htonl(Data) (Data)
335# define Xil_Ntohs(Data) (Data)
336# define Xil_Ntohl(Data) (Data)
339# define Xil_In16LE Xil_In16
340# define Xil_In32LE Xil_In32
341# define Xil_Out16LE Xil_Out16
342# define Xil_Out32LE Xil_Out32
343# define Xil_Htons Xil_EndianSwap16
344# define Xil_Htonl Xil_EndianSwap32
345# define Xil_Ntohs Xil_EndianSwap16
346# define Xil_Ntohl Xil_EndianSwap32
349#if defined (__MICROBLAZE__)
350#ifdef __LITTLE_ENDIAN__
351static INLINE u16 Xil_In16BE(UINTPTR Addr)
353static INLINE u16 Xil_In16LE(UINTPTR Addr)
356static INLINE u16 Xil_In16BE(UINTPTR Addr)
359 u16 value = Xil_In16(Addr);
360 return Xil_EndianSwap16(value);
363#if defined (__MICROBLAZE__)
364#ifdef __LITTLE_ENDIAN__
365static INLINE u32 Xil_In32BE(UINTPTR Addr)
367static INLINE u32 Xil_In32LE(UINTPTR Addr)
370static INLINE u32 Xil_In32BE(UINTPTR Addr)
373 u32 value = Xil_In32(Addr);
374 return Xil_EndianSwap32(value);
377#if defined (__MICROBLAZE__)
378#ifdef __LITTLE_ENDIAN__
379static INLINE
void Xil_Out16BE(UINTPTR Addr, u16 Value)
381static INLINE
void Xil_Out16LE(UINTPTR Addr, u16 Value)
384static INLINE
void Xil_Out16BE(UINTPTR Addr, u16 Value)
387 Value = Xil_EndianSwap16(Value);
388 Xil_Out16(Addr, Value);
391#if defined (__MICROBLAZE__)
392#ifdef __LITTLE_ENDIAN__
393static INLINE
void Xil_Out32BE(UINTPTR Addr, u32 Value)
395static INLINE
void Xil_Out32LE(UINTPTR Addr, u32 Value)
398static INLINE
void Xil_Out32BE(UINTPTR Addr, u32 Value)
401 Value = Xil_EndianSwap32(Value);
402 Xil_Out32(Addr, Value);
Definition: xnandpsu_onfi.h:181