1
0
Fork 0
forked from koniifer/ableos

attempt to log arguments in the limine framebuffer

Still needs work having to do with setting the log level
This commit is contained in:
able 2023-11-18 02:17:54 -06:00
parent 815c424248
commit fe6cccc70d
4 changed files with 34 additions and 16 deletions

View file

@ -1,7 +1,8 @@
//! Environment call handling routines //! Environment call handling routines
use { use {
super::{mem::Memory, Vm}, 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, alloc::string::String,
log::{debug, error, info, trace, warn}, log::{debug, error, info, trace, warn},
}; };
@ -65,12 +66,15 @@ pub fn handler(vm: &mut Vm) {
use alloc::vec::Vec; use alloc::vec::Vec;
match buffer_id { match buffer_id {
1 => { 1 => match log_msg_handler(vm, mem_addr, length) {
log_msg_handler(vm, mem_addr, length); Ok(()) => {}
} Err(err) => log::error!("Improper log format"),
},
buffer_id => { buffer_id => {
let mut buffs = IPC_BUFFERS.lock(); let mut buffs = IPC_BUFFERS.lock();
let mut buff = buffs.get_mut(&buffer_id).unwrap(); let mut buff = buffs.get_mut(&buffer_id).unwrap();
let mut msg_vec = vec![]; let mut msg_vec = vec![];
for x in 0..(length as isize) { for x in 0..(length as isize) {
@ -94,13 +98,14 @@ pub fn handler(vm: &mut Vm) {
} }
// 5 // 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> { fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> {
// let message_length = 8 + 8 + 8; // let message_length = 8 + 8 + 8;
// log::info!("Mem Addr {} length {}", mem_addr, length);
let mut msg_vec = vec![]; let mut msg_vec = vec![];
for x in 0..(length as isize) { 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 log_level = msg_vec.pop().unwrap();
let strr = String::from_utf8(msg_vec).unwrap(); let strr = String::from_utf8(msg_vec).unwrap();
// info!("{}", strr);
// use LogLevel::*; // use LogLevel::*;
let ll = match log_level { 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), 50 => info!("{}", strr),
51 => debug!("{}", strr), 51 => debug!("{}", strr),
52 => trace!("{}", strr), 52 => trace!("{}", strr),
_ => return Err(LogError::InvalidLogFormat), _ => {
// log::error!("Invalid log format");
return Err(LogError::InvalidLogFormat);
}
}; };
Ok(()) Ok(())

View file

@ -72,7 +72,7 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! {
unsafe { unsafe {
for module in boot_modules.into_iter().take(bm_take) { for module in boot_modules.into_iter().take(bm_take) {
let mut cmd = module.cmd; let mut cmd = module.cmd;
{ if cmd.len() > 2 {
// Remove the quotes // Remove the quotes
cmd.remove(0); cmd.remove(0);
cmd.pop(); cmd.pop();

View file

@ -18,17 +18,17 @@ TERM_BACKDROP=008080
# Setting a default resolution for the framebuffer # Setting a default resolution for the framebuffer
RESOLUTION=1024x768x24 RESOLUTION=1024x768x24
MODULE_PATH=boot:///failure.hbf # MODULE_PATH=boot:///failure.hbf
MODULE_CMDLINE="" # MODULE_CMDLINE=""
MODULE_PATH=boot:///ecall.hbf # MODULE_PATH=boot:///ecall.hbf
MODULE_CMDLINE="" # MODULE_CMDLINE=""
MODULE_PATH=boot:///main.hbf # MODULE_PATH=boot:///main.hbf
MODULE_CMDLINE="" # MODULE_CMDLINE=""
MODULE_PATH=boot:///vfs_test.hbf # MODULE_PATH=boot:///vfs_test.hbf
MODULE_CMDLINE="" # MODULE_CMDLINE=""
MODULE_PATH=boot:///limine_framebuffer_driver.hbf MODULE_PATH=boot:///limine_framebuffer_driver.hbf
MODULE_CMDLINE="height=10 width=10 arch=${ARCH}" MODULE_CMDLINE="height=10 width=10 arch=${ARCH}"

View file

@ -73,6 +73,17 @@ fn clear() {
// Define main // Define main
fn 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."); std::Info("Starting the limine framebuffer driver.");
// un(); // un();
li64(r100, 300); li64(r100, 300);