]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/arch/arm/include/asm/jailhouse_hypercall.h
core/driver: Remove multi-arg support for hypercalls
[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_ARG              "r1"
19
20 #ifndef __asmeq
21 #define __asmeq(x, y)  ".ifnc " x "," y " ; .err ; .endif\n\t"
22 #endif
23
24 #ifndef __ASSEMBLY__
25
26 static inline __u32 jailhouse_call(__u32 num)
27 {
28         register __u32 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
29
30         asm volatile(
31                 __asmeq(JAILHOUSE_CALL_NUM_RESULT, "%0")
32                 __asmeq(JAILHOUSE_CALL_NUM_RESULT, "%1")
33                 JAILHOUSE_CALL_INS
34                 : "=r" (num_result)
35                 : "r" (num_result)
36                 : "memory");
37         return num_result;
38 }
39
40 static inline __u32 jailhouse_call_arg(__u32 num, __u32 arg)
41 {
42         register __u32 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
43         register __u32 __arg asm(JAILHOUSE_CALL_ARG) = arg;
44
45         asm volatile(
46                 __asmeq(JAILHOUSE_CALL_NUM_RESULT, "%0")
47                 __asmeq(JAILHOUSE_CALL_NUM_RESULT, "%1")
48                 __asmeq(JAILHOUSE_CALL_ARG, "%2")
49                 JAILHOUSE_CALL_INS
50                 : "=r" (num_result)
51                 : "r" (num_result), "r" (__arg)
52                 : "memory");
53         return num_result;
54 }
55
56 static inline void
57 jailhouse_send_msg_to_cell(struct jailhouse_comm_region *comm_region,
58                            __u32 msg)
59 {
60         comm_region->reply_from_cell = JAILHOUSE_MSG_NONE;
61         /* ensure reply was cleared before sending new message */
62         asm volatile("dmb ishst" : : : "memory");
63         comm_region->msg_to_cell = msg;
64 }
65
66 static inline void
67 jailhouse_send_reply_from_cell(struct jailhouse_comm_region *comm_region,
68                                __u32 reply)
69 {
70         comm_region->msg_to_cell = JAILHOUSE_MSG_NONE;
71         /* ensure message was cleared before sending reply */
72         asm volatile("dmb ishst" : : : "memory");
73         comm_region->reply_from_cell = reply;
74 }
75
76 #endif /* !__ASSEMBLY__ */