better logging

This commit is contained in:
Cadey Ratio 2020-03-28 10:33:57 -04:00
parent 2a28a7a24d
commit d8992dc2c2
5 changed files with 17 additions and 16 deletions

View File

@ -1,4 +1,4 @@
use crate::{gdt, hlt_loop, print, println}; use crate::{gdt, hlt_loop, println};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame}; use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};

View File

@ -32,9 +32,9 @@ use core::panic::PanicInfo;
pub fn init(boot_info: &'static BootInfo) { pub fn init(boot_info: &'static BootInfo) {
use x86_64::VirtAddr; use x86_64::VirtAddr;
use self::memory::{self, BootInfoFrameAllocator}; use self::memory::BootInfoFrameAllocator;
println!("XeOS booting:"); println!("[ ] XeOS booting");
gdt::init(); gdt::init();
interrupts::init_idt(); interrupts::init_idt();
unsafe { interrupts::PICS.lock().initialize() }; unsafe { interrupts::PICS.lock().initialize() };

View File

@ -21,17 +21,15 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
// Read the rtc date time using this year // Read the rtc date time using this year
let now = clock::current_time(); let now = clock::current_time();
println!(" now: {}", now.to_string()); println!(" started at {}", now.to_string());
let mut executor = Executor::new(); let mut executor = Executor::new();
executor.spawn(Task::new(h_task())); executor.spawn(Task::new(h_task()));
executor.spawn(Task::new(example_task())); executor.spawn(Task::new(example_task()));
executor.spawn(Task::new(keyboard::print_keypresses())); executor.spawn(Task::new(keyboard::print_keypresses()));
println!("[ ] Starting async executor"); println!("[a] Starting async executor");
executor.run(); executor.run();
xe_os::hlt_loop();
} }
// our existing panic handler // our existing panic handler
@ -54,13 +52,13 @@ async fn async_number() -> u32 {
} }
async fn example_task() { async fn example_task() {
println!("[ ] Starting number task"); println!("[n] Starting number task");
let number = async_number().await; let number = async_number().await;
println!("async number: {}", number); println!(" async number: {}", number);
} }
async fn h_task() { async fn h_task() {
println!("[ ] Running WASM"); println!("[w] Running WASM");
wasm::run().await; wasm::run().await;
println!(" success"); println!(" success");
} }

View File

@ -22,7 +22,7 @@ impl Executor {
} }
pub fn spawn(&mut self, task: Task) { pub fn spawn(&mut self, task: Task) {
println!(" Task {:?} started", task.id()); println!("[T] Task {:?} started", task.id());
self.task_queue.push_back(task) self.task_queue.push_back(task)
} }
@ -37,7 +37,7 @@ impl Executor {
match task.poll(&mut context) { match task.poll(&mut context) {
Poll::Ready(()) => { Poll::Ready(()) => {
// task done -> remove cached waker // task done -> remove cached waker
println!(" Task {:?} done", task_id); println!("[T] Task {:?} done", task_id);
self.waker_cache.remove(&task_id); self.waker_cache.remove(&task_id);
} }
Poll::Pending => { Poll::Pending => {

View File

@ -1,4 +1,5 @@
use crate::{print, println}; use crate::{print, println};
use alloc::vec::Vec;
use wasmi::{ use wasmi::{
Error as InterpreterError, Externals, FuncInstance, FuncRef, ImportsBuilder, Error as InterpreterError, Externals, FuncInstance, FuncRef, ImportsBuilder,
ModuleImportResolver, ModuleInstance, RuntimeArgs, RuntimeValue, Signature, Trap, ValueType, ModuleImportResolver, ModuleInstance, RuntimeArgs, RuntimeValue, Signature, Trap, ValueType,
@ -9,14 +10,16 @@ use crate::{serial_print, serial_println};
mod hack; mod hack;
pub async fn run() { async fn load_wasm_module() -> wasmi::Module {
use alloc::vec::Vec;
let bytes = include_bytes!("../../data/h.wasm"); let bytes = include_bytes!("../../data/h.wasm");
let b: Vec<u8> = bytes.iter().cloned().collect(); let b: Vec<u8> = bytes.iter().cloned().collect();
println!(" loaded wasm into a Vec"); 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(); let mut imports = ImportsBuilder::new();
imports.push_resolver("h", &H); imports.push_resolver("h", &H);