feat(kernel): console cap gates DebugPutchar, no uart fast path; spawn start arg in a0; delegate returns slot
This commit is contained in:
@@ -43,12 +43,11 @@ impl<P: Platform> Kernel<P> {
|
||||
};
|
||||
|
||||
let parent = self.cap_ref(caller_pid, slot);
|
||||
let inserted = self.insert_derived(target_pid, copy, parent);
|
||||
if let Err(e) = inserted {
|
||||
return SyscallOutcome::Complete(SyscallResult::Error(e));
|
||||
// The slot it landed in, so the delegator can tell the target.
|
||||
match self.insert_derived(target_pid, copy, parent) {
|
||||
Ok(slot) => SyscallOutcome::Complete(SyscallResult::Slot(slot)),
|
||||
Err(e) => SyscallOutcome::Complete(SyscallResult::Error(e)),
|
||||
}
|
||||
|
||||
SyscallOutcome::Complete(SyscallResult::Ok)
|
||||
}
|
||||
|
||||
pub(crate) fn handle_revoke(
|
||||
|
||||
@@ -9,12 +9,14 @@ impl<P: Platform> Kernel<P> {
|
||||
pid: types::id::ProcessId,
|
||||
entry: types::address::EntryPoint,
|
||||
stack: types::address::StackPointer,
|
||||
arg: usize,
|
||||
) -> SyscallOutcome {
|
||||
use domain::thread::SavedContext;
|
||||
|
||||
let priority = types::bounded::Priority::DEFAULT;
|
||||
let time_slice = types::time::TimeSlice::DEFAULT;
|
||||
let context = SavedContext::with_entry_and_stack(entry, stack);
|
||||
let mut context = SavedContext::with_entry_and_stack(entry, stack);
|
||||
context.registers_mut()[10] = arg;
|
||||
|
||||
let tid = match self
|
||||
.threads
|
||||
@@ -87,6 +89,7 @@ impl<P: Platform> Kernel<P> {
|
||||
process_cap: types::bounded::CapSlot,
|
||||
entry: types::address::EntryPoint,
|
||||
stack: types::address::StackPointer,
|
||||
arg: usize,
|
||||
) -> SyscallOutcome {
|
||||
use domain::thread::SavedContext;
|
||||
|
||||
@@ -111,7 +114,8 @@ impl<P: Platform> Kernel<P> {
|
||||
|
||||
let priority = types::bounded::Priority::DEFAULT;
|
||||
let time_slice = types::time::TimeSlice::DEFAULT;
|
||||
let context = SavedContext::with_entry_and_stack(entry, stack);
|
||||
let mut context = SavedContext::with_entry_and_stack(entry, stack);
|
||||
context.registers_mut()[10] = arg;
|
||||
|
||||
let tid = match self
|
||||
.threads
|
||||
|
||||
@@ -80,7 +80,9 @@ impl<P: Platform> Kernel<P> {
|
||||
Syscall::ExitThread => self.handle_exit_thread(tid, pid),
|
||||
Syscall::RequestPages { count } => self.handle_request_pages(pid, count),
|
||||
Syscall::ReleasePages { addr, count } => self.handle_release_pages(pid, addr, count),
|
||||
Syscall::SpawnThread { entry, stack } => self.handle_spawn_thread(pid, entry, stack),
|
||||
Syscall::SpawnThread { entry, stack, arg } => {
|
||||
self.handle_spawn_thread(pid, entry, stack, arg)
|
||||
}
|
||||
Syscall::CreateProcess { create_cap, image } => {
|
||||
self.handle_create_process(pid, create_cap, image)
|
||||
}
|
||||
@@ -144,7 +146,10 @@ impl<P: Platform> Kernel<P> {
|
||||
}
|
||||
Syscall::Halt { control } => self.handle_halt(pid, control),
|
||||
Syscall::CreateEndpoint => self.handle_create_endpoint(pid),
|
||||
Syscall::DebugPutchar { byte } => self.handle_debug_putchar(byte),
|
||||
Syscall::DebugPutchar { console, byte } => complete(
|
||||
self.debug_putchar(pid, console, byte)
|
||||
.map(|()| SyscallResult::Ok),
|
||||
),
|
||||
Syscall::MapPage {
|
||||
process,
|
||||
src_va,
|
||||
@@ -155,7 +160,8 @@ impl<P: Platform> Kernel<P> {
|
||||
process,
|
||||
entry,
|
||||
stack,
|
||||
} => self.handle_spawn_thread_in(pid, process, entry, stack),
|
||||
arg,
|
||||
} => self.handle_spawn_thread_in(pid, process, entry, stack, arg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,9 +84,18 @@ impl<P: Platform> Kernel<P> {
|
||||
SyscallOutcome::TerminateCaller
|
||||
}
|
||||
|
||||
pub(crate) fn handle_debug_putchar(&self, byte: u8) -> SyscallOutcome {
|
||||
/// Console output is a capability like any other hardware access.
|
||||
pub(crate) fn debug_putchar(
|
||||
&self,
|
||||
pid: ProcessId,
|
||||
console: CapSlot,
|
||||
byte: u8,
|
||||
) -> Result<(), KernelError> {
|
||||
if *self.check_cap(pid, console, Permission::Write)?.resource() != Resource::Console {
|
||||
return Err(KernelError::WrongObject);
|
||||
}
|
||||
self.platform.debug_putchar(byte);
|
||||
SyscallOutcome::Complete(SyscallResult::Ok)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Halts the machine for a holder of a SystemControl capability with
|
||||
|
||||
Reference in New Issue
Block a user