From owner-freebsd-i386@FreeBSD.ORG Tue Jun 12 05:59:11 2007 Return-Path: X-Original-To: freebsd-i386@freebsd.org Delivered-To: freebsd-i386@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 88CA516A41F; Tue, 12 Jun 2007 05:59:11 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from fallbackmx03.syd.optusnet.com.au (fallbackmx03.syd.optusnet.com.au [211.29.133.136]) by mx1.freebsd.org (Postfix) with ESMTP id 063CC13C45D; Tue, 12 Jun 2007 05:59:09 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail25.syd.optusnet.com.au (mail25.syd.optusnet.com.au [211.29.133.166]) by fallbackmx03.syd.optusnet.com.au (8.12.11.20060308/8.12.11) with ESMTP id l5B3wTXh012674; Mon, 11 Jun 2007 13:58:29 +1000 Received: from besplex.bde.org (c220-239-235-248.carlnfd3.nsw.optusnet.com.au [220.239.235.248]) by mail25.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id l5B3wKCI014514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 11 Jun 2007 13:58:27 +1000 Date: Mon, 11 Jun 2007 13:58:23 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ed Schouten In-Reply-To: <20070610201813.B11831CCB7@palm.hoeg.nl> Message-ID: <20070611132137.G7222@besplex.bde.org> References: <20070610201813.B11831CCB7@palm.hoeg.nl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: FreeBSD-gnats-submit@freebsd.org, freebsd-i386@freebsd.org Subject: Re: i386/113540: decrease i8254 calibration precision to make it work with Xbox, remove warnings X-BeenThere: freebsd-i386@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: I386-specific issues for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2007 05:59:11 -0000 On Sun, 10 Jun 2007, Ed Schouten wrote: >> Description: > For some reason, the timers in the Microsoft Xbox aren't as sane as on > PC's; it has two issues: > > - The frequency of the i8254 timer is 1125000 Hz instead of 1193182 Hz. > The Microsoft Xbox port currently solves this by hardcoding TIMER_FREQ > in the config file. > - The diagnostic and status registers of the RTC contain invalid data, > which causes FreeBSD to assume the RTC is broken. This causes a lot of > spurious messages in the dmesg. >> How-To-Repeat: >> Fix: > I've been using the following patch on my Xbox for a long time now; it > essentially does the following things: > > - It changes the rtcin() routine to return fake values for the diagnose > and status registers, which forces FreeBSD to properly use theh RTC. > - It decreases the precision of the timer (by default disabled) timer > calibration code from 1% to 10%; this is needed because the Xbox clock > is 6% off. Is it only 6% off because the default is 6% off? The error margin is supposed to be just a sanity check, but if the i8254 clock frequency is not required to be nearly 1193182 then this frequency can be almost anything in theory and no sanity check works. > - It removes the hardcoded Xbox timer value from the Xbox configuration > file and enables timer calibration. I hope to remove the timer calibration. It was mainly for RTC calibration, but that most important part of it has been axed. In practice, the i8254 has always been nearly 1193182 until now, with an error of about the same as for the RTC, so it doesn't matter which of these is used as a reference. What I do now is not worry much about initial calibration; then fix up the frequencies of all timecounters in /etc/rc.local, using the results of more accurate calibrations previously done in userland. Unfortunately, this requires a lot of setup (ntpd might be able to do it automatically but might take years to stabilize if the initial frequencies are very inaccurate). > The reason why we want to do such a thing is because we could then > compile kernels that run on Xbox'es and PC's without a clock drift on > one of those systems. You could make the frequency a tunable. This would minimize clock drift before the frequency can be fixed up in /etc/rc, but still requires pre-calibration and storing the result somewhere. Does XBOX have any other timers/timecounters that might give a more suitable reference? Bruce