Facepalm and aos stress test work

This commit is contained in:
Able 2022-01-13 08:54:33 -06:00
parent 57b7d9126b
commit 83a02c904c
23 changed files with 152 additions and 117 deletions

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
repbuild/target
ableos/target
aos_wasm_stress_test/target
facepalm/target

View file

@ -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))
}
}
},
}
}
}

View file

@ -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);
}

View file

@ -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<String, String>,
}
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::<String, String>::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)
}
}
}
}

View file

@ -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");

View file

@ -0,0 +1,8 @@
pub type thumbnail = u8;
pub struct Notification {
thumbnail: thumbnail,
text_body: String,
time: u64,
}
impl Notification {}

View file

@ -0,0 +1,26 @@
use lazy_static::lazy_static;
lazy_static! {
pub static ref KERNEL_STATE: spin::Mutex<KernelInternalState> =
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();
}
}
}

View file

@ -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<String> = spin::Mutex::new("".to_string());
pub static ref KEY_BUFFER_POINTER: u8 = 0;
pub static ref THREAD_LIST: spin::Mutex<ThreadList> = spin::Mutex::new(vec![]);
pub static ref TICK: spin::Mutex<u64> = 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) {

View file

@ -44,4 +44,5 @@ pub extern crate alloc;
pub extern crate externc_libm as libm;
///////////////////////////////
pub mod kernel_state;
pub mod vga_e;

View file

@ -17,10 +17,10 @@ pub struct Argument {
}
#[derive(Debug)]
struct Command {
root_command: String,
pub struct Command {
pub root_command: String,
// arguments: HashMap<String, String>,
arguments: Vec<Argument>,
pub arguments: Vec<Argument>,
}
impl Command {

View file

@ -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 {

View file

@ -0,0 +1,2 @@
[build]
target = "wasm32-unknown-unknown"

7
aos_wasm_stress_test/Cargo.lock generated Normal file
View file

@ -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"

View file

@ -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]

View file

@ -0,0 +1,4 @@
This is a stress test and simple progrram for ableOS.
There should be two sub commands echo and input

View file

@ -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 {}
}

8
facepalm/Cargo.toml Normal file
View file

@ -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]

1
facepalm/readme.md Normal file
View file

@ -0,0 +1 @@
Facepalm is the general purpose debugger bundled with ableOS

3
facepalm/src/main.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}