[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/5] timer: ds1338 add magic reset for test code
From: |
Michael Davidsaver |
Subject: |
[Qemu-devel] [PATCH 1/5] timer: ds1338 add magic reset for test code |
Date: |
Sun, 18 Feb 2018 20:03:38 -0800 |
When running w/ QTest, allow the tester
to reliably zero time offsets.
Allows tests to read the current time,
and set time, independent of test order.
Signed-off-by: Michael Davidsaver <address@hidden>
---
hw/timer/ds1338.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c
index 3849b74a68..41c2d7dac6 100644
--- a/hw/timer/ds1338.c
+++ b/hw/timer/ds1338.c
@@ -14,6 +14,7 @@
#include "qemu-common.h"
#include "hw/i2c/i2c.h"
#include "qemu/bcd.h"
+#include "sysemu/qtest.h"
/* Size of NVRAM including both the user-accessible area and the
* secondary register area.
@@ -132,6 +133,14 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
DS1338State *s = DS1338(i2c);
if (s->addr_byte) {
+ if (data == 0xff && qtest_enabled()) {
+ /* magic, out of bounds, address to allow test code
+ * to reset offset
+ */
+ s->offset = 0;
+ s->wday_offset = 0;
+ return 0;
+ }
s->ptr = data & (NVRAM_SIZE - 1);
s->addr_byte = false;
return 0;
--
2.11.0