[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RFC] ps2: set the keybord output buffer size as

From: Gonglei (Arei)
Subject: Re: [Qemu-devel] [PATCH RFC] ps2: set the keybord output buffer size as the same as kernel
Date: Wed, 23 Apr 2014 13:14:10 +0000

>   Hi,
> > Anything bigger than 16bytes, no?  And that is the whole point that we
> > are talking about?  Or the 16bytes that we are using can be at any place
> > on the buffer?
> Yes.  It's a ring buffer, with rptr pointing to the first used element
> and wptr pointing to the first free element.
> So, what we need is a function to move the content we are interested
> (between rptr and wptr) in to the head of the ring buffer, set rptr to
> 0, set wptr to count.  We obviously need to do that in post_load(), but
> as I've noticed meanwhile also in pre_save, otherwise old qemu will get
> things wrong in case the buffer is wrapped (rptr > wptr).
Hi, Gerd. Maybe we just need to do in post_load(). Such as the follow code:

static int ps2_kbd_post_load(void* opaque, int version_id)
    PS2KbdState *s = (PS2KbdState*)opaque;
    PS2State *ps2 = &s->common;
    PS2Queue *q = &ps2->queue;
    int size;
    int i;
    if (version_id == 2)
    /* the new version id for this patch */
    if (version_id == 4) {
        return 0;
    /* set the useful data buffer queue size, < PS2_QUEUE_SIZE */
    size = MIN(q->count, PS2_QUEUE_SIZE);
    printf(" ==kbd: rptr: %d, wptr: %d, count: %d, size: %d\n", q->rptr, 
q->wptr, q->count, size);
    for (i = 0; i < size; i++) {
        /* move the queue elements to the start of data array */
        q->data[i] = q->data[q->rptr];
        if (++q->rptr == 256) {
            q->rptr = 0;
    /* reset rptr/wptr/count */
    q->rptr = 0;
    q->wptr = size;
    q->count = size;
    ps2->update_irq(ps2->update_arg, q->count != 0);

    return 0;
Any problem? Thanks.

Best regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]