sel4_sys/syscalls/helpers/arch/
aarch64.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//
// Copyright 2023, Colias Group, LLC
//
// SPDX-License-Identifier: BSD-2-Clause
//

use core::arch::asm;
use core::ffi::c_int;

use sel4_config::sel4_cfg;

use super::sys_id_to_word;
use crate::{seL4_MessageInfo, seL4_Word};

pub fn sys_send(
    sys: c_int,
    dest: seL4_Word,
    info_arg: seL4_MessageInfo,
    mr0: seL4_Word,
    mr1: seL4_Word,
    mr2: seL4_Word,
    mr3: seL4_Word,
) {
    unsafe {
        asm!("svc 0",
            in("x7") sys_id_to_word(sys),
            in("x0") dest,
            in("x1") info_arg.into_word(),
            in("x2") mr0,
            in("x3") mr1,
            in("x4") mr2,
            in("x5") mr3,
        );
    }
}

#[sel4_cfg(not(KERNEL_MCS))]
pub fn sys_reply(
    sys: c_int,
    info_arg: seL4_MessageInfo,
    mr0: seL4_Word,
    mr1: seL4_Word,
    mr2: seL4_Word,
    mr3: seL4_Word,
) {
    unsafe {
        asm!("svc 0",
            in("x7") sys_id_to_word(sys),
            in("x1") info_arg.into_word(),
            in("x2") mr0,
            in("x3") mr1,
            in("x4") mr2,
            in("x5") mr3,
        );
    }
}

pub fn sys_send_null(sys: c_int, src: seL4_Word, info_arg: seL4_MessageInfo) {
    unsafe {
        asm!("svc 0",
            in("x7") sys_id_to_word(sys),
            in("x0") src,
            in("x1") info_arg.into_word(),
        );
    }
}

pub fn sys_recv(
    sys: c_int,
    src: seL4_Word,
    out_mr0: &mut seL4_Word,
    out_mr1: &mut seL4_Word,
    out_mr2: &mut seL4_Word,
    out_mr3: &mut seL4_Word,
    reply: seL4_Word,
) -> (seL4_MessageInfo, seL4_Word) {
    let out_info: seL4_Word;
    let out_badge: seL4_Word;
    unsafe {
        asm!("svc 0",
            in("x7") sys_id_to_word(sys),
            inout("x0") src => out_badge,
            out("x1") out_info,
            out("x2") *out_mr0,
            out("x3") *out_mr1,
            out("x4") *out_mr2,
            out("x5") *out_mr3,
            in("x6") reply,
        );
    }
    (seL4_MessageInfo::from_word(out_info), out_badge)
}

pub fn sys_send_recv(
    sys: c_int,
    dest: seL4_Word,
    info_arg: seL4_MessageInfo,
    in_out_mr0: &mut seL4_Word,
    in_out_mr1: &mut seL4_Word,
    in_out_mr2: &mut seL4_Word,
    in_out_mr3: &mut seL4_Word,
    reply: seL4_Word,
) -> (seL4_MessageInfo, seL4_Word) {
    let out_info: seL4_Word;
    let out_badge: seL4_Word;
    unsafe {
        asm!("svc 0",
            in("x7") sys_id_to_word(sys),
            inout("x0") dest => out_badge,
            inout("x1") info_arg.into_word() => out_info,
            inout("x2") *in_out_mr0,
            inout("x3") *in_out_mr1,
            inout("x4") *in_out_mr2,
            inout("x5") *in_out_mr3,
            in("x6") reply,
        );
    }
    (seL4_MessageInfo::from_word(out_info), out_badge)
}

#[sel4_cfg(KERNEL_MCS)]
pub fn sys_nb_send_recv(
    sys: c_int,
    dest: seL4_Word,
    src: seL4_Word,
    info_arg: seL4_MessageInfo,
    in_out_mr0: &mut seL4_Word,
    in_out_mr1: &mut seL4_Word,
    in_out_mr2: &mut seL4_Word,
    in_out_mr3: &mut seL4_Word,
    reply: seL4_Word,
) -> (seL4_MessageInfo, seL4_Word) {
    let out_info: seL4_Word;
    let out_badge: seL4_Word;
    unsafe {
        asm!("svc 0",
            in("x7") sys_id_to_word(sys),
            inout("x0") src => out_badge,
            inout("x1") info_arg.into_word() => out_info,
            inout("x2") *in_out_mr0,
            inout("x3") *in_out_mr1,
            inout("x4") *in_out_mr2,
            inout("x5") *in_out_mr3,
            in("x6") reply,
            in("x8") dest,
        );
    }
    (seL4_MessageInfo::from_word(out_info), out_badge)
}

pub fn sys_null(sys: c_int) {
    unsafe {
        asm!("svc 0",
            in("x7") sys_id_to_word(sys),
        );
    }
}