nfc_hal_prm.c revision df5080d7feca9827fd0306471c54f52ecf185c22
1/****************************************************************************** 2 * 3 * Copyright (C) 2012-2013 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#include <string.h> 20#include "nfc_hal_int.h" 21#include "userial.h" 22 23/***************************************************************************** 24* Definitions 25*****************************************************************************/ 26 27/* Internal flags */ 28#define NFC_HAL_PRM_FLAGS_USE_PATCHRAM_BUF 0x01 /* Application provided patchram in a single buffer */ 29#define NFC_HAL_PRM_FLAGS_RFU 0x02 /* Reserved for future use */ 30#define NFC_HAL_PRM_FLAGS_SIGNATURE_SENT 0x04 /* Signature sent to NFCC */ 31#define NFC_HAL_PRM_FLAGS_I2C_FIX_REQUIRED 0x08 /* PreI2C patch required */ 32#define NFC_HAL_PRM_FLAGS_BCM20791B3 0x10 /* B3 Patch (no RESET_NTF after patch download) */ 33 34/* Secure patch download definitions */ 35#define NFC_HAL_PRM_NCD_PATCHFILE_HDR_LEN 7 /* PRJID + MAJORVER + MINORVER + COUNT */ 36 37/* Enumeration of power modes IDs */ 38#define NFC_HAL_PRM_SPD_POWER_MODE_LPM 0 39#define NFC_HAL_PRM_SPD_POWER_MODE_FPM 1 40 41/* Version string for BCM20791B3 */ 42const UINT8 NFC_HAL_PRM_BCM20791B3_STR[] = "20791B3"; 43#define NFC_HAL_PRM_BCM20791B3_STR_LEN (sizeof (NFC_HAL_PRM_BCM20791B3_STR)-1) 44 45#define NFC_HAL_PRM_SPD_TOUT (6000) /* timeout for SPD events (in ms) */ 46#define NFC_HAL_PRM_END_DELAY (250) /* delay before sending any new command (ms)*/ 47 48#if (NFC_HAL_PRM_DEBUG == TRUE) 49#define NFC_HAL_PRM_STATE(str) HAL_TRACE_DEBUG2 ("%s st: %d", str, nfc_hal_cb.prm.state) 50#else 51#define NFC_HAL_PRM_STATE(str) 52#endif 53 54void nfc_hal_prm_post_baud_update (tHAL_NFC_STATUS status); 55 56/***************************************************************************** 57** Extern variable from nfc_hal_dm_cfg.c 58*****************************************************************************/ 59extern tNFC_HAL_CFG *p_nfc_hal_cfg; 60 61/******************************************************************************* 62** 63** Function nfc_hal_prm_spd_handle_download_complete 64** 65** Description Patch download complete (for secure patch download) 66** 67** Returns void 68** 69*******************************************************************************/ 70void nfc_hal_prm_spd_handle_download_complete (UINT8 event) 71{ 72 nfc_hal_cb.prm.state = NFC_HAL_PRM_ST_IDLE; 73 74 /* Notify application now */ 75 if (nfc_hal_cb.prm.p_cback) 76 (nfc_hal_cb.prm.p_cback) (event); 77} 78 79/******************************************************************************* 80** 81** Function nfc_hal_prm_spd_send_next_segment 82** 83** Description Send next patch segment (for secure patch download) 84** 85** Returns void 86** 87*******************************************************************************/ 88void nfc_hal_prm_spd_send_next_segment (void) 89{ 90 UINT8 *p_src; 91 UINT16 len, offset = nfc_hal_cb.prm.cur_patch_offset; 92 UINT8 hcit, oid, hdr0, type; 93 UINT8 chipverlen; 94 UINT8 chipverstr[NCI_SPD_HEADER_CHIPVER_LEN]; 95 UINT8 patch_hdr_size = NCI_MSG_HDR_SIZE + 1; /* 1 is for HCIT */ 96 97 /* Validate that segment is at least big enought to have NCI_MSG_HDR_SIZE + 1 (hcit) */ 98 if (nfc_hal_cb.prm.cur_patch_len_remaining < patch_hdr_size) 99 { 100 HAL_TRACE_ERROR0 ("Unexpected end of patch."); 101 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_ABORT_INVALID_PATCH_EVT); 102 return; 103 } 104 105 /* Parse NCI command header */ 106 p_src = (UINT8*) (nfc_hal_cb.prm.p_cur_patch_data + offset); 107 STREAM_TO_UINT8 (hcit, p_src); 108 STREAM_TO_UINT8 (hdr0, p_src); 109 STREAM_TO_UINT8 (oid, p_src); 110 STREAM_TO_UINT8 (len, p_src); 111 STREAM_TO_UINT8 (type, p_src); 112 113 114 /* Update number of bytes comsumed */ 115 nfc_hal_cb.prm.cur_patch_offset += (len + patch_hdr_size); 116 nfc_hal_cb.prm.cur_patch_len_remaining -= (len + patch_hdr_size); 117 118 /* Check if sending signature byte */ 119 if ( (oid == NCI_MSG_SECURE_PATCH_DOWNLOAD ) 120 &&(type == NCI_SPD_TYPE_SIGNATURE) ) 121 { 122 nfc_hal_cb.prm.flags |= NFC_HAL_PRM_FLAGS_SIGNATURE_SENT; 123 } 124 /* Check for header */ 125 else if ( (oid == NCI_MSG_SECURE_PATCH_DOWNLOAD ) 126 &&(type == NCI_SPD_TYPE_HEADER) ) 127 { 128 /* Check if patch is for BCM20791B3 */ 129 p_src += NCI_SPD_HEADER_OFFSET_CHIPVERLEN; 130 STREAM_TO_UINT8 (chipverlen, p_src); 131 STREAM_TO_ARRAY (chipverstr, p_src, NCI_SPD_HEADER_CHIPVER_LEN); 132 133 if (memcmp (NFC_HAL_PRM_BCM20791B3_STR, chipverstr, NFC_HAL_PRM_BCM20791B3_STR_LEN) == 0) 134 { 135 /* Patch is for BCM2079B3 - do not wait for RESET_NTF after patch download */ 136 nfc_hal_cb.prm.flags |= NFC_HAL_PRM_FLAGS_BCM20791B3; 137 } 138 else 139 { 140 /* Patch is for BCM2079B4 or newer - wait for RESET_NTF after patch download */ 141 nfc_hal_cb.prm.flags &= ~NFC_HAL_PRM_FLAGS_BCM20791B3; 142 } 143 } 144 145 /* Send the command (not including HCIT here) */ 146 nfc_hal_dm_send_nci_cmd ((UINT8*) (nfc_hal_cb.prm.p_cur_patch_data + offset + 1), (UINT8) (len + NCI_MSG_HDR_SIZE), 147 nfc_hal_prm_nci_command_complete_cback); 148} 149 150/******************************************************************************* 151** 152** Function nfc_hal_prm_spd_handle_next_patch_start 153** 154** Description Handle start of next patch (for secure patch download) 155** 156** Returns void 157** 158*******************************************************************************/ 159void nfc_hal_prm_spd_handle_next_patch_start (void) 160{ 161 UINT32 cur_patch_mask; 162 UINT32 cur_patch_len; 163 BOOLEAN found_patch_to_download = FALSE; 164 165 while (!found_patch_to_download) 166 { 167 /* Get length of current patch */ 168 cur_patch_len = nfc_hal_cb.prm.spd_patch_desc[nfc_hal_cb.prm.spd_cur_patch_idx].len; 169 170 /* Check if this is a patch we need to download */ 171 cur_patch_mask = ((UINT32) 1 << nfc_hal_cb.prm.spd_patch_desc[nfc_hal_cb.prm.spd_cur_patch_idx].power_mode); 172 if (nfc_hal_cb.prm.spd_patch_needed_mask & cur_patch_mask) 173 { 174 found_patch_to_download = TRUE; 175 } 176 else 177 { 178 /* Do not need to download this patch. Skip to next patch */ 179 HAL_TRACE_DEBUG1 ("Skipping patch for power_mode %i.", nfc_hal_cb.prm.spd_patch_desc[nfc_hal_cb.prm.spd_cur_patch_idx].power_mode); 180 181 nfc_hal_cb.prm.spd_cur_patch_idx++; 182 if (nfc_hal_cb.prm.spd_cur_patch_idx >= nfc_hal_cb.prm.spd_patch_count) 183 { 184 /* No more to download */ 185 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_COMPLETE_EVT); 186 return; 187 } 188 else if (!(nfc_hal_cb.prm.flags & NFC_HAL_PRM_FLAGS_USE_PATCHRAM_BUF)) 189 { 190 /* Notify adaptation layer to call HAL_NfcPrmDownloadContinue with the next patch header */ 191 (nfc_hal_cb.prm.p_cback) (NFC_HAL_PRM_SPD_GET_NEXT_PATCH); 192 return; 193 } 194 else 195 { 196 /* Patch in buffer. Skip over current patch. Check next patch */ 197 nfc_hal_cb.prm.cur_patch_len_remaining -= (UINT16) cur_patch_len; 198 nfc_hal_cb.prm.cur_patch_offset += (UINT16) cur_patch_len; 199 } 200 } 201 } 202 203 204 /* Begin downloading patch */ 205 HAL_TRACE_DEBUG1 ("Downloading patch for power_mode %i.", nfc_hal_cb.prm.spd_patch_desc[nfc_hal_cb.prm.spd_cur_patch_idx].power_mode); 206 nfc_hal_cb.prm.state = NFC_HAL_PRM_ST_SPD_DOWNLOADING; 207 nfc_hal_prm_spd_send_next_segment (); 208} 209 210#if (defined (NFC_HAL_PRE_I2C_PATCH_INCLUDED) && (NFC_HAL_PRE_I2C_PATCH_INCLUDED == TRUE)) 211/******************************************************************************* 212** 213** Function nfc_hal_prm_spd_download_i2c_fix 214** 215** Description Start downloading patch for i2c fix 216** 217** Returns void 218** 219*******************************************************************************/ 220void nfc_hal_prm_spd_download_i2c_fix (void) 221{ 222 UINT8 *p, *p_start; 223 UINT16 patchfile_project_id; 224 UINT16 patchfile_ver_major; 225 UINT16 patchfile_ver_minor; 226 UINT16 patchfile_patchsize; 227 UINT8 u8; 228 229 HAL_TRACE_DEBUG0 ("Downloading I2C fix..."); 230 231 /* Save pointer and offset of patchfile, so we can resume after downloading the i2c fix */ 232 nfc_hal_cb.prm.spd_patch_offset = nfc_hal_cb.prm.cur_patch_offset; 233 nfc_hal_cb.prm.spd_patch_len_remaining = nfc_hal_cb.prm.cur_patch_len_remaining; 234 235 /* Initialize pointers for downloading i2c fix */ 236 nfc_hal_cb.prm.p_cur_patch_data = nfc_hal_cb.prm_i2c.p_patch; 237 nfc_hal_cb.prm.cur_patch_offset = 0; 238 nfc_hal_cb.prm.cur_patch_len_remaining = nfc_hal_cb.prm_i2c.len; 239 240 /* Parse the i2c patchfile */ 241 if (nfc_hal_cb.prm.cur_patch_len_remaining >= NFC_HAL_PRM_NCD_PATCHFILE_HDR_LEN) 242 { 243 /* Parse patchfile header */ 244 p = (UINT8 *) nfc_hal_cb.prm.p_cur_patch_data; 245 p_start = p; 246 STREAM_TO_UINT16 (patchfile_project_id, p); 247 STREAM_TO_UINT16 (patchfile_ver_major, p); 248 STREAM_TO_UINT16 (patchfile_ver_minor, p); 249 250 /* RFU */ 251 p++; 252 253 /* Check how many patches are in the patch file */ 254 STREAM_TO_UINT8 (u8, p); 255 256 /* Should only be one patch */ 257 if (u8 > 1) 258 { 259 HAL_TRACE_ERROR1 ("Invalid i2c fix: invalid number of patches (%i)", u8); 260 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_ABORT_INVALID_PATCH_EVT); 261 return; 262 } 263 264 265 /* Get info about the i2c patch*/ 266 STREAM_TO_UINT8 (u8, p); /* power mode (not needed for i2c patch) */ 267 STREAM_TO_UINT16 (patchfile_patchsize, p); /* size of patch */ 268 269 /* 5 byte RFU */ 270 p += 5; 271 272 /* Adjust length to exclude patchfiloe header */ 273 nfc_hal_cb.prm.cur_patch_len_remaining -= (UINT16) (p - p_start); /* Adjust size of patchfile */ 274 nfc_hal_cb.prm.cur_patch_offset += (UINT16) (p - p_start); /* Bytes of patchfile transmitted/processed so far */ 275 276 /* Begin sending patch to the NFCC */ 277 nfc_hal_prm_spd_send_next_segment (); 278 } 279 else 280 { 281 /* ERROR: Bad length for patchfile */ 282 HAL_TRACE_ERROR0 ("Invalid i2c fix: unexpected end of patch"); 283 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_ABORT_INVALID_PATCH_EVT); 284 } 285} 286#endif /* NFC_HAL_PRE_I2C_PATCH_INCLUDED */ 287 288/******************************************************************************* 289** 290** Function nfc_hal_prm_spd_check_version 291** 292** Description Check patchfile version with current downloaded version 293** 294** Returns void 295** 296*******************************************************************************/ 297void nfc_hal_prm_spd_check_version (void) 298{ 299 UINT8 *p, *p_start, i; 300 UINT32 patchfile_patch_present_mask; 301 UINT16 patchfile_project_id = 0; 302 UINT16 patchfile_ver_major = 0; 303 UINT16 patchfile_ver_minor = 0; 304 UINT16 patchfile_patchsize; 305 306 UINT8 return_code = NFC_HAL_PRM_COMPLETE_EVT; 307 308 /* Initialize patchfile offset pointers */ 309 p = p_start = NULL; 310 patchfile_patchsize = 0; 311 312 /* Get patchfile version */ 313 if (nfc_hal_cb.prm.cur_patch_len_remaining >= NFC_HAL_PRM_NCD_PATCHFILE_HDR_LEN) 314 { 315 /* Parse patchfile header */ 316 p = (UINT8 *) nfc_hal_cb.prm.p_cur_patch_data; 317 p_start = p; 318 STREAM_TO_UINT16 (patchfile_project_id, p); 319 STREAM_TO_UINT16 (patchfile_ver_major, p); 320 STREAM_TO_UINT16 (patchfile_ver_minor, p); 321 322 /* RFU */ 323 p++; 324 325 /* Check how many patches are in the patch file */ 326 STREAM_TO_UINT8 (nfc_hal_cb.prm.spd_patch_count, p); 327 328 if (nfc_hal_cb.prm.spd_patch_count > NFC_HAL_PRM_MAX_PATCH_COUNT) 329 { 330 HAL_TRACE_ERROR2 ("Unsupported patchfile (number of patches (%i) exceeds maximum (%i)", 331 nfc_hal_cb.prm.spd_patch_count, NFC_HAL_PRM_MAX_PATCH_COUNT); 332 } 333 334 /* Mask of patches that are present in the patchfile */ 335 patchfile_patch_present_mask = 0; 336 337 /* Get lengths for each patch */ 338 for (i = 0; i < nfc_hal_cb.prm.spd_patch_count; i++) 339 { 340 /* Get power mode for this patch */ 341 STREAM_TO_UINT8 (nfc_hal_cb.prm.spd_patch_desc[i].power_mode, p); 342 343 /* Update mask of power-modes present in the patchfile */ 344 patchfile_patch_present_mask |= ((UINT32) 1 << nfc_hal_cb.prm.spd_patch_desc[i].power_mode); 345 346 /* Get length of patch */ 347 STREAM_TO_UINT16 (nfc_hal_cb.prm.spd_patch_desc[i].len, p); 348 349 /* Add total size of patches */ 350 patchfile_patchsize += nfc_hal_cb.prm.spd_patch_desc[i].len; 351 352 /* 5 byte RFU */ 353 p += 5; 354 } 355 356 /* Adjust offset to after the patch file header */ 357 nfc_hal_cb.prm.cur_patch_offset += (UINT16) (p - p_start); /* Bytes of patchfile transmitted/processed so far */ 358 nfc_hal_cb.prm.cur_patch_len_remaining -= (UINT16) (p - p_start); /* Adjust size of patchfile */ 359 360 361 HAL_TRACE_DEBUG6 ("Patchfile info: ProjID=0x%04x, Ver=%i.%i, Num patches=%i, PatchMask=0x%08x, PatchSize=%i", 362 patchfile_project_id, patchfile_ver_major, patchfile_ver_minor, 363 nfc_hal_cb.prm.spd_patch_count, patchfile_patch_present_mask, patchfile_patchsize); 364 365 /********************************************************************* 366 * Version check of patchfile against NVM 367 *********************************************************************/ 368 if ( (nfc_hal_cb.nvm_cb.ver_major == patchfile_ver_major) 369 &&(nfc_hal_cb.nvm_cb.ver_minor == patchfile_ver_minor) 370 && !(nfc_hal_cb.nvm_cb.flags & (NFC_HAL_NVM_FLAGS_FPM_BAD | NFC_HAL_NVM_FLAGS_LPM_BAD)) ) 371 { 372 HAL_TRACE_DEBUG0 ("NVM contains the same patch version as in the patch file. Skip"); 373 return_code = NFC_HAL_PRM_COMPLETE_EVT; 374 } 375 else 376 { 377 HAL_TRACE_DEBUG5 ("NVM patch version %i.%i. Downloading version %i.%i flags:0x%x", 378 nfc_hal_cb.nvm_cb.ver_major, nfc_hal_cb.nvm_cb.ver_minor, 379 patchfile_ver_major, patchfile_ver_minor, nfc_hal_cb.nvm_cb.flags); 380 nfc_hal_cb.prm.spd_patch_needed_mask = patchfile_patch_present_mask; 381 } 382 } 383 else 384 { 385 /* Invalid patch file header */ 386 HAL_TRACE_ERROR0 ("Invalid patch file header."); 387 388 return_code = NFC_HAL_PRM_ABORT_INVALID_PATCH_EVT; 389 } 390 391 /* If we need to download anything, get the first patch to download */ 392 if (nfc_hal_cb.prm.spd_patch_needed_mask) 393 { 394 HAL_TRACE_ERROR4 ("Downloading patch version: %i.%i (previous version in NVM: %i.%i)...", 395 patchfile_ver_major, patchfile_ver_minor, 396 nfc_hal_cb.nvm_cb.ver_major, nfc_hal_cb.nvm_cb.ver_minor); 397#if (defined (NFC_HAL_PRE_I2C_PATCH_INCLUDED) && (NFC_HAL_PRE_I2C_PATCH_INCLUDED == TRUE)) 398 /* Check if I2C patch is needed: if */ 399 /* - I2C patch file was provided using HAL_NfcPrmSetI2cPatch, and */ 400 /* - current patch in NVM has ProjectID=0, or */ 401 /* FPM is not present or corrupted, or */ 402 /* or patchfile is major-ver 76+ */ 403 /* or patchfile is not for B3 (always download for B4 onward) */ 404 if ( (nfc_hal_cb.prm_i2c.p_patch) 405 &&( (nfc_hal_cb.nvm_cb.project_id == 0) 406 ||(nfc_hal_cb.nvm_cb.fpm_size == 0) 407 ||(nfc_hal_cb.nvm_cb.flags & NFC_HAL_NVM_FLAGS_FPM_BAD) 408 ||(patchfile_ver_major >= 76) 409 ||(!(nfc_hal_cb.prm.flags & NFC_HAL_PRM_FLAGS_BCM20791B3)) )) 410 { 411 HAL_TRACE_DEBUG0 ("I2C patch fix required."); 412 nfc_hal_cb.prm.flags |= NFC_HAL_PRM_FLAGS_I2C_FIX_REQUIRED; 413 414 /* Download i2c fix first */ 415 nfc_hal_prm_spd_download_i2c_fix (); 416 return; 417 } 418#endif /* NFC_HAL_PRE_I2C_PATCH_INCLUDED */ 419 420 /* Download first segment */ 421 nfc_hal_cb.prm.state = NFC_HAL_PRM_ST_SPD_GET_PATCH_HEADER; 422 if (!(nfc_hal_cb.prm.flags & NFC_HAL_PRM_FLAGS_USE_PATCHRAM_BUF)) 423 { 424 /* Notify adaptation layer to call HAL_NfcPrmDownloadContinue with the next patch segment */ 425 (nfc_hal_cb.prm.p_cback) (NFC_HAL_PRM_SPD_GET_NEXT_PATCH); 426 } 427 else 428 { 429 nfc_hal_prm_spd_handle_next_patch_start (); 430 } 431 } 432 else 433 { 434 static BOOLEAN firstTime = TRUE; 435 if (firstTime) 436 { 437 HAL_TRACE_ERROR2 ("NVM patch version is %d.%d", 438 nfc_hal_cb.nvm_cb.ver_major, nfc_hal_cb.nvm_cb.ver_minor); 439 firstTime = FALSE; 440 } 441 /* Download complete */ 442 nfc_hal_prm_spd_handle_download_complete (return_code); 443 } 444} 445 446#if (NFC_HAL_TRACE_VERBOSE == TRUE) 447/******************************************************************************* 448** 449** Function nfc_hal_prm_spd_status_str 450** 451** Description Return status string for a given spd status code 452** 453** Returns Status string 454** 455*******************************************************************************/ 456UINT8 *nfc_hal_prm_spd_status_str (UINT8 spd_status_code) 457{ 458 char *p_str; 459 460 switch (spd_status_code) 461 { 462 case NCI_STATUS_SPD_ERROR_DEST: 463 p_str = "SPD_ERROR_DEST"; 464 break; 465 466 case NCI_STATUS_SPD_ERROR_PROJECTID: 467 p_str = "SPD_ERROR_PROJECTID"; 468 break; 469 470 case NCI_STATUS_SPD_ERROR_CHIPVER: 471 p_str = "SPD_ERROR_CHIPVER"; 472 break; 473 474 case NCI_STATUS_SPD_ERROR_MAJORVER: 475 p_str = "SPD_ERROR_MAJORVER"; 476 break; 477 478 case NCI_STATUS_SPD_ERROR_INVALID_PARAM: 479 p_str = "SPD_ERROR_INVALID_PARAM"; 480 break; 481 482 case NCI_STATUS_SPD_ERROR_INVALID_SIG: 483 p_str = "SPD_ERROR_INVALID_SIG"; 484 break; 485 486 case NCI_STATUS_SPD_ERROR_NVM_CORRUPTED: 487 p_str = "SPD_ERROR_NVM_CORRUPTED"; 488 break; 489 490 case NCI_STATUS_SPD_ERROR_PWR_MODE: 491 p_str = "SPD_ERROR_PWR_MODE"; 492 break; 493 494 case NCI_STATUS_SPD_ERROR_MSG_LEN: 495 p_str = "SPD_ERROR_MSG_LEN"; 496 break; 497 498 case NCI_STATUS_SPD_ERROR_PATCHSIZE: 499 p_str = "SPD_ERROR_PATCHSIZE"; 500 break; 501 502 default: 503 p_str = "Unspecified Error"; 504 break; 505 506 } 507 508 return ((UINT8*) p_str); 509} 510#endif /* (NFC_HAL_TRACE_VERBOSE == TRUE) */ 511 512/******************************************************************************* 513** 514** Function nfc_hal_prm_nci_command_complete_cback 515** 516** Description Callback for NCI vendor specific command complete 517** (for secure patch download) 518** 519** Returns void 520** 521*******************************************************************************/ 522void nfc_hal_prm_nci_command_complete_cback (tNFC_HAL_NCI_EVT event, UINT16 data_len, UINT8 *p_data) 523{ 524 UINT8 status, u8; 525 UINT8 *p; 526 UINT32 post_signature_delay; 527 528 NFC_HAL_PRM_STATE ("nfc_hal_prm_nci_command_complete_cback"); 529 530 /* Stop the command-timeout timer */ 531 nfc_hal_main_stop_quick_timer (&nfc_hal_cb.prm.timer); 532 533 /* Skip over NCI header */ 534 p = p_data + NCI_MSG_HDR_SIZE; 535 536 /* Handle SECURE_PATCH_DOWNLOAD Rsp */ 537 if (event == NFC_VS_SEC_PATCH_DOWNLOAD_EVT) 538 { 539 /* Status and error code */ 540 STREAM_TO_UINT8 (status, p); 541 STREAM_TO_UINT8 (u8, p); 542 543 if (status != NCI_STATUS_OK) 544 { 545#if (NFC_HAL_TRACE_VERBOSE == TRUE) 546 HAL_TRACE_ERROR2 ("Patch download failed, reason code=0x%X (%s)", status, nfc_hal_prm_spd_status_str (status)); 547#else 548 HAL_TRACE_ERROR1 ("Patch download failed, reason code=0x%X", status); 549#endif 550 551 /* Notify application */ 552 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_ABORT_INVALID_PATCH_EVT); 553 return; 554 } 555 556 /* If last segment (SIGNATURE) sent */ 557 if (nfc_hal_cb.prm.flags & NFC_HAL_PRM_FLAGS_SIGNATURE_SENT) 558 { 559 /* Wait for authentication complete (SECURE_PATCH_DOWNLOAD NTF), including time to commit to NVM (for BCM43341B0) */ 560 int auth_delay = NFC_HAL_PRM_SPD_TOUT; 561 if (!(nfc_hal_cb.prm.flags & NFC_HAL_PRM_FLAGS_BCM20791B3)) 562 { 563 /* XXX maco only wait 30 seconds for B4+ revisions to avoid watchdog timeouts */ 564 auth_delay = NFC_HAL_PRM_COMMIT_DELAY; 565 } 566 nfc_hal_cb.prm.state = NFC_HAL_PRM_ST_SPD_AUTHENTICATING; 567 nfc_hal_main_start_quick_timer (&nfc_hal_cb.prm.timer, 0x00, 568 (auth_delay * QUICK_TIMER_TICKS_PER_SEC) / 1000); 569 return; 570 } 571 /* Download next segment */ 572 else if (nfc_hal_cb.prm.flags & NFC_HAL_PRM_FLAGS_USE_PATCHRAM_BUF) 573 { 574 /* If patch is in a buffer, get next patch from buffer */ 575 nfc_hal_prm_spd_send_next_segment (); 576 } 577 else 578 { 579 /* Notify adaptation layer to get next patch segment (via HAL_NfcPrmDownloadContinue) */ 580 (nfc_hal_cb.prm.p_cback) (NFC_HAL_PRM_CONTINUE_EVT); 581 } 582 } 583 /* Handle SECURE_PATCH_DOWNLOAD NTF */ 584 else if (event == NFC_VS_SEC_PATCH_AUTH_EVT) 585 { 586 HAL_TRACE_DEBUG1 ("prm flags:0x%x.", nfc_hal_cb.prm.flags); 587 /* Status and error code */ 588 STREAM_TO_UINT8 (status, p); 589 STREAM_TO_UINT8 (u8, p); 590 591 /* Sanity check - should only get this NTF while in AUTHENTICATING stage */ 592 if (nfc_hal_cb.prm.state == NFC_HAL_PRM_ST_SPD_AUTHENTICATING) 593 { 594 if (status != NCI_STATUS_OK) 595 { 596 HAL_TRACE_ERROR0 ("Patch authentication failed"); 597 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_ABORT_BAD_SIGNATURE_EVT); 598 return; 599 } 600 601#if (defined (NFC_HAL_PRE_I2C_PATCH_INCLUDED) && (NFC_HAL_PRE_I2C_PATCH_INCLUDED == TRUE)) 602 if (nfc_hal_cb.prm.flags & NFC_HAL_PRM_FLAGS_I2C_FIX_REQUIRED) 603 { 604 HAL_TRACE_DEBUG1 ("PreI2C patch downloaded...waiting %i ms for NFCC to reboot.", nfc_hal_cb.prm_i2c.prei2c_delay); 605 606 /* Restore pointers to patchfile */ 607 nfc_hal_cb.prm.flags &= ~NFC_HAL_PRM_FLAGS_I2C_FIX_REQUIRED; 608 nfc_hal_cb.prm.p_cur_patch_data = nfc_hal_cb.prm.p_spd_patch; 609 nfc_hal_cb.prm.cur_patch_offset = nfc_hal_cb.prm.spd_patch_offset; 610 nfc_hal_cb.prm.cur_patch_len_remaining = nfc_hal_cb.prm.spd_patch_len_remaining; 611 612 /* Resume normal patch download */ 613 nfc_hal_cb.prm.state = NFC_HAL_PRM_ST_SPD_GET_PATCH_HEADER; 614 nfc_hal_cb.prm.flags &= ~NFC_HAL_PRM_FLAGS_SIGNATURE_SENT; 615 616 /* Post PreI2C delay */ 617 nfc_hal_main_start_quick_timer (&nfc_hal_cb.prm.timer, 0x00, (nfc_hal_cb.prm_i2c.prei2c_delay * QUICK_TIMER_TICKS_PER_SEC) / 1000); 618 619 return; 620 } 621#endif /* NFC_HAL_PRE_I2C_PATCH_INCLUDED */ 622 623 624 /* Wait for NFCC to save the patch to NVM */ 625 if (!(nfc_hal_cb.prm.flags & NFC_HAL_PRM_FLAGS_BCM20791B3)) 626 { 627 /* 20791B4 or newer - wait for RESET_NTF; including time to commit to NVM (for BCM20791B4+) */ 628 post_signature_delay = NFC_HAL_PRM_COMMIT_DELAY; 629 HAL_TRACE_DEBUG1 ("Patch downloaded and authenticated. Waiting %i ms for RESET NTF...", post_signature_delay); 630 631 } 632 else if (nfc_hal_cb.nvm_cb.flags & NFC_HAL_NVM_FLAGS_NO_NVM) 633 { 634 /* No NVM. Wait for NFCC to restart */ 635 post_signature_delay = NFC_HAL_PRM_END_DELAY; 636 HAL_TRACE_DEBUG1 ("Patch downloaded and authenticated. Waiting %i ms for NFCC to restart...", post_signature_delay); 637 } 638 else 639 { 640 /* Wait for NFCC to save the patch to NVM (need about 1 ms per byte) */ 641 post_signature_delay = nfc_hal_cb.prm.spd_patch_desc[nfc_hal_cb.prm.spd_cur_patch_idx].len; 642 if (post_signature_delay < nfc_hal_cb.prm.patchram_delay) 643 post_signature_delay = nfc_hal_cb.prm.patchram_delay; 644 HAL_TRACE_DEBUG1 ("Patch downloaded and authenticated. Waiting %i ms for NVM update to complete...", post_signature_delay); 645 } 646 647 nfc_hal_cb.prm.state = NFC_HAL_PRM_ST_SPD_AUTH_DONE; 648 649 nfc_hal_main_start_quick_timer (&nfc_hal_cb.prm.timer, 0x00, 650 (post_signature_delay * QUICK_TIMER_TICKS_PER_SEC) / 1000); 651 } 652 else 653 { 654 HAL_TRACE_ERROR0 ("Got unexpected SECURE_PATCH_DOWNLOAD NTF"); 655 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_ABORT_EVT); 656 } 657 } 658 /* Handle NCI_MSG_GET_PATCH_VERSION RSP */ 659 else if (event == NFC_VS_GET_PATCH_VERSION_EVT) 660 { 661 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_COMPLETE_EVT); 662 } 663 else 664 { 665 /* Invalid response from NFCC during patch download */ 666 HAL_TRACE_ERROR1 ("Invalid response from NFCC during patch download (opcode=0x%02X)", event); 667 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_ABORT_INVALID_PATCH_EVT); 668 } 669 670 NFC_HAL_PRM_STATE ("prm_nci_command_complete_cback"); 671} 672 673/******************************************************************************* 674** 675** Function nfc_hal_prm_nfcc_ready_to_continue 676** 677** Description Continue to download patch or notify application completition 678** 679** Returns void 680** 681*******************************************************************************/ 682void nfc_hal_prm_nfcc_ready_to_continue (void) 683{ 684 UINT8 get_patch_version_cmd [NCI_MSG_HDR_SIZE] = 685 { 686 NCI_MTS_CMD|NCI_GID_PROP, 687 NCI_MSG_GET_PATCH_VERSION, 688 0x00 689 }; 690 691 /* Clear the bit for the patch we just downloaded */ 692 nfc_hal_cb.prm.spd_patch_needed_mask &= ~ ((UINT32) 1 << nfc_hal_cb.prm.spd_patch_desc[nfc_hal_cb.prm.spd_cur_patch_idx].power_mode); 693 694 /* Check if another patch to download */ 695 nfc_hal_cb.prm.spd_cur_patch_idx++; 696 if ((nfc_hal_cb.prm.spd_patch_needed_mask) && (nfc_hal_cb.prm.spd_cur_patch_idx < nfc_hal_cb.prm.spd_patch_count)) 697 { 698 nfc_hal_cb.prm.state = NFC_HAL_PRM_ST_SPD_GET_PATCH_HEADER; 699 nfc_hal_cb.prm.flags &= ~NFC_HAL_PRM_FLAGS_SIGNATURE_SENT; 700 701 if (nfc_hal_cb.prm.flags & NFC_HAL_PRM_FLAGS_USE_PATCHRAM_BUF) 702 { 703 /* If patch is in a buffer, get next patch from buffer */ 704 nfc_hal_prm_spd_handle_next_patch_start (); 705 } 706 else 707 { 708 /* Notify adaptation layer to get next patch header (via HAL_NfcPrmDownloadContinue) */ 709 (nfc_hal_cb.prm.p_cback) (NFC_HAL_PRM_SPD_GET_NEXT_PATCH); 710 } 711 712 } 713 else 714 { 715 /* Done downloading */ 716 HAL_TRACE_DEBUG0 ("Patch downloaded and authenticated. Get new patch version."); 717 /* add get patch info again to verify the effective FW version */ 718 nfc_hal_dm_send_nci_cmd (get_patch_version_cmd, NCI_MSG_HDR_SIZE, nfc_hal_prm_nci_command_complete_cback); 719 nfc_hal_cb.prm.state = NFC_HAL_PRM_ST_W4_GET_VERSION; 720 } 721} 722 723/******************************************************************************* 724** 725** Function nfc_hal_prm_spd_reset_ntf 726** 727** Description Received RESET NTF from NFCC, indicating it has completed 728** reset after patch download. 729** 730** Returns void 731** 732*******************************************************************************/ 733void nfc_hal_prm_spd_reset_ntf (UINT8 reset_reason, UINT8 reset_type) 734{ 735 /* Check if we were expecting a RESET NTF */ 736 if (nfc_hal_cb.prm.state == NFC_HAL_PRM_ST_SPD_AUTH_DONE) 737 { 738 HAL_TRACE_DEBUG2 ("Received RESET NTF after patch download (reset_reason=%i, reset_type=%i)", reset_reason, reset_type); 739 740 /* Stop waiting for RESET NTF */ 741 nfc_hal_main_stop_quick_timer (&nfc_hal_cb.prm.timer); 742 743 { 744 /* Continue with patch download */ 745 nfc_hal_prm_nfcc_ready_to_continue (); 746 } 747 } 748 else if (nfc_hal_cb.prm.state == NFC_HAL_PRM_ST_SPD_GET_PATCH_HEADER) 749 { 750 HAL_TRACE_DEBUG0 ("Received RESET NTF after pre-I2C patch download. Proceeding with patch download..."); 751 752 /* Stop waiting for RESET NTF */ 753 nfc_hal_main_stop_quick_timer (&nfc_hal_cb.prm.timer); 754 nfc_hal_prm_spd_handle_next_patch_start (); 755 } 756 else 757 { 758 HAL_TRACE_ERROR2 ("Received unexpected RESET NTF (reset_reason=%i, reset_type=%i)", reset_reason, reset_type); 759 } 760} 761 762/******************************************************************************* 763** 764** Function: nfc_post_final_baud_update 765** 766** Description: Called after baud rate udate 767** 768** Returns: Nothing 769** 770*******************************************************************************/ 771void nfc_hal_prm_post_baud_update (tHAL_NFC_STATUS status) 772{ 773 NFC_HAL_PRM_STATE ("nfc_hal_prm_post_baud_update"); 774 775 if (nfc_hal_cb.prm.state == NFC_HAL_PRM_ST_SPD_AUTH_DONE) 776 { 777 /* Proceed with next step of patch download sequence */ 778 nfc_hal_prm_nfcc_ready_to_continue (); 779 } 780} 781 782/******************************************************************************* 783** 784** Function nfc_hal_prm_process_timeout 785** 786** Description Process timer expireation for patch download 787** 788** Returns void 789** 790*******************************************************************************/ 791void nfc_hal_prm_process_timeout (void *p_tle) 792{ 793 NFC_HAL_PRM_STATE ("nfc_hal_prm_process_timeout"); 794 795 if (nfc_hal_cb.prm.state == NFC_HAL_PRM_ST_SPD_AUTH_DONE) 796 { 797 if (!(nfc_hal_cb.prm.flags & NFC_HAL_PRM_FLAGS_BCM20791B3)) 798 { 799 /* Timeout waiting for RESET NTF after signature sent */ 800 HAL_TRACE_ERROR0 ("Timeout waiting for RESET NTF after patch download"); 801 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_ABORT_EVT); 802 } 803 else 804 { 805 nfc_hal_prm_nfcc_ready_to_continue (); 806 } 807 } 808 else if (nfc_hal_cb.prm.state == NFC_HAL_PRM_ST_SPD_GET_PATCH_HEADER) 809 { 810 HAL_TRACE_DEBUG0 ("Delay after PreI2C patch download...proceeding to download firmware patch"); 811 nfc_hal_prm_spd_handle_next_patch_start (); 812 } 813 else if (nfc_hal_cb.prm.state == NFC_HAL_PRM_ST_W4_GET_VERSION) 814 { 815 HAL_TRACE_DEBUG0 ("get patch version timeout???"); 816 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_COMPLETE_EVT); 817 } 818 else 819 { 820 HAL_TRACE_ERROR1 ("Patch download: command timeout (state=%i)", nfc_hal_cb.prm.state); 821 822 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_ABORT_EVT); 823 } 824 825 NFC_HAL_PRM_STATE ("nfc_hal_prm_process_timeout"); 826} 827 828 829/******************************************************************************* 830** 831** Function HAL_NfcPrmDownloadStart 832** 833** Description Initiate patch download 834** 835** Input Params 836** format_type patch format type 837** (NFC_HAL_PRM_FORMAT_BIN, NFC_HAL_PRM_FORMAT_HCD, or 838** NFC_HAL_PRM_FORMAT_NCD) 839** 840** dest_address destination adderess (needed for BIN format only) 841** 842** p_patchram_buf pointer to patchram buffer. If NULL, 843** then app must call HAL_NfcPrmDownloadContinue when 844** NFC_HAL_PRM_CONTINUE_EVT is received, to send the next 845** segment of patchram 846** 847** patchram_len size of p_patchram_buf (if non-NULL) 848** 849** patchram_delay The delay after each patch. 850** If the given value is less than the size of the patchram, 851** the size of patchram is used instead. 852** 853** p_cback callback for download status 854** 855** 856** Returns TRUE if successful, otherwise FALSE 857** 858** 859*******************************************************************************/ 860BOOLEAN HAL_NfcPrmDownloadStart (tNFC_HAL_PRM_FORMAT format_type, 861 UINT32 dest_address, 862 UINT8 *p_patchram_buf, 863 UINT32 patchram_len, 864 UINT32 patchram_delay, 865 tNFC_HAL_PRM_CBACK *p_cback) 866{ 867 HAL_TRACE_API0 ("HAL_NfcPrmDownloadStart ()"); 868 869 memset (&nfc_hal_cb.prm, 0, sizeof (tNFC_HAL_PRM_CB)); 870 871 if (p_patchram_buf) 872 { 873 nfc_hal_cb.prm.p_cur_patch_data = p_patchram_buf; 874 nfc_hal_cb.prm.cur_patch_offset = 0; 875 nfc_hal_cb.prm.cur_patch_len_remaining = (UINT16) patchram_len; 876 nfc_hal_cb.prm.flags |= NFC_HAL_PRM_FLAGS_USE_PATCHRAM_BUF; 877 878 if (patchram_len == 0) 879 return FALSE; 880 } 881 882 nfc_hal_cb.prm.p_cback = p_cback; 883 nfc_hal_cb.prm.dest_ram = dest_address; 884 nfc_hal_cb.prm.format = format_type; 885 nfc_hal_cb.prm.patchram_delay = patchram_delay; 886 887 nfc_hal_cb.prm.timer.p_cback = nfc_hal_prm_process_timeout; 888 889 if (format_type == NFC_HAL_PRM_FORMAT_NCD) 890 { 891 /* Store patch buffer pointer and length */ 892 nfc_hal_cb.prm.p_spd_patch = p_patchram_buf; 893 nfc_hal_cb.prm.spd_patch_len_remaining = (UINT16)patchram_len; 894 nfc_hal_cb.prm.spd_patch_offset = 0; 895 896 /* If patch download is required, but no NVM is available, then abort */ 897 if ((p_nfc_hal_cfg->nfc_hal_prm_nvm_required) && (nfc_hal_cb.nvm_cb.flags & NFC_HAL_NVM_FLAGS_NO_NVM)) 898 { 899 HAL_TRACE_ERROR0 ("This platform requires NVM and the NVM is not available - Abort"); 900 nfc_hal_prm_spd_handle_download_complete (NFC_HAL_PRM_ABORT_NO_NVM_EVT); 901 return FALSE; 902 } 903 904 /* Compare patch version in NVM with version in patchfile */ 905 nfc_hal_cb.prm.state = NFC_HAL_PRM_ST_SPD_COMPARE_VERSION; 906 if (nfc_hal_cb.prm.flags & NFC_HAL_PRM_FLAGS_USE_PATCHRAM_BUF) 907 { 908 /* If patchfile is in a buffer, get patch version from buffer */ 909 nfc_hal_prm_spd_check_version (); 910 } 911 else 912 { 913 /* If patchfile is not in a buffer, then request patchfile header from adaptation layer. */ 914 (nfc_hal_cb.prm.p_cback) (NFC_HAL_PRM_SPD_GET_PATCHFILE_HDR_EVT); 915 } 916 } 917 else 918 { 919 HAL_TRACE_ERROR0 ("Unexpected patch format."); 920 return FALSE; 921 } 922 923 return TRUE; 924} 925 926/******************************************************************************* 927** 928** Function HAL_NfcPrmDownloadContinue 929** 930** Description Send next segment of patchram to controller. Called when 931** NFC_HAL_PRM_CONTINUE_EVT is received. 932** 933** Only needed if HAL_NfcPrmDownloadStart was called with 934** p_patchram_buf=NULL 935** 936** Input Params p_patch_data pointer to patch data 937** patch_data_len patch data len 938** 939** Returns TRUE if successful, otherwise FALSE 940** 941*******************************************************************************/ 942BOOLEAN HAL_NfcPrmDownloadContinue (UINT8 *p_patch_data, 943 UINT16 patch_data_len) 944{ 945 HAL_TRACE_API2 ("HAL_NfcPrmDownloadContinue ():state = %d, patch_data_len=%d", 946 nfc_hal_cb.prm.state, patch_data_len); 947 948 /* Check if we are in a valid state for this API */ 949 if ( (nfc_hal_cb.prm.state != NFC_HAL_PRM_ST_SPD_COMPARE_VERSION) 950 &&(nfc_hal_cb.prm.state != NFC_HAL_PRM_ST_SPD_GET_PATCH_HEADER) 951 &&(nfc_hal_cb.prm.state != NFC_HAL_PRM_ST_SPD_DOWNLOADING) ) 952 return FALSE; 953 954 if (patch_data_len == 0) 955 return FALSE; 956 957 nfc_hal_cb.prm.cur_patch_offset = 0; 958 nfc_hal_cb.prm.p_cur_patch_data = p_patch_data; 959 nfc_hal_cb.prm.cur_patch_len_remaining = patch_data_len; 960 961 /* Call appropriate handler */ 962 if (nfc_hal_cb.prm.state == NFC_HAL_PRM_ST_SPD_COMPARE_VERSION) 963 { 964 nfc_hal_prm_spd_check_version (); 965 } 966 else if (nfc_hal_cb.prm.state == NFC_HAL_PRM_ST_SPD_GET_PATCH_HEADER) 967 { 968 nfc_hal_prm_spd_handle_next_patch_start (); 969 } 970 else if (nfc_hal_cb.prm.state == NFC_HAL_PRM_ST_SPD_DOWNLOADING) 971 { 972 nfc_hal_prm_spd_send_next_segment (); 973 } 974 else 975 { 976 HAL_TRACE_ERROR1 ("Unexpected patch state:%d.", nfc_hal_cb.prm.state); 977 } 978 979 return TRUE; 980} 981 982/******************************************************************************* 983** 984** Function HAL_NfcPrmSetI2cPatch 985** 986** Description Specify patchfile for BCM20791B3 I2C fix. This fix 987** must be downloaded prior to initial patch download for I2C 988** transport 989** 990** Input Params p_i2c_patchfile_buf: pointer to patch for i2c fix 991** i2c_patchfile_len: length of patch 992** prei2c_delay: the delay before downloading main patch 993** if 0 is given, NFC_HAL_PRM_POST_I2C_FIX_DELAY is used instead. 994** 995** Returns Nothing 996** 997** 998*******************************************************************************/ 999void HAL_NfcPrmSetI2cPatch (UINT8 *p_i2c_patchfile_buf, UINT16 i2c_patchfile_len, UINT32 prei2c_delay) 1000{ 1001#if (defined (NFC_HAL_PRE_I2C_PATCH_INCLUDED) && (NFC_HAL_PRE_I2C_PATCH_INCLUDED == TRUE)) 1002 HAL_TRACE_API0 ("HAL_NfcPrmSetI2cPatch ()"); 1003 1004 nfc_hal_cb.prm_i2c.prei2c_delay = NFC_HAL_PRM_POST_I2C_FIX_DELAY; 1005 if (prei2c_delay) 1006 nfc_hal_cb.prm_i2c.prei2c_delay = prei2c_delay; 1007 nfc_hal_cb.prm_i2c.p_patch = p_i2c_patchfile_buf; 1008 nfc_hal_cb.prm_i2c.len = i2c_patchfile_len; 1009#endif /* NFC_HAL_PRE_I2C_PATCH_INCLUDED */ 1010} 1011 1012/******************************************************************************* 1013** 1014** Function HAL_NfcPrmSetSpdNciCmdPayloadSize 1015** 1016** Description Set Host-to-NFCC NCI message size for secure patch download 1017** 1018** This API must be called before calling HAL_NfcPrmDownloadStart. 1019** If the API is not called, then PRM will use the default 1020** message size. 1021** 1022** Typically, this API is only called for platforms that have 1023** message-size limitations in the transport/driver. 1024** 1025** Valid message size range: NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE to 255. 1026** 1027** Returns HAL_NFC_STATUS_OK if successful 1028** HAL_NFC_STATUS_FAILED otherwise 1029** 1030** 1031*******************************************************************************/ 1032tHAL_NFC_STATUS HAL_NfcPrmSetSpdNciCmdPayloadSize (UINT8 max_payload_size) 1033{ 1034 /* Validate: minimum size is NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE */ 1035 if (max_payload_size < NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE) 1036 { 1037 HAL_TRACE_ERROR2 ("HAL_NfcPrmSetSpdNciCmdPayloadSize: invalid size (%i). Must be between %i and 255", max_payload_size, NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE); 1038 return (HAL_NFC_STATUS_FAILED); 1039 } 1040 else 1041 { 1042 HAL_TRACE_API1 ("HAL_NfcPrmSetSpdNciCmdPayloadSize: new message size during download: %i", max_payload_size); 1043 nfc_hal_cb.ncit_cb.nci_ctrl_size = max_payload_size; 1044 return (HAL_NFC_STATUS_OK); 1045 } 1046} 1047