Memory footprint optimizations
PATCH 1/1 Memory footprint optimizations
As suggested by Wolfgang Denk:
- remove wrappers for image printing function
- merge getenv_verify and getenv_autostart into one parametrized function
---
board/mpl/common/common_util.c | 2 +- board/siemens/common/fpga.c | 2 +- common/cmd_autoscript.c | 2 +- common/cmd_bootm.c | 14 +++++++------ common/cmd_doc.c | 4 ++-- common/cmd_fdc.c | 4 ++-- common/cmd_ide.c | 4 ++-- common/cmd_nand.c | 8 ++++--- common/cmd_scsi.c | 4 ++-- common/cmd_usb.c | 4 ++-- common/cmd_ximg.c | 4 ++-- common/image.c | 43 ++++++++-------------------------------- include/image.h | 9 +++----- lib_ppc/bootm.c | 2 +- tools/mkimage.c | 6 +++--- 15 files changed, 42 insertions(+), 70 deletions(-)
board/mpl/common/common_util.c +1 -1
@@ -192,7 +192,7 @@ mpl_prg_image(uchar *ld_addr)puts ("Bad Magic Number\n" );return 1 ; } -image_print_contents (hdr); +image_print_contents (hdr," " );if (!image_check_os (hdr,IH_OS_U_BOOT )) {puts ("No U-Boot Image\n" );return 1 ;
board/siemens/common/fpga.c +1 -1
@@ -160,7 +160,7 @@ static int fpga_load (fpga_t* fpga, ulong addr, int checkall) data = (uchar *)image_get_data (hdr); len =image_get_data_size (hdr); - verify =getenv_verify (); + verify =getenv_yesno ("verify" );if (verify) {if (!image_check_dcrc (hdr)) {strcpy (msg,"Bad Image Data CRC" );
common/cmd_autoscript.c +1 -1
@@ -65,7 +65,7 @@ autoscript (ulong addr, const char *fit_uname)size_t fit_len;#endif - verify =getenv_verify (); + verify =getenv_yesno ("verify" );switch (genimg_get_format ((void *)addr)) {case IMAGE_FORMAT_LEGACY :
common/cmd_bootm.c +7 -7
@@ -133,8 +133,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])struct lmb lmb;memset ((void *)&images,0 ,sizeof (images)); - images.verify =getenv_verify (); - images.autostart =getenv_autostart (); + images.verify =getenv_yesno ("verify" ); + images.autostart =getenv_yesno ("autostart" ); images.lmb = &lmb;lmb_init (&lmb);
@@ -377,7 +377,7 @@ static image_header_t *image_get_kernel (ulong img_addr, int verify) }show_boot_progress (3 ); -image_print_contents (hdr); +image_print_contents (hdr," " );if (verify) {puts (" Verifying Checksum ... " );
@@ -714,7 +714,7 @@ static int image_info (ulong addr)return 1 ; } -image_print_contents (hdr); +image_print_contents (hdr," " );puts (" Verifying Checksum ... " );if (!image_check_dcrc (hdr)) {
@@ -732,7 +732,7 @@ static int image_info (ulong addr) return 1; } -fit_print_contents (hdr); +fit_print_contents (hdr," " );return 0 ;#endif default :
@@ -781,7 +781,7 @@ int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) goto next_sector;printf ("Legacy Image at %08lX:\n" , (ulong )hdr); -image_print_contents (hdr); +image_print_contents (hdr," " );puts (" Verifying Checksum ... " );if (!image_check_dcrc (hdr)) {
@@ -796,7 +796,7 @@ int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) goto next_sector;printf ("FIT Image at %08lX:\n" , (ulong )hdr); -fit_print_contents (hdr); +fit_print_contents (hdr," " );break ;#endif default :
common/cmd_doc.c +2 -2
@@ -268,7 +268,7 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])case IMAGE_FORMAT_LEGACY : hdr = (image_header_t *)addr; -image_print_contents (hdr); +image_print_contents (hdr," " ); cnt =image_get_image_size (hdr);break ;
@@ -305,7 +305,7 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])#if defined(CONFIG_FIT )/* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format ((void *)addr) ==IMAGE_FORMAT_FIT ) -fit_print_contents ((const void *)addr); +fit_print_contents ((const void *)addr," " );#endif /* Loading ok, update default load address */
common/cmd_fdc.c +2 -2
@@ -842,7 +842,7 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])switch (genimg_get_format ((void *)addr)) {case IMAGE_FORMAT_LEGACY : hdr = (image_header_t *)addr; -image_print_contents (hdr); +image_print_contents (hdr," " ); imsize =image_get_image_size (hdr);break ;
@@ -882,7 +882,7 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])#if defined(CONFIG_FIT )/* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format ((void *)addr) ==IMAGE_FORMAT_FIT ) -fit_print_contents ((const void *)addr); +fit_print_contents ((const void *)addr," " );#endif /* Loading ok, update default load address */
common/cmd_ide.c +2 -2
@@ -462,7 +462,7 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) }show_boot_progress (50 ); -image_print_contents (hdr); +image_print_contents (hdr," " ); cnt =image_get_image_size (hdr);break ;
@@ -501,7 +501,7 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])#if defined(CONFIG_FIT )/* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format ((void *)addr) ==IMAGE_FORMAT_FIT ) -fit_print_contents ((const void *)addr); +fit_print_contents ((const void *)addr," " );#endif /* Loading ok, update default load address */
common/cmd_nand.c +4 -4
@@ -520,7 +520,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, hdr = (image_header_t *)addr;show_boot_progress (57 ); -image_print_contents (hdr); +image_print_contents (hdr," " ); cnt =image_get_image_size (hdr);break ;
@@ -566,7 +566,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,#if defined(CONFIG_FIT )/* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format ((void *)addr) ==IMAGE_FORMAT_FIT ) -fit_print_contents ((const void *)addr); +fit_print_contents ((const void *)addr," " );#endif /* Loading ok, update default load address */
@@ -1013,7 +1013,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])switch (genimg_get_format ((void *)addr)) {case IMAGE_FORMAT_LEGACY : hdr = (image_header_t *)addr; -image_print_contents (hdr); +image_print_contents (hdr," " ); cnt =image_get_image_size (hdr); cnt -=SECTORSIZE ;
@@ -1051,7 +1051,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])#if defined(CONFIG_FIT )/* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format ((void *)addr) ==IMAGE_FORMAT_FIT ) -fit_print_contents ((const void *)addr); +fit_print_contents ((const void *)addr," " );#endif /* Loading ok, update default load address */
common/cmd_scsi.c +2 -2
@@ -285,7 +285,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])return 1 ; } -image_print_contents (hdr); +image_print_contents (hdr," " ); cnt =image_get_image_size (hdr);break ;#if defined(CONFIG_FIT )
@@ -318,7 +318,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])#if defined(CONFIG_FIT )/* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format ((void *)addr) ==IMAGE_FORMAT_FIT ) -fit_print_contents ((const void *)addr); +fit_print_contents ((const void *)addr," " );#endif /* Loading ok, update default load address */
common/cmd_usb.c +2 -2
@@ -397,7 +397,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])return 1 ; } -image_print_contents (hdr); +image_print_contents (hdr," " ); cnt =image_get_image_size (hdr);break ;
@@ -431,7 +431,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])#if defined(CONFIG_FIT )/* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format ((void *)addr) ==IMAGE_FORMAT_FIT ) -fit_print_contents ((const void *)addr); +fit_print_contents ((const void *)addr," " );#endif /* Loading ok, update default load address */
common/cmd_ximg.c +2 -2
@@ -51,7 +51,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])size_t fit_len;#endif - verify =getenv_verify (); + verify =getenv_yesno ("verify" );if (argc >1 ) { addr =simple_strtoul (argv[1 ],NULL ,16 );
@@ -83,7 +83,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])return 1 ; }#ifdef DEBUG -image_print_contents (hdr); +image_print_contents (hdr," " );#endif if (!image_check_type (hdr,IH_TYPE_MULTI )) {
common/image.c +9 -34
98 lines not on this page · raw message
include/image.h +3 -6
@@ -363,8 +363,7 @@ int image_check_hcrc (image_header_t *hdr);int image_check_dcrc (image_header_t *hdr);#ifndef USE_HOSTCC int image_check_dcrc_wd (image_header_t *hdr,ulong chunksize); -int getenv_verify (void ); -int getenv_autostart (void ); +int getenv_yesno (char *var);ulong getenv_bootm_low (void );ulong getenv_bootm_size (void );void memmove_wd (void *to,void *from,size_t len,ulong chunksz);
@@ -391,8 +390,7 @@ ulong image_multi_count (image_header_t *hdr);void image_multi_getimg (image_header_t *hdr,ulong idx,ulong *data,ulong *len); -inline void image_print_contents (image_header_t *hdr); -inline void image_print_contents_noindent (image_header_t *hdr); +void image_print_contents (image_header_t *hdr,const char *p);#ifndef USE_HOSTCC static inline int image_check_target_arch (image_header_t *hdr)
@@ -466,8 +464,7 @@ inline int fit_parse_conf (const char *spec, ulong addr_curr,inline int fit_parse_subimage (const char *spec,ulong addr_curr,ulong *addr,const char **image_name); -inline void fit_print_contents (const void *fit); -inline void fit_print_contents_noindent (const void *fit); +void fit_print_contents (const void *fit,const char *p);void fit_image_print (const void *fit,int noffset,const char *p);void fit_image_print_hash (const void *fit,int noffset,const char *p);
lib_ppc/bootm.c +1 -1
@@ -319,7 +319,7 @@ static image_header_t *image_get_fdt (ulong fdt_addr) {image_header_t *fdt_hdr = (image_header_t *)fdt_addr; -image_print_contents (fdt_hdr); +image_print_contents (fdt_hdr," " );puts (" Verifying Checksum ... " );if (!image_check_hcrc (fdt_hdr)) {
tools/mkimage.c +3 -3
@@ -229,10 +229,10 @@ NXTARG: ;if (fdt_check_header (ptr)) {/* old-style image */ image_verify_header ((char *)ptr, sbuf.st_size); -image_print_contents_noindent ((image_header_t *)ptr); +image_print_contents ((image_header_t *)ptr,"" ); }else {/* FIT image */ -fit_print_contents_noindent (ptr); +fit_print_contents (ptr,"" ); } (void )munmap ((void *)ptr, sbuf.st_size);
@@ -363,7 +363,7 @@ NXTARG: ;image_set_hcrc (hdr, checksum); -image_print_contents_noindent (hdr); +image_print_contents (hdr,"" ); (void )munmap ((void *)ptr, sbuf.st_size);
PATCH 1/1 Memory footprint optimizations
Quoted 3 lines · In message <[email protected]> you wrote:
As suggested by Wolfgang Denk:
- remove wrappers for image printing function
- mergegetenv_verifyandgetenv_autostartinto one parametrized function
...
Review
Quoted 2 lines
(quoted diff) +1
-1- image_print_contents (hdr); + image_print_contents (hdr, " ");
Now we have some 20+ calls of
image_print_contents (hdr, " ");
plus two calls of
image_print_contents (hdr, "");
Maybe there is some clever way to get rid of this second argument?
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Die meisten Menschen pflegen im Kindesalter vom Zeigen auf Gegenst?n-
de (Mausbewegung) und "ga" sagen (Mausklick) abzukommen, zugunsten
eines m?chtigeren und langwierig zu erlernenden Tools (Sprache).
-- Achim Linder in de.comp.os.linux.miscPATCH 1/1 Memory footprint optimizations
Quoted 10 lines · Wolfgang Denk
Quoted 3 lines · In message <[email protected]> you wrote:
As suggested by Wolfgang Denk:
- remove wrappers for image printing function
- mergegetenv_verifyandgetenv_autostartinto one parametrized function...
Review
Quoted 2 lines
(quoted diff) +1
-1- image_print_contents (hdr); + image_print_contents (hdr, " ");Now we have some 20+ calls of
Quoted 7 lines
image_print_contents (hdr, " ");plus two calls of
image_print_contents (hdr, "");Maybe there is some clever way to get rid of this second argument?
We could use the following two facts:
1. the image contents are printed with only two indentations: 0 or 3 spaces,
2. indentation with 3 spaces is used in U-Boot, indentation with 0 spaces is used in mkimage.
With the following change we could then drop the second argument altogether:
common/image.c +9 -1
@@ -301,8 +301,16 @@ static void image_print_type (image_header_t *hdr)* returns: * no returned results */ -void image_print_contents (image_header_t *hdr,const char *p) +void image_print_contents (image_header_t *hdr) { +const char *p; + +#ifdef USE_HOSTCC + p ="" ; +#else + p =" " ; +#endif +
If the above is what is wanted, I'll prepare a patch -- comments are welcome.
Regards,
Bartlomiej
PATCH 1/1 Memory footprint optimizations
Quoted 7 lines · In message <[email protected]> you wrote:
We could use the following two facts:
1. the image contents are printed with only two indentations: 0 or 3 spaces,
2. indentation with 3 spaces is used in U-Boot, indentation with 0 spaces is used in mkimage.With the following change we could then drop the second argument altogether:
Ah! Excellent.
Quoted 8 lines
common/image.c +5
-0+#ifdef USE_HOSTCC + p ="" ; +#else + p =" " ; +#endif If the above is what is wanted, I'll prepare a patch -- comments are welcome.
Yes, please.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de War isn't a good life, but it's life. -- Kirk, "A Private Little War", stardate 4211.8
PATCH v2 1/1 Memory footprint optimizations
As suggested by Wolfgang Denk:
- image printing functions:
- remove wrappers
- remove indentation prefix from functions' signatures
- merge getenv_verify and getenv_autostart into one parametrized function
---
board/siemens/common/fpga.c | 2 +- common/cmd_autoscript.c | 2 +- common/cmd_bootm.c | 4 ++- common/cmd_ximg.c | 2 +- common/image.c | 56 ++++++++++++++++++------------------------- include/image.h | 9 ++----- tools/mkimage.c | 6 ++--- 7 files changed, 34 insertions(+), 47 deletions(-)
board/siemens/common/fpga.c +1 -1
@@ -160,7 +160,7 @@ static int fpga_load (fpga_t* fpga, ulong addr, int checkall) data = (uchar *)image_get_data (hdr); len =image_get_data_size (hdr); - verify =getenv_verify (); + verify =getenv_yesno ("verify" );if (verify) {if (!image_check_dcrc (hdr)) {strcpy (msg,"Bad Image Data CRC" );
common/cmd_autoscript.c +1 -1
@@ -65,7 +65,7 @@ autoscript (ulong addr, const char *fit_uname)size_t fit_len;#endif - verify =getenv_verify (); + verify =getenv_yesno ("verify" );switch (genimg_get_format ((void *)addr)) {case IMAGE_FORMAT_LEGACY :
common/cmd_bootm.c +2 -2
@@ -133,8 +133,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])struct lmb lmb;memset ((void *)&images,0 ,sizeof (images)); - images.verify =getenv_verify (); - images.autostart =getenv_autostart (); + images.verify =getenv_yesno ("verify" ); + images.autostart =getenv_yesno ("autostart" ); images.lmb = &lmb;lmb_init (&lmb);
common/cmd_ximg.c +1 -1
@@ -51,7 +51,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])size_t fit_len;#endif - verify =getenv_verify (); + verify =getenv_yesno ("verify" );if (argc >1 ) { addr =simple_strtoul (argv[1 ],NULL ,16 );
common/image.c +23 -33
116 lines not on this page · raw message
include/image.h +3 -6
@@ -364,8 +364,7 @@ int image_check_hcrc (image_header_t *hdr);int image_check_dcrc (image_header_t *hdr);#ifndef USE_HOSTCC int image_check_dcrc_wd (image_header_t *hdr,ulong chunksize); -int getenv_verify (void ); -int getenv_autostart (void ); +int getenv_yesno (char *var);ulong getenv_bootm_low (void );ulong getenv_bootm_size (void );void memmove_wd (void *to,void *from,size_t len,ulong chunksz);
@@ -392,8 +391,7 @@ ulong image_multi_count (image_header_t *hdr);void image_multi_getimg (image_header_t *hdr,ulong idx,ulong *data,ulong *len); -inline void image_print_contents (image_header_t *hdr); -inline void image_print_contents_noindent (image_header_t *hdr); +void image_print_contents (image_header_t *hdr);#ifndef USE_HOSTCC static inline int image_check_target_arch (image_header_t *hdr)
@@ -469,8 +467,7 @@ inline int fit_parse_conf (const char *spec, ulong addr_curr,inline int fit_parse_subimage (const char *spec,ulong addr_curr,ulong *addr,const char **image_name); -inline void fit_print_contents (const void *fit); -inline void fit_print_contents_noindent (const void *fit); +void fit_print_contents (const void *fit);void fit_image_print (const void *fit,int noffset,const char *p);void fit_image_print_hash (const void *fit,int noffset,const char *p);
tools/mkimage.c +3 -3
@@ -229,10 +229,10 @@ NXTARG: ;if (fdt_check_header (ptr)) {/* old-style image */ image_verify_header ((char *)ptr, sbuf.st_size); -image_print_contents_noindent ((image_header_t *)ptr); +image_print_contents ((image_header_t *)ptr); }else {/* FIT image */ -fit_print_contents_noindent (ptr); +fit_print_contents (ptr); } (void )munmap ((void *)ptr, sbuf.st_size);
@@ -363,7 +363,7 @@ NXTARG: ;image_set_hcrc (hdr, checksum); -image_print_contents_noindent (hdr); +image_print_contents (hdr); (void )munmap ((void *)ptr, sbuf.st_size);
Wolfgang Denk
AppliedPATCH v2 1/1 Memory footprint optimizations
Quoted 9 lines · In message <[email protected]> you wrote:
As suggested by Wolfgang Denk:
- image printing functions:
- remove wrappers
- remove indentation prefix from functions' signatures
- mergegetenv_verifyandgetenv_autostartinto one parametrized functionSigned-off-by Bartlomiej Sieka <[email protected]>---
Quoted 8 lines
board/siemens/common/fpga.c | 2 +- common/cmd_autoscript.c | 2 +- common/cmd_bootm.c | 4 ++- common/cmd_ximg.c | 2 +- common/image.c | 56 ++++++++++++++++++------------------------- include/image.h | 9 ++----- tools/mkimage.c | 6 ++--- 7 files changed, 34 insertions(+), 47 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "There was no difference between the behavior of a god and the operations of pure chance..." - Thomas Pynchon, _Gravity's Rainbow_