summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-11-11 02:02:11 +0000
committerAmaury Pouly <amaury.pouly@gmail.com>2013-11-11 02:02:11 +0000
commitbb8dd053434cbe9c98fe5b9a1095d00ebafb7b61 (patch)
treeaf02a94d87691298a15758ed3e1c86b18c128519
parent39bfd0d2ab6b4edd30c1ccf4deefac96b9004e09 (diff)
downloadrockbox-bb8dd053434cbe9c98fe5b9a1095d00ebafb7b61.tar.gz
rockbox-bb8dd053434cbe9c98fe5b9a1095d00ebafb7b61.zip
imx233/creative: workaround stupid Creative partition table
This should fix wrong partition size on the ZEN, X-Fi and Mozaic Change-Id: Ib8999d414773c12e1b97d515e9bf058a82141d35
-rw-r--r--firmware/target/arm/imx233/partitions-imx233.c15
-rw-r--r--firmware/target/arm/imx233/partitions-imx233.h10
2 files changed, 20 insertions, 5 deletions
diff --git a/firmware/target/arm/imx233/partitions-imx233.c b/firmware/target/arm/imx233/partitions-imx233.c
index 508d6f0d66..60c36ebb4d 100644
--- a/firmware/target/arm/imx233/partitions-imx233.c
+++ b/firmware/target/arm/imx233/partitions-imx233.c
@@ -64,7 +64,6 @@ static const char *creative_part_name(enum imx233_part_t part)
64{ 64{
65 switch(part) 65 switch(part)
66 { 66 {
67 case IMX233_PART_USER: return "cfs";
68 case IMX233_PART_CFS: return "cfs"; 67 case IMX233_PART_CFS: return "cfs";
69 case IMX233_PART_MINIFS: return "minifs"; 68 case IMX233_PART_MINIFS: return "minifs";
70 default: return ""; 69 default: return "";
@@ -90,7 +89,17 @@ static int compute_window_creative(intptr_t user, part_read_fn_t read_fn,
90 if(strcmp(ent[i].name, name) == 0) 89 if(strcmp(ent[i].name, name) == 0)
91 { 90 {
92 *start = ent[i].start * hdr->block_size / 512; 91 *start = ent[i].start * hdr->block_size / 512;
93 *end = *start + ent[i].size * hdr->block_size / 512; 92 if(part == IMX233_PART_CFS)
93 {
94 /* There is a bug in Creative's partitioner which restrict
95 * computations to 32-bit even though the format itself can
96 * handle much bigger volumes. We make the assumption
97 * that the CFS partition always extends up the end of the
98 * volume. So don't touch *end */
99 }
100 else
101 *end = *start + ent[i].size * hdr->block_size / 512;
102
94 return 0; 103 return 0;
95 } 104 }
96 } 105 }
@@ -126,7 +135,7 @@ static int compute_window_freescale(intptr_t user, part_read_fn_t read_fn,
126 * it seems that it is similarly truncated. */ 135 * it seems that it is similarly truncated. */
127 if(mbr[510] != 0x55 || mbr[511] != 0xAA) 136 if(mbr[510] != 0x55 || mbr[511] != 0xAA)
128 return -101; /* invalid MBR */ 137 return -101; /* invalid MBR */
129 if(part == IMX233_PART_USER) 138 if(part == IMX233_PART_DATA)
130 { 139 {
131 /* sanity check that the first partition is greater than 2Gib */ 140 /* sanity check that the first partition is greater than 2Gib */
132 uint8_t *ent = &mbr[446]; 141 uint8_t *ent = &mbr[446];
diff --git a/firmware/target/arm/imx233/partitions-imx233.h b/firmware/target/arm/imx233/partitions-imx233.h
index 80936ad865..e5378dadbb 100644
--- a/firmware/target/arm/imx233/partitions-imx233.h
+++ b/firmware/target/arm/imx233/partitions-imx233.h
@@ -30,13 +30,15 @@
30 30
31enum imx233_part_t 31enum imx233_part_t
32{ 32{
33 IMX233_PART_USER,
34#if (IMX233_PARTITIONS & IMX233_FREESCALE) 33#if (IMX233_PARTITIONS & IMX233_FREESCALE)
35 IMX233_PART_BOOT, 34 IMX233_PART_BOOT,
35 IMX233_PART_DATA,
36 IMX233_PART_USER = IMX233_PART_DATA,
36#endif 37#endif
37#if (IMX233_PARTITIONS & IMX233_CREATIVE) 38#if (IMX233_PARTITIONS & IMX233_CREATIVE)
38 IMX233_PART_CFS, 39 IMX233_PART_CFS,
39 IMX233_PART_MINIFS, 40 IMX233_PART_MINIFS,
41 IMX233_PART_USER = IMX233_PART_CFS,
40#endif 42#endif
41}; 43};
42 44
@@ -45,9 +47,13 @@ enum imx233_part_t
45 * issue, one must provide a read function. */ 47 * issue, one must provide a read function. */
46typedef int (*part_read_fn_t)(intptr_t user, unsigned long start, int count, void* buf); 48typedef int (*part_read_fn_t)(intptr_t user, unsigned long start, int count, void* buf);
47/* Enable/Disable window computations for internal storage following the 49/* Enable/Disable window computations for internal storage following the
48 * Freescale convention */ 50 * Freescale/Creative convention */
49void imx233_partitions_enable_window(bool enable); 51void imx233_partitions_enable_window(bool enable);
50bool imx233_partitions_is_window_enabled(void); 52bool imx233_partitions_is_window_enabled(void);
53/* Compute the window size. The *start and *end parameters should contain
54 * the initial window in which the computation is done. So in particular,
55 * for a whole disk, *end should be the size of the disk when the function is
56 * called */
51int imx233_partitions_compute_window(intptr_t user, part_read_fn_t read_fn, 57int imx233_partitions_compute_window(intptr_t user, part_read_fn_t read_fn,
52 enum imx233_part_t part, unsigned *start, unsigned *end); 58 enum imx233_part_t part, unsigned *start, unsigned *end);
53 59