summaryrefslogtreecommitdiff
path: root/meta/packages/yaffs2/files/yaffs2-unioob.patch
diff options
context:
space:
mode:
authorMarcin Juszkiewicz <hrw@openedhand.com>2007-11-07 10:06:36 +0000
committerMarcin Juszkiewicz <hrw@openedhand.com>2007-11-07 10:06:36 +0000
commitb1d86e4aaa2b1614d560309d35338216bf8c58c0 (patch)
tree46d02536f2d8093418a04d6bc014dee0d2d55224 /meta/packages/yaffs2/files/yaffs2-unioob.patch
parentb5fda834416809a5348f6f5e21ddaeb484c4cdc8 (diff)
downloadopenembedded-core-b1d86e4aaa2b1614d560309d35338216bf8c58c0.tar.gz
openembedded-core-b1d86e4aaa2b1614d560309d35338216bf8c58c0.tar.bz2
openembedded-core-b1d86e4aaa2b1614d560309d35338216bf8c58c0.zip
yaffs2-utils: added from OE
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3085 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/yaffs2/files/yaffs2-unioob.patch')
-rw-r--r--meta/packages/yaffs2/files/yaffs2-unioob.patch216
1 files changed, 216 insertions, 0 deletions
diff --git a/meta/packages/yaffs2/files/yaffs2-unioob.patch b/meta/packages/yaffs2/files/yaffs2-unioob.patch
new file mode 100644
index 0000000000..c894528ca1
--- /dev/null
+++ b/meta/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;