syscall: add FullContextRegs arch types for /proc/{pid}/ctx

This commit is contained in:
2026-07-08 17:57:54 +03:00
parent c59951c038
commit 9fad5e653c
4 changed files with 124 additions and 0 deletions
+31
View File
@@ -95,6 +95,14 @@ pub struct IntRegisters {
pub x0: usize,
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C)]
pub struct FullContextRegs {
pub int: IntRegisters,
pub float: FloatRegisters,
pub env: EnvRegisters,
}
impl Deref for IntRegisters {
type Target = [u8];
fn deref(&self) -> &[u8] {
@@ -149,6 +157,29 @@ impl DerefMut for FloatRegisters {
}
}
impl Deref for FullContextRegs {
type Target = [u8];
fn deref(&self) -> &[u8] {
unsafe {
slice::from_raw_parts(
self as *const FullContextRegs as *const u8,
mem::size_of::<FullContextRegs>(),
)
}
}
}
impl DerefMut for FullContextRegs {
fn deref_mut(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(
self as *mut FullContextRegs as *mut u8,
mem::size_of::<FullContextRegs>(),
)
}
}
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C, packed)]
pub struct EnvRegisters {
+31
View File
@@ -96,6 +96,14 @@ pub struct IntRegisters {
pub x1: usize,
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C)]
pub struct FullContextRegs {
pub int: IntRegisters,
pub float: FloatRegisters,
pub env: EnvRegisters,
}
impl Deref for IntRegisters {
type Target = [u8];
fn deref(&self) -> &[u8] {
@@ -149,6 +157,29 @@ impl DerefMut for FloatRegisters {
}
}
impl Deref for FullContextRegs {
type Target = [u8];
fn deref(&self) -> &[u8] {
unsafe {
slice::from_raw_parts(
self as *const FullContextRegs as *const u8,
mem::size_of::<FullContextRegs>(),
)
}
}
}
impl DerefMut for FullContextRegs {
fn deref_mut(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(
self as *mut FullContextRegs as *mut u8,
mem::size_of::<FullContextRegs>(),
)
}
}
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(packed)]
pub struct EnvRegisters {
+31
View File
@@ -164,6 +164,14 @@ pub struct IntRegisters {
// pub gs: usize
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C)]
pub struct FullContextRegs {
pub int: IntRegisters,
pub float: FloatRegisters,
pub env: EnvRegisters,
}
impl Deref for IntRegisters {
type Target = [u8];
fn deref(&self) -> &[u8] {
@@ -227,6 +235,29 @@ impl DerefMut for FloatRegisters {
}
}
impl Deref for FullContextRegs {
type Target = [u8];
fn deref(&self) -> &[u8] {
unsafe {
slice::from_raw_parts(
self as *const FullContextRegs as *const u8,
mem::size_of::<FullContextRegs>(),
)
}
}
}
impl DerefMut for FullContextRegs {
fn deref_mut(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(
self as *mut FullContextRegs as *mut u8,
mem::size_of::<FullContextRegs>(),
)
}
}
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C, packed)]
pub struct EnvRegisters {
+31
View File
@@ -81,6 +81,14 @@ pub struct IntRegisters {
pub ss: usize,
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C)]
pub struct FullContextRegs {
pub int: IntRegisters,
pub float: FloatRegisters,
pub env: EnvRegisters,
}
impl Deref for IntRegisters {
type Target = [u8];
fn deref(&self) -> &[u8] {
@@ -133,6 +141,29 @@ impl DerefMut for FloatRegisters {
}
}
}
impl Deref for FullContextRegs {
type Target = [u8];
fn deref(&self) -> &[u8] {
unsafe {
slice::from_raw_parts(
self as *const FullContextRegs as *const u8,
mem::size_of::<FullContextRegs>(),
)
}
}
}
impl DerefMut for FullContextRegs {
fn deref_mut(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(
self as *mut FullContextRegs as *mut u8,
mem::size_of::<FullContextRegs>(),
)
}
}
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C, packed)]
pub struct EnvRegisters {