summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libcpu/sparc/include/libcpu/byteorder.h
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2012-02-08 15:57:03 +0100
committerGedare Bloom <gedare@rtems.org>2012-03-21 12:35:47 -0400
commit80d01b3cf8e4bb2998f1e8e99ed5b5d64ac8d23e (patch)
tree547fd0c47b52041da88d89c0d099659f8e1aa693 /c/src/lib/libcpu/sparc/include/libcpu/byteorder.h
parentPR2041: sparc64: vector number not included in CPU_Interrupt_frame (diff)
downloadrtems-80d01b3cf8e4bb2998f1e8e99ed5b5d64ac8d23e.tar.bz2
SPARC: added libcpu lowlevel access and byteorder routines/definitions
The low level routines can be used in different occasions, it will be required when accessing PCI. Note the difference between byteorder.h (inlined functions) and access.S where the functions will be declared in the library archive librtemscpu.a. Function names starting with _ are in library and can be referenced by function pointers. Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
Diffstat (limited to '')
-rw-r--r--c/src/lib/libcpu/sparc/include/libcpu/byteorder.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/c/src/lib/libcpu/sparc/include/libcpu/byteorder.h b/c/src/lib/libcpu/sparc/include/libcpu/byteorder.h
new file mode 100644
index 0000000000..d626f28068
--- /dev/null
+++ b/c/src/lib/libcpu/sparc/include/libcpu/byteorder.h
@@ -0,0 +1,66 @@
+/*
+ * byteorder.h - Endian conversion for SPARC. SPARC is big endian only.
+ *
+ * COPYRIGHT (c) 2011
+ * Aeroflex Gaisler.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifndef _LIBCPU_BYTEORDER_H
+#define _LIBCPU_BYTEORDER_H
+
+#include <rtems/system.h>
+#include <rtems/score/cpu.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+RTEMS_INLINE_ROUTINE uint16_t ld_le16(volatile uint16_t *addr)
+{
+ return CPU_swap_u16(*addr);
+}
+
+RTEMS_INLINE_ROUTINE void st_le16(volatile uint16_t *addr, uint16_t val)
+{
+ *addr = CPU_swap_u16(val);
+}
+
+RTEMS_INLINE_ROUTINE uint32_t ld_le32(volatile uint32_t *addr)
+{
+ return CPU_swap_u32(*addr);
+}
+
+RTEMS_INLINE_ROUTINE void st_le32(volatile uint32_t *addr, uint32_t val)
+{
+ *addr = CPU_swap_u32(val);
+}
+
+RTEMS_INLINE_ROUTINE uint16_t ld_be16(volatile uint16_t *addr)
+{
+ return *addr;
+}
+
+RTEMS_INLINE_ROUTINE void st_be16(volatile uint16_t *addr, uint16_t val)
+{
+ *addr = val;
+}
+
+RTEMS_INLINE_ROUTINE uint32_t ld_be32(volatile uint32_t *addr)
+{
+ return *addr;
+}
+
+RTEMS_INLINE_ROUTINE void st_be32(volatile uint32_t *addr, uint32_t val)
+{
+ *addr = val;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif