freemyipod r942 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r941‎ | r942 | r943 >
Date:12:34, 14 June 2014
Author:theseven
Status:new
Tags:
Comment:
genBBT: Backport some fixes from hddscan2
Modified paths:
  • /emcore/trunk/tools/genbbt.c (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/genbbt.c
@@ -33,7 +33,7 @@
3434 if (sscanf(line, "%i", &sector) == 1 && sector) mark_bad(bitmap, sector);
3535 }
3636 fclose(in);
37 - int l0count = (sectors + 0x7ffff) >> 19;
 37+ int l0count = (sectors + 0xfffff) >> 19;
3838 int bbtpages = 64 + ((l0count + 0x3f) & ~0x3f);
3939 int bbtsize;
4040 uint16_t (*bbt)[0x20];
@@ -41,7 +41,7 @@
4242 while (bbtpages <= 32832)
4343 {
4444 bbtsize = bbtpages << 6;
45 - l0count = (sectors - bbtsize + 0xfffff) >> 19;
 45+ l0count = (sectors - ((bbtsize + 0xfff) >> 12) + 0xfffff) >> 19;
4646 bbt = malloc(bbtsize);
4747 memset(bbt, 0, bbtsize);
4848 int logical = 0;
@@ -64,7 +64,7 @@
6565 else if (!(logical & 0x3ff)) level = 1;
6666 else if (!(logical & 0x1f)) level = 2;
6767 else level = 3;
68 - if (!level) remapbase = ((physical - logical) >> 12) << 12;
 68+ if (!level) remapbase = (physical - logical) & ~0xfff;
6969 if (physical - logical - remapbase > 0x7fff || remapbase > 0xffff)
7070 {
7171 printf("Need to remap across too high distance!\n");
@@ -167,7 +167,7 @@
168168 printf("User data sectors: %d (%d KiB)\n", logical, logical << 2);
169169 memcpy(bbt, "emBIbbth", 8);
170170 ((uint32_t*)bbt)[0x1fc] = logical;
171 - ((uint32_t*)bbt)[0x1ff] = (bbtpages >> 6) - 1;
 171+ ((uint32_t*)bbt)[0x1ff] = bbtgood;
172172 break;
173173 }
174174 free(bbt);