From fe6cccc70d1a5631d98f9a93be760a854e6865bd Mon Sep 17 00:00:00 2001 From: able Date: Sat, 18 Nov 2023 02:17:54 -0600 Subject: [PATCH] attempt to log arguments in the limine framebuffer Still needs work having to do with setting the log level --- kernel/src/holeybytes/ecah.rs | 21 ++++++++++++------- kernel/src/kmain.rs | 2 +- sysdata/limine.cfg | 16 +++++++------- .../limine_framebuffer_driver.rhai | 11 ++++++++++ 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 932e087..f25c0f8 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -1,7 +1,8 @@ //! Environment call handling routines + use { super::{mem::Memory, Vm}, - crate::{arch, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS}, + crate::{arch, holeybytes::mem, ipc::buffer::IpcBuffer, kmain::IPC_BUFFERS}, alloc::string::String, log::{debug, error, info, trace, warn}, }; @@ -65,12 +66,15 @@ pub fn handler(vm: &mut Vm) { use alloc::vec::Vec; match buffer_id { - 1 => { - log_msg_handler(vm, mem_addr, length); - } + 1 => match log_msg_handler(vm, mem_addr, length) { + Ok(()) => {} + Err(err) => log::error!("Improper log format"), + }, buffer_id => { let mut buffs = IPC_BUFFERS.lock(); + let mut buff = buffs.get_mut(&buffer_id).unwrap(); + let mut msg_vec = vec![]; for x in 0..(length as isize) { @@ -94,13 +98,14 @@ pub fn handler(vm: &mut Vm) { } // 5 _ => { - log::error!("Syscall unknown {:?}", r1); + log::error!("Syscall unknown {:?}{:?}", r1, vm.registers); } } } fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { // let message_length = 8 + 8 + 8; + // log::info!("Mem Addr {} length {}", mem_addr, length); let mut msg_vec = vec![]; for x in 0..(length as isize) { @@ -111,7 +116,6 @@ fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogE } let log_level = msg_vec.pop().unwrap(); let strr = String::from_utf8(msg_vec).unwrap(); - // info!("{}", strr); // use LogLevel::*; let ll = match log_level { @@ -120,7 +124,10 @@ fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogE 50 => info!("{}", strr), 51 => debug!("{}", strr), 52 => trace!("{}", strr), - _ => return Err(LogError::InvalidLogFormat), + _ => { + // log::error!("Invalid log format"); + return Err(LogError::InvalidLogFormat); + } }; Ok(()) diff --git a/kernel/src/kmain.rs b/kernel/src/kmain.rs index aaf9f8f..e6757e3 100644 --- a/kernel/src/kmain.rs +++ b/kernel/src/kmain.rs @@ -72,7 +72,7 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { unsafe { for module in boot_modules.into_iter().take(bm_take) { let mut cmd = module.cmd; - { + if cmd.len() > 2 { // Remove the quotes cmd.remove(0); cmd.pop(); diff --git a/sysdata/limine.cfg b/sysdata/limine.cfg index 8e5699f..007c09c 100644 --- a/sysdata/limine.cfg +++ b/sysdata/limine.cfg @@ -18,17 +18,17 @@ TERM_BACKDROP=008080 # Setting a default resolution for the framebuffer RESOLUTION=1024x768x24 - MODULE_PATH=boot:///failure.hbf - MODULE_CMDLINE="" + # MODULE_PATH=boot:///failure.hbf + # MODULE_CMDLINE="" - MODULE_PATH=boot:///ecall.hbf - MODULE_CMDLINE="" + # MODULE_PATH=boot:///ecall.hbf + # MODULE_CMDLINE="" - MODULE_PATH=boot:///main.hbf - MODULE_CMDLINE="" + # MODULE_PATH=boot:///main.hbf + # MODULE_CMDLINE="" - MODULE_PATH=boot:///vfs_test.hbf - MODULE_CMDLINE="" + # MODULE_PATH=boot:///vfs_test.hbf + # MODULE_CMDLINE="" MODULE_PATH=boot:///limine_framebuffer_driver.hbf MODULE_CMDLINE="height=10 width=10 arch=${ARCH}" \ No newline at end of file diff --git a/sysdata/test-programs/limine_framebuffer_driver.rhai b/sysdata/test-programs/limine_framebuffer_driver.rhai index 9d7e233..e9348ef 100644 --- a/sysdata/test-programs/limine_framebuffer_driver.rhai +++ b/sysdata/test-programs/limine_framebuffer_driver.rhai @@ -73,6 +73,17 @@ fn clear() { // Define main fn main(){ + // Log the arguments + { + cp(r3, r1); + cp(r4, r2); + + li64(r1, 3); + li64(r2, 1); + // don't forget to set the log level + + eca(); + } std::Info("Starting the limine framebuffer driver."); // un(); li64(r100, 300);