sys_exec and sys_proc_create now use argenv (XCC)
[akaros.git] / kern / src / time.c
index 3179b80..f298ba7 100644 (file)
@@ -56,11 +56,6 @@ void udelay_sched(uint64_t usec)
  * you want something to happen in the future, set an alarm. */
 void timer_interrupt(struct hw_trapframe *hw_tf, void *data)
 {
-       if (in_kernel(hw_tf))
-               oprofile_add_backtrace(get_hwtf_pc(hw_tf), get_hwtf_fp(hw_tf));
-       else
-               oprofile_add_userpc(get_hwtf_pc(hw_tf));
-
        __trigger_tchain(&per_cpu_info[core_id()].tchain, hw_tf);
 }
 
@@ -133,9 +128,38 @@ uint64_t nsec2tsc(uint64_t nsec)
                return (nsec * system_timing.tsc_freq) / 1000000000;
 }
 
-uint64_t epoch_seconds(void)
+/* TODO: figure out what epoch time TSC == 0 is and store that as boot_tsc */
+static uint64_t boot_sec = 1242129600; /* nanwan's birthday */
+
+uint64_t epoch_tsc(void)
+{
+       return read_tsc() + sec2tsc(boot_sec);
+}
+
+uint64_t epoch_sec(void)
+{
+       return tsc2sec(epoch_tsc());
+}
+
+uint64_t epoch_msec(void)
+{
+       return tsc2msec(epoch_tsc());
+}
+
+uint64_t epoch_usec(void)
+{
+       return tsc2usec(epoch_tsc());
+}
+
+uint64_t epoch_nsec(void)
+{
+       return tsc2nsec(epoch_tsc());
+}
+
+void tsc2timespec(uint64_t tsc_time, struct timespec *ts)
 {
-       /* TODO: figure out what epoch time TSC == 0 is */
-       uint64_t boot_sec = 1242129600; /* nanwan's birthday */
-       return tsc2sec(read_tsc()) + boot_sec;
+       ts->tv_sec = tsc2sec(tsc_time);
+       /* subtract off everything but the remainder */
+       tsc_time -= sec2tsc(ts->tv_sec);
+       ts->tv_nsec = tsc2nsec(tsc_time);
 }