diff options
author | Paul Sokolovsky <pmiscml@gmail.com> | 2007-09-11 16:52:27 +0000 |
---|---|---|
committer | Paul Sokolovsky <pmiscml@gmail.com> | 2007-09-11 16:52:27 +0000 |
commit | 4d5b429bca6e2a6bfb2b36dc8ad8bb38b78b2429 (patch) | |
tree | 186a1f825cb66a8ee8cbe262e06bba11ae5fc7d3 /packages/yaffs2/files/yaffs2-unioob.patch | |
parent | f56148af04529554908eb3af1d616b51266ebd1a (diff) | |
parent | 9c68f8a0ada21051d514fd158e0da531c0a602e8 (diff) |
merge of '41bc7cd136be3eabb67bde38705e491f649cd322'
and 'cb02b3f58dbbe96a4730fcb455585ec97277014a'
Diffstat (limited to 'packages/yaffs2/files/yaffs2-unioob.patch')
-rw-r--r-- | packages/yaffs2/files/yaffs2-unioob.patch | 216 |
1 files changed, 216 insertions, 0 deletions
diff --git a/packages/yaffs2/files/yaffs2-unioob.patch b/packages/yaffs2/files/yaffs2-unioob.patch new file mode 100644 index 0000000000..c894528ca1 --- /dev/null +++ b/packages/yaffs2/files/yaffs2-unioob.patch @@ -0,0 +1,216 @@ +diff -urN yaffs2.orig/yaffs_mtdif2.c yaffs2/yaffs_mtdif2.c +--- yaffs2.orig/yaffs_mtdif2.c 2005-12-07 14:00:38.000000000 -0800 ++++ yaffs2/yaffs_mtdif2.c 2006-02-10 17:13:58.000000000 -0800 +@@ -29,6 +29,130 @@ + + #include "yaffs_packedtags2.h" + ++#define PT2_BYTES 25 ++ ++void nandmtd2_pt2buf(yaffs_Device *dev, yaffs_PackedTags2 *pt, int is_raw) ++{ ++ struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice); ++ int i, j = 0, k, n; ++ __u8 pt2_byte_buf[PT2_BYTES]; ++ ++ /* Pack buffer with 0xff */ ++ for (i = 0; i < mtd->oobsize; i++) ++ dev->spareBuffer[i] = 0xff; ++ ++ if (!is_raw) { ++ *((unsigned int *) &dev->spareBuffer[0]) = pt->t.sequenceNumber; ++ *((unsigned int *) &dev->spareBuffer[4]) = pt->t.objectId; ++ *((unsigned int *) &dev->spareBuffer[8]) = pt->t.chunkId; ++ *((unsigned int *) &dev->spareBuffer[12]) = pt->t.byteCount; ++ dev->spareBuffer[16] = pt->ecc.colParity; ++ dev->spareBuffer[17] = pt->ecc.lineParity & 0xff; ++ dev->spareBuffer[18] = (pt->ecc.lineParity >> 8) & 0xff; ++ dev->spareBuffer[19] = (pt->ecc.lineParity >> 16) & 0xff; ++ dev->spareBuffer[20] = (pt->ecc.lineParity >> 24) & 0xff; ++ dev->spareBuffer[21] = pt->ecc.lineParityPrime & 0xff; ++ dev->spareBuffer[22] = (pt->ecc.lineParityPrime >> 8) & 0xff; ++ dev->spareBuffer[23] = (pt->ecc.lineParityPrime >> 16) & 0xff; ++ dev->spareBuffer[24] = (pt->ecc.lineParityPrime >> 24) & 0xff; ++ } else { ++ *((unsigned int *) &pt2_byte_buf[0]) = pt->t.sequenceNumber; ++ *((unsigned int *) &pt2_byte_buf[4]) = pt->t.objectId; ++ *((unsigned int *) &pt2_byte_buf[8]) = pt->t.chunkId; ++ *((unsigned int *) &pt2_byte_buf[12]) = pt->t.byteCount; ++ pt2_byte_buf[16] = pt->ecc.colParity; ++ pt2_byte_buf[17] = pt->ecc.lineParity & 0xff; ++ pt2_byte_buf[18] = (pt->ecc.lineParity >> 8) & 0xff; ++ pt2_byte_buf[19] = (pt->ecc.lineParity >> 16) & 0xff; ++ pt2_byte_buf[20] = (pt->ecc.lineParity >> 24) & 0xff; ++ pt2_byte_buf[21] = pt->ecc.lineParityPrime & 0xff; ++ pt2_byte_buf[22] = (pt->ecc.lineParityPrime >> 8) & 0xff; ++ pt2_byte_buf[23] = (pt->ecc.lineParityPrime >> 16) & 0xff; ++ pt2_byte_buf[24] = (pt->ecc.lineParityPrime >> 24) & 0xff; ++ ++ k = mtd->oobinfo.oobfree[j][0]; ++ n = mtd->oobinfo.oobfree[j][1]; ++ ++ if (n == 0) { ++ T(YAFFS_TRACE_ERROR, (TSTR("No OOB space for tags" TENDSTR))); ++ YBUG(); ++ } ++ ++ for (i = 0; i < PT2_BYTES; i++) { ++ if (n == 0) { ++ j++; ++ k = mtd->oobinfo.oobfree[j][0]; ++ n = mtd->oobinfo.oobfree[j][1]; ++ if (n == 0) { ++ T(YAFFS_TRACE_ERROR, (TSTR("No OOB space for tags" TENDSTR))); ++ YBUG(); ++ } ++ } ++ dev->spareBuffer[k++] = pt2_byte_buf[i]; ++ n--; ++ } ++ } ++} ++ ++void nandmtd2_buf2pt(yaffs_Device *dev, yaffs_PackedTags2 *pt, int is_raw) ++{ ++ struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice); ++ int i, j = 0, k, n; ++ __u8 pt2_byte_buf[PT2_BYTES]; ++ ++ ++ if (!is_raw) { ++ pt->t.sequenceNumber = *((unsigned int *) &dev->spareBuffer[0]); ++ pt->t.objectId = *((unsigned int *) &dev->spareBuffer[4]); ++ pt->t.chunkId = *((unsigned int *) &dev->spareBuffer[8]); ++ pt->t.byteCount = *((unsigned int *) &dev->spareBuffer[12]); ++ pt->ecc.colParity = dev->spareBuffer[16]; ++ pt->ecc.lineParity = (dev->spareBuffer[17] & 0x000000ff) | ++ ((dev->spareBuffer[18] << 8) & 0x0000ff00) | ++ ((dev->spareBuffer[19] << 16) & 0x00ff0000) | ++ ((dev->spareBuffer[20] << 24) & 0xff000000); ++ pt->ecc.lineParityPrime = (dev->spareBuffer[21] & 0x000000ff) | ++ ((dev->spareBuffer[22] << 8) & 0x0000ff00) | ++ ((dev->spareBuffer[23] << 16) & 0x00ff0000) | ++ ((dev->spareBuffer[24] << 24) & 0xff000000); ++ } else { ++ k = mtd->oobinfo.oobfree[j][0]; ++ n = mtd->oobinfo.oobfree[j][1]; ++ ++ if (n == 0) { ++ T(YAFFS_TRACE_ERROR, (TSTR("No space in OOB for tags" TENDSTR))); ++ YBUG(); ++ } ++ ++ for (i = 0; i < PT2_BYTES; i++) { ++ if (n == 0) { ++ j++; ++ k = mtd->oobinfo.oobfree[j][0]; ++ n = mtd->oobinfo.oobfree[j][1]; ++ if (n == 0) { ++ T(YAFFS_TRACE_ERROR, (TSTR("No space in OOB for tags" TENDSTR))); ++ YBUG(); ++ } ++ } ++ pt2_byte_buf[i] = dev->spareBuffer[k++]; ++ n--; ++ } ++ pt->t.sequenceNumber = *((unsigned int *) &pt2_byte_buf[0]); ++ pt->t.objectId = *((unsigned int *) &pt2_byte_buf[4]); ++ pt->t.chunkId = *((unsigned int *) &pt2_byte_buf[8]); ++ pt->t.byteCount = *((unsigned int *) &pt2_byte_buf[12]); ++ pt->ecc.colParity = pt2_byte_buf[16]; ++ pt->ecc.lineParity = (pt2_byte_buf[17] & 0x000000ff) | ++ ((pt2_byte_buf[18] << 8) & 0x0000ff00) | ++ ((pt2_byte_buf[19] << 16) & 0x00ff0000) | ++ ((pt2_byte_buf[20] << 24) & 0xff000000); ++ pt->ecc.lineParityPrime = (pt2_byte_buf[21] & 0x000000ff) | ++ ((pt2_byte_buf[22] << 8) & 0x0000ff00) | ++ ((pt2_byte_buf[23] << 16) & 0x00ff0000) | ++ ((pt2_byte_buf[24] << 24) & 0xff000000); ++ } ++} ++ + int nandmtd2_WriteChunkWithTagsToNAND(yaffs_Device * dev, int chunkInNAND, + const __u8 * data, + const yaffs_ExtendedTags * tags) +@@ -51,24 +175,22 @@ + } + + if (data && tags) { +- if (dev->useNANDECC) +- retval = +- mtd->write_ecc(mtd, addr, dev->nBytesPerChunk, +- &dummy, data, (__u8 *) & pt, NULL); +- else ++ nandmtd2_pt2buf(dev, &pt, 0); + retval = + mtd->write_ecc(mtd, addr, dev->nBytesPerChunk, +- &dummy, data, (__u8 *) & pt, NULL); ++ &dummy, data, dev->spareBuffer, ++ NULL); + } else { + if (data) + retval = + mtd->write(mtd, addr, dev->nBytesPerChunk, &dummy, + data); +- if (tags) ++ if (tags) { ++ nandmtd2_pt2buf(dev, &pt, 1); + retval = + mtd->write_oob(mtd, addr, mtd->oobsize, &dummy, +- (__u8 *) & pt); +- ++ dev->spareBuffer); ++ } + } + + if (retval == 0) +@@ -94,30 +216,24 @@ + TENDSTR), chunkInNAND, data, tags)); + + if (data && tags) { +- if (dev->useNANDECC) { + retval = + mtd->read_ecc(mtd, addr, dev->nBytesPerChunk, + &dummy, data, dev->spareBuffer, + NULL); +- } else { +- retval = +- mtd->read_ecc(mtd, addr, dev->nBytesPerChunk, +- &dummy, data, dev->spareBuffer, +- NULL); +- } ++ nandmtd2_buf2pt(dev, &pt, 0); + } else { + if (data) + retval = + mtd->read(mtd, addr, dev->nBytesPerChunk, &dummy, + data); +- if (tags) ++ if (tags) { + retval = + mtd->read_oob(mtd, addr, mtd->oobsize, &dummy, + dev->spareBuffer); ++ nandmtd2_buf2pt(dev, &pt, 1); ++ } + } + +- memcpy(&pt, dev->spareBuffer, sizeof(pt)); +- + if (tags) + yaffs_UnpackTags2(tags, &pt); + +@@ -178,10 +294,11 @@ + *sequenceNumber = 0; + *state = YAFFS_BLOCK_STATE_EMPTY; + } ++ ++ T(YAFFS_TRACE_MTD, ++ (TSTR("block is OK seq %d state %d" TENDSTR), *sequenceNumber, ++ *state)); + } +- T(YAFFS_TRACE_MTD, +- (TSTR("block is bad seq %d state %d" TENDSTR), *sequenceNumber, +- *state)); + + if (retval == 0) + return YAFFS_OK; |