xref: /aosp_15_r20/system/nfc/src/nfc/include/tags_defs.h (revision 7eba2f3b06c51ae21384f6a4f14577b668a869b3)
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-2014 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This file contains the Near Field Communication (NFC) Tags related
22  *  definitions from the specification.
23  *
24  ******************************************************************************/
25 
26 #ifndef TAGS_DEFS_H
27 #define TAGS_DEFS_H
28 
29 /* Manufacturer ID */
30 /* BROADCOM CORPORATION                           */
31 #define TAG_BRCM_MID 0x2E
32 /* MIFARE                                         */
33 #define TAG_MIFARE_MID 0x04
34 /* KOVIO                                          */
35 #define TAG_KOVIO_MID 0x37
36 /* Infineon Technologies                          */
37 #define TAG_INFINEON_MID 0x05
38 
39 /* TLV types present in Type1 and Type 2 Tags */
40 /* May be used for padding. SHALL ignore this     */
41 #define TAG_NULL_TLV 0
42 /* Defines details of the lock bytes              */
43 #define TAG_LOCK_CTRL_TLV 1
44 /* Identifies reserved memory areas               */
45 #define TAG_MEM_CTRL_TLV 2
46 /* Contains the NDEF message                      */
47 #define TAG_NDEF_TLV 3
48 /* Tag proprietary information                    */
49 #define TAG_PROPRIETARY_TLV 0xFD
50 /* Last TLV block in the data area                */
51 #define TAG_TERMINATOR_TLV 0xFE
52 /* Number of bits in every tag byte               */
53 #define TAG_BITS_PER_BYTE 0x08
54 /* Max UID Len of type 1 and type 2 tag           */
55 #define TAG_MAX_UID_LEN 0x0A
56 
57 /* Byte 0 Length field to indicate LNDEF  */
58 #define TAG_LONG_NDEF_LEN_FIELD_BYTE0 0xFF
59 /* Tlv len for LOCK_CTRL/MEM TLV per spec */
60 #define TAG_DEFAULT_TLV_LEN 3
61 
62 /* Type 1 Tag related definitions */
63 
64 /* block 0 to Block E                             */
65 #define T1T_STATIC_BLOCKS 0x0F
66 /* T1T Block size in bytes                        */
67 #define T1T_BLOCK_SIZE 0x08
68 
69 #define T1T_STATIC_SIZE \
70   T1T_STATIC_BLOCKS* T1T_BLOCK_SIZE /* Static Tag size   */
71 
72 /* Size of Type 1 Tag segment in bytes            */
73 #define T1T_SEGMENT_SIZE 0x80
74 /* Maximum segment supported by Type 1 Tag        */
75 #define T1T_MAX_SEGMENTS 0x10
76 /* Number of blocks present in a segment          */
77 #define T1T_BLOCKS_PER_SEGMENT 0x10
78 /* No.of default OTP,staticlocks,res bytes in tag */
79 #define T1T_OTP_LOCK_RES_BYTES 0x10
80 
81 /* HRO value to indicate static Tag               */
82 #define T1T_STATIC_HR0 0x11
83 /* 0x1y, as long as (y!=1)                        */
84 /* HR0 value is 0x1y, indicates NDEF supported    */
85 #define T1T_NDEF_SUPPORTED 0x10
86 /* UID block                                      */
87 #define T1T_UID_BLOCK 0x00
88 /* Reserved block                                 */
89 #define T1T_RES_BLOCK 0x0D
90 /* Static lock block                              */
91 #define T1T_LOCK_BLOCK 0x0E
92 /* Static lock offset                             */
93 #define T1T_LOCK_0_OFFSET 0x70
94 /* Block F - typically used for dynamic locks     */
95 #define T1T_DYNAMIC_LOCK_BYTES 0x08
96 
97 /* the len of reserved byte in T1T block 0        */
98 #define T1T_RES_BYTE_LEN 1
99 
100 /* Capability Container definitions */
101 /* Capability container block                     */
102 #define T1T_CC_BLOCK 1
103 /* the len of CC used in T1T tag                  */
104 #define T1T_CC_LEN 4
105 /* CC offset */
106 /* Offset for NDEF magic number in CC             */
107 #define T1T_CC_NMN_OFFSET 0x00
108 /* Offset for Read/Write access in CC             */
109 #define T1T_CC_RWA_OFFSET 0x03
110 /* NDEF Magic Number byte number                  */
111 #define T1T_CC_NMN_BYTE 0x08
112 /* Version Number byte number                     */
113 #define T1T_CC_VNO_BYTE 0x09
114 /* Tag Memory Size byte number                    */
115 #define T1T_CC_TMS_BYTE 0x0A
116 /* Read Write Access byte number                  */
117 #define T1T_CC_RWA_BYTE 0x0B
118 /* NDEF Magic Number                              */
119 #define T1T_CC_NMN 0xE1
120 /* Supported Legacy Version                       */
121 #define T1T_CC_LEGACY_VNO 0x10
122 /* Version Number                                 */
123 #define T1T_CC_VNO 0x11
124 /* RWA - Read/write allowed                       */
125 #define T1T_CC_RWA_RW 0x00
126 /* RWA - Read only                                */
127 #define T1T_CC_RWA_RO 0x0F
128 
129 /* Tlv len for LOCK_CTRL/MEM TLV per spec         */
130 #define T1T_DEFAULT_TLV_LEN 3
131 /* Tlv type identifier len                        */
132 #define T1T_TLV_TYPE_LEN 1
133 /* Length field size of  lock/mem tlv     */
134 #define T1T_DEFAULT_TLV_LEN_FIELD_LEN 1
135 
136 /* the len of HR used in Type 1 Tag               */
137 #define T1T_HR_LEN 2
138 /* the len of UID used in Type 1 Tag Commands     */
139 #define T1T_CMD_UID_LEN 4
140 /* the len of UID used in Type 1 Tag              */
141 #define T1T_UID_LEN 7
142 #define T1T_ADD_LEN 1
143 
144 /* Length Field size of short NDEF Message    */
145 #define T1T_SHORT_NDEF_LEN_FIELD_LEN 1
146 /* Length Field size of Long NDEF Message     */
147 #define T1T_LONG_NDEF_LEN_FIELD_LEN 3
148 /* Byte 0 in Length field to indicate LNDEF*/
149 #define T1T_LONG_NDEF_LEN_FIELD_BYTE0 0xFF
150 /* Min. len of NDEF to qualify as LNDEF  */
151 
152 /* Type 1 Tag Commands (7 bits) */
153 /* read id                                      */
154 #define T1T_CMD_RID 0x78
155 /* read all bytes                               */
156 #define T1T_CMD_RALL 0x00
157 /* read (1 byte)                                */
158 #define T1T_CMD_READ 0x01
159 /* write with erase (1 byte)                    */
160 #define T1T_CMD_WRITE_E 0x53
161 /* write no erase (1 byte)                      */
162 #define T1T_CMD_WRITE_NE 0x1A
163 /* dynamic memory only */
164 /* read segment                                 */
165 #define T1T_CMD_RSEG 0x10
166 /* read (8 byte)                                */
167 #define T1T_CMD_READ8 0x02
168 /* write with erase (8 byte)                    */
169 #define T1T_CMD_WRITE_E8 0x54
170 /* write no erase (8 byte)                      */
171 #define T1T_CMD_WRITE_NE8 0x1B
172 
173 /* Lock */
174 /* Number of static lock bytes in tag   */
175 #define T1T_NUM_STATIC_LOCK_BYTES 2
176 /* Bytes locked by one static lock bit  */
177 
178 /* Type 2 Tag related definitions */
179 #define T2T_STATIC_SIZE 64
180 #define T2T_BLOCK_SIZE 4
181 #define T2T_HEADER_SIZE 16
182 #define T2T_SECTOR_SIZE 1024
183 #define T2T_BLOCKS_PER_SECTOR 0x100
184 
185 #define T2T_UID_LEN 4        /* the len of UID used in T2T tag */
186 /* the len of Serial number used in T2T tag */
187 #define T2T_INTERNAL_BYTES_LEN 2 /* the len of internal used in T2T tag */
188 /* Static Lock Bytes */
189 #define T2T_STATIC_LOCK0 0x0A /* Static Lock 0 offset */
190 #define T2T_STATIC_LOCK1 0x0B /* Static Lock 1 offset */
191 
192 /* Capability Container definitions */
193 #define T2T_CC_BLOCK 0x03     /* Capability container block */
194 #define T2T_CC0_NMN_BYTE 0x0C /* NDEF Magic Number byte number */
195 #define T2T_CC1_VNO_BYTE 0x0D /* Version Number byte number*/
196 #define T2T_CC2_TMS_BYTE 0x0E /* Tag Memory Size byte number */
197 #define T2T_CC3_RWA_BYTE 0x0F /* Read Write Access byte number */
198 
199 #define T2T_CC0_NMN 0xE1        /* NDEF Magic Number */
200 #define T2T_CC1_VNO 0x11        /* Version Number */
201 #define T2T_CC1_LEGACY_VNO 0x10 /* Legacy Version Number */
202 #define T2T_CC1_NEW_VNO 0x12    /* Another supported Version Number */
203 #define T2T_CC2_TMS_STATIC 0x06 /* TMS static memory - (4 * (n+1)). */
204 #define T2T_CC3_RWA_RW 0x00     /* RWA - Read/write allowed */
205 #define T2T_CC3_RWA_RO 0x0F     /* RWA - Read only */
206 
207 /* Factor to multiply to get tag data size from TMS */
208 #define T2T_TMS_TAG_FACTOR 0x08
209 /* Bytes locked per lock bit of default locks */
210 #define T2T_DEFAULT_LOCK_BLPB 0x08
211 
212 /* Type 2 Tag Commands  */
213 #define T2T_CMD_READ 0x30    /* read  4 blocks (16 bytes) */
214 #define T2T_CMD_WRITE 0xA2   /* write 1 block  (4 bytes)  */
215 #define T2T_CMD_SEC_SEL 0xC2 /* Sector select             */
216 #define T2T_RSP_ACK 0xA
217 
218 #define T2T_STATUS_OK_1_BIT 0x11
219 #define T2T_STATUS_OK_7_BIT 0x17
220 
221 #define T2T_FIRST_DATA_BLOCK 4
222 #define T2T_READ_BLOCKS 4
223 #define T2T_BLOCK_LEN 4
224 #define T2T_READ_DATA_LEN (T2T_BLOCK_LEN * T2T_READ_BLOCKS)
225 #define T2T_WRITE_DATA_LEN 4
226 
227 /* Type 2 TLV definitions */
228 /* May be used for padding. SHALL ignore this */
229 #define T2T_TLV_TYPE_LOCK_CTRL 1      /* Defines details of the lock bytes */
230 
231 /* Tag len for LOCK_CTRL TLV per spec */
232 #define T2T_TLEN_LOCK_CTRL_TLV 3
233 
234 /* Maximum number of sectors supported */
235 #if (APPL_DTA_MODE == TRUE)
236 #define T2T_MAX_SECTOR 3
237 #else
238 #define T2T_MAX_SECTOR 2
239 #endif
240 /* Tlv type identifier len                */
241 #define T2T_TLV_TYPE_LEN 1
242 
243 /* Length Field size of short NDEF Message    */
244 #define T2T_SHORT_NDEF_LEN_FIELD_LEN 1
245 /* Length Field size of Long NDEF Message     */
246 #define T2T_LONG_NDEF_LEN_FIELD_LEN 3
247 /* Byte 0 in Length field to indicate LNDEF*/
248 #define T2T_LONG_NDEF_LEN_FIELD_BYTE0 0xFF
249 /* Min. len of NDEF to qualify as LNDEF  */
250 #define T2T_LONG_NDEF_MIN_LEN 0x00FF
251 
252 /* Lock */
253 /* Number of static lock bytes in tag   */
254 #define T2T_NUM_STATIC_LOCK_BYTES 2
255 
256 /*
257 **
258 **  Type 3 Tag Definitions
259 **
260 */
261 
262 #define T3T_SYSTEM_CODE_NDEF 0x12FC /* System Code for NDEF tags */
263 /* System Code for felica-lite tags */
264 #define T3T_SYSTEM_CODE_FELICA_LITE 0x88B4
265 #define T3T_MAX_SYSTEM_CODES 16
266 /* Maximum number of blocks for NDEF message for Felica Lite tags */
267 #define T3T_FELICALITE_NMAXB 13
268 
269 /* Block descriptor, used to describe a block to check/update */
270 typedef struct {
271   uint16_t service_code; /* Block service code. Set to T3T_SERVICE_CODE_NDEF
272                             (0x000B) for NDEF data */
273   uint16_t block_number; /* Block number */
274 } tT3T_BLOCK_DESC;
275 
276 /* Poll RC (request code) definitions */
277 #define T3T_POLL_RC_SC 1   /* System code requested in SENSF_RES */
278 typedef uint8_t tT3T_POLL_RC;
279 
280 /* Definitions for constructing t3t command messages */
281 
282 /* NFC Forum / Felica commands */
283 #define T3T_MSG_OPC_CHECK_CMD 0x06
284 #define T3T_MSG_OPC_CHECK_RSP 0x07
285 #define T3T_MSG_OPC_UPDATE_CMD 0x08
286 #define T3T_MSG_OPC_UPDATE_RSP 0x09
287 
288 /* Felica commands (not specified in NFC-Forum Type 3 tag specifications) */
289 #define T3T_MSG_OPC_POLL_CMD 0x00
290 #define T3T_MSG_OPC_POLL_RSP 0x01
291 #define T3T_MSG_OPC_REQ_SERVICE_CMD 0x02
292 #define T3T_MSG_OPC_REQ_RESPONSE_CMD 0x04
293 #define T3T_MSG_OPC_REQ_RESPONSE_RSP 0x05
294 #define T3T_MSG_OPC_REQ_SYSTEMCODE_CMD 0x0C
295 #define T3T_MSG_OPC_REQ_SYSTEMCODE_RSP 0x0D
296 
297 /* Service code: read-only NDEF */
298 #define T3T_MSG_NDEF_SC_RO 0x000B
299 /* Service code: read/write NDEF */
300 #define T3T_MSG_NDEF_SC_RW 0x0009
301 #define T3T_MSG_NDEF_VERSION 0x10 /* NDEF Mapping Version 1.0 */
302 #define T3T_MSG_NDEF_WRITEF_OFF 0x00
303 #define T3T_MSG_NDEF_WRITEF_ON 0x0F
304 #define T3T_MSG_NDEF_RWFLAG_RO 0x00
305 #define T3T_MSG_NDEF_RWFLAG_RW 0x01
306 /* Size of NDEF attribute info block (minus checksum) */
307 #define T3T_MSG_NDEF_ATTR_INFO_SIZE 14
308 
309 /* len flag for Block List Element */
310 #define T3T_MSG_MASK_TWO_BYTE_BLOCK_DESC_FORMAT 0x80
311 /* service code list mask */
312 #define T3T_MSG_SERVICE_LIST_MASK 0x0F
313 #define T3T_MSG_SERVICE_LIST_MAX 16
314 
315 /* Max Number of Blocks per UPDATE command */
316 #define T3T_MSG_NUM_BLOCKS_UPDATE_MAX 13
317 /* Max Number of Blocks per CHECK command */
318 #define T3T_MSG_NUM_BLOCKS_CHECK_MAX 15
319 
320 /* Data block size for UPDATE and CHECK commands */
321 #define T3T_MSG_BLOCKSIZE 16
322 
323 /* Common header definitions for T3t commands */
324 /* Common header: SoD + cmdcode + NFCID2 + num_services */
325 #define T3T_MSG_CMD_COMMON_HDR_LEN 11
326 
327 /* Common header definition for T3t responses */
328 /* Common header: rspcode + NFCID2 + StatusFlag1 + StatusFlag2  */
329 #define T3T_MSG_RSP_COMMON_HDR_LEN 11
330 /* Offset for Response code */
331 #define T3T_MSG_RSP_OFFSET_RSPCODE 0
332 /* Offset for Manufacturer ID */
333 #define T3T_MSG_RSP_OFFSET_IDM 1
334 /* Offset for Status Flag1 */
335 #define T3T_MSG_RSP_OFFSET_STATUS1 9
336 /* Offset for NumberOfBlocks (in CHECK response) */
337 #define T3T_MSG_RSP_OFFSET_NUMBLOCKS 11
338 /* Offset for Block Data (in CHECK response) */
339 #define T3T_MSG_RSP_OFFSET_CHECK_DATA 12
340 
341 #define T3T_MSG_RSP_STATUS_OK 0x00
342 #define T3T_MSG_RSP_STATUS_ERROR 0x01
343 
344 #define T3T_MSG_RSP_STATUS2_ERROR_MEMORY 0x70
345 #define T3T_MSG_RSP_STATUS2_ERROR_PROCESSING 0xFF
346 
347 
348 /* Felica Lite defintions */
349 /* Block ID for MC (memory configuration)                       */
350 #define T3T_MSG_FELICALITE_BLOCK_ID_MC 0x88
351 
352 /* Memory Configuration Block offset: MC_SP (Memory Configuration for scratch
353  * pad)   */
354 #define T3T_MSG_FELICALITE_MC_OFFSET_MC_SP 0x00
355 /* Memory Configuration Block offset: SYS_OP (System Option) */
356 #define T3T_MSG_FELICALITE_MC_OFFSET_SYS_OP 0x03
357 /* Memory Configuration Block offset: RF_PRM (Memory Configuration for RF
358  * Parameter) */
359 #define T3T_MSG_FELICALITE_MC_OFFSET_RF_PRM 0x04
360 
361 /*
362 **
363 **  Type 4 Tag Definitions
364 **
365 */
366 #define T4T_CMD_MIN_HDR_SIZE 4 /* CLA, INS, P1, P2 */
367 #define T4T_CMD_MAX_HDR_SIZE 5 /* CLA, INS, P1, P2, Lc */
368 
369 /* CLA, INS, P1, P2, Data ODO */
370 #define T4T_CMD_MIN_EXT_HDR_SIZE 9
371 /* CLA, INS, P1, P2, Lc, Data ODO, Le
372  * with Lc and Le coded using Extended Field Coding */
373 #define T4T_CMD_MAX_EXT_HDR_SIZE 15
374 
375 /* CLA, INS, P1, P2, Le on 3 bytes (Lc absent) using Extended Field Coding */
376 #define T4T_CMD_MAX_EFC_NO_LC_HDR_SIZE 7
377 #define T4T_VERSION_3_0 0x30 /* version 3.0 */
378 #define T4T_VERSION_2_0 0x20 /* version 2.0 */
379 #define T4T_VERSION_1_0 0x10 /* version 1.0 */
380 #define T4T_MY_VERSION T4T_VERSION_3_0
381 #define T4T_GET_MAJOR_VERSION(x) ((x) >> 4)
382 
383 #define T4T_CMD_CLASS 0x00
384 #define T4T_CMD_INS_SELECT 0xA4
385 #define T4T_CMD_INS_READ_BINARY 0xB0
386 #define T4T_CMD_INS_UPDATE_BINARY 0xD6
387 #define T4T_CMD_INS_READ_BINARY_ODO 0xB1
388 #define T4T_CMD_INS_UPDATE_BINARY_ODO 0xD7
389 #define T4T_CMD_DES_CLASS 0x90
390 #define T4T_CMD_INS_GET_HW_VERSION 0x60
391 #define T4T_CMD_CREATE_AID 0xCA
392 #define T4T_CMD_SELECT_APP 0x5A
393 #define T4T_CMD_CREATE_DATAFILE 0xCD
394 #define T4T_CMD_DES_WRITE 0x3D
395 #define T4T_CMD_P1_SELECT_BY_NAME 0x04
396 #define T4T_CMD_P1_SELECT_BY_FILE_ID 0x00
397 #define T4T_CMD_P2_FIRST_OR_ONLY_00H 0x00
398 #define T4T_CMD_P2_FIRST_OR_ONLY_0CH 0x0C
399 
400 /* Max number of bytes to be read from file in ReadBinary Command */
401 #define T4T_MAX_LENGTH_LE 0xFF
402 /* Max number of bytes written to NDEF file in UpdateBinary Command */
403 #define T4T_MAX_LENGTH_LC 0xFF
404 
405 #define T4T_RSP_STATUS_WORDS_SIZE 0x02
406 
407 #define T4T_RSP_CMD_CMPLTED 0x9000
408 #define T4T_RSP_NOT_FOUND 0x6A82
409 #define T4T_RSP_WRONG_PARAMS 0x6B00
410 #define T4T_RSP_CLASS_NOT_SUPPORTED 0x6E00
411 #define T4T_RSP_WRONG_LENGTH 0x6700
412 #define T4T_RSP_INSTR_NOT_SUPPORTED 0x6D00
413 #define T4T_RSP_CMD_NOT_ALLOWED 0x6986
414 #define T4T_RSP_WARNING_PARAMS_CHECK(X) \
415   ((X == 0x63 || X == 0x62 || X == 0x61) ? true : false)
416 
417 /* V1.0 Type 4 Tag Applicaiton ID length */
418 #define T4T_V10_NDEF_TAG_AID_LEN 0x07
419 /* V2.0 Type 4 Tag Applicaiton ID length */
420 #define T4T_V20_NDEF_TAG_AID_LEN 0x07
421 
422 /* Min of Max R-APDU data size */
423 #define T4T_MIN_MLE 0x000F
424 
425 #define T4T_FILE_ID_SIZE 0x02
426 #define T4T_CC_FILE_ID 0xE103
427 #define T4T_CC_FILE_MIN_LEN 0x000F
428 
429 #define T4T_VERSION_OFFSET_IN_CC 0x02
430 #define T4T_FC_TLV_OFFSET_IN_CC 0x07
431 /* size of T(1),L(1),V(8) for extended NDEF file control */
432 #define T4T_ENDEF_FC_V_FIELD_OFFSET 0x09
433 /* Offset of Write access byte from type field in CC */
434 #define T4T_FC_WRITE_ACCESS_OFFSET_IN_TLV 0x07
435 
436 #define T4T_NDEF_FILE_CONTROL_TYPE 0x04 /* NDEF File Control Type */
437 
438 /* size of T(1),L(1),V(6) for file control */
439 #define T4T_FILE_CONTROL_TLV_SIZE 0x08
440 /* size of V(6) for file control */
441 #define T4T_FILE_CONTROL_LENGTH 0x06
442 
443 #define T4T_ENDEF_FILE_CONTROL_TYPE 0x06 /* Extended NDEF File Control Type */
444 /* size of T(1),L(1),V(8) for extended NDEF file control */
445 #define T4T_ENDEF_FILE_CONTROL_TLV_SIZE 0x0A
446 /* size of V(8) for extended NDEF file control */
447 #define T4T_ENDEF_FILE_CONTROL_LENGTH 0x08
448 
449 /* read access granted without any security */
450 #define T4T_FC_READ_ACCESS 0x00
451 /* no read access granted at all */
452 #define T4T_FC_NO_READ_ACCESS 0xFF
453 /* proprietary read access range start */
454 #define T4T_FC_READ_ACCESS_PROP_START 0x80
455 /* write access granted without any security */
456 #define T4T_FC_WRITE_ACCESS 0x00
457 /* proprietary write access range start */
458 #define T4T_FC_WRITE_ACCESS_PROP_START 0x80
459 /* no write access granted at all (read-only) */
460 #define T4T_FC_NO_WRITE_ACCESS 0xFF
461 
462 #define T4T_FILE_LENGTH_SIZE 0x02
463 #define T4T_EFILE_LENGTH_SIZE 0x04
464 #define T4T_ADDI_FRAME_RESP 0xAFU
465 #define T4T_DES_GET_VERSION_LEN 0x09
466 #define T4T_SIZE_IDENTIFIER_2K 0x16U
467 #define T4T_SIZE_IDENTIFIER_4K 0x18U
468 #define T4T_SIZE_IDENTIFIER_8K 0x1AU
469 #define T4T_DESEV1_MAJOR_VERSION 0x01U
470 #define T4T_TYPE_DESFIRE_EV1 0x01U
471 #define T4T_DESEV0_MAJOR_VERSION 0x00U
472 #define T4T_DESEV0_MINOR_VERSION 0x06U
473 #define T4T_DES_EV1_NFC_APP_ID 0x010000
474 #define T4T_DES_EV0_NFC_APP_ID 0x10EEEE
475 
476 /*  Mifare Classic Tag Definitions */
477 #define MFC_UID_LEN 4
478 
479 /*
480 **
481 **  ISO 15693 Tag Definitions
482 **
483 */
484 
485 #define I93_VERSION_1_x 0x40 /* major mapping version 1.x */
486 
487 /* A single sub-carrier frequency shall be used by VICC */
488 #define I93_FLAG_SUB_CARRIER_SINGLE 0x00
489 
490 /* High data rate shall be used */
491 #define I93_FLAG_DATA_RATE_HIGH 0x02
492 
493 /* Flags 5 to 8 meaning is according to table 5 */
494 #define I93_FLAG_INVENTORY_SET 0x04
495 
496 /* No protocol format extension                         */
497 #define I93_FLAG_PROT_EXT_NO 0x00
498 /* Protocol format is extended. Reserved for future use */
499 #define I93_FLAG_PROT_EXT_YES 0x08
500 
501 /* Request is addressed with AMS (Address Mode Selector). UID field is included.
502  * It shall be executed only by VICC */
503 #define I93_FLAG_ADDRESS_SET 0x20
504 /* whose UID matches the UID specified in the request */
505 /* Request is addressed with SMS (Select Mode Selector). UID field is included
506  * or not.  It shall be executed by the unique VICC to be in SELECTED state */
507 #define I93_FLAG_SELECT_SET 0x10
508 
509 /* AFI field is present     */
510 #define I93_FLAG_AFI_PRESENT 0x10
511 
512 #define I93_FLAG_SLOT_ONE 0x20  /* 1 slot   */
513 
514 /* It shall be set to 0 if not otherwise defined by command */
515 /* Meaning is defined by the command description. */
516 #define I93_FLAG_OPTION_SET 0x40
517 
518 /* Error detected, Error code is in the "Error" field */
519 #define I93_FLAG_ERROR_DETECTED 0x01
520 
521 /* Response error code */
522 /* The command option is not supported                                   */
523 #define I93_ERROR_CODE_OPTION_NOT_SUPPORTED 0x03
524 /* The specific block is was not successfully programmed                 */
525 #define I93_ERROR_CODE_BLOCK_FAIL_TO_WRITE 0x13
526 /* The specific block is was not successfully locked                     */
527 
528 /* UID length in bytes                  */
529 #define I93_UID_BYTE_LEN 8
530 /* Data Storage Format is not supported */
531 #define I93_DFS_UNSUPPORTED 0x00
532 /* Block is locked                      */
533 #define I93_BLOCK_LOCKED 0x01
534 
535 /* ISO 15693 Mandatory commands */
536 #define I93_CMD_INVENTORY 0x01  /* Inventory  */
537 #define I93_CMD_STAY_QUIET 0x02 /* Stay Quiet */
538 
539 /* ISO 15693 Optional commands */
540 #define I93_CMD_READ_SINGLE_BLOCK 0x20  /* Read single block     */
541 #define I93_CMD_EXT_READ_SINGLE_BLOCK 0x30 /* Extended Read single block */
542 #define I93_CMD_WRITE_SINGLE_BLOCK 0x21 /* Write single block    */
543 #define I93_CMD_EXT_WRITE_SINGLE_BLOCK 0x31 /* Extended Write single block */
544 #define I93_CMD_LOCK_BLOCK 0x22         /* Lock block            */
545 #define I93_CMD_EXT_LOCK_BLOCK 0x32     /* Extended Lock block            */
546 #define I93_CMD_READ_MULTI_BLOCK 0x23   /* Read multiple blocks  */
547 #define I93_CMD_EXT_READ_MULTI_BLOCK 0x33 /* Extended Read multiple blocks  */
548 #define I93_CMD_WRITE_MULTI_BLOCK 0x24  /* Write multiple blocks */
549 #define I93_CMD_EXT_WRITE_MULTI_BLOCK 0x34 /* Write multiple blocks */
550 #define I93_CMD_SELECT 0x25             /* Select                */
551 #define I93_CMD_RESET_TO_READY 0x26     /* Reset to ready        */
552 #define I93_CMD_WRITE_AFI 0x27          /* Wreite AFI            */
553 #define I93_CMD_LOCK_AFI 0x28           /* Lock AFI              */
554 #define I93_CMD_WRITE_DSFID 0x29        /* Write DSFID           */
555 #define I93_CMD_LOCK_DSFID 0x2A         /* Lock DSFID            */
556 /* Get system information             */
557 #define I93_CMD_GET_SYS_INFO 0x2B
558 /* Get extended system information    */
559 #define I93_CMD_EXT_GET_SYS_INFO 0x3B
560 /* Get multiple block security status */
561 #define I93_CMD_GET_MULTI_BLK_SEC 0x2C
562 /* Get extended multiple block security status */
563 #define I93_CMD_EXT_GET_MULTI_BLK_SEC 0x3C
564 #define I93_CMD_SET_ADDR_MODE 0x3D /* Set address mode            */
565 
566 /* Information flags definition */
567 /* DSFID is supported and DSFID field is present */
568 #define I93_INFO_FLAG_DSFID 0x01
569 /* DSFID info length */
570 #define I93_INFO_DSFID_LEN 0x01
571 /* AFI is supported and AFI field is present     */
572 #define I93_INFO_FLAG_AFI 0x02
573 /* AFI info length */
574 #define I93_INFO_AFI_LEN 0x01
575 /* VICC memory size field is present             */
576 #define I93_INFO_FLAG_MEM_SIZE 0x04
577 /* block size info length */
578 #define I93_INFO_BLOCK_SIZE_LEN 0x01
579 /* 8bit num of blocks info length */
580 #define I93_INFO_8BIT_NUM_BLOCK_LEN 0x01
581 /* 16bit num of blocks info length */
582 #define I93_INFO_16BIT_NUM_BLOCK_LEN 0x02
583 /* IC reference field is present                 */
584 #define I93_INFO_FLAG_IC_REF 0x08
585 /* IC ref info length */
586 #define I93_INFO_IC_REF_LEN 0x01
587 /* Memory coded in 2 bytes address               */
588 #define I93_INFO_FLAG_MOI 0x10
589 
590 /* Max block size in bytes */
591 #define I93_MAX_BLOCK_LENGH 32
592 
593 /* Block lengths */
594 #define I93_BLEN_4BYTES 0x04
595 #define I93_BLEN_8BYTES 0x08
596 #define I93_BLEN_16BYTES 0x10
597 #define I93_BLEN_32BYTES 0x20
598 /* ICODE Capability Container(CC) definition */
599 #define I93_ICODE_CC_MAGIC_NUMER_E1 0xE1 /* magic number in CC[0]  */
600 #define I93_ICODE_CC_MAGIC_NUMER_E2 0xE2 /* magic number in CC[0]  */
601 /* read access condition in CC[1]        */
602 #define I93_ICODE_CC_READ_ACCESS_MASK 0x0C
603 /* read access granted without security  */
604 #define I93_ICODE_CC_READ_ACCESS_GRANTED 0x00
605 /* write access condition in CC[1]       */
606 #define I93_ICODE_CC_WRITE_ACCESS_MASK 0x03
607 /* write access granted without security */
608 #define I93_ICODE_CC_WRITE_ACCESS_GRANTED 0x00
609 /* write access not granted at all       */
610 #define I93_ICODE_CC_READ_ONLY 0x03
611 /* read multi block supported in CC[3]   */
612 #define I93_ICODE_CC_MBREAD_MASK 0x01
613 /* inventory page read supported in CC[3] */
614 #define I93_ICODE_CC_IPREAD_MASK 0x02
615 /* More than 2040 bytes are supported in CC[3] */
616 #define I93_STM_CC_OVERFLOW_MASK 0x04
617 #define I93_ONS_CC_OVERFLOW_MASK 0x04
618 /* Special Frame are supported in CC[3] */
619 #define I93_ICODE_CC_SPECIAL_FRAME_MASK 0x10
620 
621 /* ICODE TLV type */
622 #define I93_ICODE_TLV_TYPE_NULL 0x00 /* NULL TLV         */
623 #define I93_ICODE_TLV_TYPE_NDEF 0x03 /* NDEF message TLV */
624 #define I93_ICODE_TLV_TYPE_PROP 0xFD /* Proprietary TLV  */
625 #define I93_ICODE_TLV_TYPE_TERM 0xFE /* Terminator TLV   */
626 
627 /* UID Coding (UID Bit 64-57), First byte of ISO 15693 UID */
628 #define I93_UID_FIRST_BYTE 0xE0
629 
630 /* UID Coding (UID Bit 56-49), IC manufacturer code */
631 #define I93_UID_IC_MFG_CODE_STM 0x02
632 #define I93_UID_IC_MFG_CODE_NXP 0x04
633 #define I93_UID_IC_MFG_CODE_TI 0x07
634 #define I93_UID_IC_MFG_CODE_ONS 0x67
635 
636 /* NXP, UID Coding of ICODE type (UID Bit 48-41) */
637 /* ICODE SLI, SLIX     */
638 #define I93_UID_ICODE_SLI 0x01
639 /* ICODE SLI-S, SLIX-S */
640 #define I93_UID_ICODE_SLI_S 0x02
641 /* ICODE SLI-L, SLIX-L */
642 #define I93_UID_ICODE_SLI_L 0x03
643 
644 /* IC Reference for ICODE SLI-L */
645 #define I93_IC_REF_ICODE_SLI_L 0x03
646 /* read multi block supported check bit */
647 #define I93_ICODE_IC_REF_MBREAD_MASK 0x02
648 
649 /* TI, UID Coding of product version (UID Bit 48-42) */
650 /* upper 7 bits                     */
651 #define I93_UID_TAG_IT_HF_I_PRODUCT_ID_MASK 0xFE
652 /* Tag-it HF-I Plus Inlay           */
653 #define I93_UID_TAG_IT_HF_I_PLUS_INLAY 0x00
654 /* Tag-it HF-I Plus Chip            */
655 #define I93_UID_TAG_IT_HF_I_PLUS_CHIP 0x80
656 /* Tag-it HF-I Standard Chip/Inlyas */
657 #define I93_UID_TAG_IT_HF_I_STD_CHIP_INLAY 0xC0
658 /* Tag-it HF-I Pro Chip/Inlyas      */
659 #define I93_UID_TAG_IT_HF_I_PRO_CHIP_INLAY 0xC4
660 
661 #define I93_TAG_IT_HF_I_STD_CHIP_INLAY_NUM_TOTAL_BLK 11
662 #define I93_TAG_IT_HF_I_PRO_CHIP_INLAY_NUM_TOTAL_BLK 12
663 
664 #define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_BLK_SIZE 4
665 #define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_NUM_USER_BLK 8
666 /* LSB in Block 0x0A */
667 #define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_AFI_LOCATION 40
668 
669 /* STM, product version (IC manufacturer code) */
670 /* IC Reference mask for STM */
671 #define I93_IC_REF_STM_MASK 0xFC
672 /* IC Reference for LRI1K:      010000xx(b), blockSize: 4, numberBlocks: 0x20 */
673 #define I93_IC_REF_STM_LRI1K 0x40
674 /* IC Reference for LRI2K:      001000xx(b), blockSize: 4, numberBlocks: 0x40 */
675 #define I93_IC_REF_STM_LRI2K 0x20
676 /* IC Reference for LRIS2K:     001010xx(b), blockSize: 4, numberBlocks: 0x40 */
677 #define I93_IC_REF_STM_LRIS2K 0x28
678 /* IC Reference for LRIS64K:    010001xx(b), blockSize: 4, numberBlocks: 0x800
679  */
680 #define I93_IC_REF_STM_LRIS64K 0x44
681 /* IC Reference for M24LR64-R:  001011xx(b), blockSize: 4, numberBlocks: 0x800
682  */
683 #define I93_IC_REF_STM_M24LR64_R 0x2C
684 /* IC Reference for M24LR04E-R: 01011010(b), blockSize: 4, numberBlocks: 0x80 */
685 #define I93_IC_REF_STM_M24LR04E_R 0x5A
686 /* IC Reference for M24LR16E-R: 01001110(b), blockSize: 4, numberBlocks: 0x200
687  */
688 #define I93_IC_REF_STM_M24LR16E_R 0x4E
689 /* IC Reference for M24LR16D-W: 01001101(b), blockSize: 4, numberBlocks: 0x200
690  */
691 #define I93_IC_REF_STM_M24LR16D_W 0x4D
692 /* IC Reference for M24LR64D-W: 01011110(b), blockSize: 4, numberBlocks: 0x800
693  */
694 #define I93_IC_REF_STM_M24LR64E_R 0x5E
695 /* IC Reference for ST25DV04K: 00100100(b), blockSize: 4, numberBlocks: 0x80
696  */
697 #define I93_IC_REF_STM_ST25DV04K 0x24
698 /* IC Reference for ST25DVHIK: 00100110(b), blockSize: 4, numberBlocks: 0x800
699  * or 0x200
700  */
701 #define I93_IC_REF_STM_ST25DVHIK 0x26
702 /* IC Reference for ST25TV04K: 00110101(b), blockSize: 4, numberBlocks: 0x0200
703  */
704 #define I93_IC_REF_STM_ST25TV04K_E 0x35
705 /* IC Reference for ST25TV16K: 01001000(b), blockSize: 4, numberBlocks: 0x1000
706  * IC Reference for ST25TV64K: 01001000(b), blockSize: 4, numberBlocks: 0x4000
707  */
708 #define I93_IC_REF_STM_ST25TV16K_64K 0x48
709 
710 /* Product code family for LRI2K */
711 #define I93_PROD_CODE_STM_LRI2K_MASK I93_IC_REF_STM_LRI2K /* 0x20 */
712 /* Product code family for LRIS2K */
713 #define I93_PROD_CODE_STM_LRIS2K_MASK I93_IC_REF_STM_LRIS2K /* 0x28 */
714 /* Product code family for LRIS64K */
715 #define I93_PROD_CODE_STM_LRIS64K_MASK I93_IC_REF_STM_LRIS64K /* 0x44 */
716 /* Product code family for M24LR04E_R */
717 #define I93_PROD_CODE_STM_M24LR04E_R_MASK 0x58
718 /* Product code family for M24LR64_R */
719 #define I93_PROD_CODE_STM_M24LR64_R_MASK I93_IC_REF_STM_M24LR64_R /* 0x2C */
720 /* Product code family for M24LR16E_R */
721 #define I93_PROD_CODE_STM_M24LR16E_R_MASK 0x4C
722 /* Product code family for M24LR64E_R */
723 #define I93_PROD_CODE_STM_M24LR64E_R_MASK 0x5C
724 /* Product code family for ST25DV04K/16K/64K */
725 #define I93_PROD_CODE_STM_ST25DV_K_MASK I93_IC_REF_STM_ST25DV04K
726 
727 /* ONS, product version (IC manufacturer code) */
728 /* IC Reference for N36RW02:  00011010(b), blockSize: 4, numberBlocks: 0x40 */
729 #define I93_IC_REF_ONS_N36RW02  0x1A
730 /* IC Reference for N24RF04:  00101010(b), blockSize: 4, numberBlocks: 0x80 */
731 #define I93_IC_REF_ONS_N24RF04  0x2A
732 /* IC Reference for N24RF04E: 00101110(b), blockSize: 4, numberBlocks: 0x80 */
733 #define I93_IC_REF_ONS_N24RF04E 0x2E
734 /* IC Reference for N24RF16:  01001010(b), blockSize: 4, numberBlocks: 0x200 */
735 #define I93_IC_REF_ONS_N24RF16  0x4A
736 /* IC Reference for N24RF16E: 01001110(b), blockSize: 4, numberBlocks: 0x200 */
737 #define I93_IC_REF_ONS_N24RF16E 0x4E
738 /* IC Reference for N24RF64:  01101010(b), blockSize: 4, numberBlocks: 0x800 */
739 #define I93_IC_REF_ONS_N24RF64  0x6A
740 /* IC Reference for N24RF64E: 01101110(b), blockSize: 4, numberBlocks: 0x800 */
741 #define I93_IC_REF_ONS_N24RF64E 0x6E
742 
743 #define I93_STM_BLOCKS_PER_SECTOR 32
744 #define I93_STM_MAX_BLOCKS_PER_READ 32
745 
746 #define I93_ONS_BLOCKS_PER_SECTOR 32
747 #define I93_ONS_MAX_BLOCKS_PER_READ 32
748 
749 #endif /* TAGS_DEFS_H */