From: Michael Davidsaver <mdavidsaver@gmail.com>
To: Paul Brook <paul@codesourcery.com>,
Peter Maydell <peter.maydell@linaro.org>,
Antoine Mathys <barsamin@gmail.com>
Cc: David Gibson <david@gibson.dropbear.id.au>,
qemu-devel@nongnu.org, Michael Davidsaver <mdavidsaver@gmail.com>
Subject: [Qemu-devel] [PATCH 1/5] timer: ds1338 add magic reset for test code
Date: Sun, 18 Feb 2018 20:03:38 -0800 [thread overview]
Message-ID: <20180219040342.12686-2-mdavidsaver@gmail.com> (raw)
In-Reply-To: <20180219040342.12686-1-mdavidsaver@gmail.com>
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 <mdavidsaver@gmail.com>
---
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
next prev parent reply other threads:[~2018-02-19 4:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-19 4:03 [Qemu-devel] [PATCH 0/5] Generalize Dallas/Maxim I2C RTC devices Michael Davidsaver
2018-02-19 4:03 ` Michael Davidsaver [this message]
2018-02-19 4:03 ` [Qemu-devel] [PATCH 2/5] tests: more thorough test of ds1338 Michael Davidsaver
2018-02-19 7:39 ` Thomas Huth
2018-02-20 17:44 ` Michael Davidsaver
2018-03-24 19:39 ` Michael Davidsaver
2018-04-05 10:15 ` Thomas Huth
2018-02-19 4:03 ` [Qemu-devel] [PATCH 3/5] timer: generalize Dallas/Maxim RTC i2c devices Michael Davidsaver
2018-02-22 17:13 ` Peter Maydell
2018-02-19 4:03 ` [Qemu-devel] [PATCH 4/5] tests: ds-rtc-i2c-test test 12 hour mode and DoW Michael Davidsaver
2018-02-19 4:03 ` [Qemu-devel] [PATCH 5/5] tests: drop ds1338-test Michael Davidsaver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180219040342.12686-2-mdavidsaver@gmail.com \
--to=mdavidsaver@gmail.com \
--cc=barsamin@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=paul@codesourcery.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).