You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ar...@apache.org on 2024/03/28 11:05:18 UTC
(nuttx-apps) 01/01: nshlib/irqaff: add irq affinity command
This is an automated email from the ASF dual-hosted git repository.
archer pushed a commit to branch 24032801
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit f7a6a07f42b455c329ceefe773348151911381ce
Author: chao an <an...@lixiang.com>
AuthorDate: Thu Mar 28 18:30:10 2024 +0800
nshlib/irqaff: add irq affinity command
add support for set an IRQ affinity to CPUs by software
Signed-off-by: chao an <an...@lixiang.com>
---
nshlib/Kconfig | 5 +++++
nshlib/nsh.h | 5 +++++
nshlib/nsh_command.c | 5 +++++
nshlib/nsh_syscmds.c | 20 ++++++++++++++++++++
4 files changed, 35 insertions(+)
diff --git a/nshlib/Kconfig b/nshlib/Kconfig
index c1974c5f2..40fdceea1 100644
--- a/nshlib/Kconfig
+++ b/nshlib/Kconfig
@@ -689,6 +689,11 @@ config NSH_DISABLE_RESET_CAUSE
default DEFAULT_SMALL
depends on BOARDCTL_RESET_CAUSE
+config NSH_DISABLE_IRQ_AFFINITY
+ bool "Disable command of irq affinity"
+ default DEFAULT_SMALL
+ depends on BOARDCTL_IRQ_AFFINITY
+
endmenu
if MMCSD
diff --git a/nshlib/nsh.h b/nshlib/nsh.h
index 24bc6c802..574150247 100644
--- a/nshlib/nsh.h
+++ b/nshlib/nsh.h
@@ -1145,6 +1145,11 @@ int cmd_switchboot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
FAR char **argv);
#endif
+#if defined(CONFIG_BOARDCTL_IRQ_AFFINITY) && !defined(CONFIG_NSH_DISABLE_IRQ_AFFINITY)
+ int cmd_irq_affinity(FAR struct nsh_vtbl_s *vtbl, int argc,
+ FAR char **argv);
+#endif
+
#if defined(CONFIG_RPMSG) && !defined(CONFIG_NSH_DISABLE_RPMSG)
int cmd_rpmsg(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
#endif
diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c
index 70cd6ca8d..b66c394e9 100644
--- a/nshlib/nsh_command.c
+++ b/nshlib/nsh_command.c
@@ -497,6 +497,11 @@ static const struct cmdmap_s g_cmdmap[] =
CMD_MAP("resetcause", cmd_reset_cause, 1, 1, NULL),
#endif
+#if defined(CONFIG_BOARDCTL_IRQ_AFFINITY) && !defined(CONFIG_NSH_DISABLE_IRQ_AFFINITY)
+ CMD_MAP("irqaff", cmd_irq_affinity, 3, 3,
+ "irqaff [IRQ Number] [Core Number]"),
+#endif
+
#ifdef NSH_HAVE_DIROPTS
# ifndef CONFIG_NSH_DISABLE_RM
CMD_MAP("rm", cmd_rm, 2, 3, "[-r] <file-path>"),
diff --git a/nshlib/nsh_syscmds.c b/nshlib/nsh_syscmds.c
index 33fe42db3..cd148633a 100644
--- a/nshlib/nsh_syscmds.c
+++ b/nshlib/nsh_syscmds.c
@@ -518,6 +518,26 @@ int cmd_reset_cause(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
}
#endif
+/****************************************************************************
+ * Name: cmd_irq_affinity
+ ****************************************************************************/
+
+#if defined(CONFIG_BOARDCTL_IRQ_AFFINITY) && !defined(CONFIG_NSH_DISABLE_IRQ_AFFINITY)
+int cmd_irq_affinity(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
+{
+ int affinity[2];
+
+ if (argc == 3)
+ {
+ affinity[0] = atoi(argv[1]);
+ affinity[1] = atoi(argv[2]);
+ return boardctl(BOARDIOC_IRQ_AFFINITY, (uintptr_t)affinity);
+ }
+
+ return ERROR;
+}
+#endif
+
/****************************************************************************
* Name: cmd_rpmsg
****************************************************************************/