Revision 67deb562

b/hw/slavio_serial.c
108 108
static void serial_receive_byte(ChannelState *s, int ch);
109 109
static inline void set_txint(ChannelState *s);
110 110

  
111
static void clear_queue(void *opaque)
112
{
113
    ChannelState *s = opaque;
114
    SERIOQueue *q = &s->queue;
115
    q->rptr = q->wptr = q->count = 0;
116
}
117

  
111 118
static void put_queue(void *opaque, int b)
112 119
{
113 120
    ChannelState *s = opaque;
......
137 144
            q->rptr = 0;
138 145
        q->count--;
139 146
    }
140
    KBD_DPRINTF("channel %c get 0x%02x\n", CHN_C(s), val);
147
    SER_DPRINTF("channel %c get 0x%02x\n", CHN_C(s), val);
141 148
    if (q->count > 0)
142 149
	serial_receive_byte(s, 0);
143 150
    return val;
......
186 193
    s->rx = s->tx = 0;
187 194
    s->rxint = s->txint = 0;
188 195
    s->rxint_under_svc = s->txint_under_svc = 0;
196
    clear_queue(s);
189 197
}
190 198

  
191 199
static void slavio_serial_reset(void *opaque)
......
199 207
{
200 208
    s->rxint = 0;
201 209
    s->rxint_under_svc = 0;
202
    if (s->chn == chn_a)
210
    if (s->chn == chn_a) {
211
        if (s->wregs[9] & 0x10)
212
            s->otherchn->rregs[2] = 0x60;
213
        else
214
            s->otherchn->rregs[2] = 0x06;
203 215
        s->rregs[3] &= ~0x20;
204
    else
216
    } else {
217
        if (s->wregs[9] & 0x10)
218
            s->rregs[2] = 0x60;
219
        else
220
            s->rregs[2] = 0x06;
205 221
        s->otherchn->rregs[3] &= ~4;
222
    }
206 223
    if (s->txint)
207 224
        set_txint(s);
208 225
    else
......
215 232
    s->rxint = 1;
216 233
    if (!s->txint_under_svc) {
217 234
        s->rxint_under_svc = 1;
218
        if (s->chn == chn_a)
235
        if (s->chn == chn_a) {
236
            if (s->wregs[9] & 0x10)
237
                s->otherchn->rregs[2] = 0x30;
238
            else
239
                s->otherchn->rregs[2] = 0x0c;
219 240
            s->rregs[3] |= 0x20;
220
        else
241
        } else {
242
            if (s->wregs[9] & 0x10)
243
                s->rregs[2] = 0x20;
244
            else
245
                s->rregs[2] = 0x04;
221 246
            s->otherchn->rregs[3] |= 4;
222
        s->rregs[2] = 4;
247
        }
223 248
        slavio_serial_update_irq(s);
224 249
    }
225 250
}
......
607 632
    KBD_DPRINTF("Command %d\n", val);
608 633
    switch (val) {
609 634
    case 1: // Reset, return type code
635
        clear_queue(s);
610 636
	put_queue(s, 0xff);
611
	put_queue(s, 5); // Type 5
637
	put_queue(s, 4); // Type 4
612 638
	break;
613 639
    case 7: // Query layout
640
    case 0xf:
641
        clear_queue(s);
614 642
	put_queue(s, 0xfe);
615
	put_queue(s, 0x20); // XXX, layout?
643
	put_queue(s, 19); // XXX, layout?
616 644
	break;
617 645
    default:
618 646
	break;
......
625 653
    ChannelState *s = opaque;
626 654
    int ch;
627 655

  
628
    /* XXX: SDL sometimes generates nul events: we delete them */
629
    if (dx == 0 && dy == 0 && dz == 0 && buttons_state == 0)
630
        return;
631 656
    MS_DPRINTF("dx=%d dy=%d buttons=%01x\n", dx, dy, buttons_state);
632 657

  
633 658
    ch = 0x80 | 0x7; /* protocol start byte, no buttons pressed */

Also available in: Unified diff