You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/06/25 08:30:09 UTC

[incubator-nuttx] 03/03: Syscall instrumentation build system support for Arm and RISC-V

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch feature/syscall-instrumentation
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 159b7b49087c9a203dafc0597a07678419432ba8
Author: Nakamura, Yuuichi <Yu...@sony.com>
AuthorDate: Tue Jun 16 12:16:17 2020 +0900

    Syscall instrumentation build system support for Arm and RISC-V
---
 arch/Kconfig                              | 2 ++
 arch/arm/src/Makefile                     | 8 +++++++-
 arch/risc-v/src/Makefile                  | 8 +++++++-
 arch/risc-v/src/common/riscv_initialize.c | 6 ++++++
 sched/Kconfig                             | 2 +-
 5 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 21e3f5d..d49d844 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -14,6 +14,7 @@ config ARCH_ARM
 	select ARCH_HAVE_STACKCHECK
 	select ARCH_HAVE_CUSTOMOPT
 	select ARCH_HAVE_STDARG_H
+	select ARCH_HAVE_SYSCALL_HOOKS
 	---help---
 		The ARM architectures
 
@@ -60,6 +61,7 @@ config ARCH_RISCV
 	select ARCH_HAVE_STACKCHECK
 	select ARCH_HAVE_CUSTOMOPT
 	select ARCH_HAVE_STDARG_H
+	select ARCH_HAVE_SYSCALL_HOOKS
 	---help---
 		RISC-V 32 and 64-bit RV32 / RV64 architectures.
 
diff --git a/arch/arm/src/Makefile b/arch/arm/src/Makefile
index 0066baa..1c28a2c 100644
--- a/arch/arm/src/Makefile
+++ b/arch/arm/src/Makefile
@@ -69,6 +69,12 @@ else
   NUTTX = "$(TOPDIR)$(DELIM)nuttx$(EXEEXT)"
 endif
 
+# Additional rules for system call wrapper
+
+ifeq ($(CONFIG_SCHED_INSTRUMENTATION_SYSCALL),y)
+  EXTRALINKCMDS += @$(TOPDIR)/syscall/syscall_wraps.ldcmd
+endif
+
 # The "head" object
 
 HEAD_OBJ = $(HEAD_ASRC:.S=$(OBJEXT))
@@ -99,7 +105,7 @@ UOBJS = $(UAOBJS) $(UCOBJS)
 KBIN = libkarch$(LIBEXT)
 BIN  = libarch$(LIBEXT)
 
-LDFLAGS += $(ARCHSCRIPT)
+LDFLAGS += $(ARCHSCRIPT) $(EXTRALINKCMDS)
 
 # Override in Make.defs if linker is not 'ld'
 
diff --git a/arch/risc-v/src/Makefile b/arch/risc-v/src/Makefile
index 1ba7a6e..806eeec 100644
--- a/arch/risc-v/src/Makefile
+++ b/arch/risc-v/src/Makefile
@@ -66,6 +66,12 @@ else
   NUTTX = "$(TOPDIR)$(DELIM)nuttx$(EXEEXT)"
 endif
 
+# Additional rules for system call wrapper
+
+ifeq ($(CONFIG_SCHED_INSTRUMENTATION_SYSCALL),y)
+  EXTRALINKCMDS += @$(TOPDIR)/syscall/syscall_wraps.ldcmd
+endif
+
 # The "head" object
 
 HEAD_OBJ = $(HEAD_ASRC:.S=$(OBJEXT))
@@ -96,7 +102,7 @@ UOBJS = $(UAOBJS) $(UCOBJS)
 KBIN = libkarch$(LIBEXT)
 BIN  = libarch$(LIBEXT)
 
-LDFLAGS += $(ARCHSCRIPT)
+LDFLAGS += $(ARCHSCRIPT) $(EXTRALINKCMDS)
 
 LDSTARTGROUP ?= --start-group
 LDENDGROUP ?= --end-group
diff --git a/arch/risc-v/src/common/riscv_initialize.c b/arch/risc-v/src/common/riscv_initialize.c
index c21353f..b2cea94 100644
--- a/arch/risc-v/src/common/riscv_initialize.c
+++ b/arch/risc-v/src/common/riscv_initialize.c
@@ -44,6 +44,7 @@
 
 #include <nuttx/arch.h>
 #include <nuttx/board.h>
+#include <nuttx/sched_note.h>
 #include <nuttx/serial/pty.h>
 #include <nuttx/syslog/syslog_console.h>
 #include <nuttx/drivers/drivers.h>
@@ -144,6 +145,11 @@ void up_initialize(void)
   devzero_register();   /* Standard /dev/zero */
 #endif
 
+#if defined(CONFIG_SCHED_INSTRUMENTATION_BUFFER) && \
+    defined(CONFIG_DRIVER_NOTE)
+  note_register();    /* Non-standard /dev/note */
+#endif
+
   /* Initialize the serial device driver */
 
 #ifdef USE_SERIALDRIVER
diff --git a/sched/Kconfig b/sched/Kconfig
index 460b58a..f57bb4a 100644
--- a/sched/Kconfig
+++ b/sched/Kconfig
@@ -975,7 +975,7 @@ config SCHED_INSTRUMENTATION_SPINLOCKS
 config SCHED_INSTRUMENTATION_SYSCALL
 	bool "System call monitor hooks"
 	default n
-	depends on LIB_SYSCALL && ARCH_HAVE_SYSCALL_HOOKS
+	depends on ARCH_HAVE_SYSCALL_HOOKS
 	---help---
 		Enables additional hooks for entry and exit from system call.
 		Board-specific logic must provide this additional logic.