Facepalm and aos stress test work
This commit is contained in:
parent
57b7d9126b
commit
83a02c904c
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
repbuild/target
|
||||
ableos/target
|
||||
aos_wasm_stress_test/target
|
||||
facepalm/target
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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_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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
|
|
8
ableos/src/experiments/notification.rs
Normal file
8
ableos/src/experiments/notification.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
pub type thumbnail = u8;
|
||||
|
||||
pub struct Notification {
|
||||
thumbnail: thumbnail,
|
||||
text_body: String,
|
||||
time: u64,
|
||||
}
|
||||
impl Notification {}
|
26
ableos/src/kernel_state.rs
Normal file
26
ableos/src/kernel_state.rs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,17 +24,21 @@ 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();
|
||||
|
||||
a_thread.new_task(test_fn);
|
||||
|
@ -44,25 +46,26 @@ pub fn kernel_main() -> ! {
|
|||
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()
|
||||
);
|
||||
|
||||
if false {
|
||||
println!("$PINK$Hi$RED$ from$GREEN$ able!$RESET$");
|
||||
println!("$RED$hi$RESET$");
|
||||
|
||||
{
|
||||
clparse::test();
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
|
|
@ -44,4 +44,5 @@ pub extern crate alloc;
|
|||
pub extern crate externc_libm as libm;
|
||||
|
||||
///////////////////////////////
|
||||
pub mod kernel_state;
|
||||
pub mod vga_e;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
2
aos_wasm_stress_test/.cargo/config.toml
Normal file
2
aos_wasm_stress_test/.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
[build]
|
||||
target = "wasm32-unknown-unknown"
|
7
aos_wasm_stress_test/Cargo.lock
generated
Normal file
7
aos_wasm_stress_test/Cargo.lock
generated
Normal 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"
|
8
aos_wasm_stress_test/Cargo.toml
Normal file
8
aos_wasm_stress_test/Cargo.toml
Normal 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]
|
4
aos_wasm_stress_test/readme.md
Normal file
4
aos_wasm_stress_test/readme.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
This is a stress test and simple progrram for ableOS.
|
||||
|
||||
There should be two sub commands echo and input
|
13
aos_wasm_stress_test/src/main.rs
Normal file
13
aos_wasm_stress_test/src/main.rs
Normal 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
8
facepalm/Cargo.toml
Normal 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
1
facepalm/readme.md
Normal file
|
@ -0,0 +1 @@
|
|||
Facepalm is the general purpose debugger bundled with ableOS
|
3
facepalm/src/main.rs
Normal file
3
facepalm/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
Loading…
Reference in a new issue