This commit is contained in:
mii443
2025-07-02 18:25:27 +09:00
parent d4956a79d4
commit c928e58c5f
2 changed files with 11 additions and 3 deletions

View File

@ -14,7 +14,7 @@ use core::ptr::addr_of;
use x86_64::VirtAddr;
use crate::{
constant::{BANNER, BITS_PER_ENTRY, KERNEL_STACK_SIZE, PKG_VERSION},
constant::{BANNER, KERNEL_STACK_SIZE, PKG_VERSION},
memory::BitmapMemoryTable,
};

View File

@ -18,7 +18,7 @@ impl BitmapMemoryTable {
}
pub fn init(usable_memory: &UsableMemory) -> Self {
let mut table = Self::new();
let mut table = Self::default();
for range in usable_memory.ranges() {
table.set_range(range);
}
@ -35,7 +35,9 @@ impl BitmapMemoryTable {
table
}
pub fn get_free_frame(&self) {}
pub fn get_free_pfn(&self) -> Option<usize> {
(self.start..self.end).find(|&i| self.get_bit(i))
}
pub fn set_range(&mut self, range: &memory::Range) {
let start = Self::addr_to_pfn(range.start as usize);
@ -80,3 +82,9 @@ impl BitmapMemoryTable {
frame % BITS_PER_ENTRY
}
}
impl Default for BitmapMemoryTable {
fn default() -> Self {
Self::new()
}
}