* [Qemu-devel] [PATCH] Fix for DOS keyboard problems
@ 2009-08-18 12:02 Stefan Ring
0 siblings, 0 replies; only message in thread
From: Stefan Ring @ 2009-08-18 12:02 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]
Scratching an itch for myself, I have created a patch that allows me
to use Turbo Pascal and other Turbo Vision-based programs from DOS. I
post it here in the hope that someone take a good look, and maybe,
there's even a chance of this going into mainline. I verified that it
doesn't break keyboard or mouse functionality in Win 3.11, Win 2000
and Linux X11 (from systemrescuecd 1.1.4) as well as some DOS games.
Couldn't get win98 to run, unfortunately, so no testing there.
However, there is always the chance that it might break some random
obscure stuff, and clearly I cannot test everything.
The patch basically exploits the fact that the BIOS IRQ 1 handler
always does <disable keyboard> - <read 60h> - <enable keyboard> in
this order. We just remember the last value read from port 60h outside
this disable/enable block and play it back inside. The keyboard is
still very unreliable when a keyboard driver is loaded inside DOS (I
assume that the keyboard driver completely disables the BIOS handler).
This behavior is also present without my patch, and I personally don't
care about it, so this should not be an obstacle.
I also didn't know what to do about kbd_save and kbd_load just because
I didn't dig into them to find out what they are used for. The new
member should probably be serialized there.
My ultimate hope would be to get this into VirtualBox (see ticket #58
[1]). It should be easy enough to adapt the patch to VirtualBox; I
will try to do that within the next few days.
[1] http://www.virtualbox.org/ticket/58
[-- Attachment #2: qemu-patch --]
[-- Type: application/octet-stream, Size: 1545 bytes --]
--- qemu-0.10.5.orig/hw/pckbd.c 2009-05-20 22:46:59.000000000 +0200
+++ qemu-0.10.5/hw/pckbd.c 2009-08-18 11:26:59.896195620 +0200
@@ -120,6 +120,7 @@
uint8_t mode;
/* Bitmask of devices with data available. */
uint8_t pending;
+ uint32_t held_kbd_val;
void *kbd;
void *mouse;
@@ -161,9 +162,10 @@
{
KBDState *s = (KBDState *)opaque;
- if (level)
+ if (level) {
s->pending |= KBD_PENDING_KBD;
- else
+ s->held_kbd_val = (uint32_t) -1;
+ } else
s->pending &= ~KBD_PENDING_KBD;
kbd_update_irq(s);
}
@@ -238,6 +240,7 @@
break;
case KBD_CCMD_KBD_ENABLE:
s->mode &= ~KBD_MODE_DISABLE_KBD;
+ s->held_kbd_val = (uint32_t) -1;
kbd_update_irq(s);
break;
case KBD_CCMD_READ_INPORT:
@@ -283,8 +286,15 @@
if (s->pending == KBD_PENDING_AUX)
val = ps2_read_data(s->mouse);
- else
- val = ps2_read_data(s->kbd);
+ else {
+ if (s->mode & KBD_MODE_DISABLE_KBD && s->held_kbd_val != (uint32_t) -1)
+ val = s->held_kbd_val;
+ else {
+ val = ps2_read_data(s->kbd);
+ if (!(s->mode & KBD_MODE_DISABLE_KBD))
+ s->held_kbd_val = val;
+ }
+ }
#if defined(DEBUG_KBD)
printf("kbd: read data=0x%02x\n", val);
@@ -339,6 +349,7 @@
s->mode = KBD_MODE_KBD_INT | KBD_MODE_MOUSE_INT;
s->status = KBD_STAT_CMD | KBD_STAT_UNLOCKED;
+ s->held_kbd_val = (uint32_t) -1;
}
static void kbd_save(QEMUFile* f, void* opaque)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-08-18 12:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-18 12:02 [Qemu-devel] [PATCH] Fix for DOS keyboard problems Stefan Ring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).