]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/arch/arm/include/asm/jailhouse_hypercall.h
core/driver: Reintroduce a second hypercall argument
[jailhouse.git] / hypervisor / arch / arm / include / asm / jailhouse_hypercall.h
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2013
5  *
6  * Authors:
7  *  Jan Kiszka <jan.kiszka@siemens.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #define JAILHOUSE_BASE                  0xf0000000
14
15 #define JAILHOUSE_CALL_INS              ".arch_extension virt\n\t" \
16                                         "hvc #0x4a48"
17 #define JAILHOUSE_CALL_NUM_RESULT       "r0"
18 #define JAILHOUSE_CALL_ARG1             "r1"
19 #define JAILHOUSE_CALL_ARG2             "r2"
20
21 #ifndef __asmeq
22 #define __asmeq(x, y)  ".ifnc " x "," y " ; .err ; .endif\n\t"
23 #endif
24
25 #ifndef __ASSEMBLY__
26
27 static inline __u32 jailhouse_call(__u32 num)
28 {
29         register __u32 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
30
31         asm volatile(
32                 __asmeq(JAILHOUSE_CALL_NUM_RESULT, "%0")
33                 __asmeq(JAILHOUSE_CALL_NUM_RESULT, "%1")
34                 JAILHOUSE_CALL_INS
35                 : "=r" (num_result)
36                 : "r" (num_result)
37                 : "memory");
38         return num_result;
39 }
40
41 static inline __u32 jailhouse_call_arg1(__u32 num, __u32 arg1)
42 {
43         register __u32 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
44         register __u32 __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1;
45
46         asm volatile(
47                 __asmeq(JAILHOUSE_CALL_NUM_RESULT, "%0")
48                 __asmeq(JAILHOUSE_CALL_NUM_RESULT, "%1")
49                 __asmeq(JAILHOUSE_CALL_ARG1, "%2")
50                 JAILHOUSE_CALL_INS
51                 : "=r" (num_result)
52                 : "r" (num_result), "r" (__arg1)
53                 : "memory");
54         return num_result;
55 }
56
57 static inline __u32 jailhouse_call_arg2(__u32 num, __u32 arg1, __u32 arg2)
58 {
59         register __u32 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
60         register __u32 __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1;
61         register __u32 __arg2 asm(JAILHOUSE_CALL_ARG2) = arg2;
62
63         asm volatile(
64                 __asmeq(JAILHOUSE_CALL_NUM_RESULT, "%0")
65                 __asmeq(JAILHOUSE_CALL_NUM_RESULT, "%1")
66                 __asmeq(JAILHOUSE_CALL_ARG1, "%2")
67                 __asmeq(JAILHOUSE_CALL_ARG2, "%3")
68                 JAILHOUSE_CALL_INS
69                 : "=r" (num_result)
70                 : "r" (num_result), "r" (__arg1), "r" (__arg2)
71                 : "memory");
72         return num_result;
73 }
74
75 static inline void
76 jailhouse_send_msg_to_cell(struct jailhouse_comm_region *comm_region,
77                            __u32 msg)
78 {
79         comm_region->reply_from_cell = JAILHOUSE_MSG_NONE;
80         /* ensure reply was cleared before sending new message */
81         asm volatile("dmb ishst" : : : "memory");
82         comm_region->msg_to_cell = msg;
83 }
84
85 static inline void
86 jailhouse_send_reply_from_cell(struct jailhouse_comm_region *comm_region,
87                                __u32 reply)
88 {
89         comm_region->msg_to_cell = JAILHOUSE_MSG_NONE;
90         /* ensure message was cleared before sending reply */
91         asm volatile("dmb ishst" : : : "memory");
92         comm_region->reply_from_cell = reply;
93 }
94
95 #endif /* !__ASSEMBLY__ */