From be7681bd794872e6c4916ec28e4628aa543703c4 Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Tue, 5 Mar 2024 04:57:45 +0100 Subject: thredding 1/? --- src/arch/x86_64/context.rs | 28 ++++++++++++++++++++++++++++ src/arch/x86_64/mod.rs | 1 + 2 files changed, 29 insertions(+) create mode 100644 src/arch/x86_64/context.rs (limited to 'src') diff --git a/src/arch/x86_64/context.rs b/src/arch/x86_64/context.rs new file mode 100644 index 0000000..08fd3b6 --- /dev/null +++ b/src/arch/x86_64/context.rs @@ -0,0 +1,28 @@ +/// high level representation of the callee saved registers for thread context. The caller +/// saved registers will is pushed into the stack already upon the interrupt entry +/// fpstate is NOT saved here +#[repr(C)] +pub struct Context { + rbx: u64, + r12: u64, + r13: u64, + r14: u64, + r15: u64, + rbp: u64, + rsp: u64, +} + +/// prepare the thread (coroutine) for the first execution +pub unsafe fn settle(){ + todo!() + // it will be something like this... + // void **sp = (void**)tos; + // *(--sp) = object; // 7th parameter for kickoff + // *(--sp) = (void*)0; // return address + // *(--sp) = kickoff; // address + // regs->rsp = sp; +} + +pub unsafe fn switch(ctx_curr:usize, ctx_next:usize){ + todo!() +} diff --git a/src/arch/x86_64/mod.rs b/src/arch/x86_64/mod.rs index 715c19f..03d2af0 100644 --- a/src/arch/x86_64/mod.rs +++ b/src/arch/x86_64/mod.rs @@ -3,3 +3,4 @@ pub mod interrupt; pub mod io_port; pub mod mem; pub mod misc; +pub mod context; -- cgit v1.2.3-70-g09d2