diff options
author | Jörg Hohensohn <hohensoh@rockbox.org> | 2005-08-23 07:26:40 +0000 |
---|---|---|
committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2005-08-23 07:26:40 +0000 |
commit | 13be9f14d7ef8136ea225eaecc5ad17ef203686a (patch) | |
tree | c37ab90be55de930005ec79f3ffe0baaa918ef3c /apps/plugins/rockbox_flash.c | |
parent | 02cfd6a6e92a743460321cd2c42bde10626d73c5 (diff) | |
download | rockbox-13be9f14d7ef8136ea225eaecc5ad17ef203686a.tar.gz rockbox-13be9f14d7ef8136ea225eaecc5ad17ef203686a.zip |
allow the flash plugin to verify the RomBox link address
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7388 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockbox_flash.c')
-rw-r--r-- | apps/plugins/rockbox_flash.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/apps/plugins/rockbox_flash.c b/apps/plugins/rockbox_flash.c index 9a403197dd..4c552622e5 100644 --- a/apps/plugins/rockbox_flash.c +++ b/apps/plugins/rockbox_flash.c | |||
@@ -82,6 +82,7 @@ typedef enum | |||
82 | eNotUCL, | 82 | eNotUCL, |
83 | eWrongAlgorithm, | 83 | eWrongAlgorithm, |
84 | eMultiBlocks, | 84 | eMultiBlocks, |
85 | eBadRomLink | ||
85 | } tCheckResult; | 86 | } tCheckResult; |
86 | 87 | ||
87 | typedef struct | 88 | typedef struct |
@@ -438,10 +439,31 @@ tCheckResult CheckImageFile(char* filename, int space, tImageHeader* pHeader, | |||
438 | rb->close(fd); | 439 | rb->close(fd); |
439 | return eReadErr; | 440 | return eReadErr; |
440 | } | 441 | } |
441 | pHeader->execute = reset_vector; | 442 | if (reset_vector >= (UINT32)FB |
442 | if (reset_vector != ROCKBOX_EXEC) /* nonstandard address? */ | 443 | && reset_vector < (UINT32)FB+512*1024) /* ROM address? */ |
444 | { | ||
443 | /* assume in-place, executing directly in flash */ | 445 | /* assume in-place, executing directly in flash */ |
444 | pHeader->destination = (UINT32)(pos + sizeof(tImageHeader)); | 446 | pHeader->destination = (UINT32)(pos + sizeof(tImageHeader)); |
447 | |||
448 | /* for new RomBox, this isn't the reset vector, | ||
449 | but the link address, for us to check the position */ | ||
450 | if(pHeader->destination != reset_vector) /* compare link addr. */ | ||
451 | { | ||
452 | rb->close(fd); | ||
453 | return eBadRomLink; /* not matching the start address */ | ||
454 | } | ||
455 | |||
456 | /* read the now following reset vector */ | ||
457 | read = rb->read(fd, &reset_vector, sizeof(reset_vector)); | ||
458 | fileread += read; | ||
459 | if (read != sizeof(reset_vector)) | ||
460 | { | ||
461 | rb->close(fd); | ||
462 | return eReadErr; | ||
463 | } | ||
464 | } | ||
465 | |||
466 | pHeader->execute = reset_vector; | ||
445 | } | 467 | } |
446 | 468 | ||
447 | /* check if we can read the whole file */ | 469 | /* check if we can read the whole file */ |
@@ -737,6 +759,10 @@ void DoUserDialog(char* filename) | |||
737 | rb->lcd_puts(0, 2, "Blocksize"); | 759 | rb->lcd_puts(0, 2, "Blocksize"); |
738 | rb->lcd_puts(0, 3, " too small?"); | 760 | rb->lcd_puts(0, 3, " too small?"); |
739 | break; | 761 | break; |
762 | case eBadRomLink: | ||
763 | rb->lcd_puts(0, 1, "RomBox mismatch."); | ||
764 | rb->lcd_puts(0, 2, "Wrong ROM position"); | ||
765 | break; | ||
740 | default: | 766 | default: |
741 | rb->lcd_puts(0, 1, "Check failed."); | 767 | rb->lcd_puts(0, 1, "Check failed."); |
742 | break; | 768 | break; |
@@ -906,6 +932,9 @@ void DoUserDialog(char* filename) | |||
906 | case eMultiBlocks: | 932 | case eMultiBlocks: |
907 | rb->lcd_puts_scroll(0, 1, "File invalid. Blocksize too small?"); | 933 | rb->lcd_puts_scroll(0, 1, "File invalid. Blocksize too small?"); |
908 | break; | 934 | break; |
935 | case eBadRomLink: | ||
936 | rb->lcd_puts_scroll(0, 1, "BootBox mismatch"); | ||
937 | break; | ||
909 | default: | 938 | default: |
910 | rb->lcd_puts_scroll(0, 1, "Check failed."); | 939 | rb->lcd_puts_scroll(0, 1, "Check failed."); |
911 | break; | 940 | break; |