RTEMS  5.1
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
22 extern "C" {
23 #endif
24 
26 
45 typedef uint32_t rtems_blkdev_bnum;
46 
50 typedef int (*rtems_block_device_ioctl)(
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 {
69 
77 
86 
92 typedef struct {
99  uint32_t read_hits;
100 
108  uint32_t read_misses;
109 
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;
148 
161  dev_t dev;
162 
168 
172  uint32_t capabilities;
173 
177  char *name;
178 
184  unsigned uses;
185 
193 
198 
205 
214  uint32_t block_size;
215 
222 
229 
240 
247 
252 
256  void *driver_data;
257 
262  bool deleted;
263 
268 
273 };
274 
280 /* Use fstat() instead */
281 RTEMS_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 */
289 RTEMS_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 */
297 RTEMS_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 
304 static inline void *rtems_disk_get_driver_data(
305  const rtems_disk_device *dd
306 )
307 {
308  return dd->driver_data;
309 }
310 
311 static 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 
318 static inline uint32_t rtems_disk_get_block_size(
319  const rtems_disk_device *dd
320 )
321 {
322  return dd->block_size;
323 }
324 
325 static inline rtems_blkdev_bnum rtems_disk_get_block_begin(
326  const rtems_disk_device *dd
327 )
328 {
329  return dd->start;
330 }
331 
332 static 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 */
347 RTEMS_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 */
357 RTEMS_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  */
369 RTEMS_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  */
375 RTEMS_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  */
381 RTEMS_DEPRECATED rtems_status_code rtems_disk_release(rtems_disk_device *dd);
382 
390 /* Just remove calls to this function */
391 RTEMS_DEPRECATED rtems_status_code rtems_disk_io_initialize(void);
392 
393 /* Just remove calls to this function */
394 RTEMS_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  */
404 RTEMS_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
uint32_t block_size
Block size in bytes.
Definition: diskdevs.h:214
Definition: chain.h:68
Block device read-ahead control.
Definition: diskdevs.h:64
uint32_t rtems_blkdev_bnum
Block device block index type.
Definition: diskdevs.h:45
size_t bds_per_group
Buffer descriptors per group count.
Definition: diskdevs.h:246
Basic IO API.
rtems_blkdev_stats stats
Device statistics for this disk.
Definition: diskdevs.h:267
rtems_chain_node node
Chain node for the read-ahead request queue of the read-ahead task.
Definition: diskdevs.h:68
int(* rtems_block_device_ioctl)(rtems_disk_device *dd, uint32_t req, void *argp)
Block device IO control handler type.
Definition: diskdevs.h:50
uint32_t capabilities
Driver capabilities.
Definition: diskdevs.h:172
uint32_t media_block_size
Media block size in bytes.
Definition: diskdevs.h:204
char * name
Disk device name.
Definition: diskdevs.h:177
dev_t dev
Device identifier (concatenation of major and minor number).
Definition: diskdevs.h:161
rtems_blkdev_bnum size
Size of the physical or logical disk in media blocks.
Definition: diskdevs.h:197
rtems_blkdev_read_ahead read_ahead
Read-ahead control for this disk.
Definition: diskdevs.h:272
uint32_t read_blocks
Count of blocks transfered from the device.
Definition: diskdevs.h:120
Block device statistics.
Definition: diskdevs.h:92
Description of a disk device (logical and physical disks).
Definition: diskdevs.h:157
uint32_t read_errors
Read error count.
Definition: diskdevs.h:127
uint32_t read_ahead_transfers
Read-ahead transfer count.
Definition: diskdevs.h:115
rtems_blkdev_bnum block_count
Block count.
Definition: diskdevs.h:221
rtems_status_code
Classic API Status.
Definition: status.h:43
uint32_t media_blocks_per_block
Media blocks per device blocks.
Definition: diskdevs.h:228
uint32_t write_errors
Write error count.
Definition: diskdevs.h:146
uint32_t write_blocks
Count of blocks transfered to the device.
Definition: diskdevs.h:139
void * driver_data
Private data for the disk driver.
Definition: diskdevs.h:256
int block_to_media_block_shift
Block to media block shift.
Definition: diskdevs.h:239
Chain API.
rtems_blkdev_bnum trigger
Block value to trigger the read-ahead request.
Definition: diskdevs.h:76
rtems_blkdev_bnum start
Start media block number.
Definition: diskdevs.h:192
rtems_disk_device * phys_dev
Physical device identifier (equals the dev entry if it specifies a physical device).
Definition: diskdevs.h:167
unsigned uses
Usage counter.
Definition: diskdevs.h:184
uint32_t read_misses
Read miss count.
Definition: diskdevs.h:108
rtems_blkdev_bnum next
Start block for the next read-ahead request.
Definition: diskdevs.h:84
rtems_block_device_ioctl ioctl
IO control handler for this disk.
Definition: diskdevs.h:251
uint32_t read_hits
Read hit count.
Definition: diskdevs.h:99
bool deleted
Indicates that this disk should be deleted as soon as the last user releases this disk.
Definition: diskdevs.h:262
uint32_t write_transfers
Write transfer count.
Definition: diskdevs.h:134