Split ABI for x86_64/aarch64
This commit is contained in:
parent
15cbcf3d1f
commit
8bff432534
9
src/arch/aarch64.rs
Normal file
9
src/arch/aarch64.rs
Normal file
@ -0,0 +1,9 @@
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[repr(C)]
|
||||
pub struct SavedFrame {
|
||||
pub gp_regs: [u64; 32],
|
||||
pub spsr_el1: u64,
|
||||
pub elr_el1: u64,
|
||||
pub sp_el0: u64,
|
||||
}
|
13
src/arch/mod.rs
Normal file
13
src/arch/mod.rs
Normal file
@ -0,0 +1,13 @@
|
||||
//! Architecture-specific ABI implementation details
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub(crate) mod aarch64;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use aarch64 as arch_impl;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub(crate) mod x86_64;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use x86_64 as arch_impl;
|
||||
|
||||
pub use arch_impl::SavedFrame;
|
26
src/arch/x86_64.rs
Normal file
26
src/arch/x86_64.rs
Normal file
@ -0,0 +1,26 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[repr(C)]
|
||||
pub struct SavedFrame {
|
||||
pub rax: u64,
|
||||
pub rcx: u64,
|
||||
pub rdx: u64,
|
||||
pub rbx: u64,
|
||||
pub rsi: u64,
|
||||
pub rdi: u64,
|
||||
pub rbp: u64,
|
||||
|
||||
pub r8: u64,
|
||||
pub r9: u64,
|
||||
pub r10: u64,
|
||||
pub r11: u64,
|
||||
pub r12: u64,
|
||||
pub r13: u64,
|
||||
pub r14: u64,
|
||||
pub r15: u64,
|
||||
|
||||
pub user_ip: u64,
|
||||
pub user_sp: u64,
|
||||
pub rflags: u64,
|
||||
}
|
@ -28,6 +28,8 @@ primitive_enum!(
|
||||
DirectoryNotEmpty = 11,
|
||||
#[doc = "Operation was interrupted"]
|
||||
Interrupted = 12,
|
||||
#[doc = "Operation has not completed yet"]
|
||||
WouldBlock = 13,
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
pub(crate) mod macros;
|
||||
|
||||
pub mod arch;
|
||||
pub mod error;
|
||||
pub mod io;
|
||||
pub mod path;
|
||||
|
@ -1,15 +1,15 @@
|
||||
/// Helper macro to define primitive enums with integer reprs, as well as their conversion methods
|
||||
#[macro_export]
|
||||
macro_rules! primitive_enum {
|
||||
($(#[doc = $enum_doc:expr])? $vis:vis enum $name:ident: $repr:ty {
|
||||
$( $(#[doc = $doc:expr])? $variant:ident = $discriminant:literal, )+
|
||||
($(#[$struct_meta:meta])* $vis:vis enum $name:ident: $repr:ty {
|
||||
$( $(#[$variant_meta:meta])* $variant:ident = $discriminant:literal, )+
|
||||
}) => {
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[repr($repr)]
|
||||
$(#[doc = $enum_doc])?
|
||||
$(#[$struct_meta])*
|
||||
$vis enum $name {
|
||||
$(
|
||||
$(#[doc = $doc])?
|
||||
$(#[$variant_meta])?
|
||||
$variant = $discriminant
|
||||
),+
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use core::num::NonZeroI32;
|
||||
|
||||
use crate::{io::RawFd, primitive_enum};
|
||||
use crate::{arch::SavedFrame, io::RawFd, primitive_enum};
|
||||
|
||||
/// Code signalled by a process when it finishes or is terminated by a signal
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@ -40,21 +40,6 @@ primitive_enum! {
|
||||
}
|
||||
}
|
||||
|
||||
/// Platform-specific "snapshot" of a program's context, used to restore it later when returning
|
||||
/// from a signal handler
|
||||
#[derive(Clone, Debug)]
|
||||
#[repr(C)]
|
||||
pub struct SavedFrame {
|
||||
/// General-purpose registers
|
||||
pub gp_regs: [u64; 32],
|
||||
/// SPSR_EL1
|
||||
pub spsr_el1: u64,
|
||||
/// ELR_EL1 (return address)
|
||||
pub elr_el1: u64,
|
||||
/// SP_EL0 (return stack)
|
||||
pub sp_el0: u64,
|
||||
}
|
||||
|
||||
/// Data provided by the kernel to signal entry function
|
||||
#[derive(Clone, Debug)]
|
||||
#[repr(C)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user