BarryServer : Git

All the code for all my projects
// BarryServer : Git / Orion / commit / d41a53cbc7d055b1c00cf0a339dbed6925f4f02c / proc / load.S

// Related

Orion

Barry Importing existing Orion kernel d41a53c (2 years, 4 months ago)
diff --git a/proc/load.S b/proc/load.S
new file mode 100644
index 0000000..98330a0
--- /dev/null
+++ b/proc/load.S
@@ -0,0 +1,38 @@
+; This file is responsible for loading the tables onto the CPU.  The functions
+; will load the GDT, IDT and TSS onto the CPU running the function.  They only
+; provide a wrapper for the relevant x86 instruction, and do not do any table
+; creation.  See the relevant C files for the table setup routines.  The GDT and
+; IDT require a pointer to the table, while the TSS can be loaded from the
+; currently loaded GDT.
+
+[bits 32]
+
+; Load the IDT
+[global load_idt]
+load_idt:
+	mov eax, [esp + 4]
+	lidt [eax]
+	ret
+
+; Load the GDT
+[global load_gdt]
+load_gdt:
+	mov eax, [esp + 4]
+	lgdt [eax]
+
+	mov ax, 0x10
+	mov ds, ax
+	mov es, ax
+	mov fs, ax
+	mov gs, ax
+	mov ss, ax
+	jmp 0x08:.flush
+.flush:
+	ret
+
+; Load the TSS
+[global load_tss]
+load_tss:
+	mov ax, 0x28 | 3
+	ltr ax
+	ret