Files
XunilOS/kernel/src/task/context.rs
T
csd4ni3l 812d4cf6d4 Patched everything for aarch64, aside from scheduler, add more linker
points to aarch64 ld, add aarch64 heap, init, page tables and usermode,
make hhdm_offset a global atomic, aarch64 uses semihosting for output,
add generic PageTable type, add a function that creates and maps pages,
use allow to remove warnings, add a bufwriter so kernel panic always
works
2026-05-16 00:30:01 +02:00

41 lines
937 B
Rust

use crate::task::scheduler::{SCHEDULER, current_pid};
#[cfg(target_arch = "x86_64")]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct UserContext {
//general purpose data regs
pub r15: u64,
pub r14: u64,
pub r13: u64,
pub r12: u64,
pub r11: u64, // rflags
pub r10: u64,
pub r9: u64,
pub r8: u64,
pub rsi: u64,
pub rdi: u64,
pub rbp: u64,
pub rdx: u64,
pub rcx: u64, // rip
pub rbx: u64,
pub rax: u64,
pub rsp: u64, // user rsp
}
#[cfg(target_arch = "aarch64")]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct UserContext {}
#[unsafe(no_mangle)]
pub extern "C" fn ctx_save(regs: *const UserContext) {
if let Some(pid) = current_pid() {
let mut guard = SCHEDULER.lock();
if let Some(process) = guard.processes.get_mut(&pid) {
let saved_ctx = unsafe { core::ptr::read(regs) };
process.saved_ctx = Some(saved_ctx);
}
}
}