1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT 2 // file at the top-level directory of this distribution and at 3 // http://rust-lang.org/COPYRIGHT. 4 // 5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 8 // option. This file may not be copied, modified, or distributed 9 // except according to those terms. 10 11 /// The macro to invoke a syscall. 12 /// 13 /// # Examples 14 /// 15 /// The following code will print `Hello, world!` to the screen with black background and white foreground. 16 /// ``` 17 /// syscall!(SYS_PUTSTRING, "Hello, world!\n", 0x00ffffff, 0x00000000); 18 /// ``` 19 /// 20 /// # Note 21 /// 22 /// This macro is not meant to be used directly, but rather as a dependency for other crates. 23 #[macro_export] 24 macro_rules! syscall { 25 ($nr:ident) => { 26 ::dsc::syscall0(::dsc::nr::$nr) 27 }; 28 29 ($nr:ident, $a1:expr) => { 30 ::dsc::syscall1(::dsc::nr::$nr, $a1 as usize) 31 }; 32 33 ($nr:ident, $a1:expr, $a2:expr) => { 34 ::dsc::syscall2(::dsc::nr::$nr, $a1 as usize, $a2 as usize) 35 }; 36 37 ($nr:ident, $a1:expr, $a2:expr, $a3:expr) => { 38 ::dsc::syscall3(::dsc::nr::$nr, $a1 as usize, $a2 as usize, $a3 as usize) 39 }; 40 41 ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr) => { 42 ::dsc::syscall4( 43 ::dsc::nr::$nr, 44 $a1 as usize, 45 $a2 as usize, 46 $a3 as usize, 47 $a4 as usize, 48 ) 49 }; 50 51 ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr) => { 52 ::dsc::syscall5( 53 ::dsc::nr::$nr, 54 $a1 as usize, 55 $a2 as usize, 56 $a3 as usize, 57 $a4 as usize, 58 $a5 as usize, 59 ) 60 }; 61 62 ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr) => { 63 ::dsc::syscall6( 64 ::dsc::nr::$nr, 65 $a1 as usize, 66 $a2 as usize, 67 $a3 as usize, 68 $a4 as usize, 69 $a5 as usize, 70 $a6 as usize, 71 ) 72 }; 73 74 ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr, $a7:expr) => { 75 ::dsc::syscall7( 76 ::dsc::nr::$nr, 77 $a1 as usize, 78 $a2 as usize, 79 $a3 as usize, 80 $a4 as usize, 81 $a5 as usize, 82 $a6 as usize, 83 $a7 as usize, 84 ) 85 }; 86 } 87