summaryrefslogtreecommitdiffstats
path: root/meta/packages/yaffs2/files/yaffs2-unioob.patch
diff options
context:
space:
mode:
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 @@
1diff -urN yaffs2.orig/yaffs_mtdif2.c yaffs2/yaffs_mtdif2.c
2--- yaffs2.orig/yaffs_mtdif2.c 2005-12-07 14:00:38.000000000 -0800
3+++ yaffs2/yaffs_mtdif2.c 2006-02-10 17:13:58.000000000 -0800
4@@ -29,6 +29,130 @@
5
6 #include "yaffs_packedtags2.h"
7
8+#define PT2_BYTES 25
9+
10+void nandmtd2_pt2buf(yaffs_Device *dev, yaffs_PackedTags2 *pt, int is_raw)
11+{
12+ struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
13+ int i, j = 0, k, n;
14+ __u8 pt2_byte_buf[PT2_BYTES];
15+
16+ /* Pack buffer with 0xff */
17+ for (i = 0; i < mtd->oobsize; i++)
18+ dev->spareBuffer[i] = 0xff;
19+
20+ if (!is_raw) {
21+ *((unsigned int *) &dev->spareBuffer[0]) = pt->t.sequenceNumber;
22+ *((unsigned int *) &dev->spareBuffer[4]) = pt->t.objectId;
23+ *((unsigned int *) &dev->spareBuffer[8]) = pt->t.chunkId;
24+ *((unsigned int *) &dev->spareBuffer[12]) = pt->t.byteCount;
25+ dev->spareBuffer[16] = pt->ecc.colParity;
26+ dev->spareBuffer[17] = pt->ecc.lineParity & 0xff;
27+ dev->spareBuffer[18] = (pt->ecc.lineParity >> 8) & 0xff;
28+ dev->spareBuffer[19] = (pt->ecc.lineParity >> 16) & 0xff;
29+ dev->spareBuffer[20] = (pt->ecc.lineParity >> 24) & 0xff;
30+ dev->spareBuffer[21] = pt->ecc.lineParityPrime & 0xff;
31+ dev->spareBuffer[22] = (pt->ecc.lineParityPrime >> 8) & 0xff;
32+ dev->spareBuffer[23] = (pt->ecc.lineParityPrime >> 16) & 0xff;
33+ dev->spareBuffer[24] = (pt->ecc.lineParityPrime >> 24) & 0xff;
34+ } else {
35+ *((unsigned int *) &pt2_byte_buf[0]) = pt->t.sequenceNumber;
36+ *((unsigned int *) &pt2_byte_buf[4]) = pt->t.objectId;
37+ *((unsigned int *) &pt2_byte_buf[8]) = pt->t.chunkId;
38+ *((unsigned int *) &pt2_byte_buf[12]) = pt->t.byteCount;
39+ pt2_byte_buf[16] = pt->ecc.colParity;
40+ pt2_byte_buf[17] = pt->ecc.lineParity & 0xff;
41+ pt2_byte_buf[18] = (pt->ecc.lineParity >> 8) & 0xff;
42+ pt2_byte_buf[19] = (pt->ecc.lineParity >> 16) & 0xff;
43+ pt2_byte_buf[20] = (pt->ecc.lineParity >> 24) & 0xff;
44+ pt2_byte_buf[21] = pt->ecc.lineParityPrime & 0xff;
45+ pt2_byte_buf[22] = (pt->ecc.lineParityPrime >> 8) & 0xff;
46+ pt2_byte_buf[23] = (pt->ecc.lineParityPrime >> 16) & 0xff;
47+ pt2_byte_buf[24] = (pt->ecc.lineParityPrime >> 24) & 0xff;
48+
49+ k = mtd->oobinfo.oobfree[j][0];
50+ n = mtd->oobinfo.oobfree[j][1];
51+
52+ if (n == 0) {
53+ T(YAFFS_TRACE_ERROR, (TSTR("No OOB space for tags" TENDSTR)));
54+ YBUG();
55+ }
56+
57+ for (i = 0; i < PT2_BYTES; i++) {
58+ if (n == 0) {
59+ j++;
60+ k = mtd->oobinfo.oobfree[j][0];
61+ n = mtd->oobinfo.oobfree[j][1];
62+ if (n == 0) {
63+ T(YAFFS_TRACE_ERROR, (TSTR("No OOB space for tags" TENDSTR)));
64+ YBUG();
65+ }
66+ }
67+ dev->spareBuffer[k++] = pt2_byte_buf[i];
68+ n--;
69+ }
70+ }
71+}
72+
73+void nandmtd2_buf2pt(yaffs_Device *dev, yaffs_PackedTags2 *pt, int is_raw)
74+{
75+ struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
76+ int i, j = 0, k, n;
77+ __u8 pt2_byte_buf[PT2_BYTES];
78+
79+
80+ if (!is_raw) {
81+ pt->t.sequenceNumber = *((unsigned int *) &dev->spareBuffer[0]);
82+ pt->t.objectId = *((unsigned int *) &dev->spareBuffer[4]);
83+ pt->t.chunkId = *((unsigned int *) &dev->spareBuffer[8]);
84+ pt->t.byteCount = *((unsigned int *) &dev->spareBuffer[12]);
85+ pt->ecc.colParity = dev->spareBuffer[16];
86+ pt->ecc.lineParity = (dev->spareBuffer[17] & 0x000000ff) |
87+ ((dev->spareBuffer[18] << 8) & 0x0000ff00) |
88+ ((dev->spareBuffer[19] << 16) & 0x00ff0000) |
89+ ((dev->spareBuffer[20] << 24) & 0xff000000);
90+ pt->ecc.lineParityPrime = (dev->spareBuffer[21] & 0x000000ff) |
91+ ((dev->spareBuffer[22] << 8) & 0x0000ff00) |
92+ ((dev->spareBuffer[23] << 16) & 0x00ff0000) |
93+ ((dev->spareBuffer[24] << 24) & 0xff000000);
94+ } else {
95+ k = mtd->oobinfo.oobfree[j][0];
96+ n = mtd->oobinfo.oobfree[j][1];
97+
98+ if (n == 0) {
99+ T(YAFFS_TRACE_ERROR, (TSTR("No space in OOB for tags" TENDSTR)));
100+ YBUG();
101+ }
102+
103+ for (i = 0; i < PT2_BYTES; i++) {
104+ if (n == 0) {
105+ j++;
106+ k = mtd->oobinfo.oobfree[j][0];
107+ n = mtd->oobinfo.oobfree[j][1];
108+ if (n == 0) {
109+ T(YAFFS_TRACE_ERROR, (TSTR("No space in OOB for tags" TENDSTR)));
110+ YBUG();
111+ }
112+ }
113+ pt2_byte_buf[i] = dev->spareBuffer[k++];
114+ n--;
115+ }
116+ pt->t.sequenceNumber = *((unsigned int *) &pt2_byte_buf[0]);
117+ pt->t.objectId = *((unsigned int *) &pt2_byte_buf[4]);
118+ pt->t.chunkId = *((unsigned int *) &pt2_byte_buf[8]);
119+ pt->t.byteCount = *((unsigned int *) &pt2_byte_buf[12]);
120+ pt->ecc.colParity = pt2_byte_buf[16];
121+ pt->ecc.lineParity = (pt2_byte_buf[17] & 0x000000ff) |
122+ ((pt2_byte_buf[18] << 8) & 0x0000ff00) |
123+ ((pt2_byte_buf[19] << 16) & 0x00ff0000) |
124+ ((pt2_byte_buf[20] << 24) & 0xff000000);
125+ pt->ecc.lineParityPrime = (pt2_byte_buf[21] & 0x000000ff) |
126+ ((pt2_byte_buf[22] << 8) & 0x0000ff00) |
127+ ((pt2_byte_buf[23] << 16) & 0x00ff0000) |
128+ ((pt2_byte_buf[24] << 24) & 0xff000000);
129+ }
130+}
131+
132 int nandmtd2_WriteChunkWithTagsToNAND(yaffs_Device * dev, int chunkInNAND,
133 const __u8 * data,
134 const yaffs_ExtendedTags * tags)
135@@ -51,24 +175,22 @@
136 }
137
138 if (data && tags) {
139- if (dev->useNANDECC)
140- retval =
141- mtd->write_ecc(mtd, addr, dev->nBytesPerChunk,
142- &dummy, data, (__u8 *) & pt, NULL);
143- else
144+ nandmtd2_pt2buf(dev, &pt, 0);
145 retval =
146 mtd->write_ecc(mtd, addr, dev->nBytesPerChunk,
147- &dummy, data, (__u8 *) & pt, NULL);
148+ &dummy, data, dev->spareBuffer,
149+ NULL);
150 } else {
151 if (data)
152 retval =
153 mtd->write(mtd, addr, dev->nBytesPerChunk, &dummy,
154 data);
155- if (tags)
156+ if (tags) {
157+ nandmtd2_pt2buf(dev, &pt, 1);
158 retval =
159 mtd->write_oob(mtd, addr, mtd->oobsize, &dummy,
160- (__u8 *) & pt);
161-
162+ dev->spareBuffer);
163+ }
164 }
165
166 if (retval == 0)
167@@ -94,30 +216,24 @@
168 TENDSTR), chunkInNAND, data, tags));
169
170 if (data && tags) {
171- if (dev->useNANDECC) {
172 retval =
173 mtd->read_ecc(mtd, addr, dev->nBytesPerChunk,
174 &dummy, data, dev->spareBuffer,
175 NULL);
176- } else {
177- retval =
178- mtd->read_ecc(mtd, addr, dev->nBytesPerChunk,
179- &dummy, data, dev->spareBuffer,
180- NULL);
181- }
182+ nandmtd2_buf2pt(dev, &pt, 0);
183 } else {
184 if (data)
185 retval =
186 mtd->read(mtd, addr, dev->nBytesPerChunk, &dummy,
187 data);
188- if (tags)
189+ if (tags) {
190 retval =
191 mtd->read_oob(mtd, addr, mtd->oobsize, &dummy,
192 dev->spareBuffer);
193+ nandmtd2_buf2pt(dev, &pt, 1);
194+ }
195 }
196
197- memcpy(&pt, dev->spareBuffer, sizeof(pt));
198-
199 if (tags)
200 yaffs_UnpackTags2(tags, &pt);
201
202@@ -178,10 +294,11 @@
203 *sequenceNumber = 0;
204 *state = YAFFS_BLOCK_STATE_EMPTY;
205 }
206+
207+ T(YAFFS_TRACE_MTD,
208+ (TSTR("block is OK seq %d state %d" TENDSTR), *sequenceNumber,
209+ *state));
210 }
211- T(YAFFS_TRACE_MTD,
212- (TSTR("block is bad seq %d state %d" TENDSTR), *sequenceNumber,
213- *state));
214
215 if (retval == 0)
216 return YAFFS_OK;