All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
To: Thomas Huth <th.huth@posteo.de>,
	qemu-devel@nongnu.org, laurent@vivier.eu
Cc: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org,
	jasowang@redhat.com, dgilbert@redhat.com, mreitz@redhat.com,
	hpoussin@reactos.org, kraxel@redhat.com, pbonzini@redhat.com,
	yongbok.kim@mips.com, aurelien@aurel32.net
Subject: Re: [Qemu-devel] [PATCH v4 02/11] hw/m68k: implement ADB bus support for via
Date: Thu, 25 Oct 2018 21:20:35 +0100	[thread overview]
Message-ID: <e86ff3a4-824c-fcff-f743-583ee909b169@ilande.co.uk> (raw)
In-Reply-To: <ab0a9972-57a5-1d97-22f4-13c5c58248bc@posteo.de>

On 23/10/2018 07:49, Thomas Huth wrote:

> On 2018-10-18 19:28, Mark Cave-Ayland wrote:
>> From: Laurent Vivier <laurent@vivier.eu>
>>
>> Co-developed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
>> ---
>>  hw/input/adb.c            |   2 +
>>  hw/misc/mac_via.c         | 166 ++++++++++++++++++++++++++++++++++++++++++++++
>>  include/hw/misc/mac_via.h |   7 ++
>>  3 files changed, 175 insertions(+)
>>
>> diff --git a/hw/input/adb.c b/hw/input/adb.c
>> index bbb40aeef1..d69ca74364 100644
>> --- a/hw/input/adb.c
>> +++ b/hw/input/adb.c
>> @@ -25,6 +25,8 @@
>>  #include "hw/input/adb.h"
>>  #include "adb-internal.h"
>>  
>> +#define ADB_POLL_FREQ 50
> 
> A single define without a user in a .c file? Looks suspicious...
> 
> As far as I can see, this has been replace by VIA_ADB_POLL_FREQ which
> has been introduced in the previous patch already, so you can remove
> this define here.

Ooops yes, this should have been removed from my previous refactoring - I've now
fixed this.

>>  /* error codes */
>>  #define ADB_RET_NOTPRESENT (-2)
>>  
>> diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c
>> index 084974a24d..1ec563a707 100644
>> --- a/hw/misc/mac_via.c
>> +++ b/hw/misc/mac_via.c
> [...]
>> +static int adb_via_send(MacVIAState *s, int state, uint8_t data)
>> +{
>> +    switch (state) {
>> +    case ADB_STATE_NEW:
>> +        s->adb_data_out_index = 0;
>> +        break;
>> +    case ADB_STATE_EVEN:
>> +        if ((s->adb_data_out_index & 1) == 0) {
>> +            return 0;
>> +        }
>> +        break;
>> +    case ADB_STATE_ODD:
>> +        if (s->adb_data_out_index & 1) {
>> +            return 0;
>> +        }
>> +        break;
>> +    case ADB_STATE_IDLE:
>> +        return 0;
>> +    }
> 
> Could you please add a
> 
>  assert(s->adb_data_out_index < sizeof(s->adb_data_out) -1);
> 
> here, just in case?

Done.

>> +    s->adb_data_out[s->adb_data_out_index++] = data;
>> +    qemu_irq_raise(s->adb_data_ready);
>> +    return 1;
>> +}
>> +
>> +static int adb_via_receive(MacVIAState *s, int state, uint8_t *data)
>> +{
>> +    switch (state) {
>> +    case ADB_STATE_NEW:
>> +        return 0;
>> +    case ADB_STATE_EVEN:
>> +        if (s->adb_data_in_size <= 0) {
>> +            qemu_irq_raise(s->adb_data_ready);
>> +            return 0;
>> +        }
>> +        if (s->adb_data_in_index >= s->adb_data_in_size) {
>> +            *data = 0;
>> +            qemu_irq_raise(s->adb_data_ready);
>> +            return 1;
>> +        }
>> +        if ((s->adb_data_in_index & 1) == 0) {
>> +            return 0;
>> +        }
>> +        break;
>> +    case ADB_STATE_ODD:
>> +        if (s->adb_data_in_size <= 0) {
>> +            qemu_irq_raise(s->adb_data_ready);
>> +            return 0;
>> +        }
>> +        if (s->adb_data_in_index >= s->adb_data_in_size) {
>> +            *data = 0;
>> +            qemu_irq_raise(s->adb_data_ready);
>> +            return 1;
>> +        }
>> +        if (s->adb_data_in_index & 1) {
>> +            return 0;
>> +        }
>> +        break;
>> +    case ADB_STATE_IDLE:
>> +        if (s->adb_data_out_index == 0) {
>> +            return 0;
>> +        }
>> +        s->adb_data_in_size = adb_request(&s->adb_bus, s->adb_data_in,
>> +                                          s->adb_data_out,
>> +                                          s->adb_data_out_index);
>> +        s->adb_data_out_index = 0;
>> +        s->adb_data_in_index = 0;
>> +        if (s->adb_data_in_size < 0) {
>> +            *data = 0xff;
>> +            qemu_irq_raise(s->adb_data_ready);
>> +            return -1;
>> +        }
>> +        if (s->adb_data_in_size == 0) {
>> +            return 0;
>> +        }
>> +        break;
>> +    }
> 
> Please also add an assert before the next line here - just in case...

And also done here.

>> +    *data = s->adb_data_in[s->adb_data_in_index++];
>> +    qemu_irq_raise(s->adb_data_ready);
>> +    if (*data == 0xff || *data == 0) {
>> +        return 0;
>> +    }
>> +    return 1;
>> +}


ATB,

Mark.

  reply	other threads:[~2018-10-25 20:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-18 18:28 [Qemu-devel] [PATCH v4 00/11] hw/m68k: add Apple Machintosh Quadra 800 machine Mark Cave-Ayland
2018-10-18 18:28 ` [Qemu-devel] [PATCH v4 01/11] hw/m68k: add via support Mark Cave-Ayland
2018-10-23  6:22   ` Thomas Huth
2018-10-25 20:19     ` Mark Cave-Ayland
2018-10-18 18:28 ` [Qemu-devel] [PATCH v4 02/11] hw/m68k: implement ADB bus support for via Mark Cave-Ayland
2018-10-23  6:49   ` Thomas Huth
2018-10-25 20:20     ` Mark Cave-Ayland [this message]
2018-10-18 18:28 ` [Qemu-devel] [PATCH v4 03/11] escc: introduce a selector for the register bit Mark Cave-Ayland
2018-10-18 18:28 ` [Qemu-devel] [PATCH v4 04/11] hw/m68k: add macfb video card Mark Cave-Ayland
2018-10-23  7:13   ` Thomas Huth
2018-10-25 20:27     ` Mark Cave-Ayland
2018-10-18 18:28 ` [Qemu-devel] [PATCH v4 05/11] hw/m68k: Apple Sound Chip (ASC) emulation Mark Cave-Ayland
2018-10-23  7:18   ` Thomas Huth
2018-10-25 20:29     ` Mark Cave-Ayland
2018-10-18 18:28 ` [Qemu-devel] [PATCH v4 06/11] ESP: add pseudo-DMA as used by Macintosh Mark Cave-Ayland
2018-10-18 18:28 ` [Qemu-devel] [PATCH v4 07/11] hw/m68k: add Nubus support Mark Cave-Ayland
2018-10-23  7:36   ` Thomas Huth
2018-10-25 20:30     ` Mark Cave-Ayland
2018-10-18 18:28 ` [Qemu-devel] [PATCH v4 08/11] hw/m68k: add Nubus support for macfb video card Mark Cave-Ayland
2018-10-18 18:28 ` [Qemu-devel] [PATCH v4 09/11] hw/m68k: add a dummy SWIM floppy controller Mark Cave-Ayland
2018-10-18 18:28 ` [Qemu-devel] [PATCH v4 10/11] dp8393x: manage big endian bus Mark Cave-Ayland
2018-10-23  0:02   ` Philippe Mathieu-Daudé
2018-10-18 18:28 ` [Qemu-devel] [PATCH v4 11/11] hw/m68k: define Macintosh Quadra 800 Mark Cave-Ayland
2018-10-23 11:20   ` Thomas Huth
2018-10-25 20:36     ` Mark Cave-Ayland
2018-10-23 13:16   ` Philippe Mathieu-Daudé
2018-10-25 20:39     ` Mark Cave-Ayland
2018-10-18 18:49 ` [Qemu-devel] [PATCH v4 00/11] hw/m68k: add Apple Machintosh Quadra 800 machine Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e86ff3a4-824c-fcff-f743-583ee909b169@ilande.co.uk \
    --to=mark.cave-ayland@ilande.co.uk \
    --cc=aurelien@aurel32.net \
    --cc=dgilbert@redhat.com \
    --cc=famz@redhat.com \
    --cc=hpoussin@reactos.org \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=th.huth@posteo.de \
    --cc=yongbok.kim@mips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.