in gdb mode, OK. For the safety of TIMER_SCRATCH, put clear_bss Fn in rust_start. and explicitly UART.init in rust_main.
This commit is contained in:
parent
b1c5751546
commit
e71bbcbc8d
3 changed files with 16 additions and 9 deletions
|
@ -6,6 +6,7 @@ use lazy_static::*;
|
||||||
pub use ns16550a::NS16550a;
|
pub use ns16550a::NS16550a;
|
||||||
|
|
||||||
pub trait CharDevice {
|
pub trait CharDevice {
|
||||||
|
fn init(&self);
|
||||||
fn read(&self) -> u8;
|
fn read(&self) -> u8;
|
||||||
fn write(&self, ch: u8);
|
fn write(&self, ch: u8);
|
||||||
fn handle_irq(&self);
|
fn handle_irq(&self);
|
||||||
|
|
|
@ -135,7 +135,7 @@ impl<const BASE_ADDR: usize> NS16550a<BASE_ADDR> {
|
||||||
ns16550a: NS16550aRaw::new(BASE_ADDR),
|
ns16550a: NS16550aRaw::new(BASE_ADDR),
|
||||||
read_buffer: VecDeque::new(),
|
read_buffer: VecDeque::new(),
|
||||||
};
|
};
|
||||||
inner.ns16550a.init();
|
//inner.ns16550a.init();
|
||||||
Self {
|
Self {
|
||||||
inner: unsafe { UPIntrFreeCell::new(inner) },
|
inner: unsafe { UPIntrFreeCell::new(inner) },
|
||||||
condvar: Condvar::new(),
|
condvar: Condvar::new(),
|
||||||
|
@ -144,6 +144,11 @@ impl<const BASE_ADDR: usize> NS16550a<BASE_ADDR> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<const BASE_ADDR: usize> CharDevice for 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 {
|
fn read(&self) -> u8 {
|
||||||
loop {
|
loop {
|
||||||
let mut inner = self.inner.exclusive_access();
|
let mut inner = self.inner.exclusive_access();
|
||||||
|
|
|
@ -214,6 +214,7 @@ pub unsafe fn mie_write(x:usize){
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn timer_init() {
|
unsafe fn timer_init() {
|
||||||
|
clear_bss();
|
||||||
// each CPU has a separate source of timer interrupts
|
// each CPU has a separate source of timer interrupts
|
||||||
//let id = mhartid::read();
|
//let id = mhartid::read();
|
||||||
|
|
||||||
|
@ -246,19 +247,19 @@ unsafe fn timer_init() {
|
||||||
//mie::set_mtimer();
|
//mie::set_mtimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use crate::drivers::chardev::CharDevice;
|
||||||
|
use crate::drivers::chardev::UART;
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn rust_main() -> ! {
|
pub fn rust_main() -> ! {
|
||||||
|
|
||||||
clear_bss();
|
//clear_bss();
|
||||||
|
|
||||||
println!("KERN: begin");
|
|
||||||
|
|
||||||
mm::init();
|
mm::init();
|
||||||
|
UART.init();
|
||||||
|
println!("KERN: begin");
|
||||||
//loop{};
|
//loop{};
|
||||||
//println!("KERN: init gpu");
|
println!("KERN: init gpu");
|
||||||
//let _gpu = GPU_DEVICE.clone();
|
let _gpu = GPU_DEVICE.clone();
|
||||||
// println!("KERN: init keyboard");
|
println!("KERN: init keyboard");
|
||||||
// let _keyboard = KEYBOARD_DEVICE.clone();
|
// let _keyboard = KEYBOARD_DEVICE.clone();
|
||||||
//println!("KERN: init mouse");
|
//println!("KERN: init mouse");
|
||||||
//let _mouse = MOUSE_DEVICE.clone();
|
//let _mouse = MOUSE_DEVICE.clone();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue