File System Component  Version 6.0
MDK-Professional Middleware for Devices with Flash File System
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
fs_config.h File Reference
#include <string.h>
#include <rt_sys.h>
#include "rl_fs_lib.h"

Go to the source code of this file.

Macros

#define NOR0_ENABLE   0
 
#define NOR0_DEFAULT_DRIVE   0
 
#define NOR1_ENABLE   0
 
#define NOR1_DEFAULT_DRIVE   0
 
#define RAM0_ENABLE   0
 
#define RAM0_DEFAULT_DRIVE   0
 
#define MC0_ENABLE   0
 
#define MC0_DEFAULT_DRIVE   0
 
#define MC1_ENABLE   0
 
#define MC1_DEFAULT_DRIVE   0
 
#define NAND0_ENABLE   0
 
#define NAND0_DEFAULT_DRIVE   0
 
#define NAND1_ENABLE   0
 
#define NAND1_DEFAULT_DRIVE   0
 
#define USB0_ENABLE   0
 
#define USB0_DEFAULT_DRIVE   0
 
#define USB1_ENABLE   0
 
#define USB1_DEFAULT_DRIVE   0
 
#define FAT_MAX_OPEN_FILES   NUM_FILES
 
#define EFS_MAX_OPEN_FILES   NUM_FILES
 
#define FS_NDRV
 
#define FS_FAT_NDRV
 
#define FS_NAND_NDRV   (NAND0_ENABLE + NAND1_ENABLE)
 
#define __DEF
 
#define EFS_USE   (NOR0_ENABLE + NOR1_ENABLE)
 
#define FAT_USE   (RAM0_ENABLE + MC0_ENABLE + MC1_ENABLE + USB0_ENABLE + USB1_ENABLE + NAND0_ENABLE + NAND1_ENABLE)
 
#define FSJ_USE
 
#define FAT_SECT_RSVD   64
 
#define STREAM_LIST_LOCK
 
#define FAT_HANDLE_COUNT   ((FAT_MAX_OPEN_FILES > 0) ? FAT_MAX_OPEN_FILES : 1)
 
#define EFS_HANDLE_COUNT   ((EFS_MAX_OPEN_FILES > 0) ? EFS_MAX_OPEN_FILES : 1)
 
#define EXPAND_SYMBOL(name, port)   name##port
 
#define CREATE_SYMBOL(name, port)   EXPAND_SYMBOL(name, port)
 
#define STDIN   0x8001
 
#define STDOUT   0x8002
 
#define STDERR   0x8003
 

Functions

void fs_config (void)
 
bool efs_path_valid (const char *path)
 
int32_t efs_handle_get (fsEFS_Volume *vol)
 
fsStatus efs_open (int32_t handle, const char *fn, int openmode)
 
fsStatus efs_close (int32_t handle)
 
int32_t efs_read (int32_t handle, uint8_t *buf, uint32_t len)
 
int32_t efs_write (int32_t handle, const uint8_t *buf, uint32_t len)
 
fsStatus efs_flush (int32_t handle)
 
int32_t efs_flen (int32_t handle)
 
fsStatus efs_seek (int32_t handle, uint32_t pos)
 
fsStatus efs_ffind (int32_t handle, fsFileInfo *info)
 
fsStatus efs_find (int32_t handle, const char *fname)
 
fsStatus efs_delete (int32_t handle)
 
int32_t efs_analyse (fsEFS_Volume *vol)
 
fsStatus efs_check (fsEFS_Volume *vol)
 
fsStatus efs_format (fsEFS_Volume *vol)
 
uint32_t efs_free (fsEFS_Volume *vol)
 
fsStatus efs_defrag (fsEFS_Volume *vol)
 
int32_t fat_handle_get (fsFAT_Volume *vol)
 
fsStatus fat_open (int32_t handle, const char *path, int32_t openmode)
 
fsStatus fat_close (int32_t handle)
 
int32_t fat_read (int32_t handle, uint8_t *buf, uint32_t len)
 
int32_t fat_write (int32_t handle, const uint8_t *buf, uint32_t len)
 
int32_t fat_flen (int32_t handle)
 
fsStatus fat_seek (int32_t handle, uint32_t pos)
 
int32_t fat_init (fsFAT_Volume *vol)
 
fsStatus fat_ffind (const char *fn, fsFileInfo *info, fsFAT_Volume *vol)
 
fsStatus fat_delete (const char *fn, fsFAT_Volume *vol)
 
fsStatus fat_rename (const char *path, const char *newname, fsFAT_Volume *vol)
 
fsStatus fat_format (fsFAT_Volume *vol, const char *opt)
 
uint64_t fat_free (fsFAT_Volume *vol)
 
fsStatus fat_attrib (fsFAT_Volume *vol, const char *fn, uint32_t attrib)
 
fsStatus fat_read_label (fsFAT_Volume *vol, char *buf)
 
fsStatus fat_read_serial (fsFAT_Volume *vol, uint32_t *serial)
 
fsStatus fat_mkdir (const char *path, fsFAT_Volume *vol)
 
uint32_t fat_jour_init (fsFAT_Volume *vi)
 
uint32_t elink_init (void)
 
uint32_t elink_init_path (const char *drvLet)
 
uint32_t elink_flush (const char *drvLet)
 
uint32_t elink_cmd (uint32_t i, uint32_t j)
 
uint32_t elink_insert (void *p, uint32_t i, uint32_t j)
 
uint32_t elink_delete (void *p, uint32_t i)
 
uint32_t elink_scan (uint32_t i, void **pp, uint32_t j)
 
__weak int stdio_getc (void)
 
__weak int stdio_putc (int ch)
 
__weak void _ttywrch (int ch)
 
FILEHANDLE _sys_open (const char *name, int openmode)
 
int _sys_close (FILEHANDLE fh)
 
int _sys_write (FILEHANDLE fh, const uint8_t *buf, uint32_t len, int mode)
 
int _sys_read (FILEHANDLE fh, uint8_t *buf, uint32_t len, int mode)
 
int _sys_istty (FILEHANDLE fh)
 
int _sys_seek (FILEHANDLE fh, long pos)
 
int _sys_ensure (FILEHANDLE fh)
 
long _sys_flen (FILEHANDLE fh)
 
__weak void _sys_exit (int return_code)
 

Variables

fsFAT_Handle fs_fat_fh [FAT_HANDLE_COUNT]
 
uint8_t const FS_FAT_MAX_FILES = FAT_MAX_OPEN_FILES
 
fsEFS_Handle fs_efs_fh [EFS_HANDLE_COUNT]
 
uint8_t const FS_EFS_MAX_FILES = EFS_MAX_OPEN_FILES
 
uint8_t const _NDRV = FS_NDRV
 
uint16_t const fs_efs_timeout_erase_chip = 300
 
uint8_t const fs_efs_timeout_erase_sector = 5
 
uint8_t const fs_efs_timeout_write = 1
 
uint8_t const fs_efs_timeout_read = 1
 
FAT_NCACHE_CFG fat_ncache
 
FS_DEV fs_DevPool [FS_NDRV]
 
const char __stdin_name [] = "STDIN"
 
const char __stdout_name [] = "STDOUT"
 
const char __stderr_name [] = "STDERR"
 

Macro Definition Documentation

#define CREATE_SYMBOL (   name,
  port 
)    EXPAND_SYMBOL(name, port)
#define EFS_HANDLE_COUNT   ((EFS_MAX_OPEN_FILES > 0) ? EFS_MAX_OPEN_FILES : 1)
#define EFS_MAX_OPEN_FILES   NUM_FILES
#define EFS_USE   (NOR0_ENABLE + NOR1_ENABLE)
#define EXPAND_SYMBOL (   name,
  port 
)    name##port
#define FAT_HANDLE_COUNT   ((FAT_MAX_OPEN_FILES > 0) ? FAT_MAX_OPEN_FILES : 1)
#define FAT_MAX_OPEN_FILES   NUM_FILES
#define FAT_SECT_RSVD   64
#define FS_FAT_NDRV
Value:
MC0_ENABLE + MC1_ENABLE + \
USB0_ENABLE + USB1_ENABLE + \
NAND0_ENABLE + NAND1_ENABLE)
#define FS_NAND_NDRV   (NAND0_ENABLE + NAND1_ENABLE)
#define FS_NDRV
Value:
RAM0_ENABLE + \
MC0_ENABLE + MC1_ENABLE + \
USB0_ENABLE + USB1_ENABLE + \
NAND0_ENABLE + NAND1_ENABLE)
#define FSJ_USE
Value:
(MC0_ENABLE * MC0_FAT_JOURNAL + \
MC1_ENABLE * MC1_FAT_JOURNAL + \
USB0_ENABLE * USB0_FAT_JOURNAL + \
USB1_ENABLE * USB1_FAT_JOURNAL + \
NAND0_ENABLE * NAND0_FAT_JOURNAL + \
NAND1_ENABLE * NAND1_FAT_JOURNAL)
#define MC0_DEFAULT_DRIVE   0
#define MC0_ENABLE   0
#define MC1_DEFAULT_DRIVE   0
#define MC1_ENABLE   0
#define NAND0_DEFAULT_DRIVE   0
#define NAND0_ENABLE   0
#define NAND1_DEFAULT_DRIVE   0
#define NAND1_ENABLE   0
#define NOR0_DEFAULT_DRIVE   0
#define NOR0_ENABLE   0
#define NOR1_DEFAULT_DRIVE   0
#define NOR1_ENABLE   0
#define RAM0_DEFAULT_DRIVE   0
#define RAM0_ENABLE   0
#define STDERR   0x8003
#define STDIN   0x8001
#define STDOUT   0x8002
#define STREAM_LIST_LOCK
#define USB0_DEFAULT_DRIVE   0
#define USB0_ENABLE   0
#define USB1_DEFAULT_DRIVE   0
#define USB1_ENABLE   0

Function Documentation

int _sys_close ( FILEHANDLE  fh)

Defined in rt_sys.h, this function closes a file previously opened with _sys_open().

This function must be defined if any input/output function is to be used.

Parameters
[in]fhFile handle
Returns
The return value is 0 if successful. A nonzero value indicates an error.
int _sys_ensure ( FILEHANDLE  fh)

This function is deprecated. It is never called by any other library function, and you are not required to re-implement it if you are retargeting standard I/O (stdio).

__weak void _sys_exit ( int  return_code)

Defined in rt_sys.h, this is the library exit function. All exits from the library eventually call _sys_exit().

This function must not return. You can intercept application exit at a higher level by either:

  • Implementing the C library function exit() as part of your application. You lose atexit() processing and library shutdown if you do this.
  • Implementing the function __rt_exit(int n) as part of your application. You lose library shutdown if you do this, but atexit() processing is still performed when exit() is called or main() returns.
Parameters
[in]return_codeLibrary return code
Returns
The return code is advisory. An implementation might attempt to pass it to the execution environment.
long _sys_flen ( FILEHANDLE  fh)

Defined in rt_sys.h, this function returns the current length of a file.

This function is used by sys_seek() to convert an offset relative to the end of a file into an offset relative to the beginning of the file. You do not have to define _sys_flen() if you do not intend to use fseek(). If you retarget at system _sys*() level, you must supply _sys_flen(), even if the underlying system directly supports seeking relative to the end of a file.

Parameters
[in]fhFile handle
Returns
This function returns the current length of the file fh, or a negative error indicator.
int _sys_istty ( FILEHANDLE  fh)

Defined in rt_sys.h, this function determines if a file handle identifies a terminal.

When a file is connected to a terminal device, this function is used to provide unbuffered behavior by default (in the absence of a call to set(v)buf) and to prohibit seeking.

Parameters
[in]fhFile handle
Returns
The return value is one of the following values:
  • 0: There is no interactive device.
  • 1: There is an interactive device.
  • other: An error occurred.
FILEHANDLE _sys_open ( const char *  name,
int  openmode 
)

Defined in rt_sys.h, this function opens a file.

The _sys_open() function is required by fopen() and freopen(). These functions in turn are required if any file input/output function is to be used. The openmode parameter is a bitmap whose bits mostly correspond directly to the ISO mode specification. Target-dependent extensions are possible, but freopen() must also be extended.

Parameters
[in]nameFile name
[in]openmodeMode specification bitmap
Returns
The return value is –1 if an error occurs.
int _sys_read ( FILEHANDLE  fh,
uint8_t *  buf,
uint32_t  len,
int  mode 
)

Defined in rt_sys.h, this function reads the contents of a file into a buffer.

Reading up to and including the last byte of data does not turn on the EOF indicator. The EOF indicator is only reached when an attempt is made to read beyond the last byte of data. The target-independent code is capable of handling:

  • the EOF indicator being returned in the same read as the remaining bytes of data that precede the EOF
  • the EOF indicator being returned on its own after the remaining bytes of data have been returned in a previous read.
Note
The mode parameter is here for historical reasons. It contains nothing useful and must be ignored.
Parameters
[in]fhFile handle
[in]bufData buffer
[in]lenData length
[in]modeIgnore this parameter
Returns
The return value is one of the following:
  • The number of bytes not read (that is, len - result number of bytes were read).
  • An error indication.
  • An EOF indicator. The EOF indication involves the setting of 0x80000000 in the normal result.
int _sys_seek ( FILEHANDLE  fh,
long  pos 
)

Defined in rt_sys.h, this function puts the file pointer at offset pos from the beginning of the file.

This function sets the current read or write position to the new location pos relative to the start of the current file fh.

Parameters
[in]fhFile handle
[in]posFile pointer offset
Returns
The result is:
  • non-negative if no error occurs
  • negative if an error occurs
int _sys_write ( FILEHANDLE  fh,
const uint8_t *  buf,
uint32_t  len,
int  mode 
)

Defined in rt_sys.h, this function writes the contents of a buffer to a file previously opened with _sys_open().

Note
The mode parameter is here for historical reasons. It contains nothing useful and must be ignored.
Parameters
[in]fhFile handle
[in]bufData buffer
[in]lenData length
[in]modeIgnore this parameter
Returns
The return value is either:
  • a positive number representing the number of characters not written (so any nonzero return value denotes a failure of some sort)
  • a negative number indicating an error.
__weak void _ttywrch ( int  ch)

Defined in rt_sys.h, this function writes a character to the console. The console might have been redirected. You can use this function as a last resort error handling routine.

The default implementation of this function uses semihosting. You can redefine this function, or __raise(), even if there is no other input/output. For example, it might write an error message to a log kept in nonvolatile memory.

Parameters
[in]chcharacter to write
int32_t efs_analyse ( fsEFS_Volume *  vol)
fsStatus efs_check ( fsEFS_Volume *  vol)
fsStatus efs_close ( int32_t  handle)
fsStatus efs_defrag ( fsEFS_Volume *  vol)
fsStatus efs_delete ( int32_t  handle)
fsStatus efs_ffind ( int32_t  handle,
fsFileInfo info 
)
fsStatus efs_find ( int32_t  handle,
const char *  fname 
)
int32_t efs_flen ( int32_t  handle)
fsStatus efs_flush ( int32_t  handle)
fsStatus efs_format ( fsEFS_Volume *  vol)
uint32_t efs_free ( fsEFS_Volume *  vol)
int32_t efs_handle_get ( fsEFS_Volume *  vol)
fsStatus efs_open ( int32_t  handle,
const char *  fn,
int  openmode 
)
bool efs_path_valid ( const char *  path)
int32_t efs_read ( int32_t  handle,
uint8_t *  buf,
uint32_t  len 
)
fsStatus efs_seek ( int32_t  handle,
uint32_t  pos 
)
int32_t efs_write ( int32_t  handle,
const uint8_t *  buf,
uint32_t  len 
)
uint32_t elink_cmd ( uint32_t  i,
uint32_t  j 
)
uint32_t elink_delete ( void *  p,
uint32_t  i 
)
uint32_t elink_flush ( const char *  drvLet)
uint32_t elink_init ( void  )
uint32_t elink_init_path ( const char *  drvLet)
uint32_t elink_insert ( void *  p,
uint32_t  i,
uint32_t  j 
)
uint32_t elink_scan ( uint32_t  i,
void **  pp,
uint32_t  j 
)
fsStatus fat_attrib ( fsFAT_Volume *  vol,
const char *  fn,
uint32_t  attrib 
)
fsStatus fat_close ( int32_t  handle)
fsStatus fat_delete ( const char *  fn,
fsFAT_Volume *  vol 
)
fsStatus fat_ffind ( const char *  fn,
fsFileInfo info,
fsFAT_Volume *  vol 
)
int32_t fat_flen ( int32_t  handle)
fsStatus fat_format ( fsFAT_Volume *  vol,
const char *  opt 
)
uint64_t fat_free ( fsFAT_Volume *  vol)
int32_t fat_handle_get ( fsFAT_Volume *  vol)
int32_t fat_init ( fsFAT_Volume *  vol)
uint32_t fat_jour_init ( fsFAT_Volume *  vi)
fsStatus fat_mkdir ( const char *  path,
fsFAT_Volume *  vol 
)
fsStatus fat_open ( int32_t  handle,
const char *  path,
int32_t  openmode 
)
int32_t fat_read ( int32_t  handle,
uint8_t *  buf,
uint32_t  len 
)
fsStatus fat_read_label ( fsFAT_Volume *  vol,
char *  buf 
)
fsStatus fat_read_serial ( fsFAT_Volume *  vol,
uint32_t *  serial 
)
fsStatus fat_rename ( const char *  path,
const char *  newname,
fsFAT_Volume *  vol 
)
fsStatus fat_seek ( int32_t  handle,
uint32_t  pos 
)
int32_t fat_write ( int32_t  handle,
const uint8_t *  buf,
uint32_t  len 
)
void fs_config ( void  )
__weak int stdio_getc ( void  )
__weak int stdio_putc ( int  ch)

Variable Documentation

const char __stderr_name[] = "STDERR"
const char __stdin_name[] = "STDIN"
const char __stdout_name[] = "STDOUT"
uint8_t const _NDRV = FS_NDRV
FAT_NCACHE_CFG fat_ncache
Initial value:
= {
0, 0, 0, NULL
}
FS_DEV fs_DevPool[FS_NDRV]
Initial value:
= {
}
fsEFS_Handle fs_efs_fh[EFS_HANDLE_COUNT]
uint8_t const FS_EFS_MAX_FILES = EFS_MAX_OPEN_FILES
uint16_t const fs_efs_timeout_erase_chip = 300
uint8_t const fs_efs_timeout_erase_sector = 5
uint8_t const fs_efs_timeout_read = 1
uint8_t const fs_efs_timeout_write = 1
fsFAT_Handle fs_fat_fh[FAT_HANDLE_COUNT]
uint8_t const FS_FAT_MAX_FILES = FAT_MAX_OPEN_FILES