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