explicitly UART.init() in rust_main

This commit is contained in:
Yu Chen 2023-01-03 09:32:36 +08:00
parent 01856f5243
commit 6d1960ecd9
3 changed files with 11 additions and 1 deletions

View file

@ -6,6 +6,7 @@ use lazy_static::*;
pub use ns16550a::NS16550a;
pub trait CharDevice {
fn init(&self);
fn read(&self) -> u8;
fn write(&self, ch: u8);
fn handle_irq(&self);

View file

@ -135,7 +135,7 @@ impl<const BASE_ADDR: usize> NS16550a<BASE_ADDR> {
ns16550a: NS16550aRaw::new(BASE_ADDR),
read_buffer: VecDeque::new(),
};
inner.ns16550a.init();
//inner.ns16550a.init();
Self {
inner: unsafe { UPIntrFreeCell::new(inner) },
condvar: Condvar::new(),
@ -144,6 +144,12 @@ impl<const BASE_ADDR: usize> NS16550a<BASE_ADDR> {
}
impl<const BASE_ADDR: usize> CharDevice for NS16550a<BASE_ADDR> {
fn init(&self){
let mut inner = self.inner.exclusive_access();
inner.ns16550a.init();
drop(inner);
}
fn read(&self) -> u8 {
loop {
let mut inner = self.inner.exclusive_access();