From 6307b1af62e8902e325cd84a77d23b033a3e78d3 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 20 Jun 2013 11:57:34 +0200 Subject: bsps: Add fatal errors for shared console driver --- c/src/lib/libbsp/shared/console.c | 22 ++++++++-------------- c/src/lib/libbsp/shared/console_select.c | 3 ++- c/src/lib/libbsp/shared/include/generic-fatal.h | 10 +++++++++- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/c/src/lib/libbsp/shared/console.c b/c/src/lib/libbsp/shared/console.c index b3c3d75f27..7aba7ace74 100644 --- a/c/src/lib/libbsp/shared/console.c +++ b/c/src/lib/libbsp/shared/console.c @@ -16,13 +16,13 @@ */ #include +#include #include #include #include #include #include -#include /* rtems_panic */ #include #include "console_private.h" @@ -48,7 +48,7 @@ static void console_initialize_pointers(void) Console_Port_Count = Console_Configuration_Count; Console_Port_Tbl = malloc( Console_Port_Count * sizeof( console_tbl * ) ); if (Console_Port_Tbl == NULL) - rtems_panic("No memory for console pointers"); + bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_NO_MEMORY_0 ); for (i=0 ; i < Console_Port_Count ; i++) Console_Port_Tbl[i] = &Console_Configuration_Ports[i]; @@ -75,8 +75,7 @@ void console_register_devices( * register devices. */ if ( console_initialized ) { - printk( "Attempt to register console devices after driver initialized\n" ); - rtems_fatal_error_occurred( 0xdead0001 ); + bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_MULTI_INIT ); } /* @@ -89,14 +88,12 @@ void console_register_devices( Console_Port_Count * sizeof( console_tbl * ) ); if ( Console_Port_Tbl == NULL ) { - printk( "Unable to allocate pointer table for registering console devices\n" ); - rtems_fatal_error_occurred( 0xdead0002 ); + bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_NO_MEMORY_1 ); } Console_Port_Data = calloc( Console_Port_Count, sizeof( console_data ) ); if ( Console_Port_Data == NULL ) { - printk( "Unable to allocate data table for console devices\n" ); - rtems_fatal_error_occurred( 0xdead0003 ); + bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_NO_MEMORY_2 ); } /* @@ -257,8 +254,7 @@ rtems_device_driver console_initialize( console_initialize_pointers(); Console_Port_Data = calloc( Console_Port_Count, sizeof( console_data ) ); if ( Console_Port_Data == NULL ) { - printk( "Unable to allocate data table for console devices\n" ); - rtems_fatal_error_occurred( 0xdead0003 ); + bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_NO_MEMORY_3 ); } } @@ -293,8 +289,7 @@ rtems_device_driver console_initialize( if (port->sDeviceName != NULL) { status = rtems_io_register_name( port->sDeviceName, major, minor ); if (status != RTEMS_SUCCESSFUL) { - printk( "Unable to register %s\n", port->sDeviceName ); - rtems_fatal_error_occurred(status); + bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_REGISTER_DEV_0 ); } } @@ -305,8 +300,7 @@ rtems_device_driver console_initialize( #endif status = rtems_io_register_name( "dev/console", major, minor ); if (status != RTEMS_SUCCESSFUL) { - printk( "Unable to register /dev/console\n" ); - rtems_fatal_error_occurred(status); + bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_REGISTER_DEV_1 ); } } diff --git a/c/src/lib/libbsp/shared/console_select.c b/c/src/lib/libbsp/shared/console_select.c index 8578a5ddf7..4803a8f25f 100644 --- a/c/src/lib/libbsp/shared/console_select.c +++ b/c/src/lib/libbsp/shared/console_select.c @@ -19,6 +19,7 @@ */ #include +#include #include #include #include @@ -71,7 +72,7 @@ static rtems_device_minor_number bsp_First_Available_Device( void ) /* * Error No devices were found. We will want to bail here. */ - rtems_fatal_error_occurred(RTEMS_IO_ERROR); + bsp_generic_fatal(BSP_GENERIC_FATAL_CONSOLE_NO_DEV); } void bsp_console_select(void) diff --git a/c/src/lib/libbsp/shared/include/generic-fatal.h b/c/src/lib/libbsp/shared/include/generic-fatal.h index 4edf4675a9..ec2dfb6cf1 100644 --- a/c/src/lib/libbsp/shared/include/generic-fatal.h +++ b/c/src/lib/libbsp/shared/include/generic-fatal.h @@ -27,7 +27,15 @@ extern "C" { typedef enum { BSP_GENERIC_FATAL_EXCEPTION_INITIALIZATION, BSP_GENERIC_FATAL_INTERRUPT_INITIALIZATION, - BSP_GENERIC_FATAL_SPURIOUS_INTERRUPT + BSP_GENERIC_FATAL_SPURIOUS_INTERRUPT, + BSP_GENERIC_FATAL_CONSOLE_MULTI_INIT, + BSP_GENERIC_FATAL_CONSOLE_NO_MEMORY_0, + BSP_GENERIC_FATAL_CONSOLE_NO_MEMORY_1, + BSP_GENERIC_FATAL_CONSOLE_NO_MEMORY_2, + BSP_GENERIC_FATAL_CONSOLE_NO_MEMORY_3, + BSP_GENERIC_FATAL_CONSOLE_REGISTER_DEV_0, + BSP_GENERIC_FATAL_CONSOLE_REGISTER_DEV_1, + BSP_GENERIC_FATAL_CONSOLE_NO_DEV } bsp_generic_fatal_code; static inline void bsp_generic_fatal( bsp_generic_fatal_code code ) -- cgit v1.2.3