source: rtems/cpukit/libblock/include/rtems/blkdev.h @ 92c70b9

4.104.115
Last change on this file since 92c70b9 was 2eb89ad, checked in by Chris Johns <chrisj@…>, on 08/02/08 at 06:23:45

2008-08-02 Chris Johns (chrisj@…>

  • libblock/include/rtems/blkdev.h: Remove count and start from rtems_blkdev_request. Add RTEMS_BLKDEV_START_BLOCK macro.
  • libblock/src/bdbuf.c: Add read ahead blocks always consecutive comment. Change count to bufnum and remove start references. Sort the transfer list so blocks are consecutive where possible.
  • libblock/src/blkdev.c, libblock/src/nvdisk.c, libblock/src/ramdisk.c: Change count to bufnum and remove start references.
  • Property mode set to 100644
File size: 5.3 KB
Line 
1/**
2 * @file rtems/blkdev.h
3 * block device driver interface definitions
4 */
5 
6/*
7 * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
8 * Author: Victor V. Vengerov <vvv@oktet.ru>
9 *
10 * @(#) $Id$
11 */
12
13#ifndef _RTEMS_BLKDEV_H
14#define _RTEMS_BLKDEV_H
15
16#include <rtems.h>
17#include <sys/ioctl.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/*
24 *  Interface with device drivers Block device looks, initialized and behaves
25 * like traditional RTEMS device driver. Heart of the block device driver is in
26 * BIOREQUEST ioctl. This call puts I/O request to the block device queue, in
27 * priority order, for asynchronous processing. When driver executes request,
28 * req_done function invoked, so callee knows about it. Look for details below.
29 */
30
31/*
32 * Block device block number datatype
33 */
34typedef uint32_t rtems_blkdev_bnum;
35
36/* Block device request type */
37typedef enum rtems_blkdev_request_op {
38    RTEMS_BLKDEV_REQ_READ,     /* Read operation */
39    RTEMS_BLKDEV_REQ_WRITE,    /* Write operation */
40    RTEMS_BLKDEV_CAPABILITIES  /* Capabilities request */
41} rtems_blkdev_request_op;
42
43/**
44 * ATA multi-sector buffer requests only supported. This option
45 * means the cache will only supply multiple buffers that are
46 * inorder so the ATA multi-sector command can be used. This is a
47 * hack to work around the current ATA driver.
48 */
49#define RTEMS_BLKDEV_CAP_MULTISECTOR_CONT (1 << 0)
50
51/*
52 * @typedef rtems_blkdev_request_cb
53 *
54 * Type for block device request done callback function.
55 *
56 * @param arg Argument supplied in blkdev_request
57 * @param status RTEMS status code for this operation
58 * @param errno errno value to be passed to the user when
59 *              status != RTEMS_SUCCESSFUL
60 */
61typedef void (* rtems_blkdev_request_cb)(void *arg,
62                                         rtems_status_code status,
63                                         int error);
64
65/**
66 * @struct rtems_blkdev_sg_buffer
67 * Block device scatter/gather buffer structure
68 */
69typedef struct rtems_blkdev_sg_buffer {
70    uint32_t   block;   /* The block number */
71    uint32_t   length;  /* Buffer length */
72    void      *buffer;  /* Buffer pointer */
73    void      *user;    /* User pointer */
74} rtems_blkdev_sg_buffer;
75
76/* blkdev_request (Block Device Request) structure is
77 * used to read/write a number of blocks from/to device.
78 */
79typedef struct rtems_blkdev_request {
80    /* Block device operation (read or write) */
81    rtems_blkdev_request_op req;
82    /* Callback function */
83    rtems_blkdev_request_cb req_done;
84    /* Argument to be passed to callback function*/
85    void *done_arg;
86    /* Last I/O operation completion status */
87    rtems_status_code status;
88    /* If status != RTEMS_SUCCESSFUL, this field contains error code */
89    int error;
90    /* Number of blocks for this request. */
91    uint32_t bufnum;
92
93    /* The task requesting the IO operation. */
94    rtems_id io_task;
95
96    /* List of scatter/gather buffers */
97    rtems_blkdev_sg_buffer bufs[0];
98} rtems_blkdev_request;
99
100/* The start block in a request. Only valid if the driver has returned the
101 * RTEMS_BLKDEV_CAPABILITIES of RTEMS_BLKDEV_CAP_MULTISECTOR_CONT */
102#define RTEMS_BLKDEV_START_BLOCK(_r) (_r->bufs[0].block)
103
104/* Block device IOCTL request codes */
105#define RTEMS_BLKIO_REQUEST      _IOWR('B', 1, rtems_blkdev_request)
106#define RTEMS_BLKIO_GETBLKSIZE   _IO('B', 2)
107#define RTEMS_BLKIO_GETSIZE      _IO('B', 3)
108#define RTEMS_BLKIO_SYNCDEV      _IO('B', 4)
109
110/* Device driver interface conventions suppose that driver may
111 * contain initialize/open/close/read/write/ioctl entry points. These
112 * primitives (except initialize) can be implemented in generic fashion,
113 * based upon supplied block device driver ioctl handler. Every block
114 * device driver should provide initialize entry point, which is register
115 * all block devices and appropriate ioctl handlers.
116 */
117
118#define RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
119      rtems_blkdev_generic_open, rtems_blkdev_generic_close, \
120      rtems_blkdev_generic_read, rtems_blkdev_generic_write, \
121      rtems_blkdev_generic_ioctl
122
123/* blkdev_generic_read --
124 *     Generic block device read primitive. Implemented using block device
125 *     buffer management primitives.
126 */
127rtems_device_driver
128rtems_blkdev_generic_read(
129    rtems_device_major_number major,
130    rtems_device_minor_number minor,
131    void                    * arg
132);
133
134/* blkdev_generic_write --
135 *     Generic block device driver write primitive. Implemented using block
136 *     device buffer management primitives.
137 */
138rtems_device_driver
139rtems_blkdev_generic_write(
140    rtems_device_major_number major,
141    rtems_device_minor_number minor,
142    void                    * arg
143);
144
145/* blkdev_generic_open --
146 *     Generic block device open primitive.
147 */
148rtems_device_driver
149rtems_blkdev_generic_open(
150    rtems_device_major_number major,
151    rtems_device_minor_number minor,
152    void                    * arg
153);
154
155/* blkdev_generic_close --
156 *     Generic block device close primitive.
157 */
158rtems_device_driver
159rtems_blkdev_generic_close(
160    rtems_device_major_number major,
161    rtems_device_minor_number minor,
162    void                    * arg
163);
164
165/* blkdev_generic_ioctl --
166 *     Generic block device ioctl primitive.
167 */
168rtems_device_driver
169rtems_blkdev_generic_ioctl(
170    rtems_device_major_number major,
171    rtems_device_minor_number minor,
172    void                    * arg
173);
174
175#ifdef __cplusplus
176}
177#endif
178
179#endif
Note: See TracBrowser for help on using the repository browser.