Add more comment in kernel but not finished

master
lcy1996 6 years ago
parent 96c79520cf
commit e4300d3515

@ -11,6 +11,7 @@ pub struct TrapFrame {
} }
/// 用于在内核栈中构造新线程的中断帧 /// 用于在内核栈中构造新线程的中断帧
/// The trapframe for building new process in kernel
impl TrapFrame { impl TrapFrame {
fn new_kernel_thread(entry: extern fn(usize) -> !, arg: usize, sp: usize) -> Self { fn new_kernel_thread(entry: extern fn(usize) -> !, arg: usize, sp: usize) -> Self {
use core::mem::zeroed; use core::mem::zeroed;

@ -15,6 +15,7 @@ _binary_user_riscv_img_end:
"#); "#);
pub fn shell() { pub fn shell() {
// load riscv32/x86_64 user program
#[cfg(target_arch = "riscv32")] #[cfg(target_arch = "riscv32")]
let device = { let device = {
extern { extern {
@ -36,6 +37,7 @@ pub fn shell() {
const BUF_SIZE: usize = 0x40000; const BUF_SIZE: usize = 0x40000;
let layout = Layout::from_size_align(BUF_SIZE, 0x1000).unwrap(); let layout = Layout::from_size_align(BUF_SIZE, 0x1000).unwrap();
let buf = unsafe{ slice::from_raw_parts_mut(alloc(layout), BUF_SIZE) }; let buf = unsafe{ slice::from_raw_parts_mut(alloc(layout), BUF_SIZE) };
// start interaction
loop { loop {
print!(">> "); print!(">> ");
use console::get_line; use console::get_line;

@ -61,16 +61,20 @@ pub mod arch;
pub mod arch; pub mod arch;
pub fn kmain() -> ! { pub fn kmain() -> ! {
// Init the first kernel process(idle proc)
process::init(); process::init();
// enable the interrupt
unsafe { arch::interrupt::enable(); } unsafe { arch::interrupt::enable(); }
fs::shell(); // the test is not supported in riscv32(maybe)
//thread::test::local_key();
//thread::test::unpack();
//sync::test::philosopher_using_mutex();
//sync::test::philosopher_using_monitor();
//sync::mpsc::test::test_all();
// thread::test::local_key(); // come into shell
// thread::test::unpack(); fs::shell();
// sync::test::philosopher_using_mutex();
// sync::test::philosopher_using_monitor();
// sync::mpsc::test::test_all();
loop {} loop {}
} }

@ -9,6 +9,10 @@ mod context;
type Processor = Processor_<Context, StrideScheduler>; type Processor = Processor_<Context, StrideScheduler>;
/*
* @brief:
* initialize a new kernel process (idleproc)
*/
pub fn init() { pub fn init() {
PROCESSOR.call_once(|| PROCESSOR.call_once(||
SpinNoIrqLock::new({ SpinNoIrqLock::new({

Loading…
Cancel
Save