<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><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.76.1" /><link rel="home" href="index.html" title="MTD NAND Driver Programming Interface" /><link rel="up" href="boarddriversadvanced.html" title="Chapter 5. 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><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> </td><th width="60%" align="center">Chapter 5. Advanced board driver functions</th><td width="20%" align="right"> <a accesskey="n" href="Spare_area_autoplacement_default.html">Next</a></td></tr></table><hr /></div><div class="sect1" title="Spare area (auto)placement"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Spare_area_placement"></a>Spare area (auto)placement</h2></div></div></div><div class="toc"><dl><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><dt><span class="sect2"><a href="Spare_area_placement.html#User_space_placement_selection">User space placement selection</a></span></dt></dl></div><p> The nand driver implements different possibilities for placement of filesystem data in the spare area, </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Placement defined by fs driver</p></li><li class="listitem"><p>Automatic placement</p></li></ul></div><p> The default placement function is automatic placement. The nand driver has built in default placement schemes for the various chiptypes. If due to hardware ECC functionality the default placement does not fit then the board driver can provide a own placement scheme. </p><p> File system drivers can provide a own placement scheme which is used instead of the default placement scheme. </p><p> Placement schemes are defined by a nand_oobinfo structure </p><pre class="programlisting"> struct nand_oobinfo { int useecc; int eccbytes; int eccpos[24]; int oobfree[8][2]; }; </pre><p> </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>useecc</p><p> The useecc member controls the ecc and placement function. The header file include/mtd/mtd-abi.h contains constants to select ecc and placement. MTD_NANDECC_OFF switches off the ecc complete. This is not recommended and available for testing and diagnosis only. MTD_NANDECC_PLACE selects caller defined placement, MTD_NANDECC_AUTOPLACE selects automatic placement. </p></li><li class="listitem"><p>eccbytes</p><p> The eccbytes member defines the number of ecc bytes per page. </p></li><li class="listitem"><p>eccpos</p><p> The eccpos array holds the byte offsets in the spare area where the ecc codes are placed. </p></li><li class="listitem"><p>oobfree</p><p> The oobfree array defines the areas in the spare area which can be used for automatic placement. The information is given in the format {offset, size}. offset defines the start of the usable area, size the length in bytes. More than one area can be defined. The list is terminated by an {0, 0} entry. </p></li></ul></div><p> </p><div class="sect2" title="Placement defined by fs driver"><div class="titlepage"><div><div><h3 class="title"><a id="Placement_defined_by_fs_driver"></a>Placement defined by fs driver</h3></div></div></div><p> The calling function provides a pointer to a nand_oobinfo structure which defines the ecc placement. For writes the caller must provide a spare area buffer along with the data buffer. The spare area buffer size is (number of pages) * (size of spare area). For reads the buffer size is (number of pages) * ((size of spare area) + (number of ecc steps per page) * sizeof (int)). The driver stores the result of the ecc check for each tuple in the spare buffer. The storage sequence is </p><p> <spare data page 0><ecc result 0>...<ecc result n> </p><p> ... </p><p> <spare data page n><ecc result 0>...<ecc result n> </p><p> This is a legacy mode used by YAFFS1. </p><p> If the spare area buffer is NULL then only the ECC placement is done according to the given scheme in the nand_oobinfo structure. </p></div><div class="sect2" title="Automatic placement"><div class="titlepage"><div><div><h3 class="title"><a id="Automatic_placement"></a>Automatic placement</h3></div></div></div><p> Automatic placement uses the built in defaults to place the ecc bytes in the spare area. If filesystem data have to be stored / read into the spare area then the calling function must provide a buffer. The buffer size per page is determined by the oobfree array in the nand_oobinfo structure. </p><p> If the spare area buffer is NULL then only the ECC placement is done according to the default builtin scheme. </p></div><div class="sect2" title="User space placement selection"><div class="titlepage"><div><div><h3 class="title"><a id="User_space_placement_selection"></a>User space placement selection</h3></div></div></div><p> All non ecc functions like mtd->read and mtd->write use an internal structure, which can be set by an ioctl. This structure is preset to the autoplacement default. </p><pre class="programlisting"> ioctl (fd, MEMSETOOBSEL, oobsel); </pre><p> oobsel is a pointer to a user supplied structure of type nand_oobconfig. The contents of this structure must match the criteria of the filesystem, which will be used. See an example in utils/nandwrite.c. </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> </td><td width="20%" align="center"><a accesskey="u" href="boarddriversadvanced.html">Up</a></td><td width="40%" align="right"> <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 </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Spare area autoplacement default schemes</td></tr></table></div></body></html>