summaryrefslogtreecommitdiffstats
path: root/halimpl/bcm2079x/hal
diff options
context:
space:
mode:
authorArne Coucheron <arco68@gmail.com>2018-08-21 00:36:42 +0200
committerMichael Bestas <mkbestas@lineageos.org>2018-09-23 21:09:24 +0300
commit54588579843e7b00745eec2d870a0d8fbe3942d3 (patch)
treec76b760194729df177d43130a14a82482e4ea212 /halimpl/bcm2079x/hal
parent86b98cb60c1ef17a5f5fe3142cb001a56e6eb91f (diff)
downloadandroid_hardware_broadcom_nfc-54588579843e7b00745eec2d870a0d8fbe3942d3.tar.gz
android_hardware_broadcom_nfc-54588579843e7b00745eec2d870a0d8fbe3942d3.tar.bz2
android_hardware_broadcom_nfc-54588579843e7b00745eec2d870a0d8fbe3942d3.zip
Move include files into halimpl folderlineage-16.0
Change-Id: I975517a3b8b8db39046fe1adab7b07e0dcd0832e
Diffstat (limited to 'halimpl/bcm2079x/hal')
-rw-r--r--halimpl/bcm2079x/hal/include/gki_hal_target.h265
-rw-r--r--halimpl/bcm2079x/hal/include/nci_defs.h814
-rw-r--r--halimpl/bcm2079x/hal/include/nfc_hal_api.h248
-rw-r--r--halimpl/bcm2079x/hal/include/nfc_hal_target.h437
-rw-r--r--halimpl/bcm2079x/hal/include/nfc_types.h351
-rw-r--r--halimpl/bcm2079x/hal/int/nfc_brcm_defs.h421
-rw-r--r--halimpl/bcm2079x/hal/int/nfc_hal_int.h550
-rw-r--r--halimpl/bcm2079x/hal/int/nfc_hal_int_api.h307
-rw-r--r--halimpl/bcm2079x/hal/int/nfc_hal_nv_ci.h90
-rw-r--r--halimpl/bcm2079x/hal/int/nfc_hal_nv_co.h115
-rw-r--r--halimpl/bcm2079x/hal/int/nfc_hal_post_reset.h73
11 files changed, 3671 insertions, 0 deletions
diff --git a/halimpl/bcm2079x/hal/include/gki_hal_target.h b/halimpl/bcm2079x/hal/include/gki_hal_target.h
new file mode 100644
index 0000000..4b065c7
--- /dev/null
+++ b/halimpl/bcm2079x/hal/include/gki_hal_target.h
@@ -0,0 +1,265 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2012-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef GKI_HAL_TARGET_H
+#define GKI_HAL_TARGET_H
+
+#ifdef BUILDCFG
+#include "buildcfg_hal.h"
+#endif
+
+#include "data_types.h"
+
+/******************************************************************************
+**
+** Task configuration
+**
+******************************************************************************/
+
+/* Definitions of task IDs for inter-task messaging */
+#ifndef NFC_HAL_TASK
+#define NFC_HAL_TASK 0
+#endif
+
+/* The number of GKI tasks in the software system. */
+#ifndef GKI_MAX_TASKS
+#define GKI_MAX_TASKS 1
+#endif
+
+/******************************************************************************
+**
+** Buffer pool assignment
+**
+******************************************************************************/
+
+/* GKI pool for NCI messages */
+#ifndef NFC_HAL_NCI_POOL_ID
+#define NFC_HAL_NCI_POOL_ID GKI_POOL_ID_1
+#endif
+
+#ifndef NFC_HAL_NCI_POOL_BUF_SIZE
+#define NFC_HAL_NCI_POOL_BUF_SIZE GKI_BUF1_SIZE
+#endif
+
+/******************************************************************************
+**
+** Timer configuration
+**
+******************************************************************************/
+
+/* The number of GKI timers in the software system. */
+#ifndef GKI_NUM_TIMERS
+#define GKI_NUM_TIMERS 2
+#endif
+
+/* A conversion value for translating ticks to calculate GKI timer. */
+#ifndef TICKS_PER_SEC
+#define TICKS_PER_SEC 100
+#endif
+
+/************************************************************************
+** Utility macros converting ticks to time with user define OS ticks per sec
+**/
+#ifndef GKI_MS_TO_TICKS
+#define GKI_MS_TO_TICKS(x) ((x) / (1000 / TICKS_PER_SEC))
+#endif
+
+#ifndef GKI_SECS_TO_TICKS
+#define GKI_SECS_TO_TICKS(x) ((x) * (TICKS_PER_SEC))
+#endif
+
+#ifndef GKI_TICKS_TO_MS
+#define GKI_TICKS_TO_MS(x) ((x)*1000 / TICKS_PER_SEC)
+#endif
+
+#ifndef GKI_TICKS_TO_SECS
+#define GKI_TICKS_TO_SECS(x) ((x) / TICKS_PER_SEC)
+#endif
+
+/* TICK per second from OS (OS dependent change this macro accordingly to
+ * various OS) */
+#ifndef OS_TICKS_PER_SEC
+#define OS_TICKS_PER_SEC 1000
+#endif
+
+/************************************************************************
+** Utility macros converting ticks to time with user define OS ticks per sec
+**/
+
+#ifndef GKI_OS_TICKS_TO_MS
+#define GKI_OS_TICKS_TO_MS(x) ((x)*1000 / OS_TICKS_PER_SEC)
+#endif
+
+#ifndef GKI_OS_TICKS_TO_SECS
+#define GKI_OS_TICKS_TO_SECS(x) ((x) / OS_TICKS_PER_SEC))
+#endif
+
+/* delay in ticks before stopping system tick. */
+#ifndef GKI_DELAY_STOP_SYS_TICK
+#define GKI_DELAY_STOP_SYS_TICK 10
+#endif
+
+/* Option to guarantee no preemption during timer expiration (most system don't
+ * need this) */
+#ifndef GKI_TIMER_LIST_NOPREEMPT
+#define GKI_TIMER_LIST_NOPREEMPT FALSE
+#endif
+
+/******************************************************************************
+**
+** Buffer configuration
+**
+******************************************************************************/
+
+/* The size of the buffers in pool 0. */
+#ifndef GKI_BUF0_SIZE
+#define GKI_BUF0_SIZE 64
+#endif
+
+/* The number of buffers in buffer pool 0. */
+#ifndef GKI_BUF0_MAX
+#define GKI_BUF0_MAX 8
+#endif
+
+/* The ID of buffer pool 0. */
+#ifndef GKI_POOL_ID_0
+#define GKI_POOL_ID_0 0
+#endif
+
+/* The size of the buffers in pool 1. */
+#ifndef GKI_BUF1_SIZE
+#define GKI_BUF1_SIZE 288
+#endif
+
+/* The number of buffers in buffer pool 1. */
+#ifndef GKI_BUF1_MAX
+#define GKI_BUF1_MAX 8
+#endif
+
+/* The ID of buffer pool 1. */
+#ifndef GKI_POOL_ID_1
+#define GKI_POOL_ID_1 1
+#endif
+
+/* The size of the largest PUBLIC fixed buffer in system. */
+#ifndef GKI_MAX_BUF_SIZE
+#define GKI_MAX_BUF_SIZE GKI_BUF1_SIZE
+#endif
+
+/* The pool ID of the largest PUBLIC fixed buffer in system. */
+#ifndef GKI_MAX_BUF_SIZE_POOL_ID
+#define GKI_MAX_BUF_SIZE_POOL_ID GKI_POOL_ID_1
+#endif
+
+/* buffer size for USERIAL, it must large enough to hold NFC_HDR and max packet
+ * size */
+#ifndef USERIAL_POOL_BUF_SIZE
+#define USERIAL_POOL_BUF_SIZE GKI_BUF1_SIZE
+#endif
+
+/* buffer pool ID for USERIAL */
+#ifndef USERIAL_POOL_ID
+#define USERIAL_POOL_ID GKI_POOL_ID_1
+#endif
+
+#ifndef GKI_NUM_FIXED_BUF_POOLS
+#define GKI_NUM_FIXED_BUF_POOLS 2
+#endif
+
+/* The number of fixed and dynamic buffer pools */
+#ifndef GKI_NUM_TOTAL_BUF_POOLS
+#define GKI_NUM_TOTAL_BUF_POOLS 2
+#endif
+
+/* The buffer pool usage mask. */
+#ifndef GKI_DEF_BUFPOOL_PERM_MASK
+#define GKI_DEF_BUFPOOL_PERM_MASK 0xfff0
+#endif
+
+/* The buffer corruption check flag. */
+#ifndef GKI_ENABLE_BUF_CORRUPTION_CHECK
+#define GKI_ENABLE_BUF_CORRUPTION_CHECK TRUE
+#endif
+
+/* The GKI severe error macro. */
+#ifndef GKI_SEVERE
+#define GKI_SEVERE(code)
+#endif
+
+/* Maximum number of exceptions logged. */
+#ifndef GKI_MAX_EXCEPTION
+#define GKI_MAX_EXCEPTION 8
+#endif
+
+/* Maximum number of chars stored for each exception message. */
+#ifndef GKI_MAX_EXCEPTION_MSGLEN
+#define GKI_MAX_EXCEPTION_MSGLEN 64
+#endif
+
+#ifndef GKI_SEND_MSG_FROM_ISR
+#define GKI_SEND_MSG_FROM_ISR FALSE
+#endif
+
+#define GKI_TRACE_0(m)
+#define GKI_TRACE_1(m, p1)
+#define GKI_TRACE_2(m, p1, p2)
+#define GKI_TRACE_3(m, p1, p2, p3)
+#define GKI_TRACE_4(m, p1, p2, p3, p4)
+#define GKI_TRACE_5(m, p1, p2, p3, p4, p5)
+#define GKI_TRACE_6(m, p1, p2, p3, p4, p5, p6)
+
+#define GKI_TRACE_ERROR_0(m) \
+ LogMsg( \
+ TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
+ m)
+#define GKI_TRACE_ERROR_1(m, p1) \
+ LogMsg( \
+ TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
+ m, p1)
+#define GKI_TRACE_ERROR_2(m, p1, p2) \
+ LogMsg( \
+ TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
+ m, p1, p2)
+#define GKI_TRACE_ERROR_3(m, p1, p2, p3) \
+ LogMsg( \
+ TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
+ m, p1, p2, p3)
+#define GKI_TRACE_ERROR_4(m, p1, p2, p3, p4) \
+ LogMsg( \
+ TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
+ m, p1, p2, p3, p4)
+#define GKI_TRACE_ERROR_5(m, p1, p2, p3, p4, p5) \
+ LogMsg( \
+ TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
+ m, p1, p2, p3, p4, p5)
+#define GKI_TRACE_ERROR_6(m, p1, p2, p3, p4, p5, p6) \
+ LogMsg( \
+ TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
+ m, p1, p2, p3, p4, p5, p6)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GKI_TARGET_H */
diff --git a/halimpl/bcm2079x/hal/include/nci_defs.h b/halimpl/bcm2079x/hal/include/nci_defs.h
new file mode 100644
index 0000000..46969e0
--- /dev/null
+++ b/halimpl/bcm2079x/hal/include/nci_defs.h
@@ -0,0 +1,814 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the definition from NCI specification
+ *
+ ******************************************************************************/
+
+#ifndef NFC_NCI_DEFS_H
+#define NFC_NCI_DEFS_H
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NCI_BRCM_CO_ID 0x2E
+
+/* Define the message header size for all NCI Commands and Notifications.
+*/
+#define NCI_MSG_HDR_SIZE 3 /* per NCI spec */
+#define NCI_DATA_HDR_SIZE 3 /* per NCI spec */
+#define NCI_MAX_PAYLOAD_SIZE 0xFE
+#define NCI_MAX_CTRL_SIZE 0xFF /* max control message size */
+#define NCI_CTRL_INIT_SIZE 32 /* initial NFCC control payload size */
+#define NCI_MAX_VSC_SIZE 0xFF
+#define APPL_DTA_MODE FALSE
+/* NCI header (3) + callback function pointer(8; use 8 to be safe) + HCIT (1
+ * byte) */
+#define NCI_VSC_MSG_HDR_SIZE 12
+#define NCI_TL_SIZE 2
+
+/* Max frame size (256) - Prologue (1) - Epilogue (2) in ISO-DEP, CID and NAD
+ * are not used*/
+#define NCI_ISO_DEP_MAX_INFO 253
+/* Max payload (254) - Protocol Header (3) in NFC-DEP, DID and NAD are not used
+ */
+#define NCI_NFC_DEP_MAX_DATA 251
+
+/* NCI Command and Notification Format:
+ * 3 byte message header:
+ * byte 0: MT PBF GID
+ * byte 1: OID
+ * byte 2: Message Length */
+/* MT: Message Type (byte 0) */
+#define NCI_MT_MASK 0xE0
+#define NCI_MT_SHIFT 5
+#define NCI_MT_DATA 0x00
+#define NCI_MT_CMD 1 /* (NCI_MT_CMD << NCI_MT_SHIFT) = 0x20 */
+#define NCI_MT_RSP 2 /* (NCI_MT_RSP << NCI_MT_SHIFT) = 0x40 */
+#define NCI_MT_NTF 3 /* (NCI_MT_NTF << NCI_MT_SHIFT) = 0x60 */
+#define NCI_MT_CFG 4 /* (NCI_MT_CFG << NCI_MT_SHIFT) = 0x80 */
+
+#define NCI_MTS_CMD 0x20
+#define NCI_MTS_RSP 0x40
+#define NCI_MTS_NTF 0x60
+#define NCI_MTS_CFG 0x80
+
+#define NCI_NTF_BIT 0x80 /* the tNFC_VS_EVT is a notification */
+#define NCI_RSP_BIT 0x40 /* the tNFC_VS_EVT is a response */
+
+/* for internal use only; not from specification */
+/* the following 2 flags are used in layer_specific for fragmentation/reassembly
+ * of data packets */
+#define NCI_LS_DATA 0x00
+#define NCI_LS_DATA_PBF 0x01
+
+/* PBF: Packet Boundary Flag (byte 0) */
+#define NCI_PBF_MASK 0x10
+#define NCI_PBF_SHIFT 4
+#define NCI_PBF_NO_OR_LAST 0x00 /* not fragmented or last fragment */
+#define NCI_PBF_ST_CONT 0x10 /* start or continuing fragment */
+
+/* GID: Group Identifier (byte 0) */
+#define NCI_GID_MASK 0x0F
+#define NCI_GID_SHIFT 0
+#define NCI_GID_CORE 0x00 /* 0000b NCI Core group */
+#define NCI_GID_RF_MANAGE 0x01 /* 0001b RF Management group */
+#define NCI_GID_EE_MANAGE 0x02 /* 0010b NFCEE Management group */
+#define NCI_GID_PROP 0x0F /* 1111b Proprietary */
+/* 0111b - 1110b RFU */
+
+/* OID: Opcode Identifier (byte 1) */
+#define NCI_OID_MASK 0x3F
+#define NCI_OID_SHIFT 0
+
+/* For routing */
+#define NCI_DH_ID 0 /* for DH */
+/* To identify the loopback test */
+#define NCI_TEST_ID 0xFE /* for loopback test */
+
+/* Destination Type */
+#define NCI_DEST_TYPE_NFCC 1 /* NFCC - loopback */
+#define NCI_DEST_TYPE_REMOTE 2 /* Remote NFC Endpoint */
+#define NCI_DEST_TYPE_NFCEE 3 /* NFCEE */
+
+/* builds byte0 of NCI Command and Notification packet */
+#define NCI_MSG_BLD_HDR0(p, mt, gid) \
+ *(p)++ = (uint8_t)(((mt) << NCI_MT_SHIFT) | (gid));
+
+#define NCI_MSG_PBLD_HDR0(p, mt, pbf, gid) \
+ *(p)++ = (uint8_t)(((mt) << NCI_MT_SHIFT) | ((pbf) << NCI_PBF_SHIFT) | (gid));
+
+/* builds byte1 of NCI Command and Notification packet */
+#define NCI_MSG_BLD_HDR1(p, oid) *(p)++ = (uint8_t)(((oid) << NCI_OID_SHIFT));
+
+/* parse byte0 of NCI packet */
+#define NCI_MSG_PRS_HDR0(p, mt, pbf, gid) \
+ mt = (*(p)&NCI_MT_MASK) >> NCI_MT_SHIFT; \
+ (pbf) = (*(p)&NCI_PBF_MASK) >> NCI_PBF_SHIFT; \
+ (gid) = *(p)++ & NCI_GID_MASK;
+
+/* parse MT and PBF bits of NCI packet */
+#define NCI_MSG_PRS_MT_PBF(p, mt, pbf) \
+ mt = (*(p)&NCI_MT_MASK) >> NCI_MT_SHIFT; \
+ (pbf) = (*(p)&NCI_PBF_MASK) >> NCI_PBF_SHIFT;
+
+/* parse byte1 of NCI Cmd/Ntf */
+#define NCI_MSG_PRS_HDR1(p, oid) \
+ (oid) = (*(p)&NCI_OID_MASK); \
+ (p)++;
+
+/* NCI Data Format:
+ * byte 0: MT(0) PBF CID
+ * byte 1: RFU
+ * byte 2: Data Length */
+/* CID: Connection Identifier (byte 0) 1-0xF Dynamically assigned (by NFCC), 0
+ * is predefined */
+#define NCI_CID_MASK 0x0F
+
+/* builds 3-byte message header of NCI Data packet */
+#define NCI_DATA_BLD_HDR(p, cid, len) \
+ *(p)++ = (uint8_t)(cid); \
+ *(p)++ = 0; \
+ *(p)++ = (uint8_t)(len);
+
+#define NCI_DATA_PBLD_HDR(p, pbf, cid, len) \
+ *(p)++ = (uint8_t)(((pbf) << NCI_PBF_SHIFT) | (cid)); \
+ *(p)++ = 0; \
+ *(p)++ = (len);
+
+#define NCI_DATA_PRS_HDR(p, pbf, cid, len) \
+ (pbf) = (*(p)&NCI_PBF_MASK) >> NCI_PBF_SHIFT; \
+ (cid) = (*(p)&NCI_CID_MASK); \
+ (p)++; \
+ (p)++; \
+ (len) = *(p)++;
+
+/* Logical target ID 0x01-0xFE */
+
+/* CORE_RESET_NTF reset trigger type*/
+#define NCI2_0_RESET_TRIGGER_TYPE_ERROR 0x00
+#define NCI2_0_RESET_TRIGGER_TYPE_POWERED_ON 0x01
+#define NCI2_0_RESET_TRIGGER_TYPE_CORE_RESET_CMD_RECEIVED 0x02
+
+/* Status Codes */
+#define NCI_STATUS_OK 0x00
+#define NCI_STATUS_REJECTED 0x01
+#define NCI_STATUS_MESSAGE_CORRUPTED 0x02
+#define NCI_STATUS_BUFFER_FULL 0xE0
+#define NCI_STATUS_FAILED 0x03
+#define NCI_STATUS_NOT_INITIALIZED 0x04
+#define NCI_STATUS_SYNTAX_ERROR 0x05
+#define NCI_STATUS_SEMANTIC_ERROR 0x06
+#define NCI_STATUS_UNKNOWN_GID 0x07
+#define NCI_STATUS_UNKNOWN_OID 0x08
+#define NCI_STATUS_INVALID_PARAM 0x09
+#define NCI_STATUS_MSG_SIZE_TOO_BIG 0x0A
+/* discovery */
+#define NCI_STATUS_ALREADY_STARTED 0xA0
+#define NCI_STATUS_ACTIVATION_FAILED 0xA1
+#define NCI_STATUS_TEAR_DOWN 0xA2
+/* RF Interface */
+#define NCI_STATUS_RF_TRANSMISSION_ERR 0xB0
+#define NCI_STATUS_RF_PROTOCOL_ERR 0xB1
+#define NCI_STATUS_TIMEOUT 0xB2
+/* NFCEE Interface */
+#define NCI_STATUS_EE_INTF_ACTIVE_FAIL 0xC0
+#define NCI_STATUS_EE_TRANSMISSION_ERR 0xC1
+#define NCI_STATUS_EE_PROTOCOL_ERR 0xC2
+#define NCI_STATUS_EE_TIMEOUT 0xC3
+
+typedef uint8_t tNCI_STATUS;
+
+/* RF Technologies */
+#define NCI_RF_TECHNOLOGY_A 0x00
+#define NCI_RF_TECHNOLOGY_B 0x01
+#define NCI_RF_TECHNOLOGY_F 0x02
+#define NCI_RF_TECHNOLOGY_V 0x03
+
+/* Bit Rates */
+#define NCI_BIT_RATE_106 0x00 /* 106 kbit/s */
+#define NCI_BIT_RATE_212 0x01 /* 212 kbit/s */
+#define NCI_BIT_RATE_424 0x02 /* 424 kbit/s */
+#define NCI_BIT_RATE_848 0x03 /* 848 Kbit/s */
+#define NCI_BIT_RATE_1696 0x04 /* 1696 Kbit/s*/
+#define NCI_BIT_RATE_3392 0x05 /* 3392 Kbit/s*/
+#define NCI_BIT_RATE_6784 0x06 /* 6784 Kbit/s*/
+
+/**********************************************
+ * NCI Core Group Opcode - 0
+ **********************************************/
+#define NCI_MSG_CORE_RESET 0
+#define NCI_MSG_CORE_INIT 1
+#define NCI_MSG_CORE_SET_CONFIG 2
+#define NCI_MSG_CORE_GET_CONFIG 3
+#define NCI_MSG_CORE_CONN_CREATE 4
+#define NCI_MSG_CORE_CONN_CLOSE 5
+#define NCI_MSG_CORE_CONN_CREDITS 6
+#define NCI_MSG_CORE_GEN_ERR_STATUS 7
+#define NCI_MSG_CORE_INTF_ERR_STATUS 8
+#define NCI_MSG_CORE_SET_POWER_SUB_STATE 9
+
+/**********************************************
+ * RF MANAGEMENT Group Opcode - 1
+ **********************************************/
+#define NCI_MSG_RF_DISCOVER_MAP 0
+#define NCI_MSG_RF_SET_ROUTING 1
+#define NCI_MSG_RF_GET_ROUTING 2
+#define NCI_MSG_RF_DISCOVER 3
+#define NCI_MSG_RF_DISCOVER_SELECT 4
+#define NCI_MSG_RF_INTF_ACTIVATED 5
+#define NCI_MSG_RF_DEACTIVATE 6
+#define NCI_MSG_RF_FIELD 7
+#define NCI_MSG_RF_T3T_POLLING 8
+#define NCI_MSG_RF_EE_ACTION 9
+#define NCI_MSG_RF_EE_DISCOVERY_REQ 10
+#define NCI_MSG_RF_PARAMETER_UPDATE 11
+#define NCI_MSG_RF_ISO_DEP_NAK_PRESENCE 16
+
+/**********************************************
+ * NFCEE MANAGEMENT Group Opcode - 2
+ **********************************************/
+#define NCI_MSG_NFCEE_DISCOVER 0
+#define NCI_MSG_NFCEE_MODE_SET 1
+
+/**********************************************
+ * NCI Proprietary Group - F
+ **********************************************/
+
+/**********************************************
+ * NCI Core Group Params
+ **********************************************/
+#define NCI_CORE_PARAM_SIZE_RESET 0x01
+#define NCI_CORE_PARAM_SIZE_RESET_RSP 0x03
+#define NCI_CORE_PARAM_SIZE_RESET_NTF 0x02
+
+#define NCI_CORE_PARAM_SIZE_INIT(X) (((X) == NCI_VERSION_2_0) ? (0x02) : (0x00))
+#define NCI2_0_CORE_INIT_CMD_BYTE_0 0x00
+#define NCI2_0_CORE_INIT_CMD_BYTE_1 0x00
+#define NCI_CORE_PARAM_SIZE_INIT_RSP 0x11
+#define NCI_CORE_INIT_RSP_OFFSET_NUM_INTF 0x05
+
+/* Status (1 octet) and number of params */
+#define NCI_CORE_PARAM_SIZE_SET_CONFIG_RSP 0x02
+#define NCI_CORE_PARAM_SIZE_SET_POWER_SUB_STATE 0x01
+
+/* octet 0 */
+#define NCI_FEAT_DISCOVERY_FREG 0x00000001
+#define NCI_FEAT_DISCOVERY_CFGM 0x00000006
+/* octet 1 */
+#define NCI_FEAT_TECHNOLOGY_ROUTING 0x00000200
+#define NCI_FEAT_PROTOCOL_ROUTING 0x00000400
+#define NCI_FEAT_AID_ROUTING 0x00000800
+/* octet 2 */
+#define NCI_FEAT_BATTERY_OFF_MD 0x00010000
+#define NCI_FEAT_SWITCH_OFF_MD 0x00020000
+
+/* supported Interfaces */
+#define NCI_SUP_INTF_FRAME 0x0001
+#define NCI_SUP_INTF_ISO_DEP 0x0002
+#define NCI_SUP_INTF_NFC_DEP 0x0004
+
+#define NCI_CORE_PARAM_SIZE_CON_CREATE 0x02 /* handle, num_tlv, (tlv) */
+/* status, size, credits, conn_id */
+#define NCI_CORE_PARAM_SIZE_CON_CREATE_RSP 0x04
+#define NCI_CON_CREATE_TAG_EE_INTF 0x00 /* old */
+#define NCI_CON_CREATE_TAG_RF_DISC_ID 0x00
+#define NCI_CON_CREATE_TAG_NFCEE_VAL 0x01
+
+#define NCI_CORE_PARAM_SIZE_CON_CLOSE 0x01 /* Conn ID (1 octet) */
+#define NCI_CORE_PARAM_SIZE_CON_CLOSE_RSP 0x01 /* Status (1 octet) */
+
+/* RF Field Status (1 octet) */
+#define NCI_CORE_PARAM_SIZE_RF_FIELD_NTF 0x01
+
+/* Keep the NCI configuration (if possible) and perform NCI initialization. */
+#define NCI_RESET_TYPE_KEEP_CFG 0x00
+/* Reset the NCI configuration, and perform NCI initialization. */
+#define NCI_RESET_TYPE_RESET_CFG 0x01
+
+/* NCI Configuration has been kept */
+#define NCI_RESET_STATUS_KEPT_CFG 0x00
+/* NCI Configuration has been reset */
+#define NCI_RESET_STATUS_RESET_CFG 0x01
+
+/* No operating field generated by remote device */
+#define NCI_RF_STS_NO_REMOTE 0x00
+/* Operating field generated by remote device */
+#define NCI_RF_STS_REMOTE 0x01
+
+#define NCI_PARAM_SIZE_DISCOVER_NFCEE 0x01 /* Discovery Action (1 octet) */
+/* Status (1 octet)Number of NFCEEs (1 octet) */
+#define NCI_PARAM_SIZE_DISCOVER_NFCEE_RSP 0x02
+
+#define NCI_DISCOVER_ACTION_DISABLE 0
+#define NCI_DISCOVER_ACTION_ENABLE 1
+
+#define NCI_EE_DISCOVER_REQ_TYPE_LISTEN 0x01
+#define NCI_EE_DISCOVER_REQ_TYPE_POLL 0x02
+
+#define NCI_RF_PARAM_ID_TECH_N_MODE 0x00 /* RF Technology and Mode */
+#define NCI_RF_PARAM_ID_TX_BIT_RATE 0x01 /* Transmit Bit Rate */
+#define NCI_RF_PARAM_ID_RX_BIT_RATE 0x02 /* Receive Bit Rate */
+#define NCI_RF_PARAM_ID_B_DATA_EX_PARAM \
+ 0x03 /* B Data Exchange config param \
+ */
+
+#define NCI_NFCEE_INTERFACE_APDU 0x00
+#define NCI_NFCEE_INTERFACE_HCI_ACCESS 0x01
+#define NCI_NFCEE_INTERFACE_T3T 0x02
+#define NCI_NFCEE_INTERFACE_TRANSPARENT 0x03
+#define NCI_NFCEE_INTERFACE_PROPRIETARY 0x80
+
+#define NCI_NFCEE_STS_CONN_ACTIVE 0x00
+#define NCI_NFCEE_STS_CONN_INACTIVE 0x01
+#define NCI_NFCEE_STS_REMOVED 0x02
+#define NCI_NUM_NFCEE_STS 3
+
+/* Logical Target ID (1 octet)NFCEE Mode (1 octet) */
+#define NCI_CORE_PARAM_SIZE_NFCEE_MODE_SET 0x02
+#define NCI_CORE_PARAM_SIZE_NFCEE_MODE_SET_RSP 0x01 /* Status (1 octet) */
+
+/* Deactivate the connected NFCEE */
+#define NCI_NFCEE_MD_DEACTIVATE 0x00
+/* Activate the connected NFCEE */
+#define NCI_NFCEE_MD_ACTIVATE 0x01
+#define NCI_NUM_NFCEE_MODE 2
+
+/**********************************************
+ * NCI Deactivation Type
+ **********************************************/
+#define NCI_DEACTIVATE_TYPE_IDLE 0 /* Idle Mode */
+#define NCI_DEACTIVATE_TYPE_SLEEP 1 /* Sleep Mode */
+#define NCI_DEACTIVATE_TYPE_SLEEP_AF 2 /* Sleep_AF Mode */
+#define NCI_DEACTIVATE_TYPE_DISCOVERY 3 /* Discovery */
+
+/**********************************************
+ * NCI Deactivation Reasons
+ **********************************************/
+#define NCI_DEACTIVATE_REASON_DH_REQ 0 /* DH Request */
+#define NCI_DEACTIVATE_REASON_ENDPOINT_REQ 1 /* Endpoint Request */
+#define NCI_DEACTIVATE_REASON_RF_LINK_LOSS 2 /* RF Link Loss */
+#define NCI_DEACTIVATE_REASON_NFCB_BAD_AFI 3 /* NFC-B Bad AFI */
+/* DH Request Failed due to error */
+#define NCI_DEACTIVATE_REASON_DH_REQ_FAILED 4
+
+/**********************************************
+* NCI Interface Mode
+**********************************************/
+#define NCI_INTERFACE_MODE_POLL 1
+#define NCI_INTERFACE_MODE_LISTEN 2
+#define NCI_INTERFACE_MODE_POLL_N_LISTEN 3
+
+/**********************************************
+ * NCI Interface Types
+ **********************************************/
+#define NCI_INTERFACE_EE_DIRECT_RF 0
+#define NCI_INTERFACE_FRAME 1
+#define NCI_INTERFACE_ISO_DEP 2
+#define NCI_INTERFACE_NFC_DEP 3
+#define NCI_INTERFACE_MAX NCI_INTERFACE_NFC_DEP
+#define NCI_INTERFACE_EXTENSION_MAX 2
+#define NCI_INTERFACE_FIRST_VS 0x80
+typedef uint8_t tNCI_INTF_TYPE;
+
+/**********************************************
+ * NCI RF Management / DISCOVERY Group Params
+ **********************************************/
+#define NCI_DISCOVER_PARAM_SIZE_RSP 0x01
+
+#define NCI_DISCOVER_PARAM_SIZE_SELECT 0x03 /* ID, protocol, interface */
+#define NCI_DISCOVER_PARAM_SIZE_SELECT_RSP 0x01 /* Status (1 octet) */
+#define NCI_DISCOVER_PARAM_SIZE_STOP 0x00 /* */
+#define NCI_DISCOVER_PARAM_SIZE_STOP_RSP 0x01 /* Status (1 octet) */
+#define NCI_DISCOVER_PARAM_SIZE_DEACT 0x01 /* type */
+#define NCI_DISCOVER_PARAM_SIZE_DEACT_RSP 0x01 /* Status (1 octet) */
+#define NCI_DISCOVER_PARAM_SIZE_DEACT_NTF 0x01 /* type */
+
+/**********************************************
+ * Supported Protocols
+ **********************************************/
+#define NCI_PROTOCOL_UNKNOWN 0x00
+#define NCI_PROTOCOL_T1T 0x01
+#define NCI_PROTOCOL_T2T 0x02
+#define NCI_PROTOCOL_T3T 0x03
+#define NCI_PROTOCOL_T5T 0x06
+#define NCI_PROTOCOL_ISO_DEP 0x04
+#define NCI_PROTOCOL_NFC_DEP 0x05
+
+/* Discovery Types/Detected Technology and Mode */
+#define NCI_DISCOVERY_TYPE_POLL_A 0x00
+#define NCI_DISCOVERY_TYPE_POLL_B 0x01
+#define NCI_DISCOVERY_TYPE_POLL_F 0x02
+#define NCI_DISCOVERY_TYPE_POLL_V 0x06
+#define NCI_DISCOVERY_TYPE_POLL_A_ACTIVE 0x03
+/* NCI2.0 standardizes P2P poll active*/
+#define NCI_DISCOVERY_TYPE_POLL_ACTIVE 0x03
+#define NCI_DISCOVERY_TYPE_POLL_F_ACTIVE 0x05
+#define NCI_DISCOVERY_TYPE_LISTEN_A 0x80
+#define NCI_DISCOVERY_TYPE_LISTEN_B 0x81
+#define NCI_DISCOVERY_TYPE_LISTEN_F 0x82
+#define NCI_DISCOVERY_TYPE_LISTEN_A_ACTIVE 0x83
+/* NCI2.0 standardizes P2P listen active*/
+#define NCI_DISCOVERY_TYPE_LISTEN_ACTIVE 0x83
+#define NCI_DISCOVERY_TYPE_LISTEN_F_ACTIVE 0x85
+#define NCI_DISCOVERY_TYPE_LISTEN_ISO15693 0x86
+#define NCI_DISCOVERY_TYPE_MAX NCI_DISCOVERY_TYPE_LISTEN_ISO15693
+
+typedef uint8_t tNCI_DISCOVERY_TYPE;
+
+#define NCI_EE_TRIG_7816_SELECT 0x00
+#define NCI_EE_TRIG_RF_PROTOCOL 0x01
+#define NCI_EE_TRIG_RF_TECHNOLOGY 0x02
+#define NCI_EE_TRIG_APP_INIT 0x10
+
+#define NCI_EE_ACT_TAG_AID 0xC0 /* AID */
+#define NCI_EE_ACT_TAG_PROTO 0xC1 /* RF protocol */
+#define NCI_EE_ACT_TAG_TECH 0xC2 /* RF technology */
+#define NCI_EE_ACT_TAG_DATA 0xC3 /* hex data for app */
+#define NCI_EE_ACT_TAG_DEBUG 0xC4 /* debug trace */
+
+/* Technology based routing */
+#define NCI_ROUTE_TAG_TECH 0x00
+/* Protocol based routing */
+#define NCI_ROUTE_TAG_PROTO 0x01
+#define NCI_ROUTE_TAG_AID 0x02 /* AID routing */
+
+#define NCI_ROUTE_PWR_STATE_ON 0x01 /* The device is on */
+/* The device is switched off */
+#define NCI_ROUTE_PWR_STATE_SWITCH_OFF 0x02
+/* The device's battery is removed */
+#define NCI_ROUTE_PWR_STATE_BATT_OFF 0x04
+/* The device is in screen off Unlock mode */
+#define NCI_ROUTE_PWR_STATE_SCREEN_OFF_UNLOCK 0x08
+/* The device is in screen on lock mode */
+#define NCI_ROUTE_PWR_STATE_SCREEN_ON_LOCK 0x10
+/* The device is in screen off lock mode */
+#define NCI_ROUTE_PWR_STATE_SCREEN_OFF_LOCK 0x20
+
+/* Hardware / Registration Identification */
+#define NCI_NFCEE_TAG_HW_ID 0x00
+#define NCI_NFCEE_TAG_ATR_BYTES 0x01 /* ATR Bytes */
+/* T3T Command Set Interface Supplementary Info */
+#define NCI_NFCEE_TAG_T3T_INFO 0x02
+#define NCI_NFCEE_TAG_HCI_HOST_ID 0xA0 /* HCI host ID */
+
+#define NCI_DISCOVER_NTF_LAST 0x00
+#define NCI_DISCOVER_NTF_LAST_ABORT 0x01
+#define NCI_DISCOVER_NTF_MORE 0x02
+
+/* NCI RF Management Group Params */
+#define NCI_RF_PARAM_SIZE_T3T_POLLING 0x04 /* System Code, RC, TSN */
+
+/**********************************************
+ * NCI Parameter IDs
+ **********************************************/
+
+#define NCI_PARAM_ID_TOTAL_DURATION 0x00
+#define NCI_PARAM_ID_CON_DEVICES_LIMIT 0x01
+#define NCI_PARAM_ID_CON_DISCOVERY_PARAM 0x02
+#define NCI_PARAM_ID_PA_BAILOUT 0x08
+#define NCI_PARAM_ID_PB_AFI 0x10
+#define NCI_PARAM_ID_PB_BAILOUT 0x11
+#define NCI_PARAM_ID_PB_ATTRIB_PARAM1 0x12
+#define NCI_PARAM_ID_PF_BIT_RATE 0x18
+#define NCI_PARAM_ID_PF_RC 0x19
+#define NCI_PARAM_ID_PB_H_INFO 0x20
+#define NCI_PARAM_ID_PI_BIT_RATE 0x21
+
+#define NCI_PARAM_ID_BITR_NFC_DEP 0x28
+#define NCI_PARAM_ID_ATR_REQ_GEN_BYTES 0x29
+#define NCI_PARAM_ID_ATR_REQ_CONFIG 0x2A
+
+#define NCI_PARAM_ID_LA_BIT_FRAME_SDD 0x30
+#define NCI_PARAM_ID_LA_PLATFORM_CONFIG 0x31
+#define NCI_PARAM_ID_LA_SEL_INFO 0x32
+#define NCI_PARAM_ID_LA_NFCID1 0x33
+#define NCI_PARAM_ID_LB_SENSB_INFO 0x38
+#define NCI_PARAM_ID_LB_NFCID0 0x39
+#define NCI_PARAM_ID_LB_APPDATA 0x3A
+#define NCI_PARAM_ID_LB_SFGI 0x3B
+#define NCI_PARAM_ID_LB_ADC_FO 0x3C
+#define NCI_PARAM_ID_LB_PROTOCOL NCI_PARAM_ID_LB_SENSB_INFO
+
+#define NCI_PARAM_ID_LF_T3T_ID1 0x40
+#define NCI_PARAM_ID_LF_T3T_ID2 0x41
+#define NCI_PARAM_ID_LF_T3T_ID3 0x42
+#define NCI_PARAM_ID_LF_T3T_ID4 0x43
+#define NCI_PARAM_ID_LF_T3T_ID5 0x44
+#define NCI_PARAM_ID_LF_T3T_ID6 0x45
+#define NCI_PARAM_ID_LF_T3T_ID7 0x46
+#define NCI_PARAM_ID_LF_T3T_ID8 0x47
+#define NCI_PARAM_ID_LF_T3T_ID9 0x48
+#define NCI_PARAM_ID_LF_T3T_ID10 0x49
+#define NCI_PARAM_ID_LF_T3T_ID11 0x4A
+#define NCI_PARAM_ID_LF_T3T_ID12 0x4B
+#define NCI_PARAM_ID_LF_T3T_ID13 0x4C
+#define NCI_PARAM_ID_LF_T3T_ID14 0x4D
+#define NCI_PARAM_ID_LF_T3T_ID15 0x4E
+#define NCI_PARAM_ID_LF_T3T_ID16 0x4F
+#define NCI_PARAM_ID_LF_PROTOCOL 0x50
+#define NCI_PARAM_ID_LF_T3T_PMM 0x51
+/* max num of LF_T3T_ID supported by NFCC (1 for now) */
+#define NCI_PARAM_ID_LF_T3T_MAX 0x52
+#define NCI_PARAM_ID_LF_T3T_FLAGS2 0x53
+#define NCI_PARAM_ID_LF_CON_BITR_F 0x54
+#define NCI_PARAM_ID_LF_CON_ADV_FEAT 0x55
+/*LF_T3T name changed in NCI2.0*/
+#define NCI_PARAM_ID_LF_T3T_RD_ALLOWED 0x55
+
+#define NCI_PARAM_ID_FWI 0x58
+#define NCI_PARAM_ID_LA_HIST_BY 0x59
+#define NCI_PARAM_ID_LB_H_INFO_RSP 0x5A
+#define NCI_PARAM_ID_LI_BIT_RATE 0x5B
+
+#define NCI_PARAM_ID_WT 0x60
+#define NCI_PARAM_ID_ATR_RES_GEN_BYTES 0x61
+#define NCI_PARAM_ID_ATR_RSP_CONFIG 0x62
+
+#define NCI_PARAM_ID_RF_FIELD_INFO 0x80
+#define NCI_PARAM_ID_RF_NFCEE_ACTION 0x81
+#define NCI_PARAM_ID_NFC_DEP_OP 0x82
+
+/* NCI_PARAM_ID_HOST_LISTEN_MASK (byte1 for DH, byte2 for UICC) */
+/* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_A_PASSIVE & 0x0F)) */
+#define NCI_LISTEN_MASK_A 0x01
+/* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_B_PASSIVE & 0x0F)) */
+#define NCI_LISTEN_MASK_B 0x02
+/* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_F_PASSIVE & 0x0F)) */
+#define NCI_LISTEN_MASK_F 0x04
+/* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_A_ACTIVE & 0x0F)) */
+#define NCI_LISTEN_MASK_A_ACTIVE 0x08
+/* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_B_PRIME & 0x0F)) */
+#define NCI_LISTEN_MASK_B_PRIME 0x10
+/* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_F_ACTIVE & 0x0F)) */
+#define NCI_LISTEN_MASK_F_ACTIVE 0x20
+/* (0x01 << (NCI_DISCOVERY_TYPE_LISTEN_ISO15693 & 0x0F)) */
+#define NCI_LISTEN_MASK_ISO15693 0x40
+
+/* Type A Parameters */
+#define NCI_PARAM_PLATFORM_T1T 0x0C
+#define NCI_PARAM_SEL_INFO_ISODEP 0x20
+#define NCI_PARAM_SEL_INFO_NFCDEP 0x40
+/**********************************************
+ * NCI Parameter ID Lens
+ **********************************************/
+#define NCI_PARAM_LEN_TOTAL_DURATION 2
+
+#define NCI_PARAM_LEN_CON_DISCOVERY_PARAM 1
+
+#define NCI_PARAM_LEN_PA_FSDI 1
+
+#define NCI_PARAM_LEN_PF_RC 1
+
+#define NCI_PARAM_LEN_LA_BIT_FRAME_SDD 1
+#define NCI_PARAM_LEN_LA_PLATFORM_CONFIG 1
+#define NCI_PARAM_LEN_LA_SEL_INFO 1
+
+#define NCI_PARAM_LEN_LB_SENSB_INFO 1
+#define NCI_PARAM_LEN_LB_NFCID0 4
+#define NCI_PARAM_LEN_LB_APPDATA 4
+#define NCI_PARAM_LEN_LB_ADC_FO 1
+
+#define NCI_PARAM_LEN_LF_PROTOCOL 1
+#define NCI_PARAM_LEN_LF_T3T_FLAGS2 2
+#define NCI_PARAM_LEN_LF_T3T_PMM 8
+#define NCI_PARAM_LEN_LF_T3T_ID(X) (((X) == NCI_VERSION_2_0) ? (0x12) : (0x0A))
+#define NCI_PARAM_LEN_LF_CON_ADV_FEAT 1
+
+#define NCI_PARAM_LEN_LF_T3T_RD_ALLOWED 1 // Listen F NCI2.0 Parameter
+#define NCI_PARAM_LEN_LF_T3T_ID_MAX 16 // LF T3T indentifier Max Value 16
+#define NFA_CE_LISTEN_INFO_LF_MAX 16 // LF T3T indentifier Max Value 16
+
+#define NCI_PARAM_LEN_FWI 1
+#define NCI_PARAM_LEN_WT 1
+/* GEN_BYTES - variable */
+
+/* Listen protocol bits - NCI_PARAM_ID_LF_PROTOCOL and
+ * NCI_PARAM_ID_LB_SENSB_INFO */
+#define NCI_LISTEN_PROTOCOL_ISO_DEP 0x01
+#define NCI_LISTEN_PROTOCOL_NFC_DEP 0x02
+
+#define NCI_DISCOVER_PARAM_SIZE_TEST_RF 0x06
+
+/* LF_T3T_FLAGS2 listen bits all-disabled definition */
+#define NCI_LF_T3T_FLAGS2_ALL_DISABLED 0x0000
+#define NCI_LF_T3T_FLAGS2_ID1_ENABLED 0x0001
+
+/* The DH-NFCEE listen is considered as a enable NFCEE */
+#define NCI_LISTEN_DH_NFCEE_ENABLE_MASK 0x00
+/* The DH-NFCEE listen is considered as a disable NFCEE */
+#define NCI_LISTEN_DH_NFCEE_DISABLE_MASK 0x02
+/* The DH polling is considered as a disable NFCEE */
+#define NCI_POLLING_DH_DISABLE_MASK 0x00
+/* The DH polling is considered as a enable NFCEE */
+#define NCI_POLLING_DH_ENABLE_MASK 0x01
+
+#define NCI_ROUTE_QUAL_MASK 0x70
+/* AID matching is allowed when the SELECT AID is longer */
+#define NCI_ROUTE_QUAL_LONG_SELECT 0x10
+/* AID matching is allowed when the SELECT AID is shorter */
+#define NCI_ROUTE_QUAL_SHORT_SELECT 0x20
+/* AID is blocked in unsupported power mode */
+#define NCI_ROUTE_QUAL_BLOCK_ROUTE 0x40
+
+typedef struct {
+ uint16_t addr;
+ uint8_t len;
+ uint8_t* data;
+} NCIP_T1T_SETMEM_CMD_t;
+
+typedef struct { uint8_t status; } NCIP_T1T_SETMEM_RSP_t;
+
+typedef struct { uint16_t addr; } NCIP_T1T_GETMEM_CMD_t;
+
+typedef struct {
+ uint8_t status;
+ uint8_t* data;
+} NCIP_T1T_GETMEM_RSP_t;
+
+typedef struct {
+ uint8_t hr0;
+ uint8_t hr1;
+} NCIP_T1T_SETHR_CMD_t;
+
+typedef struct { uint8_t status; } NCIP_T1T_SETHR_RSP_t;
+
+#ifndef NCI_GET_CMD_BUF
+#if (HCI_USE_VARIABLE_SIZE_CMD_BUF == FALSE)
+/* Allocate fixed-size buffer from HCI_CMD_POOL (default case) */
+#define NCI_GET_CMD_BUF(paramlen) ((NFC_HDR*)GKI_getpoolbuf(NFC_NCI_POOL_ID))
+#else
+/* Allocate smallest possible buffer (for platforms with limited RAM) */
+#define NCI_GET_CMD_BUF(paramlen) \
+ ((NFC_HDR*)GKI_getbuf((uint16_t)(NFC_HDR_SIZE + NCI_MSG_HDR_SIZE + \
+ NCI_MSG_OFFSET_SIZE + (paramlen))))
+#endif
+#endif /* NCI_GET_CMD_BUF */
+
+#define NCI_MAX_AID_LEN 16
+
+typedef struct {
+ uint8_t type;
+ uint8_t frequency;
+} tNCI_DISCOVER_PARAMS;
+
+typedef struct {
+ uint8_t protocol;
+ uint8_t mode;
+ uint8_t intf_type;
+} tNCI_DISCOVER_MAPS;
+
+#define NCI_NFCID1_MAX_LEN 10
+#define NCI_T1T_HR_LEN 2
+typedef struct {
+ uint8_t sens_res[2]; /* SENS_RES Response (ATQA). Available after Technology
+ Detection */
+ uint8_t nfcid1_len; /* 4, 7 or 10 */
+ uint8_t nfcid1[NCI_NFCID1_MAX_LEN]; /* AKA NFCID1 */
+ uint8_t sel_rsp; /* SEL_RSP (SAK) Available after Collision Resolution */
+ uint8_t hr_len; /* 2, if T1T HR0/HR1 is reported */
+ uint8_t hr[NCI_T1T_HR_LEN]; /* T1T HR0 is in hr[0], HR1 is in hr[1] */
+} tNCI_RF_PA_PARAMS;
+
+#define NCI_MAX_SENSB_RES_LEN 12
+typedef struct {
+ uint8_t sensb_res_len; /* Length of SENSB_RES Response (Byte 2 - Byte 12 or
+ 13) Available after Technology Detection */
+ uint8_t sensb_res[NCI_MAX_SENSB_RES_LEN]; /* SENSB_RES Response (ATQ) */
+} tNCI_RF_PB_PARAMS;
+
+#define NCI_MAX_SENSF_RES_LEN 18
+#define NCI_SENSF_RES_OFFSET_PAD0 8
+#define NCI_SENSF_RES_OFFSET_RD 16
+#define NCI_NFCID2_LEN 8
+#define NCI_T3T_PMM_LEN 8
+#define NCI_SYSTEMCODE_LEN 2
+#define NCI_RF_F_UID_LEN NCI_NFCID2_LEN
+#define NCI_MRTI_CHECK_INDEX 13
+#define NCI_MRTI_UPDATE_INDEX 14
+typedef struct {
+ uint8_t bit_rate; /* NFC_BIT_RATE_212 or NFC_BIT_RATE_424 */
+ uint8_t sensf_res_len; /* Length of SENSF_RES Response (Byte 2 - Byte 17 or
+ 19) Available after Technology Detection */
+ uint8_t sensf_res[NCI_MAX_SENSF_RES_LEN]; /* SENSB_RES Response */
+} tNCI_RF_PF_PARAMS;
+
+typedef struct {
+ uint8_t nfcid2[NCI_NFCID2_LEN]; /* NFCID2 generated by the Local NFCC for
+ NFC-DEP Protocol.Available for Frame
+ Interface */
+} tNCI_RF_LF_PARAMS;
+
+typedef struct {
+ tNCI_DISCOVERY_TYPE mode;
+ union {
+ tNCI_RF_PA_PARAMS pa;
+ tNCI_RF_PB_PARAMS pb;
+ tNCI_RF_PF_PARAMS pf;
+ tNCI_RF_LF_PARAMS lf;
+ } param; /* Discovery Type specific parameters */
+} tNCI_RF_TECH_PARAMS;
+
+#ifndef NCI_MAX_ATS_LEN
+#define NCI_MAX_ATS_LEN 60
+#endif
+#ifndef NCI_MAX_HIS_BYTES_LEN
+#define NCI_MAX_HIS_BYTES_LEN 50
+#endif
+#ifndef NCI_MAX_GEN_BYTES_LEN
+#define NCI_MAX_GEN_BYTES_LEN 48
+#endif
+
+#define NCI_ATS_T0_INDEX 0
+#define NCI_ATS_TC_MASK 0x40
+#define NCI_ATS_TB_MASK 0x20
+#define NCI_ATS_TA_MASK 0x10
+#define NCI_ATS_FSCI_MASK 0x0F
+typedef struct {
+ uint8_t ats_res_len; /* Length of ATS RES */
+ uint8_t ats_res[NCI_MAX_ATS_LEN]; /* ATS RES defined in [DIGPROT] */
+} tNCI_INTF_PA_ISO_DEP;
+
+typedef struct { uint8_t rats; /* RATS */ } tNCI_INTF_LA_ISO_DEP;
+
+#define NCI_P_GEN_BYTE_INDEX 15
+#define NCI_L_GEN_BYTE_INDEX 14
+#define NCI_L_NFC_DEP_TO_INDEX 13
+typedef struct {
+ uint8_t atr_res_len; /* Length of ATR_RES */
+ uint8_t atr_res[NCI_MAX_ATS_LEN]; /* ATR_RES (Byte 3 - Byte 17+n) as defined
+ in [DIGPROT] */
+} tNCI_INTF_PA_NFC_DEP;
+
+/* Note: keep tNCI_INTF_PA_NFC_DEP data member in the same order as
+ * tNCI_INTF_LA_NFC_DEP */
+typedef struct {
+ uint8_t atr_req_len; /* Length of ATR_REQ */
+ uint8_t atr_req[NCI_MAX_ATS_LEN]; /* ATR_REQ (Byte 3 - Byte 18+n) as defined
+ in [DIGPROT] */
+} tNCI_INTF_LA_NFC_DEP;
+typedef tNCI_INTF_LA_NFC_DEP tNCI_INTF_LF_NFC_DEP;
+typedef tNCI_INTF_PA_NFC_DEP tNCI_INTF_PF_NFC_DEP;
+
+#define NCI_MAX_ATTRIB_LEN (10 + NCI_MAX_GEN_BYTES_LEN)
+
+typedef struct {
+ uint8_t attrib_res_len; /* Length of ATTRIB RES */
+ uint8_t
+ attrib_res[NCI_MAX_ATTRIB_LEN]; /* ATTRIB RES as defined in [DIGPROT] */
+} tNCI_INTF_PB_ISO_DEP;
+
+typedef struct {
+ uint8_t attrib_req_len; /* Length of ATTRIB REQ */
+ uint8_t attrib_req[NCI_MAX_ATTRIB_LEN]; /* ATTRIB REQ (Byte 2 - Byte 10+k) as
+ defined in [DIGPROT] */
+} tNCI_INTF_LB_ISO_DEP;
+
+typedef struct {
+ tNCI_INTF_TYPE type; /* Interface Type 1 Byte See Table 67 */
+ union {
+ tNCI_INTF_LA_ISO_DEP la_iso;
+ tNCI_INTF_PA_ISO_DEP pa_iso;
+ tNCI_INTF_LB_ISO_DEP lb_iso;
+ tNCI_INTF_PB_ISO_DEP pb_iso;
+ tNCI_INTF_LA_NFC_DEP la_nfc;
+ tNCI_INTF_PA_NFC_DEP pa_nfc;
+ tNCI_INTF_LF_NFC_DEP lf_nfc;
+ tNCI_INTF_PF_NFC_DEP pf_nfc;
+ } intf_param; /* Activation Parameters 0 - n Bytes */
+} tNCI_INTF_PARAMS;
+
+typedef struct {
+ uint8_t atr_res_len; /* Length of ATR_RES */
+ uint8_t atr_res[NCI_MAX_ATS_LEN]; /* ATR_RES (Byte 3 - Byte 17+n) */
+ uint8_t max_payload_size; /* 64, 128, 192 or 254 */
+ uint8_t gen_bytes_len; /* len of general bytes */
+ uint8_t gen_bytes[NCI_MAX_GEN_BYTES_LEN]; /* general bytes */
+ uint8_t waiting_time; /* WT -> Response Waiting Time
+ RWT = (256 x 16/fC) x 2WT */
+} tNCI_RF_ACM_P_PARAMS;
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NFC_NCI_DEFS_H */
diff --git a/halimpl/bcm2079x/hal/include/nfc_hal_api.h b/halimpl/bcm2079x/hal/include/nfc_hal_api.h
new file mode 100644
index 0000000..e19a8c5
--- /dev/null
+++ b/halimpl/bcm2079x/hal/include/nfc_hal_api.h
@@ -0,0 +1,248 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2012-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * NFC Hardware Abstraction Layer API
+ *
+ ******************************************************************************/
+#ifndef NFC_HAL_API_H
+#define NFC_HAL_API_H
+#include <hardware/nfc.h>
+#include "data_types.h"
+#include "nfc_hal_target.h"
+
+/*******************************************************************************
+** tHAL_HCI_NETWK_CMD Definitions
+*******************************************************************************/
+#define HAL_NFC_HCI_NO_UICC_HOST 0x00
+#define HAL_NFC_HCI_UICC0_HOST 0x01
+#define HAL_NFC_HCI_UICC1_HOST 0x02
+#define HAL_NFC_HCI_UICC2_HOST 0x04
+
+typedef uint8_t tHAL_NFC_STATUS;
+typedef void(tHAL_NFC_STATUS_CBACK)(tHAL_NFC_STATUS status);
+typedef void(tHAL_NFC_CBACK)(uint8_t event, tHAL_NFC_STATUS status);
+typedef void(tHAL_NFC_DATA_CBACK)(uint16_t data_len, uint8_t* p_data);
+
+/*******************************************************************************
+** tHAL_NFC_ENTRY HAL entry-point lookup table
+*******************************************************************************/
+
+typedef void(tHAL_API_INITIALIZE)(void);
+typedef void(tHAL_API_TERMINATE)(void);
+typedef void(tHAL_API_OPEN)(tHAL_NFC_CBACK* p_hal_cback,
+ tHAL_NFC_DATA_CBACK* p_data_cback);
+typedef void(tHAL_API_CLOSE)(void);
+typedef void(tHAL_API_CORE_INITIALIZED)(uint16_t data_len,
+ uint8_t* p_core_init_rsp_params);
+typedef void(tHAL_API_WRITE)(uint16_t data_len, uint8_t* p_data);
+typedef bool(tHAL_API_PREDISCOVER)(void);
+typedef void(tHAL_API_CONTROL_GRANTED)(void);
+typedef void(tHAL_API_POWER_CYCLE)(void);
+typedef uint8_t(tHAL_API_GET_MAX_NFCEE)(void);
+
+#define NFC_HAL_DM_PRE_SET_MEM_LEN 5
+typedef struct {
+ uint32_t addr;
+ uint32_t data;
+} tNFC_HAL_DM_PRE_SET_MEM;
+
+/* data members for NFC_HAL-HCI */
+typedef struct {
+ bool nfc_hal_prm_nvm_required; /* set nfc_hal_prm_nvm_required to TRUE, if the
+ platform wants to abort PRM process without
+ NVM */
+ uint16_t nfc_hal_nfcc_enable_timeout; /* max time to wait for RESET NTF after
+ setting REG_PU to high */
+ uint16_t nfc_hal_post_xtal_timeout; /* max time to wait for RESET NTF after
+ setting Xtal frequency */
+#if (NFC_HAL_HCI_INCLUDED == TRUE)
+ bool nfc_hal_first_boot; /* set nfc_hal_first_boot to TRUE, if platform
+ enables NFC for the first time after bootup */
+ uint8_t nfc_hal_hci_uicc_support; /* set nfc_hal_hci_uicc_support to Zero, if
+ no UICC is supported otherwise set
+ corresponding bit(s) for every supported
+ UICC(s) */
+#endif
+} tNFC_HAL_CFG;
+
+typedef struct {
+ tHAL_API_INITIALIZE* initialize;
+ tHAL_API_TERMINATE* terminate;
+ tHAL_API_OPEN* open;
+ tHAL_API_CLOSE* close;
+ tHAL_API_CORE_INITIALIZED* core_initialized;
+ tHAL_API_WRITE* write;
+ tHAL_API_PREDISCOVER* prediscover;
+ tHAL_API_CONTROL_GRANTED* control_granted;
+ tHAL_API_POWER_CYCLE* power_cycle;
+ tHAL_API_GET_MAX_NFCEE* get_max_ee;
+
+} tHAL_NFC_ENTRY;
+
+/*******************************************************************************
+** HAL API Function Prototypes
+*******************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************
+**
+** Function HAL_NfcInitialize
+**
+** Description Called when HAL library is loaded.
+**
+** Initialize GKI and start the HCIT task
+**
+** Returns void
+**
+*******************************************************************************/
+void HAL_NfcInitialize(void);
+
+/*******************************************************************************
+**
+** Function HAL_NfcTerminate
+**
+** Description Called to terminate NFC HAL
+**
+** Returns void
+**
+*******************************************************************************/
+void HAL_NfcTerminate(void);
+
+/*******************************************************************************
+**
+** Function HAL_NfcOpen
+**
+** Description Open transport and intialize the NFCC, and
+** Register callback for HAL event notifications,
+**
+** HAL_OPEN_CPLT_EVT will notify when operation is complete.
+**
+** Returns void
+**
+*******************************************************************************/
+void HAL_NfcOpen(tHAL_NFC_CBACK* p_hal_cback,
+ tHAL_NFC_DATA_CBACK* p_data_cback);
+
+/*******************************************************************************
+**
+** Function HAL_NfcClose
+**
+** Description Prepare for shutdown. A HAL_CLOSE_CPLT_EVT will be
+** reported when complete.
+**
+** Returns void
+**
+*******************************************************************************/
+void HAL_NfcClose(void);
+
+/*******************************************************************************
+**
+** Function HAL_NfcCoreInitialized
+**
+** Description Called after the CORE_INIT_RSP is received from the NFCC.
+** At this time, the HAL can do any chip-specific
+** configuration, and when finished signal the libnfc-nci with
+** event HAL_POST_INIT_CPLT_EVT.
+**
+** Returns void
+**
+*******************************************************************************/
+void HAL_NfcCoreInitialized(uint16_t data_len, uint8_t* p_core_init_rsp_params);
+
+/*******************************************************************************
+**
+** Function HAL_NfcWrite
+**
+** Description Send an NCI control message or data packet to the
+** transport. If an NCI command message exceeds the transport
+** size, HAL is responsible for fragmenting it, Data packets
+** must be of the correct size.
+**
+** Returns void
+**
+*******************************************************************************/
+void HAL_NfcWrite(uint16_t data_len, uint8_t* p_data);
+
+/*******************************************************************************
+**
+** Function HAL_NfcPreDiscover
+**
+** Description Perform any vendor-specific pre-discovery actions (if
+** needed). If any actions were performed TRUE will be
+** returned, and HAL_PRE_DISCOVER_CPLT_EVT will notify when
+** actions are completed.
+**
+** Returns TRUE if vendor-specific pre-discovery actions initialized
+** FALSE if no vendor-specific pre-discovery actions are
+** needed.
+**
+*******************************************************************************/
+bool HAL_NfcPreDiscover(void);
+
+/*******************************************************************************
+**
+** Function HAL_NfcControlGranted
+**
+** Description Grant control to HAL control for sending NCI commands.
+**
+** Call in response to HAL_REQUEST_CONTROL_EVT.
+**
+** Must only be called when there are no NCI commands pending.
+**
+** HAL_RELEASE_CONTROL_EVT will notify when HAL no longer
+** needs control of NCI.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void HAL_NfcControlGranted(void);
+
+/*******************************************************************************
+**
+** Function HAL_NfcPowerCycle
+**
+** Description Restart NFCC by power cyle
+**
+** HAL_OPEN_CPLT_EVT will notify when operation is complete.
+**
+** Returns void
+**
+*******************************************************************************/
+void HAL_NfcPowerCycle(void);
+
+/*******************************************************************************
+**
+** Function HAL_NfcGetMaxNfcee
+**
+** Description Retrieve the maximum number of NFCEEs supported by NFCC
+**
+** Returns the maximum number of NFCEEs supported by NFCC
+**
+*******************************************************************************/
+uint8_t HAL_NfcGetMaxNfcee(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NFC_HAL_API_H */
diff --git a/halimpl/bcm2079x/hal/include/nfc_hal_target.h b/halimpl/bcm2079x/hal/include/nfc_hal_target.h
new file mode 100644
index 0000000..4bb66e6
--- /dev/null
+++ b/halimpl/bcm2079x/hal/include/nfc_hal_target.h
@@ -0,0 +1,437 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2012-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef NFC_HAL_TARGET_H
+#define NFC_HAL_TARGET_H
+
+#include "data_types.h"
+#include "gki.h"
+
+/****************************************************************************
+** NCI related configuration
+****************************************************************************/
+
+/* Initial Max Control Packet Payload Size (until receiving payload size in
+ * INIT_CORE_RSP) */
+#ifndef NFC_HAL_NCI_INIT_CTRL_PAYLOAD_SIZE
+#define NFC_HAL_NCI_INIT_CTRL_PAYLOAD_SIZE 0xFF
+#endif
+
+/* Number of bytes to reserve in front of NCI messages (e.g. for transport
+ * header) */
+#ifndef NFC_HAL_NCI_MSG_OFFSET_SIZE
+#define NFC_HAL_NCI_MSG_OFFSET_SIZE 1
+#endif
+
+/* NFC-WAKE */
+#ifndef NFC_HAL_LP_NFC_WAKE_GPIO
+#define NFC_HAL_LP_NFC_WAKE_GPIO UPIO_GENERAL3
+#endif
+
+/* NFCC snooze mode idle timeout before deassert NFC_WAKE in ms */
+#ifndef NFC_HAL_LP_IDLE_TIMEOUT
+#define NFC_HAL_LP_IDLE_TIMEOUT 100
+#endif
+
+/* NFC snooze mode */
+#ifndef NFC_HAL_LP_SNOOZE_MODE
+#define NFC_HAL_LP_SNOOZE_MODE NFC_HAL_LP_SNOOZE_MODE_UART
+#endif
+
+/* Idle Threshold Host in 100ms unit */
+#ifndef NFC_HAL_LP_IDLE_THRESHOLD_HOST
+#define NFC_HAL_LP_IDLE_THRESHOLD_HOST 0
+#endif
+
+/* Idle Threshold HC in 100ms unit */
+#ifndef NFC_HAL_LP_IDLE_THRESHOLD_HC
+#define NFC_HAL_LP_IDLE_THRESHOLD_HC 0
+#endif
+
+/* Default NFCC power-up baud rate */
+#ifndef NFC_HAL_DEFAULT_BAUD
+#define NFC_HAL_DEFAULT_BAUD USERIAL_BAUD_115200
+#endif
+
+/* time (in ms) between power off and on NFCC */
+#ifndef NFC_HAL_POWER_CYCLE_DELAY
+#define NFC_HAL_POWER_CYCLE_DELAY 100
+#endif
+
+/* time (in ms) between power off and on NFCC */
+#ifndef NFC_HAL_NFCC_ENABLE_TIMEOUT
+#define NFC_HAL_NFCC_ENABLE_TIMEOUT 1000
+#endif
+
+#ifndef NFC_HAL_PRM_DEBUG
+#define NFC_HAL_PRM_DEBUG TRUE
+#endif
+
+/* max patch data length (Can be overridden by platform for ACL HCI command
+ * size) */
+#ifndef NFC_HAL_PRM_HCD_CMD_MAXLEN
+#define NFC_HAL_PRM_HCD_CMD_MAXLEN 250
+#endif
+
+/* Require PreI2C patch by default */
+#ifndef NFC_HAL_PRE_I2C_PATCH_INCLUDED
+#define NFC_HAL_PRE_I2C_PATCH_INCLUDED TRUE
+#endif
+
+/* Mininum payload size for SPD NCI commands (used to validate
+ * HAL_NfcPrmSetSpdNciCmdPayloadSize) */
+/* Default is 32, as required by the NCI specifications; however this value may
+ * be */
+/* over-riden for platforms that have transport packet limitations */
+#ifndef NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE
+#define NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE (32)
+#endif
+
+/* amount of time to wait for authenticating/committing patch to NVM */
+#ifndef NFC_HAL_PRM_COMMIT_DELAY
+#define NFC_HAL_PRM_COMMIT_DELAY (30000)
+#endif
+
+/* amount of time to wait after downloading preI2C patch before downloading
+ * LPM/FPM patch */
+#ifndef NFC_HAL_PRM_POST_I2C_FIX_DELAY
+#define NFC_HAL_PRM_POST_I2C_FIX_DELAY (200)
+#endif
+
+/* NFCC will respond to more than one technology during listen discovery */
+#ifndef NFC_HAL_DM_MULTI_TECH_RESP
+#define NFC_HAL_DM_MULTI_TECH_RESP TRUE
+#endif
+
+/* Data rate for 15693 command/response, it must be same as
+ * RW_I93_FLAG_DATA_RATE in nfc_target.h */
+#define NFC_HAL_I93_FLAG_DATA_RATE_LOW 0x00
+#define NFC_HAL_I93_FLAG_DATA_RATE_HIGH 0x02
+
+#ifndef NFC_HAL_I93_FLAG_DATA_RATE
+#define NFC_HAL_I93_FLAG_DATA_RATE NFC_HAL_I93_FLAG_DATA_RATE_HIGH
+#endif
+
+/* NFC HAL HCI */
+#ifndef NFC_HAL_HCI_INCLUDED
+#define NFC_HAL_HCI_INCLUDED TRUE
+#endif
+
+/* Quick Timer */
+#ifndef QUICK_TIMER_TICKS_PER_SEC
+#define QUICK_TIMER_TICKS_PER_SEC 100 /* 10ms timer */
+#endif
+
+#ifndef NFC_HAL_SHARED_TRANSPORT_ENABLED
+#define NFC_HAL_SHARED_TRANSPORT_ENABLED FALSE
+#endif
+
+/* Enable verbose tracing by default */
+#ifndef NFC_HAL_TRACE_VERBOSE
+#define NFC_HAL_TRACE_VERBOSE TRUE
+#endif
+
+#ifndef NFC_HAL_INITIAL_TRACE_LEVEL
+#define NFC_HAL_INITIAL_TRACE_LEVEL 5
+#endif
+
+/* Map NFC serial port to USERIAL_PORT_6 by default */
+#ifndef USERIAL_NFC_PORT
+#define USERIAL_NFC_PORT (USERIAL_PORT_6)
+#endif
+
+/* Restore NFCC baud rate to default on shutdown if baud rate was updated */
+#ifndef NFC_HAL_RESTORE_BAUD_ON_SHUTDOWN
+#define NFC_HAL_RESTORE_BAUD_ON_SHUTDOWN TRUE
+#endif
+
+/* Enable protocol tracing by default */
+#ifndef NFC_HAL_TRACE_PROTOCOL
+#define NFC_HAL_TRACE_PROTOCOL TRUE
+#endif
+
+/* Legacy protocol-trace-enable macro */
+#ifndef BT_TRACE_PROTOCOL
+#define BT_TRACE_PROTOCOL (NFC_HAL_TRACE_PROTOCOL)
+#endif
+
+/* Enable HAL tracing by default */
+#ifndef NFC_HAL_USE_TRACES
+#define NFC_HAL_USE_TRACES TRUE
+#endif
+
+/* HAL trace macros */
+#if (NFC_HAL_USE_TRACES == TRUE)
+#define NCI_TRACE_0(l, t, m) \
+ LogMsg((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)), (m))
+#define NCI_TRACE_1(l, t, m, p1) \
+ LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m), (uintptr_t)(p1))
+#define NCI_TRACE_2(l, t, m, p1, p2) \
+ LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m), \
+ (uintptr_t)(p1), (uintptr_t)(p2))
+#define NCI_TRACE_3(l, t, m, p1, p2, p3) \
+ LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m), \
+ (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3))
+#define NCI_TRACE_4(l, t, m, p1, p2, p3, p4) \
+ LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m), \
+ (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3), (uintptr_t)(p4))
+#define NCI_TRACE_5(l, t, m, p1, p2, p3, p4, p5) \
+ LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m), \
+ (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3), (uintptr_t)(p4), \
+ (uintptr_t)(p5))
+#define NCI_TRACE_6(l, t, m, p1, p2, p3, p4, p5, p6) \
+ LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m), \
+ (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3), (uintptr_t)(p4), \
+ (uintptr_t)(p5), (uintptr_t)(p6))
+
+#define HAL_TRACE_ERROR0(m) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \
+ NCI_TRACE_0(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m); \
+ }
+#define HAL_TRACE_ERROR1(m, p1) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \
+ NCI_TRACE_1(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m, p1); \
+ }
+#define HAL_TRACE_ERROR2(m, p1, p2) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \
+ NCI_TRACE_2(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m, p1, p2); \
+ }
+#define HAL_TRACE_ERROR3(m, p1, p2, p3) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \
+ NCI_TRACE_3(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m, p1, p2, p3); \
+ }
+#define HAL_TRACE_ERROR4(m, p1, p2, p3, p4) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \
+ NCI_TRACE_4(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m, p1, p2, p3, p4); \
+ }
+#define HAL_TRACE_ERROR5(m, p1, p2, p3, p4, p5) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \
+ NCI_TRACE_5(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5); \
+ }
+#define HAL_TRACE_ERROR6(m, p1, p2, p3, p4, p5, p6) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \
+ NCI_TRACE_6(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5, \
+ p6); \
+ }
+
+#define HAL_TRACE_WARNING0(m) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \
+ NCI_TRACE_0(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m); \
+ }
+#define HAL_TRACE_WARNING1(m, p1) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \
+ NCI_TRACE_1(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m, p1); \
+ }
+#define HAL_TRACE_WARNING2(m, p1, p2) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \
+ NCI_TRACE_2(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m, p1, p2); \
+ }
+#define HAL_TRACE_WARNING3(m, p1, p2, p3) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \
+ NCI_TRACE_3(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m, p1, p2, p3); \
+ }
+#define HAL_TRACE_WARNING4(m, p1, p2, p3, p4) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \
+ NCI_TRACE_4(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m, p1, p2, p3, p4); \
+ }
+#define HAL_TRACE_WARNING5(m, p1, p2, p3, p4, p5) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \
+ NCI_TRACE_5(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5); \
+ }
+#define HAL_TRACE_WARNING6(m, p1, p2, p3, p4, p5, p6) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \
+ NCI_TRACE_6(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5, \
+ p6); \
+ }
+
+#define HAL_TRACE_API0(m) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) \
+ NCI_TRACE_0(TRACE_LAYER_HAL, TRACE_TYPE_API, m); \
+ }
+#define HAL_TRACE_API1(m, p1) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) \
+ NCI_TRACE_1(TRACE_LAYER_HAL, TRACE_TYPE_API, m, p1); \
+ }
+#define HAL_TRACE_API2(m, p1, p2) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) \
+ NCI_TRACE_2(TRACE_LAYER_HAL, TRACE_TYPE_API, m, p1, p2); \
+ }
+#define HAL_TRACE_API3(m, p1, p2, p3) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) \
+ NCI_TRACE_3(TRACE_LAYER_HAL, TRACE_TYPE_API, m, p1, p2, p3); \
+ }
+#define HAL_TRACE_API4(m, p1, p2, p3, p4) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) \
+ NCI_TRACE_4(TRACE_LAYER_HAL, TRACE_TYPE_API, m, p1, p2, p3, p4); \
+ }
+#define HAL_TRACE_API5(m, p1, p2, p3, p4, p5) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) \
+ NCI_TRACE_5(TRACE_LAYER_HAL, TRACE_TYPE_API, m, p1, p2, p3, p4, p5); \
+ }
+#define HAL_TRACE_API6(m, p1, p2, p3, p4, p5, p6) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) \
+ NCI_TRACE_6(TRACE_LAYER_HAL, TRACE_TYPE_API, m, p1, p2, p3, p4, p5, p6); \
+ }
+
+#define HAL_TRACE_EVENT0(m) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \
+ NCI_TRACE_0(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m); \
+ }
+#define HAL_TRACE_EVENT1(m, p1) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \
+ NCI_TRACE_1(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m, p1); \
+ }
+#define HAL_TRACE_EVENT2(m, p1, p2) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \
+ NCI_TRACE_2(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m, p1, p2); \
+ }
+#define HAL_TRACE_EVENT3(m, p1, p2, p3) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \
+ NCI_TRACE_3(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m, p1, p2, p3); \
+ }
+#define HAL_TRACE_EVENT4(m, p1, p2, p3, p4) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \
+ NCI_TRACE_4(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m, p1, p2, p3, p4); \
+ }
+#define HAL_TRACE_EVENT5(m, p1, p2, p3, p4, p5) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \
+ NCI_TRACE_5(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5); \
+ }
+#define HAL_TRACE_EVENT6(m, p1, p2, p3, p4, p5, p6) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \
+ NCI_TRACE_6(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5, \
+ p6); \
+ }
+
+#define HAL_TRACE_DEBUG0(m) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \
+ NCI_TRACE_0(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m); \
+ }
+#define HAL_TRACE_DEBUG1(m, p1) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \
+ NCI_TRACE_1(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m, p1); \
+ }
+#define HAL_TRACE_DEBUG2(m, p1, p2) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \
+ NCI_TRACE_2(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m, p1, p2); \
+ }
+#define HAL_TRACE_DEBUG3(m, p1, p2, p3) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \
+ NCI_TRACE_3(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m, p1, p2, p3); \
+ }
+#define HAL_TRACE_DEBUG4(m, p1, p2, p3, p4) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \
+ NCI_TRACE_4(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4); \
+ }
+#define HAL_TRACE_DEBUG5(m, p1, p2, p3, p4, p5) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \
+ NCI_TRACE_5(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5); \
+ }
+#define HAL_TRACE_DEBUG6(m, p1, p2, p3, p4, p5, p6) \
+ { \
+ if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \
+ NCI_TRACE_6(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5, \
+ p6); \
+ }
+
+#else /* Disable HAL tracing */
+
+#define HAL_TRACE_0(l, t, m)
+#define HAL_TRACE_1(l, t, m, p1)
+#define HAL_TRACE_2(l, t, m, p1, p2)
+#define HAL_TRACE_3(l, t, m, p1, p2, p3)
+#define HAL_TRACE_4(l, t, m, p1, p2, p3, p4)
+#define HAL_TRACE_5(l, t, m, p1, p2, p3, p4, p5)
+#define HAL_TRACE_6(l, t, m, p1, p2, p3, p4, p5, p6)
+
+#define HAL_TRACE_ERROR0(m)
+#define HAL_TRACE_ERROR1(m, p1)
+#define HAL_TRACE_ERROR2(m, p1, p2)
+#define HAL_TRACE_ERROR3(m, p1, p2, p3)
+#define HAL_TRACE_ERROR4(m, p1, p2, p3, p4)
+#define HAL_TRACE_ERROR5(m, p1, p2, p3, p4, p5)
+#define HAL_TRACE_ERROR6(m, p1, p2, p3, p4, p5, p6)
+
+#define HAL_TRACE_WARNING0(m)
+#define HAL_TRACE_WARNING1(m, p1)
+#define HAL_TRACE_WARNING2(m, p1, p2)
+#define HAL_TRACE_WARNING3(m, p1, p2, p3)
+#define HAL_TRACE_WARNING4(m, p1, p2, p3, p4)
+#define HAL_TRACE_WARNING5(m, p1, p2, p3, p4, p5)
+#define HAL_TRACE_WARNING6(m, p1, p2, p3, p4, p5, p6)
+
+#define HAL_TRACE_API0(m)
+#define HAL_TRACE_API1(m, p1)
+#define HAL_TRACE_API2(m, p1, p2)
+#define HAL_TRACE_API3(m, p1, p2, p3)
+#define HAL_TRACE_API4(m, p1, p2, p3, p4)
+#define HAL_TRACE_API5(m, p1, p2, p3, p4, p5)
+#define HAL_TRACE_API6(m, p1, p2, p3, p4, p5, p6)
+
+#define HAL_TRACE_EVENT0(m)
+#define HAL_TRACE_EVENT1(m, p1)
+#define HAL_TRACE_EVENT2(m, p1, p2)
+#define HAL_TRACE_EVENT3(m, p1, p2, p3)
+#define HAL_TRACE_EVENT4(m, p1, p2, p3, p4)
+#define HAL_TRACE_EVENT5(m, p1, p2, p3, p4, p5)
+#define HAL_TRACE_EVENT6(m, p1, p2, p3, p4, p5, p6)
+
+#define HAL_TRACE_DEBUG0(m)
+#define HAL_TRACE_DEBUG1(m, p1)
+#define HAL_TRACE_DEBUG2(m, p1, p2)
+#define HAL_TRACE_DEBUG3(m, p1, p2, p3)
+#define HAL_TRACE_DEBUG4(m, p1, p2, p3, p4)
+#define HAL_TRACE_DEBUG5(m, p1, p2, p3, p4, p5)
+#define HAL_TRACE_DEBUG6(m, p1, p2, p3, p4, p5, p6)
+#endif /* Disable HAL tracing */
+
+#endif /* GKI_TARGET_H */
diff --git a/halimpl/bcm2079x/hal/include/nfc_types.h b/halimpl/bcm2079x/hal/include/nfc_types.h
new file mode 100644
index 0000000..d373335
--- /dev/null
+++ b/halimpl/bcm2079x/hal/include/nfc_types.h
@@ -0,0 +1,351 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2012-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef NFC_TYPES_H
+#define NFC_TYPES_H
+
+/****************************************************************************
+** NFC_HDR header definition for NFC messages
+*****************************************************************************/
+typedef struct {
+ uint16_t event;
+ uint16_t len;
+ uint16_t offset;
+ uint16_t layer_specific;
+} NFC_HDR;
+#define NFC_HDR_SIZE (sizeof(NFC_HDR))
+
+/* Mask for NFC_HDR event field */
+#define NFC_EVT_MASK 0xFF00
+#define NFC_SUB_EVT_MASK 0x00FF
+
+/****************************************************************************
+** NFC_HAL_TASK definitions
+*****************************************************************************/
+
+/* NFC_HAL_TASK event messages */
+/* NCI message for sending to NFCC */
+#define NFC_HAL_EVT_TO_NFC_NCI 0x0100
+/* Request to start NCIT quick timer */
+#define NFC_HAL_EVT_POST_CORE_RESET 0x0200
+/* Request to start chip-specific config */
+#define NFC_HAL_EVT_TO_START_QUICK_TIMER 0x0300
+/* NCI message for hci persistency data */
+#define NFC_HAL_EVT_HCI 0x0400
+/* NCI message to issue prediscover config */
+#define NFC_HAL_EVT_PRE_DISCOVER 0x0500
+/* permission to send commands queued in HAL*/
+#define NFC_HAL_EVT_CONTROL_GRANTED 0x0600
+
+/* NFC_HAL_TASK sub event messages */
+#define NFC_HAL_HCI_RSP_NV_READ_EVT (0x01 | NFC_HAL_EVT_HCI)
+#define NFC_HAL_HCI_RSP_NV_WRITE_EVT (0x02 | NFC_HAL_EVT_HCI)
+#define NFC_HAL_HCI_VSC_TIMEOUT_EVT (0x03 | NFC_HAL_EVT_HCI)
+
+/* Event masks for NFC_TASK messages */
+/* NCI message for sending to host stack */
+#define NFC_EVT_TO_NFC_NCI 0x4000
+/* Error notification to NFC Task */
+#define NFC_EVT_TO_NFC_ERR 0x4100
+/* Messages between NFC and NCI task */
+#define NFC_EVT_TO_NFC_MSGS 0x4200
+
+/*****************************************************************************
+** Macros to get and put bytes to and from a stream (Little Endian format).
+*****************************************************************************/
+
+#define UINT32_TO_STREAM(p, u32) \
+ { \
+ *(p)++ = (uint8_t)(u32); \
+ *(p)++ = (uint8_t)((u32) >> 8); \
+ *(p)++ = (uint8_t)((u32) >> 16); \
+ *(p)++ = (uint8_t)((u32) >> 24); \
+ }
+#define UINT24_TO_STREAM(p, u24) \
+ { \
+ *(p)++ = (uint8_t)(u24); \
+ *(p)++ = (uint8_t)((u24) >> 8); \
+ *(p)++ = (uint8_t)((u24) >> 16); \
+ }
+#define UINT16_TO_STREAM(p, u16) \
+ { \
+ *(p)++ = (uint8_t)(u16); \
+ *(p)++ = (uint8_t)((u16) >> 8); \
+ }
+#define UINT8_TO_STREAM(p, u8) \
+ { *(p)++ = (uint8_t)(u8); }
+#define INT8_TO_STREAM(p, u8) \
+ { *(p)++ = (int8_t)(u8); }
+#define ARRAY32_TO_STREAM(p, a) \
+ { \
+ register int ijk; \
+ for (ijk = 0; ijk < 32; ijk++) *(p)++ = (uint8_t)(a)[31 - ijk]; \
+ }
+#define ARRAY16_TO_STREAM(p, a) \
+ { \
+ register int ijk; \
+ for (ijk = 0; ijk < 16; ijk++) *(p)++ = (uint8_t)(a)[15 - ijk]; \
+ }
+#define ARRAY8_TO_STREAM(p, a) \
+ { \
+ register int ijk; \
+ for (ijk = 0; ijk < 8; ijk++) *(p)++ = (uint8_t)(a)[7 - ijk]; \
+ }
+#define BDADDR_TO_STREAM(p, a) \
+ { \
+ register int ijk; \
+ for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) \
+ *(p)++ = (uint8_t)(a)[BD_ADDR_LEN - 1 - ijk]; \
+ }
+#define LAP_TO_STREAM(p, a) \
+ { \
+ register int ijk; \
+ for (ijk = 0; ijk < LAP_LEN; ijk++) \
+ *(p)++ = (uint8_t)(a)[LAP_LEN - 1 - ijk]; \
+ }
+#define DEVCLASS_TO_STREAM(p, a) \
+ { \
+ register int ijk; \
+ for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++) \
+ *(p)++ = (uint8_t)(a)[DEV_CLASS_LEN - 1 - ijk]; \
+ }
+#define ARRAY_TO_STREAM(p, a, len) \
+ { \
+ register int ijk; \
+ for (ijk = 0; ijk < (len); ijk++) *(p)++ = (uint8_t)(a)[ijk]; \
+ }
+#define REVERSE_ARRAY_TO_STREAM(p, a, len) \
+ { \
+ register int ijk; \
+ for (ijk = 0; ijk < (len); ijk++) *(p)++ = (uint8_t)(a)[(len) - 1 - ijk]; \
+ }
+
+#define STREAM_TO_UINT8(u8, p) \
+ { \
+ (u8) = (uint8_t)(*(p)); \
+ (p) += 1; \
+ }
+#define STREAM_TO_UINT16(u16, p) \
+ { \
+ (u16) = ((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8)); \
+ (p) += 2; \
+ }
+#define STREAM_TO_UINT24(u32, p) \
+ { \
+ (u32) = (((uint32_t)(*(p))) + ((((uint32_t)(*((p) + 1)))) << 8) + \
+ ((((uint32_t)(*((p) + 2)))) << 16)); \
+ (p) += 3; \
+ }
+#define STREAM_TO_UINT32(u32, p) \
+ { \
+ (u32) = (((uint32_t)(*(p))) + ((((uint32_t)(*((p) + 1)))) << 8) + \
+ ((((uint32_t)(*((p) + 2)))) << 16) + \
+ ((((uint32_t)(*((p) + 3)))) << 24)); \
+ (p) += 4; \
+ }
+#define STREAM_TO_BDADDR(a, p) \
+ { \
+ register int ijk; \
+ register uint8_t* pbda = (uint8_t*)(a) + BD_ADDR_LEN - 1; \
+ for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *pbda-- = *(p)++; \
+ }
+#define STREAM_TO_ARRAY32(a, p) \
+ { \
+ register int ijk; \
+ register uint8_t* _pa = (uint8_t*)(a) + 31; \
+ for (ijk = 0; ijk < 32; ijk++) *_pa-- = *(p)++; \
+ }
+#define STREAM_TO_ARRAY16(a, p) \
+ { \
+ register int ijk; \
+ register uint8_t* _pa = (uint8_t*)(a) + 15; \
+ for (ijk = 0; ijk < 16; ijk++) *_pa-- = *(p)++; \
+ }
+#define STREAM_TO_ARRAY8(a, p) \
+ { \
+ register int ijk; \
+ register uint8_t* _pa = (uint8_t*)(a) + 7; \
+ for (ijk = 0; ijk < 8; ijk++) *_pa-- = *(p)++; \
+ }
+#define STREAM_TO_DEVCLASS(a, p) \
+ { \
+ register int ijk; \
+ register uint8_t* _pa = (uint8_t*)(a) + DEV_CLASS_LEN - 1; \
+ for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++) *_pa-- = *(p)++; \
+ }
+#define STREAM_TO_LAP(a, p) \
+ { \
+ register int ijk; \
+ register uint8_t* plap = (uint8_t*)(a) + LAP_LEN - 1; \
+ for (ijk = 0; ijk < LAP_LEN; ijk++) *plap-- = *(p)++; \
+ }
+#define STREAM_TO_ARRAY(a, p, len) \
+ { \
+ register int ijk; \
+ for (ijk = 0; ijk < (len); ijk++) ((uint8_t*)(a))[ijk] = *(p)++; \
+ }
+#define REVERSE_STREAM_TO_ARRAY(a, p, len) \
+ { \
+ register int ijk; \
+ register uint8_t* _pa = (uint8_t*)(a) + (len) - 1; \
+ for (ijk = 0; ijk < (len); ijk++) *_pa-- = *(p)++; \
+ }
+
+/*****************************************************************************
+** Macros to get and put bytes to and from a field (Little Endian format).
+** These are the same as to stream, except the pointer is not incremented.
+*****************************************************************************/
+
+#define UINT32_TO_FIELD(p, u32) \
+ { \
+ *(uint8_t*)(p) = (uint8_t)(u32); \
+ *((uint8_t*)(p) + 1) = (uint8_t)((u32) >> 8); \
+ *((uint8_t*)(p) + 2) = (uint8_t)((u32) >> 16); \
+ *((uint8_t*)(p) + 3) = (uint8_t)((u32) >> 24); \
+ }
+#define UINT24_TO_FIELD(p, u24) \
+ { \
+ *(uint8_t*)(p) = (uint8_t)(u24); \
+ *((uint8_t*)(p) + 1) = (uint8_t)((u24) >> 8); \
+ *((uint8_t*)(p) + 2) = (uint8_t)((u24) >> 16); \
+ }
+#define UINT16_TO_FIELD(p, u16) \
+ { \
+ *(uint8_t*)(p) = (uint8_t)(u16); \
+ *((uint8_t*)(p) + 1) = (uint8_t)((u16) >> 8); \
+ }
+#define UINT8_TO_FIELD(p, u8) \
+ { *(uint8_t*)(p) = (uint8_t)(u8); }
+
+/*****************************************************************************
+** Macros to get and put bytes to and from a stream (Big Endian format)
+*****************************************************************************/
+
+#define UINT32_TO_BE_STREAM(p, u32) \
+ { \
+ *(p)++ = (uint8_t)((u32) >> 24); \
+ *(p)++ = (uint8_t)((u32) >> 16); \
+ *(p)++ = (uint8_t)((u32) >> 8); \
+ *(p)++ = (uint8_t)(u32); \
+ }
+#define UINT24_TO_BE_STREAM(p, u24) \
+ { \
+ *(p)++ = (uint8_t)((u24) >> 16); \
+ *(p)++ = (uint8_t)((u24) >> 8); \
+ *(p)++ = (uint8_t)(u24); \
+ }
+#define UINT16_TO_BE_STREAM(p, u16) \
+ { \
+ *(p)++ = (uint8_t)((u16) >> 8); \
+ *(p)++ = (uint8_t)(u16); \
+ }
+#define UINT8_TO_BE_STREAM(p, u8) \
+ { *(p)++ = (uint8_t)(u8); }
+#define ARRAY_TO_BE_STREAM(p, a, len) \
+ { \
+ register int ijk; \
+ for (ijk = 0; ijk < (len); ijk++) *(p)++ = (uint8_t)(a)[ijk]; \
+ }
+
+#define BE_STREAM_TO_UINT8(u8, p) \
+ { \
+ (u8) = (uint8_t)(*(p)); \
+ (p) += 1; \
+ }
+#define BE_STREAM_TO_UINT16(u16, p) \
+ { \
+ (u16) = (uint16_t)(((uint16_t)(*(p)) << 8) + (uint16_t)(*((p) + 1))); \
+ (p) += 2; \
+ }
+#define BE_STREAM_TO_UINT24(u32, p) \
+ { \
+ (u32) = (((uint32_t)(*((p) + 2))) + ((uint32_t)(*((p) + 1)) << 8) + \
+ ((uint32_t)(*(p)) << 16)); \
+ (p) += 3; \
+ }
+#define BE_STREAM_TO_UINT32(u32, p) \
+ { \
+ (u32) = ((uint32_t)(*((p) + 3)) + ((uint32_t)(*((p) + 2)) << 8) + \
+ ((uint32_t)(*((p) + 1)) << 16) + ((uint32_t)(*(p)) << 24)); \
+ (p) += 4; \
+ }
+#define BE_STREAM_TO_ARRAY(p, a, len) \
+ { \
+ register int ijk; \
+ for (ijk = 0; ijk < (len); ijk++) ((uint8_t*)(a))[ijk] = *(p)++; \
+ }
+
+/*****************************************************************************
+** Macros to get and put bytes to and from a field (Big Endian format).
+** These are the same as to stream, except the pointer is not incremented.
+*****************************************************************************/
+
+#define UINT32_TO_BE_FIELD(p, u32) \
+ { \
+ *(uint8_t*)(p) = (uint8_t)((u32) >> 24); \
+ *((uint8_t*)(p) + 1) = (uint8_t)((u32) >> 16); \
+ *((uint8_t*)(p) + 2) = (uint8_t)((u32) >> 8); \
+ *((uint8_t*)(p) + 3) = (uint8_t)(u32); \
+ }
+#define UINT24_TO_BE_FIELD(p, u24) \
+ { \
+ *(uint8_t*)(p) = (uint8_t)((u24) >> 16); \
+ *((uint8_t*)(p) + 1) = (uint8_t)((u24) >> 8); \
+ *((uint8_t*)(p) + 2) = (uint8_t)(u24); \
+ }
+#define UINT16_TO_BE_FIELD(p, u16) \
+ { \
+ *(uint8_t*)(p) = (uint8_t)((u16) >> 8); \
+ *((uint8_t*)(p) + 1) = (uint8_t)(u16); \
+ }
+#define UINT8_TO_BE_FIELD(p, u8) \
+ { *(uint8_t*)(p) = (uint8_t)(u8); }
+
+/*****************************************************************************
+** Define trace levels
+*****************************************************************************/
+
+/* No trace messages to be generated */
+#define BT_TRACE_LEVEL_NONE 0
+/* Error condition trace messages */
+#define BT_TRACE_LEVEL_ERROR 1
+/* Warning condition trace messages */
+#define BT_TRACE_LEVEL_WARNING 2
+/* API traces */
+#define BT_TRACE_LEVEL_API 3
+/* Debug messages for events */
+#define BT_TRACE_LEVEL_EVENT 4
+/* Full debug messages */
+#define BT_TRACE_LEVEL_DEBUG 5
+
+#define TRACE_CTRL_GENERAL 0x00000000
+#define TRACE_LAYER_NCI 0x00280000
+#define TRACE_LAYER_HAL 0x00310000
+#define TRACE_LAYER_GKI 0x001a0000
+#define TRACE_ORG_STACK 0x00000000
+#define TRACE_ORG_GKI 0x00000400
+
+#define TRACE_TYPE_ERROR 0x00000000
+#define TRACE_TYPE_WARNING 0x00000001
+#define TRACE_TYPE_API 0x00000002
+#define TRACE_TYPE_EVENT 0x00000003
+#define TRACE_TYPE_DEBUG 0x00000004
+
+#define TRACE_TYPE_GENERIC 0x00000008
+
+#endif /* NFC_TYPES_H */
diff --git a/halimpl/bcm2079x/hal/int/nfc_brcm_defs.h b/halimpl/bcm2079x/hal/int/nfc_brcm_defs.h
new file mode 100644
index 0000000..c66ecd4
--- /dev/null
+++ b/halimpl/bcm2079x/hal/int/nfc_brcm_defs.h
@@ -0,0 +1,421 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2012-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the Broadcom-specific defintions that are shared
+ * between HAL, nfc stack, adaptation layer and applications.
+ *
+ ******************************************************************************/
+
+#ifndef NFC_BRCM_DEFS_H
+#define NFC_BRCM_DEFS_H
+
+/*****************************************************************************
+** Broadcom HW ID definitions
+*****************************************************************************/
+#define BRCM_20791B3_ID 0x20791b03
+#define BRCM_20791B4_ID 0x20791b04
+#define BRCM_20791B5_ID 0x20791b05
+#define BRCM_43341B0_ID 0x43341b00
+#define BRCM_20795T1_ID 0x20795a01
+#define BRCM_20795A0_ID 0x20795a00
+#define BRCM_20795A1_ID 0x20795a10
+
+#define BRCM_NFC_GEN_MASK 0xFFFFF000 /* HW generation mask */
+#define BRCM_NFC_REV_MASK 0x00000FFF /* HW revision mask */
+#define BRCM_NFC_20791_GEN 0x20791000
+#define BRCM_NFC_20791_GEN_MAX_EE 3 /* HCI access and 2 UICCs */
+#define BRCM_NFC_43341_GEN 0x43341000
+#define BRCM_NFC_43341_GEN_MAX_EE 3 /* HCI access and 2 UICCs */
+#define BRCM_NFC_20795_GEN 0x20795000
+#define BRCM_NFC_20795_GEN_MAX_EE 4 /* HCI access and 3 UICCs */
+
+/*****************************************************************************
+** Broadcom-specific NCI definitions
+*****************************************************************************/
+
+/**********************************************
+ * NCI Message Proprietary Group - F
+ **********************************************/
+#define NCI_MSG_TAG_SET_MEM 0x00
+#define NCI_MSG_TAG_GET_MEM 0x01
+#define NCI_MSG_T1T_SET_HR 0x02
+#define NCI_MSG_SET_CLF_REGISTERS 0x03
+#define NCI_MSG_GET_BUILD_INFO 0x04
+#define NCI_MSG_HCI_NETWK 0x05
+#define NCI_MSG_SET_FWFSM 0x06
+#define NCI_MSG_SET_UICCRDRF 0x07
+#define NCI_MSG_POWER_LEVEL 0x08
+#define NCI_MSG_FRAME_LOG 0x09
+#define NCI_MSG_UICC_READER_ACTION 0x0A
+#define NCI_MSG_SET_PPSE_RESPONSE 0x0B
+#define NCI_MSG_PRBS_SET 0x0C
+/* reset HCI network/close all pipes (S,D) register */
+#define NCI_MSG_RESET_ALL_UICC_CFG 0x0D
+#define NCI_MSG_GET_NFCEE_INFO 0x0E
+#define NCI_MSG_DISABLE_INIT_CHECK 0x0F
+#define NCI_MSG_ANTENNA_SELF_TEST 0x10
+#define NCI_MSG_SET_MAX_PKT_SIZE 0x11
+#define NCI_MSG_NCIP_CLK_REQ_OR_CAR_DET 0x12
+#define NCI_MSG_NCIP_CONFIG_DBUART 0x13
+#define NCI_MSG_NCIP_ENABLE_DVT_DRIVER 0x14
+#define NCI_MSG_SET_ASWP 0x15
+#define NCI_MSG_ENCAPSULATE_NCI 0x16
+#define NCI_MSG_CONFIGURE_ARM_JTAG 0x17
+#define NCI_MSG_STATISTICS 0x18
+#define NCI_MSG_SET_DSP_TABLE 0x19
+#define NCI_MSG_GET_DSP_TABLE 0x1a
+#define NCI_MSG_READY_RX_CMD 0x1b
+#define NCI_MSG_GET_VBAT 0x1c
+#define NCI_MSG_GET_XTAL_INDEX_FROM_DH 0x1d
+#define NCI_MSG_SWP_LOG 0x1e
+#define NCI_MSG_GET_PWRLEVEL 0x1f
+#define NCI_MSG_SET_VBAT_MONITOR 0x20
+#define NCI_MSG_SET_TINT_MODE 0x21
+#define NCI_MSG_ACCESS_APP 0x22
+#define NCI_MSG_SET_SECURE_MODE 0x23
+#define NCI_MSG_GET_NV_DEVICE 0x24
+#define NCI_MSG_LPTD 0x25
+#define NCI_MSG_SET_CE4_AS_SNOOZE 0x26
+#define NCI_MSG_NFCC_SEND_HCI 0x27
+#define NCI_MSG_CE4_PATCH_DOWNLOAD_DONE 0x28
+#define NCI_MSG_EEPROM_RW 0x29
+#define NCI_MSG_GET_CLF_REGISTERS 0x2A
+#define NCI_MSG_RF_TEST 0x2B
+#define NCI_MSG_DEBUG_PRINT 0x2C
+#define NCI_MSG_GET_PATCH_VERSION 0x2D
+#define NCI_MSG_SECURE_PATCH_DOWNLOAD 0x2E
+#define NCI_MSG_SPD_FORMAT_NVM 0x2F
+#define NCI_MSG_SPD_READ_NVM 0x30
+#define NCI_MSG_SWP_BIST 0x31
+#define NCI_MSG_WLESS_DBG_MODE 0x32
+#define NCI_MSG_I2C_REQ_POLARITY 0x33
+#define NCI_MSG_AID_FILTER 0x39
+
+/**********************************************
+ * Proprietary NCI status codes
+ **********************************************/
+#define NCI_STATUS_SPD_ERROR_ORDER 0xE0
+#define NCI_STATUS_SPD_ERROR_DEST 0xE1
+#define NCI_STATUS_SPD_ERROR_PROJECTID 0xE2
+#define NCI_STATUS_SPD_ERROR_CHIPVER 0xE3
+#define NCI_STATUS_SPD_ERROR_MAJORVER 0xE4
+#define NCI_STATUS_SPD_ERROR_INVALID_PARAM 0xE5
+#define NCI_STATUS_SPD_ERROR_INVALID_SIG 0xE6
+#define NCI_STATUS_SPD_ERROR_NVM_CORRUPTED 0xE7
+#define NCI_STATUS_SPD_ERROR_PWR_MODE 0xE8
+#define NCI_STATUS_SPD_ERROR_MSG_LEN 0xE9
+#define NCI_STATUS_SPD_ERROR_PATCHSIZE 0xEA
+
+#define NCI_NV_DEVICE_NONE 0x00
+#define NCI_NV_DEVICE_EEPROM 0x08
+#define NCI_NV_DEVICE_UICC1 0x10
+
+/* The events reported on tNFC_VS_CBACK */
+/* The event is (NCI_NTF_BIT|oid) or (NCI_RSP_BIT|oid) */
+#define NFC_VS_HCI_NETWK_EVT (NCI_NTF_BIT | NCI_MSG_HCI_NETWK)
+#define NFC_VS_HCI_NETWK_RSP (NCI_RSP_BIT | NCI_MSG_HCI_NETWK)
+#define NFC_VS_UICC_READER_ACTION_EVT (NCI_NTF_BIT | NCI_MSG_UICC_READER_ACTION)
+#define NFC_VS_POWER_LEVEL_RSP (NCI_RSP_BIT | NCI_MSG_POWER_LEVEL)
+#define NFC_VS_GET_NV_DEVICE_EVT (NCI_RSP_BIT | NCI_MSG_GET_NV_DEVICE)
+#define NFC_VS_LPTD_EVT (NCI_NTF_BIT | NCI_MSG_LPTD)
+#define NFC_VS_GET_BUILD_INFO_EVT (NCI_RSP_BIT | NCI_MSG_GET_BUILD_INFO)
+#define NFC_VS_GET_PATCH_VERSION_EVT (NCI_RSP_BIT | NCI_MSG_GET_PATCH_VERSION)
+#define NFC_VS_SEC_PATCH_DOWNLOAD_EVT \
+ (NCI_RSP_BIT | NCI_MSG_SECURE_PATCH_DOWNLOAD)
+#define NFC_VS_SEC_PATCH_AUTH_EVT (NCI_NTF_BIT | NCI_MSG_SECURE_PATCH_DOWNLOAD)
+#define NFC_VS_EEPROM_RW_EVT (NCI_RSP_BIT | NCI_MSG_EEPROM_RW)
+
+#define NCI_GET_PATCH_VERSION_NVM_OFFSET 37
+
+/* Static and dynamic pipe id and status for each pipe to uicc0 and uicc1. */
+#define NCI_NFCC_PIPE_INFO_NV_SIZE 24
+#define NCI_PERSONALITY_SLOT_SIZE 19
+#define NCI_DYNAMIC_PIPE_SIZE 8
+
+/* Type of TLV in NCI_MSG_HCI_NETWK */
+#define NCI_SWP_INTERFACE_TYPE 0xFF
+/* Type of TLV in NCI_MSG_HCI_NETWK */
+#define NCI_HCI_GATE_TYPE 0xFE
+
+/* Secure Patch Download definitions (patch type definitions) */
+#define NCI_SPD_TYPE_HEADER 0x00
+#define NCI_SPD_TYPE_SRAM 0x01
+#define NCI_SPD_TYPE_AON 0x02
+#define NCI_SPD_TYPE_PATCH_TABLE 0x03
+#define NCI_SPD_TYPE_SECURE_CONFIG 0x04
+#define NCI_SPD_TYPE_CONTROLLED_CONFIG 0x05
+#define NCI_SPD_TYPE_SIGNATURE 0x06
+#define NCI_SPD_TYPE_SIGCHEK 0x07
+
+/* Secure Patch Download definitions (NCI_SPD_TYPE_HEADER definitions) */
+#define NCI_SPD_HEADER_OFFSET_CHIPVERLEN 0x18
+#define NCI_SPD_HEADER_CHIPVER_LEN 16
+
+/* NVM Type (in GET_PATCH_VERSION RSP) */
+#define NCI_SPD_NVM_TYPE_NONE 0x00
+#define NCI_SPD_NVM_TYPE_EEPROM 0x01
+#define NCI_SPD_NVM_TYPE_UICC 0x02
+
+/**********************************************
+ * NCI NFCC proprietary features in octet 3
+ **********************************************/
+#define NCI_FEAT_SIGNED_PATCH 0x01000000
+
+/**********************************************
+ * NCI Interface Types
+ **********************************************/
+#define NCI_INTERFACE_VS_MIFARE 0x80
+#define NCI_INTERFACE_VS_CALYPSO_CE 0x81
+#define NCI_INTERFACE_VS_T2T_CE 0x82 /* for Card Emulation side */
+/* for both Reader/Writer and Card Emulation side */
+#define NCI_INTERFACE_VS_15693 0x83
+#define NCI_INTERFACE_VS_T1T_CE 0x84 /* for Card Emulation side */
+
+/**********************************************
+ * NCI Proprietary Parameter IDs
+ **********************************************/
+#define NCI_PARAM_ID_LA_FSDI 0xA0
+#define NCI_PARAM_ID_LB_FSDI 0xA1
+#define NCI_PARAM_ID_HOST_LISTEN_MASK 0xA2
+#define NCI_PARAM_ID_CHIP_TYPE 0xA3 /* NFCDEP */
+#define NCI_PARAM_ID_PA_ANTICOLL 0xA4
+#define NCI_PARAM_ID_CONTINUE_MODE 0xA5
+#define NCI_PARAM_ID_LBP 0xA6
+#define NCI_PARAM_ID_T1T_RDR_ONLY 0xA7
+#define NCI_PARAM_ID_LA_SENS_RES 0xA8
+#define NCI_PARAM_ID_PWR_SETTING_BITMAP 0xA9
+#define NCI_PARAM_ID_WI_NTF_ENABLE 0xAA
+#define NCI_PARAM_ID_LN_BITRATE 0xAB /* NFCDEP Listen Bitrate */
+#define NCI_PARAM_ID_LF_BITRATE 0xAC /* FeliCa */
+#define NCI_PARAM_ID_SWP_BITRATE_MASK 0xAD
+#define NCI_PARAM_ID_KOVIO 0xAE
+#define NCI_PARAM_ID_UICC_NTF_TO 0xAF
+#define NCI_PARAM_ID_NFCDEP 0xB0
+#define NCI_PARAM_ID_CLF_REGS_CFG 0xB1
+#define NCI_PARAM_ID_NFCDEP_TRANS_TIME 0xB2
+#define NCI_PARAM_ID_CREDIT_TIMER 0xB3
+#define NCI_PARAM_ID_CORRUPT_RX 0xB4
+#define NCI_PARAM_ID_ISODEP 0xB5
+#define NCI_PARAM_ID_LF_CONFIG 0xB6
+#define NCI_PARAM_ID_I93_DATARATE 0xB7
+#define NCI_PARAM_ID_CREDITS_THRESHOLD 0xB8
+#define NCI_PARAM_ID_TAGSNIFF_CFG 0xB9
+#define NCI_PARAM_ID_PA_FSDI 0xBA /* ISODEP */
+#define NCI_PARAM_ID_PB_FSDI 0xBB /* ISODEP */
+#define NCI_PARAM_ID_FRAME_INTF_RETXN 0xBC
+
+#define NCI_PARAM_ID_UICC_RDR_PRIORITY 0xBD
+#define NCI_PARAM_ID_GUARD_TIME 0xBE
+#define NCI_PARAM_ID_STDCONFIG 0xBF /* dont not use this config item */
+/* dont not use this config item */
+#define NCI_PARAM_ID_PROPCFG 0xC0
+#define NCI_PARAM_ID_MAXTRY2ACTIVATE 0xC1
+#define NCI_PARAM_ID_SWPCFG 0xC2
+#define NCI_PARAM_ID_CLF_LPM_CFG 0xC3
+#define NCI_PARAM_ID_DCLB 0xC4
+#define NCI_PARAM_ID_ACT_ORDER 0xC5
+#define NCI_PARAM_ID_DEP_DELAY_ACT 0xC6
+#define NCI_PARAM_ID_DH_PARITY_CRC_CTL 0xC7
+#define NCI_PARAM_ID_PREINIT_DSP_CFG 0xC8
+#define NCI_PARAM_ID_FW_WORKAROUND 0xC9
+#define NCI_PARAM_ID_RFU_CONFIG 0xCA
+#define NCI_PARAM_ID_EMVCO_ENABLE 0xCB
+#define NCI_PARAM_ID_ANTDRIVER_PARAM 0xCC
+#define NCI_PARAM_ID_PLL325_CFG_PARAM 0xCD
+#define NCI_PARAM_ID_OPNLP_ADPLL_ENABLE 0xCE
+#define NCI_PARAM_ID_CONFORMANCE_MODE 0xCF
+
+#define NCI_PARAM_ID_LPO_ON_OFF_ENABLE 0xD0
+#define NCI_PARAM_ID_FORCE_VANT 0xD1
+#define NCI_PARAM_ID_COEX_CONFIG 0xD2
+#define NCI_PARAM_ID_INTEL_MODE 0xD3
+
+#define NCI_PARAM_ID_AID 0xFF
+
+/**********************************************
+ * NCI Parameter ID Lens
+ **********************************************/
+#define NCI_PARAM_LEN_PWR_SETTING_BITMAP 3
+#define NCI_PARAM_LEN_HOST_LISTEN_MASK 2
+#define NCI_PARAM_LEN_PLL325_CFG_PARAM 14
+#define NCI_PARAM_LEN_POWER_LEVEL 6
+
+/**********************************************
+ * Snooze Mode
+ **********************************************/
+#define NFC_SNOOZE_MODE_NONE 0x00 /* Snooze mode disabled */
+#define NFC_SNOOZE_MODE_UART 0x01 /* Snooze mode for UART */
+#define NFC_SNOOZE_MODE_SPI_I2C 0x08 /* Snooze mode for SPI/I2C */
+
+#define NFC_SNOOZE_ACTIVE_LOW 0x00 /* high to low voltage is asserting */
+#define NFC_SNOOZE_ACTIVE_HIGH 0x01 /* low to high voltage is asserting */
+
+/**********************************************
+ * HCI definitions
+ **********************************************/
+#define NFC_HAL_HCI_SESSION_ID_LEN 8
+#define NFC_HAL_HCI_SYNC_ID_LEN 2
+
+/* HCI Network command definitions */
+#define NFC_HAL_HCI_NETWK_INFO_SIZE 250
+#define NFC_HAL_HCI_NO_RW_MODE_NETWK_INFO_SIZE 184
+#define NFC_HAL_HCI_DH_NETWK_INFO_SIZE 111
+#define NFC_HAL_HCI_MIN_NETWK_INFO_SIZE 12
+#define NFC_HAL_HCI_MIN_DH_NETWK_INFO_SIZE 11
+
+/* Card emulation RF Gate A definitions */
+#define NFC_HAL_HCI_CE_RF_A_UID_REG_LEN 10
+#define NFC_HAL_HCI_CE_RF_A_ATQA_RSP_CODE_LEN 2
+#define NFC_HAL_HCI_CE_RF_A_MAX_HIST_DATA_LEN 15
+#define NFC_HAL_HCI_CE_RF_A_MAX_DATA_RATE_LEN 3
+
+/* Card emulation RF Gate B definitions */
+#define NFC_HAL_HCI_CE_RF_B_PUPI_LEN 4
+#define NFC_HAL_HCI_CE_RF_B_ATQB_LEN 4
+#define NFC_HAL_HCI_CE_RF_B_HIGHER_LAYER_RSP_LEN 61
+#define NFC_HAL_HCI_CE_RF_B_MAX_DATA_RATE_LEN 3
+
+/* Card emulation RF Gate BP definitions */
+#define NFC_HAL_HCI_CE_RF_BP_MAX_PAT_IN_LEN 8
+#define NFC_HAL_HCI_CE_RF_BP_DATA_OUT_LEN 40
+
+/* Reader RF Gate A definitions */
+#define NFC_HAL_HCI_RD_RF_B_HIGHER_LAYER_DATA_LEN 61
+
+/* DH HCI Network command definitions */
+#define NFC_HAL_HCI_DH_MAX_DYN_PIPES 20
+
+/* Target handle for different host in the network */
+#define NFC_HAL_HCI_DH_TARGET_HANDLE 0xF2
+#define NFC_HAL_HCI_UICC0_TARGET_HANDLE 0xF3
+#define NFC_HAL_HCI_UICC1_TARGET_HANDLE 0xF4
+#define NFC_HAL_HCI_UICC2_TARGET_HANDLE 0xF5
+
+/* Card emulation RF Gate A registry information */
+typedef struct {
+ uint8_t pipe_id; /* if MSB is set then valid, 7 bits for Pipe ID */
+ uint8_t mode; /* Type A card emulation enabled indicator, 0x02:enabled */
+ uint8_t sak;
+ uint8_t uid_reg_len;
+ uint8_t uid_reg[NFC_HAL_HCI_CE_RF_A_UID_REG_LEN];
+ uint8_t atqa[NFC_HAL_HCI_CE_RF_A_ATQA_RSP_CODE_LEN]; /* ATQA response code */
+ uint8_t app_data_len;
+ uint8_t
+ app_data[NFC_HAL_HCI_CE_RF_A_MAX_HIST_DATA_LEN]; /* 15 bytes optional
+ storage for historic
+ data, use 2 slots */
+ uint8_t fwi_sfgi; /* FRAME WAITING TIME, START-UP FRAME GUARD TIME */
+ uint8_t cid_support;
+ uint8_t datarate_max[NFC_HAL_HCI_CE_RF_A_MAX_DATA_RATE_LEN];
+ uint8_t clt_support;
+} tNCI_HCI_CE_RF_A;
+
+/* Card emulation RF Gate B registry information */
+typedef struct {
+ uint8_t pipe_id; /* if MSB is set then valid, 7 bits for Pipe ID */
+ uint8_t mode; /* Type B card emulation enabled indicator, 0x02:enabled */
+ uint8_t pupi_len;
+ uint8_t pupi_reg[NFC_HAL_HCI_CE_RF_B_PUPI_LEN];
+ uint8_t afi;
+ uint8_t
+ atqb[NFC_HAL_HCI_CE_RF_B_ATQB_LEN]; /* 4 bytes ATQB application data */
+ uint8_t higherlayer_resp
+ [NFC_HAL_HCI_CE_RF_B_HIGHER_LAYER_RSP_LEN]; /* 0~ 61 bytes ATRB_INF use
+ 1~4 personality slots */
+ uint8_t datarate_max[NFC_HAL_HCI_CE_RF_B_MAX_DATA_RATE_LEN];
+ uint8_t natrb;
+} tNCI_HCI_CE_RF_B;
+
+/* Card emulation RF Gate BP registry information */
+typedef struct {
+ uint8_t pipe_id; /* if MSB is set then valid, 7 bits for Pipe ID */
+ uint8_t
+ mode; /* Type B prime card emulation enabled indicator, 0x02:enabled */
+ uint8_t pat_in_len;
+ uint8_t pat_in[NFC_HAL_HCI_CE_RF_BP_MAX_PAT_IN_LEN];
+ uint8_t dat_out_len;
+ uint8_t
+ dat_out[NFC_HAL_HCI_CE_RF_BP_DATA_OUT_LEN]; /* ISO7816-3 <=64 byte, and
+ other fields are 9 bytes */
+ uint8_t natr;
+} tNCI_HCI_CE_RF_BP;
+
+/* Card emulation RF Gate F registry information */
+typedef struct {
+ uint8_t pipe_id; /* if MSB is set then valid, 7 bits for Pipe ID */
+ uint8_t mode; /* Type F card emulation enabled indicator, 0x02:enabled */
+ uint8_t speed_cap;
+ uint8_t clt_support;
+} tNCI_HCI_CE_RF_F;
+
+/* Reader RF Gate A registry information */
+typedef struct {
+ uint8_t pipe_id; /* if MSB is set then valid, 7 bits for Pipe ID */
+ uint8_t datarate_max;
+} tNCI_HCI_RD_RF_A;
+
+/* Reader RF Gate B registry information */
+typedef struct {
+ uint8_t pipe_id; /* if MSB is set then valid, 7 bits for Pipe ID */
+ uint8_t afi;
+ uint8_t hldata_len;
+ uint8_t
+ high_layer_data[NFC_HAL_HCI_RD_RF_B_HIGHER_LAYER_DATA_LEN]; /* INF field
+ in ATTRIB
+ command */
+} tNCI_HCI_RD_RF_B;
+
+/* Dynamic pipe information */
+typedef struct {
+ uint8_t source_host;
+ uint8_t dest_host;
+ uint8_t source_gate;
+ uint8_t dest_gate;
+ uint8_t pipe_id; /* if MSB is set then valid, 7 bits for Pipe ID */
+} tNCI_HCI_DYN_PIPE_INFO;
+
+/*************************************************************
+ * HCI Network CMD/NTF structure for UICC host in the network
+ *************************************************************/
+typedef struct {
+ uint8_t target_handle;
+ uint8_t session_id[NFC_HAL_HCI_SESSION_ID_LEN];
+ uint8_t sync_id[NFC_HAL_HCI_SYNC_ID_LEN];
+ uint8_t static_pipe_info;
+ tNCI_HCI_CE_RF_A ce_rf_a;
+ tNCI_HCI_CE_RF_B ce_rf_b;
+ tNCI_HCI_CE_RF_BP ce_rf_bp;
+ tNCI_HCI_CE_RF_F ce_rf_f;
+ tNCI_HCI_RD_RF_A rw_rf_a;
+ tNCI_HCI_RD_RF_B rw_rf_b;
+} tNCI_HCI_NETWK;
+
+/************************************************
+ * HCI Network CMD/NTF structure for Device host
+ ************************************************/
+typedef struct {
+ uint8_t target_handle;
+ uint8_t session_id[NFC_HAL_HCI_SESSION_ID_LEN];
+ uint8_t static_pipe_info;
+ uint8_t num_dyn_pipes;
+ tNCI_HCI_DYN_PIPE_INFO dyn_pipe_info[NFC_HAL_HCI_DH_MAX_DYN_PIPES];
+} tNCI_HCI_NETWK_DH;
+
+#endif /* NFC_BRCM_DEFS_H */
diff --git a/halimpl/bcm2079x/hal/int/nfc_hal_int.h b/halimpl/bcm2079x/hal/int/nfc_hal_int.h
new file mode 100644
index 0000000..4298205
--- /dev/null
+++ b/halimpl/bcm2079x/hal/int/nfc_hal_int.h
@@ -0,0 +1,550 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2009-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * this file contains the NCI transport internal definitions and functions.
+ *
+ ******************************************************************************/
+
+#ifndef NFC_HAL_INT_H
+#define NFC_HAL_INT_H
+
+#include "gki.h"
+#include "nci_defs.h"
+#include "nfc_brcm_defs.h"
+#include "nfc_hal_api.h"
+#include "nfc_hal_int_api.h"
+#include "nfc_hal_target.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/****************************************************************************
+** NFC HAL TASK transport definitions
+****************************************************************************/
+/* NFC HAL Task event masks */
+#define NFC_HAL_TASK_EVT_DATA_RDY EVENT_MASK(APPL_EVT_0)
+#define NFC_HAL_TASK_EVT_INITIALIZE EVENT_MASK(APPL_EVT_5)
+#define NFC_HAL_TASK_EVT_TERMINATE EVENT_MASK(APPL_EVT_6)
+#define NFC_HAL_TASK_EVT_POWER_CYCLE EVENT_MASK(APPL_EVT_7)
+
+#define NFC_HAL_TASK_EVT_MBOX (TASK_MBOX_0_EVT_MASK)
+
+/* NFC HAL Task mailbox definitions */
+#define NFC_HAL_TASK_MBOX (TASK_MBOX_0)
+
+/* NFC HAL Task Timer events */
+#ifndef NFC_HAL_QUICK_TIMER_EVT_MASK
+#define NFC_HAL_QUICK_TIMER_EVT_MASK (TIMER_0_EVT_MASK)
+#endif
+
+#ifndef NFC_HAL_QUICK_TIMER_ID
+#define NFC_HAL_QUICK_TIMER_ID (TIMER_0)
+#endif
+
+/* NFC HAL Task Timer types */
+#define NFC_HAL_TTYPE_NCI_WAIT_RSP 0
+#define NFC_HAL_TTYPE_POWER_CYCLE 1
+#define NFC_HAL_TTYPE_NFCC_ENABLE 2
+
+/* NFC HAL Task Wait Response flag */
+/* wait response on an NCI command */
+#define NFC_HAL_WAIT_RSP_CMD 0x10
+/* wait response on an NCI vendor specific command */
+#define NFC_HAL_WAIT_RSP_VSC 0x20
+/* wait response on a proprietary command */
+#define NFC_HAL_WAIT_RSP_PROP 0x40
+/* not waiting for anything */
+#define NFC_HAL_WAIT_RSP_NONE 0x00
+
+typedef uint8_t tNFC_HAL_WAIT_RSP;
+
+#if (NFC_HAL_HCI_INCLUDED == TRUE)
+
+typedef uint16_t tNFC_HAL_HCI_EVT;
+
+#define NFC_HAL_HCI_PIPE_INFO_SIZE 5
+
+#define NFC_HAL_HCI_ANY_SET_PARAMETER 0x01
+#define NFC_HAL_HCI_ANY_GET_PARAMETER 0x02
+#define NFC_HAL_HCI_ADM_NOTIFY_ALL_PIPE_CLEARED 0x15
+
+#define NFC_HAL_HCI_SESSION_IDENTITY_INDEX 0x01
+#define NFC_HAL_HCI_WHITELIST_INDEX 0x03
+
+#define NFC_HAL_HCI_ADMIN_PIPE 0x01
+/* Host ID for UICC 0 */
+#define NFC_HAL_HCI_HOST_ID_UICC0 0x02
+/* Host ID for UICC 1 */
+#define NFC_HAL_HCI_HOST_ID_UICC1 0x03
+/* Host ID for UICC 2 */
+#define NFC_HAL_HCI_HOST_ID_UICC2 0x04
+#define NFC_HAL_HCI_COMMAND_TYPE 0x00
+#define NFC_HAL_HCI_RESPONSE_TYPE 0x02
+
+/* NFC HAL HCI responses */
+#define NFC_HAL_HCI_ANY_OK 0x00
+
+#endif
+
+/* Flag defintions for tNFC_HAL_NVM */
+/* No NVM available */
+#define NFC_HAL_NVM_FLAGS_NO_NVM 0x01
+/* FPM patch in NVM failed CRC check */
+#define NFC_HAL_NVM_FLAGS_LPM_BAD 0x02
+/* LPM patch in NVM failed CRC check */
+#define NFC_HAL_NVM_FLAGS_FPM_BAD 0x04
+/* Patch is present in NVM */
+#define NFC_HAL_NVM_FLAGS_PATCH_PRESENT 0x08
+
+/* NFC HAL transport configuration */
+typedef struct {
+ bool shared_transport; /* TRUE if using shared HCI/NCI transport */
+ uint8_t userial_baud;
+ uint8_t userial_fc;
+} tNFC_HAL_TRANS_CFG;
+
+#ifdef TESTER
+/* For Insight, ncit_cfg is runtime-configurable */
+#define NFC_HAL_TRANS_CFG_QUALIFIER
+#else
+/* For all other platforms, ncit_cfg is constant */
+#define NFC_HAL_TRANS_CFG_QUALIFIER const
+#endif
+extern NFC_HAL_TRANS_CFG_QUALIFIER tNFC_HAL_TRANS_CFG nfc_hal_trans_cfg;
+
+/*****************************************************************************
+* BT HCI definitions
+*****************************************************************************/
+
+/* Tranport message type */
+#define HCIT_TYPE_COMMAND 0x01
+#define HCIT_TYPE_EVENT 0x04
+#define HCIT_TYPE_NFC 0x10
+
+/* Vendor-Specific BT HCI definitions */
+#define HCI_SUCCESS 0x00
+#define HCI_GRP_VENDOR_SPECIFIC (0x3F << 10) /* 0xFC00 */
+#define HCI_BRCM_WRITE_SLEEP_MODE (0x0027 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_GRP_HOST_CONT_BASEBAND_CMDS (0x03 << 10) /* 0x0C00 */
+#define HCI_RESET (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_COMMAND_COMPLETE_EVT 0x0E
+#define HCI_BRCM_WRITE_SLEEP_MODE_LENGTH 12
+#define HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH 0x06
+#define HCIE_PREAMBLE_SIZE 2
+#define HCI_BRCM_PRE_SET_MEM (0x000C | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_PRE_SET_MEM_LENGTH 10
+#define HCI_BRCM_PRE_SET_MEM_TYPE 8
+
+/****************************************************************************
+** Internal constants and definitions
+****************************************************************************/
+
+/* NFC HAL receiving states */
+enum {
+ NFC_HAL_RCV_IDLE_ST, /* waiting for packet type byte */
+ NFC_HAL_RCV_NCI_MSG_ST, /* waiting for the first byte of NCI header */
+ NFC_HAL_RCV_NCI_HDR_ST, /* reading NCI header */
+ NFC_HAL_RCV_NCI_PAYLOAD_ST, /* reading NCI payload */
+ NFC_HAL_RCV_BT_MSG_ST, /* waiting for the first byte of BT header */
+ NFC_HAL_RCV_BT_HDR_ST, /* reading BT HCI header */
+ NFC_HAL_RCV_BT_PAYLOAD_ST /* reading BT HCI payload */
+};
+
+/* errors during NCI packet reassembly process */
+#define NFC_HAL_NCI_RAS_TOO_BIG 0x01
+#define NFC_HAL_NCI_RAS_ERROR 0x02
+typedef uint8_t tNFC_HAL_NCI_RAS;
+
+/* NFC HAL power mode */
+enum {
+ NFC_HAL_POWER_MODE_FULL, /* NFCC is full power mode */
+ NFC_HAL_POWER_MODE_LAST
+};
+typedef uint8_t tNFC_HAL_POWER_MODE;
+
+/* NFC HAL event for low power mode */
+enum {
+ NFC_HAL_LP_TX_DATA_EVT, /* DH is sending data to NFCC */
+ NFC_HAL_LP_RX_DATA_EVT, /* DH received data from NFCC */
+ NFC_HAL_LP_TIMEOUT_EVT, /* Timeout */
+ NFC_HAL_LP_LAST_EVT
+};
+typedef uint8_t tNFC_HAL_LP_EVT;
+
+#define NFC_HAL_ASSERT_NFC_WAKE 0x00 /* assert NFC_WAKE */
+#define NFC_HAL_DEASSERT_NFC_WAKE 0x01 /* deassert NFC_WAKE */
+
+#define NFC_HAL_BT_HCI_CMD_HDR_SIZE 3 /* opcode (2) + length (1) */
+#define NFC_HAL_CMD_TOUT (2000) /* timeout for NCI CMD (in ms) */
+
+#define NFC_HAL_SAVED_HDR_SIZE (2)
+#define NFC_HAL_SAVED_CMD_SIZE (2)
+
+#ifndef NFC_HAL_DEBUG
+#define NFC_HAL_DEBUG TRUE
+#endif
+
+#if (NFC_HAL_DEBUG == TRUE)
+extern const char* const nfc_hal_init_state_str[];
+#define NFC_HAL_SET_INIT_STATE(state) \
+ HAL_TRACE_DEBUG3("init state: %d->%d(%s)", \
+ nfc_hal_cb.dev_cb.initializing_state, state, \
+ nfc_hal_init_state_str[state]); \
+ nfc_hal_cb.dev_cb.initializing_state = state;
+#else
+#define NFC_HAL_SET_INIT_STATE(state) \
+ nfc_hal_cb.dev_cb.initializing_state = state;
+#endif
+
+/* NFC HAL - NFCC initializing state */
+enum {
+ NFC_HAL_INIT_STATE_IDLE, /* Initialization is done */
+ NFC_HAL_INIT_STATE_W4_XTAL_SET, /* Waiting for crystal setting rsp */
+ NFC_HAL_INIT_STATE_POST_XTAL_SET, /* Waiting for reset ntf after xtal set */
+ NFC_HAL_INIT_STATE_W4_NFCC_ENABLE, /* Waiting for reset ntf atter REG_PU up */
+ NFC_HAL_INIT_STATE_W4_BUILD_INFO, /* Waiting for build info rsp */
+ NFC_HAL_INIT_STATE_W4_PATCH_INFO, /* Waiting for patch info rsp */
+ NFC_HAL_INIT_STATE_W4_APP_COMPLETE, /* Waiting for complete from application
+ */
+ NFC_HAL_INIT_STATE_W4_POST_INIT_DONE, /* Waiting for complete of post init */
+ NFC_HAL_INIT_STATE_W4_CONTROL_DONE, /* Waiting for control release */
+ NFC_HAL_INIT_STATE_W4_PREDISCOVER_DONE, /* Waiting for complete of prediscover
+ */
+ NFC_HAL_INIT_STATE_W4_NFCC_TURN_OFF, /* Waiting for NFCC to turn OFF */
+ NFC_HAL_INIT_STATE_CLOSING /* Shutting down */
+};
+typedef uint8_t tNFC_HAL_INIT_STATE;
+
+/* NFC HAL - NFCC config items during post initialization */
+enum {
+ NFC_HAL_DM_CONFIG_LPTD,
+ NFC_HAL_DM_CONFIG_PLL_325,
+ NFC_HAL_DM_CONFIG_START_UP,
+ NFC_HAL_DM_CONFIG_I93_DATA_RATE,
+ NFC_HAL_DM_CONFIG_FW_FSM,
+ NFC_HAL_DM_CONFIG_START_UP_VSC,
+ NFC_HAL_DM_CONFIG_NONE
+};
+typedef uint8_t tNFC_HAL_DM_CONFIG;
+
+/* callback function prototype */
+typedef struct {
+ uint16_t opcode;
+ uint16_t param_len;
+ uint8_t* p_param_buf;
+} tNFC_HAL_BTVSC_CPLT;
+
+typedef void(tNFC_HAL_BTVSC_CPLT_CBACK)(tNFC_HAL_BTVSC_CPLT* p1);
+
+#if (NFC_HAL_HCI_INCLUDED == TRUE)
+
+/* data type for NFC_HAL_HCI_RSP_NV_READ_EVT */
+typedef struct {
+ NFC_HDR hdr;
+ uint8_t block;
+ uint16_t size;
+ tHAL_NFC_STATUS status;
+} tNFC_HAL_HCI_RSP_NV_READ_EVT;
+
+/* data type for NFC_HAL_HCI_RSP_NV_WRITE_EVT */
+typedef struct {
+ NFC_HDR hdr;
+ tHAL_NFC_STATUS status;
+} tNFC_HAL_HCI_RSP_NV_WRITE_EVT;
+
+/* union of all event data types */
+typedef union {
+ NFC_HDR hdr;
+ /* Internal events */
+ tNFC_HAL_HCI_RSP_NV_READ_EVT nv_read;
+ tNFC_HAL_HCI_RSP_NV_WRITE_EVT nv_write;
+} tNFC_HAL_HCI_EVENT_DATA;
+
+#endif
+/*****************************************************************************
+** Control block for NFC HAL
+*****************************************************************************/
+
+/* Patch RAM Download Control block */
+
+/* PRM states */
+enum {
+ NFC_HAL_PRM_ST_IDLE,
+
+ /* Secure patch download stated */
+ NFC_HAL_PRM_ST_SPD_COMPARE_VERSION,
+ NFC_HAL_PRM_ST_SPD_GET_PATCH_HEADER,
+ NFC_HAL_PRM_ST_SPD_DOWNLOADING,
+ NFC_HAL_PRM_ST_SPD_AUTHENTICATING,
+ NFC_HAL_PRM_ST_SPD_AUTH_DONE,
+ NFC_HAL_PRM_ST_W4_GET_VERSION
+};
+typedef uint8_t tNFC_HAL_PRM_STATE;
+
+/* Maximum number of patches (currently 2: LPM and FPM) */
+#define NFC_HAL_PRM_MAX_PATCH_COUNT 2
+#define NFC_HAL_PRM_PATCH_MASK_ALL 0xFFFFFFFF
+#define NFC_HAL_PRM_MAX_CHIP_VER_LEN 8
+
+/* Structures for PRM Control Block */
+typedef struct {
+ uint8_t power_mode;
+ uint16_t len;
+} tNFC_HAL_PRM_PATCHDESC;
+
+typedef struct {
+ tNFC_HAL_PRM_STATE state; /* download state */
+ uint32_t flags; /* internal flags */
+ uint16_t
+ cur_patch_len_remaining; /* bytes remaining in patchfile to process */
+ const uint8_t*
+ p_cur_patch_data; /* pointer to patch currently being downloaded */
+ uint16_t cur_patch_offset; /* offset of next byte to process */
+ uint32_t dest_ram;
+ TIMER_LIST_ENT timer; /* Timer for patch download */
+ void* p_param; /* general purpose param for PRM */
+ uint8_t param_idx; /* information related to general purpose param*/
+
+ /* Secure Patch Download */
+ uint32_t
+ spd_patch_needed_mask; /* Mask of patches that need to be downloaded */
+ uint8_t spd_patch_count; /* Number of patches left to download */
+ uint8_t spd_cur_patch_idx; /* Current patch being downloaded */
+
+ tNFC_HAL_PRM_PATCHDESC spd_patch_desc[NFC_HAL_PRM_MAX_PATCH_COUNT];
+
+ /* I2C-patch */
+ uint8_t* p_spd_patch; /* pointer to spd patch */
+ uint16_t spd_patch_len_remaining; /* patch length */
+ uint16_t spd_patch_offset; /* offset of next byte to process */
+
+ tNFC_HAL_PRM_FORMAT format; /* format of patch ram */
+ tNFC_HAL_PRM_CBACK* p_cback; /* Callback for download status notifications */
+ uint32_t patchram_delay; /* the dealy after patch */
+} tNFC_HAL_PRM_CB;
+
+/* Information about current patch in NVM */
+typedef struct {
+ uint16_t project_id; /* Current project_id of patch in nvm */
+ uint16_t ver_major; /* Current major version of patch in nvm */
+ uint16_t ver_minor; /* Current minor version of patch in nvm */
+ uint16_t fpm_size; /* Current size of FPM patch in nvm */
+ uint16_t lpm_size; /* Current size of LPM patch in nvm */
+ uint8_t flags; /* See NFC_HAL_NVM_FLAGS_* flag definitions */
+ uint8_t nvm_type; /* Current NVM Type - UICC/EEPROM */
+ uint8_t chip_ver[NFC_HAL_PRM_MAX_CHIP_VER_LEN]; /* patch chip version */
+} tNFC_HAL_NVM;
+
+/* Patch for I2C fix */
+typedef struct {
+ uint8_t* p_patch; /* patch for i2c fix */
+ uint32_t prei2c_delay; /* the dealy after preI2C patch */
+ uint16_t len; /* i2c patch length */
+} tNFC_HAL_PRM_I2C_FIX_CB;
+
+/* Control block for NCI transport */
+typedef struct {
+ uint8_t nci_ctrl_size; /* Max size for NCI messages */
+ uint8_t rcv_state; /* current rx state */
+ uint16_t rcv_len; /* bytes remaining to be received in current rx state */
+ NFC_HDR* p_rcv_msg; /* buffer to receive NCI message */
+ NFC_HDR* p_frag_msg; /* fragmented NCI message; waiting for last fragment */
+ NFC_HDR*
+ p_pend_cmd; /* pending NCI message; waiting for NFCC state to be free */
+ tNFC_HAL_NCI_RAS nci_ras; /* nci reassembly error status */
+ TIMER_LIST_ENT
+ nci_wait_rsp_timer; /* Timer for waiting for nci command response */
+ tNFC_HAL_WAIT_RSP nci_wait_rsp; /* nci wait response flag */
+ uint8_t
+ last_hdr[NFC_HAL_SAVED_HDR_SIZE]; /* part of last NCI command header */
+ uint8_t
+ last_cmd[NFC_HAL_SAVED_CMD_SIZE]; /* part of last NCI command payload */
+ void* p_vsc_cback; /* the callback function for last VSC command */
+} tNFC_HAL_NCIT_CB;
+
+/* Control block for device initialization */
+typedef struct {
+ tNFC_HAL_INIT_STATE initializing_state; /* state of initializing NFCC */
+
+ uint32_t brcm_hw_id; /* BRCM NFCC HW ID */
+ tNFC_HAL_DM_CONFIG next_dm_config; /* next config in post initialization */
+ uint8_t next_startup_vsc; /* next start-up VSC offset in post init */
+
+ tNFC_HAL_POWER_MODE power_mode; /* NFCC power mode */
+ uint8_t snooze_mode; /* current snooze mode */
+ uint8_t new_snooze_mode; /* next snooze mode after receiving cmpl */
+ uint8_t nfc_wake_active_mode; /* NFC_HAL_LP_ACTIVE_LOW/HIGH */
+ TIMER_LIST_ENT lp_timer; /* timer for low power mode */
+
+ tHAL_NFC_STATUS_CBACK*
+ p_prop_cback; /* callback to notify complete of proprietary update */
+} tNFC_HAL_DEV_CB;
+
+#if (NFC_HAL_HCI_INCLUDED == TRUE)
+
+/* data members for NFC_HAL-HCI */
+typedef struct {
+ TIMER_LIST_ENT
+ hci_timer; /* Timer to avoid indefinitely waiting for response */
+ uint8_t*
+ p_hci_netwk_info_buf; /* Buffer for reading HCI Network information */
+ uint8_t* p_hci_netwk_dh_info_buf; /* Buffer for reading HCI Network DH
+ information */
+ uint8_t hci_netwk_config_block; /* Rsp awaiting for hci network configuration
+ block */
+ bool b_wait_hcp_conn_create_rsp; /* Waiting for hcp connection create response
+ */
+ bool clear_all_pipes_to_uicc1; /* UICC1 was restarted for patch download */
+ bool update_session_id; /* Next response from NFCC is to Get Session id cmd */
+ bool hci_fw_workaround; /* HAL HCI Workaround need */
+ bool hci_fw_validate_netwk_cmd; /* Flag to indicate if hci network ntf to
+ validate */
+ uint8_t hcp_conn_id; /* NCI Connection id for HCP */
+ uint8_t dh_session_id[1]; /* Byte 0 of DH Session ID */
+} tNFC_HAL_HCI_CB;
+
+#endif
+
+#define NFC_HAL_FLAGS_NEED_DISABLE_VSC 0x01
+typedef uint8_t tNFC_HAL_FLAGS;
+
+typedef struct {
+ tHAL_NFC_CBACK* p_stack_cback; /* Callback for HAL event notification */
+ tHAL_NFC_DATA_CBACK* p_data_cback; /* Callback for data event notification */
+
+ TIMER_LIST_Q quick_timer_queue; /* timer list queue */
+ TIMER_LIST_ENT timer; /* timer for NCI transport task */
+
+ tNFC_HAL_NCIT_CB ncit_cb; /* NCI transport */
+ tNFC_HAL_DEV_CB dev_cb; /* device initialization */
+ tNFC_HAL_NVM nvm_cb; /* Information about current patch in NVM */
+
+ /* Patchram control block */
+ tNFC_HAL_PRM_CB prm;
+ tNFC_HAL_PRM_I2C_FIX_CB prm_i2c;
+
+#if (NFC_HAL_HCI_INCLUDED == TRUE)
+ /* data members for NFC_HAL-HCI */
+ tNFC_HAL_HCI_CB hci_cb;
+#endif
+
+ uint8_t pre_discover_done; /* TRUE, when the prediscover config is complete */
+ tNFC_HAL_FLAGS hal_flags;
+ uint8_t pre_set_mem_idx;
+
+ uint8_t max_rf_credits; /* NFC Max RF data credits */
+ uint8_t max_ee; /* NFC Max number of NFCEE supported by NFCC */
+ uint8_t trace_level; /* NFC HAL trace level */
+} tNFC_HAL_CB;
+
+/* Global NCI data */
+extern tNFC_HAL_CB nfc_hal_cb;
+
+extern uint8_t* p_nfc_hal_pre_discover_cfg;
+
+/****************************************************************************
+** Internal nfc functions
+****************************************************************************/
+
+/* From nfc_hal_main.c */
+uint32_t nfc_hal_main_task(uint32_t param);
+void nfc_hal_main_init(void);
+void nfc_hal_main_close(void);
+void nfc_hal_main_pre_init_done(tHAL_NFC_STATUS);
+void nfc_hal_main_exit_op_done(tNFC_HAL_NCI_EVT event, uint16_t data_len,
+ uint8_t* p_data);
+void nfc_hal_main_start_quick_timer(TIMER_LIST_ENT* p_tle, uint16_t type,
+ uint32_t timeout);
+void nfc_hal_main_stop_quick_timer(TIMER_LIST_ENT* p_tle);
+void nfc_hal_main_send_error(tHAL_NFC_STATUS status);
+void nfc_hal_send_nci_msg_to_nfc_task(NFC_HDR* p_msg);
+
+/* nfc_hal_nci.c */
+bool nfc_hal_nci_receive_msg(uint8_t byte);
+bool nfc_hal_nci_preproc_rx_nci_msg(NFC_HDR* p_msg);
+NFC_HDR* nfc_hal_nci_postproc_rx_nci_msg(void);
+void nfc_hal_nci_assemble_nci_msg(void);
+void nfc_hal_nci_add_nfc_pkt_type(NFC_HDR* p_msg);
+void nfc_hal_nci_send_cmd(NFC_HDR* p_buf);
+void nfc_hal_nci_cmd_timeout_cback(void* p_tle);
+
+/* nfc_hal_dm.c */
+void nfc_hal_dm_init(void);
+void nfc_hal_dm_set_xtal_freq_index(void);
+void nfc_hal_dm_set_power_level_zero(void);
+void nfc_hal_dm_send_get_build_info_cmd(void);
+void nfc_hal_dm_proc_msg_during_init(NFC_HDR* p_msg);
+void nfc_hal_dm_proc_msg_during_exit(NFC_HDR* p_msg);
+void nfc_hal_dm_config_nfcc(void);
+void nfc_hal_dm_send_nci_cmd(const uint8_t* p_data, uint16_t len,
+ tNFC_HAL_NCI_CBACK* p_cback);
+void nfc_hal_dm_send_bt_cmd(const uint8_t* p_data, uint16_t len,
+ tNFC_HAL_BTVSC_CPLT_CBACK* p_cback);
+void nfc_hal_dm_set_nfc_wake(uint8_t cmd);
+void nfc_hal_dm_pre_init_nfcc(void);
+void nfc_hal_dm_shutting_down_nfcc(void);
+bool nfc_hal_dm_power_mode_execute(tNFC_HAL_LP_EVT event);
+void nfc_hal_dm_send_pend_cmd(void);
+tHAL_NFC_STATUS nfc_hal_dm_set_config(uint8_t tlv_size, uint8_t* p_param_tlvs,
+ tNFC_HAL_NCI_CBACK* p_cback);
+bool nfc_hal_dm_check_pre_set_mem(void);
+tNFC_HAL_NCI_CBACK* nfc_hal_dm_got_vs_rsp(void);
+
+/* nfc_hal_prm.c */
+void nfc_hal_prm_spd_reset_ntf(uint8_t reset_reason, uint8_t reset_type);
+void nfc_hal_prm_nci_command_complete_cback(tNFC_HAL_NCI_EVT event,
+ uint16_t data_len, uint8_t* p_data);
+void nfc_hal_prm_process_timeout(void* p_tle);
+
+#if (NFC_HAL_HCI_INCLUDED == TRUE)
+/* nfc_hal_hci.c */
+void nfc_hal_hci_enable(void);
+void nfc_hal_hci_evt_hdlr(tNFC_HAL_HCI_EVENT_DATA* p_evt_data);
+void nfc_hal_hci_handle_hci_netwk_info(uint8_t* p_data);
+void nfc_hal_hci_handle_hcp_pkt_from_hc(uint8_t* p_data);
+NFC_HDR* nfc_hal_hci_postproc_hcp(void);
+bool nfc_hal_hci_handle_hcp_pkt_to_hc(uint8_t* p_data);
+void nfc_hal_hci_timeout_cback(void* p_tle);
+void nfc_hal_hci_handle_build_info(uint8_t chipverlen, uint8_t* p_chipverstr);
+#else
+#define nfc_hal_hci_enable() NFC_HAL_SET_INIT_STATE(NFC_HAL_INIT_STATE_IDLE);
+#define nfc_hal_hci_handle_build_info(p, a)
+#define nfc_hal_hci_evt_hdlr(p) ;
+#endif
+
+/* Define default NCI protocol trace function (if protocol tracing is enabled)
+ */
+#if (NFC_HAL_TRACE_PROTOCOL == TRUE)
+#if !defined(DISP_NCI)
+#define DISP_NCI (DispNci)
+void DispNci(uint8_t* p, uint16_t len, bool is_recv);
+#endif /* DISP_NCI */
+
+/* For displaying vendor-specific HCI commands */
+void DispHciCmd(NFC_HDR* p_buf);
+void DispHciEvt(NFC_HDR* p_buf);
+#endif /* NFC_HAL_TRACE_PROTOCOL */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NFC_HAL_INT_H */
diff --git a/halimpl/bcm2079x/hal/int/nfc_hal_int_api.h b/halimpl/bcm2079x/hal/int/nfc_hal_int_api.h
new file mode 100644
index 0000000..ffaf81a
--- /dev/null
+++ b/halimpl/bcm2079x/hal/int/nfc_hal_int_api.h
@@ -0,0 +1,307 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2009-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * Internal NFC HAL API functions.
+ *
+ ******************************************************************************/
+#ifndef NFC_HAL_INT_API_H
+#define NFC_HAL_INT_API_H
+
+/****************************************************************************
+** Device Configuration definitions
+****************************************************************************/
+
+#define NFC_HAL_PLL_325_SETCONFIG_PARAM_LEN (2 + NCI_PARAM_LEN_PLL325_CFG_PARAM)
+
+/* Crystal Frequency Index (in 1 KHz) */
+enum {
+ NFC_HAL_XTAL_INDEX_9600,
+ NFC_HAL_XTAL_INDEX_13000,
+ NFC_HAL_XTAL_INDEX_16200,
+ NFC_HAL_XTAL_INDEX_19200,
+ NFC_HAL_XTAL_INDEX_24000,
+ NFC_HAL_XTAL_INDEX_26000,
+ NFC_HAL_XTAL_INDEX_38400,
+ NFC_HAL_XTAL_INDEX_52000,
+ NFC_HAL_XTAL_INDEX_37400,
+ NFC_HAL_XTAL_INDEX_MAX,
+ NFC_HAL_XTAL_INDEX_SPECIAL = 0xFF
+};
+typedef uint8_t tNFC_HAL_XTAL_INDEX;
+
+/* Broadcom specific device initialization before sending NCI reset */
+
+typedef struct {
+ uint32_t brcm_hw_id;
+ uint16_t xtal_freq;
+ uint8_t xtal_index;
+} tNFC_HAL_DEV_INIT_XTAL_CFG;
+
+#define NFC_HAL_DEV_INIT_MAX_XTAL_CFG 5
+
+typedef struct {
+ uint8_t num_xtal_cfg;
+ tNFC_HAL_DEV_INIT_XTAL_CFG xtal_cfg[NFC_HAL_DEV_INIT_MAX_XTAL_CFG];
+} tNFC_HAL_DEV_INIT_CFG;
+
+/*****************************************************************************
+** Low Power Mode definitions
+*****************************************************************************/
+
+/* Snooze mode disabled */
+#define NFC_HAL_LP_SNOOZE_MODE_NONE NFC_SNOOZE_MODE_NONE
+/* Snooze mode for UART */
+#define NFC_HAL_LP_SNOOZE_MODE_UART NFC_SNOOZE_MODE_UART
+/* Snooze mode for SPI/I2C */
+#define NFC_HAL_LP_SNOOZE_MODE_SPI_I2C NFC_SNOOZE_MODE_SPI_I2C
+
+/* high to low voltage is asserting */
+#define NFC_HAL_LP_ACTIVE_LOW NFC_SNOOZE_ACTIVE_LOW
+/* low to high voltage is asserting */
+#define NFC_HAL_LP_ACTIVE_HIGH NFC_SNOOZE_ACTIVE_HIGH
+
+/*****************************************************************************
+** Patch RAM Constants
+*****************************************************************************/
+
+/* patch format type */
+#define NFC_HAL_PRM_FORMAT_BIN 0x00
+#define NFC_HAL_PRM_FORMAT_HCD 0x01
+#define NFC_HAL_PRM_FORMAT_NCD 0x02
+typedef uint8_t tNFC_HAL_PRM_FORMAT;
+
+/*****************************************************************************
+** Patch RAM Callback for event notificaton
+*****************************************************************************/
+/* Events for tNFC_HAL_PRM_CBACK */
+enum {
+ NFC_HAL_PRM_CONTINUE_EVT,
+ NFC_HAL_PRM_COMPLETE_EVT,
+ NFC_HAL_PRM_ABORT_EVT,
+ NFC_HAL_PRM_ABORT_INVALID_PATCH_EVT, /* Patch is invalid (bad version, project
+ id, or chip) */
+ NFC_HAL_PRM_ABORT_BAD_SIGNATURE_EVT, /* Patch has invalid signature */
+ NFC_HAL_PRM_SPD_GET_PATCHFILE_HDR_EVT, /* Secure Patch Download: request for
+ patchfile header */
+ NFC_HAL_PRM_SPD_GET_NEXT_PATCH, /* Get first command of next patch in
+ patchfile */
+ NFC_HAL_PRM_ABORT_NO_NVM_EVT /* nfc_hal_prm_nvm_required is TRUE and NVM is
+ unavail */
+};
+
+typedef void(tNFC_HAL_PRM_CBACK)(uint8_t event);
+
+typedef uint8_t tNFC_HAL_NCI_EVT; /* MT + Opcode */
+typedef void(tNFC_HAL_NCI_CBACK)(tNFC_HAL_NCI_EVT event, uint16_t data_len,
+ uint8_t* p_data);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************
+**
+** Function HAL_NfcPreInitDone
+**
+** Description Notify that pre-initialization of NFCC is complete
+**
+** Returns void
+**
+*******************************************************************************/
+void HAL_NfcPreInitDone(tHAL_NFC_STATUS status);
+
+/*******************************************************************************
+**
+** Function HAL_NfcReInit
+**
+** Description This function is called to restart initialization after
+** REG_PU toggled because of failure to detect NVM type or
+** download patchram.
+**
+** Note This function should be called only during the HAL init
+** process
+**
+** Returns HAL_NFC_STATUS_OK if successfully initiated
+** HAL_NFC_STATUS_FAILED otherwise
+**
+*******************************************************************************/
+tHAL_NFC_STATUS HAL_NfcReInit(void);
+
+/*******************************************************************************
+**
+** Function HAL_NfcSetSnoozeMode
+**
+** Description Set snooze mode
+** snooze_mode
+** NFC_HAL_LP_SNOOZE_MODE_NONE - Snooze mode disabled
+** NFC_HAL_LP_SNOOZE_MODE_UART - Snooze mode for UART
+** NFC_HAL_LP_SNOOZE_MODE_SPI_I2C - Snooze mode for SPI/I2C
+**
+** idle_threshold_dh/idle_threshold_nfcc
+** Idle Threshold Host in 100ms unit
+**
+** nfc_wake_active_mode/dh_wake_active_mode
+** NFC_HAL_LP_ACTIVE_LOW - high to low voltage is asserting
+** NFC_HAL_LP_ACTIVE_HIGH - low to high voltage is
+** asserting
+**
+** p_snooze_cback
+** Notify status of operation
+**
+** Returns tHAL_NFC_STATUS
+**
+*******************************************************************************/
+tHAL_NFC_STATUS HAL_NfcSetSnoozeMode(uint8_t snooze_mode,
+ uint8_t idle_threshold_dh,
+ uint8_t idle_threshold_nfcc,
+ uint8_t nfc_wake_active_mode,
+ uint8_t dh_wake_active_mode,
+ tHAL_NFC_STATUS_CBACK* p_snooze_cback);
+
+/*******************************************************************************
+**
+** Function HAL_NfcPrmDownloadStart
+**
+** Description Initiate patch download
+**
+** Input Params
+** format_type patch format type
+** (NFC_HAL_PRM_FORMAT_BIN,
+** NFC_HAL_PRM_FORMAT_HCD, or
+** NFC_HAL_PRM_FORMAT_NCD)
+**
+** dest_address destination adderess (needed for BIN format
+** only)
+**
+** p_patchram_buf pointer to patchram buffer. If NULL, then
+** app must call HAL_NfcPrmDownloadContinue
+** when NFC_HAL_PRM_CONTINUE_EVT is received,
+** to send the next segment of patchram
+**
+** patchram_len size of p_patchram_buf (if non-NULL)
+**
+** patchram_delay The delay after each patch.
+** If the given value is less than the size of
+** the patchram, the size of patchram is used
+** instead.
+**
+** p_cback callback for download status
+**
+**
+** Returns TRUE if successful, otherwise FALSE
+**
+**
+*******************************************************************************/
+bool HAL_NfcPrmDownloadStart(tNFC_HAL_PRM_FORMAT format_type,
+ uint32_t dest_address, uint8_t* p_patchram_buf,
+ uint32_t patchram_len, uint32_t patchram_delay,
+ tNFC_HAL_PRM_CBACK* p_cback);
+
+/*******************************************************************************
+**
+** Function HAL_NfcPrmDownloadContinue
+**
+** Description Send next segment of patchram to controller. Called when
+** NFC_HAL_PRM_CONTINUE_EVT is received.
+**
+** Only needed if HAL_NfcPrmDownloadStart was called with
+** p_patchram_buf=NULL
+**
+** Input Params p_patch_data pointer to patch data
+** patch_data_len patch data len
+**
+** Returns TRUE if successful, otherwise FALSE
+**
+*******************************************************************************/
+bool HAL_NfcPrmDownloadContinue(uint8_t* p_patch_data, uint16_t patch_data_len);
+
+/*******************************************************************************
+**
+** Function HAL_NfcPrmSetI2cPatch
+**
+** Description Specify patchfile for BCM20791B3 I2C fix. This fix
+** must be downloaded prior to initial patch download for I2C
+** transport
+**
+** Input Params p_i2c_patchfile_buf: pointer to patch for i2c fix
+** i2c_patchfile_len: length of patch
+** prei2c_delay: the delay before downloading main patch
+** if 0 is given, NFC_HAL_PRM_POST_I2C_FIX_DELAY
+** is used instead.
+**
+** Returns Nothing
+**
+**
+*******************************************************************************/
+void HAL_NfcPrmSetI2cPatch(uint8_t* p_i2c_patchfile_buf,
+ uint16_t i2c_patchfile_len, uint32_t prei2c_delay);
+
+/*******************************************************************************
+**
+** Function HAL_NfcPrmSetSpdNciCmdPayloadSize
+**
+** Description Set Host-to-NFCC NCI message size for secure patch download
+**
+** This API must be called before calling
+** HAL_NfcPrmDownloadStart. If the API is not called, then PRM
+** will use the default message size.
+**
+** Typically, this API is only called for platforms that have
+** message-size limitations in the transport/driver.
+**
+** Valid message size range:
+** NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE to 255.
+**
+** Returns HAL_NFC_STATUS_OK if successful
+** HAL_NFC_STATUS_FAILED otherwise
+**
+**
+*******************************************************************************/
+tHAL_NFC_STATUS HAL_NfcPrmSetSpdNciCmdPayloadSize(uint8_t max_payload_size);
+
+/*******************************************************************************
+**
+** Function HAL_NfcSetMaxRfDataCredits
+**
+** Description This function sets the maximum RF data credit for HAL.
+** If 0, use the value reported from NFCC.
+**
+** Returns none
+**
+*******************************************************************************/
+void HAL_NfcSetMaxRfDataCredits(uint8_t max_credits);
+
+/*******************************************************************************
+**
+** Function HAL_NfcSetTraceLevel
+**
+** Description This function sets the trace level for HAL. If called with
+** a value of 0xFF, it simply returns the current trace level.
+**
+** Returns The new or current trace level
+**
+*******************************************************************************/
+uint8_t HAL_NfcSetTraceLevel(uint8_t new_level);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NFC_HAL_INT_API_H */
diff --git a/halimpl/bcm2079x/hal/int/nfc_hal_nv_ci.h b/halimpl/bcm2079x/hal/int/nfc_hal_nv_ci.h
new file mode 100644
index 0000000..0a98edf
--- /dev/null
+++ b/halimpl/bcm2079x/hal/int/nfc_hal_nv_ci.h
@@ -0,0 +1,90 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This is the interface file for non valtile memory call-in functions.
+ *
+ ******************************************************************************/
+#ifndef NFC_HAL_NV_CI_H
+#define NFC_HAL_NV_CI_H
+
+#include "nfc_hal_target.h"
+
+#if (NFC_HAL_HCI_INCLUDED == TRUE)
+
+#include "nfc_hal_nv_co.h"
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************
+**
+** Function nfc_hal_nv_ci_write
+**
+** Description This function sends an event to NFAA indicating the phone
+** has written the number of bytes specified in the call-out
+** function, nfa_nv_co_write (), and is ready for more data.
+** This function is used to control the TX data flow.
+** Note: The data buffer is released by the stack aioer
+** calling this function.
+**
+** Parameters status - NFA_NV_CO_OK, NFA_NV_CO_NOSPACE, or NFA_NV_CO_FAIL
+** evt - Used Internally by NFA -> MUST be same value passed
+** in call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+void nfc_hal_nv_ci_write(tNFC_HAL_NV_CO_STATUS status);
+
+/*******************************************************************************
+**
+** Function nfc_hal_nv_ci_read
+**
+** Description This function sends an event to NCIT indicating the phone
+** has read in the requested amount of data specified in the
+** nfa_nv_co_read () call-out function. It should only be
+** called when the requested number of bytes has been read.
+**
+** Parameters num_bytes_read - number of bytes read into the buffer
+** specified in the read callout-function.
+** status - NFC_HAL_NV_CO_OK if full buffer of data,
+** NFC_HAL_NV_CO_EOF if the end of file has been
+** reached,
+** NFC_HAL_NV_CO_FAIL if an error has occurred.
+** evt - Used Internally by NFA -> MUST be same value passed
+** in call-out function.
+**
+** Returns void
+**
+*******************************************************************************/
+void nfc_hal_nv_ci_read(uint16_t num_bytes_read, tNFC_HAL_NV_CO_STATUS status,
+ uint8_t block);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NFC_HAL_HCI_INCLUDED */
+
+#endif /* NFC_HAL_NV_CI_H */
diff --git a/halimpl/bcm2079x/hal/int/nfc_hal_nv_co.h b/halimpl/bcm2079x/hal/int/nfc_hal_nv_co.h
new file mode 100644
index 0000000..2891c27
--- /dev/null
+++ b/halimpl/bcm2079x/hal/int/nfc_hal_nv_co.h
@@ -0,0 +1,115 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2003-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This is the interface file for storing nv data
+ *
+ ******************************************************************************/
+#ifndef NFC_HAL_NV_CO_H
+#define NFC_HAL_NV_CO_H
+
+#include "nfc_hal_target.h"
+
+#if (NFC_HAL_HCI_INCLUDED == TRUE)
+
+#include <time.h>
+
+/*****************************************************************************
+** Constants and Data Types
+*****************************************************************************/
+
+/**************************
+** Common Definitions
+***************************/
+
+/* Status codes returned by call-out functions, or in call-in functions as
+ * status */
+#define NFC_HAL_NV_CO_OK 0x00
+#define NFC_HAL_NV_CO_FAIL 0x01 /* Used to pass all other errors */
+#define NFC_HAL_NV_CO_EACCES 0x02
+#define NFC_HAL_NV_CO_ENOTEMPTY 0x03
+#define NFC_HAL_NV_CO_EOF 0x04
+#define NFC_HAL_NV_CO_EODIR 0x05
+/* Returned in nfa_nv_ci_open if no room */
+#define NFC_HAL_NV_CO_ENOSPACE 0x06
+#define NFC_HAL_NV_CO_EIS_DIR 0x07
+#define NFC_HAL_NV_CO_RESUME 0x08 /* used in nfa_nv_ci_open, on resume */
+/* used in nfa_nv_ci_open, on resume (no file to resume) */
+#define NFC_HAL_NV_CO_NONE 0x09
+
+typedef uint8_t tNFC_HAL_NV_CO_STATUS;
+
+#define DH_NV_BLOCK 0x01
+#define HC_F3_NV_BLOCK 0x02
+#define HC_F4_NV_BLOCK 0x03
+#define HC_F2_NV_BLOCK 0x04
+#define HC_F5_NV_BLOCK 0x05
+
+/*****************************************************************************
+** Function Declarations
+*****************************************************************************/
+/**************************
+** Common Functions
+***************************/
+
+/*******************************************************************************
+**
+** Function nfc_hal_nv_co_read
+**
+** Description This function is called by NFA to read in data from the
+** previously opened file.
+**
+** Parameters p_buf - buffer to read the data into.
+** nbytes - number of bytes to read into the buffer.
+**
+** Returns void
+**
+** Note: Upon completion of the request, nfa_nv_ci_read () is
+** called with the buffer of data, along with the number
+** of bytes read into the buffer, and a status. The
+** call-in function should only be called when ALL
+** requested bytes have been read, the end of file has
+** been detected, or an error has occurred.
+**
+*******************************************************************************/
+void nfc_hal_nv_co_read(uint8_t* p_buf, uint16_t nbytes, uint8_t block);
+
+/*******************************************************************************
+**
+** Function nfc_hal_nv_co_write
+**
+** Description This function is called by io to send file data to the
+** phone.
+**
+** Parameters p_buf - buffer to read the data from.
+** nbytes - number of bytes to write out to the file.
+**
+** Returns void
+**
+** Note: Upon completion of the request, nfa_nv_ci_write () is
+** called with the file descriptor and the status. The
+** call-in function should only be called when ALL
+** requested bytes have been written, or an error has
+** been detected,
+**
+*******************************************************************************/
+void nfc_hal_nv_co_write(const uint8_t* p_buf, uint16_t nbytes, uint8_t block);
+
+#endif /* NFC_HAL_HCI_INCLUDED */
+#endif /* NFC_HAL_NV_CO_H */
diff --git a/halimpl/bcm2079x/hal/int/nfc_hal_post_reset.h b/halimpl/bcm2079x/hal/int/nfc_hal_post_reset.h
new file mode 100644
index 0000000..7ce3953
--- /dev/null
+++ b/halimpl/bcm2079x/hal/int/nfc_hal_post_reset.h
@@ -0,0 +1,73 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2009-2014 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * Post NCI reset routines
+ *
+ ******************************************************************************/
+#ifndef NFC_HAL_POST_RESET_H
+#define NFC_HAL_POST_RESET_H
+
+/*****************************************************************************
+** Application control block definitions
+******************************************************************************/
+#define NFA_APP_PATCHFILE_MAX_PATH 255
+#define NFA_APP_MAX_NUM_REINIT 5
+
+typedef struct {
+ uint8_t prm_file[NFA_APP_PATCHFILE_MAX_PATH + 1]; /* Filename of patchram */
+ uint8_t* p_prm_buf; /* Pointer to buffer for holding patchram data */
+
+ /* Patchfile for I2C fix */
+ uint8_t prm_i2c_patchfile[NFA_APP_PATCHFILE_MAX_PATH + 1];
+ uint8_t* p_prm_i2c_buf;
+
+ uint8_t userial_baud;
+
+ tNFC_HAL_DEV_INIT_CFG dev_init_config;
+
+ /* snooze mode setting */
+ uint8_t snooze_mode;
+ uint8_t idle_threshold_dh;
+ uint8_t idle_threshold_nfcc;
+ uint8_t nfc_wake_active_mode;
+ uint8_t dh_wake_active_mode;
+
+ /* NVM detection retry (some platforms require re-attempts to detect NVM) */
+ uint8_t spd_nvm_detection_max_count; /* max retry to get NVM type */
+ uint8_t spd_nvm_detection_cur_count; /* current retry count */
+
+ /* handling for failure to download patch */
+ bool spd_debug_mode; /* debug mode for downloading patchram, report failure
+ immediately and obviously */
+ bool spd_skip_on_power_cycle; /* skip downloading patchram after power cycle
+ because of patch download failure */
+} tNFC_POST_RESET_CB;
+extern tNFC_POST_RESET_CB nfc_post_reset_cb;
+
+/*
+** Post NCI reset handler
+**
+** This function is called to start device pre-initialization after
+** NCI CORE-RESET. When pre-initialization is completed,
+** HAL_NfcPreInitDone() must be called to proceed with stack start up.
+*/
+void nfc_hal_post_reset_init(uint32_t brcm_hw_id, uint8_t nvm_type);
+
+#endif /* NFC_HAL_POST_RESET_H */