forked from len0rd/rockbox
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
This commit is contained in:
parent
02cfd6a6e9
commit
13be9f14d7
2 changed files with 39 additions and 2 deletions
|
@ -82,6 +82,7 @@ typedef enum
|
||||||
eNotUCL,
|
eNotUCL,
|
||||||
eWrongAlgorithm,
|
eWrongAlgorithm,
|
||||||
eMultiBlocks,
|
eMultiBlocks,
|
||||||
|
eBadRomLink
|
||||||
} tCheckResult;
|
} tCheckResult;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -438,10 +439,31 @@ tCheckResult CheckImageFile(char* filename, int space, tImageHeader* pHeader,
|
||||||
rb->close(fd);
|
rb->close(fd);
|
||||||
return eReadErr;
|
return eReadErr;
|
||||||
}
|
}
|
||||||
pHeader->execute = reset_vector;
|
if (reset_vector >= (UINT32)FB
|
||||||
if (reset_vector != ROCKBOX_EXEC) /* nonstandard address? */
|
&& reset_vector < (UINT32)FB+512*1024) /* ROM address? */
|
||||||
|
{
|
||||||
/* assume in-place, executing directly in flash */
|
/* assume in-place, executing directly in flash */
|
||||||
pHeader->destination = (UINT32)(pos + sizeof(tImageHeader));
|
pHeader->destination = (UINT32)(pos + sizeof(tImageHeader));
|
||||||
|
|
||||||
|
/* for new RomBox, this isn't the reset vector,
|
||||||
|
but the link address, for us to check the position */
|
||||||
|
if(pHeader->destination != reset_vector) /* compare link addr. */
|
||||||
|
{
|
||||||
|
rb->close(fd);
|
||||||
|
return eBadRomLink; /* not matching the start address */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read the now following reset vector */
|
||||||
|
read = rb->read(fd, &reset_vector, sizeof(reset_vector));
|
||||||
|
fileread += read;
|
||||||
|
if (read != sizeof(reset_vector))
|
||||||
|
{
|
||||||
|
rb->close(fd);
|
||||||
|
return eReadErr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pHeader->execute = reset_vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if we can read the whole file */
|
/* check if we can read the whole file */
|
||||||
|
@ -737,6 +759,10 @@ void DoUserDialog(char* filename)
|
||||||
rb->lcd_puts(0, 2, "Blocksize");
|
rb->lcd_puts(0, 2, "Blocksize");
|
||||||
rb->lcd_puts(0, 3, " too small?");
|
rb->lcd_puts(0, 3, " too small?");
|
||||||
break;
|
break;
|
||||||
|
case eBadRomLink:
|
||||||
|
rb->lcd_puts(0, 1, "RomBox mismatch.");
|
||||||
|
rb->lcd_puts(0, 2, "Wrong ROM position");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
rb->lcd_puts(0, 1, "Check failed.");
|
rb->lcd_puts(0, 1, "Check failed.");
|
||||||
break;
|
break;
|
||||||
|
@ -906,6 +932,9 @@ void DoUserDialog(char* filename)
|
||||||
case eMultiBlocks:
|
case eMultiBlocks:
|
||||||
rb->lcd_puts_scroll(0, 1, "File invalid. Blocksize too small?");
|
rb->lcd_puts_scroll(0, 1, "File invalid. Blocksize too small?");
|
||||||
break;
|
break;
|
||||||
|
case eBadRomLink:
|
||||||
|
rb->lcd_puts_scroll(0, 1, "BootBox mismatch");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
rb->lcd_puts_scroll(0, 1, "Check failed.");
|
rb->lcd_puts_scroll(0, 1, "Check failed.");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -40,6 +40,14 @@ MEMORY
|
||||||
}
|
}
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
.flashheader :
|
||||||
|
{
|
||||||
|
/* place flash link address first, so the plugin can check */
|
||||||
|
LONG(FLASHORIG);
|
||||||
|
/* followed by the start address, the first vector takes care of this. */
|
||||||
|
/* If we ever place the table elsewhere, put a constant here. */
|
||||||
|
} > FLASH
|
||||||
|
|
||||||
.vectors :
|
.vectors :
|
||||||
{
|
{
|
||||||
_datacopy = .;
|
_datacopy = .;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue