Changes between Version 6 and Version 7 of TBR/UserManual/Using_the_RTEMS_DOS_File_System


Ignore:
Timestamp:
09/13/08 08:21:45 (16 years ago)
Author:
ChrisJohns
Comment:

Update the RAM Disk usage

Legend:

Unmodified
Added
Removed
Modified
  • TBR/UserManual/Using_the_RTEMS_DOS_File_System

    v6 v7  
    8080   return 1;
    8181 }
    82   
     82 
    8383 printf ("successful\n");
    8484
     
    102102   return 1;
    103103 }
     104= RAM Disk =
     105
     106
     107The RAM disk driver supports a single continuous memory region as a disk. There is no partitions. You can specify the location of the memory to use or the driver can allocate the memory from the heap. The memory is not initialised so you need to format the disk once you have created it.
     108
     109The RAM disk has a 1:1 block mapping. Block 0 is the first block in the memory region. There is not checking on blocks so a block of memory that survives reset and even power loss such as static RAM cannot be checked for a valid disk image. You should considering using the NV Disk driver in this case.
     110
     111To configure a RAM disk add this following to a source file in your application. The configuration items are:
     112
     113# Block size. This is normally 512 for the MSDOS file-system
     114# Number of blocks in the disk drive. The memory size is the block size multiplied by the number of blocks
     115# The location. If NULL the heap is used.
     116
     117An example is:
     118
     119 /**
     120  * The RAM Disk configuration.
     121  */
     122 rtems_ramdisk_config rtems_ramdisk_configuration[] =
     123
     124 {
     125   {
     126     block_size: 512,
     127     block_num:  4000,
     128     location:   NULL
     129   }
     130 };
     131 
     132 /**
     133  * The number of RAM Disk configurations.
     134  */
     135 size_t rtems_ramdisk_configuration_size = 1;
     136
     137To use the RAM disk you need to register the driver. For example:
     138
     139  rtems_driver_address_table rtems_flashdisk_io_ops =
     140     RAMDISK_DRIVER_TABLE_ENTRY;
     141
     142  rtems_device_major_number major;
     143  rtems_status_code         sc;
    104144 
    105  return 0;
     145  /*
     146   * Register the RAM Disk driver.
     147   */
     148  printf ("Register RAM Disk Driver: ");
     149  sc = rtems_io_register_driver (RTEMS_DRIVER_AUTO_MAJOR,
     150                                 &rtems_ramdisk_io_ops,
     151                                 &major);
     152  if (sc != RTEMS_SUCCESSFUL)
     153  {
     154    printf ("error: ramdisk driver not initialised: %s\n",
     155            rtems_status_text (sc));
     156    return 1;
     157  }
     158 
     159  printf ("successful\n");
     160
     161Once the driver has been register you can mount the disk using the shell command of:
     162
     163 mkdir rd
     164 mount -t msdos /dev/ramdisk0 /rd
     165
     166The code to mount the same device to an existing {{{/rd</code> directory is:
     167
     168 #include <rtems/dosfs.h>
     169 #include <rtems/fsmount.h>
     170 
     171 rtems_filesystem_mount_table_entry_t* mt_entry;
     172 
     173 if (mount (&mt_entry, &msdos_ops, options, "/dev/ramdisk0", "/rd") < 0)
     174 {
     175   fprintf (stderr, "mount: mount failed: %s\n", strerror (errno));
     176   return 1;
     177 }
     178  = NV Disk =