slowly adding alloc features
This commit is contained in:
parent
aea13d428f
commit
b3817c0bd3
|
@ -3,7 +3,7 @@ target = "./json_targets/x86_64-ableos.json"
|
|||
|
||||
[unstable]
|
||||
build-std-features = ["compiler-builtins-mem"]
|
||||
build-std = ["core", "compiler_builtins"]
|
||||
build-std = ["core","alloc", "compiler_builtins"]
|
||||
|
||||
|
||||
[target.'cfg(target_arch = "x86_64")']
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
// Can be standardized
|
||||
// NOTE: move the file to the src/ dir
|
||||
pub struct SystemMemory {
|
||||
pub used: u64,
|
||||
pub total: u64,
|
||||
pub used: u64,
|
||||
pub total: u64,
|
||||
}
|
||||
impl core::fmt::Display for SystemMemory {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
write!(f, "{} Bytes / {} Bytes", self.used, self.total)
|
||||
}
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
write!(f, "{} Bytes / {} Bytes", self.used, self.total)
|
||||
}
|
||||
}
|
||||
/*
|
||||
pub fn format_system_info() -> core::string::String {
|
||||
let x = format!(
|
||||
"{}
|
||||
let x = format!(
|
||||
"{}
|
||||
OS: AbleOS
|
||||
Host: ComputAble
|
||||
Kernel: {}
|
||||
|
@ -23,11 +23,19 @@ Gpu: MIPS32 R4000 R4k
|
|||
Cpu: {}
|
||||
Memory: {}
|
||||
",
|
||||
crate::experiments::BANNER,
|
||||
crate::experiments::kinfo::KINFO.kernel_version,
|
||||
crate::arch::ARCH,
|
||||
crate::experiments::kinfo::KINFO.memory
|
||||
);
|
||||
return x;
|
||||
crate::experiments::BANNER,
|
||||
crate::experiments::kinfo::KINFO.kernel_version,
|
||||
crate::arch::ARCH,
|
||||
crate::experiments::kinfo::KINFO.memory
|
||||
);
|
||||
return x;
|
||||
}
|
||||
*/
|
||||
|
||||
pub const KERNEL_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
#[cfg(debug_assertions)]
|
||||
/// A constant to check if the kernel is in debug mode
|
||||
pub const RELEASE_TYPE: &str = "debug";
|
||||
#[cfg(not(debug_assertions))]
|
||||
/// A constant to check if the kernel is in release mode
|
||||
pub const RELEASE_TYPE: &str = "release";
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
use crate::{
|
||||
arch::{drivers::graphics::GraphicsBuffer, init},
|
||||
driver_traits::{graphics::Graphics, serial::Serial},
|
||||
experiments::systeminfo::{KERNEL_VERSION, RELEASE_TYPE},
|
||||
keyboard::DecodedKey,
|
||||
relib::math::rand::{linearshift::LinearShiftRegister, prand::PRand, RAND_HANDLE, RNG},
|
||||
serial_print, serial_println,
|
||||
};
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
#[no_mangle]
|
||||
#[allow(unconditional_recursion)]
|
||||
pub extern "C" fn stack_overflow() -> u8 {
|
||||
|
@ -13,8 +16,6 @@ pub extern "C" fn stack_overflow() -> u8 {
|
|||
69 // NOTE: Any specific reason for this number asside from memes?
|
||||
}
|
||||
|
||||
use crate::keyboard::DecodedKey;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref KEY_BUFFER: [DecodedKey; 256] = [DecodedKey::RawKey(123); 256];
|
||||
pub static ref KEY_BUFFER_POINTER: u8 = 0;
|
||||
|
@ -33,8 +34,8 @@ pub extern "C" fn kernel_main() {
|
|||
AES::init_rng();
|
||||
|
||||
*/
|
||||
#[cfg(not(target_arch = "riscv64"))]
|
||||
println!("init");
|
||||
|
||||
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
||||
|
||||
{
|
||||
use crate::experiments::mail::MailBoxes;
|
||||
|
|
|
@ -40,10 +40,3 @@ mod panic;
|
|||
pub use experiments::server;
|
||||
pub mod keyboard;
|
||||
pub mod relib;
|
||||
pub const KERNEL_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
#[cfg(debug_assertions)]
|
||||
/// A constant to check if the kernel is in debug mode
|
||||
pub const RELEASE_TYPE: &str = "debug";
|
||||
#[cfg(not(debug_assertions))]
|
||||
/// A constant to check if the kernel is in release mode
|
||||
pub const RELEASE_TYPE: &str = "release";
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
pub mod linearshift;
|
||||
pub mod prand;
|
||||
pub mod wichmanhillrand; // FIXEME: Reimplement
|
||||
use crate::serial_println;
|
||||
use lazy_static::lazy_static;
|
||||
use linearshift::LinearShiftRegister;
|
||||
use prand::PRand;
|
||||
pub trait RNG {
|
||||
fn new() -> Self;
|
||||
fn rand(&mut self) -> u64;
|
||||
fn seed(&mut self, seed: u64);
|
||||
fn new() -> Self;
|
||||
fn rand(&mut self) -> u64;
|
||||
fn seed(&mut self, seed: u64);
|
||||
}
|
||||
|
||||
pub type KeyEntropyHandler = u8;
|
||||
|
@ -21,20 +20,20 @@ pub struct Entropy {
|
|||
pool: [u64; 255],
|
||||
}
|
||||
impl Entropy {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
bytes_count: 0,
|
||||
pool: [0; 255],
|
||||
pool_index: 0,
|
||||
}
|
||||
}
|
||||
pub fn poll_hardware() {
|
||||
todo!();
|
||||
}
|
||||
pub fn read_entropy(&mut self) -> u8 {
|
||||
self.bytes_count -= 1;
|
||||
1
|
||||
}
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
bytes_count: 0,
|
||||
pool: [0; 255],
|
||||
pool_index: 0,
|
||||
}
|
||||
}
|
||||
pub fn poll_hardware() {
|
||||
todo!();
|
||||
}
|
||||
pub fn read_entropy(&mut self) -> u8 {
|
||||
self.bytes_count -= 1;
|
||||
1
|
||||
}
|
||||
}
|
||||
impl Default for Entropy {
|
||||
fn default() -> Self {
|
||||
|
@ -42,9 +41,9 @@ impl Default for Entropy {
|
|||
}
|
||||
}
|
||||
pub struct RandomHandeler {
|
||||
prand: prand::PRand,
|
||||
linearshift: linearshift::LinearShiftRegister,
|
||||
entropy: Entropy,
|
||||
prand: prand::PRand,
|
||||
linearshift: linearshift::LinearShiftRegister,
|
||||
entropy: Entropy,
|
||||
}
|
||||
impl RandomHandeler {
|
||||
pub fn seed_entropy(&mut self) {
|
||||
|
@ -79,9 +78,9 @@ impl RandomHandeler {
|
|||
}
|
||||
}
|
||||
lazy_static! {
|
||||
pub static ref RAND_HANDLE: spin::Mutex<RandomHandeler> = spin::Mutex::new(RandomHandeler {
|
||||
prand: PRand::new(),
|
||||
linearshift: LinearShiftRegister::new(),
|
||||
entropy: Entropy::new(),
|
||||
});
|
||||
pub static ref RAND_HANDLE: spin::Mutex<RandomHandeler> = spin::Mutex::new(RandomHandeler {
|
||||
prand: PRand::new(),
|
||||
linearshift: LinearShiftRegister::new(),
|
||||
entropy: Entropy::new(),
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue