summaryrefslogtreecommitdiff
path: root/arch/x86/lib/bios_asm.S
diff options
context:
space:
mode:
authorStefano Babic <sbabic@denx.de>2015-07-17 11:22:56 +0200
committerStefano Babic <sbabic@denx.de>2015-07-17 11:22:56 +0200
commitf448c5d3200372fa73f340144d013fdecf4e2f1f (patch)
treeb17b66f67a22b553f66bcb22e69d62cb2a5bbe7e /arch/x86/lib/bios_asm.S
parent425640256a7c5e9259f7583ee4eca1f3b70f8032 (diff)
parent605e15db2b54302364a2528d3c6604fbc57be846 (diff)
downloadu-boot-imx-f448c5d3200372fa73f340144d013fdecf4e2f1f.zip
u-boot-imx-f448c5d3200372fa73f340144d013fdecf4e2f1f.tar.gz
u-boot-imx-f448c5d3200372fa73f340144d013fdecf4e2f1f.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot
Diffstat (limited to 'arch/x86/lib/bios_asm.S')
-rw-r--r--arch/x86/lib/bios_asm.S23
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/x86/lib/bios_asm.S b/arch/x86/lib/bios_asm.S
index 4faa70e..9dbf969 100644
--- a/arch/x86/lib/bios_asm.S
+++ b/arch/x86/lib/bios_asm.S
@@ -246,6 +246,9 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
push %fs
push %gs
+ /* Save real mode SS */
+ movw %ss, %cs:__realmode_ss
+
/* Clear DF to not break ABI assumptions */
cld
@@ -258,12 +261,29 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
enter_protected_mode
+ /*
+ * Now we are in protected mode. We need compute the right ESP based
+ * on saved real mode SS otherwise interrupt_handler() won't get
+ * correct parameters from the stack.
+ */
+ movzwl %cs:__realmode_ss, %ecx
+ shll $4, %ecx
+ addl %ecx, %esp
+
/* Call the C interrupt handler */
movl $interrupt_handler, %eax
call *%eax
+ /* Restore real mode ESP based on saved SS */
+ movzwl %cs:__realmode_ss, %ecx
+ shll $4, %ecx
+ subl %ecx, %esp
+
enter_real_mode
+ /* Restore real mode SS */
+ movw %cs:__realmode_ss, %ss
+
/*
* Restore all registers, including those manipulated by the C
* handler
@@ -276,6 +296,9 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
popal
iret
+__realmode_ss = PTR_TO_REAL_MODE(.)
+ .word 0
+
.globl asm_realmode_code_size
asm_realmode_code_size:
.long . - asm_realmode_code