MyOS Kernel
|
Data Fields | |
uint16_t | limit_low16 |
Low 16 bits of the limit. | |
uint16_t | base_low16 |
Low 16 bits of the base. | |
uint8_t | base_mid8 |
Middle 8 bits of the base. | |
uint8_t | access |
uint8_t | limit_flags |
uint8_t | base_high8 |
High 8 bits of the base. | |
Represents an entry in the GDT.
uint8_t gdt_entry::access |
Access byte. Gives info about the descriptor.
Format:
Bit 7: Present. Must be 1 for all valid selectors.
Bits 6-5. Privilege. Contains the ring level for the selector. 0 for kernel mode, 3 for user mode.
Bit 4. Descriptor type. Must be set for code/data segments and cleared for system segments like the TSS.
Bit 3. Executable. If this bit is set, it is a code selector, otherwise a data selector.
Bit 2. Direction/Conforming. Too complex to explain, should be set to 0.
Bit 1. Readable/Writable. For code sels, this bit sets whther you can use it like a read-only data segment. For data sels, it sets whether the selector is writable.
Bit 0. Acessed bit. Set to 0.
uint8_t gdt_entry::limit_flags |
High nibble of this contains two flags, and the lower niblle contains the high 4 bits of the limit.
The flags are:
Bit 3. Granularity. 0 for byte granularity, 1 for 4 KB granularity.
Bit 2. Size. 0 for 16 bit protected mode, 1 for 32 bit protected mode.
Bits 1-0. Unused. Set to 0.