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

[Minios-devel] [UNIKRAFT PATCH v2 4/9] 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         | 38 ++++++++++++++++++++++++++++
 lib/syscall_shim/gen_stubs.awk       |  8 ++++++
 lib/syscall_shim/gen_syscall_map.awk |  4 +++
 lib/syscall_shim/gen_syscall_nrs.awk |  4 +++
 7 files changed, 59 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
 create mode 100644 lib/syscall_shim/gen_syscall_map.awk
 create mode 100644 lib/syscall_shim/gen_syscall_nrs.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..520e9206
--- /dev/null
+++ b/lib/syscall_shim/Makefile.uk
@@ -0,0 +1,38 @@
+$(eval $(call addlib_s,libsyscall_shim,$(CONFIG_LIBSYSCALL_SHIM)))
+
+LIBSYSCALL_SHIM_INCLUDES_PATH := $(LIBSYSCALL_SHIM_BUILD)/include/uk/bits
+
+LIBSYSCALL_SHIM_PHONY_SRC := syscall_map.h syscall_stubs.h syscall_nrs.h
+LIBSYSCALL_SHIM_PHONY_SRC := $(addprefix $(LIBSYSCALL_SHIM_INCLUDES_PATH)/, 
$(LIBSYSCALL_SHIM_PHONY_SRC))
+LIBSYSCALL_SHIM_PHONY_SRC_NEW := $(addsuffix .new, 
$(LIBSYSCALL_SHIM_PHONY_SRC))
+
+UK_PREPARE-$(CONFIG_LIBSYSCALL_SHIM) += $(LIBSYSCALL_SHIM_PHONY_SRC)
+
+
+LIBSYSCALL_SHIM_TEMPL := 
$(LIBSYSCALL_SHIM_BASE)/arch/$(CONFIG_UK_ARCH)/syscall.h.in
+
+$(if $(shell mkdir -p $(LIBSYSCALL_SHIM_INCLUDES_PATH) && \
+       cd $(LIBSYSCALL_SHIM_INCLUDES_PATH) >/dev/null && pwd),,\
+               $(error could not create directory $1))
+
+.PHONY: $(LIBSYSCALL_SHIM_PHONY_SRC_NEW)
+
+$(LIBSYSCALL_SHIM_PHONY_SRC): %: %.new
+       @cmp -s $^ $@; if [ $$? -ne 0 ]; then cp $^ $@; fi
+
+$(LIBSYSCALL_SHIM_INCLUDES_PATH)/syscall_nrs.h.new:
+       $(call build_cmd,GEN,SYSCALL_SHIM,$(notdir $@), \
+               $(AWK) -f $(LIBSYSCALL_SHIM_BASE)/gen_syscall_nrs.awk \
+               $(LIBSYSCALL_SHIM_TEMPL) > $@)
+
+$(LIBSYSCALL_SHIM_INCLUDES_PATH)/syscall_map.h.new:
+       $(call build_cmd,GEN,SYSCALL_SHIM,$(notdir $@), \
+               $(AWK) -f  $(LIBSYSCALL_SHIM_BASE)/gen_syscall_map.awk \
+               $(LIBSYSCALL_SHIM_TEMPL) > $@)
+
+$(LIBSYSCALL_SHIM_INCLUDES_PATH)/syscall_stubs.h.new:
+       $(call build_cmd,GEN,SYSCALL_SHIM,$(notdir $@), \
+               $(AWK) -f $(LIBSYSCALL_SHIM_BASE)/gen_stubs.awk \
+               $(LIBSYSCALL_SHIM_TEMPL) > $@)
+
+LIBSYSCALL_SHIM_CLEAN = $(LIBSYSCALL_SHIM_PHONY_SRC) 
$(LIBSYSCALL_SHIM_PHONY_SRC_NEW)
diff --git a/lib/syscall_shim/gen_stubs.awk b/lib/syscall_shim/gen_stubs.awk
new file mode 100644
index 00000000..de136f18
--- /dev/null
+++ b/lib/syscall_shim/gen_stubs.awk
@@ -0,0 +1,8 @@
+BEGIN { print "/* Auto generated file. Do not edit */" }
+/#define __NR_/ {
+       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;
+}
diff --git a/lib/syscall_shim/gen_syscall_map.awk 
b/lib/syscall_shim/gen_syscall_map.awk
new file mode 100644
index 00000000..99b247dd
--- /dev/null
+++ b/lib/syscall_shim/gen_syscall_map.awk
@@ -0,0 +1,4 @@
+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)
+}
diff --git a/lib/syscall_shim/gen_syscall_nrs.awk 
b/lib/syscall_shim/gen_syscall_nrs.awk
new file mode 100644
index 00000000..96a2d6a4
--- /dev/null
+++ b/lib/syscall_shim/gen_syscall_nrs.awk
@@ -0,0 +1,4 @@
+BEGIN {print "/* Automatically generated file; DO NOT EDIT */"}
+/#define __NR_/{
+        printf "\n#define SYS_%s\t\t%s", substr($2,6),$3
+}
-- 
2.19.2


_______________________________________________
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®.