Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}
int rtems_shell_main_mwdump(
  int   argc,
  char *argv[]
)
{
  unsigned char  n;
  unsigned char  m;
  int            max;
  int            res;
  void          *addr = 0;
  unsigned char *pb;

  if ( argc > 1 ) {
    if ( rtems_string_to_pointer(argv[1], &addr, NULL) ) {
      printf( "Address argument (%s) is not a number\n", argv[1] );
      return -1;
    }
  }

  if ( argc > 2 ) {
    if ( rtems_string_to_int(argv[2], &max, NULL, 0) ) {
      printf( "Address argument (%s) is not a number\n", argv[1] );
      return -1;
    }

    if (max <= 0) {
      max = 1;      /* print 1 item if 0 or neg. */
      res = 0;
    } else {
      max--;
      res = max & 0xf;/* num bytes in last row */
      max >>= 4;      /* div by 16 */
      max++;          /* num of rows to print */
      if (max > 20) { /* limit to 20 */
        max = 20;
        res = 0xf;    /* 16 bytes print in last row */
      }
    }
  } else {