From: Amelia Coutard Date: Mon, 10 Oct 2022 20:56:19 +0000 (+0200) Subject: Fixed TSS setup. X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=1a3d191551372206eeb9aef5a9161ffca03a5d3e;p=voyage-au-centre-des-fichiers.git Fixed TSS setup. --- diff --git a/src/boot.S b/src/boot.S index d63fb7d..9faf67a 100644 --- a/src/boot.S +++ b/src/boot.S @@ -57,13 +57,16 @@ GDT: .byte 0b11111010 # Access: present | readable | ring3 .byte 0b10101111 # Flags: page_gran | long_mode, Limit[16:20] .byte 0x00 # Base[24:32] +.globl GDT.TSS .set GDT.TSS, . - GDT - .short TSS_SIZE & 0xFFFF # Limit[0:16] + .short (TSS_SIZE - 1) & 0xFFFF # Limit[0:16] .short 0x0000 # Base[0:16] # TSS & 0xFFFF .byte 0x00 # Base[16:24] # (TSS >> 16) & 0xFF .byte 0b10001001 # Access - .byte (0b0000 << 4) | ((TSS_SIZE >> 16) & 0xF) # Flags, Limit[16:20] + .byte (0b0000 << 4) | (((TSS_SIZE - 1) >> 16) & 0xF) # Flags, Limit[16:20] .byte 0x00 # Base[24:32] # (TSS >> 24) & 0xFF + .int 0 # Base[32:63] # (TSS >> 32) & 0xFFFFFFFF + .int 0 # reserved GDT.PTR: .short . - GDT - 1 .quad GDT - KERNEL_VMA @@ -184,20 +187,6 @@ _start: or $1 << 31, %eax mov %eax, %cr0 - # Setup TSS address in GDT - mov $TSS - KERNEL_VMA, %eax - shr $0, %eax - and $0xFFFF, %eax - mov %ax, GDT.TSS + GDT - KERNEL_VMA + 2 - mov $TSS - KERNEL_VMA, %eax - shr $16, %eax - and $0xFF, %eax - mov %al, GDT.TSS + GDT - KERNEL_VMA + 4 - mov $TSS - KERNEL_VMA, %eax - shr $24, %eax - and $0xFF, %eax - mov %al, GDT.TSS + GDT - KERNEL_VMA + 7 - # Jump to 64 bits: lgdt (GDT.PTR - KERNEL_VMA) jmp $GDT.KERNEL_CODE, $.trampoline @@ -241,6 +230,23 @@ _start: mov $PML4T - KERNEL_VMA, %rax mov %rax, %cr3 + # Setup TSS address in GDT + movabs $TSS, %rax + shr $0, %rax + and $0xFFFF, %rax + mov %ax, GDT.TSS + GDT + 2 + movabs $TSS, %rax + shr $16, %rax + and $0xFF, %rax + mov %al, GDT.TSS + GDT + 4 + movabs $TSS, %rax + shr $24, %rax + and $0xFF, %rax + mov %al, GDT.TSS + GDT + 7 + movabs $TSS, %rax + shr $32, %rax + mov %rax, GDT.TSS + GDT + 8 + call _init mov %r14, %rsi