• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
33  * @defgroup los_trace Trace
34  * @ingroup kernel
35  */
36 
37 #ifndef _LOS_TRACE_H
38 #define _LOS_TRACE_H
39 
40 #include "los_task.h"
41 #include "trace_cnv.h"
42 
43 #ifdef __cplusplus
44 #if __cplusplus
45 extern "C" {
46 #endif /* __cplusplus */
47 #endif /* __cplusplus */
48 
49 #if (LOSCFG_TRACE_CONTROL_AGENT == 1)
50 
51 /**
52  * @ingroup los_trace
53  * Trace Control agent task's priority.
54  */
55 #define LOSCFG_TRACE_TASK_PRIORITY                              2
56 #endif
57 
58 #define LOSCFG_TRACE_OBJ_MAX_NAME_SIZE                          LOS_TASK_NAMELEN
59 
60 /**
61  * @ingroup los_trace
62  * Trace records the max number of objects(kernel object, like tasks), range is [0, LOSCFG_BASE_CORE_TSK_LIMIT].
63  * if set to 0, trace will not record any object.
64  */
65 #define LOSCFG_TRACE_OBJ_MAX_NUM                                0
66 
67 /**
68  * @ingroup los_trace
69  * Trace tlv encode buffer size, the buffer is used to encode one piece raw frame to tlv message in online mode.
70  */
71 #define LOSCFG_TRACE_TLV_BUF_SIZE                               100
72 
73 /**
74  * @ingroup los_trace
75  * Trace error code: init trace failed.
76  *
77  * Value: 0x02001400
78  *
79  * Solution: Follow the trace State Machine.
80  */
81 #define LOS_ERRNO_TRACE_ERROR_STATUS               LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x00)
82 
83 /**
84  * @ingroup los_trace
85  * Trace error code: Insufficient memory for trace buf init.
86  *
87  * Value: 0x02001401
88  *
89  * Solution: Expand the configured system memory or decrease the value defined by LOS_TRACE_BUFFER_SIZE.
90  */
91 #define LOS_ERRNO_TRACE_NO_MEMORY                  LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x01)
92 
93 /**
94  * @ingroup los_trace
95  * Trace error code: Insufficient memory for trace struct.
96  *
97  * Value: 0x02001402
98  *
99  * Solution: Increase trace buffer's size.
100  */
101 #define LOS_ERRNO_TRACE_BUF_TOO_SMALL              LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x02)
102 
103 /**
104  * @ingroup los_trace
105  * Trace state.
106  */
107 enum TraceState {
108     TRACE_UNINIT = 0,  /**< trace isn't inited */
109     TRACE_INITED,      /**< trace is inited but not started yet */
110     TRACE_STARTED,     /**< trace is started and system is tracing */
111     TRACE_STOPED,      /**< trace is stopped */
112 };
113 
114 /**
115  * @ingroup los_trace
116  * Trace mask is used to filter events in runtime. Each mask keep only one unique bit to 1, and user can define own
117  * module's trace mask.
118  */
119 typedef enum {
120     TRACE_SYS_FLAG          = 0x10,
121     TRACE_HWI_FLAG          = 0x20,
122     TRACE_TASK_FLAG         = 0x40,
123     TRACE_SWTMR_FLAG        = 0x80,
124     TRACE_MEM_FLAG          = 0x100,
125     TRACE_QUE_FLAG          = 0x200,
126     TRACE_EVENT_FLAG        = 0x400,
127     TRACE_SEM_FLAG          = 0x800,
128     TRACE_MUX_FLAG          = 0x1000,
129 
130     TRACE_MAX_FLAG          = 0x80000000,
131     TRACE_USER_DEFAULT_FLAG = 0xFFFFFFF0,
132 } LOS_TRACE_MASK;
133 
134 /**
135  * @ingroup los_trace
136  * Trace event type which indicate the exactly happened events, user can define own module's event type like
137  * TRACE_#MODULE#_FLAG | NUMBER.
138  *                   28                     4
139  *    0 0 0 0 0 0 0 0 X X X X X X X X 0 0 0 0 0 0
140  *    |                                   |     |
141  *             trace_module_flag           number
142  *
143  */
144 typedef enum {
145     /* 0x10~0x1F */
146     SYS_ERROR             = TRACE_SYS_FLAG | 0,
147     SYS_START             = TRACE_SYS_FLAG | 1,
148     SYS_STOP              = TRACE_SYS_FLAG | 2,
149 
150     /* 0x20~0x2F */
151     HWI_CREATE              = TRACE_HWI_FLAG | 0,
152     HWI_CREATE_SHARE        = TRACE_HWI_FLAG | 1,
153     HWI_DELETE              = TRACE_HWI_FLAG | 2,
154     HWI_DELETE_SHARE        = TRACE_HWI_FLAG | 3,
155     HWI_RESPONSE_IN         = TRACE_HWI_FLAG | 4,
156     HWI_RESPONSE_OUT        = TRACE_HWI_FLAG | 5,
157     HWI_ENABLE              = TRACE_HWI_FLAG | 6,
158     HWI_DISABLE             = TRACE_HWI_FLAG | 7,
159     HWI_TRIGGER             = TRACE_HWI_FLAG | 8,
160     HWI_SETPRI              = TRACE_HWI_FLAG | 9,
161     HWI_CLEAR               = TRACE_HWI_FLAG | 10,
162     HWI_SETAFFINITY         = TRACE_HWI_FLAG | 11,
163     HWI_SENDIPI             = TRACE_HWI_FLAG | 12,
164 
165     /* 0x40~0x4F */
166     TASK_CREATE           = TRACE_TASK_FLAG | 0,
167     TASK_PRIOSET          = TRACE_TASK_FLAG | 1,
168     TASK_DELETE           = TRACE_TASK_FLAG | 2,
169     TASK_SUSPEND          = TRACE_TASK_FLAG | 3,
170     TASK_RESUME           = TRACE_TASK_FLAG | 4,
171     TASK_SWITCH           = TRACE_TASK_FLAG | 5,
172     TASK_SIGNAL           = TRACE_TASK_FLAG | 6,
173 
174     /* 0x80~0x8F */
175     SWTMR_CREATE          = TRACE_SWTMR_FLAG | 0,
176     SWTMR_DELETE          = TRACE_SWTMR_FLAG | 1,
177     SWTMR_START           = TRACE_SWTMR_FLAG | 2,
178     SWTMR_STOP            = TRACE_SWTMR_FLAG | 3,
179     SWTMR_EXPIRED         = TRACE_SWTMR_FLAG | 4,
180 
181     /* 0x100~0x10F */
182     MEM_ALLOC             = TRACE_MEM_FLAG | 0,
183     MEM_ALLOC_ALIGN       = TRACE_MEM_FLAG | 1,
184     MEM_REALLOC           = TRACE_MEM_FLAG | 2,
185     MEM_FREE              = TRACE_MEM_FLAG | 3,
186     MEM_INFO_REQ          = TRACE_MEM_FLAG | 4,
187     MEM_INFO              = TRACE_MEM_FLAG | 5,
188 
189     /* 0x200~0x20F */
190     QUEUE_CREATE          = TRACE_QUE_FLAG | 0,
191     QUEUE_DELETE          = TRACE_QUE_FLAG | 1,
192     QUEUE_RW              = TRACE_QUE_FLAG | 2,
193 
194     /* 0x400~0x40F */
195     EVENT_CREATE          = TRACE_EVENT_FLAG | 0,
196     EVENT_DELETE          = TRACE_EVENT_FLAG | 1,
197     EVENT_READ            = TRACE_EVENT_FLAG | 2,
198     EVENT_WRITE           = TRACE_EVENT_FLAG | 3,
199     EVENT_CLEAR           = TRACE_EVENT_FLAG | 4,
200 
201     /* 0x800~0x80F */
202     SEM_CREATE            = TRACE_SEM_FLAG | 0,
203     SEM_DELETE            = TRACE_SEM_FLAG | 1,
204     SEM_PEND              = TRACE_SEM_FLAG | 2,
205     SEM_POST              = TRACE_SEM_FLAG | 3,
206 
207     /* 0x1000~0x100F */
208     MUX_CREATE            = TRACE_MUX_FLAG | 0,
209     MUX_DELETE            = TRACE_MUX_FLAG | 1,
210     MUX_PEND              = TRACE_MUX_FLAG | 2,
211     MUX_POST              = TRACE_MUX_FLAG | 3,
212 } LOS_TRACE_TYPE;
213 
214 /**
215  * @ingroup los_trace
216  * struct to store the trace config information.
217  */
218 typedef struct {
219     UINT32 bigLittleEndian;     /**< big little endian flag */
220     UINT32 clockFreq;           /**< system clock frequency */
221     UINT32 version;             /**< trace version */
222 } TraceBaseHeaderInfo;
223 
224 /**
225  * @ingroup los_trace
226  * struct to store the event information
227  */
228 typedef struct {
229     UINT32  eventType;                               /**< event type */
230     UINT32  curTask;                                 /**< current running task */
231     UINT64  curTime;                                 /**< current timestamp */
232     UINTPTR identity;                                /**< subject of the event description */
233 #if (LOSCFG_TRACE_FRAME_CORE_MSG == 1)
234     struct CoreStatus {
235         UINT32 cpuId      : 8,                       /**< cpuid */
236                hwiActive  : 4,                       /**< whether is in hwi response */
237                taskLockCnt : 4,                      /**< task lock count */
238                paramCount : 4,                       /**< event frame params' number */
239                reserves   : 12;                      /**< reserves */
240     } core;
241 #endif
242 
243 #if (LOSCFG_TRACE_FRAME_EVENT_COUNT == 1)
244     UINT32  eventCount;                               /**< the sequence of happened events */
245 #endif
246 
247     UINTPTR params[LOSCFG_TRACE_FRAME_MAX_PARAMS];    /**< event frame's params */
248 } TraceEventFrame;
249 
250 /**
251  * @ingroup los_trace
252  * struct to store the kernel obj information, we defined task as kernel obj in this system.
253  */
254 typedef struct {
255     UINT32      id;                                     /**< kernel obj's id */
256     UINT32      prio;                                   /**< kernel obj's priority */
257     CHAR        name[LOSCFG_TRACE_OBJ_MAX_NAME_SIZE];   /**< kernel obj's name */
258 } ObjData;
259 
260 /**
261  * @ingroup los_trace
262  * struct to store the trace data.
263  */
264 typedef struct {
265     TraceBaseHeaderInfo baseInfo;          /**< basic info, include bigLittleEndian flag, system clock freq */
266     UINT16 totalLen;                       /**< trace data's total length */
267     UINT16 objSize;                        /**< sizeof #ObjData */
268     UINT16 frameSize;                      /**< sizeof #TraceEventFrame */
269     UINT16 objOffset;                      /**< the offset of the first obj data to record beginning */
270     UINT16 frameOffset;                    /**< the offset of the first event frame data to record beginning */
271 } OfflineHead;
272 
273 /**
274  * @ingroup  los_trace
275  * @brief Define the type of trace hardware interrupt filter hook function.
276  *
277  * @par Description:
278  * User can register fliter function by LOS_TraceHwiFilterHookReg to filter hardware interrupt events. Return true if
279  * user don't need trace the certain number.
280  *
281  * @attention
282  * None.
283  *
284  * @param hwiNum        [IN] Type #UINT32. The hardware interrupt number.
285  * @retval #TRUE        0x00000001: Not record the certain number.
286  * @retval #FALSE       0x00000000: Need record the certain number.
287  *
288  * @par Dependency:
289  * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
290  */
291 typedef BOOL (*TRACE_HWI_FILTER_HOOK)(UINT32 hwiNum);
292 
293 typedef VOID (*TRACE_EVENT_HOOK)(UINT32 eventType, UINTPTR identity, const UINTPTR *params, UINT16 paramCount);
294 extern TRACE_EVENT_HOOK g_traceEventHook;
295 
296 /**
297  * @ingroup los_trace
298  * Trace event params:
299  1. Configure the macro without parameters so as not to record events of this type;
300  2. Configure the macro at least with one parameter to record this type of event;
301  3. User can delete unnecessary parameters which defined in corresponding marco;
302  * @attention
303  * <ul>
304  * <li>The first param is treat as key, keep at least this param if you want trace this event.</li>
305  * <li>All parameters were treated as UINTPTR.</li>
306  * </ul>
307  * eg. Trace an event as:
308  * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio
309  * eg. Not Trace an event as:
310  * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio)
311  * eg. Trace only you need parmas as:
312  * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId
313  */
314 #define TASK_SWITCH_PARAMS(taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus) \
315     taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus
316 #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio
317 #define TASK_CREATE_PARAMS(taskId, taskStatus, prio)     taskId, taskStatus, prio
318 #define TASK_DELETE_PARAMS(taskId, taskStatus, usrStack) taskId, taskStatus, usrStack
319 #define TASK_SUSPEND_PARAMS(taskId, taskStatus, runTaskId) taskId, taskStatus, runTaskId
320 #define TASK_RESUME_PARAMS(taskId, taskStatus, prio)     taskId, taskStatus, prio
321 #define TASK_SIGNAL_PARAMS(taskId, signal, schedFlag)    // taskId, signal, schedFlag
322 
323 #define SWTMR_START_PARAMS(swtmrId, mode, interval)  swtmrId, mode, interval
324 #define SWTMR_DELETE_PARAMS(swtmrId)                                  swtmrId
325 #define SWTMR_EXPIRED_PARAMS(swtmrId)                                 swtmrId
326 #define SWTMR_STOP_PARAMS(swtmrId)                                    swtmrId
327 #define SWTMR_CREATE_PARAMS(swtmrId)                                  swtmrId
328 
329 #define HWI_CREATE_PARAMS(hwiNum, hwiPrio, hwiMode, hwiHandler) hwiNum, hwiPrio, hwiMode, hwiHandler
330 #define HWI_CREATE_SHARE_PARAMS(hwiNum, pDevId, ret)    hwiNum, pDevId, ret
331 #define HWI_DELETE_PARAMS(hwiNum)                       hwiNum
332 #define HWI_DELETE_SHARE_PARAMS(hwiNum, pDevId, ret)    hwiNum, pDevId, ret
333 #define HWI_RESPONSE_IN_PARAMS(hwiNum)                  hwiNum
334 #define HWI_RESPONSE_OUT_PARAMS(hwiNum)                 hwiNum
335 #define HWI_ENABLE_PARAMS(hwiNum)                       hwiNum
336 #define HWI_DISABLE_PARAMS(hwiNum)                      hwiNum
337 #define HWI_TRIGGER_PARAMS(hwiNum)                      hwiNum
338 #define HWI_SETPRI_PARAMS(hwiNum, priority)             hwiNum, priority
339 #define HWI_CLEAR_PARAMS(hwiNum)                        hwiNum
340 #define HWI_SETAFFINITY_PARAMS(hwiNum, cpuMask)         hwiNum, cpuMask
341 #define HWI_SENDIPI_PARAMS(hwiNum, cpuMask)             hwiNum, cpuMask
342 
343 #define EVENT_CREATE_PARAMS(eventCB)                    eventCB
344 #define EVENT_DELETE_PARAMS(eventCB, delRetCode)        eventCB, delRetCode
345 #define EVENT_READ_PARAMS(eventCB, eventId, mask, mode, timeout) \
346     eventCB, eventId, mask, mode, timeout
347 #define EVENT_WRITE_PARAMS(eventCB, eventId, events)    eventCB, eventId, events
348 #define EVENT_CLEAR_PARAMS(eventCB, eventId, events)    eventCB, eventId, events
349 
350 #define QUEUE_CREATE_PARAMS(queueId, queueSz, itemSz, queueAddr, memType) \
351     queueId, queueSz, itemSz, queueAddr, memType
352 #define QUEUE_DELETE_PARAMS(queueId, state, readable)   queueId, state, readable
353 #define QUEUE_RW_PARAMS(queueId, queueSize, bufSize, operateType, readable, writable, timeout) \
354     queueId, queueSize, bufSize, operateType, readable, writable, timeout
355 
356 #define SEM_CREATE_PARAMS(semId, type, count)           semId, type, count
357 #define SEM_DELETE_PARAMS(semId, delRetCode)            semId, delRetCode
358 #define SEM_PEND_PARAMS(semId, count, timeout)          semId, count, timeout
359 #define SEM_POST_PARAMS(semId, type, count)             semId, type, count
360 
361 #define MUX_CREATE_PARAMS(muxId)                        muxId
362 #define MUX_DELETE_PARAMS(muxId, state, count, owner)   muxId, state, count, owner
363 #define MUX_PEND_PARAMS(muxId, count, owner, timeout)   muxId, count, owner, timeout
364 #define MUX_POST_PARAMS(muxId, count, owner)            muxId, count, owner
365 
366 #define MEM_ALLOC_PARAMS(pool, ptr, size)                   pool, ptr, size
367 #define MEM_ALLOC_ALIGN_PARAMS(pool, ptr, size, boundary)   pool, ptr, size, boundary
368 #define MEM_REALLOC_PARAMS(pool, ptr, size)                 pool, ptr, size
369 #define MEM_FREE_PARAMS(pool, ptr)                          pool, ptr
370 #define MEM_INFO_REQ_PARAMS(pool)                           pool
371 #define MEM_INFO_PARAMS(pool, usedSize, freeSize)           pool, usedSize, freeSize
372 
373 #define SYS_ERROR_PARAMS(errno)                         errno
374 
375 #if (LOSCFG_KERNEL_TRACE == 1)
376 
377 /**
378  * @ingroup los_trace
379  * @brief Trace static code stub.
380  *
381  * @par Description:
382  * This API is used to instrument trace code stub in source code, to track events.
383  * @attention
384  * None.
385  *
386  * @param TYPE           [IN] Type #LOS_TRACE_TYPE. The event type.
387  * @param IDENTITY       [IN] Type #UINTPTR. The subject of this event description.
388  * @param ...            [IN] Type #UINTPTR. This piece of event's params.
389  * @retval None.
390  *
391  * @par Dependency:
392  * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
393  */
394 #define LOS_TRACE(TYPE, IDENTITY, ...)                                             \
395     do {                                                                           \
396         UINTPTR _inner[] = {0, TYPE##_PARAMS((UINTPTR)IDENTITY, ##__VA_ARGS__)};   \
397         UINTPTR _n = sizeof(_inner) / sizeof(UINTPTR);                             \
398         if ((_n > 1) && (g_traceEventHook != NULL)) {                              \
399             g_traceEventHook(TYPE, _inner[1], _n > 2 ? &_inner[2] : NULL, _n - 2); \
400         }                                                                          \
401     } while (0)
402 #else
403 #define LOS_TRACE(TYPE, ...)
404 #endif
405 
406 #if (LOSCFG_KERNEL_TRACE == 1)
407 
408 /**
409  * @ingroup los_trace
410  * @brief Trace static easier user-defined code stub.
411  *
412  * @par Description:
413  * This API is used to instrument user-defined trace code stub in source code, to track events simply.
414  * @attention
415  * None.
416  *
417  * @param TYPE           [IN] Type #UINT32. The event type, only low 4 bits take effect.
418  * @param IDENTITY       [IN] Type #UINTPTR. The subject of this event description.
419  * @param ...            [IN] Type #UINTPTR. This piece of event's params.
420  * @retval None.
421  *
422  * @par Dependency:
423  * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
424  */
425 #define LOS_TRACE_EASY(TYPE, IDENTITY, ...)                                                                          \
426     do {                                                                                                             \
427         UINTPTR _inner[] = {0, ##__VA_ARGS__};                                                                       \
428         UINTPTR _n = sizeof(_inner) / sizeof(UINTPTR);                                                               \
429         if (g_traceEventHook != NULL) {                                                                              \
430             g_traceEventHook(TRACE_USER_DEFAULT_FLAG | TYPE, (UINTPTR)IDENTITY, _n > 1 ? &_inner[1] : NULL, _n - 1); \
431         }                                                                                                            \
432     } while (0)
433 #else
434 #define LOS_TRACE_EASY(...)
435 #endif
436 
437 /**
438  * @ingroup los_trace
439  * @brief Start trace.
440  *
441  * @par Description:
442  * This API is used to start trace.
443  * @attention
444  * <ul>
445  * <li>Start trace</li>
446  * </ul>
447  *
448  * @param  None.
449  * @retval #LOS_ERRNO_TRACE_ERROR_STATUS        0x02001400: Trace start failed.
450  * @retval #LOS_OK                              0x00000000: Trace start success.
451  *
452  * @par Dependency:
453  * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
454  * @see LOS_TraceStart
455  */
456 extern UINT32 LOS_TraceStart(VOID);
457 
458 /**
459  * @ingroup los_trace
460  * @brief Stop trace.
461  *
462  * @par Description:
463  * This API is used to stop trace.
464  * @attention
465  * <ul>
466  * <li>Stop trace</li>
467  * </ul>
468  *
469  * @param  None.
470  * @retval #None.
471  *
472  * @par Dependency:
473  * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
474  * @see LOS_TraceStop
475  */
476 extern VOID LOS_TraceStop(VOID);
477 
478 /**
479  * @ingroup los_trace
480  * @brief Clear the trace buf.
481  *
482  * @par Description:
483  * Clear the event frames in trace buf only at offline mode.
484  * @attention
485  * <ul>
486  * <li>This API can be called only after that trace buffer has been established.</li>
487  * Otherwise, the trace will be failed.</li>
488  * </ul>
489  *
490  * @param  None.
491  * @retval #NA
492  * @par Dependency:
493  * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
494  * @see LOS_TraceReset
495  */
496 extern VOID LOS_TraceReset(VOID);
497 
498 /**
499  * @ingroup los_trace
500  * @brief Set trace event mask.
501  *
502  * @par Description:
503  * Set trace event mask.
504  * @attention
505  * <ul>
506  * <li>Set trace event filter mask.</li>
507  * <li>The Default mask is (TRACE_HWI_FLAG | TRACE_TASK_FLAG), stands for switch on task and hwi events.</li>
508  * <li>Customize mask according to the type defined in enum LOS_TRACE_MASK to switch on corresponding module's
509  * trace.</li>
510  * <li>The system's trace mask will be overrode by the input parameter.</li>
511  * </ul>
512  *
513  * @param  mask [IN] Type #UINT32. The mask used to filter events of LOS_TRACE_MASK.
514  * @retval #NA.
515  * @par Dependency:
516  * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
517  * @see LOS_TraceEventMaskSet
518  */
519 extern VOID LOS_TraceEventMaskSet(UINT32 mask);
520 
521 /**
522  * @ingroup los_trace
523  * @brief Offline trace buffer display.
524  *
525  * @par Description:
526  * Display trace buf data only at offline mode.
527  * @attention
528  * <ul>
529  * <li>This API can be called only after that trace stopped. Otherwise the trace dump will be failed.</li>
530  * <li>Trace data will be send to pipeline when user set toClient = TRUE. Otherwise it will be formatted and printed
531  * out.</li>
532  * </ul>
533  *
534  * @param toClient           [IN] Type #BOOL. Whether send trace data to Client through pipeline.
535  * @retval #NA
536  *
537  * @par Dependency:
538  * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
539  * @see LOS_TraceRecordDump
540  */
541 extern VOID LOS_TraceRecordDump(BOOL toClient);
542 
543 /**
544  * @ingroup los_trace
545  * @brief Offline trace buffer export.
546  *
547  * @par Description:
548  * Return the trace buf only at offline mode.
549  * @attention
550  * <ul>
551  * <li>This API can be called only after that trace buffer has been established. </li>
552  * <li>The return buffer's address is a critical resource, user can only ready.</li>
553  * </ul>
554  *
555  * @param NA
556  * @retval #OfflineHead*   The trace buffer's address, analyze this buffer according to the structure of
557  * OfflineHead.
558  *
559  * @par Dependency:
560  * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
561  * @see LOS_TraceRecordGet
562  */
563 extern OfflineHead *LOS_TraceRecordGet(VOID);
564 
565 /**
566  * @ingroup los_trace
567  * @brief Hwi num fliter hook.
568  *
569  * @par Description:
570  * Hwi fliter function.
571  * @attention
572  * <ul>
573  * <li>Filter the hwi events by hwi num</li>
574  * </ul>
575  *
576  * @param  hook [IN] Type #TRACE_HWI_FILTER_HOOK. The user defined hook for hwi num filter,
577  *                             the hook should return true if you don't want trace this hwi num.
578  * @retval #None
579  * @par Dependency:
580  * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
581  * @see LOS_TraceHwiFilterHookReg
582  */
583 extern VOID LOS_TraceHwiFilterHookReg(TRACE_HWI_FILTER_HOOK hook);
584 #ifdef __cplusplus
585 #if __cplusplus
586 }
587 #endif /* __cplusplus */
588 #endif /* __cplusplus */
589 
590 #endif /* _LOS_TRACE_H */
591