summaryrefslogtreecommitdiff
path: root/kernel/cpu/gdt.h
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-11-28 20:11:05 +0100
committerAnton Kling <anton@kling.gg>2023-11-28 20:12:20 +0100
commitd07fa25e04a19ccb9aa25bb6e2156d23d213db77 (patch)
tree25f2e4a6301f3ad7c5b158e74966a394862fdf39 /kernel/cpu/gdt.h
parent636858dbbd48ed9f5073793b46740302aa202f43 (diff)
Meta: Apply new clang-format rules to kernel
Diffstat (limited to 'kernel/cpu/gdt.h')
-rw-r--r--kernel/cpu/gdt.h106
1 files changed, 52 insertions, 54 deletions
diff --git a/kernel/cpu/gdt.h b/kernel/cpu/gdt.h
index 7cb2dc9..de8ea09 100644
--- a/kernel/cpu/gdt.h
+++ b/kernel/cpu/gdt.h
@@ -1,7 +1,7 @@
#ifndef GDT_H
#define GDT_H
-#include <typedefs.h>
#include <string.h>
+#include <typedefs.h>
#define GDT_ENTRY_SIZE 0x8
#define GDT_NULL_SEGMENT 0x0
@@ -11,61 +11,59 @@
#define GDT_USERMODE_DATA_SEGMENT 0x4
#define GDT_TSS_SEGMENT 0x5
-struct GDT_Entry
-{
- u16 limit_low;
- u32 base_low : 24;
- u32 accessed : 1;
- u32 read_write : 1; // readable for code, writable for data
- u32 conforming_expand_down : 1; // conforming for code, expand down for data
- u32 code : 1; // 1 for code, 0 for data
- u32 code_data_segment : 1; // should be 1 for everything but TSS and LDT
- u32 DPL : 2; // privilege level
- u32 present : 1;
- u32 limit_high : 4;
- u32 available : 1; // only used in software; has no effect on hardware
- u32 long_mode : 1;
- u32 big : 1; // 32-bit opcodes for code, u32 stack for data
- u32 gran : 1; // 1 to use 4k page addressing, 0 for byte addressing
- u8 base_high;
-}__attribute__((packed));
+struct GDT_Entry {
+ u16 limit_low;
+ u32 base_low : 24;
+ u32 accessed : 1;
+ u32 read_write : 1; // readable for code, writable for data
+ u32 conforming_expand_down : 1; // conforming for code, expand down for data
+ u32 code : 1; // 1 for code, 0 for data
+ u32 code_data_segment : 1; // should be 1 for everything but TSS and LDT
+ u32 DPL : 2; // privilege level
+ u32 present : 1;
+ u32 limit_high : 4;
+ u32 available : 1; // only used in software; has no effect on hardware
+ u32 long_mode : 1;
+ u32 big : 1; // 32-bit opcodes for code, u32 stack for data
+ u32 gran : 1; // 1 to use 4k page addressing, 0 for byte addressing
+ u8 base_high;
+} __attribute__((packed));
-typedef struct GDT_Pointer
-{
- u16 size;
- u32 offset;
-}__attribute__((packed)) GDT_Pointer;
+typedef struct GDT_Pointer {
+ u16 size;
+ u32 offset;
+} __attribute__((packed)) GDT_Pointer;
-struct tss_entry_struct
-{
- u32 prev_tss; // The previous TSS - with hardware task switching these form a kind of backward linked list.
- u32 esp0; // The stack pointer to load when changing to kernel mode.
- u32 ss0; // The stack segment to load when changing to kernel mode.
- // Everything below here is unused.
- u32 esp1; // esp and ss 1 and 2 would be used when switching to rings 1 or 2.
- u32 ss1;
- u32 esp2;
- u32 ss2;
- u32 cr3;
- u32 eip;
- u32 eflags;
- u32 eax;
- u32 ecx;
- u32 edx;
- u32 ebx;
- u32 esp;
- u32 ebp;
- u32 esi;
- u32 edi;
- u32 es;
- u32 cs;
- u32 ss;
- u32 ds;
- u32 fs;
- u32 gs;
- u32 ldt;
- u16 trap;
- u16 iomap_base;
+struct tss_entry_struct {
+ u32 prev_tss; // The previous TSS - with hardware task switching these form a
+ // kind of backward linked list.
+ u32 esp0; // The stack pointer to load when changing to kernel mode.
+ u32 ss0; // The stack segment to load when changing to kernel mode.
+ // Everything below here is unused.
+ u32 esp1; // esp and ss 1 and 2 would be used when switching to rings 1 or 2.
+ u32 ss1;
+ u32 esp2;
+ u32 ss2;
+ u32 cr3;
+ u32 eip;
+ u32 eflags;
+ u32 eax;
+ u32 ecx;
+ u32 edx;
+ u32 ebx;
+ u32 esp;
+ u32 ebp;
+ u32 esi;
+ u32 edi;
+ u32 es;
+ u32 cs;
+ u32 ss;
+ u32 ds;
+ u32 fs;
+ u32 gs;
+ u32 ldt;
+ u16 trap;
+ u16 iomap_base;
} __attribute__((packed));
void gdt_init();