From 9f1a69cafa8a1b09dd71cbf3bf7493e388576391 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 13 Apr 2017 18:05:32 +0200 Subject: [PATCH] Create a new AreaFrameAllocator and allocate maximum number of frames --- src/lib.rs | 13 +++++++++++++ src/memory/mod.rs | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 71d2229..86fc2fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,6 +15,8 @@ mod memory; #[no_mangle] pub extern fn rust_main(multiboot_information_address: usize) { + use memory::FrameAllocator; + vga_buffer::clear_screen(); println!("Hello World{}", "!"); @@ -44,6 +46,17 @@ pub extern fn rust_main(multiboot_information_address: usize) { let multiboot_start = multiboot_information_address; let multiboot_end = multiboot_start + (boot_info.total_size as usize); + let mut frame_allocator = memory::AreaFrameAllocator::new( + kernel_start as usize, kernel_end as usize, multiboot_start, + multiboot_end, memory_map_tag.memory_areas()); + + for i in 0.. { + if let None = frame_allocator.allocate_frame() { + println!("allocated {} frames", i); + break; + } + } + loop{} } diff --git a/src/memory/mod.rs b/src/memory/mod.rs index 153fff1..7bfc85d 100644 --- a/src/memory/mod.rs +++ b/src/memory/mod.rs @@ -1,3 +1,5 @@ +pub use self::area_frame_allocator::AreaFrameAllocator; + mod area_frame_allocator; pub const PAGE_SIZE: usize = 4096;