diff options
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/arm/imx233/partitions-imx233.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/firmware/target/arm/imx233/partitions-imx233.c b/firmware/target/arm/imx233/partitions-imx233.c index 60c36ebb4d..bb322162c9 100644 --- a/firmware/target/arm/imx233/partitions-imx233.c +++ b/firmware/target/arm/imx233/partitions-imx233.c | |||
@@ -125,14 +125,22 @@ static int compute_window_freescale(intptr_t user, part_read_fn_t read_fn, | |||
125 | * The first table uses 512-byte sector size and the second one usually uses | 125 | * The first table uses 512-byte sector size and the second one usually uses |
126 | * 2048-byte logical sector size. | 126 | * 2048-byte logical sector size. |
127 | * | 127 | * |
128 | * We restrict the window to the user partition | ||
129 | * | ||
130 | * WARNING HACK FIXME BUG | 128 | * WARNING HACK FIXME BUG |
131 | * Reverse engineering and experiments suggests that the OF ignores the lowest 2 bits | 129 | * Reverse engineering suggests that OF has a notion of "internal sector size" |
132 | * of the LBAs in the partition table. There is at least one example | 130 | * which can either be 512 or 2048 bytes. When applied to the main data drive, |
133 | * (the Creative Zen X-Fi3) where this is important because the LBA of the user partition | 131 | * it internally converts LBA from sectors to "internal sectors". Consequently, |
134 | * is not a multiple of 4. The behaviour of the size field is less clear but | 132 | * if the internal sector size is 2048 and the sector size of 512, it will |
135 | * it seems that it is similarly truncated. */ | 133 | * drop the lowest 2 bits of the LBA from the partition table. This is the case |
134 | * of the ZEN X-Fi3 for example. However, if the internal sector size is 512 | ||
135 | * bytes, then there is no such loss. This is the case of the Zen X-Fi Style | ||
136 | * for example. | ||
137 | * The behaviour of the size field is less clear but it seems that it is similarly | ||
138 | * truncated. */ | ||
139 | #if defined(CREATIVE_ZENXFISTYLE) | ||
140 | #define DROP_MASK 0 | ||
141 | #else | ||
142 | #define DROP_MASK 3 | ||
143 | #endif | ||
136 | if(mbr[510] != 0x55 || mbr[511] != 0xAA) | 144 | if(mbr[510] != 0x55 || mbr[511] != 0xAA) |
137 | return -101; /* invalid MBR */ | 145 | return -101; /* invalid MBR */ |
138 | if(part == IMX233_PART_DATA) | 146 | if(part == IMX233_PART_DATA) |
@@ -141,9 +149,9 @@ static int compute_window_freescale(intptr_t user, part_read_fn_t read_fn, | |||
141 | uint8_t *ent = &mbr[446]; | 149 | uint8_t *ent = &mbr[446]; |
142 | *start = ent[8] | ent[9] << 8 | ent[10] << 16 | ent[11] << 24; | 150 | *start = ent[8] | ent[9] << 8 | ent[10] << 16 | ent[11] << 24; |
143 | /* ignore two lowest bits(see comment above) */ | 151 | /* ignore two lowest bits(see comment above) */ |
144 | *start &= ~3; | 152 | *start &= ~DROP_MASK; |
145 | *end = (ent[12] | ent[13] << 8 | ent[14] << 16 | ent[15] << 24); | 153 | *end = (ent[12] | ent[13] << 8 | ent[14] << 16 | ent[15] << 24); |
146 | *end &= ~3; | 154 | *end &= ~DROP_MASK; |
147 | /* ignore two lowest bits(order is important, first truncate then add start) */ | 155 | /* ignore two lowest bits(order is important, first truncate then add start) */ |
148 | *end += *start; | 156 | *end += *start; |
149 | 157 | ||