aboutsummaryrefslogtreecommitdiff
path: root/arch/i386/gdt.c
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2024-03-08 17:24:49 +0200
committeraqua <aqua@iserlohn-fortress.net>2024-03-08 22:00:07 +0200
commit20b97ea7c0dbbdc13800e12ff5c86c00c4a342ec (patch)
tree473281e5fc8b256827ce1a678573444e1aa5f669 /arch/i386/gdt.c
parentGenerate src/conf.h (diff)
downloadkernel-20b97ea7c0dbbdc13800e12ff5c86c00c4a342ec.tar.xz
Bazel build
Diffstat (limited to 'arch/i386/gdt.c')
-rw-r--r--arch/i386/gdt.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/i386/gdt.c b/arch/i386/gdt.c
new file mode 100644
index 0000000..3148096
--- /dev/null
+++ b/arch/i386/gdt.c
@@ -0,0 +1,20 @@
+#include "gdt.h"
+
+void
+SegmentDescriptor(struct SegmentDescriptor_t *self, unsigned base, unsigned limit, uint8_t access)
+{
+ self->base_15_0 = base & 0xffff;
+ self->base_23_16 = (uint8_t)(base >> 16);
+ self->base_31_24 = (uint8_t)(base >> 24);
+
+ self->limit_15_0 = (limit <= 0xffff) ? (limit & 0xffff) : ((limit >> 12) & 0xffff);
+ self->limit_19_16 = 0xfu & (uint8_t)((limit <= 0xffff) ? 0 : (limit >> 28));
+
+ self->access = access;
+
+ self->a = 0;
+ self->rsv = 0;
+ self->db = (limit > 0xffff) ? 1 : 0;
+ self->granularity = (limit > 0) ? 1 : 0;
+}
+