From 68e5c0c5c9dc26e9c7ce4bf5252719ee8dc4b3ae Mon Sep 17 00:00:00 2001 From: Alejandro Sior Date: Fri, 20 May 2022 14:27:08 +0200 Subject: bios.call: store the gdt on 8+2 bytes --- rt/+x86_64/realcall.S | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'rt/+x86_64/realcall.S') diff --git a/rt/+x86_64/realcall.S b/rt/+x86_64/realcall.S index ffbc0a9..1c51f99 100644 --- a/rt/+x86_64/realcall.S +++ b/rt/+x86_64/realcall.S @@ -21,6 +21,8 @@ prev_idt: .quad 0x0 prev_gdt: .quad 0x0 + .short 0x0 + # :The 64 bits sidt stores on 8+2 bytes # :real_call # This function is intended to be called from long mode @@ -55,7 +57,7 @@ bios.call: cli - sidt (prev_idt) + #sidt (prev_idt) sgdt (prev_gdt) lgdt (gdtr32) @@ -122,6 +124,7 @@ real_call_int: cli + xchg %bx, %bx mov %es, (res) mov %eax, (reax) mov %ebx, (rebx) @@ -155,14 +158,13 @@ real_call_to_pmode_up: or $1 << 31, %eax mov %eax, %cr0 - lgdt (prev_gdt) - # :At this point %ds is latest in stack pop %ax # :At this point %cs is latest in stack # Do a long jump push $real_call_to_longmode_up + lgdt (prev_gdt) retf .code64 real_call_to_longmode_up: @@ -174,7 +176,7 @@ real_call_to_longmode_up: # :Avoid doing this until the bootloader loads a 64 bits IDT # XXX - #idt (prev_idt) + # lidt (prev_idt) real_call_end: popf @@ -183,4 +185,5 @@ real_call_end: pop %r13 pop %r12 pop %rbx + cli ret -- cgit v1.2.3