diff --git a/kinclude/boot.S b/kinclude/boot.S index 68fda22..ecae623 100644 --- a/kinclude/boot.S +++ b/kinclude/boot.S @@ -5,20 +5,8 @@ stack_bottom: .space 4096 stack_top: - .section .text._start - -// Set up all the CSR mstatus_offsets -// .set mstatus, 0x300 // machine status -// .set mscratch, 0x340 -// .set mtvec, 0x305 // machine trap handler -// .set mcause, 0x342 // machine trap cause -// .set mtval, 0x343 // machine bad address or instruction -// .set misa, 0x301 // machine ISA -// .set mie, 0x304 // machine interrupt enable -// .set mip, 0x344 // machine interrupt pending - .extern init .type init, @function diff --git a/kinclude/sched.c b/kinclude/sched.c index 8410d96..a236fe3 100644 --- a/kinclude/sched.c +++ b/kinclude/sched.c @@ -128,12 +128,12 @@ int scheduler_index_from_pid(int pid) return -1; } -int scheduler_create_process(int binid) +int* get_current_process_registers() { - return 0; + return processes[current_process_index].regs; } -int* get_current_process_registers() +ProcessControlBlock* get_current_process() { - return processes[current_process_index].regs; -} \ No newline at end of file + return &processes[current_process_index]; +} diff --git a/kinclude/sched.h b/kinclude/sched.h index 264a3b7..5cf7b1e 100644 --- a/kinclude/sched.h +++ b/kinclude/sched.h @@ -3,12 +3,12 @@ #include "../kernel.h" -// process statuses: -#define PROC_DEAD 0 -#define PROC_RDY 1 -#define PROC_WAIT_LOCK 2 -#define PROC_WAIT_PROC 3 -#define PROC_WAIT_SLEEP 4 +enum process_status { + PROC_DEAD = 0, + PROC_RDY = 1, + PROC_WAIT_PROC = 2, + PROC_WAIT_SLEEP = 3, +} // process structure: typedef struct ProcessControlBlock ProcessControlBlock; @@ -17,8 +17,7 @@ struct ProcessControlBlock { int pc; int regs[31]; // scheduling information - int status; - int requested_lock; + enum process_status status; ProcessControlBlock *waiting_for_process; unsigned long long int asleep_until; }; @@ -33,5 +32,6 @@ void __attribute__((noreturn)) scheduler_run_next(); void __attribute__((noreturn)) scheduler_switch_to(int proc_index); int scheduler_index_from_pid(int pid); int* get_current_process_registers(); +ProcessControlBlock* get_current_process(); #endif \ No newline at end of file