Jelajahi Sumber

redox-exec: Add aarch64 stubs

Jeremy Soller 2 tahun lalu
induk
melakukan
9e2cbcc407

+ 18 - 1
src/platform/redox/clone.rs

@@ -68,7 +68,24 @@ pub unsafe fn pte_clone_impl(stack: *mut usize) -> Result<usize> {
     Ok(0)
 }
 
-//TODO
+//TODO: aarch64
+#[cfg(target_arch = "aarch64")]
+core::arch::global_asm!("
+    .globl __relibc_internal_pte_clone_ret
+    .type __relibc_internal_pte_clone_ret, @function
+    .p2align 6
+__relibc_internal_pte_clone_ret:
+    b __relibc_internal_pte_clone_ret
+
+    .size __relibc_internal_pte_clone_ret, . - __relibc_internal_pte_clone_ret
+");
+
+#[cfg(target_arch = "aarch64")]
+extern "C" {
+    fn __relibc_internal_pte_clone_ret();
+}
+
+//TODO: x86
 #[cfg(target_arch = "x86")]
 core::arch::global_asm!("
     .globl __relibc_internal_pte_clone_ret

+ 54 - 0
src/platform/redox/redox-exec/src/arch/aarch64.rs

@@ -0,0 +1,54 @@
+use syscall::error::*;
+
+use crate::{FdGuard, fork_inner};
+
+// 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;
+
+/// 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<()> {
+    //TODO: aarch64
+    Err(Error::new(ENOSYS))
+}
+
+pub fn copy_env_regs(cur_pid_fd: usize, new_pid_fd: usize) -> Result<()> {
+    //TODO: aarch64
+    Err(Error::new(ENOSYS))
+}
+
+#[no_mangle]
+unsafe extern "C" fn __relibc_internal_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) {
+    let _ = syscall::close(cur_filetable_fd);
+    let _ = syscall::close(new_pid_fd);
+}
+
+//TODO: aarch64
+core::arch::global_asm!("
+    .p2align 6
+    .globl __relibc_internal_fork_wrapper
+    .type __relibc_internal_fork_wrapper, @function
+__relibc_internal_fork_wrapper:
+        b __relibc_internal_fork_wrapper
+
+    .size __relibc_internal_fork_wrapper, . - __relibc_internal_fork_wrapper
+
+    .p2align 6
+    .globl __relibc_internal_fork_ret
+    .type __relibc_internal_fork_ret, @function
+__relibc_internal_fork_ret:
+        b __relibc_internal_fork_ret
+
+    .size __relibc_internal_fork_ret, . - __relibc_internal_fork_ret"
+);
+
+extern "C" {
+    pub(crate) fn __relibc_internal_fork_wrapper() -> usize;
+    pub(crate) fn __relibc_internal_fork_ret();
+}

+ 5 - 0
src/platform/redox/redox-exec/src/arch/mod.rs

@@ -1,3 +1,8 @@
+#[cfg(target_arch = "aarch64")]
+pub use self::aarch64::*;
+#[cfg(target_arch = "aarch64")]
+pub mod aarch64;
+
 #[cfg(target_arch = "x86")]
 pub use self::x86::*;
 #[cfg(target_arch = "x86")]

+ 1 - 1
src/platform/redox/redox-exec/src/arch/x86.rs

@@ -45,7 +45,7 @@ unsafe extern "cdecl" fn __relibc_internal_fork_hook(cur_filetable_fd: usize, ne
     let _ = syscall::close(new_pid_fd);
 }
 
-//TODO
+//TODO: x86
 core::arch::global_asm!("
     .p2align 6
     .globl __relibc_internal_fork_wrapper