xref: /dragonos-dsc/src/macros.rs (revision 943c158aa5f60c95fd655e2e1c10de1f7f3fb2f2)
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(
27                 ::dsc::nr::$nr) );
28 
29     ($nr:ident, $a1:expr)
30         => ( ::dsc::syscall1(
31                 ::dsc::nr::$nr,
32                 $a1 as usize) );
33 
34     ($nr:ident, $a1:expr, $a2:expr)
35         => ( ::dsc::syscall2(
36                 ::dsc::nr::$nr,
37                 $a1 as usize, $a2 as usize) );
38 
39     ($nr:ident, $a1:expr, $a2:expr, $a3:expr)
40         => ( ::dsc::syscall3(
41                 ::dsc::nr::$nr,
42                 $a1 as usize, $a2 as usize, $a3 as usize) );
43 
44     ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr)
45         => ( ::dsc::syscall4(
46                 ::dsc::nr::$nr,
47                 $a1 as usize, $a2 as usize, $a3 as usize,
48                 $a4 as usize) );
49 
50     ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr)
51         => ( ::dsc::syscall5(
52                 ::dsc::nr::$nr,
53                 $a1 as usize, $a2 as usize, $a3 as usize,
54                 $a4 as usize, $a5 as usize) );
55 
56     ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr)
57         => ( ::dsc::syscall6(
58                 ::dsc::nr::$nr,
59                 $a1 as usize, $a2 as usize, $a3 as usize,
60                 $a4 as usize, $a5 as usize, $a6 as usize) );
61 
62     ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr, $a7:expr)
63         => ( ::dsc::syscall7(
64                 ::dsc::nr::$nr,
65                 $a1 as usize, $a2 as usize, $a3 as usize,
66                 $a4 as usize, $a5 as usize, $a6 as usize,
67                 $a7 as usize) );
68 }