qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 4/6] hw/ds1338.c: Ensure state is properly in


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v2 4/6] hw/ds1338.c: Ensure state is properly initialized.
Date: Wed, 12 Dec 2012 13:02:17 +0000

On 12 December 2012 12:46, Antoine Mathys <address@hidden> wrote:
> On 12/12/2012 01:05 PM, Peter Maydell wrote:
>> I think we need to reset ptr and addr_byte too...
>
> The initial value of the register pointer is unspecified.
>
> addr_byte is only used when receiving user data. It is written in
> ds1338_event() then read in ds1338_send(). Setting it in ds1338_reset() is
> unnecessary and would break encapsulation.

It's true that it probably doesn't make much difference, but
both the addr_byte and ptr are part of the migration state
listed in the vmstate struct. I think it is cleaner and
more straightforward to reason about if resetting the
device returns it to an exact known state. The state may be
undefined according to the specification but that doesn't
mean that our implementation has to leave it undefined.

I don't understand your point about encapsulation -- these
are both fields of the device state, and ds1338_reset()
is a method of the device and has every right to access
them.

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]