summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2025-09-26 13:17:41 -0400
committerJon Santmyer <jon@jonsantmyer.com>2025-09-26 13:17:41 -0400
commit2dadbfc899df4179ca70c4ea04f74a5e190c2ae7 (patch)
treeb166aaa9af42406cd07fbaf150f93aefeb2fbe33 /include
parentddc4fbc15223e362896a9f42beca73f05f48e664 (diff)
downloadjove-kernel-2dadbfc899df4179ca70c4ea04f74a5e190c2ae7.tar.gz
jove-kernel-2dadbfc899df4179ca70c4ea04f74a5e190c2ae7.tar.bz2
jove-kernel-2dadbfc899df4179ca70c4ea04f74a5e190c2ae7.zip
fix usermode interrupts. add ability to define custom interrupt handlersmain
Diffstat (limited to 'include')
-rw-r--r--include/api/init.h15
-rw-r--r--include/arch/x86_64/idt.h22
-rw-r--r--include/arch/x86_64/processor.h5
-rw-r--r--include/init.h14
4 files changed, 43 insertions, 13 deletions
diff --git a/include/api/init.h b/include/api/init.h
new file mode 100644
index 0000000..e17d8fd
--- /dev/null
+++ b/include/api/init.h
@@ -0,0 +1,15 @@
+#ifndef _JOVE_API_INIT_H
+#define _JOVE_API_INIT_H 1
+
+enum {
+ INIT_OBJECT_ROOTDIR = 0,
+ INIT_OBJECT_TCB,
+ INIT_OBJECT_PAGEMAP,
+ INIT_OBJECT_PROCESSOR_DIR,
+ INIT_OBJECT_UNTYPED_DIR,
+ INIT_OBJECT_INITRD_DIR,
+ INIT_OBJECT_MESSAGE,
+ INIT_OBJECT_LOG
+};
+
+#endif
diff --git a/include/arch/x86_64/idt.h b/include/arch/x86_64/idt.h
index 4ca820f..fe544cb 100644
--- a/include/arch/x86_64/idt.h
+++ b/include/arch/x86_64/idt.h
@@ -11,6 +11,28 @@ typedef struct jove_IVTState
uint64_t rip, cs, rflags, rsp, ss;
} ivt_state_t;
+enum
+{
+ EXCEPTION_DIVISION = 0,
+ EXCEPTION_DEBUG,
+ EXCEPTION_NMI,
+ EXCEPTION_BREAKPOINT,
+ EXCEPTION_OVERFLOW,
+ EXCEPTION_BRE,
+ EXCEPTION_INVLOP,
+ EXCEPTION_DEVNA,
+ EXCEPTION_DOUBLE,
+ EXCEPTION_CSO,
+ EXCEPTION_INVALID_TSS,
+ EXCEPTION_SEG_MISSING,
+ EXCEPTION_SS,
+ EXCEPTION_GPF,
+ EXCEPTION_PF
+};
+
+typedef void (*kernel_isr_handler_t)(ivt_state_t*);
+extern kernel_isr_handler_t kernel_isr_handles[256];
+
void kpanic_state(ivt_state_t *state, const char *fmt, ...);
void ivt_setup(void);
diff --git a/include/arch/x86_64/processor.h b/include/arch/x86_64/processor.h
index 7363c41..5e878b9 100644
--- a/include/arch/x86_64/processor.h
+++ b/include/arch/x86_64/processor.h
@@ -51,6 +51,7 @@ enum
#define GDT_OFFSET_KERNEL_CODE (GDT_ENTRY_KERNEL_CODE * sizeof(segment_descriptor_t))
#define GDT_OFFSET_KERNEL_DATA (GDT_ENTRY_KERNEL_DATA * sizeof(segment_descriptor_t))
+#define GDT_OFFSET_USER_NULL (GDT_ENTRY_USER_NULL * sizeof(segment_descriptor_t))
#define GDT_OFFSET_USER_DATA (GDT_ENTRY_USER_DATA * sizeof(segment_descriptor_t))
#define GDT_OFFSET_USER_CODE (GDT_ENTRY_USER_CODE * sizeof(segment_descriptor_t))
#define GDT_OFFSET_TSS (GDT_ENTRY_TSS_LOW * sizeof(segment_descriptor_t))
@@ -60,7 +61,9 @@ typedef struct jove_Processor
physptr_t pdir;
struct jove_ObjectDirectory *odir;
+ __attribute__((aligned(0x10)))
segment_descriptor_t gdt[GDT_ENTRY_COUNT];
+
struct {
uint16_t length;
uint64_t base;
@@ -70,7 +73,9 @@ typedef struct jove_Processor
uint64_t base;
} __attribute__((packed)) idtr;
+ __attribute__((aligned(0x10)))
tss_t tss;
+
tcb_t *tcb;
} processor_t;
diff --git a/include/init.h b/include/init.h
index 2821926..f21afa6 100644
--- a/include/init.h
+++ b/include/init.h
@@ -1,20 +1,8 @@
#ifndef _JOVE_INIT_H
#define _JOVE_INIT_H 1
-#include <stdint.h>
-
-enum {
- INIT_OBJECT_ROOTDIR = 0,
- INIT_OBJECT_TCB,
- INIT_OBJECT_PAGEMAP,
- INIT_OBJECT_PROCESSOR_DIR,
- INIT_OBJECT_UNTYPED_DIR,
- INIT_OBJECT_INITRD_DIR,
- INIT_OBJECT_MESSAGE,
- INIT_OBJECT_LOG
-};
-
#include "object.h"
+#include "api/init.h"
extern objdir_t _initDirectory;
void init_load(void);