Load the TSS.

This commit is contained in:
Nicolás Ortega Froysa 2018-04-05 10:23:23 +02:00
parent d46ee029ad
commit bb36ab3656
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF
3 changed files with 18 additions and 0 deletions

View File

@ -58,9 +58,16 @@ void gdt_install() {
// user // user
gdt_entry_set(&gdt[3], 0, 0xFFFFFFFF, 0xFA, 0xCF); gdt_entry_set(&gdt[3], 0, 0xFFFFFFFF, 0xFA, 0xCF);
gdt_entry_set(&gdt[4], 0, 0xFFFFFFFF, 0xF2, 0xCF); gdt_entry_set(&gdt[4], 0, 0xFFFFFFFF, 0xF2, 0xCF);
// TSS // TSS
tss.ss0 = 0x10;
// TODO: set esp0 for system interrupts
tss.iopb = sizeof(tss);
gdt_entry_set(&gdt[5], (uint32_t)&tss, gdt_entry_set(&gdt[5], (uint32_t)&tss,
sizeof(tss), 0x89, 0x40); sizeof(tss), 0x89, 0x40);
gdt_flush(&gdtr); gdt_flush(&gdtr);
// load the TSS
tss_load();
} }

View File

@ -21,6 +21,7 @@
#include "structs.h" #include "structs.h"
extern void gdt_flush(struct segreg *gdtr); extern void gdt_flush(struct segreg *gdtr);
extern void tss_load();
void gdt_entry_set(struct segdesc *entry, uint32_t base, void gdt_entry_set(struct segdesc *entry, uint32_t base,
uint32_t limit, uint8_t access, uint8_t gran); uint32_t limit, uint8_t access, uint8_t gran);
void gdt_install(); void gdt_install();

View File

@ -35,3 +35,13 @@ gdt_flush:
gdt_flush_end: gdt_flush_end:
popl %ebp popl %ebp
ret ret
.global tss_load
.type tss_load,@function
tss_load:
pushl %ebp
movl %esp, %ebp
movw $0x28, %ax
ltr %ax
popl %ebp
ret