aboutsummaryrefslogtreecommitdiff
path: root/arch/i686/lgdt.c
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-10-29 11:26:44 +0300
committeraqua <aqua@iserlohn-fortress.net>2022-10-29 11:26:44 +0300
commitc4fcc92183c55db868d0d6ae53e6009fb2e53ee5 (patch)
treead5ef50aa07465e11f779c4482e20e6071182e9c /arch/i686/lgdt.c
parentmakefile: add libk target (diff)
downloadkernel-c4fcc92183c55db868d0d6ae53e6009fb2e53ee5.tar.xz
makefile: add i686/arch.a target
Diffstat (limited to 'arch/i686/lgdt.c')
-rw-r--r--arch/i686/lgdt.c35
1 files changed, 0 insertions, 35 deletions
diff --git a/arch/i686/lgdt.c b/arch/i686/lgdt.c
deleted file mode 100644
index 2be5d30..0000000
--- a/arch/i686/lgdt.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <gdt.h>
-
-struct __attribute__((packed)) Pointer {
- uint16_t limit;
- uint32_t base;
-};
-
-static struct SegmentDescriptor_t segments[8] __attribute__((aligned(32)));
-
-void
-gdt_install()
-{
- SegmentDescriptor(&segments[0], 0, 0, 0); // null segment
- SegmentDescriptor(&segments[2], 0, 0xffffffff, 0x9a); // ktext
- SegmentDescriptor(&segments[3], 0, 0xffffffff, 0x92); // kdata
-
- const struct Pointer ptr = {.limit = sizeof(segments) - 1, .base = (unsigned)&segments};
- asm volatile("lgdt (%0)" : : "a"(&ptr));
-
- // load the kernel data segment
- asm volatile(R"(mov %0, %%ds
- mov %0, %%es
- mov %0, %%fs
- mov %0, %%gs
- mov %0, %%ss
-)"
- :
- : "ax"(kdataDescriptor));
-
- // load the kernel code segment
- asm volatile(R"(ljmp %0, $1f
- 1:)"
- :
- : "i"(ktextDescriptor));
-}