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

@@ -16,17 +16,13 @@ use domain::{
endpoint::EndpointTable,
error::KernelError,
irq::IrqRoutingTable,
memory::{
page_pool::PagePool,
process_memory::ProcessMemory,
RegionTable,
},
memory::{RegionTable, page_pool::PagePool, process_memory::ProcessMemory},
message::Message,
process::{ProcessTable, MAX_PROCESSES},
process::{MAX_PROCESSES, ProcessTable},
resource::Resource,
scheduler::{multi_core::MultiCoreScheduler, Scheduler},
scheduler::{Scheduler, multi_core::MultiCoreScheduler},
syscall::WaitSet,
thread::{ThreadTable, ThreadState, MAX_THREADS},
thread::{MAX_THREADS, ThreadState, ThreadTable},
};
use platform::Platform;
use types::{
@@ -88,7 +84,10 @@ impl<P: Platform> Kernel<P> {
PermissionSet::empty().with(Permission::Execute),
Generation::initial(),
);
self.processes.get_mut(pid)?.capabilities_mut().insert(cap)?;
self.processes
.get_mut(pid)?
.capabilities_mut()
.insert(cap)?;
let core = self.platform.core_id();
self.scheduler.add(tid, priority, core);
@@ -109,7 +108,11 @@ impl<P: Platform> Kernel<P> {
self.pending_results[thread.raw() as usize].take()
}
pub fn set_thread_running(&mut self, tid: ThreadId, core: types::id::CoreId) -> Result<(), domain::error::KernelError> {
pub fn set_thread_running(
&mut self,
tid: ThreadId,
core: types::id::CoreId,
) -> Result<(), domain::error::KernelError> {
self.threads.get_mut(tid)?.set_running(core)
}
@@ -125,8 +128,14 @@ impl<P: Platform> Kernel<P> {
self.threads.get(tid).ok().map(|t| t.saved_context())
}
pub fn thread_context_mut(&mut self, tid: ThreadId) -> Option<&mut domain::thread::SavedContext> {
self.threads.get_mut(tid).ok().map(|t| t.saved_context_mut())
pub fn thread_context_mut(
&mut self,
tid: ThreadId,
) -> Option<&mut domain::thread::SavedContext> {
self.threads
.get_mut(tid)
.ok()
.map(|t| t.saved_context_mut())
}
pub fn thread_process(&self, tid: ThreadId) -> Option<ProcessId> {
@@ -147,21 +156,19 @@ impl<P: Platform> Kernel<P> {
pub fn create_process_internal(&mut self) -> Option<ProcessId> {
let pid = self.processes.create(CapabilityTable::new(), None).ok()?;
self.process_memory[pid.raw() as usize] =
Some(domain::memory::process_memory::ProcessMemory::new(pid, ProcessMemory::DEFAULT_PAGE_LIMIT));
Some(domain::memory::process_memory::ProcessMemory::new(
pid,
ProcessMemory::DEFAULT_PAGE_LIMIT,
));
Some(pid)
}
pub fn spawn_thread_internal(
&mut self,
pid: ProcessId,
) -> Option<ThreadId> {
pub fn spawn_thread_internal(&mut self, pid: ProcessId) -> Option<ThreadId> {
use domain::scheduler::Scheduler;
let tid = self.threads.spawn(
pid,
Priority::DEFAULT,
TimeSlice::DEFAULT,
None,
).ok()?;
let tid = self
.threads
.spawn(pid, Priority::DEFAULT, TimeSlice::DEFAULT, None)
.ok()?;
let _ = self.processes.get_mut(pid).map(|p| p.add_thread(tid));
let core = self.platform.core_id();
self.scheduler.add(tid, Priority::DEFAULT, core);
@@ -208,7 +215,9 @@ impl<P: Platform> Kernel<P> {
fn caller(&self) -> Result<(ThreadId, ProcessId), KernelError> {
let core = self.platform.core_id();
let tid = self.scheduler.current(core)
let tid = self
.scheduler
.current(core)
.ok_or(KernelError::WouldBlock)?;
let thread = self.threads.get(tid)?;
match thread.state() {
@@ -220,11 +229,14 @@ impl<P: Platform> Kernel<P> {
pub(crate) fn destroy_process(&mut self, pid: ProcessId) {
use domain::process::MAX_THREADS_PER_PROCESS;
let thread_ids: [Option<ThreadId>; MAX_THREADS_PER_PROCESS] = match self.processes.get(pid) {
let thread_ids: [Option<ThreadId>; MAX_THREADS_PER_PROCESS] = match self.processes.get(pid)
{
Ok(p) => {
let mut ids = [None; MAX_THREADS_PER_PROCESS];
for (i, tid) in p.thread_ids().enumerate() {
if i < MAX_THREADS_PER_PROCESS { ids[i] = Some(tid); }
if i < MAX_THREADS_PER_PROCESS {
ids[i] = Some(tid);
}
}
ids
}