linux/drivers/mtd/ssfdc.c
<<
>>
Prefs
   1/*
   2 * Linux driver for SSFDC Flash Translation Layer (Read only)
   3 * © 2005 Eptar srl
   4 * Author: Claudio Lanconelli <lanconelli.claudio@eptar.com>
   5 *
   6 * Based on NTFL and MTDBLOCK_RO drivers
   7 *
   8 * This program is free software; you can redistribute it and/or modify
   9 * it under the terms of the GNU General Public License version 2 as
  10 * published by the Free Software Foundation.
  11 */
  12
  13#include <linux/kernel.h>
  14#include <linux/module.h>
  15#include <linux/init.h>
  16#include <linux/slab.h>
  17#include <linux/hdreg.h>
  18#include <linux/mtd/mtd.h>
  19#include <linux/mtd/nand.h>
  20#include <linux/mtd/blktrans.h>
  21
  22struct ssfdcr_record {
  23        struct mtd_blktrans_dev mbd;
  24        int usecount;
  25        unsigned char heads;
  26        unsigned char sectors;
  27        unsigned short cylinders;
  28        int cis_block;                  /* block n. containing CIS/IDI */
  29        int erase_size;                 /* phys_block_size */
  30        unsigned short *logic_block_map; /* all zones (max 8192 phys blocks on
  31                                            the 128MiB) */
  32        int map_len;                    /* n. phys_blocks on the card */
  33};
  34
  35#define SSFDCR_MAJOR            257
  36#define SSFDCR_PARTN_BITS       3
  37
  38#define SECTOR_SIZE             512
  39#define SECTOR_SHIFT            9
  40#define OOB_SIZE                16
  41
  42#define MAX_LOGIC_BLK_PER_ZONE  1000
  43#define MAX_PHYS_BLK_PER_ZONE   1024
  44
  45#define KiB(x)  ( (x) * 1024L )
  46#define MiB(x)  ( KiB(x) * 1024L )
  47
  48/** CHS Table
  49                1MiB    2MiB    4MiB    8MiB    16MiB   32MiB   64MiB   128MiB
  50NCylinder       125     125     250     250     500     500     500     500
  51NHead           4       4       4       4       4       8       8       16
  52NSector         4       8       8       16      16      16      32      32
  53SumSector       2,000   4,000   8,000   16,000  32,000  64,000  128,000 256,000
  54SectorSize      512     512     512     512     512     512     512     512
  55**/
  56
  57typedef struct {
  58        unsigned long size;
  59        unsigned short cyl;
  60        unsigned char head;
  61        unsigned char sec;
  62} chs_entry_t;
  63
  64/* Must be ordered by size */
  65static const chs_entry_t chs_table[] = {
  66        { MiB(  1), 125,  4,  4 },
  67        { MiB(  2), 125,  4,  8 },
  68        { MiB(  4), 250,  4,  8 },
  69        { MiB(  8), 250,  4, 16 },
  70        { MiB( 16), 500,  4, 16 },
  71        { MiB( 32), 500,  8, 16 },
  72        { MiB( 64), 500,  8, 32 },
  73        { MiB(128), 500, 16, 32 },
  74        { 0 },
  75};
  76
  77static int get_chs(unsigned long size, unsigned short *cyl, unsigned char *head,
  78                        unsigned char *sec)
  79{
  80        int k;
  81        int found = 0;
  82
  83        k = 0;
  84        while (chs_table[k].size > 0 && size > chs_table[k].size)
  85                k++;
MiB
  78        {if(chs_table[k].size > 0 ){
  78                 if(cyl,
  789/a>                        ucyl,= 0a href="+code=chs_table" class="sref">chs_table[k].cyl;
  890/a>                 if(head,
  891/a>                        uhead,= 0a href="+code=chs_table" class="sref">chs_table[k].head;
  892/a>                 if(sec)
  893/a>                        usec)= 0a href="+code=chs_table" class="sref">chs_table[k].sec;
  894/a>                found = 01
  89         }MiB
  79        {eturn fa href="+code=kound" class="sref">found 
  79 }  799/a>
  10N/ Thiese bytes re Fhe cigneaurnefor She cIS/IDI *ectors*/
cunt 8t"/a> cyis_numbrs"/a>[] = {
*/ Tead ond Mcheckfor SavaluidcIS/*ectors*/
get_caluid_yis_ectors/a>(utruct gtd_binfo/a>  gtd_/a>)
cre"/a>, ua href="+code=k" class="sref">k] ua href="+code=kyis_ectors class="sref">gyis_ectors/a>(
cize"t"/a> mre"en"/a>(
  110/a>         a href="+code=slofft" class="sref">clofft"/a> coffse"/a>(
  111/a>         a href="+code=sunt 8t" class="sref">cunt 8t"/a> <sec(
  12
  11        gyis_ectors/a>(= {-1
  11
  115/a>         a href="+code=sic"t_buf class="sref">sec(= 0a href="+code=ckmallo" class="sref">skmallo"/a>(ua href="+code=cECTOR_SIZE" class="sref">SECTOR_SIZE  ua href="+code=kGFP_KERNEL class="sref">SGFP_KERNEL/a>)

  11        {if(sec(
  11        {{{{{{{{{gotocou"/a>(
  18#  119/a>         apan class="comment">/*
  12 *       u< Lookfor SIS/IDI *ectors*n the cfirt 
  12           block s). Ifthe cfirt 
  12 *         bis notSSFDC Form>atte
  12 *         
  14        ior Sua href="+code=c" class="sref">k = 0; ua href="+code=koffse" class="sref">coffse"/a>(= 0;
k =lt;< 4
k ++ ua href="+code=koffse" class="sref">coffse"/a>(=+ 0a href="+code=ctd_ class="sref">gtd_/a>)-gt;erase_ize)
{
  12                htd_blkck_misbd"/a>(ua href="+code=ctd_ class="sref">gtd_/a>) ua href="+code=koffse" class="sref">coffse"/a>()
{
  16        uuuuuuuuuuuuuuuuua href="+code=cre" class="sref">cre"/a>,= 0a href="+code=ctd_brad" class="sref">htd_brad"/a>(ua href="+code=ctd_ class="sref">gtd_/a>) ua href="+code=koffse" class="sref">coffse"/a>( ua href="+code=kECTOR_SIZE" class="sref">SECTOR_SIZE  uamp; a href="+code=cre"en" class="sref">mre"en"/a>(
  12        {{{{{{{{{      uuuuuuuuuuuuuuuuua href="+code=cic"t_buf class="sref">sec(

  12#  129/a>                        uspan class="comment">*/ TIS/*pattern >atch*n the cectors*buffes*/
  130/a>                        cre"/a>,=lt;< 0 ||mre"en"/a>( ! 0a href="+code=cECTOR_SIZE" class="sref">SECTOR_SIZE 
{
  131/a>                        uuuuuuuuua href="+code=cprnt " class="sref">kprnt "/a>(ua href="+code=cKERN_WARNING class="sref">kKERN_WARNING/a>#  132/a>                                        uspan class="ctribng">"SFDC _RO:can'tcrad"SIS/IDI *ectors\n"/span>


  133/a>                        u} else{if(lmemcm"/a>(ua href="+code=cic"t_buf class="sref">sec( ua href="+code=kyis_numbrs" class="sref">cyis_numbrs"/a>[
  134/a>                <<<<<<<<<<<<<<<<<<<<<<<<cyis_numbrs"/a>[))
{
  13                <               uspan class="comment">*/ Tounda*/
  13        uuuuuuuuuuuuuuuuu       us href="+code=kyis_ectors class="sref">gyis_ectors/a>(= {(nt )coffse"/a>(=gt;>"SECTOR_SHIFT 

  13        {{{{{{{{{      uu} else{
  13                        u       us href="+code=kpr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:SIS/IDI *ectors*notSound<"/span>
  139/a>                        u               uspan class="ctribng">"*n t% (matd%d)\n"/span>
 ua href="+code=ktd_ class="sref">gtd_/a>)-gt;game=/a>[
  140/a>                        <       u       us href="+code=ktd_ class="sref">gtd_/a>)-gt;xnder"/a> 

  141/a>                        u}  142/a>                         bradk
  143/a>                 }  144/a>         }  15#  14        ua href="+code=k"ree  class="sref">k(ua href="+code=cic"t_buf class="sref">sec(

  17
cou"/a>(:  14         eturn fa href="+code=kyis_ectors class="sref">gyis_ectors/a>(
  19<}  10<  11N/ Tead ohys_ical*ectors*(wrapprsthoMTDB_READ */
  152/a>static int grad"_hys_ical_ectors/a>(utruct gtd_binfo/a>  gtd_/a>) ua href="+code=kunt 8t" class="sref">cunt 8t"/a> <sec(
  153/a>                        uuuuuuuuunt gec(
  14<
  15         nt cre"/a>,
  15        ua href="+code=kize"t" class="sref">cize"t"/a> mre"en"/a>(
  157/a>        ua href="+code=klofft" class="sref">clofft"/a> coffse"/a>(= {(a href="+code=klofft" class="sref">clofft"/a> )a href="+code=gecgec(=lt;SECTOR_SHIFT 
  15#  159/a>         a href="+code=sre" class="sref">cre"/a>,= 0a href="+code=ctd_brad" class="sref">htd_brad"/a>(ua href="+code=ctd_ class="sref">gtd_/a>) ua href="+code=koffse" class="sref">coffse"/a>( ua href="+code=kECTOR_SIZE" class="sref">SECTOR_SIZE  uamp; a href="+code=cre"en" class="sref">mre"en"/a>(
ua href="+code=cic"t_buf class="sref">sec(

  10        uif(cre"/a>,=lt;< 0 ||mre"en"/a>( ! 0a href="+code=cECTOR_SIZE" class="sref">SECTOR_SIZE 
  161/a>                 eturn f-1
  16
  163/a>         eturn f;
  14<}  16#  16 / Tead oredndatncy re a*(wrapprsthoMTDB_READ_OOB*/
  16static int grad"_raw_oob/a>(utruct gtd_binfo/a>  gtd_/a>) ua href="+code=klofft" class="sref">clofft"/a> coffs/a>) ua href="+code=kunt 8t" class="sref">cunt 8t"/a> <sbuf/a>(
  18 
  19        {truct ctd_boob_ops/a> cops/a> 
  17        int cre"/a>,
  17
  12        {a href="+code=cops class="sref">cops/a> ctde=/a>,= 0a href="+code=cTDB_OPS_RAW class="sref">cTDB_OPS_RAW/a>,
  17        cops/a> cooboffs/a>(= 0;
  14        {a href="+code=kops class="sref">cops/a> mooben"/a>,= 0a href="+code=cOB_SIZE" class="sref">OOB_SIZE 
  175/a>         a href="+code=sops class="sref">cops/a> soobbuf/a>,= 0a href="+code=cbuf class="sref">sbuf/a>(
  17        ua href="+code=kops class="sref">cops/a> sdatbuf/a>,= 0a href="+code=cNULL class="sref">SNULL/a>(
  17
  18         a href="+code=sre" class="sref">cre"/a>,= 0a href="+code=ctd_brad"_oob class="sref">gtd_brad"_oob/a>(ua href="+code=ctd_ class="sref">gtd_/a>) ua href="+code=koffs class="sref">coffs/a>) uamp; a href="+code=cops class="sref">cops/a> 

  17        inf(cre"/a>,=lt;< 0 ||cops/a> moobre"en"/a>( ! 0a href="+code=cOB_SIZE" class="sref">OOB_SIZE 
  180/a>                 eturn f-1
  18
  18        {eturn f;
  13 }  18
  18*/ TParity calculaors*n ta wordof tn bitsize */
MiBstatic int Oet_cparity/a>(unt gaumbrs/a>) unt size)
  187/a>{
  18        int k;
  18        int Oparity/a>(
  19<  191/a>         a href="+code=sparity class="sref">Oparity/a>(= 01
  192/a>         or Sua href="+code=c" class="sref">k = 0;
k =lt;< a href="+code=geze" class="sref">size)
k ++
{
  193/a>                 a href="+code=sparity class="sref">Oparity/a>(=+ {(a href="+code=knumbrs class="sref">gaumbrs/a>)=gt;>"k 

  194/a>                Oparity/a>(=amp;  01
  19         }MiB        {eturn fa href="+code=eparity class="sref">Oparity/a>(
  19 }  19#  19 / Tead ond Maluidat Fhe cogic_alblock naddress field sorsedintFhe cOOB*/
  20Oet_cogic_al_address/a>(ua href="+code=cunt 8t" class="sref">cunt 8t"/a> <soob_buf/a>(
Olkck_maddress/a>) ua href="+code=kparity class="sref">Oparity/a>(
coffse"/a>([2 = {
6, 11} /* aoffse"of the G2naddress fields withntFOOB*/
cj/a>(
ko = 0;
/*
 *********< Lookfor She cfirt 
          * Vluidcaddress has fixedipattern n tmostcigneifc_at 
  20 *        * parity check/apan>
  21 *        *
  212/a>         or Sua href="+code=cj class="sref">cj/a>(= 0;
cj/a>(=lt;< a href="+code=gARRAYSIZE" class="sref">OARRAYSIZE"/a>(ua href="+code=coffse" class="sref">coffse"/a>()
cj/a>(++
{
  213/a>                 a href="+code=slkck_maddress class="sref">Olkck_maddress/a>)= {((nt )a href="+code=coob_buf class="sref">soob_buf/a>(coffse"/a>([a href="+code=kj class="sref">cj/a>(]]=lt;  214/a>                <<<<<<<<soob_buf/a>(coffse"/a>([a href="+code=kj class="sref">cj/a>(]+1]
  21#  21        uuuuuuuuuspan class="comment">*/ TIheckfor She cigneaurnefbitsontFhe caddress field (MSBits */
  21        {{{{{{{{{nf(Olkck_maddress/a>)=amp; <~0x7FF) == 0x100 ){
  21                        ua href="+code=sparity class="sref">Oparity/a>(= 0a href="+code=clkck_maddress class="sref">Olkck_maddress/a>)=amp; <0x01
  219/a>                        us href="+code=clkck_maddress class="sref">Olkck_maddress/a>)=amp; = 0x7FF
  220/a>                        Olkck_maddress/a>)=at;>" 01
  21
  222/a>                         nf(Oet_cparity/a>(ua href="+code=glkck_maddress class="sref">Olkck_maddress/a>) u1 ){! 0a href="+code=cparity class="sref">Oparity/a>(){
  223/a>                        uuuuuuuuua href="+code=cpr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:Sogic_albaddress field%d"/span>
  224/a>                <<<<<<<<<       uuuuuuuuuapan class="ctribng">"parity error(0x%04X)\n"/span>
 ua href="+code=kj class="sref">cj/a>(+1
  22                <                       Olkck_maddress/a>)

  26        uuuuuuuuuuuuuuuuu} else{
  22        {{{{{{{{{      uuuuuuuuuua href="+code=co" class="sref">ko = 01
  22                        u       ubradk
  229/a>                        u}  230/a>                 }  231/a>         }  23
  233/a>         if(ko 
  234/a>                Olkck_maddress/a>)= {-2
  23#  23        ua href="+code=kpr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:Set_cogic_al_address()t%d\n"/span>
   23        {{{{{{{{{s href="+code=clkck_maddress class="sref">Olkck_maddress/a>)

  23#  239/a>         eturn fa href="+code=elkck_maddress class="sref">Olkck_maddress/a>)
  240/a> }  21
  24 / TBuild he cogic_block nmap*/
  243/a> tatic int Oluildcogic_al_lkck_mmap/a>(utruct gsfdc.r_recor_/a> <gsfdc./a> 
  24<
  24         nsigned long coffse"/a>(
  24        ua href="+code=kunt 8t" class="sref">cunt 8t"/a> soob_buf/a>(OOB_SIZE ]
  24        {it cre"/a>, ua href="+code=klkck_maddress class="sref">Olkck_maddress/a>) ua href="+code=kphys_lkck_ class="sref">kphys_lkck_/a>(
  24         truct gtd_binfo/a>  gtd_/a>)= 0a href="+code=csfdc. class="sref">gsfdc./a> -gt;gtb_/a>)gtd_/a>)
  249/a>
  250/a>         a href="+code=spr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:Sluildclkck_mmap()tnblks=%d (%luK)\n"/span>
   251/a>               a href="+code=csfdc. class="sref">gsfdc./a> -gt;mmap_en"/a>)   252/a>               unsigned long )a href="+code=gefdc. class="sref">gsfdc./a> -gt;mmap_en"/a>) * a href="+code=csfdc. class="sref">gsfdc./a> -gt;erase__ize &/ 1024

  25
  25        {apan class="comment"> / TScn ceersyohys_ical*lkck_, skipTIS/*lock n/
  25         or Sua href="+code=cphys_lkck_ class="sref">kphys_lkck_/a>(= 0a href="+code=csfdc. class="sref">gsfdc./a> -gt;kyis_lkck_/a>(=+ 1
kphys_lkck_/a>(=lt;< a href="+code=gefdc. class="sref">gsfdc./a> -gt;mmap_en"/a>)
  25        uuuuuuuuuuuuuuuuua href="+code=cphys_lkck_ class="sref">kphys_lkck_/a>(++
{
  25        {{{{{{{{{s href="+code=coffse" class="sref">coffse"/a>(= {(nsigned long )a href="+code=gphys_lkck_ class="sref">kphys_lkck_/a>(=* a href="+code=csfdc. class="sref">gsfdc./a> -gt;erase__ize 
  25                 if(htd_blkck_misbd"/a>(ua href="+code=ctd_ class="sref">gtd_/a>) ua href="+code=koffse" class="sref">coffse"/a>()
  259/a>                        uontainue;      {apan class="comment"> / TskipTbd"block sn/
  26<  261/a>                 a href="+code=cre" class="sref">cre"/a>,= 0a href="+code=crad"_raw_oob class="sref">grad"_raw_oob/a>(ua href="+code=ctd_ class="sref">gtd_/a>) ua href="+code=koffse" class="sref">coffse"/a>( ua href="+code=koob_buf class="sref">soob_buf/a>(

  262/a>                 if(cre"/a>,=lt;< 0
{
  263/a>                        ua href="+code=spr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:Std/ rad"_oob()tfaild lat %lu\n"/span>
   264/a>                <<<<<<<<<       ua href="+code=coffse" class="sref">coffse"/a>()
  26                <        eturn f-1
  26        uuuuuuuuu}  26        {{{{{{{{{s href="+code=clkck_maddress class="sref">Olkck_maddress/a>)= 0a href="+code=cet_cogic_al_address class="sref">Oet_cogic_al_address/a>(ua href="+code=coob_buf class="sref">soob_buf/a>(

  26#  269/a>                 apan class="comment"> / TSkipTinvluidcaddressesn/
  270/a>                 if(Olkck_maddress/a>)=at;&=0 &&   271/a>                        uuuuuuuuua href="+code=clkck_maddress class="sref">Olkck_maddress/a>)=at;< a href="+code=gMAX_LOGIC_BLK_PER_ZON" class="sref">OMAX_LOGIC_BLK_PER_ZON"/a>(){
  272/a>                         nt xzone_nder"/a> 
  27
  274/a>                <<<<<<<<xzone_nder"/a> = 0a href="+code=cphys_lkck_ class="sref">kphys_lkck_/a>(=/ a href="+code=gMAX_PHYS_BLK_PER_ZON" class="sref">OMAX_PHYS_BLK_PER_ZON"/a> 
  27                <        a href="+code=clkck_maddress class="sref">Olkck_maddress/a>)=+ 0a href="+code=czone_nder" class="sref">xzone_nder"/a> =* a href="+code=cMAX_LOGIC_BLK_PER_ZON" class="sref">OMAX_LOGIC_BLK_PER_ZON"/a>(
  27        uuuuuuuuuuuuuuuuua href="+code=csfdc. class="sref">gsfdc./a> -gt;Oogic__lkck_mmap/a>(Olkck_maddress/a>)] =  27        {{{{{{{{{      uuuuuuuuuu(nsigned lshor )a href="+code=cphys_lkck_ class="sref">kphys_lkck_/a>(
  27#  279/a>                        us href="+code=cpr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:Sluildclkck_mmap()tphys_lkck_=%d,"/span>
  280/a>                                uspan class="ctribng">"ogic__lkck_maddr=%d, zone=%d\n"/span>
   281/a>                        uuuuuuuuua href="+code=cphys_lkck_ class="sref">kphys_lkck_/a>( ua href="+code=klkck_maddress class="sref">Olkck_maddress/a>) ua href="+code=kzone_nder" class="sref">xzone_nder"/a> 

  282/a>                 }  283/a>         }  284/a>         eturn f;
  28<}MiB
  28static ivoidca href="+code=msfdc.r_add_td_ class="sref">gsfdc.r_add_td_/a>(utruct ctd_blkktrans_ops/a>  gts/a>) utruct gtd_binfo/a>  gtd_/a>)
  28 
  28        {truct gsfdc.r_recor_/a> <gsfdc./a> 
  29        int gyis_ectors/a>(
  29
  292/a>         span class="comment">*/ TIheckfor Ssmall page NANDcfasshn/
  293/a>         if(gtd_/a>)-gt;etyp"/a>  ! 0a href="+code=cTDB_NANDFLASH class="sref">OMDB_NANDFLASH/a>  ||gtd_/a>)-gt;eoobize"/a>  ! 0a href="+code=cOB_SIZE" class="sref">OOB_SIZE  ||  294/a>             a href="+code=ctd_ class="sref">gtd_/a>)-gt;size) gt;"sUINT_MAX/a>)
  29                MiB
  297/a>        uapan class="comment">/*at by rad"bngSIS/IDI *ectors*/
  29         a href="+code=syis_ectors class="sref">gyis_ectors/a>(= {a href="+code=cet_cvluid_yis_ectors class="sref">get_cvluid_yis_ectors/a>(ua href="+code=ctd_ class="sref">gtd_/a>)

  29        inf(gyis_ectors/a>(=  {-1
  300/a>                 eturn 
gsfdc./a> = 0a href="+code=ckzallo" class="sref">skzallo"/a>(uizegsfdc.r_recor_/a> ) ua href="+code=kGFP_KERNEL class="sref">SGFP_KERNEL/a>)

gsfdc./a> 
gsfdc./a> -gt;gtb_/a>)gtd_/a>)= 0a href="+code=ctd_ class="sref">gtd_/a>)
gsfdc./a> -gt;gtb_/a>)gdevnum/a>)= 0-1
gsfdc./a> -gt;gtb_/a>)gts/a>)= 0a href="+code=cts class="sref">gts/a>)
gsfdc./a> -gt;gtb_/a>)Orad"only/a>)= 01
  31<  311/a>         a href="+code=ssfdc. class="sref">gsfdc./a> -gt;kyis_lkck_/a>(= 0a href="+code=cyis_ectors class="sref">gyis_ectors/a>(=/(gtd_/a>)-gt;erase_ize)=gt;>"SECTOR_SHIFT 

  31        {a href="+code=csfdc. class="sref">gsfdc./a> -gt;erase__ize & 0a href="+code=ctd_ class="sref">gtd_/a>)-gt;erase_ize)
  313/a>         a href="+code=sifdc. class="sref">gsfdc./a> -gt;mmap_en"/a>)  {(a href="+code=ku2" class="lref">cu3
)a href="+code=ctd_ class="sref">gtd_/a>)-gt;size) / a href="+code=gtd_ class="sref">gtd_/a>)-gt;erase_ize)
  31
  315/a>         a href="+code=spr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:Syis_lkck_=%d,rase__ize<=%d,map_en"=%d,n_zones=%d\n"/span>
   31        uuuuuuuuus href="+code=ssfdc. class="sref">gsfdc./a> -gt;kyis_lkck_/a>(
ua href="+code=cifdc. class="sref">gsfdc./a> -gt;erase__ize 
ua href="+code=cifdc. class="sref">gsfdc./a> -gt;mmap_en"/a>)   31        {{{{{{{{{/ href="+code=cDIV_ROUND_UP class="sref">mDIV_ROUND_UP/a>(ua href="+code=cifdc. class="sref">gsfdc./a> -gt;mmap_en"/a>)  a href="+code=gMAX_PHYS_BLK_PER_ZON" class="sref">OMAX_PHYS_BLK_PER_ZON"/a> )

  31#  319/a>         apan class="comment"> / TSet geometry*/
  320/a>         a href="+code=sifdc. class="sref">gsfdc./a> -gt;chad"s/a>)= 016
  321/a>         a href="+code=ssfdc. class="sref">gsfdc./a> -gt;cectorss/a>)= 032
  32        {a href="+code=cet_cchs class="sref">Oet_cchs/a>(ua href="+code=ctd_ class="sref">gtd_/a>)-gt;size)  a href="+code=gNULL class="sref">SNULL/a>( uamp; a href="+code=cifdc. class="sref">gsfdc./a> -gt;chad"s/a>) uamp; a href="+code=cifdc. class="sref">gsfdc./a> -gt;cectorss/a>)

  323/a>         a href="+code=sifdc. class="sref">gsfdc./a> -gt;ccylnderss/a>)  {(nsigned lshor )(cu3
)a href="+code=ctd_ class="sref">gtd_/a>)-gt;size) gt;>"SECTOR_SHIFT 
 /  324/a>                <<<<<<<<<((ong )a href="+code=gefdc. class="sref">gsfdc./a> -gt;cectorss/a>)=* (ong )a href="+code=gefdc. class="sref">gsfdc./a> -gt;chad"s/a>))

  32#  32        ua href="+code=kpr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:SusbngSI:%d H:%d S:%d == %ld*ectos\n"/span>
   32        {{{{{{{{{a href="+code=sifdc. class="sref">gsfdc./a> -gt;ccylnderss/a>)
ua href="+code=cifdc. class="sref">gsfdc./a> -gt;chad"s/a>)=
ua href="+code=cifdc. class="sref">gsfdc./a> -gt;cectorss/a>)   32                 (ong )a href="+code=gefdc. class="sref">gsfdc./a> -gt;ccylnderss/a>) * (ong )a href="+code=gefdc. class="sref">gsfdc./a> -gt;chad"s/a>) *  329/a>                 (ong )a href="+code=gefdc. class="sref">gsfdc./a> -gt;cectorss/a>)

  33<  331/a>         a href="+code=ssfdc. class="sref">gsfdc./a> -gt;gtb_/a>)size) = (ong )a href="+code=gefdc. class="sref">gsfdc./a> -gt;chad"s/a>) * (ong )a href="+code=gefdc. class="sref">gsfdc./a> -gt;ccylnderss/a>) *  332/a>                                 (ong )a href="+code=gefdc. class="sref">gsfdc./a> -gt;cectorss/a>)
  33
  334/a>         apan class="comment"> / TAllo"at Fogic_alblock nmap*/
  335/a>         a href="+code=sefdc. class="sref">gsfdc./a> -gt;Oogic__lkck_mmap/a>(= 0a href="+code=ckmallo" class="sref">skmallo"/a>(uizegsfdc./a> -gt;Oogic__lkck_mmap/a>([0]) *  33        uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuua href="+code=cifdc. class="sref">gsfdc./a> -gt;mmap_en"/a>)  a href="+code=gGFP_KERNEL class="sref">SGFP_KERNEL/a>)

  33        {if(gsfdc./a> -gt;Oogic__lkck_mmap/a>(
  33                 gotoua href="+code=cout_ers class="sref">gout_ers/a>)
  339/a>         a href="+code=smemse" class="sref">cmemse"/a>(ua href="+code=cifdc. class="sref">gsfdc./a> -gt;Oogic__lkck_mmap/a>(, 0xff, izegsfdc./a> -gt;Oogic__lkck_mmap/a>([0]) *  340/a>                 a href="+code=cifdc. class="sref">gsfdc./a> -gt;mmap_en"/a>)

  31
  342/a>         span class="comment">*/ TBuild ogic_alblock nmap*/
  343/a>         if(Oluildcogic_al_lkck_mmap/a>(ua href="+code=cifdc. class="sref">gsfdc./a> )=lt;< 0
  344/a>                gout_ers/a>)
  34#  34        uapan class="comment"> / Teagister device + partitionsn/
  34        {if(gadd_td_blkktrans_dev/a>(uamp; a href="+code=cifdc. class="sref">gsfdc./a> -gt;gtb_/a>))
  34                 gotoua href="+code=cout_ers class="sref">gout_ers/a>)
  349/a>
  350/a>         a href="+code=sprint_ class="sref">kprint_/a>(ua href="+code=cKERN_INFO class="sref">kKERN_INFO/a>  apan class="ctribng">"SFDC _RO:SFound sfdc.%c n tmtd%d (%s)\n"/span>
   351/a>                ua href="+code=kifdc. class="sref">gsfdc./a> -gt;gtb_/a>)gdevnum/a>)=+ apan class="ctribng">'a'/span>
 ua href="+code=ktd_ class="sref">gtd_/a>)-gt;xnder"/a>  ua href="+code=ktd_ class="sref">gtd_/a>)-gt;game=/a>)

  352/a>         eturn 
  35
  35 a href="+code=cout_ers class="sref">gout_ers/a>):  355/a>         a href="+code=skfre= class="sref">gkfre=/a>(ua href="+code=cifdc. class="sref">gsfdc./a> -gt;Oogic__lkck_mmap/a>(

  35        ua href="+code=kkfre= class="sref">gkfre=/a>(ua href="+code=cifdc. class="sref">gsfdc./a> 

  35 }  35#  359/a> tatic ivoidca href="+code=msfdc.r_remove_dev class="sref">gsfdc.r_remove_dev/a>(uiruct gtd_blkktrans_dev/a>(<gdev/a>(
  36<
  361/a>         truct gsfdc.r_recor_/a> <gsfdc./a>  = (truct gsfdc.r_recor_/a> <<)a href="+code=gdev class="sref">gdev/a>(
  36
  363/a>         a href="+code=kpr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:Sremove_dev (i=%d)\n"/span>
 ua href="+code=kdev class="sref">gdev/a>(-gt;gdevnum/a>)

  36
  365/a>         a href="+code=sdel_td_blkktrans_dev class="sref">gdel_td_blkktrans_dev/a>(ua href="+code=cdev class="sref">gdev/a>(

  36        ua href="+code=kkfre= class="sref">gkfre=/a>(ua href="+code=cifdc. class="sref">gsfdc./a> -gt;Oogic__lkck_mmap/a>(

  36 }  36#  369/a> tatic int gsfdc.r_readecto/a>(uiruct gtd_blkktrans_dev/a>(<gdev/a>(   370/a>                                 nsigned long gogic__ecto_no/a>  uchar<sbuf/a>(
  371/a>s
  372/a>         truct gsfdc.r_recor_/a> <gsfdc./a>  = (truct gsfdc.r_recor_/a> <<)a href="+code=gdev class="sref">gdev/a>(
  373/a>         nt kectorss_per_lkck_/a>  ua href="+code=koffse" class="sref">coffse"/a>( ua href="+code=klkck_maddress class="sref">Olkck_maddress/a>)
  37
  375/a>         a href="+code=sectorss_per_lkck_ class="sref">kectorss_per_lkck_/a> = 0a href="+code=csfdc. class="sref">gsfdc./a> -gt;erase__ize >>"SECTOR_SHIFT 
  37        ua href="+code=koffse" class="sref">coffse"/a>(= {(nt )ua href="+code=cogic__ecto_no class="sref">gogic__ecto_no/a>  % a href="+code=sectorss_per_lkck_ class="sref">kectorss_per_lkck_/a> 

  377/a>        ua href="+code=klkck_maddress class="sref">Olkck_maddress/a>)= {(nt )ua href="+code=cogic__ecto_no class="sref">gogic__ecto_no/a>  / a href="+code=gectorss_per_lkck_ class="sref">kectorss_per_lkck_/a> 

  37#  379/a>         a href="+code=spr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:Ssfdc.r_readecto(%lu)*ect_per_lk_=%d, ofst=%d,"/span>
  380/a>                 apan class="ctribng">" lkck_maddr=%d\n"/span>
 ua href="+code=kogic__ecto_no class="sref">gogic__ecto_no/a>  ua href="+code=gectorss_per_lkck_ class="sref">kectorss_per_lkck_/a>  ua href="+code=koffse" class="sref">coffse"/a>(   381/a>                 a href="+code=klkck_maddress class="sref">Olkck_maddress/a>)

  38
  383/a>         if(Olkck_maddress/a>)=at;&=0a href="+code=cifdc. class="sref">gsfdc./a> -gt;mmap_en"/a>)
  384/a>                mBUG/a>(u

  38#MiB        ua href="+code=klkck_maddress class="sref">Olkck_maddress/a>)= 0a href="+code=cefdc. class="sref">gsfdc./a> -gt;Oogic__lkck_mmap/a>([a href="+code=klkck_maddress class="sref">Olkck_maddress/a>)]
  38s  38         a href="+code=spr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:Ssfdc.r_readecto()tphys_lkck_maddr=%d\n"/span>
   389/a>                 a href="+code=klkck_maddress class="sref">Olkck_maddress/a>)

  39<  391/a>         if(Olkck_maddress/a>)=at;< 0xffff){
  392/a>                 nsigned long gecto_no/a> 
  39
  394/a>                 a href="+code=secto_no class="sref">gecto_no/a> = {(nsigned long )a href="+code=gbkck_maddress class="sref">Olkck_maddress/a>)=* a href="+code=csctorss_per_lkck_ class="sref">kectorss_per_lkck_/a> =+  39                <                a href="+code=soffse" class="sref">coffse"/a>(
MiB
  39        {{{{{{{{{a href="+code=spr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:Ssfdc.r_readecto()tphys_ecto_no=%lu\n"/span>
   39                        ua href="+code=secto_no class="sref">gecto_no/a> 

  399/a>
  400/a>                 if(gread_hys_ical_ectors/a>(ua href="+code=cifdc. class="sref">gsfdc./a> -gt;gtb_/a>)gtd_/a>) ua href="+code=kluf class="sref">sbuf/a>( ua href="+code=gecto_no class="sref">gecto_no/a> 
=lt;< 0
kEIO/a>(
cmemse"/a>(ua href="+code=cluf class="sref">sbuf/a>( u0xff, a href="+code=SECTOR_SHZE" class="sref">OECTOR_SHZE"/a> 

gefdc.r_getgeo/a>(uiruct gtd_blkktrans_dev/a>(<gdev/a>(   truct ghd_geometry/a>(<ggeo/a>(
  41<
  411/a>         truct gsfdc.r_recor_/a> <gsfdc./a>  = (truct gsfdc.r_recor_/a> <<)a href="+code=gdev class="sref">gdev/a>(
  41
  413/a>         a href="+code=spr_debug class="sref">kpr_debug/a>(uapan class="ctribng">"SFDC _RO:Ssfdc.r_getgeo()tC=%d, H=%d, S=%d\n"/span>
   414/a>                <<<<<<<<gsfdc./a> -gt;ccylnderss/a>)
ua href="+code=cifdc. class="sref">gsfdc./a> -gt;chad"s/a>)
ua href="+code=cifdc. class="sref">gsfdc./a> -gt;cectorss/a>)

  41#  41        ua href="+code=kgeo class="sref">ggeo/a>(-gt;chad"s/a>)= 0a href="+code=cifdc. class="sref">gsfdc./a> -gt;chad"s/a>)
  417/a>        ua href="+code=kgeo class="sref">ggeo/a>(-gt;cectorss/a>)= 0a href="+code=cifdc. class="sref">gsfdc./a> -gt;cectorss/a>)
  41         a href="+code=sgeo class="sref">ggeo/a>(-gt;ccylnderss/a>)  {a href="+code=cifdc. class="sref">gsfdc./a> -gt;ccylnderss/a>)
  419/a>
  420/a>         eturn f;
  421/a> }  42
  423/a> apan class="comment"> /                                                                            /span>
  424/a> apan class="comment">   /span>
  42#apan class="comment">    Module truff/span>
  42 apan class="comment">   /span>
  42 apan class="comment">                                                                              
  42#  429/a> tatic itruct ctd_blkktrans_ops/a>  a href="+code=msfdc.r_ts class="sref">gsfdc.r_ts/a>)  {
  430/a>         game=/a>)  <<<<<<<<<= apan class="ctribng">"sfdc."/span>
   431/a>         gmajrs/a>)  <<<<<<<< {a href="+code=cSFDC R_MAJOR class="sref">OEFDC R_MAJOR/a>(   432/a>         cpart_bits/a>        {a href="+code=cSFDC R_PARTN_BITS class="sref">OEFDC R_PARTN_BITS/a>(   433/a>         elkkize"/a>          {a href="+code=cSCTOR_SHZE" class="sref">OECTOR_SHZE"/a>    434/a>         ggetgeo/a>( <<<<<<<< {a href="+code=csfdc.r_getgeo class="sref">gefdc.r_getgeo/a>(   435/a>         greadecto/a>(<<<<<<< {a href="+code=csfdc.r_readecto class="sref">gsfdc.r_readecto/a>(   43        ugadd_td_/a>(<<<<<<<< {a href="+code=csfdc.r_add_td_ class="sref">gsfdc.r_add_td_/a>(   43        {gremove_dev/a>(<<<<< {a href="+code=csfdc.r_remove_dev class="sref">gsfdc.r_remove_dev/a>(   43         gownes/a>)  <<<<<<<< {a href="+code=cTHIS_MODUL" class="sref">OTHIS_MODUL"/a>(   439/a> }
  44<  41
tatic int g__inio/a>  a href="+code=minio_sfdc.r class="sref">ginio_sfdc.r/a>(uvoid
  442/a> 
  443/a>         a href="+code=sprint_ class="sref">kprint_/a>(ua href="+code=cKERN_INFO class="sref">kKERN_INFO/a>  apan class="ctribng">"SFDC  rad"-only FlsshnTranslation layer\n"/span>


  44
  445/a>         eturn fa href="+code=sragister_td_blkktrans class="sref">gregister_td_blkktrans/a>(uamp; a href="+code=cifdc.r_ts class="sref">gsfdc.r_ts/a>)

  44 }  44s  44 tatic ivoidca href="+code=m__exio class="sref">g__exio/a>  a href="+code=mcleanup_sfdc.r class="sref">gcleanup_sfdc.r/a>(uvoid
  449/a>

  450/a>         a href="+code=sderagister_td_blkktrans class="sref">gderagister_td_blkktrans/a>(uamp; a href="+code=cifdc.r_ts class="sref">gsfdc.r_ts/a>)

  451/a> }  45
  45
a href="+code=smodule_inio class="sref">gmodule_inio/a>(ua href="+code=cinio_sfdc.r class="sref">ginio_sfdc.r/a>(

  45 a href="+code=cmodule_exio class="sref">gmodule_exio/a>(ua href="+code=ccleanup_sfdc.r class="sref">gcleanup_sfdc.r/a>(

  45#  45 a href="+code=cMODUL"_LICENS" class="sref">OMODUL"_LICENS"/a>(uapan class="ctribng">"GPL"/span>


  45 a href="+code=cMODUL"_AUTHOR class="sref">OMODUL"_AUTHOR/a>(uapan class="ctribng">"Claudio Lanconelli=lt;


  45#a href="+code=cMODUL"_DESCRIPTION class="sref">OMODUL"_DESCRIPTION/a>(uapan class="ctribng">"FlsshnTranslation Layerfor Srad"-only SFDC  SmartMedia cardgquot;/span>


  459/a> 
The original LXR software by the a href="dhttp://sourceor ge.net/projctos/lxr">LXR ommeunioy/a>) uthis experient"al ers/ion by a href="dmailto:lxr@ineux.no">lxr@ineux.no/a>).
lxr.ineux.no kindly hosted by a href="dhttp://www.redpill-inepro.no">Redpill Lnepro AS/a>( provider of Lneux omnsultbngSand operationsnservicesnsince 1995.