Mercurial > flash_v2
changeset 307:906a5d289c6d
Better memory use vis FIS & ZLIB - from Thomas Koeller
| author | gthomas |
|---|---|
| date | Sat, 24 Aug 2002 11:34:49 +0000 |
| parents | eb332fa195ca |
| children | d64d82910fa2 |
| files | packages/redboot/current/ChangeLog packages/redboot/current/cdl/redboot.cdl packages/redboot/current/include/redboot.h packages/redboot/current/src/decompress.c packages/redboot/current/src/flash.c packages/redboot/current/src/main.c |
| diffstat | 6 files changed, 71 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,12 @@ +2002-08-20 Thomas Koeller <thomas@koeller.dyndns.org> + + * cdl/redboot.cdl: + * include/redboot.h: + * src/main.c: + * src/flash.c: + * src/decompress.c: Use a common buffer for FIS directory + manipulation and zlib workspace to conserve RAM. + 2002-08-20 Thomas Koeller <thomas@koeller.dyndns.org> * cdl/redboot.cdl:
--- a/packages/redboot/current/cdl/redboot.cdl +++ b/packages/redboot/current/cdl/redboot.cdl @@ -833,6 +833,28 @@ cdl_package CYGPKG_REDBOOT { no_define } } + + cdl_component CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER { + display "Use a common buffer for Zlib and FIS" + flavor bool + active_if { CYGBLD_BUILD_REDBOOT_WITH_ZLIB && \ + CYGOPT_REDBOOT_FIS } + default_value 0 + description " + Use a common memory buffer for both the zlib workspace + and FIS directory operations. This can save a substantial + amount of RAM, especially when flash sectors are large." + + cdl_option CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE { + display "Size of Zlib/FIS common buffer" + flavor data + default_value 0xc000 + legal_values 0x4000 to 0x80000000 + description " + Size of common buffer to allocate. Must be at least the + size of one flash sector." + } + } } # EOF redboot.cdl
--- a/packages/redboot/current/include/redboot.h +++ b/packages/redboot/current/include/redboot.h @@ -42,7 +42,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, tkoeller // Date: 2000-07-14 // Purpose: // Description: @@ -116,6 +116,10 @@ EXTERN int console_baud_rate; #endif #endif +#ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER +EXTERN unsigned char *fis_zlib_common_buffer; +#endif + // Prototypes typedef int _printf_fun(const char *fmt, ...); externC int strcasecmp(const char *s1, const char *s2);
--- a/packages/redboot/current/src/decompress.c +++ b/packages/redboot/current/src/decompress.c @@ -41,7 +41,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): jskov -// Contributors: jskov, gthomas +// Contributors: jskov, gthomas, tkoeller // Date: 2001-03-08 // Purpose: // Description: @@ -74,7 +74,11 @@ struct _block { }; static struct _block *memlist; -#define ZLIB_COMPRESSION_OVERHEAD 0xC000 +#ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER +# define ZLIB_COMPRESSION_OVERHEAD CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE +#else +# define ZLIB_COMPRESSION_OVERHEAD 0xC000 +#endif static void *zlib_workspace; // @@ -87,9 +91,13 @@ static void *zlib_workspace; static void _zlib_init(void) { +#ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER + zlib_workspace = fis_zlib_common_buffer; +#else // Allocate some RAM for use by the gzip/zlib routines workspace_end -= ZLIB_COMPRESSION_OVERHEAD; zlib_workspace = workspace_end; +#endif } RedBoot_init(_zlib_init, RedBoot_INIT_FIRST);
--- a/packages/redboot/current/src/flash.c +++ b/packages/redboot/current/src/flash.c @@ -41,7 +41,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, tkoeller // Date: 2000-07-28 // Purpose: // Description: @@ -477,7 +477,7 @@ fis_list(int argc, char *argv[]) { return; } - img = (struct fis_image_desc *)fis_work_block; + img = (struct fis_image_desc *) fis_addr; // Let diag_printf do the formatting in both cases, rather than counting // cols by hand.... diag_printf("%-16s %-10s %-10s %-10s %-s\n", @@ -619,6 +619,7 @@ fis_create(int argc, char *argv[]) return; } + memcpy(fis_work_block, fis_addr, fisdir_size); defaults_assumed = false; if (name) { // Search existing files to acquire defaults for params not specified: @@ -819,6 +820,7 @@ fis_delete(int argc, char *argv[]) num_reserved++; #endif + memcpy(fis_work_block, fis_addr, fisdir_size); img = fis_lookup(name, &i); if (img) { if (i < num_reserved) { @@ -874,6 +876,7 @@ fis_load(int argc, char *argv[]) fis_usage("invalid arguments"); return; } + memcpy(fis_work_block, fis_addr, fisdir_size); if ((img = fis_lookup(name, NULL)) == (struct fis_image_desc *)0) { diag_printf("No image '%s' found\n", name); return; @@ -915,6 +918,9 @@ fis_load(int argc, char *argv[]) // Set load address/top load_address = mem_addr; load_address_end = (unsigned long)p->out_buf; + + // Reload fis directory + memcpy(fis_work_block, fis_addr, fisdir_size); } else // dangling block #endif { @@ -1092,6 +1098,7 @@ fis_lock(int argc, char *argv[]) /* Get parameters from image if specified */ if (name) { struct fis_image_desc *img; + memcpy(fis_work_block, fis_addr, fisdir_size); if ((img = fis_lookup(name, NULL)) == (struct fis_image_desc *)0) { diag_printf("No image '%s' found\n", name); return; @@ -1138,6 +1145,7 @@ fis_unlock(int argc, char *argv[]) if (name) { struct fis_image_desc *img; + memcpy(fis_work_block, fis_addr, fisdir_size); if ((img = fis_lookup(name, NULL)) == (struct fis_image_desc *)0) { diag_printf("No image '%s' found\n", name); return; @@ -1190,8 +1198,17 @@ do_flash_init(void) flash_get_block_info(&flash_block_size, &flash_num_blocks); workspace_end = (unsigned char *)(workspace_end-FLASH_MIN_WORKSPACE); #ifdef CYGOPT_REDBOOT_FIS +# ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER + fis_work_block = fis_zlib_common_buffer; + if(CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE < flash_block_size) { + diag_printf("FLASH: common buffer too small\n"); + workspace_end += FLASH_MIN_WORKSPACE; + return false; + } +# else workspace_end = (unsigned char *)(workspace_end-flash_block_size); fis_work_block = workspace_end; +# endif fisdir_size = flash_block_size; if (CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK < 0) { fis_addr = (void *)((CYG_ADDRESS)flash_end + 1 + @@ -1230,9 +1247,6 @@ do_fis(int argc, char *argv[]) diag_printf("Sorry, no FLASH memory is available\n"); return; } -#ifdef CYGOPT_REDBOOT_FIS - memcpy(fis_work_block, fis_addr, flash_block_size); -#endif if ((cmd = cmd_search(__FIS_cmds_TAB__, &__FIS_cmds_TAB_END__, argv[1])) != (struct cmd *)0) { (cmd->fun)(argc, argv);
--- a/packages/redboot/current/src/main.c +++ b/packages/redboot/current/src/main.c @@ -42,7 +42,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, tkoeller // Date: 2000-07-14 // Purpose: // Description: @@ -223,6 +223,11 @@ cyg_start(void) bist(); +#ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER + fis_zlib_common_buffer = + workspace_end -= CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE; +#endif + for (init_entry = __RedBoot_INIT_TAB__; init_entry != &__RedBoot_INIT_TAB_END__; init_entry++) { (*init_entry->fun)(); }
