Changeset 24b94c4 in rtems for testsuites/samples


Ignore:
Timestamp:
Jul 30, 2018, 4:39:09 AM (19 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
16f3f10
Parents:
d56e68b
git-author:
Sebastian Huber <sebastian.huber@…> (07/30/18 04:39:09)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/07/18 05:17:16)
Message:

ramdisk: Use rtems_blkdev_create()

Update #3358.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/samples/fileio/init.c

    rd56e68b r24b94c4  
    4444#define RTEMS_DRIVER_AUTO_MAJOR (0)
    4545
    46 /*
    47  * RAM disk driver so you can create a RAM disk from the shell prompt.
    48  */
    49 /**
    50  * The RAM Disk configuration.
    51  */
    52 rtems_ramdisk_config rtems_ramdisk_configuration[] =
    53 {
    54   {
    55     block_size: 512,
    56     block_num:  1024,
    57     location:   NULL
    58   }
    59 };
    60 
    61 /**
    62  * The number of RAM Disk configurations.
    63  */
    64 size_t rtems_ramdisk_configuration_size = 1;
    65 
    66 /**
    67  * Create the RAM Disk Driver entry.
    68  */
    69 rtems_driver_address_table rtems_ramdisk_io_ops = {
    70   initialization_entry: ramdisk_initialize,
    71   open_entry:           rtems_blkdev_generic_open,
    72   close_entry:          rtems_blkdev_generic_close,
    73   read_entry:           rtems_blkdev_generic_read,
    74   write_entry:          rtems_blkdev_generic_write,
    75   control_entry:        rtems_blkdev_generic_ioctl
    76 };
    77 
    7846/**
    7947 * The NV Device descriptor. For this test it is just DRAM.
     
    405373}
    406374
    407 static size_t
     375static uint32_t
    408376parse_size_arg (const char* arg)
    409377{
    410   size_t size;
    411   size_t scalar = 1;
    412  
     378  uint32_t size;
     379  uint32_t scalar = 1;
     380
    413381  size = strtoul (arg, 0, 0);
    414382  switch (arg[strlen (arg) - 1])
    415383  {
     384    case 'b':
     385      scalar = 1;
     386      break;
    416387    case 'M':
    417       scalar = (size_t) 1000 * 1024;
     388      scalar = 1024000;
    418389      break;
    419390    case 'm':
     
    427398      break;
    428399    default:
    429       printf ("error: invalid scalar (M/m/K/k): %c\n", arg[strlen (arg) - 1]);
     400      printf ("error: invalid scalar (b,M/m/K/k): %c\n", arg[strlen (arg) - 1]);
    430401      return 0;
    431402  }
    432403  return size * scalar;
    433  }
     404}
    434405
    435406static int
    436407create_ramdisk (int argc, char *argv[])
    437408{
    438   rtems_device_major_number major;
    439409  rtems_status_code         sc;
    440410  int                       arg;
    441   size_t                    size = 0;
    442   size_t                    block_size = 0;
     411  uint32_t                  size = 524288;
     412  uint32_t                  block_size = 512;
     413  uint32_t                  block_count;
    443414
    444415  for (arg = 0; arg < argc; ++arg)
     
    446417    if (argv[arg][0] == '-')
    447418    {
    448       switch (argv[arg][0])
     419      switch (argv[arg][1])
    449420      {
    450421        case 's':
     
    477448  }
    478449
    479   if (block_size)
    480     rtems_ramdisk_configuration[0].block_size = block_size;
    481   if (size)
    482     rtems_ramdisk_configuration[0].block_num =
    483       size / rtems_ramdisk_configuration[0].block_size;
    484    
     450  block_count = size / block_size;
     451
    485452  /*
    486453   * Register the RAM Disk driver.
    487454   */
    488455  printf ("Register RAM Disk Driver [blocks=%" PRIu32 \
    489           " block-size=%" PRIu32"]:",
    490           rtems_ramdisk_configuration[0].block_num,
    491           rtems_ramdisk_configuration[0].block_size);
    492  
    493   sc = rtems_io_register_driver (RTEMS_DRIVER_AUTO_MAJOR,
    494                                  &rtems_ramdisk_io_ops,
    495                                  &major);
     456          " block-size=%" PRIu32 "]:",
     457          block_count,
     458          block_size);
     459
     460  sc = ramdisk_register(block_size, block_count, false, "/dev/rda");
    496461  if (sc != RTEMS_SUCCESSFUL)
    497462  {
     
    500465    return 1;
    501466  }
    502  
     467
    503468  printf ("successful\n");
    504469
     
    512477  rtems_status_code         sc;
    513478  int                       arg;
    514   size_t                    size = 0;
     479  uint32_t                  size = 0;
    515480#if ADD_WHEN_NVDISK_HAS_CHANGED
    516   size_t                    block_size = 0;
     481  uint32_t                  block_size = 0;
    517482#endif
    518483 
Note: See TracChangeset for help on using the changeset viewer.