From 933b3b8fc0b3f0e8993be0e0aff80ce65672bb04 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 14 Feb 2022 10:29:12 -0700 Subject: [PATCH] Respect min flag to allocate_frames_complex --- src/memory/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/memory/mod.rs b/src/memory/mod.rs index 9894666..42dc53b 100644 --- a/src/memory/mod.rs +++ b/src/memory/mod.rs @@ -1,6 +1,8 @@ //! # Memory management //! Some code was borrowed from [Phil Opp's Blog](http://os.phil-opp.com/allocating-frames.html) +use core::cmp; + use crate::arch::rmm::FRAME_ALLOCATOR; pub use crate::paging::{PAGE_SIZE, PhysicalAddress}; @@ -43,8 +45,10 @@ pub fn allocate_frames(count: usize) -> Option { } } pub fn allocate_frames_complex(count: usize, flags: PhysallocFlags, strategy: Option, min: usize) -> Option<(Frame, usize)> { - if count == min && flags == PhysallocFlags::SPACE_64 && strategy.is_none() { - return allocate_frames(count).map(|frame| (frame, count)); + //TODO: support partial allocation + if flags == PhysallocFlags::SPACE_64 && strategy.is_none() { + let actual = cmp::max(count, min); + return allocate_frames(actual).map(|frame| (frame, actual)); } println!(