1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-25 17:33:28 +04:00

aarch64: remove test functions

This commit is contained in:
equation314 2018-12-01 22:39:21 +08:00
parent 163e092c29
commit 4f592336ff
3 changed files with 1 additions and 80 deletions

View File

@ -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();

View File

@ -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));
}

View File

@ -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