RTEMS CPU Kit with SuperCore  4.11.3
Files | Data Structures | Macros | Typedefs
Block Device Disk Management

This module provides functions to manage disk devices. More...

Collaboration diagram for Block Device Disk Management:

Files

file  diskdevs.h
 Block Device Disk Management API.
 
file  diskdevs-init.c
 Block Device Disk Management Initialize.
 
file  diskdevs.c
 Block device disk management implementation.
 

Data Structures

struct  rtems_blkdev_read_ahead
 Block device read-ahead control. More...
 
struct  rtems_blkdev_stats
 Block device statistics. More...
 
struct  rtems_disk_device
 Description of a disk device (logical and physical disks). More...
 

Macros

#define RTEMS_DISK_READ_AHEAD_NO_TRIGGER   ((rtems_blkdev_bnum) -1)
 Trigger value to disable further read-ahead requests.
 

Typedefs

typedef uint32_t rtems_blkdev_bnum
 Block device block index type.
 
typedef int(* rtems_block_device_ioctl) (rtems_disk_device *dd, uint32_t req, void *argp)
 Block device IO control handler type.
 

Disk Device Maintainance

rtems_status_code rtems_disk_create_phys (dev_t dev, uint32_t block_size, rtems_blkdev_bnum block_count, rtems_block_device_ioctl handler, void *driver_data, const char *name)
 Creates a physical disk with device identifier dev. More...
 
rtems_status_code rtems_disk_create_log (dev_t dev, dev_t phys, rtems_blkdev_bnum block_begin, rtems_blkdev_bnum block_count, const char *name)
 Creates a logical disk with device identifier dev. More...
 
rtems_status_code rtems_disk_delete (dev_t dev)
 Deletes a physical or logical disk device with identifier dev. More...
 
rtems_disk_devicertems_disk_obtain (dev_t dev)
 Returns the disk device descriptor for the device identifier dev. More...
 
rtems_status_code rtems_disk_release (rtems_disk_device *dd)
 Releases the disk device descriptor dd. More...
 

Disk Management

rtems_status_code rtems_disk_io_initialize (void)
 Initializes the disk device management. More...
 
rtems_status_code rtems_disk_io_done (void)
 Releases all resources allocated for disk device management. More...
 

Detailed Description

This module provides functions to manage disk devices.

A disk is a set of blocks which are identified by a consecutive set of non-negative integers starting at zero. There are also logical disks which contain a subset of consecutive disk blocks. The logical disks are used to represent the partitions of a disk. The disk devices are accessed via the block device buffer module.

Function Documentation

◆ rtems_disk_create_log()

rtems_status_code rtems_disk_create_log ( dev_t  dev,
dev_t  phys,
rtems_blkdev_bnum  block_begin,
rtems_blkdev_bnum  block_count,
const char *  name 
)

Creates a logical disk with device identifier dev.

A logical disk manages a subset of consecutive blocks contained in the physical disk with identifier phys. The start block index of the logical disk device is block_begin. The block count of the logcal disk will be block_count. The blocks must be within the range of blocks managed by the associated physical disk device. A device node will be registered in the file system with absolute path name, if name is not NULL. The block size and IO control handler are inherited by the physical disk.

Return values
RTEMS_SUCCESSFULSuccessful operation.
RTEMS_NOT_CONFIGUREDCannot lock disk device operation mutex.
RTEMS_INVALID_IDSpecified physical disk identifier does not correspond to a physical disk.
RTEMS_INVALID_NUMBERBegin block or block count are out of range.
RTEMS_NO_MEMORYNot enough memory.
RTEMS_RESOURCE_IN_USEDisk device descriptor for logical disk identifier is already in use.
RTEMS_UNSATISFIEDCannot create device node.

References RTEMS_SUCCESSFUL.

◆ rtems_disk_create_phys()

rtems_status_code rtems_disk_create_phys ( dev_t  dev,
uint32_t  block_size,
rtems_blkdev_bnum  block_count,
rtems_block_device_ioctl  handler,
void *  driver_data,
const char *  name 
)

Creates a physical disk with device identifier dev.

The block size block_size must be positive. The disk will have block_count blocks. The block index starts with zero. The associated disk device driver will be invoked via the IO control handler handler. A device node will be registered in the file system with absolute path name, if name is not NULL. This function is usually invoked from a block device driver during initialization when a physical device is detected in the system. The device driver provides an IO control handler to allow block device operations.

Return values
RTEMS_SUCCESSFULSuccessful operation.
RTEMS_NOT_CONFIGUREDCannot lock disk device operation mutex.
RTEMS_INVALID_ADDRESSIO control handler is NULL.
RTEMS_INVALID_NUMBERBlock size is invalid.
RTEMS_NO_MEMORYNot enough memory.
RTEMS_RESOURCE_IN_USEDisk device descriptor is already in use.
RTEMS_UNSATISFIEDCannot create device node.

References RTEMS_INVALID_ADDRESS, and RTEMS_SUCCESSFUL.

◆ rtems_disk_delete()

rtems_status_code rtems_disk_delete ( dev_t  dev)

Deletes a physical or logical disk device with identifier dev.

Marks the disk device as deleted. When a physical disk device is deleted, all corresponding logical disk devices will marked as deleted too. Disks that are marked as deleted and have a usage counter of zero will be deleted. The corresponding device nodes will be removed from the file system. In case of a physical disk deletion the IO control handler will be invoked with a RTEMS_BLKIO_DELETED request. Disks that are still in use will be deleted upon release.

Return values
RTEMS_SUCCESSFULSuccessful operation.
RTEMS_NOT_CONFIGUREDCannot lock disk device operation mutex.
RTEMS_INVALID_IDNo disk for specified device identifier.

References RTEMS_SUCCESSFUL.

Referenced by rtems_disk_release().

◆ rtems_disk_io_done()

rtems_status_code rtems_disk_io_done ( void  )

Releases all resources allocated for disk device management.

There is no protection against concurrent access. If parts of the system are still in use the behaviour is undefined.

Return values
RTEMS_SUCCESSFULSuccessful operation.

◆ rtems_disk_io_initialize()

rtems_status_code rtems_disk_io_initialize ( void  )

Initializes the disk device management.

This functions returns successful if the disk device management is already initialized. There is no protection against concurrent access.

Return values
RTEMS_SUCCESSFULSuccessful initialization.
RTEMS_NO_MEMORYNot enough memory or no semaphore available.
RTEMS_UNSATISFIEDBlock device buffer initialization failed.

References RTEMS_SUCCESSFUL.

◆ rtems_disk_obtain()

rtems_disk_device* rtems_disk_obtain ( dev_t  dev)

Returns the disk device descriptor for the device identifier dev.

Increments usage counter by one. You should release the disk device descriptor with rtems_disk_release().

Returns
Pointer to the disk device descriptor or NULL if no corresponding disk exists.

References rtems_interrupt_lock_acquire, and RTEMS_SUCCESSFUL.

◆ rtems_disk_release()

rtems_status_code rtems_disk_release ( rtems_disk_device dd)

Releases the disk device descriptor dd.

Decrements usage counter by one.

Return values
RTEMS_SUCCESSFULSuccessful operation.

References rtems_disk_device::deleted, rtems_disk_device::dev, rtems_disk_delete(), rtems_interrupt_lock_acquire, rtems_interrupt_lock_release, RTEMS_SUCCESSFUL, and rtems_disk_device::uses.