Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Jun 1995 19:10:03 -0700
From:      Akira SAWADA <sawada@zoo.ncl.omron.co.jp>
To:        freebsd-bugs
Subject:   i386/498: bug in checking RTC status at initialization
Message-ID:  <199506080210.TAA26819@freefall.cdrom.com>
In-Reply-To: Your message of Thu, 08 Jun 1995 11:01:50 %2B0900 <199506080201.LAA28549@azalea.zoo.ncl.omron.co.jp>

next in thread | previous in thread | raw e-mail | index | archive | help

>Number:         498
>Category:       i386
>Synopsis:       bug in checking RTC status at initialization
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs (FreeBSD bugs mailing list)
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun  7 19:10:02 1995
>Originator:     Akira SAWADA
>Organization:
OMRON Corporation
>Release:        FreeBSD 2.0.950412-SNAP i386
>Environment:

IBM PS/55 note

>Description:

At boot time, kernel always says:
Invalid time in real time clock.
Check and reset the date immediately!

In inittodr() of sys/i386/isa/clock.c:
        /* Look if we have a RTC present and the time is valid */
        if (rtcin(RTC_STATUSD) != RTCSD_PWR)
                goto wrong_time;

This RTC status check is failed,
because rtcin(RTC_STATUSD) returns 0x82.

In sys/i386/isa/rtc.h:
#define RTC_STATUSD     0x0d    /* status register D (R) Lost Power */
#define  RTCSD_PWR       0x80   /* clock lost power */

To check the RTC status, 
we should check only the MSB bit of rtcin(RTC_STATUSD).
According to the system manual of PS/55 note,
the lower 7 bits are system reserved.

>How-To-Repeat:

Always at boot time.

>Fix:

The above line:
        if (rtcin(RTC_STATUSD) != RTCSD_PWR)
shuould be
        if ((rtcin(RTC_STATUSD) & RTCSD_PWR) != RTCSD_PWR)
or
        if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))

The corresponding lines in NetBSD-current are here:

(in rtcget() of sys/arch/i386/isa/clock.c)
        if (mc146818_read(NULL, MC_REGD) & MC_REGD_VRT == 0) /* XXX softc */
                return (-1);

(in sys/dev/ic/mc146818.h)
#define MC_REGD         0xd     /* Control register D */

/*       MC_REGD_UNUSED 0x7f    UNUSED */
#define  MC_REGD_VRT    0x80    /* Valid RAM and Time bit */

Thanks in advance.
>Audit-Trail:
>Unformatted:




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199506080210.TAA26819>