recovery_seq.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /******************************************************************************
  2. * Copyright (C) 2021 NXP
  3. * *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. *
  18. ******************************************************************************/
  19. #if IS_ENABLED(CONFIG_NXP_NFC_RECOVERY)
  20. #ifndef __RECOVERY_SEQ_H_
  21. #define __RECOVERY_SEQ_H_
  22. #include "common.h"
  23. #define MAX_FRAME_SIZE 0x22A /* support for 256(0x100) & 554(0x22A) frame size*/
  24. #define MAX_DATA_SIZE \
  25. (MAX_FRAME_SIZE - FW_CRC_LEN - FW_HDR_LEN)
  26. #define RECOVERY_FW_MJ_VER_OFFSET 5
  27. #define DL_SET_HDR_FRAGBIT(n) \
  28. ((n) | (1 << 10)) /* Header chunk bit set macro */
  29. #define DL_CLR_HDR_FRAGBIT(n) \
  30. ((n) & ~(1U << 10)) /* Header chunk bit clear macro */
  31. #define DL_FRAME_RESP_LEN 0x04
  32. #define DL_FRAME_RESP_LEN_OFFSET 1
  33. #define DL_FRAME_RESP_STAT_OFFSET 2
  34. #define DL_SEGMENTED_FRAME_RESP_STAT1 0x2D
  35. #define DL_SEGMENTED_FRAME_RESP_STAT2 0x2E
  36. #define DL_NON_SEGMENTED_FRAME_RESP_STAT 0x00
  37. #define DL_INVALID_CRC_VALUE 0xffffU
  38. #define DL_CRC_MASK 0xff
  39. #define SHIFT_MASK 0x00FF
  40. #define MSB_POS 8
  41. /* Data buffer for frame to write */
  42. struct recovery_frame {
  43. uint32_t len;
  44. uint8_t *p_buffer;
  45. };
  46. /* Contains Info about user buffer and last data frame */
  47. struct recovery_info {
  48. uint32_t currentReadOffset; /* current offset within the user buffer to read/write */
  49. uint32_t remBytes; /* Remaining bytes to write */
  50. uint16_t wRemChunkBytes; /* Remaining bytes within the chunked frame */
  51. bool bFrameSegmented; /* Indicates the current frame is segmented */
  52. };
  53. /* indicates the error codes for nfc recovery module */
  54. enum recovery_status {
  55. STATUS_SUCCESS = 0x00,
  56. STATUS_FAILED = 0x01,
  57. };
  58. extern const uint32_t gphDnldNfc_DlSeqSz; /* Recovery user buffer size */
  59. extern const uint8_t gphDnldNfc_DlSequence[]; /* Recovery user buffer */
  60. /** @brief Function to recover the nfcc.
  61. * @param nfc_dev nfc driver object.
  62. * @return status code of type recovery_status_t.
  63. */
  64. enum recovery_status do_recovery(struct nfc_dev *nfc_dev);
  65. #endif// end __RECOVERY_SEQ_H_
  66. #endif