diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-15 10:03:20 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-15 10:03:20 -0400 |
| commit | a783cc865f1f261c20f6ef55cb37d4839f519865 (patch) | |
| tree | eabd6992f3be7c0f4d778a9fba2bfe7173ed6c8c /arch/x86_64/hal | |
| parent | 1f4260648f02db1b4fe8c60fe36f936125042880 (diff) | |
| download | jove-kernel-a783cc865f1f261c20f6ef55cb37d4839f519865.tar.gz jove-kernel-a783cc865f1f261c20f6ef55cb37d4839f519865.tar.bz2 jove-kernel-a783cc865f1f261c20f6ef55cb37d4839f519865.zip | |
move constants to api. centralize interrupts. fix rootdir lock hang
Diffstat (limited to 'arch/x86_64/hal')
| -rw-r--r-- | arch/x86_64/hal/idt.c | 20 | ||||
| -rw-r--r-- | arch/x86_64/hal/idt.h | 7 | ||||
| -rw-r--r-- | arch/x86_64/hal/idt_entries.s | 9 | ||||
| -rw-r--r-- | arch/x86_64/hal/obj.c | 1 | ||||
| -rw-r--r-- | arch/x86_64/hal/obj.h | 36 | ||||
| -rw-r--r-- | arch/x86_64/hal/paging.c | 4 | ||||
| -rw-r--r-- | arch/x86_64/hal/process.c | 4 |
7 files changed, 33 insertions, 48 deletions
diff --git a/arch/x86_64/hal/idt.c b/arch/x86_64/hal/idt.c index b2251bd..235d8c6 100644 --- a/arch/x86_64/hal/idt.c +++ b/arch/x86_64/hal/idt.c @@ -3,6 +3,7 @@ #include "gdt.h" #include "jove.h" #include "lib/printf.h" +#include "lib/string.h" ALIGN(8) static struct idt_entry s_idt[IDT_ENTRIES]; @@ -11,7 +12,9 @@ typedef void (*isr_t)(void); extern isr_t __isrs[IDT_ENTRIES]; typedef struct int_stackframe *(*int_handler_t)(struct int_stackframe*); -int_handler_t __int_handles[IDT_ENTRIES]; +int_handler_t __int_kernel_handles[IDT_ENTRIES]; + +struct int_user_handle __int_user_handles[IDT_ENTRIES]; static struct int_stackframe* s_int_handle_stub(struct int_stackframe* frame) @@ -20,9 +23,22 @@ s_int_handle_stub(struct int_stackframe* frame) hcf(); } +struct int_stackframe* +__int_handle_body(struct int_stackframe *frame) +{ + frame = __int_kernel_handles[frame->int_num](frame); + + struct int_user_handle *usr_handle = &__int_user_handles[frame->int_num]; + if(usr_handle->pid == 0) return frame; + + kprintf("TODO: Handle user interrupt switching\n"); + return frame; +} + void idt_init(void) { + memset(__int_user_handles, 0, sizeof(struct int_user_handle) * IDT_ENTRIES); for(size_t i = 0; i < IDT_ENTRIES; i++) { uintptr_t isr = (uintptr_t)(__isrs[i]); @@ -37,7 +53,7 @@ idt_init(void) .offset_32_63 = (uint32_t)(isr >> 32) }; - __int_handles[i] = s_int_handle_stub; + __int_kernel_handles[i] = s_int_handle_stub; } } diff --git a/arch/x86_64/hal/idt.h b/arch/x86_64/hal/idt.h index 961e720..2aa759b 100644 --- a/arch/x86_64/hal/idt.h +++ b/arch/x86_64/hal/idt.h @@ -63,4 +63,11 @@ struct int_stackframe #define IDT_EXCEPT_VE 20 #define IDT_EXCEPT_CP 21 +struct int_user_handle +{ + uintmax_t pid; + void *handle; +}; +extern struct int_user_handle __int_user_handles[IDT_ENTRIES]; + #endif diff --git a/arch/x86_64/hal/idt_entries.s b/arch/x86_64/hal/idt_entries.s index 204fa93..0bed23d 100644 --- a/arch/x86_64/hal/idt_entries.s +++ b/arch/x86_64/hal/idt_entries.s @@ -42,18 +42,15 @@ 1: .endm -.extern __int_handles +.extern __int_handle_body .type __isr_header @function __isr_header: push_state cld movq %rsp, %rdi - -isr_break: - movq 0x78(%rdi), %rax - movq __int_handles(,%rax,8), %rbx - call %rbx + call __int_handle_body + movq %rax, %rsp pop_state addq $16, %rsp diff --git a/arch/x86_64/hal/obj.c b/arch/x86_64/hal/obj.c index b8924a6..af0491a 100644 --- a/arch/x86_64/hal/obj.c +++ b/arch/x86_64/hal/obj.c @@ -1,5 +1,6 @@ #include "obj.h" #include "arch/x86_64/lock.h" +#include "lib/printf.h" #include "paging.h" #include "hal/obj.h" #include "jove.h" diff --git a/arch/x86_64/hal/obj.h b/arch/x86_64/hal/obj.h index 8955a55..deea2be 100644 --- a/arch/x86_64/hal/obj.h +++ b/arch/x86_64/hal/obj.h @@ -36,40 +36,4 @@ typedef struct jove_locked_obj #define JOVE_OBJDIR_SIZE 0x1000 #define JOVE_OBJDIR_ENTRIES (JOVE_OBJDIR_SIZE / sizeof(jove_obj_t)) -typedef struct jove_objdir -{ - jove_obj_t entries[JOVE_OBJDIR_ENTRIES]; -} jove_objdir_t; -/*Locks the mutex of the kernel object provided. Returns the locked version. */ -jove_owned_obj_t *obj_take(jove_obj_t *obj); -/*Unlocks the mutex of the kernel object provided. Returns the unlocked version. */ -jove_obj_t *obj_release(jove_owned_obj_t *obj); - -/*Converts the value pointer of the object into a pointer to kernel memory.*/ -void *obj_deref(jove_owned_obj_t *obj); - -/*Getters and setters for accessing the type field of the kernel object. */ -uint8_t obj_gettype(jove_owned_obj_t *obj); -uint8_t obj_peektype(jove_obj_t obj); -void obj_settype(jove_owned_obj_t *obj, uint8_t type); - -/*Getters and setters for accessing the value field of the kernel object. */ -uintmax_t obj_getvalue(jove_owned_obj_t *obj); -void obj_setvalue(jove_owned_obj_t *obj, uintmax_t value); - -/*Returns the n'th entry of the object directory passed. - * If the passed object is not an objdir, returns NULL and sets errno to EBADOBJ. - * If the passed entry index is out of bounds, returns NULL and sets errno to EOOB.*/ -jove_owned_obj_t *objdir_getlocal(jove_owned_obj_t *objdir_obj, uint16_t entry); -jove_obj_t objdir_peeklocal(jove_owned_obj_t *objdir_obj, uint16_t entry); - -/*Recursively seeks through an object directory for an object following the passed - * path variable. - * If the path length is zero, returns the passed object. - * If the passed object is not an objdir, returns NULL and sets errno to EBADOBJ. - * If any object excluding the object at the end of the path is not an objdir, - * returns NULL and sets errno to EBADOBJ. - * If any entry in the path is out of bounds, returns NULL and sets errno to EBADOBJ.*/ -jove_owned_obj_t *objdir_getobj(jove_owned_obj_t *objdir_obj, const uint16_t *path, size_t path_len); - #endif diff --git a/arch/x86_64/hal/paging.c b/arch/x86_64/hal/paging.c index 507dfce..7b45005 100644 --- a/arch/x86_64/hal/paging.c +++ b/arch/x86_64/hal/paging.c @@ -251,6 +251,6 @@ paging_pml4_init(void) /*Before tasking, if the kernel has a bug and crashes we need some * information about what happened.*/ - extern struct int_stackframe *(*__int_handles[])(struct int_stackframe*); - __int_handles[IDT_EXCEPT_PF] = s_int_handle_pf_early; + extern struct int_stackframe *(*__int_kernel_handles[])(struct int_stackframe*); + __int_kernel_handles[IDT_EXCEPT_PF] = s_int_handle_pf_early; } diff --git a/arch/x86_64/hal/process.c b/arch/x86_64/hal/process.c index c766a28..0155919 100644 --- a/arch/x86_64/hal/process.c +++ b/arch/x86_64/hal/process.c @@ -49,15 +49,15 @@ processing_setup(void (*process_main)) s_init_pcb->pid = 1; s_init_pcb->ksp = (void*)ksp; s_init_pcb->pml4 = paging_get_pml4(); - s_init_pcb->rootdir = obj_take(_rootdir_obj); + 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); { |
