gila/src/memory.rs
2025-02-07 10:47:15 -05:00

32 lines
730 B
Rust

#![allow(dead_code)]
#![allow(unused_imports)]
use flagset::flags;
use talc::*;
use spin;
use core::alloc::{Allocator, Layout};
static mut ARENA: [u8; 10000] = [0; 10000];
#[global_allocator]
static ALLOCATOR: Talck<spin::Mutex<()>, ClaimOnOom> = Talc::new(unsafe {
// if we're in a hosted environment, the Rust runtime may allocate before
// main() is called, so we need to initialize the arena automatically
ClaimOnOom::new(Span::from_array(core::ptr::addr_of!(ARENA).cast_mut()))
}).lock();
pub struct MemoryRegion {
start_address: usize,
end_address: usize,
flags: MemoryRegionFlags,
}
flags! {
pub enum MemoryRegionFlags: u8 {
READABLE,
WRITABLE,
EXECUTABLE,
}
}