From 8c0a1da9a81b6ef1c3b4edad09ffb99272cfbda1 Mon Sep 17 00:00:00 2001 From: Chloe M Date: Fri, 10 Jul 2026 21:10:30 -0400 Subject: [PATCH] ptos/amd64: Add global descriptor table defs Signed-off-by: Chloe M --- service/ptos/head/arch/amd64/gdt.h | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 service/ptos/head/arch/amd64/gdt.h diff --git a/service/ptos/head/arch/amd64/gdt.h b/service/ptos/head/arch/amd64/gdt.h new file mode 100644 index 0000000..325c505 --- /dev/null +++ b/service/ptos/head/arch/amd64/gdt.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2026, Chloe M. + * Provided under the BSD-3 clause. + * + * Description: Global descriptor table + * Author: Chloe M. + */ + +#ifndef _MACHINE_GDT_H_ +#define _MACHINE_GDT_H_ 1 + +#include + +/* Number of GDT entries */ +#define GDT_ENTRY_COUNT 7 + +/* 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 + +/* + * Global descriptor table entry + */ +typedef struct PACKED { + USHORT Limit; + USHORT BaseLow; + UCHAR BaseMid; + USHORT Attributes; + UCHAR BaseHigh; +} GDT_ENTRY; + +#endif /* !_MACHINE_GDT_H_ */