> Unfortunately I can't apply Japheth's mod for QEMU 0.9.1 to QEMU 0.10.x
> "automatically" due to QEMU source code changes. So I have to ask Japheth
> for some help. 
I added the changes to 0.10.2 and created a patch.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> qemukbd.dif
--- pckbd.co Tue Apr 7 02:05:00 2009
+++ pckbd.c Fri Apr 10 16:09:30 2009
@@ -26,6 +26,7 @@
#include "pc.h"
#include "ps2.h"
#include "sysemu.h"
+#include "qemu-timer.h"
/* debug PC keyboard */
//#define DEBUG_KBD
@@ -126,6 +127,8 @@
qemu_irq irq_kbd;
qemu_irq irq_mouse;
target_phys_addr_t mask;
+ QEMUTimer *kbd_timer;
+ uint32_t last_kbd;
} KBDState;
static KBDState kbd_state;
@@ -148,9 +151,13 @@
if (s->mode & KBD_MODE_MOUSE_INT)
irq_mouse_level = 1;
} else {
+ if (qemu_timer_pending(s->kbd_timer)) {
+ s->status &= ~KBD_STAT_OBF;
+ } else {
if ((s->mode & KBD_MODE_KBD_INT) &&
!(s->mode & KBD_MODE_DISABLE_KBD))
irq_kbd_level = 1;
+ }
}
}
qemu_set_irq(s->irq_kbd, irq_kbd_level);
@@ -168,6 +175,16 @@
kbd_update_irq(s);
}
+static void kbd_timer_proc(void *opaque)
+{
+ KBDState *s = opaque;
+ if (ps2_getcount(s->kbd))
+ kbd_update_kbd_irq( s, 1 );
+ else
+ kbd_update_kbd_irq( s, 0 );
+ return;
+}
+
static void kbd_update_aux_irq(void *opaque, int level)
{
KBDState *s = (KBDState *)opaque;
@@ -279,17 +296,21 @@
static uint32_t kbd_read_data(void *opaque, uint32_t addr)
{
KBDState *s = opaque;
- uint32_t val;
if (s->pending == KBD_PENDING_AUX)
- val = ps2_read_data(s->mouse);
- else
- val = ps2_read_data(s->kbd);
+ return ps2_read_data(s->mouse);
+
+ if ( !qemu_timer_pending( s->kbd_timer )) {
+ if ( ps2_getcount( s->kbd ) > 1)
+ qemu_mod_timer( s->kbd_timer, qemu_get_clock(vm_clock) + ticks_per_sec / 50 );
+ s->last_kbd = ps2_read_data(s->kbd);
+ }
+
#if defined(DEBUG_KBD)
- printf("kbd: read data=0x%02x\n", val);
+ printf("kbd: read data=0x%02x\n", s->last_kbd);
#endif
- return val;
+ return s->last_kbd;
}
static void kbd_write_data(void *opaque, uint32_t addr, uint32_t val)
@@ -380,6 +401,8 @@
s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s);
s->mouse = ps2_mouse_init(kbd_update_aux_irq, s);
+ s->kbd_timer = qemu_new_timer(vm_clock, kbd_timer_proc, s);
+ s->last_kbd = 0;
#ifdef TARGET_I386
vmmouse_init(s->mouse);
#endif
@@ -437,6 +460,8 @@
s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s);
s->mouse = ps2_mouse_init(kbd_update_aux_irq, s);
+ s->kbd_timer = qemu_new_timer(vm_clock, kbd_timer_proc, s);
+ s->last_kbd = 0;
#ifdef TARGET_I386
vmmouse_init(s->mouse);
#endif
--- ps2.co Tue Apr 7 02:05:00 2009
+++ ps2.c Fri Apr 10 16:02:04 2009
@@ -134,6 +134,12 @@
s->update_irq(s->update_arg, 1);
}
+int ps2_getcount(void *opaque)
+{
+ PS2Queue *q = opaque;
+ return( q->count );
+}
+
/*
keycode is expressed as follow:
bit 7 - 0 key pressed, 1 = key released
--- ps2.ho Tue Apr 7 02:05:00 2009
+++ ps2.h Fri Apr 10 16:02:30 2009
@@ -7,3 +7,4 @@
void ps2_queue(void *, int b);
void ps2_keyboard_set_translation(void *opaque, int mode);
void ps2_mouse_fake_event(void *opaque);
+int ps2_getcount(void *);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> qemukbd.dif --- MS-DOS forever! |