feat: add SavedContext::with_entry_and_stack, wire SpawnThread to preserve entry point and stack

This commit is contained in:
2026-10-18 01:24:56 +02:00
parent 4833f2e2bb
commit 142505d8a4
4 changed files with 88 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ use crate::{SyscallOutcome, SyscallResult};
use domain::syscall::Syscall;
use types::address::{DataRef, EntryPoint, StackPointer};
use types::bounded::CapSlot;
use types::id::ThreadId;
#[test]
fn spawn_thread_creates_ready_thread() {
@@ -17,6 +18,21 @@ fn spawn_thread_creates_ready_thread() {
));
}
#[test]
fn spawn_thread_preserves_entry_and_stack() {
let (mut k, _) = kernel_with_process();
let tid = match k.handle_syscall(Syscall::SpawnThread {
entry: EntryPoint::from_raw(0xDEAD),
stack: StackPointer::from_raw(0xBEEF),
}) {
SyscallOutcome::Complete(SyscallResult::Value(v)) => ThreadId::from_raw(v as u16),
_ => panic!("expected Value"),
};
let ctx = k.thread_context(tid);
assert_eq!(ctx.program_counter(), 0xDEAD);
assert_eq!(ctx.stack_pointer(), 0xBEEF);
}
#[test]
fn create_process_with_cap_succeeds() {
let (mut k, _) = kernel_with_process();