1 /*
2 * The components of this software package from Cadence Design Systems,
3 * Inc. are subject to the licenses below. By using the software package,
4 * you agree to the legal terms of each license.
5 *
6 * Copyright (c) 1999-2018 Cadence Design Systems, Inc.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 */
27 
28 #ifndef __XA_ERROR_STANDARDS_H__
29 #define __XA_ERROR_STANDARDS_H__
30 
31 /*****************************************************************************/
32 /* File includes                                                             */
33 /*  xa_type_def.h                                                            */
34 /*****************************************************************************/
35 
36 /*****************************************************************************/
37 /* Constant hash defines                                                     */
38 /*****************************************************************************/
39 #define XA_NO_ERROR	0
40 #define XA_FATAL_ERROR	0x80000000
41 
42 enum xa_error_severity {
43   xa_severity_nonfatal = 0,
44   xa_severity_fatal    = (int)0xffffffff
45 };
46 
47 enum xa_error_class {
48   xa_class_api     = 0,
49   xa_class_config  = 1,
50   xa_class_execute = 2
51 };
52 
53 #define XA_CODEC_GENERIC	0
54 
55 #define XA_ERROR_CODE(severity, class, codec, index)	((severity << 15) | (class << 11) | (codec << 6) | index)
56 #define XA_ERROR_SEVERITY(code)	(((code) & XA_FATAL_ERROR) != 0)
57 #define XA_ERROR_CLASS(code)	(((code) >> 11) & 0x0f)
58 #define XA_ERROR_CODEC(code)    (((code) >>  6) & 0x1f)
59 #define XA_ERROR_SUBCODE(code)	(((code) >>  0) & 0x3f)
60 
61 /* Our convention is that only api-class errors can be generic ones. */
62 
63 /*****************************************************************************/
64 /* Class 0: API Errors                                                       */
65 /*****************************************************************************/
66 /* Non Fatal Errors */
67 /* (none) */
68 /* Fatal Errors */
69 enum xa_error_fatal_api_generic {
70   XA_API_FATAL_MEM_ALLOC        = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 0),
71   XA_API_FATAL_MEM_ALIGN        = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 1),
72   XA_API_FATAL_INVALID_CMD      = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 2),
73   XA_API_FATAL_INVALID_CMD_TYPE = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 3)
74 };
75 
76 #endif /* __XA_ERROR_STANDARDS_H__ */
77