1 use core::arch::asm; 2 3 pub mod nr; 4 5 #[inline(always)] 6 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)] 18 pub unsafe fn syscall1(mut n: usize, a1: usize) -> usize { 19 asm!( 20 "int 0x80", 21 inout("rax") n, 22 in("r8") a1, 23 out("rcx") _, 24 out("r11") _, 25 options(nostack), 26 ); 27 n 28 } 29 30 #[inline(always)] 31 pub unsafe fn syscall2(mut n: usize, a1: usize, a2: usize) -> usize { 32 asm!( 33 "int 0x80", 34 inout("rax") n, 35 in("r8") a1, 36 in("r9") a2, 37 out("rcx") _, 38 out("r11") _, 39 options(nostack), 40 ); 41 n 42 } 43 44 #[inline(always)] 45 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("r8") a1, 50 in("r9") a2, 51 in("r10") a3, 52 out("rcx") _, 53 out("r11") _, 54 options(nostack), 55 ); 56 n 57 } 58 59 #[inline(always)] 60 pub unsafe fn syscall4(mut n: usize, 61 a1: usize, 62 a2: usize, 63 a3: usize, 64 a4: usize) 65 -> usize { 66 asm!( 67 "int 0x80", 68 inout("rax") n, 69 in("r8") a1, 70 in("r9") a2, 71 in("r10") a3, 72 in("r11") a4, 73 out("rcx") _, 74 options(nostack), 75 ); 76 n 77 } 78 79 #[inline(always)] 80 pub unsafe fn syscall5(mut n: usize, 81 a1: usize, 82 a2: usize, 83 a3: usize, 84 a4: usize, 85 a5: usize) 86 -> usize { 87 asm!( 88 "int 0x80", 89 inout("rax") n, 90 in("r8") a1, 91 in("r9") a2, 92 in("r10") a3, 93 in("r11") a4, 94 in("r12") a5, 95 out("rcx") _, 96 options(nostack), 97 ); 98 n 99 } 100 101 #[inline(always)] 102 pub unsafe fn syscall6(mut n: usize, 103 a1: usize, 104 a2: usize, 105 a3: usize, 106 a4: usize, 107 a5: usize, 108 a6: usize) 109 -> usize { 110 asm!( 111 "int 0x80", 112 inout("rax") n, 113 in("r8") a1, 114 in("r9") a2, 115 in("r10") a3, 116 in("r11") a4, 117 in("r12") a5, 118 in("r13") a6, 119 out("rcx") _, 120 options(nostack), 121 ); 122 n 123 } 124 125 #[inline(always)] 126 pub unsafe fn syscall7(mut n: usize, 127 a1: usize, 128 a2: usize, 129 a3: usize, 130 a4: usize, 131 a5: usize, 132 a6: usize, 133 a7: usize) 134 -> usize { 135 asm!( 136 "int 0x80", 137 inout("rax") n, 138 in("r8") a1, 139 in("r9") a2, 140 in("r10") a3, 141 in("r11") a4, 142 in("r12") a5, 143 in("r13") a6, 144 in("r14") a7, 145 out("rcx") _, 146 options(nostack), 147 ); 148 n 149 }