File System Component  Version 5.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 <absacc.h>
#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 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 EXPAND_SYMBOL(name, port)   name##port
 
#define CREATE_SYMBOL(name, port)   EXPAND_SYMBOL(name, port)
 
#define NAND_INFO0   NULL
 
#define NAND_INFO0_SZ   0
 
#define NAND_INFO1   NULL
 
#define NAND_INFO1_SZ   0
 
#define STDIN   0x8001
 
#define STDOUT   0x8002
 
#define STDERR   0x8003
 

Functions

void fs_config (void)
 
uint32_t efs_rename (const char *filename, IOB *fcb)
 
uint32_t efs_create (const char *fname, IOB *fcb)
 
uint32_t efs_delete (IOB *fcb)
 
uint32_t efs_free (EFS_VI *vi)
 
uint32_t efs_format (EFS_VI *vi)
 
uint32_t efs_ffind (fsFileInfo *info, IOB *fcb)
 
uint32_t efs_wclose (IOB *fcb)
 
uint32_t efs_read (IOB *fcb, uint8_t *buf, uint32_t len)
 
uint32_t efs_write (IOB *fcb, const uint8_t *buf, uint32_t len)
 
uint32_t efs_ensure (IOB *fcb)
 
uint32_t efs_seek (IOB *fcb, uint32_t pos)
 
void efs_fsize (IOB *fcb)
 
uint32_t efs_find (const char *name, IOB *fcb)
 
int efs_analyse (EFS_VI *vi)
 
uint32_t efs_check (EFS_VI *vi)
 
uint32_t efs_defrag (IOB *fcb)
 
int fat_init (FAT_VI *vi)
 
uint32_t fat_find (const char *fn, IOB *fcb)
 
uint32_t fat_seek (IOB *fcb, uint32_t pos)
 
uint32_t fat_read (IOB *fcb, uint8_t *buf, uint32_t len)
 
uint32_t fat_write (IOB *fcb, const uint8_t *buf, uint32_t len)
 
uint64_t fat_free (FAT_VI *vi)
 
uint32_t fat_delete (const char *fn, IOB *fcb)
 
uint32_t fat_wclose (IOB *fcb)
 
uint32_t fat_rename (const char *old, const char *newn, IOB *fcb)
 
uint32_t fat_create (const char *fn, IOB *fcb)
 
uint32_t fat_format (FAT_VI *vi, const char *param)
 
uint32_t fat_ffind (const char *fn, fsFileInfo *info, IOB *fcb)
 
uint32_t fat_jour_init (FAT_VI *vi)
 
uint32_t fat_path_valid (const char *path, IOB *fcb)
 
uint32_t fat_getlabel (IOB *fcb, char *buf)
 
uint32_t fat_attrib (IOB *fcb, const char *fn, uint32_t attrib)
 
__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

struct iob _iob [NUM_FILES]
 
uint16_t const _NFILE = NUM_FILES
 
uint16_t const _NDRV = FS_NDRV
 
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_USE   (NOR0_ENABLE + NOR1_ENABLE)
#define EXPAND_SYMBOL (   name,
  port 
)    name##port
#define FAT_SECT_RSVD   64
#define FS_FAT_NDRV
Value:
(RAM0_ENABLE \
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 NAND_INFO0   NULL
#define NAND_INFO0_SZ   0
#define NAND_INFO1   NULL
#define NAND_INFO1_SZ   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
int efs_analyse ( EFS_VI *  vi)
uint32_t efs_check ( EFS_VI *  vi)
uint32_t efs_create ( const char *  fname,
IOB *  fcb 
)
uint32_t efs_defrag ( IOB *  fcb)
uint32_t efs_delete ( IOB *  fcb)
uint32_t efs_ensure ( IOB *  fcb)
uint32_t efs_ffind ( fsFileInfo info,
IOB *  fcb 
)
uint32_t efs_find ( const char *  name,
IOB *  fcb 
)
uint32_t efs_format ( EFS_VI *  vi)
uint32_t efs_free ( EFS_VI *  vi)
void efs_fsize ( IOB *  fcb)
uint32_t efs_read ( IOB *  fcb,
uint8_t *  buf,
uint32_t  len 
)
uint32_t efs_rename ( const char *  filename,
IOB *  fcb 
)
uint32_t efs_seek ( IOB *  fcb,
uint32_t  pos 
)
uint32_t efs_wclose ( IOB *  fcb)
uint32_t efs_write ( IOB *  fcb,
const uint8_t *  buf,
uint32_t  len 
)
uint32_t fat_attrib ( IOB *  fcb,
const char *  fn,
uint32_t  attrib 
)
uint32_t fat_create ( const char *  fn,
IOB *  fcb 
)
uint32_t fat_delete ( const char *  fn,
IOB *  fcb 
)
uint32_t fat_ffind ( const char *  fn,
fsFileInfo info,
IOB *  fcb 
)
uint32_t fat_find ( const char *  fn,
IOB *  fcb 
)
uint32_t fat_format ( FAT_VI *  vi,
const char *  param 
)
uint64_t fat_free ( FAT_VI *  vi)
uint32_t fat_getlabel ( IOB *  fcb,
char *  buf 
)
int fat_init ( FAT_VI *  vi)
uint32_t fat_jour_init ( FAT_VI *  vi)
uint32_t fat_path_valid ( const char *  path,
IOB *  fcb 
)
uint32_t fat_read ( IOB *  fcb,
uint8_t *  buf,
uint32_t  len 
)
uint32_t fat_rename ( const char *  old,
const char *  newn,
IOB *  fcb 
)
uint32_t fat_seek ( IOB *  fcb,
uint32_t  pos 
)
uint32_t fat_wclose ( IOB *  fcb)
uint32_t fat_write ( IOB *  fcb,
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"
struct iob _iob[NUM_FILES]
uint16_t const _NDRV = FS_NDRV
uint16_t const _NFILE = NUM_FILES
FAT_NCACHE_CFG fat_ncache
Initial value:
= {
0, 0, 0, NULL
}
FS_DEV fs_DevPool[FS_NDRV]
Initial value:
= {
}