Changeset 24b94c4 in rtems


Ignore:
Timestamp:
Jul 30, 2018, 4:39:09 AM (12 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.

Files:
13 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/ramdisk.h

    rd56e68b r24b94c4  
    8585#define RAMDISK_DRIVER_TABLE_ENTRY \
    8686  { \
    87     .initialization_entry = ramdisk_initialize, \
    88     RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
     87    ramdisk_initialize, \
     88    NULL, NULL, NULL, NULL, NULL \
    8989  }
    9090
     
    137137  bool free_at_delete_request;
    138138} ramdisk;
    139 
    140 extern const rtems_driver_address_table ramdisk_ops;
    141139
    142140int ramdisk_ioctl(rtems_disk_device *dd, uint32_t req, void *argp);
     
    213211  rtems_blkdev_bnum media_block_count,
    214212  bool trace,
    215   const char *disk,
    216   dev_t *dev
     213  const char *disk
    217214);
    218215
  • cpukit/libblock/src/ramdisk-config.c

    rd56e68b r24b94c4  
    2424rtems_device_driver
    2525ramdisk_initialize(
    26     rtems_device_major_number major,
     26    rtems_device_major_number major RTEMS_UNUSED,
    2727    rtems_device_minor_number minor RTEMS_UNUSED,
    2828    void *arg RTEMS_UNUSED)
     
    3232    struct ramdisk *r;
    3333    rtems_status_code rc;
    34 
    35     rc = rtems_disk_io_initialize();
    36     if (rc != RTEMS_SUCCESSFUL)
    37         return rc;
    3834
    3935    /*
     
    4945    for (i = 0; i < rtems_ramdisk_configuration_size; i++, c++, r++)
    5046    {
    51         dev_t dev = rtems_filesystem_make_dev_t(major, i);
    5247        char name [] = RAMDISK_DEVICE_BASE_NAME "a";
    5348        name [sizeof(RAMDISK_DEVICE_BASE_NAME) - 1] += i;
     
    7469            r->area = c->location;
    7570        }
    76         rc = rtems_disk_create_phys(dev, c->block_size, c->block_num,
    77                                     ramdisk_ioctl, r, name);
     71        rc = rtems_blkdev_create(name, c->block_size, c->block_num,
     72                                 ramdisk_ioctl, r);
    7873        if (rc != RTEMS_SUCCESSFUL)
    7974        {
  • cpukit/libblock/src/ramdisk-register.c

    rd56e68b r24b94c4  
    2525#endif
    2626
    27 #include <rtems.h>
    2827#include <rtems/ramdisk.h>
    29 
    30 const rtems_driver_address_table ramdisk_ops = {
    31   .initialization_entry = NULL,
    32   RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES
    33 };
    3428
    3529rtems_status_code ramdisk_register(
     
    3731  rtems_blkdev_bnum media_block_count,
    3832  bool trace,
    39   const char *disk,
    40   dev_t *dev_ptr
     33  const char *disk
    4134)
    4235{
    4336  rtems_status_code sc = RTEMS_SUCCESSFUL;
    44   rtems_device_major_number major = 0;
    4537  ramdisk *rd = NULL;
    46   dev_t dev = 0;
    4738
    48   sc = rtems_io_register_driver(0, &ramdisk_ops, &major);
    49   if (sc != RTEMS_SUCCESSFUL) {
     39  rd = ramdisk_allocate(NULL, media_block_size, media_block_count, trace);
     40  if (rd == NULL) {
    5041    return RTEMS_UNSATISFIED;
    5142  }
    5243
    53   rd = ramdisk_allocate(NULL, media_block_size, media_block_count, trace);
    54   if (rd == NULL) {
    55     rtems_io_unregister_driver(major);
     44  sc = rtems_blkdev_create(
     45    disk,
     46    media_block_size,
     47    media_block_count,
     48    ramdisk_ioctl,
     49    rd
     50  );
     51  if (sc != RTEMS_SUCCESSFUL) {
     52    ramdisk_free(rd);
    5653
    5754    return RTEMS_UNSATISFIED;
    5855  }
    5956
    60   dev = rtems_filesystem_make_dev_t(major, 0);
    61 
    62   sc = rtems_disk_create_phys(
    63     dev,
    64     media_block_size,
    65     media_block_count,
    66     ramdisk_ioctl,
    67     rd,
    68     disk
    69   );
    70   if (sc != RTEMS_SUCCESSFUL) {
    71     ramdisk_free(rd);
    72     rtems_io_unregister_driver(major);
    73 
    74     return RTEMS_UNSATISFIED;
    75   }
    76 
    77   *dev_ptr = dev;
    78 
    7957  return RTEMS_SUCCESSFUL;
    8058}
  • testsuites/fstests/fsdosfsname01/init.c

    rd56e68b r24b94c4  
    6363
    6464#define BLOCK_SIZE 512
    65 
    66 #define BLOCK_COUNT ( sizeof( image_bin ) / BLOCK_SIZE )
    67 
    68 static ramdisk                            disk_image = {
    69   .block_size             = BLOCK_SIZE,
    70   .block_num              = BLOCK_COUNT,
    71   .area                   = &image_bin[0],
    72   .initialized            = true,
    73   .malloced               = false,
    74   .trace                  = false,
    75   .free_at_delete_request = false
    76 };
    7765
    7866static rtems_resource_snapshot            before_mount;
     
    987975{
    988976  int                       rc;
    989   rtems_status_code         sc;
    990   dev_t                     dev;
    991   char                      diskpath[] = "/dev/ramdisk1";
     977  char                      diskpath[] = "/dev/rdd";
    992978  rtems_dosfs_mount_options mount_opts;
    993   rtems_device_major_number major;
    994979  FILE                     *fp;
    995980  int                       buffer;
     
    1008993  rtems_test_assert( mount_opts.converter != NULL );
    1009994
    1010   sc = rtems_io_register_driver( 0, &ramdisk_ops, &major );
    1011   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    1012 
    1013   dev = rtems_filesystem_make_dev_t( major, 1 );
    1014 
    1015   sc  = rtems_disk_create_phys(
    1016     dev,
    1017     BLOCK_SIZE,
    1018     BLOCK_COUNT,
    1019     ramdisk_ioctl,
    1020     &disk_image,
    1021     diskpath );
    1022   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    1023 
    1024995  rc = mount_and_make_target_path(
    1025996    diskpath,
     
    14221393  { .block_size = BLOCK_SIZE, .block_num = BLOCK_NUM },
    14231394  { .block_size = BLOCK_SIZE, .block_num = BLOCK_NUM, .location = &IMAGE_BIN_LE_SINGLEBYTE[0] },
    1424   { .block_size = BLOCK_SIZE, .block_num = BLOCK_NUM, .location = &IMAGE_BIN_LE_MULTIBYTE[0] }
     1395  { .block_size = BLOCK_SIZE, .block_num = BLOCK_NUM, .location = &IMAGE_BIN_LE_MULTIBYTE[0] },
     1396  { .block_size = BLOCK_SIZE, .block_num = sizeof( image_bin ) / BLOCK_SIZE, .location = image_bin }
    14251397};
    14261398
     
    14301402#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
    14311403#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
    1432 #define CONFIGURE_MAXIMUM_DRIVERS 4
    14331404#define CONFIGURE_MAXIMUM_SEMAPHORES (2 * RTEMS_DOSFS_SEMAPHORES_PER_INSTANCE)
    14341405#define CONFIGURE_APPLICATION_EXTRA_DRIVERS RAMDISK_DRIVER_TABLE_ENTRY
  • testsuites/fstests/mdosfs_support/fs_support.c

    rd56e68b r24b94c4  
    8888#define CONFIGURE_MAXIMUM_SEMAPHORES RTEMS_DOSFS_SEMAPHORES_PER_INSTANCE
    8989#define CONFIGURE_MAXIMUM_TASKS                     10
    90 #define CONFIGURE_MAXIMUM_DRIVERS                   10
    9190#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS    40
    9291#define CONFIGURE_INIT_TASK_STACK_SIZE (16 * 1024)
  • testsuites/fstests/mrfs_support/fs_support.c

    rd56e68b r24b94c4  
    6767
    6868#define CONFIGURE_MAXIMUM_TASKS                     10
    69 #define CONFIGURE_MAXIMUM_DRIVERS                   10
    7069#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS    40
    7170#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024)
  • testsuites/fstests/support/ramdisk_support.c

    rd56e68b r24b94c4  
    1212#endif
    1313
    14 #include <sys/stat.h>
    15 #include <fcntl.h>
     14#include <unistd.h>
    1615
    1716#include <rtems/ramdisk.h>
    18 #include <rtems/blkdev.h>
    19 #include <rtems/libio.h>
    2017
    2118#include "ramdisk_support.h"
     
    2724 */
    2825
    29 dev_t dev = 0;
    30 
    3126void
    3227init_ramdisk (void)
     
    3429
    3530  int rc = 0;
    36   rc = rtems_disk_io_initialize ();
    37   rtems_test_assert (rc == 0);
     31
    3832  rc = ramdisk_register (RAMDISK_BLOCK_SIZE, RAMDISK_BLOCK_COUNT,
    39                          false, RAMDISK_PATH, &dev);
     33                         false, RAMDISK_PATH);
    4034  rtems_test_assert (rc == 0);
    4135}
     
    4640
    4741  int rc = 0;
    48   rtems_device_major_number major = 0;
    49   rtems_device_minor_number minor = 0;
    5042
    51   rc = rtems_disk_delete (dev);
     43  rc = unlink (RAMDISK_PATH);
    5244  rtems_test_assert (rc == 0);
    53 
    54   rtems_filesystem_split_dev_t (dev, major, minor);
    55 
    56   rtems_test_assert (major >= 0);
    57   rtems_test_assert (minor >= 0);
    58 
    59   rc = rtems_io_unregister_driver (major);
    60   rtems_test_assert (rc == 0);
    61   rc = rtems_disk_io_done ();
    62   rtems_test_assert (rc == 0);
    63 
    6445}
  • testsuites/libtests/block01/init.c

    rd56e68b r24b94c4  
    88
    99/*
    10  * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2009, 2018 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    3636const char rtems_test_name[] = "BLOCK 1";
    3737
    38 /* forward declarations to avoid warnings */
    39 static rtems_task Init(rtems_task_argument argument);
    40 
    4138#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
    4239
     
    4643
    4744#define BLOCK_COUNT 16U
     45
     46static const rtems_driver_address_table ramdisk_ops = {
     47  .initialization_entry = NULL,
     48  RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES
     49};
    4850
    4951static void test_block_io_control_api(dev_t dev, ramdisk *rd)
  • testsuites/libtests/block02/init.c

    rd56e68b r24b94c4  
    88
    99/*
    10  * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2009, 2018 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    3131#include <rtems/ramdisk.h>
    3232#include <rtems/bdbuf.h>
    33 #include <rtems/diskdevs.h>
     33
     34#include <sys/stat.h>
     35#include <fcntl.h>
     36#include <unistd.h>
    3437
    3538const char rtems_test_name[] = "BLOCK 2";
    36 
    37 /* forward declarations to avoid warnings */
    38 static rtems_task Init(rtems_task_argument argument);
    3939
    4040#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
     
    131131}
    132132
     133static void do_ramdisk_register(
     134  uint32_t media_block_size,
     135  rtems_blkdev_bnum media_block_count,
     136  const char *disk,
     137  rtems_disk_device **dd
     138)
     139{
     140  rtems_status_code sc;
     141  int fd;
     142  int rv;
     143
     144  sc = ramdisk_register(media_block_size, media_block_count, false, disk);
     145  ASSERT_SC(sc);
     146
     147  fd = open(disk, O_RDWR);
     148  rtems_test_assert(fd >= 0);
     149
     150  rv = rtems_disk_fd_get_disk_device(fd, dd);
     151  rtems_test_assert(rv == 0);
     152
     153  rv = close(fd);
     154  rtems_test_assert(rv == 0);
     155}
     156
    133157static rtems_task Init(rtems_task_argument argument)
    134158{
    135159  rtems_status_code sc = RTEMS_SUCCESSFUL;
    136160  rtems_bdbuf_buffer *bd = NULL;
    137   dev_t dev_a = 0;
    138   dev_t dev_b = 0;
    139161
    140162  TEST_BEGIN();
    141163
    142   sc = rtems_disk_io_initialize();
    143   ASSERT_SC(sc);
    144 
    145   sc = ramdisk_register(BLOCK_SIZE_A, BLOCK_COUNT_A, false, "/dev/rda", &dev_a);
    146   ASSERT_SC(sc);
    147 
    148   sc = ramdisk_register(BLOCK_SIZE_B, BLOCK_COUNT_B, false, "/dev/rdb", &dev_b);
    149   ASSERT_SC(sc);
    150 
    151   dd_a = rtems_disk_obtain(dev_a);
    152   rtems_test_assert(dd_a != NULL);
    153 
    154   dd_b = rtems_disk_obtain(dev_b);
    155   rtems_test_assert(dd_b != NULL);
     164  do_ramdisk_register(BLOCK_SIZE_A, BLOCK_COUNT_A, "/dev/rda", &dd_a);
     165  do_ramdisk_register(BLOCK_SIZE_B, BLOCK_COUNT_B, "/dev/rdb", &dd_b);
    156166
    157167  sc = rtems_task_create(
     
    201211#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
    202212
     213#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
     214
    203215#define CONFIGURE_MAXIMUM_TASKS 3
    204 #define CONFIGURE_MAXIMUM_DRIVERS 3
    205216
    206217#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
  • testsuites/libtests/block03/init.c

    rd56e68b r24b94c4  
    88
    99/*
    10  * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2009, 2018 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    3131#include <rtems/ramdisk.h>
    3232#include <rtems/bdbuf.h>
    33 #include <rtems/diskdevs.h>
     33
     34#include <sys/stat.h>
     35#include <fcntl.h>
     36#include <unistd.h>
    3437
    3538const char rtems_test_name[] = "BLOCK 3";
    36 
    37 /* forward declarations to avoid warnings */
    38 static rtems_task Init(rtems_task_argument argument);
    3939
    4040#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
     
    125125}
    126126
     127static void do_ramdisk_register(
     128  uint32_t media_block_size,
     129  rtems_blkdev_bnum media_block_count,
     130  const char *disk,
     131  rtems_disk_device **dd
     132)
     133{
     134  rtems_status_code sc;
     135  int fd;
     136  int rv;
     137
     138  sc = ramdisk_register(media_block_size, media_block_count, false, disk);
     139  ASSERT_SC(sc);
     140
     141  fd = open(disk, O_RDWR);
     142  rtems_test_assert(fd >= 0);
     143
     144  rv = rtems_disk_fd_get_disk_device(fd, dd);
     145  rtems_test_assert(rv == 0);
     146
     147  rv = close(fd);
     148  rtems_test_assert(rv == 0);
     149}
     150
    127151static rtems_task Init(rtems_task_argument argument)
    128152{
    129153  rtems_status_code sc = RTEMS_SUCCESSFUL;
    130154  rtems_bdbuf_buffer *bd = NULL;
    131   dev_t dev = 0;
    132155
    133156  TEST_BEGIN();
    134157
    135   sc = rtems_disk_io_initialize();
    136   ASSERT_SC(sc);
    137 
    138   sc = ramdisk_register(BLOCK_SIZE, BLOCK_COUNT, false, "/dev/rda", &dev);
    139   ASSERT_SC(sc);
    140 
    141   dd = rtems_disk_obtain(dev);
    142   rtems_test_assert(dd != NULL);
     158  do_ramdisk_register(BLOCK_SIZE, BLOCK_COUNT, "/dev/rda", &dd);
    143159
    144160  sc = rtems_task_create(
     
    188204#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
    189205
     206#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
     207
    190208#define CONFIGURE_MAXIMUM_TASKS 3
    191 #define CONFIGURE_MAXIMUM_DRIVERS 2
    192209
    193210#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
  • testsuites/libtests/block04/init.c

    rd56e68b r24b94c4  
    88
    99/*
    10  * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2009, 2018 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    3131#include <rtems/ramdisk.h>
    3232#include <rtems/bdbuf.h>
    33 #include <rtems/diskdevs.h>
     33
     34#include <sys/stat.h>
     35#include <fcntl.h>
     36#include <unistd.h>
    3437
    3538const char rtems_test_name[] = "BLOCK 4";
    36 
    37 /* forward declarations to avoid warnings */
    38 static rtems_task Init(rtems_task_argument argument);
    3939
    4040#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
     
    108108}
    109109
     110static void do_ramdisk_register(
     111  uint32_t media_block_size,
     112  rtems_blkdev_bnum media_block_count,
     113  const char *disk,
     114  rtems_disk_device **dd
     115)
     116{
     117  rtems_status_code sc;
     118  int fd;
     119  int rv;
     120
     121  sc = ramdisk_register(media_block_size, media_block_count, false, disk);
     122  ASSERT_SC(sc);
     123
     124  fd = open(disk, O_RDWR);
     125  rtems_test_assert(fd >= 0);
     126
     127  rv = rtems_disk_fd_get_disk_device(fd, dd);
     128  rtems_test_assert(rv == 0);
     129
     130  rv = close(fd);
     131  rtems_test_assert(rv == 0);
     132}
     133
    110134static rtems_task Init(rtems_task_argument argument)
    111135{
    112136  rtems_status_code sc = RTEMS_SUCCESSFUL;
    113   dev_t dev = 0;
    114137
    115138  TEST_BEGIN();
    116139
    117   sc = rtems_disk_io_initialize();
    118   ASSERT_SC(sc);
    119 
    120   sc = ramdisk_register(BLOCK_SIZE, BLOCK_COUNT, false, "/dev/rda", &dev);
    121   ASSERT_SC(sc);
    122 
    123   dd = rtems_disk_obtain(dev);
    124   rtems_test_assert(dd != NULL);
     140  do_ramdisk_register(BLOCK_SIZE, BLOCK_COUNT, "/dev/rda", &dd);
    125141
    126142  sc = rtems_task_create(
     
    160176#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
    161177
     178#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
     179
    162180#define CONFIGURE_MAXIMUM_TASKS 3
    163 #define CONFIGURE_MAXIMUM_DRIVERS 2
    164181
    165182#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
  • testsuites/libtests/block07/init.c

    rd56e68b r24b94c4  
    88
    99/*
    10  * Copyright (c) 2009
    11  * embedded brains GmbH
    12  * Obere Lagerstr. 30
    13  * D-82178 Puchheim
    14  * Germany
    15  * <rtems@embedded-brains.de>
     10 * Copyright (c) 2009, 2018 embedded brains GmbH.  All rights reserved.
     11 *
     12 *  embedded brains GmbH
     13 *  Dornierstr. 4
     14 *  82178 Puchheim
     15 *  Germany
     16 *  <rtems@embedded-brains.de>
    1617 *
    1718 * The license and distribution terms for this file may be
     
    2829#include <sys/stat.h>
    2930#include <fcntl.h>
     31#include <unistd.h>
    3032
    3133#include "tmacros.h"
     
    3436#include <rtems/ramdisk.h>
    3537#include <rtems/bdbuf.h>
    36 #include <rtems/diskdevs.h>
    3738
    3839const char rtems_test_name[] = "BLOCK 7";
    39 
    40 /* forward declarations to avoid warnings */
    41 static rtems_task Init(rtems_task_argument argument);
    4240
    4341#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
     
    159157}
    160158
     159static void do_ramdisk_register(
     160  uint32_t media_block_size,
     161  rtems_blkdev_bnum media_block_count,
     162  const char *disk,
     163  rtems_disk_device **dd
     164)
     165{
     166  rtems_status_code sc;
     167  int fd;
     168  int rv;
     169
     170  sc = ramdisk_register(media_block_size, media_block_count, false, disk);
     171  ASSERT_SC(sc);
     172
     173  fd = open(disk, O_RDWR);
     174  rtems_test_assert(fd >= 0);
     175
     176  rv = rtems_disk_fd_get_disk_device(fd, dd);
     177  rtems_test_assert(rv == 0);
     178
     179  rv = close(fd);
     180  rtems_test_assert(rv == 0);
     181}
     182
    161183static rtems_task Init(rtems_task_argument argument)
    162184{
     
    164186  rtems_task_priority cur_prio = 0;
    165187  rtems_bdbuf_buffer *bd = NULL;
    166   dev_t dev = 0;
    167188
    168189  TEST_BEGIN();
    169190
    170   sc = rtems_disk_io_initialize();
    171   ASSERT_SC(sc);
    172 
    173   sc = ramdisk_register(BLOCK_SIZE_A, BLOCK_COUNT, false, "/dev/rda", &dev);
    174   ASSERT_SC(sc);
    175 
    176   dd = rtems_disk_obtain(dev);
    177   rtems_test_assert(dd != NULL);
     191  do_ramdisk_register(BLOCK_SIZE_A, BLOCK_COUNT, "/dev/rda", &dd);
    178192
    179193  sc = rtems_task_create(
     
    266280
    267281#define CONFIGURE_MAXIMUM_TASKS 4
    268 #define CONFIGURE_MAXIMUM_DRIVERS 2
    269282
    270283#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
  • 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.