[Qemu-devel] [PATCH] hw/ds1338.c: implement clock enable/disable (CH bit)

2013-02-16 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c | 156 --- 1 file changed, 95 insertions(+), 61 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index 1da0f96..5a93fb6 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -48,17 +48,32

Re: [Qemu-devel] [PATCH] Fix conversion between 12 hours and 24 hours modes.

2013-02-15 Thread Antoine Mathys
On 02/15/2013 12:24 PM, Andreas Färber wrote: The expected answer would've been "take guest X and do Y to see Z", or better to extend the existing qtest cases to prove something was broken before and fixed afterwards and to avoid the same bug being reintroduced later. If we are talking about ad

Re: [Qemu-devel] [PATCH] Fix conversion between 12 hours and 24 hours modes.

2013-02-14 Thread Antoine Mathys
First, the ds1338 code was in a poor state and never handled the 12 hour clock correctly. My first patch failed to fully fix the problem so I had to write a second one, but at no point did Peter or I introduce a regression, quite the opposite. Second, I don't know where you got the idea that I

Re: [Qemu-devel] [PATCH] hw/mc146818rtc.c: Fix reading and writing of time registers

2013-02-14 Thread Antoine Mathys
On 02/14/2013 10:30 AM, Paolo Bonzini wrote: Nice. Do you have a testcase? No, but the refactoring makes the code very easy to audit. Please also test this patch with the two rtc-test patches at http://thread.gmane.org/gmane.comp.emulators.qemu/188244. I did and the tests pass.

[Qemu-devel] [PATCH] hw/mc146818rtc.c: Fix reading and writing of time registers

2013-02-13 Thread Antoine Mathys
This patch consolidates the bit twidling involved in reading and writing the time registers to four functions that are used consistently. This also has the effect of fixing bug 1090558. Signed-off-by: Antoine Mathys --- hw/mc146818rtc.c | 163

[Qemu-devel] [PATCH] Fix conversion between 12 hours and 24 hours modes.

2012-12-14 Thread Antoine Mathys
The proper mapping between 24 hours and 12 hours modes is: 0 12 AM 1-111-11 AM 12 12 PM 13-23 1-11 PM Fix code accordingly. Signed-off-by: Antoine Mathys --- hw/ds1338.c |8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c

[Qemu-devel] [Bug 1090558] [NEW] hw/mc146818: error reading RTC_HOURS_ALARM

2012-12-14 Thread Antoine Mathys
Public bug reported: get_next_alarm() doesn't read the RTC_HOURS_ALARM field correctly. - Bit 7 must be masked before conversion from BCD. - Care must be taken to check the don't care condition before masking. - The PM bit must be read from RTC_HOURS_ALARM, not from RTC_HOURS (as is done in conv

Re: [Qemu-devel] [PATCH v4 0/6] hw/ds1338.c

2012-12-14 Thread Antoine Mathys
On 12/13/2012 03:09 PM, Peter Maydell wrote: I certainly will send further patches. As you noticed I am new to git. Thanks for your patience and advice.

[Qemu-devel] [PATCH v4 5/6] hw/ds1338.c: Implement support for the control register.

2012-12-12 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index d2f52fc..94a2f54 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -125,7 +125,8 @@ static int ds1338_send(I2CSlave *i2c, uint8_t

[Qemu-devel] [PATCH v4 6/6] hw/ds1338.c: Fix handling of DAY (wday) register.

2012-12-12 Thread Antoine Mathys
Per the datasheet, the DAY (wday) register is user defined. Implement this. Signed-off-by: Antoine Mathys --- hw/ds1338.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index 94a2f54..1aefa3b 100644 --- a/hw/ds1338.c +++ b/hw

[Qemu-devel] [PATCH v4 4/6] hw/ds1338.c: Ensure state is properly initialized.

2012-12-12 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c | 12 1 file changed, 12 insertions(+) diff --git a/hw/ds1338.c b/hw/ds1338.c index 0f88720..d2f52fc 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -179,6 +179,17 @@ static int ds1338_init(I2CSlave *i2c) return 0; } +static

[Qemu-devel] [PATCH v4 3/6] hw/ds1338.c: Fix handling of HOURS register.

2012-12-12 Thread Antoine Mathys
Per the datasheet, the mapping between 12 and 24 hours modes is: 0 <-> 12 PM 1-12 <-> 1-12 AM 13-23 <-> 1-11 PM Signed-off-by: Antoine Mathys --- hw/ds1338.c | 29 ++--- 1 file changed, 18 insertions(+), 11 deletions(-

[Qemu-devel] [PATCH v4 2/6] hw/ds1338.c: Add definitions for various flags in the RTC registers.

2012-12-12 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/hw/ds1338.c b/hw/ds1338.c index faaa4a0..69018bc 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -17,6 +17,12 @@ */ #define NVRAM_SIZE 64 +/* Flags definitions */ +#define SECONDS_CH

[Qemu-devel] [PATCH v4 1/6] hw/ds1338.c: Correct bug in conversion to BCD.

2012-12-12 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index b576d56..faaa4a0 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -57,9 +57,9 @@ static void capture_current_time(DS1338State *s) } else

[Qemu-devel] [PATCH v4 0/6] hw/ds1338.c

2012-12-12 Thread Antoine Mathys

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

2012-12-12 Thread Antoine Mathys
Oops. There was a problem in the patch. Resending the series.

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

2012-12-12 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c | 51 ++- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index b576d56..d2f52fc 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -17,6 +17,12 @@ */ #define

Re: [Qemu-devel] [PATCH v3 6/6] hw/ds1338.c: Fix handling of DAY (wday) register.

2012-12-12 Thread Antoine Mathys
Per the datasheet, the DAY (wday) register is user defined. Implement this. Signed-off-by: Antoine Mathys --- hw/ds1338.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index 94a2f54..1aefa3b 100644 --- a/hw/ds1338.c +++ b/hw

Re: [Qemu-devel] [PATCH v3 3/6] hw/ds1338.c: Fix handling of HOURS register.

2012-12-12 Thread Antoine Mathys
Per the datasheet, the mapping between 12 and 24 hours modes is: 0 <-> 12 PM 1-12 <-> 1-12 AM 13-23 <-> 1-11 PM Signed-off-by: Antoine Mathys --- hw/ds1338.c | 29 ++--- 1 file changed, 18 insertions(+), 11 deletions(-

Re: [Qemu-devel] [PATCH v3 5/6] hw/ds1338.c: Implement support for the control register.

2012-12-12 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index d2f52fc..94a2f54 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -125,7 +125,8 @@ static int ds1338_send(I2CSlave *i2c, uint8_t

Re: [Qemu-devel] [PATCH v3 1/6] hw/ds1338.c: Correct bug in conversion to BCD.

2012-12-12 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index b576d56..faaa4a0 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -57,9 +57,9 @@ static void capture_current_time(DS1338State *s) } else

Re: [Qemu-devel] [PATCH v3 2/6] hw/ds1338.c: Add definitions for various flags in, the RTC registers.

2012-12-12 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/hw/ds1338.c b/hw/ds1338.c index faaa4a0..69018bc 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -17,6 +17,12 @@ */ #define NVRAM_SIZE 64 +/* Flags definitions */ +#define SECONDS_CH

[Qemu-devel] [PATCH v3 0/6] hw/ds1338.c

2012-12-12 Thread Antoine Mathys

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

2012-12-12 Thread Antoine Mathys
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 undefi

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

2012-12-12 Thread Antoine Mathys
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

[Qemu-devel] [PATCH v2 6/6] hw/ds1338.c: Fix handling of DAY (wday) register.

2012-12-11 Thread Antoine Mathys
Per the datasheet, the DAY (wday) register is user defined. Implement this. Signed-off-by: Antoine Mathys --- hw/ds1338.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index 319c341..c5cee99 100644 --- a/hw/ds1338.c +++ b/hw

[Qemu-devel] [PATCH v2 5/6] hw/ds1338.c: Implement support for the control register.

2012-12-11 Thread Antoine Mathys
The previous patch has the side effect of clearing the control register. That's already its proper power-on-reset value. Signed-off-by: Antoine Mathys --- hw/ds1338.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c

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

2012-12-11 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/hw/ds1338.c b/hw/ds1338.c index 0f88720..b4d5b74 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -179,6 +179,15 @@ static int ds1338_init(I2CSlave *i2c) return 0; } +static void

[Qemu-devel] [PATCH v2 3/6] hw/ds1338.c: Fix handling of HOURS register.

2012-12-11 Thread Antoine Mathys
Per the datasheet, the mapping between 12 and 24 hours modes is: 0 <-> 12 PM 1-12 <-> 1-12 AM 13-23 <-> 1-11 PM Signed-off-by: Antoine Mathys --- hw/ds1338.c | 29 ++--- 1 file changed, 18 insertions(+), 11 deletions(-

[Qemu-devel] [PATCH v2 2/6] hw/ds1338.c: Add definitions for various flags in the RTC registers.

2012-12-11 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/hw/ds1338.c b/hw/ds1338.c index faaa4a0..69018bc 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -17,6 +17,12 @@ */ #define NVRAM_SIZE 64 +/* Flags definitions */ +#define SECONDS_CH

[Qemu-devel] [PATCH v2 1/6] hw/ds1338.c: Correct bug in conversion to BCD.

2012-12-11 Thread Antoine Mathys
Signed-off-by: Antoine Mathys --- hw/ds1338.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index b576d56..faaa4a0 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -57,9 +57,9 @@ static void capture_current_time(DS1338State *s) } else

[Qemu-devel] [PATCH v2 0/6] hw/ds1338.c

2012-12-11 Thread Antoine Mathys
This is the second version of my series of patch to hw/ds1338.c It should address the various points that were made. The main difference with the previous version is that I dropped some stuff that will only be useful once we implement clock enable/disable.

Re: [Qemu-devel] [PATCH 1/4] hw/ds1338.c: Fix handling of HOURS register.

2012-12-04 Thread Antoine Mathys
On 12/04/2012 06:42 PM, Peter Maydell wrote: This looks good as far as the logic goes, but I think we could use some symbolic constants for the 12-hour and PM bits rather than all the literal 0x20 0x40 0x60. thanks -- PMM I refrained from using symbolic constants for three reasons: 1. You need

[Qemu-devel] [PATCH 5/?] hw/ds1338.c: Fix handling of DATE (wday) register

2012-12-03 Thread Antoine Mathys
Per the datasheet, the DATE (wday) register is user defined. Implement this. Signed-off-by: Antoine Mathys --- hw/ds1338.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index 8f85635..c502934 100644 --- a/hw/ds1338.c +++ b/hw

[Qemu-devel] [PATCH 4/4] hw/ds1338.c: Handle stuck bits and preserve CH

2012-12-02 Thread Antoine Mathys
supposed to set these bits it is safer to check anyway. In order not to duplicate this logic I thus chose to enforce it at read time. Note that currently we don't preserve what the user sends in (2). We will have to once we support stopping the clock (CH bit). Signed-off-by: Antoine Mathys --

[Qemu-devel] [PATCH 3/4] hw/ds1338.c: ensure OSF can only be cleared

2012-12-02 Thread Antoine Mathys
Per the datasheet, the OSF bit in the control register can only be cleared. Attempts to set it have no effect. Implement this. Signed-off-by: Antoine Mathys --- hw/ds1338.c |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index 1fb152e

[Qemu-devel] [PATCH 2/4] hw/ds1338.c: Minor fixes

2012-12-02 Thread Antoine Mathys
Minor fixes in the handling of the RTC registers. Signed-off-by: Antoine Mathys --- hw/ds1338.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/ds1338.c b/hw/ds1338.c index 1274b22..1fb152e 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -62,9 +62,9

[Qemu-devel] [PATCH 1/4] hw/ds1338.c: Fix handling of HOURS register.

2012-12-02 Thread Antoine Mathys
Per the datasheet, the mapping between 12 and 24 hours modes is: 0 <-> 12 PM 1-12 <-> 1-12 AM 13-23 <-> 1-11 PM Signed-off-by: Antoine Mathys --- hw/ds1338.c | 23 +++ 1 file changed, 15 insertions(+), 8 deletions(-) diff --git