Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KEp3a-0006cV-VF for mharc-grub-devel@gnu.org; Fri, 04 Jul 2008 13:26:51 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KEp3Y-0006c0-Sl for grub-devel@gnu.org; Fri, 04 Jul 2008 13:26:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KEp3Y-0006bm-8g for grub-devel@gnu.org; Fri, 04 Jul 2008 13:26:48 -0400 Received: from [199.232.76.173] (port=33779 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KEp3Y-0006bj-5l for grub-devel@gnu.org; Fri, 04 Jul 2008 13:26:48 -0400 Received: from gateway13.websitewelcome.com ([69.56.195.10]:56703) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1KEp3X-00029P-OO for grub-devel@gnu.org; Fri, 04 Jul 2008 13:26:48 -0400 Received: (qmail 19196 invoked from network); 4 Jul 2008 17:31:18 -0000 Received: from gator297.hostgator.com (74.53.228.114) by gateway13.websitewelcome.com with SMTP; 4 Jul 2008 17:31:18 -0000 Received: from c-67-185-142-228.hsd1.wa.comcast.net ([67.185.142.228]:60513 helo=localhost) by gator297.hostgator.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.68) (envelope-from ) id 1KEp3V-0002On-2J; Fri, 04 Jul 2008 12:26:45 -0500 Date: Fri, 4 Jul 2008 10:26:16 -0700 From: Colin D Bennett To: The development of GRUB 2 Message-ID: <20080704102616.6ce86238@gibibit.com> In-Reply-To: <878wwi6bqy.fsf@xs4all.nl> References: <20080623075438.5861e6d1@gibibit.com> <878wwi6bqy.fsf@xs4all.nl> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/ASkKy6hjb7wk4PDB6=_j8TX"; protocol="application/pgp-signature"; micalg=PGP-SHA1 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator297.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - gibibit.com X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Cc: 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 17:26:49 -0000 --Sig_/ASkKy6hjb7wk4PDB6=_j8TX Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Marco, On Thu, 03 Jul 2008 20:52:53 +0200 Marco Gerards wrote: > Hi Colin, >=20 > Colin D Bennett writes: >=20 > > I have implemented high resolution time support (through the > > new grub_get_time_ms() function) using the RDTSC instruction > > available on Pentium and higher x86 CPUs. The TSC value is simply > > a 64-bit block cycle counter that is zeroed at bootup, so > > grub_main() calls grub_time_init(), which is defined by each > > platform. If a platform links to kern/i386/tsc.c, then the > > grub_time_init() function from tsc.c is used, which calibrates the > > TSC rate and absolute zero reference using the RTC. > What if TSC is not available? I updated the changelog entry to indicate that running on a 386 or 486 will fail, since TSC is provided in Pentium+. Do we support running on 386 or 386? Should I check for this? If so, the code will have to change a bit, and be able to select between the generic implementation and the TSC implementation at runtime. I think this would be best done letting the "grub_get_time_ms" implementation be selected by setting a function pointer in grub_machine_init() depending on the machine's capabilities. I would have to significantly re-structure my patch, but it might be necessary (and could lead to more understandable code?). What do you think? >... > > + * kern/i386/pc/init.c (grub_millisleep): Likewise. > > + > > + * kern/ieee1275/init.c (grub_millisleep): Don't define > > + grub_millisleep() -- it just called > > grub_millisleep_generic() but now > > + we just need to link with kern/generic/millisleep.c to use > > the generic > > + implementation. >=20 > No need to mention how it has to be linked. I just assume you made > this change already? Yes. I removed that part of the changelog comment. >... > > + (grub_time_init): Define this required function. Does > > nothing since > > + the generic RTC-based functions are used. >=20 > No need to mention what a function does. Only describe the changes > you make. Other information should go into the file itself as > comments, if it is important enough. Here it is only noise... Ok. I tried to clean this up. > > + * 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(). >=20 > I think this should go into grub_machine_init? Why didn't you just > add it there? I commented on this in a separate message a few minutes ago. > > +grub_uint64_t > > +grub_get_time_ms (void) > > +{ > > + /* FIXME: Delete this function and link to `kern/i386/tsc.c' > > once RTC > > + * is implemented. See also comment below in grub_time_init(). > > */ > > + return 0; > > +} >=20 > Please do not use comments with *'s on each line. Sorry, it was a habit of mine. Fixed. >... > > +void > > +grub_time_init (void) > > +{ > > + /* FIXME: Delete this function and link with `kern/i386/tsc.c' > > once RTC > > + * is implemented. Until then, this dummy function simply > > defines=20 > > + * grub_time_init(), which is called by grub_main() in > > `kern/main.c'. > > + * Without RTC, TSC calibration will hang waiting for an RTC > > edge. */ +} > > + >=20 > Same here. Can you explain what is going on here? Since grub_main() calls grub_time_init(), it must be defined. However, we can't use the TSC implementation of grub_time_init() from kern/i386/tsc.c, since it will not be able to calibrate (it will hang) if the RTC always returns the same value, which the i386-linuxbios kernel does. >... > > +/* Reference for TSC=3D0. This defines the time since the epoch >in=20 > > + * milliseconds that TSC=3D0 refers to. */ > > +static grub_uint64_t tsc_boot_time =3D 0; >=20 > Please do not use a * on each line for comments. No need to set this > to zero explicitly. Ok. >=20 > > +/* TSC rate. TSC ticks per millisecond.=20 > > + * Begin with default (incorrect) value of assuming a 1 GHz > > machine. > > + * grub_tsc_calibrate() must be called to set this properly. */ > > +static grub_uint64_t tsc_ticks_per_ms =3D 1000000; >=20 > Same as above. >=20 > The value is not correct. Why can't we just set it to 0? I figured that in case calibration was not done, we could at least fake partial functionality by going with an incorrect value. However, I don't initialize tsc_boot_time, then there is no sense in initializing tsc_ticks_per_ms either, since without both of them set to a valid value, grub_get_time_ms() will not work. I just realize I should probably not have chopped up the patch above in my reply in an attempt to make it short. I hope I didn't make it too hard to follow. I'll send a new patch shortly for your comments -- it will include the minor changes you mentioned, but will not address the issue of supporting 386/486 machines (no TSC), as I discussed at the beginning of this message. I await your comments regarding that point. Regards, Colin --Sig_/ASkKy6hjb7wk4PDB6=_j8TX Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkhuXTsACgkQokx8fzcGbYfcKACcCVjEatlSQjOKobDEt+C3Yqza 5IoAnjJOUSLU5yR9iLw65G7Uf0LT3CiE =UASU -----END PGP SIGNATURE----- --Sig_/ASkKy6hjb7wk4PDB6=_j8TX--