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 TRIGGER MODULE
15 * Author:
16 * Create:
17 */
18
19 #include "log_trigger.h"
20 #include "dfx_adapt_layer.h"
21
22 #if ((CORE == CORE_LOGGING) && defined(BUILD_APPLICATION_STANDARD)) || (CORE_NUMS == 1)
23
24 #ifndef USE_CMSIS_OS
25 #error "log reader not implemented for non-os version"
26 #endif
27
28 static log_trigger_callback_t g_log_trigger_callback = NULL;
29
log_trigger(void)30 void log_trigger(void)
31 {
32 if (g_log_trigger_callback != NULL) {
33 g_log_trigger_callback();
34 }
35 }
36
register_log_trigger(log_trigger_callback_t callback)37 void register_log_trigger(log_trigger_callback_t callback)
38 {
39 if (callback != NULL) {
40 g_log_trigger_callback = callback;
41 }
42 }
43
44 #else // (CORE != CORE_LOGGING) case
45 #include "ipc.h"
46 #ifdef IPC_NEW
47 #include "ipc_porting.h"
48 #endif
49
50 // Have a definition for the right cores_t enum in CORES_CORE_LOGGING
51 #if CORE_LOGGING == BT
52 #define CORES_CORE_LOGGING CORES_BT_CORE
53 #elif CORE_LOGGING == PROTOCOL
54 #define CORES_CORE_LOGGING CORES_PROTOCOL_CORE
55 #elif CORE_LOGGING == APPS
56 #define CORES_CORE_LOGGING CORES_APPS_CORE
57 #elif CORE_LOGGING == GNSS
58 #define CORES_CORE_LOGGING CORES_GNSS_CORE
59 #endif
60
61 #ifdef IPC_NEW
log_trigger(void)62 void log_trigger(void)
63 {
64 ipc_msg_info_t head;
65 head.dst_core = CORES_CORE_LOGGING;
66 head.priority = IPC_PRIORITY_LOWEST;
67 head.msg_id = IPC_MSG_LOG_INFO;
68 head.buf_addr = NULL;
69 head.buf_len = 0;
70 head.channel = 0;
71 (void)uapi_ipc_send_msg_async(&head);
72 }
73 #elif (defined CONFIG_DFX_SUPPORT_CUSTOM_LOG) && (CONFIG_DFX_SUPPORT_CUSTOM_LOG == DFX_YES)
log_trigger(void)74 void log_trigger(void)
75 {
76 dfx_log_trigger();
77 }
78 #else
log_trigger(void)79 void log_trigger(void)
80 {
81 #if (BTH_WITH_SMART_WEAR == NO) && (USE_COMPRESS_LOG_INSTEAD_OF_SDT_LOG == YES)
82 if (ipc_check_status(CORES_CORE_LOGGING) == IPC_STATUS_OK) {
83 ipc_interrupt_core(CORES_CORE_LOGGING);
84 }
85 #else
86 (void)ipc_send_message(CORES_CORE_LOGGING,
87 IPC_ACTION_LOG_INFO,
88 NULL,
89 0,
90 IPC_PRIORITY_LOWEST, false);
91 #endif
92 }
93 #endif
94 #endif // (CORE == CORE_LOGGING)
95
96 #if (BTH_WITH_SMART_WEAR == NO && (CORE == BT))
97 #include "log_buffer.h"
98 #include "ipc.h"
massdata_trigger(void * pay_i,uint8_t core,uint8_t type)99 void massdata_trigger(void *pay_i, uint8_t core, uint8_t type)
100 {
101 #define MASS_POINT_SIZE sizeof(system_event_s_t)
102 ipc_payload_mass_data_type ipc_pay;
103 system_event_s_t *pay = (system_event_s_t *)(pay_i);
104 ipc_pay.core = core;
105 ipc_pay.type = type;
106 ipc_pay.event_id = pay->event_id;
107 ipc_pay.time_stamp = pay->time_stamp;
108 ipc_pay.event_info = pay->event_info;
109 ipc_pay.subevent_info = pay->sub_event_info;
110 ipc_pay.chr_up_type = pay->chr_up_type;
111 ipc_pay.psn = pay->psn;
112 ipc_pay.role = pay->role;
113
114 (void)ipc_send_message(CORES_APPS_CORE,
115 IPC_ACTION_MASS_DATA_INFORM,
116 (ipc_payload *)((void *)&ipc_pay),
117 sizeof(ipc_payload_mass_data_type),
118 IPC_PRIORITY_LOWEST, false);
119 #undef MASS_POINT_SIZE
120 }
121 #endif
122