From f69a86955e028f963ae31257bd6cb25be705a6cd Mon Sep 17 00:00:00 2001
From: bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Date: Sun, 30 Oct 2005 17:05:44 +0000
Subject: [PATCH] slavio_serial fixes (Blue Swirl)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1575 c046a42c-6fe2-441c-8c8c-71466251a162
---
 hw/slavio_serial.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/slavio_serial.c b/hw/slavio_serial.c
index 4b02d29f6b..de45cc5de1 100644
--- a/hw/slavio_serial.c
+++ b/hw/slavio_serial.c
@@ -195,7 +195,7 @@ static void slavio_serial_mem_writeb(void *opaque, target_phys_addr_t addr, uint
 	    val &= 0x38;
 	    switch (val) {
 	    case 8:
-		s->reg |= 0x8;
+		newreg |= 0x8;
 		break;
 	    case 0x20:
 		s->rxint = 0;
@@ -245,7 +245,8 @@ static void slavio_serial_mem_writeb(void *opaque, target_phys_addr_t addr, uint
 		handle_kbd_command(s, val);
 	    }
 	    s->txint = 1;
-	    s->rregs[0] |= 4;
+	    s->rregs[0] |= 4; // Tx buffer empty
+	    s->rregs[1] |= 1; // All sent
 	    // Interrupts reported only on channel A
 	    if (s->chn == 0)
 		s->rregs[3] |= 0x10;
@@ -278,12 +279,12 @@ static uint32_t slavio_serial_mem_readb(void *opaque, target_phys_addr_t addr)
 	s->reg = 0;
 	return ret;
     case 1:
-	SER_DPRINTF("Read channel %c, ch %d\n", channel? 'b' : 'a', s->rx);
 	s->rregs[0] &= ~1;
 	if (s->type == kbd)
 	    ret = get_queue(s);
 	else
 	    ret = s->rx;
+	SER_DPRINTF("Read channel %c, ch %d\n", channel? 'b' : 'a', ret);
 	return ret;
     default:
 	break;
@@ -453,7 +454,6 @@ static void handle_kbd_command(ChannelState *s, int val)
     KBD_DPRINTF("Command %d\n", val);
     switch (val) {
     case 1: // Reset, return type code
-	put_queue(s, 0xff);
 	put_queue(s, 0xff);
 	put_queue(s, 5); // Type 5
 	break;