diff options
Diffstat (limited to 'drivers/staging/spectra/flash.c')
-rw-r--r-- | drivers/staging/spectra/flash.c | 420 |
1 files changed, 2 insertions, 418 deletions
diff --git a/drivers/staging/spectra/flash.c b/drivers/staging/spectra/flash.c index 134aa5166a8..9b5218b6ada 100644 --- a/drivers/staging/spectra/flash.c +++ b/drivers/staging/spectra/flash.c | |||
@@ -61,7 +61,6 @@ static void FTL_Cache_Read_Page(u8 *pData, u64 dwPageAddr, | |||
61 | static void FTL_Cache_Write_Page(u8 *pData, u64 dwPageAddr, | 61 | static void FTL_Cache_Write_Page(u8 *pData, u64 dwPageAddr, |
62 | u8 cache_blk, u16 flag); | 62 | u8 cache_blk, u16 flag); |
63 | static int FTL_Cache_Write(void); | 63 | static int FTL_Cache_Write(void); |
64 | static int FTL_Cache_Write_Back(u8 *pData, u64 blk_addr); | ||
65 | static void FTL_Calculate_LRU(void); | 64 | static void FTL_Calculate_LRU(void); |
66 | static u32 FTL_Get_Block_Index(u32 wBlockNum); | 65 | static u32 FTL_Get_Block_Index(u32 wBlockNum); |
67 | 66 | ||
@@ -86,8 +85,6 @@ static u32 FTL_Replace_MWBlock(void); | |||
86 | static int FTL_Replace_Block(u64 blk_addr); | 85 | static int FTL_Replace_Block(u64 blk_addr); |
87 | static int FTL_Adjust_Relative_Erase_Count(u32 Index_of_MAX); | 86 | static int FTL_Adjust_Relative_Erase_Count(u32 Index_of_MAX); |
88 | 87 | ||
89 | static int FTL_Flash_Error_Handle(u8 *pData, u64 old_page_addr, u64 blk_addr); | ||
90 | |||
91 | struct device_info_tag DeviceInfo; | 88 | struct device_info_tag DeviceInfo; |
92 | struct flash_cache_tag Cache; | 89 | struct flash_cache_tag Cache; |
93 | static struct spectra_l2_cache_info cache_l2; | 90 | static struct spectra_l2_cache_info cache_l2; |
@@ -775,7 +772,7 @@ static void dump_cache_l2_table(void) | |||
775 | { | 772 | { |
776 | struct list_head *p; | 773 | struct list_head *p; |
777 | struct spectra_l2_cache_list *pnd; | 774 | struct spectra_l2_cache_list *pnd; |
778 | int n, i; | 775 | int n; |
779 | 776 | ||
780 | n = 0; | 777 | n = 0; |
781 | list_for_each(p, &cache_l2.table.list) { | 778 | list_for_each(p, &cache_l2.table.list) { |
@@ -1538,79 +1535,6 @@ static int FTL_Cache_Write_All(u8 *pData, u64 blk_addr) | |||
1538 | } | 1535 | } |
1539 | 1536 | ||
1540 | /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | 1537 | /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& |
1541 | * Function: FTL_Cache_Update_Block | ||
1542 | * Inputs: pointer to buffer,page address,block address | ||
1543 | * Outputs: PASS=0 / FAIL=1 | ||
1544 | * Description: It updates the cache | ||
1545 | *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ | ||
1546 | static int FTL_Cache_Update_Block(u8 *pData, | ||
1547 | u64 old_page_addr, u64 blk_addr) | ||
1548 | { | ||
1549 | int i, j; | ||
1550 | u8 *buf = pData; | ||
1551 | int wResult = PASS; | ||
1552 | int wFoundInCache; | ||
1553 | u64 page_addr; | ||
1554 | u64 addr; | ||
1555 | u64 old_blk_addr; | ||
1556 | u16 page_offset; | ||
1557 | |||
1558 | nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", | ||
1559 | __FILE__, __LINE__, __func__); | ||
1560 | |||
1561 | old_blk_addr = (u64)(old_page_addr >> | ||
1562 | DeviceInfo.nBitsInBlockDataSize) * DeviceInfo.wBlockDataSize; | ||
1563 | page_offset = (u16)(GLOB_u64_Remainder(old_page_addr, 2) >> | ||
1564 | DeviceInfo.nBitsInPageDataSize); | ||
1565 | |||
1566 | for (i = 0; i < DeviceInfo.wPagesPerBlock; i += Cache.pages_per_item) { | ||
1567 | page_addr = old_blk_addr + i * DeviceInfo.wPageDataSize; | ||
1568 | if (i != page_offset) { | ||
1569 | wFoundInCache = FAIL; | ||
1570 | for (j = 0; j < CACHE_ITEM_NUM; j++) { | ||
1571 | addr = Cache.array[j].address; | ||
1572 | addr = FTL_Get_Physical_Block_Addr(addr) + | ||
1573 | GLOB_u64_Remainder(addr, 2); | ||
1574 | if ((addr >= page_addr) && addr < | ||
1575 | (page_addr + Cache.cache_item_size)) { | ||
1576 | wFoundInCache = PASS; | ||
1577 | buf = Cache.array[j].buf; | ||
1578 | Cache.array[j].changed = SET; | ||
1579 | #if CMD_DMA | ||
1580 | #if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE | ||
1581 | int_cache[ftl_cmd_cnt].item = j; | ||
1582 | int_cache[ftl_cmd_cnt].cache.address = | ||
1583 | Cache.array[j].address; | ||
1584 | int_cache[ftl_cmd_cnt].cache.changed = | ||
1585 | Cache.array[j].changed; | ||
1586 | #endif | ||
1587 | #endif | ||
1588 | break; | ||
1589 | } | ||
1590 | } | ||
1591 | if (FAIL == wFoundInCache) { | ||
1592 | if (ERR == FTL_Cache_Read_All(g_pTempBuf, | ||
1593 | page_addr)) { | ||
1594 | wResult = FAIL; | ||
1595 | break; | ||
1596 | } | ||
1597 | buf = g_pTempBuf; | ||
1598 | } | ||
1599 | } else { | ||
1600 | buf = pData; | ||
1601 | } | ||
1602 | |||
1603 | if (FAIL == FTL_Cache_Write_All(buf, | ||
1604 | blk_addr + (page_addr - old_blk_addr))) { | ||
1605 | wResult = FAIL; | ||
1606 | break; | ||
1607 | } | ||
1608 | } | ||
1609 | |||
1610 | return wResult; | ||
1611 | } | ||
1612 | |||
1613 | /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | ||
1614 | * Function: FTL_Copy_Block | 1538 | * Function: FTL_Copy_Block |
1615 | * Inputs: source block address | 1539 | * Inputs: source block address |
1616 | * Destination block address | 1540 | * Destination block address |
@@ -1698,7 +1622,7 @@ static int get_l2_cache_blks(void) | |||
1698 | static int erase_l2_cache_blocks(void) | 1622 | static int erase_l2_cache_blocks(void) |
1699 | { | 1623 | { |
1700 | int i, ret = PASS; | 1624 | int i, ret = PASS; |
1701 | u32 pblk, lblk; | 1625 | u32 pblk, lblk = BAD_BLOCK; |
1702 | u64 addr; | 1626 | u64 addr; |
1703 | u32 *pbt = (u32 *)g_pBlockTable; | 1627 | u32 *pbt = (u32 *)g_pBlockTable; |
1704 | 1628 | ||
@@ -2004,87 +1928,6 @@ static int search_l2_cache(u8 *buf, u64 logical_addr) | |||
2004 | return ret; | 1928 | return ret; |
2005 | } | 1929 | } |
2006 | 1930 | ||
2007 | /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | ||
2008 | * Function: FTL_Cache_Write_Back | ||
2009 | * Inputs: pointer to data cached in sys memory | ||
2010 | * address of free block in flash | ||
2011 | * Outputs: PASS=0 / FAIL=1 | ||
2012 | * Description: writes all the pages of Cache Block to flash | ||
2013 | * | ||
2014 | *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ | ||
2015 | static int FTL_Cache_Write_Back(u8 *pData, u64 blk_addr) | ||
2016 | { | ||
2017 | int i, j, iErase; | ||
2018 | u64 old_page_addr, addr, phy_addr; | ||
2019 | u32 *pbt = (u32 *)g_pBlockTable; | ||
2020 | u32 lba; | ||
2021 | |||
2022 | nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", | ||
2023 | __FILE__, __LINE__, __func__); | ||
2024 | |||
2025 | old_page_addr = FTL_Get_Physical_Block_Addr(blk_addr) + | ||
2026 | GLOB_u64_Remainder(blk_addr, 2); | ||
2027 | |||
2028 | iErase = (FAIL == FTL_Replace_Block(blk_addr)) ? PASS : FAIL; | ||
2029 | |||
2030 | pbt[BLK_FROM_ADDR(blk_addr)] &= (~SPARE_BLOCK); | ||
2031 | |||
2032 | #if CMD_DMA | ||
2033 | p_BTableChangesDelta = (struct BTableChangesDelta *)g_pBTDelta_Free; | ||
2034 | g_pBTDelta_Free += sizeof(struct BTableChangesDelta); | ||
2035 | |||
2036 | p_BTableChangesDelta->ftl_cmd_cnt = ftl_cmd_cnt; | ||
2037 | p_BTableChangesDelta->BT_Index = (u32)(blk_addr >> | ||
2038 | DeviceInfo.nBitsInBlockDataSize); | ||
2039 | p_BTableChangesDelta->BT_Entry_Value = | ||
2040 | pbt[(u32)(blk_addr >> DeviceInfo.nBitsInBlockDataSize)]; | ||
2041 | p_BTableChangesDelta->ValidFields = 0x0C; | ||
2042 | #endif | ||
2043 | |||
2044 | if (IN_PROGRESS_BLOCK_TABLE != g_cBlockTableStatus) { | ||
2045 | g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; | ||
2046 | FTL_Write_IN_Progress_Block_Table_Page(); | ||
2047 | } | ||
2048 | |||
2049 | for (i = 0; i < RETRY_TIMES; i++) { | ||
2050 | if (PASS == iErase) { | ||
2051 | phy_addr = FTL_Get_Physical_Block_Addr(blk_addr); | ||
2052 | if (FAIL == GLOB_FTL_Block_Erase(phy_addr)) { | ||
2053 | lba = BLK_FROM_ADDR(blk_addr); | ||
2054 | MARK_BLOCK_AS_BAD(pbt[lba]); | ||
2055 | i = RETRY_TIMES; | ||
2056 | break; | ||
2057 | } | ||
2058 | } | ||
2059 | |||
2060 | for (j = 0; j < CACHE_ITEM_NUM; j++) { | ||
2061 | addr = Cache.array[j].address; | ||
2062 | if ((addr <= blk_addr) && | ||
2063 | ((addr + Cache.cache_item_size) > blk_addr)) | ||
2064 | cache_block_to_write = j; | ||
2065 | } | ||
2066 | |||
2067 | phy_addr = FTL_Get_Physical_Block_Addr(blk_addr); | ||
2068 | if (PASS == FTL_Cache_Update_Block(pData, | ||
2069 | old_page_addr, phy_addr)) { | ||
2070 | cache_block_to_write = UNHIT_CACHE_ITEM; | ||
2071 | break; | ||
2072 | } else { | ||
2073 | iErase = PASS; | ||
2074 | } | ||
2075 | } | ||
2076 | |||
2077 | if (i >= RETRY_TIMES) { | ||
2078 | if (ERR == FTL_Flash_Error_Handle(pData, | ||
2079 | old_page_addr, blk_addr)) | ||
2080 | return ERR; | ||
2081 | else | ||
2082 | return FAIL; | ||
2083 | } | ||
2084 | |||
2085 | return PASS; | ||
2086 | } | ||
2087 | |||
2088 | /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | 1931 | /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& |
2089 | * Function: FTL_Cache_Write_Page | 1932 | * Function: FTL_Cache_Write_Page |
2090 | * Inputs: Pointer to buffer, page address, cache block number | 1933 | * Inputs: Pointer to buffer, page address, cache block number |
@@ -2370,159 +2213,6 @@ static int FTL_Write_Block_Table(int wForce) | |||
2370 | return 1; | 2213 | return 1; |
2371 | } | 2214 | } |
2372 | 2215 | ||
2373 | /****************************************************************** | ||
2374 | * Function: GLOB_FTL_Flash_Format | ||
2375 | * Inputs: none | ||
2376 | * Outputs: PASS | ||
2377 | * Description: The block table stores bad block info, including MDF+ | ||
2378 | * blocks gone bad over the ages. Therefore, if we have a | ||
2379 | * block table in place, then use it to scan for bad blocks | ||
2380 | * If not, then scan for MDF. | ||
2381 | * Now, a block table will only be found if spectra was already | ||
2382 | * being used. For a fresh flash, we'll go thru scanning for | ||
2383 | * MDF. If spectra was being used, then there is a chance that | ||
2384 | * the MDF has been corrupted. Spectra avoids writing to the | ||
2385 | * first 2 bytes of the spare area to all pages in a block. This | ||
2386 | * covers all known flash devices. However, since flash | ||
2387 | * manufacturers have no standard of where the MDF is stored, | ||
2388 | * this cannot guarantee that the MDF is protected for future | ||
2389 | * devices too. The initial scanning for the block table assures | ||
2390 | * this. It is ok even if the block table is outdated, as all | ||
2391 | * we're looking for are bad block markers. | ||
2392 | * Use this when mounting a file system or starting a | ||
2393 | * new flash. | ||
2394 | * | ||
2395 | *********************************************************************/ | ||
2396 | static int FTL_Format_Flash(u8 valid_block_table) | ||
2397 | { | ||
2398 | u32 i, j; | ||
2399 | u32 *pbt = (u32 *)g_pBlockTable; | ||
2400 | u32 tempNode; | ||
2401 | int ret; | ||
2402 | |||
2403 | #if CMD_DMA | ||
2404 | u32 *pbtStartingCopy = (u32 *)g_pBTStartingCopy; | ||
2405 | if (ftl_cmd_cnt) | ||
2406 | return FAIL; | ||
2407 | #endif | ||
2408 | |||
2409 | if (FAIL == FTL_Check_Block_Table(FAIL)) | ||
2410 | valid_block_table = 0; | ||
2411 | |||
2412 | if (valid_block_table) { | ||
2413 | u8 switched = 1; | ||
2414 | u32 block, k; | ||
2415 | |||
2416 | k = DeviceInfo.wSpectraStartBlock; | ||
2417 | while (switched && (k < DeviceInfo.wSpectraEndBlock)) { | ||
2418 | switched = 0; | ||
2419 | k++; | ||
2420 | for (j = DeviceInfo.wSpectraStartBlock, i = 0; | ||
2421 | j <= DeviceInfo.wSpectraEndBlock; | ||
2422 | j++, i++) { | ||
2423 | block = (pbt[i] & ~BAD_BLOCK) - | ||
2424 | DeviceInfo.wSpectraStartBlock; | ||
2425 | if (block != i) { | ||
2426 | switched = 1; | ||
2427 | tempNode = pbt[i]; | ||
2428 | pbt[i] = pbt[block]; | ||
2429 | pbt[block] = tempNode; | ||
2430 | } | ||
2431 | } | ||
2432 | } | ||
2433 | if ((k == DeviceInfo.wSpectraEndBlock) && switched) | ||
2434 | valid_block_table = 0; | ||
2435 | } | ||
2436 | |||
2437 | if (!valid_block_table) { | ||
2438 | memset(g_pBlockTable, 0, | ||
2439 | DeviceInfo.wDataBlockNum * sizeof(u32)); | ||
2440 | memset(g_pWearCounter, 0, | ||
2441 | DeviceInfo.wDataBlockNum * sizeof(u8)); | ||
2442 | if (DeviceInfo.MLCDevice) | ||
2443 | memset(g_pReadCounter, 0, | ||
2444 | DeviceInfo.wDataBlockNum * sizeof(u16)); | ||
2445 | #if CMD_DMA | ||
2446 | memset(g_pBTStartingCopy, 0, | ||
2447 | DeviceInfo.wDataBlockNum * sizeof(u32)); | ||
2448 | memset(g_pWearCounterCopy, 0, | ||
2449 | DeviceInfo.wDataBlockNum * sizeof(u8)); | ||
2450 | if (DeviceInfo.MLCDevice) | ||
2451 | memset(g_pReadCounterCopy, 0, | ||
2452 | DeviceInfo.wDataBlockNum * sizeof(u16)); | ||
2453 | #endif | ||
2454 | for (j = DeviceInfo.wSpectraStartBlock, i = 0; | ||
2455 | j <= DeviceInfo.wSpectraEndBlock; | ||
2456 | j++, i++) { | ||
2457 | if (GLOB_LLD_Get_Bad_Block((u32)j)) | ||
2458 | pbt[i] = (u32)(BAD_BLOCK | j); | ||
2459 | } | ||
2460 | } | ||
2461 | |||
2462 | nand_dbg_print(NAND_DBG_WARN, "Erasing all blocks in the NAND\n"); | ||
2463 | |||
2464 | for (j = DeviceInfo.wSpectraStartBlock, i = 0; | ||
2465 | j <= DeviceInfo.wSpectraEndBlock; | ||
2466 | j++, i++) { | ||
2467 | if ((pbt[i] & BAD_BLOCK) != BAD_BLOCK) { | ||
2468 | ret = GLOB_LLD_Erase_Block(j); | ||
2469 | if (FAIL == ret) { | ||
2470 | pbt[i] = (u32)(j); | ||
2471 | MARK_BLOCK_AS_BAD(pbt[i]); | ||
2472 | nand_dbg_print(NAND_DBG_WARN, | ||
2473 | "NAND Program fail in %s, Line %d, " | ||
2474 | "Function: %s, new Bad Block %d generated!\n", | ||
2475 | __FILE__, __LINE__, __func__, (int)j); | ||
2476 | } else { | ||
2477 | pbt[i] = (u32)(SPARE_BLOCK | j); | ||
2478 | } | ||
2479 | } | ||
2480 | #if CMD_DMA | ||
2481 | pbtStartingCopy[i] = pbt[i]; | ||
2482 | #endif | ||
2483 | } | ||
2484 | |||
2485 | g_wBlockTableOffset = 0; | ||
2486 | for (i = 0; (i <= (DeviceInfo.wSpectraEndBlock - | ||
2487 | DeviceInfo.wSpectraStartBlock)) | ||
2488 | && ((pbt[i] & BAD_BLOCK) == BAD_BLOCK); i++) | ||
2489 | ; | ||
2490 | if (i > (DeviceInfo.wSpectraEndBlock - DeviceInfo.wSpectraStartBlock)) { | ||
2491 | printk(KERN_ERR "All blocks bad!\n"); | ||
2492 | return FAIL; | ||
2493 | } else { | ||
2494 | g_wBlockTableIndex = pbt[i] & ~BAD_BLOCK; | ||
2495 | if (i != BLOCK_TABLE_INDEX) { | ||
2496 | tempNode = pbt[i]; | ||
2497 | pbt[i] = pbt[BLOCK_TABLE_INDEX]; | ||
2498 | pbt[BLOCK_TABLE_INDEX] = tempNode; | ||
2499 | } | ||
2500 | } | ||
2501 | pbt[BLOCK_TABLE_INDEX] &= (~SPARE_BLOCK); | ||
2502 | |||
2503 | #if CMD_DMA | ||
2504 | pbtStartingCopy[BLOCK_TABLE_INDEX] &= (~SPARE_BLOCK); | ||
2505 | #endif | ||
2506 | |||
2507 | g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; | ||
2508 | memset(g_pBTBlocks, 0xFF, | ||
2509 | (1 + LAST_BT_ID - FIRST_BT_ID) * sizeof(u32)); | ||
2510 | g_pBTBlocks[FIRST_BT_ID-FIRST_BT_ID] = g_wBlockTableIndex; | ||
2511 | FTL_Write_Block_Table(FAIL); | ||
2512 | |||
2513 | for (i = 0; i < CACHE_ITEM_NUM; i++) { | ||
2514 | Cache.array[i].address = NAND_CACHE_INIT_ADDR; | ||
2515 | Cache.array[i].use_cnt = 0; | ||
2516 | Cache.array[i].changed = CLEAR; | ||
2517 | } | ||
2518 | |||
2519 | #if (RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE && CMD_DMA) | ||
2520 | memcpy((void *)&cache_start_copy, (void *)&Cache, | ||
2521 | sizeof(struct flash_cache_tag)); | ||
2522 | #endif | ||
2523 | return PASS; | ||
2524 | } | ||
2525 | |||
2526 | static int force_format_nand(void) | 2216 | static int force_format_nand(void) |
2527 | { | 2217 | { |
2528 | u32 i; | 2218 | u32 i; |
@@ -3031,112 +2721,6 @@ static int FTL_Read_Block_Table(void) | |||
3031 | return wResult; | 2721 | return wResult; |
3032 | } | 2722 | } |
3033 | 2723 | ||
3034 | |||
3035 | /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | ||
3036 | * Function: FTL_Flash_Error_Handle | ||
3037 | * Inputs: Pointer to data | ||
3038 | * Page address | ||
3039 | * Block address | ||
3040 | * Outputs: PASS=0 / FAIL=1 | ||
3041 | * Description: It handles any error occured during Spectra operation | ||
3042 | *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ | ||
3043 | static int FTL_Flash_Error_Handle(u8 *pData, u64 old_page_addr, | ||
3044 | u64 blk_addr) | ||
3045 | { | ||
3046 | u32 i; | ||
3047 | int j; | ||
3048 | u32 tmp_node, blk_node = BLK_FROM_ADDR(blk_addr); | ||
3049 | u64 phy_addr; | ||
3050 | int wErase = FAIL; | ||
3051 | int wResult = FAIL; | ||
3052 | u32 *pbt = (u32 *)g_pBlockTable; | ||
3053 | |||
3054 | nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", | ||
3055 | __FILE__, __LINE__, __func__); | ||
3056 | |||
3057 | if (ERR == GLOB_FTL_Garbage_Collection()) | ||
3058 | return ERR; | ||
3059 | |||
3060 | do { | ||
3061 | for (i = DeviceInfo.wSpectraEndBlock - | ||
3062 | DeviceInfo.wSpectraStartBlock; | ||
3063 | i > 0; i--) { | ||
3064 | if (IS_SPARE_BLOCK(i)) { | ||
3065 | tmp_node = (u32)(BAD_BLOCK | | ||
3066 | pbt[blk_node]); | ||
3067 | pbt[blk_node] = (u32)(pbt[i] & | ||
3068 | (~SPARE_BLOCK)); | ||
3069 | pbt[i] = tmp_node; | ||
3070 | #if CMD_DMA | ||
3071 | p_BTableChangesDelta = | ||
3072 | (struct BTableChangesDelta *) | ||
3073 | g_pBTDelta_Free; | ||
3074 | g_pBTDelta_Free += | ||
3075 | sizeof(struct BTableChangesDelta); | ||
3076 | |||
3077 | p_BTableChangesDelta->ftl_cmd_cnt = | ||
3078 | ftl_cmd_cnt; | ||
3079 | p_BTableChangesDelta->BT_Index = | ||
3080 | blk_node; | ||
3081 | p_BTableChangesDelta->BT_Entry_Value = | ||
3082 | pbt[blk_node]; | ||
3083 | p_BTableChangesDelta->ValidFields = 0x0C; | ||
3084 | |||
3085 | p_BTableChangesDelta = | ||
3086 | (struct BTableChangesDelta *) | ||
3087 | g_pBTDelta_Free; | ||
3088 | g_pBTDelta_Free += | ||
3089 | sizeof(struct BTableChangesDelta); | ||
3090 | |||
3091 | p_BTableChangesDelta->ftl_cmd_cnt = | ||
3092 | ftl_cmd_cnt; | ||
3093 | p_BTableChangesDelta->BT_Index = i; | ||
3094 | p_BTableChangesDelta->BT_Entry_Value = pbt[i]; | ||
3095 | p_BTableChangesDelta->ValidFields = 0x0C; | ||
3096 | #endif | ||
3097 | wResult = PASS; | ||
3098 | break; | ||
3099 | } | ||
3100 | } | ||
3101 | |||
3102 | if (FAIL == wResult) { | ||
3103 | if (FAIL == GLOB_FTL_Garbage_Collection()) | ||
3104 | break; | ||
3105 | else | ||
3106 | continue; | ||
3107 | } | ||
3108 | |||
3109 | if (IN_PROGRESS_BLOCK_TABLE != g_cBlockTableStatus) { | ||
3110 | g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; | ||
3111 | FTL_Write_IN_Progress_Block_Table_Page(); | ||
3112 | } | ||
3113 | |||
3114 | phy_addr = FTL_Get_Physical_Block_Addr(blk_addr); | ||
3115 | |||
3116 | for (j = 0; j < RETRY_TIMES; j++) { | ||
3117 | if (PASS == wErase) { | ||
3118 | if (FAIL == GLOB_FTL_Block_Erase(phy_addr)) { | ||
3119 | MARK_BLOCK_AS_BAD(pbt[blk_node]); | ||
3120 | break; | ||
3121 | } | ||
3122 | } | ||
3123 | if (PASS == FTL_Cache_Update_Block(pData, | ||
3124 | old_page_addr, | ||
3125 | phy_addr)) { | ||
3126 | wResult = PASS; | ||
3127 | break; | ||
3128 | } else { | ||
3129 | wResult = FAIL; | ||
3130 | wErase = PASS; | ||
3131 | } | ||
3132 | } | ||
3133 | } while (FAIL == wResult); | ||
3134 | |||
3135 | FTL_Write_Block_Table(FAIL); | ||
3136 | |||
3137 | return wResult; | ||
3138 | } | ||
3139 | |||
3140 | /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | 2724 | /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& |
3141 | * Function: FTL_Get_Page_Num | 2725 | * Function: FTL_Get_Page_Num |
3142 | * Inputs: Size in bytes | 2726 | * Inputs: Size in bytes |