[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 3/6] lib/syscall_shim: uk_syscall_name(), uk_syscall_name_p()
The functions return a string with the name of a given system call number. `uk_syscall_name_p()` does work exactly the same as `uk_syscall_name()` with the difference that it only resolves compiled-in system calls. These are the ones that are populated to UK_PROVIDED_SYSCALLS-y. Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx> --- lib/syscall_shim/Makefile.uk | 17 +++++++++++-- lib/syscall_shim/gen_uk_syscall_name.awk | 20 +++++++++++++++ lib/syscall_shim/gen_uk_syscall_name_p.awk | 20 +++++++++++++++ lib/syscall_shim/include/uk/syscall.h | 29 +++++++++++++++++++++- 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 lib/syscall_shim/gen_uk_syscall_name.awk create mode 100644 lib/syscall_shim/gen_uk_syscall_name_p.awk diff --git a/lib/syscall_shim/Makefile.uk b/lib/syscall_shim/Makefile.uk index bbe98807..015e3aad 100644 --- a/lib/syscall_shim/Makefile.uk +++ b/lib/syscall_shim/Makefile.uk @@ -7,8 +7,10 @@ LIBSYSCALL_SHIM_PHONY_SRC := $(addprefix $(LIBSYSCALL_SHIM_INCLUDES_PATH)/, $(LI LIBSYSCALL_SHIM_PHONY_SRC += $(LIBSYSCALL_SHIM_BUILD)/provided_syscalls.h.in LIBSYSCALL_SHIM_PHONY_SRC_NEW := $(addsuffix .new, $(LIBSYSCALL_SHIM_PHONY_SRC)) -LIBSYSCALL_SHIM_GEN_SRC := $(LIBSYSCALL_SHIM_INCLUDES_PATH)/provided_syscalls.h \ - $(LIBSYSCALL_SHIM_BUILD)/syscall_entry.c +LIBSYSCALL_SHIM_GEN_SRC := $(LIBSYSCALL_SHIM_INCLUDES_PATH)/provided_syscalls.h +LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/syscall_entry.c +LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name.c +LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name_p.c UK_PREPARE-$(CONFIG_LIBSYSCALL_SHIM) += $(LIBSYSCALL_SHIM_PHONY_SRC) $(LIBSYSCALL_SHIM_GEN_SRC) @@ -43,6 +45,15 @@ $(LIBSYSCALL_SHIM_BUILD)/syscall_entry.c: $(LIBSYSCALL_SHIM_BUILD)/provided_sysc $(AWK) -F '-' -f $(LIBSYSCALL_SHIM_BASE)/gen_entry.awk $< > $@ && \ cat $(LIBSYSCALL_SHIM_BASE)/entry.c.in_end >> $@) +$(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name.c: $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall_name.awk $(LIBSYSCALL_SHIM_TEMPL) + $(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \ + $(AWK) -f $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall_name.awk \ + $(LIBSYSCALL_SHIM_TEMPL) > $@) + +$(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name_p.c: $(LIBSYSCALL_SHIM_BUILD)/provided_syscalls.h.in $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall_name_p.awk + $(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \ + $(AWK) -F '-' -f $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall_name_p.awk $< > $@) + $(LIBSYSCALL_SHIM_BUILD)/provided_syscalls.h.in.new: $(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \ echo $(UK_PROVIDED_SYSCALLS-y) | tr ' ' '\n' > $@) @@ -58,5 +69,7 @@ CINCLUDES-y += -I$(LIBSYSCALL_SHIM_BASE)/include CXXINCLUDES-y += -I$(LIBSYSCALL_SHIM_BASE)/include LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/syscall_entry.c +LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name.c +LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name_p.c LIBSYSCALL_SHIM_CLEAN = $(LIBSYSCALL_SHIM_PHONY_SRC) $(LIBSYSCALL_SHIM_PHONY_SRC_NEW) $(LIBSYSCALL_SHIM_GEN_SRC) $(LIBSYSCALL_SHIM_GEN_SRC) diff --git a/lib/syscall_shim/gen_uk_syscall_name.awk b/lib/syscall_shim/gen_uk_syscall_name.awk new file mode 100644 index 00000000..7e99ab2b --- /dev/null +++ b/lib/syscall_shim/gen_uk_syscall_name.awk @@ -0,0 +1,20 @@ +BEGIN { + print "/* Auto generated file. DO NOT EDIT */\n" + + print "#include <stddef.h>\n" + print "#include <uk/syscall.h>\n" + + print "const char *uk_syscall_name(long nr)\n{" + print "\tswitch (nr) {" +} + +/#define __NR_/{ + printf "\tcase SYS_%s:\n", substr($2,6) + printf "\t\treturn \"%s\";\n", substr($2,6) +} + +END { + print "\tdefault:" + print "\t\treturn NULL;" + print "\t}\n}" +} diff --git a/lib/syscall_shim/gen_uk_syscall_name_p.awk b/lib/syscall_shim/gen_uk_syscall_name_p.awk new file mode 100644 index 00000000..c6251299 --- /dev/null +++ b/lib/syscall_shim/gen_uk_syscall_name_p.awk @@ -0,0 +1,20 @@ +BEGIN { + print "/* Auto generated file. DO NOT EDIT */\n" + + print "#include <stddef.h>\n" + print "#include <uk/syscall.h>\n" + + print "const char *uk_syscall_name_p(long nr)\n{" + print "\tswitch (nr) {" +} + +/[a-zA-Z0-9]+-[0-9]+/{ + printf "\tcase SYS_%s:\n", $1 + printf "\t\treturn \"%s\";\n", $1 +} + +END { + print "\tdefault:" + print "\t\treturn NULL;" + print "\t}\n}" +} diff --git a/lib/syscall_shim/include/uk/syscall.h b/lib/syscall_shim/include/uk/syscall.h index 7ef19e5d..54946119 100644 --- a/lib/syscall_shim/include/uk/syscall.h +++ b/lib/syscall_shim/include/uk/syscall.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause */ /* * Authors: Yuri Volchkov <yuri.volchkov@xxxxxxxxx> + * Simon Kuenzer <simon.kuenzer@xxxxxxxxx> * * * Copyright (c) 2019, NEC Laboratories Europe GmbH, NEC Corporation. @@ -154,6 +155,32 @@ long uk_syscall(long n, ...); */ #define uk_syscall_static(...) \ UK_CONCAT(__uk_syscall, __UK_SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__) -#endif + +/** + * Returns a string with the name of the system call number `nr`. + * + * @param nr + * System call number of current architecture + * @return + * - (const char *): name of system call + * - (NULL): if system call number is unknown + */ +const char *uk_syscall_name(long nr); + +/** + * Returns a string with the name of the system call number `nr`. + * This function is similar to `uk_syscall_name` but it uses + * a smaller lookup table internally. This table contains only + * system call name mappings of provided calls. + * + * @param nr + * System call number of current architecture + * @return + * - (const char *): name of provided system call + * - (NULL): if system call is not provided + */ +const char *uk_syscall_name_p(long nr); + +#endif /* CONFIG_LIBSYSCALL_SHIM */ #endif /* __UK_SYSCALL_H__ */ -- 2.20.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |