diff options
Diffstat (limited to '')
-rw-r--r-- | kernel/main.c | 13 | ||||
-rw-r--r-- | kernel/procs.c | 3 | ||||
-rw-r--r-- | kernel/syscall.c | 3 | ||||
-rw-r--r-- | kernel/user.c | 4 |
4 files changed, 16 insertions, 7 deletions
diff --git a/kernel/main.c b/kernel/main.c index 4047a64..c15c38d 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -7,6 +7,7 @@ #include <comus/drivers/pci.h> #include <comus/drivers/gpu.h> #include <comus/drivers/ata.h> +#include <comus/user.h> #include <comus/fs.h> #include <comus/procs.h> #include <lib.h> @@ -21,7 +22,7 @@ void kreport(void) gpu_report(); } -void main(long magic, volatile void *mboot) +__attribute__((noreturn)) void main(long magic, volatile void *mboot) { // initalize idt and pic cpu_init(); @@ -47,6 +48,12 @@ void main(long magic, volatile void *mboot) // report system state kreport(); - // halt - kprintf("halting...\n"); + // load init process + pcb_alloc(&init_pcb); + if (user_load(init_pcb, &fs_disks[0])) + panic("failed to load init"); + + // schedule and dispatch init + schedule(init_pcb); + dispatch(); } diff --git a/kernel/procs.c b/kernel/procs.c index 340739d..c1bcc4f 100644 --- a/kernel/procs.c +++ b/kernel/procs.c @@ -35,7 +35,7 @@ struct pcb *init_pcb = NULL; struct pcb ptable[N_PROCS]; /// next avaliable pid -pid_t next_pid = 0; +pid_t next_pid = 1; static struct pcb *find_prev_wakeup(pcb_queue_t queue, struct pcb *pcb) { @@ -119,6 +119,7 @@ int pcb_alloc(struct pcb **pcb) if (pcb_queue_pop(pcb_freelist, &tmp) != SUCCESS) return E_NO_PCBS; + tmp->pid = next_pid++; *pcb = tmp; return SUCCESS; } diff --git a/kernel/syscall.c b/kernel/syscall.c index 7944f46..12db401 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -91,7 +91,4 @@ void syscall_handler(struct cpu_regs *regs) // save return value current_pcb->regs->rax = ret; - - // switch back to process ctx - mem_ctx_switch(current_pcb->memctx); } diff --git a/kernel/user.c b/kernel/user.c index 592b35b..3c686a0 100644 --- a/kernel/user.c +++ b/kernel/user.c @@ -98,6 +98,10 @@ static int user_setup_stack(struct pcb *pcb) int user_load(struct pcb *pcb, struct disk *disk) { + // check inputs + if (pcb == NULL || disk == NULL) + return 1; + pcb->regs = NULL; // allocate memory context |