Feat: kernel thread done
This commit is contained in:
53
kernel/include/thread.h
Normal file
53
kernel/include/thread.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <queue.h>
|
||||
|
||||
typedef int32_t (*thread_func_t)(uint64_t);
|
||||
|
||||
typedef enum: uint32_t {
|
||||
THREAD_STATUS_RUNABLE = 0,
|
||||
THREAD_STATUS_WAIT = 1,
|
||||
THREAD_STATUS_EXIT = 2,
|
||||
THREAD_STATUS_ZOMBIE = 3,
|
||||
} thread_status_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t x19, x20;
|
||||
uint64_t x21, x22;
|
||||
uint64_t x23, x24;
|
||||
uint64_t x25, x26;
|
||||
uint64_t x27, x28;
|
||||
uint64_t fp, lr;
|
||||
uint64_t sp;
|
||||
uint64_t sp_el0;
|
||||
uint64_t elr_el1;
|
||||
} cpu_state_t;
|
||||
|
||||
typedef struct {
|
||||
thread_func_t func;
|
||||
uint64_t param;
|
||||
|
||||
thread_status_t status;
|
||||
int32_t retcode;
|
||||
|
||||
void *stack_pointer;
|
||||
size_t stack_size;
|
||||
|
||||
cpu_state_t regs;
|
||||
} thread_t;
|
||||
|
||||
// thread.S
|
||||
void context_switch(void *from, void *to, thread_t *th);
|
||||
|
||||
// thread.c
|
||||
void thread_init(void);
|
||||
void run_thread(thread_func_t func, uint64_t param);
|
||||
void schedule(void);
|
||||
#define yield schedule
|
||||
|
||||
thread_t *get_current(void);
|
||||
|
||||
extern queue_t *global_run_queue;
|
||||
extern queue_t *global_wait_queue;
|
||||
extern queue_t *global_gc_queue;
|
||||
Reference in New Issue
Block a user