File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ use lazy_static::*;
66pub use ns16550a:: NS16550a ;
77
88pub trait CharDevice {
9+ fn init ( & self ) ;
910 fn read ( & self ) -> u8 ;
1011 fn write ( & self , ch : u8 ) ;
1112 fn handle_irq ( & self ) ;
Original file line number Diff line number Diff 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
146146impl < 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 ( ) ;
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ mod task;
2828mod timer;
2929mod trap;
3030
31+ use crate :: drivers:: chardev:: CharDevice ;
32+ use crate :: drivers:: chardev:: UART ;
3133//use syscall::create_desktop; //for test
3234
3335core:: arch:: global_asm!( include_str!( "entry.asm" ) ) ;
@@ -55,6 +57,7 @@ lazy_static! {
5557pub 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" ) ;
You can’t perform that action at this time.
0 commit comments