]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Add clock
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 9 Dec 2009 16:58:48 +0000 (17:58 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 9 Dec 2009 16:58:48 +0000 (17:58 +0100)
include/grub/mips/yeeloong/memory.h
include/grub/mips/yeeloong/time.h
include/grub/time.h
kern/mips/yeeloong/init.c
loader/mips/linux.c

index c85db712a720c2a43e93cb743e0209b4813e78cc..922db2404f2840a8c73f67efacc35492138698c8 100644 (file)
@@ -62,8 +62,6 @@ grub_uint64_t grub_mmap_get_upper (void);
 
 extern grub_uint32_t EXPORT_VAR (grub_arch_memsize);
 extern grub_uint32_t EXPORT_VAR (grub_arch_highmemsize);
-extern grub_uint32_t EXPORT_VAR (grub_arch_busclock);
-extern grub_uint32_t EXPORT_VAR (grub_arch_cpuclock);
 
 #endif
 
index a73f64deab3f29c205af142fe1c8285daf60da71..7f468bf124ec2d23d27555b788e9a1992b0c829d 100644 (file)
 
 #include <grub/symbol.h>
 
-#define GRUB_TICKS_PER_SECOND  1000
+#define GRUB_TICKS_PER_SECOND  (grub_arch_cpuclock / 2)
 
 /* Return the real time in ticks.  */
-grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void);
+grub_uint64_t EXPORT_FUNC (grub_get_rtc) (void);
+
+extern grub_uint32_t EXPORT_VAR (grub_arch_busclock);
+extern grub_uint32_t EXPORT_VAR (grub_arch_cpuclock);
 
 static inline void
 grub_cpu_idle(void)
index 115fbd95e869197de92c9620c72817e16dfad5fd..5aafdc9ed6359c71653907ed906ab843d056df71 100644 (file)
@@ -23,7 +23,7 @@
 #include <grub/symbol.h>
 #include <grub/cpu/time.h>
 
-#ifdef GRUB_MACHINE_EMU
+#if defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL)
 #define GRUB_TICKS_PER_SECOND 100000
 #else
 #include <grub/machine/time.h>
index 1bd9d2ed9c6bf19ef796d93ee7f0643116744918..8b93ac18f485baf2bde23fc695d11483ce321a9d 100644 (file)
 #include <grub/machine/memory.h>
 #include <grub/cpu/kernel.h>
 
-grub_uint32_t
+/* FIXME: use interrupt to count high.  */
+grub_uint64_t
 grub_get_rtc (void)
 {
-  static grub_uint64_t calln = 0;
+  static grub_uint32_t high = 0;
+  static grub_uint32_t last = 0;
+  grub_uint32_t low;
 
-  return (calln++) >> 8;
+  asm volatile ("mfc0 %0, $9": "=r" (low));
+  if (low < last)
+    high++;
+  last = low;
+
+  return (((grub_uint64_t) high) << 32) | low;
 }
 
 grub_err_t
index bb71d63e9da3847dad81131c7caa04c4a5ca9f96..8d7cda0ed65390ca8509d3e24d10ba93e85005f3 100644 (file)
@@ -30,6 +30,7 @@
 
 /* For frequencies.  */
 #include <grub/pci.h>
+#include <grub/machine/time.h>
 
 #define ELF32_LOADMASK (0x00000000UL)
 #define ELF64_LOADMASK (0x0000000000000000ULL)