From d4e4d7046126e9ca391fe171170c0a5f4506cc17 Mon Sep 17 00:00:00 2001 From: Able Date: Thu, 17 Feb 2022 04:05:56 -0600 Subject: [PATCH] rhai shell tinkering --- ableos/Cargo.lock | 5 +++-- ableos/Cargo.toml | 2 +- ableos/src/arch/x86_64/interrupts.rs | 13 +++++------- ableos/src/kmain.rs | 4 +--- ableos/src/scratchpad.rs | 31 +++++++++++++++++++++++++--- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/ableos/Cargo.lock b/ableos/Cargo.lock index 136d4b9..f1bfc64 100644 --- a/ableos/Cargo.lock +++ b/ableos/Cargo.lock @@ -46,6 +46,7 @@ dependencies = [ "picorand", "pretty-hex", "rdrand", + "rhai", "rkyv", "serde", "serde_json", @@ -483,9 +484,9 @@ dependencies = [ [[package]] name = "rhai" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898b114d6cfa18af4593393fdc6c7437118e7e624d97f635fba8c75fd5c06f56" +checksum = "49c94fda0280985896ed6d8bf0b43bbb5a7f0e39ccc8728ac907ddb4f06dae94" dependencies = [ "ahash", "core-error", diff --git a/ableos/Cargo.toml b/ableos/Cargo.toml index 9397f58..4a6072c 100644 --- a/ableos/Cargo.toml +++ b/ableos/Cargo.toml @@ -62,7 +62,7 @@ picorand = "*" genfs = "0.1.0" # pc-beeper = "0.1.0" pc-beeper = {git = "https://github.com/AbleOS/pc-beeper"} - +rhai = "1.5" pci = {git="https://gitlab.com/robigalia/pci"} libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"} diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index eb0e06f..1429a9b 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -1,7 +1,7 @@ use crate::{ arch::{drivers::vga::WRITER, gdt}, kernel_state::KERNEL_STATE, - print, println, + print, println, KEYBUFF, }; use lazy_static::lazy_static; @@ -94,16 +94,13 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac // WRITER.lock().backspace(); } - // Enter - 0x0A => { - // let _xyz = crate::kmain::KEY_BUFFER.lock(); - - // print!("{}", char::try_from(character).unwrap()); - } - 0x5E => KERNEL_STATE.lock().shutdown(), _ => { + let mut buff = KEYBUFF.lock(); + + buff.push(character as u8 as char); + print!("{}", char::try_from(character).unwrap()); } } diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index 0cec6e7..64caa08 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -88,7 +88,7 @@ pub fn kernel_main() -> ! { start_facepalm(); scratchpad(); - loop { + if false { disable(); let mut mode = SCREEN_BUFFER.lock(); mode.force_redraw(); @@ -104,8 +104,6 @@ pub fn kernel_main() -> ! { // sloop::halt(); } - // } - sloop() } diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index 58c62c7..36300c4 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -31,7 +31,9 @@ pub fn scratchpad() { debug!("{}", key); } - interp(); + // interp(); + + rhai_shell(); } pub struct PciIO {} @@ -61,7 +63,7 @@ impl PortOps for PciIO { cpuio::outl(val, port as u16); } } - +/* /// An experimental process message format pub struct ProcessMessage { pub to_pid: PID, @@ -71,7 +73,7 @@ pub struct ProcessMessage { pub sender_time: SecondsTime, } // -use libwasm::syscalls::time_calls::SecondsTime; +// use libwasm::syscalls::time_calls::SecondsTime; impl ProcessMessage { pub fn new(to_pid: PID, from_pid: PID, message: [u8; 2048]) -> Self { @@ -86,3 +88,26 @@ impl ProcessMessage { } } } +*/ + +pub fn rhai_shell() { + let mut engine = rhai::Engine::new(); + + let ret = engine.eval::("1 + 2"); + + match ret { + Ok(x) => println!("{}", x), + Err(e) => println!("{}", e), + } + + loop {} +} +lazy_static::lazy_static!( + pub static ref KEYBUFF: spin::Mutex> = spin::Mutex::new( + Vec::new()) + ; +); + +use alloc::string::String; + +use crate::arch::sloop;