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

4.104.114.84.9
Last change on this file since ef142d7 was ef142d7, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 28, 2002 at 2:00:43 PM

2002-10-28 Eugeny S. Mints <Eugeny.Mints@…>

  • Added ATA support.
  • include/rtems/blkdev.h: Added last IO status.
  • include/rtems/ata.h, include/rtems/ata_internal.h, include/rtems/ide_part_table.h, src/ata.c, src/ide_part_table.c: New files.
  • Property mode set to 100644
File size: 4.6 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    rtems_status_code status;  /* Last I/O operation completion status */
66    int               error;   /* If status != RTEMS_SUCCESSFUL, this field
67                                * contains error code
68                                */
69    blkdev_bnum       start;    /* Start block number */
70    rtems_unsigned32  count;    /* Number of blocks to be exchanged */
71    rtems_unsigned32  bufnum;   /* Number of buffers provided */   
72   
73    blkdev_sg_buffer  bufs[0];/* List of scatter/gather buffers */
74} blkdev_request;
75
76/* Block device IOCTL request codes */
77#define BLKIO_REQUEST      _IOWR('B', 1, blkdev_request)
78#define BLKIO_GETBLKSIZE   _IO('B', 2)
79#define BLKIO_GETSIZE      _IO('B', 3)
80#define BLKIO_SYNCDEV      _IO('B', 4)
81
82/* Device driver interface conventions suppose that driver may
83 * contain initialize/open/close/read/write/ioctl entry points. These
84 * primitives (except initialize) can be implemented in generic fashion,
85 * based upon supplied block device driver ioctl handler. Every block
86 * device driver should provide initialize entry point, which is register
87 * all block devices and appropriate ioctl handlers.
88 */
89
90#define GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
91      rtems_blkdev_generic_open, rtems_blkdev_generic_close, \
92      rtems_blkdev_generic_read, rtems_blkdev_generic_write, \
93      rtems_blkdev_generic_ioctl
94
95/* blkdev_generic_read --
96 *     Generic block device read primitive. Implemented using block device
97 *     buffer management primitives.
98 */
99rtems_device_driver
100rtems_blkdev_generic_read(
101    rtems_device_major_number major,
102    rtems_device_minor_number minor,
103    void                    * arg
104);
105
106/* blkdev_generic_write --
107 *     Generic block device driver write primitive. Implemented using block
108 *     device buffer management primitives.
109 */
110rtems_device_driver
111rtems_blkdev_generic_write(
112    rtems_device_major_number major,
113    rtems_device_minor_number minor,
114    void                    * arg
115);
116
117/* blkdev_generic_open --
118 *     Generic block device open primitive.
119 */
120rtems_device_driver
121rtems_blkdev_generic_open(
122    rtems_device_major_number major,
123    rtems_device_minor_number minor,
124    void                    * arg
125);
126
127/* blkdev_generic_close --
128 *     Generic block device close primitive.
129 */
130rtems_device_driver
131rtems_blkdev_generic_close(
132    rtems_device_major_number major,
133    rtems_device_minor_number minor,
134    void                    * arg
135);
136
137/* blkdev_generic_ioctl --
138 *     Generic block device ioctl primitive.
139 */
140rtems_device_driver
141rtems_blkdev_generic_ioctl(
142    rtems_device_major_number major,
143    rtems_device_minor_number minor,
144    void                    * arg
145);
146
147#ifdef __cplusplus
148}
149#endif
150
151#endif
Note: See TracBrowser for help on using the repository browser.