From 3b134c245f6fc8aebe77ae3c252629e6a67b6c89 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 23 Dec 2025 01:50:31 -0500 Subject: mos/x86_64: Add GDT header Signed-off-by: Ian Moffett --- mos/sys/inc/arch/x86_64/gdt.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 mos/sys/inc/arch/x86_64/gdt.h 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 +#include +#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_ */ -- cgit v1.2.3