forked from Imagelibrary/rtems
@@ -13,17 +13,20 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/io.h>
|
||||
#include <rtems/diskdevs.h>
|
||||
#include <rtems/bdbuf.h>
|
||||
#include <rtems/inttypes.h>
|
||||
#include "bdbuf_tests.h"
|
||||
|
||||
#include <tmacros.h>
|
||||
|
||||
struct bdbuf_test_descr {
|
||||
void (* main)(void);
|
||||
@@ -105,17 +108,10 @@ bdbuf_test_start_aux_task(rtems_name name,
|
||||
void
|
||||
run_bdbuf_tests()
|
||||
{
|
||||
rtems_disk_device *disk;
|
||||
rtems_status_code sc;
|
||||
dev_t dev = -1;
|
||||
dev_t test_dev;
|
||||
unsigned int i;
|
||||
|
||||
rtems_device_major_number major;
|
||||
rtems_driver_address_table testdisk = {
|
||||
test_disk_initialize,
|
||||
RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES
|
||||
};
|
||||
rtems_status_code sc;
|
||||
unsigned int i;
|
||||
int fd;
|
||||
int rv;
|
||||
|
||||
/* Create a message queue to get events from disk driver. */
|
||||
sc = rtems_message_queue_create(TEST_TASK_RX_MQUEUE_NAME,
|
||||
@@ -130,40 +126,17 @@ run_bdbuf_tests()
|
||||
return;
|
||||
}
|
||||
|
||||
/* Register a disk device that is used in tests */
|
||||
sc = rtems_io_register_driver(0, &testdisk, &major);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
{
|
||||
printf("Failed to register TEST DEVICE: %d\n", sc);
|
||||
return;
|
||||
}
|
||||
sc = test_disk_initialize();
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
test_dev = -1;
|
||||
while ((disk = rtems_disk_next(dev)) != NULL)
|
||||
{
|
||||
printf(
|
||||
"DEV: %s [%" PRIdrtems_blkdev_bnum "]\n",
|
||||
disk->name,
|
||||
disk->size
|
||||
);
|
||||
dev = disk->dev;
|
||||
if (strcmp(disk->name, TEST_DISK_NAME) == 0)
|
||||
test_dev = dev;
|
||||
rtems_disk_release(disk);
|
||||
}
|
||||
fd = open(TEST_DISK_NAME, O_RDWR);
|
||||
rtems_test_assert(fd >= 0);
|
||||
|
||||
if (test_dev == (dev_t)-1)
|
||||
{
|
||||
printf("Failed to find %s disk\n", TEST_DISK_NAME);
|
||||
return;
|
||||
}
|
||||
rv = rtems_disk_fd_get_disk_device(fd, &test_dd);
|
||||
rtems_test_assert(rv == 0);
|
||||
|
||||
test_dd = rtems_disk_obtain(test_dev);
|
||||
if (test_dd == NULL)
|
||||
{
|
||||
printf("Failed to obtain %s disk\n", TEST_DISK_NAME);
|
||||
return;
|
||||
}
|
||||
rv = close(fd);
|
||||
rtems_test_assert(rv == 0);
|
||||
|
||||
/*
|
||||
* On initialization test disk device driver registers
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <rtems/bspIo.h>
|
||||
#include <rtems/diskdevs.h>
|
||||
#include <rtems/bdbuf.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -46,11 +45,7 @@ extern void bdbuf_test4_1_main(void);
|
||||
extern void bdbuf_test4_2_main(void);
|
||||
extern void bdbuf_test4_3_main(void);
|
||||
|
||||
extern rtems_device_driver
|
||||
test_disk_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg);
|
||||
extern rtems_status_code test_disk_initialize(void);
|
||||
|
||||
#define ARRAY_NUM(a_) (sizeof(a_) / sizeof(a_[0]))
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ rtems_task Init(
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 28
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 10
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 20
|
||||
@@ -40,13 +42,6 @@ rtems_task Init(
|
||||
#define CONFIGURE_BDBUF_BUFFER_MIN_SIZE (512)
|
||||
#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE (512)
|
||||
|
||||
/*
|
||||
* Define it here in order to be able to register
|
||||
* test driver after RTEMS initialization phase
|
||||
* (on test start-up).
|
||||
*/
|
||||
#define CONFIGURE_MAXIMUM_DRIVERS 5
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "rtems/blkdev.h"
|
||||
#include "rtems/diskdevs.h"
|
||||
#include <rtems/blkdev.h>
|
||||
|
||||
#include "bdbuf_tests.h"
|
||||
|
||||
@@ -58,9 +57,7 @@ test_disk_ioctl(rtems_disk_device *dd, uint32_t req, void *argp)
|
||||
}
|
||||
|
||||
default:
|
||||
printf("%s() Unexpected request comes %" PRIu32 "\n",
|
||||
__FUNCTION__, req);
|
||||
return -1;
|
||||
return rtems_blkdev_ioctl (dd, req, argp);
|
||||
}
|
||||
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
@@ -107,25 +104,15 @@ test_disk_ioctl(rtems_disk_device *dd, uint32_t req, void *argp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtems_device_driver
|
||||
test_disk_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
rtems_status_code
|
||||
test_disk_initialize(void)
|
||||
{
|
||||
rtems_status_code rc;
|
||||
dev_t dev;
|
||||
|
||||
rc = rtems_disk_io_initialize();
|
||||
if (rc != RTEMS_SUCCESSFUL)
|
||||
return rc;
|
||||
|
||||
dev = rtems_filesystem_make_dev_t(major, minor);
|
||||
rc = rtems_disk_create_phys(dev,
|
||||
TEST_DISK_BLOCK_SIZE, TEST_DISK_BLOCK_NUM,
|
||||
test_disk_ioctl,
|
||||
NULL,
|
||||
TEST_DISK_NAME);
|
||||
rc = rtems_blkdev_create(TEST_DISK_NAME,
|
||||
TEST_DISK_BLOCK_SIZE, TEST_DISK_BLOCK_NUM,
|
||||
test_disk_ioctl,
|
||||
NULL);
|
||||
if (rc != RTEMS_SUCCESSFUL)
|
||||
{
|
||||
printf("Failed to create %s disk\n", TEST_DISK_NAME);
|
||||
|
||||
Reference in New Issue
Block a user