diff options
author | Zachary Yedidia <zyedidia@gmail.com> | 2022-05-16 14:42:25 -0700 |
---|---|---|
committer | Zachary Yedidia <zyedidia@gmail.com> | 2022-05-16 14:42:25 -0700 |
commit | f746a5d6fc1b1ec0044d1bd86d1ed2020837e9ec (patch) | |
tree | 62a726cc41b64a6acb5d97178e7b6d860e5f1533 | |
parent | e346361750940c6b4ae258c6acba5fa59cf4092b (diff) |
Minor
-rw-r--r-- | kern/kern.c | 9 | ||||
-rw-r--r-- | kern/proc.c | 11 |
2 files changed, 15 insertions, 5 deletions
diff --git a/kern/kern.c b/kern/kern.c index ed98e97..255dc59 100644 --- a/kern/kern.c +++ b/kern/kern.c @@ -13,6 +13,9 @@ #include "vm.h" #include "libc/rand.h" +/* #define PIDOS */ +/* #define HELLOOS */ + void reboot() { printf("DONE!!!\n"); uart_tx_flush(); @@ -59,6 +62,12 @@ void kernel_start() { proc_new(&_binary_pidos_bin_start, &_binary_pidos_bin_end); enable_interrupts(); // TODO: Set this in the SPSR proc_run(p_pidos_1); +#elif defined(HELLOOS) + extern uint8_t _binary_hello_bin_start; + extern uint8_t _binary_hello_bin_end; + proc_t *p_hello = + proc_new(&_binary_hello_bin_start, &_binary_hello_bin_end); + proc_run(p_hello); #else extern uint8_t _binary_basic_bin_start; extern uint8_t _binary_basic_bin_end; diff --git a/kern/proc.c b/kern/proc.c index 3275a58..cf519de 100644 --- a/kern/proc.c +++ b/kern/proc.c @@ -1,3 +1,4 @@ +#include "bits.h" #include "proc.h" #include "kern.h" #include "kmalloc.h" @@ -46,24 +47,24 @@ void __attribute__((noreturn)) proc_run(proc_t *proc) { // NOTE: To use SPSR, need to be sure we are *NOT* in user/system mode. // TODO(masot): add an assert like that - set_spsr((get_cpsr() & ~0b11111) | 0b10000); + set_spsr(bits_set(get_cpsr(), 0, 4, 0b10000)); asm volatile("ldm %0, {r0-r15}^" : : "r"(proc)); while (1) { } } void swippityswap(regs_t *live_state, proc_t *new_thread, proc_t *old_thread) { - memcpy(&(old_thread->regs), live_state, sizeof(regs_t)); - memcpy(live_state, &(new_thread->regs), sizeof(regs_t)); + memcpy(&old_thread->regs, live_state, sizeof(regs_t)); + memcpy(live_state, &new_thread->regs, sizeof(regs_t)); } void proc_scheduler_irq(regs_t *regs) { pid_t curr_pid = curproc->id, next_pid = (curr_pid + 1) % id; - swippityswap(regs, &(procs[next_pid]), &(procs[curr_pid])); + swippityswap(regs, &procs[next_pid], &procs[curr_pid]); curproc->state = PROC_RUNNABLE; - curproc = &(procs[next_pid]); + curproc = &procs[next_pid]; curproc->state = PROC_RUNNING; vm_set_pt(curproc->pt); } |