Go to the source code of this file.
Data Structures |
struct | __attribute__ |
Defines |
#define | GDT_CORE_CODE_SEGMENT 1 |
#define | GDT_CORE_DATA_SEGMENT 2 |
#define | GDT_TSS_SEGMENT 3 |
#define | GDT_PARTITION_CODE_SEGMENT(partition_id) (4 + 2 * partition_id) |
#define | GDT_PARTITION_DATA_SEGMENT(partition_id) (4 + 2 * partition_id + 1) |
#define | GDT_BUILD_SELECTOR(seg, local, rpl) ((seg << 3) | ((local & 0x1) << 2) | (rpl & 0x3)) |
Typedefs |
typedef enum e_gdte_type | e_gdte_type |
Enumerations |
enum | e_gdte_type { GDTE_CODE = 0xB,
GDTE_DATA = 0x3,
GDTE_TSS = 0x9
} |
Functions |
pok_ret_t | pok_gdt_init () |
int | pok_tss_init () |
void | tss_set_esp0 (uint32_t esp0) |
void | gdt_set_segment (uint16_t index, uint32_t base_address, uint32_t limit, e_gdte_type t, int dpl) |
void | gdt_set_system (uint16_t index, uint32_t base_address, uint32_t limit, e_gdte_type t, int dpl) |
void | gdt_enable (uint16_t index) |
void | gdt_disable (uint16_t index) |
Define Documentation
#define GDT_BUILD_SELECTOR |
( |
|
seg, |
|
|
|
local, |
|
|
|
rpl |
|
) |
| ((seg << 3) | ((local & 0x1) << 2) | (rpl & 0x3)) |
Definition at line 52 of file gdt.h.
Definition at line 45 of file gdt.h.
Definition at line 46 of file gdt.h.
Definition at line 49 of file gdt.h.
Definition at line 50 of file gdt.h.
Definition at line 47 of file gdt.h.
Typedef Documentation
Enumeration Type Documentation
- Enumerator:
GDTE_CODE |
|
GDTE_DATA |
|
GDTE_TSS |
|
Definition at line 23 of file gdt.h.
Function Documentation
Definition at line 99 of file gdt.c.
{
if (limit > (1 << 20))
{
pok_gdt[index].limit_low = (limit >> 12) & 0xFFFF;
pok_gdt[index].limit_high = (limit >> 28) & 0xF;
pok_gdt[index].granularity = 1;
}
else
{
pok_gdt[index].limit_low = limit & 0xFFFF;
pok_gdt[index].limit_high = (limit >> 16) & 0xFF;
pok_gdt[index].granularity = 0;
}
pok_gdt[index].base_low = base_address & 0xFFFFFF;
pok_gdt[index].base_high = (base_address >> 24) & 0xFF;
pok_gdt[index].type = t & 0xF;
pok_gdt[index].dpl = dpl & 0x3;
pok_gdt[index].s = 1;
pok_gdt[index].present = 1;
pok_gdt[index].available = 0;
pok_gdt[index].op_size = 1;
}
Definition at line 130 of file gdt.c.
{
pok_gdt[index].limit_low = limit & 0xFFFF;
pok_gdt[index].limit_high = (limit >> 16) & 0xFF;
pok_gdt[index].base_low = base_address & 0xFFFFFF;
pok_gdt[index].base_high = (base_address >> 24) & 0xFF;
pok_gdt[index].type = t & 0xF;
pok_gdt[index].dpl = dpl & 0x3;
pok_gdt[index].s = 0;
pok_gdt[index].present = 1;
pok_gdt[index].available = 0;
pok_gdt[index].op_size = 0;
}
Definition at line 41 of file gdt.c.
{
sysdesc_t sysdesc;
memset(pok_gdt, 0, sizeof (gdt_entry_t) * GDT_SIZE);
gdt_set_segment(GDT_CORE_CODE_SEGMENT, 0, ~0UL, GDTE_CODE, 0);
gdt_set_segment(GDT_CORE_DATA_SEGMENT, 0, ~0UL, GDTE_DATA, 0);
sysdesc.limit = sizeof (pok_gdt);
sysdesc.base = (uint32_t)pok_gdt;
asm ("lgdt %0"
:
: "m" (sysdesc));
asm ("ljmp %0, $1f \n"
"1: \n"
"mov %1, %%ax \n"
"mov %%ax, %%ds \n"
"mov %%ax, %%es \n"
"mov %%ax, %%fs \n"
"mov %%ax, %%gs \n"
"mov %%ax, %%ss \n"
:
: "i" (GDT_CORE_CODE_SEGMENT << 3),
"i" (GDT_CORE_DATA_SEGMENT << 3)
: "eax");
pok_tss_init();
return (POK_ERRNO_OK);
}
Definition at line 79 of file gdt.c.
{
uint16_t sel = GDT_BUILD_SELECTOR(GDT_TSS_SEGMENT, 0, 0);
memset(&pok_tss, 0, sizeof (tss_t));
pok_tss.ss0 = GDT_BUILD_SELECTOR(GDT_CORE_DATA_SEGMENT, 0, 0);
gdt_set_system(GDT_TSS_SEGMENT, (uint32_t)&pok_tss,
sizeof (tss_t), GDTE_TSS, 0);
asm ("ltr %0" : :"m"(sel));
return (POK_ERRNO_OK);
}
Definition at line 94 of file gdt.c.