From f17a1b52bd144dcc7ab10aebd4ecc977dbc47055 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 9 Sep 2020 16:02:59 -0600 Subject: [PATCH] Test multi-page allocation --- src/main.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 801389fbe4..1c7b72d425 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ use rmm::{ BumpAllocator, EmulateArch, FrameAllocator, + FrameCount, MemoryArea, PageFlushAll, PageMapper, @@ -204,13 +205,27 @@ unsafe fn new_tables(areas: &'static [MemoryArea]) { println!("Permanently used: {}", format_size(offset)); let mut allocator = BuddyAllocator::::new(bump_allocator).unwrap(); + for i in 0..16 { - let phys_opt = allocator.allocate_one(); - println!("page {}: {:X?}", i, phys_opt); - if i % 2 == 0 { - if let Some(phys) = phys_opt { - println!("free {}: {:X?}", i, phys_opt); - allocator.free_one(phys); + { + let phys_opt = allocator.allocate_one(); + println!("page {}: {:X?}", i, phys_opt); + if i % 3 == 0 { + if let Some(phys) = phys_opt { + println!("free {}: {:X?}", i, phys_opt); + allocator.free_one(phys); + } + } + } + + { + let phys_opt = allocator.allocate(FrameCount::new(16)); + println!("page*16 {}: {:X?}", i, phys_opt); + if i % 2 == 0 { + if let Some(phys) = phys_opt { + println!("free*16 {}: {:X?}", i, phys_opt); + allocator.free(phys, FrameCount::new(16)); + } } } }