diff -ur grub-0.92/stage2/shared.h grub/stage2/shared.h
--- grub-0.92/stage2/shared.h	25 Mar 2002 21:43:55 -0000
+++ grub/stage2/shared.h	7 May 2002 18:34:23 -0000
@@ -258,14 +258,18 @@
 #define VARIABLE(x) ENTRY(x)
 
 
+/* Keyboard controller defines */
 #define K_RDWR  	0x60	/* keyboard data & cmds (read/write) */
-#define K_STATUS	0x64	/* keyboard status */
+#define K_STATUS	0x64	/* keyboard status (read-only) */
 #define K_CMD		0x64	/* keybd ctlr command (write-only) */
 
 #define K_OBUF_FUL 	0x01	/* output buffer full */
 #define K_IBUF_FUL 	0x02	/* input buffer full */
 
-#define KC_CMD_WIN	0xd0	/* read  output port */
+#define KC_CMD_KBDIS	0xad	/* disable keyboard */
+#define KC_CMD_KBEN	0xae	/* enable keyboard */
+
+#define KC_CMD_ROUT	0xd0	/* read  output port */
 #define KC_CMD_WOUT	0xd1	/* write output port */
 #define KB_OUTPUT_MASK  0xdd	/* enable output buffer full interrupt
 				   enable data line
diff -ur grub-0.92/stage2/asm.S grub/stage2/asm.S
--- grub-0.92/stage2/asm.S	12 Nov 2001 06:57:29 -0000
+++ grub/stage2/asm.S	7 May 2002 18:34:28 -0000
@@ -1694,10 +1694,24 @@
  */
 
 ENTRY(gateA20)
+	pushl	%ebp
+	movl	%esp, %ebp
 	pushl	%eax
+	pushl	%ebx
 
 	call    gloop1
 
+        /* mask PS/2 interrupts */
+        movb    $0x10, %al
+        outb    $0xa1
+        movb    $1, %al
+        outb    $0x21
+	/* disable keyboard */
+	movb	$KC_CMD_KBDIS, %al
+	outb	$K_CMD
+	call    gloop1
+
+	/* set up to write keyboard controller "output port" */
 	movb	$KC_CMD_WOUT, %al
 	outb	$K_CMD
 
@@ -1707,16 +1721,29 @@
 	jnz	gloopint1
 
 	movb	$KB_OUTPUT_MASK, %al
-	cmpb	$0, 0x8(%esp)
+	cmpb	$0, 0x8(%ebp)
 	jz	gdoit
 
 	orb	$KB_A20_ENABLE, %al
 gdoit:
+	/* write keyboard controller "output port" */
 	outb	$K_RDWR
 
 	call	gloop1
 
+	/* enable keyboard again (this also adds a bit of delay...) */
+	movb	$KC_CMD_KBEN, %al
+	outb	$K_CMD
+	call    gloop1
+        /* unmask PS/2 interrupts */
+        movb    $0, %al
+        outb    $0xa1
+        movb    $0, %al
+        outb    $0x21
+
+	popl	%ebx
 	popl	%eax
+	popl	%ebp
 	ret
 
 gloop1:
