]> rtime.felk.cvut.cz Git - jailhouse.git/blobdiff - inmates/lib/x86/timing.c
inmates: Add delay_us service to timing library
[jailhouse.git] / inmates / lib / x86 / timing.c
index c3b722fce6e2ab888d1c501b962586f0604eb7f7..bb53a89abe3f7a2ac640473c71044a8b95d1f3c0 100644 (file)
@@ -34,6 +34,14 @@ unsigned long pm_timer_read(void)
        return tmr + overflows;
 }
 
+void delay_us(unsigned long microsecs)
+{
+       unsigned long timeout = pm_timer_read() + microsecs * NS_PER_USEC;
+
+       while ((long)(timeout - pm_timer_read()) > 0)
+               cpu_relax();
+}
+
 unsigned long apic_timer_init(unsigned int vector)
 {
        unsigned long start, end;