1*e70bc57bSJanosch Frank #ifndef TIME_H 2*e70bc57bSJanosch Frank #define TIME_H 3*e70bc57bSJanosch Frank get_clock(void)4*e70bc57bSJanosch Frankstatic inline u64 get_clock(void) 5*e70bc57bSJanosch Frank { 6*e70bc57bSJanosch Frank u64 r; 7*e70bc57bSJanosch Frank 8*e70bc57bSJanosch Frank asm volatile("stck %0" : "=Q" (r) : : "cc"); 9*e70bc57bSJanosch Frank return r; 10*e70bc57bSJanosch Frank } 11*e70bc57bSJanosch Frank get_time_ms(void)12*e70bc57bSJanosch Frankstatic inline u64 get_time_ms(void) 13*e70bc57bSJanosch Frank { 14*e70bc57bSJanosch Frank /* Bit 51 is incremented each microsecond */ 15*e70bc57bSJanosch Frank return (get_clock() >> 12) / 1000; 16*e70bc57bSJanosch Frank } 17*e70bc57bSJanosch Frank get_time_seconds(void)18*e70bc57bSJanosch Frankstatic inline u64 get_time_seconds(void) 19*e70bc57bSJanosch Frank { 20*e70bc57bSJanosch Frank return get_time_ms() / 1000; 21*e70bc57bSJanosch Frank } 22*e70bc57bSJanosch Frank 23*e70bc57bSJanosch Frank #endif 24