add htif read function for rocket-chip

toolchain_update
Jackey-Huo 6 years ago
parent e594a4af32
commit e91718648e

@ -48,13 +48,6 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
hartid, device_tree_vaddr hartid, device_tree_vaddr
); );
//while true {
//let fuck_char = get_char_fuck();
//if fuck_char as u8 != 254 {
//print!("{0}", fuck_char as char);
//}
//}
crate::logging::init(); crate::logging::init();
interrupt::init(); interrupt::init();
memory::init(device_tree_vaddr); memory::init(device_tree_vaddr);

@ -28,7 +28,14 @@ impl Stdin {
return c; return c;
} }
} }
#[cfg(not(feature = "board_k210"))] #[cfg(feature = "board_rocket_chip")]
loop {
let c = crate::arch::io::getchar();
if c != '\0' && c as u8 != 254 {
return c;
}
}
#[cfg(not(any(feature = "board_k210", feature = "board_rocket_chip")))]
loop { loop {
let ret = self.buf.lock().pop_front(); let ret = self.buf.lock().pop_front();
match ret { match ret {
@ -38,7 +45,12 @@ impl Stdin {
} }
} }
pub fn can_read(&self) -> bool { pub fn can_read(&self) -> bool {
self.buf.lock().len() > 0 // Currently, rocket-chip implementation rely on htif interface, the serial interrupt DO
// NOT work, so return true always
#[cfg(feature = "board_rocket_chip")]
return true;
#[cfg(not(feature = "board_rocket_chip"))]
return self.buf.lock().len() > 0;
} }
} }

@ -5,6 +5,7 @@ use crate::fs::{INodeExt, ROOT_INODE};
use crate::process::*; use crate::process::*;
use alloc::string::String; use alloc::string::String;
use alloc::vec::Vec; use alloc::vec::Vec;
use crate::arch::io;
#[cfg(not(feature = "run_cmdline"))] #[cfg(not(feature = "run_cmdline"))]
pub fn add_user_shell() { pub fn add_user_shell() {
@ -31,10 +32,12 @@ pub fn add_user_shell() {
let init_args = vec!["busybox".into(), "ash".into()]; let init_args = vec!["busybox".into(), "ash".into()];
if let Ok(inode) = ROOT_INODE.lookup(init_shell) { if let Ok(inode) = ROOT_INODE.lookup(init_shell) {
println!("use fucking up busybox");
processor() processor()
.manager() .manager()
.add(Thread::new_user(&inode, init_shell, init_args, init_envs)); .add(Thread::new_user(&inode, init_shell, init_args, init_envs));
} else { } else {
println!("not use fucking up busybox, but shell");
processor().manager().add(Thread::new_kernel(shell, 0)); processor().manager().add(Thread::new_kernel(shell, 0));
} }
} }
@ -46,9 +49,9 @@ pub fn add_user_shell() {
println!("not use the fucking up busybox"); println!("not use the fucking up busybox");
processor().manager().add(Thread::new_user( processor().manager().add(Thread::new_user(
&inode, &inode,
"/busybox",
cmdline.split(' ').map(|s| s.into()).collect(), cmdline.split(' ').map(|s| s.into()).collect(),
Vec::new(), Vec::new(),
Vec::new(),
)); ));
} }

Loading…
Cancel
Save