summaryrefslogtreecommitdiffstats
path: root/schedsim/shell/shared
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2014-05-26 12:46:20 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-05-26 12:46:20 -0500
commite340e9652d1586fd6990f8bb5119c1c14e332385 (patch)
treef4f5f1a43787ac9b9a8fc62e4d858cf4c35ecd4c /schedsim/shell/shared
parentconfigure.ac: Generate config.h (diff)
downloadrtems-schedsim-e340e9652d1586fd6990f8bb5119c1c14e332385.tar.bz2
current_cpu is now a shared SMP command
Diffstat (limited to 'schedsim/shell/shared')
-rw-r--r--schedsim/shell/shared/Makefile.am1
-rw-r--r--schedsim/shell/shared/commands.c2
-rw-r--r--schedsim/shell/shared/main_currentcpu.c60
3 files changed, 63 insertions, 0 deletions
diff --git a/schedsim/shell/shared/Makefile.am b/schedsim/shell/shared/Makefile.am
index 846497f..c90824e 100644
--- a/schedsim/shell/shared/Makefile.am
+++ b/schedsim/shell/shared/Makefile.am
@@ -53,6 +53,7 @@ libschedsim_a_SOURCES += shell_cmdset.c
libschedsim_a_SOURCES += shell_makeargs.c
if HAS_SMP
libschedsim_a_SOURCES += smp_stub.c
+libschedsim_a_SOURCES += main_currentcpu.c
libschedsim_a_SOURCES += main_taskgetaffinity.c
libschedsim_a_SOURCES += main_tasksetaffinity.c
endif
diff --git a/schedsim/shell/shared/commands.c b/schedsim/shell/shared/commands.c
index 457ec9f..483c7ef 100644
--- a/schedsim/shell/shared/commands.c
+++ b/schedsim/shell/shared/commands.c
@@ -34,6 +34,7 @@ extern rtems_shell_cmd_t rtems_shell_TASK_WAKE_AFTER_Command;
#if RTEMS_SMP
extern rtems_shell_cmd_t rtems_shell_TASK_GET_AFFINITY_Command;
extern rtems_shell_cmd_t rtems_shell_TASK_SET_AFFINITY_Command;
+ extern rtems_shell_cmd_t rtems_shell_CURRENT_CPU_Command;
#endif
extern rtems_shell_cmd_t rtems_shell_CLOCK_TICK_Command;
@@ -65,6 +66,7 @@ rtems_shell_cmd_t *rtems_shell_Initial_commands[] = {
#if RTEMS_SMP
&rtems_shell_TASK_GET_AFFINITY_Command,
&rtems_shell_TASK_SET_AFFINITY_Command,
+ &rtems_shell_CURRENT_CPU_Command,
#endif
&rtems_shell_CLOCK_TICK_Command,
diff --git a/schedsim/shell/shared/main_currentcpu.c b/schedsim/shell/shared/main_currentcpu.c
new file mode 100644
index 0000000..06a031a
--- /dev/null
+++ b/schedsim/shell/shared/main_currentcpu.c
@@ -0,0 +1,60 @@
+/**
+ * @file
+ * @brief current_cpu Command in Scheduler Simulator
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2014.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <newlib/getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "shell.h"
+#include "rtems_sched.h"
+
+#include <rtems.h>
+#include <rtems/score/percpu.h>
+#include <rtems/score/schedulerpriority.h>
+#include <rtems/stringto.h>
+
+extern uint32_t Schedsim_Current_cpu;
+
+int rtems_shell_main_current_cpu(int argc, char **argv)
+{
+ long cpu;
+
+ if ( argc >= 2 ) {
+ if ( rtems_string_to_long(argv[1], &cpu, NULL, 0) ) {
+ printf( "CPU argument (%s) is not a number\n", argv[1] );
+ return -1;
+ }
+ printf(
+ "Changing current CPU from %d to %d\n",
+ Schedsim_Current_cpu,
+ cpu
+ );
+ Schedsim_Current_cpu = cpu;
+ } else {
+ printf( "Current CPU is %d\n", Schedsim_Current_cpu );
+ }
+
+ return 0;
+}
+
+rtems_shell_cmd_t rtems_shell_CURRENT_CPU_Command = {
+ "current_cpu", /* name */
+ "current_cpu [cpu]", /* usage */
+ "rtems", /* topic */
+ rtems_shell_main_current_cpu, /* command */
+ NULL, /* alias */
+ NULL /* next */
+};