*
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*
- * $Id: yaffs_guts.h,v 1.1 2004-11-03 08:14:07 charles Exp $
+ * $Id: yaffs_guts.h,v 1.3 2004-12-17 04:39:04 charles Exp $
*/
#ifndef __YAFFS_GUTS_H__
#define YAFFS_BYTES_PER_BLOCK (YAFFS_CHUNKS_PER_BLOCK*YAFFS_BYTES_PER_CHUNK)
#endif
+#define YAFFS_MIN_YAFFS2_CHUNK_SIZE 1024
+#define YAFFS_MIN_YAFFS2_SPARE_SIZE 32
+
#define YAFFS_MAX_CHUNK_ID 0x000FFFFF
#define YAFFS_UNUSED_OBJECT_ID 0x0003FFFF
int dirty;
int nBytes; // Only valid if the cache is dirty
int locked; // Can't push out or flush while locked..
-#ifdef YAFFS2_DEFINES
+#ifdef CONFIG_YAFFS_YAFFS2
__u8 *data;
#else
__u8 data[YAFFS_BYTES_PER_CHUNK];
typedef enum {
YAFFS_BLOCK_STATE_UNKNOWN = 0,
-#ifndef YAFFS2_DEFINES
+
YAFFS_BLOCK_STATE_SCANNING,
-#else
YAFFS_BLOCK_STATE_NEEDS_SCANNING,// The block might have something on it (ie it is allocating or full, perhaps empty)
// but it needs to be scanned to determine its true state.
// This state is only valid during yaffs_Scan.
// NB We tolerate empty because the pre-scanner might be incapable of deciding
// However, if this state is returned on a YAFFS2 device, then we expect a sequence number
-#endif
YAFFS_BLOCK_STATE_EMPTY, // This block is empty
YAFFS_BLOCK_STATE_ALLOCATING, // This block is partially allocated.
typedef struct
{
- int softDeletions:8; // number of soft deleted pages
+ int softDeletions:8; // number of soft deleted pages
int pagesInUse:8; // number of pages in use
__u32 blockState:4; // One of the above block states
__u32 needsRetiring:1; // Data has failed on this block, need to get valid data off
// and retire the block.
-#ifndef CONFIG_YAFFS_NO_YAFFS2
+#ifdef CONFIG_YAFFS_YAFFS2
__u32 hasShrinkHeader:1;// This block has at least one object header that does a shrink
__u32 sequenceNumber; // block sequence number for yaffs2
#endif
// object might be created before the data
// is available (ie. file data records appear before the header).
__u8 serial; // serial number of chunk in NAND. Store here so we don't have to
+
+ __u8 deferedFree: 1; // For Linux kernel. Object is removed from NAND, but still in the inode cache.
+ // Free of object is defered.
+
// read back the old one to update.
__u16 sum; // sum of the name to speed searching
#ifdef __KERNEL__
struct inode *myInode;
+
#endif
// NAND access functions (Must be set before calling YAFFS)
-#ifndef CONFIG_YAFFS_NO_YAFFS1
+
int (*writeChunkToNAND)(struct yaffs_DeviceStruct *dev,int chunkInNAND, const __u8 *data, const yaffs_Spare *spare);
int (*readChunkFromNAND)(struct yaffs_DeviceStruct *dev,int chunkInNAND, __u8 *data, yaffs_Spare *spare);
-// int (*eraseBlockInNAND)(struct yaffs_DeviceStruct *dev,int blockInNAND);
-// int (*initialiseNAND)(struct yaffs_DeviceStruct *dev);
-#endif
-#ifndef CONFIG_YAFFS_NO_YAFFS2
- int (*writeChunkWithTagsToNAND)(struct yaffs_DeviceStruct *dev,int chunkInNAND, const __u8 *data, yaffs_ExtendedTags *tags);
- int (*readChunkWithTagsFromNAND)(struct yaffs_DeviceStruct *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags);
int (*eraseBlockInNAND)(struct yaffs_DeviceStruct *dev,int blockInNAND);
int (*initialiseNAND)(struct yaffs_DeviceStruct *dev);
+
+#ifdef CONFIG_YAFFS_YAFFS2
+ int (*writeChunkWithTagsToNAND)(struct yaffs_DeviceStruct *dev,int chunkInNAND, const __u8 *data, yaffs_ExtendedTags *tags);
+ int (*readChunkWithTagsFromNAND)(struct yaffs_DeviceStruct *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags);
int (*markNANDBlockBad)(struct yaffs_DeviceStruct *dev, int blockNo);
int (*queryNANDBlock)(struct yaffs_DeviceStruct *dev, int blockNo, yaffs_BlockState *state, int *sequenceNumber);
#endif
struct semaphore sem;// Semaphore for waiting on erasure.
struct semaphore grossLock; // Gross locking semaphore
-
-#endif
-#ifdef __KERNEL__
+ __u8 * spareBuffer; // For mtdif2 use. Don't know the size of the buffer at compile time so we have to allocate it.
void (*putSuperFunc)(struct super_block *sb);
#endif
void yfsd_WinFileTimeNow(__u32 target[2]);
#endif
+#ifdef __KERNEL__
+
+void yaffs_HandleDeferedFree(yaffs_Object *obj);
+#endif
+
+
+
// Debug dump
int yaffs_DumpObject(yaffs_Object *obj);