summaryrefslogtreecommitdiff
path: root/packages/yaffs2/files/yaffs2-unioob.patch
diff options
context:
space:
mode:
authorMichael Lauer <mickey@vanille-media.de>2007-09-11 13:50:31 +0000
committerMichael Lauer <mickey@vanille-media.de>2007-09-11 13:50:31 +0000
commita1a2f252b696f1b9e301824b747eb5a19d517899 (patch)
tree3466e13f6854cdbd7b0cee6156acbe1b5f4bc490 /packages/yaffs2/files/yaffs2-unioob.patch
parent496383e73baaaeae20a3e8c21785e9ef66182899 (diff)
add yaffs2-utils[-native]
Diffstat (limited to 'packages/yaffs2/files/yaffs2-unioob.patch')
-rw-r--r--packages/yaffs2/files/yaffs2-unioob.patch216
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;