KernOS
gdt.h
Go to the documentation of this file.
1 //
2 // Created on 5/20/20.
3 //
4 
5 #ifndef KERNOS_GDT_H
6 #define KERNOS_GDT_H
7 
10 namespace GDT
11 {
12  const uint8_t GDT_ENTRIES = 5;
13 
16  enum Segment : uint16_t
17  {
18  Null = 0,
19  K_CS,
20  K_DS,
21  U_CS,
22  U_DS,
23  };
24 
29  inline constexpr uint8_t SEG_OFFSET(const Segment Seg)
30  {
31  return (((Seg) << 3) & 0xFF); // each gdt entry is 8 bytes
32  }
33 }
34 
35 namespace INIT
36 {
37  void gdt();
38 }
39 
40 #endif //KERNOS_GDT_H
void gdt()
creates global descriptor table and loads it into CPU
Definition: gdt.cpp:172
user code segment
Definition: gdt.h:21
global descriptor table
Definition: gdt.h:10
null descriptor
Definition: gdt.h:18
user data segment
Definition: gdt.h:22
contains all kernel initialization routines
Definition: cpu.h:10
kernel data segment
Definition: gdt.h:20
const uint8_t GDT_ENTRIES
Definition: gdt.h:12
constexpr uint8_t SEG_OFFSET(const Segment Seg)
Translates code segment enum to code segment selector.
Definition: gdt.h:29
Segment
Code segments.
Definition: gdt.h:16
kernel code segment
Definition: gdt.h:19