1
0
Fork 0
forked from AbleOS/ableos
ableos-idl/ableos/src/kmain.rs

74 lines
1.7 KiB
Rust
Raw Normal View History

2021-11-16 00:09:27 -06:00
#![allow(clippy::empty_loop)]
use crate::{
2021-11-27 09:19:08 -06:00
arch::{drivers::graphics::GraphicsBuffer, init, sloop},
driver_traits::graphics::Graphics,
2021-11-22 04:10:07 -06:00
experiments::systeminfo::{KERNEL_VERSION, RELEASE_TYPE},
keyboard::DecodedKey,
2021-11-27 09:19:08 -06:00
relib::math::rand::{RAND_HANDLE, RNG},
2021-11-16 00:09:27 -06:00
};
2021-11-22 04:10:07 -06:00
2021-11-23 06:01:42 -06:00
use lazy_static::lazy_static;
2021-11-23 05:53:10 -06:00
2021-11-16 00:09:27 -06:00
#[no_mangle]
#[allow(unconditional_recursion)]
pub extern "C" fn stack_overflow() -> u8 {
stack_overflow();
// 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;
}
// Defines the entry point
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();
GraphicsBuffer::draw();
GraphicsBuffer::hide_cursor();
GraphicsBuffer::show_cursor();
2021-11-23 05:53:06 -06:00
{
use alloc::{vec, vec::Vec};
let x: Vec<u8> = vec![1];
println!("{:?}", x);
}
2021-11-16 00:09:27 -06:00
/* If AES is present then AES init rng as well
// Maybe via a cfg
AES::init_rng();
2021-11-23 05:53:06 -06:00
*/
2021-11-22 04:10:07 -06:00
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
2021-11-16 00:09:27 -06:00
{
use crate::experiments::mail::MailBoxes;
let mut x = MailBoxes::new();
x.set_flag(1);
x.set_flag(2);
// x.dump_flags();
}
// stack_overflow();
// crate::arch::shutdown();
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
lazy_static! {
pub static ref TICK: spin::Mutex<u64> = spin::Mutex::new(0);
}
/// 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);
}