diff options
Diffstat (limited to 'rbutil/mkmpioboot/mkmpioboot.c')
-rw-r--r-- | rbutil/mkmpioboot/mkmpioboot.c | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/rbutil/mkmpioboot/mkmpioboot.c b/rbutil/mkmpioboot/mkmpioboot.c index b36f009730..ea619ed2f2 100644 --- a/rbutil/mkmpioboot/mkmpioboot.c +++ b/rbutil/mkmpioboot/mkmpioboot.c | |||
@@ -30,31 +30,26 @@ | |||
30 | #define MPIO_STRING_OFFSET 0xfffe0 /* offset of the version string in OF */ | 30 | #define MPIO_STRING_OFFSET 0xfffe0 /* offset of the version string in OF */ |
31 | #define BOOTLOADER_MAX_SIZE 0x1f800 /* free space size */ | 31 | #define BOOTLOADER_MAX_SIZE 0x1f800 /* free space size */ |
32 | 32 | ||
33 | /* Descriptive name of these models */ | 33 | struct mpio_model { |
34 | static const char* model_names[] = { | 34 | /* Descriptive name of this model */ |
35 | [MODEL_HD200] = "MPIO HD200", | 35 | const char* model_name; |
36 | [MODEL_HD300] = "MPIO HD300", | 36 | /* Model name used in the Rockbox header in ".mpio" files - these match the |
37 | -add parameter to the "scramble" tool */ | ||
38 | const char* rb_model_name; | ||
39 | /* Model number used to initialise the checksum in the Rockbox header in | ||
40 | ".mpio" files - these are the same as MODEL_NUMBER in config-target.h */ | ||
41 | const int rb_model_num; | ||
42 | /* Strings which indentifies OF version */ | ||
43 | const char* of_model_string; | ||
37 | }; | 44 | }; |
38 | 45 | ||
39 | /* Model names used in the Rockbox header in ".mpio" files - these match the | 46 | static const struct mpio_model mpio_models[] = { |
40 | -add parameter to the "scramble" tool */ | 47 | [MODEL_HD200] = |
41 | static const char* rb_model_names[] = { | 48 | { "MPIO HD200", "hd20", 69, "HD200 HDD Audio Ver113005" }, |
42 | [MODEL_HD200] = "hd20", | 49 | [MODEL_HD300] = |
43 | [MODEL_HD300] = "hd30", | 50 | { "MPIO HD300", "hd30", 70, "HD300 HDD Audio Ver113006" }, |
44 | }; | 51 | }; |
45 | 52 | ||
46 | /* Model numbers used to initialise the checksum in the Rockbox header in | ||
47 | ".mpio" files - these are the same as MODEL_NUMBER in config-target.h */ | ||
48 | static const int rb_model_num[] = { | ||
49 | [MODEL_HD200] = 69, | ||
50 | [MODEL_HD300] = 70, | ||
51 | }; | ||
52 | |||
53 | /* Strings which indentify OF version */ | ||
54 | static const char* of_model_string[] = { | ||
55 | [MODEL_HD200] = "HD200 HDD Audio Ver113005", | ||
56 | [MODEL_HD300] = "HD300 HDD Audio Ver113006", | ||
57 | }; | ||
58 | 53 | ||
59 | /* MPIO HD200 and HD300 firmware is plain binary image | 54 | /* MPIO HD200 and HD300 firmware is plain binary image |
60 | * 4 bytes of initial SP (loaded on reset) | 55 | * 4 bytes of initial SP (loaded on reset) |
@@ -123,7 +118,7 @@ int mkmpioboot(const char* infile, const char* bootfile, const char* outfile, in | |||
123 | */ | 118 | */ |
124 | 119 | ||
125 | for(model_index = 0; model_index < NUM_MODELS; model_index++) | 120 | for(model_index = 0; model_index < NUM_MODELS; model_index++) |
126 | if (strcmp(of_model_string[model_index], | 121 | if (strcmp(mpio_models[model_index].of_model_string, |
127 | (char*)(image + MPIO_STRING_OFFSET)) == 0) | 122 | (char*)(image + MPIO_STRING_OFFSET)) == 0) |
128 | break; | 123 | break; |
129 | 124 | ||
@@ -134,7 +129,7 @@ int mkmpioboot(const char* infile, const char* bootfile, const char* outfile, in | |||
134 | } | 129 | } |
135 | 130 | ||
136 | fprintf(stderr, "[INFO] Loading original firmware file for %s\n", | 131 | fprintf(stderr, "[INFO] Loading original firmware file for %s\n", |
137 | model_names[model_index]); | 132 | mpio_models[model_index].model_name); |
138 | 133 | ||
139 | /* Now, read the boot loader into the image */ | 134 | /* Now, read the boot loader into the image */ |
140 | f = fopen(bootfile, "rb"); | 135 | f = fopen(bootfile, "rb"); |
@@ -178,11 +173,11 @@ int mkmpioboot(const char* infile, const char* bootfile, const char* outfile, in | |||
178 | /* get bootloader header*/ | 173 | /* get bootloader header*/ |
179 | fread(header,1,8,f); | 174 | fread(header,1,8,f); |
180 | 175 | ||
181 | if ( memcmp(header + 4, rb_model_names[model_index], 4) != 0 ) | 176 | if ( memcmp(header + 4, mpio_models[model_index].rb_model_name, 4) != 0 ) |
182 | { | 177 | { |
183 | fprintf(stderr, "[ERR] Original firmware and rockbox bootloader mismatch!\n"); | 178 | fprintf(stderr, "[ERR] Original firmware and rockbox bootloader mismatch!\n"); |
184 | fprintf(stderr, "[ERR] Double check that you have bootloader for %s\n", | 179 | fprintf(stderr, "[ERR] Double check that you have bootloader for %s\n", |
185 | model_names[model_index]); | 180 | mpio_models[model_index].model_name); |
186 | return -7; | 181 | return -7; |
187 | } | 182 | } |
188 | 183 | ||
@@ -202,7 +197,7 @@ int mkmpioboot(const char* infile, const char* bootfile, const char* outfile, in | |||
202 | /* calculate checksum and compare with data | 197 | /* calculate checksum and compare with data |
203 | * from header | 198 | * from header |
204 | */ | 199 | */ |
205 | file_checksum = checksum(image + origin, rb_model_num[model_index], len); | 200 | file_checksum = checksum(image + origin, mpio_models[model_index].rb_model_num, len); |
206 | 201 | ||
207 | if ( file_checksum != get_uint32be(header) ) | 202 | if ( file_checksum != get_uint32be(header) ) |
208 | { | 203 | { |