mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
feat: drop legacy flags for riscv-sbi
This commit is contained in:
parent
dd5325db2a
commit
daf96a0c64
@ -37,7 +37,7 @@ log = "0.4"
|
||||
num-derive = "0.4"
|
||||
num-traits = { version = "0.2", default-features = false }
|
||||
riscv = { version = "0.11.1", features = ["s-mode"] }
|
||||
sbi-rt = { version = "0.0.3", features = ["legacy"] }
|
||||
sbi-rt = { version = "0.0.3" }
|
||||
spin = "0.9.8"
|
||||
static_assertions = "1.1.0"
|
||||
uart_16550 = "0.3"
|
||||
|
@ -1,21 +1,28 @@
|
||||
use crate::plat::io::{Printer, RawConsole, Reader};
|
||||
|
||||
impl Printer for RawConsole {
|
||||
#[inline]
|
||||
fn put_char(c: char) {
|
||||
#[allow(deprecated)]
|
||||
sbi_rt::legacy::console_putchar(c as usize);
|
||||
sbi_rt::console_write_byte(c as u8);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn put_str(s: &str) {
|
||||
sbi_rt::console_write(sbi_rt::Physical::new(s.len(), s.as_ptr() as _, 0));
|
||||
}
|
||||
}
|
||||
|
||||
impl Reader for RawConsole {
|
||||
#[inline]
|
||||
fn get_char() -> char {
|
||||
let mut buf = [0u8; 1];
|
||||
loop {
|
||||
#[allow(deprecated)]
|
||||
let ch = sbi_rt::legacy::console_getchar();
|
||||
if ch == usize::MAX {
|
||||
continue;
|
||||
let ret = sbi_rt::console_read(sbi_rt::Physical::new(1, buf.as_mut_ptr() as _, 0));
|
||||
if let Some(len) = ret.ok()
|
||||
&& len == 1
|
||||
{
|
||||
return buf[0] as char;
|
||||
}
|
||||
return ch as u8 as char;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#![no_main]
|
||||
// Features
|
||||
#![feature(asm_const)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(naked_functions)]
|
||||
#![feature(panic_info_message)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
Loading…
Reference in New Issue
Block a user