vserver 1.9.5.x5
[linux-2.6.git] / arch / mips / kernel / time.c
index d0c980a..648c822 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2001 MontaVista Software Inc.
  * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- * Copyright (c) 2003  Maciej W. Rozycki
+ * Copyright (c) 2003, 2004  Maciej W. Rozycki
  *
  * Common time service routines for MIPS machines. See
  * Documentation/mips/time.README.
@@ -11,7 +11,6 @@
  * Free Software Foundation;  either version 2 of the  License, or (at your
  * option) any later version.
  */
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/module.h>
 
 #include <asm/bootinfo.h>
+#include <asm/compiler.h>
 #include <asm/cpu.h>
 #include <asm/cpu-features.h>
 #include <asm/div64.h>
-#include <asm/hardirq.h>
 #include <asm/sections.h>
 #include <asm/time.h>
 
@@ -53,13 +52,7 @@ EXPORT_SYMBOL(jiffies_64);
  */
 extern volatile unsigned long wall_jiffies;
 
-spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED;
-
-/*
- * whether we emulate local_timer_interrupts for SMP machines.
- */
-int emulate_local_timer_interrupt;
-
+DEFINE_SPINLOCK(rtc_lock);
 
 /*
  * By default we provide the null RTC ops
@@ -278,7 +271,7 @@ static unsigned long fixed_rate_gettimeoffset(void)
        __asm__("multu  %1,%2"
                : "=h" (res)
                : "r" (count), "r" (sll32_usecs_per_cycle)
-               : "lo", "accum");
+               : "lo", GCC_REG_ACCUM);
 
        /*
         * Due to possible jiffies inconsistencies, we need to check
@@ -333,7 +326,7 @@ static unsigned long calibrate_div32_gettimeoffset(void)
        __asm__("multu  %1,%2"
                : "=h" (res)
                : "r" (count), "r" (quotient)
-               : "lo", "accum");
+               : "lo", GCC_REG_ACCUM);
 
        /*
         * Due to possible jiffies inconsistencies, we need to check
@@ -375,7 +368,7 @@ static unsigned long calibrate_div64_gettimeoffset(void)
                                : "r" (timerhi), "m" (timerlo),
                                  "r" (tmp), "r" (USECS_PER_JIFFY),
                                  "r" (USECS_PER_JIFFY_FRAC)
-                               : "hi", "lo", "accum");
+                               : "hi", "lo", GCC_REG_ACCUM);
                        cached_quotient = quotient;
                }
        }
@@ -389,7 +382,7 @@ static unsigned long calibrate_div64_gettimeoffset(void)
        __asm__("multu  %1,%2"
                : "=h" (res)
                : "r" (count), "r" (quotient)
-               : "lo", "accum");
+               : "lo", GCC_REG_ACCUM);
 
        /*
         * Due to possible jiffies inconsistencies, we need to check
@@ -417,27 +410,9 @@ static long last_rtc_update;
  */
 void local_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-       if (!user_mode(regs)) {
-               if (prof_buffer && current->pid) {
-                       unsigned long pc = regs->cp0_epc;
-
-                       pc -= (unsigned long) _stext;
-                       pc >>= prof_shift;
-                       /*
-                        * Dont ignore out-of-bounds pc values silently,
-                        * put them into the last histogram slot, so if
-                        * present, they will show up as a sharp peak.
-                        */
-                       if (pc > prof_len - 1)
-                               pc = prof_len - 1;
-                       atomic_inc((atomic_t *)&prof_buffer[pc]);
-               }
-       }
-
-#ifdef CONFIG_SMP
-       /* in UP mode, update_process_times() is invoked by do_timer() */
+       if (current->pid)
+               profile_tick(CPU_PROFILING, regs);
        update_process_times(user_mode(regs));
-#endif
 }
 
 /*
@@ -521,7 +496,6 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                }
        }
 
-#if !defined(CONFIG_SMP)
        /*
         * In UP mode, we call local_timer_interrupt() to do profiling
         * and process accouting.
@@ -531,21 +505,6 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
         */
        local_timer_interrupt(irq, dev_id, regs);
 
-#else  /* CONFIG_SMP */
-
-       if (emulate_local_timer_interrupt) {
-               /*
-                * this is the place where we send out inter-process
-                * interrupts and let each CPU do its own profiling
-                * and process accouting.
-                *
-                * Obviously we need to call local_timer_interrupt() for
-                * the current CPU too.
-                */
-               panic("Not implemented yet!!!");
-       }
-#endif /* CONFIG_SMP */
-
        return IRQ_HANDLED;
 }
 
@@ -789,3 +748,8 @@ EXPORT_SYMBOL(rtc_lock);
 EXPORT_SYMBOL(to_tm);
 EXPORT_SYMBOL(rtc_set_time);
 EXPORT_SYMBOL(rtc_get_time);
+
+unsigned long long sched_clock(void)
+{
+       return (unsigned long long)jiffies*(1000000000/HZ);
+}