1 /*
2  * Copyright (C) 2010-2014 NXP Semiconductors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * ESE Status Values - Function Return Codes
19  */
20 
21 #ifndef PHESESTATUS_H
22 #define PHESESTATUS_H
23 
24 #include <phEseTypes.h>
25 
26 /* Internally required by PHESESTVAL. */
27 #define PHESESTSHL8 (8U)
28 /* Required by PHESESTVAL. */
29 #define PHESESTBLOWER ((ESESTATUS)(0x00FFU))
30 
31 /*
32  *  ESE Status Composition Macro
33  *
34  *  This is the macro which must be used to compose status values.
35  *
36  *  phEseCompID Component ID, as defined in phEseCompId.h .
37  *  phEseStatus Status values, as defined in phEseStatus.h .
38  *
39  *  The macro is not required for the ESESTATUS_SUCCESS value.
40  *  This is the only return value to be used directly.
41  *  For all other values it shall be used in assignment and conditional
42  *statements, e.g.:
43  *     ESESTATUS status = PHESESTVAL(phEseCompID, phEseStatus); ...
44  *     if (status == PHESESTVAL(phEseCompID, phEseStatus)) ...
45  */
46 #define PHESESTVAL(phEseCompID, phEseStatus)               \
47   (((phEseStatus) == (ESESTATUS_SUCCESS))                  \
48        ? (ESESTATUS_SUCCESS)                               \
49        : ((((ESESTATUS)(phEseStatus)) & (PHESESTBLOWER)) | \
50           (((uint16_t)(phEseCompID)) << (PHESESTSHL8))))
51 
52 /*
53  * PHESESTATUS
54  * Get grp_retval from Status Code
55  */
56 #define PHESESTATUS(phEseStatus) ((phEseStatus)&0x00FFU)
57 #define PHESECID(phEseStatus) (((phEseStatus)&0xFF00U) >> 8)
58 
59 /*
60  *  Status Codes
61  *
62  *  Generic Status codes for the ESE components. Combined with the Component ID
63  *  they build the value (status) returned by each function.
64  *  Example:
65  *      grp_comp_id "Component ID" -  e.g. 0x10, plus
66  *      status code as listed in this file - e.g. 0x03
67  *      result in a status value of 0x0003.
68  */
69 
70 /*
71  * The function indicates successful completion
72  */
73 #define ESESTATUS_SUCCESS (0x0000)
74 
75 /*
76  *  The function indicates successful completion
77  */
78 #define ESESTATUS_OK (ESESTATUS_SUCCESS)
79 
80 /*
81  * At least one parameter could not be properly interpreted
82  */
83 #define ESESTATUS_INVALID_PARAMETER (0x0001)
84 
85 /*
86  * Invalid buffer provided by application
87  *  */
88 #define ESESTATUS_INVALID_BUFFER (0x0002)
89 
90 /*
91  * The buffer provided by the caller is too small
92  */
93 #define ESESTATUS_BUFFER_TOO_SMALL (0x0003)
94 
95 /*
96  * Invalid class byte provided by application
97  *  */
98 #define ESESTATUS_INVALID_CLA (0x0004)
99 
100 /*
101  * Invalid command pdu type provided by application
102  *  */
103 #define ESESTATUS_INVALID_CPDU_TYPE (0x0005)
104 
105 /*
106  * Invalid command LE type provided by application
107  *  */
108 #define ESESTATUS_INVALID_LE_TYPE (0x0007)
109 
110 /*
111  * Device specifier/handle value is invalid for the operation
112  */
113 #define ESESTATUS_INVALID_DEVICE (0x0006)
114 
115 /*
116  * The function executed successfully but could have returned
117  * more information than space provided by the caller
118  */
119 #define ESESTATUS_MORE_FRAME (0x0008)
120 
121 /*
122  * No response from the remote device received: Time-out
123  */
124 #define ESESTATUS_LAST_FRAME (0x0009)
125 
126 /*
127  * CRC Error during data transaction with the device
128  */
129 #define ESESTATUS_CRC_ERROR (0x000A)
130 
131 /*
132  * SOF Error during data transaction with the device
133  */
134 #define ESESTATUS_SOF_ERROR (0x000B)
135 
136 /*
137  * Not enough resources Memory, Timer etc(e.g. allocation failed.)
138  */
139 #define ESESTATUS_INSUFFICIENT_RESOURCES (0x000C)
140 
141 /*
142  * A non-blocking function returns this immediately to indicate
143  * that an internal operation is in progress
144  */
145 #define ESESTATUS_PENDING (0x000D)
146 
147 /*
148  * A board communication error occurred
149  * (e.g. Configuration went wrong)
150  */
151 #define ESESTATUS_BOARD_COMMUNICATION_ERROR (0x000F)
152 
153 /*
154  * Invalid State of the particular state machine
155  */
156 #define ESESTATUS_INVALID_STATE (0x0011)
157 
158 /*
159  * This Layer is Not initialized, hence initialization required.
160  */
161 #define ESESTATUS_NOT_INITIALISED (0x0031)
162 
163 /*
164  * The Layer is already initialized, hence initialization repeated.
165  */
166 #define ESESTATUS_ALREADY_INITIALISED (0x0032)
167 
168 /*
169  * Feature not supported
170  */
171 #define ESESTATUS_FEATURE_NOT_SUPPORTED (0x0033)
172 
173 /*
174  */
175 #define ESESTATUS_PARITY_ERROR (0x0034)
176 
177 /* The Registration command has failed because the user wants to register on
178  * an element for which he is already registered
179  */
180 #define ESESTATUS_ALREADY_REGISTERED (0x0035)
181 
182 /*  Chained frame is being sent */
183 #define ESESTATUS_CHAINED_FRAME (0x0036)
184 
185 /*
186  * Single frame is sent
187  */
188 #define ESESTATUS_SINGLE_FRAME (0x0037)
189 
190 /*
191  * A DESELECT event has occurred
192  */
193 #define ESESTATUS_DESELECTED (0x0038)
194 
195 /*
196  * A RELEASE event has occurred
197  */
198 #define ESESTATUS_RELEASED (0x0039)
199 
200 /*
201  * The operation is currently not possible or not allowed
202  */
203 #define ESESTATUS_NOT_ALLOWED (0x003A)
204 
205 /*
206  *  Other indicaated error sent by JCOP.
207  */
208 #define ESESTATUS_OTHER_ERROR (0x003C)
209 /*
210  *  The system is busy with the firmware download operation.
211  */
212 #define ESESTATUS_DWNLD_BUSY (0x006E)
213 
214 /*
215  *  The system is busy with the previous operation.
216  */
217 #define ESESTATUS_BUSY (0x006F)
218 
219 /* NDEF Mapping error codes */
220 
221 /* The remote device (type) is not valid for this request. */
222 #define ESESTATUS_INVALID_REMOTE_DEVICE (0x001D)
223 
224 /* Read operation failed */
225 #define ESESTATUS_READ_FAILED (0x0014)
226 
227 /*
228  * Write operation failed
229  */
230 #define ESESTATUS_WRITE_FAILED (0x0015)
231 
232 /* Non Ndef Compliant */
233 #define ESESTATUS_NO_NDEF_SUPPORT (0x0016)
234 
235 /* resend the frame with seq_counter 0*/
236 #define ESESTATUS_RESET_SEQ_COUNTER_FRAME_RESEND (0x001A)
237 
238 /* Incorrect number of bytes received from the card*/
239 #define ESESTATUS_INVALID_RECEIVE_LENGTH (0x001B)
240 
241 /* The data format/composition is not understood/correct. */
242 #define ESESTATUS_INVALID_FORMAT (0x001C)
243 
244 /* There is not sufficient storage available. */
245 #define ESESTATUS_INSUFFICIENT_STORAGE (0x001F)
246 
247 /* The last command would be re-sent */
248 #define ESESTATUS_FRAME_RESEND (0x0023)
249 
250 /* The write timeout error */
251 #define ESESTATUS_WRITE_TIMEOUT (0x0024)
252 
253 /*
254  * Response Time out for the control message(ESEC not responded)
255  */
256 #define ESESTATUS_RESPONSE_TIMEOUT (0x0025)
257 
258 /*
259  * Resend the last R Frame
260  */
261 #define ESESTATUS_FRAME_RESEND_R_FRAME (0x0026)
262 
263 /*
264  * Send next chained frame
265  */
266 #define ESESTATUS_SEND_NEXT_FRAME (0x0027)
267 
268 /*
269  * Protocol revovery started
270  */
271 #define ESESTATUS_REVOCERY_STARTED (0x0028)
272 
273 /*
274  * Single Target Detected
275  */
276 #define ESESTATUS_SEND_R_FRAME (0x0029)
277 
278 /*
279  * Resend the  RNAK
280  */
281 
282 #define ESESTATUS_FRAME_RESEND_RNAK (0x0030)
283 
284 /*
285  * Resend the last R Frame
286  */
287 #define ESESTATUS_FRAME_SEND_R_FRAME (0x003B)
288 
289 /*
290  * Unknown error Status Codes
291  */
292 #define ESESTATUS_UNKNOWN_ERROR (0x00FE)
293 
294 /*
295  * Status code for failure
296  */
297 #define ESESTATUS_FAILED (0x00FF)
298 
299 /*
300  * The function/command has been aborted
301  */
302 #define ESESTATUS_CMD_ABORTED (0x0002)
303 
304 /*
305  * No target found after poll
306  */
307 #define ESESTATUS_NO_TARGET_FOUND (0x000A)
308 
309 /* Attempt to disconnect a not connected remote device. */
310 #define ESESTATUS_NO_DEVICE_CONNECTED (0x000B)
311 
312 /* requesting a resynchronization */
313 #define ESESTATUS_RESYNCH_REQ (0x000E)
314 
315 /*
316  * acknowledging resynchronization
317  */
318 #define ESESTATUS_RESYNCH_RES (0x0010)
319 
320 /*
321  * S-block offering a maximum size of the information field
322  */
323 #define ESESTATUS_IFS_REQ (0x001E)
324 
325 /* S-block offering a maximum size of the information field */
326 #define ESESTATUS_IFS_RES (0x0017)
327 
328 /* S-block requesting a chain abortion */
329 #define ESESTATUS_ABORT_REQ (0x00F0)
330 
331 /*S-block acknowledging the chain abortion*/
332 #define ESESTATUS_ABORT_RES (0x00F2)
333 
334 /* S-block requesting a waiting time extension*/
335 #define ESESTATUS_WTX_REQ (0x00F5)
336 
337 /* S-block acknowledging the waiting time extension */
338 #define ESESTATUS_WTX_RES (0x00F6)
339 
340 /* S-block interface reset request */
341 #define ESESTATUS_RESET_REQ (0x00F7)
342 
343 /* S-block interface reset response */
344 #define ESESTATUS_RESET_RES (0x00F8)
345 
346 /* S-block requesting a end of apdu transfer*/
347 #define ESESTATUS_END_APDU_REQ (0x00F9)
348 
349 /* S-block acknowledging end of apdu transfer*/
350 #define ESESTATUS_END_APDU_RES (0x00FA)
351 
352 /*
353  * Shutdown in progress, cannot handle the request at this time.
354  */
355 #define ESESTATUS_SHUTDOWN (0x0091)
356 
357 /*
358  * Target is no more in RF field
359  */
360 #define ESESTATUS_TARGET_LOST (0x0092)
361 
362 /*
363  * Request is rejected
364  */
365 #define ESESTATUS_REJECTED (0x0093)
366 
367 /*
368  * Target is not connected
369  */
370 #define ESESTATUS_TARGET_NOT_CONNECTED (0x0094)
371 
372 /*
373  * Invalid handle for the operation
374  */
375 #define ESESTATUS_INVALID_HANDLE (0x0095)
376 
377 /*
378  * Process aborted
379  */
380 #define ESESTATUS_ABORTED (0x0096)
381 
382 /*
383  * Requested command is not supported
384  */
385 #define ESESTATUS_COMMAND_NOT_SUPPORTED (0x0097)
386 
387 /*
388  * Tag is not NDEF compilant
389  */
390 #define ESESTATUS_NON_NDEF_COMPLIANT (0x0098)
391 
392 /*
393  * Not enough memory available to complete the requested operation
394  */
395 #define ESESTATUS_NOT_ENOUGH_MEMORY (0x001F)
396 
397 /*
398  * Indicates incoming connection
399  */
400 #define ESESTATUS_INCOMING_CONNECTION (0x0045)
401 
402 /*
403  * Indicates Connection was successful
404  */
405 #define ESESTATUS_CONNECTION_SUCCESS (0x0046)
406 
407 /*
408  * Indicates Connection failed
409  */
410 #define ESESTATUS_CONNECTION_FAILED (0x0047)
411 
412 #endif /* PHESESTATUS_H */
413