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