summaryrefslogtreecommitdiff
path: root/kernel/gdt.h
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-09 14:26:20 +0200
committerMiguel <m.i@gmx.at>2018-09-09 14:26:20 +0200
commit9a4b35fd5a32490f8f15b48f978e7b1fbfdceb2a (patch)
treeaf39516afa68237379c30bb67aad1136ccabb2f3 /kernel/gdt.h
parentc2ef64149849fcae608b1c6010303eca86229d22 (diff)
gdt cleanup, reorder info collection to start
Diffstat (limited to 'kernel/gdt.h')
-rw-r--r--kernel/gdt.h54
1 files changed, 13 insertions, 41 deletions
diff --git a/kernel/gdt.h b/kernel/gdt.h
index 314cc99..9b7eece 100644
--- a/kernel/gdt.h
+++ b/kernel/gdt.h
@@ -1,49 +1,21 @@
// https://xarnze.com/posts/post/Tutorial:%20Entering%20User%20mode
// http://wiki.osdev.org/TSS
// http://wiki.osdev.org/Global_Descriptor_Table
+// http://wiki.osdev.org/GDT_Tutorial
+//https://wiki.osdev.org/Task_State_Segment
#include <stdint.h>
-typedef volatile struct strtss{
- unsigned short link;
- unsigned short link_h;
- unsigned long esp0;
- unsigned short ss0;
- unsigned short ss0_h;
- unsigned long esp1;
- unsigned short ss1;
- unsigned short ss1_h;
- unsigned long esp2;
- unsigned short ss2;
- unsigned short ss2_h;
- unsigned long cr3;
- unsigned long eip;
- unsigned long eflags;
- unsigned long eax;
- unsigned long ecx;
- unsigned long edx;
- unsigned long ebx;
- unsigned long esp;
- unsigned long ebp;
- unsigned long esi;
- unsigned long edi;
- unsigned short es;
- unsigned short es_h;
- unsigned short cs;
- unsigned short cs_h;
- unsigned short ss;
- unsigned short ss_h;
- unsigned short ds;
- unsigned short ds_h;
- unsigned short fs;
- unsigned short fs_h;
- unsigned short gs;
- unsigned short gs_h;
- unsigned short ldt;
- unsigned short ldt_h;
- unsigned short trap;
- unsigned short iomap;
-}__attribute__((packed)) tss_struct;
-
+/** Call this one on each CPU to get a fresh 6-entries GDT
+ * * 0
+ * * ring0 code
+ * * ring0 data
+ * * ring3 code
+ * * ring3 data
+ * * tss
+ */
void gdt_init();
+
+/** update tss.esp0 for a given cpu
+ */
void install_tss(uint32_t cpu,uint32_t esp0);