https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ff722ac72e98f320f27a0…
commit ff722ac72e98f320f27a0e57b4a5fb78753a2320
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Dec 22 13:53:17 2019 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Dec 23 21:06:40 2019 +0100
[FREELDR] Support setting up the EBP register on INT386() entry only if EBP != 0,
otherwise use it only as output.
---
boot/freeldr/freeldr/arch/amd64/int386.S | 1 -
boot/freeldr/freeldr/arch/i386/int386.S | 1 +
boot/freeldr/freeldr/arch/realmode/int386.inc | 9 ++++++++-
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/boot/freeldr/freeldr/arch/amd64/int386.S
b/boot/freeldr/freeldr/arch/amd64/int386.S
index f3bd65a4da7..4e0dfa72d1b 100644
--- a/boot/freeldr/freeldr/arch/amd64/int386.S
+++ b/boot/freeldr/freeldr/arch/amd64/int386.S
@@ -45,7 +45,6 @@ Int386:
sub rsp, 40
//.ENDPROLOG
-int386_2:
/* Copy the int vector to shared memory */
mov dword ptr [BSS_IntVector], ecx
diff --git a/boot/freeldr/freeldr/arch/i386/int386.S
b/boot/freeldr/freeldr/arch/i386/int386.S
index e1c371956d5..295c47cc109 100644
--- a/boot/freeldr/freeldr/arch/i386/int386.S
+++ b/boot/freeldr/freeldr/arch/i386/int386.S
@@ -73,6 +73,7 @@ Int386_return:
mov ecx, REGS_SIZE / 4
rep movsd
+ /* Restore all registers + segment registers */
popa
pop gs
pop fs
diff --git a/boot/freeldr/freeldr/arch/realmode/int386.inc
b/boot/freeldr/freeldr/arch/realmode/int386.inc
index 49a63eb9e37..ea3a822424d 100644
--- a/boot/freeldr/freeldr/arch/realmode/int386.inc
+++ b/boot/freeldr/freeldr/arch/realmode/int386.inc
@@ -37,13 +37,19 @@ Int386:
mov ax, word ptr cs:[BSS_RegisterSet + REGS_GS]
mov gs, ax
+ /* Setup ebp only if EBP != 0, otherwise use it only as output */
+ mov eax, dword ptr cs:[BSS_RegisterSet + REGS_EBP]
+ test eax, eax
+ jz Int386_set_registers
+ mov ebp, eax
+
+Int386_set_registers:
mov eax, dword ptr cs:[BSS_RegisterSet + REGS_EAX]
mov ebx, dword ptr cs:[BSS_RegisterSet + REGS_EBX]
mov ecx, dword ptr cs:[BSS_RegisterSet + REGS_ECX]
mov edx, dword ptr cs:[BSS_RegisterSet + REGS_EDX]
mov esi, dword ptr cs:[BSS_RegisterSet + REGS_ESI]
mov edi, dword ptr cs:[BSS_RegisterSet + REGS_EDI]
- // Don't setup ebp, we only use it as output!
/* Call the interrupt vector */
/*int Int386_vector*/
@@ -72,6 +78,7 @@ Int386_vector_opcode:
pushfd
pop dword ptr cs:[BSS_RegisterSet + REGS_EFLAGS]
+ /* Restore all registers + segment registers */
popad
pop gs
pop fs