RTEMS: cpukit/include/rtems/diskdevs.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
diskdevs.h
Go to the documentation of this file.
1
9/*
10 * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
11 * Author: Victor V. Vengerov <vvv@oktet.ru>
12 */
13
14#ifndef _RTEMS_DISKDEVS_H
15#define _RTEMS_DISKDEVS_H
16
17#include <rtems.h>
18#include <rtems/libio.h>
19#include <rtems/chain.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25typedef struct rtems_disk_device rtems_disk_device;
26
45 typedef uint32_t rtems_blkdev_bnum;
46
50 typedef int (*rtems_block_device_ioctl)(
51 rtems_disk_device *dd,
52 uint32_t req,
53 void *argp
54);
55
59#define RTEMS_DISK_READ_AHEAD_NO_TRIGGER ((rtems_blkdev_bnum) -1)
60
64 typedef struct {
68 rtems_chain_node node;
69
76 rtems_blkdev_bnum trigger;
77
84 rtems_blkdev_bnum next;
85} rtems_blkdev_read_ahead;
86
92 typedef struct {
99 uint32_t read_hits;
100
108 uint32_t read_misses;
109
115 uint32_t read_ahead_transfers;
116
120 uint32_t read_blocks;
121
127 uint32_t read_errors;
128
134 uint32_t write_transfers;
135
139 uint32_t write_blocks;
140
146 uint32_t write_errors;
147} rtems_blkdev_stats;
148
157 struct rtems_disk_device {
161 dev_t dev;
162
167 rtems_disk_device *phys_dev;
168
172 uint32_t capabilities;
173
177 char *name;
178
184 unsigned uses;
185
192 rtems_blkdev_bnum start;
193
197 rtems_blkdev_bnum size;
198
204 uint32_t media_block_size;
205
214 uint32_t block_size;
215
221 rtems_blkdev_bnum block_count;
222
228 uint32_t media_blocks_per_block;
229
239 int block_to_media_block_shift;
240
246 size_t bds_per_group;
247
251 rtems_block_device_ioctl ioctl;
252
256 void *driver_data;
257
262 bool deleted;
263
267 rtems_blkdev_stats stats;
268
272 rtems_blkdev_read_ahead read_ahead;
273};
274
280/* Use fstat() instead */
281RTEMS_DEPRECATED static inline dev_t rtems_disk_get_device_identifier(
282 const rtems_disk_device *dd
283)
284{
285 return dd->dev;
286}
287
288/* Use fstat() instead */
289RTEMS_DEPRECATED static inline rtems_device_major_number rtems_disk_get_major_number(
290 const rtems_disk_device *dd
291)
292{
293 return rtems_filesystem_dev_major_t(dd->dev);
294}
295
296/* Use fstat() instead */
297RTEMS_DEPRECATED static inline rtems_device_minor_number rtems_disk_get_minor_number(
298 const rtems_disk_device *dd
299)
300{
301 return rtems_filesystem_dev_minor_t(dd->dev);
302}
303
304static inline void *rtems_disk_get_driver_data(
305 const rtems_disk_device *dd
306)
307{
308 return dd->driver_data;
309}
310
311static inline uint32_t rtems_disk_get_media_block_size(
312 const rtems_disk_device *dd
313)
314{
315 return dd->media_block_size;
316}
317
318static inline uint32_t rtems_disk_get_block_size(
319 const rtems_disk_device *dd
320)
321{
322 return dd->block_size;
323}
324
325static inline rtems_blkdev_bnum rtems_disk_get_block_begin(
326 const rtems_disk_device *dd
327)
328{
329 return dd->start;
330}
331
332static inline rtems_blkdev_bnum rtems_disk_get_block_count(
333 const rtems_disk_device *dd
334)
335{
336 return dd->size;
337}
338
346/* Use rtems_blkdev_create() instead */
347RTEMS_DEPRECATED rtems_status_code rtems_disk_create_phys(
348 dev_t dev,
349 uint32_t block_size,
350 rtems_blkdev_bnum block_count,
351 rtems_block_device_ioctl handler,
352 void *driver_data,
353 const char *name
354);
355
356/* Use rtems_blkdev_create_partition() instead */
357RTEMS_DEPRECATED rtems_status_code rtems_disk_create_log(
358 dev_t dev,
359 dev_t phys,
360 rtems_blkdev_bnum block_begin,
361 rtems_blkdev_bnum block_count,
362 const char *name
363);
364
365/*
366 * Use rtems_blkdev_create() or rtems_blkdev_create_partition and unlink()
367 * instead.
368 */
369RTEMS_DEPRECATED rtems_status_code rtems_disk_delete(dev_t dev);
370
371/*
372 * Use rtems_blkdev_create() or rtems_blkdev_create_partition and open()
373 * instead.
374 */
375RTEMS_DEPRECATED rtems_disk_device *rtems_disk_obtain(dev_t dev);
376
377/*
378 * Use rtems_blkdev_create() or rtems_blkdev_create_partition and close()
379 * instead.
380 */
381RTEMS_DEPRECATED rtems_status_code rtems_disk_release(rtems_disk_device *dd);
382
390/* Just remove calls to this function */
391RTEMS_DEPRECATED rtems_status_code rtems_disk_io_initialize(void);
392
393/* Just remove calls to this function */
394RTEMS_DEPRECATED rtems_status_code rtems_disk_io_done(void);
395
400/*
401 * This functionality no longer available. There is no global registration for
402 * disk devices.
403 */
404RTEMS_DEPRECATED rtems_disk_device *rtems_disk_next(dev_t dev);
405
406/* Internal function, do not use */
407 rtems_status_code rtems_disk_init_phys(
408 rtems_disk_device *dd,
409 uint32_t block_size,
410 rtems_blkdev_bnum block_count,
411 rtems_block_device_ioctl handler,
412 void *driver_data
413);
414
415/* Internal function, do not use */
416 rtems_status_code rtems_disk_init_log(
417 rtems_disk_device *dd,
418 rtems_disk_device *phys_dd,
419 rtems_blkdev_bnum block_begin,
420 rtems_blkdev_bnum block_count
421);
422
423#ifdef __cplusplus
424}
425#endif
426
427#endif
chain.h
Chain API.
rtems_status_code
rtems_status_code
Classic API Status.
Definition: status.h:43
rtems_blkdev_bnum
uint32_t rtems_blkdev_bnum
Block device block index type.
Definition: diskdevs.h:45
rtems_block_device_ioctl
int(* rtems_block_device_ioctl)(rtems_disk_device *dd, uint32_t req, void *argp)
Block device IO control handler type.
Definition: diskdevs.h:50
libio.h
Basic IO API.
rtems.h
Chain_Node_struct
Definition: chain.h:68
rtems_blkdev_read_ahead
Block device read-ahead control.
Definition: diskdevs.h:64
rtems_blkdev_read_ahead::node
rtems_chain_node node
Chain node for the read-ahead request queue of the read-ahead task.
Definition: diskdevs.h:68
rtems_blkdev_read_ahead::next
rtems_blkdev_bnum next
Start block for the next read-ahead request.
Definition: diskdevs.h:84
rtems_blkdev_read_ahead::trigger
rtems_blkdev_bnum trigger
Block value to trigger the read-ahead request.
Definition: diskdevs.h:76
rtems_blkdev_stats
Block device statistics.
Definition: diskdevs.h:92
rtems_blkdev_stats::read_ahead_transfers
uint32_t read_ahead_transfers
Read-ahead transfer count.
Definition: diskdevs.h:115
rtems_blkdev_stats::read_blocks
uint32_t read_blocks
Count of blocks transfered from the device.
Definition: diskdevs.h:120
rtems_blkdev_stats::read_errors
uint32_t read_errors
Read error count.
Definition: diskdevs.h:127
rtems_blkdev_stats::write_errors
uint32_t write_errors
Write error count.
Definition: diskdevs.h:146
rtems_blkdev_stats::write_blocks
uint32_t write_blocks
Count of blocks transfered to the device.
Definition: diskdevs.h:139
rtems_blkdev_stats::read_misses
uint32_t read_misses
Read miss count.
Definition: diskdevs.h:108
rtems_blkdev_stats::write_transfers
uint32_t write_transfers
Write transfer count.
Definition: diskdevs.h:134
rtems_blkdev_stats::read_hits
uint32_t read_hits
Read hit count.
Definition: diskdevs.h:99
rtems_disk_device
Description of a disk device (logical and physical disks).
Definition: diskdevs.h:157
rtems_disk_device::media_block_size
uint32_t media_block_size
Media block size in bytes.
Definition: diskdevs.h:204
rtems_disk_device::ioctl
rtems_block_device_ioctl ioctl
IO control handler for this disk.
Definition: diskdevs.h:251
rtems_disk_device::driver_data
void * driver_data
Private data for the disk driver.
Definition: diskdevs.h:256
rtems_disk_device::dev
dev_t dev
Device identifier (concatenation of major and minor number).
Definition: diskdevs.h:161
rtems_disk_device::bds_per_group
size_t bds_per_group
Buffer descriptors per group count.
Definition: diskdevs.h:246
rtems_disk_device::stats
rtems_blkdev_stats stats
Device statistics for this disk.
Definition: diskdevs.h:267
rtems_disk_device::capabilities
uint32_t capabilities
Driver capabilities.
Definition: diskdevs.h:172
rtems_disk_device::uses
unsigned uses
Usage counter.
Definition: diskdevs.h:184
rtems_disk_device::start
rtems_blkdev_bnum start
Start media block number.
Definition: diskdevs.h:192
rtems_disk_device::read_ahead
rtems_blkdev_read_ahead read_ahead
Read-ahead control for this disk.
Definition: diskdevs.h:272
rtems_disk_device::phys_dev
rtems_disk_device * phys_dev
Physical device identifier (equals the dev entry if it specifies a physical device).
Definition: diskdevs.h:167
rtems_disk_device::size
rtems_blkdev_bnum size
Size of the physical or logical disk in media blocks.
Definition: diskdevs.h:197
rtems_disk_device::deleted
bool deleted
Indicates that this disk should be deleted as soon as the last user releases this disk.
Definition: diskdevs.h:262
rtems_disk_device::block_size
uint32_t block_size
Block size in bytes.
Definition: diskdevs.h:214
rtems_disk_device::media_blocks_per_block
uint32_t media_blocks_per_block
Media blocks per device blocks.
Definition: diskdevs.h:228
rtems_disk_device::name
char * name
Disk device name.
Definition: diskdevs.h:177
rtems_disk_device::block_to_media_block_shift
int block_to_media_block_shift
Block to media block shift.
Definition: diskdevs.h:239
rtems_disk_device::block_count
rtems_blkdev_bnum block_count
Block count.
Definition: diskdevs.h:221