diff --git a/ableos/src/arch/x86_64/init.rs b/ableos/src/arch/x86_64/init.rs index 98b8371c..e19df2bb 100644 --- a/ableos/src/arch/x86_64/init.rs +++ b/ableos/src/arch/x86_64/init.rs @@ -1,6 +1,12 @@ #![allow(clippy::print_literal)] -use super::{gdt, interrupts}; -use crate::{println, serial_println}; +use { + super::{gdt, interrupts}, + crate::{ + info, + log::{self, Log}, + println, + }, +}; pub fn init() { gdt::init(); @@ -8,5 +14,5 @@ pub fn init() { unsafe { interrupts::PICS.lock().initialize() }; x86_64::instructions::interrupts::enable(); println!("Initialized"); - serial_println!("Initialized"); + info!("Initialized"); } diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index 8ec72d63..7329ae7a 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -29,7 +29,6 @@ lazy_static! { pub static ref THREAD_LIST: spin::Mutex = spin::Mutex::new(vec![]); pub static ref TICK: spin::Mutex = spin::Mutex::new(0); } -use alloc::format; use crate::log::{self, Log}; #[no_mangle] @@ -51,8 +50,7 @@ pub fn kernel_main() -> ! { // crate::wasm::evaluate(); println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION); - log::ANSISerialLogger::info(&format!("{} v{}", RELEASE_TYPE, KERNEL_VERSION)); - + info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION); { use crate::experiments::mail::MailBoxes; let mut x = MailBoxes::new(); diff --git a/ableos/src/lib.rs b/ableos/src/lib.rs index efa40d50..cca1880d 100644 --- a/ableos/src/lib.rs +++ b/ableos/src/lib.rs @@ -27,13 +27,14 @@ pub mod arch; #[macro_use] pub mod print; +#[macro_use] +pub mod log; pub mod allocator; pub mod driver_traits; pub mod experiments; pub mod keyboard; pub mod kmain; -pub mod log; pub mod panic; pub mod relib; pub mod scheduler; diff --git a/ableos/src/log.rs b/ableos/src/log.rs index 2e6f7c3f..ccfd3347 100644 --- a/ableos/src/log.rs +++ b/ableos/src/log.rs @@ -1,22 +1,14 @@ pub trait Log { -<<<<<<< HEAD fn debug(val: &str); fn error(val: &str); fn info(val: &str); fn trace(val: &str); -======= - fn debug(val: &str); - fn error(); - fn info(val: &str); - fn trace(); ->>>>>>> 6a61fb8a9ede4d1a04da38100c4f7728e721b2d4 } use crate::serial_print; use lliw::{Fg, Reset}; pub struct ANSISerialLogger; impl Log for ANSISerialLogger { -<<<<<<< HEAD fn debug(val: &str) { serial_print!("[{}Debug{}] {}\n", Fg::Blue, Reset, val); } @@ -29,46 +21,32 @@ impl Log for ANSISerialLogger { fn trace(val: &str) { serial_print!("[{}Trace{}] {}\n", Fg::Yellow, Reset, val); } -======= - fn debug(val: &str) { - serial_print!("[{}Debug{}] {}\n", Fg::Blue, Reset, val); - } - fn error() { - todo!(); - } - fn info(val: &str) { - serial_print!("[{}Info{}] {}\n", Fg::Blue, Reset, val); - } - fn trace() { - todo!(); - } } #[macro_export] macro_rules! debug { ($($arg:tt)*) => ({ - log::ANSISerialLogger::debug(&format!($($arg)*)); + let _ = &log::ANSISerialLogger::debug(&alloc::format!($($arg)*)); }) } #[macro_export] macro_rules! error { ($($arg:tt)*) => ({ - log::ANSISerialLogger::error(&format!($($arg)*)); + log::ANSISerialLogger::error(&alloc::format!($($arg)*)); }) } #[macro_export] macro_rules! info { ($($arg:tt)*) => ({ - log::ANSISerialLogger::info(&format!($($arg)*)); + log::ANSISerialLogger::info(&alloc::format!($($arg)*)); }) } #[macro_export] macro_rules! trace { ($($arg:tt)*) => ({ - log::ANSISerialLogger::trace(&format!($($arg)*)); + log::ANSISerialLogger::trace(&alloc::format!($($arg)*)); }) ->>>>>>> 6a61fb8a9ede4d1a04da38100c4f7728e721b2d4 } diff --git a/ableos/src/scheduler.rs b/ableos/src/scheduler.rs index 207968d4..1fe3ca28 100644 --- a/ableos/src/scheduler.rs +++ b/ableos/src/scheduler.rs @@ -1,9 +1,11 @@ -use core::cmp::Ordering; - -use alloc::vec; -use alloc::vec::Vec; - -use crate::kmain::THREAD_LIST; +use { + crate::{ + kmain::THREAD_LIST, + log::{self, Log}, + }, + alloc::{vec, vec::Vec}, + core::cmp::Ordering, +}; pub type Pointer = fn(); pub type ThreadID = u64; @@ -18,6 +20,11 @@ pub struct Task { } impl Task { fn new(parent_thread: ThreadID, task_id: u64, function_pointer: fn()) -> Self { + debug!( + "New task with TaskID: {} | Parent ThreadID: {}", + task_id, parent_thread + ); + Self { id: task_id, parent_thread, @@ -56,7 +63,7 @@ impl Thread { Some(last_thread) => final_threadid = last_thread.id + 1, None => {} } - + debug!("New thread with ThreadID: {}", final_threadid); Self { id: final_threadid, tasks: vec![], @@ -66,7 +73,9 @@ impl Thread { self.tasks.sort(); } pub fn new_task_id(&self) -> TaskID { - self.tasks.len().try_into().unwrap() + let task_id = self.tasks.len().try_into().unwrap(); + trace!("New TaskID: {}", task_id); + task_id } pub fn new_task(&mut self, function_pointer: fn()) { let x = Task::new(self.id, self.new_task_id(), function_pointer);