comparison packages/redboot/current/src/main.c @ 1328:afd4dd211d3a

Attempt to handle illegal memory accesses and other abort conditions
author gthomas
date Thu, 23 Oct 2003 14:00:19 +0000
parents e4e339326f84
children 19f40f995cc2
comparison
equal deleted inserted replaced
1327:b1c975b96245 1328:afd4dd211d3a
213 } 213 }
214 mon_write_char(c); 214 mon_write_char(c);
215 } 215 }
216 216
217 // 217 //
218 // Handle illegal memory accesses (and other abort conditions)
219 //
220 static hal_jmp_buf error_jmpbuf;
221 externC void* volatile __mem_fault_handler;
222
223 static void error_handler(void)
224 {
225 hal_longjmp(error_jmpbuf, 1);
226 }
227
228
229 //
218 // This is the main entry point for RedBoot 230 // This is the main entry point for RedBoot
219 // 231 //
220 void 232 void
221 cyg_start(void) 233 cyg_start(void)
222 { 234 {
393 diag_printf("%s\n", &line[2]); 405 diag_printf("%s\n", &line[2]);
394 } 406 }
395 } else { 407 } else {
396 while (strlen(command) > 0) { 408 while (strlen(command) > 0) {
397 if ((cmd = parse(&command, &argc, &argv[0])) != (struct cmd *)0) { 409 if ((cmd = parse(&command, &argc, &argv[0])) != (struct cmd *)0) {
398 (cmd->fun)(argc, argv); 410 // Try to handle aborts - messy because of the stack unwinding...
411 __mem_fault_handler = error_handler;
412 if (hal_setjmp(error_jmpbuf)) {
413 diag_printf("** command abort - illegal memory access?\n");
414 } else {
415 (cmd->fun)(argc, argv);
416 }
417 __mem_fault_handler = 0;
399 } else { 418 } else {
400 diag_printf("** Error: Illegal command: \"%s\"\n", argv[0]); 419 diag_printf("** Error: Illegal command: \"%s\"\n", argv[0]);
401 } 420 }
402 } 421 }
403 } 422 }