Event system

This commit is contained in:
2024-06-12 02:18:10 +03:00
parent 1b2dd2bfbe
commit 638bfb2d5c
8 changed files with 103 additions and 32 deletions

View File

@@ -1,5 +1,3 @@
use core::slice::Iter;
use super::{Frame, FrameAllocator, MemInfo, MemoryAreaIter};
use multiboot2::MemoryArea;

View File

@@ -1,6 +1,6 @@
use core::{alloc::{GlobalAlloc, Layout}, ops::Deref};
use core::alloc::{GlobalAlloc, Layout};
use multiboot2::{BootInformation, BootInformationHeader, MemoryArea, MemoryAreaType, MemoryMapTag, TagTrait};
use multiboot2::{BootInformationHeader, MemoryArea, MemoryAreaType, MemoryMapTag, TagTrait};
pub mod area_frame_alloc;
@@ -8,8 +8,8 @@ pub mod area_frame_alloc;
static GLOBAL_ALLOCATOR: DummyAlloc = DummyAlloc;
pub struct DummyAlloc;
unsafe impl GlobalAlloc for DummyAlloc {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 { 0 as *mut u8 }
unsafe fn dealloc(&self, ptr: *mut u8, _: Layout) {}
unsafe fn alloc(&self, _: Layout) -> *mut u8 { 0 as *mut u8 }
unsafe fn dealloc(&self, _ptr: *mut u8, _: Layout) {}
}
pub const PAGE_SIZE: usize = 4096;
@@ -26,6 +26,7 @@ impl Frame {
}
}
#[allow(dead_code)]
pub trait FrameAllocator {
fn allocate_frame(&mut self) -> Option<Frame>;
fn deallocate_frame(&mut self, frame: Frame);
@@ -83,7 +84,7 @@ impl MemInfo {
let boot_info = unsafe {
multiboot2::BootInformation::load(mb_ptr as *const BootInformationHeader).unwrap()
};
let mmap_tag = boot_info.memory_map_tag().unwrap().clone();
let mmap_tag = boot_info.memory_map_tag().unwrap();
// log::debug!("Memory areas:");
// for area in mmap_tag.memory_areas() {