
/*
 *
 *     Module Name: errhndlr.c
 *	       Version: 1.00
 *   Original Date: 09/10/02	
 *	        Author: Charles Gordon
 *	      Language: Ansi C
 * Compile Options:
 * Compile defines:
 *	     Libraries:
 *    Link Options:
 *
 *    Entry Points: customizeErrorHandler()
 *
 *  Copyright (c) Digi International Inc., All Rights Reserved
 *  
 *  This software contains proprietary and confidential information of Digi
 *  International Inc.  By accepting transfer of this copy, Recipient agrees
 *  to retain this software in confidence, to prevent disclosure to others,
 *  and to make no use of this software other than that for which it was
 *  delivered.  This is an unpublished copyrighted work of Digi International
 *  Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
 *  prohibited.
 *  
 *  Restricted Rights Legend
 * 
 *  Use, duplication, or disclosure by the Government is subject to
 *  restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
 *  Technical Data and Computer Software clause at DFARS 252.227-7031 or
 *  subparagraphs (c)(1) and (2) of the Commercial Computer Software -
 *  Restricted Rights at 48 CFR 52.227-19, as applicable.
 * 
 *  Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
 *
 * Description.
 * =======================================================================
 *  This file contains a template error handler.  
 *
 *
 *
 * Edit Date/Ver   Edit Description
 * ==============  =======================================================
 *
 *
 */

#ifndef errhndlr_h

#define errhndlr_h

#ifdef __cplusplus
extern "C"
{
#endif

/*ad*
 * Error code for customizeErrorHandler. This error code is used for blinking pattern
 * for red or error led in customizeErrorHandler.
 *
 * @category error_handler
 * @include 	<errhndlr.h>
 * @since 6.0
 * @external
 *
 * @name blink_code "LED Error Blink Codes"
 *
 * @param  ERROR_POST_FAILED           Power On Self Test failed
 * @param  ERROR_IRQ_TABLE             Interrupt Handler Error
 * @param  ERROR_SNMP_MIB			   SNMP Error
 * @param  ERROR_SNMP_MIB1213		   Error in MIB-II implementation
 * @param  ERROR_RAM_FAILURE           Memory error 
 * @param  ERROR_ACE_FAILURE           Address Configuration Executable Failure
 * @param  ERROR_SERIAL_DRIVER         Serial Driver Error
 * @param  ERROR_ETHERNET_DRIVER       Ethernet Driver Error
 * @param  ERROR_PPP                   PPP driver Error
 * @param  ERROR_FILEIO                File System Error
 * @param  ERROR_ROOSTER_THREADX	   TCP/IP Rooster Thread Error
 * @param  ERROR_ROOSTER_CRITICAL	   TCP/IP Rooster Thread Critical Section Error
 * @param  ERROR_CHECKSUM			   Checksum Error
 * @param  ERROR_MAMAPI				   Management API error
 * @param  ERROR_OUT_OF_MEMORY		   Out of Memory
 * @param  ERROR_ASSERT_FAILED         NA_ASSERT() failed.  This was probably caused by passing
 *                                     a bad parameter to a function.
 * @param  ERROR_LCD_DRIVER		       LCD Driver Error
 * @param  ERROR_POWERSAVE             Error reported by power save API.
 * @param  ERROR_MMU                   Error reported by MMU set up routines.
 * @param  ERROR_TIMER                 Error reported by timer API.
 * @param  ERROR_PARALLEL              Error reported by parallel driver.
 * @param  ERROR_MII                   Error reported by MII driver.
 * @param  ERROR_USB_DEVICE            Error reported by USB device driver
 * @param  ERROR_GPIO_MUX              Error reported by GPIO MUX code.
 * @param  ERROR_SNMP_AGENT            Error reported by SNMP agent.
 * @param  ERROR_PANIC                 panic() called
 * @param  ERROR_SDIO                  Error reported by SDIO driver.
 * @param  ERROR_CAN                   Error reported by CAN driver.
 * @see @link customizeErrorHandler
*ad*/
#define ERROR_POST_FAILED                   1
#define ERROR_IRQ_TABLE                     3
#define ERROR_SNMP_MIB						4
#define ERROR_SNMP_MIB1213					5
#define ERROR_RAM_FAILURE                   6
#define ERROR_ACE_FAILURE                   7
#define ERROR_SERIAL_DRIVER                 8
#define ERROR_ETHERNET_DRIVER               9
#define ERROR_PPP                           10
#define ERROR_FILEIO                        11
#define ERROR_ROOSTER_THREADX				12
#define ERROR_ROOSTER_CRITICAL				13
#define ERROR_CHECKSUM						14
#define ERROR_MAMAPI						15
#define ERROR_OUT_OF_MEMORY					16
#define ERROR_ASSERT_FAILED                 17
#define ERROR_LCD_DRIVER                    18
#define ERROR_POWERSAVE                     19
#define ERROR_MMU                           20
#define ERROR_TIMER                         21
#define ERROR_PARALLEL                      22
#define ERROR_MII                           23
#define ERROR_USB_DEVICE                    24
#define ERROR_GPIO_MUX                      25
#define ERROR_SNMP_AGENT                    26
#define ERROR_PANIC                         27
#define ERROR_SDIO                          28
#define ERROR_CAN                           29


/***********************************************

The structure stores the all the register values whenever the crash occurs.
These values the referenced from the errhndlr.c file 

************************************************/
typedef unsigned long reg_at_crash;

typedef struct 
    {
        reg_at_crash r[13];         //Registers R0 to R12
        reg_at_crash sp;            //Stack Pointer
        reg_at_crash lr;            //Link Register
        reg_at_crash pc;            //Program Counter
        reg_at_crash cpsr;          //Current program status register

    } all_reg_at_crash;

extern all_reg_at_crash SavedRegs;

unsigned long CoreDump(all_reg_at_crash * data , int source);

/* Macro definations for the different registers */

#define Reg_SP 13
#define Reg_LR 14
#define Reg_PC 15

#define Reg_CPSR (Reg_PC + 25 + 1)
#define Reg_MAX (Reg_CPSR + 1)

/************************************************
************************************************/


/*ad*
 * Subcode for customizeErrorHandler. This subcode is used for blinking pattern
 * for green or normal led in customizeErrorHandler.
 *
 * @category error_handler
 * @include 	<errhndlr.h>
 * @since 6.0
 * @external
 *
 * @name blink_subcode      "LED Error Blink Subcodes"
 *
 * @param  ERROR_NO_SUBCODE                	   Error subcode was not specified
 * @param  ERROR_CANT_CREATE_EVENT_FLAG        Unable to create event flag
 * @param  ERROR_ETHERNET_SEMAPHORE            Error with semaphore
 * @param  ERROR_PPP_UNABLE_TO_ADD_DEVICE      Unable to add PPP device
 * @param  ERROR_FILEIO_SEMAPHORE              Error with file system semaphore
 * @param  ERROR_SUBCODE_INVALID_INTERRUPT     Unexpected interrupt occurred
 * @param  ERROR_SUBCODE_TCPIP_HEAP            Unable to allocate network heap
 * @param  ERROR_SUBCODE_DUPLICATE_IRQ_ENTRY   Duplicate entry in IRQ table
 * @param  ERROR_SUBCODE_AT_TABLE			   Error processing request in AT table 
 * @param  ERROR_SUBCODE_EGP_TABLE			   Error processing request in EGP table 
 * @param  ERROR_SUBCODE_IF_TABLE			   Error processing request in IF table 
 * @param  ERROR_SUBCODE_IPADDR_TABLE		   Error processing request in IPADDR table 
 * @param  ERROR_SUBCODE_IPROUTE_TABLE		   Error processing request in IPROUTE table 
 * @param  ERROR_SUBCODE_IPMEDIA_TABLE		   Error processing request in IPMEDIA table 
 * @param  ERROR_SUBCODE_SYSOR_TABLE		   Error processing request in SYSOR table 
 * @param  ERROR_SUBCODE_TCPCONN_TABLE		   Error processing request in TCPCONN table 
 * @param  ERROR_SUBCODE_UPD_TABLE			   Error processing request in UPD table 
 * @param  ERROR_SUBCODE_NO_RAM                No RAM detected
 * @param  ERROR_SUBCODE_FAILED_RAM_TEST       Failed RAM test
 * @param  ERROR_SUBCODE_INSUFFICIENT_RAM      Insufficient RAM for application
 * @param  ERROR_SUBCODE_BAD_ACE_CONFIG        Invalid ACE configuration
 * @param  ERROR_ACE_FAILED                    ACE could not get IP address
 * @param  ERROR_SUBCODE_COUNTER			   Bad counter
 * @param  ERROR_SUBCODE_FREE_VARIABLE		   Error freeing variable
 * @param  ERROR_SUBCODE_FREE_ROW			   Error freeing row
 * @param  ERROR_SUBCODE_ALLOC_ROW			   Unable to allocate row
 * @param  ERROR_SUBCODE_COPY_ROW			   Unable to copy row
 * @param  ERROR_SUBCODE_ASSERT_FAILED         NA_ASSERT() or NA_INSIST() failed
 * @param  ERROR_POWERSAVE_SEMAPHORE           Error accessing power save semaphore
 * @param  ERROR_MMU_MISALIGNED_REGION         Region in mmuTable is not aligned on a page boundary
 * @param  ERROR_MMU_INVALID_PAGE_SIZE         Region in mmuTable has an invalid page size
 * @param  ERROR_MMU_REGIONS_OVERLAP           A region in mmuTable overlaps at least one other address range
 * @param  ERROR_MMU_OUT_OF_RESOURCES          Unable to construct MMU table because malloc() failed
 * @param  ERROR_MMU_TABLE_OVERFLOW            The .ttb region specified in the linker script is too small
 * @param  ERROR_MMU_MISALIGNED_TABLE          The .ttb region specified in the linker script is not aligned on a 16K boundary
 * @param  ERROR_TIMER_BAD_SEMAPHORE           Unable to get or set the timer driver semaphore.
 * @param  ERROR_TIMER_CANT_CREATE_SEMAPHORE   Unable to create the timer driver semaphore.
 * @param  ERROR_TIMER_NAWAIT_TIMER_UNAVAIL    NAWAIT_TIMER was not available.
 * @param  ERROR_TIMER_NAWAIT_TIMER_CONFIG     Unable to configure NAWAIT_TIMER.
 * @param  ERROR_TIMER_INTERNAL_DRIVER_ERROR   Size field of configuration was set to an invalid value.
 * @param  ERROR_PARALLEL_ILLEGAL_MODE         Attempt to set port into an unsupported mode.
 * @param  ERROR_MII_INTERRUPT_NOT_SUPPORTED   Attempt to enable interrupts on a PHY that does not support them.
 * @param  ERROR_PHY_TYPE_NOT_SUPPORTED        Could not Identify PHY.
 * @param  ERROR_IRQ_NESTED_IRQ_OVERFLOW       Too many nested IRQ interrupts have occurred.
 * @param  ERROR_GPIO_ERROR_CONFIGURING        Invalid GPIO MUX configuration setting.
 * @param  ERROR_GPIO_NOT_SUPPORTED            This function is not supported on this pin.
 * @param  ERROR_CANT_CREATE_SEMAPHORE         Can't create the semaphore.
 * @param  ERROR_GETTING_SEMAPHORE             Can't get the semaphore.
 * @param  ERROR_RELEASING_SEMAPHORE           Error releasing the semaphore.
 * @param  ERROR_SDIO_INITIALIZATION           Error initializing SDIO driver.
 * @param  ERROR_SDIO_SEMAPHORE                Error accessing semaphore.
 * @param  ERROR_CAN_INITIALIZATION            Error initializing CAN driver.
 * @param  ERROR_CAN_SEMAPHORE                 Error accessing CAN semaphore.
 *
 * @see @link customizeErrorHandler
*ad*/
#define ERROR_NO_SUBCODE                	0
#define ERROR_CANT_CREATE_EVENT_FLAG        1
#define ERROR_ETHERNET_SEMAPHORE            1
#define ERROR_PPP_UNABLE_TO_ADD_DEVICE      1
#define ERROR_FILEIO_SEMAPHORE              1
#define ERROR_SUBCODE_INVALID_INTERRUPT     1	/* subcode for ERROR_IRQ_TABLE */
#define ERROR_SUBCODE_TCPIP_HEAP            1   /* subcode for network heap */      
#define ERROR_SUBCODE_DUPLICATE_IRQ_ENTRY   2
#define ERROR_SUBCODE_AT_TABLE				1	/* subcode for ERROR_SNMP_MIB & ERROR_SNMP_MIB1213 */
#define ERROR_SUBCODE_EGP_TABLE				2
#define ERROR_SUBCODE_IF_TABLE				3
#define ERROR_SUBCODE_IPADDR_TABLE			4
#define ERROR_SUBCODE_IPROUTE_TABLE			5
#define ERROR_SUBCODE_IPMEDIA_TABLE			6
#define ERROR_SUBCODE_SYSOR_TABLE			7
#define ERROR_SUBCODE_TCPCONN_TABLE			8
#define ERROR_SUBCODE_UPD_TABLE				9
#define ERROR_SUBCODE_NO_RAM                1	/* subcode for ERROR_RAM_FAILURE */
#define ERROR_SUBCODE_FAILED_RAM_TEST       2
#define ERROR_SUBCODE_INSUFFICIENT_RAM      3
#define ERROR_SUBCODE_BAD_ACE_CONFIG        1	/* subcode for ERROR_ACE_FAILURE */
#define ERROR_ACE_FAILED                    2
#define ERROR_SUBCODE_COUNTER				1	/* subcode for ERROR_MAMAPI */
#define ERROR_SUBCODE_FREE_VARIABLE			2
#define ERROR_SUBCODE_FREE_ROW				3
#define ERROR_SUBCODE_ALLOC_ROW				4
#define ERROR_SUBCODE_COPY_ROW				5
#define ERROR_SUBCODE_ASSERT_FAILED         6
#define ERROR_POWERSAVE_SEMAPHORE           1
#define ERROR_MMU_MISALIGNED_REGION         1
#define ERROR_MMU_INVALID_PAGE_SIZE         2
#define ERROR_MMU_REGIONS_OVERLAP           3
#define ERROR_MMU_OUT_OF_RESOURCES          4
#define ERROR_MMU_TABLE_OVERFLOW            5
#define ERROR_MMU_MISALIGNED_TABLE          6
#define ERROR_TIMER_BAD_SEMAPHORE           1
#define ERROR_TIMER_CANT_CREATE_SEMAPHORE   2
#define ERROR_TIMER_NAWAIT_TIMER_UNAVAIL    3
#define ERROR_TIMER_NAWAIT_TIMER_CONFIG     4
#define ERROR_TIMER_INTERNAL_DRIVER_ERROR   5
#define ERROR_PARALLEL_ILLEGAL_MODE         1
#define ERROR_MII_INTERRUPT_NOT_SUPPORTED   1
#define ERROR_PHY_TYPE_NOT_SUPPORTED        2
#define ERROR_IRQ_NESTED_IRQ_OVERFLOW       3
#define ERROR_GPIO_ERROR_CONFIGURING        1
#define ERROR_GPIO_NOT_SUPPORTED            2
#define ERROR_CANT_CREATE_SEMAPHORE         1
#define ERROR_GETTING_SEMAPHORE             2
#define ERROR_RELEASING_SEMAPHORE           3
#define ERROR_SDIO_INITIALIZATION           4
#define ERROR_SDIO_SEMAPHORE                5
#define ERROR_CAN_INITIALIZATION            4
#define ERROR_CAN_SEMAPHORE                 5



void customizeErrorHandler(int errorCode, int subcode);

                                                      

/*************************************************
*************************************************/

#ifdef __cplusplus
}
#endif

#endif


