From b6da3ed850e93be8817af0c9120b97e2886d9af1 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Sat, 20 Jul 2024 19:30:06 +0200 Subject: [PATCH] bios/a20: Improve a20_check(). Could fix #386 --- common/sys/a20.s2.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/common/sys/a20.s2.c b/common/sys/a20.s2.c index 4adfc947..0c55e737 100644 --- a/common/sys/a20.s2.c +++ b/common/sys/a20.s2.c @@ -8,15 +8,26 @@ #include bool a20_check(void) { - if (mminw(0x7dfe) != mminw(0x7dfe + 0x100000)) - return true; + bool ret = false; + uint16_t orig = mminw(0x7dfe); + + mmoutw(0x7dfe, 0x1234); + + if (mminw(0x7dfe) != mminw(0x7dfe + 0x100000)) { + ret = true; + goto out; + } mmoutw(0x7dfe, ~mminw(0x7dfe)); - if (mminw(0x7dfe) != mminw(0x7dfe + 0x100000)) - return true; + if (mminw(0x7dfe) != mminw(0x7dfe + 0x100000)) { + ret = true; + goto out; + } - return false; +out: + mmoutw(0x7dfe, orig); + return ret; } // Keyboard controller method code below taken from: