MOS Source Code
Loading...
Searching...
No Matches
platform_syscall.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include <mos/mos_global.h>
6#include <mos/types.h>
7
8enum
9{
11};
12
13#define do_syscall(...) __asm__ volatile("ecall" : "=r"(a0) : __VA_ARGS__ : "memory")
14
16{
17 register long a7 __asm__("a7") = n;
18 register long a0 __asm__("a0");
19 do_syscall("r"(a7));
20 return a0;
21}
22
24{
25 register long a7 __asm__("a7") = n;
26 register long a0 __asm__("a0") = a;
27 do_syscall("r"(a0), "r"(a7));
28 return a0;
29}
30
31should_inline reg_t platform_syscall2(long n, long a, long b)
32{
33 register long a7 __asm__("a7") = n;
34 register long a0 __asm__("a0") = a;
35 register long a1 __asm__("a1") = b;
36 do_syscall("r"(a0), "r"(a7), "r"(a1));
37 return a0;
38}
39
40should_inline reg_t platform_syscall3(long n, long a, long b, long c)
41{
42 register long a7 __asm__("a7") = n;
43 register long a0 __asm__("a0") = a;
44 register long a1 __asm__("a1") = b;
45 register long a2 __asm__("a2") = c;
46 do_syscall("r"(a0), "r"(a7), "r"(a1), "r"(a2));
47 return a0;
48}
49
50should_inline reg_t platform_syscall4(long n, long a, long b, long c, long d)
51{
52 register long a7 __asm__("a7") = n;
53 register long a0 __asm__("a0") = a;
54 register long a1 __asm__("a1") = b;
55 register long a2 __asm__("a2") = c;
56 register long a3 __asm__("a3") = d;
57 do_syscall("r"(a0), "r"(a7), "r"(a1), "r"(a2), "r"(a3));
58 return a0;
59}
60
61should_inline reg_t platform_syscall5(long n, long a, long b, long c, long d, long e)
62{
63 register long a7 __asm__("a7") = n;
64 register long a0 __asm__("a0") = a;
65 register long a1 __asm__("a1") = b;
66 register long a2 __asm__("a2") = c;
67 register long a3 __asm__("a3") = d;
68 register long a4 __asm__("a4") = e;
69 do_syscall("r"(a0), "r"(a7), "r"(a1), "r"(a2), "r"(a3), "r"(a4));
70 return a0;
71}
72
73should_inline reg_t platform_syscall6(long n, long a, long b, long c, long d, long e, long f)
74{
75 register long a7 __asm__("a7") = n;
76 register long a0 __asm__("a0") = a;
77 register long a1 __asm__("a1") = b;
78 register long a2 __asm__("a2") = c;
79 register long a3 __asm__("a3") = d;
80 register long a4 __asm__("a4") = e;
81 register long a5 __asm__("a5") = f;
82 do_syscall("r"(a0), "r"(a7), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5));
83 return a0;
84}
85
86#undef do_syscall
#define should_inline
Definition mos_global.h:37
@ RISCV64_SYSCALL_SET_TP
should_inline reg_t platform_syscall2(long n, long a, long b)
should_inline reg_t platform_syscall0(long n)
should_inline reg_t platform_syscall1(long n, long a)
#define do_syscall(...)
should_inline reg_t platform_syscall3(long n, long a, long b, long c)
uintn reg_t
Definition types.h:51
should_inline reg_t platform_syscall5(reg_t number, reg_t arg1, reg_t arg2, reg_t arg3, reg_t arg4, reg_t arg5)
should_inline reg_t platform_syscall6(reg_t number, reg_t arg1, reg_t arg2, reg_t arg3, reg_t arg4, reg_t arg5, reg_t arg6)
should_inline reg_t platform_syscall4(reg_t number, reg_t arg1, reg_t arg2, reg_t arg3, reg_t arg4)