From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/2] rtc-test: always set register B in its entirety
Date: Fri, 11 Jan 2013 17:46:56 +0100 [thread overview]
Message-ID: <1357922817-17584-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1357922817-17584-1-git-send-email-pbonzini@redhat.com>
Eliminate dependencies between one test and the others.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
tests/rtc-test.c | 36 +++++++++---------------------------
1 file changed, 9 insertions(+), 27 deletions(-)
diff --git a/tests/rtc-test.c b/tests/rtc-test.c
index 02edbf5..7b39831 100644
--- a/tests/rtc-test.c
+++ b/tests/rtc-test.c
@@ -26,11 +26,6 @@ static int bcd2dec(int value)
return (((value >> 4) & 0x0F) * 10) + (value & 0x0F);
}
-static int dec2bcd(int value)
-{
- return ((value / 10) << 4) | (value % 10);
-}
-
static uint8_t cmos_read(uint8_t reg)
{
outb(base + 0, reg);
@@ -182,7 +177,7 @@ static int wiggle = 2;
static void set_year_20xx(void)
{
/* Set BCD mode */
- cmos_write(RTC_REG_B, cmos_read(RTC_REG_B) & ~REG_B_DM);
+ cmos_write(RTC_REG_B, REG_B_24H);
cmos_write(RTC_REG_A, 0x76);
cmos_write(RTC_YEAR, 0x11);
cmos_write(RTC_CENTURY, 0x20);
@@ -230,7 +225,7 @@ static void set_year_20xx(void)
static void set_year_1980(void)
{
/* Set BCD mode */
- cmos_write(RTC_REG_B, cmos_read(RTC_REG_B) & ~REG_B_DM);
+ cmos_write(RTC_REG_B, REG_B_24H);
cmos_write(RTC_REG_A, 0x76);
cmos_write(RTC_YEAR, 0x80);
cmos_write(RTC_CENTURY, 0x19);
@@ -253,32 +248,17 @@ static void set_year_1980(void)
static void bcd_check_time(void)
{
/* Set BCD mode */
- cmos_write(RTC_REG_B, cmos_read(RTC_REG_B) & ~REG_B_DM);
+ cmos_write(RTC_REG_B, REG_B_24H);
check_time(wiggle);
}
static void dec_check_time(void)
{
/* Set DEC mode */
- cmos_write(RTC_REG_B, cmos_read(RTC_REG_B) | REG_B_DM);
+ cmos_write(RTC_REG_B, REG_B_24H | REG_B_DM);
check_time(wiggle);
}
-static void set_alarm_time(struct tm *tm)
-{
- int sec;
-
- sec = tm->tm_sec;
-
- if ((cmos_read(RTC_REG_B) & REG_B_DM) == 0) {
- sec = dec2bcd(sec);
- }
-
- cmos_write(RTC_SECONDS_ALARM, sec);
- cmos_write(RTC_MINUTES_ALARM, RTC_ALARM_DONT_CARE);
- cmos_write(RTC_HOURS_ALARM, RTC_ALARM_DONT_CARE);
-}
-
static void alarm_time(void)
{
struct tm now;
@@ -289,13 +269,15 @@ static void alarm_time(void)
gmtime_r(&ts, &now);
/* set DEC mode */
- cmos_write(RTC_REG_B, cmos_read(RTC_REG_B) | REG_B_DM);
+ cmos_write(RTC_REG_B, REG_B_24H | REG_B_DM);
g_assert(!get_irq(RTC_ISA_IRQ));
cmos_read(RTC_REG_C);
now.tm_sec = (now.tm_sec + 2) % 60;
- set_alarm_time(&now);
+ cmos_write(RTC_SECONDS_ALARM, now.tm_sec);
+ cmos_write(RTC_MINUTES_ALARM, RTC_ALARM_DONT_CARE);
+ cmos_write(RTC_HOURS_ALARM, RTC_ALARM_DONT_CARE);
cmos_write(RTC_REG_B, cmos_read(RTC_REG_B) | REG_B_AIE);
for (i = 0; i < 2 + wiggle; i++) {
@@ -330,7 +312,7 @@ static void fuzz_registers(void)
static void register_b_set_flag(void)
{
/* Enable binary-coded decimal (BCD) mode and SET flag in Register B*/
- cmos_write(RTC_REG_B, (cmos_read(RTC_REG_B) & ~REG_B_DM) | REG_B_SET);
+ cmos_write(RTC_REG_B, REG_B_24H | REG_B_SET);
cmos_write(RTC_REG_A, 0x76);
cmos_write(RTC_YEAR, 0x11);
--
1.8.1
next prev parent reply other threads:[~2013-01-11 16:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-11 16:46 [Qemu-devel] [PATCH 0/2] Improve rtc-test coverage Paolo Bonzini
2013-01-11 16:46 ` Paolo Bonzini [this message]
2013-01-11 16:46 ` [Qemu-devel] [PATCH 2/2] rtc-test: add testcases for alarms in 12hour mode Paolo Bonzini
2013-02-02 12:17 ` [Qemu-devel] [PATCH 0/2] Improve rtc-test coverage Paolo Bonzini
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=1357922817-17584-2-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--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).