Changeset 1560d12 in rtems for cpukit/libblock


Ignore:
Timestamp:
10/16/09 08:44:51 (14 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, 5, master
Children:
c20f690
Parents:
fdaa1354
Message:

restructuring of ramdisk code

Location:
cpukit/libblock
Files:
3 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libblock/Makefile.am

    rfdaa1354 r1560d12  
    88noinst_LIBRARIES = libblock.a
    99libblock_a_SOURCES = src/bdbuf.c src/blkdev.c src/diskdevs.c src/flashdisk.c \
    10     src/ramdisk.c src/ide_part_table.c src/nvdisk.c \
     10    src/ramdisk-driver.c \
     11    src/ramdisk-init.c \
     12    src/ramdisk-config.c \
     13    src/ide_part_table.c \
     14    src/nvdisk.c \
    1115    src/nvdisk-sram.c \
    1216    src/bdpart.c \
  • cpukit/libblock/include/rtems/ramdisk.h

    rfdaa1354 r1560d12  
    44 * @ingroup rtems_ramdisk
    55 *
    6  * RAM disk block device.
     6 * @brief RAM disk block device API.
    77 */
    88
     
    3434
    3535/**
    36  * RAM disk configuration table entry.
     36 * @name Static Configuration
     37 *
     38 * @{
     39 */
     40
     41/**
     42 * @brief RAM disk configuration table entry.
    3743 */
    3844typedef struct rtems_ramdisk_config {
    3945  /**
    40    * RAM disk block size (must be a power of two).
     46   * @brief RAM disk block size.
    4147   */
    4248  uint32_t block_size;
    4349
    4450  /**
    45    * Number of blocks on this RAM disk.
     51   * @brief Number of blocks on this RAM disk.
    4652   */
    4753  rtems_blkdev_bnum block_num;
    4854
    4955  /**
    50    * RAM disk location or @c NULL if RAM disk memory should be allocated
     56   * @brief RAM disk location or @c NULL if RAM disk memory should be allocated
    5157   * dynamically.
    5258   */
     
    5561
    5662/**
    57  * External reference to the RAM disk configuration table describing each RAM
    58  * disk in the system.
     63 * @brief External reference to the RAM disk configuration table describing
     64 * each RAM disk in the system.
    5965 *
    6066 * The configuration table is provided by the application.
     
    6369
    6470/**
    65  * External reference the size of the RAM disk configuration table
    66  * @ref rtems_ramdisk_configuration.
     71 * @brief External reference the size of the RAM disk configuration table @ref
     72 * rtems_ramdisk_configuration.
    6773 *
    6874 * The configuration table size is provided by the application.
     
    7076extern size_t rtems_ramdisk_configuration_size;
    7177
    72 /**
    73  * RAM disk driver initialization entry point.
     78int ramdisk_ioctl(rtems_disk_device *dd, uint32_t req, void *argp);
     79
     80/**
     81 * @brief RAM disk driver initialization entry point.
    7482 */
    7583rtems_device_driver ramdisk_initialize(
     
    8896  }
    8997
     98#define RAMDISK_DEVICE_BASE_NAME "/dev/rd"
     99
     100/** @} */
     101
     102/**
     103 * @name Runtime Configuration
     104 *
     105 * @{
     106 */
     107
     108/**
     109 * @brief RAM disk descriptor.
     110 */
     111typedef struct ramdisk {
     112  /**
     113   * @brief RAM disk block size, the media size.
     114   */
     115  uint32_t block_size;
     116
     117  /**
     118   * @brief Number of blocks on this RAM disk.
     119   */
     120  rtems_blkdev_bnum block_num;
     121
     122  /**
     123   * @brief RAM disk memory area.
     124   */
     125  void *area;
     126
     127  /**
     128   * @brief RAM disk is initialized.
     129   */
     130  bool initialized;
     131
     132  /**
     133   * @brief Indicates if memory is allocated by malloc() for this RAM disk.
     134   */
     135  bool malloced;
     136
     137  /**
     138   * @brief Trace enable.
     139   */
     140  bool trace;
     141} ramdisk;
     142
     143extern const rtems_driver_address_table ramdisk_ops;
     144
     145/**
     146 * @brief Allocates and initializes a RAM disk descriptor.
     147 *
     148 * The block size will be @a block_size.  The block count will be @a
     149 * block_count.  The disk storage area begins at @a area_begin.  If @a
     150 * area_begin is @c NULL, the memory will be allocated and zeroed.  Sets the
     151 * trace enable to @a trace.
     152 *
     153 * @return Pointer to allocated and initialized ramdisk structure, or @c NULL
     154 * if no memory is available.
     155 *
     156 * @code
     157 * rtems_status_code create_ramdisk(
     158 *   const char *disk_name_path,
     159 *   uint32_t block_size,
     160 *   rtems_blkdev_bnum block_count
     161 * )
     162 * {
     163 *   rtems_status_code sc = RTEMS_SUCCESSFUL;
     164 *   rtems_device_major_number major = 0;
     165 *   ramdisk *rd = NULL;
     166 *   dev_t dev = 0;
     167 *
     168 *   sc = rtems_io_register_driver(0, &ramdisk_ops, &major);
     169 *   if (sc != RTEMS_SUCCESSFUL) {
     170 *     return RTEMS_UNSATISFIED;
     171 *   }
     172 *
     173 *   rd = ramdisk_allocate(NULL, block_size, block_count, false);
     174 *   if (rd == NULL) {
     175 *     rtems_io_unregister_driver(major);
     176 *
     177 *     return RTEMS_UNSATISFIED;
     178 *   }
     179 *
     180 *   dev = rtems_filesystem_make_dev_t(major, 0);
     181 *
     182 *   sc = rtems_disk_create_phys(
     183 *     dev,
     184 *     block_size,
     185 *     block_count,
     186 *     ramdisk_ioctl,
     187 *     rd,
     188 *     disk_name_path
     189 *   );
     190 *   if (sc != RTEMS_SUCCESSFUL) {
     191 *     ramdisk_free(rd);
     192 *     rtems_io_unregister_driver(major);
     193 *
     194 *     return RTEMS_UNSATISFIED;
     195 *   }
     196 *
     197 *   return RTEMS_SUCCESSFUL;
     198 * }
     199 * @endcode
     200 */
     201ramdisk *ramdisk_allocate(
     202  void *area_begin,
     203  uint32_t block_size,
     204  rtems_blkdev_bnum block_count,
     205  bool trace
     206);
     207
     208void ramdisk_free(ramdisk *rd);
     209
     210/** @} */
     211
    90212/** @} */
    91213
Note: See TracChangeset for help on using the changeset viewer.