This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RedBoot - improve error handling


-- 
Gary Thomas <gary@mlbassoc.com>
MLB Associates
Index: redboot/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.154
diff -u -5 -p -r1.154 ChangeLog
--- redboot/current/ChangeLog	17 Oct 2003 21:45:24 -0000	1.154
+++ redboot/current/ChangeLog	23 Oct 2003 13:59:43 -0000
@@ -1,5 +1,10 @@
+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
 	lowest loadable address (only used when -b XXX option used).  Otherwise,
 	an offset into space could be chosen.
Index: redboot/current/src/main.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/src/main.c,v
retrieving revision 1.47
diff -u -5 -p -r1.47 main.c
--- redboot/current/src/main.c	20 Sep 2003 13:28:31 -0000	1.47
+++ redboot/current/src/main.c	23 Oct 2003 13:59:09 -0000
@@ -213,10 +213,22 @@ _mon_write_char(char c, void **param)
     }
     mon_write_char(c);
 }
 
 //
+// 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
 cyg_start(void)
 {
@@ -393,11 +405,18 @@ cyg_start(void)
                         diag_printf("%s\n", &line[2]);
                     }
                 } 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]);
                         }
                     }
                 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]