Patchwork [08/11] Add scoop post_load callback that sets IRQs to loaded levels

login
register
mail settings
Submitter Dmitry Eremin-Solenikov
Date Jan. 31, 2011, 3:20 p.m.
Message ID <1296487250-28254-8-git-send-email-dbaryshkov@gmail.com>
Download mbox | patch
Permalink /patch/81172/
State New
Headers show

Comments

Dmitry Eremin-Solenikov - Jan. 31, 2011, 3:20 p.m.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 hw/zaurus.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
andrzej zaborowski - Feb. 11, 2011, 12:57 a.m.
Hi Dmitry,

On 31 January 2011 16:20, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
>  hw/zaurus.c |   19 ++++++++++++++++++-
>  1 files changed, 18 insertions(+), 1 deletions(-)
>
> diff --git a/hw/zaurus.c b/hw/zaurus.c
> index fca11a5..90fedc9 100644
> --- a/hw/zaurus.c
> +++ b/hw/zaurus.c
> @@ -181,17 +181,34 @@ static int scoop_init(SysBusDevice *dev)
>     return 0;
>  }
>
> +static int scoop_post_load(void *opaque, int version_id)
> +{
> +    ScoopInfo *s = (ScoopInfo *) opaque;
> +    int i;
> +    uint32_t level;
> +
> +    level = s->gpio_level & s->gpio_dir;
> +
> +    for (i = 1; i < 1 << 16; i <<= 1) {
> +        qemu_set_irq(s->handler[i], level & i);

This looks like it's going to try to set s->handler[1] up to
s->handler[32k] (should be 0 to 15), otherwise this patch is a good
catch.

Cheers
Dmitry Eremin-Solenikov - Feb. 11, 2011, 10:27 p.m.
On 2/11/11, andrzej zaborowski <balrogg@gmail.com> wrote:
> Hi Dmitry,
>
> On 31 January 2011 16:20, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> wrote:
>> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
>> ---
>>  hw/zaurus.c |   19 ++++++++++++++++++-
>>  1 files changed, 18 insertions(+), 1 deletions(-)
>>
>> diff --git a/hw/zaurus.c b/hw/zaurus.c
>> index fca11a5..90fedc9 100644
>> --- a/hw/zaurus.c
>> +++ b/hw/zaurus.c
>> @@ -181,17 +181,34 @@ static int scoop_init(SysBusDevice *dev)
>>     return 0;
>>  }
>>
>> +static int scoop_post_load(void *opaque, int version_id)
>> +{
>> +    ScoopInfo *s = (ScoopInfo *) opaque;
>> +    int i;
>> +    uint32_t level;
>> +
>> +    level = s->gpio_level & s->gpio_dir;
>> +
>> +    for (i = 1; i < 1 << 16; i <<= 1) {
>> +        qemu_set_irq(s->handler[i], level & i);
>
> This looks like it's going to try to set s->handler[1] up to
> s->handler[32k] (should be 0 to 15), otherwise this patch is a good
> catch.

Oops. Fixed in a resent patch.

Patch

diff --git a/hw/zaurus.c b/hw/zaurus.c
index fca11a5..90fedc9 100644
--- a/hw/zaurus.c
+++ b/hw/zaurus.c
@@ -181,17 +181,34 @@  static int scoop_init(SysBusDevice *dev)
     return 0;
 }
 
+static int scoop_post_load(void *opaque, int version_id)
+{
+    ScoopInfo *s = (ScoopInfo *) opaque;
+    int i;
+    uint32_t level;
+
+    level = s->gpio_level & s->gpio_dir;
+
+    for (i = 1; i < 1 << 16; i <<= 1) {
+        qemu_set_irq(s->handler[i], level & i);
+    }
+
+    s->prev_level = level;
+
+    return 0;
+}
+
 static bool is_version_0 (void *opaque, int version_id)
 {
     return version_id == 0;
 }
 
-
 static const VMStateDescription vmstate_scoop_regs = {
     .name = "scoop",
     .version_id = 1,
     .minimum_version_id = 0,
     .minimum_version_id_old = 0,
+    .post_load = scoop_post_load,
     .fields = (VMStateField []) {
         VMSTATE_UINT16(status, ScoopInfo),
         VMSTATE_UINT16(power, ScoopInfo),