RTEMS CPU Kit with SuperCore  4.10.99.0
Data Structures
RAM Disk Device
Block Device Management
Collaboration diagram for RAM Disk Device:

Data Structures

struct  rtems_ramdisk_config
 RAM disk configuration table entry. More...
struct  ramdisk
 RAM disk descriptor. More...

Static Configuration

typedef struct rtems_ramdisk_config rtems_ramdisk_config
 RAM disk configuration table entry.
rtems_ramdisk_config rtems_ramdisk_configuration []
 External reference to the RAM disk configuration table describing each RAM disk in the system.
size_t rtems_ramdisk_configuration_size
 External reference the size of the RAM disk configuration table rtems_ramdisk_configuration.
rtems_device_driver ramdisk_initialize (rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
 RAM disk driver initialization entry point.
#define RAMDISK_DRIVER_TABLE_ENTRY
 RAM disk driver table entry.
#define RAMDISK_DEVICE_BASE_NAME   "/dev/rd"

Runtime Configuration

typedef struct ramdisk ramdisk
 RAM disk descriptor.
const rtems_driver_address_table ramdisk_ops
int ramdisk_ioctl (rtems_disk_device *dd, uint32_t req, void *argp)
ramdiskramdisk_allocate (void *area_begin, uint32_t media_block_size, rtems_blkdev_bnum media_block_count, bool trace)
 Allocates and initializes a RAM disk descriptor.
void ramdisk_free (ramdisk *rd)
rtems_status_code ramdisk_register (uint32_t media_block_size, rtems_blkdev_bnum media_block_count, bool trace, const char *disk, dev_t *dev)
 Allocates, initializes and registers a RAM disk.

Define Documentation

#define RAMDISK_DRIVER_TABLE_ENTRY
Value:
{ \
    .initialization_entry = ramdisk_initialize, \
    RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
  }

RAM disk driver table entry.


Function Documentation

ramdisk* ramdisk_allocate ( void *  area_begin,
uint32_t  media_block_size,
rtems_blkdev_bnum  media_block_count,
bool  trace 
)

Allocates and initializes a RAM disk descriptor.

The block size will be media_block_size. The block count will be media_block_count. The disk storage area begins at area_begin. If area_begin is NULL, the memory will be allocated and zeroed. Sets the trace enable to trace.

Returns:
Pointer to allocated and initialized ramdisk structure, or NULL if no memory is available.
Note:
Runtime configuration example:
 #include <rtems/ramdisk.h>

 rtems_status_code create_ramdisk(
   const char *device,
   uint32_t media_block_size,
   rtems_blkdev_bnum media_block_count
 )
 {
   rtems_status_code sc;
   ramdisk *rd;

   rd = ramdisk_allocate(NULL, media_block_size, media_block_count, false);
   if (rd != NULL) {
     sc = rtems_blkdev_create(
       device,
       media_block_size,
       media_block_count,
       ramdisk_ioctl,
       rd
     );
   } else {
     sc = RTEMS_UNSATISFIED;
   }

   return sc;
 }
rtems_status_code ramdisk_register ( uint32_t  media_block_size,
rtems_blkdev_bnum  media_block_count,
bool  trace,
const char *  disk,
dev_t *  dev 
)

Allocates, initializes and registers a RAM disk.

The block size will be media_block_size. The block count will be media_block_count. The disk storage will be allocated. Sets the trace enable to trace. Registers a device node with disk name path disk. The registered device number will be returned in dev.

Return values:
RTEMS_SUCCESSFULSuccessful operation.
RTEMS_UNSATISFIEDSomething is wrong.

Variable Documentation

External reference to the RAM disk configuration table describing each RAM disk in the system.

The configuration table is provided by the application.

External reference the size of the RAM disk configuration table rtems_ramdisk_configuration.

The configuration table size is provided by the application.