@@ -3,7 +3,7 @@ use crate::{
33 addr:: PhysAddr ,
44 boot:: { HHDM_REQUEST , MEMMAP_REQUEST } ,
55 } ,
6- debug, trace ,
6+ debug, info , println ,
77} ;
88use limine:: memory_map:: EntryType ;
99
@@ -46,27 +46,27 @@ pub fn create_bitmap_allocator() -> BitmapAllocator {
4646 let memmap = MEMMAP_REQUEST . get_response ( ) . unwrap ( ) ;
4747 let hhdm = HHDM_REQUEST . get_response ( ) . unwrap ( ) . offset ( ) ;
4848
49+ info ! ( "Detecting physical memory" ) ;
50+ debug ! ( "Usable memory regions:" ) ;
4951 let mut high: u64 = 0 ;
5052 for entry in memmap. entries ( ) {
5153 if entry. entry_type == EntryType :: USABLE {
5254 let top: u64 = entry. base + entry. length ;
5355 if top > high {
5456 high = top;
5557 }
56- debug ! (
57- "Found usable memory region from: {:#x} to {:#x}" ,
58- entry. base, top
59- ) ;
58+ println ! ( " {:#010x} - {:#010x}" , entry. base, top) ;
6059 }
6160 }
6261
6362 let frame_count = ( high / FRAME_SIZE ) as usize ;
6463 let bitmap_size_bytes = ( frame_count + 7 ) / 8 ;
6564 let bitmap_size_u64s = ( bitmap_size_bytes + 7 ) / 8 ;
6665
67- trace ! (
68- "Total frames: {}, bitmap size: {} bytes ({} u64s)" ,
69- frame_count, bitmap_size_bytes, bitmap_size_u64s
66+ debug ! ( "Total frames: {}" , frame_count) ;
67+ debug ! (
68+ "Bitmap size: {} ({} u64s)" ,
69+ bitmap_size_bytes, bitmap_size_u64s
7070 ) ;
7171
7272 let mut best_region: Option < ( u64 , u64 ) > = None ;
@@ -83,7 +83,7 @@ pub fn create_bitmap_allocator() -> BitmapAllocator {
8383
8484 let ( bitmap_base, _) = best_region. expect ( "No suitable memory region found for bitmap" ) ;
8585
86- trace ! ( "Placing bitmap at physical address : {:#x }" , bitmap_base) ;
86+ debug ! ( "Bitmap placed at: {:#010x }" , bitmap_base) ;
8787
8888 // Create the bitmap slice from the chosen memory region with HHDM added to the base
8989 let bitmap_ptr = ( bitmap_base + hhdm) as * mut u64 ;
@@ -109,11 +109,11 @@ pub fn create_bitmap_allocator() -> BitmapAllocator {
109109 }
110110 }
111111 }
112-
113- debug ! ( "Freed frames {:#x} to {:#x}" , start_frame, end_frame) ;
114112 }
115113 }
116114
115+ debug ! ( "Freed frames in usable ranges" ) ;
116+
117117 let bitmap_start_frame = bitmap_base / FRAME_SIZE ;
118118 let bitmap_end_frame = ( bitmap_base + bitmap_size_bytes as u64 + FRAME_SIZE - 1 ) / FRAME_SIZE ;
119119
@@ -129,11 +129,6 @@ pub fn create_bitmap_allocator() -> BitmapAllocator {
129129 }
130130 }
131131
132- trace ! (
133- "Marked bitmap region frames {:#x} to {:#x} as used" ,
134- bitmap_start_frame, bitmap_end_frame
135- ) ;
136-
137132 // Print memory information
138133 let total_memory = frame_count as u64 * FRAME_SIZE ;
139134 let mut free_frames = 0usize ;
@@ -146,11 +141,10 @@ pub fn create_bitmap_allocator() -> BitmapAllocator {
146141 }
147142 let free_memory = free_frames as u64 * FRAME_SIZE ;
148143
149- trace ! (
150- "Physical memory: total = {} MiB, free = {} MiB ({} frames free) " ,
144+ info ! (
145+ "Total memory: {} MiB, usable: {} MiB" ,
151146 total_memory / 1024 / 1024 ,
152147 free_memory / 1024 / 1024 ,
153- free_frames
154148 ) ;
155149
156150 BitmapAllocator {
0 commit comments