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

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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
27#ifdef __cplusplus
28extern "C" {
29#endif /* __cplusplus */
30
131#define RTEMS_FLASHDISK_DEVICE_BASE_NAME "/dev/fdd"
132
133#define RTEMS_FDISK_IOCTL_ERASE_DISK _IO('B', 128)
134#define RTEMS_FDISK_IOCTL_COMPACT _IO('B', 129)
135#define RTEMS_FDISK_IOCTL_ERASE_USED _IO('B', 130)
136#define RTEMS_FDISK_IOCTL_MONITORING _IO('B', 131)
137#define RTEMS_FDISK_IOCTL_INFO_LEVEL _IO('B', 132)
138#define RTEMS_FDISK_IOCTL_PRINT_STATUS _IO('B', 133)
139
144 typedef struct rtems_fdisk_monitor_data
145{
146 uint32_t block_size;
147 uint32_t block_count;
148 uint32_t unavail_blocks;
149 uint32_t device_count;
150 uint32_t segment_count;
151 uint32_t page_count;
152 uint32_t blocks_used;
153 uint32_t segs_available;
154 uint32_t segs_used;
155 uint32_t segs_failed;
156 uint32_t seg_erases;
157 uint32_t pages_desc;
158 uint32_t pages_active;
159 uint32_t pages_used;
160 uint32_t pages_bad;
161 uint32_t info_level;
162} rtems_fdisk_monitor_data;
163
174 typedef struct rtems_fdisk_segment_desc
175{
176 uint16_t count;
177 uint16_t segment;
178 uint32_t offset;
179 uint32_t size;
180} rtems_fdisk_segment_desc;
181
185#define RTEMS_FDISK_KBYTES(_k) (UINT32_C(1024) * (_k))
186
190struct rtems_fdisk_device_desc;
191
200 typedef struct rtems_fdisk_driver_handlers
201{
220 int (*read) (const rtems_fdisk_segment_desc* sd,
221 uint32_t device,
222 uint32_t segment,
223 uint32_t offset,
224 void* buffer,
225 uint32_t size);
226
245 int (*write) (const rtems_fdisk_segment_desc* sd,
246 uint32_t device,
247 uint32_t segment,
248 uint32_t offset,
249 const void* buffer,
250 uint32_t size);
251
269 int (*blank) (const rtems_fdisk_segment_desc* sd,
270 uint32_t device,
271 uint32_t segment,
272 uint32_t offset,
273 uint32_t size);
274
293 int (*verify) (const rtems_fdisk_segment_desc* sd,
294 uint32_t device,
295 uint32_t segment,
296 uint32_t offset,
297 const void* buffer,
298 uint32_t size);
299
313 int (*erase) (const rtems_fdisk_segment_desc* sd,
314 uint32_t device,
315 uint32_t segment);
316
329 int (*erase_device) (const struct rtems_fdisk_device_desc* dd,
330 uint32_t device);
331
332} rtems_fdisk_driver_handlers;
333
345 typedef struct rtems_fdisk_device_desc
346{
347 uint32_t segment_count;
348 const rtems_fdisk_segment_desc* segments;
349 const rtems_fdisk_driver_handlers* flash_ops;
350} rtems_fdisk_device_desc;
351
381 typedef struct rtems_flashdisk_config
382{
383 uint32_t block_size;
384 uint32_t device_count;
385 const rtems_fdisk_device_desc* devices;
386 uint32_t flags;
393 uint32_t unavail_blocks;
394
395 uint32_t compact_segs;
403 uint32_t avail_compact_segs;
404 uint32_t info_level;
405} rtems_flashdisk_config;
406
407/*
408 * Driver flags.
409 */
410
414#define RTEMS_FDISK_BACKGROUND_ERASE (1 << 0)
415
419#define RTEMS_FDISK_BACKGROUND_COMPACT (1 << 1)
420
426#define RTEMS_FDISK_CHECK_PAGES (1 << 2)
427
432#define RTEMS_FDISK_BLANK_CHECK_BEFORE_WRITE (1 << 3)
433
445 rtems_device_driver
446rtems_fdisk_initialize (rtems_device_major_number major,
447 rtems_device_minor_number minor,
448 void* arg);
449
454extern const rtems_flashdisk_config rtems_flashdisk_configuration[];
455
460extern uint32_t rtems_flashdisk_configuration_size;
461
464#ifdef __cplusplus
465}
466#endif /* __cplusplus */
467
468#endif
rtems_status_code
rtems_status_code
Classic API Status.
Definition: status.h:43
rtems_fdisk_initialize
rtems_device_driver rtems_fdisk_initialize(rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
rtems_flashdisk_configuration
const rtems_flashdisk_config rtems_flashdisk_configuration[]
External reference to the configuration. Please supply. Support is present in confdefs....
rtems_flashdisk_configuration_size
uint32_t rtems_flashdisk_configuration_size
External reference to the number of configurations. Please supply. Support is present in confdefs....
rtems.h
device
Definition: rtemscompat1.h:15
rtems_fdisk_device_desc
Flash Device Descriptor holds the segments in a device.
Definition: flashdisk.h:346
rtems_fdisk_device_desc::flash_ops
const rtems_fdisk_driver_handlers * flash_ops
Definition: flashdisk.h:349
rtems_fdisk_device_desc::segments
const rtems_fdisk_segment_desc * segments
Definition: flashdisk.h:348
rtems_fdisk_device_desc::segment_count
uint32_t segment_count
Definition: flashdisk.h:347
rtems_fdisk_driver_handlers
Flash Low Level driver handlers.
Definition: flashdisk.h:201
rtems_fdisk_driver_handlers::write
int(* write)(const rtems_fdisk_segment_desc *sd, uint32_t device, uint32_t segment, uint32_t offset, const void *buffer, uint32_t size)
Definition: flashdisk.h:245
rtems_fdisk_driver_handlers::erase_device
int(* erase_device)(const struct rtems_fdisk_device_desc *dd, uint32_t device)
Definition: flashdisk.h:329
rtems_fdisk_driver_handlers::verify
int(* verify)(const rtems_fdisk_segment_desc *sd, uint32_t device, uint32_t segment, uint32_t offset, const void *buffer, uint32_t size)
Definition: flashdisk.h:293
rtems_fdisk_driver_handlers::erase
int(* erase)(const rtems_fdisk_segment_desc *sd, uint32_t device, uint32_t segment)
Definition: flashdisk.h:313
rtems_fdisk_driver_handlers::read
int(* read)(const rtems_fdisk_segment_desc *sd, uint32_t device, uint32_t segment, uint32_t offset, void *buffer, uint32_t size)
Definition: flashdisk.h:220
rtems_fdisk_driver_handlers::blank
int(* blank)(const rtems_fdisk_segment_desc *sd, uint32_t device, uint32_t segment, uint32_t offset, uint32_t size)
Definition: flashdisk.h:269
rtems_fdisk_monitor_data
Flash Disk Monitoring Data allows a user to obtain the current status of the disk.
Definition: flashdisk.h:145
rtems_fdisk_segment_desc
Flash Segment Descriptor holds, number of continuous segments in the device of this type,...
Definition: flashdisk.h:175
rtems_fdisk_segment_desc::size
uint32_t size
Definition: flashdisk.h:179
rtems_fdisk_segment_desc::segment
uint16_t segment
Definition: flashdisk.h:177
rtems_fdisk_segment_desc::offset
uint32_t offset
Definition: flashdisk.h:178
rtems_fdisk_segment_desc::count
uint16_t count
Definition: flashdisk.h:176
rtems_flashdisk_config
RTEMS Flash Disk configuration table used to initialise the driver.
Definition: flashdisk.h:382
rtems_flashdisk_config::flags
uint32_t flags
Definition: flashdisk.h:386
rtems_flashdisk_config::avail_compact_segs
uint32_t avail_compact_segs
Definition: flashdisk.h:403
rtems_flashdisk_config::info_level
uint32_t info_level
Definition: flashdisk.h:404
rtems_flashdisk_config::block_size
uint32_t block_size
Definition: flashdisk.h:383
rtems_flashdisk_config::devices
const rtems_fdisk_device_desc * devices
Definition: flashdisk.h:385
rtems_flashdisk_config::compact_segs
uint32_t compact_segs
Definition: flashdisk.h:395
rtems_flashdisk_config::device_count
uint32_t device_count
Definition: flashdisk.h:384
rtems_flashdisk_config::unavail_blocks
uint32_t unavail_blocks
Definition: flashdisk.h:393