|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 05/10] lib/syscall_shim: generate base headers
The following headers are generated by the code in this patch:
- syscall_nrs.h - just definitions of all the syscalls with their
numbers
- syscall_map.h - provides maps from syscall number to a concrete
function in the Unikarft
- syscall_stubs.h - if no library is providing a syscall, it will be
resolved to a stub, defined in this file
Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
lib/Config.uk | 1 +
lib/Makefile.uk | 1 +
lib/syscall_shim/Config.uk | 3 +++
lib/syscall_shim/Makefile.uk | 40 ++++++++++++++++++++++++++++++++++
lib/syscall_shim/gen_stubs.awk | 8 +++++++
5 files changed, 53 insertions(+)
create mode 100644 lib/syscall_shim/Config.uk
create mode 100644 lib/syscall_shim/Makefile.uk
create mode 100644 lib/syscall_shim/gen_stubs.awk
diff --git a/lib/Config.uk b/lib/Config.uk
index 822c624f..b517abd8 100644
--- a/lib/Config.uk
+++ b/lib/Config.uk
@@ -47,3 +47,4 @@ source "lib/ukswrand/Config.uk"
source "lib/ukbus/Config.uk"
source "lib/uksglist/Config.uk"
source "lib/uknetdev/Config.uk"
+source "lib/syscall_shim/Config.uk"
diff --git a/lib/Makefile.uk b/lib/Makefile.uk
index d06837f1..e6664952 100644
--- a/lib/Makefile.uk
+++ b/lib/Makefile.uk
@@ -24,3 +24,4 @@ $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukmpi))
$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukbus))
$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/uksglist))
$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/uknetdev))
+$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/syscall_shim))
diff --git a/lib/syscall_shim/Config.uk b/lib/syscall_shim/Config.uk
new file mode 100644
index 00000000..f88cf970
--- /dev/null
+++ b/lib/syscall_shim/Config.uk
@@ -0,0 +1,3 @@
+config LIBSYSCALL_SHIM
+ bool "Syscall shim layer"
+ default n
diff --git a/lib/syscall_shim/Makefile.uk b/lib/syscall_shim/Makefile.uk
new file mode 100644
index 00000000..52a12f18
--- /dev/null
+++ b/lib/syscall_shim/Makefile.uk
@@ -0,0 +1,40 @@
+$(eval $(call addlib_s,libsyscall_shim,$(CONFIG_LIBSYSCALL_SHIM)))
+
+__GEN_INCLUDES_PATH := $(LIBSYSCALL_SHIM_BUILD)/include/uk/bits
+
+__PHONY_GEN_SRC := syscall_map.h syscall_stubs.h syscall_nrs.h
+__PHONY_GEN_SRC := $(addprefix $(__GEN_INCLUDES_PATH)/, $(__PHONY_GEN_SRC))
+__PHONY_GEN_SRC_NEW := $(addsuffix .new, $(__PHONY_GEN_SRC))
+
+UK_PREPARE-$(CONFIG_LIBSYSCALL_SHIM) += $(__PHONY_GEN_SRC)
+
+
+__SYSCALL_SHIM_TEMPL :=
$(LIBSYSCALL_SHIM_BASE)/arch/$(CONFIG_UK_ARCH)/syscall.h.in
+
+$(call uk_mk_dir, $(__GEN_INCLUDES_PATH))
+
+.PHONY: $(__PHONY_GEN_SRC_NEW)
+
+$(__PHONY_GEN_SRC): %: %.new
+ @cmp -s $^ $@; if [ $$? -ne 0 ]; then cp $^ $@; fi
+
+$(__GEN_INCLUDES_PATH)/syscall_nrs.h.new:
+ $(Q) awk 'BEGIN {print "/* Automatically generated file; DO NOT EDIT
*/"} \
+ {printf "\n#define SYS_%s\t\t%s", \
+ substr($$2,6),$$3}' \
+ $(__SYSCALL_SHIM_TEMPL) > $@
+
+$(__GEN_INCLUDES_PATH)/syscall_map.h.new:
+ $(Q) awk 'BEGIN \
+ {print "/* Automatically generated file; DO NOT EDIT */\n"} \
+ /#define __NR_/{\
+ printf "#define uk_syscall_fn_%s(...)
uk_syscall_%s(__VA_ARGS__)\n", \
+ $$3,substr($$2,6)\
+ }' \
+ $(__SYSCALL_SHIM_TEMPL) > $@
+
+$(__GEN_INCLUDES_PATH)/syscall_stubs.h.new:
+ $(Q) $(AWK) -f $(LIBSYSCALL_SHIM_BASE)/gen_stubs.awk \
+ $(__SYSCALL_SHIM_TEMPL) > $@
+
+LIBSYSCALL_SHIM_CLEAN = $(__PHONY_GEN_SRC) $(__PHONY_GEN_SRC_NEW)
diff --git a/lib/syscall_shim/gen_stubs.awk b/lib/syscall_shim/gen_stubs.awk
new file mode 100644
index 00000000..9e0ad6c6
--- /dev/null
+++ b/lib/syscall_shim/gen_stubs.awk
@@ -0,0 +1,8 @@
+BEGIN { print "/* Auto generated file. Do not edit */" }
+{
+ name = substr($2,6);
+ uk_name = "uk_syscall_" name
+ printf "\n#ifndef HAVE_%s", uk_name;
+ printf "\n#define %s(...) uk_syscall_stub(\"%s\")", uk_name, name;
+ printf "\n#endif /* HAVE_%s */\n", uk_name;
+}
--
2.19.2
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |