Debian Codegraph @

modules/libcom/src/osi/os/RTEMS/epicsMMIO.h

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