📄 ffs_nand.h.bak
字号:
/****************************************************************
;* *
;* INSTUTITE FOR INFORMATION INDUSTRY *
;* FFS HEADER -- FFS *
;* July 22, 1999 *
;* *
;****************************************************************/
#ifndef _FFS_NAND_H
#define _FFS_NAND_H
/**************************************************************
C++ SUPPORT
**************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _PROCOMP_
// #include "/rtos/driver/FileSys/FileSys.h"
#include "/rtos/driver/FileSys/include/FileSys.h"
#else
// #include "../../FileSys/FileSys.h"
#include "../../FileSys/include/FileSys.h"
#endif // #ifdef _PROCOMP_
/**** added by chilong 12/20/2001 temporarily ****/
//#define NAND_FLASH_DISK_ID 1
/**** added by chilong 12/20/2001 temporarily ****/
/**************************************************************
;* *
;* Gloabal Definitions *
;* *
;*************************************************************/
//#define NAND_FFS_DEBUG
//jason #define NAND_FFS_USE_CACHE
//jason #define NAND_FFS_CACHE_DEBUG
//**********************************
#define NAND_FFS_START_BLOCK 512 // the starting block number of FFS_NAND
#define NAND_FFS_BLOCK_NUM (1024 - NAND_FFS_START_BLOCK) // the number of flash blocks
// The maximum NAND flash size was 120 M
// (120M / 16k = 8192 )
#define NAND_FLASH_BLOCK_SIZE 16384 // The flash block size should be
// same with NAND flash memory
// Block erase size
#define NAND_LUMP_SIZE 8192 // the lump size
//************************************
//#define NAND_FFS_START_BLOCK 512 // the starting block number of FFS_NAND
//#define NAND_FFS_BLOCK_NUM 128 // the number of flash blocks
//#define NAND_FFS_BLOCK_NUM 256 // the number of flash blocks
/*
#define NAND_FLASH_BLOCK_SIZE 4096 // the flash block size
#define NAND_LUMP_SIZE 4096 // the lump size
*/
/**** modified by chilong 01/12/2002 ****/
//#define NAND_FLASH_BLOCK_SIZE 16384 // the flash block size
//#define NAND_LUMP_SIZE 4096 // the lump size
/**** modified by chilong 01/12/2002 ****/
// NAND_FLASH_BLOCK_SIZE 512 defined in nflash.h
//#define NAND_FLASH_BLOCK_SIZE 4096 // the flash block size
//#define NAND_LUMP_SIZE 512 // the lump size
#define NAND_FFS_NAME_LEN 51 // the max length of an application name
#define NAND_FFS_END_OF_NAME 0xFF // the un-used chars of a name shorter than 64 chars
/**** added by chilong 12/25/2001 ****/
#define NAND_MAX_PATH_LENGTH (2*NAND_FFS_NAME_LEN)
#define LUMP_DATA_SIZE (NAND_LUMP_SIZE - sizeof(struct NAND_diskLump))
#define L_HEADER (sizeof(struct NAND_diskLump))
/**** added by chilong 12/25/2001 ****/
#ifdef NAND_FFS_USE_CACHE
// #define NAND_FFS_CACHE_BASE_ADDRESS 0x001EC000L // cache location
#define NAND_FFS_CACHE_BASE_ADDRESS 0x80FAF000
#define NAND_FFS_CACHE_BLOCK_NUM 16 // number of lumps that can be cached at the same time
#define NAND_FFS_DIRTY_BIT_MASK 0x00000001L // the dirty bit mask (MSb in an integer)
#endif
// lump types (unsigned int)
/* marked by chilong 12/25/2001
#define NAND_LUMP_TYPE_START 0x00000000 // the first byte of an used block is 0x00
// or 1st char of AP name if it is the starting block
#define NAND_LUMP_TYPE_OTHER 0x00000001 // the first byte of an empty block is 0xFF
#define NAND_LUMP_TYPE_FREE 0xFFFFFFFF // this lump is unused
marked by chilong 12/25/2001 */
/**** modified by chilong 12/25/2001 ****/
#define NAND_LUMP_TYPE_DIR 0x00000000 // the first byte of an used block is 0x00
// or 1st char of AP name if it is the starting block
#define NAND_LUMP_TYPE_FILE 0x00000001 // the first byte of an empty block is 0xFF
/**** added by chilong 01/19/2002 ****/
#define NAND_LUMP_TYPE_ROOT 0x00000002 // only root lump can has this type
/**** added by chilong 01/19/2002 ****/
#define NAND_LUMP_TYPE_FREE 0xFFFFFFFF // this lump is unused
/**** modified by chilong 12/25/2001 ****/
#define NAND_END_LUMP (-1) // the ending lump
/**** added by chilong 12/21/2001 ****/
#define DELETED_ENTRY (0xe5) /* file/directory is deleted */
// chilong: NAND_FREE_ENTRY is different from RAMDISK & fat because
// after a block is erased, all bytes are set to 0xff.
#define NAND_FREE_ENTRY (0xff) /* entry was never in use */
/**** added by chilong 12/21/2001 ****/
//#define NAND_BLOCK_FULL_BIT_MASK 0x80000000
/*
// operation code
#define NAND_FFS_ERASE 0
#define NAND_FFS_PROGRAM 1
*/
// flash block status
#define NAND_FB_UNUSED 0
#define NAND_FB_OK 1
#define NAND_FB_FULL 2
// error bits for NAND_FFS_scanDisk
#define ERR_SYSTEM 0x80
#define ERR_AP 0x01
#define ERR_USED_BLOCK 0x02
#define NAND_FFS_VERSION "NAND Flash Disk version 2.0"
/****************************************************************
* Structures *
****************************************************************/
/* marked by chilong 12/20/2001
// the header of a starting lump
#ifndef MACHINE_TYPE_X86P
struct NAND_diskLump
{
unsigned int type; // lump type
unsigned long dataSize; // size of data in this lump
unsigned short updateDate; // last update date of this lump
unsigned short updateTime; // last update time of this lump
int nextLump; // next lump
unsigned short createDate; // file creation date
unsigned short createTime; // file creation time
unsigned char name[NAND_FFS_NAME_LEN]; // filename
};
#else
struct NAND_diskLump
{
unsigned int type __attribute__((packed));
unsigned long dataSize __attribute__((packed));
unsigned short updateDate __attribute__((packed));
unsigned short updateTime __attribute__((packed));
int nextLump __attribute__((packed));
unsigned short createDate __attribute__((packed));
unsigned short createTime __attribute__((packed));
unsigned char name[NAND_FFS_NAME_LEN] __attribute__((packed));
};
#endif // #ifndef MACHINE_TYPE_X86P
// the header of lumps other than the starting lump
#ifndef MACHINE_TYPE_X86P
struct NAND_diskLump
{
unsigned int type; // lump type
unsigned long dataSize; // size of data in this lump
unsigned short updateDate; // last update date of this lump
unsigned short updateTime; // last update time of this lump
int nextLump; // next lump
};
#else
struct NAND_diskLump
{
unsigned int type __attribute__((packed));
unsigned long dataSize __attribute__((packed));
unsigned short updateDate __attribute__((packed));
unsigned short updateTime __attribute__((packed));
int nextLump __attribute__((packed));
};
#endif // #ifndef MACHINE_TYPE_X86P
#define NAND_LUMP_START_HEADER_SIZE (sizeof(struct NAND_diskLump))
#define NAND_LUMP_OTHER_HEADER_SIZE (sizeof(struct NAND_diskLump))
#define NAND_LUMP_START_DATA_SIZE (NAND_LUMP_SIZE - sizeof(struct NAND_diskLump))
#define NAND_LUMP_OTHER_DATA_SIZE (NAND_LUMP_SIZE - sizeof(struct NAND_diskLump))
marked by chilong 12/20/2001 */
/**** modified by chilong 12/20/2001 ****/
// the header of a starting lump
#ifndef MACHINE_TYPE_X86P
struct NAND_diskLump
{
unsigned int type;
int prevLump;
int nextLump;
unsigned long size;
unsigned long actualSize;
// unsigned short status;
// unsigned short userCount;
};
#else
struct NAND_diskLump
{
unsigned int type;
int prevLump __attribute__((packed));
int nextLump __attribute__((packed));
unsigned long size __attribute__((packed));
unsigned long actualSize __attribute__((packed));
// unsigned short status;
// unsigned short userCount __attribute__((packed));
};
#endif // #ifndef MACHINE_TYPE_X86P
/**** modified by chilong 12/20/2001 ****/
/**** added by chilong 12/19/2001 ****/
#ifndef MACHINE_TYPE_X86P
struct NAND_directory
{
unsigned char name[NAND_FFS_NAME_LEN]; // file name
unsigned char attribute; // file attribute
unsigned short time; // file creation time
unsigned short date; // file creation date
int startLump; // the starting disk block of the file
long fsize; // file size
};
#else
struct NAND_directory
{
unsigned char name[NAND_FFS_NAME_LEN] __attribute__ ((packed));
unsigned char attribute __attribute__ ((packed));
unsigned short time __attribute__ ((packed));
unsigned short date __attribute__ ((packed));
int startLump __attribute__ ((packed));
long fsize __attribute__ ((packed));
};
#endif // MACHINE_TYPE_M68EZ328
/**** added by chilong 12/19/2001 ****/
/* marked by chilong 12/20/2001
struct NAND_FFS_FILE
{
short deviceID; // device ID
int handle; // file handle
int headLump; // the starting block of the file
int currentLump; // Last block for later updating; if it is 0,
// the block should be searched before accessing;
// otherwise, it is the one pointed by file position
long fpos; // Absolute file position in a file
unsigned long size; // size of the file
int ownerID; // the owner thread ID
};
// internal data structure for findfirst, findnext, findclose
#ifndef MACHINE_TYPE_X86P
struct NAND_FFS_ffInternal
{
unsigned char attrib;
int lump;
unsigned char wildname[NAND_FFS_NAME_LEN]; // found file name
};
#else
struct NAND_FFS_ffInternal
{
unsigned char attrib __attribute__((packed));
int lump __attribute__((packed));
unsigned char wildname[NAND_FFS_NAME_LEN] __attribute__((packed)); // found file name
};
#endif // #ifndef MACHINE_TYPE_X86P
marked by chilong 12/20/2001 */
/**** modified by chilong 12/20/2001 ****/
struct NAND_FFS_FILE
{
short deviceID; // device ID
// unsigned short nThDirEntry; // Is nth entry in its root dir sector, count from 0
/**** modified by chilong 01/10/2002 ****/
// Originally, it should be defined as "unsigned short"
// We define it as "short" because nThDirEntry might be
// set to "NAND_END_LUMP", which is defined as -1
short nThDirEntry;
/**** modified by chilong 01/10/2002 ****/
int subDirLumpNo; // 郎
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -