IgrOS-Kernel 0.1.34.545
Simple C++20 Kernel for i386/x86_64
Loading...
Searching...
No Matches
igros::i386::gdt Class Referencefinal

GDT structure. More...

#include <arch/i386/gdt.hpp>

Classes

struct  entry_t
 GDT table entry. More...
struct  pointer_t
 GDT table pointer. More...

Public Types

using table_t = std::array<gdt::entry_t, gdt::GDT_SIZE>
 GDT table.

Public Member Functions

 gdt (const gdt &other)=delete
 Copy c-tor.
auto operator= (const gdt &other) -> gdt &=delete
 Copy assignment.
 gdt (gdt &&other)=delete
 Move c-tor.
auto operator= (gdt &&other) -> gdt &=delete
 Move assignment.
 gdt () noexcept=default
 Default c-tor.
 ~gdt () noexcept=default
 D-tor.

Static Public Member Functions

static constexpr auto tssEntry (const igros_dword_t base, const igros_dword_t limit) noexcept -> entry_t
 Available 32-bit TSS descriptor (base is known at run time only).
static constexpr auto setEntry (const igros_dword_t base, const igros_dword_t limit, const klib::kFlags< FLAGS > flags) noexcept -> entry_t
 Set GDT entry.
static constexpr auto calcSize (const table_t &table) noexcept -> igros_word_t
 Calc GDT size.
static void setPointer (const pointer_t &pointer) noexcept
 Set GDT pointer.
static void init () noexcept
 Init GDT table.

Static Public Attributes

static constexpr auto KERNEL_CODE {igros_word_t {0x08}}
 Kernel code segment.
static constexpr auto KERNEL_DATA {igros_word_t {0x10}}
 Kernel data segment.
static constexpr auto TSS {igros_word_t {0x28}}
 Kernel task.
static constexpr auto TSS_DOUBLE_FAULT {igros_word_t {0x30}}
 Double fault task.

Private Types

enum class  FLAGS : igros_word_t {
  EMPTY = 0x0000_u16 , TYPE_ACCESS = 0x0001_u16 , TYPE_RODATA = 0x0000_u16 , TYPE_DATA = 0x0002_u16 ,
  TYPE_ROSTACK = 0x0004_u16 , TYPE_STACK = 0x0006_u16 , TYPE_EXCODE = 0x0008_u16 , TYPE_CODE = 0x000A_u16 ,
  TYPE_EXCONF = 0x000C_u16 , TYPE_CONF = 0x000E_u16 , RING0 = 0x0010_u16 , RING1 = 0x0030_u16 ,
  RING2 = 0x0050_u16 , RING3 = 0x0070_u16 , RING_USE = 0x0080_u16 , L = 0x0200_u16 ,
  SZ = 0x0400_u16 , G = 0x0800_u16
}
 GDT entry flags: access byte (bits 0..7) and flags nibble (bits 8..11). More...

Static Private Attributes

static constexpr auto GDT_ENTRY_EMPTY {klib::kFlags<FLAGS> {}}
 Empty GDT entry (the first one).
static constexpr auto GDT_ENTRY_CODE_RING0 {klib::make_kflags<FLAGS>(FLAGS::G, FLAGS::SZ, FLAGS::RING_USE, FLAGS::RING0, FLAGS::TYPE_CODE)}
 Kernel code segment (ring 0, code).
static constexpr auto GDT_ENTRY_DATA_RING0 {klib::make_kflags<FLAGS>(FLAGS::G, FLAGS::SZ, FLAGS::RING_USE, FLAGS::RING0, FLAGS::TYPE_DATA)}
 Kernel data segment (ring 0, data).
static constexpr auto GDT_ENTRY_CODE_RING3 {klib::make_kflags<FLAGS>(FLAGS::G, FLAGS::SZ, FLAGS::RING_USE, FLAGS::RING3, FLAGS::TYPE_CODE)}
 User code segment (ring 3, code).
static constexpr auto GDT_ENTRY_DATA_RING3 {klib::make_kflags<FLAGS>(FLAGS::G, FLAGS::SZ, FLAGS::RING_USE, FLAGS::RING3, FLAGS::TYPE_DATA)}
 User data segment (ring 3, data).
static constexpr auto GDT_SIZE {7_usize}
 Number of GDT entries.

Detailed Description

GDT structure.

Definition at line 29 of file gdt.hpp.

Member Typedef Documentation

◆ table_t

GDT table.

Definition at line 104 of file gdt.hpp.

Member Enumeration Documentation

◆ FLAGS

enum class igros::i386::gdt::FLAGS : igros_word_t
strongprivate

GDT entry flags: access byte (bits 0..7) and flags nibble (bits 8..11).

Enumerator
EMPTY 

No flags (null descriptor).

TYPE_ACCESS 

Segment accessed.

TYPE_RODATA 

Read-only data.

TYPE_DATA 

Read/write data.

TYPE_ROSTACK 

Read-only expand-down data.

TYPE_STACK 

Read/write expand-down data.

TYPE_EXCODE 

Execute-only code.

TYPE_CODE 

Execute/read code.

TYPE_EXCONF 

Execute-only conforming code.

TYPE_CONF 

Execute/read conforming code.

RING0 

Code/data segment, privilege level 0.

RING1 

Code/data segment, privilege level 1.

RING2 

Code/data segment, privilege level 2.

RING3 

Code/data segment, privilege level 3.

RING_USE 

Segment present.

L 

64-bit code segment

SZ 

32-bit segment

G 

Limit in 4 KB units.

Definition at line 32 of file gdt.hpp.

Member Function Documentation

◆ calcSize()

auto igros::i386::gdt::calcSize ( const table_t & table) ->igros_word_t
staticnodiscardconstexprnoexcept

Calc GDT size.

Calculate GDT size.

Parameters
tableGDT
Returns
GDT size in bytes - 1 (GDT pointer limit)

Definition at line 178 of file gdt.hpp.

◆ init()

void igros::i386::gdt::init ( )
staticnoexcept

Init GDT table.

Definition at line 60 of file gdt.cpp.

◆ setEntry()

auto igros::i386::gdt::setEntry ( const igros_dword_t base,
const igros_dword_t limit,
const klib::kFlags< FLAGS > flags )->entry_t
staticnodiscardconstexprnoexcept

Set GDT entry.

Parameters
baseSegment base
limitSegment limit (20 bits used)
flagsAccess byte and flags
Returns
GDT entry

Definition at line 148 of file gdt.hpp.

◆ setPointer()

void igros::i386::gdt::setPointer ( const pointer_t & pointer)
staticnoexcept

Set GDT pointer.

Parameters
pointerGDT pointer to load

Definition at line 53 of file gdt.cpp.

◆ tssEntry()

auto igros::i386::gdt::tssEntry ( const igros_dword_t base,
const igros_dword_t limit )->entry_t
staticnodiscardconstexprnoexcept

Available 32-bit TSS descriptor (base is known at run time only).

Available 32-bit TSS descriptor.

Parameters
baseTSS address
limitTSS size - 1
Returns
GDT entry

Definition at line 163 of file gdt.hpp.

Member Data Documentation

◆ GDT_ENTRY_CODE_RING0

auto igros::i386::gdt::GDT_ENTRY_CODE_RING0 {klib::make_kflags<FLAGS>(FLAGS::G, FLAGS::SZ, FLAGS::RING_USE, FLAGS::RING0, FLAGS::TYPE_CODE)}
staticconstexprprivate

Kernel code segment (ring 0, code).

Definition at line 57 of file gdt.hpp.

◆ GDT_ENTRY_CODE_RING3

auto igros::i386::gdt::GDT_ENTRY_CODE_RING3 {klib::make_kflags<FLAGS>(FLAGS::G, FLAGS::SZ, FLAGS::RING_USE, FLAGS::RING3, FLAGS::TYPE_CODE)}
staticconstexprprivate

User code segment (ring 3, code).

Definition at line 61 of file gdt.hpp.

◆ GDT_ENTRY_DATA_RING0

auto igros::i386::gdt::GDT_ENTRY_DATA_RING0 {klib::make_kflags<FLAGS>(FLAGS::G, FLAGS::SZ, FLAGS::RING_USE, FLAGS::RING0, FLAGS::TYPE_DATA)}
staticconstexprprivate

Kernel data segment (ring 0, data).

Definition at line 59 of file gdt.hpp.

◆ GDT_ENTRY_DATA_RING3

auto igros::i386::gdt::GDT_ENTRY_DATA_RING3 {klib::make_kflags<FLAGS>(FLAGS::G, FLAGS::SZ, FLAGS::RING_USE, FLAGS::RING3, FLAGS::TYPE_DATA)}
staticconstexprprivate

User data segment (ring 3, data).

Definition at line 63 of file gdt.hpp.

◆ GDT_ENTRY_EMPTY

auto igros::i386::gdt::GDT_ENTRY_EMPTY {klib::kFlags<FLAGS> {}}
staticconstexprprivate

Empty GDT entry (the first one).

Definition at line 55 of file gdt.hpp.

◆ GDT_SIZE

auto igros::i386::gdt::GDT_SIZE {7_usize}
staticconstexprprivate

Number of GDT entries.

Definition at line 66 of file gdt.hpp.

◆ KERNEL_CODE

auto igros::i386::gdt::KERNEL_CODE {igros_word_t {0x08}}
staticconstexpr

Kernel code segment.

Definition at line 107 of file gdt.hpp.

◆ KERNEL_DATA

auto igros::i386::gdt::KERNEL_DATA {igros_word_t {0x10}}
staticconstexpr

Kernel data segment.

Definition at line 108 of file gdt.hpp.

◆ TSS

auto igros::i386::gdt::TSS {igros_word_t {0x28}}
staticconstexpr

Kernel task.

Definition at line 109 of file gdt.hpp.

◆ TSS_DOUBLE_FAULT

auto igros::i386::gdt::TSS_DOUBLE_FAULT {igros_word_t {0x30}}
staticconstexpr

Double fault task.

Definition at line 110 of file gdt.hpp.


The documentation for this class was generated from the following files: