5 #include <epicsTypes.h> 6 #include <epicsEndian.h> 11 # define INLINE inline 22 return *(
volatile epicsUInt8*)(addr);
29 *(
volatile epicsUInt8*)(addr) = val;
36 return *(
volatile epicsUInt16*)(addr);
43 *(
volatile epicsUInt16*)(addr) = val;
50 return *(
volatile epicsUInt32*)(addr);
57 *(
volatile epicsUInt32*)(addr) = val;
60 #if EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG 62 #define bswap16(value) ((epicsUInt16) ( \ 63 (((epicsUInt16)(value) & 0x00ff) << 8) | \ 64 (((epicsUInt16)(value) & 0xff00) >> 8))) 66 #define bswap32(value) ( \ 67 (((epicsUInt32)(value) & 0x000000ff) << 24) | \ 68 (((epicsUInt32)(value) & 0x0000ff00) << 8) | \ 69 (((epicsUInt32)(value) & 0x00ff0000) >> 8) | \ 70 (((epicsUInt32)(value) & 0xff000000) >> 24)) 72 # define be_ioread16(A) nat_ioread16(A) 73 # define be_ioread32(A) nat_ioread32(A) 74 # define be_iowrite16(A,D) nat_iowrite16(A,D) 75 # define be_iowrite32(A,D) nat_iowrite32(A,D) 77 # define le_ioread16(A) bswap16(nat_ioread16(A)) 78 # define le_ioread32(A) bswap32(nat_ioread32(A)) 79 # define le_iowrite16(A,D) nat_iowrite16(A,bswap16(D)) 80 # define le_iowrite32(A,D) nat_iowrite32(A,bswap32(D)) 82 #elif EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE 88 #include <netinet/in.h> 89 #include <arpa/inet.h> 95 #define bswap16(v) htons(v) 96 #define bswap32(v) htonl(v) 98 # define be_ioread16(A) bswap16(nat_ioread16(A)) 99 # define be_ioread32(A) bswap32(nat_ioread32(A)) 100 # define be_iowrite16(A,D) nat_iowrite16(A,bswap16(D)) 101 # define be_iowrite32(A,D) nat_iowrite32(A,bswap32(D)) 103 # define le_ioread16(A) nat_ioread16(A) 104 # define le_ioread32(A) nat_ioread32(A) 105 # define le_iowrite16(A,D) nat_iowrite16(A,D) 106 # define le_iowrite32(A,D) nat_iowrite32(A,D) 109 # error Unable to determine native byte order 112 #define rbarr() do{}while(0) 113 #define wbarr() do{}while(0) 114 #define rwbarr() do{}while(0) INLINE void nat_iowrite32(volatile void *addr, epicsUInt32 val)
INLINE void iowrite8(volatile void *addr, epicsUInt8 val)
INLINE epicsUInt8 ioread8(volatile void *addr)
INLINE epicsUInt32 nat_ioread32(volatile void *addr)
INLINE epicsUInt16 nat_ioread16(volatile void *addr)
INLINE void nat_iowrite16(volatile void *addr, epicsUInt16 val)