Changeset 982ca110 in rtems for cpukit/libblock


Ignore:
Timestamp:
Oct 29, 2009, 12:47:04 PM (10 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, master
Children:
b5b07cad
Parents:
82a8add
Message:

Aded ramdisk_register().

Location:
cpukit/libblock
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libblock/include/rtems/ramdisk.h

    r82a8add r982ca110  
    214214void ramdisk_free(ramdisk *rd);
    215215
     216/**
     217 * @brief Allocates, initializes and registers a RAM disk.
     218 *
     219 * The block size will be @a block_size.  The block count will be @a
     220 * block_count.  The disk storage will be allocated.  Sets the trace enable to
     221 * @a trace.  Registers a device node with disk name path @a disk.  The
     222 * registered device number will be returned in @a dev.
     223 *
     224 * @retval RTEMS_SUCCESSFUL Successful operation.
     225 * @retval RTEMS_UNSATISFIED Something is wrong.
     226 */
     227rtems_status_code ramdisk_register(
     228  uint32_t block_size,
     229  rtems_blkdev_bnum block_count,
     230  bool trace,
     231  const char *disk,
     232  dev_t *dev
     233);
     234
    216235/** @} */
    217236
  • cpukit/libblock/src/ramdisk-init.c

    r82a8add r982ca110  
    7474  }
    7575}
     76
     77rtems_status_code ramdisk_register(
     78  uint32_t block_size,
     79  rtems_blkdev_bnum block_count,
     80  bool trace,
     81  const char *disk,
     82  dev_t *dev_ptr
     83)
     84{
     85  rtems_status_code sc = RTEMS_SUCCESSFUL;
     86  rtems_device_major_number major = 0;
     87  ramdisk *rd = NULL;
     88  dev_t dev = 0;
     89
     90  sc = rtems_io_register_driver(0, &ramdisk_ops, &major);
     91  if (sc != RTEMS_SUCCESSFUL) {
     92    return RTEMS_UNSATISFIED;
     93  }
     94
     95  rd = ramdisk_allocate(NULL, block_size, block_count, trace);
     96  if (rd == NULL) {
     97    rtems_io_unregister_driver(major);
     98
     99    return RTEMS_UNSATISFIED;
     100  }
     101
     102  dev = rtems_filesystem_make_dev_t(major, 0);
     103
     104  sc = rtems_disk_create_phys(
     105    dev,
     106    block_size,
     107    block_count,
     108    ramdisk_ioctl,
     109    rd,
     110    disk
     111  );
     112  if (sc != RTEMS_SUCCESSFUL) {
     113    ramdisk_free(rd);
     114    rtems_io_unregister_driver(major);
     115
     116    return RTEMS_UNSATISFIED;
     117  }
     118
     119  *dev_ptr = dev;
     120
     121  return RTEMS_SUCCESSFUL;
     122}
Note: See TracChangeset for help on using the changeset viewer.