summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2005-08-23 07:26:40 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2005-08-23 07:26:40 +0000
commit13be9f14d7ef8136ea225eaecc5ad17ef203686a (patch)
treec37ab90be55de930005ec79f3ffe0baaa918ef3c
parent02cfd6a6e92a743460321cd2c42bde10626d73c5 (diff)
downloadrockbox-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
-rw-r--r--apps/plugins/rockbox_flash.c33
-rw-r--r--firmware/rom.lds8
2 files changed, 39 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
87typedef struct 88typedef 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;
diff --git a/firmware/rom.lds b/firmware/rom.lds
index 632a69ed9e..8781873f45 100644
--- a/firmware/rom.lds
+++ b/firmware/rom.lds
@@ -40,6 +40,14 @@ MEMORY
40} 40}
41SECTIONS 41SECTIONS
42{ 42{
43 .flashheader :
44 {
45 /* place flash link address first, so the plugin can check */
46 LONG(FLASHORIG);
47 /* followed by the start address, the first vector takes care of this. */
48 /* If we ever place the table elsewhere, put a constant here. */
49 } > FLASH
50
43 .vectors : 51 .vectors :
44 { 52 {
45 _datacopy = .; 53 _datacopy = .;