2008-08-08 Robert Millan <rmh@aybabtu.com>
* kern/disk.c: Replace `<grub/machine/time.h>' with `<grub/time.h>'. (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 `<grub/machine/time.h>' with `<grub/time.h>'. (run_menu): Migrate code from to using grub_get_time_ms(). * util/misc.c (grub_get_time_ms): New function.
This commit is contained in:
parent
7f280db554
commit
042bd419da
4 changed files with 35 additions and 12 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2008-08-08 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
|
* kern/disk.c: Replace `<grub/machine/time.h>' with `<grub/time.h>'.
|
||||||
|
(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 `<grub/machine/time.h>' with `<grub/time.h>'.
|
||||||
|
(run_menu): Migrate code from to using grub_get_time_ms().
|
||||||
|
|
||||||
|
* util/misc.c (grub_get_time_ms): New function.
|
||||||
|
|
||||||
2008-08-08 Marco Gerards <marco@gnu.org>
|
2008-08-08 Marco Gerards <marco@gnu.org>
|
||||||
|
|
||||||
* disk/ata.c (grub_ata_regget): Change return type to
|
* disk/ata.c (grub_ata_regget): Change return type to
|
||||||
|
|
12
kern/disk.c
12
kern/disk.c
|
@ -22,13 +22,13 @@
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/partition.h>
|
#include <grub/partition.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/machine/time.h>
|
#include <grub/time.h>
|
||||||
#include <grub/file.h>
|
#include <grub/file.h>
|
||||||
|
|
||||||
#define GRUB_CACHE_TIMEOUT 2
|
#define GRUB_CACHE_TIMEOUT 2
|
||||||
|
|
||||||
/* The last time the disk was used. */
|
/* The last time the disk was used. */
|
||||||
static unsigned long grub_last_time = 0;
|
static grub_uint64_t grub_last_time = 0;
|
||||||
|
|
||||||
|
|
||||||
/* Disk cache. */
|
/* Disk cache. */
|
||||||
|
@ -215,7 +215,7 @@ grub_disk_open (const char *name)
|
||||||
grub_disk_t disk;
|
grub_disk_t disk;
|
||||||
grub_disk_dev_t dev;
|
grub_disk_dev_t dev;
|
||||||
char *raw = (char *) name;
|
char *raw = (char *) name;
|
||||||
unsigned long current_time;
|
grub_uint64_t current_time;
|
||||||
|
|
||||||
grub_dprintf ("disk", "Opening `%s'...\n", name);
|
grub_dprintf ("disk", "Opening `%s'...\n", name);
|
||||||
|
|
||||||
|
@ -280,10 +280,10 @@ grub_disk_open (const char *name)
|
||||||
|
|
||||||
/* The cache will be invalidated about 2 seconds after a device was
|
/* The cache will be invalidated about 2 seconds after a device was
|
||||||
closed. */
|
closed. */
|
||||||
current_time = grub_get_rtc ();
|
current_time = grub_get_time_ms ();
|
||||||
|
|
||||||
if (current_time > (grub_last_time
|
if (current_time > (grub_last_time
|
||||||
+ GRUB_CACHE_TIMEOUT * GRUB_TICKS_PER_SECOND))
|
+ GRUB_CACHE_TIMEOUT * 1000))
|
||||||
grub_disk_cache_invalidate_all ();
|
grub_disk_cache_invalidate_all ();
|
||||||
|
|
||||||
grub_last_time = current_time;
|
grub_last_time = current_time;
|
||||||
|
@ -315,7 +315,7 @@ grub_disk_close (grub_disk_t disk)
|
||||||
(disk->dev->close) (disk);
|
(disk->dev->close) (disk);
|
||||||
|
|
||||||
/* Reset the timer. */
|
/* Reset the timer. */
|
||||||
grub_last_time = grub_get_rtc ();
|
grub_last_time = grub_get_time_ms ();
|
||||||
|
|
||||||
grub_free (disk->partition);
|
grub_free (disk->partition);
|
||||||
grub_free ((void *) disk->name);
|
grub_free ((void *) disk->name);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/loader.h>
|
#include <grub/loader.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/machine/time.h>
|
#include <grub/time.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/script.h>
|
#include <grub/script.h>
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ static int
|
||||||
run_menu (grub_menu_t menu, int nested)
|
run_menu (grub_menu_t menu, int nested)
|
||||||
{
|
{
|
||||||
int first, offset;
|
int first, offset;
|
||||||
unsigned long saved_time;
|
grub_uint64_t saved_time;
|
||||||
int default_entry;
|
int default_entry;
|
||||||
int timeout;
|
int timeout;
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ run_menu (grub_menu_t menu, int nested)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the time. */
|
/* Initialize the time. */
|
||||||
saved_time = grub_get_rtc ();
|
saved_time = grub_get_time_ms ();
|
||||||
|
|
||||||
refresh:
|
refresh:
|
||||||
grub_setcursor (0);
|
grub_setcursor (0);
|
||||||
|
@ -371,10 +371,10 @@ run_menu (grub_menu_t menu, int nested)
|
||||||
|
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
{
|
{
|
||||||
unsigned long current_time;
|
grub_uint64_t current_time;
|
||||||
|
|
||||||
current_time = grub_get_rtc ();
|
current_time = grub_get_time_ms ();
|
||||||
if (current_time - saved_time >= GRUB_TICKS_PER_SECOND)
|
if (current_time - saved_time >= 1000)
|
||||||
{
|
{
|
||||||
timeout--;
|
timeout--;
|
||||||
set_timeout (timeout);
|
set_timeout (timeout);
|
||||||
|
|
11
util/misc.c
11
util/misc.c
|
@ -33,6 +33,7 @@
|
||||||
#include <grub/util/misc.h>
|
#include <grub/util/misc.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
|
#include <grub/time.h>
|
||||||
#include <grub/machine/time.h>
|
#include <grub/machine/time.h>
|
||||||
|
|
||||||
/* Include malloc.h, only if memalign is available. It is known that
|
/* Include malloc.h, only if memalign is available. It is known that
|
||||||
|
@ -284,6 +285,16 @@ grub_get_rtc (void)
|
||||||
* GRUB_TICKS_PER_SECOND / 1000000));
|
* 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
|
void
|
||||||
grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
||||||
grub_size_t len __attribute__ ((unused)))
|
grub_size_t len __attribute__ ((unused)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue