diff --git a/ChangeLog b/ChangeLog index 47588a035..de914d38e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,44 @@ +2007-10-22 Robert Millan + + * include/grub/time.h: New file. + * include/grub/i386/time.h: Likewise. + * include/grub/powerpc/time.h: Likewise. + * include/grub/sparc64/time.h: Likewise. + + * include/grub/i386/pc/time.h (KERNEL_TIME_HEADER): Rename all + instances to ... + (KERNEL_MACHINE_TIME_HEADER): ... this. + * include/grub/powerpc/ieee1275/time.h (KERNEL_TIME_HEADER): Rename all + instances to ... + (KERNEL_MACHINE_TIME_HEADER): ... this. + * include/grub/sparc64/ieee1275/time.h (KERNEL_TIME_HEADER): Rename all + instances to ... + (KERNEL_MACHINE_TIME_HEADER): ... this. + + * kern/i386/efi/init.c: Include `'. + (grub_millisleep): New function. + * kern/i386/pc/init.c: Include `'. + (grub_millisleep): New function. + * kern/powerpc/ieee1275/init.c: Include `'. + Remove `grub/machine/time.h' include. + (grub_millisleep): New function. + * kern/sparc64/ieee1275/init.c: Include `'. + Remove `grub/machine/time.h' include. + (grub_millisleep): New function. + + * include/grub/misc.h (grub_div_roundup): New function. + + * kern/misc.c: Include `'. + (grub_millisleep_generic): New function. + + * conf/i386-efi.rmk (kernel_mod_HEADERS): Remove `i386/efi/time.h'. + Add `time.h'. + * conf/i386-pc.rmk (kernel_img_HEADERS): Remove `machine/time.h'. + Add `time.h'. + * conf/powerpc-ieee1275.rmk (kernel_elf_HEADERS): Remove + `machine/time.h'. Add `time.h'. + * conf/sparc64-ieee1275.rmk (kernel_elf_HEADERS): Likewise. + 2007-10-21 Robert Millan * include/grub/misc.h (grub_max): New function. diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index da96909bb..00a5b8841 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -88,8 +88,8 @@ kernel_mod_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.c \ term/efi/console.c disk/efi/efidisk.c kernel_mod_HEADERS = arg.h boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ - partition.h pc_partition.h rescue.h symbol.h term.h types.h \ - i386/efi/time.h efi/efi.h efi/time.h efi/disk.h + partition.h pc_partition.h rescue.h symbol.h term.h time.h types.h \ + efi/efi.h efi/time.h efi/disk.h kernel_mod_CFLAGS = $(COMMON_CFLAGS) kernel_mod_ASFLAGS = $(COMMON_ASFLAGS) kernel_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index e0d6e63cc..a53b77fa0 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -32,10 +32,9 @@ kernel_img_SOURCES = kern/i386/pc/startup.S kern/main.c kern/device.c \ symlist.c kernel_img_HEADERS = arg.h boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ - partition.h pc_partition.h rescue.h symbol.h term.h types.h \ + partition.h pc_partition.h rescue.h symbol.h term.h time.h types.h \ machine/biosdisk.h machine/boot.h machine/console.h machine/init.h \ - machine/memory.h machine/loader.h machine/time.h machine/vga.h \ - machine/vbe.h + machine/memory.h machine/loader.h machine/vga.h machine/vbe.h kernel_img_CFLAGS = $(COMMON_CFLAGS) kernel_img_ASFLAGS = $(COMMON_ASFLAGS) kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,8200 $(COMMON_CFLAGS) diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index 451039261..bf06c0005 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -12,8 +12,8 @@ DEFSYMFILES += kernel_syms.lst kernel_elf_HEADERS = arg.h boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h misc.h mm.h net.h parser.h rescue.h \ - symbol.h term.h types.h powerpc/libgcc.h loader.h partition.h \ - pc_partition.h ieee1275/ieee1275.h machine/time.h machine/kernel.h + symbol.h term.h time.h types.h powerpc/libgcc.h loader.h partition.h \ + pc_partition.h ieee1275/ieee1275.h machine/kernel.h kernel_elf_symlist.c: $(addprefix include/grub/,$(kernel_elf_HEADERS)) config.h gensymlist.sh /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index 8aa0bec21..972ee44a6 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -12,8 +12,8 @@ DEFSYMFILES += kernel_syms.lst kernel_elf_HEADERS = arg.h boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h misc.h mm.h net.h parser.h rescue.h \ - symbol.h term.h types.h sparc64/libgcc.h loader.h partition.h \ - pc_partition.h ieee1275/ieee1275.h machine/time.h machine/kernel.h + symbol.h term.h time.h types.h sparc64/libgcc.h loader.h partition.h \ + pc_partition.h ieee1275/ieee1275.h machine/kernel.h kernel_elf_symlist.c: $(addprefix include/grub/,$(kernel_elf_HEADERS)) config.h gensymlist.sh /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) diff --git a/include/grub/i386/pc/time.h b/include/grub/i386/pc/time.h index dba56e815..98399b687 100644 --- a/include/grub/i386/pc/time.h +++ b/include/grub/i386/pc/time.h @@ -16,8 +16,8 @@ * along with GRUB. If not, see . */ -#ifndef KERNEL_TIME_HEADER -#define KERNEL_TIME_HEADER 1 +#ifndef KERNEL_MACHINE_TIME_HEADER +#define KERNEL_MACHINE_TIME_HEADER 1 #include @@ -26,4 +26,4 @@ /* Return the real time in ticks. */ grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void); -#endif /* ! KERNEL_TIME_HEADER */ +#endif /* ! KERNEL_MACHINE_TIME_HEADER */ diff --git a/include/grub/misc.h b/include/grub/misc.h index 8bd4baab8..56f649246 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -83,6 +83,7 @@ grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, grub_uint32_t d, grub_uint32_t *r); /* Inline functions. */ + static inline unsigned int grub_abs (int x) { @@ -101,4 +102,11 @@ grub_max (long x, long y) return y; } +/* Rounded-up division */ +static inline unsigned int +grub_div_roundup (unsigned int x, unsigned int y) +{ + return (x + (y - 1) / y); +} + #endif /* ! GRUB_MISC_HEADER */ diff --git a/include/grub/powerpc/ieee1275/time.h b/include/grub/powerpc/ieee1275/time.h index 85f3ebf78..3f8ad26d7 100644 --- a/include/grub/powerpc/ieee1275/time.h +++ b/include/grub/powerpc/ieee1275/time.h @@ -16,8 +16,8 @@ * along with GRUB. If not, see . */ -#ifndef KERNEL_TIME_HEADER -#define KERNEL_TIME_HEADER 1 +#ifndef KERNEL_MACHINE_TIME_HEADER +#define KERNEL_MACHINE_TIME_HEADER 1 #include @@ -26,4 +26,4 @@ /* Return the real time in ticks. */ grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void); -#endif /* ! KERNEL_TIME_HEADER */ +#endif /* ! KERNEL_MACHINE_TIME_HEADER */ diff --git a/include/grub/sparc64/ieee1275/time.h b/include/grub/sparc64/ieee1275/time.h index 85f3ebf78..3f8ad26d7 100644 --- a/include/grub/sparc64/ieee1275/time.h +++ b/include/grub/sparc64/ieee1275/time.h @@ -16,8 +16,8 @@ * along with GRUB. If not, see . */ -#ifndef KERNEL_TIME_HEADER -#define KERNEL_TIME_HEADER 1 +#ifndef KERNEL_MACHINE_TIME_HEADER +#define KERNEL_MACHINE_TIME_HEADER 1 #include @@ -26,4 +26,4 @@ /* Return the real time in ticks. */ grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void); -#endif /* ! KERNEL_TIME_HEADER */ +#endif /* ! KERNEL_MACHINE_TIME_HEADER */ diff --git a/kern/i386/efi/init.c b/kern/i386/efi/init.c index 15d597a85..0683502a8 100644 --- a/kern/i386/efi/init.c +++ b/kern/i386/efi/init.c @@ -25,6 +25,13 @@ #include #include #include +#include + +void +grub_millisleep (grub_uint32_t ms) +{ + grub_millisleep_generic (ms); +} void grub_machine_init (void) diff --git a/kern/i386/pc/init.c b/kern/i386/pc/init.c index 90abd9537..00c7f4976 100644 --- a/kern/i386/pc/init.c +++ b/kern/i386/pc/init.c @@ -30,6 +30,7 @@ #include #include #include +#include struct mem_region { @@ -46,6 +47,12 @@ grub_addr_t grub_os_area_addr; grub_size_t grub_os_area_size; grub_size_t grub_lower_mem, grub_upper_mem; +void +grub_millisleep (grub_uint32_t ms) +{ + grub_millisleep_generic (ms); +} + void grub_arch_sync_caches (void *address __attribute__ ((unused)), grub_size_t len __attribute__ ((unused))) diff --git a/kern/misc.c b/kern/misc.c index 8df1ee066..4cb846d5e 100644 --- a/kern/misc.c +++ b/kern/misc.c @@ -23,6 +23,7 @@ #include #include #include +#include void * grub_memmove (void *dest, const void *src, grub_size_t n) @@ -1041,6 +1042,17 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest, const grub_uint8_t *src, return p - dest; } +void +grub_millisleep_generic (grub_uint32_t ms) +{ + grub_uint32_t end_at; + + end_at = grub_get_rtc () + grub_div_roundup (ms * GRUB_TICKS_PER_SECOND, 1000); + + while (grub_get_rtc () < end_at) + grub_cpu_idle (); +} + /* Abort GRUB. This function does not return. */ void grub_abort (void) diff --git a/kern/powerpc/ieee1275/init.c b/kern/powerpc/ieee1275/init.c index 26a690a5d..4727d7d0b 100644 --- a/kern/powerpc/ieee1275/init.c +++ b/kern/powerpc/ieee1275/init.c @@ -27,8 +27,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -46,6 +46,12 @@ extern char _start[]; extern char _end[]; +void +grub_millisleep (grub_uint32_t ms) +{ + grub_millisleep_generic (ms); +} + void grub_exit (void) { diff --git a/kern/sparc64/ieee1275/init.c b/kern/sparc64/ieee1275/init.c index 8bad9eadf..dbc1fee3e 100644 --- a/kern/sparc64/ieee1275/init.c +++ b/kern/sparc64/ieee1275/init.c @@ -27,8 +27,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -66,6 +66,12 @@ _start (uint64_t r0 __attribute__((unused)), /* Never reached. */ } +void +grub_millisleep (grub_uint32_t ms) +{ + grub_millisleep_generic (ms); +} + int grub_ieee1275_test_flag (enum grub_ieee1275_flag flag) {