doc(gdt): add comments in gdt header

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2021-07-14 18:53:11 +02:00
parent 5ada33613a
commit 60800e71fd

55
k/gdt.h

@ -11,22 +11,35 @@
struct gdt_entry
{
uint16_t limit_1 : 16;
uint16_t base_1 : 16;
uint8_t base_2 : 8;
uint8_t accessed : 1;
uint8_t rw : 1;
uint8_t dc : 1;
uint8_t ex : 1;
uint8_t desc_type : 1;
uint8_t desc_priv : 2;
uint8_t present : 1;
uint8_t limit_2 : 4;
uint8_t available : 1;
uint8_t l : 1;
uint8_t db : 1;
uint8_t granularity : 1;
uint8_t base_3 : 8;
uint16_t limit_1 : 16; // 16 lsbs of the segment limit
uint16_t base_1 : 16; // 16 lsbs of the segment base address
uint8_t base_2 : 8; // 8 next bits of the segment base address
/* Access Byte */
uint8_t accessed : 1; // set to 0, is set to 1 by CPU when segment is
// accessed
uint8_t rw : 1; // read/write bit, 1 to grant read acces on code
// segments or write access on data segments
uint8_t dc : 1; // Direction/Conforming bit
uint8_t ex : 1; // Executable bit
uint8_t desc_type : 1; // Descriptor type: 1 for data or code segmentm
// 0 for system segments (like TSS)
uint8_t desc_priv : 2; // Descriptor privilege
uint8_t present : 1; // Always set to 1
uint8_t limit_2 : 4; // 4 msbs of the segment limit
/* Flags */
uint8_t available : 1; // Available for use by system software
uint8_t l : 1; // 64-bit code segment
uint8_t db : 1; // size, 0 for 16 bits, 1 for 32 bits
uint8_t granularity : 1; // limit unit, 0 for bytes, 1 for 4KiB (1 page)
uint8_t base_3 : 8; // 8 msbs of the segment base
} __attribute__ ((packed));
struct gdt
@ -36,15 +49,15 @@ struct gdt
struct gdt_r
{
uint16_t limit;
uint32_t addr;
uint16_t limit; // total size of the GDT - 1 in bytes
uint32_t addr; // base address of the DGT
} __attribute__ ((packed));
struct segment_selector
{
uint8_t rpl : 2;
uint8_t table_indicator : 1;
uint16_t index : 13;
uint8_t rpl : 2; // request privilege level
uint8_t table_indicator : 1; // 0 for GDT, 1 for LDT
uint16_t index : 13; // index of the entry in the table
} __attribute__ ((packed));
void init_gdt();