This is Unofficial EPICS BASE Doxygen Site
epicsMMIO.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2010 Brookhaven Science Associates, as Operator of
3 * Brookhaven National Laboratory.
4 * EPICS BASE is distributed subject to a Software License Agreement found
5 * in file LICENSE that is included with this distribution.
6 \*************************************************************************/
7 /*
8  * Author: Michael Davidsaver <mdavidsaver@bnl.gov>
9  */
10 
11 #ifndef EPICSMMIO_H
12 #define EPICSMMIO_H
13 
14 #include <epicsEndian.h>
15 #include <epicsTypes.h>
16 #include <compilerSpecific.h>
17 
18 #if defined(_ARCH_PPC) || defined(__PPC__) || defined(__PPC)
19 # include <libcpu/io.h>
20 
21 /*NOTE: All READ/WRITE operations have an implicit read or write barrier */
22 
23 # define ioread8(A) in_8((volatile epicsUInt8*)(A))
24 # define iowrite8(A,D) out_8((volatile epicsUInt8*)(A), D)
25 # define le_ioread16(A) in_le16((volatile epicsUInt16*)(A))
26 # define le_ioread32(A) in_le32((volatile epicsUInt32*)(A))
27 # define le_iowrite16(A,D) out_le16((volatile epicsUInt16*)(A), D)
28 # define le_iowrite32(A,D) out_le32((volatile epicsUInt32*)(A), D)
29 # define be_ioread16(A) in_be16((volatile epicsUInt16*)(A))
30 # define be_ioread32(A) in_be32((volatile epicsUInt32*)(A))
31 # define be_iowrite16(A,D) out_be16((volatile epicsUInt16*)(A), D)
32 # define be_iowrite32(A,D) out_be32((volatile epicsUInt32*)(A), D)
33 
34 # define rbarr() iobarrier_r()
35 # define wbarr() iobarrier_w()
36 # define rwbarr() iobarrier_rw()
37 
38 /* Define native operations */
39 # define nat_ioread16 be_ioread16
40 # define nat_ioread32 be_ioread32
41 # define nat_iowrite16 be_iowrite16
42 # define nat_iowrite32 be_iowrite32
43 
46 bswap16(epicsUInt16 value)
47 {
48  return (((epicsUInt16)(value) & 0x00ff) << 8) |
49  (((epicsUInt16)(value) & 0xff00) >> 8);
50 }
51 
54 bswap32(epicsUInt32 value)
55 {
56  return (((epicsUInt32)(value) & 0x000000ff) << 24) |
57  (((epicsUInt32)(value) & 0x0000ff00) << 8) |
58  (((epicsUInt32)(value) & 0x00ff0000) >> 8) |
59  (((epicsUInt32)(value) & 0xff000000) >> 24);
60 }
61 
62 #elif defined(i386) || defined(__i386__) || defined(__i386) || defined(__m68k__)
63 
64 /* X86 does not need special handling for read/write width.
65  *
66  * TODO: Memory barriers?
67  */
68 
69 #include "epicsMMIODef.h"
70 
71 #else
72 # warning I/O operations not defined for this RTEMS architecture
73 
74 #include "epicsMMIODef.h"
75 
76 #endif /* if defined PPC */
77 
78 #endif /* EPICSMMIO_H */
Definition: link.h:174
#define EPICS_ALWAYS_INLINE
unsigned short epicsUInt16
Definition: epicsTypes.h:41
unsigned int epicsUInt32
Definition: epicsTypes.h:43
Memory Mapped I/O.