aboutsummaryrefslogtreecommitdiff
path: root/kernel/inc
diff options
context:
space:
mode:
authorMarvin Borner2021-04-29 14:36:40 +0200
committerMarvin Borner2021-04-29 14:36:40 +0200
commitf8e47b6b0c0578c52d82c0e243620361b87a4abe (patch)
treee42d898d299b7aa10c8f266d347b4fda5a5967f3 /kernel/inc
parent04104fc051d44f4f9b3328f29b4be91fa4060f34 (diff)
Multiboot/Grub progress
Diffstat (limited to 'kernel/inc')
-rw-r--r--kernel/inc/cpu.h2
-rw-r--r--kernel/inc/gdt.h60
-rw-r--r--kernel/inc/mm.h3
-rw-r--r--kernel/inc/multiboot.h9
-rw-r--r--kernel/inc/proc.h5
5 files changed, 69 insertions, 10 deletions
diff --git a/kernel/inc/cpu.h b/kernel/inc/cpu.h
index 3d29e4f..7ac6074 100644
--- a/kernel/inc/cpu.h
+++ b/kernel/inc/cpu.h
@@ -32,8 +32,6 @@ void cr3_set(u32 cr3);
u32 cr4_get(void);
void cr4_set(u32 cr4);
-void tss_set_stack(u32 ss, u32 esp);
-
void clac(void);
void stac(void);
diff --git a/kernel/inc/gdt.h b/kernel/inc/gdt.h
new file mode 100644
index 0000000..06388a9
--- /dev/null
+++ b/kernel/inc/gdt.h
@@ -0,0 +1,60 @@
+// MIT License, Copyright (c) 2021 Marvin Borner
+
+#ifndef GDT_H
+#define GDT_H
+
+#include <def.h>
+
+#define GDT_SUPER_CODE_OFFSET 0x08 // Super (kernel) code segment offset in GDT
+#define GDT_SUPER_DATA_OFFSET 0x10 // Super (kernel) data segment offset in GDT
+#define GDT_USER_CODE_OFFSET 0x1b // User code segment offset in GDT (with ring3 mask)
+#define GDT_USER_DATA_OFFSET 0x23 // User data segment offset in GDT (with ring3 mask)
+
+struct gdt_entry {
+ u16 limit_low;
+ u16 base_low;
+ u8 base_middle;
+ u8 access;
+ u8 granularity;
+ u8 base_high;
+} PACKED;
+
+struct gdt_ptr {
+ u16 limit;
+ void *base;
+} PACKED;
+
+struct tss_entry {
+ u32 prev_tss;
+ u32 esp0;
+ u32 ss0;
+ u32 esp1;
+ u32 ss1;
+ u32 esp2;
+ u32 ss2;
+ u32 cr3;
+ u32 eip;
+ u32 eflags;
+ u32 eax;
+ u32 ecx;
+ u32 edx;
+ u32 ebx;
+ u32 esp;
+ u32 ebp;
+ u32 esi;
+ u32 edi;
+ u32 es;
+ u32 cs;
+ u32 ss;
+ u32 ds;
+ u32 fs;
+ u32 gs;
+ u32 ldt;
+ u16 trap;
+ u16 iomap_base;
+} PACKED;
+
+void gdt_install(void);
+void tss_set_stack(u32 ss, u32 esp);
+
+#endif
diff --git a/kernel/inc/mm.h b/kernel/inc/mm.h
index 1652695..a33d9d1 100644
--- a/kernel/inc/mm.h
+++ b/kernel/inc/mm.h
@@ -27,6 +27,9 @@ void page_fault_handler(struct regs *r) NONNULL;
struct memory_range physical_alloc(u32 size);
void physical_free(struct memory_range range);
+void physical_set_used(struct memory_range range);
+void physical_set_free(struct memory_range range);
+void physical_set_total(u32 total);
/**
* Virtual
diff --git a/kernel/inc/multiboot.h b/kernel/inc/multiboot.h
index f9851fb..839ade7 100644
--- a/kernel/inc/multiboot.h
+++ b/kernel/inc/multiboot.h
@@ -104,9 +104,11 @@ struct multiboot_info {
};
struct multiboot_mmap_entry {
- u32 size;
- u64 addr;
- u64 len;
+ u32 struct_size;
+ u32 addr;
+ u32 addr_high;
+ u32 len;
+ u32 len_high;
u32 type;
} PACKED;
@@ -119,6 +121,7 @@ struct multiboot_mod_list {
u32 pad;
};
+void multiboot_mmap(void);
void multiboot_init(u32 magic, u32 addr);
#endif
diff --git a/kernel/inc/proc.h b/kernel/inc/proc.h
index 877e53e..e74286c 100644
--- a/kernel/inc/proc.h
+++ b/kernel/inc/proc.h
@@ -15,11 +15,6 @@
#define EFLAGS_ALWAYS 0x2 // Always one
#define EFLAGS_INTERRUPTS 0x200 // Enable interrupts
-#define GDT_SUPER_CODE_OFFSET 0x08 // Super (kernel) code segment offset in GDT
-#define GDT_SUPER_DATA_OFFSET 0x10 // Super (kernel) data segment offset in GDT
-#define GDT_USER_CODE_OFFSET 0x1b // User code segment offset in GDT (with ring3 mask)
-#define GDT_USER_DATA_OFFSET 0x23 // User data segment offset in GDT (with ring3 mask)
-
#define RING(regs) ((regs->cs) & 3)
enum proc_priv { PROC_PRIV_NONE, PROC_PRIV_ROOT, PROC_PRIV_KERNEL };