2021-11-16 00:09:27 -06:00
|
|
|
#![allow(clippy::empty_loop)]
|
2021-11-28 14:50:14 -06:00
|
|
|
|
2021-12-24 03:30:27 -06:00
|
|
|
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},
|
|
|
|
},
|
2021-12-24 07:03:15 -06:00
|
|
|
alloc::vec,
|
2021-12-24 03:30:27 -06:00
|
|
|
lazy_static::lazy_static,
|
2021-11-16 00:09:27 -06:00
|
|
|
};
|
2021-11-22 04:10:07 -06:00
|
|
|
|
2021-11-16 00:09:27 -06:00
|
|
|
#[no_mangle]
|
|
|
|
#[allow(unconditional_recursion)]
|
|
|
|
pub extern "C" fn stack_overflow() -> u8 {
|
|
|
|
stack_overflow();
|
2021-11-23 05:54:57 -06:00
|
|
|
// meme number
|
2021-11-16 00:09:27 -06:00
|
|
|
69 // NOTE: Any specific reason for this number asside from memes?
|
|
|
|
}
|
|
|
|
|
|
|
|
lazy_static! {
|
|
|
|
pub static ref KEY_BUFFER: [DecodedKey; 256] = [DecodedKey::RawKey(123); 256];
|
|
|
|
pub static ref KEY_BUFFER_POINTER: u8 = 0;
|
2021-12-24 03:30:27 -06:00
|
|
|
pub static ref THREAD_LIST: spin::Mutex<ThreadList> = spin::Mutex::new(vec![]);
|
|
|
|
pub static ref TICK: spin::Mutex<u64> = spin::Mutex::new(0);
|
2021-11-16 00:09:27 -06:00
|
|
|
}
|
2021-11-23 06:01:42 -06:00
|
|
|
|
2021-11-16 00:09:27 -06:00
|
|
|
#[no_mangle]
|
2021-11-23 06:01:42 -06:00
|
|
|
pub fn kernel_main() -> ! {
|
2021-11-16 00:09:27 -06:00
|
|
|
init::init();
|
2021-12-24 03:30:27 -06:00
|
|
|
let mut a_thread = Thread::new();
|
|
|
|
|
|
|
|
a_thread.new_task(test_fn);
|
|
|
|
a_thread.new_task(test_fn);
|
|
|
|
|
|
|
|
THREAD_LIST.lock().push(a_thread);
|
2021-11-16 00:09:27 -06:00
|
|
|
|
|
|
|
GraphicsBuffer::draw();
|
|
|
|
GraphicsBuffer::hide_cursor();
|
|
|
|
GraphicsBuffer::show_cursor();
|
2021-12-24 08:04:07 -06:00
|
|
|
crate::wasm::evaluate();
|
2021-11-28 14:50:14 -06:00
|
|
|
|
2021-11-22 04:10:07 -06:00
|
|
|
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
2021-12-24 04:05:23 -06:00
|
|
|
info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
2021-11-16 00:09:27 -06:00
|
|
|
|
|
|
|
// stack_overflow();
|
2021-11-17 08:42:54 -06:00
|
|
|
// crate::arch::shutdown();
|
2021-11-23 05:54:57 -06:00
|
|
|
sloop()
|
2021-11-16 00:09:27 -06:00
|
|
|
}
|
2021-11-23 08:49:41 -06:00
|
|
|
|
2021-11-16 00:09:27 -06:00
|
|
|
/// called by arch specific timers to tick up all kernel related functions
|
|
|
|
pub fn tick() {
|
|
|
|
let mut data = TICK.lock();
|
|
|
|
*data += 1;
|
|
|
|
RAND_HANDLE.lock().seed_entropy_timer(*data);
|
|
|
|
}
|
2021-11-23 08:49:41 -06:00
|
|
|
|
2021-11-16 00:09:27 -06:00
|
|
|
pub fn key_entropy(key: u8) {
|
|
|
|
RAND_HANDLE.lock().seed_entropy_keyboard(key);
|
|
|
|
}
|