projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Compilation clean up
[yaffs2.git]
/
direct
/
test-framework
/
yaffs_fileem.c
diff --git
a/direct/test-framework/yaffs_fileem.c
b/direct/test-framework/yaffs_fileem.c
index 96a64c61a32c1084abf9c361ececaf32351ebb9a..a791214fb891f74fe5a4e6c791d7766c3f30e548 100644
(file)
--- a/
direct/test-framework/yaffs_fileem.c
+++ b/
direct/test-framework/yaffs_fileem.c
@@
-25,7
+25,7
@@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <unistd.h>
+#include <unistd.h>
@@
-36,7
+36,7
@@
-typedef struct
+typedef struct
{
u8 data[528]; // Data + spare
} yflash_Page;
{
u8 data[528]; // Data + spare
} yflash_Page;
@@
-44,7
+44,7
@@
typedef struct
typedef struct
{
yflash_Page page[32]; // The pages in the block
typedef struct
{
yflash_Page page[32]; // The pages in the block
-
+
} yflash_Block;
} yflash_Block;
@@
-60,56
+60,55
@@
static yflash_Device filedisk;
static int CheckInit(struct yaffs_dev *dev)
{
static int initialised = 0;
static int CheckInit(struct yaffs_dev *dev)
{
static int initialised = 0;
-
int i;
int i;
-
-
int fSize;
int written;
int fSize;
int written;
-
+
yflash_Page p;
yflash_Page p;
-
- if(initialised)
+
+ (void)dev;
+
+ if(initialised)
{
return YAFFS_OK;
}
initialised = 1;
{
return YAFFS_OK;
}
initialised = 1;
-
-
+
+
filedisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);
filedisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);
-
+
filedisk.handle = open("emfile-512-0", O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
filedisk.handle = open("emfile-512-0", O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
-
+
if(filedisk.handle < 0)
{
perror("Failed to open yaffs emulation file");
return YAFFS_FAIL;
}
if(filedisk.handle < 0)
{
perror("Failed to open yaffs emulation file");
return YAFFS_FAIL;
}
-
-
+
+
fSize = lseek(filedisk.handle,0,SEEK_END);
fSize = lseek(filedisk.handle,0,SEEK_END);
-
+
if(fSize < SIZE_IN_MB * 1024 * 1024)
{
printf("Creating yaffs emulation file\n");
if(fSize < SIZE_IN_MB * 1024 * 1024)
{
printf("Creating yaffs emulation file\n");
-
+
lseek(filedisk.handle,0,SEEK_SET);
lseek(filedisk.handle,0,SEEK_SET);
-
+
memset(&p,0xff,sizeof(yflash_Page));
memset(&p,0xff,sizeof(yflash_Page));
-
+
for(i = 0; i < SIZE_IN_MB * 1024 * 1024; i+= 512)
{
written = write(filedisk.handle,&p,sizeof(yflash_Page));
for(i = 0; i < SIZE_IN_MB * 1024 * 1024; i+= 512)
{
written = write(filedisk.handle,&p,sizeof(yflash_Page));
-
+
if(written != sizeof(yflash_Page))
{
printf("Write failed\n");
return YAFFS_FAIL;
}
if(written != sizeof(yflash_Page))
{
printf("Write failed\n");
return YAFFS_FAIL;
}
- }
+ }
}
}
-
+
return 1;
}
return 1;
}
@@
-118,27
+117,25
@@
int yflash_WriteChunkToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data,
int written;
CheckInit(dev);
int written;
CheckInit(dev);
-
-
-
+
if(data)
{
lseek(filedisk.handle,nand_chunk * 528,SEEK_SET);
written = write(filedisk.handle,data,512);
if(data)
{
lseek(filedisk.handle,nand_chunk * 528,SEEK_SET);
written = write(filedisk.handle,data,512);
-
+
if(written != 512) return YAFFS_FAIL;
}
if(written != 512) return YAFFS_FAIL;
}
-
+
if(spare)
{
lseek(filedisk.handle,nand_chunk * 528 + 512,SEEK_SET);
written = write(filedisk.handle,spare,16);
if(spare)
{
lseek(filedisk.handle,nand_chunk * 528 + 512,SEEK_SET);
written = write(filedisk.handle,spare,16);
-
+
if(written != 16) return YAFFS_FAIL;
}
if(written != 16) return YAFFS_FAIL;
}
-
- return YAFFS_OK;
+
+ return YAFFS_OK;
}
}
@@
-148,38
+145,35
@@
int yflash_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, str
int nread;
CheckInit(dev);
int nread;
CheckInit(dev);
-
-
-
+
if(data)
{
lseek(filedisk.handle,nand_chunk * 528,SEEK_SET);
nread = read(filedisk.handle,data,512);
if(data)
{
lseek(filedisk.handle,nand_chunk * 528,SEEK_SET);
nread = read(filedisk.handle,data,512);
-
+
if(nread != 512) return YAFFS_FAIL;
}
if(nread != 512) return YAFFS_FAIL;
}
-
+
if(spare)
{
lseek(filedisk.handle,nand_chunk * 528 + 512,SEEK_SET);
nread= read(filedisk.handle,spare,16);
if(spare)
{
lseek(filedisk.handle,nand_chunk * 528 + 512,SEEK_SET);
nread= read(filedisk.handle,spare,16);
-
+
if(nread != 16) return YAFFS_FAIL;
}
if(nread != 16) return YAFFS_FAIL;
}
-
- return YAFFS_OK;
+
+ return YAFFS_OK;
}
int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
{
}
int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
{
-
int i;
int i;
-
+
CheckInit(dev);
CheckInit(dev);
-
+
if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
{
yaffs_trace(YAFFS_TRACE_ALWAYS,
if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
{
yaffs_trace(YAFFS_TRACE_ALWAYS,
@@
-189,25
+183,26
@@
int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
}
else
{
}
else
{
-
+
yflash_Page pg;
yflash_Page pg;
-
+
memset(&pg,0xff,sizeof(yflash_Page));
memset(&pg,0xff,sizeof(yflash_Page));
-
+
lseek(filedisk.handle, blockNumber * 32 * 528, SEEK_SET);
lseek(filedisk.handle, blockNumber * 32 * 528, SEEK_SET);
-
+
for(i = 0; i < 32; i++)
{
write(filedisk.handle,&pg,528);
}
return YAFFS_OK;
}
for(i = 0; i < 32; i++)
{
write(filedisk.handle,&pg,528);
}
return YAFFS_OK;
}
-
+
}
int yflash_InitialiseNAND(struct yaffs_dev *dev)
{
}
int yflash_InitialiseNAND(struct yaffs_dev *dev)
{
-
+ (void) dev;
+
return YAFFS_OK;
}
return YAFFS_OK;
}