[Krafton Jungle] PintOS 2.0.0
크래프톤 정글 PintOS
 
Loading...
Searching...
No Matches
gdt.h File Reference
#include "threads/loader.h"
Include dependency graph for gdt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void gdt_init (void)
 

Function Documentation

◆ gdt_init()

void gdt_init ( void  )
83 {
84 /* Initialize GDT. */
85 struct segment_descriptor64 *tss_desc =
86 (struct segment_descriptor64 *) &gdt[SEL_TSS >> 3];
87 struct task_state *tss = tss_get ();
88
89 *tss_desc = (struct segment_descriptor64) {
90 .lim_15_0 = (uint64_t) (sizeof (struct task_state)) & 0xffff,
91 .base_15_0 = (uint64_t) (tss) & 0xffff,
92 .base_23_16 = ((uint64_t) (tss) >> 16) & 0xff,
93 .type = 0x9,
94 .s = 0,
95 .dpl = 0,
96 .p = 1,
97 .lim_19_16 = ((uint64_t)(sizeof (struct task_state)) >> 16) & 0xf,
98 .avl = 0,
99 .rsv1 = 0,
100 .g = 0,
101 .base_31_24 = ((uint64_t)(tss) >> 24) & 0xff,
102 .base_63_32 = ((uint64_t)(tss) >> 32) & 0xffffffff,
103 .res1 = 0,
104 .clear = 0,
105 .res2 = 0
106 };
107
108 lgdt (&gdt_ds);
109 /* reload segment registers */
110 asm volatile("movw %%ax, %%gs" :: "a" (SEL_UDSEG));
111 asm volatile("movw %%ax, %%fs" :: "a" (0));
112 asm volatile("movw %%ax, %%es" :: "a" (SEL_KDSEG));
113 asm volatile("movw %%ax, %%ds" :: "a" (SEL_KDSEG));
114 asm volatile("movw %%ax, %%ss" :: "a" (SEL_KDSEG));
115 asm volatile("pushq %%rbx\n"
116 "movabs $1f, %%rax\n"
117 "pushq %%rax\n"
118 "lretq\n"
119 "1:\n" :: "b" (SEL_KCSEG):"cc","memory");
120 /* Kill the local descriptor table */
121 lldt (0);
122}
static struct segment_desc gdt[SEL_CNT]
Definition: gdt.c:64
struct desc_ptr gdt_ds
Definition: gdt.c:75
#define SEL_KDSEG
Definition: loader.h:37
#define SEL_KCSEG
Definition: loader.h:36
#define SEL_UDSEG
Definition: loader.h:38
#define SEL_TSS
Definition: loader.h:40
unsigned long long int uint64_t
Definition: stdint.h:29
Definition: gdt.c:40
uint32_t base_63_32
Definition: gdt.c:53
unsigned base_23_16
Definition: gdt.c:43
unsigned base_15_0
Definition: gdt.c:42
unsigned lim_15_0
Definition: gdt.c:41
Definition: tss.h:7
struct task_state * tss
Definition: tss.c:49
struct task_state * tss_get(void)
Definition: tss.c:63
Here is the call graph for this function:
Here is the caller graph for this function: