X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Ftest-framework%2Fyramsim.c;h=430adce781768b18a8e0d97890e0a71a865f4a04;hp=881c6e3500e6bf689db979e1dea3948ff70bcf42;hb=HEAD;hpb=bfde38bff96a421dcb73ffbb8b9b69f3f6500677 diff --git a/direct/test-framework/yramsim.c b/direct/test-framework/yramsim.c index 881c6e3..430adce 100644 --- a/direct/test-framework/yramsim.c +++ b/direct/test-framework/yramsim.c @@ -1,8 +1,7 @@ /* * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. * - * Copyright (C) 2002-2011 Aleph One Ltd. - * for Toby Churchill Ltd and Brightstar Engineering + * Copyright (C) 2002-2018 Aleph One Ltd. * * Created by Charles Manning * @@ -15,11 +14,12 @@ * NAND Simulator for testing YAFFS */ -#include #include "yramsim.h" #include "yaffs_guts.h" +#include + #define DATA_SIZE 2048 @@ -88,10 +88,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 +104,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 +117,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 +139,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 +151,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 +163,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 +174,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; }