Developer World
Spresense SDK Library
v3.2.0-ebc0364
common_errcode.h
1
/****************************************************************************
2
* modules/include/memutils/common_utils/common_errcode.h
3
*
4
* Copyright 2018 Sony Semiconductor Solutions Corporation
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
8
* are met:
9
*
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in
14
* the documentation and/or other materials provided with the
15
* distribution.
16
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17
* the names of its contributors may be used to endorse or promote
18
* products derived from this software without specific prior written
19
* permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
* POSSIBILITY OF SUCH DAMAGE.
33
*
34
****************************************************************************/
35
36
#ifndef __SONY_APPS_INCLUDE_MEMUTILS_COMMON_ERRCODE_H
37
#define __SONY_APPS_INCLUDE_MEMUTILS_COMMON_ERRCODE_H
38
39
typedef
unsigned
int
err_t;
40
41
/***********************************************************************
42
*
43
* [type]
44
*
45
* D31 D30 D29 D28 D27 D26 D25 D24 D23 D22 D21 D20 D19 D18 D17 D16
46
* +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
47
* |REQ | ERR LEVEL | ERR Code | ERR SCode_S |ERR SCode_E/SubCode|
48
* +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
49
*
50
* D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
51
* +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
52
* | ALL 0 |
53
* +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
54
*
55
* D31: MSG_TYPE_REQUEST
56
* 0x0: OK
57
* 0x1: NG
58
*
59
* D30-D28: ERR LEVEL
60
* 0x0:NoError
61
* 0x1:Exception
62
* 0x2:Fatal
63
* 0x3:Error
64
* 0x4:Warning
65
* 0x5:Information
66
*
67
* D27-D24: ERR Code
68
* 0x1:Resource
69
* 0x2:Reference
70
* 0x3:OS
71
* 0x4:Data
72
* 0x5:Address
73
* 0x6:Event
74
* 0x7:Device
75
* 0x8:Timeout
76
* 0xf:Others
77
*
78
* D23-D20: ERR SCode_S(System Call)
79
* 0x0:Memory/SEM
80
* 0x1:Que/MPF
81
* 0x2:Stk/MTX
82
* 0x3:PQue/DTQ
83
*
84
* D19-D16: ERR SCode_E(Event)
85
* 0x0:Create
86
* 0x1:Full/Read/Give/Send/Lock
87
* 0x2:Empty/Free/Take/Recv/UnLk
88
* 0x3:Big
89
* 0x4:Small
90
*
91
* D19-D16:ERR SubCode
92
* 0x0:Data Value
93
* 0x1:Data Size
94
**********************************************************************
95
*/
96
97
/***********************************************************************
98
* Defintions
99
***********************************************************************
100
*/
101
#define ERR_OK 0x00000000
102
#define ERR_NG 0x80000000
103
104
/*---------------------------------------------------------------------
105
* Error Level
106
* 0:NoError
107
* 1:Exception
108
* 2:Fatal
109
* 3:Error
110
* 4:Warning
111
* 5:Information
112
* ---------------------------------------------------------------------
113
*/
114
#define ERR_LV_NOERR 0
115
#define ERR_LV_EXC 1
116
#define ERR_LV_FATAL 2
117
#define ERR_LV_ERR 3
118
#define ERR_LV_WARNING 4
119
#define ERR_LV_INFO 5
120
121
/*---------------------------------------------------------------------
122
* Error Code (Category)
123
* 0x1:Resource
124
* 0x2:Reference
125
* 0x3:OS
126
* 0x4:Data
127
* 0x5:Address
128
* 0x6:Event
129
* 0x7:Device
130
* 0x8:Timeout
131
* 0xf:Others
132
* ---------------------------------------------------------------------
133
*/
134
#define ERR_CODE_RES 0x1
135
#define ERR_CODE_REF 0x2
136
#define ERR_CODE_OS 0x3
137
#define ERR_CODE_DATA 0x4
138
#define ERR_CODE_ADR 0x5
139
#define ERR_CODE_EVT 0x6
140
#define ERR_CODE_DEV 0x7
141
#define ERR_CODE_TOUT 0x8
142
#define ERR_CODE_OTHR 0xf
143
144
/*---------------------------------------------------------------------
145
* Error SubCode System Call
146
* 0x00:Memory/SEM
147
* 0x01:Que/MPF
148
* 0x02:Stk/MTX
149
* 0x03:PQue/DTQ
150
* ---------------------------------------------------------------------
151
*/
152
#define ERR_SCAL_MEM 0x00
153
#define ERR_SCAL_QUE 0x01
154
#define ERR_SCAL_STK 0x02
155
#define ERR_SCAL_PQUE 0x03
156
157
#define ERR_SCAL_SEM 0x00
158
#define ERR_SCAL_MPF 0x01
159
#define ERR_SCAL_MTX 0x02
160
#define ERR_SCAL_DTQ 0x03
161
162
#define ERR_SCAL_INPUT 0x00
/* For Adr */
163
#define ERR_SCAL_OUTPUT 0x01
/* For Adr */
164
165
#define ERR_SCAL_EER 0x00
/* For Dev */
166
#define ERR_SCAL_NRDY 0x01
/* For Dev */
167
168
/*---------------------------------------------------------------------
169
* Error SubCode Error Event
170
* 0x00:Create
171
* 0x01:Full/Read/Give/Send/Lock
172
* 0x02:Empty/Free/Take/Recv/UnLk
173
* 0x03:Big
174
* 0x04:Small
175
* 0x05:Busy
176
* ---------------------------------------------------------------------
177
*/
178
#define ERR_EVT_FULL 0x01
179
#define ERR_EVT_EMP 0x02
180
#define ERR_EVT_BIG 0x03
181
#define ERR_EVT_SMALL 0x04
182
#define ERR_EVT_BUSY 0x05
183
184
#define ERR_EVT_READ 0x01
185
#define ERR_EVT_FREE 0x02
186
187
#define ERR_EVT_CRE 0x00
188
189
#define ERR_EVT_GIVE 0x01
190
#define ERR_EVT_TAKE 0x02
191
192
#define ERR_EVT_SEND 0x01
193
#define ERR_EVT_RECV 0x02
194
195
#define ERR_EVT_LOCK 0x01
196
#define ERR_EVT_UNLK 0x02
197
198
#define ERR_EVT_GET 0x01
199
#define ERR_EVT_RELEASE 0x02
200
201
#define ERR_EVT_ERR 0x00
/* For Dev */
202
203
/*---------------------------------------------------------------------
204
* Error SubCode
205
* 0x00:Data Value
206
* 0x01:Data Size
207
* ---------------------------------------------------------------------
208
*/
209
#define ERR_SCODE_VAL 0x0000
210
#define ERR_SCODE_SIZE 0x0001
211
212
/***********************************************************************
213
* Integrated Definitions
214
***********************************************************************
215
*/
216
/*** Resource ***/
217
#define ERR_MEM_FULL (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_RES << CODE_NUM) | \
218
(ERR_SCAL_MEM < SCAL_NUM) | (ERR_EVT_FULL << EVT_NUM) )
219
#define ERR_MEM_EMPTY (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_RES << CODE_NUM) | \
220
(ERR_SCAL_MEM < SCAL_NUM) | (ERR_EVT_EMP << EVT_NUM) )
221
#define ERR_MEM_BIG (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_RES << CODE_NUM) | \
222
(ERR_SCAL_MEM < SCAL_NUM) | (ERR_EVT_BIG << EVT_NUM) )
223
#define ERR_MEM_SMALL (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_RES << CODE_NUM) | \
224
(ERR_SCAL_MEM < SCAL_NUM) | (ERR_EVT_SMALL << EVT_NUM) )
225
#define ERR_MEM_BUSY (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_RES << CODE_NUM) | \
226
(ERR_SCAL_MEM < SCAL_NUM) | (ERR_EVT_BUSY << EVT_NUM) )
227
228
#define ERR_QUE_FULL (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_RES << CODE_NUM) | \
229
(ERR_SCAL_QUE << SCAL_NUM) | (ERR_EVT_FULL << EVT_NUM) )
230
#define ERR_QUE_EMP (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_RES<<CODE_NUM) | \
231
(ERR_SCAL_QUE << SCAL_NUM) | (ERR_EVT_EMP << EVT_NUM) )
232
233
#define ERR_STK_FULL (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_RES << CODE_NUM) | \
234
(ERR_SCAL_STK << SCAL_NUM) | (ERR_EVT_FULL << EVT_NUM) )
235
#define ERR_STK_EMP (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_RES << CODE_NUM) | \
236
(ERR_SCAL_STK << SCAL_NUM) | (ERR_EVT_EMP << EVT_NUM) )
237
238
#define ERR_PQUE_FULL (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_RES << CODE_NUM) | \
239
(ERR_SCAL_PQUE << SCAL_NUM) | (ERR_EVT_FULL << EVT_NUM) )
240
#define ERR_PQUE_EMP (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_RES << CODE_NUM) | \
241
(ERR_SCAL_PQUE << SCAL_NUM) | (ERR_EVT_EMP << EVT_NUM) )
242
243
/*** Reference ***/
244
#define ERR_MEM_READ (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_REF << CODE_NUM) | \
245
(ERR_SCAL_MEM << SCAL_NUM) | (ERR_EVT_READ << EVT_NUM) )
246
#define ERR_MEM_FREE (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_REF << CODE_NUM) | \
247
(ERR_SCAL_MEM << SCAL_NUM) | (ERR_EVT_FREE << EVT_NUM) )
248
249
#define ERR_QUE_READ (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_REF << CODE_NUM) | \
250
(ERR_SCAL_QUE << SCAL_NUM) | (ERR_EVT_READ << EVT_NUM) )
251
#define ERR_QUE_FREE (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_REF << CODE_NUM) | \
252
(ERR_SCAL_QUE << SCAL_NUM) | (ERR_EVT_FREE << EVT_NUM) )
253
254
/*** OS ***/
255
#define ERR_SEM_CRE (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
256
(ERR_SCAL_SEM << SCAL_NUM) | (ERR_EVT_CRE << EVT_NUM) )
257
#define ERR_SEM_GIVE (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
258
(ERR_SCAL_SEM << SCAL_NUM) | (ERR_EVT_GIVE << EVT_NUM) )
259
#define ERR_SEM_TAKE (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
260
(ERR_SCAL_SEM << SCAL_NUM) | (ERR_EVT_TAKE << EVT_NUM) )
261
262
#define ERR_MPF_CRE (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
263
(ERR_SCAL_MPF << SCAL_NUM) | (ERR_EVT_CRE << EVT_NUM) )
264
#define ERR_MPF_GET (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
265
(ERR_SCAL_MPF << SCAL_NUM) | (ERR_EVT_GET << EVT_NUM) )
266
#define ERR_MPF_RELEASE (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
267
(ERR_SCAL_MPF << SCAL_NUM) | (ERR_EVT_RELEASE << EVT_NUM) )
268
269
#define ERR_MTX_CRE (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
270
(ERR_SCAL_MTX << SCAL_NUM) | (ERR_EVT_CRE << EVT_NUM) )
271
#define ERR_MTX_LOCK (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
272
(ERR_SCAL_MTX << SCAL_NUM) | (ERR_EVT_LOCK << EVT_NUM) )
273
#define ERR_MTX_UNLK (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
274
(ERR_SCAL_MTX << SCAL_NUM) | (ERR_EVT_UNLK << EVT_NUM) )
275
276
#define ERR_DTQ_CRE (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
277
(ERR_SCAL_DTQ << SCAL_NUM) | (ERR_EVT_CRE << EVT_NUM) )
278
#define ERR_DTQ_SEND (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
279
(ERR_SCAL_DTQ << SCAL_NUM) | (ERR_EVT_SEND << EVT_NUM) )
280
#define ERR_DTQ_RECV (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_OS << CODE_NUM) | \
281
(ERR_SCAL_DTQ << SCAL_NUM) | (ERR_EVT_RECV << EVT_NUM) )
282
283
/*** Data ***/
284
#define ERR_DATA (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_DATA << CODE_NUM) )
285
#define ERR_DATA_VAL (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_DATA << CODE_NUM) | \
286
(ERR_SCODE_VAL << SCODE_NUM) )
287
#define ERR_DATA_SIZE (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_DATA << CODE_NUM) | \
288
(ERR_SCODE_SIZE << SCODE_NUM) )
289
290
/*** Address ***/
291
#define ERR_ADR_INPUT (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_ADR << CODE_NUM) | \
292
(ERR_SCAL_INPUT << SCAL_NUM) )
293
#define ERR_ADR_OUTPUT (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_ADR << CODE_NUM) | \
294
(ERR_SCAL_OUTPUT << SCAL_NUM) )
295
#define ERR_ADR_ALIGN (ERR_NG | (ERR_LV_WARNING << LV_NUM) | (ERR_CODE_ADR << CODE_NUM) | \
296
(ERR_SCAL_INPUT << SCAL_NUM) )
297
298
/*** Event ***/
299
#define ERR_EVT_ILG (ERR_NG | (ERR_LV_FATAL << LV_NUM) | (ERR_CODE_EVT << CODE_NUM) )
300
#define ERR_EVT_BAD (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_EVT << CODE_NUM) )
301
302
/*** Device ***/
303
#define ERR_DEV_EXE (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_DEV << CODE_NUM) | \
304
(ERR_SCAL_EER << SCAL_NUM) )
305
#define ERR_DEV_NRDY (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_DEV << CODE_NUM) | \
306
(ERR_SCAL_NRDY << SCAL_NUM) )
307
308
/*** Timeout ***/
309
#define ERR_TOUT (ERR_NG | (ERR_LV_ERR << LV_NUM) | (ERR_CODE_TOUT << CODE_NUM) )
310
311
/* ErrorCode Wrapper */
312
#define ERR_ARG ERR_DATA_VAL
313
#define ERR_STS ERR_EVT_BAD
314
315
/*** Other ***/
316
/***********************************************************************
317
* Macros
318
***********************************************************************
319
*/
320
#define isError(x) (x>>31)
321
#define getErrLv(x) ((x<<1)>>28)
322
#define getErrCode(x) ((x<<4)>>28)
323
#define getErrSCal(x) ((x<<8)>>28)
324
#define getErrEvt(x) ((x<<16)>>28)
325
326
#define setErrLv(x,y) ((x | (y << LV_NUM)
327
#define setErrCode(x) ((x | (y << CODE_NUM)
328
#define setErrSCal(x) ((x | (y << SCAL_NUM)
329
#define setErrEvt(x) ((x | (y << EVT_NUM)
330
331
#define LV_NUM 28
332
#define CODE_NUM 24
333
#define SCAL_NUM 20
334
#define EVT_NUM 16
335
#define SCODE_NUM 16
336
337
#endif
/* __SONY_APPS_INCLUDE_MEMUTILS_COMMON_ERRCODE_H */
spresense
sdk
modules
include
memutils
common_utils
common_errcode.h
Generated by
1.9.4