Changeset eb93595 in rtems for cpukit/libblock


Ignore:
Timestamp:
Oct 31, 2012, 12:56:15 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
7a1e92a1
Parents:
9f0a68c
git-author:
Sebastian Huber <sebastian.huber@…> (10/31/12 12:56:15)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/02/12 08:40:58)
Message:

libblock: Documentation

Location:
cpukit/libblock
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libblock/include/rtems/blkdev.h

    r9f0a68c reb93595  
    4242
    4343/**
    44  * Block device request type.
     44 * @brief Block device request type.
    4545 *
    4646 * @warning The sync request is an IO one and only used from the cache. Use the
     
    6565
    6666/**
    67  * Block device scatter or gather buffer structure.
     67 * @brief Block device scatter or gather buffer structure.
    6868 */
    6969typedef struct rtems_blkdev_sg_buffer {
     
    167167
    168168/**
    169  * The start block in a request.
    170  *
    171  * Only valid if the driver has returned the @ref RTEMS_BLKIO_CAPABILITIES of
    172  * @ref RTEMS_BLKDEV_CAP_MULTISECTOR_CONT.
     169 * @brief The start block in a request.
     170 *
     171 * Only valid if the driver has returned the
     172 * @ref RTEMS_BLKDEV_CAP_MULTISECTOR_CONT capability.
    173173 */
    174174#define RTEMS_BLKDEV_START_BLOCK(req) (req->bufs[0].block)
     
    253253
    254254/**
    255  * Only consecutive multi-sector buffer requests are supported.
     255 * @name Block Device Driver Capabilities
     256 *
     257 * @{
     258 */
     259
     260/**
     261 * @brief Only consecutive multi-sector buffer requests are supported.
    256262 *
    257263 * This option means the cache will only supply multiple buffers that are
     
    262268
    263269/**
    264  * The driver will accept a sync call. A sync call is made to a driver
    265  * after a bdbuf cache sync has finished.
     270 * @brief The driver will accept a sync call.
     271 *
     272 * A sync call is made to a driver after a bdbuf cache sync has finished.
    266273 */
    267274#define RTEMS_BLKDEV_CAP_SYNC (1 << 1)
    268275
    269 /**
    270  * The device driver interface conventions suppose that a driver may contain an
    271  * initialize, open, close, read, write and IO control entry points. These
    272  * primitives (except initialize) can be implemented in a generic fashion based
    273  * upon the supplied block device driver IO control handler. Every block device
    274  * driver should provide an initialize entry point, which registers the
    275  * appropriate IO control handler.
    276  */
    277 #define RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
    278   rtems_blkdev_generic_open, \
    279   rtems_blkdev_generic_close, \
    280   rtems_blkdev_generic_read, \
    281   rtems_blkdev_generic_write, \
    282   rtems_blkdev_generic_ioctl
    283 
    284 /**
    285  * Generic block device read primitive.
    286  *
    287  * Implemented using block device buffer management primitives.
    288  */
    289 rtems_device_driver
    290 rtems_blkdev_generic_read(
    291     rtems_device_major_number major,
    292     rtems_device_minor_number minor,
    293     void                    * arg
    294 );
    295 
    296 /**
    297  * Generic block device write primitive.
    298  *
    299  * Implemented using block device buffer management primitives.
    300  */
    301 rtems_device_driver
    302 rtems_blkdev_generic_write(
    303     rtems_device_major_number major,
    304     rtems_device_minor_number minor,
    305     void                    * arg
    306 );
    307 
    308 /**
    309  * Generic block device open primitive.
    310  *
    311  * Implemented using block device buffer management primitives.
    312  */
    313 rtems_device_driver
    314 rtems_blkdev_generic_open(
    315     rtems_device_major_number major,
    316     rtems_device_minor_number minor,
    317     void                    * arg
    318 );
    319 
    320 /**
    321  * Generic block device close primitive.
    322  *
    323  * Implemented using block device buffer management primitives.
    324  */
    325 rtems_device_driver
    326 rtems_blkdev_generic_close(
    327     rtems_device_major_number major,
    328     rtems_device_minor_number minor,
    329     void                    * arg
    330 );
    331 
    332 /**
    333  * Generic block device IO control primitive.
    334  *
    335  * Implemented using block device buffer management primitives.
    336  */
    337 rtems_device_driver
    338 rtems_blkdev_generic_ioctl(
    339     rtems_device_major_number major,
    340     rtems_device_minor_number minor,
    341     void                    * arg
    342 );
    343 
    344 /**
    345  * Common IO control primitive.
    346  *
    347  * Use this in all block devices to handle the common set of ioctl requests.
     276/** @} */
     277
     278/**
     279 * @brief Common IO control primitive.
     280 *
     281 * Use this in all block devices to handle the common set of IO control
     282 * requests.
    348283 */
    349284int
     
    351286
    352287/**
    353  * @brief Generic block operations driver address table.
    354  */
    355 extern const rtems_driver_address_table rtems_blkdev_generic_ops;
    356 
    357 /**
    358288 * @brief Creates a block device.
    359289 *
     290 * The block size is set to the media block size.
     291 *
    360292 * @param[in] device The path for the new block device.
    361  * @param[in] block_size The block size.  Must be positive.
    362  * @param[in] block_count The block count.  Must be positive.
     293 * @param[in] media_block_size The media block size in bytes.  Must be positive.
     294 * @param[in] media_block_count The media block count.  Must be positive.
    363295 * @param[in] handler The block device IO control handler.  Must not be @c NULL.
    364296 * @param[in] driver_data The block device driver data.
    365297 *
    366298 * @retval RTEMS_SUCCESSFUL Successful operation.
    367  * @retval RTEMS_INVALID_NUMBER Block size or block count is not positive.
     299 * @retval RTEMS_INVALID_NUMBER Media block size or count is not positive.
    368300 * @retval RTEMS_NO_MEMORY Not enough memory.
    369301 * @retval RTEMS_UNSATISFIED Cannot create generic device node.
    370302 *
    371  * @see rtems_blkdev_create_partition() and rtems_blkdev_request.
     303 * @see rtems_blkdev_create_partition(), rtems_bdbuf_set_block_size(), and
     304 * rtems_blkdev_request.
    372305 */
    373306rtems_status_code rtems_blkdev_create(
    374307  const char *device,
    375   uint32_t block_size,
    376   rtems_blkdev_bnum block_count,
     308  uint32_t media_block_size,
     309  rtems_blkdev_bnum media_block_count,
    377310  rtems_block_device_ioctl handler,
    378311  void *driver_data
     
    380313
    381314/**
    382  * @brief Creates a partition within a block device.
    383  *
    384  * A partition manages a subset of consecutive blocks contained in a block
     315 * @brief Creates a partition within a parent block device.
     316 *
     317 * A partition manages a subset of consecutive blocks contained in a parent block
    385318 * device.  The blocks must be within the range of blocks managed by the
    386  * associated block device.  The media block size, block size, and IO control
    387  * handler are inherited by the block device.
     319 * associated parent block device.  The media block size and IO control
     320 * handler are inherited by the parent block device.  The block size is set to
     321 * the media block size.
    388322 *
    389323 * @param[in] partition The path for the new partition device.
    390  * @param[in] device The block device path.
    391  * @param[in] block_begin The block begin of the partition.
    392  * @param[in] block_count The block count of the partition.
     324 * @param[in] parent_block_device The parent block device path.
     325 * @param[in] media_block_begin The media block begin of the partition within
     326 * the parent block device.
     327 * @param[in] media_block_count The media block count of the partition.
    393328 *
    394329 * @retval RTEMS_SUCCESSFUL Successful operation.
     
    400335 * @retval RTEMS_UNSATISFIED Cannot create generic device node.
    401336 *
    402  * @see rtems_blkdev_create().
     337 * @see rtems_blkdev_create() and rtems_bdbuf_set_block_size().
    403338 */
    404339rtems_status_code rtems_blkdev_create_partition(
    405340  const char *partition,
    406   const char *device,
    407   rtems_blkdev_bnum block_begin,
    408   rtems_blkdev_bnum block_count
     341  const char *parent_block_device,
     342  rtems_blkdev_bnum media_block_begin,
     343  rtems_blkdev_bnum media_block_count
    409344);
    410345
     
    429364/** @} */
    430365
     366/**
     367 * @defgroup rtems_blkdev_generic Generic Disk Device
     368 *
     369 * @ingroup rtems_blkdev
     370 *
     371 * Generic disk device operations for standard RTEMS IO drivers.
     372 *
     373 * @{
     374 */
     375
     376/**
     377 * The device driver interface conventions suppose that a driver may contain an
     378 * initialize, open, close, read, write and IO control entry points. These
     379 * primitives (except initialize) can be implemented in a generic fashion based
     380 * upon the supplied block device driver IO control handler. Every block device
     381 * driver should provide an initialize entry point, which registers the
     382 * appropriate IO control handler.
     383 */
     384#define RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
     385  rtems_blkdev_generic_open, \
     386  rtems_blkdev_generic_close, \
     387  rtems_blkdev_generic_read, \
     388  rtems_blkdev_generic_write, \
     389  rtems_blkdev_generic_ioctl
     390
     391/**
     392 * Generic block device read primitive.
     393 *
     394 * Implemented using block device buffer management primitives.
     395 */
     396rtems_device_driver
     397rtems_blkdev_generic_read(
     398    rtems_device_major_number major,
     399    rtems_device_minor_number minor,
     400    void                    * arg
     401);
     402
     403/**
     404 * Generic block device write primitive.
     405 *
     406 * Implemented using block device buffer management primitives.
     407 */
     408rtems_device_driver
     409rtems_blkdev_generic_write(
     410    rtems_device_major_number major,
     411    rtems_device_minor_number minor,
     412    void                    * arg
     413);
     414
     415/**
     416 * Generic block device open primitive.
     417 *
     418 * Implemented using block device buffer management primitives.
     419 */
     420rtems_device_driver
     421rtems_blkdev_generic_open(
     422    rtems_device_major_number major,
     423    rtems_device_minor_number minor,
     424    void                    * arg
     425);
     426
     427/**
     428 * Generic block device close primitive.
     429 *
     430 * Implemented using block device buffer management primitives.
     431 */
     432rtems_device_driver
     433rtems_blkdev_generic_close(
     434    rtems_device_major_number major,
     435    rtems_device_minor_number minor,
     436    void                    * arg
     437);
     438
     439/**
     440 * Generic block device IO control primitive.
     441 *
     442 * Implemented using block device buffer management primitives.
     443 */
     444rtems_device_driver
     445rtems_blkdev_generic_ioctl(
     446    rtems_device_major_number major,
     447    rtems_device_minor_number minor,
     448    void                    * arg
     449);
     450
     451/**
     452 * @brief Generic block operations driver address table.
     453 */
     454extern const rtems_driver_address_table rtems_blkdev_generic_ops;
     455
     456/** @} */
     457
    431458#ifdef __cplusplus
    432459}
  • cpukit/libblock/src/blkdev-imfs.c

    r9f0a68c reb93595  
    263263rtems_status_code rtems_blkdev_create(
    264264  const char *device,
    265   uint32_t block_size,
    266   rtems_blkdev_bnum block_count,
     265  uint32_t media_block_size,
     266  rtems_blkdev_bnum media_block_count,
    267267  rtems_block_device_ioctl handler,
    268268  void *driver_data
     
    275275    sc = rtems_disk_init_phys(
    276276      &ctx->dd,
    277       block_size,
    278       block_count,
     277      media_block_size,
     278      media_block_count,
    279279      handler,
    280280      driver_data
     
    307307rtems_status_code rtems_blkdev_create_partition(
    308308  const char *partition,
    309   const char *device,
    310   rtems_blkdev_bnum block_begin,
    311   rtems_blkdev_bnum block_count
     309  const char *parent_block_device,
     310  rtems_blkdev_bnum media_block_begin,
     311  rtems_blkdev_bnum media_block_count
    312312)
    313313{
    314314  rtems_status_code sc = RTEMS_SUCCESSFUL;
    315   int fd = open(device, O_RDWR);
     315  int fd = open(parent_block_device, O_RDWR);
    316316
    317317  if (fd >= 0) {
     
    331331            &ctx->dd,
    332332            phys_dd,
    333             block_begin,
    334             block_count
     333            media_block_begin,
     334            media_block_count
    335335          );
    336336
Note: See TracChangeset for help on using the changeset viewer.