From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KEnrJ-0007Dt-Ad for mharc-grub-devel@gnu.org; Fri, 04 Jul 2008 12:10:05 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KEnrF-0007Cc-Jk for grub-devel@gnu.org; Fri, 04 Jul 2008 12:10:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KEnrE-0007Bq-3i for grub-devel@gnu.org; Fri, 04 Jul 2008 12:10:01 -0400 Received: from [199.232.76.173] (port=60633 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KEnrD-0007Bl-N3 for grub-devel@gnu.org; Fri, 04 Jul 2008 12:09:59 -0400 Received: from mta-out.inet.fi ([195.156.147.13]:50889 helo=jenni1.rokki.sonera.fi) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KEnrD-0003eI-0l for grub-devel@gnu.org; Fri, 04 Jul 2008 12:09:59 -0400 Received: from [127.0.0.1] (88.193.32.97) by jenni1.rokki.sonera.fi (8.5.014) id 483E82F101969D97 for grub-devel@gnu.org; Fri, 4 Jul 2008 19:09:56 +0300 Message-ID: <486E4B58.60306@nic.fi> Date: Fri, 04 Jul 2008 19:10:00 +0300 From: =?ISO-8859-1?Q?Vesa_J=E4=E4skel=E4inen?= User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: The development of GRUB 2 References: <20080623075438.5861e6d1@gibibit.com> <878wwi6bqy.fsf@xs4all.nl> <20080704085831.4bfa826b@gibibit.com> In-Reply-To: <20080704085831.4bfa826b@gibibit.com> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: Quoted-Printable X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Subject: Re: [RFC] High resolution time support using x86 TSC 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: Fri, 04 Jul 2008 16:10:03 -0000 Colin D Bennett wrote: > On Thu, 03 Jul 2008 20:52:53 +0200 > Marco Gerards wrote: >=20 >> Hi Colin, >> >> Colin D Bennett writes: >> >>> + * kern/i386/linuxbios/init.c (grub_get_time_ms): >>> + Define grub_get_time_ms() to always return 0. This should >>> be fixed >>> + when RTC functionality is implemented. >>> + (grub_time_init): Define this required function as a >>> no-op. Inserted >>> + a comment to remind us delete this function when proper >>> time support=20 >>> + is added to i386-linuxbios. >>> + >>> + * kern/main.c (grub_main): Call grub_time_init() right >>> after >>> + grub_machine_init(). >> I think this should go into grub_machine_init? Why didn't you just >> add it there? >=20 > Originally, I had grub_machine_init() call grub_tsc_calibrate(), but > these are comments Vesa made to me about that code: >=20 > Vesa J=E4=E4skel=E4inen wrote > on Mon, 16 Jun 2008 20:34:54 +0300: >=20 >> Colin D Bennett wrote: >>> This week I implemented high resolution timer support using the x86 >>> TSC (see attached patch ). It is >>> calibrated at GRUB startup using the RTC as a reference. The core >>> TSC function is ``grub_get_tsc()`` -- corresponding to >>> ``grub_get_rtc()``, but returning a uint64 value representing the >>> number of CPU cycles elapsed since boot. >>> >>> In most situations, you will want to use ``grub_get_time_ms()`` to >>> get the system time in milliseconds based on the TSC value. The >>> calibration function ``grub_tsc_calibrate()``, calculates the >>> proper scale factor and absolute offset so that the millisecond >>> value represents real time. >>> >>> The ``grub_get_time_ms()`` function is implemented for non-x86 >>> platforms to simply call ``grub_get_time_ms_generic()`` (defined in >>> kern/misc.c), which uses the RTC to get the time in milliseconds. =20 >> We would probably want to leave that generic out from kernel, and let=20 >> every platform either use this generic code or implement their own=20 >> mechanism to do the job. Perhaps we should make own folder for >> generic stuff that can be included for arch specific build if there >> is no better replacement. >> >> How about calling function like grub_time_init() which would then be=20 >> platform specific? Then platform can implement whatever way to >> calibrate (if needed) as long as it provides this grub_get_time_ms() >> function (also being platform specific). This would make >> initialization non-specific to arch while leaving more room for >> implementation. >=20 > Therefore, I thought this was the right way to do it. Do you want me > to instead call grub_time_init() from grub_machine_init()? Hi Colin, That is Ok. My comment was more of calling directly tsc_calibrate which is not=20 generic function at all. You can call grub_time_init() and in there you=20 decide that you use tsc (and then call tsc_calibrate) or something else=20 depending what is available. This way time handling stuff can be reside=20 easily on one module and it is easy to provide generic function to other=20 platforms. Thanks, Vesa J=E4=E4skel=E4inen