ramdisk: Use rtems_blkdev_create()

Update #3358.
This commit is contained in:
Sebastian Huber
2018-07-30 06:39:09 +02:00
parent d56e68bb8b
commit 24b94c4771
13 changed files with 181 additions and 236 deletions

View File

@@ -63,18 +63,6 @@ static const char UTF8_BOM[] = {0xEF, 0xBB, 0xBF};
#define BLOCK_SIZE 512
#define BLOCK_COUNT ( sizeof( image_bin ) / BLOCK_SIZE )
static ramdisk disk_image = {
.block_size = BLOCK_SIZE,
.block_num = BLOCK_COUNT,
.area = &image_bin[0],
.initialized = true,
.malloced = false,
.trace = false,
.free_at_delete_request = false
};
static rtems_resource_snapshot before_mount;
static const msdos_format_request_param_t rqdata = {
@@ -981,11 +969,8 @@ static void compare_image(
static void test_compatibility( void )
{
int rc;
rtems_status_code sc;
dev_t dev;
char diskpath[] = "/dev/ramdisk1";
char diskpath[] = "/dev/rdd";
rtems_dosfs_mount_options mount_opts;
rtems_device_major_number major;
FILE *fp;
int buffer;
unsigned int index_file = 0;
@@ -1002,20 +987,6 @@ static void test_compatibility( void )
mount_opts.converter = rtems_dosfs_create_utf8_converter( "CP850" );
rtems_test_assert( mount_opts.converter != NULL );
sc = rtems_io_register_driver( 0, &ramdisk_ops, &major );
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
dev = rtems_filesystem_make_dev_t( major, 1 );
sc = rtems_disk_create_phys(
dev,
BLOCK_SIZE,
BLOCK_COUNT,
ramdisk_ioctl,
&disk_image,
diskpath );
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
rc = mount_and_make_target_path(
diskpath,
MOUNT_DIR,
@@ -1416,7 +1387,8 @@ static void Init( rtems_task_argument arg )
rtems_ramdisk_config rtems_ramdisk_configuration [] = {
{ .block_size = BLOCK_SIZE, .block_num = BLOCK_NUM },
{ .block_size = BLOCK_SIZE, .block_num = BLOCK_NUM, .location = &IMAGE_BIN_LE_SINGLEBYTE[0] },
{ .block_size = BLOCK_SIZE, .block_num = BLOCK_NUM, .location = &IMAGE_BIN_LE_MULTIBYTE[0] }
{ .block_size = BLOCK_SIZE, .block_num = BLOCK_NUM, .location = &IMAGE_BIN_LE_MULTIBYTE[0] },
{ .block_size = BLOCK_SIZE, .block_num = sizeof( image_bin ) / BLOCK_SIZE, .location = image_bin }
};
size_t rtems_ramdisk_configuration_size = RTEMS_ARRAY_SIZE(rtems_ramdisk_configuration);
@@ -1424,7 +1396,6 @@ size_t rtems_ramdisk_configuration_size = RTEMS_ARRAY_SIZE(rtems_ramdisk_configu
#define CONFIGURE_INIT_TASK_STACK_SIZE ( 1024 * 64 )
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_MAXIMUM_DRIVERS 4
#define CONFIGURE_MAXIMUM_SEMAPHORES (2 * RTEMS_DOSFS_SEMAPHORES_PER_INSTANCE)
#define CONFIGURE_APPLICATION_EXTRA_DRIVERS RAMDISK_DRIVER_TABLE_ENTRY

View File

@@ -87,7 +87,6 @@ void test_shutdown_filesystem(void)
#define CONFIGURE_MAXIMUM_SEMAPHORES RTEMS_DOSFS_SEMAPHORES_PER_INSTANCE
#define CONFIGURE_MAXIMUM_TASKS 10
#define CONFIGURE_MAXIMUM_DRIVERS 10
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 40
#define CONFIGURE_INIT_TASK_STACK_SIZE (16 * 1024)
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT

View File

@@ -66,7 +66,6 @@ test_shutdown_filesystem (void)
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_MAXIMUM_TASKS 10
#define CONFIGURE_MAXIMUM_DRIVERS 10
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 40
#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024)
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT

View File

@@ -11,12 +11,9 @@
#include "config.h"
#endif
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <rtems/ramdisk.h>
#include <rtems/blkdev.h>
#include <rtems/libio.h>
#include "ramdisk_support.h"
#include "fstest.h"
@@ -26,17 +23,14 @@
* Ramdisk information
*/
dev_t dev = 0;
void
init_ramdisk (void)
{
int rc = 0;
rc = rtems_disk_io_initialize ();
rtems_test_assert (rc == 0);
rc = ramdisk_register (RAMDISK_BLOCK_SIZE, RAMDISK_BLOCK_COUNT,
false, RAMDISK_PATH, &dev);
false, RAMDISK_PATH);
rtems_test_assert (rc == 0);
}
@@ -45,20 +39,7 @@ del_ramdisk (void)
{
int rc = 0;
rtems_device_major_number major = 0;
rtems_device_minor_number minor = 0;
rc = rtems_disk_delete (dev);
rc = unlink (RAMDISK_PATH);
rtems_test_assert (rc == 0);
rtems_filesystem_split_dev_t (dev, major, minor);
rtems_test_assert (major >= 0);
rtems_test_assert (minor >= 0);
rc = rtems_io_unregister_driver (major);
rtems_test_assert (rc == 0);
rc = rtems_disk_io_done ();
rtems_test_assert (rc == 0);
}