X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Ftest-framework%2Fyramsim.c;h=6466d3b9a2ce9e1c1088927d27515b856d95c259;hp=881c6e3500e6bf689db979e1dea3948ff70bcf42;hb=d13e6146b4ccadd7aab2033b6cf9f4551d6abd71;hpb=bfde38bff96a421dcb73ffbb8b9b69f3f6500677 diff --git a/direct/test-framework/yramsim.c b/direct/test-framework/yramsim.c index 881c6e3..6466d3b 100644 --- a/direct/test-framework/yramsim.c +++ b/direct/test-framework/yramsim.c @@ -15,11 +15,12 @@ * NAND Simulator for testing YAFFS */ -#include #include "yramsim.h" #include "yaffs_guts.h" +#include + #define DATA_SIZE 2048 @@ -88,10 +89,10 @@ static int yramsim_deinitialise(struct yaffs_dev *dev) return 1; } -static int yramsim_rd_chunk (struct yaffs_dev *dev, unsigned pageId, - unsigned char *data, unsigned dataLength, - unsigned char *spare, unsigned spareLength, - int *eccStatus) +static int yramsim_rd_chunk (struct yaffs_dev *dev, int pageId, + u8 *data, int dataLength, + u8 *spare, int spareLength, + enum yaffs_ecc_result *ecc_result) { SimData *sim = DevToSim(dev); Block **blockList = sim->blockList; @@ -104,9 +105,8 @@ static int yramsim_rd_chunk (struct yaffs_dev *dev, unsigned pageId, pageOffset >= PAGES_PER_BLOCK || dataLength >DATA_SIZE || spareLength > SPARE_SIZE || - !eccStatus || !blockList[blockId]->blockOk){ - return 0; + return YAFFS_FAIL; } d = blockList[blockId]->page[pageOffset]; @@ -118,14 +118,15 @@ static int yramsim_rd_chunk (struct yaffs_dev *dev, unsigned pageId, if(spare) memcpy(spare,s,spareLength); - *eccStatus = 0; /* 0 = no error, -1 = unfixable error, 1 = fixable */ + if (ecc_result) + *ecc_result = YAFFS_ECC_RESULT_NO_ERROR; - return 1; + return YAFFS_OK; } -static int yramsim_wr_chunk (struct yaffs_dev *dev,unsigned pageId, - const unsigned char *data, unsigned dataLength, - const unsigned char *spare, unsigned spareLength) +static int yramsim_wr_chunk (struct yaffs_dev *dev, int pageId, + const u8 *data, int dataLength, + const u8 *spare, int spareLength) { SimData *sim = DevToSim(dev); Block **blockList = sim->blockList; @@ -139,7 +140,7 @@ static int yramsim_wr_chunk (struct yaffs_dev *dev,unsigned pageId, dataLength >DATA_SIZE || spareLength > SPARE_SIZE || !blockList[blockId]->blockOk){ - return 0; + return YAFFS_FAIL; } d = blockList[blockId]->page[pageOffset]; @@ -151,11 +152,11 @@ static int yramsim_wr_chunk (struct yaffs_dev *dev,unsigned pageId, if(spare) memcpy(s,spare,spareLength); - return 1; + return YAFFS_OK; } -static int yramsim_erase(struct yaffs_dev *dev,unsigned blockId) +static int yramsim_erase(struct yaffs_dev *dev, int blockId) { SimData *sim = DevToSim(dev); @@ -163,7 +164,7 @@ static int yramsim_erase(struct yaffs_dev *dev,unsigned blockId) return yramsim_erase_internal(sim,blockId,0); } -static int yramsim_check_block_bad(struct yaffs_dev *dev,unsigned blockId) +static int yramsim_check_block_bad(struct yaffs_dev *dev, int blockId) { SimData *sim = DevToSim(dev); Block **blockList = sim->blockList; @@ -174,17 +175,17 @@ static int yramsim_check_block_bad(struct yaffs_dev *dev,unsigned blockId) return blockList[blockId]->blockOk ? YAFFS_OK : YAFFS_FAIL; } -static int yramsim_mark_block_bad(struct yaffs_dev *dev,unsigned blockId) +static int yramsim_mark_block_bad(struct yaffs_dev *dev, int blockId) { SimData *sim = DevToSim(dev); Block **blockList = sim->blockList; if(blockId >= sim->nBlocks){ - return 0; + return YAFFS_FAIL; } blockList[blockId]->blockOk = 0; - return 1; + return YAFFS_OK; }