From ce765f2488d847b4e9bf2d7c98f236daa66e6836 Mon Sep 17 00:00:00 2001 From: able Date: Wed, 3 Aug 2022 02:09:34 -0500 Subject: [PATCH] fix backspace --- ableos/src/arch/x86_64/interrupts.rs | 3 +- ableos/src/channels.rs | 40 ------------ ableos/src/lib.rs | 3 +- ableos/src/print.rs | 2 + ableos/src/relib/image/mono_bitmap.rs | 3 + ableos/src/scratchpad.rs | 11 ++-- ableos/src/vgai.rs | 62 ------------------- ableos/src/vterm.rs | 13 ++-- ableos/src/wasm_jumploader/host_functions.rs | 12 +++- userland/root_fs/ext2.img | Bin 4194304 -> 4194304 bytes 10 files changed, 34 insertions(+), 115 deletions(-) delete mode 100644 ableos/src/channels.rs delete mode 100644 ableos/src/vgai.rs diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index e08eb07f..94f0a1ac 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -1,6 +1,6 @@ use core::panic::PanicInfo; -use crate::{arch::gdt, println, rhai_shell::KEYBUFF}; +use crate::{arch::gdt, print, println, rhai_shell::KEYBUFF}; use cpuio::outb; use pic8259::ChainedPics; use qrcode::QrCode; @@ -141,6 +141,7 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac // TODO: Fix this and apply to new term KEYBUFF.lock().push(8.into()); + // trace!("8"); // print!("\u{8}"); } // '^' => KERNEL_STATE.lock().shutdown(), diff --git a/ableos/src/channels.rs b/ableos/src/channels.rs deleted file mode 100644 index ab0e73d9..00000000 --- a/ableos/src/channels.rs +++ /dev/null @@ -1,40 +0,0 @@ -use alloc::collections::VecDeque; - -#[derive(Debug)] -pub struct ChannelPermission { - pub owner: bool, - pub producer: bool, - - pub consumer: bool, - /// Whether or not the process can be destructive about reading - pub distructive_consumer: bool, -} - -#[derive(Debug)] -pub struct Channel { - inner: VecDeque, -} - -impl Channel { - pub fn new() -> Self { - let deq = VecDeque::from([]); - - Self { inner: deq } - } - - pub fn read(&mut self) -> Result { - if let Some(abc) = self.inner.pop_front() { - return Ok(abc); - } - return Err(ChannelError::EmptyBuffer); - } - - pub fn send(&mut self, data: u8) { - self.inner.push_back(data); - } -} - -pub enum ChannelError { - EmptyBuffer, - InvalidPermissions, -} diff --git a/ableos/src/lib.rs b/ableos/src/lib.rs index b2995995..f6823ee9 100644 --- a/ableos/src/lib.rs +++ b/ableos/src/lib.rs @@ -68,14 +68,13 @@ pub mod wasm_jumploader; pub mod allocator; // pub use allocator as aalloc; -pub mod channels; pub mod handle; pub mod hardware; pub mod ipc; pub mod panic; mod unicode_utils; pub mod vga_e; -pub mod vgai; +// pub mod vgai; pub mod vterm; #[prelude_import] diff --git a/ableos/src/print.rs b/ableos/src/print.rs index 805ad50f..6af2a8ff 100644 --- a/ableos/src/print.rs +++ b/ableos/src/print.rs @@ -41,8 +41,10 @@ impl core::fmt::Write for Stdout { // trace!("printing"); // x86_64::instructions::interrupts::without_interrupts(|| { let mut term = TERM.lock(); + term.set_dirty(true); term.print(s); + drop(term); // }); // trace!("Finished printing"); diff --git a/ableos/src/relib/image/mono_bitmap.rs b/ableos/src/relib/image/mono_bitmap.rs index 56c5a79b..69956209 100644 --- a/ableos/src/relib/image/mono_bitmap.rs +++ b/ableos/src/relib/image/mono_bitmap.rs @@ -9,6 +9,9 @@ pub fn bruh() { let xyz_old = decode(&xyz_new); + println!("{}", xyz_new.len()); + println!("{}", xyz_old.len()); + let screen_lock = VGAE.lock(); screen_lock.set_mode(); for y in 0..8 { diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index 8e1569f5..88a4aa70 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -1,5 +1,6 @@ use crate::arch::drivers::sysinfo::master; use crate::arch::interrupts::{reset_pit_for_cpu, set_pit_2}; +use crate::image::mono_bitmap::bruh; use crate::systeminfo::{KERNEL_VERSION, RELEASE_TYPE}; use crate::time::fetch_time; use crate::{ @@ -65,6 +66,8 @@ pub fn scratchpad() { println!("\0RED\0OHNO\0RESET\0"); + // bruh(); + disable(); let tick_time = fetch_time(); @@ -133,7 +136,7 @@ pub fn real_shell() { let mut buf = String::new(); print!("{}", prompt); - + // panic!(":<"); loop { match x86_64::instructions::interrupts::without_interrupts(|| KEYBUFF.lock().pop()) { Some('\n') => { @@ -151,9 +154,9 @@ pub fn real_shell() { buf.clear(); print!("{}", prompt); } - Some('\u{0008}') => { - print!("\u{08}"); - + Some('\u{8}') => { + print!("\u{8}"); + trace!(""); buf.pop(); } diff --git a/ableos/src/vgai.rs b/ableos/src/vgai.rs deleted file mode 100644 index 18f45d30..00000000 --- a/ableos/src/vgai.rs +++ /dev/null @@ -1,62 +0,0 @@ -pub enum Color { - /// Represents the color `Black (0x0)`. - Black = 0x0, - /// Represents the color `Blue (0x1)`. - Blue = 0x1, - /// Represents the color `Green (0x2)`. - Green = 0x2, - /// Represents the color `Cyan (0x3)`. - Cyan = 0x3, - /// Represents the color `Red (0x4)`. - Red = 0x4, - /// Represents the color `Magenta (0x5)`. - Magenta = 0x5, - /// Represents the color `Brown (0x6)`. - Brown = 0x6, - /// Represents the color `LightGrey (0x7)`. - LightGrey = 0x7, - /// Represents the color `DarkGrey (0x8)`. - DarkGrey = 0x8, - /// Represents the color `LightBlue (0x9)`. - LightBlue = 0x9, - /// Represents the color `LightGreen (0xA)`. - LightGreen = 0xA, - /// Represents the color `LightCyan (0xB)`. - LightCyan = 0xB, - /// Represents the color `LightRed (0xC)`. - LightRed = 0xC, - /// Represents the color `Pink (0xD)`. - Pink = 0xD, - /// Represents the color `Yellow (0xE)`. - Yellow = 0xE, - /// Represents the color `White (0xF)`. - White = 0xF, -} - -const VGA_BUFFER_SIZE: usize = 480; - -pub struct ScreenBuffer {} -impl ScreenBuffer { - pub fn initialise() {} - - pub fn flip_buffer() { - /* - before doing anything past here we need to tell the VGA about some things - */ - let setup = false; - if setup { - use Color::*; - let dualpixel: u8 = Red as u8; - - let buff: [u8; VGA_BUFFER_SIZE] = [dualpixel; VGA_BUFFER_SIZE]; - - let buff_ptr = buff.as_ptr(); - let vga_buffer = 0xb8000 as *mut u8; - - use core::ptr; - unsafe { - ptr::copy(buff_ptr, vga_buffer, VGA_BUFFER_SIZE); - } - } - } -} diff --git a/ableos/src/vterm.rs b/ableos/src/vterm.rs index 7f83dabc..6ed775dc 100644 --- a/ableos/src/vterm.rs +++ b/ableos/src/vterm.rs @@ -10,17 +10,20 @@ pub struct Term { dirty: bool, color: Color16, term: [(char, Color16); 80 * 60], + back_buffer: [u8; 640 * 480], x: u8, } impl Term { pub fn new() -> Self { let mode = VGAE.lock(); mode.set_mode(); + // let fb = mode.get_frame_buffer(); drop(mode); Self { dirty: false, x: 0, + back_buffer: [0; 640 * 480], term: [('\0', Color16::LightGrey); 80 * 60], color: Color16::White, } @@ -67,11 +70,11 @@ impl Term { if self.x == 80 { self.move_up(); } - + // trace!("C"); match c { '\u{08}' => { if self.x == 0 { - // trace!("IMPOSSIBLE BACKSPACE"); + trace!("IMPOSSIBLE BACKSPACE"); return; } trace!("BACKSPACE"); @@ -111,7 +114,7 @@ impl Term { pub fn draw_term(&mut self) { if self.is_dirty() { - trace!("Redrawing"); + // trace!("Redrawing"); use Color16::*; let mode = VGAE.lock(); mode.clear_screen(DarkGrey); @@ -153,7 +156,7 @@ impl Term { } self.set_dirty(false); - trace!("Finished drawing"); + // trace!("Finished drawing"); } } } @@ -203,7 +206,7 @@ pub enum Token { #[token(" ")] Space, - #[regex("[\t\n!-~]+", text_lex, priority = 0)] + #[regex("[\t\n\u{8}█!-~]+", text_lex, priority = 0)] Text(String), } diff --git a/ableos/src/wasm_jumploader/host_functions.rs b/ableos/src/wasm_jumploader/host_functions.rs index 04b956f1..f560d3a2 100644 --- a/ableos/src/wasm_jumploader/host_functions.rs +++ b/ableos/src/wasm_jumploader/host_functions.rs @@ -1,4 +1,4 @@ -use crate::{arch::generate_process_pass, rhai_shell::KEYBUFF}; +use crate::{arch::generate_process_pass, ipc::channel::ChannelMessage, rhai_shell::KEYBUFF}; use wasmi::{ Error, Externals, FuncInstance, FuncRef, ModuleImportResolver, RuntimeArgs, RuntimeValue, Signature, Trap, ValueType, @@ -165,4 +165,14 @@ host_externals! { print!("{}", char::from(chr)); Ok(None) } + + + + // TODO: Send a message to a channel + 6: send_channel_message(){ + + + Ok(None) + + } } diff --git a/userland/root_fs/ext2.img b/userland/root_fs/ext2.img index 1b7a899a870d33304b5f3d9ffcd33e618f098153..762bece5e084b6d5140ba9b727274b81d923afd2 100644 GIT binary patch delta 327 zcmW;8IZgsm0D$4VVMO2!49FtNGAtq};sOkd0v0xu7A9m`DlTC%356t71kYfj1xhhz zpy3{K07?>nExzQlZCkOi(p2%X4626zQ*+0gm^*H+P4!7A6MZ4J;{97V;>R}|dcHJw zJ%4`n{zs1X;xAKay-778(#RkS y13BbTKoMss;T&aDaDhuyafKSLaf4gjp^gTcFwsIA9dvPz2lUX#z>(JD?&B8)GF?po delta 322 zcmW;8NlwC00D$4V*II^GW|2{u1q2nSP;g@5#$|V;TRjI!69bsI+&yyZDrY?Hxh+YcWjpduq+7I;?A>U(Lv6Q>u=d0%YEcRc{-1v{0{RuxG%3Uc} zKth9#6Bq~}h!Db1FcCo%F~pHT5-FS_jWcABMGkosP{cVdP(m3MR8d164P2s$7TUN% j2VGp_2Dj*;j{z*)VTciIj4{DI9`J}KJRg)h{rx@yo~l{1