diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-02-18 19:23:28 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-02-18 19:23:28 +0000 |
commit | 5d024595a7cbb8a04fad883fd89b42d61d72acf7 (patch) | |
tree | 8bffa56dd3e0d9ab2c5d61651c43da9676105644 /c/src/lib/libbsp/m68k/mvme167/fatal | |
parent | Missed this file in the merge. (diff) | |
download | rtems-5d024595a7cbb8a04fad883fd89b42d61d72acf7.tar.bz2 |
MVME167 BSP submitted by Charles Gauthier <Charles.Gauthier@iit.nrc.ca>.
Diffstat (limited to 'c/src/lib/libbsp/m68k/mvme167/fatal')
-rw-r--r-- | c/src/lib/libbsp/m68k/mvme167/fatal/Makefile.in | 54 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/mvme167/fatal/bspfatal.c | 127 | ||||
-rw-r--r-- | c/src/lib/libbsp/m68k/mvme167/fatal/fatal.c | 127 |
3 files changed, 308 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/m68k/mvme167/fatal/Makefile.in b/c/src/lib/libbsp/m68k/mvme167/fatal/Makefile.in new file mode 100644 index 0000000000..6c8b9e1355 --- /dev/null +++ b/c/src/lib/libbsp/m68k/mvme167/fatal/Makefile.in @@ -0,0 +1,54 @@ +# +# $Id$ +# + +@SET_MAKE@ +srcdir = @srcdir@ +VPATH = @srcdir@ +RTEMS_ROOT = @top_srcdir@ +PROJECT_ROOT = @PROJECT_ROOT@ + +PGM=${ARCH}/fatal.rel + +# C source names, if any, go here -- minus the .c +C_PIECES=fatal +C_FILES=$(C_PIECES:%=%.c) +C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) + +H_FILES= + +SRCS=$(C_FILES) $(H_FILES) +OBJS=$(C_O_FILES) + +include $(RTEMS_ROOT)/make/custom/$(RTEMS_BSP).cfg +include $(RTEMS_ROOT)/make/leaf.cfg + +# +# (OPTIONAL) Add local stuff here using += +# + +DEFINES += +CPPFLAGS += +CFLAGS += + +LD_PATHS += +LD_LIBS += +LDFLAGS += + +# +# Add your list of files to delete here. The config files +# already know how to delete some stuff, so you may want +# to just run 'make clean' first to see what gets missed. +# 'make clobber' already includes 'make clean' +# + +CLEAN_ADDITIONS += +CLOBBER_ADDITIONS += + +${PGM}: ${SRCS} ${OBJS} + $(make-rel) + +all: ${ARCH} $(SRCS) $(PGM) + +# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile +install: all diff --git a/c/src/lib/libbsp/m68k/mvme167/fatal/bspfatal.c b/c/src/lib/libbsp/m68k/mvme167/fatal/bspfatal.c new file mode 100644 index 0000000000..8f1f69f999 --- /dev/null +++ b/c/src/lib/libbsp/m68k/mvme167/fatal/bspfatal.c @@ -0,0 +1,127 @@ +/* fatal.c + * + * User-define fatal error handler. + * + * Copyright (c) 1998, National Research Council of Canada + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <bsp.h> +#include <fatal.h> + +/* + * mystrcat + * + * Can't rely on libc being operational. So we provide our own strcat-like + * function. + * + * Input parameters: + * destination - string (buffer) to append to + * source - string to append to the end of destination + * + * Output parameters: + * destination - source is appended to the end + * + * Return values: + * Number of characters appended. + */ +static int mystrcat( + char *destination, + const char *source +) +{ + int i; + + for ( i = 0; ( *destination++ = *source++) != '\0'; i++ ); + return i; +} + + +/* + * bsp_fatal_error_occurred + * + * Called when rtems_fatal_error_occurred() is called. Returns control to + * 167Bug. The _Internal_error_Occurred() function has already saved the + * parameters in Internal_errors_What_happened. If the function returns, + * RTEMS will halt the CPU. + * + * Make sure the CPU is + * + * Input parameters: + * the_source - what subsystem the error originated in + * is_internal - if the error was internally generated + * the_error - fatal error status code + * + * Output parameters: + * output to the 167Bug console + * + * Return values: NONE. + */ +User_extensions_routine bsp_fatal_error_occurred( + Internal_errors_Source the_source, + rtems_boolean is_internal, + rtems_unsigned32 the_error +) +{ + struct { + char index; /* First byte is number of chars in strbuf */ + char strbuf[254]; /* In case count is bumped up by one by 167Bug */ + } my_p_str; + + my_p_str.index = 0; + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "\r\nRTEMS Fatal Error Occurred:\r\n the_source = " ); + + switch ( the_source ) { + case INTERNAL_ERROR_CORE: + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "INTERNAL_ERROR_CORE\r\n is_internal = " ); + break; + + case INTERNAL_ERROR_RTEMS_API: + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "INTERNAL_ERROR_RTEMS_API\r\n is_internal = " ); + break; + + case INTERNAL_ERROR_POSIX_API: + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "INTERNAL_ERROR_POSIX_API\r\n is_internal = " ); + break; + + default: + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "UNKNOWN\r\n is_internal = " ); + break; + } + + if ( is_internal ) + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "TRUE\r\n the_error = 0x|10,8|\r\n" ); + else + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "FALSE\r\n the_error = 0x|10,8|\r\n" ); + + lcsr->intr_ena = 0; /* disable interrupts */ + m68k_set_vbr(0xFFE00000); /* restore 167Bug vectors */ + + asm volatile( "movel %0, -(%%a7) + pea (%%a7) + pea (%1) + trap #15 /* trap to 167Bug (.WRITDLN) */ + .short 0x25 + trap #15 + .short 0x63" + :: "d" (the_error), "a" (&my_p_str) ); +} diff --git a/c/src/lib/libbsp/m68k/mvme167/fatal/fatal.c b/c/src/lib/libbsp/m68k/mvme167/fatal/fatal.c new file mode 100644 index 0000000000..8f1f69f999 --- /dev/null +++ b/c/src/lib/libbsp/m68k/mvme167/fatal/fatal.c @@ -0,0 +1,127 @@ +/* fatal.c + * + * User-define fatal error handler. + * + * Copyright (c) 1998, National Research Council of Canada + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <bsp.h> +#include <fatal.h> + +/* + * mystrcat + * + * Can't rely on libc being operational. So we provide our own strcat-like + * function. + * + * Input parameters: + * destination - string (buffer) to append to + * source - string to append to the end of destination + * + * Output parameters: + * destination - source is appended to the end + * + * Return values: + * Number of characters appended. + */ +static int mystrcat( + char *destination, + const char *source +) +{ + int i; + + for ( i = 0; ( *destination++ = *source++) != '\0'; i++ ); + return i; +} + + +/* + * bsp_fatal_error_occurred + * + * Called when rtems_fatal_error_occurred() is called. Returns control to + * 167Bug. The _Internal_error_Occurred() function has already saved the + * parameters in Internal_errors_What_happened. If the function returns, + * RTEMS will halt the CPU. + * + * Make sure the CPU is + * + * Input parameters: + * the_source - what subsystem the error originated in + * is_internal - if the error was internally generated + * the_error - fatal error status code + * + * Output parameters: + * output to the 167Bug console + * + * Return values: NONE. + */ +User_extensions_routine bsp_fatal_error_occurred( + Internal_errors_Source the_source, + rtems_boolean is_internal, + rtems_unsigned32 the_error +) +{ + struct { + char index; /* First byte is number of chars in strbuf */ + char strbuf[254]; /* In case count is bumped up by one by 167Bug */ + } my_p_str; + + my_p_str.index = 0; + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "\r\nRTEMS Fatal Error Occurred:\r\n the_source = " ); + + switch ( the_source ) { + case INTERNAL_ERROR_CORE: + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "INTERNAL_ERROR_CORE\r\n is_internal = " ); + break; + + case INTERNAL_ERROR_RTEMS_API: + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "INTERNAL_ERROR_RTEMS_API\r\n is_internal = " ); + break; + + case INTERNAL_ERROR_POSIX_API: + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "INTERNAL_ERROR_POSIX_API\r\n is_internal = " ); + break; + + default: + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "UNKNOWN\r\n is_internal = " ); + break; + } + + if ( is_internal ) + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "TRUE\r\n the_error = 0x|10,8|\r\n" ); + else + my_p_str.index += mystrcat( + my_p_str.strbuf + my_p_str.index, + "FALSE\r\n the_error = 0x|10,8|\r\n" ); + + lcsr->intr_ena = 0; /* disable interrupts */ + m68k_set_vbr(0xFFE00000); /* restore 167Bug vectors */ + + asm volatile( "movel %0, -(%%a7) + pea (%%a7) + pea (%1) + trap #15 /* trap to 167Bug (.WRITDLN) */ + .short 0x25 + trap #15 + .short 0x63" + :: "d" (the_error), "a" (&my_p_str) ); +} |