From 83a02c904cbc5a5c549c1946ef82d0e0fec30c1b Mon Sep 17 00:00:00 2001 From: Able Date: Thu, 13 Jan 2022 08:54:33 -0600 Subject: [PATCH] Facepalm and aos stress test work --- .gitignore | 2 + ableos/src/arch/x86_64/interrupts.rs | 20 ++++-- ableos/src/arch/x86_64/mod.rs | 18 ++--- ableos/src/experiments/clparse.rs | 72 ------------------- ableos/src/experiments/mod.rs | 2 +- ableos/src/experiments/notification.rs | 8 +++ .../compositor.rs | 0 .../{compositor => y_compositor}/mod.rs | 0 .../{compositor => y_compositor}/window.rs | 0 .../{compositor => y_compositor}/wm.rs | 0 ableos/src/kernel_state.rs | 26 +++++++ ableos/src/kmain.rs | 56 ++++++++------- ableos/src/lib.rs | 1 + ableos/src/relib/clparse/mod.rs | 6 +- ableos/src/vga_e.rs | 12 +++- aos_wasm_stress_test/.cargo/config.toml | 2 + aos_wasm_stress_test/Cargo.lock | 7 ++ aos_wasm_stress_test/Cargo.toml | 8 +++ aos_wasm_stress_test/readme.md | 4 ++ aos_wasm_stress_test/src/main.rs | 13 ++++ facepalm/Cargo.toml | 8 +++ facepalm/readme.md | 1 + facepalm/src/main.rs | 3 + 23 files changed, 152 insertions(+), 117 deletions(-) delete mode 100644 ableos/src/experiments/clparse.rs create mode 100644 ableos/src/experiments/notification.rs rename ableos/src/experiments/{compositor => y_compositor}/compositor.rs (100%) rename ableos/src/experiments/{compositor => y_compositor}/mod.rs (100%) rename ableos/src/experiments/{compositor => y_compositor}/window.rs (100%) rename ableos/src/experiments/{compositor => y_compositor}/wm.rs (100%) create mode 100644 ableos/src/kernel_state.rs create mode 100644 aos_wasm_stress_test/.cargo/config.toml create mode 100644 aos_wasm_stress_test/Cargo.lock create mode 100644 aos_wasm_stress_test/Cargo.toml create mode 100644 aos_wasm_stress_test/readme.md create mode 100644 aos_wasm_stress_test/src/main.rs create mode 100644 facepalm/Cargo.toml create mode 100644 facepalm/readme.md create mode 100644 facepalm/src/main.rs diff --git a/.gitignore b/.gitignore index 6ea2636e7..2a685f731 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ repbuild/target ableos/target +aos_wasm_stress_test/target +facepalm/target \ No newline at end of file diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index 65148cc28..4892250a8 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -2,6 +2,7 @@ use crate::{ arch::{drivers::vga::WRITER, gdt}, kmain::KEY_BUFFER, print, println, + relib::clparse, }; use alloc::string::ToString; use lazy_static::lazy_static; @@ -93,7 +94,12 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac print!(" "); WRITER.lock().backspace(); } + // Enter + 10 => { + let xyz = crate::kmain::KEY_BUFFER.lock(); + // println!("{:?}", clparse::Command::parse(xyz.to_string())); + } _ => { print!("{}", char::try_from(character).unwrap()); } @@ -102,8 +108,8 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac let crazy = true; if crazy { let mut xyz = crate::kmain::KEY_BUFFER.lock(); - println!("{:?}", &xyz); xyz.push(character.try_into().unwrap()); + // println!("{:?}", &xyz); crate::kmain::key_entropy(character.try_into().unwrap()); } @@ -111,11 +117,17 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac DecodedKey { kind: DecodedKeyKind::RawKey, value: key, - } => { - if KeyCode::from(key) != KeyCode::AltLeft { + } => match KeyCode::from(key) { + KeyCode::AltLeft => {} + + KeyCode::AltRight => { + let xyz = crate::kmain::KEY_BUFFER.lock(); + println!("{:?}", &xyz); + } + _ => { print!("{:?}", KeyCode::from(key)) } - } + }, } } } diff --git a/ableos/src/arch/x86_64/mod.rs b/ableos/src/arch/x86_64/mod.rs index 03a95cb01..99b201aa7 100644 --- a/ableos/src/arch/x86_64/mod.rs +++ b/ableos/src/arch/x86_64/mod.rs @@ -1,4 +1,4 @@ -use crate::arch::drivers::allocator; // new import +use crate::{arch::drivers::allocator, info}; use bootloader::{entry_point, BootInfo}; use x86_64::{ instructions::hlt, @@ -19,22 +19,22 @@ pub fn start(boot_info: &'static BootInfo) -> ! { let mut mapper = unsafe { memory::init(phys_mem_offset) }; let mut frame_allocator = unsafe { memory::BootInfoFrameAllocator::init(&boot_info.memory_map) }; + if false { + let page = Page::containing_address(VirtAddr::new(0xdeadbeaf000)); + memory::create_example_mapping(page, &mut mapper, &mut frame_allocator); - let page = Page::containing_address(VirtAddr::new(0xdeadbeaf000)); - memory::create_example_mapping(page, &mut mapper, &mut frame_allocator); - - // let page_ptr: *mut u64 = page.start_address().as_mut_ptr(); - // unsafe { page_ptr.offset(400).write_volatile(0xf021_f077_f065_804e) }; + let page_ptr: *mut u64 = page.start_address().as_mut_ptr(); + unsafe { page_ptr.offset(400).write_volatile(0xf021_f077_f065_804e) }; + } allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed"); - + // info!("{:?}", boot_info); crate::kmain::kernel_main(); - - // sloop(); } #[allow(unused)] pub fn shutdown() -> ! { + info!("Shutting down"); unsafe { cpuio::outw(0x2000, 0x604); } diff --git a/ableos/src/experiments/clparse.rs b/ableos/src/experiments/clparse.rs deleted file mode 100644 index c4b12d4f7..000000000 --- a/ableos/src/experiments/clparse.rs +++ /dev/null @@ -1,72 +0,0 @@ -/* -clparse -* A simple command line parser for ableOS -*/ - -use alloc::collections::HashMap; -use std::collections::HashMap; - -const CURRENT_PATH: &str = "file://test/"; - -#[derive(Debug)] -struct Command { - root_command: String, - arguments: HashMap, -} - -impl Command { - pub fn parse(command: String) -> Command { - let split_command = command.split("?"); - let mut root = "".to_string(); - let mut rootCount = 0; - let mut args = HashMap::::new(); - for subcommand in split_command { - match rootCount { - 0 => root = subcommand.to_string(), - 1 => { - for subarg in subcommand.split("&") { - let mut arg1 = ""; - let mut arg2 = ""; - let mut arg_count = 0; - for arg in subarg.split("=") { - if arg_count == 0 { - arg1 = arg; - } else { - arg2 = arg; - } - arg_count += 1; - } - args.insert(arg1.to_string(), arg2.to_string()); - } - } - _ => {} - } - rootCount += 1; - } - - Command { - root_command: root, - arguments: args, - } - } -} -fn main() { - let x = Command::parse("ls?path=".to_string()); - - let y = &x.arguments["path"]; - parsePath(y.to_string()); -} - -fn parsePath(path: String) { - if path.len() == 0 { - println!("EMPTY PATH"); - } else { - match &path[..1] { - "@" => println!("PARTIAL PATH: {}{}", CURRENT_PATH, path), - "/" => println!("FULL PATH: {}", path), - _ => { - println!("MALFORMED PATH: {}", path) - } - } - } -} diff --git a/ableos/src/experiments/mod.rs b/ableos/src/experiments/mod.rs index de46d0778..a5d7fec56 100644 --- a/ableos/src/experiments/mod.rs +++ b/ableos/src/experiments/mod.rs @@ -2,7 +2,6 @@ pub mod absi; pub mod clip; -pub mod compositor; pub mod futex; pub mod info; pub mod kinfo; @@ -10,4 +9,5 @@ pub mod mail; pub mod server; pub mod systeminfo; pub mod virtual_memory; +pub mod y_compositor; pub const BANNER: &str = include_str!("banner.txt"); diff --git a/ableos/src/experiments/notification.rs b/ableos/src/experiments/notification.rs new file mode 100644 index 000000000..51a08de89 --- /dev/null +++ b/ableos/src/experiments/notification.rs @@ -0,0 +1,8 @@ +pub type thumbnail = u8; + +pub struct Notification { + thumbnail: thumbnail, + text_body: String, + time: u64, +} +impl Notification {} diff --git a/ableos/src/experiments/compositor/compositor.rs b/ableos/src/experiments/y_compositor/compositor.rs similarity index 100% rename from ableos/src/experiments/compositor/compositor.rs rename to ableos/src/experiments/y_compositor/compositor.rs diff --git a/ableos/src/experiments/compositor/mod.rs b/ableos/src/experiments/y_compositor/mod.rs similarity index 100% rename from ableos/src/experiments/compositor/mod.rs rename to ableos/src/experiments/y_compositor/mod.rs diff --git a/ableos/src/experiments/compositor/window.rs b/ableos/src/experiments/y_compositor/window.rs similarity index 100% rename from ableos/src/experiments/compositor/window.rs rename to ableos/src/experiments/y_compositor/window.rs diff --git a/ableos/src/experiments/compositor/wm.rs b/ableos/src/experiments/y_compositor/wm.rs similarity index 100% rename from ableos/src/experiments/compositor/wm.rs rename to ableos/src/experiments/y_compositor/wm.rs diff --git a/ableos/src/kernel_state.rs b/ableos/src/kernel_state.rs new file mode 100644 index 000000000..e1f9fd8dd --- /dev/null +++ b/ableos/src/kernel_state.rs @@ -0,0 +1,26 @@ +use lazy_static::lazy_static; + +lazy_static! { + pub static ref KERNEL_STATE: spin::Mutex = + spin::Mutex::new(KernelInternalState::new()); +} + +pub struct KernelInternalState { + should_shutdown: bool, +} + +impl KernelInternalState { + pub fn new() -> Self { + Self { + should_shutdown: false, + } + } + pub fn shutdown(&mut self) { + self.should_shutdown = true; + } + pub fn update_state(&mut self) { + if self.should_shutdown { + crate::arch::shutdown(); + } + } +} diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index ff8da2bfe..6daba8aa6 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -1,21 +1,19 @@ #![allow(clippy::empty_loop)] -use alloc::string::{String, ToString}; - -use crate::{experiments::info::master, log::LOG_STATE, relib::clparse, vga_e}; - use { crate::{ arch::{drivers::graphics::GraphicsBuffer, init, sloop}, driver_traits::graphics::Graphics, experiments::systeminfo::{KERNEL_VERSION, RELEASE_TYPE}, - keyboard::DecodedKey, relib::math::rand::RAND_HANDLE, scheduler::{test_fn, Thread, ThreadList}, }, + crate::{experiments::info::master, log::LOG_STATE, vga_e}, + alloc::string::{String, ToString}, alloc::vec, lazy_static::lazy_static, }; + #[no_mangle] #[allow(unconditional_recursion)] pub extern "C" fn stack_overflow() -> u8 { @@ -26,43 +24,48 @@ pub extern "C" fn stack_overflow() -> u8 { lazy_static! { 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); } #[no_mangle] pub fn kernel_main() -> ! { + if false { + LOG_STATE.lock().info = false; + LOG_STATE.lock().trace = false; + LOG_STATE.lock().debug = false; + } + init::init(); - // LOG_STATE.lock().log_to_screen = false; + { + let mut a_thread = Thread::new(); - let mut a_thread = Thread::new(); + a_thread.new_task(test_fn); + a_thread.new_task(test_fn); + THREAD_LIST.lock().push(a_thread); + GraphicsBuffer::draw(); + GraphicsBuffer::hide_cursor(); + } - 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() - ); - - println!("$PINK$Hi$RED$ from$GREEN$ able!$RESET$"); - println!("$RED$hi$RESET$"); - { - clparse::test(); + info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION); + info!( + "Brand String: {:?}", + master().unwrap().brand_string().unwrap() + ); + if false { + println!("$PINK$Hi$RED$ from$GREEN$ able!$RESET$"); + println!("$RED$hi$RESET$"); + } } // vga_e::test_it_fucko(); - + // KERNEL_STATE.lock().shutdown(); // stack_overflow(); - // crate::arch::shutdown(); + sloop() } @@ -71,6 +74,9 @@ pub fn tick() { let mut data = TICK.lock(); *data += 1; RAND_HANDLE.lock().seed_entropy_timer(*data); + + // println!("{}", *data); + crate::kernel_state::KERNEL_STATE.lock().update_state(); } pub fn key_entropy(key: u8) { diff --git a/ableos/src/lib.rs b/ableos/src/lib.rs index 38b204d25..de34d09be 100644 --- a/ableos/src/lib.rs +++ b/ableos/src/lib.rs @@ -44,4 +44,5 @@ pub extern crate alloc; pub extern crate externc_libm as libm; /////////////////////////////// +pub mod kernel_state; pub mod vga_e; diff --git a/ableos/src/relib/clparse/mod.rs b/ableos/src/relib/clparse/mod.rs index a5969cfae..319633d0d 100644 --- a/ableos/src/relib/clparse/mod.rs +++ b/ableos/src/relib/clparse/mod.rs @@ -17,10 +17,10 @@ pub struct Argument { } #[derive(Debug)] -struct Command { - root_command: String, +pub struct Command { + pub root_command: String, // arguments: HashMap, - arguments: Vec, + pub arguments: Vec, } impl Command { diff --git a/ableos/src/vga_e.rs b/ableos/src/vga_e.rs index e18a2426b..278a4908e 100644 --- a/ableos/src/vga_e.rs +++ b/ableos/src/vga_e.rs @@ -1,7 +1,9 @@ use alloc::string::String; -use vga::colors::Color16; -use vga::writers::{Graphics640x480x16, GraphicsWriter}; +use vga::{ + colors::Color16, + writers::{Graphics640x480x16, GraphicsWriter}, +}; pub fn test_it_fucko() { let mode = Graphics640x480x16::new(); @@ -28,10 +30,14 @@ pub fn test_it_fucko() { for (offset, character) in "ableOS".chars().enumerate() { mode.draw_character(270 + offset * 8, 72, character, Color16::White) } + + for (offset, character) in "S".chars().enumerate() { + mode.draw_character(270 + offset * 8, 50, character, Color16::White) + } } pub trait GraphicsAPI { - fn addShader() {} + fn add_shader() {} } pub struct Buffer { diff --git a/aos_wasm_stress_test/.cargo/config.toml b/aos_wasm_stress_test/.cargo/config.toml new file mode 100644 index 000000000..f4e8c002f --- /dev/null +++ b/aos_wasm_stress_test/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +target = "wasm32-unknown-unknown" diff --git a/aos_wasm_stress_test/Cargo.lock b/aos_wasm_stress_test/Cargo.lock new file mode 100644 index 000000000..c22b57753 --- /dev/null +++ b/aos_wasm_stress_test/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aos_wasm_stress_test" +version = "0.1.0" diff --git a/aos_wasm_stress_test/Cargo.toml b/aos_wasm_stress_test/Cargo.toml new file mode 100644 index 000000000..b174cd4e0 --- /dev/null +++ b/aos_wasm_stress_test/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "aos_wasm_stress_test" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/aos_wasm_stress_test/readme.md b/aos_wasm_stress_test/readme.md new file mode 100644 index 000000000..03b81cc9b --- /dev/null +++ b/aos_wasm_stress_test/readme.md @@ -0,0 +1,4 @@ + +This is a stress test and simple progrram for ableOS. + +There should be two sub commands echo and input diff --git a/aos_wasm_stress_test/src/main.rs b/aos_wasm_stress_test/src/main.rs new file mode 100644 index 000000000..115efee93 --- /dev/null +++ b/aos_wasm_stress_test/src/main.rs @@ -0,0 +1,13 @@ +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +pub struct Command {} + +fn _start(_command: Command) {} + +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop {} +} diff --git a/facepalm/Cargo.toml b/facepalm/Cargo.toml new file mode 100644 index 000000000..581272b20 --- /dev/null +++ b/facepalm/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "facepalm" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/facepalm/readme.md b/facepalm/readme.md new file mode 100644 index 000000000..172c720d6 --- /dev/null +++ b/facepalm/readme.md @@ -0,0 +1 @@ +Facepalm is the general purpose debugger bundled with ableOS \ No newline at end of file diff --git a/facepalm/src/main.rs b/facepalm/src/main.rs new file mode 100644 index 000000000..e7a11a969 --- /dev/null +++ b/facepalm/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}