The Option ROM might mess with the EFLAGS register and break assumptions
the C part of coreboot implicitly has, e.g. the state of the direction
flag.
Prevent Option ROMs from confusing coreboot by restoring the old EFLAGS
value after the Option ROMs has finished and always clear the direction
flag before calling the C part of the interrupt handler.
Change-Id: I84663be6681b17f95f48d93f0b730e443336b4a8
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Reviewed-on: http://review.coreboot.org/837
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
.globl __realmode_call
__realmode_call = RELOCATED(.)
/* save all registers to the stack */
.globl __realmode_call
__realmode_call = RELOCATED(.)
/* save all registers to the stack */
- /* Move the protected mode stack to a safe place */
+ /* Move the protected mode stack pointer to a safe place */
- /* This function is called with regparm=0 and we have
- * to skip the 32 byte from pushal. Hence start at 36.
+ /* This function is called with regparm=0 and we have to
+ * skip the 36 byte from pushf+pusha. Hence start at 40.
mov %ax, __lcall_instr + 1
andl $0xffff0000, %eax
shrl $4, %eax
mov %ax, __lcall_instr + 3
/* initial register values */
mov %ax, __lcall_instr + 1
andl $0xffff0000, %eax
shrl $4, %eax
mov %ax, __lcall_instr + 3
/* initial register values */
- movl 40(%ebp), %eax
- movl %eax, __registers + 0 /* eax */
- movl %eax, __registers + 4 /* ebx */
+ movl %eax, __registers + 0 /* eax */
- movl %eax, __registers + 8 /* ecx */
+ movl %eax, __registers + 4 /* ebx */
- movl %eax, __registers + 12 /* edx */
+ movl %eax, __registers + 8 /* ecx */
- movl %eax, __registers + 16 /* esi */
+ movl %eax, __registers + 12 /* edx */
+ movl %eax, __registers + 16 /* esi */
+ movl 64(%ebp), %eax
movl %eax, __registers + 20 /* edi */
/* Activate the right segment descriptor real mode. */
movl %eax, __registers + 20 /* edi */
/* Activate the right segment descriptor real mode. */
/* restore proper idt */
lidt idtarg
/* restore proper idt */
lidt idtarg
+ /* restore stack pointer, eflags and register values */
// TODO return AX from OPROM call
ret
.globl __realmode_interrupt
__realmode_interrupt = RELOCATED(.)
/* save all registers to the stack */
// TODO return AX from OPROM call
ret
.globl __realmode_interrupt
__realmode_interrupt = RELOCATED(.)
/* save all registers to the stack */
- pushal
- /* save the stack */
+ pusha
+ pushf
+
+ /* save the stack pointer */
- /* This function is called with regparm=0 and we have
- * to skip the 32 byte from pushal. Hence start at 36.
+ /* This function is called with regparm=0 and we have to
+ * skip the 36 byte from pushf+pusha. Hence start at 40.
*/
/* prepare interrupt calling code */
*/
/* prepare interrupt calling code */
movb %al, __intXX_instr + 1 /* intno */
/* initial register values */
movb %al, __intXX_instr + 1 /* intno */
/* initial register values */
- movl 40(%ebp), %eax
- movl %eax, __registers + 0 /* eax */
- movl %eax, __registers + 4 /* ebx */
+ movl %eax, __registers + 0 /* eax */
- movl %eax, __registers + 8 /* ecx */
+ movl %eax, __registers + 4 /* ebx */
- movl %eax, __registers + 12 /* edx */
+ movl %eax, __registers + 8 /* ecx */
- movl %eax, __registers + 16 /* esi */
+ movl %eax, __registers + 12 /* edx */
+ movl %eax, __registers + 16 /* esi */
+ movl 64(%ebp), %eax
movl %eax, __registers + 20 /* edi */
/* This configures CS properly for real mode. */
movl %eax, __registers + 20 /* edi */
/* This configures CS properly for real mode. */
/* restore coreboot's 32-bit IDT */
lidt idtarg
/* restore coreboot's 32-bit IDT */
lidt idtarg
+ /* restore stack pointer, eflags and register values and exit */
ret
/* This is the 16-bit interrupt entry point called by the IDT stub code.
ret
/* This is the 16-bit interrupt entry point called by the IDT stub code.
+ /* Clear DF to not break ABI assumptions */
+ cld
+
/* Clean up the interrupt number. We could have done this in the stub,
* but it would have cost 2 more bytes per stub entry.
*/
/* Clean up the interrupt number. We could have done this in the stub,
* but it would have cost 2 more bytes per stub entry.
*/