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 #define T1T_DYNAMIC_HR0 0x12 85 /* HR0 value is 0x1y, indicates NDEF supported */ 86 #define T1T_NDEF_SUPPORTED 0x10 87 /* should be ignored */ 88 #define T1T_HR1 0x00 89 /* UID block */ 90 #define T1T_UID_BLOCK 0x00 91 /* Reserved block */ 92 #define T1T_RES_BLOCK 0x0D 93 /* Static lock block */ 94 #define T1T_LOCK_BLOCK 0x0E 95 /* Manufacturer ID offset */ 96 #define T1T_MID_OFFSET 0x06 97 /* Reserved bytes offset */ 98 #define T1T_STATIC_RES_OFFSET 0x68 99 /* Static lock offset */ 100 #define T1T_LOCK_0_OFFSET 0x70 101 /* Static lock offset */ 102 #define T1T_LOCK_1_OFFSET 0x71 103 /* Block F - typically used for dynamic locks */ 104 #define T1T_DYNAMIC_LOCK_OFFSET 0x78 105 #define T1T_DYNAMIC_LOCK_BYTES 0x08 106 107 /* the len of reserved byte in T1T block 0 */ 108 #define T1T_RES_BYTE_LEN 1 109 110 /* Capability Container definitions */ 111 /* Capability container block */ 112 #define T1T_CC_BLOCK 1 113 /* the len of CC used in T1T tag */ 114 #define T1T_CC_LEN 4 115 /* CC offset */ 116 /* Offset for NDEF magic number in CC */ 117 #define T1T_CC_NMN_OFFSET 0x00 118 /* Offset for Version number in CC */ 119 #define T1T_CC_VNO_OFFSET 0x01 120 /* Offset for Tag memory size in CC */ 121 #define T1T_CC_TMS_OFFSET 0x02 122 /* Offset for Read/Write access in CC */ 123 #define T1T_CC_RWA_OFFSET 0x03 124 /* NDEF Magic Number byte number */ 125 #define T1T_CC_NMN_BYTE 0x08 126 /* Version Number byte number */ 127 #define T1T_CC_VNO_BYTE 0x09 128 /* Tag Memory Size byte number */ 129 #define T1T_CC_TMS_BYTE 0x0A 130 /* Read Write Access byte number */ 131 #define T1T_CC_RWA_BYTE 0x0B 132 /* NDEF Magic Number */ 133 #define T1T_CC_NMN 0xE1 134 /* Supported Legacy Version */ 135 #define T1T_CC_LEGACY_VNO 0x10 136 /* Version Number */ 137 #define T1T_CC_VNO 0x11 138 /* TMS static memory - (8 * (n+1)). */ 139 #define T1T_CC_TMS_STATIC 0x0E 140 /* RWA - Read/write allowed */ 141 #define T1T_CC_RWA_RW 0x00 142 /* RWA - Read only */ 143 #define T1T_CC_RWA_RO 0x0F 144 145 /* May be used for padding. SHALL ignore this */ 146 #define T1T_TAG_NULL 0 147 /* Defines details of the lock bytes */ 148 #define T1T_TAG_LOCK_CTRL 1 149 /* Identifies reserved memory areas */ 150 #define T1T_TAG_MEM_CTRL 2 151 /* Contains the NDEF message */ 152 #define T1T_TAG_NDEF 3 153 /* Tag proprietary information */ 154 #define T1T_TAG_PROPRIETARY 0xFD 155 /* Last TLV block in the data area */ 156 #define T1T_TAG_TERMINATOR 0xFE 157 158 /* Tlv len for LOCK_CTRL/MEM TLV per spec */ 159 #define T1T_DEFAULT_TLV_LEN 3 160 /* Tlv type identifier len */ 161 #define T1T_TLV_TYPE_LEN 1 162 /* Length field size of lock/mem tlv */ 163 #define T1T_DEFAULT_TLV_LEN_FIELD_LEN 1 164 165 /* the len of HR used in Type 1 Tag */ 166 #define T1T_HR_LEN 2 167 /* the len of UID used in Type 1 Tag Commands */ 168 #define T1T_CMD_UID_LEN 4 169 /* the len of UID used in Type 1 Tag */ 170 #define T1T_UID_LEN 7 171 #define T1T_ADD_LEN 1 172 173 /* Length Field size of short NDEF Message */ 174 #define T1T_SHORT_NDEF_LEN_FIELD_LEN 1 175 /* Length Field size of Long NDEF Message */ 176 #define T1T_LONG_NDEF_LEN_FIELD_LEN 3 177 /* Byte 0 in Length field to indicate LNDEF*/ 178 #define T1T_LONG_NDEF_LEN_FIELD_BYTE0 0xFF 179 /* Min. len of NDEF to qualify as LNDEF */ 180 #define T1T_LONG_NDEF_MIN_LEN 0x00FF 181 182 /* Type 1 Tag Commands (7 bits) */ 183 /* read id */ 184 #define T1T_CMD_RID 0x78 185 /* read all bytes */ 186 #define T1T_CMD_RALL 0x00 187 /* read (1 byte) */ 188 #define T1T_CMD_READ 0x01 189 /* write with erase (1 byte) */ 190 #define T1T_CMD_WRITE_E 0x53 191 /* write no erase (1 byte) */ 192 #define T1T_CMD_WRITE_NE 0x1A 193 /* dynamic memory only */ 194 /* read segment */ 195 #define T1T_CMD_RSEG 0x10 196 /* read (8 byte) */ 197 #define T1T_CMD_READ8 0x02 198 /* write with erase (8 byte) */ 199 #define T1T_CMD_WRITE_E8 0x54 200 /* write no erase (8 byte) */ 201 #define T1T_CMD_WRITE_NE8 0x1B 202 203 /* Lock */ 204 /* Number of static lock bytes in tag */ 205 #define T1T_NUM_STATIC_LOCK_BYTES 2 206 /* Bytes locked by one static lock bit */ 207 #define T1T_BYTES_LOCKED_BY_STATIC_LOCK_BIT 4 208 209 /* Type 2 Tag related definitions */ 210 #define T2T_STATIC_MEM_STR 0 211 #define T2T_DYNAMIC_MEM_STR 1 212 #define T2T_STATIC_SIZE 64 213 #define T2T_STATIC_BLOCKS 16 /* block 0 to Block 15 */ 214 #define T2T_BLOCK_SIZE 4 215 #define T2T_HEADER_BLOCKS 4 216 #define T2T_HEADER_SIZE 16 217 #define T2T_SECTOR_SIZE 1024 218 #define T2T_BLOCKS_PER_SECTOR 0x100 219 220 #define T2T_UID_LEN 4 /* the len of UID used in T2T tag */ 221 #define T2T_BLOCK0_UID_LEN 3 /* the len of UID in Block 0 of T2T tag */ 222 #define T2T_BCC0_LEN 1 /* the len of BCC0 of T2T tag */ 223 #define T2T_BLOCK1_UID_LEN 4 /* the len of UID in Block 1 of T2T tag */ 224 #define T2T_BCC1_LEN 1 /* the len of BCC0 of T2T tag */ 225 /* the len of Serial number used in T2T tag */ 226 #define T2T_SNO_LEN 4 227 #define T2T_INTERNAL_BYTES_LEN 2 /* the len of internal used in T2T tag */ 228 /* the len of static lock used in T2T tag */ 229 #define T2T_STATIC_LOCK_LEN 2 230 /* Static Lock Bytes */ 231 #define T2T_STATIC_LOCK0 0x0A /* Static Lock 0 offset */ 232 #define T2T_STATIC_LOCK1 0x0B /* Static Lock 1 offset */ 233 234 /* the len of CC used in T2T tag */ 235 #define T2T_CC_LEN 4 236 237 /* Capability Container definitions */ 238 #define T2T_CC_BLOCK 0x03 /* Capability container block */ 239 #define T2T_CC0_NMN_BYTE 0x0C /* NDEF Magic Number byte number */ 240 #define T2T_CC1_VNO_BYTE 0x0D /* Version Number byte number*/ 241 #define T2T_CC2_TMS_BYTE 0x0E /* Tag Memory Size byte number */ 242 #define T2T_CC3_RWA_BYTE 0x0F /* Read Write Access byte number */ 243 #define T2T_DATA_MEM 0x10 /* Data Memory */ 244 245 #define T2T_CC0_NMN 0xE1 /* NDEF Magic Number */ 246 #define T2T_CC1_VNO 0x11 /* Version Number */ 247 #define T2T_CC1_LEGACY_VNO 0x10 /* Legacy Version Number */ 248 #define T2T_CC1_NEW_VNO 0x12 /* Another supported Version Number */ 249 #define T2T_CC2_TMS_STATIC 0x06 /* TMS static memory - (4 * (n+1)). */ 250 #define T2T_CC3_RWA_RW 0x00 /* RWA - Read/write allowed */ 251 #define T2T_CC3_RWA_RO 0x0F /* RWA - Read only */ 252 253 /* Factor to multiply to get tag data size from TMS */ 254 #define T2T_TMS_TAG_FACTOR 0x08 255 /* Bytes locked per lock bit of default locks */ 256 #define T2T_DEFAULT_LOCK_BLPB 0x08 257 258 /* Type 2 Tag Commands */ 259 #define T2T_CMD_READ 0x30 /* read 4 blocks (16 bytes) */ 260 #define T2T_CMD_WRITE 0xA2 /* write 1 block (4 bytes) */ 261 #define T2T_CMD_SEC_SEL 0xC2 /* Sector select */ 262 #define T2T_RSP_ACK 0xA 263 #define T2T_RSP_NACK5 0x5 264 #define T2T_RSP_NACK1 0x1 /* Nack can be either 1 */ 265 266 #define T2T_STATUS_OK_1_BIT 0x11 267 #define T2T_STATUS_OK_2_BIT 0x12 268 #define T2T_STATUS_OK_3_BIT 0x13 269 #define T2T_STATUS_OK_4_BIT 0x14 270 #define T2T_STATUS_OK_5_BIT 0x15 271 #define T2T_STATUS_OK_6_BIT 0x16 272 #define T2T_STATUS_OK_7_BIT 0x17 273 274 #define T2T_FIRST_DATA_BLOCK 4 275 #define T2T_READ_BLOCKS 4 276 #define T2T_BLOCK_LEN 4 277 #define T2T_READ_DATA_LEN (T2T_BLOCK_LEN * T2T_READ_BLOCKS) 278 #define T2T_WRITE_DATA_LEN 4 279 280 /* Type 2 TLV definitions */ 281 /* May be used for padding. SHALL ignore this */ 282 #define T2T_TLV_TYPE_NULL 0 283 #define T2T_TLV_TYPE_LOCK_CTRL 1 /* Defines details of the lock bytes */ 284 #define T2T_TLV_TYPE_MEM_CTRL 2 /* Identifies reserved memory areas */ 285 #define T2T_TLV_TYPE_NDEF 3 /* Contains the NDEF message */ 286 #define T2T_TLV_TYPE_PROPRIETARY 0xFD /* Tag proprietary information */ 287 #define T2T_TLV_TYPE_TERMINATOR 0xFE /* Last TLV block in the data area */ 288 289 /* Tag len for LOCK_CTRL TLV per spec */ 290 #define T2T_TLEN_LOCK_CTRL_TLV 3 291 #define T2T_TLEN_MEM_CTRL_TLV 3 /* Tag len for MEM_CTRL TLV per spec */ 292 293 /* Maximum number of sectors supported */ 294 #if (APPL_DTA_MODE == TRUE) 295 #define T2T_MAX_SECTOR 3 296 #else 297 #define T2T_MAX_SECTOR 2 298 #endif 299 /* Tlv type identifier len */ 300 #define T2T_TLV_TYPE_LEN 1 301 302 /* Tlv len for LOCK_CTRL/MEM TLV per spec */ 303 #define T2T_DEFAULT_TLV_LEN 3 304 /* Length Field size of short NDEF Message */ 305 #define T2T_SHORT_NDEF_LEN_FIELD_LEN 1 306 /* Length Field size of Long NDEF Message */ 307 #define T2T_LONG_NDEF_LEN_FIELD_LEN 3 308 /* Byte 0 in Length field to indicate LNDEF*/ 309 #define T2T_LONG_NDEF_LEN_FIELD_BYTE0 0xFF 310 /* Min. len of NDEF to qualify as LNDEF */ 311 #define T2T_LONG_NDEF_MIN_LEN 0x00FF 312 313 /* Lock */ 314 /* Number of static lock bytes in tag */ 315 #define T2T_NUM_STATIC_LOCK_BYTES 2 316 /* Bytes locked by one static lock bit */ 317 #define T2T_BYTES_LOCKED_BY_STATIC_LOCK_BIT 4 318 319 #define T2T_CC2_TMS_MUL 0x06 320 #define T2T_CC2_TMS_MULC 0x12 321 /* 322 ** 323 ** Type 3 Tag Definitions 324 ** 325 */ 326 327 #define T3T_SYSTEM_CODE_NDEF 0x12FC /* System Code for NDEF tags */ 328 /* System Code for felica-lite tags */ 329 #define T3T_SYSTEM_CODE_FELICA_LITE 0x88B4 330 #define T3T_MAX_SYSTEM_CODES 16 331 /* Maximum number of blocks for NDEF message for Felica Lite tags */ 332 #define T3T_FELICALITE_NMAXB 13 333 334 /* Block descriptor, used to describe a block to check/update */ 335 typedef struct { 336 uint16_t service_code; /* Block service code. Set to T3T_SERVICE_CODE_NDEF 337 (0x000B) for NDEF data */ 338 uint16_t block_number; /* Block number */ 339 } tT3T_BLOCK_DESC; 340 341 /* Poll RC (request code) definitions */ 342 #define T3T_POLL_RC_NONE 0 /* No RD requested in SENSF_RES */ 343 #define T3T_POLL_RC_SC 1 /* System code requested in SENSF_RES */ 344 /* Avanced protocol features requested in SENSF_RES */ 345 #define T3T_POLL_RC_COMM 2 346 typedef uint8_t tT3T_POLL_RC; 347 348 /* Definitions for constructing t3t command messages */ 349 350 /* NFC Forum / Felica commands */ 351 #define T3T_MSG_OPC_CHECK_CMD 0x06 352 #define T3T_MSG_OPC_CHECK_RSP 0x07 353 #define T3T_MSG_OPC_UPDATE_CMD 0x08 354 #define T3T_MSG_OPC_UPDATE_RSP 0x09 355 356 /* Felica commands (not specified in NFC-Forum Type 3 tag specifications) */ 357 #define T3T_MSG_OPC_POLL_CMD 0x00 358 #define T3T_MSG_OPC_POLL_RSP 0x01 359 #define T3T_MSG_OPC_REQ_SERVICE_CMD 0x02 360 #define T3T_MSG_OPC_REQ_SERVICE_RSP 0x03 361 #define T3T_MSG_OPC_REQ_RESPONSE_CMD 0x04 362 #define T3T_MSG_OPC_REQ_RESPONSE_RSP 0x05 363 #define T3T_MSG_OPC_REQ_SYSTEMCODE_CMD 0x0C 364 #define T3T_MSG_OPC_REQ_SYSTEMCODE_RSP 0x0D 365 366 /* Service code: read-only NDEF */ 367 #define T3T_MSG_NDEF_SC_RO 0x000B 368 /* Service code: read/write NDEF */ 369 #define T3T_MSG_NDEF_SC_RW 0x0009 370 #define T3T_MSG_NDEF_VERSION 0x10 /* NDEF Mapping Version 1.0 */ 371 #define T3T_MSG_NDEF_WRITEF_OFF 0x00 372 #define T3T_MSG_NDEF_WRITEF_ON 0x0F 373 #define T3T_MSG_NDEF_RWFLAG_RO 0x00 374 #define T3T_MSG_NDEF_RWFLAG_RW 0x01 375 /* Size of NDEF attribute info block (minus checksum) */ 376 #define T3T_MSG_NDEF_ATTR_INFO_SIZE 14 377 378 /* offset of Manufacturer ID in UPDATE/CHECK messages */ 379 #define T3T_MSG_OFFSET_IDM 1 380 /* offset of Number of Services parameter in UPDATE/CHECK messages */ 381 #define T3T_MSG_OFFSET_NUM_SERVICES 9 382 /* offset of Service Code List parameter in UPDATE/CHECK messages */ 383 #define T3T_MSG_OFFSET_SERVICE_CODE_LIST 10 384 /* len flag for Block List Element */ 385 #define T3T_MSG_MASK_TWO_BYTE_BLOCK_DESC_FORMAT 0x80 386 /* service code list mask */ 387 #define T3T_MSG_SERVICE_LIST_MASK 0x0F 388 #define T3T_MSG_SERVICE_LIST_MAX 16 389 390 /* Max Number of Services per UPDATE command */ 391 #define T3T_MSG_NUM_SERVICES_UPDATE_MAX 12 392 /* Max Number of Services per CHECK command */ 393 #define T3T_MSG_NUM_SERVICES_CHECK_MAX 15 394 /* Max Number of Blocks per UPDATE command */ 395 #define T3T_MSG_NUM_BLOCKS_UPDATE_MAX 13 396 /* Max Number of Blocks per CHECK command */ 397 #define T3T_MSG_NUM_BLOCKS_CHECK_MAX 15 398 399 /* Data block size for UPDATE and CHECK commands */ 400 #define T3T_MSG_BLOCKSIZE 16 401 402 /* Common header definitions for T3t commands */ 403 /* Common header: SoD + cmdcode + NFCID2 + num_services */ 404 #define T3T_MSG_CMD_COMMON_HDR_LEN 11 405 406 /* Common header definition for T3t responses */ 407 /* Common header: rspcode + NFCID2 + StatusFlag1 + StatusFlag2 */ 408 #define T3T_MSG_RSP_COMMON_HDR_LEN 11 409 /* Common header + NumBlocks */ 410 #define T3T_MSG_RSP_CHECK_HDR_LEN (T3T_MSG_RSP_COMMON_HDR_LEN + 1) 411 /* Offset for Response code */ 412 #define T3T_MSG_RSP_OFFSET_RSPCODE 0 413 /* Offset for Manufacturer ID */ 414 #define T3T_MSG_RSP_OFFSET_IDM 1 415 /* Offset for Status Flag1 */ 416 #define T3T_MSG_RSP_OFFSET_STATUS1 9 417 /* Offset for NumberOfBlocks (in CHECK response) */ 418 #define T3T_MSG_RSP_OFFSET_NUMBLOCKS 11 419 /* Offset for Block Data (in CHECK response) */ 420 #define T3T_MSG_RSP_OFFSET_CHECK_DATA 12 421 /* Offset for PMm (in POLL response) */ 422 #define T3T_MSG_RSP_OFFSET_POLL_PMM 9 423 /* Offset for RD (in POLL response) */ 424 #define T3T_MSG_RSP_OFFSET_POLL_RD 17 425 /* Offset for Number of Systems */ 426 #define T3T_MSG_RSP_OFFSET_NUMSYS 9 427 428 #define T3T_MSG_RSP_STATUS_OK 0x00 429 #define T3T_MSG_RSP_STATUS_ERROR 0x01 430 431 #define T3T_MSG_RSP_STATUS2_ERROR_MEMORY 0x70 432 #define T3T_MSG_RSP_STATUS2_ERROR_EXCESSIVE_WRITES 0x71 433 #define T3T_MSG_RSP_STATUS2_ERROR_PROCESSING 0xFF 434 435 /* Maximum payload lenght for NFC-F messages (including SoD) */ 436 #define T3T_NFC_F_MAX_PAYLOAD_LEN 0xFE 437 438 /* Felica Lite defintions */ 439 /* Block ID for MC (memory configuration) */ 440 #define T3T_MSG_FELICALITE_BLOCK_ID_MC 0x88 441 442 /* Memory Configuration Block offset: MC_SP (Memory Configuration for scratch 443 * pad) */ 444 #define T3T_MSG_FELICALITE_MC_OFFSET_MC_SP 0x00 445 /* Memory Configuration Block offset: MC_ALL (Memory Configuration for system 446 * block) */ 447 #define T3T_MSG_FELICALITE_MC_OFFSET_MC_ALL 0x02 448 /* Memory Configuration Block offset: SYS_OP (System Option) */ 449 #define T3T_MSG_FELICALITE_MC_OFFSET_SYS_OP 0x03 450 /* Memory Configuration Block offset: RF_PRM (Memory Configuration for RF 451 * Parameter) */ 452 #define T3T_MSG_FELICALITE_MC_OFFSET_RF_PRM 0x04 453 454 /* 455 ** 456 ** Type 4 Tag Definitions 457 ** 458 */ 459 #define T4T_CMD_MIN_HDR_SIZE 4 /* CLA, INS, P1, P2 */ 460 #define T4T_CMD_MAX_HDR_SIZE 5 /* CLA, INS, P1, P2, Lc */ 461 462 #define T4T_VERSION_2_0 0x20 /* version 2.0 */ 463 #define T4T_VERSION_1_0 0x10 /* version 1.0 */ 464 #define T4T_MY_VERSION T4T_VERSION_2_0 465 #define T4T_GET_MAJOR_VERSION(x) ((x) >> 4) 466 #define T4T_GET_MINOR_VERSION(x) ((x)&0x0F) 467 468 #define T4T_CMD_CLASS 0x00 469 #define T4T_CMD_INS_SELECT 0xA4 470 #define T4T_CMD_INS_READ_BINARY 0xB0 471 #define T4T_CMD_INS_UPDATE_BINARY 0xD6 472 #define T4T_CMD_DES_CLASS 0x90 473 #define T4T_CMD_INS_GET_HW_VERSION 0x60 474 #define T4T_CMD_CREATE_AID 0xCA 475 #define T4T_CMD_SELECT_APP 0x5A 476 #define T4T_CMD_CREATE_DATAFILE 0xCD 477 #define T4T_CMD_DES_WRITE 0x3D 478 #define T4T_CMD_P1_SELECT_BY_NAME 0x04 479 #define T4T_CMD_P1_SELECT_BY_FILE_ID 0x00 480 #define T4T_CMD_P2_FIRST_OR_ONLY_00H 0x00 481 #define T4T_CMD_P2_FIRST_OR_ONLY_0CH 0x0C 482 483 /* Max number of bytes to be read from file in ReadBinary Command */ 484 #define T4T_MAX_LENGTH_LE 0xFF 485 /* Max number of bytes written to NDEF file in UpdateBinary Command */ 486 #define T4T_MAX_LENGTH_LC 0xFF 487 488 #define T4T_RSP_STATUS_WORDS_SIZE 0x02 489 490 #define T4T_RSP_CMD_CMPLTED 0x9000 491 #define T4T_RSP_NOT_FOUND 0x6A82 492 #define T4T_RSP_WRONG_PARAMS 0x6B00 493 #define T4T_RSP_CLASS_NOT_SUPPORTED 0x6E00 494 #define T4T_RSP_WRONG_LENGTH 0x6700 495 #define T4T_RSP_INSTR_NOT_SUPPORTED 0x6D00 496 #define T4T_RSP_CMD_NOT_ALLOWED 0x6986 497 498 /* V1.0 Type 4 Tag Applicaiton ID length */ 499 #define T4T_V10_NDEF_TAG_AID_LEN 0x07 500 /* V2.0 Type 4 Tag Applicaiton ID length */ 501 #define T4T_V20_NDEF_TAG_AID_LEN 0x07 502 503 /* Min of Max R-APDU data size */ 504 #define T4T_MIN_MLE 0x000F 505 506 #define T4T_FILE_ID_SIZE 0x02 507 #define T4T_CC_FILE_ID 0xE103 508 #define T4T_CC_FILE_MIN_LEN 0x000F 509 510 #define T4T_VERSION_OFFSET_IN_CC 0x02 511 #define T4T_FC_TLV_OFFSET_IN_CC 0x07 512 /* Offset of Write access byte from type field in CC */ 513 #define T4T_FC_WRITE_ACCESS_OFFSET_IN_TLV 0x07 514 515 #define T4T_NDEF_FILE_CONTROL_TYPE 0x04 /* NDEF File Control Type */ 516 /* Proprietary File Control Type */ 517 #define T4T_PROP_FILE_CONTROL_TYPE 0x05 518 519 /* size of T(1),L(1),V(6) for file control */ 520 #define T4T_FILE_CONTROL_TLV_SIZE 0x08 521 /* size of V(6) for file control */ 522 #define T4T_FILE_CONTROL_LENGTH 0x06 523 524 /* read access granted without any security */ 525 #define T4T_FC_READ_ACCESS 0x00 526 /* write access granted without any security */ 527 #define T4T_FC_WRITE_ACCESS 0x00 528 /* proprietary write access range start */ 529 #define T4T_FC_WRITE_ACCESS_PROP_START 0x80 530 /* no write access granted at all (read-only) */ 531 #define T4T_FC_NO_WRITE_ACCESS 0xFF 532 533 #define T4T_FILE_LENGTH_SIZE 0x02 534 #define T4T_ADDI_FRAME_RESP 0xAFU 535 #define T4T_DES_GET_VERSION_LEN 0x09 536 #define T4T_SIZE_IDENTIFIER_2K 0x16U 537 #define T4T_SIZE_IDENTIFIER_4K 0x18U 538 #define T4T_SIZE_IDENTIFIER_8K 0x1AU 539 #define T4T_DESEV1_MAJOR_VERSION 0x01U 540 #define T4T_TYPE_DESFIRE_EV1 0x01U 541 #define T4T_DESEV0_MAJOR_VERSION 0x00U 542 #define T4T_DESEV0_MINOR_VERSION 0x06U 543 #define T4T_DES_EV1_NFC_APP_ID 0x010000 544 #define T4T_DES_EV0_NFC_APP_ID 0x10EEEE 545 546 /* 547 ** 548 ** ISO 15693 Tag Definitions 549 ** 550 */ 551 552 /* Request flags 1 to 4 definition */ 553 #define I93_FLAG_SUB_CARRIER_MASK 0x01 /* Sub_carrier_flag */ 554 /* A single sub-carrier frequency shall be used by VICC */ 555 #define I93_FLAG_SUB_CARRIER_SINGLE 0x00 556 /* Two sub-carriers shall be used by VICC */ 557 #define I93_FLAG_SUB_CARRIER_DOUBLE 0x01 558 559 #define I93_FLAG_DATA_RATE_MASK 0x02 /* Data_rate_flag */ 560 /* Low data rate shall be used */ 561 #define I93_FLAG_DATA_RATE_LOW 0x00 562 /* High data rate shall be used */ 563 #define I93_FLAG_DATA_RATE_HIGH 0x02 564 565 #define I93_FLAG_INVENTORY_MASK 0x04 /* Inventory_flag */ 566 /* Flags 5 to 8 meaning is according to table 4 */ 567 #define I93_FLAG_INVENTORY_UNSET 0x00 568 /* Flags 5 to 8 meaning is according to table 5 */ 569 #define I93_FLAG_INVENTORY_SET 0x04 570 571 /* Protocol_Extension_flag */ 572 #define I93_FLAG_PROT_EXT_MASK 0x08 573 /* No protocol format extension */ 574 #define I93_FLAG_PROT_EXT_NO 0x00 575 /* Protocol format is extended. Reserved for future use */ 576 #define I93_FLAG_PROT_EXT_YES 0x08 577 578 /* Request flags 5 to 6 definition when inventory flag is not set */ 579 #define I93_FLAG_SELECT_MASK 0x10 /* Select_flag */ 580 /* Request shall be executed by any VICC according to the setting of 581 * Address_flag */ 582 #define I93_FLAG_SELECT_UNSET 0x00 583 /* Request shall be executed only by VICC in selected state */ 584 #define I93_FLAG_SELECT_SET 0x10 585 /* The Address_flag shall be set to 0 and the UID field shall bot be included in 586 * the request */ 587 588 #define I93_FLAG_ADDRESS_MASK 0x20 /* Address_flag */ 589 /* Request is not addressed. UID field is not included. It shall be executed by 590 * any VICC */ 591 #define I93_FLAG_ADDRESS_UNSET 0x00 592 /* Request is addressed. UID field is included. It shall be executed only by 593 * VICC */ 594 #define I93_FLAG_ADDRESS_SET 0x20 595 /* whose UID matches the UID specified in the request */ 596 597 /* Request flags 5 to 6 definition when inventory flag is set */ 598 #define I93_FLAG_AFI_MASK 0x10 /* AFI_flag */ 599 /* AFI field is not present */ 600 #define I93_FLAG_AFI_NOT_PRESENT 0x00 601 /* AFI field is present */ 602 #define I93_FLAG_AFI_PRESENT 0x10 603 604 #define I93_FLAG_SLOT_MASK 0x20 /* Nb_slots_flag */ 605 #define I93_FLAG_SLOT_16 0x00 /* 16 slots */ 606 #define I93_FLAG_SLOT_ONE 0x20 /* 1 slot */ 607 608 /* Request flags 6 to 8 definition when inventory flag is set or not set */ 609 610 #define I93_FLAG_OPTION_MASK 0x40 /* Option_flag */ 611 /* Meaning is defined by the command description. */ 612 #define I93_FLAG_OPTION_UNSET 0x00 613 /* It shall be set to 0 if not otherwise defined by command */ 614 /* Meaning is defined by the command description. */ 615 #define I93_FLAG_OPTION_SET 0x40 616 617 /* Response flags */ 618 #define I93_FLAG_ERROR_MASK 0x01 /* Error_flag */ 619 /* No error */ 620 #define I93_FLAG_ERORR_NOT_DETECTED 0x00 621 /* Error detected, Error code is in the "Error" field */ 622 #define I93_FLAG_ERROR_DETECTED 0x01 623 624 /* Response error code */ 625 /* The command is not supported, i.e. the request code is not recognized */ 626 #define I93_ERROR_CODE_NOT_SUPPORTED 0x01 627 /* The command is not recognized, for example: a format error occured */ 628 #define I93_ERROR_CODE_NOT_RECOGNIZED 0x02 629 /* The command option is not supported */ 630 #define I93_ERROR_CODE_OPTION_NOT_SUPPORTED 0x03 631 /* Error with no information given or a specific error code is not supported */ 632 #define I93_ERROR_CODE_NO_INFO 0x0F 633 /* The specific block is not available (doesn't exist) */ 634 #define I93_ERROR_CODE_BLOCK_NOT_AVAILABLE 0x10 635 /* The specific block is already locked and thus cannot be locked again */ 636 #define I93_ERROR_CODE_BLOCK_ALREADY_LOCKED 0x11 637 /* The specific block is locked and its content cannot be changed */ 638 #define I93_ERROR_CODE_BLOCK_LOCKED 0x12 639 /* The specific block is was not successfully programmed */ 640 #define I93_ERROR_CODE_BLOCK_FAIL_TO_WRITE 0x13 641 /* The specific block is was not successfully locked */ 642 #define I93_ERROR_CODE_BLOCK_FAIL_TO_LOCK 0x14 643 644 /* UID length in bytes */ 645 #define I93_UID_BYTE_LEN 8 646 /* Data Storage Format is not supported */ 647 #define I93_DFS_UNSUPPORTED 0x00 648 /* Block is not locked */ 649 #define I93_BLOCK_UNLOCKED 0x00 650 /* Block is locked */ 651 #define I93_BLOCK_LOCKED 0x01 652 653 /* ISO 15693 Mandatory commands */ 654 #define I93_CMD_INVENTORY 0x01 /* Inventory */ 655 #define I93_CMD_STAY_QUIET 0x02 /* Stay Quiet */ 656 657 /* ISO 15693 Optional commands */ 658 #define I93_CMD_READ_SINGLE_BLOCK 0x20 /* Read single block */ 659 #define I93_CMD_WRITE_SINGLE_BLOCK 0x21 /* Write single block */ 660 #define I93_CMD_LOCK_BLOCK 0x22 /* Lock block */ 661 #define I93_CMD_READ_MULTI_BLOCK 0x23 /* Read multiple blocks */ 662 #define I93_CMD_WRITE_MULTI_BLOCK 0x24 /* Write multiple blocks */ 663 #define I93_CMD_SELECT 0x25 /* Select */ 664 #define I93_CMD_RESET_TO_READY 0x26 /* Reset to ready */ 665 #define I93_CMD_WRITE_AFI 0x27 /* Wreite AFI */ 666 #define I93_CMD_LOCK_AFI 0x28 /* Lock AFI */ 667 #define I93_CMD_WRITE_DSFID 0x29 /* Write DSFID */ 668 #define I93_CMD_LOCK_DSFID 0x2A /* Lock DSFID */ 669 /* Get system information */ 670 #define I93_CMD_GET_SYS_INFO 0x2B 671 /* Get multiple block security status */ 672 #define I93_CMD_GET_MULTI_BLK_SEC 0x2C 673 674 /* Information flags definition */ 675 /* DSFID is supported and DSFID field is present */ 676 #define I93_INFO_FLAG_DSFID 0x01 677 /* AFI is supported and AFI field is present */ 678 #define I93_INFO_FLAG_AFI 0x02 679 /* VICC memory size field is present */ 680 #define I93_INFO_FLAG_MEM_SIZE 0x04 681 /* IC reference field is present */ 682 #define I93_INFO_FLAG_IC_REF 0x08 683 684 /* Max block size in bytes */ 685 #define I93_MAX_BLOCK_LENGH 32 686 /* Max number of blocks */ 687 #define I93_MAX_NUM_BLOCK 256 688 689 /* ICODE Capability Container(CC) definition */ 690 #define I93_ICODE_CC_MAGIC_NUMER 0xE1 /* magic number in CC[0] */ 691 #define I93_ICODE_CC_MAJOR_VER_MASK 0xC0 /* major version in CC[1] */ 692 #define I93_ICODE_CC_MINOR_VER_MASK 0x30 /* minor version in CC[1] */ 693 /* read access condition in CC[1] */ 694 #define I93_ICODE_CC_READ_ACCESS_MASK 0x0C 695 /* read access granted without security */ 696 #define I93_ICODE_CC_READ_ACCESS_GRANTED 0x00 697 /* write access condition in CC[1] */ 698 #define I93_ICODE_CC_WRITE_ACCESS_MASK 0x03 699 /* write access granted without security */ 700 #define I93_ICODE_CC_WRITE_ACCESS_GRANTED 0x00 701 /* write access not granted at all */ 702 #define I93_ICODE_CC_READ_ONLY 0x03 703 /* read multi block supported in CC[3] */ 704 #define I93_ICODE_CC_MBREAD_MASK 0x01 705 /* inventory page read supported in CC[3] */ 706 #define I93_ICODE_CC_IPREAD_MASK 0x02 707 /* More than 2040 bytes are supported in CC[3] */ 708 #define I93_STM_CC_OVERFLOW_MASK 0x04 709 710 /* ICODE TLV type */ 711 #define I93_ICODE_TLV_TYPE_NULL 0x00 /* NULL TLV */ 712 #define I93_ICODE_TLV_TYPE_NDEF 0x03 /* NDEF message TLV */ 713 #define I93_ICODE_TLV_TYPE_PROP 0xFD /* Proprietary TLV */ 714 #define I93_ICODE_TLV_TYPE_TERM 0xFE /* Terminator TLV */ 715 716 /* UID Coding (UID Bit 64-57), First byte of ISO 15693 UID */ 717 #define I93_UID_FIRST_BYTE 0xE0 718 719 /* UID Coding (UID Bit 56-49), IC manufacturer code */ 720 #define I93_UID_IC_MFG_CODE_STM 0x02 721 #define I93_UID_IC_MFG_CODE_NXP 0x04 722 #define I93_UID_IC_MFG_CODE_TI 0x07 723 724 /* NXP, UID Coding of ICODE type (UID Bit 48-41) */ 725 /* ICODE SLI, SLIX */ 726 #define I93_UID_ICODE_SLI 0x01 727 /* ICODE SLI-S, SLIX-S */ 728 #define I93_UID_ICODE_SLI_S 0x02 729 /* ICODE SLI-L, SLIX-L */ 730 #define I93_UID_ICODE_SLI_L 0x03 731 732 /* IC Reference for ICODE SLI-L */ 733 #define I93_IC_REF_ICODE_SLI_L 0x03 734 /* read multi block supported check bit */ 735 #define I93_ICODE_IC_REF_MBREAD_MASK 0x02 736 737 /* TI, UID Coding of product version (UID Bit 48-42) */ 738 /* upper 7 bits */ 739 #define I93_UID_TAG_IT_HF_I_PRODUCT_ID_MASK 0xFE 740 /* Tag-it HF-I Plus Inlay */ 741 #define I93_UID_TAG_IT_HF_I_PLUS_INLAY 0x00 742 /* Tag-it HF-I Plus Chip */ 743 #define I93_UID_TAG_IT_HF_I_PLUS_CHIP 0x80 744 /* Tag-it HF-I Standard Chip/Inlyas */ 745 #define I93_UID_TAG_IT_HF_I_STD_CHIP_INLAY 0xC0 746 /* Tag-it HF-I Pro Chip/Inlyas */ 747 #define I93_UID_TAG_IT_HF_I_PRO_CHIP_INLAY 0xC4 748 749 #define I93_TAG_IT_HF_I_STD_CHIP_INLAY_NUM_TOTAL_BLK 11 750 #define I93_TAG_IT_HF_I_PRO_CHIP_INLAY_NUM_TOTAL_BLK 12 751 752 #define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_BLK_SIZE 4 753 #define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_NUM_USER_BLK 8 754 /* LSB in Block 0x0A */ 755 #define I93_TAG_IT_HF_I_STD_PRO_CHIP_INLAY_AFI_LOCATION 40 756 757 /* STM, product version (IC manufacturer code) */ 758 /* IC Reference mask for STM */ 759 #define I93_IC_REF_STM_MASK 0xFC 760 /* IC Reference for LRI1K: 010000xx(b), blockSize: 4, numberBlocks: 0x20 */ 761 #define I93_IC_REF_STM_LRI1K 0x40 762 /* IC Reference for LRI2K: 001000xx(b), blockSize: 4, numberBlocks: 0x40 */ 763 #define I93_IC_REF_STM_LRI2K 0x20 764 /* IC Reference for LRIS2K: 001010xx(b), blockSize: 4, numberBlocks: 0x40 */ 765 #define I93_IC_REF_STM_LRIS2K 0x28 766 /* IC Reference for LRIS64K: 010001xx(b), blockSize: 4, numberBlocks: 0x800 767 */ 768 #define I93_IC_REF_STM_LRIS64K 0x44 769 /* IC Reference for M24LR64-R: 001011xx(b), blockSize: 4, numberBlocks: 0x800 770 */ 771 #define I93_IC_REF_STM_M24LR64_R 0x2C 772 /* IC Reference for M24LR04E-R: 01011010(b), blockSize: 4, numberBlocks: 0x80 */ 773 #define I93_IC_REF_STM_M24LR04E_R 0x5A 774 /* IC Reference for M24LR16E-R: 01001110(b), blockSize: 4, numberBlocks: 0x200 775 */ 776 #define I93_IC_REF_STM_M24LR16E_R 0x4E 777 /* IC Reference for M24LR64E-R: 01011110(b), blockSize: 4, numberBlocks: 0x800 778 */ 779 #define I93_IC_REF_STM_M24LR64E_R 0x5E 780 781 #define I93_STM_BLOCKS_PER_SECTOR 32 782 #define I93_STM_MAX_BLOCKS_PER_READ 32 783 784 #endif /* TAGS_DEFS_H */ 785