📄 ffs.h
字号:
/******************************************************************************
* Flash File System (ffs)
* Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com
*
* FFS Types and globals
*
* $Id: ffs.h,v 1.1.1.1 2004/06/19 06:00:30 root Exp $
*
******************************************************************************/
#ifndef _FFS_H_
#define _FFS_H_
#ifndef TARGET
#include "ffs.cfg"
#endif
#ifdef _RVF
#include "rvf_api.h"
#endif
/******************************************************************************
* Types
******************************************************************************/
#ifndef BASIC_TYPES
#define BASIC_TYPES
typedef signed char int8;
typedef unsigned char uint8;
typedef signed short int16;
typedef unsigned short uint16;
typedef signed int int32;
typedef unsigned int uint32;
#endif
#if (TARGET == 1)
/*
* Macro for building the message offset from the USE ID.
*/
#define FFS_BUILD_MESSAGE_OFFSET(useid) ( (useid & 0xFFFF0000) + \
((((useid & 0xAAAA) ? 1 : 0) + \
((useid & 0xCCCC) ? 2 : 0) + \
((useid & 0xF0F0) ? 4 : 0) + \
((useid & 0xFF00) ? 8 : 0)) << 12) )
// Unique message offset returned in the header of each mail (msg_id).
#define FFS_MESSAGE_OFFSET FFS_BUILD_MESSAGE_OFFSET(FFS_USE_ID)
#endif
typedef int8 effs_t; // error type
//typedef int effs_t;
typedef int32 req_id_t; // request id
typedef int32 offset_t; // offset from first address of ffs.
typedef uint32 location_t; // object location offset
typedef int32 blocksize_t; // can hold size of a block
typedef uint8 objflags_t; // object flags
typedef uint8 objtype_t; // object type
typedef int16 iref_t; // inode reference
typedef int8 bref_t; // block reference
typedef int32 fd_t; // file descriptor
typedef uint16 ffs_options_t; // option flags to open() and file_write()
// For directory operations
struct dir_s {
iref_t this; // iref of dir that was opened
iref_t index; // last inode returned by ffs_readdir()
};
// File stat structure
struct stat_s {
objtype_t type;
objflags_t flags;
iref_t inode;
int size; // size of data space occupied by object
};
// File xstat structure
struct xstat_s {
objtype_t type;
objflags_t flags;
iref_t inode;
int size; // size of data space occupied by object
int space; // size of physical data space occupied by object
location_t location;
uint8 reserved; // only for debug
bref_t block; // only for debug
uint16 sequence; // only for debug
uint16 updates; // only for debug
};
#if (TARGET == 0)
// Only use to run on PC and not in target. Must be syncron with the typedef
// from rv_general.h
typedef void (*CALLBACK_FUNC)(void *);
typedef uint16 T_RVF_ADDR_ID;
/* define return_path */
typedef struct
{
T_RVF_ADDR_ID addr_id;
void (*callback_func)(void *);
} T_RV_RETURN;
/* Define the header of each message used in Riviera. */
typedef struct {
uint32 msg_id;
void (*callback_func)(void *);
T_RVF_ADDR_ID src_addr_id;
T_RVF_ADDR_ID dest_addr_id;
} T_RV_HDR;
// Used riviera types
typedef uint16 UINT16;
typedef int8 INT8;
#endif
// Confirm mail sent from FFS task to caller (application)
struct ffs_file_cnf_s {
T_RV_HDR header;
int error; // error code of FFS operation
req_id_t request_id; // Unique id number
char *path; // path name of object operation was performed on
};
struct ffs_stream_cnf_s {
T_RV_HDR header;
int error; // error code of FFS operation
req_id_t request_id; // Unique id number
fd_t fdi; // file descriptor
};
/******************************************************************************
* RVF Types
******************************************************************************/
typedef ffs_options_t T_FFS_OPEN_FLAGS;
typedef int T_FFS_SIZE;
typedef offset_t T_FFS_OFFSET;
typedef effs_t T_FFS_RET;
typedef req_id_t T_FFS_REQ_ID;
typedef int T_FFS_WHENCE;
typedef fd_t T_FFS_FD;
typedef objtype_t T_FFS_OBJECT_TYPE;
typedef objflags_t T_FFS_FLAGS;
typedef struct stat_s T_FFS_STAT;
typedef struct xstat_s T_FFS_XSTAT;
typedef struct dir_s T_FFS_DIR;
typedef struct ffs_file_cnf_s T_FFS_FILE_CNF;
typedef struct ffs_stream_cnf_s T_FFS_STREAM_CNF;
/******************************************************************************
* Errors
******************************************************************************/
enum FFS_ERRORS {
EFFS_OK = 0, /* ok */
EFFS_NODEVICE = -1, /* flash device unknown */
EFFS_CORRUPTED = -2, /* filesystem corrupted!? */
EFFS_NOPREFORMAT = -3, /* ffs not preformatted */
EFFS_NOFORMAT = -4, /* ffs not formatted */
EFFS_BADFORMAT = -5, /* incompatible ffs version, re-format needed */
EFFS_MAGIC = -6, /* bad magic */
EFFS_AGAIN = -7, /* not ready, try again later */
EFFS_NOSYS = -8, /* function not implemented */
EFFS_DRIVER = -9, /* ffs device driver error */
EFFS_NOSPACE = -10, /* out of data space */
EFFS_FSFULL = -11, /* file system full, no free inodes */
EFFS_BADNAME = -12, /* bad filename */
EFFS_NOTFOUND = -13, /* object not found */
EFFS_EXISTS = -14, /* object exists */
EFFS_ACCESS = -15, /* access permission violation */
EFFS_NAMETOOLONG = -16, /* filename too long */
EFFS_INVALID = -17, /* invalid argument */
EFFS_DIRNOTEMPTY = -18, /* directory not empty */
EFFS_NOTADIR = -19, /* object is not a directory */
EFFS_SPARE = -20, /* SPARE */
EFFS_FILETOOBIG = -21, /* file too big */
EFFS_NOTAFILE = -22, /* object is not a file */
EFFS_PATHTOODEEP = -23, /* path too deep */
EFFS_NUMFD = -24, /* Max number of open files reached */
EFFS_BADFD = -25, /* Bad file descriptor */
EFFS_BADOP = -26, /* Bad operation */
EFFS_LOCKED = -27, /* The file is locked */
EFFS_TOOBIG = -30, /* too big (tmffs buffer overflow) */
EFFS_MEMORY = -31, /* out of memory */
EFFS_MSGSEND = -32, /* message send failed */
/* debug errors */
EFFS_SIBLINGLOOP = -40, /* directory sibling loop */
EFFS_NOBLOCKS = -41, /* No more blocks!? */
EFFS_DBR = -42, /* Data reclaim did not finish!? */
EFFS_RECLAIMLOOP = -43 /* Data reclaim loop */
};
/******************************************************************************
* Enumerations
******************************************************************************/
enum FFS_OBJECT_CONTROL_ACTION {
OC_FLAGS = 1
};
enum FFS_OBJECT_TYPE {
OT_FILE = 1,
OT_DIR = 2,
OT_LINK = 3,
OT_SEGMENT = 4
};
enum FFS_OBJECT_FLAGS {
OF_READONLY = 1<<4 // object cannot be modified
};
enum FFS_OPEN {
FFS_O_EMPTY = 0x00, // Okay?
FFS_O_CREATE = 0x01,
FFS_O_APPEND = 0x02,
FFS_O_EXCL = 0x04,
FFS_O_TRUNC = 0x08,
FFS_O_RDONLY = 0x10,
FFS_O_WRONLY = 0x20,
FFS_O_RDWR = FFS_O_RDONLY | FFS_O_WRONLY
};
enum FFS_SEEK {
FFS_SEEK_SET = 0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -