Fix attached for qemu.

It would be nice to know if this causes trouble for real hardware,
but it should not.

ron
There are some problems with the way these interrrupts were managed. First, the CLI erases
any knowledge of whether interrupts were enabled or disabled. Second, the STI
works badly on qemu; we get an immediate INT #0 as soon as the STI happens.

This doesn't happen on real hardware but, that said, I don't think
this code should be doing cli and sti.

This change fixes the observed qemu failures.

Signed-off-by: Ronald G. Minnich <[email protected]>

Index: /home/rminnich/src/bios/coreboot-v2/util/x86emu/x86_asm.S
===================================================================
--- /home/rminnich/src/bios/coreboot-v2/util/x86emu/x86_asm.S	(revision 1171)
+++ /home/rminnich/src/bios/coreboot-v2/util/x86emu/x86_asm.S	(working copy)
@@ -71,11 +71,6 @@
 	// FIXME: Should this function be called with regparm=0?
 	movl    8(%ebp), %ecx
 
-	/* Clear interrupts before making a
-	 * transition to Real Mode
-	 */
-	cli
-
 	/* Activate the right segment descriptor real mode. */
 	ljmp	$0x28, $RELOCATED(1f)
 1:
@@ -111,14 +106,11 @@
 	movl	$0x1000, %eax
 	movl	%eax, %esp
 
-	/* Load our 16 it idt */
+	/* Load our 16 bit idt */
 	xor	%ax, %ax
 	mov	%ax, %ds
 	lidt	__realmode_idt
 
-	/* All critical work is done, allow interrupts again */
-	sti
-
 	/* Set all segments to 0x0000, ds to 0x0040 */
 	mov	%ax, %es       
 	mov	%ax, %fs       
@@ -133,11 +125,6 @@
 	lcall	$0xc000, $0x0003
 	/* ************************************ */
 
-	/* Clear interrupts before making a 
-	 * transition to Protected Mode
-	 */
-	cli
-
 	/* If we got here, just about done.
 	 * Need to get back to protected mode
 	 */
@@ -161,9 +148,6 @@
 	/* restore proper idt */
 	lidt	idtarg
 
-	/* All critical work is done, allow interrupts again */
-	sti
-
 	/* and exit */
 	mov	__stack, %esp
 	popal
@@ -179,11 +163,6 @@
 	mov	%esp, __stack
 
 
-	/* Clear interrupts before making a 
-	 * transition to Real Mode
-	 */
-	cli
-
 	/*  This configures CS properly for real mode. */
 	ljmp 	$0x28, $RELOCATED(1f)
 1:
@@ -228,9 +207,6 @@
 	mov	%ax, %ds
 	lidt	__realmode_idt
 
-	/* All critical work is done, allow interrupts again */
-	sti
-
 	/* Set all segments to 0x0000 */
 	mov	%ax, %ds
 	mov	%ax, %es
@@ -250,11 +226,6 @@
 	movw	$0, %di
 	int	$0x10
 
-	/* Clear interrupts before making a 
-	 * transition to Protected Mode
-	 */
-	cli
-
 	/* Ok, the job is done, now go back to protected mode coreboot */
 	movl	%cr0, %eax
 	orl	$PE, %eax
@@ -274,9 +245,6 @@
 	/* restore coreboot's 32-bit IDT */
 	lidt	idtarg
 
-	/* All critical work is done, allow interrupts again */
-	sti
-
 	/* Exit */
 	mov	__stack, %esp
 	popal
@@ -299,11 +267,6 @@
 	andl	$0xff, %eax
 	pushl	%eax		/* ... and make it the first parameter */
 
-	/* Clear interrupts before making a 
-	 * transition to Protected Mode
-	 */
-	cli
-
 	/* Switch to protected mode */
 	movl    %cr0, %eax
 	orl	$PE, %eax
@@ -322,9 +285,6 @@
 
 	lidt	idtarg
 
-	/* All critical work is done, allow interrupts again */
-	sti
-
 	/* Call the C interrupt handler */
 	movl	$interrupt_handler, %eax
 	call	*%eax
@@ -344,11 +304,6 @@
 	mov	%ax, %gs
 	mov	%ax, %ss
 
-	/* Clear interrupts before making a 
-	 * transition to Real Mode
-	 */
-	cli
-
 	/* Disable Protected Mode */
 	movl	%cr0, %eax
 	andl	$~PE, %eax
@@ -366,9 +321,6 @@
 	mov	%ax, %ds
 	lidt	__realmode_idt
 
-	/* All critical work is done, allow interrupts again */
-	sti
-
 	/* Set up our segment registers to segment 0x0000 */
 	mov	%ax, %es
 	mov	%ax, %fs
-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to