rework error handling so common functions don't reset
PATCH 1/1 rework error handling so common functions don't reset
Changed image_get_ramdisk() to just return NULL on error and have get_ramdisk() propogate that error to the caller. It's left to the caller to call do_reset() if it wants to.
Also moved calling do_reset() in get_fdt() on ppc to a common location. In the future we will change get_fdt() to return success/failure and not call do_reset() at all.
---
This is against the new-image branch of u-boot-testing
common/image.c | 25 ++++++++++++++++--------- include/image.h | 2 +- lib_m68k/bootm.c | 15 +++++++++++++-- lib_ppc/bootm.c | 46 +++++++++++++++++++++++++++++----------------- 4 files changed, 59 insertions(+), 29 deletions(-)
common/image.c +16 -9
@@ -41,8 +41,6 @@#include <logbuff.h> #endif -extern int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]); -#ifdef CONFIG_CMD_BDI extern int do_bdinfo (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]);#endif
@@ -324,7 +322,7 @@ const char* image_get_comp_name (uint8_t comp)* * returns: * pointer to a ramdisk image header, if image was found and valid -* otherwise, board is reset +* otherwise, return NULL */ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
@@ -348,13 +346,13 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,if (!image_check_magic (rd_hdr)) {puts ("Bad Magic Number\n" );show_boot_progress (-10 ); -do_reset (cmdtp, flag, argc, argv); +return NULL ; }if (!image_check_hcrc (rd_hdr)) {puts ("Bad Header Checksum\n" );show_boot_progress (-11 ); -do_reset (cmdtp, flag, argc, argv); +return NULL ; }show_boot_progress (10 );
@@ -377,7 +375,7 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,if (!image_check_dcrc_wd (rd_hdr,CHUNKSZ )) {puts ("Bad Data CRC\n" );show_boot_progress (-12 ); -do_reset (cmdtp, flag, argc, argv); +return NULL ; }puts ("OK\n" ); }
@@ -390,7 +388,7 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,printf ("No Linux %s Ramdisk Image\n" ,image_get_arch_name (arch));show_boot_progress (-13 ); -do_reset (cmdtp, flag, argc, argv); +return NULL ; }return rd_hdr;
@@ -417,9 +415,10 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,* rd_start and rd_end are set to ramdisk start/end addresses if * ramdisk image is found and valid * rd_start and rd_end are set to 0 if no ramdisk exists -* board is reset if ramdisk image is found but corrupted +* return 1 if ramdisk image is found but corrupted +* */ -void get_ramdisk (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[], +int get_ramdisk (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[],image_header_t *hdr,int verify,uint8_t arch,ulong *rd_start,ulong *rd_end) {
@@ -447,6 +446,12 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], rd_hdr =image_get_ramdisk (cmdtp, flag, argc, argv, rd_addr, arch, verify); +if (rd_hdr ==NULL ) { + *rd_start =0 ; + *rd_end =0 ; +return 1 ; + } + rd_data =image_get_data (rd_hdr); rd_len =image_get_data_size (rd_hdr);
@@ -488,6 +493,8 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], }debug (" ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n" , *rd_start, *rd_end); + +return 0 ; }#if defined(CONFIG_PPC ) || defined(CONFIG_M68K )
include/image.h +1 -1
@@ -338,7 +338,7 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], ulong rd_addr, uint8_t arch, int verify); -void get_ramdisk (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[], +int get_ramdisk (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[],image_header_t *hdr,int verify,uint8_t arch,ulong *rd_start,ulong *rd_end);
lib_m68k/bootm.c +13 -2
@@ -35,6 +35,8 @@DECLARE_GLOBAL_DATA_PTR ; +extern int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]); +#define PHYSADDR (x) x#define LINUX_MAX_ENVS 256
@@ -51,6 +53,7 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,ulong rd_data_start, rd_data_end, rd_len;ulong initrd_start, initrd_end; +int ret;ulong cmd_start, cmd_end;bd_t *kbd;
@@ -83,8 +86,11 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, (void (*)(bd_t *,ulong ,ulong ,ulong ,ulong ))image_get_ep (hdr);/* find ramdisk */ -get_ramdisk (cmdtp, flag, argc, argv, hdr, verify, -IH_ARCH_M68K , &rd_data_start, &rd_data_end); + ret =get_ramdisk (cmdtp, flag, argc, argv, hdr, verify, +IH_ARCH_M68K , &rd_data_start, &rd_data_end); + +if (ret) + goto error; rd_len = rd_data_end - rd_data_start; alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len,
@@ -105,6 +111,11 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,*/ (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);/* does not return */ +return ; + +error: +do_reset (cmdtp, flag, argc, argv); +return ; }static ulong get_sp (void )
lib_ppc/bootm.c +29 -17
138 lines not on this page · raw message
Signature · 1 line
1.5.3.8
PATCH 1/1 rework error handling so common functions don't reset
Dear Kumar,
Quoted 9 lines · in message <[email protected]> you wrote:
Changed
image_get_ramdisk()to just return NULL on error and haveget_ramdisk()propogate that error to the caller. It's left to the caller to calldo_reset()if it wants to.Also moved calling
do_reset()inget_fdt()on ppc to a common location. In the future we will changeget_fdt()to return success/failure and not calldo_reset()at all.Signed-off-by Kumar Gala <[email protected]>
Just to make my position clear: I expect that you negotiate new-image related patches more or less directly with Bartek, who I consider as kind of "new-image" custodian.
That means that I will not track the state of these patches - if you want me to apply something directly, please ring a bell.
Bartek: I would also appreciate if you could merge Kumar's patches in a local repo and then send me just a pull request when something is ready to go into u-boot-testing (or even into mainline).
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 Q: What's a light-year? A: One-third less calories than a regular year.
PATCH 1/1 rework error handling so common functions don't reset
Quoted 17 lines · Wolfgang Denk
Dear Kumar,
Quoted 9 lines · in message <[email protected]> you wrote:
Changed
image_get_ramdisk()to just return NULL on error and haveget_ramdisk()propogate that error to the caller. It's left to the caller to calldo_reset()if it wants to.Also moved calling
do_reset()inget_fdt()on ppc to a common location. In the future we will changeget_fdt()to return success/failure and not calldo_reset()at all.Signed-off-by Kumar Gala <[email protected]>Just to make my position clear: I expect that you negotiate new-image related patches more or less directly with Bartek, who I consider as kind of "new-image" custodian.
Quoted 6 lines
That means that I will not track the state of these patches - if you want me to apply something directly, please ring a bell.
Bartek: I would also appreciate if you could merge Kumar's patches in a local repo and then send me just a pull request when something is ready to go into u-boot-testing (or even into mainline).
OK, will coordinate new uImage stuff that gets posted to the list, and request pulling as needed.
Regards,
Bartlomiej
PATCH 1/1 rework error handling so common functions don't reset
Quoted 23 lines · Bartlomiej Sieka
Quoted 13 lines · Wolfgang Denk
Dear Kumar,
in message <Pine.LNX.Quoted 10 lines · 4.64.0802181306060.21964 at blarg.am.freescale.net> you wrote:
Changed
image_get_ramdisk()to just return NULL on error and haveget_ramdisk()propogate that error to the caller. It's left to the caller to calldo_reset()if it wants to.Also moved calling
do_reset()inget_fdt()on ppc to a common location.
In the future we will changeget_fdt()to return success/failure and not calldo_reset()at all.Signed-off-by Kumar Gala <[email protected]>Quoted 8 lines
Just to make my position clear: I expect that you negotiate new-image related patches more or less directly with Bartek, who I consider as kind of "new-image" custodian.
That means that I will not track the state of these patches - if you want me to apply something directly, please ring a bell.
Bartek: I would also appreciate if you could merge Kumar's patches in a local repo and then send me just a pull request when something is ready to go into u-boot-testing (or even into mainline).
Quoted 2 lines
OK, will coordinate new uImage stuff that gets posted to the list, and request pulling as needed.
Works for me. I'll look at updating my patches based on the new code in the branch.
- k