#include <asm/io.h>
#include <asm/irq.h>
#include <asm/leds.h>
-
+#include <asm/thread_info.h>
#include <asm/mach/time.h>
u64 jiffies_64 = INITIAL_JIFFIES;
/* change this if you have some constant time drift */
#define USECS_PER_JIFFY (1000000/HZ)
+#ifdef CONFIG_SMP
+unsigned long profile_pc(struct pt_regs *regs)
+{
+ unsigned long fp, pc = instruction_pointer(regs);
+
+ if (in_lock_functions(pc)) {
+ fp = thread_saved_fp(current);
+ pc = pc_pointer(((unsigned long *)fp)[-1]);
+ }
+
+ return pc;
+}
+EXPORT_SYMBOL(profile_pc);
+#endif
/*
* hook for setting the RTC's idea of the current time.
return (unsigned long long)jiffies * (1000000000 / HZ);
}
-/*
- * Handle kernel profile stuff...
- */
-static inline void do_profile(struct pt_regs *regs)
-{
-
- profile_hook(regs);
-
- if (!user_mode(regs) &&
- prof_buffer &&
- current->pid) {
- unsigned long pc = instruction_pointer(regs);
- extern int _stext;
-
- pc -= (unsigned long)&_stext;
-
- pc >>= prof_shift;
-
- if (pc >= prof_len)
- pc = prof_len - 1;
-
- prof_buffer[pc] += 1;
- }
-}
-
static unsigned long next_rtc_update;
/*
EXPORT_SYMBOL(do_settimeofday);
+/**
+ * save_time_delta - Save the offset between system time and RTC time
+ * @delta: pointer to timespec to store delta
+ * @rtc: pointer to timespec for current RTC time
+ *
+ * Return a delta between the system time and the RTC time, such
+ * that system time can be restored later with restore_time_delta()
+ */
+void save_time_delta(struct timespec *delta, struct timespec *rtc)
+{
+ set_normalized_timespec(delta,
+ xtime.tv_sec - rtc->tv_sec,
+ xtime.tv_nsec - rtc->tv_nsec);
+}
+EXPORT_SYMBOL(save_time_delta);
+
+/**
+ * restore_time_delta - Restore the current system time
+ * @delta: delta returned by save_time_delta()
+ * @rtc: pointer to timespec for current RTC time
+ */
+void restore_time_delta(struct timespec *delta, struct timespec *rtc)
+{
+ struct timespec ts;
+
+ set_normalized_timespec(&ts,
+ delta->tv_sec + rtc->tv_sec,
+ delta->tv_nsec + rtc->tv_nsec);
+
+ do_settimeofday(&ts);
+}
+EXPORT_SYMBOL(restore_time_delta);
+
void timer_tick(struct pt_regs *regs)
{
- do_profile(regs);
+ profile_tick(CPU_PROFILING, regs);
do_leds();
do_set_rtc();
do_timer(regs);