コード例 #1
0
int rtems_shell_main_task_set_affinity(
  int   argc,
  char *argv[]
)
{
  rtems_id             id;
  rtems_status_code    status;
  unsigned long        tmp;
  cpu_set_t            cpuset;

  CHECK_RTEMS_IS_UP();

  if (argc != 3) {
    fprintf( stderr, "%s: Usage [name|id] affinity\n", argv[0] );
    return -1;
  }

  if ( lookup_task( argv[1], &id ) )
    return -1;

  if ( rtems_string_to_unsigned_long( argv[2], &tmp, NULL, 0) ) {
    fprintf( stderr, "Affinity (%s) is not a number\n", argv[2] );
    return 1;
  }

  CPU_ZERO( &cpuset );
  cpuset.__bits[0] = tmp;

  /*
   *  Now change the affinity of the task
   */
  status = rtems_task_set_affinity( id, sizeof(cpuset), &cpuset );
  if ( status != RTEMS_SUCCESSFUL ) {
    fprintf(
      stderr,
      "Task Set Affinity(%s) returned %s\n",
      argv[1],
      rtems_status_text( status )
    );
    return -1;
  }

  printf("Task (0x%08x) Set affinity=0x%08x\n", id, cpuset.__bits[0] );

  return 0;
}
コード例 #2
0
int rtems_shell_main_task_wake_after(
  int   argc,
  char *argv[]
)
{
  rtems_status_code    status;
  rtems_interval       ticks;
  unsigned long        tmp;
  rtems_id             self;

  CHECK_RTEMS_IS_UP();

  if (argc != 2) {
    fprintf( stderr, "%s: Usage ticks\n", argv[0] );
    return -1;
  }

  if ( rtems_string_to_unsigned_long( argv[1], &tmp, NULL, 0) ) {
    fprintf( stderr, "Argument (%s) is not a number\n", argv[2] );
    return 1;
  }

  ticks = (rtems_interval) tmp;
  self = get_thread_executing()->Object.id,

  /*
   *  Now sleep
   */
  printf( "Task (0x%08x) sleeping for %d ticks\n", self, ticks );

  status = rtems_task_wake_after( ticks );
  if ( status != RTEMS_SUCCESSFUL ) {
    fprintf(
      stderr,
      "Task Wake After (%s) returned %s\n",
      argv[1],
      rtems_status_text( status )
    );
    return -1;
  }

  return 0;
}
コード例 #3
0
ファイル: main_mfill.c プロジェクト: epicsdeb/rtems
int rtems_shell_main_mfill(
  int   argc,
  char *argv[]
)
{
  unsigned long  tmp;
  void          *addr;
  size_t         size;
  unsigned char  value;

  if ( argc != 4 ) {
    fprintf(stderr,"%s: too few arguments\n", argv[0]);
    return -1;
  }

  /*
   *  Convert arguments into numbers
   */
  if ( rtems_string_to_pointer(argv[1], &addr, NULL) ) {
    printf( "Address argument (%s) is not a number\n", argv[1] );
    return -1;
  }

  if ( rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
    printf( "Size argument (%s) is not a number\n", argv[2] );
    return -1;
  }
  size = (size_t) tmp;

  if ( rtems_string_to_unsigned_char(argv[3], &value, NULL, 0) ) {
    printf( "Value argument (%s) is not a number\n", argv[3] );
    return -1;
  }

  /*
   *  Now fill the memory.
   */
  memset(addr, size, value);

  return 0;
}
コード例 #4
0
ファイル: main_mmove.c プロジェクト: aniwang2013/leon-rtems
static int rtems_shell_main_mmove(
  int   argc,
  char *argv[]
)
{
  unsigned long  tmp;
  void          *src;
  void          *dst;
  size_t         length;

  if ( argc < 4 ) {
    fprintf(stderr,"%s: too few arguments\n", argv[0]);
    return -1;
   }

  /*
   *  Convert arguments into numbers
   */
  if ( rtems_string_to_pointer(argv[1], &dst, NULL) ) {
    printf( "Destination argument (%s) is not a number\n", argv[1] );
    return -1;
  }

  if ( rtems_string_to_pointer(argv[2], &src, NULL) ) {
    printf( "Source argument (%s) is not a number\n", argv[2] );
    return -1;
  }

  if ( rtems_string_to_unsigned_long(argv[3], &tmp, NULL, 0) ) {
    printf( "Length argument (%s) is not a number\n", argv[3] );
    return -1;
  }
  length = (size_t) tmp;

  /*
   *  Now copy the memory.
   */
  memcpy(dst, src, length);

 return 0;
}
コード例 #5
0
ファイル: main_umask.c プロジェクト: AlexShiLucky/rtems
static int rtems_shell_main_umask(
  int   argc,
  char *argv[]
)
{
  unsigned long tmp;
  mode_t        msk = umask(0);

  if (argc == 2) {
    if ( rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
      printf( "Mask argument (%s) is not a number\n", argv[1] );
      return -1;
    }
    msk = (mode_t) tmp;

  }
  umask(msk);

  msk = umask(0);
  printf("0%o\n", (unsigned int) msk);
  umask(msk);
  return 0;
}
コード例 #6
0
int rtems_shell_main_joel(
  int    argc,
  char **argv
)
{
  unsigned long        tmp;
  int                  option;
  int                  sc;
  int                  verbose = 0;
  char                *taskName = "JOEL";
  uint32_t             stackSize = RTEMS_MINIMUM_STACK_SIZE * 10;
  rtems_task_priority  taskPriority = 20;
  char                *outputFile = "stdout";
  rtems_status_code    result;
  char                 scriptFile[PATH_MAX];
  struct getopt_data   getopt_reent;

  memset(&getopt_reent, 0, sizeof(getopt_data));
  while ( (option = getopt_r( argc, argv, "o:p:s:t:v", &getopt_reent)) != -1 ) {
    switch ((char)option) {
      case 'o':
        outputFile = getopt_reent.optarg;
        break;
      case 'p': {
        const char *s = getopt_reent.optarg;

	if ( rtems_string_to_unsigned_long( s, &tmp, NULL, 0) ) {
	  printf( "Task Priority argument (%s) is not a number\n", s );
	  return -1;
	}
	taskPriority = (rtems_task_priority) tmp;
        break;
      }
      case 's': {
        const char *s = getopt_reent.optarg;

	if ( rtems_string_to_unsigned_long( s, &tmp, NULL, 0) ) {
	  printf( "Stack size argument (%s) is not a number\n", s );
	  return -1;
	}
        stackSize = (uint32_t) tmp;
        break;
      }
      case 't':
        taskName = getopt_reent.optarg;
        break;
      case 'v':
        verbose = 1;
        break;
      case '?':
      default:
        rtems_shell_joel_usage();
        return -1;
    }
  }

  if ( verbose ) {
    fprintf( stderr,
      "outputFile: %s\n"
      "taskPriority: %" PRId32 "\n"
      "stackSize: %" PRId32 "\n"
      "taskName: %s\n",
      outputFile,
      taskPriority,
      stackSize,
      taskName
   );
  }

  /*
   *  Verify there is a script name past the end of the arguments.
   *  Preincrement to skip program name.
   */
  if ( getopt_reent.optind >= argc ) {
    fprintf( stderr, "Shell: No script to execute\n" );
    return -1;
  }

  /*
   *  Find script on the path.
   *
   *  NOTE: It is terrible that this is done twice but it
   *        seems to be the most expedient thing.
   */
  sc = findOnPATH( argv[getopt_reent.optind], scriptFile );
  if ( sc ) {
    fprintf( stderr, "%s: command not found\n", argv[0] );
    return -1;
  }

  /* fprintf( stderr, "SCRIPT: -%s-\n", scriptFile ); */

  /*
   *  I assume that argv[optind...] will have the arguments to
   *  the shell script.  But that remains to be implemented.
   */

  /*
   * Run the script
   */
  result = rtems_shell_script(
    taskName,        /* the name of the task */
    stackSize,       /* stack size */
    taskPriority,    /* task priority */
    scriptFile,      /* the script file */
    outputFile,      /* where to redirect the script */
    0,               /* run once and exit */
    1,               /* we will wait */
    verbose          /* do we echo */
  );
  if (result)
    return -1;
  return 0;
}