source: rtems/cpukit/libblock/include/rtems/nvdisk.h @ 21242c2

4.115
Last change on this file since 21242c2 was 21242c2, checked in by Joel Sherrill <joel.sherrill@…>, on 06/24/11 at 17:52:58

2011-06-24 Joel Sherrill <joel.sherrill@…>

  • include/rtems/bspIo.h, include/rtems/concat.h, include/rtems/endian.h, include/rtems/fs.h, include/rtems/irq.h, include/rtems/pci.h, include/rtems/userenv.h, libblock/include/rtems/flashdisk.h, libblock/include/rtems/nvdisk-sram.h, libblock/include/rtems/nvdisk.h, libcsupport/include/clockdrv.h, libcsupport/include/console.h, libcsupport/include/iosupp.h, libcsupport/include/spurious.h, libcsupport/include/motorola/mc68230.h, libcsupport/include/rtems/assoc.h, libcsupport/include/rtems/error.h, libcsupport/include/rtems/framebuffer.h, libcsupport/include/rtems/gxx_wrappers.h, libcsupport/include/rtems/libcsupport.h, libcsupport/include/rtems/libio_.h, libcsupport/include/rtems/malloc.h, libcsupport/include/rtems/termiostypes.h, libcsupport/include/sys/statvfs.h, libcsupport/include/sys/termios.h, libcsupport/include/sys/utsname.h, libcsupport/include/zilog/z8036.h, libcsupport/include/zilog/z8530.h, libcsupport/include/zilog/z8536.h, libfs/src/imfs/imfs.h, libfs/src/pipe/pipe.h, libmisc/capture/capture-cli.h, libmisc/capture/capture.h, libmisc/cpuuse/cpuuse.h, libmisc/devnull/devnull.h, libmisc/devnull/devzero.h, libmisc/dumpbuf/dumpbuf.h, libmisc/fb/fb.h, libmisc/fb/mw_uid.h, libmisc/mouse/mouse_parser.h, libmisc/shell/shellconfig.h, libmisc/stringto/stringto.h, libmisc/untar/untar.h, libnetworking/memory.h, posix/include/aio.h, posix/include/mqueue.h, posix/include/semaphore.h, posix/include/rtems/posix/aio_misc.h, posix/include/rtems/posix/barrier.h, posix/include/rtems/posix/cond.h, posix/include/rtems/posix/config.h, posix/include/rtems/posix/key.h, posix/include/rtems/posix/mqueue.h, posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/posixapi.h, posix/include/rtems/posix/priority.h, posix/include/rtems/posix/psignal.h, posix/include/rtems/posix/pthread.h, posix/include/rtems/posix/ptimer.h, posix/include/rtems/posix/rwlock.h, posix/include/rtems/posix/semaphore.h, posix/include/rtems/posix/sigset.h, posix/include/rtems/posix/spinlock.h, posix/include/rtems/posix/threadsup.h, posix/include/rtems/posix/time.h, posix/include/rtems/posix/timer.h, posix/inline/rtems/posix/barrier.inl, posix/inline/rtems/posix/cond.inl, posix/inline/rtems/posix/mqueue.inl, posix/inline/rtems/posix/mutex.inl, posix/inline/rtems/posix/priority.inl, posix/inline/rtems/posix/pthread.inl, posix/inline/rtems/posix/rwlock.inl, posix/inline/rtems/posix/semaphore.inl, posix/inline/rtems/posix/spinlock.inl, posix/inline/rtems/posix/timer.inl, rtems/mainpage.h, rtems/include/rtems/rtems/barrier.h, rtems/include/rtems/rtems/object.h, rtems/include/rtems/rtems/timer.h, rtems/inline/rtems/rtems/barrier.inl, rtems/inline/rtems/rtems/timer.inl, rtems/src/semtranslatereturncode.c, sapi/include/rtems/config.h, sapi/include/rtems/fatal.h, sapi/include/rtems/mptables.h, score/include/rtems/score/object.h, score/include/rtems/score/priority.h, score/inline/rtems/score/object.inl, score/inline/rtems/score/priority.inl: Add @file Doxygen directives and descriptions to files which originated with RTEMS. This improves the file list page generated by Doxygen.
  • Property mode set to 100644
File size: 6.6 KB
Line 
1/**
2 * @file rtems/nvdisk.h
3 *
4 * Non-volatile disk block device implementation
5 */
6
7/*
8 * Copyright (C) 2007 Chris Johns
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.com/license/LICENSE.
13 *
14 * $Id$
15 */
16
17/**
18 * The Non-volatile disk provides a simple directly mapped disk
19 * driver with checksums for each. It is designed to provied a
20 * disk that can survive a restart. Examples are EEPROM devices
21 * which have byte writeable locations, or a battery backed up
22 * RAM disk.
23 *
24 * The low level driver provides the physical access to the
25 * hardware.
26 */
27#if !defined (_RTEMS_NVDISK_H_)
28#define _RTEMS_NVDISK_H_
29
30#include <stdint.h>
31#include <sys/ioctl.h>
32
33#include <rtems.h>
34
35/**
36 * The base name of the nv disks.
37 */
38#define RTEMS_NVDISK_DEVICE_BASE_NAME "/dev/nvd"
39
40/**
41 * NV disk specific ioctl request types. To use open the
42 * device and issue the ioctl call.
43 *
44 * @code
45 *  int fd = open ("/dev/nvdisk0", O_WRONLY, 0);
46 *  if (fd < 0)
47 *  {
48 *    printf ("driver open failed: %s\n", strerror (errno));
49 *    exit (1);
50 *  }
51 *  if (ioctl (fd, RTEMS_NVDISK_IOCTL_ERASE_DISK) < 0)
52 *  {
53 *    printf ("driver erase failed: %s\n", strerror (errno));
54 *    exit (1);
55 *  }
56 *  close (fd);
57 * @endcode
58 */
59#define RTEMS_NVDISK_IOCTL_ERASE_DISK   _IO('B', 128)
60#define RTEMS_NVDISK_IOCTL_MONITORING   _IO('B', 129)
61#define RTEMS_NVDISK_IOCTL_INFO_LEVEL   _IO('B', 130)
62#define RTEMS_NVDISK_IOCTL_PRINT_STATUS _IO('B', 131)
63
64/**
65 * NV Disk Monitoring Data allows a user to obtain
66 * the current status of the disk.
67 */
68typedef struct rtems_nvdisk_monitor_data
69{
70  uint32_t block_size;
71  uint32_t block_count;
72  uint32_t page_count;
73  uint32_t pages_available;
74  uint32_t pages_used;
75  uint32_t info_level;
76} rtems_nvdisk_monitor_data;
77
78/**
79 * Return the number of kilo-bytes.
80 */
81#define RTEMS_NVDISK_KBYTES(_k) ((_k) * 1024)
82
83/**
84 * NV Low Level driver handlers.
85
86 * Typically this structure is part of a table of handlers in the
87 * device which is referenced in the nvdisk configuration table.
88 * The reference is kept in the driver and used all the time to
89 * manage the nv device, therefore it must always exist.
90 */
91typedef struct rtems_nvdisk_driver_handlers
92{
93  /**
94   * Read data from the device into the buffer. Return an errno
95   * error number if the data cannot be read.
96   *
97   * @param device The device to read data from.
98   * @param flags Device specific flags for the driver.
99   * @param base The base address of the device.
100   * @param offset The offset in the segment to read.
101   * @param buffer The buffer to read the data into.
102   * @param size The amount of data to read.
103   * @retval 0 No error.
104   * @retval EIO The read did not complete.
105   */
106  int (*read) (uint32_t device, uint32_t flags, void* base,
107               uint32_t offset, void* buffer, size_t size);
108
109  /**
110   * Write data from the buffer to the device. Return an errno
111   * error number if the device cannot be written to.
112   *
113   * @param device The device to write data to.
114   * @param flags Device specific flags for the driver.
115   * @param base The base address of the device.
116   * @param offset The offset in the device to write to.
117   * @param buffer The buffer to write the data from.
118   * @param size The amount of data to write.
119   * @retval 0 No error.
120   * @retval EIO The write did not complete or verify.
121   */
122  int (*write) (uint32_t device, uint32_t flags, void* base,
123                uint32_t offset, const void* buffer, size_t size);
124
125  /**
126   * Verify data in the buffer to the data in the device. Return an
127   * errno error number if the device cannot be read or the data verified.
128   *
129   * @param device The device to verify the data with.
130   * @param flags Device specific flags for the driver.
131   * @param base The base address of the device.
132   * @param offset The offset in the device to verify.
133   * @param buffer The buffer to verify the data in the device with.
134   * @param size The amount of data to verify.
135   * @retval 0 No error.
136   * @retval EIO The data did not verify.
137   */
138  int (*verify) (uint32_t device, uint32_t flags, void* base,
139                 uint32_t offset, const void* buffer, size_t size);
140
141} rtems_nvdisk_driver_handlers;
142
143/**
144 * NV Device Descriptor holds the description of a device that is
145 * part of the NV disk.
146 *
147 * Typically this structure is part of a table of the device which
148 * is referenced in the nvdisk configuration table.
149 * The reference is kept in the driver and used all the time to
150 * manage the nv device, therefore it must always exist.
151 */
152typedef struct rtems_nvdisk_device_desc
153{
154  uint32_t                            flags;  /**< Private user flags. */
155  void*                               base;   /**< Base address of the device. */
156  uint32_t                            size;   /**< Size of the device. */
157  const rtems_nvdisk_driver_handlers* nv_ops; /**< Device handlers. */
158} rtems_nvdisk_device_desc;
159
160/**
161 * RTEMS Non-Volatile Disk configuration table used to initialise the
162 * driver.
163 */
164typedef struct rtems_nvdisk_config
165{
166  uint32_t                        block_size;   /**< The block size. */
167  uint32_t                        device_count; /**< The number of devices. */
168  const rtems_nvdisk_device_desc* devices;      /**< The device descriptions. */
169  uint32_t                        flags;        /**< Set of flags to control
170                                                     driver. */
171  uint32_t                        info_level;   /**< Default info level. */
172} rtems_nvdisk_config;
173
174/*
175 * Driver flags.
176 */
177
178/**
179 * Check the pages during initialisation to see which pages are
180 * valid and which are not. This could slow down initialising the
181 * disk driver.
182 */
183#define RTEMS_NVDISK_CHECK_PAGES (1 << 0)
184
185/**
186 * Non-volatile disk device driver initialization. Place in a table as the
187 * initialisation entry and remainder of the entries are the RTEMS block
188 * device generic handlers.
189 *
190 * @param major NV disk major device number.
191 * @param minor Minor device number, not applicable.
192 * @param arg Initialization argument, not applicable.
193 * @return The rtems_device_driver is actually just
194 *         rtems_status_code.
195 */
196rtems_device_driver
197rtems_nvdisk_initialize (rtems_device_major_number major,
198                         rtems_device_minor_number minor,
199                         void*                     arg);
200
201/**
202 * External reference to the configuration. Please supply.
203 * Support is present in confdefs.h for providing this variable.
204 */
205extern const rtems_nvdisk_config rtems_nvdisk_configuration[];
206
207/**
208 * External reference to the number of configurations. Please supply.
209 * Support is present in confdefs.h for providing this variable.
210 */
211extern uint32_t rtems_nvdisk_configuration_size;
212
213#endif
Note: See TracBrowser for help on using the repository browser.