view rvinterf/include/ffs.h @ 656:9f5a3e9e6294

fc-xram: implemented CRC-32 verification
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 03 Mar 2020 00:08:27 +0000
parents e7502631a0f9
children
line wrap: on
line source

/*
 * A few generic FFS API definitions which apply to both TMFFS1 and TMFFS2
 */

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,
    FFS_SEEK_CUR = 1,
    FFS_SEEK_END = 2
};

enum FFS_QUERY {              // data size, description
    Q_BYTES_FREE        =  1, // 4, number of free bytes in FFS
    Q_BYTES_USED        =  2, // 4, number of used bytes in FFS
    Q_BYTES_LOST        =  3, // 4, number of lost bytes in FFS
    Q_BYTES_MAX         =  4, // 4, number of max available bytes in FFS
    Q_BYTES_FREE_RAW    =  5, // 4, number of free raw bytes in FFS (used internal)

    Q_FD_BUF_SIZE       = 10, // 4, size of buffer used by stream functions

    Q_TM_BUFADDR        = 11, // 4, testmode buffer addr
    Q_TM_BUFSIZE        = 12, // 4, testmode ffs buffer size
    Q_DEV_BASE          = 13, // 4, FFS device base address
    Q_CHUNK_SIZE_MAX    = 14, // 4, max size of chunks made by non stream fkt.

    // FFS versions
    Q_FFS_API_VERSION   = 16, // 2, FFS API Version
    Q_FFS_DRV_VERSION   = 17, // 2, FFS Driver Version
    Q_FFS_REVISION      = 18, // 2, FFS Revision (from PRCS)
    Q_FFS_FORMAT_READ   = 19, // 2, FFS version as read from ffs
    Q_FFS_LASTERROR     = 20, // 2, FFS last error (from init)
    Q_FFS_FORMAT_WRITE  = 21, // 2, FFS version as written to ffs on format
    Q_FFS_TM_VERSION    = 22, // 2, FFS Testmode version

    // File system queries
    Q_FILENAME_MAX      = 24, // 2, max filename length
    Q_PATH_DEPTH_MAX    = 25, // 2, max path/directory nesting depth
    Q_FD_MAX            = 26, // 2, max numbers of simultaneous open files

    Q_OBJECTS_FREE      = 32, // 2, number of objects that can be created
    Q_INODES_USED       = 33, // 2, number of inodes used
    Q_INODES_LOST       = 34, // 2, number of inodes lost
    Q_OBJECTS_USED      = 33, // 2, DEPRECATED: old name for Q_INODES_USED
    Q_OBJECTS_LOST      = 34, // 2, DEPRECATED: old name for Q_INODES_LOST
    Q_OBJECTS_MAX       = 35, // 2, max number of valid objects allowed
    Q_INODES_MAX        = 36, // 2, physical total max number of inodes
    Q_INODES_HIGH       = 37, // 2, watermark for when inodes will be reclaimed
    Q_LOST_HIGH         = 38, // 2, watermark for when data block will be reclaimed

    // Device queries
    Q_DEV_MANUFACTURER  = 48, // 2, flash manufacturer ID
    Q_DEV_DEVICE        = 49, // 2, flash device ID
    Q_DEV_BLOCKS        = 50, // 2, number of FFS blocks in device
    Q_DEV_ATOMSIZE      = 51, // 2, atomsize used by FFS for this device
    Q_DEV_DRIVER        = 52, // 2, flash device driver

    // All queries below here are for debug purpose only, are unsupported
    // and can change at any time without notice!

    // Miscellaneous/Internal
    Q_BLOCKS_FREE_MIN   = 64, // 2, Number of spare blocks (0 or 1)

    Q_BLOCKS_FREE       = 70, // 2, number of free blocks

    // Debug queries
    Q_FS_FLAGS          = 80,
    Q_FS_INODES         = 81,
    Q_FS_ROOT           = 82,

    Q_OBJECTS_TOTAL     = 90, // 2, Accumulated number of valid objects
    Q_TOTAL_OBJECTS     = 90, // 2, DEPRECATED: old name for Q_OBJECTS_TOTAL

    Q_STATS_FIRST             = 100,
    Q_STATS_DRECLAIMS         = 100,
    Q_STATS_IRECLAIMS         = 101,
    Q_STATS_BRECLAIMS         = 102,
    Q_STATS_DATA_RECLAIMED    = 103,
    Q_STATS_INODES_RECLAIMED  = 104,
    Q_STATS_DATA_ALLOCATED    = 105,

    Q_REQUEST_ID_LAST         = 110,

    Q_DEBUG_FIRST             = 120,
    Q_DEBUG_0                 = 120,
    Q_DEBUG_1                 = 121,
    Q_DEBUG_2                 = 122,
    Q_DEBUG_3                 = 123,
    Q_DEBUG_LAST              = 127,

    // individual lines of the bstat array can be returned by the following
    // id plus the bstat index of the line wanted.
    Q_BSTAT                   = -128
};