Supervisor mode
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -1,13 +1,16 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![allow(static_mut_refs)]
|
||||
#![feature(riscv_ext_intrinsics)]
|
||||
|
||||
use core::arch::asm;
|
||||
use core::arch::riscv64::wfi;
|
||||
|
||||
use embedded_alloc::LlffHeap as Heap;
|
||||
use log::info;
|
||||
|
||||
use crate::{
|
||||
io::init_log,
|
||||
riscv::enable_supervisor_interrupt,
|
||||
vga::{Color, Vga},
|
||||
};
|
||||
|
||||
@@ -15,9 +18,11 @@ extern crate alloc;
|
||||
|
||||
mod boot;
|
||||
mod critical_section;
|
||||
mod interrupt;
|
||||
mod io;
|
||||
mod panic_handler;
|
||||
mod riscv;
|
||||
mod time;
|
||||
mod uart;
|
||||
mod vga;
|
||||
|
||||
@@ -26,17 +31,18 @@ pub const HEAP_SIZE: usize = 40960;
|
||||
static HEAP: Heap = Heap::empty();
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn main() {
|
||||
pub extern "C" fn supervisor_mode_entry() {
|
||||
unsafe {
|
||||
embedded_alloc::init!(HEAP, HEAP_SIZE);
|
||||
init_log().unwrap();
|
||||
Vga::init();
|
||||
enable_supervisor_interrupt();
|
||||
}
|
||||
init_log().unwrap();
|
||||
Vga::init();
|
||||
|
||||
info!("Hello World !");
|
||||
unsafe { Vga::draw_string(10, 10, "Hello World !", Color::WHITE) };
|
||||
unsafe { Vga::draw_string(10, 10, "Hello World !", Color::WHITE, Color::BLACK) };
|
||||
|
||||
loop {
|
||||
unsafe { asm!("wfi") }
|
||||
unsafe { wfi() }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user