From 4f592336ff3db6cc4e67d11128b037f98f3c8d16 Mon Sep 17 00:00:00 2001 From: equation314 Date: Sat, 1 Dec 2018 22:39:21 +0800 Subject: [PATCH] aarch64: remove test functions --- kernel/src/fs.rs | 56 ----------------------------------- kernel/src/lib.rs | 16 +--------- kernel/src/process/context.rs | 9 ------ 3 files changed, 1 insertion(+), 80 deletions(-) diff --git a/kernel/src/fs.rs b/kernel/src/fs.rs index 89e32aa..d25501b 100644 --- a/kernel/src/fs.rs +++ b/kernel/src/fs.rs @@ -40,62 +40,6 @@ pub fn show_logo() { println!("{}", LOGO); } -#[inline(always)] -fn sys_call(id: usize, arg0: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) -> i32 { - let ret: i32; - unsafe { - #[cfg(target_arch = "riscv32")] - asm!("ecall" - : "={x10}" (ret) - : "{x10}" (id), "{x11}" (arg0), "{x12}" (arg1), "{x13}" (arg2), "{x14}" (arg3), "{x15}" (arg4), "{x16}" (arg5) - : "memory" - : "volatile"); - #[cfg(target_arch = "x86_64")] - asm!("int 0x40" - : "={rax}" (ret) - : "{rax}" (id), "{rdi}" (arg0), "{rsi}" (arg1), "{rdx}" (arg2), "{rcx}" (arg3), "{r8}" (arg4), "{r9}" (arg5) - : "memory" - : "intel" "volatile"); - #[cfg(target_arch = "aarch64")] - asm!("svc 0" - : "={x0}" (ret) - : "{x8}" (id), "{x0}" (arg0), "{x1}" (arg1), "{x2}" (arg2), "{x3}" (arg3), "{x4}" (arg4), "{x5}" (arg5) - : "memory" - : "volatile"); - } - ret -} - -pub fn test_shell(prefix: &str) -> ! { - show_logo(); - loop { - print!("{}", prefix); - loop { - let c = super::arch::io::getchar(); - match c { - '\u{7f}' => { - print!("\u{7f}"); - } - 'c' => unsafe { - print!("sys_putc: "); - sys_call(30, 'A' as usize, 0, 0, 0, 0, 0); - }, - 't' => unsafe { - println!("sys_get_time: {}", sys_call(17, 0, 0, 0, 0, 0, 0)); - }, - ' '...'\u{7e}' => { - print!("{}", c); - } - '\n' | '\r' => { - print!("\n"); - break; - } - _ => {} - } - } - } -} - pub fn shell() { show_logo(); diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 063b1d0..38bd97c 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -68,14 +68,9 @@ pub mod arch; pub fn kmain() -> ! { process::init(); - - use process::*; - processor().add(Context::new_kernel(kernel_proc2, 2333)); - processor().add(Context::new_user_test(kernel_proc3)); - unsafe { arch::interrupt::enable(); } - // fs::shell(); + fs::shell(); // thread::test::local_key(); // thread::test::unpack(); @@ -93,12 +88,3 @@ pub fn kmain() -> ! { /// It should be defined in memory mod, but in Rust `global_allocator` must be in root mod. #[global_allocator] static HEAP_ALLOCATOR: LockedHeap = LockedHeap::empty(); - - -pub extern "C" fn kernel_proc2(arg: usize) -> ! { - fs::test_shell(&format!("proc2-{}>> ", arg)); -} - -pub extern "C" fn kernel_proc3(arg: usize) -> ! { - fs::test_shell(&format!("proc3-{}$ ", arg)); -} diff --git a/kernel/src/process/context.rs b/kernel/src/process/context.rs index 088b1b8..2df7a58 100644 --- a/kernel/src/process/context.rs +++ b/kernel/src/process/context.rs @@ -33,15 +33,6 @@ impl Context { } } - pub fn new_user_test(entry: extern fn(usize) -> !) -> Self { - let ms = MemorySet::new(); - let user_stack = ::memory::alloc_stack(); - Context { - arch: unsafe { ArchContext::new_user_thread(entry as usize, user_stack.top - 8, ms.kstack_top(), false, ms.token()) }, - memory_set: ms, - } - } - /// Make a new user thread from ELF data pub fn new_user(data: &[u8]) -> Self { // Parse elf