summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-12-23 01:50:31 -0500
committerIan Moffett <ian@osmora.org>2025-12-23 01:50:31 -0500
commit3b134c245f6fc8aebe77ae3c252629e6a67b6c89 (patch)
treefa25442507cdb1da8e214a0a726b79cbf39fc88c
parente2ba0980ebcc37431c3893a1d1967a637bf72916 (diff)
mos/x86_64: Add GDT headerHEADmaster
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--mos/sys/inc/arch/x86_64/gdt.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/mos/sys/inc/arch/x86_64/gdt.h b/mos/sys/inc/arch/x86_64/gdt.h
new file mode 100644
index 0000000..35081b3
--- /dev/null
+++ b/mos/sys/inc/arch/x86_64/gdt.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025, Ian Moffett.
+ * Provided under the BSD-3 clause.
+ */
+
+#ifndef _MACHINE_GDT_H_
+#define _MACHINE_GDT_H_ 1
+
+#ifndef __ASSEMBLER__
+#include <sdk/types.h>
+#include <sdk/defs.h>
+#endif /* __ASSEMBLER__ */
+
+/* Kernel code/data */
+#define GDT_KCODE 0x08
+#define GDT_KDATA 0x10
+
+/* User code/data */
+#define GDT_UCODE 0x18
+#define GDT_UDATA 0x20
+
+/* Task state segment */
+#define GDT_TSS 0x28
+#define GDT_TSS_INDEX 0x05
+
+#ifndef __ASSEMBLER__
+typedef struct {
+ USHORT limit;
+ USHORT base_low;
+ UBYTE base_mid;
+ UBYTE access;
+ UBYTE granularity;
+ UBYTE base_hi;
+} PACKED GDT_ENTRY;
+
+typedef struct {
+ USHORT limit;
+ UPTR offset;
+} PACKED GDTR;
+
+#endif /* !__ASSEMBLER__ */
+#endif /* !_MACHINE_GDT_H_ */