From d8992dc2c2f6417df7d358ddfc74d8ebd5c312de Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sat, 28 Mar 2020 10:33:57 -0400 Subject: [PATCH] better logging --- src/interrupts.rs | 2 +- src/lib.rs | 4 ++-- src/main.rs | 12 +++++------- src/task/executor.rs | 4 ++-- src/wasm/mod.rs | 11 +++++++---- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/interrupts.rs b/src/interrupts.rs index 9bb5d35..3c36c4f 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -1,4 +1,4 @@ -use crate::{gdt, hlt_loop, print, println}; +use crate::{gdt, hlt_loop, println}; use lazy_static::lazy_static; use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame}; diff --git a/src/lib.rs b/src/lib.rs index 32fe0cc..10d1f4e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,9 +32,9 @@ use core::panic::PanicInfo; pub fn init(boot_info: &'static BootInfo) { use x86_64::VirtAddr; - use self::memory::{self, BootInfoFrameAllocator}; + use self::memory::BootInfoFrameAllocator; - println!("XeOS booting:"); + println!("[ ] XeOS booting"); gdt::init(); interrupts::init_idt(); unsafe { interrupts::PICS.lock().initialize() }; diff --git a/src/main.rs b/src/main.rs index 3fb8b45..5bdb6bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,17 +21,15 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! { // Read the rtc date time using this year let now = clock::current_time(); - println!(" now: {}", now.to_string()); + println!(" started at {}", now.to_string()); let mut executor = Executor::new(); executor.spawn(Task::new(h_task())); executor.spawn(Task::new(example_task())); executor.spawn(Task::new(keyboard::print_keypresses())); - println!("[ ] Starting async executor"); + println!("[a] Starting async executor"); executor.run(); - - xe_os::hlt_loop(); } // our existing panic handler @@ -54,13 +52,13 @@ async fn async_number() -> u32 { } async fn example_task() { - println!("[ ] Starting number task"); + println!("[n] Starting number task"); let number = async_number().await; - println!("async number: {}", number); + println!(" async number: {}", number); } async fn h_task() { - println!("[ ] Running WASM"); + println!("[w] Running WASM"); wasm::run().await; println!(" success"); } diff --git a/src/task/executor.rs b/src/task/executor.rs index d53c992..4ba8e6e 100644 --- a/src/task/executor.rs +++ b/src/task/executor.rs @@ -22,7 +22,7 @@ impl Executor { } pub fn spawn(&mut self, task: Task) { - println!(" Task {:?} started", task.id()); + println!("[T] Task {:?} started", task.id()); self.task_queue.push_back(task) } @@ -37,7 +37,7 @@ impl Executor { match task.poll(&mut context) { Poll::Ready(()) => { // task done -> remove cached waker - println!(" Task {:?} done", task_id); + println!("[T] Task {:?} done", task_id); self.waker_cache.remove(&task_id); } Poll::Pending => { diff --git a/src/wasm/mod.rs b/src/wasm/mod.rs index e6f93db..04c368a 100644 --- a/src/wasm/mod.rs +++ b/src/wasm/mod.rs @@ -1,4 +1,5 @@ use crate::{print, println}; +use alloc::vec::Vec; use wasmi::{ Error as InterpreterError, Externals, FuncInstance, FuncRef, ImportsBuilder, ModuleImportResolver, ModuleInstance, RuntimeArgs, RuntimeValue, Signature, Trap, ValueType, @@ -9,14 +10,16 @@ use crate::{serial_print, serial_println}; mod hack; -pub async fn run() { - use alloc::vec::Vec; - +async fn load_wasm_module() -> wasmi::Module { let bytes = include_bytes!("../../data/h.wasm"); let b: Vec = bytes.iter().cloned().collect(); println!(" loaded wasm into a Vec"); - let module = wasmi::Module::from_buffer(&b).unwrap(); + wasmi::Module::from_buffer(&b).unwrap() +} + +pub async fn run() { + let module = load_wasm_module().await; let mut imports = ImportsBuilder::new(); imports.push_resolver("h", &H);