mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-25 06:04:17 +08:00
sapi: Add and use rtems_internal_error_description
This commit is contained in:
@@ -26,49 +26,6 @@ void BSP_panic(char *s)
|
||||
#define ISITNL _Internal_errors_What_happened.is_internal
|
||||
#define THEERR _Internal_errors_What_happened.the_error
|
||||
|
||||
char *score_status_text(rtems_status_code sc)
|
||||
{
|
||||
switch (sc) {
|
||||
case INTERNAL_ERROR_NO_CONFIGURATION_TABLE:
|
||||
return "INTERNAL_ERROR_NO_CONFIGURATION_TABLE";
|
||||
case INTERNAL_ERROR_NO_CPU_TABLE:
|
||||
return "INTERNAL_ERROR_NO_CPU_TABLE";
|
||||
case INTERNAL_ERROR_TOO_LITTLE_WORKSPACE:
|
||||
return "INTERNAL_ERROR_TOO_LITTLE_WORKSPACE";
|
||||
case INTERNAL_ERROR_WORKSPACE_ALLOCATION:
|
||||
return "INTERNAL_ERROR_WORKSPACE_ALLOCATION";
|
||||
case INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL:
|
||||
return "INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL";
|
||||
case INTERNAL_ERROR_THREAD_EXITTED:
|
||||
return "INTERNAL_ERROR_THREAD_EXITTED";
|
||||
case INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION:
|
||||
return "INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION";
|
||||
case INTERNAL_ERROR_INVALID_NODE:
|
||||
return "INTERNAL_ERROR_INVALID_NODE";
|
||||
case INTERNAL_ERROR_NO_MPCI:
|
||||
return "INTERNAL_ERROR_NO_MPCI";
|
||||
case INTERNAL_ERROR_BAD_PACKET:
|
||||
return "INTERNAL_ERROR_BAD_PACKET";
|
||||
case INTERNAL_ERROR_OUT_OF_PACKETS:
|
||||
return "INTERNAL_ERROR_OUT_OF_PACKETS";
|
||||
case INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS:
|
||||
return "INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS";
|
||||
case INTERNAL_ERROR_OUT_OF_PROXIES:
|
||||
return "INTERNAL_ERROR_OUT_OF_PROXIES";
|
||||
case INTERNAL_ERROR_INVALID_GLOBAL_ID:
|
||||
return "INTERNAL_ERROR_INVALID_GLOBAL_ID";
|
||||
case INTERNAL_ERROR_BAD_STACK_HOOK:
|
||||
return "INTERNAL_ERROR_BAD_STACK_HOOK";
|
||||
case INTERNAL_ERROR_BAD_ATTRIBUTES:
|
||||
return "INTERNAL_ERROR_BAD_ATTRIBUTES";
|
||||
case 18: /* not in header (yet) :-( */
|
||||
return "INTERNAL_ERROR_CALLED_FROM_WRONG_ENVIRONMENT";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _BSP_Fatal_error(unsigned int v)
|
||||
{
|
||||
unsigned long flags;
|
||||
@@ -82,7 +39,7 @@ void _BSP_Fatal_error(unsigned int v)
|
||||
switch (THESRC) {
|
||||
case INTERNAL_ERROR_CORE:
|
||||
printk(" RTEMS Core\n");
|
||||
err = score_status_text(THEERR);
|
||||
err = rtems_internal_error_description(THEERR);
|
||||
break;
|
||||
|
||||
case INTERNAL_ERROR_RTEMS_API:
|
||||
|
||||
@@ -37,7 +37,7 @@ libsapi_a_SOURCES = src/debug.c src/extension.c src/extensioncreate.c \
|
||||
src/iounregisterdriver.c src/iowrite.c src/posixapi.c \
|
||||
src/rtemsapi.c src/extensiondata.c src/getversionstring.c \
|
||||
src/chainappendnotify.c src/chaingetnotify.c src/chaingetwait.c \
|
||||
src/chainprependnotify.c src/rbheap.c
|
||||
src/chainprependnotify.c src/rbheap.c src/interrdesc.c
|
||||
libsapi_a_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
include $(srcdir)/preinstall.am
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#define _RTEMS_FATAL_H
|
||||
|
||||
#include <rtems/score/basedefs.h> /* RTEMS_COMPILER_NO_RETURN_ATTRIBUTE */
|
||||
#include <rtems/extension.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -42,6 +43,16 @@ void rtems_fatal_error_occurred(
|
||||
uint32_t the_error
|
||||
) RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* @brief Returns a description for an internal error code.
|
||||
*
|
||||
* @param[in] error The error code.
|
||||
*
|
||||
* @return The error code description or "?" in case the passed error code is
|
||||
* invalid.
|
||||
*/
|
||||
const char *rtems_internal_error_description( rtems_fatal_code error );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2012 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Obere Lagerstr. 30
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/fatal.h>
|
||||
|
||||
static const char *const internal_error_desc [] = {
|
||||
"INTERNAL_ERROR_NO_CONFIGURATION_TABLE",
|
||||
"INTERNAL_ERROR_NO_CPU_TABLE",
|
||||
"INTERNAL_ERROR_TOO_LITTLE_WORKSPACE",
|
||||
"INTERNAL_ERROR_WORKSPACE_ALLOCATION",
|
||||
"INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL",
|
||||
"INTERNAL_ERROR_THREAD_EXITTED",
|
||||
"INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION",
|
||||
"INTERNAL_ERROR_INVALID_NODE",
|
||||
"INTERNAL_ERROR_NO_MPCI",
|
||||
"INTERNAL_ERROR_BAD_PACKET",
|
||||
"INTERNAL_ERROR_OUT_OF_PACKETS",
|
||||
"INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS",
|
||||
"INTERNAL_ERROR_OUT_OF_PROXIES",
|
||||
"INTERNAL_ERROR_INVALID_GLOBAL_ID",
|
||||
"INTERNAL_ERROR_BAD_STACK_HOOK",
|
||||
"INTERNAL_ERROR_BAD_ATTRIBUTES",
|
||||
"INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY",
|
||||
"INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL",
|
||||
"INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE",
|
||||
"INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0",
|
||||
"INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP",
|
||||
"INTERNAL_ERROR_GXX_KEY_ADD_FAILED",
|
||||
"INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED",
|
||||
"INTERNAL_ERROR_NO_MEMORY_FOR_HEAP"
|
||||
};
|
||||
|
||||
const char *rtems_internal_error_description( rtems_fatal_code error )
|
||||
{
|
||||
size_t i = error;
|
||||
const char *desc = "?";
|
||||
|
||||
if ( i < RTEMS_ARRAY_SIZE( internal_error_desc ) ) {
|
||||
desc = internal_error_desc [i];
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ fatal.texi: fatal.t
|
||||
-n "Board Support Packages" < $< > $@
|
||||
|
||||
bsp.texi: bsp.t
|
||||
$(BMENU2) -p "Fatal Error Manager FATAL_ERROR_OCCURRED - Invoke the fatal error handler" \
|
||||
$(BMENU2) -p "Fatal Error Manager INTERNAL_ERROR_DESCRIPTION - Returns a description for an internal error code" \
|
||||
-u "Top" \
|
||||
-n "User Extensions Manager" < $< > $@
|
||||
|
||||
|
||||
+28
-1
@@ -129,7 +129,7 @@ constants, usage, and status codes.
|
||||
@ifset is-C
|
||||
@findex rtems_fatal_error_occurred
|
||||
@example
|
||||
void volatile rtems_fatal_error_occurred(
|
||||
void rtems_fatal_error_occurred(
|
||||
uint32_t the_error
|
||||
);
|
||||
@end example
|
||||
@@ -167,3 +167,30 @@ NOT RETURN to the caller.
|
||||
|
||||
The user-defined extension for this directive may
|
||||
wish to initiate a global shutdown.
|
||||
|
||||
@c
|
||||
@c
|
||||
@c
|
||||
@page
|
||||
@subsection INTERNAL_ERROR_DESCRIPTION - Returns a description for an internal error code
|
||||
|
||||
@cindex fatal error
|
||||
|
||||
@subheading CALLING SEQUENCE:
|
||||
|
||||
@ifset is-C
|
||||
@findex rtems_internal_error_description
|
||||
@example
|
||||
const char *rtems_internal_error_description(
|
||||
rtems_fatal_code error
|
||||
);
|
||||
@end example
|
||||
@end ifset
|
||||
|
||||
@subheading DIRECTIVE STATUS CODES
|
||||
|
||||
The error code description or "?" in case the passed error code is invalid.
|
||||
|
||||
@subheading DESCRIPTION:
|
||||
|
||||
Returns a description for an internal error code.
|
||||
|
||||
@@ -68,40 +68,10 @@ char *Errors_Rtems[] = {
|
||||
"RTEMS_NOT_IMPLEMENTED" /* directive not implemented */
|
||||
};
|
||||
|
||||
char *Errors_Core[] = {
|
||||
"INTERNAL_ERROR_NO_CONFIGURATION_TABLE",
|
||||
"INTERNAL_ERROR_NO_CPU_TABLE",
|
||||
"INTERNAL_ERROR_TOO_LITTLE_WORKSPACE",
|
||||
"INTERNAL_ERROR_WORKSPACE_ALLOCATION",
|
||||
"INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL",
|
||||
"INTERNAL_ERROR_THREAD_EXITTED",
|
||||
"INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION",
|
||||
"INTERNAL_ERROR_INVALID_NODE",
|
||||
"INTERNAL_ERROR_NO_MPCI",
|
||||
"INTERNAL_ERROR_BAD_PACKET",
|
||||
"INTERNAL_ERROR_OUT_OF_PACKETS",
|
||||
"INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS",
|
||||
"INTERNAL_ERROR_OUT_OF_PROXIES",
|
||||
"INTERNAL_ERROR_INVALID_GLOBAL_ID",
|
||||
"INTERNAL_ERROR_BAD_STACK_HOOK",
|
||||
"INTERNAL_ERROR_BAD_ATTRIBUTES",
|
||||
"INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY",
|
||||
"INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL",
|
||||
"INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE",
|
||||
"INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0",
|
||||
"INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP",
|
||||
"INTERNAL_ERROR_GXX_KEY_ADD_FAILED",
|
||||
"INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED",
|
||||
"INTERNAL_ERROR_NO_MEMORY_FOR_HEAP"
|
||||
};
|
||||
|
||||
void Put_Error( uint32_t source, uint32_t error )
|
||||
{
|
||||
if ( source == INTERNAL_ERROR_CORE ) {
|
||||
if ( error > INTERNAL_ERROR_NO_MEMORY_FOR_HEAP )
|
||||
printk("Unknown Internal Core Error (%d)", error);
|
||||
else
|
||||
printk( Errors_Core[ error ] );
|
||||
printk( rtems_internal_error_description( error ) );
|
||||
}
|
||||
else if (source == INTERNAL_ERROR_RTEMS_API ){
|
||||
if (error > RTEMS_NOT_IMPLEMENTED )
|
||||
|
||||
@@ -31,6 +31,7 @@ SUBDIRS = \
|
||||
SUBDIRS += speventtransient01
|
||||
SUBDIRS += speventsystem01
|
||||
SUBDIRS += spinternalerror01
|
||||
SUBDIRS += spinternalerror02
|
||||
|
||||
include $(top_srcdir)/../automake/subdirs.am
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
|
||||
@@ -27,6 +27,7 @@ AC_CHECK_SIZEOF([time_t])
|
||||
|
||||
# Explicitly list all Makefiles here
|
||||
AC_CONFIG_FILES([Makefile
|
||||
spinternalerror02/Makefile
|
||||
spinternalerror01/Makefile
|
||||
speventsystem01/Makefile
|
||||
speventtransient01/Makefile
|
||||
|
||||
@@ -69,40 +69,10 @@ char *Errors_Rtems[] = {
|
||||
"RTEMS_NOT_IMPLEMENTED" /* directive not implemented */
|
||||
};
|
||||
|
||||
char *Errors_Core[] = {
|
||||
"INTERNAL_ERROR_NO_CONFIGURATION_TABLE",
|
||||
"INTERNAL_ERROR_NO_CPU_TABLE",
|
||||
"INTERNAL_ERROR_TOO_LITTLE_WORKSPACE",
|
||||
"INTERNAL_ERROR_WORKSPACE_ALLOCATION",
|
||||
"INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL",
|
||||
"INTERNAL_ERROR_THREAD_EXITTED",
|
||||
"INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION",
|
||||
"INTERNAL_ERROR_INVALID_NODE",
|
||||
"INTERNAL_ERROR_NO_MPCI",
|
||||
"INTERNAL_ERROR_BAD_PACKET",
|
||||
"INTERNAL_ERROR_OUT_OF_PACKETS",
|
||||
"INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS",
|
||||
"INTERNAL_ERROR_OUT_OF_PROXIES",
|
||||
"INTERNAL_ERROR_INVALID_GLOBAL_ID",
|
||||
"INTERNAL_ERROR_BAD_STACK_HOOK",
|
||||
"INTERNAL_ERROR_BAD_ATTRIBUTES",
|
||||
"INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY",
|
||||
"INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL",
|
||||
"INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE",
|
||||
"INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0",
|
||||
"INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP",
|
||||
"INTERNAL_ERROR_GXX_KEY_ADD_FAILED",
|
||||
"INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED",
|
||||
"INTERNAL_ERROR_NO_MEMORY_FOR_HEAP"
|
||||
};
|
||||
|
||||
void Put_Error( uint32_t source, uint32_t error )
|
||||
{
|
||||
if ( source == INTERNAL_ERROR_CORE ) {
|
||||
if ( error > INTERNAL_ERROR_NO_MEMORY_FOR_HEAP )
|
||||
printk("Unknown Internal Core Error (%d)", error);
|
||||
else
|
||||
printk( Errors_Core[ error ] );
|
||||
printk( rtems_internal_error_description( error ) );
|
||||
}
|
||||
else if (source == INTERNAL_ERROR_RTEMS_API ){
|
||||
if (error > RTEMS_NOT_IMPLEMENTED )
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
rtems_tests_PROGRAMS = spinternalerror02
|
||||
spinternalerror02_SOURCES = init.c
|
||||
|
||||
dist_rtems_tests_DATA = spinternalerror02.scn spinternalerror02.doc
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../automake/compile.am
|
||||
include $(top_srcdir)/../automake/leaf.am
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
|
||||
LINK_OBJS = $(spinternalerror02_OBJECTS)
|
||||
LINK_LIBS = $(spinternalerror02_LDLIBS)
|
||||
|
||||
spinternalerror02$(EXEEXT): $(spinternalerror02_OBJECTS) $(spinternalerror02_DEPENDENCIES)
|
||||
@rm -f spinternalerror02$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2012 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Obere Lagerstr. 30
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "tmacros.h"
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
static void test(void)
|
||||
{
|
||||
rtems_fatal_code error = 0;
|
||||
const char *desc_last = NULL;
|
||||
const char *desc;
|
||||
|
||||
do {
|
||||
desc_last = desc;
|
||||
desc = rtems_internal_error_description( error );
|
||||
++error;
|
||||
puts( desc );
|
||||
} while ( desc != desc_last );
|
||||
|
||||
rtems_test_assert( error - 3 == INTERNAL_ERROR_NO_MEMORY_FOR_HEAP );
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
{
|
||||
puts("\n\n*** TEST SPINTERNALERROR 2 ***");
|
||||
|
||||
test();
|
||||
|
||||
puts("*** END OF TEST SPINTERNALERROR 2 ***");
|
||||
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
@@ -0,0 +1,11 @@
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: spinternalerror02
|
||||
|
||||
directives:
|
||||
|
||||
rtems_internal_error_description()
|
||||
|
||||
concepts:
|
||||
|
||||
- Ensure that rtems_internal_error_description() works for some values.
|
||||
@@ -0,0 +1,28 @@
|
||||
*** TEST SPINTERNALERROR 2 ***
|
||||
INTERNAL_ERROR_NO_CONFIGURATION_TABLE
|
||||
INTERNAL_ERROR_NO_CPU_TABLE
|
||||
INTERNAL_ERROR_TOO_LITTLE_WORKSPACE
|
||||
INTERNAL_ERROR_WORKSPACE_ALLOCATION
|
||||
INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL
|
||||
INTERNAL_ERROR_THREAD_EXITTED
|
||||
INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION
|
||||
INTERNAL_ERROR_INVALID_NODE
|
||||
INTERNAL_ERROR_NO_MPCI
|
||||
INTERNAL_ERROR_BAD_PACKET
|
||||
INTERNAL_ERROR_OUT_OF_PACKETS
|
||||
INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS
|
||||
INTERNAL_ERROR_OUT_OF_PROXIES
|
||||
INTERNAL_ERROR_INVALID_GLOBAL_ID
|
||||
INTERNAL_ERROR_BAD_STACK_HOOK
|
||||
INTERNAL_ERROR_BAD_ATTRIBUTES
|
||||
INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY
|
||||
INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL
|
||||
INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE
|
||||
INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0
|
||||
INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP
|
||||
INTERNAL_ERROR_GXX_KEY_ADD_FAILED
|
||||
INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED
|
||||
INTERNAL_ERROR_NO_MEMORY_FOR_HEAP
|
||||
?
|
||||
?
|
||||
*** END OF TEST SPINTERNALERROR 2 ***
|
||||
Reference in New Issue
Block a user