WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
los_trace.h
浏览该文件的文档.
1/* ----------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved.
3 * Description: LiteOS Trace Module Implementation HeadFile
4 * Author: Huawei LiteOS Team
5 * Create: 2019-08-30
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 * to endorse or promote products derived from this software without specific prior written
15 * permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * --------------------------------------------------------------------------- */
28
34#ifndef _LOS_TRACE_H
35#define _LOS_TRACE_H
36
37#include "los_base.h"
38#include "los_task.h"
39
40#include "los_perf.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif /* __cplusplus */
45
46#ifdef LOSCFG_TRACE_CONTROL_AGENT
47
52#define LOSCFG_TRACE_TASK_PRIORITY 2
53#endif
54
55#define LOSCFG_TRACE_OBJ_MAX_NAME_SIZE LOS_TASK_NAMELEN
56
61#define LOSCFG_TRACE_OBJ_MAX_NUM 0 // LOSCFG_BASE_CORE_TSK_LIMIT
62
67#define LOSCFG_TRACE_TLV_BUF_SIZE 100
68
77#define LOS_ERRNO_TRACE_ERROR_STATUS LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x00)
78
87#define LOS_ERRNO_TRACE_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x01)
88
97#define LOS_ERRNO_TRACE_BUF_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x02)
98
107#define LOS_ERRNO_TRACE_BUF_IS_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x03)
108
119
139
150typedef enum {
151 /* 0x10~0x1F */
155
156 /* 0x20~0x2F */
170
171 /* 0x40~0x4F */
179
180 /* 0x80~0x8F */
186
187 /* 0x100~0x10F */
194
195 /* 0x200~0x20F */
199
200 /* 0x400~0x40F */
208
209 /* 0x800~0x80F */
214
215 /* 0x1000~0x100F */
221
231
236typedef struct {
241#ifdef LOSCFG_TRACE_FRAME_CORE_MSG
242 struct CoreStatus {
243 UINT32 cpuId : 8,
244 hwiActive : 4,
245 taskLockCnt : 4,
246 paramCount : 4,
247 reserves : 12;
248 } core;
249#endif
250
251#ifdef LOSCFG_TRACE_FRAME_EVENT_COUNT
252 UINT32 eventCount;
253#endif
254
255#ifdef LOSCFG_TRACE_FRAME_MAX_PARAMS
256 UINTPTR params[LOSCFG_TRACE_FRAME_MAX_PARAMS];
257#endif
259
269
282
303
304typedef VOID (*TRACE_EVENT_HOOK)(UINT32 eventType, UINTPTR identity, const UINTPTR *params, UINT16 paramCount);
306
307/*
308 * The first param is treat as key, keep at least this param if you want trace this event.
309 * All parameters were treated as UINTPTR.
310 * 1. Configure the macro without parameters so as not to record events of this type;
311 * 2. Configure the macro at least with one parameter to record this type of event;
312 * 3. User can delete unnecessary parameters which defined in corresponding marco;
313 * Trace an event as:
314 * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio
315 * Not Trace an event as:
316 * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio)
317 * Trace only you need parmas as:
318 * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId
319 */
320#define TASK_SWITCH_PARAMS(taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus) \
321 taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus
322#define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio
323#define TASK_CREATE_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio
324#define TASK_DELETE_PARAMS(taskId, taskStatus, usrStack) taskId, taskStatus, usrStack
325#define TASK_SUSPEND_PARAMS(taskId, taskStatus, runTaskId) taskId, taskStatus, runTaskId
326#define TASK_RESUME_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio
327#define TASK_SIGNAL_PARAMS(taskId, signal)
328
329#define SWTMR_START_PARAMS(swtmrId, mode, overrun, interval, expiry) swtmrId, mode, overrun, interval, expiry
330#define SWTMR_DELETE_PARAMS(swtmrId) swtmrId
331#define SWTMR_EXPIRED_PARAMS(swtmrId) swtmrId
332#define SWTMR_STOP_PARAMS(swtmrId) swtmrId
333#define SWTMR_CREATE_PARAMS(swtmrId) swtmrId
334
335#define HWI_CREATE_PARAMS(hwiNum, hwiPrio, hwiMode, hwiHandler) hwiNum, hwiPrio, hwiMode, hwiHandler
336#define HWI_CREATE_NODE_PARAMS(hwiNum, pDevId, ret) hwiNum, pDevId, ret
337#define HWI_DELETE_PARAMS(hwiNum) hwiNum
338#define HWI_DELETE_NODE_PARAMS(hwiNum, pDevId, ret) hwiNum, pDevId, ret
339#define HWI_RESPONSE_IN_PARAMS(hwiNum) hwiNum
340#define HWI_RESPONSE_OUT_PARAMS(hwiNum) hwiNum
341#define HWI_ENABLE_PARAMS(hwiNum) hwiNum
342#define HWI_DISABLE_PARAMS(hwiNum) hwiNum
343#define HWI_TRIGGER_PARAMS(hwiNum) hwiNum
344#define HWI_SETPRI_PARAMS(hwiNum, priority) hwiNum, priority
345#define HWI_CLEAR_PARAMS(hwiNum) hwiNum
346#define HWI_SETAFFINITY_PARAMS(hwiNum, cpuMask) hwiNum, cpuMask
347#define HWI_SENDIPI_PARAMS(hwiNum, cpuMask) hwiNum, cpuMask
348
349#define EVENT_CREATE_PARAMS(eventCB) eventCB
350#define EVENT_DELETE_PARAMS(eventCB, delRetCode) eventCB, delRetCode
351#define EVENT_READ_PARAMS(eventCB, eventId, mask, mode, timeout) \
352 eventCB, eventId, mask, mode, timeout
353#define EVENT_WRITE_PARAMS(eventCB, eventId, events) eventCB, eventId, events
354#define EVENT_CLEAR_PARAMS(eventCB, eventId, events) eventCB, eventId, events
355#define EVENT_COND_READ_PARAMS(eventCB, eventId) eventCB, eventId
356#define EVENT_COND_WRITE_PARAMS(eventCB, eventId) eventCB, eventId
357
358#define QUEUE_CREATE_PARAMS(queueId, queueSz, itemSz, queueAddr, memType) \
359 queueId, queueSz, itemSz, queueAddr, memType
360#define QUEUE_DELETE_PARAMS(queueId, state, readable) queueId, state, readable
361#define QUEUE_RW_PARAMS(queueId, queueSize, bufSize, operateType, readable, writable, timeout) \
362 queueId, queueSize, bufSize, operateType, readable, writable, timeout
363
364#define SEM_CREATE_PARAMS(semId, type, count) semId, type, count
365#define SEM_DELETE_PARAMS(semId, delRetCode) semId, delRetCode
366#define SEM_PEND_PARAMS(semId, count, timeout) semId, count, timeout
367#define SEM_POST_PARAMS(semId, type, count) semId, type, count
368
369#define MUX_CREATE_PARAMS(muxId) muxId
370#define MUX_DELETE_PARAMS(muxId, state, count, owner) muxId, state, count, owner
371#define MUX_PEND_PARAMS(muxId, count, owner, timeout) muxId, count, owner, timeout
372#define MUX_POST_PARAMS(muxId, count, owner) muxId, count, owner
373
374#define MEM_ALLOC_PARAMS(pool, ptr, size) pool, ptr, size
375#define MEM_ALLOC_ALIGN_PARAMS(pool, ptr, size, boundary) pool, ptr, size, boundary
376#define MEM_REALLOC_PARAMS(pool, ptr, size) pool, ptr, size
377#define MEM_FREE_PARAMS(pool, ptr) pool, ptr
378#define MEM_INFO_REQ_PARAMS(pool) pool
379#define MEM_INFO_PARAMS(pool, usedSize, freeSize) pool, usedSize, freeSize
380
381#define SYS_ERROR_PARAMS(errno) errno
382
383#ifdef LOSCFG_KERNEL_TRACE
384
403#define LOS_TRACE(TYPE, IDENTITY, ...) do { \
404 LOS_PERF(TYPE); \
405 UINTPTR _innerArr[] = {0, TYPE##_PARAMS((UINTPTR)IDENTITY, ##__VA_ARGS__)}; \
406 size_t _n = sizeof(_innerArr) / sizeof(UINTPTR); \
407 if ((_n > 1) && (g_traceEventHook != NULL)) { \
408 UINTPTR *_inner = _innerArr; \
409 g_traceEventHook(TYPE, _inner[1], _n > 2 ? &_inner[2] : NULL, _n - 2); \
410 } \
411 } while (0)
412#else
413#define LOS_TRACE(TYPE, ...) LOS_PERF(TYPE)
414#endif
415
416#ifdef LOSCFG_KERNEL_TRACE
417
436#define LOS_TRACE_EASY(TYPE, IDENTITY, ...) \
437 do { \
438 UINTPTR _inner[] = {0, ##__VA_ARGS__}; \
439 UINTPTR _n = sizeof(_inner) / sizeof(UINTPTR); \
440 if (g_traceEventHook != NULL) { \
441 g_traceEventHook(TRACE_USER_DEFAULT_FLAG | TYPE, (UINTPTR)IDENTITY, _n > 1 ? &_inner[1] : NULL, _n - 1); \
442 } \
443 } while (0)
444#else
445#define LOS_TRACE_EASY(...)
446#endif
447
476extern UINT32 LOS_TraceInit(VOID *buf, UINT32 size);
477
499
520
541
565
588
611
632#ifdef __cplusplus
633}
634#endif /* __cplusplus */
635
636#endif /* _LOS_TRACE_H */
BOOL(* TRACE_HWI_FILTER_HOOK)(UINT32 hwiNum)
Define the type of trace hardware interrupt filter hook function.
Definition los_trace.h:302
LOS_TRACE_MASK
Definition los_trace.h:125
void LOS_TraceHwiFilterHookReg(TRACE_HWI_FILTER_HOOK hook)
Hwi num filter hook.
void LOS_TraceStop(void)
Stop trace sample.
LOS_TRACE_TYPE
Definition los_trace.h:150
UINT32 LOS_TraceStart(void)
Start trace.
void LOS_TraceReset(void)
Clear the trace buf.
TraceState
Definition los_trace.h:113
void LOS_TraceRecordDump(BOOL toClient)
Offline trace buffer display.
UINT32 LOS_TraceInit(void *buf, UINT32 size)
Initialize the trace when the system startup.
OfflineHead * LOS_TraceRecordGet(void)
Offline trace buffer export.
void LOS_TraceEventMaskSet(UINT32 mask)
Set trace event mask.
@ TRACE_MEM_FLAG
Definition los_trace.h:130
@ TRACE_MUX_FLAG
Definition los_trace.h:134
@ TRACE_HWI_FLAG
Definition los_trace.h:127
@ TRACE_SWTMR_FLAG
Definition los_trace.h:129
@ TRACE_QUE_FLAG
Definition los_trace.h:131
@ TRACE_SYS_FLAG
Definition los_trace.h:126
@ TRACE_USER_DEFAULT_FLAG
Definition los_trace.h:137
@ TRACE_SEM_FLAG
Definition los_trace.h:133
@ TRACE_TASK_FLAG
Definition los_trace.h:128
@ TRACE_EVENT_FLAG
Definition los_trace.h:132
@ TRACE_MAX_FLAG
Definition los_trace.h:136
@ QUEUE_DELETE
Definition los_trace.h:197
@ HWI_SETAFFINITY
Definition los_trace.h:168
@ HWI_SENDIPI
Definition los_trace.h:169
@ SEM_CREATE
Definition los_trace.h:210
@ MEM_INFO
Definition los_trace.h:193
@ TASK_SUSPEND
Definition los_trace.h:175
@ SEM_DELETE
Definition los_trace.h:211
@ MEM_ALLOC
Definition los_trace.h:188
@ QUEUE_CREATE
Definition los_trace.h:196
@ TASK_DELETE
Definition los_trace.h:174
@ EVENT_DELETE
Definition los_trace.h:202
@ TASK_PRIOSET
Definition los_trace.h:173
@ MUX_DELETE
Definition los_trace.h:217
@ EVENT_CREATE
Definition los_trace.h:201
@ TASK_CREATE
Definition los_trace.h:172
@ SYS_ERROR
Definition los_trace.h:152
@ SWTMR_STOP
Definition los_trace.h:184
@ MEM_REALLOC
Definition los_trace.h:190
@ EVENT_COND_READ
Definition los_trace.h:206
@ QUEUE_RW
Definition los_trace.h:198
@ HWI_RESPONSE_OUT
Definition los_trace.h:162
@ MEM_INFO_REQ
Definition los_trace.h:192
@ EVENT_COND_WRITE
Definition los_trace.h:207
@ TASK_RESUME
Definition los_trace.h:176
@ MUX_CREATE
Definition los_trace.h:216
@ SWTMR_DELETE
Definition los_trace.h:182
@ MUX_PEND
Definition los_trace.h:218
@ SYS_STOP
Definition los_trace.h:154
@ HWI_ENABLE
Definition los_trace.h:163
@ SWTMR_EXPIRED
Definition los_trace.h:185
@ HWI_CREATE_NODE
Definition los_trace.h:158
@ SEM_PEND
Definition los_trace.h:212
@ SWTMR_START
Definition los_trace.h:183
@ TASK_SIGNAL
Definition los_trace.h:178
@ SWTMR_CREATE
Definition los_trace.h:181
@ HWI_SETPRI
Definition los_trace.h:166
@ HWI_TRIGGER
Definition los_trace.h:165
@ EVENT_CLEAR
Definition los_trace.h:205
@ EVENT_READ
Definition los_trace.h:203
@ SEM_POST
Definition los_trace.h:213
@ SYS_START
Definition los_trace.h:153
@ HWI_DELETE_NODE
Definition los_trace.h:160
@ HWI_RESPONSE_IN
Definition los_trace.h:161
@ MUX_POST
Definition los_trace.h:219
@ MEM_ALLOC_ALIGN
Definition los_trace.h:189
@ HWI_DELETE
Definition los_trace.h:159
@ EVENT_WRITE
Definition los_trace.h:204
@ TASK_SWITCH
Definition los_trace.h:177
@ HWI_DISABLE
Definition los_trace.h:164
@ MEM_FREE
Definition los_trace.h:191
@ HWI_CREATE
Definition los_trace.h:157
@ HWI_CLEAR
Definition los_trace.h:167
@ TRACE_UNINIT
Definition los_trace.h:114
@ TRACE_INITED
Definition los_trace.h:115
@ TRACE_STOPED
Definition los_trace.h:117
@ TRACE_STARTED
Definition los_trace.h:116
TRACE_EVENT_HOOK g_traceEventHook
void(* TRACE_EVENT_HOOK)(UINT32 eventType, UINTPTR identity, const UINTPTR *params, UINT16 paramCount)
Definition los_trace.h:304
#define LOSCFG_TRACE_OBJ_MAX_NAME_SIZE
Definition los_trace.h:55
unsigned short UINT16
Definition los_typedef.h:51
unsigned long long UINT64
Definition los_typedef.h:72
#define VOID
Definition los_typedef.h:88
unsigned int UINTPTR
Definition los_typedef.h:74
unsigned int UINT32
Definition los_typedef.h:52
char CHAR
Definition los_typedef.h:58
size_t BOOL
Definition los_typedef.h:83
Definition los_trace.h:264
UINT32 id
Definition los_trace.h:265
UINT32 prio
Definition los_trace.h:266
Definition los_trace.h:274
TraceBaseHeaderInfo baseInfo
Definition los_trace.h:275
UINT16 totalLen
Definition los_trace.h:276
UINT16 objOffset
Definition los_trace.h:279
UINT16 frameOffset
Definition los_trace.h:280
UINT16 frameSize
Definition los_trace.h:278
UINT16 objSize
Definition los_trace.h:277
Definition los_trace.h:226
UINT32 clockFreq
Definition los_trace.h:228
UINT32 bigLittleEndian
Definition los_trace.h:227
UINT32 version
Definition los_trace.h:229
Definition los_trace.h:236
UINT64 curTime
Definition los_trace.h:239
UINTPTR identity
Definition los_trace.h:240
UINT32 curTask
Definition los_trace.h:238
UINT32 eventType
Definition los_trace.h:237