summaryrefslogtreecommitdiff
path: root/halimpl/include/hal_msg.h
blob: a8860536b5f4c85274d27f91bb006a5d4d30cf2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
 *    Copyright (C) 2013 SAMSUNG S.LSI
 *
 *   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_SEC_HALMSG__
#define __NFC_SEC_HALMSG__

/***************************************
 * NCI
 ***************************************/
#define HAL_EVT_SIZE 1
#define NCI_HDR_SIZE 3
#define NCI_MAX_PAYLOAD 0xFF
#define NCI_CTRL_SIZE (NCI_HDR_SIZE + NCI_MAX_PAYLOAD)

typedef struct {
  uint8_t oct0;
  uint8_t oid;
  uint8_t len;
  uint8_t payload[NCI_MAX_PAYLOAD];
} tNFC_NCI_PKT;
/* START [181106] Patch for supporting NCI v2.0 */
// [1. NCI Version Management]
#define NCI_VER_1_0 0x10
#define NCI_VER_2_0 0x20
/* END [181106] Patch for supporting NCI v2.0 */
#define NCI_MT(x) ((x)->oct0 & 0xE0)
#define NCI_PBF(x) ((x)->oct0 & 0x10)
#define NCI_GID(x) ((x)->oct0 & 0x0F)
#define NCI_OID(x) ((x)->oid & 0x3F)
#define NCI_LEN(x) ((x)->len)
#define NCI_PAYLOAD(x) ((x)->payload)
#define NCI_STATUS(x) (((x)->payload)[0])
#define NCI_MF_INFO_SIZE 4
#define NCI_MF_INFO(x) (((x)->payload) + (x)->len - NCI_MF_INFO_SIZE)
#define NCI_PKT_LEN(x) (NCI_HDR_SIZE + NCI_LEN(x))

#define NCI_MT_DATA 0x00
#define NCI_MT_CMD 0x20
#define NCI_MT_RSP 0x40
#define NCI_MT_NTF 0x60

#define NCI_PBF_LAST 0x00
#define NCI_PBF_CONTINUE 0x10

#define NCI_GID_CORE 0x00
#define NCI_GID_RF_MANAGE 0x01
#define NCI_GID_EE_MANAGE 0x02
#define NCI_GID_PROP 0x0F

#define NCI_CORE_RESET 0x00
#define NCI_CORE_INIT 0x01

#define NCI_PROP_AGAIN                                     \
  0x01 /* This prop oid is used only for N3 (sleep mode) \ \
        */
#define NCI_PROP_FW_CFG 0x28
#define NCI_PROP_WR_RESET 0x2F
#define NCI_PROP_SET_SLEEP_TIME 0x1A /* Last updated value: 20160530 */

#define SET_SLEEP_TIME_CFG 0
#define SET_SLEEP_TIME_ONCE 1
#define SET_SLEEP_TIME_FORCE 2

#define NCI_STATUS_OK 0x00
#define NCI_STATUS_E_SYNTAX 0x05

/* START [S15012201] - block flip cover in RF field */
#define HAL_NFC_STATUS_ERR_TRANSPORT 2
/* END [S15012201] - block flip cover in RF field */

/* Response Value for Clock Setting. */
#define NCI_CLOCK_STATUS_SYNTAX_ERROR 0x01
#define NCI_CLOCK_STATUS_MISMATCHED 0x02
#define NCI_CLOCK_STATUS_FULL 0x03
/***************************************
 * BOOTLOADER
 ***************************************/
#define FW_HDR_SIZE 4
typedef struct {
  uint8_t type;
  uint8_t code;
  uint16_t len;
  uint8_t payload[NCI_MAX_PAYLOAD + 1];
} tNFC_FW_PKT;
#define FW_PAYLOAD(x) ((x)->payload)

/* type */
typedef enum { FW_MSG_CMD = 0, FW_MSG_RSP, FW_MSG_DATA } eNFC_FW_BLTYPE;

/***************************************
 * HAL Message
 ***************************************/
#define MSG_EVENT_SIZE 1
typedef struct {
  uint8_t event;
  union {
    tNFC_NCI_PKT nci_packet;
    tNFC_FW_PKT fw_packet;
    uint8_t param[NCI_CTRL_SIZE];
  };
} tNFC_HAL_MSG;

#define HAL_EVT_OPEN 0x00
#define HAL_EVT_CORE_INIT 0x01
#define HAL_EVT_PRE_DISCOVER 0x02
#define HAL_EVT_WRITE 0x03
#define HAL_EVT_READ 0x04
#define HAL_EVT_CONTROL_GRANTED 0x05
#define HAL_EVT_TERMINATE 0x06
/* START - VTS */
#define HAL_EVT_POWER_CYCLE 0x07
/* END - VTS */
#define HAL_EVT_COMPLETE 0xF0
#define HAL_EVT_COMPLETE_FAILED 0xF1

/***************************************
 * NFC Message
 ***************************************/
#define NFC_STATUS_OK 0x00
#define NFC_STATUS_FAILED 0x01

#endif  //__NFC_SEC_HALMSG__