Changes between Version 17 and Version 18 of TBR/UserManual/Using_the_RTEMS_DOS_File_System


Ignore:
Timestamp:
Apr 13, 2015, 1:57:51 PM (5 years ago)
Author:
Wendell P Silva
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TBR/UserManual/Using_the_RTEMS_DOS_File_System

    v17 v18  
    88RTEMS provides an MS-DOS compatible file system. Currently the implementation provides support FAT12, FAT16 and FAT32 disks and short file-names. Long file-name support is being added. Contact for [wiki:ChrisJohns ChrisJohns] for details.
    99
    10 Configuration is based around the {{{confdefs.h</code> configuration file.
     10Configuration is based around the {{{confdefs.h}}} configuration file.
    1111
    1212For details of the RTEMS File System see [wiki:Developer/FileSystems File Systems].
     
    1616Your application needs a clock driver. The swap out task manages the block hold timers. You also need to use the IMFS as the base file system, configure the number of libio descriptors and indicate the application needs libblock:
    1717
     18
     19{{{
    1820 /**
    1921  * Configure drivers.
     
    2830 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS   20
    2931 #define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
     32
     33}}}
    3034
    3135The block cache requires configuration. You can configure:
     
    4448An example that can be used with a 4.5G IDE disk on a PC with 1G of memory to get great performance coping 250M of files:
    4549
     50
     51{{{
    4652 #define CONFIGURE_SWAPOUT_TASK_PRIORITY            10
    4753 #define CONFIGURE_BDBUF_BUFFER_COUNT               1024
    4854 #define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS      64
    4955 #define CONFIGURE_BDBUF_MAX_WRITE_BLOCKS           32
     56}}}
     57
    5058= ATA Disk =
    5159
    5260
    53 The ATA driver is in libchip and requires a BSP driver. It is best to take an existing driver and modify it. You can locate the various drivers by searching the source tree for {{{IDE_Controller_Table</code>. There are drivers in :
    54 
     61The ATA driver is in libchip and requires a BSP driver. It is best to take an existing driver and modify it. You can locate the various drivers by searching the source tree for {{{IDE_Controller_Table}}}. There are drivers in :
     62
     63
     64{{{
    5565  c/src/lib/libbsp/arm/nds/block/block.c
    5666  c/src/lib/libbsp/i386/pc386/ide/idecfg.c
     
    5969  c/src/lib/libbsp/powerpc/mbx8xx/ide/pcmcia_ide.c
    6070
    61 The {{{confdefs.h</code> configuration entry configures the IDE driver and the ATA driver:
    62 
     71}}}
     72
     73The {{{confdefs.h}}} configuration entry configures the IDE driver and the ATA driver:
     74
     75{{{
    6376 #define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER
    6477 #define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
    6578 #define CONFIGURE_ATA_DRIVER_TASK_PRIORITY         9
     79}}}
    6680
    6781Note, the examples given the ATA driver is a higher priority than the cache swap out task. This will make the ATA more responsive to the low levels. It does not have to be configured this way.
     
    6983Some where in the initialization phase of your application you need to read the IDE disk partition table. You need to provide the path to the IDE block driver. The code is:
    7084
     85{{{
    7186 extern rtems_status_code rtems_ide_part_table_initialize (const char* );
    7287 
     
    86101 
    87102 printf ("successful\n");
    88 
    89 Once the partition table has been read you can mount partitions. The ATA code will create devices in the device tree for each MSDOS partition found. The first primary partition on a primary IDE disk is called {{{/dev/hda1</code>.
    90 
    91 You can use the shell to mount the partition or you can code the mount call directly. Note, the shell can run scripts so you could embedded a simple initialization script that mounts the partition. The shell code to mount is in the function {{{rtems_shell_libc_mounter</code> and the shell command is:
    92 
     103}}}
     104
     105Once the partition table has been read you can mount partitions. The ATA code will create devices in the device tree for each MSDOS partition found. The first primary partition on a primary IDE disk is called {{{/dev/hda1}}}.
     106
     107You can use the shell to mount the partition or you can code the mount call directly. Note, the shell can run scripts so you could embedded a simple initialization script that mounts the partition. The shell code to mount is in the function {{{rtems_shell_libc_mounter}}} and the shell command is:
     108
     109{{{
    93110 mkdir c
    94111 mount -t msdos /dev/hda1 /c
    95 
    96 The code to mount the same partition to an existing {{{/c</code> directory is:
    97 
     112}}}
     113
     114The code to mount the same partition to an existing {{{/c}}} directory is:
     115
     116{{{
    98117 #include <rtems/dosfs.h>
    99118 #include <rtems/fsmount.h>
     
    106125   return 1;
    107126 }
     127}}}
     128
    108129= RAM Disk =
    109130
     
    121142An example is:
    122143
     144{{{
    123145 /**
    124146  * The RAM Disk configuration.
     
    138160  */
    139161 size_t rtems_ramdisk_configuration_size = 1;
     162}}}
    140163
    141164To use the RAM disk you need to register the driver. For example:
    142165
     166{{{
    143167  rtems_driver_address_table rtems_flashdisk_io_ops =
    144168     RAMDISK_DRIVER_TABLE_ENTRY;
     
    162186 
    163187  printf ("successful\n");
     188}}}
    164189
    165190Once the driver has been register you can mount the disk using the shell command of:
    166191
     192{{{
    167193 mkdir rd
    168194 mount -t msdos /dev/ramdisk0 /rd
    169 
    170 The code to mount the same device to an existing {{{/rd</code> directory is:
    171 
     195}}}
     196
     197The code to mount the same device to an existing {{{/rd}}} directory is:
     198
     199{{{
    172200 #include <rtems/dosfs.h>
    173201 #include <rtems/fsmount.h>
     
    180208   return 1;
    181209 }
     210}}}
     211
    182212= NV Disk =
    183213
     
    185215The Non-Volatile Disk driver supports more than one device per disk. A table of device descriptions describes the devices in a disk and you can have more than one NV disk active at once.
    186216
    187 The NV Disk is suitable for devices that byte or word reprogrammable and retain data over a power loss or target reset. For example battery backed up static RAM or EEPROM type devices. The driver performs no wear levelling as the disk blocks are mapped 1:1 with the devices in the device description table. There is no remapping of blocks.
    188 
    189 A device is describing using the {{{rtems_nvdisk_device_desc</code> structure. It is located in the <file>nvdisk.h</file> header file. The structure is:
    190 
     217The NV Disk is suitable for devices that byte or word reprogrammable and retain data over a power loss or target reset. For example battery backed up static RAM or EEPROM type devices. The driver performs no wear leveling as the disk blocks are mapped 1:1 with the devices in the device description table. There is no remapping of blocks.
     218
     219A device is describing using the {{{rtems_nvdisk_device_desc}}} structure. It is located in the {{{nvdisk.h}}} header file. The structure is:
     220
     221{{{
    191222 /**
    192223  * NV Device Descriptor holds the description of a device that is
     
    205236   const rtems_nvdisk_driver_handlers* nv_ops; /**< Device handlers. */
    206237 } rtems_nvdisk_device_desc;
     238}}}
    207239
    208240The fields are:
    209241
    210 # The {{{flags</code> field provides a private set of flags a specific low level device handlers for a device may need.
    211 # The {{{base</code> is the base address of the device. Its definition depends on the low level device handlers for a specific device.
    212 # The {{{size</code> field defines the number of bytes of storage the device provides in bytes. This is the raw number of bytes available to the driver.
    213 # The {{{nv_ops</code> is a set of handlers for the specific device.
     242 * The {{{flags}}} field provides a private set of flags a specific low level device handlers for a device may need.
     243 * The {{{base}}} is the base address of the device. Its definition depends on the low level device handlers for a specific device.
     244 * The {{{size}} field defines the number of bytes of storage the device provides in bytes. This is the raw number of bytes available to the driver.
     245 * The {{{nv_ops}}} is a set of handlers for the specific device.
    214246
    215247The NV Disk device requires a set of handlers for each type of device. The handles can manage more than one device in a disk or disks. The handlers are:
    216248
    217   {{{int (*<i><b>read</b></i>) (uint32_t device, uint32_t flags, uint32_t base, uint32_t offset,
    218  ::                  void* buffer, uint32_t size);</code>
    219  : Read a block of data from the {{{offset</code> in the {{{device</code> with the {{{base</code> address to the provided {{{buffer</code>.
    220 
    221   {{{int (*<i><b>write</b></i>) (uint32_t device, uint32_t flags, uint32_t base, uint32_t offset,
    222  ::                   const void* buffer, uint32_t size);</code>
    223  : Write a block of data to the {{{offset</code> in the {{{device</code> with the {{{base</code> address from the provided {{{buffer</code>.
    224 
    225   {{{int (*<i><b>verify</b></i>) (uint32_t device, uint32_t flags, uint32_t base, uint32_t offset,
    226  ::                    const void* buffer, uint32_t size);</code>
    227  : Verify a block of data provided in {{{buffer</code> against to the data at the {{{offset</code> in the {{{device</code> with this {{{base</code> address.
    228 
    229 The <tt>nvdisk-sram.h</tt> provides a set of handlers suitable for static RAM.
     249 * int (*'''''read''''') (uint32_t device, uint32_t flags, uint32_t base, uint32_t offset, void* buffer, uint32_t size);
     250  :: Read a block of data from the {{{offset}}} in the {{{device}}} with the {{{base}}} address to the provided {{{buffer}}}.
     251
     252 * int (*'''''write''''') (uint32_t device, uint32_t flags, uint32_t base, uint32_t offset, const void* buffer, uint32_t size);
     253   :: Write a block of data to the {{{offset}}} in the {{{device}}} with the {{{base}}} address from the provided {{{buffer}}}.
     254
     255  * int (*'''''verify''''') (uint32_t device, uint32_t flags, uint32_t base, uint32_t offset, const void* buffer, uint32_t size);
     256  :: Verify a block of data provided in {{{buffer}}} against to the data at the {{{offset}}} in the {{{device}}} with this {{{base}}} address.
     257
     258The {{{nvdisk-sram.h}}} provides a set of handlers suitable for static RAM.
    230259
    231260To configure a NV disk add this following to a source file in your application. The configuration items are:
    232261
    233 # Block size. This is normally 512 for the MSDOS file-system.
    234 # Number of device descriptions.
    235 # Pointer to the device descriptions.
    236 # Flags to control the driver.
    237 # Debug information level if compiled into the driver.
     262 * Block size. This is normally 512 for the MSDOS file-system.
     263 * Number of device descriptions.
     264 * Pointer to the device descriptions.
     265 * Flags to control the driver.
     266 * Debug information level if compiled into the driver.
    238267
    239268The flags to control the driver are:
    240269
    241 # {{{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.
     270 * {{{RTEMS_NVDISK_CHECK_PAGES}}} checks the pages during initialisation. This can slow down the initialisation of the disk. Pages not written too may have incorrect checksums.
    242271
    243272An example set up with static RAM allocated from the heap is:
    244273
     274{{{
    245275 #include <rtems/nvdisk.h>
    246276 #include <rtems/nvdisk-sram.h>
     
    274304   }
    275305 };
     306}}}
    276307
    277308To use the NV disk you need to register the driver. For example:
    278309
     310{{{
    279311  /*
    280312   * For our test we do not have any static RAM or EEPROM devices so
     
    306338 
    307339  printf ("successful\n");
     340}}}
    308341
    309342Once the driver has been register you can mount the disk using the shell command of:
    310343
     344{{{
    311345 mkdir nv
    312346 mount -t msdos /dev/nvdisk0 /nv
     347}}}
    313348
    314349The code to mount the same device to an existing /nv directory is:
    315350
     351{{{
    316352 #include <rtems/dosfs.h>
    317353 #include <rtems/fsmount.h>
     
    324360   return 1;
    325361 }
     362}}}
     363
    326364= Flash Disk =