添加user_console用户态的print相关接口,但是并未实现系统调用
parent
8b8d353e86
commit
5ce82f274e
@ -1,9 +1,9 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use user_lib;
|
||||
use user_lib::*;
|
||||
|
||||
#[no_mangle]
|
||||
fn main() {
|
||||
|
||||
println!("123");
|
||||
}
|
@ -1 +1,2 @@
|
||||
pub mod user_panic;
|
||||
pub mod user_console;
|
@ -0,0 +1,31 @@
|
||||
use core::fmt::{Arguments, Write, Result};
|
||||
|
||||
struct Stdout;
|
||||
|
||||
const STDOUT: usize = 1;
|
||||
|
||||
impl Write for Stdout {
|
||||
fn write_str(&mut self, s: &str) -> Result {
|
||||
// ... todo 实现系统调用
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print(args: Arguments) {
|
||||
Stdout.write_fmt(args).unwrap();
|
||||
}
|
||||
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! print {
|
||||
($fmt: literal $(, $($arg: tt)+)?) => {
|
||||
$crate::user_console::print(format_args!($fmt $(, $($arg)+)?));
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! println {
|
||||
($fmt: literal $(, $($arg: tt)+)?) => {
|
||||
$crate::user_console::print(format_args!(concat!($fmt, "\n") $(, $($arg)+)?));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue