Fix fork and syscall return value.

master
WangRunji 6 years ago
parent 27daa6d491
commit 0c9679b710

@ -205,6 +205,12 @@ impl<T: InactivePageTable> Clone for MemorySet<T> {
}
}
impl<T: InactivePageTable> Drop for MemorySet<T> {
fn drop(&mut self) {
self.clear();
}
}
impl<T: InactivePageTable> Debug for MemorySet<T> {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
f.debug_list()

@ -153,7 +153,7 @@ impl Context {
context: ContextData::new(cr3),
tf: {
let mut tf = tf.clone();
tf.x[1] = 0; // ra
tf.x[10] = 0; // a0
tf
},
}.push_at(kstack_top)

@ -53,9 +53,9 @@ fn timer() {
}
fn syscall(tf: &mut TrapFrame) {
tf.sepc += 4; // Must before syscall, because of fork.
let ret = ::syscall::syscall(tf.x[10], [tf.x[11], tf.x[12], tf.x[13], tf.x[14], tf.x[15], tf.x[16]], tf);
unsafe { *(&tf.x[10] as *const _ as *mut i32) = ret; }
tf.sepc += 4;
tf.x[10] = ret as usize;
}
extern {

@ -160,14 +160,14 @@ fn syscall(tf: &mut TrapFrame) {
trace!("\nInterupt: Syscall {:#x?}", tf.rax);
use syscall::syscall;
let ret = syscall(tf.rax, [tf.rdi, tf.rsi, tf.rdx, tf.rcx, tf.r8, tf.r9], tf);
unsafe { *(&tf.rax as *const _ as *mut i32) = ret; }
tf.rax = ret as usize;
}
fn syscall32(tf: &mut TrapFrame) {
trace!("\nInterupt: Syscall {:#x?}", tf.rax);
use syscall::syscall;
let ret = syscall(tf.rax, [tf.rdx, tf.rcx, tf.rbx, tf.rdi, tf.rsi, 0], tf);
unsafe { *(&tf.rax as *const _ as *mut i32) = ret; }
tf.rax = ret as usize;
}
fn error(tf: &TrapFrame) {

@ -6,7 +6,7 @@ pub use self::riscv::*;
pub use self::x86_64::*;
pub const MAX_CPU_NUM: usize = 8;
pub const MAX_PROCESS_NUM: usize = 32;
pub const MAX_PROCESS_NUM: usize = 48;
#[cfg(target_arch = "riscv")]
mod riscv {
@ -18,7 +18,7 @@ mod riscv {
pub const KERNEL_OFFSET: usize = 0;
pub const KERNEL_PML4: usize = 0x8000_0000 >> 22;
pub const KERNEL_HEAP_OFFSET: usize = 0x8020_0000;
pub const KERNEL_HEAP_SIZE: usize = 0x0010_0000;
pub const KERNEL_HEAP_SIZE: usize = 0x0020_0000;
pub const MEMORY_OFFSET: usize = 0x8000_0000;
pub const MEMORY_END: usize = 0x8080_0000;
pub const USER_STACK_OFFSET: usize = 0x70000000;

Loading…
Cancel
Save