Skip to content
Snippets Groups Projects
Verified Commit 18b5c73b authored by Jacob Lorentzon's avatar Jacob Lorentzon
Browse files

Compile on the other arches.

parent f37bb3cb
No related branches found
No related tags found
1 merge request!480Refactor redox runtime and impl signals in userspace
use syscall::error::*;
use crate::{fork_inner, FdGuard};
use crate::proc::{fork_inner, FdGuard};
use crate::signal::inner_c;
// Setup a stack starting from the very end of the address space, and then growing downwards.
pub(crate) const STACK_TOP: usize = 1 << 47;
pub(crate) const STACK_SIZE: usize = 1024 * 1024;
#[derive(Debug, Default)]
pub struct SigArea {
pub altstack_top: usize,
pub altstack_bottom: usize,
pub tmp: usize,
pub onstack: u64,
pub disable_signals_depth: u64,
}
/// Deactive TLS, used before exec() on Redox to not trick target executable into thinking TLS
/// is already initialized as if it was a thread.
pub unsafe fn deactivate_tcb(open_via_dup: usize) -> Result<()> {
......@@ -33,18 +43,16 @@ pub fn copy_env_regs(cur_pid_fd: usize, new_pid_fd: usize) -> Result<()> {
Ok(())
}
#[no_mangle]
unsafe extern "C" fn __relibc_internal_fork_impl(initial_rsp: *mut usize) -> usize {
unsafe extern "C" fn fork_impl(initial_rsp: *mut usize) -> usize {
Error::mux(fork_inner(initial_rsp))
}
#[no_mangle]
unsafe extern "C" fn __relibc_internal_fork_hook(cur_filetable_fd: usize, new_pid_fd: usize) {
unsafe extern "C" fn child_hook(cur_filetable_fd: usize, new_pid_fd: usize) {
let _ = syscall::close(cur_filetable_fd);
let _ = syscall::close(new_pid_fd);
}
asmfunction!(__relibc_internal_fork_wrapper: ["
asmfunction!(__relibc_internal_fork_wrapper -> usize: ["
stp x29, x30, [sp, #-16]!
stp x27, x28, [sp, #-16]!
stp x25, x26, [sp, #-16]!
......@@ -57,20 +65,20 @@ asmfunction!(__relibc_internal_fork_wrapper: ["
//TODO: store floating point regs
mov x0, sp
bl __relibc_internal_fork_impl
b 2f
"]);
bl {fork_impl}
add sp, sp, #128
ret
"] <= [fork_impl = sym fork_impl]);
asmfunction!(__relibc_internal_fork_hook: ["
asmfunction!(__relibc_internal_fork_ret: ["
ldp x0, x1, [sp]
bl __relibc_internal_fork_hook
bl {child_hook}
//TODO: load floating point regs
mov x0, xzr
.p2align 4
2:
add sp, sp, #32
ldp x19, x20, [sp], #16
ldp x21, x22, [sp], #16
......@@ -80,17 +88,17 @@ asmfunction!(__relibc_internal_fork_hook: ["
ldp x29, x30, [sp], #16
ret
"]);
"] <= [child_hook = sym child_hook]);
asmfunction!(__relibc_internal_sigentry: ["
mov x0, sp
bl {inner}
mov x8, {SYS_SIGRETURN}
svc 0
"] <= [inner = sym inner_c, SYS_SIGRETURN = const SYS_SIGRETURN]);
// FIXME
b .
"] <= [inner = sym inner_c]);
asmfunction!(__relibc_internal_rlct_clone_ret -> usize: ["
asmfunction!(__relibc_internal_rlct_clone_ret: ["
# Load registers
ldp x8, x0, [sp], #16
ldp x1, x2, [sp], #16
......@@ -100,4 +108,4 @@ asmfunction!(__relibc_internal_rlct_clone_ret -> usize: ["
blr x8
ret
"]);
"] <= []);
use syscall::error::*;
use crate::{fork_inner, FdGuard};
use crate::proc::{fork_inner, FdGuard};
use crate::signal::{inner_fastcall, RtSigarea};
// Setup a stack starting from the very end of the address space, and then growing downwards.
pub(crate) const STACK_TOP: usize = 1 << 31;
pub(crate) const STACK_SIZE: usize = 1024 * 1024;
#[derive(Debug, Default)]
pub struct SigArea {
pub altstack_top: usize,
pub altstack_bottom: usize,
pub tmp: usize,
pub onstack: u64,
pub disable_signals_depth: u64,
}
/// Deactive TLS, used before exec() on Redox to not trick target executable into thinking TLS
/// is already initialized as if it was a thread.
pub unsafe fn deactivate_tcb(open_via_dup: usize) -> Result<()> {
......@@ -45,7 +55,7 @@ unsafe extern "cdecl" fn __relibc_internal_fork_hook(cur_filetable_fd: usize, ne
let _ = syscall::close(new_pid_fd);
}
asmfunction!(__relibc_internal_fork_wrapper: ["
asmfunction!(__relibc_internal_fork_wrapper -> usize: ["
push ebp
mov ebp, esp
......@@ -98,9 +108,8 @@ asmfunction!(__relibc_internal_sigentry: ["
add esp, 512
fxrstor [esp]
mov eax, {SYS_SIGRETURN}
int 0x80
"] <= [inner = sym inner_fastcall, SYS_SIGRETURN = const SYS_SIGRETURN]);
ud2
"] <= [inner = sym inner_fastcall]);
asmfunction!(__relibc_internal_rlct_clone_ret -> usize: ["
# Load registers
......
......@@ -4,9 +4,9 @@ pub use self::aarch64::*;
pub mod aarch64;
#[cfg(target_arch = "x86")]
pub use self::x86::*;
pub use self::i686::*;
#[cfg(target_arch = "x86")]
pub mod x86;
pub mod i686;
#[cfg(target_arch = "x86_64")]
pub use self::x86_64::*;
......
......@@ -45,8 +45,8 @@ pub type Tcb = GenericTcb<RtSigarea>;
pub unsafe fn tcb_activate(tls_end: usize, tls_len: usize) {
// Uses ABI page
let abi_ptr = tls_end - tls_len - 16;
ptr::write(abi_ptr as *mut usize, tls_end);
asm!(
core::ptr::write(abi_ptr as *mut usize, tls_end);
core::arch::asm!(
"msr tpidr_el0, {}",
in(reg) abi_ptr,
);
......
......@@ -11,7 +11,7 @@ use crate::sync::Mutex;
static CPUID_EAX1_ECX: core::sync::atomic::AtomicU32 = core::sync::atomic::AtomicU32::new(0);
pub fn sighandler_function() -> usize {
#[cfg(target_arch = "x86_64")]
//#[cfg(target_arch = "x86_64")]
// Check OSXSAVE bit
// TODO: HWCAP?
/*if CPUID_EAX1_ECX.load(core::sync::atomic::Ordering::Relaxed) & (1 << 27) != 0 {
......@@ -73,7 +73,7 @@ pub(crate) unsafe extern "C" fn inner_c(stack: usize) {
inner(&mut *(stack as *mut SigStack))
}
#[cfg(target_arch = "x86")]
unsafe extern "fastcall" fn inner_fastcall(stack: usize) {
pub(crate) unsafe extern "fastcall" fn inner_fastcall(stack: usize) {
inner(&mut *(stack as *mut SigStack))
}
......
......@@ -125,7 +125,7 @@ impl PalSignal for Sys {
SigactionKind::Ignore
} else {
SigactionKind::Handled {
handler: if c_act.sa_flags & crate::header::signal::SA_SIGINFO as u64 != 0 {
handler: if c_act.sa_flags & crate::header::signal::SA_SIGINFO as c_ulong != 0 {
SignalHandler {
sigaction: unsafe { core::mem::transmute(c_act.sa_handler) },
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment