From b467782b5354c5d524f46bac84c5b70a8b4fa1f6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 26 Mar 2012 14:58:35 +0200 Subject: libblock: Add rtems_bdbuf_set_block_size() The new function rtems_bdbuf_set_block_size() must be used to set the block size of a disk device. It will check if the block size is valid and set the new fields block_to_media_block_shift and bds_per_group of the rtems_disk_device structure. This helps to avoid complex arithmetic operations in the block device buffer get and read path. --- cpukit/libblock/include/rtems/diskdevs.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'cpukit/libblock/include/rtems/diskdevs.h') diff --git a/cpukit/libblock/include/rtems/diskdevs.h b/cpukit/libblock/include/rtems/diskdevs.h index 8e59f36af3..8571daaa90 100644 --- a/cpukit/libblock/include/rtems/diskdevs.h +++ b/cpukit/libblock/include/rtems/diskdevs.h @@ -109,7 +109,9 @@ struct rtems_disk_device { /** * @brief Device block size in bytes. * - * This is the minimum transfer unit. It can be any size. + * This is the minimum transfer unit. It must be positive. + * + * @see rtems_bdbuf_set_block_size(). */ uint32_t block_size; @@ -120,6 +122,24 @@ struct rtems_disk_device { */ uint32_t media_block_size; + /** + * @brief Block to media block shift. + * + * In case this value is non-negative the media block of a block can be + * calculated as media block = block << block_to_media_block_shift, otherwise + * a 64-bit operation will be used. + * + * @see rtems_bdbuf_set_block_size(). + */ + int block_to_media_block_shift; + + /** + * @brief Buffer descriptors per group count. + * + * @see rtems_bdbuf_set_block_size(). + */ + size_t bds_per_group; + /** * @brief IO control handler for this disk. */ @@ -222,7 +242,7 @@ static inline rtems_blkdev_bnum rtems_disk_get_block_count( * @retval RTEMS_SUCCESSFUL Successful operation. * @retval RTEMS_NOT_CONFIGURED Cannot lock disk device operation mutex. * @retval RTEMS_INVALID_ADDRESS IO control handler is @c NULL. - * @retval RTEMS_INVALID_NUMBER Block size is zero. + * @retval RTEMS_INVALID_NUMBER Block size is invalid. * @retval RTEMS_NO_MEMORY Not enough memory. * @retval RTEMS_RESOURCE_IN_USE Disk device descriptor is already in use. * @retval RTEMS_UNSATISFIED Cannot create device node. -- cgit v1.2.3