Squash commits for public release
This commit is contained in:
22
kernel/include/platform/arm64/tasking/context.h
Normal file
22
kernel/include/platform/arm64/tasking/context.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef _KERNEL_PLATFORM_ARM64_TASKING_CONTEXT_H
|
||||
#define _KERNEL_PLATFORM_ARM64_TASKING_CONTEXT_H
|
||||
|
||||
#include <libkern/c_attrs.h>
|
||||
#include <libkern/types.h>
|
||||
|
||||
typedef struct {
|
||||
uint64_t x[22];
|
||||
uint64_t lr;
|
||||
} PACKED context_t;
|
||||
|
||||
static inline uintptr_t context_get_instruction_pointer(context_t* ctx)
|
||||
{
|
||||
return ctx->lr;
|
||||
}
|
||||
|
||||
static inline void context_set_instruction_pointer(context_t* ctx, uintptr_t ip)
|
||||
{
|
||||
ctx->lr = ip;
|
||||
}
|
||||
|
||||
#endif // _KERNEL_PLATFORM_ARM64_TASKING_CONTEXT_H
|
||||
12
kernel/include/platform/arm64/tasking/dump_impl.h
Normal file
12
kernel/include/platform/arm64/tasking/dump_impl.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef _KERNEL_PLATFORM_ARM64_TASKING_DUMP_IMPL_H
|
||||
#define _KERNEL_PLATFORM_ARM64_TASKING_DUMP_IMPL_H
|
||||
|
||||
#include <libkern/types.h>
|
||||
#include <tasking/bits/dump.h>
|
||||
#include <tasking/tasking.h>
|
||||
|
||||
int dump_impl(dump_data_t* data);
|
||||
int dump_kernel_impl(dump_data_t* dump_data, const char* err_desc);
|
||||
int dump_kernel_impl_from_tf(dump_data_t* dump_data, const char* err_desc, trapframe_t* tf);
|
||||
|
||||
#endif // _KERNEL_PLATFORM_ARM64_TASKING_DUMP_IMPL_H
|
||||
10
kernel/include/platform/arm64/tasking/signal_impl.h
Normal file
10
kernel/include/platform/arm64/tasking/signal_impl.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef _KERNEL_PLATFORM_ARM64_TASKING_SIGNAL_IMPL_H
|
||||
#define _KERNEL_PLATFORM_ARM64_TASKING_SIGNAL_IMPL_H
|
||||
|
||||
#include <libkern/types.h>
|
||||
struct thread;
|
||||
|
||||
int signal_impl_prepare_stack(struct thread* thread, int signo, uintptr_t old_sp, uintptr_t magic);
|
||||
int signal_impl_restore_stack(struct thread* thread, uintptr_t* old_sp, uintptr_t* magic);
|
||||
|
||||
#endif // _KERNEL_PLATFORM_ARM64_TASKING_SIGNAL_IMPL_H
|
||||
103
kernel/include/platform/arm64/tasking/trapframe.h
Normal file
103
kernel/include/platform/arm64/tasking/trapframe.h
Normal file
@@ -0,0 +1,103 @@
|
||||
#ifndef _KERNEL_PLATFORM_ARM64_TASKING_TRAPFRAME_H
|
||||
#define _KERNEL_PLATFORM_ARM64_TASKING_TRAPFRAME_H
|
||||
|
||||
#include <libkern/c_attrs.h>
|
||||
#include <libkern/log.h>
|
||||
#include <libkern/types.h>
|
||||
|
||||
typedef struct {
|
||||
uint64_t x[31];
|
||||
uint64_t esr;
|
||||
uint64_t elr;
|
||||
uint64_t far;
|
||||
uint64_t spsr;
|
||||
uint64_t sp;
|
||||
} PACKED trapframe_t;
|
||||
|
||||
static inline uintptr_t get_stack_pointer(trapframe_t* tf)
|
||||
{
|
||||
return tf->sp;
|
||||
}
|
||||
|
||||
static inline void set_stack_pointer(trapframe_t* tf, uintptr_t sp)
|
||||
{
|
||||
tf->sp = sp;
|
||||
}
|
||||
|
||||
static inline uintptr_t get_frame_pointer(trapframe_t* tf)
|
||||
{
|
||||
return tf->x[29];
|
||||
}
|
||||
|
||||
static inline void set_frame_pointer(trapframe_t* tf, uintptr_t bp)
|
||||
{
|
||||
tf->x[29] = bp;
|
||||
}
|
||||
|
||||
static inline uintptr_t get_instruction_pointer(trapframe_t* tf)
|
||||
{
|
||||
return tf->elr;
|
||||
}
|
||||
|
||||
static inline void set_instruction_pointer(trapframe_t* tf, uintptr_t ip)
|
||||
{
|
||||
tf->elr = ip;
|
||||
}
|
||||
|
||||
static inline uintptr_t get_syscall_result(trapframe_t* tf)
|
||||
{
|
||||
return tf->x[0];
|
||||
}
|
||||
|
||||
static inline void set_syscall_result(trapframe_t* tf, uintptr_t val)
|
||||
{
|
||||
tf->x[0] = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* STACK FUNCTIONS
|
||||
*/
|
||||
|
||||
static inline void tf_push_to_stack(trapframe_t* tf, uintptr_t val)
|
||||
{
|
||||
tf->sp -= sizeof(uintptr_t);
|
||||
*((uintptr_t*)tf->sp) = val;
|
||||
}
|
||||
|
||||
static inline uintptr_t tf_pop_to_stack(trapframe_t* tf)
|
||||
{
|
||||
uintptr_t val = *((uintptr_t*)tf->sp);
|
||||
tf->sp += sizeof(uintptr_t);
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline void tf_move_stack_pointer(trapframe_t* tf, int32_t val)
|
||||
{
|
||||
tf->sp += val;
|
||||
}
|
||||
|
||||
static inline void tf_setup_as_user_thread(trapframe_t* tf)
|
||||
{
|
||||
tf->spsr = 0x0;
|
||||
}
|
||||
|
||||
static inline void tf_setup_as_kernel_thread(trapframe_t* tf)
|
||||
{
|
||||
tf->spsr = 0x4;
|
||||
}
|
||||
|
||||
static void dump_tf(trapframe_t* tf)
|
||||
{
|
||||
for (int i = 0; i < 31; i++) {
|
||||
log("x[%d]: %zx", i, tf->x[i]);
|
||||
}
|
||||
|
||||
log("tf: %p", tf);
|
||||
log("sp: %zx", tf->sp);
|
||||
log("ip: %zx", tf->elr);
|
||||
log("fl: %zx", tf->spsr);
|
||||
log("far: %zx", tf->far);
|
||||
log("esr: %zx", tf->esr);
|
||||
}
|
||||
|
||||
#endif // _KERNEL_PLATFORM_ARM64_TASKING_TRAPFRAME_H
|
||||
Reference in New Issue
Block a user