RTEMS CPU Kit with SuperCore  4.11.3
flashdisk.h
Go to the documentation of this file.
1 
11 /*
12  * Copyright (C) 2007 Chris Johns
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #if !defined (_RTEMS_FLASHDISK_H_)
20 #define _RTEMS_FLASHDISK_H_
21 
22 #include <stdint.h>
23 #include <sys/ioctl.h>
24 
25 #include <rtems.h>
26 
127 #define RTEMS_FLASHDISK_DEVICE_BASE_NAME "/dev/fdd"
128 
129 #define RTEMS_FDISK_IOCTL_ERASE_DISK _IO('B', 128)
130 #define RTEMS_FDISK_IOCTL_COMPACT _IO('B', 129)
131 #define RTEMS_FDISK_IOCTL_ERASE_USED _IO('B', 130)
132 #define RTEMS_FDISK_IOCTL_MONITORING _IO('B', 131)
133 #define RTEMS_FDISK_IOCTL_INFO_LEVEL _IO('B', 132)
134 #define RTEMS_FDISK_IOCTL_PRINT_STATUS _IO('B', 133)
135 
141 {
142  uint32_t block_size;
143  uint32_t block_count;
144  uint32_t unavail_blocks;
145  uint32_t device_count;
146  uint32_t segment_count;
147  uint32_t page_count;
148  uint32_t blocks_used;
149  uint32_t segs_available;
150  uint32_t segs_used;
151  uint32_t segs_failed;
152  uint32_t seg_erases;
153  uint32_t pages_desc;
154  uint32_t pages_active;
155  uint32_t pages_used;
156  uint32_t pages_bad;
157  uint32_t info_level;
159 
171 {
172  uint16_t count;
173  uint16_t segment;
174  uint32_t offset;
175  uint32_t size;
177 
181 #define RTEMS_FDISK_KBYTES(_k) (UINT32_C(1024) * (_k))
182 
187 
197 {
216  int (*read) (const rtems_fdisk_segment_desc* sd,
217  uint32_t device,
218  uint32_t segment,
219  uint32_t offset,
220  void* buffer,
221  uint32_t size);
222 
241  int (*write) (const rtems_fdisk_segment_desc* sd,
242  uint32_t device,
243  uint32_t segment,
244  uint32_t offset,
245  const void* buffer,
246  uint32_t size);
247 
265  int (*blank) (const rtems_fdisk_segment_desc* sd,
266  uint32_t device,
267  uint32_t segment,
268  uint32_t offset,
269  uint32_t size);
270 
289  int (*verify) (const rtems_fdisk_segment_desc* sd,
290  uint32_t device,
291  uint32_t segment,
292  uint32_t offset,
293  const void* buffer,
294  uint32_t size);
295 
309  int (*erase) (const rtems_fdisk_segment_desc* sd,
310  uint32_t device,
311  uint32_t segment);
312 
325  int (*erase_device) (const struct rtems_fdisk_device_desc* dd,
326  uint32_t device);
327 
329 
342 {
343  uint32_t segment_count;
347 
378 {
379  uint32_t block_size;
380  uint32_t device_count;
382  uint32_t flags;
389  uint32_t unavail_blocks;
390 
391  uint32_t compact_segs;
400  uint32_t info_level;
402 
403 /*
404  * Driver flags.
405  */
406 
410 #define RTEMS_FDISK_BACKGROUND_ERASE (1 << 0)
411 
415 #define RTEMS_FDISK_BACKGROUND_COMPACT (1 << 1)
416 
422 #define RTEMS_FDISK_CHECK_PAGES (1 << 2)
423 
428 #define RTEMS_FDISK_BLANK_CHECK_BEFORE_WRITE (1 << 3)
429 
442 rtems_fdisk_initialize (rtems_device_major_number major,
443  rtems_device_minor_number minor,
444  void* arg);
445 
450 extern const rtems_flashdisk_config rtems_flashdisk_configuration[];
451 
456 extern uint32_t rtems_flashdisk_configuration_size;
457 
460 #endif
const rtems_fdisk_device_desc * devices
The device descriptions.
Definition: flashdisk.h:381
uint32_t segment_count
Number of segments.
Definition: flashdisk.h:343
uint32_t info_level
Default info level.
Definition: flashdisk.h:400
ssize_t read(int fd, void *buffer, size_t count)
POSIX 1003.1b 6.4.1 - Read From a File.
Definition: read.c:27
uint32_t device_count
The number of devices.
Definition: flashdisk.h:380
rtems_device_driver rtems_fdisk_initialize(rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
Flash disk device driver initialization.
Definition: flashdisk.c:2464
RTEMS Flash Disk configuration table used to initialise the driver.
Definition: flashdisk.h:377
ssize_t write(int fd, const void *buffer, size_t count)
POSIX 1003.1b 6.4.2 - Write to a File.
Definition: write.c:30
struct rtems_fdisk_monitor_data rtems_fdisk_monitor_data
Flash Disk Monitoring Data allows a user to obtain the current status of the disk.
rtems_status_code
Classic API Status.
Definition: status.h:46
uint16_t count
Number of segments of this type in a row.
Definition: flashdisk.h:172
struct rtems_fdisk_driver_handlers rtems_fdisk_driver_handlers
Flash Low Level driver handlers.
uint32_t compact_segs
Max number of segs to compact in one pass.
Definition: flashdisk.h:391
uint32_t flags
Set of flags to control driver.
Definition: flashdisk.h:382
uint32_t unavail_blocks
Number of blocks not available to the file system.
Definition: flashdisk.h:389
const rtems_fdisk_segment_desc * segments
Array of segments.
Definition: flashdisk.h:344
uint32_t offset
Address offset of base segment in device.
Definition: flashdisk.h:174
uint32_t rtems_flashdisk_configuration_size
External reference to the number of configurations.
Flash Segment Descriptor holds, number of continuous segments in the device of this type...
Definition: flashdisk.h:170
Flash Disk Monitoring Data allows a user to obtain the current status of the disk.
Definition: flashdisk.h:140
uint16_t segment
The base segment number.
Definition: flashdisk.h:173
uint32_t avail_compact_segs
The number of segments when compaction occurs when writing.
Definition: flashdisk.h:399
struct rtems_flashdisk_config rtems_flashdisk_config
RTEMS Flash Disk configuration table used to initialise the driver.
uint32_t block_size
The block size.
Definition: flashdisk.h:379
const rtems_fdisk_driver_handlers * flash_ops
Device handlers.
Definition: flashdisk.h:345
struct rtems_fdisk_device_desc rtems_fdisk_device_desc
Flash Device Descriptor holds the segments in a device.
Flash Device Descriptor holds the segments in a device.
Definition: flashdisk.h:341
uint32_t size
Size of the segment in bytes.
Definition: flashdisk.h:175
struct rtems_fdisk_segment_desc rtems_fdisk_segment_desc
Flash Segment Descriptor holds, number of continuous segments in the device of this type...
Flash Low Level driver handlers.
Definition: flashdisk.h:196