[OpenBIOS] [commit] r705 - in trunk/openbios-devel: include/kernel kernel

repository service svn at openbios.org
Wed Mar 24 12:49:41 CET 2010


Author: mcayland
Date: Wed Mar 24 12:49:41 2010
New Revision: 705
URL: http://tracker.coreboot.org/trac/openbios/changeset/705

Log:
Change the sysdebug exception() callback so that it is now a function pointer, rather than a function. This enables us to setup an appropriate exception handler 
for the task in hand; in particular it allows us to distinguish between an error that occurs when attempting to execute a base dictionary, and an error that 
occurs when interpreting source.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at siriusit.co.uk>

Modified:
   trunk/openbios-devel/include/kernel/kernel.h
   trunk/openbios-devel/kernel/bootstrap.c
   trunk/openbios-devel/kernel/internal.c

Modified: trunk/openbios-devel/include/kernel/kernel.h
==============================================================================
--- trunk/openbios-devel/include/kernel/kernel.h	Wed Mar 24 11:28:51 2010	(r704)
+++ trunk/openbios-devel/include/kernel/kernel.h	Wed Mar 24 12:49:41 2010	(r705)
@@ -34,7 +34,7 @@
 extern void		modules_init( void );
 
 /* arch kernel hooks */
-extern void 		exception(cell no);
+extern void 		(*exception)(cell no);
 
 #ifdef FCOMPILER
 extern void		include_file( const char *str );

Modified: trunk/openbios-devel/kernel/bootstrap.c
==============================================================================
--- trunk/openbios-devel/kernel/bootstrap.c	Wed Mar 24 11:28:51 2010	(r704)
+++ trunk/openbios-devel/kernel/bootstrap.c	Wed Mar 24 12:49:41 2010	(r705)
@@ -52,6 +52,8 @@
 static int srclines[MAX_SRC_FILES];
 static unsigned int cursrc = 0;
 
+static char *srcbasedict;
+
 #ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
 unsigned long base_address;
 #endif
@@ -485,6 +487,47 @@
 
 
 /*
+ * Common Forth exception handler
+ */
+
+static void exception_common(cell no)
+{
+	switch (no) {
+	case -19:
+		printk(" undefined word.\n");
+		break;
+	default:
+		printk("error %" FMT_CELL_d " occured.\n", no);
+	}
+	exit(1);
+}
+
+
+/*
+ * Exception handler for run_dictionary()
+ */
+
+static void exception_run_dictionary(cell no)
+{
+	printk("Error executing base dictionary %s: ", srcbasedict);
+
+	exception_common(no);
+}
+
+
+/*
+ * Exception handler for interpret_source()
+ */
+
+static void exception_interpret_source(cell no)
+{
+	printk("%s:%d: ", srcfilenames[cursrc - 1], srclines[cursrc - 1]);
+
+	exception_common(no);
+}
+
+
+/*
  * This is the C version of the forth interpreter
  */
 
@@ -505,6 +548,9 @@
 		exit(1);
 	}
 
+        /* Set up exception handler for this invocation (allows better error reporting) */
+        exception = exception_interpret_source;
+
 	/* FIXME: We should read this file at
 	 * once. No need to get it char by char
 	 */
@@ -862,20 +908,6 @@
 	PUSH(pointer2cell(memory) + MEMORY_SIZE-1);
 }
 
-void exception(cell no)
-{
-	printk("%s:%d: ", srcfilenames[cursrc - 1], srclines[cursrc - 1]);
-
-	switch (no) {
-	case -19:
-		printk(" undefined word.\n");
-		break;
-	default:
-		printk("error %" FMT_CELL_d " occured.\n", no);
-	}
-	exit(1);
-}
-
 
 void
 include_file( const char *name )
@@ -927,8 +959,12 @@
 	read_dictionary(basedict);
 	PC = (ucell)findword("initialize");
 
-	if (!PC)
+	if (!PC) {
+		if (verbose) {
+			printk("Unable to find initialize word in dictionary %s; ignoring\n", basedict);
+		}
 		return;
+	}
 
 	if(!srcfiles[0]) {
 		cursrc = 1;
@@ -940,7 +976,11 @@
 
 	init_memory();
 	if (verbose)
-		printk("Jumping to dictionary...");
+		printk("Jumping to dictionary %s...\n", basedict);
+
+	/* Set up exception handler for this invocation (allows better error reporting) */
+	exception = exception_run_dictionary;
+	srcbasedict = basedict;	
 
 	enterforth((xt_t)PC);
 }

Modified: trunk/openbios-devel/kernel/internal.c
==============================================================================
--- trunk/openbios-devel/kernel/internal.c	Wed Mar 24 11:28:51 2010	(r704)
+++ trunk/openbios-devel/kernel/internal.c	Wed Mar 24 12:49:41 2010	(r705)
@@ -25,6 +25,10 @@
 ucell PC;
 volatile int interruptforth = 0;
 
+#ifdef FCOMPILER
+void (*exception)(cell no) = NULL;
+#endif
+
 #define DEBUG_MODE_NONE 0
 #define DEBUG_MODE_STEP 1
 #define DEBUG_MODE_TRACE 2



More information about the OpenBIOS mailing list