Squash commits for public release

This commit is contained in:
2025-02-12 09:54:05 -05:00
commit 7118adc514
1108 changed files with 80873 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
#ifndef _KERNEL_PLATFORM_RISCV64_TASKING_CONTEXT_H
#define _KERNEL_PLATFORM_RISCV64_TASKING_CONTEXT_H
#include <libkern/c_attrs.h>
#include <libkern/types.h>
typedef struct {
uint64_t ra;
uint64_t sp;
uint64_t s[12];
} PACKED context_t;
static inline uintptr_t context_get_instruction_pointer(context_t* ctx)
{
return ctx->ra;
}
static inline void context_set_instruction_pointer(context_t* ctx, uintptr_t ip)
{
ctx->ra = ip;
}
#endif // _KERNEL_PLATFORM_RISCV64_TASKING_CONTEXT_H

View 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

View 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

View File

@@ -0,0 +1,126 @@
#ifndef _KERNEL_PLATFORM_RISCV64_TASKING_TRAPFRAME_H
#define _KERNEL_PLATFORM_RISCV64_TASKING_TRAPFRAME_H
#include <libkern/c_attrs.h>
#include <libkern/log.h>
#include <libkern/types.h>
typedef struct {
uint64_t ra;
uint64_t sp;
uint64_t gp;
uint64_t tp;
uint64_t t0;
uint64_t t1;
uint64_t t2;
uint64_t s0;
uint64_t s1;
uint64_t a0;
uint64_t a1;
uint64_t a2;
uint64_t a3;
uint64_t a4;
uint64_t a5;
uint64_t a6;
uint64_t a7;
uint64_t s2;
uint64_t s3;
uint64_t s4;
uint64_t s5;
uint64_t s6;
uint64_t s7;
uint64_t s8;
uint64_t s9;
uint64_t s10;
uint64_t s11;
uint64_t t3;
uint64_t t4;
uint64_t t5;
uint64_t t6;
uint64_t sstatus;
uint64_t epc;
} 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 0;
}
static inline void set_frame_pointer(trapframe_t* tf, uintptr_t bp)
{
}
static inline uintptr_t get_instruction_pointer(trapframe_t* tf)
{
return tf->epc;
}
static inline void set_instruction_pointer(trapframe_t* tf, uintptr_t ip)
{
tf->epc = ip;
}
static inline uintptr_t get_syscall_result(trapframe_t* tf)
{
return tf->a0;
}
static inline void set_syscall_result(trapframe_t* tf, uintptr_t val)
{
tf->a0 = 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;
}
#define SSTATUS_VM (1L << 18) // VM
#define SSTATUS_SPP (1L << 8) // Previous mode, 1=Supervisor, 0=User
#define SSTATUS_SPIE (1L << 5) // Supervisor Previous Interrupt Enable
#define SSTATUS_UPIE (1L << 4) // User Previous Interrupt Enable
#define SSTATUS_SIE (1L << 1) // Supervisor Interrupt Enable
#define SSTATUS_UIE (1L << 0) // User Interrupt Enable
static inline void tf_setup_as_user_thread(trapframe_t* tf)
{
tf->sstatus = SSTATUS_VM | SSTATUS_UPIE | SSTATUS_SPIE;
}
static inline void tf_setup_as_kernel_thread(trapframe_t* tf)
{
tf->sstatus = SSTATUS_VM | SSTATUS_SPP | SSTATUS_SPIE;
}
static void dump_tf(trapframe_t* tf)
{
}
#endif // _KERNEL_PLATFORM_RISCV64_TASKING_TRAPFRAME_H