source: rtems/cpukit/libblock/include/rtems/diskdevs.h @ cec5c069

4.104.114.95
Last change on this file since cec5c069 was cec5c069, checked in by Joel Sherrill <joel.sherrill@…>, on 08/21/08 at 16:17:35

2008-08-21 Joel Sherrill <joel.sherrill@…>

  • libblock/include/rtems/bdbuf.h, libblock/include/rtems/diskdevs.h, libblock/src/bdbuf.c, libblock/src/blkdev.c, libblock/src/diskdevs.c, libblock/src/ramdisk.c: Eliminate sign mismatch warnings.
  • Property mode set to 100644
File size: 7.4 KB
Line 
1/**
2 * @file rtems/diskdevs.h
3 * Physical and logical block devices (disks) support
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_DISKDEVS_H
14#define _RTEMS_DISKDEVS_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#include <rtems.h>
21#include <rtems/libio.h>
22#include <stdlib.h>
23
24/* Buffer pool identifier */
25typedef int rtems_bdpool_id;
26
27#include "rtems/blkdev.h"
28
29/* Driver capabilities. */
30
31/* Block device ioctl handler */
32typedef int (* rtems_block_device_ioctl) (dev_t dev, uint32_t req, void *argp);
33
34/* rtems_disk_device: Entry of this type created for every disk device
35 * (both for logical and physical disks).
36 * Array of arrays of pointers to disk_device structures maintained. First
37 * table indexed by major number and second table indexed by minor number.
38 * Such data organization allow quick lookup using data structure of
39 * moderated size.
40 */
41typedef struct rtems_disk_device {
42    dev_t                     dev;          /* Device ID (major + minor) */
43    struct rtems_disk_device *phys_dev;     /* Physical device ID (the same
44                                               as dev if this entry specifies
45                                               the physical device) */
46    uint32_t                  capabilities; /* Driver capabilities. */
47    char                     *name;         /* Disk device name */
48    int                       uses;         /* Use counter. Device couldn't be
49                                               removed if it is in use. */
50    uint32_t                  start;        /* Starting block number (0 for
51                                               physical devices, block offset
52                                               on the related physical device
53                                               for logical device) */
54    uint32_t                  size;         /* Size of physical or logical disk
55                                               in disk blocks */
56    uint32_t                  block_size;   /* Size of device block (minimum
57                                               transfer unit) in bytes
58                                               (must be power of 2) */
59    uint32_t            block_size_log2;    /* log2 of block_size */
60    rtems_bdpool_id     pool;               /* Buffer pool assigned to this
61                                               device */
62    rtems_block_device_ioctl  ioctl;        /* ioctl handler for this block
63                                               device */
64} rtems_disk_device;
65
66/* rtems_disk_create_phys --
67 *     Create physical disk entry. This function usually invoked from
68 *     block device driver initialization code when physical device
69 *     detected in the system. Device driver should provide ioctl handler
70 *     to allow block device access operations. This primitive will register
71 *     device in rtems (invoke rtems_io_register_name).
72 *
73 * PARAMETERS:
74 *     dev        - device identifier (major, minor numbers)
75 *     block_size - size of disk block (minimum data transfer unit); must be
76 *                  power of 2
77 *     disk_size  - number of blocks on device
78 *     handler    - IOCTL handler (function providing basic block input/output
79 *                  request handling BIOREQUEST and other device management
80 *                  operations)
81 *     name       - character name of device (e.g. /dev/hda)
82 *
83 * RETURNS:
84 *     RTEMS_SUCCESSFUL if information about new physical disk added, or
85 *     error code if error occured (device already registered, wrong block
86 *     size value, no memory available).
87 */
88rtems_status_code
89rtems_disk_create_phys(dev_t dev, int block_size, int disk_size,
90                       rtems_block_device_ioctl handler,
91                       const char *name);
92
93/* rtems_disk_create_log --
94 *     Create logical disk entry. Logical disk is contiguous area on physical
95 *     disk. Disk may be splitted to several logical disks in several ways:
96 *     manually or using information stored in blocks on physical disk
97 *     (DOS-like partition table, BSD disk label, etc). This function usually
98 *     invoked from application when application-specific splitting are in use,
99 *     or from generic code which handle different logical disk organizations.
100 *     This primitive will register device in rtems (invoke
101 *     rtems_io_register_name).
102 *
103 * PARAMETERS:
104 *     dev   - logical device identifier (major, minor numbers)
105 *     phys  - physical device (block device which holds this logical disk)
106 *             identifier
107 *     start - starting block number on the physical device
108 *     size  - logical disk size in blocks
109 *     name  - logical disk name
110 *
111 * RETURNS:
112 *     RTEMS_SUCCESSFUL if logical device successfully added, or error code
113 *     if error occured (device already registered, no physical device
114 *     exists, logical disk is out of physical disk boundaries, no memory
115 *     available).
116 */
117rtems_status_code
118rtems_disk_create_log(dev_t dev, dev_t phys, int start, int size, char *name);
119
120/* rtems_disk_delete --
121 *     Delete physical or logical disk device. Device may be deleted if its
122 *     use counter (and use counters of all logical devices - if it is
123 *     physical device) equal to 0. When physical device deleted,
124 *     all logical devices deleted inherently. Appropriate devices removed
125 *     from "/dev" filesystem.
126 *
127 * PARAMETERS:
128 *     dev - device identifier (major, minor numbers)
129 *
130 * RETURNS:
131 *     RTEMS_SUCCESSFUL if block device successfully deleted, or error code
132 *     if error occured (device is not defined, device is in use).
133 */
134rtems_status_code
135rtems_disk_delete(dev_t dev);
136
137/* rtems_disk_obtain --
138 *     Find block device descriptor by its device identifier. This function
139 *     increment usage counter to 1. User should release disk_device structure
140 *     by invoking rtems_disk_release primitive.
141 *
142 * PARAMETERS:
143 *     dev - device identifier (major, minor numbers)
144 *
145 * RETURNS:
146 *     pointer to the block device descriptor, or NULL if no such device
147 *     exists.
148 */
149rtems_disk_device *
150rtems_disk_obtain(dev_t dev);
151
152/* rtems_disk_release --
153 *     Release disk_device structure (decrement usage counter to 1).
154 *
155 * PARAMETERS:
156 *     dd - pointer to disk device structure
157 *
158 * RETURNS:
159 *     RTEMS_SUCCESSFUL
160 *
161 * NOTE:
162 *     It should be implemented as inline function.
163 */
164rtems_status_code
165rtems_disk_release(rtems_disk_device *dd);
166
167/* rtems_disk_next --
168 *     Disk device enumerator. Looking for device having device number larger
169 *     than dev and return disk device descriptor for it. If there are no
170 *     such device, NULL value returned.
171 *
172 * PARAMETERS:
173 *     dev - device number (use -1 to start search)
174 *
175 * RETURNS:
176 *     Pointer to the disk descriptor for next disk device, or NULL if all
177 *     devices enumerated. */
178rtems_disk_device *
179rtems_disk_next(dev_t dev);
180
181/* rtems_diskio_initialize --
182 *     Initialization of disk device library (initialize all data structures,
183 *     etc.)
184 *
185 * PARAMETERS:
186 *     none
187 *
188 * RETURNS:
189 *     RTEMS_SUCCESSFUL if library initialized, or error code if error
190 *     occured.
191 */
192rtems_status_code
193rtems_disk_io_initialize(void);
194
195/* rtems_diskio_done --
196 *     Release all resources allocated for disk device interface.
197 *
198 * PARAMETERS:
199 *     none
200 *
201 * RETURNS:
202 *     RTEMS_SUCCESSFUL if all resources released, or error code if error
203 *     occured.
204 */
205rtems_status_code
206rtems_disk_io_done(void);
207
208#ifdef __cplusplus
209}
210#endif
211
212#endif
Note: See TracBrowser for help on using the repository browser.