From: Antonios Motakis <antonios.mota...@huawei.com>

Add the jailhouse_hypercall.h header file for AArch64. We will need
this also from the Linux side, in order to load Jailhouse in memory
and to issue hypercalls to an already loaded instance of the
hypervisor.

Signed-off-by: Antonios Motakis <antonios.mota...@huawei.com>
Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>
---
 .../arch/arm64/include/asm/jailhouse_hypercall.h   | 91 ++++++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100644 hypervisor/arch/arm64/include/asm/jailhouse_hypercall.h

diff --git a/hypervisor/arch/arm64/include/asm/jailhouse_hypercall.h 
b/hypervisor/arch/arm64/include/asm/jailhouse_hypercall.h
new file mode 100644
index 0000000..fb12d23
--- /dev/null
+++ b/hypervisor/arch/arm64/include/asm/jailhouse_hypercall.h
@@ -0,0 +1,91 @@
+/*
+ * Jailhouse AArch64 support
+ *
+ * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH
+ *
+ * Authors:
+ *  Antonios Motakis <antonios.mota...@huawei.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#include <jailhouse/config.h>
+
+#define JAILHOUSE_CALL_INS             "hvc #0x4a48"
+#define JAILHOUSE_CALL_NUM_RESULT      "x0"
+#define JAILHOUSE_CALL_ARG1            "x1"
+#define JAILHOUSE_CALL_ARG2            "x2"
+
+/* CPU statistics */
+#define JAILHOUSE_CPU_STAT_VMEXITS_MAINTENANCE JAILHOUSE_GENERIC_CPU_STATS
+#define JAILHOUSE_CPU_STAT_VMEXITS_VIRQ                
JAILHOUSE_GENERIC_CPU_STATS + 1
+#define JAILHOUSE_CPU_STAT_VMEXITS_VSGI                
JAILHOUSE_GENERIC_CPU_STATS + 2
+#define JAILHOUSE_NUM_CPU_STATS                        
JAILHOUSE_GENERIC_CPU_STATS + 3
+
+#ifndef __ASSEMBLY__
+
+struct jailhouse_comm_region {
+       COMM_REGION_GENERIC_HEADER;
+};
+
+static inline __u64 jailhouse_call(__u64 num)
+{
+       register __u64 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
+
+       asm volatile(
+               JAILHOUSE_CALL_INS
+               : "=r" (num_result)
+               : "r" (num_result)
+               : "memory");
+       return num_result;
+}
+
+static inline __u64 jailhouse_call_arg1(__u64 num, __u64 arg1)
+{
+       register __u64 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
+       register __u64 __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1;
+
+       asm volatile(
+               JAILHOUSE_CALL_INS
+               : "=r" (num_result)
+               : "r" (num_result), "r" (__arg1)
+               : "memory");
+       return num_result;
+}
+
+static inline __u64 jailhouse_call_arg2(__u64 num, __u64 arg1, __u64 arg2)
+{
+       register __u64 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
+       register __u64 __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1;
+       register __u64 __arg2 asm(JAILHOUSE_CALL_ARG2) = arg2;
+
+       asm volatile(
+               JAILHOUSE_CALL_INS
+               : "=r" (num_result)
+               : "r" (num_result), "r" (__arg1), "r" (__arg2)
+               : "memory");
+       return num_result;
+}
+
+static inline void
+jailhouse_send_msg_to_cell(struct jailhouse_comm_region *comm_region,
+                          __u64 msg)
+{
+       comm_region->reply_from_cell = JAILHOUSE_MSG_NONE;
+       /* ensure reply was cleared before sending new message */
+       asm volatile("dmb ishst" : : : "memory");
+       comm_region->msg_to_cell = msg;
+}
+
+static inline void
+jailhouse_send_reply_from_cell(struct jailhouse_comm_region *comm_region,
+                              __u64 reply)
+{
+       comm_region->msg_to_cell = JAILHOUSE_MSG_NONE;
+       /* ensure message was cleared before sending reply */
+       asm volatile("dmb ishst" : : : "memory");
+       comm_region->reply_from_cell = reply;
+}
+
+#endif /* !__ASSEMBLY__ */
-- 
2.1.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 jailhouse-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to