• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @file hi_mdm_types.h
3  *
4  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __HI_MDM_TYPES_H__
19 #define __HI_MDM_TYPES_H__
20 #ifndef __HI_TYPES_H__
21 #error "Please include hi_types.h before using hi_mdm_types.h"
22 #endif
23 HI_START_HEADER
24 
25 #include <hi_types_base.h>
26 
27 #define HI_ALL_F_32          0xFFFFFFFF
28 
29 typedef struct {
30     hi_u32 major_minor_version;
31     hi_u32 revision_version;
32     hi_u32 build_version;
33 } hi_ue_soft_version;
34 
35 #define HI_BUILD_VER_DATE_LEN             10
36 #define HI_BUILD_VER_TIME_LEN             8
37 #define HI_BUILD_VER_PRODUCT_NAME_LEN_MAX 28
38 #define HI_BUILD_VER_PRODUCT_LEN_MAX      (HI_BUILD_VER_PRODUCT_NAME_LEN_MAX + HI_BUILD_VER_DATE_LEN + \
39                                             HI_BUILD_VER_TIME_LEN + 6)
40 typedef struct {
41     hi_u16 version_v;
42     hi_u16 version_r;
43     hi_u16 version_c;
44     hi_u16 version_b;
45     hi_u16 version_spc;
46     hi_u16 reserved[3];  /* 3 bytes reserved */
47 } hi_ue_product_ver;
48 
49 typedef struct {
50     hi_char* build_date; /* pszDate;        // For example: 2011-08-01 */
51     hi_char* build_time; /* pszTime;        // For example: 14:30:26 */
52 } hi_product_info;
53 
54 /*
55 * @ingroup  iot_diag
56 * @brief Registers the callback function for DIAG channel status changes.
57 CNcomment:DIAG通道状态变更回调函数。CNend
58 *
59 * @par 描述:
60 *      Registers the callback function for DIAG channel status changes. That is, when the DIAG channel is
61 *      connected or disconnected, the function registered by this API is called back.
62 CNcomment:注册DIAG通道变更回调函数(即:当DIAG通道连接或断开时,会回调本接口注册的函数)。CNend
63 *
64 * @attention None。
65 * @param  port_num   [IN] type #hi_u16,port number.
66 CNcomment:端口号。CNend
67 * @param  is_connected  [IN] type #hi_bool,connection status.
68 CNcomment:连接状态。CNend
69 *
70 * @retval #0      Success.
71 * @retval #Other  Failure. For details, see hi_errno.h.
72 * @par Dependency:
73 *           @li hi_diag.h: Describes DIAG APIs.
74 CNcomment:文件用于描述DIAG相关接口。CNend
75 * @see  None
76  */
77 typedef hi_u32 (*hi_diag_connect_f)(hi_u16 port_num, hi_bool is_connected);
78 
79 /**
80 * @ingroup  iot_dms
81 *
82 * Strcture of Channel interface object.
83 CNcomment:通道接口实例结构。CNend
84 */
85 #define HI_DMS_FRM_INTER_INFO1_SIZE (sizeof(hi_u8) + sizeof(hi_u8)) /* mmt, vt */
86 #define HI_DMS_FRM_INTER_INFO2_SIZE 4                             /* 公用控制字段长度 */
87 #define HI_DMS_INTER_INFO_SIZE      (HI_DMS_FRM_INTER_INFO1_SIZE + HI_DMS_FRM_INTER_INFO2_SIZE)
88 
89 typedef struct {
90     hi_u16 data_size;                          /**< Length of data element(Unit: type).
91                                                   CNcomment: 数据大小,即ucData所占空间大小(单位:byte)CNend */
92     hi_u8 inside_info[HI_DMS_INTER_INFO_SIZE]; /**< For internal use. CNcomment:内部使用CNend */
93     hi_u8 data[0];                             /**< Data. CNcomment:数据CNend */
94 } hi_dms_chl_tx_data;
95 
96 #define HI_DMS_CHL_FRAME_HRD_SIZE (sizeof(hi_dms_chl_tx_data))
97 
98 typedef struct {
99     hi_u32 id;  /* Specify the message id. */
100     hi_u32 src_mod_id;
101     hi_u32 dest_mod_id;
102     hi_u32 data_size;  /* the data size in bytes. */
103     hi_pvoid data;     /* Pointer to the data buffer. */
104 } hi_diag_layer_msg;
105 
106 /**
107 * @ingroup  iot_diag
108 * @brief Callback function for handling diagnosis commands.
109 CNcommond:HSO命令处理回调函数。CNend
110 *
111 * @par 描述:
112 *           Callback function for handling diagnosis commands, that is, the function body for executing commands.
113 CNcomment:HSO命令处理回调函数,即命令的执行函数体。CNend
114 *
115 * @attention
116 *           @li If the returned value is not HI_ERR_CONSUMED, the DIAG framework automatically forwards
117 *               the returned value to the host. CNcomment:如果返回值不为HI_ERR_CONSUMED,
118 则表示有DIAG框架自动直接将返回值回复给HSO。CNend
119 *           @li If the return value is HI_ERR_CONSUMED, it indicates that the user sends a response (local connection)
120 *               to the host through the hi_diag_send_ack_packet API. The DIAG framework does not automatically
121 *               respond to the host. CNcomment:如果返回值为HI_ERR_CONSUMED,
122 则表示用户通过hi_diag_send_ack_packet接口给HSO应答(本地连接),DIAG框架不自动给HSO应答。CNend
123 *           @li The return value of the API cannot be HI_ERR_NOT_FOUND.
124 CNcomment:该注册接口的返回值不能为HI_ERR_NOT_FOUND。CNend
125 * @param  cmd_id          [IN] type #hi_u16,Command ID CNcomment:命令ID。CNend
126 * @param  cmd_param       [IN] type #hi_pvoid,Pointer to the use input command.
127 CNcomment:用户输入命令指针。CNend
128 * @param  cmd_param_size  [IN] type #hi_u16,Length of the command input by the user (unit:byte).
129 CNcomment:用户输入命令长度(单位:byte)。CNend
130 * @param  option          [IN] type #hi_u8,#HI_DIAG_CMD_INSTANCE_LOCAL and #HI_DIAG_CMD_INSTANCE_IREMOTE are supported.
131 CNcomment:支持使用#HI_DIAG_CMD_INSTANCE_LOCAL、#HI_DIAG_CMD_INSTANCE_IREMOTE。CNend.
132 *
133 * @retval #0              Success
134 * @retval #Other            Failure. For details, see hi_errno.h
135 * @par Dependency:
136 *           @li hi_diag.h: Describes DIAG APIs.
137 CNcomment: 文件用于描述DIAG相关接口。CNend
138 * @see  None.
139 */
140 typedef hi_u32 (*hi_diag_cmd_f)(hi_u16 cmd_id, hi_pvoid cmd_param, hi_u16 cmd_param_size, hi_u8 option);
141 /**
142 * @ingroup  iot_diag
143 * Command registration structure. The same callback function can be used within the command ID range.
144 CNcommand:命令注册结构体,支持标注命令ID范围内使用同一个回调函数。CNend.
145 *
146 * If a single command is used, the maximum and minimum IDs are the same.
147 CNcommand:如果单命令,则最大和最小填写相同ID号。CNend
148 */
149 typedef struct {
150     hi_u16 min_id;           /**< Minimum DIAG ID, [0, 65535]. CNcomment:最小的DIAG ID,取值范围[0, 65535]。 CNend */
151     hi_u16 max_id;           /**< Maximum DIAG ID, [0, 65535]. CNcomment:最大的DIAG ID,取值范围[0, 65535]。 CNend */
152     hi_diag_cmd_f input_cmd; /**< This Handler is used to process the HSO command.
153                                 CNcomment:处理HSO命令的入口函数。CNend */
154 } hi_diag_cmd_reg_obj;
155 
156 /**
157  * @ingroup  iot_diag
158  * Local instance  -->HSO  Interaction command between the host software and the local station.
159  CNcomment:本地实例  -->HSO  表示上位机软件和本地站点间的交互命令 CNend
160  */
161 #define HI_DIAG_CMD_INSTANCE_DEFAULT ((hi_u8)0)
162 
163 /**
164  * @ingroup  iot_diag
165  * Local instance  -->HSO  Interaction command between the host software and the local station.
166  CNcomment: 本地实例  -->HSO  表示上位机软件和本地站点间的交互命令 CNend
167  */
168 #define HI_DIAG_CMD_INSTANCE_LOCAL   HI_DIAG_CMD_INSTANCE_DEFAULT /* Local CMD.CNcomment:本地命令 CNend */
169 #define HI_DIAG_CMD_INSTANCE_IREMOTE 1 /* Remote CMD.CNcomment:远程命令 CNend */
170 
171 #if defined(HAVE_PCLINT_CHECK)
172 #define hi_check_default_id(id) (id)
173 #else
174 #define hi_check_default_id(id) (((id) == 0) ? __LINE__ : (id))
175 #endif
176 #define hi_diag_log_msg_mk_id_e(id) hi_makeu32(((((hi_u16)(hi_check_default_id(id))) << 2) + 0), \
177     HI_DIAG_LOG_MSG_FILE_ID)
178 #define hi_diag_log_msg_mk_id_w(id) hi_makeu32(((((hi_u16)(hi_check_default_id(id))) << 2) + 1), \
179     HI_DIAG_LOG_MSG_FILE_ID)
180 #define hi_diag_log_msg_mk_id_i(id) hi_makeu32(((((hi_u16)(hi_check_default_id(id))) << 2) + 2), \
181     HI_DIAG_LOG_MSG_FILE_ID)
182 
183 #define HI_ND_SYS_BOOT_CAUSE_NORMAL        0x0
184 #define HI_ND_SYS_BOOT_CAUSE_EXP           0x1
185 #define HI_ND_SYS_BOOT_CAUSE_WD            0x2
186 #define HI_ND_SYS_BOOT_CAUSE_UPG_VERIFY    0x3
187 #define HI_ND_SYS_BOOT_CAUSE_UPG_FAIL      0x4
188 #define HI_ND_SYS_BOOT_CAUSE_UPG_BACK_FAIL 0x5
189 
190 #define CHANLLENGE_SALT_SIZE 16
191 /******************************DIAG***********************************************/
192 #define HI_DIAG_LOG_OPT_LOCAL_REQ           1 /**< Local command request from the host to DIAG.
193                                                  CNcomment:本地命令请求 上位机->DIAG CNend */
194 #define HI_DIAG_LOG_OPT_LOCAL_IND           2 /**< local response from DIAG to the host.
195                                                  CNcomment: 本地应答 DIAG ->上位机 CNend */
196 #define HI_DIAG_LOG_OPT_LOCAL_ACK           3 /**< Local ACK from DIAG to the host.
197                                                  CNcomment: 本地ACK DIAG ->上位机 CNend */
198 
199 /**
200  * @ingroup  iot_diag
201  * Describes the command type transferred to the app layer.
202  CNcomment: 描述传递给应用层的命令类型。CNend
203  */
204 typedef struct {
205     /**< Option configuration, which is used to set the command as a local command or a remote
206        * command. The value is a HI_DIAG_LOG_OPT_XXX macro such as #HI_DIAG_LOG_OPT_LOCAL_REQ.
207        CNcomment: 选项配置,用于设置此命令为本地命令或远程命令等信息,
208        取值为HI_DIAG_LOG_OPT_XXX 宏 CNend */
209     hi_u32 opt;
210 } hi_diag_log_ctrl;
211 
212 /**
213 * @ingroup  iot_diag
214 * @brief  Callback function for notifying DIAG operations.
215 CNcomment:DIAG操作通知回调函数。CNend
216 *
217 * @par 描述:
218 *          Carbon copies data to the app layer by using a callback function in
219 *          the case of data interaction between the host and the board.
220 CNcomment: 该函数用于当HSO与单板有数据交互发生时,将数据通过回调函数抄送给应用层。CNend
221 *
222 * @attention 无。
223 * @param  cmd_id       [IN] type #hi_u32,Command ID. CNcomend:命令ID。CNend
224 * @param  buffer       [IN] type #hi_pvoid,Data pointer transferred to the app layer.
225 CNcomment:传递给应用层的数据指针。CNend
226 * @param  buffer_size  [IN] type #hi_u16,Length of the data transferred to the app layer (unit: byte)
227 CNcomment:传递给应用层的数据长度(单位:byte)。CNend
228 * @param  log_ctrl     [IN] type #hi_diag_log_ctrl*,Command type sent to the app layer
229 CNcomment:传递给应用层的命令类型。CNend
230 *
231 * @retval #0             Success
232 * @retval #Other         Failure. For details, see hi_errno.h.
233 * @par Dependency:
234 *           @li hi_diag.h:Describes DIAG APIs. CNcomment:文件用于描述DIAG相关接口。CNend
235 * @see  None
236  */
237 typedef hi_void (*hi_diag_cmd_notify_f)(hi_u16 cmd_id, hi_pvoid buffer, hi_u16 buffer_size,
238                                         hi_diag_log_ctrl *log_ctrl);
239 HI_END_HEADER
240 #endif  /* __HI_MDM_TYPES_H__ */
241