mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Create a new AreaFrameAllocator and allocate maximum number of frames
This commit is contained in:
13
src/lib.rs
13
src/lib.rs
@@ -15,6 +15,8 @@ mod memory;
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn rust_main(multiboot_information_address: usize) {
|
pub extern fn rust_main(multiboot_information_address: usize) {
|
||||||
|
use memory::FrameAllocator;
|
||||||
|
|
||||||
vga_buffer::clear_screen();
|
vga_buffer::clear_screen();
|
||||||
println!("Hello World{}", "!");
|
println!("Hello World{}", "!");
|
||||||
|
|
||||||
@@ -44,6 +46,17 @@ pub extern fn rust_main(multiboot_information_address: usize) {
|
|||||||
let multiboot_start = multiboot_information_address;
|
let multiboot_start = multiboot_information_address;
|
||||||
let multiboot_end = multiboot_start + (boot_info.total_size as usize);
|
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{}
|
loop{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
pub use self::area_frame_allocator::AreaFrameAllocator;
|
||||||
|
|
||||||
mod area_frame_allocator;
|
mod area_frame_allocator;
|
||||||
|
|
||||||
pub const PAGE_SIZE: usize = 4096;
|
pub const PAGE_SIZE: usize = 4096;
|
||||||
|
|||||||
Reference in New Issue
Block a user