14#ifndef _RTEMS_BLKDEV_H
15#define _RTEMS_BLKDEV_H
20#include <sys/ioccom.h>
159static inline void rtems_blkdev_request_done(
164 (*req->done)(req, status);
173#define RTEMS_BLKDEV_START_BLOCK(req) (req->bufs[0].block)
180#define RTEMS_BLKIO_REQUEST _IOWR('B', 1, rtems_blkdev_request)
181#define RTEMS_BLKIO_GETMEDIABLKSIZE _IOR('B', 2, uint32_t)
182#define RTEMS_BLKIO_GETBLKSIZE _IOR('B', 3, uint32_t)
183#define RTEMS_BLKIO_SETBLKSIZE _IOW('B', 4, uint32_t)
184#define RTEMS_BLKIO_GETSIZE _IOR('B', 5, rtems_blkdev_bnum)
185#define RTEMS_BLKIO_SYNCDEV _IO('B', 6)
186#define RTEMS_BLKIO_DELETED _IO('B', 7)
187#define RTEMS_BLKIO_CAPABILITIES _IO('B', 8)
188#define RTEMS_BLKIO_GETDISKDEV _IOR('B', 9, rtems_disk_device *)
189#define RTEMS_BLKIO_PURGEDEV _IO('B', 10)
190#define RTEMS_BLKIO_GETDEVSTATS _IOR('B', 11, rtems_blkdev_stats *)
191#define RTEMS_BLKIO_RESETDEVSTATS _IO('B', 12)
195static inline int rtems_disk_fd_get_media_block_size(
197 uint32_t *media_block_size
200 return ioctl(fd, RTEMS_BLKIO_GETMEDIABLKSIZE, media_block_size);
203static inline int rtems_disk_fd_get_block_size(
int fd, uint32_t *block_size)
205 return ioctl(fd, RTEMS_BLKIO_GETBLKSIZE, block_size);
208static inline int rtems_disk_fd_set_block_size(
int fd, uint32_t block_size)
210 return ioctl(fd, RTEMS_BLKIO_SETBLKSIZE, &block_size);
213static inline int rtems_disk_fd_get_block_count(
218 return ioctl(fd, RTEMS_BLKIO_GETSIZE, block_count);
221static inline int rtems_disk_fd_get_disk_device(
226 return ioctl(fd, RTEMS_BLKIO_GETDISKDEV, dd_ptr);
229static inline int rtems_disk_fd_sync(
int fd)
231 return ioctl(fd, RTEMS_BLKIO_SYNCDEV);
234static inline int rtems_disk_fd_purge(
int fd)
236 return ioctl(fd, RTEMS_BLKIO_PURGEDEV);
239static inline int rtems_disk_fd_get_device_stats(
244 return ioctl(fd, RTEMS_BLKIO_GETDEVSTATS, stats);
247static inline int rtems_disk_fd_reset_device_stats(
int fd)
249 return ioctl(fd, RTEMS_BLKIO_RESETDEVSTATS);
264#define RTEMS_BLKDEV_CAP_MULTISECTOR_CONT (1 << 0)
271#define RTEMS_BLKDEV_CAP_SYNC (1 << 1)
306 uint32_t media_block_size,
339 const char *parent_block_device,
349 uint32_t media_block_size,
350 uint32_t media_block_count,
383#define RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
384 rtems_blkdev_generic_open, \
385 rtems_blkdev_generic_close, \
386 rtems_blkdev_generic_read, \
387 rtems_blkdev_generic_write, \
388 rtems_blkdev_generic_ioctl
392rtems_blkdev_generic_read(
400rtems_blkdev_generic_write(
408rtems_blkdev_generic_open(
416rtems_blkdev_generic_close(
424rtems_blkdev_generic_ioctl(
Block Device Disk Management API.
#define RTEMS_DEPRECATED
Instructs the compiler in a declaration to issue a warning whenever a variable, function,...
Definition: basedefs.h:334
#define RTEMS_ZERO_LENGTH_ARRAY
This constant represents the element count of a zero-length array.
Definition: basedefs.h:1032
uint32_t rtems_device_major_number
This integer type represents the major number of devices.
Definition: io.h:103
uint32_t rtems_device_minor_number
This integer type represents the minor number of devices.
Definition: io.h:115
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
struct rtems_blkdev_sg_buffer rtems_blkdev_sg_buffer
Block device scatter or gather buffer structure.
rtems_blkdev_request_op
Block device request type.
Definition: blkdev.h:49
void(* rtems_blkdev_request_cb)(struct rtems_blkdev_request *req, rtems_status_code status)
Block device request done callback function type.
Definition: blkdev.h:60
struct rtems_blkdev_request rtems_blkdev_request
The block device transfer request is used to read or write a number of blocks from or to the device.
rtems_status_code rtems_blkdev_create_partition(const char *partition, const char *parent_block_device, rtems_blkdev_bnum media_block_begin, rtems_blkdev_bnum media_block_count)
Creates a partition within a parent block device.
Definition: blkdev-imfs.c:343
void rtems_blkdev_print_stats(const rtems_blkdev_stats *stats, uint32_t media_block_size, uint32_t media_block_count, uint32_t block_size, const rtems_printer *printer)
Prints the block device statistics.
Definition: blkdev-print-stats.c:44
int rtems_blkdev_ioctl(rtems_disk_device *dd, uint32_t req, void *argp)
Common IO control primitive.
Definition: blkdev-ioctl.c:24
void rtems_blkstats(const rtems_printer *printer, const char *device, bool reset)
Block device statistics command.
Definition: blkdev-blkstats.c:48
rtems_status_code rtems_blkdev_create(const char *device, uint32_t media_block_size, rtems_blkdev_bnum media_block_count, rtems_block_device_ioctl handler, void *driver_data)
Creates a block device.
Definition: blkdev-imfs.c:293
@ RTEMS_BLKDEV_REQ_READ
Definition: blkdev.h:50
@ RTEMS_BLKDEV_REQ_SYNC
Definition: blkdev.h:52
@ RTEMS_BLKDEV_REQ_WRITE
Definition: blkdev.h:51
uint32_t rtems_blkdev_bnum
Block device block index type.
Definition: diskdevs.h:45
int(* rtems_block_device_ioctl)(rtems_disk_device *dd, uint32_t req, void *argp)
Block device IO control handler type.
Definition: diskdevs.h:50
User print interface to the bspIO print plug in.
This header file defines the RTEMS Classic API.
The block device transfer request is used to read or write a number of blocks from or to the device.
Definition: blkdev.h:102
rtems_id io_task
Definition: blkdev.h:131
void * done_arg
Definition: blkdev.h:116
rtems_status_code status
Definition: blkdev.h:121
rtems_blkdev_request_op req
Definition: blkdev.h:106
rtems_blkdev_sg_buffer bufs[RTEMS_ZERO_LENGTH_ARRAY]
Definition: blkdev.h:145
rtems_blkdev_request_cb done
Definition: blkdev.h:111
uint32_t bufnum
Definition: blkdev.h:126
Block device scatter or gather buffer structure.
Definition: blkdev.h:68
rtems_blkdev_bnum block
Definition: blkdev.h:72
void * buffer
Definition: blkdev.h:82
uint32_t length
Definition: blkdev.h:77
void * user
Definition: blkdev.h:87
Block device statistics.
Definition: diskdevs.h:106
Description of a disk device (logical and physical disks).
Definition: diskdevs.h:177
This structure contains the device driver entries.
Definition: io.h:140