feat: drop legacy flags for riscv-sbi

This commit is contained in:
Paul Pan 2024-03-20 22:13:21 +08:00
parent dd5325db2a
commit daf96a0c64
3 changed files with 16 additions and 8 deletions

View File

@ -37,7 +37,7 @@ log = "0.4"
num-derive = "0.4" num-derive = "0.4"
num-traits = { version = "0.2", default-features = false } num-traits = { version = "0.2", default-features = false }
riscv = { version = "0.11.1", features = ["s-mode"] } 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" spin = "0.9.8"
static_assertions = "1.1.0" static_assertions = "1.1.0"
uart_16550 = "0.3" uart_16550 = "0.3"

View File

@ -1,21 +1,28 @@
use crate::plat::io::{Printer, RawConsole, Reader}; use crate::plat::io::{Printer, RawConsole, Reader};
impl Printer for RawConsole { impl Printer for RawConsole {
#[inline]
fn put_char(c: char) { fn put_char(c: char) {
#[allow(deprecated)] sbi_rt::console_write_byte(c as u8);
sbi_rt::legacy::console_putchar(c as usize); }
#[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 { impl Reader for RawConsole {
#[inline]
fn get_char() -> char { fn get_char() -> char {
let mut buf = [0u8; 1];
loop { loop {
#[allow(deprecated)] let ret = sbi_rt::console_read(sbi_rt::Physical::new(1, buf.as_mut_ptr() as _, 0));
let ch = sbi_rt::legacy::console_getchar(); if let Some(len) = ret.ok()
if ch == usize::MAX { && len == 1
continue; {
} return buf[0] as char;
return ch as u8 as char; }
} }
} }
} }

View File

@ -3,6 +3,7 @@
#![no_main] #![no_main]
// Features // Features
#![feature(asm_const)] #![feature(asm_const)]
#![feature(let_chains)]
#![feature(naked_functions)] #![feature(naked_functions)]
#![feature(panic_info_message)] #![feature(panic_info_message)]
#![feature(stmt_expr_attributes)] #![feature(stmt_expr_attributes)]