feat: add SavedContext::with_entry_and_stack, wire SpawnThread to preserve entry point and stack
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user