Changeset 9f0a68c in rtems for cpukit/libblock


Ignore:
Timestamp:
Oct 31, 2012, 10:54:39 AM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
eb93595
Parents:
20e1e769
git-author:
Sebastian Huber <sebastian.huber@…> (10/31/12 10:54:39)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/02/12 08:40:58)
Message:

libblock: Block device transfer request API change

Add and use rtems_blkdev_request_done(). Block device transfer requests
must signal the completion status now with rtems_blkdev_request_done().
The return value of the block device IO control will be ignored for
transfer requests.

The first parameter of rtems_blkdev_request_cb is now the transfer
request structure.

Renamed rtems_blkdev_request::req_done to rtems_blkdev_request::done to
break third party drivers at compile time, otherwise this API change
would result in runtime errors.

Location:
cpukit/libblock
Files:
5 edited

Legend:

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

    r20e1e769 r9f0a68c  
    5454} rtems_blkdev_request_op;
    5555
     56struct rtems_blkdev_request;
     57
    5658/**
    5759 * @brief Block device request done callback function type.
    58  *
    59  * The first parameter @a arg must be the argument provided by the block device
    60  * request structure @ref rtems_blkdev_request.
    61  *
    62  * The second parameter @a status should contain the status of the operation:
    63  *  - @c RTEMS_SUCCESSFUL Operation was successful.
    64  *  - @c RTEMS_IO_ERROR Some sort of input or output error.
    65  *  - @c RTEMS_UNSATISFIED Media no more present.
    66  */
    67 typedef void (*rtems_blkdev_request_cb)(void *arg, rtems_status_code status);
     60 */
     61typedef void (*rtems_blkdev_request_cb)(
     62  struct rtems_blkdev_request *req,
     63  rtems_status_code status
     64);
    6865
    6966/**
     
    9390
    9491/**
    95  * The block device request structure is used to read or write a number of
    96  * blocks from or to the device.
    97  *
    98  * TODO: The use of these req blocks is not a great design. The req is a
    99  *       struct with a single 'bufs' declared in the req struct and the
    100  *       others are added in the outer level struct. This relies on the
    101  *       structs joining as a single array and that assumes the compiler
    102  *       packs the structs. Why not just place on a list ? The BD has a
    103  *       node that can be used.
     92 * @brief The block device transfer request is used to read or write a number
     93 * of blocks from or to the device.
     94 *
     95 * Transfer requests are issued to the disk device driver with the
     96 * @ref RTEMS_BLKIO_REQUEST IO control.  The transfer request completion status
     97 * must be signalled with rtems_blkdev_request_done().  This function must be
     98 * called exactly once per request.  The return value of the IO control will be
     99 * ignored for transfer requests.
     100 *
     101 * @see rtems_blkdev_create().
    104102 */
    105103typedef struct rtems_blkdev_request {
     
    112110   * Request done callback function.
    113111   */
    114   rtems_blkdev_request_cb req_done;
     112  rtems_blkdev_request_cb done;
    115113
    116114  /**
     
    133131   */
    134132  rtems_id io_task;
     133
     134  /*
     135   * TODO: The use of these req blocks is not a great design. The req is a
     136   *       struct with a single 'bufs' declared in the req struct and the
     137   *       others are added in the outer level struct. This relies on the
     138   *       structs joining as a single array and that assumes the compiler
     139   *       packs the structs. Why not just place on a list ? The BD has a
     140   *       node that can be used.
     141   */
    135142
    136143  /**
     
    139146  rtems_blkdev_sg_buffer bufs[0];
    140147} rtems_blkdev_request;
     148
     149/**
     150 * @brief Signals transfer request completion status.
     151 *
     152 * This function must be called exactly once per request.
     153 *
     154 * @param[in,out] req The transfer request.
     155 * @param[in] status The status of the operation should be
     156 *  - @c RTEMS_SUCCESSFUL, if the operation was successful,
     157 *  - @c RTEMS_IO_ERROR, if some sort of input or output error occured, or
     158 *  - @c RTEMS_UNSATISFIED, if media is no more present.
     159 */
     160static inline void rtems_blkdev_request_done(
     161  rtems_blkdev_request *req,
     162  rtems_status_code status
     163)
     164{
     165  (*req->done)(req, status);
     166}
    141167
    142168/**
     
    342368 * @retval RTEMS_NO_MEMORY Not enough memory.
    343369 * @retval RTEMS_UNSATISFIED Cannot create generic device node.
     370 *
     371 * @see rtems_blkdev_create_partition() and rtems_blkdev_request.
    344372 */
    345373rtems_status_code rtems_blkdev_create(
     
    371399 * @retval RTEMS_NO_MEMORY Not enough memory.
    372400 * @retval RTEMS_UNSATISFIED Cannot create generic device node.
     401 *
     402 * @see rtems_blkdev_create().
    373403 */
    374404rtems_status_code rtems_blkdev_create_partition(
  • cpukit/libblock/src/bdbuf.c

    r20e1e769 r9f0a68c  
    18721872 */
    18731873static void
    1874 rtems_bdbuf_transfer_done (void* arg, rtems_status_code status)
    1875 {
    1876   rtems_blkdev_request* req = (rtems_blkdev_request*) arg;
    1877 
     1874rtems_bdbuf_transfer_done (rtems_blkdev_request* req, rtems_status_code status)
     1875{
    18781876  req->status = status;
    18791877
     
    18871885{
    18881886  rtems_status_code sc = RTEMS_SUCCESSFUL;
    1889   int result = 0;
    18901887  uint32_t transfer_index = 0;
    18911888  bool wake_transfer_waiters = false;
     
    18951892    rtems_bdbuf_unlock_cache ();
    18961893
    1897   result = dd->ioctl (dd->phys_dev, RTEMS_BLKIO_REQUEST, req);
    1898 
    1899   if (result == 0)
    1900   {
    1901     rtems_bdbuf_wait_for_transient_event ();
    1902     sc = req->status;
    1903   }
    1904   else
    1905     sc = RTEMS_IO_ERROR;
     1894  /* The return value will be ignored for transfer requests */
     1895  dd->ioctl (dd->phys_dev, RTEMS_BLKIO_REQUEST, req);
     1896
     1897  /* Wait for transfer request completion */
     1898  rtems_bdbuf_wait_for_transient_event ();
     1899  sc = req->status;
    19061900
    19071901  rtems_bdbuf_lock_cache ();
     
    19781972
    19791973  req->req = RTEMS_BLKDEV_REQ_READ;
    1980   req->req_done = rtems_bdbuf_transfer_done;
    1981   req->done_arg = req;
     1974  req->done = rtems_bdbuf_transfer_done;
    19821975  req->io_task = rtems_task_self ();
    1983   req->status = RTEMS_RESOURCE_IN_USE;
    19841976  req->bufnum = 0;
    19851977
     
    26562648
    26572649  write_req->req = RTEMS_BLKDEV_REQ_WRITE;
    2658   write_req->req_done = rtems_bdbuf_transfer_done;
    2659   write_req->done_arg = write_req;
     2650  write_req->done = rtems_bdbuf_transfer_done;
    26602651  write_req->io_task = rtems_task_self ();
    26612652
  • cpukit/libblock/src/flashdisk.c

    r20e1e769 r9f0a68c  
    20872087  }
    20882088
    2089   req->status = ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL;
    2090   req->req_done (req->done_arg, req->status);
     2089  rtems_blkdev_request_done (req, ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL);
    20912090
    20922091  return 0;
     
    21232122  }
    21242123
    2125   req->status = ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL;
    2126   req->req_done (req->done_arg, req->status);
     2124  rtems_blkdev_request_done (req, ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL);
    21272125
    21282126  return 0;
  • cpukit/libblock/src/nvdisk.c

    r20e1e769 r9f0a68c  
    598598  }
    599599
    600   req->status = ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL;
    601   req->req_done (req->done_arg, req->status);
    602 
    603   return ret;
     600  rtems_blkdev_request_done (req, ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL);
     601
     602  return 0;
    604603}
    605604
     
    638637  }
    639638
    640   req->status = ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL;
    641   req->req_done (req->done_arg, req->status);
     639  rtems_blkdev_request_done (req, ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL);
    642640
    643641  return 0;
  • cpukit/libblock/src/ramdisk-driver.c

    r20e1e769 r9f0a68c  
    6868        memcpy(sg->buffer, from + (sg->block * rd->block_size), sg->length);
    6969    }
    70     req->status = RTEMS_SUCCESSFUL;
    71     req->req_done(req->done_arg, RTEMS_SUCCESSFUL);
     70    rtems_blkdev_request_done (req, RTEMS_SUCCESSFUL);
    7271    return 0;
    7372}
     
    9392        memcpy(to + (sg->block * rd->block_size), sg->buffer, sg->length);
    9493    }
    95     req->status = RTEMS_SUCCESSFUL;
    96     req->req_done(req->done_arg, RTEMS_SUCCESSFUL);
     94    rtems_blkdev_request_done (req, RTEMS_SUCCESSFUL);
    9795    return 0;
    9896}
Note: See TracChangeset for help on using the changeset viewer.