From owner-freebsd-bugs Wed Jun 7 19:10:04 1995 Return-Path: bugs-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id TAA26826 for bugs-outgoing; Wed, 7 Jun 1995 19:10:04 -0700 Received: (from gnats@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id TAA26819 ; Wed, 7 Jun 1995 19:10:03 -0700 Date: Wed, 7 Jun 1995 19:10:03 -0700 Message-Id: <199506080210.TAA26819@freefall.cdrom.com> From: Akira SAWADA Reply-To: Akira SAWADA To: freebsd-bugs Subject: i386/498: bug in checking RTC status at initialization In-Reply-To: Your message of Thu, 08 Jun 1995 11:01:50 +0900 <199506080201.LAA28549@azalea.zoo.ncl.omron.co.jp> Sender: bugs-owner@FreeBSD.org Precedence: bulk >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: