mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-23 03:53:26 +00:00
增加x87FPU支持 (#212)
* remove `ret_from_syscall` *修复ps2键盘驱动程序inode在进程fork的时候导致死锁的问题. *更新: VFS每次拷贝文件描述符的时候,都会去调用inode的open函数 --------- Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
@ -1,8 +1,14 @@
|
||||
use core::{ffi::c_void, intrinsics::size_of, ptr::read_volatile, sync::atomic::compiler_fence};
|
||||
use core::{
|
||||
ffi::c_void,
|
||||
intrinsics::size_of,
|
||||
ptr::{null_mut, read_volatile},
|
||||
sync::atomic::compiler_fence,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
arch::{
|
||||
asm::{bitops::ffz, current::current_pcb, ptrace::user_mode},
|
||||
fpu::FpState,
|
||||
interrupt::sti,
|
||||
},
|
||||
include::bindings::bindings::{
|
||||
@ -658,6 +664,17 @@ fn setup_frame(
|
||||
(*frame).handler = ka._u._sa_handler as usize as *mut c_void;
|
||||
}
|
||||
|
||||
// 将当前进程的fp_state拷贝到用户栈
|
||||
if current_pcb().fp_state != null_mut() {
|
||||
unsafe {
|
||||
let fp_state: &mut FpState = (current_pcb().fp_state as usize as *mut FpState)
|
||||
.as_mut()
|
||||
.unwrap();
|
||||
(*frame).context.sc_stack.fpstate = *fp_state;
|
||||
// 保存完毕后,清空fp_state,以免下次save的时候,出现SIMD exception
|
||||
fp_state.clear();
|
||||
}
|
||||
}
|
||||
// 将siginfo拷贝到用户栈
|
||||
err |= copy_siginfo_to_user(unsafe { &mut (*frame).info }, info).unwrap_or(1);
|
||||
|
||||
@ -768,7 +785,11 @@ fn restore_sigcontext(context: *const sigcontext, regs: &mut pt_regs) -> bool {
|
||||
(*current_thread).trap_num = (*context).trap_num;
|
||||
(*current_thread).cr2 = (*context).cr2;
|
||||
(*current_thread).err_code = (*context).err_code;
|
||||
|
||||
// 如果当前进程有fpstate,则将其恢复到pcb的fp_state中
|
||||
*(current_pcb().fp_state as usize as *mut FpState) = (*context).sc_stack.fpstate;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ use core::fmt::Debug;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use crate::arch::fpu::FpState;
|
||||
use crate::include::bindings::bindings::NULL;
|
||||
// todo: 将这里更换为手动编写的ffi绑定
|
||||
use crate::include::bindings::bindings::atomic_t;
|
||||
@ -664,4 +665,5 @@ pub struct signal_stack {
|
||||
pub sp: *mut c_void,
|
||||
pub flags: u32,
|
||||
pub size: u32,
|
||||
pub fpstate:FpState,
|
||||
}
|
||||
|
Reference in New Issue
Block a user