mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-26 11:23:37 +04:00
Remove sigret.S
This commit is contained in:
parent
7a97faee6c
commit
ae1a50673d
@ -4,7 +4,6 @@ mod pid;
|
||||
mod processor;
|
||||
mod signal;
|
||||
mod switch;
|
||||
mod sigret;
|
||||
mod action;
|
||||
#[allow(clippy::module_inception)]
|
||||
mod task;
|
||||
@ -27,8 +26,6 @@ pub use processor::{
|
||||
pub use signal::{SignalFlags, MAX_SIG};
|
||||
pub use action::{SignalAction, SignalActions};
|
||||
|
||||
use self::sigret::end_sigret;
|
||||
use self::sigret::start_sigret;
|
||||
|
||||
pub fn suspend_current_and_run_next() {
|
||||
// There must be an application running.
|
||||
@ -130,9 +127,9 @@ fn call_kernel_signal_handler(signal: SignalFlags) {
|
||||
}
|
||||
|
||||
fn call_user_signal_handler(sig: usize, signal: SignalFlags) {
|
||||
let token = current_user_token();
|
||||
let task = current_task().unwrap();
|
||||
let mut task_inner = task.inner_exclusive_access();
|
||||
let token = current_user_token();
|
||||
|
||||
let handler = task_inner.signal_actions.table[sig].handler;
|
||||
// change current mask
|
||||
@ -148,21 +145,8 @@ fn call_user_signal_handler(sig: usize, signal: SignalFlags) {
|
||||
// modify trapframe
|
||||
trap_ctx.sepc = handler;
|
||||
|
||||
// inject sigret
|
||||
let sigret_size = end_sigret as usize - start_sigret as usize;
|
||||
trap_ctx.x[2] -= sigret_size;
|
||||
let cur_sp = trap_ctx.x[2];
|
||||
unsafe {
|
||||
let target_sigret_ptr = translated_refmut(token, cur_sp as *mut u8);
|
||||
let target_sigret_ptr = core::slice::from_raw_parts_mut(target_sigret_ptr as *mut u8, sigret_size);
|
||||
let source_sigret_ptr = core::slice::from_raw_parts(start_sigret as usize as *mut u8, sigret_size);
|
||||
target_sigret_ptr.copy_from_slice(source_sigret_ptr);
|
||||
}
|
||||
|
||||
// put args (a0)
|
||||
trap_ctx.x[10] = sig;
|
||||
// return addr
|
||||
trap_ctx.x[1] = cur_sp;
|
||||
}
|
||||
|
||||
fn check_pending_signals() {
|
||||
@ -173,6 +157,7 @@ fn check_pending_signals() {
|
||||
if task_inner.signals.contains(signal) && (!task_inner.signal_mask.contains(signal)) {
|
||||
if task_inner.handling_sig == -1 {
|
||||
drop(task_inner);
|
||||
drop(task);
|
||||
if signal == SignalFlags::SIGKILL || signal == SignalFlags::SIGSTOP ||
|
||||
signal == SignalFlags::SIGCONT || signal == SignalFlags::SIGDEF {
|
||||
// signal is a kernel signal
|
||||
@ -185,6 +170,7 @@ fn check_pending_signals() {
|
||||
} else {
|
||||
if !task_inner.signal_actions.table[task_inner.handling_sig as usize].mask.contains(signal) {
|
||||
drop(task_inner);
|
||||
drop(task);
|
||||
if signal == SignalFlags::SIGKILL || signal == SignalFlags::SIGSTOP ||
|
||||
signal == SignalFlags::SIGCONT || signal == SignalFlags::SIGDEF {
|
||||
// signal is a kernel signal
|
||||
@ -208,6 +194,7 @@ pub fn handle_signals() {
|
||||
let frozen_flag = task_inner.frozen;
|
||||
let killed_flag = task_inner.killed;
|
||||
drop(task_inner);
|
||||
drop(task);
|
||||
if (!frozen_flag) || killed_flag {
|
||||
break;
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
.section .text
|
||||
.global start_sigret
|
||||
.global end_sigret
|
||||
start_sigret:
|
||||
li a7,139;
|
||||
ecall;
|
||||
ret;
|
||||
end_sigret:
|
@ -1,8 +0,0 @@
|
||||
use core::arch::global_asm;
|
||||
|
||||
global_asm!(include_str!("sigret.S"));
|
||||
|
||||
extern "C" {
|
||||
pub fn start_sigret();
|
||||
pub fn end_sigret();
|
||||
}
|
@ -4,10 +4,11 @@
|
||||
#[macro_use]
|
||||
extern crate user_lib;
|
||||
|
||||
use user_lib::{sigaction, sigprocmask, SignalAction, SignalFlags, fork, exit, wait, kill, getpid, sleep};
|
||||
use user_lib::{sigaction, sigprocmask, SignalAction, SignalFlags, fork, exit, wait, kill, getpid, sleep, sigreturn};
|
||||
|
||||
fn func() {
|
||||
println!("user_sig_test succsess");
|
||||
sigreturn();
|
||||
}
|
||||
|
||||
fn user_sig_test_failsignum() {
|
||||
|
@ -204,3 +204,7 @@ pub fn sigaction(signum: usize, action: *const SignalAction, old_action: *const
|
||||
pub fn sigprocmask(mask: u32) -> isize {
|
||||
sys_sigprocmask(mask)
|
||||
}
|
||||
|
||||
pub fn sigreturn() -> isize {
|
||||
sys_sigreturn()
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ const SYSCALL_YIELD: usize = 124;
|
||||
const SYSCALL_KILL: usize = 129;
|
||||
const SYSCALL_SIGACTION: usize = 134;
|
||||
const SYSCALL_SIGPROCMASK: usize = 135;
|
||||
const SYSCALL_SIGRETURN: usize = 139;
|
||||
const SYSCALL_GET_TIME: usize = 169;
|
||||
const SYSCALL_GETPID: usize = 172;
|
||||
const SYSCALL_FORK: usize = 220;
|
||||
@ -103,3 +104,7 @@ pub fn sys_sigaction(signum: usize, action: *const SignalAction, old_action: *co
|
||||
pub fn sys_sigprocmask(mask: u32) -> isize {
|
||||
syscall(SYSCALL_SIGPROCMASK, [mask as usize, 0, 0])
|
||||
}
|
||||
|
||||
pub fn sys_sigreturn() -> isize {
|
||||
syscall(SYSCALL_SIGRETURN, [0, 0, 0])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user