diff options
author | Till Straumann <strauman@slac.stanford.edu> | 2007-11-27 21:14:26 +0000 |
---|---|---|
committer | Till Straumann <strauman@slac.stanford.edu> | 2007-11-27 21:14:26 +0000 |
commit | 6c81fcc2a11d7939504d32ac07a45cd3d205a0c3 (patch) | |
tree | cc66f61326bc233db1f1a69673ccea72acb78dfc | |
parent | 2007-11-27 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-6c81fcc2a11d7939504d32ac07a45cd3d205a0c3.tar.bz2 |
2007-11-29 Till Straumann <strauman@slac.stanford.edu>
* shared/flash/flash.c, shared/flash/flashPgm.h:
added calls to obtain info about flash bank start,
size and block size.
-rw-r--r-- | c/src/lib/libbsp/powerpc/shared/flash/flash.c | 38 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/shared/flash/flashPgm.h | 29 |
2 files changed, 62 insertions, 5 deletions
diff --git a/c/src/lib/libbsp/powerpc/shared/flash/flash.c b/c/src/lib/libbsp/powerpc/shared/flash/flash.c index 285e51a765..7ce45b0e95 100644 --- a/c/src/lib/libbsp/powerpc/shared/flash/flash.c +++ b/c/src/lib/libbsp/powerpc/shared/flash/flash.c @@ -104,6 +104,9 @@ BSP_flashProbeSize(struct bankdesc *b); STATIC struct bankdesc * bankValidate(int bank, int quiet); +static struct bankdesc * +argcheck(int bank, uint32_t offset, char *src, uint32_t size); + /* Type definitions */ union bconv { @@ -407,10 +410,39 @@ unsigned q; for ( rval = 0, q=1; rval < max && (dd = BSP_flashCheckId(b, b->start + max - SCAN_BACK_OFFSET - rval, q)); q=3 ) { rval += dd->size * FLASH_NDEVS(b); } + b->start += max - rval; } return rval; } +uint32_t +BSP_flashStart(int bank) +{ +struct bankdesc *b; + if ( ! ( b = argcheck(bank, 0, 0, 0) ) ) + return -1; + return b->start; +} + +uint32_t +BSP_flashSize(int bank) +{ +struct bankdesc *b; + if ( ! ( b = argcheck(bank, 0, 0, 0) ) ) + return -1; + return b->size; +} + +uint32_t +BSP_flashBlockSize(int bank) +{ +struct bankdesc *b; + if ( ! ( b = argcheck(bank, 0, 0, 0) ) ) + return -1; + return b->fblksz; +} + + #ifndef TESTING /* Obtain bank description making sure it is initialized and not write protected */ @@ -446,7 +478,7 @@ struct bankdesc *b = BSP_flashBspOps.bankcheck(bank, quiet); */ static struct bankdesc * -argcheck(uint32_t bank, uint32_t offset, char *src, uint32_t size) +argcheck(int bank, uint32_t offset, char *src, uint32_t size) { struct bankdesc *b; @@ -639,7 +671,7 @@ bail: } int -BSP_flashErase(uint32_t bank, uint32_t offset, uint32_t size, int quiet) +BSP_flashErase(int bank, uint32_t offset, uint32_t size, int quiet) { struct bankdesc *b; uint32_t a,i; @@ -660,7 +692,7 @@ int f; a = b->start + offset; if ( !quiet ) { - printf("ERASING Flash (Bank #%"PRIu32")\n from 0x%08"PRIx32" .. 0x%08"PRIx32"\nproceed y/[n]?", + printf("ERASING Flash (Bank #%i)\n from 0x%08"PRIx32" .. 0x%08"PRIx32"\nproceed y/[n]?", bank, a, (a+size-1)); fflush(stdout); if ( 'Y' != getUc() ) { diff --git a/c/src/lib/libbsp/powerpc/shared/flash/flashPgm.h b/c/src/lib/libbsp/powerpc/shared/flash/flashPgm.h index 2d93cd094e..3b49ff172c 100644 --- a/c/src/lib/libbsp/powerpc/shared/flash/flashPgm.h +++ b/c/src/lib/libbsp/powerpc/shared/flash/flashPgm.h @@ -70,12 +70,13 @@ BSP_flashWriteDisable(int bank); * NOTES: - 'offset' and 'size' must be block-aligned. Common 16-bit devices * have a block size of 0x20000 bytes. If two such devices are * operated in parallel to form a 32-bit word then the 'effective' - * block size is 0x40000 bytes. + * block size is 0x40000 bytes. The block size can be queried by + * BSP_flashBlockSize(int bank); * * - erase operation is verified. */ int -BSP_flashErase(uint32_t bank, uint32_t offset, uint32_t size, int quiet); +BSP_flashErase(int bank, uint32_t offset, uint32_t size, int quiet); /* Write data from a buffer to flash. The target area is erased if necessary. * @@ -133,6 +134,30 @@ BSP_flashWriteFile(int bank, uint32_t offset, char *path, int quiet); int BSP_flashDumpInfo(FILE *f); +/* + * Obtain starting-address of flash bank (as seen from CPU) + * (returns ((uint32_t) -1) if the bank argument is invalid). + */ + +uint32_t +BSP_flashStart(int bank); + +/* + * Obtain size of flash bank (returns ((uint32_t) -1) if the + * bank argument is invalid). + */ +uint32_t +BSP_flashSize(int bank); + +/* + * Obtain block size of flash bank (sector size times + * number of devices in parallel; the block size determines + * alignment and granularity accepted by BSP_flashErase() + * (returns ((uint32_t) -1) if the bank argument is invalid). + */ +uint32_t +BSP_flashBlockSize(int bank); + #ifdef __cplusplus } #endif |