summaryrefslogtreecommitdiffstats
path: root/src/phFriNfc_MifULFormat.c
diff options
context:
space:
mode:
authorMartijn Coenen <martijn.coenen@nxp.com>2010-12-18 12:09:06 +0100
committerNick Pelly <npelly@google.com>2011-01-04 13:15:24 +1100
commitc0bdf30e40dd60628bfafd5f93a3a911e3b91da9 (patch)
tree447b27ab5e15e760037d7577ecf6feb542095037 /src/phFriNfc_MifULFormat.c
parent80ee29b88ec489e2bbf6ae446692229d36755429 (diff)
downloadexternal_libnfc-nxp-c0bdf30e40dd60628bfafd5f93a3a911e3b91da9.zip
external_libnfc-nxp-c0bdf30e40dd60628bfafd5f93a3a911e3b91da9.tar.gz
external_libnfc-nxp-c0bdf30e40dd60628bfafd5f93a3a911e3b91da9.tar.bz2
Actually set the lock bits for static T1T and T2T.
Change-Id: I594e588fb7f0f8151e54ac872640bb8d3e19bfce
Diffstat (limited to 'src/phFriNfc_MifULFormat.c')
-rw-r--r--src/phFriNfc_MifULFormat.c68
1 files changed, 56 insertions, 12 deletions
diff --git a/src/phFriNfc_MifULFormat.c b/src/phFriNfc_MifULFormat.c
index 8f3de28..899249d 100644
--- a/src/phFriNfc_MifULFormat.c
+++ b/src/phFriNfc_MifULFormat.c
@@ -20,10 +20,10 @@
*
* Project: NFC-FRI
*
- * $Date: Fri Oct 23 12:00:05 2009 $
+ * $Date: Mon Dec 13 14:14:12 2010 $
* $Author: ing02260 $
- * $Revision: 1.8 $
- * $Aliases: NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $
+ * $Revision: 1.9 $
+ * $Aliases: $
*
*/
@@ -37,17 +37,20 @@
*
*/
/*@{*/
-#define PHFRINFCMIFULFORMAT_FILEREVISION "$Revision: 1.8 $"
-#define PHFRINFCMIFULFORMAT_FILEALIASES "$Aliases: NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $"
+#define PHFRINFCMIFULFORMAT_FILEREVISION "$Revision: 1.9 $"
+#define PHFRINFCMIFULFORMAT_FILEALIASES "$Aliases: $"
/*@}*/
#ifdef FRINFC_READONLY_NDEF
/* Mifare UL OTP block number is 3 */
+ #define RD_LOCK_OTP_BLOCK_NUMBER 0x02U
#define OTP_BLOCK_NUMBER 0x03U
/* READ ONLY value that shall be written in the OTP to make the card read only */
#define READ_ONLY_VALUE_IN_OTP 0x0FU
/* Mifare UL OTP block number is 3 */
#define MIFARE_UL_READ_MAX_SIZE 16U
+ /* Lock byte value */
+ #define MIFARE_UL_LOCK_BYTE_VALUE 0xFFU
#endif /* #ifdef FRINFC_READONLY_NDEF */
/*!
* \brief \copydoc page_ovr Helper function for Mifare UL. This function calls the
@@ -110,6 +113,12 @@ void phFriNfc_MfUL_Reset(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
(void)memcpy(NdefSmtCrdFmt->AddInfo.Type2Info.OTPBytes,
OTPByte,
sizeof(NdefSmtCrdFmt->AddInfo.Type2Info.OTPBytes));
+#ifdef FRINFC_READONLY_NDEF
+ NdefSmtCrdFmt->AddInfo.Type2Info.LockBytes[0] = 0;
+ NdefSmtCrdFmt->AddInfo.Type2Info.LockBytes[1] = 0;
+ NdefSmtCrdFmt->AddInfo.Type2Info.LockBytes[2] = 0;
+ NdefSmtCrdFmt->AddInfo.Type2Info.LockBytes[3] = 0;
+#endif /* #ifdef FRINFC_READONLY_NDEF */
}
NFCSTATUS phFriNfc_MfUL_Format(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
@@ -176,7 +185,7 @@ void phFriNfc_MfUL_Process(void *Context,
/* Card already have the OTP bytes so write TLV */
NdefSmtCrdFmt->State = PH_FRINFC_MFUL_FMT_WR_TLV1;
- Status = phFriNfc_MfUL_H_WrRd(NdefSmtCrdFmt);
+ Status = phFriNfc_MfUL_H_WrRd (NdefSmtCrdFmt);
}
#endif /* #ifdef PH_NDEF_MIFARE_ULC */
@@ -188,14 +197,25 @@ void phFriNfc_MfUL_Process(void *Context,
{
if (MIFARE_UL_READ_MAX_SIZE == *NdefSmtCrdFmt->SendRecvLength)
{
- uint8_t otp_page_size = 0;
+ uint8_t otp_lock_page_size = 0;
+ uint8_t i = 0;
+
+ otp_lock_page_size = sizeof (NdefSmtCrdFmt->AddInfo.Type2Info.LockBytes);
+ (void)memcpy ((void *)NdefSmtCrdFmt->AddInfo.Type2Info.LockBytes,
+ (void *)NdefSmtCrdFmt->SendRecvBuf,
+ sizeof(NdefSmtCrdFmt->AddInfo.Type2Info.LockBytes));
- otp_page_size = sizeof (NdefSmtCrdFmt->AddInfo.Type2Info.OTPBytes);
- (void)memcpy (NdefSmtCrdFmt->AddInfo.Type2Info.OTPBytes,
- NdefSmtCrdFmt->SendRecvBuf,
+ NdefSmtCrdFmt->AddInfo.Type2Info.LockBytes[2] = MIFARE_UL_LOCK_BYTE_VALUE;
+ NdefSmtCrdFmt->AddInfo.Type2Info.LockBytes[3] = MIFARE_UL_LOCK_BYTE_VALUE;
+ i = (uint8_t)(i + otp_lock_page_size);
+
+ otp_lock_page_size = sizeof (NdefSmtCrdFmt->AddInfo.Type2Info.OTPBytes);
+
+ (void)memcpy ((void *)NdefSmtCrdFmt->AddInfo.Type2Info.OTPBytes,
+ (void *)(NdefSmtCrdFmt->SendRecvBuf + i),
sizeof(NdefSmtCrdFmt->AddInfo.Type2Info.OTPBytes));
- NdefSmtCrdFmt->AddInfo.Type2Info.OTPBytes[(otp_page_size - 1)] =
+ NdefSmtCrdFmt->AddInfo.Type2Info.OTPBytes[(otp_lock_page_size - 1)] =
READ_ONLY_VALUE_IN_OTP;
NdefSmtCrdFmt->State = PH_FRINFC_MFUL_FMT_RO_WR_OTP_BYTES;
@@ -206,6 +226,12 @@ void phFriNfc_MfUL_Process(void *Context,
case PH_FRINFC_MFUL_FMT_RO_WR_OTP_BYTES:
{
+ NdefSmtCrdFmt->State = PH_FRINFC_MFUL_FMT_RO_WR_LOCK_BYTES;
+ Status = phFriNfc_MfUL_H_WrRd (NdefSmtCrdFmt);
+ }
+
+ case PH_FRINFC_MFUL_FMT_RO_WR_LOCK_BYTES:
+ {
/* Do nothing */
break;
}
@@ -299,12 +325,30 @@ static void phFriNfc_MfUL_H_fillSendBuf( phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFm
/* Read command */
NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareCmdListMifareRead;
#endif /* #ifdef PH_HAL4_ENABLE */
- *NdefSmtCrdFmt->SendRecvBuf = OTP_BLOCK_NUMBER;
+ *NdefSmtCrdFmt->SendRecvBuf = RD_LOCK_OTP_BLOCK_NUMBER;
/* Send length for read command is always one */
NdefSmtCrdFmt->SendLength = PH_FRINFC_MFUL_FMT_VAL_1;
break;
}
+ case PH_FRINFC_MFUL_FMT_RO_WR_LOCK_BYTES:
+ {
+#ifdef PH_HAL4_ENABLE
+ NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareWrite4;
+#else
+ /* Read command */
+ NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareCmdListMifareWrite4;
+#endif /* #ifdef PH_HAL4_ENABLE */
+
+ /* Send length for read command is always one */
+ NdefSmtCrdFmt->SendLength = PH_FRINFC_MFUL_FMT_VAL_5;
+ *NdefSmtCrdFmt->SendRecvBuf = RD_LOCK_OTP_BLOCK_NUMBER;
+ (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFUL_FMT_VAL_1],
+ NdefSmtCrdFmt->AddInfo.Type2Info.LockBytes,
+ PH_FRINFC_MFUL_FMT_VAL_4);
+ break;
+ }
+
case PH_FRINFC_MFUL_FMT_RO_WR_OTP_BYTES:
{
#ifdef PH_HAL4_ENABLE