From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 19 11:38:37 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE6701065696 for ; Thu, 19 Aug 2010 11:38:37 +0000 (UTC) (envelope-from peterjeremy@acm.org) Received: from mail14.syd.optusnet.com.au (mail14.syd.optusnet.com.au [211.29.132.195]) by mx1.freebsd.org (Postfix) with ESMTP id 4C60E8FC12 for ; Thu, 19 Aug 2010 11:38:36 +0000 (UTC) Received: from server.vk2pj.dyndns.org (c220-239-116-103.belrs4.nsw.optusnet.com.au [220.239.116.103]) by mail14.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o7JBcYWu030911 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 19 Aug 2010 21:38:35 +1000 X-Bogosity: Ham, spamicity=0.000000 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by server.vk2pj.dyndns.org (8.14.4/8.14.4) with ESMTP id o7JBcY1t060813; Thu, 19 Aug 2010 21:38:34 +1000 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.14.4/8.14.4/Submit) id o7JBcX7I060812; Thu, 19 Aug 2010 21:38:33 +1000 (EST) (envelope-from peter) Date: Thu, 19 Aug 2010 21:38:33 +1000 From: Peter Jeremy To: phil hefferan Message-ID: <20100819113833.GA59397@server.vk2pj.dyndns.org> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="cNdxnHkX5QqsyA0e" Content-Disposition: inline In-Reply-To: X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-hackers@freebsd.org Subject: Re: Reading rtc on FreeBSD X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Aug 2010 11:38:37 -0000 --cNdxnHkX5QqsyA0e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Repeating your question will not encourage an answer. On 2010-Aug-19 13:09:46 +0300, phil hefferan wrote: >I've been looking around for how to read the cmos/rtc on FreeBSD. There is >no hwclock utility in FreeBSD that I can read sources for to see how it is >done. The RTC is only accessed within the kernel (/sys/isa/atrtc.c for i386 and amd64) and read in /sys/kern/subr_rtc.c::inittodr() >implies that, on FreeBSD, gettimeofday reads the software time and >settimeofday sets the cmos clock. I read here >http://www.mail-archive.com/freebsd-hardware@freebsd.org/msg03414.html that >settimeofday in fact sets both rtc and system time together. gettimeofday(2) reads the software clock only. settimeofday(2) writes both the software clock and RTC. >BUT the source to adjkerntz.c for FreeBSD seems to say that gettimeofday >reads the CMOS clock not the system time: > >/* get local CMOS clock and possible kernel offset */ >if (gettimeofday(&tv, &tz)) { > syslog(LOG_ERR, "gettimeofday: %m"); > return 1; >} That comment is incorrect. >Which is it? Does gettimeofday read the cmos clock/rtc on FreeBSD? If not, >how do I read the battery-backed clock on FreeBSD? There is no managed access to the RTC in FreeBSD. Your only option to read the RTC is to directly access its IO port registers via io(4) or i386_set_ioperm(2) --=20 Peter Jeremy --cNdxnHkX5QqsyA0e Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (FreeBSD) iEYEARECAAYFAkxtF7kACgkQ/opHv/APuId4UwCeIX0Oqg38buhFxD/QoQvEq5D5 DI0An1ZUAuMvI2SglELi62p9jO4858Gl =Vkpr -----END PGP SIGNATURE----- --cNdxnHkX5QqsyA0e--