YuuichiNakamura commented on a change in pull request #1377:
URL: https://github.com/apache/incubator-nuttx/pull/1377#discussion_r493666398



##########
File path: include/nuttx/sched_note.h
##########
@@ -254,10 +266,78 @@ struct note_irqhandler_s
 };
 #endif /* CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER */
 
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+
+/* This is the type of the argument passed to the TRIOC_GETMODE and
+ * TRIOC_SETMODE ioctls
+ */
+
+struct note_trace_mode_s
+{
+  bool enable;                /* Trace enable */
+  unsigned int flag;          /* Trace mode flag */
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
+#define TRIOC_MODE_FLAG_SYSCALL      (1 << 0) /* Enable syscall trace */
+#define TRIOC_MODE_FLAG_SYSCALL_ARGS (1 << 1) /* Enable collecting syscall 
arguments */
+#endif
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+#define TRIOC_MODE_FLAG_IRQ          (1 << 2) /* Enable IRQ trace */
+#endif
+};
+
+/* This is the type of the argument passed to the TRIOC_GETSYSCALLFILTER and
+ * TRIOC_SETSYSCALLFILTER ioctls
+ */
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
+struct note_trace_syscallfilter_s
+{
+  uint8_t syscall_mask[(SYS_nsyscalls + 7) / 8];
+};
+
+/* Helper macros */
+
+#define SYSCALLMASK_SET(nr, s) \
+  ((s)->syscall_mask[(nr) / 8] |= (1 << ((nr) % 8)))
+#define SYSCALLMASK_CLR(nr, s) \
+  ((s)->syscall_mask[(nr) / 8] &= ~(1 << ((nr) % 8)))
+#define SYSCALLMASK_ISSET(nr, s) \
+  ((s)->syscall_mask[(nr) / 8] & (1 << ((nr) % 8)))
+#define SYSCALLMASK_ZERO(s) \
+  memset((s), 0, sizeof(struct note_trace_syscallfilter_s))
+#endif
+
+/* This is the type of the argument passed to the TRIOC_GETIRQFILTER and
+ * TRIOC_SETIRQFILTER ioctls
+ */
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+struct note_trace_irqfilter_s
+{
+  uint8_t irq_mask[(NR_IRQS + 7) / 8];
+};
+
+/* Helper macros */
+
+#define IRQMASK_SET(nr, s) \
+  ((s)->irq_mask[(nr) / 8] |= (1 << ((nr) % 8)))
+#define IRQMASK_CLR(nr, s) \
+  ((s)->irq_mask[(nr) / 8] &= ~(1 << ((nr) % 8)))
+#define IRQMASK_ISSET(nr, s) \
+  ((s)->irq_mask[(nr) / 8] & (1 << ((nr) % 8)))
+#define IRQMASK_ZERO(s) \
+  memset((s), 0, sizeof(struct note_trace_irqfilter_s))
+#endif
+
+#endif /* CONFIG_SCHED_INSTRUMENTATION_FILTER */
+
 /****************************************************************************
  * Public Function Prototypes
  ****************************************************************************/
 
+#if defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT)

Review comment:
       I have moved it to beginning of the filter APIs.
   I think it is still needed because in the case of PROTECTED and KERNEL 
build, application code requires constants and struct definitions of this file 
to control note filters, but no need kernel function declarations because it 
cannot be called directly. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to