|
|
|
@ -1,17 +1,18 @@
|
|
|
|
|
#![allow(unused)]
|
|
|
|
|
//! SBI call wrappers
|
|
|
|
|
|
|
|
|
|
use core::arch::asm;
|
|
|
|
|
|
|
|
|
|
const SBI_SET_TIMER: usize = 0;
|
|
|
|
|
const SBI_CONSOLE_PUTCHAR: usize = 1;
|
|
|
|
|
const SBI_CONSOLE_GETCHAR: usize = 2;
|
|
|
|
|
const SBI_CLEAR_IPI: usize = 3;
|
|
|
|
|
const SBI_SEND_IPI: usize = 4;
|
|
|
|
|
const SBI_REMOTE_FENCE_I: usize = 5;
|
|
|
|
|
const SBI_REMOTE_SFENCE_VMA: usize = 6;
|
|
|
|
|
const SBI_REMOTE_SFENCE_VMA_ASID: usize = 7;
|
|
|
|
|
const SBI_SHUTDOWN: usize = 8;
|
|
|
|
|
// const SBI_SET_TIMER: usize = 0;
|
|
|
|
|
// const SBI_CONSOLE_GETCHAR: usize = 2;
|
|
|
|
|
// const SBI_CLEAR_IPI: usize = 3;
|
|
|
|
|
// const SBI_SEND_IPI: usize = 4;
|
|
|
|
|
// const SBI_REMOTE_FENCE_I: usize = 5;
|
|
|
|
|
// const SBI_REMOTE_SFENCE_VMA: usize = 6;
|
|
|
|
|
// const SBI_REMOTE_SFENCE_VMA_ASID: usize = 7;
|
|
|
|
|
|
|
|
|
|
/// handle SBI call with `which` SBI_id and other arguments
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize {
|
|
|
|
|
let mut ret;
|
|
|
|
@ -33,9 +34,9 @@ pub fn console_putchar(c: usize) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// use sbi call to getchar from console (qemu uart handler)
|
|
|
|
|
pub fn console_getchar() -> usize {
|
|
|
|
|
sbi_call(SBI_CONSOLE_GETCHAR, 0, 0, 0)
|
|
|
|
|
}
|
|
|
|
|
// pub fn console_getchar() -> usize {
|
|
|
|
|
// sbi_call(SBI_CONSOLE_GETCHAR, 0, 0, 0)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/// use sbi call to shutdown the kernel
|
|
|
|
|
pub fn shutdown() -> ! {
|
|
|
|
|