arm64: Add thread exit syscall in commpage.

Change-Id: Ia8e7e4626add623735fefefa1af151b7338adc35
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5265
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
milek7
2022-05-29 18:51:32 +00:00
committed by waddlesplash
parent d1c3213a6d
commit e9d04b25e6
3 changed files with 37 additions and 0 deletions
@@ -10,4 +10,6 @@
# error Must not be included directly. Include <commpage_defs.h> instead!
#endif
#define COMMPAGE_ENTRY_ARM64_THREAD_EXIT (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 0)
#endif /* _SYSTEM_ARCH_ARM64_COMMPAGE_DEFS_H */
+5
View File
@@ -5,9 +5,14 @@
#include <arch/arm/arch_cpu.h>
#include <asm_defs.h>
#include "asm_offsets.h"
#include "syscall_numbers.h"
.text
FUNCTION(_thread_exit_syscall):
svc #((SYSCALL_EXIT_THREAD << 5) | 1)
FUNCTION_END(_thread_exit_syscall)
.macro xchg_sp xt
add sp, sp, \xt
sub \xt, sp, \xt
@@ -13,6 +13,33 @@
#include <smp.h>
extern "C" void _thread_exit_syscall();
static void
register_commpage_function(const char* functionName, int32 commpageIndex,
const char* commpageSymbolName, addr_t expectedAddress)
{
// get address and size of function
elf_symbol_info symbolInfo;
if (elf_lookup_kernel_symbol(functionName, &symbolInfo) != B_OK) {
panic("register_commpage_function(): Failed to find signal frame function \"%s\"!",
functionName);
}
ASSERT(expectedAddress == symbolInfo.address);
// fill in the commpage table entry
addr_t position = fill_commpage_entry(commpageIndex, (void*)symbolInfo.address,
symbolInfo.size);
// add symbol to the commpage image
image_id image = get_commpage_image();
elf_add_memory_image_symbol(image, commpageSymbolName, position, symbolInfo.size,
B_SYMBOL_TYPE_TEXT);
}
status_t
arch_commpage_init(void)
{
@@ -23,5 +50,8 @@ arch_commpage_init(void)
status_t
arch_commpage_init_post_cpus(void)
{
register_commpage_function("_thread_exit_syscall", COMMPAGE_ENTRY_ARM64_THREAD_EXIT,
"commpage_thread_exit", (addr_t)&_thread_exit_syscall);
return B_OK;
}