qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, paul@codesourcery.com
Subject: Re: [Qemu-devel] [PATCH] Realview/Versatile: Export LED state
Date: Fri, 11 Jan 2013 15:58:04 +0100	[thread overview]
Message-ID: <50F0287C.1010708@suse.de> (raw)
In-Reply-To: <1357911723-12688-1-git-send-email-wolfgang.mauerer@siemens.com>

Hello,

Am 11.01.2013 14:42, schrieb Wolfgang Mauerer:
> The configuration register for the onboard LEDs is
> emulated, but the state is not exported, which makes
> the feature not particularly useful. Create a character
> device to make status changes accessible to the host.
> 
> For example, use the command line argument
> 
> -chardev socket,id=leds,host=localhost,port=12345,server,nowait
> 
> to observe status changes via a socket.
> 
> Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
> ---
>  hw/arm_sysctl.c |   24 ++++++++++++++++++++++++
>  1 files changed, 24 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c
> index b733617..7cb8559 100644
> --- a/hw/arm_sysctl.c
> +++ b/hw/arm_sysctl.c
> @@ -19,6 +19,7 @@ typedef struct {
>      SysBusDevice busdev;
>      MemoryRegion iomem;
>      qemu_irq pl110_mux_ctrl;
> +    CharDriverState *display;
>  
>      uint32_t sys_id;
>      uint32_t leds;
> @@ -92,6 +93,24 @@ static void arm_sysctl_reset(DeviceState *d)
>      }
>  }
>  
> +static void notify_led_change(CharDriverState *chr, uint32_t old, uint32_t new)
> +{
> +    uint32_t changed;
> +    unsigned int i;
> +
> +    if (chr == NULL) {
> +        return;
> +    }
> +
> +    changed = old ^ new;
> +    for (i = 0; i < 8; i++) {
> +        if (changed & (1 << i)) {
> +            qemu_chr_fe_printf(chr, "%u:%s\r\n", i,
> +                               new & (1 << i) ? "on" : "off");

Instead of inventing a custom text-based protocol, would exposing a bool
QOM property per LED be an option? What exactly are you trying to do
with the state?

> +        }
> +    }
> +}
> +
>  static uint64_t arm_sysctl_read(void *opaque, hwaddr offset,
>                                  unsigned size)
>  {
> @@ -198,6 +217,7 @@ static void arm_sysctl_write(void *opaque, hwaddr offset,
>  
>      switch (offset) {
>      case 0x08: /* LED */
> +        notify_led_change(s->display, s->leds, (uint32_t)val);
>          s->leds = val;
>      case 0x0c: /* OSC0 */
>      case 0x10: /* OSC1 */
> @@ -386,6 +406,10 @@ static int arm_sysctl_init(SysBusDevice *dev)
>  {
>      arm_sysctl_state *s = FROM_SYSBUS(arm_sysctl_state, dev);
>  
> +    s->display = qemu_chr_new("leds0", "chardev:leds", NULL);
> +    if (s->display) {

Can this ever be NULL?

> +        qemu_chr_fe_printf(s->display, "8 LEDs available\r\n");
> +    }
>      memory_region_init_io(&s->iomem, &arm_sysctl_ops, s, "arm-sysctl", 0x1000);
>      sysbus_init_mmio(dev, &s->iomem);
>      qdev_init_gpio_in(&s->busdev.qdev, arm_sysctl_gpio_set, 2);

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2013-01-11 14:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11 13:42 [Qemu-devel] [PATCH] Realview/Versatile: Export LED state Wolfgang Mauerer
2013-01-11 14:58 ` Andreas Färber [this message]
2013-01-11 15:46   ` Wolfgang Mauerer
2013-01-11 15:00 ` Peter Maydell
2013-01-11 15:23   ` Andreas Färber
2013-01-11 15:44     ` Wolfgang Mauerer
2013-01-11 20:22       ` Luiz Capitulino

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=50F0287C.1010708@suse.de \
    --to=afaerber@suse.de \
    --cc=paul@codesourcery.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wolfgang.mauerer@siemens.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 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).