46 lines
1.0 KiB
Rust
46 lines
1.0 KiB
Rust
// Copyright (c) 2025 shibedrill
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#![allow(unused_imports)]
|
|
|
|
use enumflags2::*;
|
|
|
|
use core::alloc::{Allocator, Layout};
|
|
use talc::*;
|
|
|
|
pub extern crate alloc;
|
|
|
|
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();
|
|
|
|
#[allow(dead_code)]
|
|
pub struct MemoryRegion {
|
|
start_address: usize,
|
|
end_address: usize,
|
|
flags: BitFlags<MemoryRegionFlags>,
|
|
}
|
|
|
|
impl MemoryRegion {
|
|
// TODO: Memory allocation and virtual addressing
|
|
#[allow(unused_variables)]
|
|
pub fn new(flags: BitFlags<MemoryRegionFlags>) -> Self {
|
|
todo!()
|
|
}
|
|
}
|
|
|
|
#[bitflags]
|
|
#[repr(u8)]
|
|
#[derive(Clone, Copy)]
|
|
pub enum MemoryRegionFlags {
|
|
Readable,
|
|
Writable,
|
|
Executable,
|
|
}
|