From: Amelia Coutard Date: Sun, 9 Oct 2022 18:30:21 +0000 (+0200) Subject: Changed the order of the info in the GDT, to make it possible to use syscall/sysret X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=6eea8a6272c5d81e8d821bddb12c92d86ea041fd;p=voyage-au-centre-des-fichiers.git Changed the order of the info in the GDT, to make it possible to use syscall/sysret --- diff --git a/src/boot.S b/src/boot.S index ef9fce4..d63fb7d 100644 --- a/src/boot.S +++ b/src/boot.S @@ -29,13 +29,6 @@ multiboot_header_end: GDT: .set GDT.NULL, . - GDT .quad 0 -.set GDT.KERNEL_CODE, . - GDT - .short 0xFFFF # Limit[0:16] - .short 0x0000 # Base[0:16] - .byte 0x00 # Base[16:24] - .byte 0b10011010 # Access: present | readable | ring0 - .byte 0b10101111 # Flags: page_gran | long_mode, Limit[16:20] - .byte 0x00 # Base[24:32] .set GDT.KERNEL_DATA, . - GDT .short 0xFFFF # Limit[0:16] .short 0x0000 # Base[0:16] @@ -43,11 +36,11 @@ GDT: .byte 0b10010010 # Access: present | writeable | ring0 .byte 0b11001111 # Flags: page_gran | d_b, Limit[16:20] .byte 0x00 # Base[24:32] -.set GDT.USER_CODE, . - GDT +.set GDT.KERNEL_CODE, . - GDT .short 0xFFFF # Limit[0:16] .short 0x0000 # Base[0:16] .byte 0x00 # Base[16:24] - .byte 0b11111010 # Access: present | readable | ring3 + .byte 0b10011010 # Access: present | readable | ring0 .byte 0b10101111 # Flags: page_gran | long_mode, Limit[16:20] .byte 0x00 # Base[24:32] .set GDT.USER_DATA, . - GDT @@ -57,6 +50,13 @@ GDT: .byte 0b11110010 # Access: present | writeable | ring3 .byte 0b11001111 # Flags: page_gran | d_b, Limit[16:20] .byte 0x00 # Base[24:32] +.set GDT.USER_CODE, . - GDT + .short 0xFFFF # Limit[0:16] + .short 0x0000 # Base[0:16] + .byte 0x00 # Base[16:24] + .byte 0b11111010 # Access: present | readable | ring3 + .byte 0b10101111 # Flags: page_gran | long_mode, Limit[16:20] + .byte 0x00 # Base[24:32] .set GDT.TSS, . - GDT .short TSS_SIZE & 0xFFFF # Limit[0:16] .short 0x0000 # Base[0:16] # TSS & 0xFFFF @@ -68,6 +68,7 @@ GDT.PTR: .short . - GDT - 1 .quad GDT - KERNEL_VMA +.globl TSS TSS: .skip 4 RSP0: .quad 0 diff --git a/src/interrupts.hpp b/src/interrupts.hpp index 9cbf48e..af4cb6d 100644 --- a/src/interrupts.hpp +++ b/src/interrupts.hpp @@ -56,7 +56,7 @@ void enable_interrupts(const isr_info (&ISRs)[interrupt_nb], os::idt