From d284820b706a18d142fe0dd391cd52757b541919 Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Mon, 28 Aug 2006 21:05:57 +0000 Subject: [PATCH] When testing for active multiplexing failed hard, revert to legacy mode and continue. This should fix bug 829. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18677 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/bus_managers/ps2/ps2_common.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_common.c b/src/add-ons/kernel/bus_managers/ps2/ps2_common.c index 43ee9be335..3536ec6a29 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_common.c +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_common.c @@ -138,7 +138,7 @@ ps2_setup_active_multiplexing(bool *enabled) out = 0xf0; res = ps2_command(0xd3, &out, 1, &in, 1); if (res) - return res; + goto fail; // Step 1, if controller is good, in does match out. // This test failes with MS Virtual PC. if (in != out) @@ -147,7 +147,7 @@ ps2_setup_active_multiplexing(bool *enabled) out = 0x56; res = ps2_command(0xd3, &out, 1, &in, 1); if (res) - return res; + goto fail; // Step 2, if controller is good, in does match out. if (in != out) goto no_support; @@ -155,7 +155,7 @@ ps2_setup_active_multiplexing(bool *enabled) out = 0xa4; res = ps2_command(0xd3, &out, 1, &in, 1); if (res) - return res; + goto fail; // Step 3, if the controller doesn't support active multiplexing, // then in data does match out data (0xa4), else it's version number. if (in == out) @@ -186,6 +186,18 @@ no_support: dprintf("ps2: active multiplexing not supported\n"); *enabled = false; return B_OK; + +fail: + dprintf("ps2: testing for active multiplexing failed\n"); + *enabled = false; + // this should revert the controller into legacy mode, + // just in case it has switched to multiplexed mode + res = ps2_command(PS2_CTRL_SELF_TEST, NULL, 0, &out, 1); + if (res != B_OK || out != 0x55) { + dprintf("ps2: controller self test failed, status 0x%08x, data 0x%02x\n", res, out); + return B_ERROR; + } + return B_OK; }