MentOS
0.8.0
The Mentoring Operating System
|
Is used to define the characteristics of the various memory areas used during program execution, including the base address, the size and access privileges like executability and writability. More...
Classes | |
struct | gdt_descriptor_t |
Data structure representing a GDT descriptor. More... | |
struct | gdt_pointer_t |
Data structure used to load the GDT into the GDTR. More... | |
Macros | |
#define | IDT_PADDING 14U |
Used in IDT for padding. | |
Typedefs | |
typedef struct gdt_descriptor_t | _syscall0 = _syscall0( (packed) )= _syscall1( (packed) )= _syscall2( (packed) )= _syscall3( (packed) )= gdt_descriptor_t |
Data structure representing a GDT descriptor. More... | |
Enumerations | |
enum | gdt_bits_t { GDT_PRESENT = 128U , GDT_KERNEL = 0U , GDT_USER = 96U , GDT_S = 16U , GDT_EX = 8U , GDT_DC = 4U , GDT_RW = 2U , GDT_AC = 1U , GDT_CODE = (GDT_S | GDT_EX) , GDT_DATA = (GDT_S | GDT_RW) , GDT_GRANULARITY = 128U , GDT_OPERAND_SIZE = 64U } |
Bitmasks used to access to specific bits of the GDT. More... | |
Functions | |
void | init_gdt (void) |
Initialise the GDT. More... | |
void | gdt_set_gate (uint8_t index, uint32_t base, uint32_t limit, uint8_t access, uint8_t granul) |
Sets the value of one GDT entry. More... | |
Is used to define the characteristics of the various memory areas used during program execution, including the base address, the size and access privileges like executability and writability.
typedef struct page_directory_t _syscall0 = _syscall0( (packed) )= _syscall1( (packed) )= _syscall2( (packed) )= _syscall3( (packed) )= gdt_descriptor_t |
Data structure representing a GDT descriptor.
A page directory.
A pointer structure used for informing the CPU about our IDT.
Data structure used to load the GDT into the GDTR.
In the two-level paging, this is the first level.
enum gdt_bits_t |
Bitmasks used to access to specific bits of the GDT.
Contains the ring level, specifically:
00 (0)
= highest (kernel),11 (3)
= lowest (user applications).This bit should be set for code or data segments and should be cleared for system segments (eg. a Task State Segment).
Direction bit for data selectors: Tells the direction. 0 the segment grows up. 1 the segment grows down, ie., the offset has to be greater than the limit.
Conforming bit for code selectors:
Just set to 0. The CPU sets this to 1 when the segment is accessed.
You can have both 16 bit and 32 bit selectors at once.
Sets the value of one GDT entry.
index | The index inside the GDT. |
base | Memory address where the segment we are defining starts. |
limit | The memory address which determines the end of the segnment. |
access | Type (4bit) - S (1) bit -DPL (2 bit) - P(1 bit). |
granul | SegLimit_hi(4 bit) AVL(1 bit) L(1 bit) D/B(1 bit) G(1bit). |
void init_gdt | ( | void | ) |
Initialise the GDT.
This will setup the special GDT pointer, set up the first 3 entries in our GDT, and then finally call gdt_flush() in our assembler file in order to tell the processor where the new GDT is and update the new segment registers.