Home | History | Annotate | Download | only in inc
      1 /*
      2  * Copyright (c) 2010, Texas Instruments Incorporated
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  *
      9  * *  Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  *
     12  * *  Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * *  Neither the name of Texas Instruments Incorporated nor the names of
     17  *    its contributors may be used to endorse or promote products derived
     18  *    from this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 /*
     34 *  @file timm_timm_osal_error.h
     35 *  The osal header file defines the error codes
     36 *  @path
     37 *
     38 */
     39 /* -------------------------------------------------------------------------- */
     40 /* =========================================================================
     41  *!
     42  *! Revision History
     43  *! ===================================
     44  *! 0.1: Created the first draft version, ksrini (at) ti.com
     45  * ========================================================================= */
     46 
     47 #ifndef _TIMM_OSAL_ERROR_H_
     48 #define _TIMM_OSAL_ERROR_H_
     49 
     50 #ifdef __cplusplus
     51 extern "C"
     52 {
     53 #endif				/* __cplusplus */
     54 
     55 #include "timm_osal_types.h"
     56 
     57 /** A unique ID for each component*/
     58 	typedef TIMM_OSAL_U16 TIMM_OSAL_COMPID;
     59 
     60 /** TIMM_OSAL_ERROR is a 32 bits unsigned integer.
     61  *   Each error code can be broken up into three fields as given below:
     62  * - Type of error (2 bits): NO_ERROR: 00, WARNING: 01, FATAL_ERROR: 10
     63  * - Component ID (14 bits): A unique ID which indicates which of the component generated the error
     64  * - Error ID (16 bits): The specific error generated by a component
     65  */
     66 	typedef TIMM_OSAL_U32 TIMM_OSAL_ERRORTYPE;
     67 
     68 #define TIMM_OSAL_OK  0
     69 #define TIMM_OSAL_WAR 1
     70 #define TIMM_OSAL_ERR 2
     71 
     72 
     73 /* Macro to process TIMM_OSAL_ERROR */
     74 
     75 /** This macro tests if the provided M4OSA_ERR is a warning or not*/
     76 #define TIMM_OSAL_IS_WARNING(error)   ((((error)>>30) == TIMM_OSAL_WAR) ? 1:0)
     77 
     78 /** This macro tests if the provided M4OSA_ERR is a fatal error or not*/
     79 #define TIMM_OSAL_IS_ERROR(error)   ((((error)>>30) == TIMM_OSAL_ERR) ? 1:0)
     80 
     81 /** This macro returns an error code accroding to the 3 provided fields:
     82   * @arg Type: (IN) [TIMM_OSAL_U32] Type of error to put in the error code
     83   * @arg compID: (IN) [TIMM_OSAL_U32] CompID to put in the error code
     84   * @arg errorID: (IN) [TIMM_OSAL_U32] ErrorID to put in the error code*/
     85 #define TIMM_OSAL_ERR_CREATE(type, compID, errorID)\
     86    (((type)<<30)+(((compID)&0x003FFF)<<16)+((errorID)&0x00FFFF))
     87 
     88 /** This macro extracts the 3 fields from the error:
     89   * @arg error: (IN) [TIMM_OSAL_ERRORTYPE] Error code
     90   * @arg type: (OUT) [TIMM_OSAL_U32] Type of error in the error code
     91   * @arg compID: (OUT) [TIMM_OSAL_U32] CompID to put in the error code
     92   * @arg errorID: (OUT) [TIMM_OSAL_U32] ErrorID to put in the error code*/
     93 #define TIMM_OSAL_ERR_SPLIT(error, type, compID, errorID)\
     94    { type=(TIMM_OSAL_U32)((error)>>30);\
     95      compID=(TIMM_OSAL_U32)(((error)>>16)&0x003FFF);\
     96      (TIMM_OSAL_U32)(errorID=(error)&0x00FFFF); }
     97 
     98 /* Component IDs */
     99 #define TIMM_OSAL_COMP_GENERAL      0x00
    100 #define TIMM_OSAL_COMP_MEMORY       0x01
    101 #define TIMM_OSAL_COMP_PIPES        0x02
    102 #define TIMM_OSAL_COMP_EVENTS       0x03
    103 #define TIMM_OSAL_COMP_SEMAPHORES   0x04
    104 #define TIMM_OSAL_COMP_TASK         0x05
    105 
    106 /* Definition of common error codes */
    107 /** there is no error*/
    108 #define TIMM_OSAL_ERR_NONE                 ((TIMM_OSAL_ERRORTYPE) 0x00000000)
    109 
    110 
    111 /** There is no more memory available*/
    112 #define TIMM_OSAL_ERR_ALLOC                ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000001))
    113 #define TIMM_OSAL_ERR_OUT_OF_RESOURCE      ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000002))
    114 
    115 /** Time out */
    116 #define TIMM_OSAL_WAR_TIMEOUT              ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_WAR,TIMM_OSAL_COMP_GENERAL,0x000003))
    117 #define TIMM_OSAL_ERR_PARAMETER            ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000004))
    118 #define TIMM_OSAL_ERR_NOT_READY            ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000005))
    119 #define TIMM_OSAL_ERR_OMX                  ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000006))
    120 #define TIMM_OSAL_ERR_PIPE_FULL            ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000007))
    121 #define TIMM_OSAL_ERR_PIPE_EMPTY           ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000008))
    122 #define TIMM_OSAL_ERR_PIPE_DELETED         ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000009))
    123 #define TIMM_OSAL_ERR_PIPE_RESET           ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000A))
    124 #define TIMM_OSAL_ERR_GROUP_DELETED        ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000B))
    125 #define TIMM_OSAL_ERR_UNKNOWN              ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000C))
    126 
    127 
    128 #define TIMM_OSAL_ERR_SEM_CREATE_FAILED    ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_SEMAPHORE,0x000001))
    129 
    130 /*Added during Linux Porting*/
    131 #define TIMM_OSAL_ERR_NO_PERMISSIONS		((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000D))
    132 #define TIMM_OSAL_ERR_RESOURCE_EXISTS		((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000E))
    133 #define TIMM_OSAL_ERR_RESOURCE_REMOVED		((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000F))
    134 #define TIMM_OSAL_ERR_SYSTEM_LIMIT_EXCEEDED	((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000010))
    135 #define TIMM_OSAL_ERR_NOT_SUPPORTED		((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000011))
    136 #define TIMM_OSAL_ERR_SIGNAL_CAUGHT		((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000012))
    137 #define TIMM_OSAL_ERR_TIMEOUT              ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000013))
    138 
    139 
    140 
    141 #define TIMM_OSAL_COMP_MSG_Q        0x06
    142 #define TIMM_OSAL_ERR_MSG_SIZE_MISMATCH		((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_MSG_Q,0x000001))
    143 #define TIMM_OSAL_ERR_MSG_TYPE_NOT_FOUND	((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_MSG_Q,0x000002))
    144 
    145 
    146 /*
    147 #define GOTO_EXIT_IF(_Cond,_ErrorCode) { \
    148     if ((_Cond)) { \
    149         status = _ErrorCode; \
    150         printf ("Error :: %s : %s : %d :: Exiting because : %s\n", \
    151                 __FILE__, __FUNCTION__, __LINE__, #_Cond); \
    152         goto EXIT; \
    153     } \
    154 }
    155 */
    156 
    157 #define SWITCH_CASE(_Case, _ErrCode, _ErrMsg)\
    158 	case _Case:\
    159 		TIMM_OSAL_Error(_ErrMsg);\
    160 		bReturnStatus = _ErrCode;\
    161 		break;
    162 
    163 #define SWITCH_DEFAULT_CASE(_ErrCode, _ErrMsg )\
    164 	default:\
    165 		TIMM_OSAL_Error(_ErrMsg);\
    166 		bReturnStatus = _ErrCode;\
    167 		break;
    168 
    169 
    170 
    171 #ifdef __cplusplus
    172 }
    173 #endif				/* __cplusplus */
    174 
    175 #endif /*_TIMM_OSAL_ERROR_H_*/
    176