diff --git a/.gitignore b/.gitignore index 1358d8d..aa837aa 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,5 @@ build/** **/*.o **/*.a -**/*.so -**/haiku_include/** \ No newline at end of file +**/*.so* +**/haiku_include/** diff --git a/haiku_loader/sys/linux/loader_commpage.cpp b/haiku_loader/sys/linux/loader_commpage.cpp index 9f1cd6f..6266c01 100644 --- a/haiku_loader/sys/linux/loader_commpage.cpp +++ b/haiku_loader/sys/linux/loader_commpage.cpp @@ -50,6 +50,12 @@ void* loader_allocate_commpage() // Stubbed. realTimeData->arch_data.system_time_conversion_factor = 0; realTimeData->arch_data.system_time_offset = 0; +#elif defined(__aarch64__) + // Stubbed. + realTimeData->arch_data.data[0].system_time_offset = 0; + realTimeData->arch_data.data[1].system_time_offset = 0; + realTimeData->arch_data.system_time_conversion_factor = 0; + realTimeData->arch_data.version = 0; #else #warning commpage time data not set up for this architecture. #endif diff --git a/libroot/libgcc_s.so.1 b/libroot/libgcc_s.so.1 deleted file mode 100644 index a1495b5..0000000 Binary files a/libroot/libgcc_s.so.1 and /dev/null differ diff --git a/monika/linux/linux_syscall.S b/monika/linux/linux_syscall.S index adaccc8..01820ff 100644 --- a/monika/linux/linux_syscall.S +++ b/monika/linux/linux_syscall.S @@ -35,8 +35,14 @@ linux_syscall: pop %ebx ret +#elif defined(__aarch64__) + + mov x8, x6 + svc 0 + ret + #else # error Missing assembly! -#endif \ No newline at end of file +#endif diff --git a/monika/linux/process.cpp b/monika/linux/process.cpp index ea3170d..78143af 100644 --- a/monika/linux/process.cpp +++ b/monika/linux/process.cpp @@ -2,9 +2,9 @@ #include "haiku_signal.h" #include -#include #include #include +#include #include #include "BeDefs.h" @@ -270,4 +270,4 @@ haiku_pid_t _moni_setsid() return result; } -} \ No newline at end of file +} diff --git a/monika/linux/signal_conversion.cpp b/monika/linux/signal_conversion.cpp index 5f31166..8d0c645 100644 --- a/monika/linux/signal_conversion.cpp +++ b/monika/linux/signal_conversion.cpp @@ -384,7 +384,22 @@ void ContextLinuxToB(const ucontext_t& linuxContext, haiku_ucontext_t& context) // TODO: floating point registers. memset(&context.uc_mcontext.fpu, 0, sizeof(context.uc_mcontext.fpu)); +#elif defined(__aarch64__) + for (int i = 0; i < 29; ++i) + { + context.uc_mcontext.x[i] = linuxContext.uc_mcontext.regs[i]; + } + context.uc_mcontext.lr = linuxContext.uc_mcontext.regs[30]; + context.uc_mcontext.sp = linuxContext.uc_mcontext.sp; + + // TODO: additional rocessor state + // https://elixir.bootlin.com/linux/latest/source/arch/arm64/include/uapi/asm/sigcontext.h + context.uc_mcontext.elr = 0; + context.uc_mcontext.spsr = 0; + memset(&context.uc_mcontext.fp_q, 0, sizeof(context.uc_mcontext.fp_q)); + context.uc_mcontext.fpsr = 0; + context.uc_mcontext.fpcr = 0; #else # error Implement mcontext_t marshalling on this platform! #endif -} \ No newline at end of file +} diff --git a/monika/linux/signal_restore.S b/monika/linux/signal_restore.S index 961d9a7..6e514de 100644 --- a/monika/linux/signal_restore.S +++ b/monika/linux/signal_restore.S @@ -22,8 +22,15 @@ __restore_rt: movl $173, %eax int $0x80 +#elif defined(__aarch64__) + +__restore: +__restore_rt: + mov x8,#139 // SYS_rt_sigreturn + svc 0 + #else # error Missing assembly! -#endif \ No newline at end of file +#endif diff --git a/runtime_loader/stl6c1j9 b/runtime_loader/stl6c1j9 deleted file mode 100644 index e69de29..0000000 diff --git a/shared_headers/BeDefs.h b/shared_headers/BeDefs.h index f65cb2f..dd57b45 100644 --- a/shared_headers/BeDefs.h +++ b/shared_headers/BeDefs.h @@ -11,6 +11,9 @@ typedef unsigned int uint32; typedef int64_t int64; typedef uint64_t uint64; +typedef volatile int32 vint32; +typedef volatile int64 vint64; + typedef unsigned char uchar; typedef int32 status_t; @@ -65,6 +68,9 @@ typedef long signed int haiku_ssize_t; #ifdef __x86_64__ #define B_PAGE_SIZE 4096 #define B_HAIKU_64_BIT 1 +#elif defined(__aarch64__) +#define B_PAGE_SIZE 4096 +#define B_HAIKU_64_BIT 1 #endif struct user_space_program_args @@ -101,4 +107,4 @@ enum | B_TIMEOUT_REAL_TIME_BASE }; -#endif // __HAIKU_STRUCTS_H__ \ No newline at end of file +#endif // __HAIKU_STRUCTS_H__ diff --git a/shared_headers/arm64/arch_commpage_defs.h b/shared_headers/arm64/arch_commpage_defs.h new file mode 100644 index 0000000..2d2fd25 --- /dev/null +++ b/shared_headers/arm64/arch_commpage_defs.h @@ -0,0 +1,15 @@ +/* + * Copyright 2019 Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ + +#ifndef _SYSTEM_ARCH_ARM64_COMMPAGE_DEFS_H +#define _SYSTEM_ARCH_ARM64_COMMPAGE_DEFS_H + +#ifndef _SYSTEM_COMMPAGE_DEFS_H +# error Must not be included directly. Include instead! +#endif + +#define COMMPAGE_ENTRY_ARM64_THREAD_EXIT (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 0) + +#endif /* _SYSTEM_ARCH_ARM64_COMMPAGE_DEFS_H */ diff --git a/shared_headers/arm64/arch_debugger.h b/shared_headers/arm64/arch_debugger.h new file mode 100644 index 0000000..0f2487f --- /dev/null +++ b/shared_headers/arm64/arch_debugger.h @@ -0,0 +1,16 @@ +/* + * Copyright 2019 Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _ARCH_ARM64_DEBUGGER_H +#define _ARCH_ARM64_DEBUGGER_H + +struct arm64_debug_cpu_state { + unsigned long x[30]; + unsigned long lr; + unsigned long sp; + unsigned long elr; + unsigned int spsr; +} __attribute__((aligned(16))); + +#endif // _ARCH_ARM_DEBUGGER_H diff --git a/shared_headers/arm64/arch_real_time_data.h b/shared_headers/arm64/arch_real_time_data.h new file mode 100644 index 0000000..16ec433 --- /dev/null +++ b/shared_headers/arm64/arch_real_time_data.h @@ -0,0 +1,20 @@ +/* + * Copyright 2019 Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_REAL_TIME_DATA_H +#define _KERNEL_ARCH_REAL_TIME_DATA_H + +#include "BeDefs.h" + +struct arm64_real_time_data { + vint64 system_time_offset; +}; + +struct arch_real_time_data { + struct arm64_real_time_data data[2]; + vint32 system_time_conversion_factor; + vint32 version; +}; + +#endif /* _KERNEL_ARCH_REAL_TIME_DATA_H */ diff --git a/shared_headers/arm64/arch_signal.h b/shared_headers/arm64/arch_signal.h new file mode 100644 index 0000000..5d7bf96 --- /dev/null +++ b/shared_headers/arm64/arch_signal.h @@ -0,0 +1,29 @@ +/* + * Copyright 2019 Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ + +#ifndef _ARCH_ARM64_SIGNAL_H_ +#define _ARCH_ARM64_SIGNAL_H_ + + +/* + * Architecture-specific structure passed to signal handlers + */ + +#if defined(__aarch64__) +struct vregs +{ + unsigned long x[30]; + unsigned long lr; + unsigned long sp; + unsigned long elr; + unsigned long spsr; + __uint128_t fp_q[32]; + unsigned int fpsr; + unsigned int fpcr; +}; +#endif /* defined(__aarch64__) */ + + +#endif /* _ARCH_ARM64_SIGNAL_H_ */