mirror of
https://github.com/XunilGroup/XunilOS.git
synced 2026-04-25 11:49:03 +02:00
FRAME_ALLOCATOR global, make XunilFrameAllocator not hold Limine entries so it can be used without lifetimes, implement the process struct, add user heap by giving back heap_start from ELF and adding sbrk syscall, align ELF loading in userspace_stub, implement lots of libc functions in libxunil, remove x86_64 dependency from libxunil, add malloc and all required heap functions to libxunil and more syscall numbers, add a util file to libxunil, add build scripts for libxunil and doomgeneric
41 lines
829 B
Rust
41 lines
829 B
Rust
use crate::{arch::x86_64::paging::XunilFrameAllocator, mm::address_space::AddressSpace};
|
|
|
|
enum ProcessState {
|
|
Ready,
|
|
Running,
|
|
Blocked,
|
|
Zombie,
|
|
}
|
|
|
|
pub struct Process {
|
|
pub pid: u64,
|
|
pub state: ProcessState,
|
|
// cpu_ctx: &[u8],
|
|
pub stack_top: u64,
|
|
pub heap_base: u64,
|
|
pub heap_end: u64,
|
|
pub address_space: AddressSpace,
|
|
pub user_entry: u64,
|
|
}
|
|
impl Process {
|
|
pub fn new(
|
|
pid: u64,
|
|
user_entry: u64,
|
|
stack_top: u64,
|
|
heap_base: u64,
|
|
heap_end: u64,
|
|
) -> Option<Process> {
|
|
let address_space = AddressSpace::new()?;
|
|
|
|
Some(Process {
|
|
pid,
|
|
stack_top,
|
|
state: ProcessState::Ready,
|
|
heap_base,
|
|
heap_end,
|
|
address_space,
|
|
user_entry,
|
|
})
|
|
}
|
|
}
|