diff options
author | Rafaël Carré <rafael.carre@gmail.com> | 2009-05-28 21:19:21 +0000 |
---|---|---|
committer | Rafaël Carré <rafael.carre@gmail.com> | 2009-05-28 21:19:21 +0000 |
commit | a96f2373db547c4ed482dffe1b4037013a1171ea (patch) | |
tree | fdbfae1fa1d58d8c661c0f7c31cf1dbd7e405734 | |
parent | 5941869a6940c829d4299843d61b83465713fa3a (diff) | |
download | rockbox-a96f2373db547c4ed482dffe1b4037013a1171ea.tar.gz rockbox-a96f2373db547c4ed482dffe1b4037013a1171ea.zip |
mkamsboot : brackets at the start of functions must be on their line - thanks to linuxstb for noticing
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21122 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | rbutil/mkamsboot/mkamsboot.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/rbutil/mkamsboot/mkamsboot.c b/rbutil/mkamsboot/mkamsboot.c index 4210d3bd7c..b55c8bcbdb 100644 --- a/rbutil/mkamsboot/mkamsboot.c +++ b/rbutil/mkamsboot/mkamsboot.c | |||
@@ -216,7 +216,8 @@ static struct md5sums sansasums[] = { | |||
216 | 216 | ||
217 | #define NUM_MD5S (sizeof(sansasums)/sizeof(sansasums[0])) | 217 | #define NUM_MD5S (sizeof(sansasums)/sizeof(sansasums[0])) |
218 | 218 | ||
219 | static off_t filesize(int fd) { | 219 | static off_t filesize(int fd) |
220 | { | ||
220 | struct stat buf; | 221 | struct stat buf; |
221 | 222 | ||
222 | if (fstat(fd, &buf) < 0) { | 223 | if (fstat(fd, &buf) < 0) { |
@@ -227,22 +228,26 @@ static off_t filesize(int fd) { | |||
227 | } | 228 | } |
228 | } | 229 | } |
229 | 230 | ||
230 | static uint32_t get_uint32le(unsigned char* p) { | 231 | static uint32_t get_uint32le(unsigned char* p) |
232 | { | ||
231 | return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); | 233 | return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); |
232 | } | 234 | } |
233 | 235 | ||
234 | static uint32_t get_uint32be(unsigned char* p) { | 236 | static uint32_t get_uint32be(unsigned char* p) |
237 | { | ||
235 | return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; | 238 | return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; |
236 | } | 239 | } |
237 | 240 | ||
238 | static void put_uint32le(unsigned char* p, uint32_t x) { | 241 | static void put_uint32le(unsigned char* p, uint32_t x) |
242 | { | ||
239 | p[0] = x & 0xff; | 243 | p[0] = x & 0xff; |
240 | p[1] = (x >> 8) & 0xff; | 244 | p[1] = (x >> 8) & 0xff; |
241 | p[2] = (x >> 16) & 0xff; | 245 | p[2] = (x >> 16) & 0xff; |
242 | p[3] = (x >> 24) & 0xff; | 246 | p[3] = (x >> 24) & 0xff; |
243 | } | 247 | } |
244 | 248 | ||
245 | void calc_MD5(unsigned char* buf, int len, char *md5str) { | 249 | void calc_MD5(unsigned char* buf, int len, char *md5str) |
250 | { | ||
246 | int i; | 251 | int i; |
247 | md5_context ctx; | 252 | md5_context ctx; |
248 | unsigned char md5sum[16]; | 253 | unsigned char md5sum[16]; |
@@ -256,7 +261,8 @@ void calc_MD5(unsigned char* buf, int len, char *md5str) { | |||
256 | } | 261 | } |
257 | 262 | ||
258 | /* Calculate a simple checksum used in Sansa Original Firmwares */ | 263 | /* Calculate a simple checksum used in Sansa Original Firmwares */ |
259 | static uint32_t calc_checksum(unsigned char* buf, uint32_t n) { | 264 | static uint32_t calc_checksum(unsigned char* buf, uint32_t n) |
265 | { | ||
260 | uint32_t sum = 0; | 266 | uint32_t sum = 0; |
261 | uint32_t i; | 267 | uint32_t i; |
262 | 268 | ||
@@ -266,7 +272,8 @@ static uint32_t calc_checksum(unsigned char* buf, uint32_t n) { | |||
266 | return sum; | 272 | return sum; |
267 | } | 273 | } |
268 | 274 | ||
269 | static int get_model(int model_id) { | 275 | static int get_model(int model_id) |
276 | { | ||
270 | switch(model_id) { | 277 | switch(model_id) { |
271 | case 0x1e: | 278 | case 0x1e: |
272 | return MODEL_FUZE; | 279 | return MODEL_FUZE; |
@@ -286,7 +293,8 @@ static int get_model(int model_id) { | |||
286 | } | 293 | } |
287 | 294 | ||
288 | /* Compress using nrv2e algorithm : Thumb decompressor fits in 168 bytes ! */ | 295 | /* Compress using nrv2e algorithm : Thumb decompressor fits in 168 bytes ! */ |
289 | static unsigned char* uclpack(unsigned char* inbuf, int insize, int* outsize) { | 296 | static unsigned char* uclpack(unsigned char* inbuf, int insize, int* outsize) |
297 | { | ||
290 | int maxsize; | 298 | int maxsize; |
291 | unsigned char* outbuf; | 299 | unsigned char* outbuf; |
292 | int r; | 300 | int r; |
@@ -327,8 +335,8 @@ static unsigned char* uclpack(unsigned char* inbuf, int insize, int* outsize) { | |||
327 | unsigned char* load_of_file( | 335 | unsigned char* load_of_file( |
328 | char* filename, off_t* bufsize, char* md5sum, int* model, | 336 | char* filename, off_t* bufsize, char* md5sum, int* model, |
329 | int* fw_version, int* firmware_size, unsigned char** of_packed, | 337 | int* fw_version, int* firmware_size, unsigned char** of_packed, |
330 | int* of_packedsize, char* errstr, int errstrsize | 338 | int* of_packedsize, char* errstr, int errstrsize) |
331 | ) { | 339 | { |
332 | int fd; | 340 | int fd; |
333 | unsigned char* buf =NULL; | 341 | unsigned char* buf =NULL; |
334 | off_t n; | 342 | off_t n; |
@@ -411,8 +419,8 @@ error: | |||
411 | /* Loads a rockbox bootloader file into memory */ | 419 | /* Loads a rockbox bootloader file into memory */ |
412 | unsigned char* load_rockbox_file( | 420 | unsigned char* load_rockbox_file( |
413 | char* filename, int model, int* bufsize, int* rb_packedsize, | 421 | char* filename, int model, int* bufsize, int* rb_packedsize, |
414 | char* errstr, int errstrsize | 422 | char* errstr, int errstrsize) |
415 | ) { | 423 | { |
416 | int fd; | 424 | int fd; |
417 | unsigned char* buf = NULL; | 425 | unsigned char* buf = NULL; |
418 | unsigned char* packed = NULL; | 426 | unsigned char* packed = NULL; |
@@ -474,8 +482,8 @@ error: | |||
474 | void patch_firmware( | 482 | void patch_firmware( |
475 | int model, int fw_version, int firmware_size, unsigned char* buf, | 483 | int model, int fw_version, int firmware_size, unsigned char* buf, |
476 | int len, unsigned char* of_packed, int of_packedsize, | 484 | int len, unsigned char* of_packed, int of_packedsize, |
477 | unsigned char* rb_packed, int rb_packedsize | 485 | unsigned char* rb_packed, int rb_packedsize) |
478 | ) { | 486 | { |
479 | unsigned char *p; | 487 | unsigned char *p; |
480 | uint32_t sum, filesum; | 488 | uint32_t sum, filesum; |
481 | unsigned int i; | 489 | unsigned int i; |
@@ -543,14 +551,16 @@ void patch_firmware( | |||
543 | } | 551 | } |
544 | 552 | ||
545 | /* returns size of new firmware block */ | 553 | /* returns size of new firmware block */ |
546 | int total_size(int model, int rb_packedsize, int of_packedsize) { | 554 | int total_size(int model, int rb_packedsize, int of_packedsize) |
555 | { | ||
547 | return bootloader_sizes[model] + sizeof(nrv2e_d8) + of_packedsize + | 556 | return bootloader_sizes[model] + sizeof(nrv2e_d8) + of_packedsize + |
548 | rb_packedsize; | 557 | rb_packedsize; |
549 | } | 558 | } |
550 | 559 | ||
551 | #ifndef LIB | 560 | #ifndef LIB |
552 | /* standalone executable */ | 561 | /* standalone executable */ |
553 | int main(int argc, char* argv[]) { | 562 | int main(int argc, char* argv[]) |
563 | { | ||
554 | char *infile, *bootfile, *outfile; | 564 | char *infile, *bootfile, *outfile; |
555 | int fdout; | 565 | int fdout; |
556 | off_t len; | 566 | off_t len; |