Too late but it kinda works

This commit is contained in:
2026-02-11 15:19:10 +01:00
parent 53043fd3cd
commit 6fc08b5dbb
9 changed files with 570 additions and 59 deletions

View File

@@ -1,16 +1,18 @@
#![no_std]
#![no_main]
#![allow(static_mut_refs)]
#![feature(riscv_ext_intrinsics)]
#![feature(riscv_ext_intrinsics, const_trait_impl, iter_map_windows)]
use core::arch::riscv64::wfi;
use core::{arch::riscv64::wfi, time::Duration};
use embedded_alloc::LlffHeap as Heap;
use log::info;
use crate::{
io::init_log,
process::{create_processus, sleep},
riscv::enable_supervisor_interrupt,
scheduler::scheduler_init,
vga::{Color, Vga},
};
@@ -21,27 +23,50 @@ mod critical_section;
mod interrupt;
mod io;
mod panic_handler;
mod process;
mod riscv;
mod scheduler;
mod time;
mod uart;
mod vga;
pub const HEAP_SIZE: usize = 40960;
pub const HEAP_SIZE: usize = 4096;
#[global_allocator]
static HEAP: Heap = Heap::empty();
extern "C" fn test() {
loop {
info!("test");
enable_supervisor_interrupt();
sleep(Duration::new(2, 0));
unsafe { wfi() };
}
}
extern "C" fn proc2() {
loop {
info!("proc2");
enable_supervisor_interrupt();
sleep(Duration::new(3, 0));
unsafe { wfi() };
}
}
#[unsafe(no_mangle)]
pub extern "C" fn supervisor_mode_entry() {
unsafe {
embedded_alloc::init!(HEAP, HEAP_SIZE);
init_log().unwrap();
Vga::init();
scheduler_init();
enable_supervisor_interrupt();
}
info!("Hello World !");
unsafe { Vga::draw_string(10, 10, "Hello World !", Color::WHITE, Color::BLACK) };
create_processus(test, "proc1");
create_processus(proc2, "proc2");
loop {
unsafe { wfi() }
}