mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 16:16:16 +04:00
add htif read function for rocket-chip
This commit is contained in:
parent
e594a4af32
commit
e91718648e
@ -48,13 +48,6 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
|
||||
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();
|
||||
interrupt::init();
|
||||
memory::init(device_tree_vaddr);
|
||||
|
@ -28,7 +28,14 @@ impl Stdin {
|
||||
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 {
|
||||
let ret = self.buf.lock().pop_front();
|
||||
match ret {
|
||||
@ -38,7 +45,12 @@ impl Stdin {
|
||||
}
|
||||
}
|
||||
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 alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use crate::arch::io;
|
||||
|
||||
#[cfg(not(feature = "run_cmdline"))]
|
||||
pub fn add_user_shell() {
|
||||
@ -31,10 +32,12 @@ pub fn add_user_shell() {
|
||||
let init_args = vec!["busybox".into(), "ash".into()];
|
||||
|
||||
if let Ok(inode) = ROOT_INODE.lookup(init_shell) {
|
||||
println!("use fucking up busybox");
|
||||
processor()
|
||||
.manager()
|
||||
.add(Thread::new_user(&inode, init_shell, init_args, init_envs));
|
||||
} else {
|
||||
println!("not use fucking up busybox, but shell");
|
||||
processor().manager().add(Thread::new_kernel(shell, 0));
|
||||
}
|
||||
}
|
||||
@ -46,9 +49,9 @@ pub fn add_user_shell() {
|
||||
println!("not use the fucking up busybox");
|
||||
processor().manager().add(Thread::new_user(
|
||||
&inode,
|
||||
"/busybox",
|
||||
cmdline.split(' ').map(|s| s.into()).collect(),
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user