Remove the pub access in UserContext's fields

This commit is contained in:
Yuke Peng 2023-04-03 05:36:51 -07:00 committed by Tate, Hongliang Tian
parent d7d2d2ce40
commit efe88f9d47
3 changed files with 18 additions and 8 deletions

View File

@ -35,10 +35,9 @@ pub fn this_cpu() -> u32 {
#[derive(Clone, Default, Copy, Debug)]
#[repr(C)]
pub struct UserContext {
pub(crate) user_context: RawUserContext,
pub fp_regs: FpRegs,
/// trap information, this field is all zero when it is syscall
pub trap_information: TrapInformation,
user_context: RawUserContext,
fp_regs: FpRegs,
trap_information: TrapInformation,
}
#[derive(Clone, Default, Copy, Debug)]
@ -57,6 +56,18 @@ impl UserContext {
pub fn general_regs_mut(&mut self) -> &mut GeneralRegs {
&mut self.user_context.general
}
pub fn trap_information(&self) -> &TrapInformation {
&self.trap_information
}
pub fn fp_regs(&self) -> &FpRegs {
&self.fp_regs
}
pub fn fp_regs_mut(&mut self) -> &mut FpRegs {
&mut self.fp_regs
}
}
impl UserContextApiInternal for UserContext {

View File

@ -53,7 +53,7 @@ pub fn sys_execve(
let default_content = UserContext::default();
*context.general_regs_mut() = *default_content.general_regs();
context.set_fsbase(default_content.fsbase());
context.fp_regs = default_content.fp_regs;
*context.fp_regs_mut() = *default_content.fp_regs();
// set new entry point
context.set_rip(elf_load_info.entry_point() as _);
debug!("entry_point: 0x{:x}", elf_load_info.entry_point());

View File

@ -1,4 +1,3 @@
use jinux_frame::user::UserContextApi;
use jinux_frame::{cpu::*, vm::VmIo};
use crate::vm::page_fault_handler::PageFaultHandler;
@ -6,9 +5,9 @@ use crate::{prelude::*, process::signal::signals::fault::FaultSignal};
/// We can't handle most exceptions, just send self a fault signal before return to user space.
pub fn handle_exception(context: &mut UserContext) {
let trap_info = context.trap_information.clone();
let trap_info = context.trap_information();
let exception = CpuException::to_cpu_exception(trap_info.id as u16).unwrap();
log_trap_info(exception, &trap_info);
log_trap_info(exception, trap_info);
let current = current!();
let root_vmar = current.root_vmar();