I noticed that one also needs to update time.h headers in conf/*.rmk to
make the build system happy about symbol dependencies.  See new patch.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
2007-10-21  Robert Millan  <[EMAIL PROTECTED]>

	* 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/time.h>'.
	(grub_millisleep): New function.
	* kern/i386/pc/init.c: Include `<grub/time.h>'.
	(grub_millisleep): New function.
	* kern/powerpc/ieee1275/init.c: Include `<grub/time.h>'.
	Remove `grub/machine/time.h' include.
	(grub_millisleep): New function.
	* kern/sparc64/ieee1275/init.c: Include `<grub/time.h>'.
	Remove `grub/machine/time.h' include.
	(grub_millisleep): New function.

	* include/grub/misc.h (grub_div_roundup): New function.

	* kern/misc.c: Include `<grub/time.h>'.
	(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.

diff -Nurp grub2/conf/i386-efi.rmk grub2.time/conf/i386-efi.rmk
--- grub2/conf/i386-efi.rmk	2007-10-02 23:34:33.000000000 +0200
+++ grub2.time/conf/i386-efi.rmk	2007-10-21 14:48:27.000000000 +0200
@@ -88,8 +88,8 @@ kernel_mod_SOURCES = kern/i386/efi/start
 	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 -Nurp grub2/conf/i386-pc.rmk grub2.time/conf/i386-pc.rmk
--- grub2/conf/i386-pc.rmk	2007-10-01 17:50:34.000000000 +0200
+++ grub2.time/conf/i386-pc.rmk	2007-10-21 14:48:04.000000000 +0200
@@ -32,10 +32,9 @@ kernel_img_SOURCES = kern/i386/pc/startu
 	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 -Nurp grub2/conf/powerpc-ieee1275.rmk grub2.time/conf/powerpc-ieee1275.rmk
--- grub2/conf/powerpc-ieee1275.rmk	2007-10-12 12:22:27.000000000 +0200
+++ grub2.time/conf/powerpc-ieee1275.rmk	2007-10-21 14:48:44.000000000 +0200
@@ -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 -Nurp grub2/conf/sparc64-ieee1275.rmk grub2.time/conf/sparc64-ieee1275.rmk
--- grub2/conf/sparc64-ieee1275.rmk	2007-07-02 22:38:01.000000000 +0200
+++ grub2.time/conf/sparc64-ieee1275.rmk	2007-10-21 14:48:57.000000000 +0200
@@ -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 -Nurp grub2/include/grub/i386/pc/time.h grub2.time/include/grub/i386/pc/time.h
--- grub2/include/grub/i386/pc/time.h	2007-07-22 01:32:24.000000000 +0200
+++ grub2.time/include/grub/i386/pc/time.h	2007-10-21 14:47:03.000000000 +0200
@@ -16,8 +16,8 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef KERNEL_TIME_HEADER
-#define KERNEL_TIME_HEADER	1
+#ifndef KERNEL_MACHINE_TIME_HEADER
+#define KERNEL_MACHINE_TIME_HEADER	1
 
 #include <grub/symbol.h>
 
@@ -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 -Nurp grub2/include/grub/i386/time.h grub2.time/include/grub/i386/time.h
--- grub2/include/grub/i386/time.h	1970-01-01 01:00:00.000000000 +0100
+++ grub2.time/include/grub/i386/time.h	2007-10-21 14:47:03.000000000 +0200
@@ -0,0 +1,28 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2007  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef KERNEL_CPU_TIME_HEADER
+#define KERNEL_CPU_TIME_HEADER	1
+
+static __inline void
+grub_cpu_idle ()
+{
+  __asm__ __volatile__ ("hlt");
+}
+
+#endif /* ! KERNEL_CPU_TIME_HEADER */
diff -Nurp grub2/include/grub/misc.h grub2.time/include/grub/misc.h
--- grub2/include/grub/misc.h	2007-07-22 01:32:22.000000000 +0200
+++ grub2.time/include/grub/misc.h	2007-10-21 14:47:03.000000000 +0200
@@ -83,6 +83,7 @@ grub_uint64_t EXPORT_FUNC(grub_divmod64)
 					  grub_uint32_t d, grub_uint32_t *r);
 
 /* Inline functions.  */
+
 static inline unsigned int
 grub_abs (int x)
 {
@@ -92,4 +93,11 @@ grub_abs (int x)
     return (unsigned int) x;
 }
 
+/* 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 -Nurp grub2/include/grub/powerpc/ieee1275/time.h grub2.time/include/grub/powerpc/ieee1275/time.h
--- grub2/include/grub/powerpc/ieee1275/time.h	2007-07-22 01:32:24.000000000 +0200
+++ grub2.time/include/grub/powerpc/ieee1275/time.h	2007-10-21 14:47:03.000000000 +0200
@@ -16,8 +16,8 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef KERNEL_TIME_HEADER
-#define KERNEL_TIME_HEADER	1
+#ifndef KERNEL_MACHINE_TIME_HEADER
+#define KERNEL_MACHINE_TIME_HEADER	1
 
 #include <grub/symbol.h>
 
@@ -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 -Nurp grub2/include/grub/powerpc/time.h grub2.time/include/grub/powerpc/time.h
--- grub2/include/grub/powerpc/time.h	1970-01-01 01:00:00.000000000 +0100
+++ grub2.time/include/grub/powerpc/time.h	2007-10-21 14:47:03.000000000 +0200
@@ -0,0 +1,28 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2007  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef KERNEL_CPU_TIME_HEADER
+#define KERNEL_CPU_TIME_HEADER	1
+
+static __inline void
+grub_cpu_idle ()
+{
+  /* FIXME: not implemented */
+}
+
+#endif /* ! KERNEL_CPU_TIME_HEADER */
diff -Nurp grub2/include/grub/sparc64/ieee1275/time.h grub2.time/include/grub/sparc64/ieee1275/time.h
--- grub2/include/grub/sparc64/ieee1275/time.h	2007-07-22 01:32:25.000000000 +0200
+++ grub2.time/include/grub/sparc64/ieee1275/time.h	2007-10-21 14:47:03.000000000 +0200
@@ -16,8 +16,8 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef KERNEL_TIME_HEADER
-#define KERNEL_TIME_HEADER	1
+#ifndef KERNEL_MACHINE_TIME_HEADER
+#define KERNEL_MACHINE_TIME_HEADER	1
 
 #include <grub/symbol.h>
 
@@ -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 -Nurp grub2/include/grub/sparc64/time.h grub2.time/include/grub/sparc64/time.h
--- grub2/include/grub/sparc64/time.h	1970-01-01 01:00:00.000000000 +0100
+++ grub2.time/include/grub/sparc64/time.h	2007-10-21 14:47:03.000000000 +0200
@@ -0,0 +1,28 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2007  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef KERNEL_CPU_TIME_HEADER
+#define KERNEL_CPU_TIME_HEADER	1
+
+static __inline void
+grub_cpu_idle ()
+{
+  /* FIXME: not implemented */
+}
+
+#endif /* ! KERNEL_CPU_TIME_HEADER */
diff -Nurp grub2/include/grub/time.h grub2.time/include/grub/time.h
--- grub2/include/grub/time.h	1970-01-01 01:00:00.000000000 +0100
+++ grub2.time/include/grub/time.h	2007-10-21 14:47:03.000000000 +0200
@@ -0,0 +1,35 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2007  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef KERNEL_TIME_HEADER
+#define KERNEL_TIME_HEADER	1
+
+#include <grub/symbol.h>
+#include <grub/machine/time.h>
+#include <grub/cpu/time.h>
+
+void EXPORT_FUNC(grub_millisleep) (grub_uint32_t ms);
+void EXPORT_FUNC(grub_millisleep_generic) (grub_uint32_t ms);
+
+static __inline void
+grub_sleep (grub_uint32_t s)
+{
+  grub_millisleep (1000 * s);
+}
+
+#endif /* ! KERNEL_TIME_HEADER */
diff -Nurp grub2/kern/i386/efi/init.c grub2.time/kern/i386/efi/init.c
--- grub2/kern/i386/efi/init.c	2007-07-22 01:32:27.000000000 +0200
+++ grub2.time/kern/i386/efi/init.c	2007-10-21 14:47:03.000000000 +0200
@@ -25,6 +25,13 @@
 #include <grub/cache.h>
 #include <grub/kernel.h>
 #include <grub/efi/efi.h>
+#include <grub/time.h>
+
+void
+grub_millisleep (grub_uint32_t ms)
+{
+  grub_millisleep_generic (ms);
+}
 
 void
 grub_machine_init (void)
diff -Nurp grub2/kern/i386/pc/init.c grub2.time/kern/i386/pc/init.c
--- grub2/kern/i386/pc/init.c	2007-09-07 23:55:26.000000000 +0200
+++ grub2.time/kern/i386/pc/init.c	2007-10-21 14:47:03.000000000 +0200
@@ -30,6 +30,7 @@
 #include <grub/loader.h>
 #include <grub/env.h>
 #include <grub/cache.h>
+#include <grub/time.h>
 
 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 -Nurp grub2/kern/misc.c grub2.time/kern/misc.c
--- grub2/kern/misc.c	2007-08-02 22:42:19.000000000 +0200
+++ grub2.time/kern/misc.c	2007-10-21 14:47:03.000000000 +0200
@@ -23,6 +23,7 @@
 #include <stdarg.h>
 #include <grub/term.h>
 #include <grub/env.h>
+#include <grub/time.h>
 
 void *
 grub_memmove (void *dest, const void *src, grub_size_t n)
@@ -1041,6 +1042,17 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest, 
   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 -Nurp grub2/kern/powerpc/ieee1275/init.c grub2.time/kern/powerpc/ieee1275/init.c
--- grub2/kern/powerpc/ieee1275/init.c	2007-10-12 12:22:27.000000000 +0200
+++ grub2.time/kern/powerpc/ieee1275/init.c	2007-10-21 14:47:03.000000000 +0200
@@ -27,8 +27,8 @@
 #include <grub/setjmp.h>
 #include <grub/env.h>
 #include <grub/misc.h>
+#include <grub/time.h>
 #include <grub/machine/console.h>
-#include <grub/machine/time.h>
 #include <grub/machine/kernel.h>
 #include <grub/ieee1275/ofdisk.h>
 #include <grub/ieee1275/ieee1275.h>
@@ -47,6 +47,12 @@ extern char _start[];
 extern char _end[];
 
 void
+grub_millisleep (grub_uint32_t ms)
+{
+  grub_millisleep_generic (ms);
+}
+
+void
 grub_exit (void)
 {
   /* Trap to Open Firmware.  */
diff -Nurp grub2/kern/sparc64/ieee1275/init.c grub2.time/kern/sparc64/ieee1275/init.c
--- grub2/kern/sparc64/ieee1275/init.c	2007-07-22 01:32:28.000000000 +0200
+++ grub2.time/kern/sparc64/ieee1275/init.c	2007-10-21 14:47:03.000000000 +0200
@@ -27,8 +27,8 @@
 #include <grub/setjmp.h>
 #include <grub/env.h>
 #include <grub/misc.h>
+#include <grub/time.h>
 #include <grub/machine/console.h>
-#include <grub/machine/time.h>
 #include <grub/machine/kernel.h>
 #include <grub/ieee1275/ofdisk.h>
 #include <grub/ieee1275/ieee1275.h>
@@ -66,6 +66,12 @@ _start (uint64_t r0 __attribute__((unuse
   /* Never reached.  */
 }
 
+void
+grub_millisleep (grub_uint32_t ms)
+{
+  grub_millisleep_generic (ms);
+}
+
 int
 grub_ieee1275_test_flag (enum grub_ieee1275_flag flag)
 {
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to