mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Revert the parts of the last commit which changed the exception function to use an exception pointer as it isn't really
required. Update forthstrap to add a new -c option that when specified will direct the Forth kernel console output to a file and integrate this into the build system. By default, when a dictionary is built using a base dictionary then a new log file called <dict>-console.log will be generated to help debugging if the build fails. Also update the exception handler in kernel/bootstrap.c so that it matches the entire range of error codes in forth/bootstrap/interpreter.fs. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@706 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
committed by
Mark Cave-Ayland
parent
a288b3044b
commit
34d5a76f7e
@@ -129,6 +129,7 @@
|
||||
<xsl:if test="$init!=''">
|
||||
<xsl:text> -d $(ODIR)/</xsl:text><xsl:value-of select="$init"/><xsl:text>.dict</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text> -c $@-console.log</xsl:text>
|
||||
<xsl:text> $(</xsl:text>
|
||||
<xsl:value-of select="@name"/>
|
||||
<xsl:text>-DICTIONARY)," GEN $(TARGET_DIR)$@") </xsl:text>
|
||||
|
||||
@@ -34,12 +34,13 @@ extern xt_t findword(const char *s1);
|
||||
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 );
|
||||
extern void encode_file( const char *str );
|
||||
extern int get_inputbyte( void );
|
||||
extern void put_outputbyte( int c );
|
||||
#endif
|
||||
|
||||
#ifndef BOOTSTRAP
|
||||
|
||||
@@ -54,6 +54,9 @@ static unsigned int cursrc = 0;
|
||||
|
||||
static char *srcbasedict;
|
||||
|
||||
/* console variables */
|
||||
static FILE *console;
|
||||
|
||||
#ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
|
||||
unsigned long base_address;
|
||||
#endif
|
||||
@@ -487,15 +490,43 @@ static FILE *fopen_include(const char *fil)
|
||||
|
||||
|
||||
/*
|
||||
* Common Forth exception handler
|
||||
* Forth exception handler
|
||||
*/
|
||||
|
||||
static void exception_common(cell no)
|
||||
void exception(cell no)
|
||||
{
|
||||
printk("%s:%d: ", srcfilenames[cursrc - 1], srclines[cursrc - 1]);
|
||||
|
||||
/* See also forth/bootstrap/interpreter.fs */
|
||||
switch (no) {
|
||||
case -1:
|
||||
case -2:
|
||||
printk("Aborted.\n");
|
||||
break;
|
||||
case -3:
|
||||
printk("Stack Overflow.\n");
|
||||
break;
|
||||
case -4:
|
||||
printk("Stack Underflow.\n");
|
||||
break;
|
||||
case -5:
|
||||
printk("Return Stack Overflow.\n");
|
||||
break;
|
||||
case -6:
|
||||
printk("Return Stack Underflow.\n");
|
||||
break;
|
||||
case -19:
|
||||
printk("undefined word.\n");
|
||||
break;
|
||||
case -21:
|
||||
printk("out of memory.\n");
|
||||
break;
|
||||
case -33:
|
||||
printk("undefined method.\n");
|
||||
break;
|
||||
case -34:
|
||||
printk("no such device.\n");
|
||||
break;
|
||||
default:
|
||||
printk("error %" FMT_CELL_d " occured.\n", no);
|
||||
}
|
||||
@@ -503,30 +534,6 @@ static void exception_common(cell no)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
@@ -548,9 +555,6 @@ static int interpret_source(char *fil)
|
||||
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
|
||||
*/
|
||||
@@ -731,7 +735,7 @@ static int interpret_source(char *fil)
|
||||
|
||||
if (*test != 0) {
|
||||
/* what is it?? */
|
||||
printk("%s:%d - %s is not defined.\n\n", srcfilenames[cursrc - 1], srclines[cursrc - 1], tib);
|
||||
printk("%s:%d: %s is not defined.\n\n", srcfilenames[cursrc - 1], srclines[cursrc - 1], tib);
|
||||
errors++;
|
||||
#ifdef CONFIG_DEBUG_INTERPRETER
|
||||
continue;
|
||||
@@ -844,14 +848,27 @@ int get_inputbyte( void )
|
||||
}
|
||||
|
||||
tmp = getc( srcfiles[cursrc-1] );
|
||||
if (tmp != EOF)
|
||||
|
||||
/* Update current line number */
|
||||
if (tmp == '\n') {
|
||||
srclines[cursrc - 1]++;
|
||||
}
|
||||
|
||||
if (tmp != EOF) {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
fclose(srcfiles[--cursrc]);
|
||||
|
||||
return get_inputbyte();
|
||||
}
|
||||
|
||||
void put_outputbyte( int c )
|
||||
{
|
||||
if (console)
|
||||
fputc(c, console);
|
||||
}
|
||||
|
||||
/*
|
||||
* segmentation fault handler. linux specific?
|
||||
*/
|
||||
@@ -951,7 +968,7 @@ encode_file( const char *name )
|
||||
}
|
||||
|
||||
|
||||
static void run_dictionary(char *basedict)
|
||||
static void run_dictionary(char *basedict, char *confile)
|
||||
{
|
||||
if(!basedict)
|
||||
return;
|
||||
@@ -978,11 +995,17 @@ static void run_dictionary(char *basedict)
|
||||
if (verbose)
|
||||
printk("Jumping to dictionary %s...\n", basedict);
|
||||
|
||||
/* Set up exception handler for this invocation (allows better error reporting) */
|
||||
exception = exception_run_dictionary;
|
||||
/* If a console file has been specified, open it */
|
||||
if (confile)
|
||||
console = fopen(confile, "w");
|
||||
|
||||
srcbasedict = basedict;
|
||||
|
||||
enterforth((xt_t)PC);
|
||||
|
||||
/* Close the console file */
|
||||
if (console)
|
||||
fclose(console);
|
||||
}
|
||||
|
||||
static void new_dictionary(const char *source)
|
||||
@@ -1015,6 +1038,8 @@ static void new_dictionary(const char *source)
|
||||
" use this dictionary as base\n" \
|
||||
" -D|--target-dictionary output.dict\n" \
|
||||
" write to output.dict\n" \
|
||||
" -c|--console output.log\n" \
|
||||
" write kernel console output to log file\n" \
|
||||
" -s|--segfault install segfault handler\n\n"
|
||||
#else
|
||||
#define USAGE "Usage: %s [options] [dictionary file|source file]\n\n" \
|
||||
@@ -1026,6 +1051,8 @@ static void new_dictionary(const char *source)
|
||||
" use this dictionary as base\n" \
|
||||
" -D output.dict\n" \
|
||||
" write to output.dict\n" \
|
||||
" -c output.log\n" \
|
||||
" write kernel console output to log file\n" \
|
||||
" -s install segfault handler\n\n"
|
||||
|
||||
#endif
|
||||
@@ -1037,11 +1064,12 @@ int main(int argc, char *argv[])
|
||||
unsigned char *ressources=NULL; /* All memory used by us */
|
||||
char *dictname = NULL;
|
||||
char *basedict = NULL;
|
||||
char *consolefile = NULL;
|
||||
|
||||
unsigned char *bootstrapdict[2];
|
||||
int c, cnt;
|
||||
|
||||
const char *optstring = "VvhsI:d:D:?";
|
||||
const char *optstring = "VvhsI:d:D:c:?";
|
||||
|
||||
while (1) {
|
||||
#ifdef __GLIBC__
|
||||
@@ -1054,6 +1082,7 @@ int main(int argc, char *argv[])
|
||||
{"include", 1, NULL, 'I'},
|
||||
{"source-dictionary", 1, NULL, 'd'},
|
||||
{"target-dictionary", 1, NULL, 'D'},
|
||||
{"console", 1, NULL, 'c'},
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -1093,11 +1122,17 @@ int main(int argc, char *argv[])
|
||||
if (!basedict) {
|
||||
basedict = optarg;
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
if(!dictname) {
|
||||
dictname = optarg;
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
if (!consolefile) {
|
||||
consolefile = optarg;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
@@ -1176,7 +1211,7 @@ int main(int argc, char *argv[])
|
||||
for (c=argc-1; c>=optind; c--)
|
||||
include_file(argv[c]);
|
||||
|
||||
run_dictionary(basedict);
|
||||
run_dictionary(basedict, consolefile);
|
||||
}
|
||||
if(errors)
|
||||
break;
|
||||
|
||||
@@ -860,11 +860,11 @@ static void herewrite(void)
|
||||
|
||||
static void emit(void)
|
||||
{
|
||||
#ifndef FCOMPILER
|
||||
cell tmp = POP();
|
||||
#ifndef FCOMPILER
|
||||
putchar(tmp);
|
||||
#else
|
||||
(void) POP();
|
||||
put_outputbyte(tmp);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -25,10 +25,6 @@ static forth_word * const words[];
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user