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

📄 ffs.h

📁 AMD公司官方版FLASH文件系统。有详细说明文档和Windows仿真测试环境。
💻 H
字号:
/**
 *
 * FFS.H 
 * Description: Main storage area for structures
 *
 */

#ifndef _FFS_H_
#define _FFS_H_

#ifdef cplusplus
extern "C"
{
#endif

#ifndef NULL
    #define NULL (0)
#endif

#define offsetof(s,m)    (unsigned int)&(((s *)0)->m)


typedef unsigned char  BYTE;
typedef unsigned short WORD;
typedef unsigned long  DWORD;


#define MAX_WORD                        (0xFFFF)
#define MAX_BYTE                        (0xFF)
#define RESERVED_HEADER_SPACE_SIZE      (6)
#define DATABLOCK_SIZE                  (100) 

typedef enum {
    No_Error = 0, 
    Dms_Not_Initialized,            /* ...*/
    No_Available_Blocks,            /* ...Returned by BlockAlloc when block count is less than min */
    Invalid_Sector_Count,           /* ...Two or more sectors are required by dms */
    Invalid_Sector_Size,            /* ...A sector is smaller than the min required size */
    Sector_Address_Overlap,         /* ...Sector address of two or more sectors overlap */
    Sector_Invalid_Address,         /* ...Address is not within defined DeviceArchecture */
    Cannot_Obtain_Cell_Count,       /* ...Couldn't get the cell count for the FFS */ 
    No_Garbage_Blocks,              /* ...Returned when requesting to get a sector */
                                    /*    to erase and there are no garbage blocks in any sectors */
    Invalid_Arguments_Error,        /* ...Arguments were passed in invalid */ 
    Invalid_Cell_Status,            /* ...Returned during Initialization when a cell status is invalid */ 
    Sector_Initialization_Failed,   /* ...Returned when after formating a sector is still has an */
                                    /*    invalid header status */
    Duplicate_Block,                /* ...Returned by and internal function durring initialization. */
    Exact_Duplicate_Block,          /* ...Returned by and internal function durring initialization. */
                                    /* ...The difference between the two is a matching cell status. */
    More_Than_Two_Dirty_Cells,      /* ...Returned durring CellInitialize. */
    Not_Enough_Free_Blocks,         /* ...Returned at initialization.  */
    Cell_Already_In_Process,        /* ...Returned durring Initialization if the DMS contained more */
                                    /*    than one cell that appears to have been in process. */
    Block_Already_In_Process,       /* ...Returned durring Initialization if the DMS contained more */
                                    /*    than one block that appears to have been in process not */
                                    /*    including the cell in process. */
    Block_Not_Found,                /* ...Internal Error. */
    Missing_Block_In_Cell,          /* ...Returned at initialization durring cell check */
    Out_Of_Memory_Error,            /* ...Out of Memory Error */ 
    Uneven_Cell_Size,               /* ...A cell size wasn't an even multiple of DATABLOCK_SIZE */ 
    Cell_Size_Too_Small,            /* ...A cell sent to the Format or from the Initialize function was too small */ 
    Read_Sector_Header_Error,       /* ...Error while trying to read an sector header */ 
    Total_Cell_Size_Too_Large,      /* ...Total of Cell Sizes was larger than available space on device */ 
    Device_Not_Busy,                /* ...The Device Is Not Busy (Not really an error) */
    Device_Confused,                /* ...The device seems to be in a confused state */
	Device_Memory_Map_Error,	    /* ...Unable to perform Memory Map Operation */
	Device_Erase_In_Progress,	    /* ...An Erase Is In Progress (Not really an error)*/
	Device_Invalid_Data,		    /* ...The data being writtin the device is invalid */
	Device_Write_Failed,      	    /* ...The Device Write Failed */
    Write_Count_Zero                /* ...Used durring debug to simulate power loss */
} DMS_STATUS;    


 
typedef enum {
    BlockAvailable    = 0xFF, 
    BlockBeingWritten = 0xFE,
    BlockValid        = 0xFC, 
    BlockErase        = 0xF0 
} DMS_BLOCK_STATUS;
 
typedef enum {
    CellValid1 = 0xFF, 
    CellValid2 = 0xFC, 
    CellErase  = 0xF0 
} DMS_CELL_STATUS;

 
typedef enum {
    HeaderEmpty        = 0xFF, 
    HeaderBeingWritten = 0xFE,
    HeaderValid        = 0xFC, 
    HeaderErase        = 0x00 
} DMS_HEADER_STATUS;

 
typedef struct CELL_TABLE_ENTRY_type
{
    WORD wBlockIndex;
    BYTE bCellStatus;
    WORD wSectorIndex;
    WORD wSectorBlockIndex;
    struct CELL_TABLE_ENTRY_type *pNext;
} CELL_TABLE_ENTRY;
 
typedef struct DATABLOCK
{
    BYTE bData[DATABLOCK_SIZE];
} DATABLOCK;
 
/**
 * SECTOR_DESCRIPTOR
 * Used to define the architecture of the flash system.
 * The dms requires a global variable of type and name
 *   as follows:
 *   SECTOR_DESCRIPTIOR gpDeviceArchitecture[];
 *   This is and array of structures where each element
 *   represents the starting address of a sector and
 *   the size of the sector.  To denote the last element
 *   in the array the address and size should must be
 *   zero.  There should be one element for each sector
 *   to be used in the DMS plus the last zero terminating
 *   element.
 *   See Dms.h for more information.
 */
typedef struct
{
    DWORD    dwAddress;
    DWORD    dwSize;
}SECTOR_DESCRIPTIOR;
 
typedef struct
{
    WORD wSectorNumber;
    BYTE bHeaderStatus;
    DWORD dwSize;
    WORD wCellCount;
    WORD wDataBlockCountInThisSector;
    BYTE bReserved[RESERVED_HEADER_SPACE_SIZE];
} SECTOR_HEADER;
 

#ifdef cplusplus
} /* #ifdef cplusplus */
#endif

#endif /*  _FFS_H_  */

⌨️ 快捷键说明

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