summaryrefslogtreecommitdiffstats
path: root/schedsim/shell/schedsim_smpsimple
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2014-05-23 16:46:22 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-05-23 16:46:49 -0500
commit36f4cb93ed8f1837658d7dc9b805681b9cb45ec6 (patch)
tree1ec0dbd803062f13bc37aa7f032efe06187eb2de /schedsim/shell/schedsim_smpsimple
parentmain_dump_all_cpus.c: Return error do not exit (diff)
downloadrtems-schedsim-36f4cb93ed8f1837658d7dc9b805681b9cb45ec6.tar.bz2
Use shared main() and file processor
Diffstat (limited to 'schedsim/shell/schedsim_smpsimple')
-rw-r--r--schedsim/shell/schedsim_smpsimple/Makefile.am1
-rw-r--r--schedsim/shell/schedsim_smpsimple/schedsim.cc181
2 files changed, 0 insertions, 182 deletions
diff --git a/schedsim/shell/schedsim_smpsimple/Makefile.am b/schedsim/shell/schedsim_smpsimple/Makefile.am
index a931b05..bc058fe 100644
--- a/schedsim/shell/schedsim_smpsimple/Makefile.am
+++ b/schedsim/shell/schedsim_smpsimple/Makefile.am
@@ -8,7 +8,6 @@ schedsim_smpsimple_SOURCES += main_dump_ready_tasks.c
schedsim_smpsimple_SOURCES += printheir_executing.c
schedsim_smpsimple_SOURCES += smp_stub.c
schedsim_smpsimple_SOURCES += wrap_thread_dispatch.c
-schedsim_smpsimple_SOURCES += schedsim.cc
cpukitdir=@rtems_srcdir@/cpukit
schedsim_smpsimple_CPPFLAGS = -I$(top_builddir)/score/include
diff --git a/schedsim/shell/schedsim_smpsimple/schedsim.cc b/schedsim/shell/schedsim_smpsimple/schedsim.cc
deleted file mode 100644
index 5136ac9..0000000
--- a/schedsim/shell/schedsim_smpsimple/schedsim.cc
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * COPYRIGHT (c) 1989-2013.
- * 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"
-
-/*
- * Variables to control global behavior
- */
-int verbose = 1;
-const char *progname;
-const char *scriptname;
-
-FILE *Script;
-int ScriptFileLine = 0;
-
-/*
- * Print program usage message
- */
-void usage()
-{
- fprintf(
- stderr,
- "Usage: %s [-v] script\n"
- "\n"
- " -v - enable verbose output\n",
- progname
- );
- exit( -1 );
-}
-
-#define RTEMS_SHELL_MAXIMUM_ARGUMENTS (128)
-
-void ProcessScript(
- FILE *script
-)
-{
- char buffer[512];
- int sc;
- char *cStatus;
- char *c;
- size_t length;
- int argc;
- char *argv[RTEMS_SHELL_MAXIMUM_ARGUMENTS];
- rtems_shell_cmd_t *shell_cmd;
-
-
- while ( 1 ) {
- cStatus = fgets( buffer, sizeof(buffer), script );
- if ( cStatus == NULL )
- break;
- // If the last line does not have a CR, then we don't want to
- // arbitrarily clobber an = instead of a \n.
- length = strlen(buffer);
- if ( buffer[ length - 1] == '\n' )
- buffer[ length - 1] = '\0';
-
- if ( verbose )
- printf( "==> %d: %s\n", ++ScriptFileLine, buffer );
-
- if ( buffer[0] == '#' )
- continue;
-
- for ( c = buffer ; *c ; c++ ) {
- if (!isblank((int)*c))
- break;
- }
-
-
- if (!strcmp(c,"bye") || !strcmp(c,"exit")) {
- exit( 0 );
- }
-
- if (rtems_shell_make_args(c, &argc, argv, RTEMS_SHELL_MAXIMUM_ARGUMENTS)) {
- fprintf(stderr, "Error parsing arguments\n" );
- continue;
- }
-
- if ( argc == 0 )
- continue;
-
- shell_cmd = rtems_shell_lookup_cmd(argv[0]);
- if ( !shell_cmd ) {
- fprintf(stderr, "%s is unknown command\n", c );
- exit( 1 );
- }
-
- sc = shell_cmd->command(argc, argv);
- if ( sc != 0 ) {
- fprintf( stderr, "ERROR: Command %s returned %d\n", argv[0], sc );
- exit( sc );
- }
- }
-}
-
-extern "C" {
- void add_commands(void);
-};
-
-int main(
- int argc,
- char **argv
-)
-{
- int opt;
- progname = argv[0];
-
- while ((opt = getopt(argc, argv, "v")) != -1) {
- switch (opt) {
- case 'v': verbose = 0; break;
- default: /* '?' */
- usage();
- }
- }
-
- if ( optind >= argc ) {
- scriptname = "-";
- } else {
- scriptname = argv[ optind ];
- }
-
- if ( !strcmp( scriptname, "-" ) ) {
- scriptname = "/dev/stdin";
- }
-
- if ( verbose ) {
- printf(
- "Script File : %s\n"
- "verbose : %d\n",
- scriptname,
- verbose
- );
- }
-
- //
- // Initialize the command interpreter
- //
- rtems_shell_initialize_command_set();
- add_commands();
-
- //
- // Open the script file
- //
- Script = fopen( scriptname, "r" );
- if ( !Script ) {
- fprintf( stderr, "Unable to open script file (%s)\n", scriptname );
- exit( -1 );
- }
-
- //
- // Process the Script
- //
- ProcessScript( Script );
-
- //
- // Open the script file
- //
- (void) fclose( Script );
-
- //
- // Just in case something throws
- //
- try {
- } catch (...) {
- exit(-1);
- }
-
- return 0;
-}