style: cargo fmt kernel crates

This commit is contained in:
2026-10-26 19:07:54 +01:00
parent 818eaecadd
commit 1c04ddf909
50 changed files with 995 additions and 499 deletions

View File

@@ -17,7 +17,8 @@ impl TrapFrame {
}
}
global_asm!(r#"
global_asm!(
r#"
.align 4
.globl trap_vector
trap_vector:
@@ -120,7 +121,8 @@ _restore_smode:
csrrw sp, sscratch, sp
_sret_smode:
sret
"#);
"#
);
const CAUSE_INTERRUPT_BIT: usize = 1 << 63;
const CAUSE_S_TIMER: usize = 5;
@@ -169,7 +171,10 @@ fn decode_syscall(frame: &TrapFrame) -> Option<domain::syscall::Syscall> {
SYS_SEND => {
let slot = types::bounded::CapSlot::new(a0 as u8)?;
let msg = Message::from_words([a1, a2, a3, a4]);
Some(Syscall::Send { endpoint: slot, message: msg })
Some(Syscall::Send {
endpoint: slot,
message: msg,
})
}
SYS_RECEIVE => {
let slot = types::bounded::CapSlot::new(a0 as u8)?;
@@ -179,7 +184,11 @@ fn decode_syscall(frame: &TrapFrame) -> Option<domain::syscall::Syscall> {
let slot = types::bounded::CapSlot::new(a0 as u8)?;
let to = types::bounded::CapSlot::new(a1 as u8)?;
let perms = types::permission::PermissionSet::from_bits(a2 as u8);
Some(Syscall::Delegate { slot, to_endpoint: to, permissions: perms })
Some(Syscall::Delegate {
slot,
to_endpoint: to,
permissions: perms,
})
}
SYS_WAIT_FOR_INTERRUPT => {
let slot = types::bounded::CapSlot::new(a0 as u8)?;
@@ -190,14 +199,27 @@ fn decode_syscall(frame: &TrapFrame) -> Option<domain::syscall::Syscall> {
Some(Syscall::AcknowledgeInterrupt { irq: slot })
}
SYS_WAIT_ANY => {
let ep0 = if a0 != usize::MAX { types::bounded::CapSlot::new(a0 as u8) } else { None };
let ep1 = if a1 != usize::MAX { types::bounded::CapSlot::new(a1 as u8) } else { None };
let ep2 = if a2 != usize::MAX { types::bounded::CapSlot::new(a2 as u8) } else { None };
let ep3 = if a3 != usize::MAX { types::bounded::CapSlot::new(a3 as u8) } else { None };
let sources = WaitSet::new(
[ep0, ep1, ep2, ep3],
[None, None, None, None],
);
let ep0 = if a0 != usize::MAX {
types::bounded::CapSlot::new(a0 as u8)
} else {
None
};
let ep1 = if a1 != usize::MAX {
types::bounded::CapSlot::new(a1 as u8)
} else {
None
};
let ep2 = if a2 != usize::MAX {
types::bounded::CapSlot::new(a2 as u8)
} else {
None
};
let ep3 = if a3 != usize::MAX {
types::bounded::CapSlot::new(a3 as u8)
} else {
None
};
let sources = WaitSet::new([ep0, ep1, ep2, ep3], [None, None, None, None]);
Some(Syscall::WaitAny { sources })
}
SYS_CREATE_PROCESS => {
@@ -288,7 +310,7 @@ fn load_context_to_frame(ctx: &domain::thread::SavedContext, frame: &mut TrapFra
frame.sstatus = ctx.status();
// ensure returning to U-mode
frame.sstatus &= !(1 << 8); // clear SPP
frame.sstatus |= 1 << 5; // set SPIE
frame.sstatus |= 1 << 5; // set SPIE
}
fn apply_pending_result(frame: &mut TrapFrame, tid: types::id::ThreadId) {
@@ -315,7 +337,11 @@ fn write_result_direct(frame: &mut TrapFrame, result: &kernel::SyscallResult) {
}
}
fn switch_to_thread(frame: &mut TrapFrame, current_tid: types::id::ThreadId, next_tid: types::id::ThreadId) {
fn switch_to_thread(
frame: &mut TrapFrame,
current_tid: types::id::ThreadId,
next_tid: types::id::ThreadId,
) {
let kern = unsafe { &mut *crate::kernel_ptr() };
if let Some(ctx) = kern.thread_context_mut(current_tid) {
@@ -372,7 +398,9 @@ fn switch_to_next(frame: &mut TrapFrame, current_tid: types::id::ThreadId) {
}
}
} else {
loop { unsafe { core::arch::asm!("wfi") }; }
loop {
unsafe { core::arch::asm!("wfi") };
}
}
}
@@ -471,7 +499,9 @@ fn handle_exception(frame: &mut TrapFrame, scause: usize) {
kern.handle_fault(current_tid, fault, frame.sepc);
switch_to_next(frame, current_tid);
} else {
loop { unsafe { core::arch::asm!("wfi") }; }
loop {
unsafe { core::arch::asm!("wfi") };
}
}
}
}