mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-18 12:06:43 +00:00
Remove the pub access in UserContext's fields
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
d7d2d2ce40
commit
efe88f9d47
@ -35,10 +35,9 @@ pub fn this_cpu() -> u32 {
|
|||||||
#[derive(Clone, Default, Copy, Debug)]
|
#[derive(Clone, Default, Copy, Debug)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct UserContext {
|
pub struct UserContext {
|
||||||
pub(crate) user_context: RawUserContext,
|
user_context: RawUserContext,
|
||||||
pub fp_regs: FpRegs,
|
fp_regs: FpRegs,
|
||||||
/// trap information, this field is all zero when it is syscall
|
trap_information: TrapInformation,
|
||||||
pub trap_information: TrapInformation,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, Copy, Debug)]
|
#[derive(Clone, Default, Copy, Debug)]
|
||||||
@ -57,6 +56,18 @@ impl UserContext {
|
|||||||
pub fn general_regs_mut(&mut self) -> &mut GeneralRegs {
|
pub fn general_regs_mut(&mut self) -> &mut GeneralRegs {
|
||||||
&mut self.user_context.general
|
&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 {
|
impl UserContextApiInternal for UserContext {
|
||||||
|
@ -53,7 +53,7 @@ pub fn sys_execve(
|
|||||||
let default_content = UserContext::default();
|
let default_content = UserContext::default();
|
||||||
*context.general_regs_mut() = *default_content.general_regs();
|
*context.general_regs_mut() = *default_content.general_regs();
|
||||||
context.set_fsbase(default_content.fsbase());
|
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
|
// set new entry point
|
||||||
context.set_rip(elf_load_info.entry_point() as _);
|
context.set_rip(elf_load_info.entry_point() as _);
|
||||||
debug!("entry_point: 0x{:x}", elf_load_info.entry_point());
|
debug!("entry_point: 0x{:x}", elf_load_info.entry_point());
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use jinux_frame::user::UserContextApi;
|
|
||||||
use jinux_frame::{cpu::*, vm::VmIo};
|
use jinux_frame::{cpu::*, vm::VmIo};
|
||||||
|
|
||||||
use crate::vm::page_fault_handler::PageFaultHandler;
|
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.
|
/// We can't handle most exceptions, just send self a fault signal before return to user space.
|
||||||
pub fn handle_exception(context: &mut UserContext) {
|
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();
|
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 current = current!();
|
||||||
let root_vmar = current.root_vmar();
|
let root_vmar = current.root_vmar();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user