# HG changeset patch # User gthomas # Date 1066917619 0 # Node ID afd4dd211d3a7f78a8d71b33ab4d9fd9f0db047a # Parent b1c975b962453c903753b7b401156c14e6209d32 Attempt to handle illegal memory accesses and other abort conditions diff --git a/packages/redboot/current/ChangeLog b/packages/redboot/current/ChangeLog --- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,8 @@ +2003-10-23 Gary Thomas + + * src/main.c (cyg_start): Try to catch illegal memory accesses and + other abort conditions during command execution. + 2003-10-17 Gary Thomas * src/load.c: Only examine loadable segments when scanning to determine diff --git a/packages/redboot/current/src/main.c b/packages/redboot/current/src/main.c --- a/packages/redboot/current/src/main.c +++ b/packages/redboot/current/src/main.c @@ -215,6 +215,18 @@ static void } // +// Handle illegal memory accesses (and other abort conditions) +// +static hal_jmp_buf error_jmpbuf; +externC void* volatile __mem_fault_handler; + +static void error_handler(void) +{ + hal_longjmp(error_jmpbuf, 1); +} + + +// // This is the main entry point for RedBoot // void @@ -395,7 +407,14 @@ cyg_start(void) } else { while (strlen(command) > 0) { if ((cmd = parse(&command, &argc, &argv[0])) != (struct cmd *)0) { - (cmd->fun)(argc, argv); + // Try to handle aborts - messy because of the stack unwinding... + __mem_fault_handler = error_handler; + if (hal_setjmp(error_jmpbuf)) { + diag_printf("** command abort - illegal memory access?\n"); + } else { + (cmd->fun)(argc, argv); + } + __mem_fault_handler = 0; } else { diag_printf("** Error: Illegal command: \"%s\"\n", argv[0]); }