File nut/fs/uflashfs.c

References Functions: UFlashFileClose() nut/fs/uflashfs.c
  UFlashFileOpen() nut/fs/uflashfs.c
  UFlashFileRead() nut/fs/uflashfs.c
  UFlashFileSize() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c
  UFlashFileWrite_P() nut/fs/uflashfs.c
  UFlashIOCtl() nut/fs/uflashfs.c
  UFlashInit() nut/fs/uflashfs.c

Included Files


Preprocessor definitions

#define UFLASH_MAX_BLOCKS 8192

#define UFLASH_BLOCK_UNITS 4

#define UFLASH_ENTRIES 128

#define UFLASH_USAGE_CACHE 32

#define UFLASH_MAX_PATH 0

#define UFLASH_BLOCK_INVALID

#define UFLASH_VOLF_FIXED 0x80


Typedef blknum_t

typedef uint16_t blknum_t

Typedef blknum_fast_t

typedef uint_fast16_t blknum_fast_t

Typedef BLOCK_USAGE

typedef struct _BLOCK_USAGE BLOCK_USAGE
struct _BLOCK_USAGE  
   {  
      uint8_t use_cnt;  
      blknum_t use_phyblk;  
   }  

Typedef BLOCKHEAD

typedef struct _BLOCKHEAD BLOCKHEAD
struct _BLOCKHEAD  
   {  
      blknum_t bh_logblk;  
      blknum_t bh_version;  
      blknum_t bh_entblk;  
      blknum_t bh_entseq;  
   }  

Typedef BLOCKFOOT

typedef struct _BLOCKFOOT BLOCKFOOT
struct _BLOCKFOOT  
   {  
      uint8_t bf_wear;  
   }  

Typedef ENTRYHEAD

typedef struct _ENTRYHEAD ENTRYHEAD
struct _ENTRYHEAD  
   {  
      uint8_t eh_attr;  
      uint8_t eh_nlen;  
   }  

Typedef UFLASHENTRY

typedef struct _UFLASHENTRY UFLASHENTRY
struct _UFLASHENTRY  
   {  
      blknum_t ent_id;  
      uint32_t ent_pos;  
      blknum_t ent_bidx;  
      uint16_t ent_sidx;  
      uint16_t ent_uidx;  
      uint16_t ent_upos;  
      uint32_t ent_mode;  
      uint8_t ent_attr;  
      uint8_t ent_namlen;  
      uint32_t ent_size;  
      uint16_t ent_eoff;  
   }  

Typedef UFLASHVOLUME

typedef struct _UFLASHVOLUME UFLASHVOLUME
See: Type struct _UFLASHVOLUME

Type struct _UFLASHVOLUME

struct _UFLASHVOLUME
struct _UFLASHVOLUME  
   {  
      NUTSERIALFLASH* vol_ifc;  
      HANDLE vol_mutex;  
      uint8_t vol_attrib;  
      blknum_t vol_blocks;  
      blknum_t* vol_l2p;  
   }  

Typedef UFLASHFIND

typedef struct _UFLASHFIND UFLASHFIND
struct _UFLASHFIND  
   {  
      blknum_t uff_lbe;  
      char* uff_path;  
   }  

Global Variable devUFlash0

NUTDEVICE devUFlash0
Visible in:   nut/fs/uflashfs.c

Global Variable devUFlash1

NUTDEVICE devUFlash1
Visible in:   nut/fs/uflashfs.c

Local Variables

min_used
static BLOCK_USAGE min_used[32]
Used in: CollectLeastUsed()  
  PhysBlkAllocate()  
  UFlashMount()  

Global Function UFlashAttach()

int UFlashAttach ( NUTDEVICE* dev, NUTSERIALFLASH* sfi, NUTSPIBUS* bus )
Prototyped in: nut/include/fs/uflashfs.h
Calls: UFlashMount() nut/fs/uflashfs.c
  NutEventPost()

Global Function UFlashDetach()

void UFlashDetach ( NUTDEVICE* dev )
Prototyped in: nut/include/fs/uflashfs.h
Calls: UFlashUnmount() nut/fs/uflashfs.c

Global Function UFlashFormat()

int UFlashFormat ( NUTDEVICE* dev, NUTSERIALFLASH* sfi, NUTSPIBUS* bus )
Prototyped in: nut/include/fs/uflashfs.h
Calls: FlashEraseBlocks() nut/fs/uflashfs.c
  NutEventPost()

Local Function CollectLeastUsed()

static void CollectLeastUsed ( UFLASHVOLUME* vol, uint8_t* usage )
Calls: memset() nut/c/string/memset.c
Called by: PhysBlkAllocate() nut/fs/uflashfs.c
References Variables: min_used nut/fs/uflashfs.c

Local Function EntryCreate()

static int EntryCreate ( UFLASHVOLUME* vol, blknum_t lbe, ENTRYHEAD* eh, const char* name )
Calls: FlashEraseBlockData() nut/fs/uflashfs.c
  FlashReadBlockFoot() nut/fs/uflashfs.c
  FlashUnitCommit() nut/fs/uflashfs.c
  FlashWriteBlockFoot() nut/fs/uflashfs.c
  FlashWriteBlockHead() nut/fs/uflashfs.c
  FlashWriteEntry() nut/fs/uflashfs.c
Called by: UFlashFileOpen() nut/fs/uflashfs.c

Local Function EntryPosInc()

static void EntryPosInc ( NUTFILE* nfp, int step )
Called by: UFlashFileRead() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c

Local Function EntryPosSet()

static void EntryPosSet ( NUTFILE* nfp, long pos )
Called by: UFlashFileOpen() nut/fs/uflashfs.c
  UFlashFileSeek() nut/fs/uflashfs.c

Local Function EntryScan()

static long EntryScan ( UFLASHVOLUME* vol, blknum_t lbe, time_t* mod )
Calls: FlashReadBlockHead() nut/fs/uflashfs.c
Called by: UFlashFileOpen() nut/fs/uflashfs.c
  UFlashFileStatus() nut/fs/uflashfs.c

Local Function EntrySearch()

static int EntrySearch ( UFLASHVOLUME* vol, const char* name, ENTRYHEAD* eh )
Calls: EntrySearchNext() nut/fs/uflashfs.c
Called by: UFlashFileOpen() nut/fs/uflashfs.c
  UFlashFileRemove() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c
  UFlashFileStatus() nut/fs/uflashfs.c

Local Function EntrySearchNext()

static int EntrySearchNext ( UFLASHVOLUME* vol, const char* name, ENTRYHEAD* eh, blknum_t lbs )
Calls: FlashBlockCmpEntryName() nut/fs/uflashfs.c
  FlashReadEntry() nut/fs/uflashfs.c
  strlen() nut/c/string/strlen.c
  NutEventPost(), NutEventWait()
Called by: EntrySearch() nut/fs/uflashfs.c
  UFlashDirRead() nut/fs/uflashfs.c
  UFlashFileStatus() nut/fs/uflashfs.c

Local Function EntrySeek()

static blknum_t EntrySeek ( UFLASHVOLUME* vol, blknum_t lbe, blknum_t seq )
Calls: FlashReadBlockHead() nut/fs/uflashfs.c
  NutEventPost(), NutEventWait()
Called by: UFlashFileRead() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c

Local Function EntryTruncate()

static int EntryTruncate ( UFLASHVOLUME* vol, blknum_t lbe )
Calls: EntryTruncateSeq() nut/fs/uflashfs.c
  FlashEraseBlockData() nut/fs/uflashfs.c
  FlashEraseEntry() nut/fs/uflashfs.c
  FlashReadBlockFoot() nut/fs/uflashfs.c
  FlashReadBlockHead() nut/fs/uflashfs.c
  FlashReadEntry() nut/fs/uflashfs.c
  FlashUnitCommit() nut/fs/uflashfs.c
  FlashWriteBlockFoot() nut/fs/uflashfs.c
  FlashWriteBlockHead() nut/fs/uflashfs.c
  FlashWriteEntry() nut/fs/uflashfs.c
  PhysBlkAllocate() nut/fs/uflashfs.c
  free() nut/crt/malloc.c
Called by: UFlashFileOpen() nut/fs/uflashfs.c

Local Function EntryTruncateSeq()

static int EntryTruncateSeq ( UFLASHVOLUME* vol, int lbe )
Calls: FlashReadBlockHead() nut/fs/uflashfs.c
  LogBlkRelease() nut/fs/uflashfs.c
Called by: EntryTruncate() nut/fs/uflashfs.c
  UFlashFileRemove() nut/fs/uflashfs.c

Local Function FlashBlockCmpEntryName()

static int FlashBlockCmpEntryName ( NUTSERIALFLASH* ifc, blknum_t b, const char* name, uint8_t len )
Called by: EntrySearchNext() nut/fs/uflashfs.c

Local Function FlashCheckBlock()

static int FlashCheckBlock ( NUTSERIALFLASH* ifc, blknum_t b )
Called by: UFlashMount() nut/fs/uflashfs.c

Local Function FlashEraseBlockData()

static int FlashEraseBlockData ( NUTSERIALFLASH* ifc, blknum_t b )
Called by: EntryCreate() nut/fs/uflashfs.c
  EntryTruncate() nut/fs/uflashfs.c
  PhysBlkMove() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c

Local Function FlashEraseBlocks()

static int FlashEraseBlocks ( NUTSERIALFLASH* ifc, int n )
Called by: UFlashFormat() nut/fs/uflashfs.c

Local Function FlashEraseEntry()

static int FlashEraseEntry ( NUTSERIALFLASH* ifc, blknum_t b )
Called by: EntryTruncate() nut/fs/uflashfs.c
  LogBlkRelease() nut/fs/uflashfs.c
  PhysBlkMove() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c
  UFlashMount() nut/fs/uflashfs.c

Local Function FlashReadBlockFoot()

static int FlashReadBlockFoot ( NUTSERIALFLASH* ifc, blknum_t b, BLOCKFOOT* bf )
Called by: EntryCreate() nut/fs/uflashfs.c
  EntryTruncate() nut/fs/uflashfs.c
  PhysBlkAllocate() nut/fs/uflashfs.c
  PhysBlkMove() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c

Local Function FlashReadBlockHead()

static int FlashReadBlockHead ( NUTSERIALFLASH* ifc, blknum_t b, BLOCKHEAD* bh )
Called by: EntryScan() nut/fs/uflashfs.c
  EntrySeek() nut/fs/uflashfs.c
  EntryTruncate() nut/fs/uflashfs.c
  EntryTruncateSeq() nut/fs/uflashfs.c
  PhysBlkMove() nut/fs/uflashfs.c
  PhysBlkUnused() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c
  UFlashMount() nut/fs/uflashfs.c

Local Function FlashReadEntry()

static int FlashReadEntry ( NUTSERIALFLASH* ifc, blknum_t b, ENTRYHEAD* eh, char** name )
Calls: malloc() nut/crt/malloc.c
Called by: EntrySearchNext() nut/fs/uflashfs.c
  EntryTruncate() nut/fs/uflashfs.c
  UFlashDirRead() nut/fs/uflashfs.c

Local Function FlashUnitCommit()

static void FlashUnitCommit ( NUTSERIALFLASH* ifc, blknum_t b, sf_unit_t unit )
Called by: EntryCreate() nut/fs/uflashfs.c
  EntryTruncate() nut/fs/uflashfs.c
  PhysBlkMove() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c

Local Function FlashUnitCopy()

static int FlashUnitCopy ( NUTSERIALFLASH* ifc, blknum_t b_src, blknum_t b_dst, sf_unit_t unit )
Called by: PhysBlkMove() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c

Local Function FlashUnitRead()

static int FlashUnitRead ( NUTSERIALFLASH* ifc, blknum_t b, sf_unit_t unit, int upos, void* data, int len )
Called by: UFlashFileRead() nut/fs/uflashfs.c

Local Function FlashUnitWrite()

static int FlashUnitWrite ( NUTSERIALFLASH* ifc, blknum_t b, sf_unit_t unit, int upos, const void* data, int len )
Called by: UFlashFileWrite() nut/fs/uflashfs.c

Local Function FlashWriteBlockFoot()

static int FlashWriteBlockFoot ( NUTSERIALFLASH* ifc, blknum_t b, BLOCKFOOT* bf )
Called by: EntryCreate() nut/fs/uflashfs.c
  EntryTruncate() nut/fs/uflashfs.c
  PhysBlkMove() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c

Local Function FlashWriteBlockHead()

static int FlashWriteBlockHead ( NUTSERIALFLASH* ifc, blknum_t b, BLOCKHEAD* bh )
Called by: EntryCreate() nut/fs/uflashfs.c
  EntryTruncate() nut/fs/uflashfs.c
  PhysBlkMove() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c

Local Function FlashWriteEntry()

static int FlashWriteEntry ( NUTSERIALFLASH* ifc, blknum_t b, const ENTRYHEAD* eh, const char* name )
Called by: EntryCreate() nut/fs/uflashfs.c
  EntryTruncate() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c

Local Function LogBlkAllocate()

static blknum_t LogBlkAllocate ( UFLASHVOLUME* vol, blknum_t lb )
Calls: PhysBlkAllocate() nut/fs/uflashfs.c
Called by: UFlashFileOpen() nut/fs/uflashfs.c
  UFlashFileWrite() nut/fs/uflashfs.c

Local Function LogBlkReallocate()

static blknum_t LogBlkReallocate ( UFLASHVOLUME* vol, blknum_t lb )
Calls: PhysBlkAllocate() nut/fs/uflashfs.c
Called by: UFlashFileWrite() nut/fs/uflashfs.c

Local Function LogBlkRelease()

static int LogBlkRelease ( UFLASHVOLUME* vol, blknum_t lb )
Calls: FlashEraseEntry() nut/fs/uflashfs.c
Called by: EntryTruncateSeq() nut/fs/uflashfs.c
  UFlashFileRemove() nut/fs/uflashfs.c

Local Function PhysBlkAllocate()

static blknum_t PhysBlkAllocate ( UFLASHVOLUME* vol, int level )
Prototyped in: nut/fs/uflashfs.c
Calls: CollectLeastUsed() nut/fs/uflashfs.c
  FlashReadBlockFoot() nut/fs/uflashfs.c
  PhysBlkRequest() nut/fs/uflashfs.c
  PhysBlkUnused() nut/fs/uflashfs.c
  free() nut/crt/malloc.c
  calloc()
Called by: EntryTruncate() nut/fs/uflashfs.c
  LogBlkAllocate() nut/fs/uflashfs.c
  LogBlkReallocate() nut/fs/uflashfs.c
  PhysBlkRequest() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c
References Variables: min_used nut/fs/uflashfs.c

Local Function PhysBlkMove()

static int PhysBlkMove ( UFLASHVOLUME* vol, blknum_t src, blknum_t dst )
Calls: FlashEraseBlockData() nut/fs/uflashfs.c
  FlashEraseEntry() nut/fs/uflashfs.c
  FlashReadBlockFoot() nut/fs/uflashfs.c
  FlashReadBlockHead() nut/fs/uflashfs.c
  FlashUnitCommit() nut/fs/uflashfs.c
  FlashUnitCopy() nut/fs/uflashfs.c
  FlashWriteBlockFoot() nut/fs/uflashfs.c
  FlashWriteBlockHead() nut/fs/uflashfs.c
Called by: PhysBlkRequest() nut/fs/uflashfs.c

Local Function PhysBlkRequest()

static int PhysBlkRequest ( UFLASHVOLUME* vol, int level, blknum_t n )
Calls: PhysBlkAllocate() nut/fs/uflashfs.c
  PhysBlkMove() nut/fs/uflashfs.c
Called by: PhysBlkAllocate() nut/fs/uflashfs.c

Local Function PhysBlkUnused()

static blknum_t PhysBlkUnused ( UFLASHVOLUME* vol )
Calls: FlashReadBlockHead() nut/fs/uflashfs.c
Called by: PhysBlkAllocate() nut/fs/uflashfs.c

Local Function UFlashDirClose()

static int UFlashDirClose ( NUTFILE* ndp )
Calls: free() nut/crt/malloc.c
Called by: UFlashIOCtl() nut/fs/uflashfs.c

Local Function UFlashDirOpen()

static NUTFILE* UFlashDirOpen ( NUTDEVICE* dev, const char* dpath )
Calls: free() nut/crt/malloc.c
  malloc() nut/crt/malloc.c
  strdup() nut/crt/strdup.c
Called by: UFlashIOCtl() nut/fs/uflashfs.c

Local Function UFlashDirRead()

static int UFlashDirRead ( DIR* dir )
Calls: EntrySearchNext() nut/fs/uflashfs.c
  FlashReadEntry() nut/fs/uflashfs.c
  free() nut/crt/malloc.c
  memset() nut/c/string/memset.c
  strchr() nut/c/string/strchr.c
  strcpy() nut/c/string/strcpy.c
  strlen() nut/c/string/strlen.c
Called by: UFlashIOCtl() nut/fs/uflashfs.c

Local Function UFlashFileClose()

static int UFlashFileClose ( NUTFILE* nfp )
Calls: free() nut/crt/malloc.c
Used in:   nut/fs/uflashfs.c

Local Function UFlashFileOpen()

static NUTFILE* UFlashFileOpen ( NUTDEVICE* dev, const char* path, int mode, int acc )
Calls: EntryCreate() nut/fs/uflashfs.c
  EntryPosSet() nut/fs/uflashfs.c
  EntryScan() nut/fs/uflashfs.c
  EntrySearch() nut/fs/uflashfs.c
  EntryTruncate() nut/fs/uflashfs.c
  LogBlkAllocate() nut/fs/uflashfs.c
  free() nut/crt/malloc.c
  malloc() nut/crt/malloc.c
  strlen() nut/c/string/strlen.c
  NutEventPost(), NutEventWait(), calloc()
Used in:   nut/fs/uflashfs.c

Local Function UFlashFileRead()

static int UFlashFileRead ( NUTFILE* nfp, void* data, int size )
Calls: EntryPosInc() nut/fs/uflashfs.c
  EntrySeek() nut/fs/uflashfs.c
  FlashUnitRead() nut/fs/uflashfs.c
  NutEventPost(), NutEventWait()
Used in:   nut/fs/uflashfs.c

Local Function UFlashFileRemove()

static int UFlashFileRemove ( NUTDEVICE* dev, const char* name )
Calls: EntrySearch() nut/fs/uflashfs.c
  EntryTruncateSeq() nut/fs/uflashfs.c
  LogBlkRelease() nut/fs/uflashfs.c
  NutEventPost(), NutEventWait()
Called by: UFlashIOCtl() nut/fs/uflashfs.c

Local Function UFlashFileRename()

static int UFlashFileRename ( NUTDEVICE* dev, const char* old_path, const char* new_path )
Calls: EntrySearch() nut/fs/uflashfs.c
  FlashEraseBlockData() nut/fs/uflashfs.c
  FlashEraseEntry() nut/fs/uflashfs.c
  FlashReadBlockFoot() nut/fs/uflashfs.c
  FlashReadBlockHead() nut/fs/uflashfs.c
  FlashUnitCommit() nut/fs/uflashfs.c
  FlashUnitCopy() nut/fs/uflashfs.c
  FlashWriteBlockFoot() nut/fs/uflashfs.c
  FlashWriteBlockHead() nut/fs/uflashfs.c
  FlashWriteEntry() nut/fs/uflashfs.c
  PhysBlkAllocate() nut/fs/uflashfs.c
  strlen() nut/c/string/strlen.c
  NutEventPost(), NutEventWait()
Called by: UFlashIOCtl() nut/fs/uflashfs.c

Local Function UFlashFileSeek()

static int UFlashFileSeek ( NUTFILE* nfp, long* pos, int whence )
Calls: EntryPosSet() nut/fs/uflashfs.c
Called by: UFlashIOCtl() nut/fs/uflashfs.c

Local Function UFlashFileSize()

static long UFlashFileSize ( NUTFILE* nfp )
Used in:   nut/fs/uflashfs.c

Local Function UFlashFileStatus()

static int UFlashFileStatus ( NUTDEVICE* dev, const char* name, struct stat* st )
Calls: EntryScan() nut/fs/uflashfs.c
  EntrySearch() nut/fs/uflashfs.c
  EntrySearchNext() nut/fs/uflashfs.c
  memset() nut/c/string/memset.c
  NutEventPost(), NutEventWait()
Called by: UFlashIOCtl() nut/fs/uflashfs.c

Local Function UFlashFileWrite()

static int UFlashFileWrite ( NUTFILE* nfp, const void* data, int len )
Calls: EntryPosInc() nut/fs/uflashfs.c
  EntrySeek() nut/fs/uflashfs.c
  FlashEraseBlockData() nut/fs/uflashfs.c
  FlashEraseEntry() nut/fs/uflashfs.c
  FlashReadBlockFoot() nut/fs/uflashfs.c
  FlashReadBlockHead() nut/fs/uflashfs.c
  FlashUnitCommit() nut/fs/uflashfs.c
  FlashUnitCopy() nut/fs/uflashfs.c
  FlashUnitWrite() nut/fs/uflashfs.c
  FlashWriteBlockFoot() nut/fs/uflashfs.c
  FlashWriteBlockHead() nut/fs/uflashfs.c
  LogBlkAllocate() nut/fs/uflashfs.c
  LogBlkReallocate() nut/fs/uflashfs.c
  NutEventPost(), NutEventWait()
Used in:   nut/fs/uflashfs.c

Local Function UFlashFileWrite_P()

static int UFlashFileWrite_P ( NUTFILE* nfp, const char* buffer, int len )
Used in:   nut/fs/uflashfs.c

Local Function UFlashIOCtl()

static int UFlashIOCtl ( NUTDEVICE* dev, int req, void* conf )
Calls: UFlashDirClose() nut/fs/uflashfs.c
  UFlashDirOpen() nut/fs/uflashfs.c
  UFlashDirRead() nut/fs/uflashfs.c
  UFlashFileRemove() nut/fs/uflashfs.c
  UFlashFileRename() nut/fs/uflashfs.c
  UFlashFileSeek() nut/fs/uflashfs.c
  UFlashFileStatus() nut/fs/uflashfs.c
  UFlashMount() nut/fs/uflashfs.c
  UFlashUnmount() nut/fs/uflashfs.c
Used in:   nut/fs/uflashfs.c

Local Function UFlashInit()

static int UFlashInit ( NUTDEVICE* dev )
Used in:   nut/fs/uflashfs.c

Local Function UFlashMount()

static int UFlashMount ( NUTDEVICE* dev )
Calls: FlashCheckBlock() nut/fs/uflashfs.c
  FlashEraseEntry() nut/fs/uflashfs.c
  FlashReadBlockHead() nut/fs/uflashfs.c
  free() nut/crt/malloc.c
  malloc() nut/crt/malloc.c
  memset() nut/c/string/memset.c
  NutEventPost(), calloc()
Called by: UFlashAttach() nut/fs/uflashfs.c
  UFlashIOCtl() nut/fs/uflashfs.c
References Variables: min_used nut/fs/uflashfs.c

Local Function UFlashUnmount()

static int UFlashUnmount ( NUTDEVICE* dev )
Calls: free() nut/crt/malloc.c
Called by: UFlashDetach() nut/fs/uflashfs.c
  UFlashIOCtl() nut/fs/uflashfs.c