From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KRFEe-0004U9-1n for mharc-grub-devel@gnu.org; Thu, 07 Aug 2008 19:49:36 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KRFEc-0004Sg-EE for grub-devel@gnu.org; Thu, 07 Aug 2008 19:49:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KRFEZ-0004Rc-2g for grub-devel@gnu.org; Thu, 07 Aug 2008 19:49:34 -0400 Received: from [199.232.76.173] (port=57901 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KRFEY-0004RM-MU for grub-devel@gnu.org; Thu, 07 Aug 2008 19:49:30 -0400 Received: from aybabtu.com ([69.60.117.155]:33838) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KRFEW-0004UU-TB for grub-devel@gnu.org; Thu, 07 Aug 2008 19:49:30 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1KRF6u-0005ak-O8 for grub-devel@gnu.org; Fri, 08 Aug 2008 01:41:39 +0200 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1KRFDA-00011r-Sf for grub-devel@gnu.org; Fri, 08 Aug 2008 01:48:04 +0200 Date: Fri, 8 Aug 2008 01:48:04 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20080807234804.GA3944@thorin> References: <20080805235450.GA7453@thorin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080805235450.GA7453@thorin> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [PATCH] use grub_get_time_ms() instead of grub_get_rtc() 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: Thu, 07 Aug 2008 23:49:34 -0000 Committed. On Wed, Aug 06, 2008 at 01:54:50AM +0200, Robert Millan wrote: > > This replaces usage of grub_get_rtc() with grub_get_time_ms() in a few places > throurough the code. Aside from the gained precision, it also permits that > functionality to work on Coreboot. > > -- > Robert Millan > > The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and > how) you may access your data; but nobody's threatening your freedom: we > still allow you to remove your data and not access it at all." > 2008-08-06 Robert Millan > > * kern/disk.c: Replace `' with `'. > (grub_last_time): Change type to grub_uint64_t. > (grub_disk_open): Migrate code from to using grub_get_time_ms(). > (grub_disk_close): Likewise. > > * normal/menu.c: Replace `' with `'. > (run_menu): Migrate code from to using grub_get_time_ms(). > > * util/misc.c (grub_get_time_ms): New function. > > Index: kern/disk.c > =================================================================== > --- kern/disk.c (revision 1780) > +++ kern/disk.c (working copy) > @@ -22,13 +22,13 @@ > #include > #include > #include > -#include > +#include > #include > > #define GRUB_CACHE_TIMEOUT 2 > > /* The last time the disk was used. */ > -static unsigned long grub_last_time = 0; > +static grub_uint64_t grub_last_time = 0; > > > /* Disk cache. */ > @@ -215,7 +215,7 @@ > grub_disk_t disk; > grub_disk_dev_t dev; > char *raw = (char *) name; > - unsigned long current_time; > + grub_uint64_t current_time; > > grub_dprintf ("disk", "Opening `%s'...\n", name); > > @@ -280,10 +280,10 @@ > > /* The cache will be invalidated about 2 seconds after a device was > closed. */ > - current_time = grub_get_rtc (); > + current_time = grub_get_time_ms (); > > if (current_time > (grub_last_time > - + GRUB_CACHE_TIMEOUT * GRUB_TICKS_PER_SECOND)) > + + GRUB_CACHE_TIMEOUT * 1000)) > grub_disk_cache_invalidate_all (); > > grub_last_time = current_time; > @@ -315,7 +315,7 @@ > (disk->dev->close) (disk); > > /* Reset the timer. */ > - grub_last_time = grub_get_rtc (); > + grub_last_time = grub_get_time_ms (); > > grub_free (disk->partition); > grub_free ((void *) disk->name); > Index: normal/menu.c > =================================================================== > --- normal/menu.c (revision 1780) > +++ normal/menu.c (working copy) > @@ -21,7 +21,7 @@ > #include > #include > #include > -#include > +#include > #include > #include > > @@ -326,7 +326,7 @@ > run_menu (grub_menu_t menu, int nested) > { > int first, offset; > - unsigned long saved_time; > + grub_uint64_t saved_time; > int default_entry; > int timeout; > > @@ -351,7 +351,7 @@ > } > > /* Initialize the time. */ > - saved_time = grub_get_rtc (); > + saved_time = grub_get_time_ms (); > > refresh: > grub_setcursor (0); > @@ -371,10 +371,10 @@ > > if (timeout > 0) > { > - unsigned long current_time; > + grub_uint64_t current_time; > > - current_time = grub_get_rtc (); > - if (current_time - saved_time >= GRUB_TICKS_PER_SECOND) > + current_time = grub_get_time_ms (); > + if (current_time - saved_time >= 1000) > { > timeout--; > set_timeout (timeout); > Index: util/misc.c > =================================================================== > --- util/misc.c (revision 1780) > +++ util/misc.c (working copy) > @@ -33,6 +33,7 @@ > #include > #include > #include > +#include > #include > > /* Include malloc.h, only if memalign is available. It is known that > @@ -284,6 +285,16 @@ > * GRUB_TICKS_PER_SECOND / 1000000)); > } > > +grub_uint64_t > +grub_get_time_ms (void) > +{ > + struct timeval tv; > + > + gettimeofday (&tv, 0); > + > + return (tv.tv_sec * 1000 + tv.tv_usec / 1000); > +} > + > void > grub_arch_sync_caches (void *address __attribute__ ((unused)), > grub_size_t len __attribute__ ((unused))) > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."