Subversion Repositories freemyipod

Rev

Rev 124 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 124 Rev 128
Line 429... Line 429...
429
 
429
 
430
#endif
430
#endif
431
 
431
 
432
 
432
 
433
static struct mutex ftl_mtx;
433
static struct mutex ftl_mtx;
-
 
434
bool ftl_initialized;
434
 
435
 
435
 
436
 
436
 
437
 
437
/* Finds a device info page for the specified bank and returns its number.
438
/* Finds a device info page for the specified bank and returns its number.
438
   Used to check if one is present, and to read the lowlevel BBT. */
439
   Used to check if one is present, and to read the lowlevel BBT. */
Line 1307... Line 1308...
1307
{
1308
{
1308
    uint32_t i, j;
1309
    uint32_t i, j;
1309
    uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
1310
    uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
1310
    uint32_t error = 0;
1311
    uint32_t error = 0;
1311
 
1312
 
-
 
1313
    if (!ftl_initialized) return 1;
-
 
1314
 
1312
#ifdef FTL_TRACE
1315
#ifdef FTL_TRACE
1313
    DEBUGF("FTL: Reading %d sectors starting at %d", count, sector);
1316
    DEBUGF("FTL: Reading %d sectors starting at %d", count, sector);
1314
#endif
1317
#endif
1315
 
1318
 
1316
	if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
1319
	if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
Line 1967... Line 1970...
1967
uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer)
1970
uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer)
1968
{
1971
{
1969
    uint32_t i, j, k;
1972
    uint32_t i, j, k;
1970
    uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
1973
    uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
1971
 
1974
 
-
 
1975
    if (!ftl_initialized) return 1;
-
 
1976
 
1972
#ifdef FTL_TRACE
1977
#ifdef FTL_TRACE
1973
    DEBUGF("FTL: Writing %d sectors starting at %d", count, sector);
1978
    DEBUGF("FTL: Writing %d sectors starting at %d", count, sector);
1974
#endif
1979
#endif
1975
 
1980
 
1976
	if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
1981
	if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
Line 2150... Line 2155...
2150
uint32_t ftl_sync(void)
2155
uint32_t ftl_sync(void)
2151
{
2156
{
2152
    uint32_t i;
2157
    uint32_t i;
2153
    uint32_t rc = 0;
2158
    uint32_t rc = 0;
2154
    uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
2159
    uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
-
 
2160
 
-
 
2161
    if (!ftl_initialized) return 1;
-
 
2162
 
2155
    if (ftl_cxt.clean_flag == 1) return 0;
2163
    if (ftl_cxt.clean_flag == 1) return 0;
2156
 
2164
 
2157
    mutex_lock(&ftl_mtx, TIMEOUT_BLOCK);
2165
    mutex_lock(&ftl_mtx, TIMEOUT_BLOCK);
2158
	
2166
	
2159
#ifdef FTL_TRACE
2167
#ifdef FTL_TRACE
Line 2543... Line 2551...
2543
        return 1;
2551
        return 1;
2544
    }
2552
    }
2545
    if (ftl_vfl_open() == 0)
2553
    if (ftl_vfl_open() == 0)
2546
	{
2554
	{
2547
        if (ftl_open() == 0)
2555
        if (ftl_open() == 0)
-
 
2556
        {
-
 
2557
            ftl_initialized = true;
2548
            return 0;
2558
            return 0;
-
 
2559
        }
2549
		cprintf(CONSOLE_BOOT, "The FTL seems to be damaged. Forcing check.\n");
2560
		cprintf(CONSOLE_BOOT, "The FTL seems to be damaged. Forcing check.\n");
2550
		if (ftl_repair() != 0)
2561
		if (ftl_repair() != 0)
2551
			cprintf(CONSOLE_BOOT, "FTL recovery failed. Use disk mode to recover.\n");
2562
			cprintf(CONSOLE_BOOT, "FTL recovery failed. Use disk mode to recover.\n");
2552
		else
2563
		else
2553
		{
2564
		{
2554
			cprintf(CONSOLE_BOOT, "FTL recovery finished. Trying to mount again...\n");
2565
			cprintf(CONSOLE_BOOT, "FTL recovery finished. Trying to mount again...\n");
2555
	        if (ftl_open() == 0)
2566
	        if (ftl_open() == 0)
-
 
2567
            {
-
 
2568
                ftl_initialized = true;
2556
	            return 0;
2569
                return 0;
-
 
2570
            }
2557
			cprintf(CONSOLE_BOOT, "Mounting FTL failed again, use disk mode to recover.\n");
2571
			cprintf(CONSOLE_BOOT, "Mounting FTL failed again, use disk mode to recover.\n");
2558
		}
2572
		}
2559
	}
2573
	}
2560
 
2574
 
2561
    DEBUGF("FTL: Initialization failed!");
2575
    DEBUGF("FTL: Initialization failed!");