Xyris
0.5
gdt.hpp
Go to the documentation of this file.
1
/**
2
* @file gdt.hpp
3
* @author Keeton Feavel (
[email protected]
)
4
* @brief The Global Descriptor Table (GDT) is specific to the IA32 architecture.
5
* It contains entries telling the CPU about memory segments.
6
* @version 0.3
7
* @date 2019-09-26
8
*
9
* @copyright Copyright Keeton Feavel (c) 2019
10
*
11
*/
12
#pragma once
13
#include <stdint.h>
14
#include <
Arch/i686/Arch.i686.hpp
>
15
16
namespace
GDT
{
17
18
union
Limit
{
19
struct
[[gnu::packed]]
LimitSections
20
{
21
uint16_t
low
: 16;
22
uint8_t
high
: 4;
23
}
section
;
24
uint32_t
value
;
25
};
26
27
union
Base
{
28
struct
[[gnu::packed]]
BaseSections
29
{
30
uint32_t
low
: 24;
31
uint8_t
high
: 8;
32
}
section
;
33
uint32_t
value
;
34
};
35
36
/**
37
* @brief GDT Code & Data Segment Selector Struct
38
* See https://wiki.osdev.org/Descriptors#Code.2FData_Segment_Descriptors for details
39
*
40
*/
41
struct
[[gnu::packed]]
Entry
{
42
// Limit
43
uint16_t
limit_low
: 16;
44
// Base
45
uint32_t
base_low
: 24;
46
// Access byte
47
uint8_t
accessed
: 1;
// Accessed indicator (default to 0)
48
uint8_t
rw
: 1;
// Readable (code segment) / writeable bit (data segment)
49
uint8_t
dc
: 1;
// Conforming (code segment) / direction (data segment)
50
uint8_t
executable
: 1;
// Code (1) or data (0)
51
uint8_t
system
: 1;
// Task segment (0) or code/data segment (1)
52
uint8_t
privilege
: 2;
// Privilege level (rings 0-3)
53
uint8_t
present
: 1;
// Indicates entry is available (default to 1)
54
// Limit
55
uint8_t
limit_high
: 4;
56
// Flags
57
uint8_t
reserved
: 1;
// Reserved (default to 0)
58
uint8_t
longMode
: 1;
// Indicates a long mode (64-bit) code segment if set
59
uint8_t
size
: 1;
// Indicates a 32-bit (if set) or 16-bit (if unset) protected mode segment
60
uint8_t
granulatity
: 1;
// Indicates page granularity if set (otherwise byte granularity)
61
// Base
62
uint8_t
base_high
: 8;
63
};
64
static_assert(
sizeof
(
struct
Entry
) == 8);
65
66
/**
67
* @brief Setup and install the GDT onto the system.
68
*
69
*/
70
void
init
();
71
72
}
// !namespace GDT
GDT::Entry::system
uint8_t system
Definition:
gdt.hpp:51
GDT::Entry::limit_low
uint16_t limit_low
Definition:
gdt.hpp:43
GDT::Base::BaseSections::low
uint32_t low
Definition:
gdt.hpp:30
GDT::Base::value
uint32_t value
Definition:
gdt.hpp:33
GDT::Entry::size
uint8_t size
Definition:
gdt.hpp:59
GDT::Limit::section
struct GDT::Limit::LimitSections section
GDT::Entry::base_low
uint32_t base_low
Definition:
gdt.hpp:45
GDT::Entry
GDT Code & Data Segment Selector Struct See https://wiki.osdev.org/Descriptors#Code....
Definition:
gdt.hpp:41
GDT::Limit::LimitSections::low
uint16_t low
Definition:
gdt.hpp:21
GDT
Definition:
gdt.cpp:17
GDT::Entry::limit_high
uint8_t limit_high
Definition:
gdt.hpp:55
GDT::Base::BaseSections
Definition:
gdt.hpp:28
GDT::Entry::reserved
uint8_t reserved
Definition:
gdt.hpp:57
Arch.i686.hpp
i686 architecture implementation of Arch.hpp
GDT::Base::BaseSections::high
uint8_t high
Definition:
gdt.hpp:31
GDT::Limit::LimitSections
Definition:
gdt.hpp:19
GDT::Entry::privilege
uint8_t privilege
Definition:
gdt.hpp:52
GDT::Entry::base_high
uint8_t base_high
Definition:
gdt.hpp:62
GDT::Limit::value
uint32_t value
Definition:
gdt.hpp:24
GDT::Base
Definition:
gdt.hpp:27
GDT::Entry::longMode
uint8_t longMode
Definition:
gdt.hpp:58
GDT::Entry::present
uint8_t present
Definition:
gdt.hpp:53
GDT::Entry::executable
uint8_t executable
Definition:
gdt.hpp:50
GDT::Limit
Definition:
gdt.hpp:18
GDT::Base::section
struct GDT::Base::BaseSections section
GDT::Entry::granulatity
uint8_t granulatity
Definition:
gdt.hpp:60
GDT::Entry::dc
uint8_t dc
Definition:
gdt.hpp:49
GDT::Entry::accessed
uint8_t accessed
Definition:
gdt.hpp:47
GDT::init
void init()
Setup and install the GDT onto the system.
Definition:
gdt.cpp:22
GDT::Entry::rw
uint8_t rw
Definition:
gdt.hpp:48
GDT::Limit::LimitSections::high
uint8_t high
Definition:
gdt.hpp:22
Kernel
Arch
i686
gdt.hpp
Generated by
1.8.17