bsps: Add fatal errors for shared console driver

This commit is contained in:
Sebastian Huber
2013-06-20 11:57:34 +02:00
parent ade27c69eb
commit 6307b1af62
3 changed files with 19 additions and 16 deletions

View File

@@ -16,13 +16,13 @@
*/ */
#include <bsp.h> #include <bsp.h>
#include <bsp/generic-fatal.h>
#include <rtems/libio.h> #include <rtems/libio.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <termios.h> #include <termios.h>
#include <rtems/termiostypes.h> #include <rtems/termiostypes.h>
#include <rtems/error.h> /* rtems_panic */
#include <libchip/serial.h> #include <libchip/serial.h>
#include "console_private.h" #include "console_private.h"
@@ -48,7 +48,7 @@ static void console_initialize_pointers(void)
Console_Port_Count = Console_Configuration_Count; Console_Port_Count = Console_Configuration_Count;
Console_Port_Tbl = malloc( Console_Port_Count * sizeof( console_tbl * ) ); Console_Port_Tbl = malloc( Console_Port_Count * sizeof( console_tbl * ) );
if (Console_Port_Tbl == NULL) 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++) for (i=0 ; i < Console_Port_Count ; i++)
Console_Port_Tbl[i] = &Console_Configuration_Ports[i]; Console_Port_Tbl[i] = &Console_Configuration_Ports[i];
@@ -75,8 +75,7 @@ void console_register_devices(
* register devices. * register devices.
*/ */
if ( console_initialized ) { if ( console_initialized ) {
printk( "Attempt to register console devices after driver initialized\n" ); bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_MULTI_INIT );
rtems_fatal_error_occurred( 0xdead0001 );
} }
/* /*
@@ -89,14 +88,12 @@ void console_register_devices(
Console_Port_Count * sizeof( console_tbl * ) Console_Port_Count * sizeof( console_tbl * )
); );
if ( Console_Port_Tbl == NULL ) { if ( Console_Port_Tbl == NULL ) {
printk( "Unable to allocate pointer table for registering console devices\n" ); bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_NO_MEMORY_1 );
rtems_fatal_error_occurred( 0xdead0002 );
} }
Console_Port_Data = calloc( Console_Port_Count, sizeof( console_data ) ); Console_Port_Data = calloc( Console_Port_Count, sizeof( console_data ) );
if ( Console_Port_Data == NULL ) { if ( Console_Port_Data == NULL ) {
printk( "Unable to allocate data table for console devices\n" ); bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_NO_MEMORY_2 );
rtems_fatal_error_occurred( 0xdead0003 );
} }
/* /*
@@ -257,8 +254,7 @@ rtems_device_driver console_initialize(
console_initialize_pointers(); console_initialize_pointers();
Console_Port_Data = calloc( Console_Port_Count, sizeof( console_data ) ); Console_Port_Data = calloc( Console_Port_Count, sizeof( console_data ) );
if ( Console_Port_Data == NULL ) { if ( Console_Port_Data == NULL ) {
printk( "Unable to allocate data table for console devices\n" ); bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_NO_MEMORY_3 );
rtems_fatal_error_occurred( 0xdead0003 );
} }
} }
@@ -293,8 +289,7 @@ rtems_device_driver console_initialize(
if (port->sDeviceName != NULL) { if (port->sDeviceName != NULL) {
status = rtems_io_register_name( port->sDeviceName, major, minor ); status = rtems_io_register_name( port->sDeviceName, major, minor );
if (status != RTEMS_SUCCESSFUL) { if (status != RTEMS_SUCCESSFUL) {
printk( "Unable to register %s\n", port->sDeviceName ); bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_REGISTER_DEV_0 );
rtems_fatal_error_occurred(status);
} }
} }
@@ -305,8 +300,7 @@ rtems_device_driver console_initialize(
#endif #endif
status = rtems_io_register_name( "dev/console", major, minor ); status = rtems_io_register_name( "dev/console", major, minor );
if (status != RTEMS_SUCCESSFUL) { if (status != RTEMS_SUCCESSFUL) {
printk( "Unable to register /dev/console\n" ); bsp_generic_fatal( BSP_GENERIC_FATAL_CONSOLE_REGISTER_DEV_1 );
rtems_fatal_error_occurred(status);
} }
} }

View File

@@ -19,6 +19,7 @@
*/ */
#include <bsp.h> #include <bsp.h>
#include <bsp/generic-fatal.h>
#include <rtems/libio.h> #include <rtems/libio.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
@@ -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. * 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) void bsp_console_select(void)

View File

@@ -27,7 +27,15 @@ extern "C" {
typedef enum { typedef enum {
BSP_GENERIC_FATAL_EXCEPTION_INITIALIZATION, BSP_GENERIC_FATAL_EXCEPTION_INITIALIZATION,
BSP_GENERIC_FATAL_INTERRUPT_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; } bsp_generic_fatal_code;
static inline void bsp_generic_fatal( bsp_generic_fatal_code code ) static inline void bsp_generic_fatal( bsp_generic_fatal_code code )