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/bdbuf.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'cpukit/libblock/include/rtems/bdbuf.h') diff --git a/cpukit/libblock/include/rtems/bdbuf.h b/cpukit/libblock/include/rtems/bdbuf.h index 8e672bbf73..134a0ceff5 100644 --- a/cpukit/libblock/include/rtems/bdbuf.h +++ b/cpukit/libblock/include/rtems/bdbuf.h @@ -479,7 +479,7 @@ rtems_bdbuf_init (void); * @param bd [out] Reference to the buffer descriptor pointer. * * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_NUMBER Invalid block size. + * @retval RTEMS_INVALID_ID Invalid block number. */ rtems_status_code rtems_bdbuf_get ( @@ -512,7 +512,7 @@ rtems_bdbuf_get ( * @param bd [out] Reference to the buffer descriptor pointer. * * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_NUMBER Invalid block size. + * @retval RTEMS_INVALID_ID Invalid block number. * @retval RTEMS_IO_ERROR IO error. */ rtems_status_code @@ -625,6 +625,25 @@ rtems_bdbuf_syncdev (const rtems_disk_device *dd); void rtems_bdbuf_purge_dev (const rtems_disk_device *dd); +/** + * @brief Sets the block size of a disk device. + * + * This will also change the block_to_media_block_shift and bds_per_group + * fields of the disk device. + * + * Before you can use this function, the rtems_bdbuf_init() routine must be + * called at least once to initialize the cache, otherwise a fatal error will + * occur. + * + * @param dd [in, out] The disk device. + * @param dd [in] The new block size. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_NUMBER Invalid block size. + */ +rtems_status_code +rtems_bdbuf_set_block_size (rtems_disk_device *dd, uint32_t block_size); + /** @} */ #ifdef __cplusplus -- cgit v1.2.3