Subversion Repositories freemyipod

Rev

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

Rev 128 Rev 134
Line 2340... Line 2340...
2340
    uint32_t block;
2340
    uint32_t block;
2341
    uint32_t dirty;
2341
    uint32_t dirty;
2342
    if (count)
2342
    if (count)
2343
    {
2343
    {
2344
#ifdef HAVE_LCD
2344
#ifdef HAVE_LCD
2345
        lcdconsole_progressbar(&progressbar, 0, count * ppb);
2345
        lcdconsole_progressbar(&progressbar, 0, count * ppb * 2);
2346
#endif
2346
#endif
2347
        count = 0;
2347
        count = 0;
2348
        for (i = 0; i < ftl_nand_type->userblocks + 0x17; i++)
2348
        for (i = 0; i < ftl_nand_type->userblocks + 0x17; i++)
2349
            if (blk_type[i] == 2)
2349
            if (blk_type[i] == 2)
2350
            {
2350
            {
2351
                block = 0xffff;
2351
                block = 0xffff;
2352
                for (j = 0; j < ftl_nand_type->pagesperblock * ftl_banks; j++)
2352
                for (j = 0; j < ppb; j++)
2353
                {
2353
                {
-
 
2354
#ifdef HAVE_LCD
-
 
2355
                    progressbar_setpos(&progressbar, count * ppb * 2 + j, false);
-
 
2356
#endif
2354
                    uint32_t ret = ftl_vfl_read(i * ppb + j, ftl_buffer,
2357
                    uint32_t ret = ftl_vfl_read(i * ppb + j, ftl_buffer,
2355
                                                &ftl_sparebuffer[0], 1, 0);
2358
                                                &ftl_sparebuffer[0], 1, 0);
2356
                    if (ret & 0x11F) continue;
2359
                    if (ret & 0x11F) continue;
2357
                    if (ftl_sparebuffer[0].user.type != 0x40)
2360
                    if (ftl_sparebuffer[0].user.type != 0x40)
2358
                    {
2361
                    {
Line 2418... Line 2421...
2418
                                              "(scattered page commit)!\n", i);
2421
                                              "(scattered page commit)!\n", i);
2419
                        return 1;
2422
                        return 1;
2420
                    }
2423
                    }
2421
                    for (j = 0; j < ppb; j++)
2424
                    for (j = 0; j < ppb; j++)
2422
                    {
2425
                    {
-
 
2426
#ifdef HAVE_LCD
-
 
2427
                        progressbar_setpos(&progressbar, count * ppb * 2 + ppb + j, false);
-
 
2428
#endif
2423
                        memset(&ftl_sparebuffer[0], 0xFF, 0x40);
2429
                        memset(&ftl_sparebuffer[0], 0xFF, 0x40);
2424
                        ftl_sparebuffer[0].user.lpn = block * ppb + j;
2430
                        ftl_sparebuffer[0].user.lpn = block * ppb + j;
2425
                        ftl_sparebuffer[0].user.usn = pageusn[j];
2431
                        ftl_sparebuffer[0].user.usn = pageusn[j];
2426
                        ftl_sparebuffer[0].user.type = 0x40;
2432
                        ftl_sparebuffer[0].user.type = 0x40;
2427
                        if (j == ppb - 1) ftl_sparebuffer[0].user.type = 0x41;
2433
                        if (j == ppb - 1) ftl_sparebuffer[0].user.type = 0x41;
Line 2429... Line 2435...
2429
                        {
2435
                        {
2430
                            cprintf(CONSOLE_BOOT, "Couldn't write vPage %d "
2436
                            cprintf(CONSOLE_BOOT, "Couldn't write vPage %d "
2431
                                                  "(scattered page commit)!\n", i * ppb + j);
2437
                                                  "(scattered page commit)!\n", i * ppb + j);
2432
                            return 1;
2438
                            return 1;
2433
                        }
2439
                        }
2434
#ifdef HAVE_LCD
-
 
2435
                        progressbar_setpos(&progressbar, count * ppb + j, false);
-
 
2436
#endif
-
 
2437
                    }
2440
                    }
2438
                    if (ftl_map[block] != 0xffff) blk_type[ftl_map[block]] = 5;
2441
                    if (ftl_map[block] != 0xffff) blk_type[ftl_map[block]] = 5;
2439
                    blk_type[i] = 1;
2442
                    blk_type[i] = 1;
2440
                    ftl_map[block] = i;
2443
                    ftl_map[block] = i;
2441
                }
2444
                }
2442
                else blk_type[i] = 5;
2445
                else blk_type[i] = 5;
2443
#ifdef HAVE_LCD
2446
#ifdef HAVE_LCD
2444
                progressbar_setpos(&progressbar, ++count * ppb, false);
2447
                progressbar_setpos(&progressbar, ++count * ppb * 2, false);
2445
#endif
2448
#endif
2446
            }
2449
            }
2447
    }
2450
    }
2448
 
2451
 
2449
    cputs(CONSOLE_BOOT, "Fixing block map...\n");
2452
    cputs(CONSOLE_BOOT, "Fixing block map...\n");
Line 2499... Line 2502...
2499
    {
2502
    {
2500
        cprintf(CONSOLE_BOOT, "Couldn't write vPage %d (save FTL context)!\n", page);
2503
        cprintf(CONSOLE_BOOT, "Couldn't write vPage %d (save FTL context)!\n", page);
2501
        return 1;
2504
        return 1;
2502
    }
2505
    }
2503
    ftl_store_ctrl_block_list();
2506
    ftl_store_ctrl_block_list();
-
 
2507
    return 0;
2504
}
2508
}
2505
 
2509
 
2506
 
2510
 
2507
/* Initializes and mounts the FTL.
2511
/* Initializes and mounts the FTL.
2508
   As long as nothing was written, you won't need to unmount it.
2512
   As long as nothing was written, you won't need to unmount it.
Line 2563... Line 2567...
2563
		else
2567
		else
2564
		{
2568
		{
2565
			cprintf(CONSOLE_BOOT, "FTL recovery finished. Trying to mount again...\n");
2569
			cprintf(CONSOLE_BOOT, "FTL recovery finished. Trying to mount again...\n");
2566
	        if (ftl_open() == 0)
2570
	        if (ftl_open() == 0)
2567
            {
2571
            {
-
 
2572
			    cprintf(CONSOLE_BOOT, "Mount succeeded.\n");
2568
                ftl_initialized = true;
2573
                ftl_initialized = true;
2569
                return 0;
2574
                return 0;
2570
            }
2575
            }
2571
			cprintf(CONSOLE_BOOT, "Mounting FTL failed again, use disk mode to recover.\n");
2576
			cprintf(CONSOLE_BOOT, "Mounting FTL failed again, use disk mode to recover.\n");
2572
		}
2577
		}