|
ginnOS
The reference: libc, the libraries and the kernel
|
Macros | |
| #define | GDT_ENTRIES 9 |
Functions | |
| struct gdt_entry | __attribute__ ((packed)) |
| void | gdt_flush (uint32_t) |
| void | tss_flush (void) |
| void | gdt_initialize (uint32_t core) |
| set up the GDT of a core with kernel segments, user segments and a Task State Segment, and load the GDT into GDTR and the TSS into TR. | |
| void | gdt_set_tls (uint32_t base) |
| set the base of the user TLS segment in the GDT of the core that runs the call, and load GS with it. | |
| void | gdt_set_percpu (uint32_t core, uint32_t base) |
| set the base of the per-CPU segment (the cpu_t of the core) and load FS with it. | |
| void | tss_set_kernel_stack (uintptr_t esp0) |
| update the kernel stack pointer (ESP0) in the TSS of the core that runs the call. | |
| void | tss_install_double_fault (uint32_t core, void(*entry)(void), uintptr_t stack_top) |
| set up the double-fault task: a second TSS whose state the CPU loads when a double fault arrives through a task gate, so the handler runs on its own stack even when the faulting stack is unusable (a kernel stack overflow into its guard page). | |
| void | tss_set_double_fault_cr3 (uint32_t core, uint32_t cr3) |
| set the page directory the double-fault task of a core runs with. | |
| void | tss_interrupted_state (uint32_t *eip, uint32_t *esp, uint32_t *ebp) |
| read the state of the task that was running when the double fault struck. | |
| #define GDT_ENTRIES 9 |
| struct gdt_entry __attribute__ | ( | (packed) | ) |
|
extern |
|
extern |
| void gdt_initialize | ( | uint32_t | core | ) |
set up the GDT of a core with kernel segments, user segments and a Task State Segment, and load the GDT into GDTR and the TSS into TR.
each core has its own GDT and TSS. call it on the core itself.
| core | the index of the core (cpu_t.index), 0 for the boot core. |
| void gdt_set_tls | ( | uint32_t | base | ) |
set the base of the user TLS segment in the GDT of the core that runs the call, and load GS with it.
| base | the thread pointer. |
| void tss_set_kernel_stack | ( | uintptr_t | esp0 | ) |
update the kernel stack pointer (ESP0) in the TSS of the core that runs the call.
called on context switches so the CPU knows where to find the kernel stack when an interrupt occurs in ring 3.
| esp0 | the kernel stack pointer to store. |
set up the double-fault task: a second TSS whose state the CPU loads when a double fault arrives through a task gate, so the handler runs on its own stack even when the faulting stack is unusable (a kernel stack overflow into its guard page).
each core has its own task.
| core | the index of the core. |
| entry | function the task starts in; it must never return. |
| stack_top | initial ESP for the task. |
set the page directory the double-fault task of a core runs with.
| core | the index of the core. |
| cr3 | physical address of the kernel page directory. |
read the state of the task that was running when the double fault struck.
the task switch saves it into the main TSS of the core that runs the call.
| eip | receives the interrupted EIP. |
| esp | receives the interrupted ESP. |
| ebp | receives the interrupted EBP. |
| uint16_t limit_low |
| uint16_t base_low |
| uint8_t base_middle |
| uint8_t access |
| uint8_t granularity |
| uint8_t base_high |
| uint16_t limit |
| uint32_t base |
| uint32_t prev_tss |
| uint32_t esp0 |
| uint32_t ss0 |
| uint32_t esp1 |
| uint32_t ss1 |
| uint32_t esp2 |
| uint32_t ss2 |
| uint32_t cr3 |
| uint32_t eip |
| uint32_t eflags |
| uint32_t eax |
| uint32_t ecx |
| uint32_t edx |
| uint32_t ebx |
| uint32_t esp |
| uint32_t ebp |
| uint32_t esi |
| uint32_t edi |
| uint32_t es |
| uint32_t cs |
| uint32_t ss |
| uint32_t ds |
| uint32_t fs |
| uint32_t gs |
| uint32_t ldt |
| uint16_t trap |
| uint16_t iomap_base |