summaryrefslogtreecommitdiff
path: root/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c')
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c
index a3d860730a..976b648a83 100644
--- a/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c
+++ b/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c
@@ -687,11 +687,11 @@ static uint32_t ftl_vfl_get_physical_block(uint32_t bank, uint32_t block)
687 uint32_t spareused = ftl_vfl_cxt[bank].spareused; 687 uint32_t spareused = ftl_vfl_cxt[bank].spareused;
688 for (spareindex = 0; spareindex < spareused; spareindex++) 688 for (spareindex = 0; spareindex < spareused; spareindex++)
689 if (ftl_vfl_cxt[bank].remaptable[spareindex] == block) 689 if (ftl_vfl_cxt[bank].remaptable[spareindex] == block)
690 { 690 {
691 DEBUGF("FTL: VFL: Following remapped block: %d => %d\n", 691 DEBUGF("FTL: VFL: Following remapped block: %d => %d\n",
692 block, ftl_vfl_cxt[bank].firstspare + spareindex); 692 block, ftl_vfl_cxt[bank].firstspare + spareindex);
693 return ftl_vfl_cxt[bank].firstspare + spareindex; 693 return ftl_vfl_cxt[bank].firstspare + spareindex;
694 } 694 }
695 return block; 695 return block;
696} 696}
697 697
@@ -881,10 +881,10 @@ static uint32_t ftl_vfl_read_fast(uint32_t vpage, void* buffer, void* sparebuffe
881 uint32_t i, rc = 0; 881 uint32_t i, rc = 0;
882 uint32_t abspage = vpage + ppb * syshyperblocks; 882 uint32_t abspage = vpage + ppb * syshyperblocks;
883 if (abspage + ftl_banks - 1 >= ftl_nand_type->blocks * ppb || abspage < ppb) 883 if (abspage + ftl_banks - 1 >= ftl_nand_type->blocks * ppb || abspage < ppb)
884 { 884 {
885 DEBUGF("FTL: Trying to read out-of-bounds vPage %u\n", (unsigned)vpage); 885 DEBUGF("FTL: Trying to read out-of-bounds vPage %u\n", (unsigned)vpage);
886 return 4; 886 return 4;
887 } 887 }
888 888
889 uint32_t bank = abspage % ftl_banks; 889 uint32_t bank = abspage % ftl_banks;
890 uint32_t block = abspage / (ftl_nand_type->pagesperblock * ftl_banks); 890 uint32_t block = abspage / (ftl_nand_type->pagesperblock * ftl_banks);
@@ -954,11 +954,11 @@ static uint32_t ftl_vfl_write(uint32_t vpage, uint32_t count,
954 954
955 uint32_t abspage = vpage + ppb * syshyperblocks; 955 uint32_t abspage = vpage + ppb * syshyperblocks;
956 if (abspage + count > ftl_nand_type->blocks * ppb || abspage < ppb) 956 if (abspage + count > ftl_nand_type->blocks * ppb || abspage < ppb)
957 { 957 {
958 DEBUGF("FTL: Trying to write out-of-bounds vPage %u\n", 958 DEBUGF("FTL: Trying to write out-of-bounds vPage %u\n",
959 (unsigned)vpage); 959 (unsigned)vpage);
960 return 4; 960 return 4;
961 } 961 }
962 962
963 static uint32_t bank[5]; 963 static uint32_t bank[5];
964 static uint32_t block[5]; 964 static uint32_t block[5];
@@ -1065,11 +1065,11 @@ static uint32_t ftl_vfl_open(void)
1065 vflcxtidx = k; 1065 vflcxtidx = k;
1066 } 1066 }
1067 if (vflcxtidx == 4) 1067 if (vflcxtidx == 4)
1068 { 1068 {
1069 DEBUGF("FTL: No VFL CXT block found on bank %u!\n", 1069 DEBUGF("FTL: No VFL CXT block found on bank %u!\n",
1070 (unsigned)i); 1070 (unsigned)i);
1071 return 1; 1071 return 1;
1072 } 1072 }
1073 last = 0; 1073 last = 0;
1074 uint32_t max = ftl_nand_type->pagesperblock; 1074 uint32_t max = ftl_nand_type->pagesperblock;
1075 for (k = 8; k < max; k += 8) 1075 for (k = 8; k < max; k += 8)
@@ -1096,10 +1096,10 @@ static uint32_t ftl_vfl_open(void)
1096 } 1096 }
1097 } 1097 }
1098 else 1098 else
1099 { 1099 {
1100 DEBUGF("FTL: Couldn't load bank %u lowlevel BBT!\n", (unsigned)i); 1100 DEBUGF("FTL: Couldn't load bank %u lowlevel BBT!\n", (unsigned)i);
1101 return 1; 1101 return 1;
1102 } 1102 }
1103 cxt = ftl_vfl_get_newest_cxt(); 1103 cxt = ftl_vfl_get_newest_cxt();
1104 for (i = 0; i < ftl_banks; i++) 1104 for (i = 0; i < ftl_banks; i++)
1105 memcpy(ftl_vfl_cxt[i].ftlctrlblocks, cxt->ftlctrlblocks, 6); 1105 memcpy(ftl_vfl_cxt[i].ftlctrlblocks, cxt->ftlctrlblocks, 6);
@@ -1160,10 +1160,10 @@ static uint32_t ftl_open(void)
1160 } 1160 }
1161 1161
1162 if (ftlcxtfound == 0) 1162 if (ftlcxtfound == 0)
1163 { 1163 {
1164 DEBUGF("FTL: Couldn't find FTL CXT page!\n"); 1164 DEBUGF("FTL: Couldn't find FTL CXT page!\n");
1165 return 1; 1165 return 1;
1166 } 1166 }
1167 1167
1168 DEBUGF("FTL: Successfully read FTL context block\n"); 1168 DEBUGF("FTL: Successfully read FTL context block\n");
1169 uint32_t pagestoread = ftl_nand_type->userblocks >> 10; 1169 uint32_t pagestoread = ftl_nand_type->userblocks >> 10;
@@ -1173,10 +1173,10 @@ static uint32_t ftl_open(void)
1173 { 1173 {
1174 if ((ftl_vfl_read(ftl_cxt.ftl_map_pages[i], 1174 if ((ftl_vfl_read(ftl_cxt.ftl_map_pages[i],
1175 ftl_buffer, &ftl_sparebuffer[0], 1, 1) & 0x11F) != 0) 1175 ftl_buffer, &ftl_sparebuffer[0], 1, 1) & 0x11F) != 0)
1176 { 1176 {
1177 DEBUGF("FTL: Failed to read block map page %u\n", (unsigned)i); 1177 DEBUGF("FTL: Failed to read block map page %u\n", (unsigned)i);
1178 return 1; 1178 return 1;
1179 } 1179 }
1180 1180
1181 uint32_t toread = 2048; 1181 uint32_t toread = 2048;
1182 if (toread > (ftl_nand_type->userblocks << 1) - (i << 11)) 1182 if (toread > (ftl_nand_type->userblocks << 1) - (i << 11))
@@ -1193,10 +1193,10 @@ static uint32_t ftl_open(void)
1193 { 1193 {
1194 if ((ftl_vfl_read(ftl_cxt.ftl_erasectr_pages[i], 1194 if ((ftl_vfl_read(ftl_cxt.ftl_erasectr_pages[i],
1195 ftl_buffer, &ftl_sparebuffer[0], 1, 1) & 0x11F) != 0) 1195 ftl_buffer, &ftl_sparebuffer[0], 1, 1) & 0x11F) != 0)
1196 { 1196 {
1197 DEBUGF("FTL: Failed to read erase counter page %u\n", (unsigned)i); 1197 DEBUGF("FTL: Failed to read erase counter page %u\n", (unsigned)i);
1198 return 1; 1198 return 1;
1199 } 1199 }
1200 1200
1201 uint32_t toread = 2048; 1201 uint32_t toread = 2048;
1202 if (toread > ((ftl_nand_type->userblocks + 23) << 1) - (i << 11)) 1202 if (toread > ((ftl_nand_type->userblocks + 23) << 1) - (i << 11))
@@ -1301,14 +1301,14 @@ uint32_t ftl_read(uint32_t sector, uint32_t count, void* buffer)
1301 if (logentry != NULL) 1301 if (logentry != NULL)
1302 { 1302 {
1303#ifdef FTL_TRACE 1303#ifdef FTL_TRACE
1304 DEBUGF("FTL: Block %d has a log entry\n", block); 1304 DEBUGF("FTL: Block %d has a log entry\n", block);
1305#endif 1305#endif
1306 if (logentry->scatteredvblock != 0xFFFF 1306 if (logentry->scatteredvblock != 0xFFFF
1307 && logentry->pageoffsets[page] != 0xFFFF) 1307 && logentry->pageoffsets[page] != 0xFFFF)
1308 { 1308 {
1309#ifdef FTL_TRACE 1309#ifdef FTL_TRACE
1310 DEBUGF("FTL: Found page %d at block %d, page %d\n", page, 1310 DEBUGF("FTL: Found page %d at block %d, page %d\n", page,
1311 (*logentry).scatteredvblock, (*logentry).pageoffsets[page]); 1311 (*logentry).scatteredvblock, (*logentry).pageoffsets[page]);
1312#endif 1312#endif
1313 abspage = logentry->scatteredvblock * ppb 1313 abspage = logentry->scatteredvblock * ppb
1314 + logentry->pageoffsets[page]; 1314 + logentry->pageoffsets[page];
@@ -1330,7 +1330,7 @@ uint32_t ftl_read(uint32_t sector, uint32_t count, void* buffer)
1330 memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800); 1330 memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800);
1331 else if ((ret & (0xd << (j << 2))) || ftl_sparebuffer[j].user.eccmark != 0xFF) 1331 else if ((ret & (0xd << (j << 2))) || ftl_sparebuffer[j].user.eccmark != 0xFF)
1332 { 1332 {
1333 DEBUGF("FTL: Error while reading sector %d!\n", (sector + i)); 1333 DEBUGF("FTL: Error while reading sector %d!\n", (sector + i));
1334 error = -3; 1334 error = -3;
1335 memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800); 1335 memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800);
1336 } 1336 }
@@ -1343,7 +1343,7 @@ uint32_t ftl_read(uint32_t sector, uint32_t count, void* buffer)
1343 if (ret & 2) memset(&((uint8_t*)buffer)[i << 11], 0, 0x800); 1343 if (ret & 2) memset(&((uint8_t*)buffer)[i << 11], 0, 0x800);
1344 else if ((ret & 0x11D) != 0 || ftl_sparebuffer[0].user.eccmark != 0xFF) 1344 else if ((ret & 0x11D) != 0 || ftl_sparebuffer[0].user.eccmark != 0xFF)
1345 { 1345 {
1346 DEBUGF("FTL: Error while reading sector %d!\n", (sector + i)); 1346 DEBUGF("FTL: Error while reading sector %d!\n", (sector + i));
1347 error = -4; 1347 error = -4;
1348 memset(&((uint8_t*)buffer)[i << 11], 0, 0x800); 1348 memset(&((uint8_t*)buffer)[i << 11], 0, 0x800);
1349 } 1349 }
@@ -1944,7 +1944,7 @@ uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer)
1944 { 1944 {
1945 for (i = 0; i < 3; i++) 1945 for (i = 0; i < 3; i++)
1946 { 1946 {
1947 DEBUGF("FTL: Marking dirty, try %d\n", i); 1947 DEBUGF("FTL: Marking dirty, try %d\n", i);
1948 if (ftl_next_ctrl_pool_page() != 0) 1948 if (ftl_next_ctrl_pool_page() != 0)
1949 { 1949 {
1950 mutex_unlock(&ftl_mtx); 1950 mutex_unlock(&ftl_mtx);
@@ -1963,7 +1963,7 @@ uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer)
1963 mutex_unlock(&ftl_mtx); 1963 mutex_unlock(&ftl_mtx);
1964 return -4; 1964 return -4;
1965 } 1965 }
1966 DEBUGF("FTL: Wrote dirty mark to %d\n", ftl_cxt.ftlctrlpage); 1966 DEBUGF("FTL: Wrote dirty mark to %d\n", ftl_cxt.ftlctrlpage);
1967 ftl_cxt.clean_flag = 0; 1967 ftl_cxt.clean_flag = 0;
1968 } 1968 }
1969 1969
@@ -1981,14 +1981,14 @@ uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer)
1981 if (page == 0 && count - i >= ppb) 1981 if (page == 0 && count - i >= ppb)
1982 { 1982 {
1983#ifdef FTL_TRACE 1983#ifdef FTL_TRACE
1984 DEBUGF("FTL: Going to write a full hyperblock in one shot\n"); 1984 DEBUGF("FTL: Going to write a full hyperblock in one shot\n");
1985#endif 1985#endif
1986 uint32_t vblock = logentry->scatteredvblock; 1986 uint32_t vblock = logentry->scatteredvblock;
1987 logentry->scatteredvblock = 0xFFFF; 1987 logentry->scatteredvblock = 0xFFFF;
1988 if (logentry->pagesused != 0) 1988 if (logentry->pagesused != 0)
1989 { 1989 {
1990#ifdef FTL_TRACE 1990#ifdef FTL_TRACE
1991 DEBUGF("FTL: Scattered block had some pages already used, committing\n"); 1991 DEBUGF("FTL: Scattered block had some pages already used, committing\n");
1992#endif 1992#endif
1993 ftl_release_pool_block(vblock); 1993 ftl_release_pool_block(vblock);
1994 vblock = ftl_allocate_pool_block(); 1994 vblock = ftl_allocate_pool_block();
@@ -2030,7 +2030,7 @@ uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer)
2030 if (logentry->pagesused == ppb) 2030 if (logentry->pagesused == ppb)
2031 { 2031 {
2032#ifdef FTL_TRACE 2032#ifdef FTL_TRACE
2033 DEBUGF("FTL: Scattered block is full, committing\n"); 2033 DEBUGF("FTL: Scattered block is full, committing\n");
2034#endif 2034#endif
2035 ftl_remove_scattered_block(logentry); 2035 ftl_remove_scattered_block(logentry);
2036 logentry = ftl_allocate_log_entry(block); 2036 logentry = ftl_allocate_log_entry(block);
@@ -2107,7 +2107,7 @@ uint32_t ftl_sync(void)
2107 if (ftl_cxt.clean_flag == 1) return 0; 2107 if (ftl_cxt.clean_flag == 1) return 0;
2108 2108
2109 mutex_lock(&ftl_mtx); 2109 mutex_lock(&ftl_mtx);
2110 2110
2111#ifdef FTL_TRACE 2111#ifdef FTL_TRACE
2112 DEBUGF("FTL: Syncing\n"); 2112 DEBUGF("FTL: Syncing\n");
2113#endif 2113#endif
@@ -2164,7 +2164,7 @@ uint32_t ftl_init(void)
2164 2164
2165 if (!ftl_has_devinfo()) 2165 if (!ftl_has_devinfo())
2166 { 2166 {
2167 DEBUGF("FTL: No DEVICEINFO found!\n"); 2167 DEBUGF("FTL: No DEVICEINFO found!\n");
2168 return -1; 2168 return -1;
2169 } 2169 }
2170 if (ftl_vfl_open() == 0) 2170 if (ftl_vfl_open() == 0)