-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crates/sel4/sys: Add support for aarch32
- Loading branch information
Showing
11 changed files
with
297 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
use crate::bf::*; | ||
use crate::c::*; | ||
|
||
use sel4_config::sel4_cfg_match; | ||
|
||
impl seL4_Fault { | ||
pub(crate) fn arch_get_with(label: seL4_Word, length: seL4_Word, f: impl Fn(core::ffi::c_ulong) -> seL4_Word) -> Option<Self> { | ||
Some({ | ||
#[sel4_cfg_match] | ||
match label { | ||
seL4_Fault_tag::seL4_Fault_UnknownSyscall => { | ||
assert!(length == seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_Length); | ||
seL4_Fault_UnknownSyscall_Unpacked { | ||
R0: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_R0), | ||
R1: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_R1), | ||
R2: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_R2), | ||
R3: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_R3), | ||
R4: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_R4), | ||
R5: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_R5), | ||
R6: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_R6), | ||
R7: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_R7), | ||
FaultIP: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_FaultIP), | ||
SP: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_SP), | ||
LR: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_LR), | ||
CPSR: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_CPSR), | ||
Syscall: f(seL4_UnknownSyscall_Msg::seL4_UnknownSyscall_Syscall), | ||
} | ||
.unsplay() | ||
} | ||
seL4_Fault_tag::seL4_Fault_UserException => { | ||
assert!(length == seL4_UserException_Msg::seL4_UserException_Length); | ||
seL4_Fault_UserException_Unpacked { | ||
FaultIP: f(seL4_UserException_Msg::seL4_UserException_FaultIP), | ||
Stack: f(seL4_UserException_Msg::seL4_UserException_SP), | ||
CPSR: f(seL4_UserException_Msg::seL4_UserException_CPSR), | ||
Number: f(seL4_UserException_Msg::seL4_UserException_Number), | ||
Code: f(seL4_UserException_Msg::seL4_UserException_Code), | ||
} | ||
.unsplay() | ||
} | ||
seL4_Fault_tag::seL4_Fault_VMFault => { | ||
assert!(length == seL4_VMFault_Msg::seL4_VMFault_Length); | ||
seL4_Fault_VMFault_Unpacked { | ||
IP: f(seL4_VMFault_Msg::seL4_VMFault_IP), | ||
Addr: f(seL4_VMFault_Msg::seL4_VMFault_Addr), | ||
PrefetchFault: f(seL4_VMFault_Msg::seL4_VMFault_PrefetchFault), | ||
FSR: f(seL4_VMFault_Msg::seL4_VMFault_FSR), | ||
} | ||
.unsplay() | ||
} | ||
#[sel4_cfg(ARM_HYPERVISOR_SUPPORT)] | ||
seL4_Fault_tag::seL4_Fault_VGICMaintenance => { | ||
assert!(length == seL4_VGICMaintenance_Msg::seL4_VGICMaintenance_Length); | ||
seL4_Fault_VGICMaintenance_Unpacked { | ||
IDX: f(seL4_VGICMaintenance_Msg::seL4_VGICMaintenance_IDX), | ||
} | ||
.unsplay() | ||
} | ||
#[sel4_cfg(ARM_HYPERVISOR_SUPPORT)] | ||
seL4_Fault_tag::seL4_Fault_VCPUFault => { | ||
assert!(length == seL4_VCPUFault_Msg::seL4_VCPUFault_Length); | ||
seL4_Fault_VCPUFault_Unpacked { | ||
HSR: f(seL4_VCPUFault_Msg::seL4_VCPUFault_HSR), | ||
} | ||
.unsplay() | ||
} | ||
#[sel4_cfg(ARM_HYPERVISOR_SUPPORT)] | ||
seL4_Fault_tag::seL4_Fault_VPPIEvent => { | ||
// TODO | ||
// assert!(length == seL4_VPPIEvent_Msg::seL4_VPPIEvent_Length); | ||
seL4_Fault_VPPIEvent_Unpacked { | ||
irq: f(seL4_VPPIEvent_Msg::seL4_VPPIEvent_IRQ), | ||
} | ||
.unsplay() | ||
} | ||
_ => { | ||
return None | ||
} | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
use core::arch::asm; | ||
use core::ffi::c_int; | ||
|
||
use sel4_config::sel4_cfg; | ||
|
||
use crate::{seL4_Word, seL4_MessageInfo}; | ||
use super::sys_id_to_word; | ||
|
||
// NOTE: | ||
// asm!() does not allow r6 to be used for input or output operands, because it's sometimes used by LLVM. | ||
|
||
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!("swi 0", | ||
in("r7") sys_id_to_word(sys), | ||
in("r0") dest, | ||
in("r1") info_arg.into_word(), | ||
in("r2") mr0, | ||
in("r3") mr1, | ||
in("r4") mr2, | ||
in("r5") 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!("swi 0", | ||
in("r7") sys_id_to_word(sys), | ||
in("r1") info_arg.into_word(), | ||
in("r2") mr0, | ||
in("r3") mr1, | ||
in("r4") mr2, | ||
in("r5") mr3, | ||
); | ||
} | ||
} | ||
|
||
pub fn sys_send_null( | ||
sys: c_int, | ||
src: seL4_Word, | ||
info_arg: seL4_MessageInfo, | ||
) { | ||
unsafe { | ||
asm!("swi 0", | ||
in("r7") sys_id_to_word(sys), | ||
in("r0") src, | ||
in("r1") 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!( | ||
"mov r10, r6", | ||
"mov r6, r9", | ||
"swi 0", | ||
"mov r6, r10", | ||
in("r7") sys_id_to_word(sys), | ||
inout("r0") src => out_badge, | ||
out("r1") out_info, | ||
out("r2") *out_mr0, | ||
out("r3") *out_mr1, | ||
out("r4") *out_mr2, | ||
out("r5") *out_mr3, | ||
in("r9") reply, | ||
inout("r10") 0 => _, | ||
); | ||
} | ||
(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!( | ||
"mov r10, r6", | ||
"mov r6, r9", | ||
"swi 0", | ||
"mov r6, r10", | ||
in("r7") sys_id_to_word(sys), | ||
inout("r0") dest => out_badge, | ||
inout("r1") info_arg.into_word() => out_info, | ||
inout("r2") *in_out_mr0, | ||
inout("r3") *in_out_mr1, | ||
inout("r4") *in_out_mr2, | ||
inout("r5") *in_out_mr3, | ||
in("r9") reply, | ||
inout("r10") 0 => _, | ||
); | ||
} | ||
(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!( | ||
"mov r10, r6", | ||
"mov r6, r9", | ||
"swi 0", | ||
"mov r6, r10", | ||
in("r7") sys_id_to_word(sys), | ||
inout("r0") src => out_badge, | ||
inout("r1") info_arg.into_word() => out_info, | ||
inout("r2") *in_out_mr0, | ||
inout("r3") *in_out_mr1, | ||
inout("r4") *in_out_mr2, | ||
inout("r5") *in_out_mr3, | ||
in("r9") reply, | ||
in("r8") dest, | ||
inout("r10") 0 => _, | ||
); | ||
} | ||
(seL4_MessageInfo::from_word(out_info), out_badge) | ||
} | ||
|
||
pub fn sys_null( | ||
sys: c_int, | ||
) { | ||
unsafe { | ||
asm!("swi 0", | ||
in("r7") sys_id_to_word(sys), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -410,7 +410,7 @@ sel4_cfg_if! { | |
|
||
sel4_cfg_if! { | ||
if #[cfg(ENABLE_BENCHMARKS)] { | ||
|
||
// TODO | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.