博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NAND BBT code
阅读量:4285 次
发布时间:2019-05-27

本文共 2781 字,大约阅读时间需要 9 分钟。

FILENAME:/// /** * search_bbt - [GENERIC] scan the device for a specific bad block table * @mtd: MTD device structure * @buf: temporary buffer * @td: descriptor for the bad block table * * Read the bad block table by searching for a given ident pattern. Search is * preformed either from the beginning up or from the end of the device * downwards. The search starts always at the start of a block. If the option * NAND_BBT_PERCHIP is given, each chip is searched for a bbt, which contains * the bad block information of this chip. This is necessary to provide support * for certain DOC devices. * * The bbt ident pattern resides in the oob area of the first page in a block. */static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td){    struct nand_chip *this = mtd->priv;    int i, chips;    int bits, startblock, block, dir;    int scanlen = mtd->writesize + mtd->oobsize;    int bbtblocks;    int blocktopage = this->bbt_erase_shift - this->page_shift;    /* Search direction top -> down? */    if (td->options & NAND_BBT_LASTBLOCK) {        startblock = (mtd->size >> this->bbt_erase_shift) - 1;        dir = -1;    } else {        startblock = 0;        dir = 1;    }    /* Do we have a bbt per chip? */    if (td->options & NAND_BBT_PERCHIP) {        chips = this->numchips;        bbtblocks = this->chipsize >> this->bbt_erase_shift;        startblock &= bbtblocks - 1;    } else {        chips = 1;        bbtblocks = mtd->size >> this->bbt_erase_shift;    }    /* Number of bits for each erase block in the bbt */    bits = td->options & NAND_BBT_NRBITS_MSK;    for (i = 0; i < chips; i++) {        /* Reset version information */        td->version[i] = 0;        td->pages[i] = -1;        /* Scan the maximum number of blocks */        for (block = 0; block < td->maxblocks; block++) {            int actblock = startblock + dir * block;            loff_t offs = (loff_t)actblock << this->bbt_erase_shift;            /* Read first page */            scan_read(mtd, buf, offs, mtd->writesize, td);            if (!check_pattern(buf, scanlen, mtd->writesize, td)) {                td->pages[i] = actblock << blocktopage;                if (td->options & NAND_BBT_VERSION) {                    offs = bbt_get_ver_offs(mtd, td);                    td->version[i] = buf[offs];                }                break;            }        }        startblock += this->chipsize >> this->bbt_erase_shift;    }    /* Check, if we found a bbt for each requested chip */    for (i = 0; i < chips; i++) {        if (td->pages[i] == -1)            pr_warn("Bad block table not found for chip %d\n", i);        else            pr_info("Bad block table found at page %d, version "                 "0x%02X\n", td->pages[i], td->version[i]);    }    return 0;}

转载地址:http://vqsgi.baihongyu.com/

你可能感兴趣的文章
JavaScript利用URL向后台传入中文参数乱码问题解决之道!
查看>>
网页布局框架之Iframe
查看>>
Tomcat发布多个项目抛出异常
查看>>
Hibernate坑爹之实体类与数据库字段
查看>>
SpringMvc前端提交多个对象,后台接收
查看>>
关于Request
查看>>
AJAX——核心XMLHttpRequest对象
查看>>
Java处理js输入特殊字符(如“+、@、¥”)
查看>>
Mysql注释
查看>>
MySQL(root用户)密码重置
查看>>
grant授权
查看>>
MySQL创建用户与授权方法
查看>>
MySql数据类型
查看>>
MySql简单sql使用
查看>>
"未能加载文件或程序集“MySql.Data, Version=6.9.3.0”或它的某一个依赖项。
查看>>
CodeFirst for MySql
查看>>
Code Frist for Mysql 实例
查看>>
Visual Studio 开源控件扩展 NuGet 常用命令及常用组件
查看>>
mysql局域网访问设置
查看>>
UEditor 编辑器跨域上传解决方法
查看>>