From e768c308e6b5bf296787be1e350ab12f4b8ff3bf Mon Sep 17 00:00:00 2001 From: able Date: Sat, 6 Aug 2022 22:12:48 -0500 Subject: [PATCH] port clparse --- Cargo.lock | 11 +++++++++++ ableos/Cargo.toml | 2 ++ ableos/assets/kernel.toml | 1 + ableos/src/arch/x86_64/interrupts.rs | 1 - ableos/src/boot_conf.rs | 1 + ableos/src/devices/pci/devices.rs | 1 + ableos/src/devices/pci/support.rs | 2 +- ableos/src/logger.rs | 24 ++++++++++++----------- ableos/src/scratchpad.rs | 29 ++++++++++++++++++++++------ 9 files changed, 53 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cdf3e6ed..01b48c70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,6 +31,7 @@ dependencies = [ "axel", "bitflags", "bootloader", + "clparse", "cpuio", "ext2", "externc-libm", @@ -161,6 +162,16 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "clparse" +version = "0.1.0" +source = "git+https://git.ablecorp.us/able/core_utils#46a97f827bd11f3cea8dcab797b9697d9485c4b3" +dependencies = [ + "hashbrown", + "log", + "toml", +] + [[package]] name = "colored" version = "2.0.0" diff --git a/ableos/Cargo.toml b/ableos/Cargo.toml index 151a0299..665889b5 100644 --- a/ableos/Cargo.toml +++ b/ableos/Cargo.toml @@ -71,6 +71,8 @@ versioning = { git = "https://git.ablecorp.us/able/aos_userland" } # embedded-graphics = "*" pc-keyboard = "0.5" # mini-backtrace = "0.1" +clparse = { git = "https://git.ablecorp.us/able/core_utils", default-features = false } + [dependencies.linked_list_allocator] version = "0.9.0" diff --git a/ableos/assets/kernel.toml b/ableos/assets/kernel.toml index af5569e4..efcb00c0 100644 --- a/ableos/assets/kernel.toml +++ b/ableos/assets/kernel.toml @@ -6,6 +6,7 @@ user_processes = ["shell"] enabled = true level = "Trace" log_to_serial = true +log_to_vterm = false filter = ["ableos::ps2_mouse", "ableos::vterm"] diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index 2f6cfcff..a3ae22ee 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -140,7 +140,6 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac DecodedKey::Unicode(chr) => match chr { '\n' => { KEYBUFF.lock().push('\n'); - trace!("ENTER"); } // Backspace '\u{8}' => { diff --git a/ableos/src/boot_conf.rs b/ableos/src/boot_conf.rs index 87f6530b..f3248c2a 100644 --- a/ableos/src/boot_conf.rs +++ b/ableos/src/boot_conf.rs @@ -52,6 +52,7 @@ impl Default for KernelConfig { pub struct LoggingConfig { pub enabled: bool, pub log_to_serial: bool, + pub log_to_vterm: bool, pub level: LogLevel, pub filter: Vec, } diff --git a/ableos/src/devices/pci/devices.rs b/ableos/src/devices/pci/devices.rs index 35f25ba6..a10f97f4 100644 --- a/ableos/src/devices/pci/devices.rs +++ b/ableos/src/devices/pci/devices.rs @@ -17,3 +17,4 @@ impl DeviceID { } pub const VMWARE_SVGA2: DeviceID = DeviceID::new(VMware, 0x0405); +pub const S3INC_TRIO64V2: DeviceID = DeviceID::new(S3Inc, 0x8900); diff --git a/ableos/src/devices/pci/support.rs b/ableos/src/devices/pci/support.rs index d0998ada..793074f9 100644 --- a/ableos/src/devices/pci/support.rs +++ b/ableos/src/devices/pci/support.rs @@ -9,7 +9,7 @@ use super::devices::*; pub fn check_pci_support(device_id: DeviceID) -> bool { match device_id { VMWARE_SVGA2 => true, - + S3INC_TRIO64V2 => true, _ => false, } } diff --git a/ableos/src/logger.rs b/ableos/src/logger.rs index 34cb8c46..1dd878ea 100644 --- a/ableos/src/logger.rs +++ b/ableos/src/logger.rs @@ -47,18 +47,20 @@ impl log::Log for SimpleLogger { None => 0, }; - let msg = format!( - // "[{}{}$RESET$][$GREEN${}$RESET$]{}\n", - "[{}{:05}\0RESET\0][\0GREEN\0{}\0RESET\0][\0BLUE\0{}@{}\0RESET\0] {}", - color.1, - record.level(), - time_float, - mod_path, - line, - record.args(), - ); + if KERNEL_CONF.logging.log_to_vterm { + let msg = format!( + // "[{}{}$RESET$][$GREEN${}$RESET$]{}\n", + "[{}{:05}\0RESET\0][\0GREEN\0{}\0RESET\0][\0BLUE\0{}@{}\0RESET\0] {}", + color.1, + record.level(), + time_float, + mod_path, + line, + record.args(), + ); - // println!("{msg}"); + println!("{msg}"); + } if KERNEL_CONF.logging.log_to_serial { serial_println!( diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index 6599f989..2948cc9f 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -7,7 +7,6 @@ use crate::arch::drivers::sysinfo::master; use crate::arch::interrupts::{reset_pit_for_cpu, set_pit_2}; use crate::devices::pci::brute_force_scan; -use crate::image::mono_bitmap::bruh; use crate::systeminfo::{KERNEL_VERSION, RELEASE_TYPE}; use crate::time::fetch_time; use crate::KERNEL_STATE; @@ -204,6 +203,21 @@ pub fn command_parser(user: String, command: String) { let bin_name = iter.next().unwrap(); + let mut strin = String::new(); + for stri in iter { + trace!("{}", stri); + strin.push_str(stri); + } + let conf_args; + match clparse::Arguments::parse_from_string(strin) { + Ok(ok) => conf_args = ok, + Err(err) => { + println!("ERROR: {}", err); + error!("{}", err); + return; + } + }; + match bin_name { // note: able asked for rhaish to stay in the repo but will be removed // in the future so just comment it out for now @@ -217,9 +231,12 @@ pub fn command_parser(user: String, command: String) { } } - "echo" => { - echo_file(iter.next().unwrap().to_string(), fs); - } + "echo" => match conf_args.1.arguments.get("p") { + Some(path) => echo_file(path.to_string(), fs), + + None => println!("No path provided"), + }, + "test" => {} "quit" => shutdown(), @@ -252,8 +269,8 @@ pub fn command_parser(user: String, command: String) { let mut binary = vec![]; file.read_to_end(&mut binary).unwrap(); - let args = iter.collect::>(); - println!("{:?}", args); + // let args = iter.collect::>(); + // println!("{:?}", args); run_program(&binary); } }