parent
f1407dff7b
commit
60c2a77ac1
@ -0,0 +1,21 @@
|
||||
use super::bbl::sbi;
|
||||
use core::fmt::{Write, Result, Arguments};
|
||||
|
||||
struct SerialPort;
|
||||
|
||||
impl Write for SerialPort {
|
||||
fn write_str(&mut self, s: &str) -> Result {
|
||||
for c in s.bytes() {
|
||||
sbi::console_putchar(c as usize);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn getchar() -> char {
|
||||
sbi::console_getchar() as u8 as char
|
||||
}
|
||||
|
||||
pub fn putfmt(fmt: Arguments) {
|
||||
SerialPort.write_fmt(fmt).unwrap();
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
use super::bbl::sbi;
|
||||
use core::fmt;
|
||||
|
||||
pub struct SerialPort;
|
||||
|
||||
impl fmt::Write for SerialPort {
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
for c in s.bytes() {
|
||||
sbi::console_putchar(c as usize);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
use super::driver::serial::*;
|
||||
use core::fmt::{Arguments, Write};
|
||||
|
||||
pub fn getchar() -> char {
|
||||
unsafe { COM1.force_unlock(); }
|
||||
COM1.lock().receive() as char
|
||||
}
|
||||
|
||||
pub fn putfmt(fmt: Arguments) {
|
||||
unsafe { COM1.force_unlock(); }
|
||||
COM1.lock().write_fmt(fmt).unwrap()
|
||||
}
|
Loading…
Reference in new issue