xref: /dragonos-dsc/src/platform/x86_64/mod.rs (revision ee7a2b93994c37ce67f47077027166332f204bac)
1 use core::arch::asm;
2 
3 pub mod nr;
4 
5 #[inline(always)]
syscall0(mut n: usize) -> usize6 pub unsafe fn syscall0(mut n: usize) -> usize {
7     asm!(
8         "int 0x80",
9         inout("rax") n,
10         out("rcx") _,
11         out("r11") _,
12         options(nostack),
13     );
14     n
15 }
16 
17 #[inline(always)]
syscall1(mut n: usize, a1: usize) -> usize18 pub unsafe fn syscall1(mut n: usize, a1: usize) -> usize {
19     asm!(
20         "int 0x80",
21         inout("rax") n,
22         in("rdi") a1,
23         out("rcx") _,
24         out("r11") _,
25         options(nostack),
26     );
27     n
28 }
29 
30 #[inline(always)]
syscall2(mut n: usize, a1: usize, a2: usize) -> usize31 pub unsafe fn syscall2(mut n: usize, a1: usize, a2: usize) -> usize {
32     asm!(
33         "int 0x80",
34         inout("rax") n,
35         in("rdi") a1,
36         in("rsi") a2,
37         out("rcx") _,
38         out("r11") _,
39         options(nostack),
40     );
41     n
42 }
43 
44 #[inline(always)]
syscall3(mut n: usize, a1: usize, a2: usize, a3: usize) -> usize45 pub unsafe fn syscall3(mut n: usize, a1: usize, a2: usize, a3: usize) -> usize {
46     asm!(
47         "int 0x80",
48         inout("rax") n,
49         in("rdi") a1,
50         in("rsi") a2,
51         in("rdx") a3,
52         out("rcx") _,
53         out("r11") _,
54         options(nostack),
55     );
56     n
57 }
58 
59 #[inline(always)]
syscall4(mut n: usize, a1: usize, a2: usize, a3: usize, a4: usize) -> usize60 pub unsafe fn syscall4(mut n: usize, a1: usize, a2: usize, a3: usize, a4: usize) -> usize {
61     asm!(
62         "int 0x80",
63         inout("rax") n,
64         in("rdi") a1,
65         in("rsi") a2,
66         in("rdx") a3,
67         in("r10") a4,
68         out("rcx") _,
69         out("r11") _,
70         options(nostack),
71     );
72     n
73 }
74 
75 #[inline(always)]
syscall5( mut n: usize, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize, ) -> usize76 pub unsafe fn syscall5(
77     mut n: usize,
78     a1: usize,
79     a2: usize,
80     a3: usize,
81     a4: usize,
82     a5: usize,
83 ) -> usize {
84     asm!(
85         "int 0x80",
86         inout("rax") n,
87         in("rdi") a1,
88         in("rsi") a2,
89         in("rdx") a3,
90         in("r10") a4,
91         in("r8") a5,
92         out("rcx") _,
93         out("r11") _,
94         options(nostack),
95     );
96     n
97 }
98 
99 #[inline(always)]
syscall6( mut n: usize, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize, a6: usize, ) -> usize100 pub unsafe fn syscall6(
101     mut n: usize,
102     a1: usize,
103     a2: usize,
104     a3: usize,
105     a4: usize,
106     a5: usize,
107     a6: usize,
108 ) -> usize {
109     asm!(
110         "int 0x80",
111         inout("rax") n,
112         in("rdi") a1,
113         in("rsi") a2,
114         in("rdx") a3,
115         in("r10") a4,
116         in("r8") a5,
117         in("r9") a6,
118         out("rcx") _,
119         out("r11") _,
120         options(nostack),
121     );
122     n
123 }
124