changed some stuff

This commit is contained in:
FantasyPvP
2023-09-27 00:42:04 +01:00
parent 45304c26d8
commit 76a2ec2163
8 changed files with 88 additions and 58 deletions
+2 -1
View File
@@ -5,4 +5,5 @@ pub mod interrupts;
pub mod memory;
pub mod render;
pub mod serial;
pub mod tasks;
pub mod tasks;
pub mod sysinit;
+2 -1
View File
@@ -1,3 +1,4 @@
fn init() -> Result<(), ()> {
use crate::println;
pub fn init() -> Result<(), ()> {
Ok(())
}
+1
View File
@@ -6,4 +6,5 @@ pub fn init() {
kernel::interrupts::init_idt();
unsafe { kernel::interrupts::PICS.lock().initialize() };
x86_64::instructions::interrupts::enable();
kernel::sysinit::init().unwrap();
}
+8 -6
View File
@@ -3,14 +3,16 @@ use alloc::{string::{String, ToString}, vec::Vec};
use rand::{Rng, SeedableRng, rngs::SmallRng, RngCore};
use spin::Mutex;
use lazy_static::lazy_static;
use cmos_rtc::{ReadRTC, Time};
lazy_static! {
pub static ref RANDOM: Mutex<SmallRng> = Mutex::new(SmallRng::seed_from_u64(1));
pub static ref RANDOM: Mutex<SmallRng> = Mutex::new(SmallRng::seed_from_u64({
let mut cmos = ReadRTC::new(0x00, 0x00);
let time: Time = cmos.read();
time.second as u64 + time.minute as u64 + time.hour as u64 + time.day as u64 + time.month as u64 + time.year as u64
}));
}
pub struct Random;
impl Random {
@@ -28,8 +30,8 @@ impl Random {
}
}
pub fn selection<T: Clone>(ls: Vec<T>) -> T {
pub fn selection<T: Clone>(ls: &Vec<T>) -> &T {
let range = Random::int(0, ls.len() - 1);
ls[range as usize].clone()
&ls[range as usize]
}
}