From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttg3g-0000Lo-HY for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:58:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ttg3c-0008Dy-UZ for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:58:12 -0500 Received: from cantor2.suse.de ([195.135.220.15]:37102 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttg3c-0008Dk-Lw for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:58:08 -0500 Message-ID: <50F0287C.1010708@suse.de> Date: Fri, 11 Jan 2013 15:58:04 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1357911723-12688-1-git-send-email-wolfgang.mauerer@siemens.com> In-Reply-To: <1357911723-12688-1-git-send-email-wolfgang.mauerer@siemens.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] Realview/Versatile: Export LED state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wolfgang Mauerer Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, paul@codesourcery.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. >=20 > For example, use the command line argument >=20 > -chardev socket,id=3Dleds,host=3Dlocalhost,port=3D12345,server,nowait >=20 > to observe status changes via a socket. >=20 > Signed-off-by: Wolfgang Mauerer > --- > hw/arm_sysctl.c | 24 ++++++++++++++++++++++++ > 1 files changed, 24 insertions(+), 0 deletions(-) >=20 > 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; > =20 > uint32_t sys_id; > uint32_t leds; > @@ -92,6 +93,24 @@ static void arm_sysctl_reset(DeviceState *d) > } > } > =20 > +static void notify_led_change(CharDriverState *chr, uint32_t old, uint= 32_t new) > +{ > + uint32_t changed; > + unsigned int i; > + > + if (chr =3D=3D NULL) { > + return; > + } > + > + changed =3D old ^ new; > + for (i =3D 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 o= ffset, > =20 > switch (offset) { > case 0x08: /* LED */ > + notify_led_change(s->display, s->leds, (uint32_t)val); > s->leds =3D val; > case 0x0c: /* OSC0 */ > case 0x10: /* OSC1 */ > @@ -386,6 +406,10 @@ static int arm_sysctl_init(SysBusDevice *dev) > { > arm_sysctl_state *s =3D FROM_SYSBUS(arm_sysctl_state, dev); > =20 > + s->display =3D 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 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg