From: Peng Fan <[email protected]>

Move mmio helpers to mmio.h to prepare mmio.h be moved out
to libbaremetal

Signed-off-by: Peng Fan <[email protected]>
---
 inmates/lib/arm-common/include/inmate.h | 49 +-----------------
 inmates/lib/arm-common/include/mmio.h   | 88 +++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 47 deletions(-)
 create mode 100644 inmates/lib/arm-common/include/mmio.h

diff --git a/inmates/lib/arm-common/include/inmate.h 
b/inmates/lib/arm-common/include/inmate.h
index ab5681d6..76d3ace3 100644
--- a/inmates/lib/arm-common/include/inmate.h
+++ b/inmates/lib/arm-common/include/inmate.h
@@ -39,56 +39,11 @@
 #ifndef _JAILHOUSE_INMATE_H
 #define _JAILHOUSE_INMATE_H
 
+#include <mmio.h>
+
 #define COMM_REGION_BASE       0x80000000
 #define PAGE_SIZE      (4 * 1024ULL)
 
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-static inline u8 mmio_read8(void *address)
-{
-       return *(volatile u8 *)address;
-}
-
-static inline void mmio_write8(void *address, u8 value)
-{
-       *(volatile u8 *)address = value;
-}
-
-static inline u16 mmio_read16(void *address)
-{
-       return *(volatile u16 *)address;
-}
-
-static inline void mmio_write16(void *address, u16 value)
-{
-       *(volatile u16 *)address = value;
-}
-
-static inline u32 mmio_read32(void *address)
-{
-       return *(volatile u32 *)address;
-}
-
-static inline void mmio_write32(void *address, u32 value)
-{
-       *(volatile u32 *)address = value;
-}
-
-static inline u64 mmio_read64(void *address)
-{
-       return *(volatile u64 *)address;
-}
-
 static inline void __attribute__((noreturn)) halt(void)
 {
        while (1)
diff --git a/inmates/lib/arm-common/include/mmio.h 
b/inmates/lib/arm-common/include/mmio.h
new file mode 100644
index 00000000..df7a2312
--- /dev/null
+++ b/inmates/lib/arm-common/include/mmio.h
@@ -0,0 +1,88 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright (c) ARM Limited, 2014
+ *
+ * Authors:
+ *  Jean-Philippe Brucker <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ * Alternatively, you can use or redistribute this file under the following
+ * BSD license:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _JAILHOUSE_MMIO_H
+#define _JAILHOUSE_MMIO_H
+
+typedef signed char s8;
+typedef unsigned char u8;
+
+typedef signed short s16;
+typedef unsigned short u16;
+
+typedef signed int s32;
+typedef unsigned int u32;
+
+typedef signed long long s64;
+typedef unsigned long long u64;
+
+static inline u8 mmio_read8(void *address)
+{
+       return *(volatile u8 *)address;
+}
+
+static inline void mmio_write8(void *address, u8 value)
+{
+       *(volatile u8 *)address = value;
+}
+
+static inline u16 mmio_read16(void *address)
+{
+       return *(volatile u16 *)address;
+}
+
+static inline void mmio_write16(void *address, u16 value)
+{
+       *(volatile u16 *)address = value;
+}
+
+static inline u32 mmio_read32(void *address)
+{
+       return *(volatile u32 *)address;
+}
+
+static inline void mmio_write32(void *address, u32 value)
+{
+       *(volatile u32 *)address = value;
+}
+
+static inline u64 mmio_read64(void *address)
+{
+       return *(volatile u64 *)address;
+}
+#endif
-- 
2.16.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/20200807030632.28259-2-peng.fan%40nxp.com.

Reply via email to