[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT early RFC PATCH 01/11] lib/nolibc: Introduce ndelay and mdelay for busy wait



Signed-off-by: Jia He <justin.he@xxxxxxx>
---
 lib/nolibc/exportsyms.uk  |  4 ++++
 lib/nolibc/include/time.h |  3 +++
 lib/nolibc/time.c         | 16 ++++++++++++++--
 plat/kvm/Makefile.uk      |  1 +
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/lib/nolibc/exportsyms.uk b/lib/nolibc/exportsyms.uk
index cae6e29..11afda8 100644
--- a/lib/nolibc/exportsyms.uk
+++ b/lib/nolibc/exportsyms.uk
@@ -74,6 +74,10 @@ strlcat
 nanosleep
 clock_gettime
 
+# busywait delay
+ndelay
+mdelay
+
 # unistd
 sleep
 
diff --git a/lib/nolibc/include/time.h b/lib/nolibc/include/time.h
index f77bb2f..89cc3a4 100644
--- a/lib/nolibc/include/time.h
+++ b/lib/nolibc/include/time.h
@@ -58,6 +58,9 @@ struct itimerspec {
 int nanosleep(const struct timespec *req, struct timespec *rem);
 int clock_gettime(clockid_t clk, struct timespec *tp);
 
+void ndelay(__u64 nsec);
+void mdelay(__u64 msec);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/nolibc/time.c b/lib/nolibc/time.c
index f884531..d06c3c1 100644
--- a/lib/nolibc/time.c
+++ b/lib/nolibc/time.c
@@ -41,9 +41,8 @@
 #include <uk/config.h>
 #if CONFIG_HAVE_SCHED
 #include <uk/sched.h>
-#else
-#include <uk/plat/lcpu.h>
 #endif
+#include <uk/plat/lcpu.h>
 #include <uk/essentials.h>
 
 #ifndef CONFIG_HAVE_SCHED
@@ -143,3 +142,16 @@ int clock_gettime(clockid_t clk_id, struct timespec *tp)
        tp->tv_nsec = ukarch_time_subsec(now);
        return 0;
 }
+
+void ndelay(__u64 nsec)
+{
+       __nsec until = ukplat_monotonic_clock() + nsec;
+
+       while (until > ukplat_monotonic_clock())
+               ukplat_lcpu_halt_to(until);
+}
+
+void mdelay(__u64 msec)
+{
+       ndelay(msec/1000);
+}
diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk
index 34d8b14..1c7b242 100644
--- a/plat/kvm/Makefile.uk
+++ b/plat/kvm/Makefile.uk
@@ -19,6 +19,7 @@ LIBKVMPLAT_ASINCLUDES-y        += 
-I$(UK_PLAT_COMMON_BASE)/include
 LIBKVMPLAT_CINCLUDES-y         += -I$(LIBKVMPLAT_BASE)/include
 LIBKVMPLAT_CINCLUDES-y         += -I$(UK_PLAT_COMMON_BASE)/include
 LIBKVMPLAT_CINCLUDES-$(CONFIG_ARCH_ARM_64)         += 
-I$(UK_PLAT_DRIVERS_BASE)/include
+LIBKVMPLAT_CINCLUDES-$(CONFIG_ARCH_ARM_64)         += 
-I$(LIBNOLIBC_BASE)/include
 
 LIBKVMPLAT_ASFLAGS             += -DKVMPLAT
 LIBKVMPLAT_CFLAGS              += -DKVMPLAT
-- 
2.17.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.