mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 04:16:35 +08:00
note:support filter for each note channel
Signed-off-by: zhangwenjian <zhangwenjian@xiaomi.com>
This commit is contained in:
+259
-179
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg);
|
||||
static int notectl_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@@ -62,7 +62,7 @@ static const struct file_operations g_notectl_fops =
|
||||
* Name: notectl_ioctl
|
||||
****************************************************************************/
|
||||
|
||||
static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
static int notectl_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
int ret = -ENOSYS;
|
||||
|
||||
@@ -77,7 +77,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_GETMODE:
|
||||
{
|
||||
struct note_filter_mode_s *mode = (struct note_filter_mode_s *)arg;
|
||||
FAR struct note_filter_named_mode_s *mode =
|
||||
(FAR struct note_filter_named_mode_s *)arg;
|
||||
|
||||
if (mode == NULL)
|
||||
{
|
||||
@@ -98,7 +99,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_SETMODE:
|
||||
{
|
||||
struct note_filter_mode_s *mode = (struct note_filter_mode_s *)arg;
|
||||
FAR struct note_filter_named_mode_s *mode =
|
||||
(FAR struct note_filter_named_mode_s *)arg;
|
||||
|
||||
if (mode == NULL)
|
||||
{
|
||||
@@ -120,8 +122,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_GETSYSCALLFILTER:
|
||||
{
|
||||
struct note_filter_syscall_s *filter;
|
||||
filter = (struct note_filter_syscall_s *)arg;
|
||||
FAR struct note_filter_named_syscall_s *filter;
|
||||
filter = (FAR struct note_filter_named_syscall_s *)arg;
|
||||
|
||||
if (filter == NULL)
|
||||
{
|
||||
@@ -142,8 +144,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_SETSYSCALLFILTER:
|
||||
{
|
||||
struct note_filter_syscall_s *filter;
|
||||
filter = (struct note_filter_syscall_s *)arg;
|
||||
FAR struct note_filter_named_syscall_s *filter;
|
||||
filter = (FAR struct note_filter_named_syscall_s *)arg;
|
||||
|
||||
if (filter == NULL)
|
||||
{
|
||||
@@ -166,8 +168,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_GETIRQFILTER:
|
||||
{
|
||||
struct note_filter_irq_s *filter;
|
||||
filter = (struct note_filter_irq_s *)arg;
|
||||
FAR struct note_filter_named_irq_s *filter;
|
||||
filter = (FAR struct note_filter_named_irq_s *)arg;
|
||||
|
||||
if (filter == NULL)
|
||||
{
|
||||
@@ -189,8 +191,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_SETIRQFILTER:
|
||||
{
|
||||
struct note_filter_irq_s *filter;
|
||||
filter = (struct note_filter_irq_s *)arg;
|
||||
FAR struct note_filter_named_irq_s *filter;
|
||||
filter = (FAR struct note_filter_named_irq_s *)arg;
|
||||
|
||||
if (filter == NULL)
|
||||
{
|
||||
|
||||
@@ -124,6 +124,17 @@ static const struct note_driver_ops_s g_notelog_ops =
|
||||
|
||||
struct note_driver_s g_notelog_driver =
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"log",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_notelog_ops,
|
||||
};
|
||||
|
||||
|
||||
@@ -146,7 +146,20 @@ static const struct note_driver_ops_s g_noteram_ops =
|
||||
|
||||
struct noteram_driver_s g_noteram_driver =
|
||||
{
|
||||
{&g_noteram_ops},
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"ram",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_noteram_ops
|
||||
},
|
||||
g_ramnote_buffer,
|
||||
CONFIG_DRIVERS_NOTERAM_BUFSIZE,
|
||||
#ifdef CONFIG_DRIVERS_NOTERAM_DEFAULT_NOOVERWRITE
|
||||
@@ -1339,17 +1352,35 @@ FAR struct note_driver_s *
|
||||
noteram_initialize(FAR const char *devpath, size_t bufsize, bool overwrite)
|
||||
{
|
||||
FAR struct noteram_driver_s *drv;
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
size_t len = strlen(devpath) + 1;
|
||||
#else
|
||||
size_t len = 0;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
drv = kmm_malloc(sizeof(*drv) + bufsize);
|
||||
drv = kmm_malloc(sizeof(*drv) + len + bufsize);
|
||||
if (drv == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
|
||||
memcpy(drv + 1, devpath, len);
|
||||
drv->driver.name = (FAR const char *)(drv + 1);
|
||||
drv->driver.filter.mode.flag =
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE;
|
||||
|
||||
# ifdef CONFIG_SMP
|
||||
drv->driver.filter.mode.cpuset =
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
drv->driver.ops = &g_noteram_ops;
|
||||
drv->ni_bufsize = bufsize;
|
||||
drv->ni_buffer = (FAR uint8_t *)(drv + 1);
|
||||
drv->ni_buffer = (FAR uint8_t *)(drv + 1) + len;
|
||||
drv->ni_overwrite = overwrite;
|
||||
drv->ni_head = 0;
|
||||
drv->ni_tail = 0;
|
||||
|
||||
@@ -67,7 +67,20 @@ static const struct note_driver_ops_s g_noterpmsg_ops =
|
||||
|
||||
struct noterpmsg_driver_s g_noterpmsg_driver =
|
||||
{
|
||||
{&g_noterpmsg_ops},
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"rpmsg",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_noterpmsg_ops
|
||||
},
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -150,7 +150,20 @@ static const struct note_driver_ops_s g_notesnap_ops =
|
||||
|
||||
static struct notesnap_s g_notesnap =
|
||||
{
|
||||
{&g_notesnap_ops}
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"snap",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_notesnap_ops
|
||||
}
|
||||
};
|
||||
|
||||
static FAR const char *g_notesnap_type[] =
|
||||
|
||||
@@ -65,6 +65,17 @@ static const struct note_driver_ops_s g_notestream_ops =
|
||||
struct notestream_driver_s g_notestream_lowerout =
|
||||
{
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"lowerout",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_notestream_ops
|
||||
},
|
||||
&g_lowoutstream
|
||||
@@ -91,14 +102,32 @@ static void notestream_add(FAR struct note_driver_s *drv,
|
||||
int notefile_register(FAR const char *filename)
|
||||
{
|
||||
FAR struct notestream_file_s *notefile;
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
size_t len = strlen(filename) + 1;
|
||||
#else
|
||||
size_t len = 0;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
notefile = kmm_zalloc(sizeof(struct notestream_file_s));
|
||||
notefile = kmm_zalloc(sizeof(struct notestream_file_s) + len);
|
||||
if (notefile == NULL)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
memcpy(notefile + 1, filename, len);
|
||||
notefile->driver.driver.name = (FAR const char *)(notefile + 1);
|
||||
notefile->driver.driver.filter.mode.flag =
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE;
|
||||
|
||||
# ifdef CONFIG_SMP
|
||||
notefile->driver.driver.filter.mode.cpuset =
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
notefile->driver.stream = ¬efile->filestream.common;
|
||||
ret = file_open(¬efile->file, filename, O_WRONLY);
|
||||
if (ret < 0)
|
||||
|
||||
Reference in New Issue
Block a user