feat(kernel): load tss

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-07-17 10:08:43 +02:00
parent 40d3009b1a
commit 4b8036b192
4 changed files with 48 additions and 7 deletions

View file

@ -111,7 +111,7 @@ cga_putc:
; scroll up ; scroll up
push esi push esi
push edi push edi
mov ecx, CGA_COLUMNS*(CGA_LINES)*2 mov ecx, CGA_COLUMNS*(CGA_LINES)
mov edi, CGA_MEMORY mov edi, CGA_MEMORY
mov esi, CGA_MEMORY+80*2 mov esi, CGA_MEMORY+80*2
rep movsw rep movsw

View file

@ -23,8 +23,12 @@ gdt:
; Tss ; Tss
.tss: .tss:
dw ? .limit dw ?
dd ? .base dw ?
.baseh0 db ?
.access db ?
.flags db ?
.baseh1 db ?
.end: .end:
@ -33,5 +37,32 @@ pGDT:
dd gdt dd gdt
gdt_set_tss: gdt_set_tss:
mov ecx, sizeof.TSS
mov [gdt.limit], cx
mov [gdt.base], ax
shr ecx, 16
shr eax, 16
mov [gdt.baseh0], al
mov [gdt.baseh1], ah
mov al, 0x89
mov [gdt.access], al
and cl, 0xF
or cl, 0x40
mov [gdt.flags], cl
ret
gdt_flush:
; load kernel gdt
lgdt [pGDT]
jmp 0x08:@f
@@:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
ret ret

View file

@ -58,9 +58,18 @@ kmain:
call pic_init call pic_init
; load kernel gdt ; clear tss
lgdt [pGDT] mov ecx, sizeof.TSS
; I don't think i need to reload segment cuz their value are already correct xor ax, ax
mov edi, kTSS
rep movsb
mov cx, 0xdfff
mov eax, kTSS
mov [eax + TSS.iomap], cx
call gdt_set_tss
call gdt_flush
call idt_setup call idt_setup

View file

@ -87,6 +87,7 @@ struc TSS {
.trap dw ? .trap dw ?
.iomap dw ? .iomap dw ?
} }
DEFN TSS
struc GDTGate { struc GDTGate {