Turnstone Operating System
|
cpu segment descriptors for long mode. More...
#include <types.h>
Classes | |
struct | descriptor_gdt_null |
null segment descriptor for gdt More... | |
struct | descriptor_gdt_code |
code segment descriptor for gdt More... | |
struct | descriptor_gdt_data |
data segment descriptor for gdt More... | |
struct | descriptor_gdt |
general segment descriptor for gdt More... | |
struct | descriptor_idt |
idt table descriptor More... | |
struct | descriptor_register |
common register value for gdtr, idtr, ldtr, tr More... | |
Macros | |
#define | ___CPU_DESCRIPTOR_H 0 |
#define | DPL_RING0 0 |
#define | DPL_RING1 1 |
#define | DPL_RING2 2 |
#define | DPL_RING3 3 |
#define | DPL_KERNEL DPL_RING0 |
#define | DPL_USER DPL_RING3 |
#define | KERNEL_CODE_SEG 0x08 |
#define | KERNEL_DATA_SEG 0x10 |
#define | KERNEL_TSS_SEG 0x18 |
#define | DESCRIPTOR_BUILD_GDT_NULL_SEG(seg) {seg.null.unused1 = 0; seg.null.unused2 = 0;} |
null segment builder macro More... | |
#define | DESCRIPTOR_BUILD_GDT_CODE_SEG(seg, DPL) |
code segment builder macro with privilage level More... | |
#define | DESCRIPTOR_BUILD_GDT_DATA_SEG(seg, DPL) |
data segment builder macro More... | |
#define | IDT_BASE_ADDRESS (1 << 20) |
#define | SYSTEM_SEGMENT_TYPE_IDT 0x02 |
#define | SYSTEM_SEGMENT_TYPE_TSS_A 0x09 |
#define | SYSTEM_SEGMENT_TYPE_TSS_B 0x0B |
#define | SYSTEM_SEGMENT_TYPE_GATE_CALL 0x0C |
#define | SYSTEM_SEGMENT_TYPE_GATE_INT 0x0E |
#define | SYSTEM_SEGMENT_TYPE_GATE_TRAP 0x0F |
#define | DESCRIPTOR_BUILD_IDT_SEG(IE, FUNC_ADDR, SELECTOR, IST, DPL) |
assign a function to interrupt nomber More... | |
Typedefs | |
typedef struct descriptor_gdt_null | descriptor_gdt_null_t |
struct short hand | |
typedef struct descriptor_gdt_code | descriptor_gdt_code_t |
struct short hand | |
typedef struct descriptor_gdt_data | descriptor_gdt_data_t |
struct short hand | |
typedef struct descriptor_gdt | descriptor_gdt_t |
struct short hand | |
typedef struct descriptor_idt | descriptor_idt_t |
struct short hand | |
typedef struct descriptor_register | descriptor_register_t |
struct short hand | |
Functions | |
_Static_assert (sizeof(descriptor_idt_t)==16, "descriptor_idt_t size must be 16") | |
uint8_t | descriptor_build_gdt_register (void) |
builds a default gdt More... | |
uint8_t | descriptor_build_idt_register (void) |
builds a default idt More... | |
uint8_t | descriptor_build_ap_descriptors_register (void) |
builds gdt and tss for application processor More... | |
Variables | |
descriptor_register_t * | GDT_REGISTER |
static address of gdt for lgdtr/sgdtr | |
descriptor_register_t * | IDT_REGISTER |
static address of idt for lidtr/sidtr | |
cpu segment descriptors for long mode.
This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.
#define ___CPU_DESCRIPTOR_H 0 |
prevent duplicate header error macro
#define DESCRIPTOR_BUILD_GDT_CODE_SEG | ( | seg, | |
DPL | |||
) |
code segment builder macro with privilage level
seg | segment to build as code |
DPL | privilage level to build as code |
#define DESCRIPTOR_BUILD_GDT_DATA_SEG | ( | seg, | |
DPL | |||
) |
data segment builder macro
seg | segment to build as data |
#define DESCRIPTOR_BUILD_GDT_NULL_SEG | ( | seg | ) | {seg.null.unused1 = 0; seg.null.unused2 = 0;} |
null segment builder macro
seg | segment to build as null |
#define DESCRIPTOR_BUILD_IDT_SEG | ( | IE, | |
FUNC_ADDR, | |||
SELECTOR, | |||
IST, | |||
DPL | |||
) |
assign a function to interrupt nomber
[in] | IE | interrupt vector |
[in] | FUNC_ADDR | interrupt vector's function address |
[in] | SELECTOR | gdt code selector for interrupt vector |
[in] | IST | ist number for vector, if ist is zero not ist mechanism, else use ist at tss |
[in] | DPL | privilage level of interrupt |
#define DPL_KERNEL DPL_RING0 |
a short hand for ring0 aka kernel space
#define DPL_RING0 0 |
cpu privilage level 0 for kernel space
#define DPL_RING1 1 |
cpu privilage level 1 for kernel additional space
#define DPL_RING2 2 |
cpu privilage level 2 for kernel additional space
#define DPL_RING3 3 |
cpu privilage level 3 for user space
#define DPL_USER DPL_RING3 |
a short hand for ring3 aka user space
#define KERNEL_CODE_SEG 0x08 |
hard coded gdt code segment value
#define KERNEL_DATA_SEG 0x10 |
hard coded gdt data segment value
#define KERNEL_TSS_SEG 0x18 |
hard coded gdt tss segment value
#define SYSTEM_SEGMENT_TYPE_GATE_CALL 0x0C |
Call Gate segment type
#define SYSTEM_SEGMENT_TYPE_GATE_INT 0x0E |
Interrupt Gate segment type
#define SYSTEM_SEGMENT_TYPE_GATE_TRAP 0x0F |
Trap Gate segment type
#define SYSTEM_SEGMENT_TYPE_IDT 0x02 |
IDT segment type
#define SYSTEM_SEGMENT_TYPE_TSS_A 0x09 |
Active TSS segment type
#define SYSTEM_SEGMENT_TYPE_TSS_B 0x0B |
Busy TSS segment type
uint8_t descriptor_build_ap_descriptors_register | ( | void | ) |
builds gdt and tss for application processor
uint8_t descriptor_build_gdt_register | ( | void | ) |
builds a default gdt
uint8_t descriptor_build_idt_register | ( | void | ) |
builds a default idt