From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KQ6W3-00033l-Cj for mharc-grub-devel@gnu.org; Mon, 04 Aug 2008 16:18:51 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KQ6W2-00033e-7l for grub-devel@gnu.org; Mon, 04 Aug 2008 16:18:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KQ6W0-00033S-Eh for grub-devel@gnu.org; Mon, 04 Aug 2008 16:18:49 -0400 Received: from [199.232.76.173] (port=35351 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KQ6W0-00033P-AQ for grub-devel@gnu.org; Mon, 04 Aug 2008 16:18:48 -0400 Received: from smtp-vbr2.xs4all.nl ([194.109.24.22]:1505) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KQ6W0-0000Mk-0m for grub-devel@gnu.org; Mon, 04 Aug 2008 16:18:48 -0400 Received: from localhost.localdomain (249-174.surfsnel.dsl.internl.net [145.99.174.249]) by smtp-vbr2.xs4all.nl (8.13.8/8.13.8) with ESMTP id m74KIkCK082827 for ; Mon, 4 Aug 2008 22:18:47 +0200 (CEST) (envelope-from mgerards@xs4all.nl) From: Marco Gerards To: The development of GRUB 2 References: <20080623075438.5861e6d1@gibibit.com> <878wwi6bqy.fsf@xs4all.nl> <20080704112801.470827ea@gibibit.com> <87tzekiecu.fsf@xs4all.nl> <20080728100533.19118c0b@gibibit.com> <20080803194816.GA13744@thorin> <20080803235348.GA23220@thorin> Mail-Copies-To: mgerards@xs4all.nl Date: Mon, 04 Aug 2008 22:21:20 +0200 In-Reply-To: <20080803235348.GA23220@thorin> (Robert Millan's message of "Mon, 4 Aug 2008 01:53:48 +0200") Message-ID: <87proo351b.fsf@xs4all.nl> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by XS4ALL Virus Scanner X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9 Subject: Re: TSC on coreboot (Re: [PATCH] High resolution time/TSC patch v3) X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Aug 2008 20:18:50 -0000 Hi Robert, Robert Millan writes: You forgot the changelog entry :-) > On Sun, Aug 03, 2008 at 09:48:16PM +0200, Robert Millan wrote: >> On Mon, Jul 28, 2008 at 10:05:33AM -0700, Colin D Bennett wrote: >> > +/* Calibrate the TSC based on the RTC. */ >> > +static void >> > +calibrate_tsc (void) >> > +{ >> > + /* First calbrate the TSC rate (relative, not absolute time). */ >> > + grub_uint64_t start_tsc; >> > + grub_uint64_t end_tsc; >> > + grub_uint32_t initial_tick; >> > + grub_uint32_t start_tick; >> > + grub_uint32_t end_tick; >> > + >> > + /* Wait for the start of the next tick; >> > + we'll base out timing off this edge. */ >> > + initial_tick = grub_get_rtc (); >> >> Ah, I see the problem. It calls grub_get_rtc() which in grub-coreboot is just >> a stub. >> >> How about using the interval timer for calibration instead? > > Here. With this patch your code works on coreboot too. > > Note: AFAICT we can't calculate the epoch without RTC. But then again, this > epoch is just as defined by the time BIOS enables RTC interrupts, so why not > define it ourselves? I propose that we define epoch as the time in which our > TSC code is initialized. > > If knowing the time in which BIOS was started is really useful, maybe we could > #ifdef it instead. Though if it's not I'd prefer the simplicity. If this works and fixes coreboot, it is fine to me ;-) One comment follows below. > --- ../grub2.tsc/include/grub/i386/pit.h 1970-01-01 01:00:00.000000000 +0100 > +++ ./include/grub/i386/pit.h 2008-08-04 01:22:12.000000000 +0200 > @@ -0,0 +1,19 @@ > +/* > + * GRUB -- GRand Unified Bootloader > + * Copyright (C) 2008 Free Software Foundation, Inc. > + * > + * GRUB is free software: you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation, either version 3 of the License, or > + * (at your option) any later version. > + * > + * GRUB is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with GRUB. If not, see . > + */ > + > +extern void grub_pit_wait (grub_uint16_t tics); Please us an inclusion guard. -- Marco