source: rtems/cpukit/libblock/include/rtems/blkdev.h @ e51bd96

4.104.114.84.9
Last change on this file since e51bd96 was e51bd96, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 28, 2002 at 8:39:54 PM

2002-02-28 Joel Sherrill <joel@…>

  • Submitted by Victor V. Vengerov <vvv@…> and merged into the RTEMS source.
  • ChangeLog?, Makefile.am, README, configure.ac, include/Makefile.am, include/rtems/bdbuf.h, include/rtems/blkdev.h, include/rtems/diskdevs.h, include/rtems/ramdisk.h, include/rtems/.cvsignore, include/.cvsignore, src/Makefile.am, src/bdbuf.c, src/blkdev.c, src/diskdevs.c, src/ramdisk.c, src/.cvsignore, .cvsignore: New files.
  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*
2 * blkdev.h - block device driver interface definitions
3 *
4 * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
5 * Author: Victor V. Vengerov <vvv@oktet.ru>
6 *
7 * @(#) $Id$
8 */
9
10#ifndef __RTEMS_LIBBLOCK_BLKDEV_H__
11#define __RTEMS_LIBBLOCK_BLKDEV_H__
12
13#include <rtems.h>
14#include <sys/ioctl.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/* Interface with device drivers
21 * Block device looks, initialized and behaves like traditional RTEMS device
22 * driver. Heart of the block device driver is in BIOREQUEST ioctl. This call
23 * puts I/O request to the block device queue, in priority order, for
24 * asynchronous processing. When driver executes request, req_done
25 * function invoked, so callee knows about it. Look for details below.
26 */
27
28
29/* Block device block number datatype */
30typedef rtems_unsigned32 blkdev_bnum;
31
32/* Block device request type */
33typedef enum blkdev_request_op {
34    BLKDEV_REQ_READ,  /* Read operation */
35    BLKDEV_REQ_WRITE  /* Write operation */
36} blkdev_request_op;
37
38/* Type for block device request done callback function.
39 *
40 * PARAMETERS:
41 *     arg    - argument supplied in blkdev_request
42 *     status - rtems status code for this operation
43 *     errno  - errno value to be passed to the user when
44 *              status != RTEMS_SUCCESSFUL
45 */
46typedef void (* blkdev_request_cb)(void *arg, 
47                                   rtems_status_code status,
48                                   int error);
49
50/* blkdev_sg_buffer
51 * Block device scatter/gather buffer structure
52 */
53typedef struct blkdev_sg_buffer {
54    rtems_unsigned32 length;  /* Buffer length */
55    void            *buffer;  /* Buffer pointer */
56} blkdev_sg_buffer;
57
58/* blkdev_request (Block Device Request) structure is
59 * used to read/write a number of blocks from/to device.
60 */
61typedef struct blkdev_request {
62    blkdev_request_op req;      /* Block device operation (read or write) */
63    blkdev_request_cb req_done; /* Callback function */
64    void             *done_arg; /* Argument to be passed to callback function*/
65    blkdev_bnum       start;    /* Start block number */
66    rtems_unsigned32  count;    /* Number of blocks to be exchanged */
67    rtems_unsigned32  bufnum;   /* Number of buffers provided */   
68   
69    blkdev_sg_buffer  bufs[0];/* List of scatter/gather buffers */
70} blkdev_request;
71
72/* Block device IOCTL request codes */
73#define BLKIO_REQUEST      _IOWR('B', 1, blkdev_request)
74#define BLKIO_GETBLKSIZE   _IO('B', 2)
75#define BLKIO_GETSIZE      _IO('B', 3)
76#define BLKIO_SYNCDEV      _IO('B', 4)
77
78/* Device driver interface conventions suppose that driver may
79 * contain initialize/open/close/read/write/ioctl entry points. These
80 * primitives (except initialize) can be implemented in generic fashion,
81 * based upon supplied block device driver ioctl handler. Every block
82 * device driver should provide initialize entry point, which is register
83 * all block devices and appropriate ioctl handlers.
84 */
85
86#define GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
87      rtems_blkdev_generic_open, rtems_blkdev_generic_close, \
88      rtems_blkdev_generic_read, rtems_blkdev_generic_write, \
89      rtems_blkdev_generic_ioctl
90
91/* blkdev_generic_read --
92 *     Generic block device read primitive. Implemented using block device
93 *     buffer management primitives.
94 */
95rtems_device_driver
96rtems_blkdev_generic_read(
97    rtems_device_major_number major,
98    rtems_device_minor_number minor,
99    void                    * arg
100);
101
102/* blkdev_generic_write --
103 *     Generic block device driver write primitive. Implemented using block
104 *     device buffer management primitives.
105 */
106rtems_device_driver
107rtems_blkdev_generic_write(
108    rtems_device_major_number major,
109    rtems_device_minor_number minor,
110    void                    * arg
111);
112
113/* blkdev_generic_open --
114 *     Generic block device open primitive.
115 */
116rtems_device_driver
117rtems_blkdev_generic_open(
118    rtems_device_major_number major,
119    rtems_device_minor_number minor,
120    void                    * arg
121);
122
123/* blkdev_generic_close --
124 *     Generic block device close primitive.
125 */
126rtems_device_driver
127rtems_blkdev_generic_close(
128    rtems_device_major_number major,
129    rtems_device_minor_number minor,
130    void                    * arg
131);
132
133/* blkdev_generic_ioctl --
134 *     Generic block device ioctl primitive.
135 */
136rtems_device_driver
137rtems_blkdev_generic_ioctl(
138    rtems_device_major_number major,
139    rtems_device_minor_number minor,
140    void                    * arg
141);
142
143#ifdef __cplusplus
144}
145#endif
146
147#endif
Note: See TracBrowser for help on using the repository browser.