This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Flash bound checking fails if "upper (0xffffffff)" flash mapping
- From: sebastien Couret <sebastien dot couret at elios-informatique dot fr>
- To: ecos-patches at sources dot redhat dot com
- Date: Thu, 22 Apr 2004 12:13:07 +0200
- Subject: Flash bound checking fails if "upper (0xffffffff)" flash mapping
- Organization: Elios Informatique
- Reply-to: sebastien dot couret at elios-informatique dot fr
I have ran into a particular problem with the flash.
It's about flash address bound checking.
This problem only happens if the two following conditions are met :
- Assert are activated (CYG_INFRA_DEBUG set)
- Upper flash address is set to 0xffffffff
What happens is that 'flash_hwr_init()' (which is implemented differently for
each flash hardware) sets flash_info.end to zero (0xffffffff+1 !))
As a result , in io/flash/current/src/flashiodev.c , following check fails !
(flashend=0 and endpos>0 ), so flash access is always refused !
#ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time
char *endpos = startpos + *len - 1;
char *flashend = MIN( (char *)flash_info.end, dev->end);
if ( startpos < dev->start )
return -EINVAL;
if ( endpos > flashend )
return -EINVAL;
#endif
May be the better corrective will be to change the way of computing
flash_info.end (by just substracting one) in each hardware flash driver.
But it's quicker to change directly flashiodev.c.
Here 's a patch :
diff -a -w -r -u io/flash/current/src/v1.7/ io/flash/current/src/flashiodev.c
--- io/flash/current/src/v1.7/flashiodev.c Thu Apr 22 11:31:55 2004
+++ io/flash/current/src/flashiodev.c Mon Apr 19 18:47:35 2004
@@ -126,7 +126,7 @@
#ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time
char *endpos = startpos + *len - 1;
- char *flashend = MIN( (char *)flash_info.end, dev->end);
+ char *flashend = MIN( (char *)flash_info.end - 1, dev->end);
if ( startpos < dev->start )
return -EINVAL;
if ( endpos > flashend )
@@ -154,7 +154,7 @@
#ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time
char *endpos = startpos + *len - 1;
- char *flashend = MIN( (char *)flash_info.end, dev->end);
+ char *flashend = MIN( (char *)flash_info.end - 1, dev->end);
if ( startpos < dev->start )
return -EINVAL;
if ( endpos > flashend )
@@ -188,7 +188,7 @@
#ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time
char *endpos = startpos + e->len - 1;
- char *flashend = MIN( (char *)flash_info.end, dev->end);
+ char *flashend = MIN( (char *)flash_info.end - 1,
dev->end);
if ( startpos < dev->start )
return -EINVAL;
if ( endpos > flashend )
@@ -218,7 +218,7 @@
(cyg_io_flash_getconfig_blocksize_t *)buf;
#ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time
char *startpos = dev->start + b->offset;
- char *flashend = MIN( (char *)flash_info.end, dev->end);
+ char *flashend = MIN( (char *)(flash_info.end) - 1, dev->end);
if ( startpos < dev->start )
return -EINVAL;
@@ -244,8 +244,10 @@
const void* buf,
cyg_uint32* len)
{
+#ifdef CYGNUM_IO_FLASH_BLOCK_CFG_FIS_1
struct cyg_devtab_entry *tab = (struct cyg_devtab_entry *)handle;
struct flashiodev_priv_t *dev = (struct flashiodev_priv_t *)tab->priv;
+#endif
switch (key) {
#ifdef CYGNUM_IO_FLASH_BLOCK_CFG_FIS_1
And the Changelog entry :
2004-04-22 ?Sebastien Couret ?<sebastien.couret@elios-informatique.com>
? ? ? ? * src/flashiodev.c: Modified flash upper bound checking. (substracted
one)