From e594a4af32eef992dd0e2635aad4f9aa17516cff Mon Sep 17 00:00:00 2001 From: Jackey-Huo Date: Thu, 2 May 2019 21:32:19 +0800 Subject: [PATCH 1/3] stage debug code for output --- kernel/src/arch/riscv32/mod.rs | 13 ++++++++++++- kernel/src/shell.rs | 3 +++ tools/addr2line.py | 0 user | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) mode change 100644 => 100755 tools/addr2line.py diff --git a/kernel/src/arch/riscv32/mod.rs b/kernel/src/arch/riscv32/mod.rs index 75b7ccc..a0c5cd9 100644 --- a/kernel/src/arch/riscv32/mod.rs +++ b/kernel/src/arch/riscv32/mod.rs @@ -44,10 +44,17 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! { } println!( - "Hello RISCV! in hart {}, device tree @ {:#x}", + "Hello fucking RISCV! in hart {}, device tree @ {:#x}", 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); @@ -74,6 +81,10 @@ fn others_main() -> ! { crate::kmain(); } +fn get_char_fuck() -> char { + io::getchar() +} + static AP_CAN_INIT: AtomicBool = AtomicBool::new(false); #[cfg(not(feature = "board_u540"))] diff --git a/kernel/src/shell.rs b/kernel/src/shell.rs index 84c4367..3e28227 100644 --- a/kernel/src/shell.rs +++ b/kernel/src/shell.rs @@ -19,6 +19,7 @@ pub fn add_user_shell() { // // #[cfg(not(target_arch = "x86_64"))] let init_shell = "/busybox"; //from docker-library + println!("use the fucking up busybox"); #[cfg(target_arch = "x86_64")] let init_envs = @@ -42,10 +43,12 @@ pub fn add_user_shell() { pub fn add_user_shell() { let cmdline = CMDLINE.read(); let inode = ROOT_INODE.lookup(&cmdline).unwrap(); + println!("not use the fucking up busybox"); processor().manager().add(Thread::new_user( &inode, cmdline.split(' ').map(|s| s.into()).collect(), Vec::new(), + Vec::new(), )); } diff --git a/tools/addr2line.py b/tools/addr2line.py old mode 100644 new mode 100755 diff --git a/user b/user index 05f0efd..8dbc0ed 160000 --- a/user +++ b/user @@ -1 +1 @@ -Subproject commit 05f0efd3fda084109e4b6da8ff30ecb1557a267f +Subproject commit 8dbc0edb935a62d748aaac39258d4a985de0ae17 From e91718648e6fcadb707f890ad508c940aaf4a4c0 Mon Sep 17 00:00:00 2001 From: Jackey-Huo Date: Fri, 3 May 2019 11:33:44 +0800 Subject: [PATCH 2/3] add htif read function for rocket-chip --- kernel/src/arch/riscv32/mod.rs | 7 ------- kernel/src/fs/stdio.rs | 16 ++++++++++++++-- kernel/src/shell.rs | 5 ++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/kernel/src/arch/riscv32/mod.rs b/kernel/src/arch/riscv32/mod.rs index a0c5cd9..e22b7d9 100644 --- a/kernel/src/arch/riscv32/mod.rs +++ b/kernel/src/arch/riscv32/mod.rs @@ -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); diff --git a/kernel/src/fs/stdio.rs b/kernel/src/fs/stdio.rs index 3967e41..429b80c 100644 --- a/kernel/src/fs/stdio.rs +++ b/kernel/src/fs/stdio.rs @@ -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; } } diff --git a/kernel/src/shell.rs b/kernel/src/shell.rs index 3e28227..816be57 100644 --- a/kernel/src/shell.rs +++ b/kernel/src/shell.rs @@ -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(), )); } From c63831870dc49c30b3f226f97a535f140c8e05f7 Mon Sep 17 00:00:00 2001 From: Jackey-Huo Date: Fri, 3 May 2019 14:06:00 +0800 Subject: [PATCH 3/3] remove the fxxk words.... --- kernel/src/arch/riscv32/mod.rs | 6 +----- kernel/src/shell.rs | 4 ---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/kernel/src/arch/riscv32/mod.rs b/kernel/src/arch/riscv32/mod.rs index e22b7d9..75b7ccc 100644 --- a/kernel/src/arch/riscv32/mod.rs +++ b/kernel/src/arch/riscv32/mod.rs @@ -44,7 +44,7 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! { } println!( - "Hello fucking RISCV! in hart {}, device tree @ {:#x}", + "Hello RISCV! in hart {}, device tree @ {:#x}", hartid, device_tree_vaddr ); @@ -74,10 +74,6 @@ fn others_main() -> ! { crate::kmain(); } -fn get_char_fuck() -> char { - io::getchar() -} - static AP_CAN_INIT: AtomicBool = AtomicBool::new(false); #[cfg(not(feature = "board_u540"))] diff --git a/kernel/src/shell.rs b/kernel/src/shell.rs index 1375b14..45274c8 100644 --- a/kernel/src/shell.rs +++ b/kernel/src/shell.rs @@ -19,7 +19,6 @@ pub fn add_user_shell() { // // #[cfg(not(target_arch = "x86_64"))] let init_shell = "/busybox"; //from docker-library - println!("use the fucking up busybox"); #[cfg(target_arch = "x86_64")] let init_envs = @@ -31,12 +30,10 @@ 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,7 +43,6 @@ pub fn add_user_shell() { use crate::drivers::CMDLINE; let cmdline = CMDLINE.read(); let inode = ROOT_INODE.lookup(&cmdline).unwrap(); - println!("not use the fucking up busybox"); processor().manager().add(Thread::new_user( &inode, "/busybox",