• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description:  LOG oam message recv MODULE
15  * Author:
16  * Create:
17  */
18 
19 #ifndef LOG_OAM_MSG_H
20 #define LOG_OAM_MSG_H
21 
22 #include "product.h"
23 #include "chip_definitions.h"
24 #include "chip_core_definition.h"
25 /**
26  * @defgroup connectivity_libs_log_reader LOG Reader
27  * @ingroup  connectivity_libs
28  * @{
29  */
30 #if SYS_DEBUG_MODE_ENABLE == YES
31 
32 #ifndef LIB_LOG_READER_LOG_OAM_MSG_H
33 #define LIB_LOG_READER_LOG_OAM_MSG_H
34 #include "string.h"
35 #ifdef SUPPORT_IPC
36 #include "ipc.h"
37 #endif
38 #if CORE != GNSS
39 #include "uart.h"
40 #endif
41 
42 #define LOG_OML_HEADER_PRIME_ID_MASK  (0x0F)
43 #ifdef USE_GPIO_SIMULATE_SSI
44 #define LOG_OAM_RX_BUFF_LEN           (0x420)
45 #else
46 #define LOG_OAM_RX_BUFF_LEN           (300)
47 #endif
48 #define LOG_OAM_RX_BUFF_NUM           (2)
49 #define REGMEM_ADDR_AND_VALUE_MAX_LEN (2)
50 
51 /**
52  * @brief  Definitions of the operation result
53  */
54 typedef enum {
55     OAM_RET_OK,          // !< operation successful.
56     OAM_ERR_POINT_NULL,  // !< operation fail as point to NULL.
57     OAM_ERR_LEN_ERR,     // !< operation fail as the len is error.
58     OAM_ERR_OP_ERR,      // !< operation fail as the operation field is error.
59     OAM_ERR_SIZE_ERR,    // !< operation fail as the size is error.
60     OAM_ERR_VALUE_ERR,   // !< operation fail as the value is error.
61 } oam_ret_t;
62 
63 enum OM_LOG_CONFIG_RESULT_ENUM {
64     OM_LOG_CONFIG_SUCCESS = 0,
65     OM_LOG_CONFIG_FAIL = 1,
66 
67     OM_LOG_CONFIG_RESULT_BUTT,
68 };
69 
70 enum OM_IF_TYPE_ENUM {
71     OM_IF_UART = 0,
72     OM_IF_SDIO = 1,
73 
74     OM_IF_TYPE_BUTT,
75 };
76 
77 enum OM_TXQUEUE_NODE_STATUS {
78     OM_TXQUEUE_NODE_INVALID,
79     OM_TXQUEUE_NODE_VALID,
80 };
81 
82 typedef enum {
83     OML_BUFF_NOT_USED,
84     OML_BUFF_USING,
85     OML_BUFF_USED, /* There is already a complete oml command in this buff */
86     OML_BUFF_BUTT,
87 } oml_buff_status_t;
88 
89 typedef void (*ramfunc_oml_csstat_cmd)(uint8_t *, uint8_t);
90 typedef void (*oam_cmd_handle_callback)(uint8_t *, uint16_t);
91 
92 typedef struct {
93     uint8_t uc_buff_state;
94     uint8_t uc_reserv;
95     uint16_t s_buff_used_len;
96     uint8_t auc_buff[LOG_OAM_RX_BUFF_LEN];
97 } oml_rx_data_stru_t;
98 
99 typedef struct {
100     uint8_t mode;
101     uint8_t reg_mem_size;
102     uint32_t reg_mem_addr_value[REGMEM_ADDR_AND_VALUE_MAX_LEN];
103 } rw_reg_mem_cmd_t;
104 
105 /**
106  * @brief  Parse the opetaion in the command.
107  * @param  data The AT command from App core.
108  * @param  len The length of the AT command.
109  * @param  reg_mem_cmd The parse result stored here.
110  * @return OAM_RET.
111  */
112 uint32_t parse_reg_or_mem_cmd_operate(const uint8_t *data, uint32_t len, rw_reg_mem_cmd_t *reg_mem_cmd);
113 
114 /**
115  * @brief  Parse the value size in the command.
116  * @param  data The AT command from App core.
117  * @param  len The length of the AT command.
118  * @param  reg_mem_cmd The parse result stored here.
119  * @return OAM_RET.
120  */
121 uint32_t parse_reg_or_mem_cmd_size(const uint8_t *data, uint32_t len, rw_reg_mem_cmd_t *reg_mem_cmd);
122 
123 /**
124  * @brief  Parse the addr and value in the command.
125  * @param  data The AT command from App core.
126  * @param  len The length of the AT command.
127  * @param  reg_mem_cmd The parse result stored here.
128  * @return OAM_RET.
129  */
130 uint32_t parse_reg_or_mem_cmd_addr_value(const uint8_t *data, uint32_t len, rw_reg_mem_cmd_t *reg_mem_cmd);
131 
132 #ifdef SUPPORT_IPC
133 /**
134  * @brief  The handler of IPC_ACTION_AP_BT_HOOK_DATA
135  * @param  message The ipc_action_t of the received message.
136  * @param  payload_p Data payload of the received mssage. Note that this is the uinion, not the individual memeber.
137  * @param  src Sending core.
138  * @param  id Internal message id. Can be used to detect duplicate delivery and for debug.
139  * @return True if the incoming mailslot shluld be released or
140  *         false if the message was not (fully) processed and should be redelivered.
141  */
142 bool ap_bt_hook_data_action_handler(ipc_action_t message,
143                                     const volatile ipc_payload *payload_p, cores_t src, uint32_t id);
144 #endif
145 
146 #ifdef SUPPORT_IPC
147 /**
148  * @brief  Send the result of start hooking to app core
149  * @param  hook_type The type of hook that should be used by app core.
150  * @param  addr The address that want to dump.
151  * @param  len The length of the memory want to dump.
152  * @param  value The value of the register or memory want to read.
153  * @return None
154  */
155 void send_bt_ap_hook_data(ipc_bt_ap_hook_type_e hook_type, uint32_t addr, uint32_t len, uint32_t value);
156 #endif
157 #if CORE != GNSS
158 void log_uart_rx_callback(const void *buffer, uint16_t length, bool remaining);
159 #endif
160 bool log_oam_register_handler_callback(uint8_t message_type, oam_cmd_handle_callback callback);
161 void log_oam_prase_message(void);
162 void oml_msg_parse(uint8_t *data, uint16_t data_len);
163 #ifdef SUPPORT_IPC
164 bool get_hci_data_action_handler(ipc_action_t message,
165                                  const volatile ipc_payload *payload_p, cores_t src, uint32_t id);
166 #endif
167 
168 #endif
169 
170 #else  /* SYS_DEBUG_MODE_ENABLE == NO */
171 
172 #ifndef LIB_LOG_READER_LOG_OAM_MSG_H
173 #define LIB_LOG_READER_LOG_OAM_MSG_H
174 // This branch should be deleted after the code of BTC has been finished.
175 #include <stdint.h>
176 #include <stdbool.h>
177 #include "log_oam_msg.h"
178 #ifdef SUPPORT_IPC
179 #include "ipc_actions.h"
180 #include "ipc.h"
181 #endif
182 
183 #if (defined CONFIG_DFX_SUPPORT_CUSTOM_LOG) && (CONFIG_DFX_SUPPORT_CUSTOM_LOG == DFX_YES)
184 #include "dfx_adapt_typedef.h"
185 #endif
186 
187 typedef void (*oam_cmd_handle_callback)(uint8_t *, uint16_t);
188 
189 /**
190  * @brief  Send the result of start hooking to app core
191  * @param  hook_type The type of hook that should be used by app core.
192  * @param  addr The address that want to dump.
193  * @param  len The length of the memory want to dump.
194  * @param  value The value of the register or memory want to read.
195  * @return None
196  */
197 
198 #ifdef SUPPORT_IPC
199 void send_bt_ap_hook_data(ipc_bt_ap_hook_type_e hook_type, uint32_t addr, uint32_t len, uint32_t value);
200 bool get_hci_data_action_handler(ipc_action_t message,
201                                  const volatile ipc_payload *payload_p, cores_t src, uint32_t id);
202 #endif
203 bool log_oam_register_handler_callback(uint8_t message_type, oam_cmd_handle_callback callback);
204 #endif
205 
206 #endif
207 
208 /**
209  * @}
210  */
211 #endif