kernel/arch/thread: implement for riscv64
Change-Id: I3effa598626b32c29606299cd0edee390d430baf Reviewed-on: https://review.haiku-os.org/c/haiku/+/4066 Reviewed-by: Alex von Gluck IV <[email protected]>
This commit is contained in:
@@ -11,30 +11,24 @@
|
||||
|
||||
#include <arch/cpu.h>
|
||||
|
||||
#warning IMPLEMENT arch_thread.h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void riscv64_push_iframe(struct iframe_stack* stack, struct iframe* frame);
|
||||
void riscv64_pop_iframe(struct iframe_stack* stack);
|
||||
struct iframe* riscv64_get_user_iframe(void);
|
||||
|
||||
|
||||
static inline Thread*
|
||||
arch_thread_get_current_thread(void)
|
||||
{
|
||||
#warning IMPLEMENT arch_thread_get_current_thread
|
||||
Thread* t = NULL;
|
||||
return t;
|
||||
Thread* t;
|
||||
asm volatile("mv %0, tp" : "=r" (t));
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
arch_thread_set_current_thread(Thread* t)
|
||||
{
|
||||
#warning IMPLEMENT arch_thread_set_current_thread
|
||||
asm volatile("mv tp, %0" : : "r" (t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,20 +7,65 @@
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
#define IFRAME_TRACE_DEPTH 4
|
||||
|
||||
struct iframe_stack {
|
||||
struct iframe *frames[IFRAME_TRACE_DEPTH];
|
||||
int32 index;
|
||||
namespace BKernel {
|
||||
struct Thread;
|
||||
}
|
||||
|
||||
|
||||
struct iframe {
|
||||
uint64 ra;
|
||||
uint64 t6;
|
||||
uint64 sp;
|
||||
uint64 gp;
|
||||
uint64 tp;
|
||||
uint64 t0;
|
||||
uint64 t1;
|
||||
uint64 t2;
|
||||
uint64 t5;
|
||||
uint64 s1;
|
||||
uint64 a0;
|
||||
uint64 a1;
|
||||
uint64 a2;
|
||||
uint64 a3;
|
||||
uint64 a4;
|
||||
uint64 a5;
|
||||
uint64 a6;
|
||||
uint64 a7;
|
||||
uint64 s2;
|
||||
uint64 s3;
|
||||
uint64 s4;
|
||||
uint64 s5;
|
||||
uint64 s6;
|
||||
uint64 s7;
|
||||
uint64 s8;
|
||||
uint64 s9;
|
||||
uint64 s10;
|
||||
uint64 s11;
|
||||
uint64 t3;
|
||||
uint64 t4;
|
||||
uint64 fp;
|
||||
uint64 epc;
|
||||
};
|
||||
|
||||
// architecture specific thread info
|
||||
struct arch_thread {
|
||||
void *sp; // stack pointer
|
||||
void *interrupt_stack;
|
||||
struct arch_context {
|
||||
uint64 ra; // 0
|
||||
uint64 s[12]; // 12
|
||||
uint64 sp; // 13
|
||||
uint64 satp; // 14
|
||||
};
|
||||
|
||||
// used to track interrupts on this thread
|
||||
struct iframe_stack iframes;
|
||||
struct fpu_context {
|
||||
double f[32];
|
||||
uint64 fcsr;
|
||||
};
|
||||
|
||||
|
||||
struct arch_thread {
|
||||
BKernel::Thread* thread;
|
||||
arch_context context;
|
||||
fpu_context fpuContext;
|
||||
iframe* userFrame;
|
||||
};
|
||||
|
||||
struct arch_team {
|
||||
@@ -31,10 +76,25 @@ struct arch_team {
|
||||
};
|
||||
|
||||
struct arch_fork_arg {
|
||||
// gcc treats empty structures as zero-length in C, but as if they contain
|
||||
// a char in C++. So we have to put a dummy in to be able to use the struct
|
||||
// from both in a consistent way.
|
||||
char dummy;
|
||||
iframe frame;
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int arch_setjmp(arch_context* ctx);
|
||||
void arch_longjmp(arch_context* ctx, int val);
|
||||
void save_fpu(fpu_context* ctx);
|
||||
void restore_fpu(fpu_context* ctx);
|
||||
void arch_thread_entry();
|
||||
void arch_enter_userspace(void *arg1, void *arg2, addr_t sp);
|
||||
void arch_longjmp_iframe(iframe* frame);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* KERNEL_ARCH_RISCV64_THREAD_TYPES_H */
|
||||
|
||||
Reference in New Issue
Block a user