source: rtems/cpukit/libblock/include/rtems/diskdevs.h @ 2e92a5d

4.104.115
Last change on this file since 2e92a5d was 0d15414e, checked in by Chris Johns <chrisj@…>, on 08/05/09 at 00:00:54

009-08-05 Chris Johns <chrisj@…>

  • libmisc/dummy/dummy-networking.c: New.
  • libmisc/dummy/dummy.c, libmisc/Makefile.am: Move trhe networking configuration into a separate file so configuration varations do not cause conflicts.
  • score/inline/rtems/score/object.inl, score/include/rtems/score/object.h: Remove warnings.
  • score/inline/rtems/score/object.inl: Add _Chain_First, _Chain_Last, _Chain_Mext, and _Chain_Previous.
  • sapi/inline/rtems/chain.inl: Add rtems_chain_first, rtems_chain_last, rtems_chain_mext, and rtems_chain_previous.
  • libblock/include/rtems/diskdevs.h: Remove the bdbuf pool id and block_size_log2. Add media_block_size.
  • libblock/src/diskdevs.c: Remove size restrictions on block size. Add media block size initialisation. Remove comment to clean up the bdbuf cache.
  • libblock/src/blkdev.c: Remove references to block_size_log2. Allow any block size.
  • libblock/include/rtems/bdbuf.h, libblock/src/bdbuf.c: Remove all references to pools and make the cache handle demand driver variable buffer size allocation. Added worker threads support the swapout task.
  • sapi/include/confdefs.h: Updated the bdbuf configutation.
  • Property mode set to 100644
File size: 5.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup rtems_disk
5 *
6 * Block device disk management.
7 */
8 
9/*
10 * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
11 * Author: Victor V. Vengerov <vvv@oktet.ru>
12 *
13 * @(#) $Id$
14 */
15
16#ifndef _RTEMS_DISKDEVS_H
17#define _RTEMS_DISKDEVS_H
18
19#include <rtems.h>
20#include <rtems/libio.h>
21#include <stdlib.h>
22
23#include <rtems/blkdev.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/**
30 * @defgroup rtems_disk Block Device Disk Management
31 *
32 * @ingroup rtems_libblock
33 *
34 * This module provides functions to manage disk devices.
35 *
36 * A disk is a set of blocks which are identified by a consecutive set of
37 * non-negative integers starting at zero.  There are also logical disks which
38 * contain a subset of consecutive disk blocks.  The logical disks are used to
39 * represent the partitions of a disk.  The disk devices are accessed via the
40 * @ref rtems_bdbuf "block device buffer module".
41 *
42 * @{
43 */
44
45/**
46 * Block device IO control handler type.
47 */
48typedef int (*rtems_block_device_ioctl)( dev_t dev, uint32_t req, void *argp);
49
50/**
51 * Description of a disk device (logical and physical disks).
52 *
53 * An array of pointer tables to rtems_disk_device structures is maintained.
54 * The first table will be indexed by the major number and the second table
55 * will be indexed by the minor number.  This allows quick lookup using a data
56 * structure of moderated size.
57 */
58typedef struct rtems_disk_device {
59  /**
60   * Device identifier (concatenation of major and minor number).
61   */
62  dev_t dev;
63
64  /**
65   * Physical device identifier (equals the @c dev entry if it specifies a
66   * physical device).
67   */
68  struct rtems_disk_device *phys_dev;
69
70  /**
71   * Driver capabilities.
72   */
73  uint32_t capabilities;
74
75  /**
76   * Disk device name.
77   */
78  char *name;
79
80  /**
81   * Usage counter.
82   *
83   * Devices cannot be removed if they are in use.
84   */
85  unsigned uses;
86
87  /**
88   * Start block number.
89   *
90   * Equals zero for physical devices.  It is a block offset to the related
91   * physical device for logical device.
92   */
93  rtems_blkdev_bnum start;
94
95  /**
96   * Size of the physical or logical disk in blocks.
97   */
98  rtems_blkdev_bnum size;
99
100  /**
101   * Device block size in bytes.
102   *
103   * This is the minimum transfer unit. It can be any size.
104   */
105  uint32_t block_size;
106
107  /**
108   * Device media block size in bytes.
109   *
110   * This is the media transfer unit the hardware defaults to.
111   */
112  uint32_t media_block_size;
113
114  /**
115   * IO control handler for this disk.
116   */
117  rtems_block_device_ioctl ioctl;
118} rtems_disk_device;
119
120/**
121 * Creates a physical disk with device identifier @a dev.
122 *
123 * The block size @a block_size must be a power of two.  The disk size @a
124 * disk_size is the number of blocks provided by this disk.  The block index
125 * starts with zero.  The associated disk device driver will be invoked via the
126 * IO control handler @a handler.  A device node will be registered in the file
127 * system with absolute path @a name.  This function is usually invoked from a
128 * block device driver during initialization when a physical device is detected
129 * in the system.  The device driver provides an IO control handler to allow
130 * block device operations.
131 */
132rtems_status_code rtems_disk_create_phys(
133  dev_t dev,
134  uint32_t block_size,
135  rtems_blkdev_bnum disk_size,
136  rtems_block_device_ioctl handler,
137  const char *name
138);
139
140/**
141 * Creates a logical disk with device identifier @a dev.
142 *
143 * A logical disk manages a subset of consecutive blocks containd in the
144 * physical disk with identifier @a phys.  The start block index of the logical
145 * disk device is @a start.  The block number of the logcal disk will be @a
146 * size.  The blocks must be within the range of blocks managed by the
147 * associated physical disk device.  A device node will be registered in the
148 * file system with absolute path @a name.  The block size and IO control
149 * handler are inherited by the physical disk.
150 */
151rtems_status_code rtems_disk_create_log(
152  dev_t dev,
153  dev_t phys,
154  rtems_blkdev_bnum start,
155  rtems_blkdev_bnum size,
156  const char *name
157);
158
159/**
160 * Deletes a physical or logical disk device with identifier @a dev.
161 *
162 * Disk devices may be deleted if there usage counter (and the usage counters
163 * of all contained logical disks devices) equals zero.  When a physical disk
164 * device is deleted, all logical disk devices will deleted too.  The
165 * corresponding device nodes will be removed from the file system.
166 */
167rtems_status_code rtems_disk_delete(dev_t dev);
168
169/**
170 * Returns the disk device descriptor for the device identifier @a dev.
171 *
172 * Increments usage counter by one.  You should release the disk device
173 * descriptor with rtems_disk_release().  Returns @c NULL if no corresponding
174 * disk exists.
175 */
176rtems_disk_device *rtems_disk_obtain(dev_t dev);
177
178/**
179 * Releases the disk device description @a dd.
180 *
181 * Decrements usage counter by one.
182 */
183rtems_status_code rtems_disk_release(rtems_disk_device *dd);
184
185/**
186 * Disk device iterator.
187 *
188 * Returns the next disk device descriptor with a device identifier larger than
189 * @a dev.  If there is no such device, @c NULL will be returned.  Use minus
190 * one to start the search.
191 *
192 * @code
193 * rtems_disk_device *dd = rtems_disk_next((dev_t) -1);
194 *
195 * while (dd != NULL) {
196 *   dd = rtems_disk_next(dd->dev);
197 * }
198 * @endcode
199 */
200rtems_disk_device *rtems_disk_next(dev_t dev);
201
202/**
203 * Initializes the disk device management.
204 *
205 * This functions returns successful if the disk device management is already
206 * initialized.  There is no protection against concurrent access.
207 */
208rtems_status_code rtems_disk_io_initialize(void);
209
210/**
211 * Releases all resources allocated for disk device management.
212 */
213rtems_status_code rtems_disk_io_done(void);
214
215/** @} */
216
217#ifdef __cplusplus
218}
219#endif
220
221#endif
Note: See TracBrowser for help on using the repository browser.