mirror of
https://github.com/XunilGroup/XunilOS.git
synced 2026-06-02 11:44:24 +02:00
812d4cf6d4
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
41 lines
937 B
Rust
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);
|
|
}
|
|
}
|
|
}
|