qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Anthony PERARD <anthony.perard@citrix.com>
Cc: QEMU-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] e1000: Handle IO Port.
Date: Mon, 27 Jun 2011 19:07:55 +0100	[thread overview]
Message-ID: <BANLkTimHE7GxT-zB9OZR1XaprNQ-kkeciA@mail.gmail.com> (raw)
In-Reply-To: <1309192483-32468-1-git-send-email-anthony.perard@citrix.com>

On 27 June 2011 17:34, Anthony PERARD <anthony.perard@citrix.com> wrote:
> @@ -83,6 +86,8 @@ typedef struct E1000State_st {
>     NICState *nic;
>     NICConf conf;
>     int mmio_index;
> +    int ioport_base;
> +    uint32_t ioport_reg[2];

I think ioport_reg[] needs to go in the VMStateDescription as well.
I don't know enough about the PCI subsystem to know whether that's
also true of ioport_base or whether the the map function is called
again on a vmload.

> @@ -202,6 +201,11 @@ rxbufsize(uint32_t v)
>  static void
>  set_ctrl(E1000State *s, int index, uint32_t val)
>  {
> +    DBGOUT(IO, "set ctrl = %08x\n", val);
> +    if (val & E1000_CTRL_RST) {
> +        s->mac_reg[CTRL] = val;
> +        e1000_reset(s);
> +    }

There doesn't seem to be much point in setting mac_reg[CTRL]
when e1000_reset() is going to put it to its reset value anyway;
and you almost certainly don't want to fall through to this:

>     /* RST is self clearing */
>     s->mac_reg[CTRL] = val & ~E1000_CTRL_RST;

...which means there's no need for that bit to special case RST.

>  static void
> +e1000_ioport_writel(void *opaque, uint32_t addr, uint32_t val)
> +{
> +    E1000State *s = opaque;
> +
> +    if (addr == s->ioport_base + REG_IOADDR) {
> +        DBGOUT(IO, "e1000_ioport_writel write base: 0x%04x\n", val);
> +        s->ioport_reg[REG_IOADDR] = val & 0xfffff;
> +    } else if (addr == (s->ioport_base + REG_IODATA)) {
> +        unsigned int index = (s->ioport_reg[REG_IOADDR] & 0x1ffff) >> 2;
> +
> +        DBGOUT(IO, "e1000_ioport_writel %x: 0x%04x\n", index, val);
> +
> +        if (index < NWRITEOPS && macreg_writeops[index]) {
> +            macreg_writeops[index](s, index, val);
> +        } else if (index < NREADOPS && macreg_readops[index]) {
> +            DBGOUT(IO, "e1000_ioport_writel RO %x: 0x%04x\n", index << 2, val);
> +        } else {
> +            DBGOUT(UNKNOWN, "IO unknown write index=0x%08x,val=0x%08x\n",
> +                   index, val);
> +        }

This part of this function seems to be duplicating the code in
e1000_mmio_writel: wouldn't it be cleaner just to call that function?
Ditto readl.

-- PMM

  reply	other threads:[~2011-06-27 18:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-27 16:34 [Qemu-devel] [PATCH] e1000: Handle IO Port Anthony PERARD
2011-06-27 18:07 ` Peter Maydell [this message]
2011-06-28  5:49   ` Paolo Bonzini
2011-06-30 18:45     ` Anthony PERARD
2011-06-30 18:37   ` Anthony PERARD
  -- strict thread matches above, loose matches on Subject: below --
2010-10-12 13:58 anthony.perard

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=BANLkTimHE7GxT-zB9OZR1XaprNQ-kkeciA@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=anthony.perard@citrix.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).