xref: /freebsd/sys/contrib/ncsw/etc/error.c (revision c2c014f24c10f90d85126ac5fbd4d8524de32b1c)
1*852ba100SJustin Hibbits /*
2*852ba100SJustin Hibbits  * Copyright 2008-2012 Freescale Semiconductor Inc.
30aeed3e9SJustin Hibbits  *
40aeed3e9SJustin Hibbits  * Redistribution and use in source and binary forms, with or without
50aeed3e9SJustin Hibbits  * modification, are permitted provided that the following conditions are met:
60aeed3e9SJustin Hibbits  *     * Redistributions of source code must retain the above copyright
70aeed3e9SJustin Hibbits  *       notice, this list of conditions and the following disclaimer.
80aeed3e9SJustin Hibbits  *     * Redistributions in binary form must reproduce the above copyright
90aeed3e9SJustin Hibbits  *       notice, this list of conditions and the following disclaimer in the
100aeed3e9SJustin Hibbits  *       documentation and/or other materials provided with the distribution.
110aeed3e9SJustin Hibbits  *     * Neither the name of Freescale Semiconductor nor the
120aeed3e9SJustin Hibbits  *       names of its contributors may be used to endorse or promote products
130aeed3e9SJustin Hibbits  *       derived from this software without specific prior written permission.
140aeed3e9SJustin Hibbits  *
150aeed3e9SJustin Hibbits  *
160aeed3e9SJustin Hibbits  * ALTERNATIVELY, this software may be distributed under the terms of the
170aeed3e9SJustin Hibbits  * GNU General Public License ("GPL") as published by the Free Software
180aeed3e9SJustin Hibbits  * Foundation, either version 2 of that License or (at your option) any
190aeed3e9SJustin Hibbits  * later version.
200aeed3e9SJustin Hibbits  *
210aeed3e9SJustin Hibbits  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
220aeed3e9SJustin Hibbits  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
230aeed3e9SJustin Hibbits  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
240aeed3e9SJustin Hibbits  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
250aeed3e9SJustin Hibbits  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
260aeed3e9SJustin Hibbits  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
270aeed3e9SJustin Hibbits  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
280aeed3e9SJustin Hibbits  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
290aeed3e9SJustin Hibbits  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
300aeed3e9SJustin Hibbits  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
310aeed3e9SJustin Hibbits  */
320aeed3e9SJustin Hibbits 
33*852ba100SJustin Hibbits 
340aeed3e9SJustin Hibbits /*
350aeed3e9SJustin Hibbits 
360aeed3e9SJustin Hibbits  @File          error.c
370aeed3e9SJustin Hibbits 
380aeed3e9SJustin Hibbits  @Description   General errors and events reporting utilities.
390aeed3e9SJustin Hibbits *//***************************************************************************/
400aeed3e9SJustin Hibbits #if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
41*852ba100SJustin Hibbits #include "error_ext.h"
42*852ba100SJustin Hibbits 
430aeed3e9SJustin Hibbits 
440aeed3e9SJustin Hibbits const char *dbgLevelStrings[] =
450aeed3e9SJustin Hibbits {
460aeed3e9SJustin Hibbits      "CRITICAL"
470aeed3e9SJustin Hibbits     ,"MAJOR"
480aeed3e9SJustin Hibbits     ,"MINOR"
490aeed3e9SJustin Hibbits     ,"WARNING"
500aeed3e9SJustin Hibbits     ,"INFO"
510aeed3e9SJustin Hibbits     ,"TRACE"
520aeed3e9SJustin Hibbits };
530aeed3e9SJustin Hibbits 
54*852ba100SJustin Hibbits 
ErrTypeStrings(e_ErrorType err)55*852ba100SJustin Hibbits char * ErrTypeStrings (e_ErrorType err)
560aeed3e9SJustin Hibbits {
57*852ba100SJustin Hibbits     switch (err)
580aeed3e9SJustin Hibbits     {
59*852ba100SJustin Hibbits         case (E_OK):                    return "OK";
60*852ba100SJustin Hibbits         case (E_WRITE_FAILED):          return "Write Access Failed";
61*852ba100SJustin Hibbits         case (E_NO_DEVICE):             return "No Device";
62*852ba100SJustin Hibbits         case (E_NOT_AVAILABLE):         return "Resource Is Unavailable";
63*852ba100SJustin Hibbits         case (E_NO_MEMORY):             return "Memory Allocation Failed";
64*852ba100SJustin Hibbits         case (E_INVALID_ADDRESS):       return "Invalid Address";
65*852ba100SJustin Hibbits         case (E_BUSY):                  return "Resource Is Busy";
66*852ba100SJustin Hibbits         case (E_ALREADY_EXISTS):        return "Resource Already Exists";
67*852ba100SJustin Hibbits         case (E_INVALID_OPERATION):     return "Invalid Operation";
68*852ba100SJustin Hibbits         case (E_INVALID_VALUE):         return "Invalid Value";
69*852ba100SJustin Hibbits         case (E_NOT_IN_RANGE):          return "Value Out Of Range";
70*852ba100SJustin Hibbits         case (E_NOT_SUPPORTED):         return "Unsupported Operation";
71*852ba100SJustin Hibbits         case (E_INVALID_STATE):         return "Invalid State";
72*852ba100SJustin Hibbits         case (E_INVALID_HANDLE):        return "Invalid Handle";
73*852ba100SJustin Hibbits         case (E_INVALID_ID):            return "Invalid ID";
74*852ba100SJustin Hibbits         case (E_NULL_POINTER):          return "Unexpected NULL Pointer";
75*852ba100SJustin Hibbits         case (E_INVALID_SELECTION):     return "Invalid Selection";
76*852ba100SJustin Hibbits         case (E_INVALID_COMM_MODE):     return "Invalid Communication Mode";
77*852ba100SJustin Hibbits         case (E_INVALID_MEMORY_TYPE):   return "Invalid Memory Type";
78*852ba100SJustin Hibbits         case (E_INVALID_CLOCK):         return "Invalid Clock";
79*852ba100SJustin Hibbits         case (E_CONFLICT):              return "Conflict In Settings";
80*852ba100SJustin Hibbits         case (E_NOT_ALIGNED):           return "Incorrect Alignment";
81*852ba100SJustin Hibbits         case (E_NOT_FOUND):             return "Resource Not Found";
82*852ba100SJustin Hibbits         case (E_FULL):                  return "Resource Is Full";
83*852ba100SJustin Hibbits         case (E_EMPTY):                 return "Resource Is Empty";
84*852ba100SJustin Hibbits         case (E_ALREADY_FREE):          return "Resource Already Free";
85*852ba100SJustin Hibbits         case (E_READ_FAILED):           return "Read Access Failed";
86*852ba100SJustin Hibbits         case (E_INVALID_FRAME):         return "Invalid Frame";
87*852ba100SJustin Hibbits         case (E_SEND_FAILED):           return "Send Operation Failed";
88*852ba100SJustin Hibbits         case (E_RECEIVE_FAILED):        return "Receive Operation Failed";
89*852ba100SJustin Hibbits         case (E_TIMEOUT):               return "Operation Timed Out";
90*852ba100SJustin Hibbits         default:
91*852ba100SJustin Hibbits             break;
92*852ba100SJustin Hibbits     }
93*852ba100SJustin Hibbits     return NULL;
94*852ba100SJustin Hibbits }
950aeed3e9SJustin Hibbits #endif /* (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) */
96