Skip to content

Commit cd2e230

Browse files
committed
explicitly UART.init() in rust_main
1 parent e0e201a commit cd2e230

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

os/src/drivers/chardev/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use lazy_static::*;
66
pub use ns16550a::NS16550a;
77

88
pub trait CharDevice {
9+
fn init(&self);
910
fn read(&self) -> u8;
1011
fn write(&self, ch: u8);
1112
fn handle_irq(&self);

os/src/drivers/chardev/ns16550a.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<const BASE_ADDR: usize> NS16550a<BASE_ADDR> {
135135
ns16550a: NS16550aRaw::new(BASE_ADDR),
136136
read_buffer: VecDeque::new(),
137137
};
138-
inner.ns16550a.init();
138+
//inner.ns16550a.init();
139139
Self {
140140
inner: unsafe { UPIntrFreeCell::new(inner) },
141141
condvar: Condvar::new(),
@@ -144,6 +144,12 @@ impl<const BASE_ADDR: usize> NS16550a<BASE_ADDR> {
144144
}
145145

146146
impl<const BASE_ADDR: usize> CharDevice for NS16550a<BASE_ADDR> {
147+
fn init(&self){
148+
let mut inner = self.inner.exclusive_access();
149+
inner.ns16550a.init();
150+
drop(inner);
151+
}
152+
147153
fn read(&self) -> u8 {
148154
loop {
149155
let mut inner = self.inner.exclusive_access();

os/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ mod task;
2828
mod timer;
2929
mod trap;
3030

31+
use crate::drivers::chardev::CharDevice;
32+
use crate::drivers::chardev::UART;
3133
//use syscall::create_desktop; //for test
3234

3335
core::arch::global_asm!(include_str!("entry.asm"));
@@ -55,6 +57,7 @@ lazy_static! {
5557
pub fn rust_main() -> ! {
5658
clear_bss();
5759
mm::init();
60+
UART.init();
5861
println!("KERN: init gpu");
5962
let _gpu = GPU_DEVICE.clone();
6063
println!("KERN: init keyboard");

0 commit comments

Comments
 (0)