Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Changes between Version 12 and Version 13 of TBR/UserManual/Using_the_RTEMS_DOS_File_System


Ignore:
Timestamp:
10/22/08 10:29:12 (16 years ago)
Author:
ChrisJohns
Comment:

Add examples.

Legend:

Unmodified
Added
Removed
Modified
  • TBR/UserManual/Using_the_RTEMS_DOS_File_System

    v12 v13  
    235235# Number of device descriptions.
    236236# Pointer to the device descriptions.
    237 #
     237# Flags to control the driver.
     238# Debug information level if compiled into the driver.
     239
     240The flags to control the driver are:
     241
     242# {{{RTEMS_NVDISK_CHECK_PAGES</code> checks the pages during initialisation. This can slow down the initialisation of the disk. Pages not written too may have incorrect checksums.
     243
     244An example set up with static RAM allocated from the heap is:
     245
     246 #include <rtems/nvdisk.h>
     247 #include <rtems/nvdisk-sram.h>
     248
     249 /**
     250  * The NV Device descriptor. For this test it is just DRAM.
     251  */
     252 rtems_nvdisk_device_desc rtems_nv_heap_device_descriptor[] =
     253
     254 {
     255   {
     256     flags:  0,
     257     base:   0,
     258     size:   2 * 1024 * 1024,
     259     nv_ops: &rtems_nvdisk_sram_handlers
     260   }
     261 };
     262 
     263 /**
     264  * The NV Disk configuration.
     265  */
     266 const rtems_nvdisk_config rtems_nvdisk_configuration[] =
     267
     268 {
     269   {
     270     block_size:         512,
     271     device_count:       1,
     272     devices:            &rtems_nv_heap_device_descriptor[0],
     273     flags:              0,
     274     info_level:         0
     275   }
     276 };
     277
     278To use the NV disk you need to register the driver. For example:
     279
     280  /*
     281   * For our test we do not have any static RAM or EEPROM devices so
     282   * we allocate the memory from the heap.
     283   */
     284  rtems_nv_heap_device_descriptor[0].base =
     285
     286    (uint32_t) malloc (rtems_nv_heap_device_descriptor[0].size);
     287
     288  if (!rtems_nv_heap_device_descriptor[0].base)
     289  {
     290    printf ("error: no memory for NV disk\n");
     291    return 1;
     292  }
     293 
     294  /*
     295   * Register the NV Disk driver.
     296   */
     297  printf ("Register NV Disk Driver: ");
     298  sc = rtems_io_register_driver (RTEMS_DRIVER_AUTO_MAJOR,
     299                                 &rtems_nvdisk_io_ops,
     300                                 &major);
     301  if (sc != RTEMS_SUCCESSFUL)
     302  {
     303    printf ("error: nvdisk driver not initialised: %s\n",
     304            rtems_status_text (sc));
     305    return 1;
     306  }
     307 
     308  printf ("successful\n");
     309
     310Once the driver has been register you can mount the disk using the shell command of:
     311
     312 mkdir nv
     313 mount -t msdos /dev/nvdisk0 /nv
     314
     315The code to mount the same device to an existing /nv directory is:
     316
     317 #include <rtems/dosfs.h>
     318 #include <rtems/fsmount.h>
     319
     320 rtems_filesystem_mount_table_entry_t* mt_entry;
     321 
     322 if (mount (&mt_entry, &msdos_ops, options, "/dev/nvdisk0", "/nv") < 0)
     323 {
     324   fprintf (stderr, "mount: mount failed: %s\n", strerror (errno));
     325   return 1;
     326 }
     327= Flash Disk =