1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Spare area (auto)placement</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="MTD NAND Driver Programming Interface"><link rel="up" href="boarddriversadvanced.html" title="Chapter&#160;5.&#160;Advanced board driver functions"><link rel="prev" href="Bad_Block_table_support.html" title="Bad block table support"><link rel="next" href="Spare_area_autoplacement_default.html" title="Spare area autoplacement default schemes"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Spare area (auto)placement</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="Bad_Block_table_support.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;5.&#160;Advanced board driver functions</th><td width="20%" align="right">&#160;<a accesskey="n" href="Spare_area_autoplacement_default.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Spare_area_placement"></a>Spare area (auto)placement</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="Spare_area_placement.html#Placement_defined_by_fs_driver">Placement defined by fs driver</a></span></dt><dt><span class="sect2"><a href="Spare_area_placement.html#Automatic_placement">Automatic placement</a></span></dt></dl></div><p>
2			The nand driver implements different possibilities for
3			placement of filesystem data in the spare area, 
4			</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Placement defined by fs driver</p></li><li class="listitem"><p>Automatic placement</p></li></ul></div><p>
5			The default placement function is automatic placement. The
6			nand driver has built in default placement schemes for the
7			various chiptypes. If due to hardware ECC functionality the
8			default placement does not fit then the board driver can
9			provide a own placement scheme.
10		</p><p>
11			File system drivers can provide a own placement scheme which
12			is used instead of the default placement scheme.
13		</p><p>
14			Placement schemes are defined by a nand_oobinfo structure
15	     		</p><pre class="programlisting">
16struct nand_oobinfo {
17	int	useecc;
18	int	eccbytes;
19	int	eccpos[24];
20	int	oobfree[8][2];
21};
22	     		</pre><p>
23			</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>useecc</p><p>
24				The useecc member controls the ecc and placement function. The header
25				file include/mtd/mtd-abi.h contains constants to select ecc and
26				placement. MTD_NANDECC_OFF switches off the ecc complete. This is
27				not recommended and available for testing and diagnosis only.
28				MTD_NANDECC_PLACE selects caller defined placement, MTD_NANDECC_AUTOPLACE
29				selects automatic placement.
30			</p></li><li class="listitem"><p>eccbytes</p><p>
31				The eccbytes member defines the number of ecc bytes per page.
32			</p></li><li class="listitem"><p>eccpos</p><p>
33				The eccpos array holds the byte offsets in the spare area where
34				the ecc codes are placed.
35			</p></li><li class="listitem"><p>oobfree</p><p>
36				The oobfree array defines the areas in the spare area which can be
37				used for automatic placement. The information is given in the format
38				{offset, size}. offset defines the start of the usable area, size the
39				length in bytes. More than one area can be defined. The list is terminated
40				by an {0, 0} entry.
41			</p></li></ul></div><p>
42		</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="Placement_defined_by_fs_driver"></a>Placement defined by fs driver</h3></div></div></div><p>
43				The calling function provides a pointer to a nand_oobinfo
44				structure which defines the ecc placement. For writes the
45				caller must provide a spare area buffer along with the
46				data buffer. The spare area buffer size is (number of pages) *
47				(size of spare area). For reads the buffer size is
48				(number of pages) * ((size of spare area) + (number of ecc
49				steps per page) * sizeof (int)). The driver stores the
50				result of the ecc check for each tuple in the spare buffer.
51				The storage sequence is 
52			</p><p>
53				&lt;spare data page 0&gt;&lt;ecc result 0&gt;...&lt;ecc result n&gt;
54			</p><p>
55				...
56			</p><p>
57				&lt;spare data page n&gt;&lt;ecc result 0&gt;...&lt;ecc result n&gt;
58			</p><p>
59				This is a legacy mode used by YAFFS1.
60			</p><p>
61				If the spare area buffer is NULL then only the ECC placement is
62				done according to the given scheme in the nand_oobinfo structure.
63			</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="Automatic_placement"></a>Automatic placement</h3></div></div></div><p>
64				Automatic placement uses the built in defaults to place the
65				ecc bytes in the spare area. If filesystem data have to be stored /
66				read into the spare area then the calling function must provide a
67				buffer. The buffer size per page is determined by the oobfree array in
68				the nand_oobinfo structure.
69			</p><p>
70				If the spare area buffer is NULL then only the ECC placement is
71				done according to the default builtin scheme.
72			</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="Bad_Block_table_support.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="boarddriversadvanced.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="Spare_area_autoplacement_default.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Bad block table support&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Spare area autoplacement default schemes</td></tr></table></div></body></html>
73