rhai shell tinkering

This commit is contained in:
Able 2022-02-17 04:05:56 -06:00
parent 19508c979e
commit d4e4d70461
5 changed files with 38 additions and 17 deletions

5
ableos/Cargo.lock generated
View file

@ -46,6 +46,7 @@ dependencies = [
"picorand", "picorand",
"pretty-hex", "pretty-hex",
"rdrand", "rdrand",
"rhai",
"rkyv", "rkyv",
"serde", "serde",
"serde_json", "serde_json",
@ -483,9 +484,9 @@ dependencies = [
[[package]] [[package]]
name = "rhai" name = "rhai"
version = "1.4.1" version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "898b114d6cfa18af4593393fdc6c7437118e7e624d97f635fba8c75fd5c06f56" checksum = "49c94fda0280985896ed6d8bf0b43bbb5a7f0e39ccc8728ac907ddb4f06dae94"
dependencies = [ dependencies = [
"ahash", "ahash",
"core-error", "core-error",

View file

@ -62,7 +62,7 @@ picorand = "*"
genfs = "0.1.0" genfs = "0.1.0"
# pc-beeper = "0.1.0" # pc-beeper = "0.1.0"
pc-beeper = {git = "https://github.com/AbleOS/pc-beeper"} pc-beeper = {git = "https://github.com/AbleOS/pc-beeper"}
rhai = "1.5"
pci = {git="https://gitlab.com/robigalia/pci"} pci = {git="https://gitlab.com/robigalia/pci"}
libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"} libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"}

View file

@ -1,7 +1,7 @@
use crate::{ use crate::{
arch::{drivers::vga::WRITER, gdt}, arch::{drivers::vga::WRITER, gdt},
kernel_state::KERNEL_STATE, kernel_state::KERNEL_STATE,
print, println, print, println, KEYBUFF,
}; };
use lazy_static::lazy_static; use lazy_static::lazy_static;
@ -94,16 +94,13 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac
// WRITER.lock().backspace(); // WRITER.lock().backspace();
} }
// Enter
0x0A => {
// let _xyz = crate::kmain::KEY_BUFFER.lock();
// print!("{}", char::try_from(character).unwrap());
}
0x5E => KERNEL_STATE.lock().shutdown(), 0x5E => KERNEL_STATE.lock().shutdown(),
_ => { _ => {
let mut buff = KEYBUFF.lock();
buff.push(character as u8 as char);
print!("{}", char::try_from(character).unwrap()); print!("{}", char::try_from(character).unwrap());
} }
} }

View file

@ -88,7 +88,7 @@ pub fn kernel_main() -> ! {
start_facepalm(); start_facepalm();
scratchpad(); scratchpad();
loop { if false {
disable(); disable();
let mut mode = SCREEN_BUFFER.lock(); let mut mode = SCREEN_BUFFER.lock();
mode.force_redraw(); mode.force_redraw();
@ -104,8 +104,6 @@ pub fn kernel_main() -> ! {
// sloop::halt(); // sloop::halt();
} }
// }
sloop() sloop()
} }

View file

@ -31,7 +31,9 @@ pub fn scratchpad() {
debug!("{}", key); debug!("{}", key);
} }
interp(); // interp();
rhai_shell();
} }
pub struct PciIO {} pub struct PciIO {}
@ -61,7 +63,7 @@ impl PortOps for PciIO {
cpuio::outl(val, port as u16); cpuio::outl(val, port as u16);
} }
} }
/*
/// An experimental process message format /// An experimental process message format
pub struct ProcessMessage { pub struct ProcessMessage {
pub to_pid: PID, pub to_pid: PID,
@ -71,7 +73,7 @@ pub struct ProcessMessage {
pub sender_time: SecondsTime, pub sender_time: SecondsTime,
} }
// //
use libwasm::syscalls::time_calls::SecondsTime; // use libwasm::syscalls::time_calls::SecondsTime;
impl ProcessMessage { impl ProcessMessage {
pub fn new(to_pid: PID, from_pid: PID, message: [u8; 2048]) -> Self { 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::<i64>("1 + 2");
match ret {
Ok(x) => println!("{}", x),
Err(e) => println!("{}", e),
}
loop {}
}
lazy_static::lazy_static!(
pub static ref KEYBUFF: spin::Mutex<Vec<char>> = spin::Mutex::new(
Vec::new())
;
);
use alloc::string::String;
use crate::arch::sloop;