コード例 #1
0
static bool valid_bmt_data(phys_bmt_struct * phys_table)
{
    int i;
    u8 checksum = cal_bmt_checksum(phys_table, bmt_block_count);

    // checksum correct?
    if (phys_table->header.checksum != checksum)
    {
        MSG(INIT, "BMT Data checksum error: %x %x\n", phys_table->header.checksum, checksum);
        return false;
    }

    MSG(INIT, "BMT Checksum is: 0x%x\n", phys_table->header.checksum);

    // block index correct?
    for (i = 0; i < phys_table->header.mapped_count; i++)
    {
        if (phys_table->table[i].bad_index >= total_block_count || phys_table->table[i].mapped_index >= total_block_count || phys_table->table[i].mapped_index < system_block_count)
        {
            MSG(INIT, "index error: bad_index: %d, mapped_index: %d\n", phys_table->table[i].bad_index, phys_table->table[i].mapped_index);
            return false;
        }
    }

    // pass check, valid bmt.
    MSG(INIT, "Valid BMT, version v%d\n", phys_table->header.version);
    return true;
}
コード例 #2
0
ファイル: bmt.c プロジェクト: ndmsystems/linux-2.6.36
static void fill_nand_bmt_buffer(bmt_struct *bmt, u8 *dat, u8 *oob)
{
    dump_bmt_info(bmt);

    // fill phys_bmt_struct structure with bmt_struct
    memset(&fnbb_phys_bmt, 0xFF, sizeof(fnbb_phys_bmt));
    
    memcpy(fnbb_phys_bmt.header.signature, MAIN_SIGNATURE, SIGNATURE_SIZE);
    fnbb_phys_bmt.header.version = BMT_VERSION;
    fnbb_phys_bmt.header.mapped_count = bmt->mapped_count;
    memcpy(fnbb_phys_bmt.table, bmt->table, sizeof(bmt_entry) * bmt_block_count);

    fnbb_phys_bmt.header.checksum = cal_bmt_checksum(&fnbb_phys_bmt, bmt_block_count);

    memcpy(dat + MAIN_SIGNATURE_OFFSET, &fnbb_phys_bmt, sizeof(fnbb_phys_bmt));

    return;
}