diff options
Diffstat (limited to 'arch/x86_64/hal')
| -rw-r--r-- | arch/x86_64/hal/idt.c | 1 | ||||
| -rw-r--r-- | arch/x86_64/hal/obj.c | 6 | ||||
| -rw-r--r-- | arch/x86_64/hal/paging.c | 8 | ||||
| -rw-r--r-- | arch/x86_64/hal/process.c | 77 | ||||
| -rw-r--r-- | arch/x86_64/hal/process.h | 25 | ||||
| -rw-r--r-- | arch/x86_64/hal/smp.c | 15 | ||||
| -rw-r--r-- | arch/x86_64/hal/smp.h | 4 |
7 files changed, 15 insertions, 121 deletions
diff --git a/arch/x86_64/hal/idt.c b/arch/x86_64/hal/idt.c index 235d8c6..ff7a8a0 100644 --- a/arch/x86_64/hal/idt.c +++ b/arch/x86_64/hal/idt.c @@ -4,6 +4,7 @@ #include "jove.h" #include "lib/printf.h" #include "lib/string.h" +#include "panic/panic.h" ALIGN(8) static struct idt_entry s_idt[IDT_ENTRIES]; diff --git a/arch/x86_64/hal/obj.c b/arch/x86_64/hal/obj.c index 9844a54..103b53d 100644 --- a/arch/x86_64/hal/obj.c +++ b/arch/x86_64/hal/obj.c @@ -97,9 +97,6 @@ objdir_getlocal( jove_owned_obj_t *objdir_obj, uint16_t entry) { - while(obj_gettype(objdir_obj) == JOVE_OBJ_LINK) { - objdir_obj = link_deref(objdir_obj); - } if(obj_gettype(objdir_obj) != JOVE_OBJ_OBJDIR) { reterr(EBADOBJ); } @@ -116,9 +113,6 @@ objdir_trygetlocal( jove_owned_obj_t *objdir_obj, uint16_t entry) { - while(obj_gettype(objdir_obj) == JOVE_OBJ_LINK) { - objdir_obj = link_deref(objdir_obj); - } if(obj_gettype(objdir_obj) != JOVE_OBJ_OBJDIR) { reterr(EBADOBJ); } diff --git a/arch/x86_64/hal/paging.c b/arch/x86_64/hal/paging.c index 2fbf26c..770cdff 100644 --- a/arch/x86_64/hal/paging.c +++ b/arch/x86_64/hal/paging.c @@ -7,7 +7,7 @@ #include "hal/obj.h" #include "lib/string.h" #include "lib/printf.h" -#include "lib/panic.h" +#include "panic/panic.h" #include "idt.h" #include "api/syscall.h" @@ -69,11 +69,7 @@ s_int_handle_pf_early(struct int_stackframe *frame) uintptr_t cr2 = 0; __asm__ volatile("movq %%cr2, %0": "=r"(cr2)); - kprintf("Faulting address: %p\n", cr2); - kprintf("RIP: %p | RSP: %p\n", frame->int_rip, frame->int_rsp); - print_state(&frame->state); - - hcf(); + kpanic_istate(frame, "Faulting address: %p\n", cr2); } static page_t* diff --git a/arch/x86_64/hal/process.c b/arch/x86_64/hal/process.c deleted file mode 100644 index aa51f45..0000000 --- a/arch/x86_64/hal/process.c +++ /dev/null @@ -1,77 +0,0 @@ -#include "process.h" -#include "arch/x86_64/hal/obj.h" -#include "hal/obj.h" -#include "hal/process.h" -#include "hal/smp.h" -#include "lib/string.h" -#include "init.h" -#include "smp.h" -#include "paging.h" -#include "jove.h" - -PAGEALIGN uint8_t s_init_iopb[0x2000]; -PAGEALIGN char s_init_pcb_bytes[0x1000] = { 0 }; -static pcb_t *s_init_pcb = (pcb_t*)&s_init_pcb_bytes; - -jove_owned_obj_t* -process_current(void) -{ - return obj_take(((processor_t*)processor_current())->pcb_obj); -} - -pcb_t* -pcb_from_obj(jove_owned_obj_t *obj) -{ - if(obj_gettype(obj) != JOVE_OBJ_PCB) { - reterr(EBADOBJ); - } - return obj_deref(obj); -} - -pid_t -pcb_pid(pcb_t *pcb) -{ - return pcb->pid; -} - -jove_obj_t* -pcb_rootdir(pcb_t *pcb) -{ - return pcb->rootdir; -} - -void -processing_setup(void (*process_main)) -{ - memset(s_init_iopb, 0xFF, 0x2000); - uintptr_t ksp = ((uintptr_t)&s_init_pcb_bytes) + 0xFF8; - - s_init_pcb->pid = 1; - s_init_pcb->ksp = (void*)ksp; - s_init_pcb->pml4 = paging_get_pml4(); - s_init_pcb->rootdir = _rootdir_obj; - - jove_owned_obj_t *iopb_obj = objdir_getlocal(_rootdir_obj, ROOTDIR_IOPB_I); - obj_settype(iopb_obj, JOVE_OBJ_IOPB); - obj_setvalue(iopb_obj, (uintptr_t)s_init_iopb); - s_init_pcb->iopb = iopb_obj; - - processor_t *proc = processor_current(); - proc->tss.rsp[0] = (uintptr_t)s_init_pcb->ksp; - memcpy(proc->iopb, s_init_iopb, 0x2000); - - { - jove_owned_obj_t *process_obj = objdir_getlocal(_rootdir_obj, ROOTDIR_PCB_I); - obj_settype(process_obj, JOVE_OBJ_PCB); - obj_setvalue(process_obj, (uintptr_t)s_init_pcb); - - proc->pcb_obj = obj_release(process_obj); - proc->pcb = s_init_pcb; - } - - __asm__ volatile("\ - movq %0, %%rsp; \ - movq $0, %%rbp; \ - jmpq %1":: - "r"(s_init_pcb->ksp), "r"(process_main)); -} diff --git a/arch/x86_64/hal/process.h b/arch/x86_64/hal/process.h deleted file mode 100644 index f903153..0000000 --- a/arch/x86_64/hal/process.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _JOVE_x86_64_HAL_PROCESS_H -#define _JOVE_x86_64_HAL_PROCESS_H 1 - -#include "hal/process.h" -#include "arch/x86_64/x86_64.h" - -typedef struct process_control_block -{ - pid_t pid; - jove_obj_t *rootdir; - jove_owned_obj_t *iopb; - uintptr_t pml4; - - enum pcb_state state; - int killed; - struct pcb_mailbox send, recv; - - struct cpu_context context; - void *ksp; - char kstack[]; -} pcb_t; - -#define PCB_KSTACK_SIZE (0x1000 - sizeof(pcb_t)) - -#endif diff --git a/arch/x86_64/hal/smp.c b/arch/x86_64/hal/smp.c index f67ce0b..4c79d79 100644 --- a/arch/x86_64/hal/smp.c +++ b/arch/x86_64/hal/smp.c @@ -1,13 +1,13 @@ #include "smp.h" -#include "hal/process.h" #include "init.h" -#include "hal/obj.h" #include "config.h" #include "jove.h" -#include "lib/printf.h" -#include "lib/string.h" #include "paging.h" #include "msr.h" +#include "hal/obj.h" +#include "proc/process.h" +#include "lib/printf.h" +#include "lib/string.h" processor_t s_processors[SMP_PROCESSORS_MAX]; @@ -54,7 +54,7 @@ smp_init_bsp(void) obj_release(processor_objdir_obj); } - //idt_init(); + idt_init(); paging_pml4_init(); } @@ -62,3 +62,8 @@ processor_t *processor_current(void) { return (processor_t*)msr_get_gs_base(); } + +jove_owned_obj_t *processor_pcb(processor_t *processor) +{ + return processor->pcb_obj; +} diff --git a/arch/x86_64/hal/smp.h b/arch/x86_64/hal/smp.h index b208e92..b26d4ac 100644 --- a/arch/x86_64/hal/smp.h +++ b/arch/x86_64/hal/smp.h @@ -1,8 +1,8 @@ #ifndef _JOVE_x86_64_HAL_SMP_H #define _JOVE_x86_64_HAL_SMP_H 1 +#include "arch/x86_64/proc/process.h" #include "gdt.h" -#include "process.h" #include "hal/obj.h" #include "hal/smp.h" @@ -12,7 +12,7 @@ typedef struct processor struct tss tss; uint8_t iopb[0x2000]; - jove_obj_t *pcb_obj; + jove_owned_obj_t *pcb_obj; pcb_t *pcb; } processor_t; |
