From 123a7d880f3f3d60965e83fd3c69f945d33dbf7d Mon Sep 17 00:00:00 2001 From: Able Date: Fri, 7 Jan 2022 10:31:47 -0600 Subject: [PATCH] various changes and wat things --- ableos/Cargo.lock | 36 ++++++++++++++++ ableos/Cargo.toml | 2 + ableos/src/arch/x86_64/interrupts.rs | 11 ++++- ableos/src/experiments/absi.rs | 1 - .../src/experiments/compositor/compositor.rs | 7 ++++ ableos/src/experiments/compositor/mod.rs | 3 ++ .../{wm.rs => compositor/window.rs} | 24 +++++++++-- ableos/src/experiments/compositor/wm.rs | 1 + ableos/src/experiments/mod.rs | 12 +++--- ableos/src/kmain.rs | 14 ++++--- ableos/src/lib.rs | 3 ++ ableos/src/log.rs | 6 ++- ableos/src/panic.rs | 2 +- ableos/src/vga_e.rs | 41 +++++++++++++++++++ ableos/src/wasm/mod.rs | 5 ++- ableos/src/wasm/text/example.wat | 0 16 files changed, 146 insertions(+), 22 deletions(-) create mode 100644 ableos/src/experiments/compositor/compositor.rs create mode 100644 ableos/src/experiments/compositor/mod.rs rename ableos/src/experiments/{wm.rs => compositor/window.rs} (54%) create mode 100644 ableos/src/experiments/compositor/wm.rs create mode 100644 ableos/src/vga_e.rs create mode 100644 ableos/src/wasm/text/example.wat diff --git a/ableos/Cargo.lock b/ableos/Cargo.lock index 09b268deb..de00b7bed 100644 --- a/ableos/Cargo.lock +++ b/ableos/Cargo.lock @@ -16,6 +16,7 @@ dependencies = [ "qoi_rs", "spin", "uart_16550", + "vga", "volatile 0.2.7", "wasmi", "x86_64", @@ -45,6 +46,21 @@ version = "0.9.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b0718f186cd449b21f044683933284ed90fb83f3e13949ff0e03b0b6f02e38e" +[[package]] +name = "conquer-once" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c6d3a9775a69f6d1fe2cc888999b67ed30257d3da4d2af91984e722f2ec918a" +dependencies = [ + "conquer-util", +] + +[[package]] +name = "conquer-util" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e763eef8846b13b380f37dfecda401770b0ca4e56e95170237bd7c25c7db3582" + [[package]] name = "cpuio" version = "0.3.0" @@ -64,6 +80,12 @@ dependencies = [ "libm", ] +[[package]] +name = "font8x8" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875488b8711a968268c7cf5d139578713097ca4635a76044e8fe8eedf831d07e" + [[package]] name = "lazy_static" version = "1.4.0" @@ -191,6 +213,20 @@ dependencies = [ "x86_64", ] +[[package]] +name = "vga" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cbcb7bfff998d176ffb8f2c3dfd6cb0fe62740e36dee6c64fc3928c01001bf" +dependencies = [ + "bitflags", + "conquer-once", + "font8x8", + "num-traits", + "spinning_top", + "x86_64", +] + [[package]] name = "volatile" version = "0.2.7" diff --git a/ableos/Cargo.toml b/ableos/Cargo.toml index 5ca3e3b56..18dcda3ba 100644 --- a/ableos/Cargo.toml +++ b/ableos/Cargo.toml @@ -30,6 +30,8 @@ linked_list_allocator = "0.9.0" lliw = "0.2.0" qoi_rs = "*" spin = "0.5.2" +vga = "*" + [dependencies.wasmi] default-features = false diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index ef6ab7ad2..65148cc28 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -1,7 +1,9 @@ use crate::{ arch::{drivers::vga::WRITER, gdt}, + kmain::KEY_BUFFER, print, println, }; +use alloc::string::ToString; use lazy_static::lazy_static; use pic8259::ChainedPics; use spin; @@ -97,7 +99,14 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac } } - crate::kmain::key_entropy(character.try_into().unwrap()); + let crazy = true; + if crazy { + let mut xyz = crate::kmain::KEY_BUFFER.lock(); + println!("{:?}", &xyz); + xyz.push(character.try_into().unwrap()); + + crate::kmain::key_entropy(character.try_into().unwrap()); + } } DecodedKey { kind: DecodedKeyKind::RawKey, diff --git a/ableos/src/experiments/absi.rs b/ableos/src/experiments/absi.rs index 4bbdd913c..ee4c4b11a 100644 --- a/ableos/src/experiments/absi.rs +++ b/ableos/src/experiments/absi.rs @@ -2,7 +2,6 @@ use crate::{ arch::drivers::vga::{set_vga_color, Color}, kprint, }; - pub fn colorify(eval: &str) { let y = eval.split("$"); for z in y { diff --git a/ableos/src/experiments/compositor/compositor.rs b/ableos/src/experiments/compositor/compositor.rs new file mode 100644 index 000000000..2ea6da002 --- /dev/null +++ b/ableos/src/experiments/compositor/compositor.rs @@ -0,0 +1,7 @@ +pub struct Compositor {} + +impl Compositor { + pub fn new() -> Self { + Self {} + } +} diff --git a/ableos/src/experiments/compositor/mod.rs b/ableos/src/experiments/compositor/mod.rs new file mode 100644 index 000000000..a09d7f8dd --- /dev/null +++ b/ableos/src/experiments/compositor/mod.rs @@ -0,0 +1,3 @@ +//! +pub mod window; +pub mod compositor; \ No newline at end of file diff --git a/ableos/src/experiments/wm.rs b/ableos/src/experiments/compositor/window.rs similarity index 54% rename from ableos/src/experiments/wm.rs rename to ableos/src/experiments/compositor/window.rs index cd02d3c39..683cfb76f 100644 --- a/ableos/src/experiments/wm.rs +++ b/ableos/src/experiments/compositor/window.rs @@ -1,15 +1,31 @@ -//! used to give a base line example of windows and window handling use crate::driver_traits::graphics::Point; + +use alloc::string::String; +use alloc::vec::Vec; + +pub struct MenuOption { + symbol: char, +} + +pub type MenuBar = Vec; + pub struct Window { - // title: String, + title: String, position: Point, fullscreen: bool, } // all of these should return a result impl Window { - pub fn fullscreen(&mut self) -> Result<(), u8> { + pub fn new(title: String, position: Point, fullscreen: bool) -> Self { + Self { + title, + position, + fullscreen, + } + } + + pub fn fullscreen(&mut self) { self.fullscreen = true; - Ok(()) } pub fn revert_fullscreen(&mut self) { self.fullscreen = false; diff --git a/ableos/src/experiments/compositor/wm.rs b/ableos/src/experiments/compositor/wm.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/ableos/src/experiments/compositor/wm.rs @@ -0,0 +1 @@ + diff --git a/ableos/src/experiments/mod.rs b/ableos/src/experiments/mod.rs index 194bfc328..de46d0778 100644 --- a/ableos/src/experiments/mod.rs +++ b/ableos/src/experiments/mod.rs @@ -2,14 +2,12 @@ pub mod absi; pub mod clip; +pub mod compositor; +pub mod futex; +pub mod info; +pub mod kinfo; +pub mod mail; pub mod server; pub mod systeminfo; pub mod virtual_memory; -// pub mod wm; -// added for experimental use -pub mod kinfo; -pub mod mail; - -pub mod futex; -pub mod info; pub const BANNER: &str = include_str!("banner.txt"); diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index eeec09389..ff8da2bfe 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -1,6 +1,8 @@ #![allow(clippy::empty_loop)] -use crate::{experiments::info::master, relib::clparse}; +use alloc::string::{String, ToString}; + +use crate::{experiments::info::master, log::LOG_STATE, relib::clparse, vga_e}; use { crate::{ @@ -19,11 +21,11 @@ use { pub extern "C" fn stack_overflow() -> u8 { stack_overflow(); // meme number - 69 // NOTE: Any specific reason for this number asside from memes? + 69 // NOTE: Any specific reason for this number aside from memes? } lazy_static! { - pub static ref KEY_BUFFER: [DecodedKey; 256] = [DecodedKey::RawKey(123); 256]; + pub static ref KEY_BUFFER: spin::Mutex = spin::Mutex::new("".to_string()); pub static ref KEY_BUFFER_POINTER: u8 = 0; pub static ref THREAD_LIST: spin::Mutex = spin::Mutex::new(vec![]); pub static ref TICK: spin::Mutex = spin::Mutex::new(0); @@ -32,6 +34,7 @@ lazy_static! { #[no_mangle] pub fn kernel_main() -> ! { init::init(); + // LOG_STATE.lock().log_to_screen = false; let mut a_thread = Thread::new(); @@ -39,13 +42,11 @@ pub fn kernel_main() -> ! { a_thread.new_task(test_fn); a_thread.new_task(test_fn); THREAD_LIST.lock().push(a_thread); - GraphicsBuffer::draw(); GraphicsBuffer::hide_cursor(); crate::wasm::evaluate(); info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION); - info!( "Brand String: {:?}", master().unwrap().brand_string().unwrap() @@ -57,6 +58,9 @@ pub fn kernel_main() -> ! { { clparse::test(); } + + // vga_e::test_it_fucko(); + // stack_overflow(); // crate::arch::shutdown(); sloop() diff --git a/ableos/src/lib.rs b/ableos/src/lib.rs index 890c99955..38b204d25 100644 --- a/ableos/src/lib.rs +++ b/ableos/src/lib.rs @@ -42,3 +42,6 @@ pub mod wasm; pub extern crate alloc; pub extern crate externc_libm as libm; + +/////////////////////////////// +pub mod vga_e; diff --git a/ableos/src/log.rs b/ableos/src/log.rs index e32af3af6..2a76199ab 100644 --- a/ableos/src/log.rs +++ b/ableos/src/log.rs @@ -42,7 +42,11 @@ impl Log for ANSISerialLogger { ); } if LOG_STATE.lock().log_to_screen { - println!("[$BLUE$Debug$RESET$][$GREEN$FakeTempTime$RESET$] {}", val); + // NOTE: LIGHTBLUE because gamma color theory probably + println!( + "[$LIGHTBLUE$Debug$RESET$][$GREEN$FakeTempTime$RESET$] {}", + val + ); } } fn error(val: &str) { diff --git a/ableos/src/panic.rs b/ableos/src/panic.rs index ef857b6d3..b45e8c5d7 100644 --- a/ableos/src/panic.rs +++ b/ableos/src/panic.rs @@ -5,7 +5,7 @@ use { #[panic_handler] fn panic(info: &PanicInfo) -> ! { - println!("{}", info); + // println!("{}", info); error!("{}", info); sloop() } diff --git a/ableos/src/vga_e.rs b/ableos/src/vga_e.rs new file mode 100644 index 000000000..e18a2426b --- /dev/null +++ b/ableos/src/vga_e.rs @@ -0,0 +1,41 @@ +use alloc::string::String; + +use vga::colors::Color16; +use vga::writers::{Graphics640x480x16, GraphicsWriter}; + +pub fn test_it_fucko() { + let mode = Graphics640x480x16::new(); + mode.set_mode(); + mode.clear_screen(Color16::Black); + + mode.draw_line((80, 60), (80, 420), Color16::White); + mode.draw_line((80, 60), (540, 60), Color16::White); + + { + let offset = 110; + mode.draw_character(offset - 15 - 4, 60 + 15 - 4, 'x', Color16::Red); + + mode.draw_line( + (offset.try_into().unwrap(), 60), + (offset.try_into().unwrap(), 90), + Color16::White, + ); + } + + mode.draw_line((80, 420), (540, 420), Color16::White); + mode.draw_line((540, 420), (540, 60), Color16::White); + mode.draw_line((80, 90), (540, 90), Color16::White); + for (offset, character) in "ableOS".chars().enumerate() { + mode.draw_character(270 + offset * 8, 72, character, Color16::White) + } +} + +pub trait GraphicsAPI { + fn addShader() {} +} + +pub struct Buffer { + label: String, + resolution: (u64, u64), + // pointer +} diff --git a/ableos/src/wasm/mod.rs b/ableos/src/wasm/mod.rs index 96f06f817..fefee1797 100644 --- a/ableos/src/wasm/mod.rs +++ b/ableos/src/wasm/mod.rs @@ -51,7 +51,7 @@ impl Externals for HostFunctions { } let arg: u64 = args.nth(0); let buf = unsafe { String::from_utf8_unchecked(arg.to_le_bytes().to_vec()) }; - println!["helllooooooo{}", buf]; + println!["{}", buf]; Ok(None) } SysCall::CONSOLE_GET_TITLE => Ok(None), @@ -90,7 +90,8 @@ impl ModuleImportResolver for HostFunctions { } pub fn evaluate() { - let wasm_binary = include_bytes!("bin/console_out_test.wasm"); + // let wasm_binary = include_bytes!("bin/console_out_test.wasm"); + let wasm_binary = include_bytes!("bin/rust.wasm"); // Load wasm binary and prepare it for instantiation. let module = wasmi::Module::from_buffer(&wasm_binary).expect("failed to load wasm"); diff --git a/ableos/src/wasm/text/example.wat b/ableos/src/wasm/text/example.wat new file mode 100644 index 000000000..e69de29bb