Subversion Repositories freemyipod

Rev

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

Rev 166 Rev 201
Line 701... Line 701...
701
 
701
 
702
    uint32_t spareindex;
702
    uint32_t spareindex;
703
    uint32_t spareused = ftl_vfl_cxt[bank].spareused;
703
    uint32_t spareused = ftl_vfl_cxt[bank].spareused;
704
    for (spareindex = 0; spareindex < spareused; spareindex++)
704
    for (spareindex = 0; spareindex < spareused; spareindex++)
705
        if (ftl_vfl_cxt[bank].remaptable[spareindex] == block)
705
        if (ftl_vfl_cxt[bank].remaptable[spareindex] == block)
706
		{
706
        {
707
            DEBUGF("FTL: VFL: Following remapped block: %d => %d",
707
            DEBUGF("FTL: VFL: Following remapped block: %d => %d",
708
                   block, ftl_vfl_cxt[bank].firstspare + spareindex);
708
                   block, ftl_vfl_cxt[bank].firstspare + spareindex);
709
            return ftl_vfl_cxt[bank].firstspare + spareindex;
709
            return ftl_vfl_cxt[bank].firstspare + spareindex;
710
		}
710
        }
711
    return block;
711
    return block;
712
}
712
}
713
 
713
 
714
 
714
 
715
#ifndef FTL_READONLY
715
#ifndef FTL_READONLY
Line 728... Line 728...
728
/* Schedules remapping for the specified bank and vBlock */
728
/* Schedules remapping for the specified bank and vBlock */
729
static void ftl_vfl_schedule_block_for_remap(uint32_t bank, uint32_t block)
729
static void ftl_vfl_schedule_block_for_remap(uint32_t bank, uint32_t block)
730
{
730
{
731
    if (ftl_vfl_check_remap_scheduled(bank, block) == 1) return;
731
    if (ftl_vfl_check_remap_scheduled(bank, block) == 1) return;
732
    panicf(PANIC_FATAL, "FTL: Scheduling bank %u block %u for remap!",
732
    panicf(PANIC_FATAL, "FTL: Scheduling bank %u block %u for remap!",
733
	       (unsigned)bank, (unsigned)block);
733
           (unsigned)bank, (unsigned)block);
734
    if (ftl_vfl_cxt[bank].scheduledstart == ftl_vfl_cxt[bank].spareused)
734
    if (ftl_vfl_cxt[bank].scheduledstart == ftl_vfl_cxt[bank].spareused)
735
        return;
735
        return;
736
    ftl_vfl_cxt[bank].remaptable[--ftl_vfl_cxt[bank].scheduledstart] = block;
736
    ftl_vfl_cxt[bank].remaptable[--ftl_vfl_cxt[bank].scheduledstart] = block;
737
    ftl_vfl_commit_cxt(bank);
737
    ftl_vfl_commit_cxt(bank);
738
}
738
}
Line 815... Line 815...
815
static uint32_t ftl_vfl_remap_block(uint32_t bank, uint32_t block)
815
static uint32_t ftl_vfl_remap_block(uint32_t bank, uint32_t block)
816
{
816
{
817
    uint32_t i;
817
    uint32_t i;
818
    uint32_t newblock = 0, newidx;
818
    uint32_t newblock = 0, newidx;
819
    panicf(PANIC_FATAL, "FTL: Remapping bank %u block %u!",
819
    panicf(PANIC_FATAL, "FTL: Remapping bank %u block %u!",
820
	       (unsigned)bank, (unsigned)block);
820
           (unsigned)bank, (unsigned)block);
821
    if (bank >= ftl_banks || block >= ftl_nand_type->blocks) return 0;
821
    if (bank >= ftl_banks || block >= ftl_nand_type->blocks) return 0;
822
    for (i = 0; i < ftl_vfl_cxt[bank].sparecount; i++)
822
    for (i = 0; i < ftl_vfl_cxt[bank].sparecount; i++)
823
        if (ftl_vfl_cxt[bank].remaptable[i] == 0)
823
        if (ftl_vfl_cxt[bank].remaptable[i] == 0)
824
        {
824
        {
825
            newblock = ftl_vfl_cxt[bank].firstspare + i;
825
            newblock = ftl_vfl_cxt[bank].firstspare + i;
Line 902... Line 902...
902
    uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
902
    uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
903
    uint32_t syshyperblocks = ftl_nand_type->blocks
903
    uint32_t syshyperblocks = ftl_nand_type->blocks
904
                            - ftl_nand_type->userblocks - 0x17;
904
                            - ftl_nand_type->userblocks - 0x17;
905
    uint32_t abspage = vpage + ppb * syshyperblocks;
905
    uint32_t abspage = vpage + ppb * syshyperblocks;
906
    if (abspage + ftl_banks - 1 >= ftl_nand_type->blocks * ppb || abspage < ppb)
906
    if (abspage + ftl_banks - 1 >= ftl_nand_type->blocks * ppb || abspage < ppb)
907
	{
907
    {
908
        DEBUGF("FTL: Trying to read out-of-bounds vPage %u", (unsigned)vpage);
908
        DEBUGF("FTL: Trying to read out-of-bounds vPage %u", (unsigned)vpage);
909
        return 4;
909
        return 4;
910
	}
910
    }
911
 
911
 
912
    uint32_t bank = abspage % ftl_banks;
912
    uint32_t bank = abspage % ftl_banks;
913
    uint32_t block = abspage / (ftl_nand_type->pagesperblock * ftl_banks);
913
    uint32_t block = abspage / (ftl_nand_type->pagesperblock * ftl_banks);
914
    uint32_t page = (abspage / ftl_banks) % ftl_nand_type->pagesperblock;
914
    uint32_t page = (abspage / ftl_banks) % ftl_nand_type->pagesperblock;
915
    uint32_t remapped = 0;
915
    uint32_t remapped = 0;
Line 978... Line 978...
978
    uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
978
    uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
979
    uint32_t syshyperblocks = ftl_nand_type->blocks
979
    uint32_t syshyperblocks = ftl_nand_type->blocks
980
                            - ftl_nand_type->userblocks - 0x17;
980
                            - ftl_nand_type->userblocks - 0x17;
981
    uint32_t abspage = vpage + ppb * syshyperblocks;
981
    uint32_t abspage = vpage + ppb * syshyperblocks;
982
    if (abspage + count > ftl_nand_type->blocks * ppb || abspage < ppb)
982
    if (abspage + count > ftl_nand_type->blocks * ppb || abspage < ppb)
983
	{
983
    {
984
        DEBUGF("FTL: Trying to write out-of-bounds vPage %u",
984
        DEBUGF("FTL: Trying to write out-of-bounds vPage %u",
985
               (unsigned)vpage);
985
               (unsigned)vpage);
986
        return 4;
986
        return 4;
987
	}
987
    }
988
 
988
 
989
    uint32_t bank[5];
989
    uint32_t bank[5];
990
    uint32_t block[5];
990
    uint32_t block[5];
991
    uint32_t physpage[5];
991
    uint32_t physpage[5];
992
 
992
 
Line 1093... Line 1093...
1093
                                    {
1093
                                    {
1094
                                        minusn = ftl_sparebuffer[0].meta.usn;
1094
                                        minusn = ftl_sparebuffer[0].meta.usn;
1095
                                        vflcxtidx = k;
1095
                                        vflcxtidx = k;
1096
                                    }
1096
                                    }
1097
                        if (vflcxtidx == 4)
1097
                        if (vflcxtidx == 4)
1098
						{
1098
                        {
1099
                            DEBUGF("FTL: No VFL CXT block found on bank %u!",
1099
                            DEBUGF("FTL: No VFL CXT block found on bank %u!",
1100
                                   (unsigned)i);
1100
                                   (unsigned)i);
1101
						    return 1;
1101
                            return 1;
1102
						}
1102
                        }
1103
                        last = 0;
1103
                        last = 0;
1104
                        uint32_t max = ftl_nand_type->pagesperblock;
1104
                        uint32_t max = ftl_nand_type->pagesperblock;
1105
                        for (k = 8; k < max; k += 8)
1105
                        for (k = 8; k < max; k += 8)
1106
                        {
1106
                        {
1107
                            if (ftl_vfl_read_page(i, vflcxtblock[vflcxtidx],
1107
                            if (ftl_vfl_read_page(i, vflcxtblock[vflcxtidx],
Line 1124... Line 1124...
1124
#endif
1124
#endif
1125
                        break;
1125
                        break;
1126
                    }
1126
                    }
1127
        }
1127
        }
1128
        else
1128
        else
1129
		{
1129
        {
1130
            DEBUGF("FTL: Couldn't load bank %u lowlevel BBT!", (unsigned)i);
1130
            DEBUGF("FTL: Couldn't load bank %u lowlevel BBT!", (unsigned)i);
1131
		    return 1;
1131
            return 1;
1132
		}
1132
        }
1133
    cxt = ftl_vfl_get_newest_cxt();
1133
    cxt = ftl_vfl_get_newest_cxt();
1134
    for (i = 0; i < ftl_banks; i++)
1134
    for (i = 0; i < ftl_banks; i++)
1135
        memcpy(ftl_vfl_cxt[i].ftlctrlblocks, cxt->ftlctrlblocks, 6);
1135
        memcpy(ftl_vfl_cxt[i].ftlctrlblocks, cxt->ftlctrlblocks, 6);
1136
    return 0;
1136
    return 0;
1137
}
1137
}
Line 1190... Line 1190...
1190
#endif
1190
#endif
1191
        }
1191
        }
1192
    }
1192
    }
1193
 
1193
 
1194
    if (ftlcxtfound == 0)
1194
    if (ftlcxtfound == 0)
1195
	{
1195
    {
1196
        DEBUGF("FTL: Couldn't find FTL CXT page!");
1196
        DEBUGF("FTL: Couldn't find FTL CXT page!");
1197
	    return 1;
1197
        return 1;
1198
	}
1198
    }
1199
 
1199
 
1200
    DEBUGF("FTL: Successfully read FTL context block");
1200
    DEBUGF("FTL: Successfully read FTL context block");
1201
    uint32_t pagestoread = ftl_nand_type->userblocks >> 10;
1201
    uint32_t pagestoread = ftl_nand_type->userblocks >> 10;
1202
    if ((ftl_nand_type->userblocks & 0x1FF) != 0) pagestoread++;
1202
    if ((ftl_nand_type->userblocks & 0x1FF) != 0) pagestoread++;
1203
 
1203
 
1204
    for (i = 0; i < pagestoread; i++)
1204
    for (i = 0; i < pagestoread; i++)
1205
    {
1205
    {
1206
        if ((ftl_vfl_read(ftl_cxt.ftl_map_pages[i],
1206
        if ((ftl_vfl_read(ftl_cxt.ftl_map_pages[i],
1207
                          ftl_buffer, &ftl_sparebuffer[0], 1, 1) & 0x11F) != 0)
1207
                          ftl_buffer, &ftl_sparebuffer[0], 1, 1) & 0x11F) != 0)
1208
		{
1208
        {
1209
            DEBUGF("FTL: Failed to read block map page %u", (unsigned)i);
1209
            DEBUGF("FTL: Failed to read block map page %u", (unsigned)i);
1210
            return 1;
1210
            return 1;
1211
		}
1211
        }
1212
 
1212
 
1213
        uint32_t toread = 2048;
1213
        uint32_t toread = 2048;
1214
        if (toread > (ftl_nand_type->userblocks << 1) - (i << 11))
1214
        if (toread > (ftl_nand_type->userblocks << 1) - (i << 11))
1215
            toread = (ftl_nand_type->userblocks << 1) - (i << 11);
1215
            toread = (ftl_nand_type->userblocks << 1) - (i << 11);
1216
 
1216
 
Line 1223... Line 1223...
1223
 
1223
 
1224
    for (i = 0; i < pagestoread; i++)
1224
    for (i = 0; i < pagestoread; i++)
1225
    {
1225
    {
1226
        if ((ftl_vfl_read(ftl_cxt.ftl_erasectr_pages[i],
1226
        if ((ftl_vfl_read(ftl_cxt.ftl_erasectr_pages[i],
1227
                          ftl_buffer, &ftl_sparebuffer[0], 1, 1) & 0x11F) != 0)
1227
                          ftl_buffer, &ftl_sparebuffer[0], 1, 1) & 0x11F) != 0)
1228
		{
1228
        {
1229
            DEBUGF("FTL: Failed to read erase counter page %u", (unsigned)i);
1229
            DEBUGF("FTL: Failed to read erase counter page %u", (unsigned)i);
1230
            return 1;
1230
            return 1;
1231
		}
1231
        }
1232
 
1232
 
1233
        uint32_t toread = 2048;
1233
        uint32_t toread = 2048;
1234
        if (toread > ((ftl_nand_type->userblocks + 23) << 1) - (i << 11))
1234
        if (toread > ((ftl_nand_type->userblocks + 23) << 1) - (i << 11))
1235
            toread = ((ftl_nand_type->userblocks + 23) << 1) - (i << 11);
1235
            toread = ((ftl_nand_type->userblocks + 23) << 1) - (i << 11);
1236
 
1236
 
Line 1314... Line 1314...
1314
 
1314
 
1315
#ifdef FTL_TRACE
1315
#ifdef FTL_TRACE
1316
    DEBUGF("FTL: Reading %d sectors starting at %d", count, sector);
1316
    DEBUGF("FTL: Reading %d sectors starting at %d", count, sector);
1317
#endif
1317
#endif
1318
 
1318
 
1319
	if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
1319
    if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
1320
		panicf(PANIC_KILLTHREAD,
1320
        panicf(PANIC_KILLTHREAD,
1321
		       "ftl_read: Misaligned data buffer at %08X (sector %lu, count %lu)",
1321
               "ftl_read: Misaligned data buffer at %08X (sector %lu, count %lu)",
1322
			   (unsigned int)buffer, sector, count);
1322
               (unsigned int)buffer, sector, count);
1323
 
1323
 
1324
    if (sector + count > ftl_nand_type->userblocks * ppb)
1324
    if (sector + count > ftl_nand_type->userblocks * ppb)
1325
    {
1325
    {
1326
        DEBUGF("FTL: Sector %d is out of range!", sector + count - 1);
1326
        DEBUGF("FTL: Sector %d is out of range!", sector + count - 1);
1327
        return -2;
1327
        return -2;
Line 1339... Line 1339...
1339
#ifndef FTL_READONLY
1339
#ifndef FTL_READONLY
1340
        struct ftl_log_type* logentry = ftl_get_log_entry(block);
1340
        struct ftl_log_type* logentry = ftl_get_log_entry(block);
1341
        if (logentry != NULL)
1341
        if (logentry != NULL)
1342
        {
1342
        {
1343
#ifdef FTL_TRACE
1343
#ifdef FTL_TRACE
1344
	        DEBUGF("FTL: Block %d has a log entry", block);
1344
            DEBUGF("FTL: Block %d has a log entry", block);
1345
#endif
1345
#endif
1346
            if (logentry->scatteredvblock != 0xFFFF
1346
            if (logentry->scatteredvblock != 0xFFFF
1347
             && logentry->pageoffsets[page] != 0xFFFF)
1347
             && logentry->pageoffsets[page] != 0xFFFF)
1348
            {
1348
            {
1349
#ifdef FTL_TRACE
1349
#ifdef FTL_TRACE
1350
   		     DEBUGF("FTL: Found page %d at block %d, page %d", page,
1350
                DEBUGF("FTL: Found page %d at block %d, page %d", page,
1351
          		    (*logentry).scatteredvblock, (*logentry).pageoffsets[page]);
1351
                      (*logentry).scatteredvblock, (*logentry).pageoffsets[page]);
1352
#endif
1352
#endif
1353
                abspage = logentry->scatteredvblock * ppb
1353
                abspage = logentry->scatteredvblock * ppb
1354
                        + logentry->pageoffsets[page];
1354
                        + logentry->pageoffsets[page];
1355
            }
1355
            }
1356
        }
1356
        }
Line 1368... Line 1368...
1368
            for (j = 0; j < ftl_banks; j++)
1368
            for (j = 0; j < ftl_banks; j++)
1369
                if (ret & (2 << (j << 2)))
1369
                if (ret & (2 << (j << 2)))
1370
                    memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800);
1370
                    memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800);
1371
                else if ((ret & (0xd << (j << 2))) || ftl_sparebuffer[j].user.eccmark != 0xFF)
1371
                else if ((ret & (0xd << (j << 2))) || ftl_sparebuffer[j].user.eccmark != 0xFF)
1372
                {
1372
                {
1373
		            DEBUGF("FTL: Error while reading sector %d!", (sector + i));
1373
                    DEBUGF("FTL: Error while reading sector %d!", (sector + i));
1374
                    error = -3;
1374
                    error = -3;
1375
                    memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800);
1375
                    memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800);
1376
                }
1376
                }
1377
            i += ftl_banks - 1;
1377
            i += ftl_banks - 1;
1378
        }
1378
        }
Line 1381... Line 1381...
1381
            uint32_t ret = ftl_vfl_read(abspage, &((uint8_t*)buffer)[i << 11],
1381
            uint32_t ret = ftl_vfl_read(abspage, &((uint8_t*)buffer)[i << 11],
1382
                                        &ftl_sparebuffer[0], 1, 1);
1382
                                        &ftl_sparebuffer[0], 1, 1);
1383
            if (ret & 2) memset(&((uint8_t*)buffer)[i << 11], 0, 0x800);
1383
            if (ret & 2) memset(&((uint8_t*)buffer)[i << 11], 0, 0x800);
1384
            else if ((ret & 0x11D) != 0 || ftl_sparebuffer[0].user.eccmark != 0xFF)
1384
            else if ((ret & 0x11D) != 0 || ftl_sparebuffer[0].user.eccmark != 0xFF)
1385
            {
1385
            {
1386
	            DEBUGF("FTL: Error while reading sector %d!", (sector + i));
1386
                DEBUGF("FTL: Error while reading sector %d!", (sector + i));
1387
                error = -4;
1387
                error = -4;
1388
                memset(&((uint8_t*)buffer)[i << 11], 0, 0x800);
1388
                memset(&((uint8_t*)buffer)[i << 11], 0, 0x800);
1389
            }
1389
            }
1390
        }
1390
        }
1391
    }
1391
    }
Line 1979... Line 1979...
1979
 
1979
 
1980
#ifdef FTL_TRACE
1980
#ifdef FTL_TRACE
1981
    DEBUGF("FTL: Writing %d sectors starting at %d", count, sector);
1981
    DEBUGF("FTL: Writing %d sectors starting at %d", count, sector);
1982
#endif
1982
#endif
1983
 
1983
 
1984
	if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
1984
    if ((uint32_t)buffer & (CACHEALIGN_SIZE - 1))
1985
		panicf(PANIC_KILLTHREAD,
1985
        panicf(PANIC_KILLTHREAD,
1986
		       "ftl_write: Misaligned data buffer at %08X (sector %lu, count %lu)",
1986
               "ftl_write: Misaligned data buffer at %08X (sector %lu, count %lu)",
1987
			   (unsigned int)buffer, sector, count);
1987
               (unsigned int)buffer, sector, count);
1988
 
1988
 
1989
    if (sector + count > ftl_nand_type->userblocks * ppb)
1989
    if (sector + count > ftl_nand_type->userblocks * ppb)
1990
    {
1990
    {
1991
        DEBUGF("FTL: Sector %d is out of range!", sector + count - 1);
1991
        DEBUGF("FTL: Sector %d is out of range!", sector + count - 1);
1992
        return -2;
1992
        return -2;
Line 1997... Line 1997...
1997
 
1997
 
1998
    if (ftl_cxt.clean_flag == 1)
1998
    if (ftl_cxt.clean_flag == 1)
1999
    {
1999
    {
2000
        for (i = 0; i < 3; i++)
2000
        for (i = 0; i < 3; i++)
2001
        {
2001
        {
2002
		    DEBUGF("FTL: Marking dirty, try %d", i);
2002
            DEBUGF("FTL: Marking dirty, try %d", i);
2003
            if (ftl_next_ctrl_pool_page() != 0)
2003
            if (ftl_next_ctrl_pool_page() != 0)
2004
            {
2004
            {
2005
                mutex_unlock(&ftl_mtx);
2005
                mutex_unlock(&ftl_mtx);
2006
                return -3;
2006
                return -3;
2007
            }
2007
            }
Line 2016... Line 2016...
2016
        if (i == 3)
2016
        if (i == 3)
2017
        {
2017
        {
2018
            mutex_unlock(&ftl_mtx);
2018
            mutex_unlock(&ftl_mtx);
2019
            return -4;
2019
            return -4;
2020
        }
2020
        }
2021
    	DEBUGF("FTL: Wrote dirty mark to %d", ftl_cxt.ftlctrlpage);
2021
        DEBUGF("FTL: Wrote dirty mark to %d", ftl_cxt.ftlctrlpage);
2022
        ftl_cxt.clean_flag = 0;
2022
        ftl_cxt.clean_flag = 0;
2023
    }
2023
    }
2024
 
2024
 
2025
    for (i = 0; i < count; )
2025
    for (i = 0; i < count; )
2026
    {
2026
    {
Line 2034... Line 2034...
2034
            return -5;
2034
            return -5;
2035
        }
2035
        }
2036
        if (page == 0 && count - i >= ppb)
2036
        if (page == 0 && count - i >= ppb)
2037
        {
2037
        {
2038
#ifdef FTL_TRACE
2038
#ifdef FTL_TRACE
2039
		    DEBUGF("FTL: Going to write a full hyperblock in one shot");
2039
            DEBUGF("FTL: Going to write a full hyperblock in one shot");
2040
#endif
2040
#endif
2041
            uint32_t vblock = logentry->scatteredvblock;
2041
            uint32_t vblock = logentry->scatteredvblock;
2042
            logentry->scatteredvblock = 0xFFFF;
2042
            logentry->scatteredvblock = 0xFFFF;
2043
            if (logentry->pagesused != 0)
2043
            if (logentry->pagesused != 0)
2044
            {
2044
            {
2045
#ifdef FTL_TRACE
2045
#ifdef FTL_TRACE
2046
    			DEBUGF("FTL: Scattered block had some pages already used, committing");
2046
                DEBUGF("FTL: Scattered block had some pages already used, committing");
2047
#endif
2047
#endif
2048
                ftl_release_pool_block(vblock);
2048
                ftl_release_pool_block(vblock);
2049
                vblock = ftl_allocate_pool_block();
2049
                vblock = ftl_allocate_pool_block();
2050
                if (vblock == 0xFFFFFFFF)
2050
                if (vblock == 0xFFFFFFFF)
2051
                {
2051
                {
Line 2083... Line 2083...
2083
        else
2083
        else
2084
        {
2084
        {
2085
            if (logentry->pagesused == ppb)
2085
            if (logentry->pagesused == ppb)
2086
            {
2086
            {
2087
#ifdef FTL_TRACE
2087
#ifdef FTL_TRACE
2088
    			DEBUGF("FTL: Scattered block is full, committing");
2088
                DEBUGF("FTL: Scattered block is full, committing");
2089
#endif
2089
#endif
2090
                ftl_remove_scattered_block(logentry);
2090
                ftl_remove_scattered_block(logentry);
2091
                logentry = ftl_allocate_log_entry(block);
2091
                logentry = ftl_allocate_log_entry(block);
2092
                if (logentry == NULL)
2092
                if (logentry == NULL)
2093
                {
2093
                {
Line 2164... Line 2164...
2164
    if (!ftl_initialized) return 1;
2164
    if (!ftl_initialized) return 1;
2165
 
2165
 
2166
    if (ftl_cxt.clean_flag == 1) return 0;
2166
    if (ftl_cxt.clean_flag == 1) return 0;
2167
 
2167
 
2168
    mutex_lock(&ftl_mtx, TIMEOUT_BLOCK);
2168
    mutex_lock(&ftl_mtx, TIMEOUT_BLOCK);
2169
	
2169
    
2170
#ifdef FTL_TRACE
2170
#ifdef FTL_TRACE
2171
    DEBUGF("FTL: Syncing");
2171
    DEBUGF("FTL: Syncing");
2172
#endif
2172
#endif
2173
 
2173
 
2174
    if (ftl_cxt.swapcounter >= 20)
2174
    if (ftl_cxt.swapcounter >= 20)
Line 2547... Line 2547...
2547
 
2547
 
2548
    repaired = 0;
2548
    repaired = 0;
2549
    skip = 0;
2549
    skip = 0;
2550
    if (founddevinfo == 0)
2550
    if (founddevinfo == 0)
2551
    {
2551
    {
2552
	   	DEBUGF("FTL: No DEVICEINFO found!");
2552
           DEBUGF("FTL: No DEVICEINFO found!");
2553
        return -1;
2553
        return -1;
2554
    }
2554
    }
2555
    if (foundsignature != 0 && (result & 0x11F) != 0)
2555
    if (foundsignature != 0 && (result & 0x11F) != 0)
2556
    {
2556
    {
2557
        DEBUGF("FTL: Problem with the signature!");
2557
        DEBUGF("FTL: Problem with the signature!");
2558
        return -2;
2558
        return -2;
2559
    }
2559
    }
2560
    if (ftl_vfl_open() == 0)
2560
    if (ftl_vfl_open() == 0)
2561
	{
2561
    {
2562
        if (ftl_open() == 0)
2562
        if (ftl_open() == 0)
2563
        {
2563
        {
2564
            ftl_initialized = true;
2564
            ftl_initialized = true;
2565
            return 0;
2565
            return 0;
2566
        }
2566
        }
2567
		cprintf(CONSOLE_BOOT, "The FTL seems to be damaged. Forcing check.\n");
2567
        cprintf(CONSOLE_BOOT, "The FTL seems to be damaged. Forcing check.\n");
2568
		if (ftl_repair() != 0)
2568
        if (ftl_repair() != 0)
2569
			cprintf(CONSOLE_BOOT, "FTL recovery failed. Use disk mode to recover.\n");
2569
            cprintf(CONSOLE_BOOT, "FTL recovery failed. Use disk mode to recover.\n");
2570
		else
2570
        else
2571
		{
2571
        {
2572
			cprintf(CONSOLE_BOOT, "FTL recovery finished. Trying to mount again...\n");
2572
            cprintf(CONSOLE_BOOT, "FTL recovery finished. Trying to mount again...\n");
2573
	        if (ftl_open() == 0)
2573
            if (ftl_open() == 0)
2574
            {
2574
            {
2575
			    cprintf(CONSOLE_BOOT, "Mount succeeded.\n");
2575
                cprintf(CONSOLE_BOOT, "Mount succeeded.\n");
2576
                ftl_initialized = true;
2576
                ftl_initialized = true;
2577
                return 0;
2577
                return 0;
2578
            }
2578
            }
2579
			cprintf(CONSOLE_BOOT, "Mounting FTL failed again, use disk mode to recover.\n");
2579
            cprintf(CONSOLE_BOOT, "Mounting FTL failed again, use disk mode to recover.\n");
2580
		}
2580
        }
2581
	}
2581
    }
2582
 
2582
 
2583
    DEBUGF("FTL: Initialization failed!");
2583
    DEBUGF("FTL: Initialization failed!");
2584
 
2584
 
2585
    return -3;
2585
    return -3;
2586
}
2586
}