• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-2012 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 #define TAG_BRCM_MID            0x2E  /* BROADCOM CORPORATION                           */
31 #define TAG_MIFARE_MID          0x04  /* MIFARE                                         */
32 #define TAG_KOVIO_MID           0x37  /* KOVIO                                          */
33 #define TAG_INFINEON_MID        0x05  /* Infineon Technologies                          */
34 
35 /* TLV types present in Type1 and Type 2 Tags */
36 #define TAG_NULL_TLV            0     /* May be used for padding. SHALL ignore this     */
37 #define TAG_LOCK_CTRL_TLV       1     /* Defines details of the lock bytes              */
38 #define TAG_MEM_CTRL_TLV        2     /* Identifies reserved memory areas               */
39 #define TAG_NDEF_TLV            3     /* Contains the NDEF message                      */
40 #define TAG_PROPRIETARY_TLV     0xFD  /* Tag proprietary information                    */
41 #define TAG_TERMINATOR_TLV      0xFE  /* Last TLV block in the data area                */
42 #define TAG_BITS_PER_BYTE       0x08  /* Number of bits in every tag byte               */
43 #define TAG_MAX_UID_LEN         0x0A  /* Max UID Len of type 1 and type 2 tag           */
44 
45 #define TAG_LONG_NDEF_LEN_FIELD_BYTE0   0xFF  /* Byte 0 Length field to indicate LNDEF  */
46 #define TAG_DEFAULT_TLV_LEN             3     /* Tlv len for LOCK_CTRL/MEM TLV per spec */
47 
48 /* Type 1 Tag related definitions */
49 
50 #define T1T_STATIC_BLOCKS       0x0F  /* block 0 to Block E                             */
51 #define T1T_BLOCK_SIZE          0x08  /* T1T Block size in bytes                        */
52 
53 #define T1T_STATIC_SIZE         T1T_STATIC_BLOCKS * T1T_BLOCK_SIZE /* Static Tag size   */
54 
55 #define T1T_SEGMENT_SIZE        0x80  /* Size of Type 1 Tag segment in bytes            */
56 #define T1T_MAX_SEGMENTS        0x10  /* Maximum segment supported by Type 1 Tag        */
57 #define T1T_BLOCKS_PER_SEGMENT  0x10  /* Number of blocks present in a segment          */
58 #define T1T_OTP_LOCK_RES_BYTES  0x10  /* No.of default OTP,staticlocks,res bytes in tag */
59 
60 #define T1T_STATIC_HR0          0x11  /* HRO value to indicate static Tag               */
61 #define T1T_DYNAMIC_HR0         0x12  /* 0x1y, as long as (y!=1)                        */
62 #define T1T_NDEF_SUPPORTED      0x10  /* HR0 value is 0x1y, indicates NDEF supported    */
63 #define T1T_HR1                 0x00  /* should be ignored                              */
64 #define T1T_UID_BLOCK           0x00  /* UID block                                      */
65 #define T1T_RES_BLOCK           0x0D  /* Reserved block                                 */
66 #define T1T_LOCK_BLOCK          0x0E  /* Static lock block                              */
67 #define T1T_MID_OFFSET          0x06  /* Manufacturer ID offset                         */
68 #define T1T_STATIC_RES_OFFSET   0x68  /* Reserved bytes offset                          */
69 #define T1T_LOCK_0_OFFSET       0x70  /* Static lock offset                             */
70 #define T1T_LOCK_1_OFFSET       0x71  /* Static lock offset                             */
71 #define T1T_DYNAMIC_LOCK_OFFSET 0x78  /* Block F - typically used for dynamic locks     */
72 #define T1T_DYNAMIC_LOCK_BYTES  0x08
73 
74 #define T1T_RES_BYTE_LEN        1     /* the len of reserved byte in T1T block 0        */
75 
76 /* Capability Container definitions */
77 #define T1T_CC_BLOCK            1     /* Capability container block                     */
78 #define T1T_CC_LEN              4     /* the len of CC used in T1T tag                  */
79 /* CC offset */
80 #define T1T_CC_NMN_OFFSET       0x00  /* Offset for NDEF magic number in CC             */
81 #define T1T_CC_VNO_OFFSET       0x01  /* Offset for Version number in CC                */
82 #define T1T_CC_TMS_OFFSET       0x02  /* Offset for Tag memory size in CC               */
83 #define T1T_CC_RWA_OFFSET       0x03  /* Offset for Read/Write access in CC             */
84 #define T1T_CC_NMN_BYTE         0x08  /* NDEF Magic Number byte number                  */
85 #define T1T_CC_VNO_BYTE         0x09  /* Version Number byte number                     */
86 #define T1T_CC_TMS_BYTE         0x0A  /* Tag Memory Size byte number                    */
87 #define T1T_CC_RWA_BYTE         0x0B  /* Read Write Access byte number                  */
88 #define T1T_CC_NMN              0xE1  /* NDEF Magic Number                              */
89 #define T1T_CC_LEGACY_VNO       0x10  /* Supported Legacy Version                       */
90 #define T1T_CC_VNO              0x11  /* Version Number                                 */
91 #define T1T_CC_TMS_STATIC       0x0E  /* TMS static memory - (8 * (n+1)).               */
92 #define T1T_CC_RWA_RW           0x00  /* RWA - Read/write allowed                       */
93 #define T1T_CC_RWA_RO           0x0F  /* RWA - Read only                                */
94 
95 #define T1T_TAG_NULL            0     /* May be used for padding. SHALL ignore this     */
96 #define T1T_TAG_LOCK_CTRL       1     /* Defines details of the lock bytes              */
97 #define T1T_TAG_MEM_CTRL        2     /* Identifies reserved memory areas               */
98 #define T1T_TAG_NDEF            3     /* Contains the NDEF message                      */
99 #define T1T_TAG_PROPRIETARY     0xFD  /* Tag proprietary information                    */
100 #define T1T_TAG_TERMINATOR      0xFE  /* Last TLV block in the data area                */
101 
102 #define T1T_DEFAULT_TLV_LEN     3     /* Tlv len for LOCK_CTRL/MEM TLV per spec         */
103 #define T1T_TLV_TYPE_LEN        1     /* Tlv type identifier len                        */
104 #define T1T_DEFAULT_TLV_LEN_FIELD_LEN   1     /* Length field size of  lock/mem tlv     */
105 
106 #define T1T_HR_LEN              2     /* the len of HR used in Type 1 Tag               */
107 #define T1T_CMD_UID_LEN         4     /* the len of UID used in Type 1 Tag Commands     */
108 #define T1T_UID_LEN             7     /* the len of UID used in Type 1 Tag              */
109 #define T1T_ADD_LEN             1
110 
111 #define T1T_SHORT_NDEF_LEN_FIELD_LEN    1 /* Length Field size of short NDEF Message    */
112 #define T1T_LONG_NDEF_LEN_FIELD_LEN     3 /* Length Field size of Long NDEF Message     */
113 #define T1T_LONG_NDEF_LEN_FIELD_BYTE0   0xFF /* Byte 0 in Length field to indicate LNDEF*/
114 #define T1T_LONG_NDEF_MIN_LEN           0x00FF /* Min. len of NDEF to qualify as LNDEF  */
115 
116 /* Type 1 Tag Commands (7 bits) */
117 #define T1T_CMD_RID             0x78    /* read id                                      */
118 #define T1T_CMD_RALL            0x00    /* read all bytes                               */
119 #define T1T_CMD_READ            0x01    /* read (1 byte)                                */
120 #define T1T_CMD_WRITE_E         0x53    /* write with erase (1 byte)                    */
121 #define T1T_CMD_WRITE_NE        0x1A    /* write no erase (1 byte)                      */
122 /* dynamic memory only */
123 #define T1T_CMD_RSEG            0x10    /* read segment                                 */
124 #define T1T_CMD_READ8           0x02    /* read (8 byte)                                */
125 #define T1T_CMD_WRITE_E8        0x54    /* write with erase (8 byte)                    */
126 #define T1T_CMD_WRITE_NE8       0x1B    /* write no erase (8 byte)                      */
127 
128 /* Lock */
129 #define T1T_NUM_STATIC_LOCK_BYTES           2   /* Number of static lock bytes in tag   */
130 #define T1T_BYTES_LOCKED_BY_STATIC_LOCK_BIT 4   /* Bytes locked by one static lock bit  */
131 
132 
133 /* Type 2 Tag related definitions */
134 #define T2T_STATIC_MEM_STR      0
135 #define T2T_DYNAMIC_MEM_STR     1
136 #define T2T_STATIC_SIZE         64
137 #define T2T_STATIC_BLOCKS       16      /* block 0 to Block 15 */
138 #define T2T_BLOCK_SIZE          4
139 #define T2T_HEADER_BLOCKS       4
140 #define T2T_HEADER_SIZE         16
141 #define T2T_SECTOR_SIZE         1024
142 #define T2T_BLOCKS_PER_SECTOR   0x100
143 
144 #define T2T_UID_LEN             4     /* the len of UID used in T2T tag */
145 #define T2T_BLOCK0_UID_LEN      3     /* the len of UID in Block 0 of T2T tag */
146 #define T2T_BCC0_LEN            1     /* the len of BCC0 of T2T tag */
147 #define T2T_BLOCK1_UID_LEN      4     /* the len of UID in Block 1 of T2T tag */
148 #define T2T_BCC1_LEN            1     /* the len of BCC0 of T2T tag */
149 #define T2T_SNO_LEN             4     /* the len of Serial number used in T2T tag */
150 #define T2T_INTERNAL_BYTES_LEN  2     /* the len of internal used in T2T tag */
151 #define T2T_STATIC_LOCK_LEN     2     /* the len of static lock used in T2T tag */
152 /* Static Lock Bytes */
153 #define T2T_STATIC_LOCK0        0x0A  /* Static Lock 0 offset */
154 #define T2T_STATIC_LOCK1        0x0B  /* Static Lock 1 offset */
155 
156 #define T2T_CC_LEN              4     /* the len of CC used in T2T tag                  */
157 
158 /* Capability Container definitions */
159 #define T2T_CC_BLOCK		    0x03  /* Capability container block */
160 #define T2T_CC0_NMN_BYTE        0x0C  /* NDEF Magic Number byte number */
161 #define T2T_CC1_VNO_BYTE        0x0D  /* Version Number byte number*/
162 #define T2T_CC2_TMS_BYTE        0x0E  /* Tag Memory Size byte number */
163 #define T2T_CC3_RWA_BYTE        0x0F  /* Read Write Access byte number */
164 #define T2T_DATA_MEM            0x10  /* Data Memory */
165 
166 #define T2T_CC0_NMN             0xE1  /* NDEF Magic Number */
167 #define T2T_CC1_VNO             0x11  /* Version Number */
168 #define T2T_CC1_LEGACY_VNO      0x10  /* Legacy Version Number */
169 #define T2T_CC1_NEW_VNO         0x12  /* Another supported Version Number */
170 #define T2T_CC2_TMS_STATIC      0x06  /* TMS static memory - (4 * (n+1)). */
171 #define T2T_CC3_RWA_RW          0x00  /* RWA - Read/write allowed */
172 #define T2T_CC3_RWA_RO          0x0F  /* RWA - Read only */
173 
174 #define T2T_TMS_TAG_FACTOR      0x08  /* Factor to multiply to get tag data size from TMS */
175 #define T2T_DEFAULT_LOCK_BLPB   0x08  /* Bytes locked per lock bit of default locks */
176 
177 /* Type 2 Tag Commands  */
178 #define T2T_CMD_READ            0x30    /* read  4 blocks (16 bytes) */
179 #define T2T_CMD_WRITE           0xA2    /* write 1 block  (4 bytes)  */
180 #define T2T_CMD_SEC_SEL         0xC2    /* Sector select             */
181 #define T2T_RSP_ACK			    0xA
182 #define T2T_RSP_NACK5		    0x5
183 #define T2T_RSP_NACK1           0x1     /* Nack can be either 1    */
184 
185 #define T2T_FIRST_DATA_BLOCK    4
186 #define T2T_READ_BLOCKS         4
187 #define T2T_BLOCK_LEN           4
188 #define T2T_READ_DATA_LEN       (T2T_BLOCK_LEN * T2T_READ_BLOCKS)
189 #define T2T_WRITE_DATA_LEN      4
190 
191 
192 /* Type 2 TLV definitions */
193 #define T2T_TLV_TYPE_NULL         0     /* May be used for padding. SHALL ignore this */
194 #define T2T_TLV_TYPE_LOCK_CTRL    1     /* Defines details of the lock bytes */
195 #define T2T_TLV_TYPE_MEM_CTRL     2     /* Identifies reserved memory areas */
196 #define T2T_TLV_TYPE_NDEF         3     /* Contains the NDEF message */
197 #define T2T_TLV_TYPE_PROPRIETARY  0xFD  /* Tag proprietary information */
198 #define T2T_TLV_TYPE_TERMINATOR   0xFE  /* Last TLV block in the data area */
199 
200 
201 #define T2T_TLEN_LOCK_CTRL_TLV    3      /* Tag len for LOCK_CTRL TLV per spec */
202 #define T2T_TLEN_MEM_CTRL_TLV     3      /* Tag len for MEM_CTRL TLV per spec */
203 
204 #define T2T_MAX_SECTOR            2      /* Maximum number of sectors supported */
205 
206 #define T2T_TLV_TYPE_LEN                1     /* Tlv type identifier len                */
207 
208 #define T2T_DEFAULT_TLV_LEN             3 /* Tlv len for LOCK_CTRL/MEM TLV per spec     */
209 #define T2T_SHORT_NDEF_LEN_FIELD_LEN    1 /* Length Field size of short NDEF Message    */
210 #define T2T_LONG_NDEF_LEN_FIELD_LEN     3 /* Length Field size of Long NDEF Message     */
211 #define T2T_LONG_NDEF_LEN_FIELD_BYTE0   0xFF /* Byte 0 in Length field to indicate LNDEF*/
212 #define T2T_LONG_NDEF_MIN_LEN           0x00FF /* Min. len of NDEF to qualify as LNDEF  */
213 
214 /* Lock */
215 #define T2T_NUM_STATIC_LOCK_BYTES           2   /* Number of static lock bytes in tag   */
216 #define T2T_BYTES_LOCKED_BY_STATIC_LOCK_BIT 4   /* Bytes locked by one static lock bit  */
217 
218 #define T2T_CC2_TMS_MULC          0x12
219 /*
220 **
221 **  Type 3 Tag Definitions
222 **
223 */
224 
225 #define T3T_SYSTEM_CODE_NDEF        0x12FC  /* System Code for NDEF tags */
226 #define T3T_SYSTEM_CODE_FELICA_LITE 0x88B4  /* System Code for felica-lite tags */
227 #define T3T_MAX_SYSTEM_CODES        16
228 
229 /* Block descriptor, used to describe a block to check/update */
230 typedef struct
231 {
232     UINT16 service_code;    /* Block service code. Set to T3T_SERVICE_CODE_NDEF (0x000B) for NDEF data */
233     UINT16 block_number;    /* Block number */
234 } tT3T_BLOCK_DESC;
235 
236 /* Poll RC (request code) definitions */
237 #define T3T_POLL_RC_NONE    0   /* No RD requested in SENSF_RES */
238 #define T3T_POLL_RC_SC      1   /* System code requested in SENSF_RES */
239 #define T3T_POLL_RC_COMM    2   /* Avanced protocol features requested in SENSF_RES */
240 typedef UINT8 tT3T_POLL_RC;
241 
242 /* Definitions for constructing t3t command messages */
243 
244 /* NFC Forum / Felica commands */
245 #define T3T_MSG_OPC_CHECK_CMD   0x06
246 #define T3T_MSG_OPC_CHECK_RSP   0x07
247 #define T3T_MSG_OPC_UPDATE_CMD  0x08
248 #define T3T_MSG_OPC_UPDATE_RSP  0x09
249 
250 /* Felica commands (not specified in NFC-Forum Type 3 tag specifications) */
251 #define T3T_MSG_OPC_POLL_CMD            0x00
252 #define T3T_MSG_OPC_POLL_RSP            0x01
253 #define T3T_MSG_OPC_REQ_SERVICE_CMD     0x02
254 #define T3T_MSG_OPC_REQ_SERVICE_RSP     0x03
255 #define T3T_MSG_OPC_REQ_RESPONSE_CMD    0x04
256 #define T3T_MSG_OPC_REQ_RESPONSE_RSP    0x05
257 #define T3T_MSG_OPC_REQ_SYSTEMCODE_CMD  0x0C
258 #define T3T_MSG_OPC_REQ_SYSTEMCODE_RSP  0x0D
259 
260 #define T3T_MSG_NDEF_SC_RO          0x000B      /* Service code: read-only NDEF */
261 #define T3T_MSG_NDEF_SC_RW          0x0009      /* Service code: read/write NDEF */
262 #define T3T_MSG_NDEF_VERSION        0x10        /* NDEF Mapping Version 1.0 */
263 #define T3T_MSG_NDEF_WRITEF_OFF     0x00
264 #define T3T_MSG_NDEF_WRITEF_ON      0x0F
265 #define T3T_MSG_NDEF_RWFLAG_RO      0x00
266 #define T3T_MSG_NDEF_RWFLAG_RW      0x01
267 #define T3T_MSG_NDEF_ATTR_INFO_SIZE 14          /* Size of NDEF attribute info block (minus checksum) */
268 
269 #define T3T_MSG_OFFSET_IDM                          1       /* offset of Manufacturer ID in UPDATE/CHECK messages */
270 #define T3T_MSG_OFFSET_NUM_SERVICES                 9       /* offset of Number of Services parameter in UPDATE/CHECK messages */
271 #define T3T_MSG_OFFSET_SERVICE_CODE_LIST            10      /* offset of Service Code List parameter in UPDATE/CHECK messages */
272 #define T3T_MSG_MASK_TWO_BYTE_BLOCK_DESC_FORMAT     0x80    /* len flag for Block List Element */
273 #define T3T_MSG_SERVICE_LIST_MASK                   0x0F    /* service code list mask */
274 #define T3T_MSG_SERVICE_LIST_MAX                    16
275 
276 #define T3T_MSG_NUM_SERVICES_UPDATE_MAX             12      /* Max Number of Services per UPDATE command */
277 #define T3T_MSG_NUM_SERVICES_CHECK_MAX              15      /* Max Number of Services per CHECK command */
278 #define T3T_MSG_NUM_BLOCKS_UPDATE_MAX               13      /* Max Number of Blocks per UPDATE command */
279 #define T3T_MSG_NUM_BLOCKS_CHECK_MAX                15      /* Max Number of Blocks per CHECK command */
280 
281 #define T3T_MSG_BLOCKSIZE                           16      /* Data block size for UPDATE and CHECK commands */
282 
283 /* Common header definitions for T3t commands */
284 #define T3T_MSG_CMD_COMMON_HDR_LEN          11      /* Common header: SoD + cmdcode + NFCID2 + num_services */
285 
286 /* Common header definition for T3t responses */
287 #define T3T_MSG_RSP_COMMON_HDR_LEN          11      /* Common header: rspcode + NFCID2 + StatusFlag1 + StatusFlag2  */
288 #define T3T_MSG_RSP_CHECK_HDR_LEN           (T3T_MSG_RSP_COMMON_HDR_LEN + 1)    /* Common header + NumBlocks */
289 #define T3T_MSG_RSP_OFFSET_RSPCODE          0       /* Offset for Response code */
290 #define T3T_MSG_RSP_OFFSET_IDM              1       /* Offset for Manufacturer ID */
291 #define T3T_MSG_RSP_OFFSET_STATUS1          9       /* Offset for Status Flag1 */
292 #define T3T_MSG_RSP_OFFSET_NUMBLOCKS        11      /* Offset for NumberOfBlocks (in CHECK response) */
293 #define T3T_MSG_RSP_OFFSET_CHECK_DATA       12      /* Offset for Block Data (in CHECK response) */
294 #define T3T_MSG_RSP_OFFSET_POLL_PMM         9       /* Offset for PMm (in POLL response) */
295 #define T3T_MSG_RSP_OFFSET_POLL_RD          17      /* Offset for RD (in POLL response) */
296 #define T3T_MSG_RSP_OFFSET_NUMSYS           9       /* Offset for Number of Systems */
297 
298 #define T3T_MSG_RSP_STATUS_OK                       0x00
299 #define T3T_MSG_RSP_STATUS_ERROR                    0x01
300 
301 #define T3T_MSG_RSP_STATUS2_ERROR_MEMORY            0x70
302 #define T3T_MSG_RSP_STATUS2_ERROR_EXCESSIVE_WRITES  0x71
303 #define T3T_MSG_RSP_STATUS2_ERROR_PROCESSING        0xFF
304 
305 #define T3T_NFC_F_MAX_PAYLOAD_LEN                   0xFE    /* Maximum payload lenght for NFC-F messages (including SoD) */
306 
307 /* Felica Lite defintions */
308 #define T3T_MSG_FELICALITE_BLOCK_ID_MC              0x88    /* Block ID for MC (memory configuration)                       */
309 #define T3T_MSG_FELICALITE_MC_OFFSET_SYS_OP         0x03    /* Memory Configuration Block offset: SYS_OP (System Option)    */
310 
311 
312 
313 /*
314 **
315 **  Type 4 Tag Definitions
316 **
317 */
318 #define T4T_CMD_MIN_HDR_SIZE            4       /* CLA, INS, P1, P2 */
319 #define T4T_CMD_MAX_HDR_SIZE            5       /* CLA, INS, P1, P2, Lc */
320 
321 #define T4T_VERSION_2_0                 0x20    /* version 2.0 */
322 #define T4T_VERSION_1_0                 0x10    /* version 1.0 */
323 #define T4T_MY_VERSION                  T4T_VERSION_2_0
324 #define T4T_GET_MAJOR_VERSION(x)        ((x) >> 4)
325 #define T4T_GET_MINOR_VERSION(x)        ((x) & 0x0F )
326 
327 #define T4T_CMD_CLASS                   0x00
328 #define T4T_CMD_INS_SELECT              0xA4
329 #define T4T_CMD_INS_READ_BINARY         0xB0
330 #define T4T_CMD_INS_UPDATE_BINARY       0xD6
331 #define T4T_CMD_P1_SELECT_BY_NAME       0x04
332 #define T4T_CMD_P1_SELECT_BY_FILE_ID    0x00
333 #define T4T_CMD_P2_FIRST_OR_ONLY_00H    0x00
334 #define T4T_CMD_P2_FIRST_OR_ONLY_0CH    0x0C
335 
336 #define T4T_MAX_LENGTH_LE               0xFF    /* Max number of bytes to be read from file in ReadBinary Command */
337 #define T4T_MAX_LENGTH_LC               0xFF    /* Max number of bytes written to NDEF file in UpdateBinary Command */
338 
339 #define T4T_RSP_STATUS_WORDS_SIZE       0x02
340 
341 #define T4T_RSP_CMD_CMPLTED             0x9000
342 #define T4T_RSP_NOT_FOUND               0x6A82
343 #define T4T_RSP_WRONG_PARAMS            0x6B00
344 #define T4T_RSP_CLASS_NOT_SUPPORTED     0x6E00
345 #define T4T_RSP_WRONG_LENGTH            0x6700
346 #define T4T_RSP_INSTR_NOT_SUPPORTED     0x6D00
347 #define T4T_RSP_CMD_NOT_ALLOWED         0x6986
348 
349 #define T4T_V10_NDEF_TAG_AID_LEN        0x07    /* V1.0 Type 4 Tag Applicaiton ID length */
350 #define T4T_V20_NDEF_TAG_AID_LEN        0x07    /* V2.0 Type 4 Tag Applicaiton ID length */
351 
352 #define T4T_MIN_MLE                     0x000F  /* Min of Max R-APDU data size */
353 
354 #define T4T_FILE_ID_SIZE                0x02
355 #define T4T_CC_FILE_ID                  0xE103
356 #define T4T_CC_FILE_MIN_LEN             0x000F
357 
358 #define T4T_VERSION_OFFSET_IN_CC        0x02
359 #define T4T_FC_TLV_OFFSET_IN_CC         0x07
360 
361 #define T4T_NDEF_FILE_CONTROL_TYPE      0x04    /* NDEF File Control Type */
362 #define T4T_PROP_FILE_CONTROL_TYPE      0x05    /* Proprietary File Control Type */
363 
364 #define T4T_FILE_CONTROL_TLV_SIZE       0x08    /* size of T(1),L(1),V(6) for file control */
365 #define T4T_FILE_CONTROL_LENGTH         0x06    /* size of V(6) for file control */
366 
367 #define T4T_FC_READ_ACCESS              0x00    /* read access granted without any security */
368 #define T4T_FC_WRITE_ACCESS             0x00    /* write access granted without any security */
369 #define T4T_FC_NO_WRITE_ACCESS          0xFF    /* no write access granted at all (read-only) */
370 
371 #define T4T_FILE_LENGTH_SIZE            0x02
372 
373 /*
374 **
375 **  ISO 15693 Tag Definitions
376 **
377 */
378 
379 /* Request flags 1 to 4 definition */
380 #define I93_FLAG_SUB_CARRIER_MASK           0x01    /* Sub_carrier_flag */
381 #define I93_FLAG_SUB_CARRIER_SINGLE         0x00    /* A single sub-carrier frequency shall be used by VICC */
382 #define I93_FLAG_SUB_CARRIER_DOUBLE         0x01    /* Two sub-carriers shall be used by VICC               */
383 
384 #define I93_FLAG_DATA_RATE_MASK             0x02    /* Data_rate_flag */
385 #define I93_FLAG_DATA_RATE_LOW              0x00    /* Low data rate shall be used  */
386 #define I93_FLAG_DATA_RATE_HIGH             0x02    /* High data rate shall be used */
387 
388 #define I93_FLAG_INVENTORY_MASK             0x04    /* Inventory_flag */
389 #define I93_FLAG_INVENTORY_UNSET            0x00    /* Flags 5 to 8 meaning is according to table 4 */
390 #define I93_FLAG_INVENTORY_SET              0x04    /* Flags 5 to 8 meaning is according to table 5 */
391 
392 #define I93_FLAG_PROT_EXT_MASK              0x08    /* Protocol_Extension_flag */
393 #define I93_FLAG_PROT_EXT_NO                0x00    /* No protocol format extension                         */
394 #define I93_FLAG_PROT_EXT_YES               0x08    /* Protocol format is extended. Reserved for future use */
395 
396 /* Request flags 5 to 6 definition when inventory flag is not set */
397 #define I93_FLAG_SELECT_MASK                0x10    /* Select_flag */
398 #define I93_FLAG_SELECT_UNSET               0x00    /* Request shall be executed by any VICC according to the setting of Address_flag */
399 #define I93_FLAG_SELECT_SET                 0x10    /* Request shall be executed only by VICC in selected state */
400                                                     /* The Address_flag shall be set to 0 and the UID field shall bot be included in the request */
401 
402 #define I93_FLAG_ADDRESS_MASK               0x20    /* Address_flag */
403 #define I93_FLAG_ADDRESS_UNSET              0x00    /* Request is not addressed. UID field is not included. It shall be executed by any VICC */
404 #define I93_FLAG_ADDRESS_SET                0x20    /* Request is addressed. UID field is included. It shall be executed only by VICC */
405                                                     /* whose UID matches the UID specified in the request */
406 
407 /* Request flags 5 to 6 definition when inventory flag is set */
408 #define I93_FLAG_AFI_MASK                   0x10    /* AFI_flag */
409 #define I93_FLAG_AFI_NOT_PRESENT            0x00    /* AFI field is not present */
410 #define I93_FLAG_AFI_PRESENT                0x10    /* AFI field is present     */
411 
412 #define I93_FLAG_SLOT_MASK                  0x20    /* Nb_slots_flag */
413 #define I93_FLAG_SLOT_16                    0x00    /* 16 slots */
414 #define I93_FLAG_SLOT_ONE                   0x20    /* 1 slot   */
415 
416 /* Request flags 6 to 8 definition when inventory flag is set or not set */
417 
418 #define I93_FLAG_OPTION_MASK                0x40    /* Option_flag */
419 #define I93_FLAG_OPTION_UNSET               0x00    /* Meaning is defined by the command description. */
420                                                     /* It shall be set to 0 if not otherwise defined by command */
421 #define I93_FLAG_OPTION_SET                 0x40    /* Meaning is defined by the command description. */
422 
423 /* Response flags */
424 #define I93_FLAG_ERROR_MASK                 0x01    /* Error_flag */
425 #define I93_FLAG_ERORR_NOT_DETECTED         0x00    /* No error                                           */
426 #define I93_FLAG_ERROR_DETECTED             0x01    /* Error detected, Error code is in the "Error" field */
427 
428 /* Response error code */
429 #define I93_ERROR_CODE_NOT_SUPPORTED        0x01    /* The command is not supported, i.e. the request code is not recognized */
430 #define I93_ERROR_CODE_NOT_RECOGNIZED       0x02    /* The command is not recognized, for example: a format error occured    */
431 #define I93_ERROR_CODE_OPTION_NOT_SUPPORTED 0x03    /* The command option is not supported                                   */
432 #define I93_ERROR_CODE_NO_INFO              0x0F    /* Error with no information given or a specific error code is not supported */
433 #define I93_ERROR_CODE_BLOCK_NOT_AVAILABLE  0x10    /* The specific block is not available (doesn't exist)                   */
434 #define I93_ERROR_CODE_BLOCK_ALREADY_LOCKED 0x11    /* The specific block is already locked and thus cannot be locked again  */
435 #define I93_ERROR_CODE_BLOCK_LOCKED         0x12    /* The specific block is locked and its content cannot be changed        */
436 #define I93_ERROR_CODE_BLOCK_FAIL_TO_WRITE  0x13    /* The specific block is was not successfully programmed                 */
437 #define I93_ERROR_CODE_BLOCK_FAIL_TO_LOCK   0x14    /* The specific block is was not successfully locked                     */
438 
439 #define I93_UID_BYTE_LEN                    8       /* UID length in bytes                  */
440 #define I93_DFS_UNSUPPORTED                 0x00    /* Data Storage Format is not supported */
441 #define I93_BLOCK_UNLOCKED                  0x00    /* Block is not locked                  */
442 #define I93_BLOCK_LOCKED                    0x01    /* Block is locked                      */
443 
444 /* ISO 15693 Mandatory commands */
445 #define I93_CMD_INVENTORY                   0x01    /* Inventory  */
446 #define I93_CMD_STAY_QUIET                  0x02    /* Stay Quiet */
447 
448 /* ISO 15693 Optional commands */
449 #define I93_CMD_READ_SINGLE_BLOCK           0x20    /* Read single block     */
450 #define I93_CMD_WRITE_SINGLE_BLOCK          0x21    /* Write single block    */
451 #define I93_CMD_LOCK_BLOCK                  0x22    /* Lock block            */
452 #define I93_CMD_READ_MULTI_BLOCK            0x23    /* Read multiple blocks  */
453 #define I93_CMD_WRITE_MULTI_BLOCK           0x24    /* Write multiple blocks */
454 #define I93_CMD_SELECT                      0x25    /* Select                */
455 #define I93_CMD_RESET_TO_READY              0x26    /* Reset to ready        */
456 #define I93_CMD_WRITE_AFI                   0x27    /* Wreite AFI            */
457 #define I93_CMD_LOCK_AFI                    0x28    /* Lock AFI              */
458 #define I93_CMD_WRITE_DSFID                 0x29    /* Write DSFID           */
459 #define I93_CMD_LOCK_DSFID                  0x2A    /* Lock DSFID            */
460 #define I93_CMD_GET_SYS_INFO                0x2B    /* Get system information             */
461 #define I93_CMD_GET_MULTI_BLK_SEC           0x2C    /* Get multiple block security status */
462 
463 /* Information flags definition */
464 #define I93_INFO_FLAG_DSFID                 0x01    /* DSFID is supported and DSFID field is present */
465 #define I93_INFO_FLAG_AFI                   0x02    /* AFI is supported and AFI field is present     */
466 #define I93_INFO_FLAG_MEM_SIZE              0x04    /* VICC memory size field is present             */
467 #define I93_INFO_FLAG_IC_REF                0x08    /* IC reference field is present                 */
468 
469 #define I93_MAX_BLOCK_LENGH                 32      /* Max block size in bytes */
470 #define I93_MAX_NUM_BLOCK                   256     /* Max number of blocks    */
471 
472 /* ICODE Capability Container(CC) definition */
473 #define I93_ICODE_CC_MAGIC_NUMER            0xE1    /* magic number in CC[0]  */
474 #define I93_ICODE_CC_MAJOR_VER_MASK         0xC0    /* major version in CC[1] */
475 #define I93_ICODE_CC_MINOR_VER_MASK         0x30    /* minor version in CC[1] */
476 #define I93_ICODE_CC_READ_ACCESS_MASK       0x0C    /* read access condition in CC[1]        */
477 #define I93_ICODE_CC_READ_ACCESS_GRANTED    0x00    /* read access granted without security  */
478 #define I93_ICODE_CC_WRITE_ACCESS_MASK      0x03    /* write access condition in CC[1]       */
479 #define I93_ICODE_CC_WRITE_ACCESS_GRANTED   0x00    /* write access granted without security */
480 #define I93_ICODE_CC_READ_ONLY              0x03    /* write access not granted at all       */
481 #define I93_ICODE_CC_MBREAD_MASK            0x01    /* read multi block supported in CC[3]   */
482 #define I93_ICODE_CC_IPREAD_MASK            0x02    /* inventory page read supported in CC[3] */
483 
484 /* ICODE TLV type */
485 #define I93_ICODE_TLV_TYPE_NULL             0x00    /* NULL TLV         */
486 #define I93_ICODE_TLV_TYPE_NDEF             0x03    /* NDEF message TLV */
487 #define I93_ICODE_TLV_TYPE_PROP             0xFD    /* Proprietary TLV  */
488 #define I93_ICODE_TLV_TYPE_TERM             0xFE    /* Terminator TLV   */
489 
490 /* UID Coding (UID Bit 64-57), First byte of ISO 15693 UID */
491 #define I93_UID_FIRST_BYTE                      0xE0
492 
493 /* UID Coding (UID Bit 56-49), IC manufacturer code */
494 #define I93_UID_IC_MFG_CODE_NXP                 0x04
495 #define I93_UID_IC_MFG_CODE_TI                  0x07
496 
497 /* NXP, UID Coding of ICODE type (UID Bit 48-41) */
498 #define I93_UID_ICODE_SLI                       0x01    /* ICODE SLI, SLIX     */
499 #define I93_UID_ICODE_SLI_S                     0x02    /* ICODE SLI-S, SLIX-S */
500 #define I93_UID_ICODE_SLI_L                     0x03    /* ICODE SLI-L, SLIX-L */
501 
502 #define I93_IC_REF_ICODE_SLI_L                  0x03    /* IC Reference for ICODE SLI-L */
503 #define I93_ICODE_IC_REF_MBREAD_MASK            0x02    /* read multi block supported check bit */
504 
505 /* TI, UID Coding of product version (UID Bit 48-42) */
506 #define I93_UID_TAG_IT_HF_I_PRODUCT_ID_MASK     0xFE    /* upper 7 bits                     */
507 #define I93_UID_TAG_IT_HF_I_PLUS_INLAY          0x00    /* Tag-it HF-I Plus Inlay           */
508 #define I93_UID_TAG_IT_HF_I_PLUS_CHIP           0x80    /* Tag-it HF-I Plus Chip            */
509 #define I93_UID_TAG_IT_HF_I_STD_CHIP_INLAY      0xC0    /* Tag-it HF-I Standard Chip/Inlyas */
510 #define I93_UID_TAG_IT_HF_I_PRO_CHIP_INLAY      0xC4    /* Tag-it HF-I Pro Chip/Inlyas      */
511 
512 #define I93_TAG_IT_HF_I_STD_CHIP_INLAY_NUM_TOTAL_BLK   11
513 #define I93_TAG_IT_HF_I_PRO_CHIP_INLAY_NUM_TOTAL_BLK   12
514 
515 #define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_BLK_SIZE         4
516 #define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_NUM_USER_BLK     8
517 #define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_AFI_LOCATION    40   /* LSB in Block 0x0A */
518 
519 #endif /* TAGS_DEFS_H */
520