1 /*
2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 * of conditions and the following disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include "los_trace_pri.h"
33 #include "trace_pipeline.h"
34
35 #ifdef __cplusplus
36 #if __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
39 #endif /* __cplusplus */
40
41 #if (LOSCFG_RECORDER_MODE_ONLINE == 1)
OsTraceGetMaskTid(UINT32 taskId)42 UINT32 OsTraceGetMaskTid(UINT32 taskId)
43 {
44 return taskId;
45 }
46
OsTraceSendHead(VOID)47 VOID OsTraceSendHead(VOID)
48 {
49 TraceBaseHeaderInfo head = {
50 .bigLittleEndian = TRACE_BIGLITTLE_WORD,
51 .version = TRACE_VERSION(TRACE_MODE_ONLINE),
52 .clockFreq = g_sysClock,
53 };
54
55 OsTraceDataSend(HEAD, sizeof(TraceBaseHeaderInfo), (UINT8 *)&head);
56 }
57
OsTraceSendNotify(UINT32 type,UINT32 value)58 VOID OsTraceSendNotify(UINT32 type, UINT32 value)
59 {
60 TraceNotifyFrame frame = {
61 .cmd = type,
62 .param = value,
63 };
64
65 OsTraceDataSend(NOTIFY, sizeof(TraceNotifyFrame), (UINT8 *)&frame);
66 }
67
OsTraceSendObj(const LosTaskCB * tcb)68 STATIC VOID OsTraceSendObj(const LosTaskCB *tcb)
69 {
70 ObjData obj;
71
72 OsTraceSetObj(&obj, tcb);
73 OsTraceDataSend(OBJ, sizeof(ObjData), (UINT8 *)&obj);
74 }
75
OsTraceSendObjTable(VOID)76 VOID OsTraceSendObjTable(VOID)
77 {
78 UINT32 loop;
79 LosTaskCB *tcb = NULL;
80
81 for (loop = 0; loop < g_taskMaxNum; ++loop) {
82 tcb = g_taskCBArray + loop;
83 if (tcb->taskStatus & OS_TASK_STATUS_UNUSED) {
84 continue;
85 }
86 OsTraceSendObj(tcb);
87 }
88 }
89
OsTraceObjAdd(UINT32 eventType,UINT32 taskId)90 VOID OsTraceObjAdd(UINT32 eventType, UINT32 taskId)
91 {
92 if (OsTraceIsEnable()) {
93 OsTraceSendObj(OS_TCB_FROM_TID(taskId));
94 }
95 }
96
OsTraceWriteOrSendEvent(const TraceEventFrame * frame)97 VOID OsTraceWriteOrSendEvent(const TraceEventFrame *frame)
98 {
99 OsTraceDataSend(EVENT, sizeof(TraceEventFrame), (UINT8 *)frame);
100 }
101
OsTraceRecordGet(VOID)102 OfflineHead *OsTraceRecordGet(VOID)
103 {
104 return NULL;
105 }
106
107 #endif /* LOSCFG_RECORDER_MODE_ONLINE == 1 */
108
109 #ifdef __cplusplus
110 #if __cplusplus
111 }
112 #endif /* __cplusplus */
113 #endif /* __cplusplus */
114