Mercurial > ecos
changeset 1328:afd4dd211d3a
Attempt to handle illegal memory accesses and other abort conditions
| author | gthomas |
|---|---|
| date | Thu, 23 Oct 2003 14:00:19 +0000 |
| parents | b1c975b96245 |
| children | c687f86ab7a4 |
| files | packages/redboot/current/ChangeLog packages/redboot/current/src/main.c |
| diffstat | 2 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,8 @@ +2003-10-23 Gary Thomas <gary@mlbassoc.com> + + * src/main.c (cyg_start): Try to catch illegal memory accesses and + other abort conditions during command execution. + 2003-10-17 Gary Thomas <gary@mlbassoc.com> * src/load.c: Only examine loadable segments when scanning to determine
--- 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]); }
