⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fs_int.h

📁 嵌入式文件系统 ucfs.包含全部源代码
💻 H
字号:
/*
**********************************************************************
*                          Micrium, Inc.
*                      949 Crestview Circle
*                     Weston,  FL 33327-1848
*
*                            uC/FS
*
*             (c) Copyright 2001 - 2003, Micrium, Inc.
*                      All rights reserved.
*
***********************************************************************

----------------------------------------------------------------------
File        : fs_int.h 
Purpose     : Internals used accross different layers of the file system
---------------------------END-OF-HEADER------------------------------
*/

#ifndef _FS_INT_H_
#define _FS_INT_H_


#include "FS_Debug.h"
#include "FS_ConfDefaults.h"        /* FS Configuration */

#if defined(__cplusplus)
extern "C" {     /* Make sure we have C-declarations in C++ programs */
#endif



/*********************************************************************
*
*             Global data types
*
**********************************************************************
*/

#define FS_COUNTOF(a) (sizeof(a) / sizeof(a[0]))

/*********************************************************************
*
*       Defines non configurable
*
**********************************************************************
*/
#define FS_DIRENTRY_GET_ATTRIBUTES    (1 << 0)
#define FS_DIRENTRY_GET_TIMESTAMP     (1 << 1)



#define FS_DIRENTRY_SET_ATTRIBUTES    (1 << 0)
#define FS_DIRENTRY_SET_TIMESTAMP     (1 << 1)



/* BIOS parameter block (FAT12/FAT16) */
typedef struct {
  FS_U32          NumSectors;       /* RSVD + FAT + ROOT + FATA       */
  FS_U32          FATSize;          /* number of FAT sectors          */
  FS_U32          RootDirPos;       /* Position of root directory. FAT32: Cluster, FAT12/16: Sector */
  FS_U32          BytesPerCluster;
  FS_U16          BytesPerSec;      /* _512_,1024,2048,4096           */
  FS_U16          ldBytesPerSector; /* 9, 10, 11, 12               */
  FS_U16          RootEntCnt;          /* number of root dir entries     */
  FS_U16          RsvdSecCnt;       /* 1 for FAT12 & FAT16            */
  FS_U8           SecPerClus;       /* sec in allocation unit         */
  FS_U8           NumFATs;          /* 2                              */
  FS_U8           FATType;
  FS_U32          NumClusters;
  FS_U32          FirstDataSector;
} FS_FAT_INFO;

typedef struct {
  FS_U32          NumSectors;          /* Total number of sectors on the medium */
  FS_U32          NumClusters;
  FS_U32          BytesPerCluster;
  FS_U16          BytesPerSector;      /* _512_,1024,2048,4096           */
  FS_U32          FirstDataSector;
  FS_U8           SectorsPerCluster;   /* Number of Sectors in allocation unit         */
  FS_U8           ldBytesPerCluster;
  FS_U16          ldBytesPerSector;    /* 9, 10, 11, 12               */
} FS_EFS_INFO;


typedef union {
  FS_FAT_INFO  FATInfo;
  FS_EFS_INFO  EFSInfo;
} FS_INFO;

typedef struct {
  FS_DEVICE   Device;
  FS_U32      StartSector;
} FS_PARTITION;

typedef struct {
  FS_PARTITION Partition;
  FS_INFO      FSInfo;
  FS_U8        PartitionIndex;
  FS_U8        IsMounted;
/*FS_FS_TYPE ... To be added with multiple FS support */
} FS_VOLUME;


/* FS Sector Buffer */
typedef struct {
  FS_I32 SectorNo;
  FS_PARTITION * pPart;
  FS_U8 * pBuffer;
  char   IsDirty;
  char   HasError;
} FS_SB;

void FS_SB_Clean    (FS_SB * pSB);
char FS_SB_Create   (FS_SB * pSB, FS_PARTITION *pPart);
void FS_SB_Delete   (FS_SB * pSB);
void FS_SB_Flush    (FS_SB * pSB);
void FS_SB_MarkDirty(FS_SB * pSB);
void FS_SB_MarkValid(FS_SB * pSB, FS_I32 SectorNo);
char FS_SB_Read     (FS_SB * pSB, FS_I32 SectorNo);
char FS_SB_WriteAt  (FS_SB * pSB, FS_I32 SectorNo);

FS_U8 * FS_AllocSectorBuffer(void);
void    FS_FreeSectorBuffer  (void * p);

const char *   FS_strchr  (const char *s, int c);

FS_VOLUME * FS_FindVolume(const char *pFullName, const char ** pFileName);

#if defined(__cplusplus)
}                /* Make sure we have C-declarations in C++ programs */
#endif


#endif  /* _FS_INT_H_ */

/*************************** End of file ****************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -