1/* 2 * Copyright 2017, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12 13#ifndef __LIBSEL4_SEL4_SEL4_ARCH_SYSCALLS_SYSCALL_H_ 14#define __LIBSEL4_SEL4_SEL4_ARCH_SYSCALLS_SYSCALL_H_ 15 16#include <autoconf.h> 17#include <sel4/arch/functions.h> 18#include <sel4/types.h> 19 20static inline void 21x64_sys_send(seL4_Word sys, seL4_Word dest, seL4_Word info, seL4_Word msg0, seL4_Word msg1, seL4_Word msg2, seL4_Word msg3) 22{ 23 register seL4_Word mr0 asm("r10") = msg0; 24 register seL4_Word mr1 asm("r8") = msg1; 25 register seL4_Word mr2 asm("r9") = msg2; 26 register seL4_Word mr3 asm("r15") = msg3; 27 28 asm volatile ( 29 "movq %%rsp, %%rbx \n" 30 "syscall \n" 31 "movq %%rbx, %%rsp \n" 32 : 33 : "d" (sys), 34 "D" (dest), 35 "S" (info), 36 "r" (mr0), 37 "r" (mr1), 38 "r" (mr2), 39 "r" (mr3) 40 : "%rcx", "%rbx", "r11" 41 ); 42} 43 44static inline void 45x64_sys_reply(seL4_Word sys, seL4_Word info, seL4_Word msg0, seL4_Word msg1, seL4_Word msg2, seL4_Word msg3) 46{ 47 register seL4_Word mr0 asm("r10") = msg0; 48 register seL4_Word mr1 asm("r8") = msg1; 49 register seL4_Word mr2 asm("r9") = msg2; 50 register seL4_Word mr3 asm("r15") = msg3; 51 52 asm volatile ( 53 "movq %%rsp, %%rbx \n" 54 "syscall \n" 55 "movq %%rbx, %%rsp \n" 56 : 57 : "d" (sys), 58 "S" (info), 59 "r" (mr0), 60 "r" (mr1), 61 "r" (mr2), 62 "r" (mr3) 63 : "%rbx", "%rcx", "%r11" 64 ); 65} 66 67static inline void 68x64_sys_send_null(seL4_Word sys, seL4_Word dest, seL4_Word info) 69{ 70 asm volatile ( 71 "movq %%rsp, %%rbx \n" 72 "syscall \n" 73 "movq %%rbx, %%rsp \n" 74 : 75 : "d" (sys), 76 "D" (dest), 77 "S" (info) 78 : "%rcx", "%rbx", "%r11" 79 ); 80} 81 82static inline void 83x64_sys_recv(seL4_Word sys, seL4_Word src, seL4_Word *out_badge, seL4_Word *out_info, seL4_Word *out_mr0, seL4_Word *out_mr1, seL4_Word *out_mr2, seL4_Word *out_mr3) 84{ 85 register seL4_Word mr0 asm("r10"); 86 register seL4_Word mr1 asm("r8"); 87 register seL4_Word mr2 asm("r9"); 88 register seL4_Word mr3 asm("r15"); 89 90 asm volatile ( 91 "movq %%rsp, %%rbx \n" 92 "syscall \n" 93 "movq %%rbx, %%rsp \n" 94 : "=D" (*out_badge), 95 "=S" (*out_info), 96 "=r" (mr0), 97 "=r" (mr1), 98 "=r" (mr2), 99 "=r" (mr3) 100 : "d" (sys), 101 "D" (src) 102 : "%rcx", "%rbx", "r11", "memory" 103 ); 104 *out_mr0 = mr0; 105 *out_mr1 = mr1; 106 *out_mr2 = mr2; 107 *out_mr3 = mr3; 108} 109 110static inline void 111x64_sys_send_recv(seL4_Word sys, seL4_Word dest, seL4_Word *out_dest, seL4_Word info, seL4_Word *out_info, seL4_Word *in_out_mr0, seL4_Word *in_out_mr1, seL4_Word *in_out_mr2, seL4_Word *in_out_mr3) 112{ 113 register seL4_Word mr0 asm("r10") = *in_out_mr0; 114 register seL4_Word mr1 asm("r8") = *in_out_mr1; 115 register seL4_Word mr2 asm("r9") = *in_out_mr2; 116 register seL4_Word mr3 asm("r15") = *in_out_mr3; 117 118 asm volatile ( 119 "movq %%rsp, %%rbx \n" 120 "syscall \n" 121 "movq %%rbx, %%rsp \n" 122 : "=S" (*out_info), 123 "=r" (mr0), 124 "=r" (mr1), 125 "=r" (mr2), 126 "=r" (mr3), 127 "=D" (*out_dest) 128 : "d" (sys), 129 "D" (dest), 130 "S" (info), 131 "r" (mr0), 132 "r" (mr1), 133 "r" (mr2), 134 "r" (mr3) 135 : "%rcx", "%rbx", "r11", "memory" 136 ); 137 *in_out_mr0 = mr0; 138 *in_out_mr1 = mr1; 139 *in_out_mr2 = mr2; 140 *in_out_mr3 = mr3; 141} 142 143static inline void 144x64_sys_null(seL4_Word sys) 145{ 146 asm volatile ( 147 "movq %%rsp, %%rbx \n" 148 "syscall \n" 149 "movq %%rbx, %%rsp \n" 150 : 151 : "d" (sys) 152 : "%rbx", "%rcx", "%rsi", "%rdi", "%r11" 153 ); 154} 155 156#endif /* __LIBSEL4_SEL4_SEL4_ARCH_SYSCALLS_SYSCALL_H_ */ 157