From bb56af20ed036bed8d9d2f8bf68376ce4d55e79a Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Wed, 24 Aug 2022 19:33:08 -0700 Subject: Rename to serial print --- src/mem/alloc.rs | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/mem/alloc.rs') diff --git a/src/mem/alloc.rs b/src/mem/alloc.rs index a388c85..514f34f 100644 --- a/src/mem/alloc.rs +++ b/src/mem/alloc.rs @@ -5,7 +5,7 @@ use super::types::*; use crate::sync::interface::Mutex; use crate::sync::NullLock; -use crate::vprintln; +use crate::serial_vprintln; use alloc::alloc::{GlobalAlloc, Layout}; use os_pic::init_lifo_queue; use os_pic::util::lifo_queue::LifoQueue; @@ -33,27 +33,27 @@ init_lifo_queue!(U4096_GRAND_ALLOC, GRAND_ALLOC_SIZE, { U4096::new() }, U4096); impl GrandAllocator { pub fn init(&self) -> Result<(), &'static str> { - vprintln!("GA: \x1b[93mInit U8 Pool\x1b[0m"); + serial_vprintln!("GA: \x1b[93mInit U8 Pool\x1b[0m"); U8_GRAND_ALLOC.init(); - vprintln!("GA: \x1b[93mInit U16 Pool\x1b[0m"); + serial_vprintln!("GA: \x1b[93mInit U16 Pool\x1b[0m"); U16_GRAND_ALLOC.init(); - vprintln!("GA: \x1b[93mInit U32 Pool\x1b[0m"); + serial_vprintln!("GA: \x1b[93mInit U32 Pool\x1b[0m"); U32_GRAND_ALLOC.init(); - vprintln!("GA: \x1b[93mInit U64 Pool\x1b[0m"); + serial_vprintln!("GA: \x1b[93mInit U64 Pool\x1b[0m"); U64_GRAND_ALLOC.init(); - vprintln!("GA: \x1b[93mInit U128 Pool\x1b[0m"); + serial_vprintln!("GA: \x1b[93mInit U128 Pool\x1b[0m"); U128_GRAND_ALLOC.init(); - vprintln!("GA: \x1b[93mInit U256 Pool\x1b[0m"); + serial_vprintln!("GA: \x1b[93mInit U256 Pool\x1b[0m"); U256_GRAND_ALLOC.init(); - vprintln!("GA: \x1b[93mInit U512 Pool\x1b[0m"); + serial_vprintln!("GA: \x1b[93mInit U512 Pool\x1b[0m"); U512_GRAND_ALLOC.init(); - vprintln!("GA: \x1b[93mInit U1024 Pool\x1b[0m"); + serial_vprintln!("GA: \x1b[93mInit U1024 Pool\x1b[0m"); U1024_GRAND_ALLOC.init(); - vprintln!("GA: \x1b[93mInit U2048 Pool\x1b[0m"); + serial_vprintln!("GA: \x1b[93mInit U2048 Pool\x1b[0m"); U2048_GRAND_ALLOC.init(); - vprintln!("GA: \x1b[93mInit U4096 Pool\x1b[0m"); + serial_vprintln!("GA: \x1b[93mInit U4096 Pool\x1b[0m"); U4096_GRAND_ALLOC.init(); - vprintln!("GA: \x1b[94mPools Initialized!\x1b[0m"); + serial_vprintln!("GA: \x1b[94mPools Initialized!\x1b[0m"); Ok(()) } } @@ -63,7 +63,7 @@ unsafe impl GlobalAlloc for GrandAllocator { /// /// Allocate the fixed size chunks unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - vprintln!("GA: Allocating chunk of size {}!", layout.size()); + serial_vprintln!("GA: Allocating chunk of size {}!", layout.size()); match layout.size() { 1 => match U8_GRAND_ALLOC.pop() { None => { @@ -155,7 +155,7 @@ unsafe impl GlobalAlloc for GrandAllocator { /// /// Deallocate the fixed size chunks by searching for them unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { - vprintln!("GA: Deallocating chunk of size {}!", layout.size()); + serial_vprintln!("GA: Deallocating chunk of size {}!", layout.size()); match layout.size() { 1 => { U8_GRAND_ALLOC.inner.lock(|pool| { @@ -165,7 +165,7 @@ unsafe impl GlobalAlloc for GrandAllocator { assert!(index < GRAND_ALLOC_SIZE, "{} is out of the allocation bounds ({})", index, GRAND_ALLOC_SIZE); assert_eq!(diff % spacing, 0, "{} is not aligned with the spacings and so it must not have been allocated by the Grand Allocator", diff % spacing); U8_GRAND_ALLOC.push(&mut pool[index+1]); - vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); + serial_vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); }); } 2 => { @@ -176,7 +176,7 @@ unsafe impl GlobalAlloc for GrandAllocator { assert!(index < GRAND_ALLOC_SIZE, "{} is out of the allocation bounds ({})", index, GRAND_ALLOC_SIZE); assert_eq!(diff % spacing, 0, "{} is not aligned with the spacings and so it must not have been allocated by the Grand Allocator", diff % spacing); U16_GRAND_ALLOC.push(&mut pool[index+1]); - vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); + serial_vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); }); } 3..=4 => { @@ -187,7 +187,7 @@ unsafe impl GlobalAlloc for GrandAllocator { assert!(index < GRAND_ALLOC_SIZE, "{} is out of the allocation bounds ({})", index, GRAND_ALLOC_SIZE); assert_eq!(diff % spacing, 0, "{} is not aligned with the spacings and so it must not have been allocated by the Grand Allocator", diff % spacing); U32_GRAND_ALLOC.push(&mut pool[index+1]); - vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); + serial_vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); }); } 5..=8 => { @@ -198,7 +198,7 @@ unsafe impl GlobalAlloc for GrandAllocator { assert!(index < GRAND_ALLOC_SIZE, "{} is out of the allocation bounds ({})", index, GRAND_ALLOC_SIZE); assert_eq!(diff % spacing, 0, "{} is not aligned with the spacings and so it must not have been allocated by the Grand Allocator", diff % spacing); U64_GRAND_ALLOC.push(&mut pool[index+1]); - vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); + serial_vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); }); } 9..=16 => { @@ -209,7 +209,7 @@ unsafe impl GlobalAlloc for GrandAllocator { assert!(index < GRAND_ALLOC_SIZE, "{} is out of the allocation bounds ({})", index, GRAND_ALLOC_SIZE); assert_eq!(diff % spacing, 0, "{} is not aligned with the spacings and so it must not have been allocated by the Grand Allocator", diff % spacing); U128_GRAND_ALLOC.push(&mut pool[index+1]); - vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); + serial_vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); }); } 17..=32 => { @@ -220,7 +220,7 @@ unsafe impl GlobalAlloc for GrandAllocator { assert!(index < GRAND_ALLOC_SIZE, "{} is out of the allocation bounds ({})", index, GRAND_ALLOC_SIZE); assert_eq!(diff % spacing, 0, "{} is not aligned with the spacings and so it must not have been allocated by the Grand Allocator", diff % spacing); U256_GRAND_ALLOC.push(&mut pool[index+1]); - vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); + serial_vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); }); } 33..=64 => { @@ -231,7 +231,7 @@ unsafe impl GlobalAlloc for GrandAllocator { assert!(index < GRAND_ALLOC_SIZE, "{} is out of the allocation bounds ({})", index, GRAND_ALLOC_SIZE); assert_eq!(diff % spacing, 0, "{} is not aligned with the spacings and so it must not have been allocated by the Grand Allocator", diff % spacing); U512_GRAND_ALLOC.push(&mut pool[index+1]); - vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); + serial_vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); }); } 65..=128 => { @@ -242,7 +242,7 @@ unsafe impl GlobalAlloc for GrandAllocator { assert!(index < GRAND_ALLOC_SIZE, "{} is out of the allocation bounds ({})", index, GRAND_ALLOC_SIZE); assert_eq!(diff % spacing, 0, "{} is not aligned with the spacings and so it must not have been allocated by the Grand Allocator", diff % spacing); U1024_GRAND_ALLOC.push(&mut pool[index+1]); - vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); + serial_vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); }); } 129..=256 => { @@ -253,7 +253,7 @@ unsafe impl GlobalAlloc for GrandAllocator { assert!(index < GRAND_ALLOC_SIZE, "{} is out of the allocation bounds ({})", index, GRAND_ALLOC_SIZE); assert_eq!(diff % spacing, 0, "{} is not aligned with the spacings and so it must not have been allocated by the Grand Allocator", diff % spacing); U2048_GRAND_ALLOC.push(&mut pool[index+1]); - vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); + serial_vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); }); } 257..=512 => { @@ -264,7 +264,7 @@ unsafe impl GlobalAlloc for GrandAllocator { assert!(index < GRAND_ALLOC_SIZE, "{} is out of the allocation bounds ({})", index, GRAND_ALLOC_SIZE); assert_eq!(diff % spacing, 0, "{} is not aligned with the spacings and so it must not have been allocated by the Grand Allocator", diff % spacing); U4096_GRAND_ALLOC.push(&mut pool[index+1]); - vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); + serial_vprintln!("GA: Freeing ({}, {}, {})", index, diff, spacing); }); } _ => { @@ -284,6 +284,6 @@ pub static ALLOCATOR: GrandAllocator = GrandAllocator {}; /// /// Returns a borrow for the Global Allocator pub fn allocator() -> &'static crate::mem::alloc::GrandAllocator { - vprintln!("AL: Getting global allocator!"); + serial_vprintln!("AL: Getting global allocator!"); &crate::mem::alloc::ALLOCATOR } -- cgit v1.2.1