From defcbbc6527cd20bd45e42fab53d7e185156df48 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 15 Feb 2008 22:35:18 -0800 Subject: [PATCH] Don't close the A20 gate; leave it open Don't close the A20 gate (restore to previous state); leave it open. This is good for performance, but also avoids a nasty race condition when leaving protected mode to then quickly re-enter protected mode. --- bcopy32.inc | 9 ++++++++- com32.inc | 2 ++ config.inc | 11 +++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bcopy32.inc b/bcopy32.inc index b62d3ac..99a16d8 100644 --- a/bcopy32.inc +++ b/bcopy32.inc @@ -190,7 +190,9 @@ simple_pm_call: pop fs pop es pop ds +%if DISABLE_A20 call disable_a20 +%endif popfd ; Re-enables interrupts pop ebp @@ -412,6 +414,8 @@ a20_test: pop es ret +%if DISABLE_A20 + disable_a20: pushad ; @@ -464,6 +468,8 @@ a20d_none: popad ret +%endif + ; ; Routine to empty the 8042 KBC controller. If dl != 0 ; then we will test A20 in the loop and exit if A20 is @@ -594,8 +600,9 @@ trampoline_to_pm: align 2 A20List dw a20_dunno, a20_none, a20_bios, a20_kbc, a20_fast +%if DISABLE_A20 A20DList dw a20d_dunno, a20d_none, a20d_bios, a20d_kbc, a20d_fast -a20_adjust_cnt equ ($-A20List)/2 +%endif A20Type dw A20_NONE ; A20 type diff --git a/com32.inc b/com32.inc index c90c9ec..220c9d7 100644 --- a/com32.inc +++ b/com32.inc @@ -210,7 +210,9 @@ com32_enter_rm: jmp bx ; Go to whereever we need to go... com32_done: +%if DISABLE_A20 call disable_a20 +%endif sti jmp enter_command diff --git a/config.inc b/config.inc index d199597..d6a981e 100644 --- a/config.inc +++ b/config.inc @@ -28,6 +28,17 @@ MAX_FKEYS equ 12 ; Number of F-key help files %assign DO_WBINVD 0 ; Should we use WBINVD or not? ; +; Set this to return the A20 gate to its previous state, instead of +; leaving it open. This has caused problems, because there appear +; to be a race condition between disabling the A20 gate and trying to +; re-enter protected mode, causing the A20 gate disable to take effect +; after we have already done the A20 enabled check, with disastrous +; consequences. Plus, there seems to be little or no demand for it. +; +%assign DISABLE_A20 0 + + +; ; Version number definitinons ; %ifndef DEPEND ; Generated file -- 2.7.4