mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-24 17:06:18 +04:00
Implement sys_reboot with isa-debug-exit and add test script using expect
This commit is contained in:
parent
9269a9856d
commit
8dc7c7bd3c
@ -148,7 +148,7 @@ impl ThreadPool {
|
|||||||
match (&proc.status, &status) {
|
match (&proc.status, &status) {
|
||||||
(Status::Ready, Status::Ready) => return,
|
(Status::Ready, Status::Ready) => return,
|
||||||
(Status::Ready, _) => panic!("can not remove a process from ready queue"),
|
(Status::Ready, _) => panic!("can not remove a process from ready queue"),
|
||||||
(Status::Exited(_), _) => panic!("can not set status for a exited process"),
|
(Status::Exited(_), _) => panic!("can not set status for a exited thread"),
|
||||||
(Status::Sleeping, Status::Exited(_)) => self.timer.lock().stop(Event::Wakeup(tid)),
|
(Status::Sleeping, Status::Exited(_)) => self.timer.lock().stop(Event::Wakeup(tid)),
|
||||||
(Status::Running(_), Status::Ready) => {} // process will be added to scheduler in stop()
|
(Status::Running(_), Status::Ready) => {} // process will be added to scheduler in stop()
|
||||||
(_, Status::Ready) => self.scheduler.push(tid),
|
(_, Status::Ready) => self.scheduler.push(tid),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
use core::sync::atomic::{AtomicI32, Ordering};
|
use core::sync::atomic::{AtomicI32, Ordering};
|
||||||
|
use crate::arch::cpu;
|
||||||
|
|
||||||
pub fn sys_arch_prctl(code: i32, addr: usize, tf: &mut TrapFrame) -> SysResult {
|
pub fn sys_arch_prctl(code: i32, addr: usize, tf: &mut TrapFrame) -> SysResult {
|
||||||
const ARCH_SET_FS: i32 = 0x1002;
|
const ARCH_SET_FS: i32 = 0x1002;
|
||||||
@ -111,6 +112,18 @@ pub fn sys_futex(uaddr: usize, op: u32, val: i32, timeout: *const TimeSpec) -> S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const LINUX_REBOOT_CMD_HALT: u32 = 0xcdef0123;
|
||||||
|
pub fn sys_reboot(magic: u32, magic2: u32, cmd: u32, arg: *const u8) -> SysResult {
|
||||||
|
// we will skip verifying magic
|
||||||
|
if cmd == LINUX_REBOOT_CMD_HALT {
|
||||||
|
unsafe {
|
||||||
|
cpu::exit_in_qemu(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(0)
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct SysInfo {
|
pub struct SysInfo {
|
||||||
|
@ -105,7 +105,7 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize {
|
|||||||
158 => sys_arch_prctl(args[0] as i32, args[1], tf),
|
158 => sys_arch_prctl(args[0] as i32, args[1], tf),
|
||||||
// 160 => sys_setrlimit(),
|
// 160 => sys_setrlimit(),
|
||||||
// 162 => sys_sync(),
|
// 162 => sys_sync(),
|
||||||
// 169 => sys_reboot(),
|
169 => sys_reboot(args[0] as u32, args[1] as u32, args[2] as u32, args[3] as *const u8),
|
||||||
186 => sys_gettid(),
|
186 => sys_gettid(),
|
||||||
201 => sys_time(args[0] as *mut u64),
|
201 => sys_time(args[0] as *mut u64),
|
||||||
202 => sys_futex(args[0], args[1] as u32, args[2] as i32, args[3] as *const TimeSpec),
|
202 => sys_futex(args[0], args[1] as u32, args[2] as i32, args[3] as *const TimeSpec),
|
||||||
@ -181,6 +181,10 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize {
|
|||||||
warn!("sys_sigaltstack is unimplemented");
|
warn!("sys_sigaltstack is unimplemented");
|
||||||
Ok(0)
|
Ok(0)
|
||||||
}
|
}
|
||||||
|
162 => {
|
||||||
|
warn!("sys_sync is unimplemented");
|
||||||
|
Ok(0)
|
||||||
|
}
|
||||||
213 => {
|
213 => {
|
||||||
warn!("sys_epoll_create is unimplemented");
|
warn!("sys_epoll_create is unimplemented");
|
||||||
Err(SysError::ENOSYS)
|
Err(SysError::ENOSYS)
|
||||||
|
13
tests/fork.exp
Normal file
13
tests/fork.exp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
set timeout -1
|
||||||
|
cd ../kernel
|
||||||
|
spawn make run arch=x86_64
|
||||||
|
sleep 2
|
||||||
|
expect ">>"
|
||||||
|
sleep 2
|
||||||
|
send "biscuit/fork\n"
|
||||||
|
sleep 2
|
||||||
|
expect "hello from 100"
|
||||||
|
expect "parent done!"
|
||||||
|
sleep 2
|
||||||
|
send "busybox halt -f\n"
|
||||||
|
expect ">>"
|
2
tests/test.sh
Executable file
2
tests/test.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
expect *.exp
|
2
user
2
user
@ -1 +1 @@
|
|||||||
Subproject commit 93bac1ce10eae9aa541b64e955316b325f8dc9cb
|
Subproject commit 9ba5207eecc6f3685dd976d1a5aa6f23b5066f0b
|
Loading…
Reference in New Issue
Block a user