コード例 #1
0
ファイル: merge.c プロジェクト: djytw/bootloader
/*
************************************************************************************************************************
*                       NAND FLASH LOGIC MANAGE LAYER MERGE LOG BLOCK
*
*Description: Merge the log block whoes mapping table is active.
*
*Arguments  : nMode     the type of the merge;
*                       = 0     normal merge, the log block  table is not full;
*                       = 1     special merge, the log block table is full.
*
*Return     : merge result;
*               = 0     merge log successful;
*               = -1    do bad block manage failed.
************************************************************************************************************************
*/
__s32 LML_MergeLogBlk(__u32 nMode, __u32 nlogical)
{
    __u8 InOrder;
    __u16 nValidPage;
	__s32 ret;

    _get_page_map_tbl_info(nlogical,&InOrder,&nValidPage);

    if (InOrder)
    {
    	//DBUG_INF("--%x swap--\n", nlogical);
    	ret = (_log2data_swap_merge(nlogical));
    }
    else{
        if ( (nMode == SPECIAL_MERGE_MODE) && (nValidPage < PAGE_CNT_OF_SUPER_BLK/(INTERLEAVE_BANK_CNT+1)))
        {
        	//DBUG_INF("--%x move--\n", nlogical);
        	ret =  (_free2log_move_merge(nlogical));
        }
        else
        {
        	//DBUG_INF("--%x simple--\n", nlogical);
			ret =  (_free2data_simple_merge(nlogical));
        }
    }

	//DBUG_INF("--%x merge end--\n", nlogical);
	return ret;

}