|
|
/* ----------------------------------------------------------------------------
|
|
|
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved.
|
|
|
* Description: LiteOS Trace Module Implementation HeadFile
|
|
|
* Author: Huawei LiteOS Team
|
|
|
* Create: 2019-08-30
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
* conditions and the following disclaimer.
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
|
* provided with the distribution.
|
|
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
|
* to endorse or promote products derived from this software without specific prior written
|
|
|
* permission.
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
* --------------------------------------------------------------------------- */
|
|
|
/*这段代码是关于 Huawei LiteOS 操作系统中的跟踪(Trace)功能的实现,包括了跟踪数据结构、跟踪事件类型、初始化、启动、停止、事件掩码
|
|
|
设置以及导出等一系列相关操作。此外,还定义了一些宏,用于用户自定义的跟踪代码存根,以简单地追踪事件。*/
|
|
|
/**
|
|
|
* @defgroup los_trace Trace
|
|
|
* @ingroup kernel
|
|
|
*/
|
|
|
|
|
|
#ifndef _LOS_TRACE_H
|
|
|
#define _LOS_TRACE_H
|
|
|
|
|
|
#include "los_base.h"
|
|
|
#include "los_task.h"
|
|
|
|
|
|
#include "los_perf.h"
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
extern "C" {
|
|
|
#endif /* __cplusplus */
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
#ifdef LOSCFG_TRACE_CONTROL_AGENT
|
|
|
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* Trace Control agent task's priori00ty.
|
|
|
*/
|
|
|
#define LOSCFG_TRACE_TASK_PRIORITY 2
|
|
|
#endif
|
|
|
|
|
|
#define LOSCFG_TRACE_OBJ_MAX_NAME_SIZE LOS_TASK_NAMELEN
|
|
|
/*这段代码是关于轨迹追踪(Trace Control)的配置*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* Trace records the max number of objects(kernel object, like tasks). if set to 0, trace will not record any object.
|
|
|
*/
|
|
|
#define LOSCFG_TRACE_OBJ_MAX_NUM 0 // LOSCFG_BASE_CORE_TSK_LIMIT
|
|
|
/*这段代码是关于轨迹追踪(Trace Control)中记录对象数量的配置*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* Trace tlv encode buffer size, the buffer is used to encode one piece raw frame to tlv message in online mode.
|
|
|
*/
|
|
|
#define LOSCFG_TRACE_TLV_BUF_SIZE 100
|
|
|
/*这段代码是关于轨迹追踪(Trace Control)中tlv编码缓冲区大小的配置*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* Trace error code: init trace failed.
|
|
|
*
|
|
|
* Value: 0x02001400
|
|
|
*
|
|
|
* Solution: Follow the trace State Machine.
|
|
|
*/
|
|
|
#define LOS_ERRNO_TRACE_ERROR_STATUS LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x00)
|
|
|
/*跟踪错误代码:初始化跟踪失败*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* Trace error code: Insufficient memory for trace buf init.
|
|
|
*
|
|
|
* Value: 0x02001401
|
|
|
*
|
|
|
* Solution: Expand the configured system memory or decrease the value defined by LOS_TRACE_BUFFER_SIZE.
|
|
|
*/
|
|
|
#define LOS_ERRNO_TRACE_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x01)
|
|
|
/*跟踪错误代码:内存不足,无法进行跟踪buf-init。*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* Trace error code: Insufficient memory for trace struct.
|
|
|
*
|
|
|
* Value: 0x02001402
|
|
|
*
|
|
|
* Solution: Increase trace buffer's size.
|
|
|
*/
|
|
|
#define LOS_ERRNO_TRACE_BUF_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x02)
|
|
|
/*跟踪错误代码:跟踪结构的内存不足 */
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* Trace state.
|
|
|
*/
|
|
|
enum TraceState {
|
|
|
TRACE_UNINIT = 0, /**< trace isn't inited */
|
|
|
TRACE_INITED, /**< trace is inited but not started yet */
|
|
|
TRACE_STARTED, /**< trace is started and system is tracing */
|
|
|
TRACE_STOPED, /**< trace is stopped */
|
|
|
};
|
|
|
/*这段代码定义了一个枚举类型 TraceState,用于表示轨迹追踪(Trace Control)的状态。该枚举包括以下几个取值:
|
|
|
|
|
|
TRACE_UNINIT:表示轨迹追踪未初始化。
|
|
|
TRACE_INITED:表示轨迹追踪已经初始化,但尚未启动。
|
|
|
TRACE_STARTED:表示轨迹追踪已经启动,系统正在进行追踪。
|
|
|
TRACE_STOPED:表示轨迹追踪已经停止。*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* Trace mask is used to filter events in runtime. Each mask keep only one unique bit to 1, and user can define own
|
|
|
* module's trace mask.
|
|
|
*/
|
|
|
typedef enum {
|
|
|
TRACE_SYS_FLAG = 0x10,
|
|
|
TRACE_HWI_FLAG = 0x20,
|
|
|
TRACE_TASK_FLAG = 0x40,
|
|
|
TRACE_SWTMR_FLAG = 0x80,
|
|
|
TRACE_MEM_FLAG = 0x100,
|
|
|
TRACE_QUE_FLAG = 0x200,
|
|
|
TRACE_EVENT_FLAG = 0x400,
|
|
|
TRACE_SEM_FLAG = 0x800,
|
|
|
TRACE_MUX_FLAG = 0x1000,
|
|
|
|
|
|
TRACE_MAX_FLAG = 0x80000000,
|
|
|
TRACE_USER_DEFAULT_FLAG = 0xFFFFFFF0,
|
|
|
} LOS_TRACE_MASK;
|
|
|
/*这段代码定义了一个枚举类型 LOS_TRACE_MASK,用于在运行时过滤事件。每个标志位都保持唯一的一位为1,用户可以定义自己模块的跟踪掩码
|
|
|
该枚举包括了以下几个取值:
|
|
|
|
|
|
TRACE_SYS_FLAG:系统事件的跟踪掩码
|
|
|
TRACE_HWI_FLAG:硬件中断事件的跟踪掩码
|
|
|
TRACE_TASK_FLAG:任务事件的跟踪掩码
|
|
|
TRACE_SWTMR_FLAG:软件定时器事件的跟踪掩码
|
|
|
TRACE_MEM_FLAG:内存事件的跟踪掩码
|
|
|
TRACE_QUE_FLAG:队列事件的跟踪掩码
|
|
|
TRACE_EVENT_FLAG:事件事件的跟踪掩码
|
|
|
TRACE_SEM_FLAG:信号量事件的跟踪掩码
|
|
|
TRACE_MUX_FLAG:互斥锁事件的跟踪掩码
|
|
|
TRACE_MAX_FLAG:最大的跟踪掩码
|
|
|
TRACE_USER_DEFAULT_FLAG:用户默认的跟踪掩码*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* Trace event type which indicate the exactly happend events, user can define own module's event type like
|
|
|
* TRACE_#MODULE#_FLAG | NUMBER.
|
|
|
* 28 4
|
|
|
* 0 0 0 0 0 0 0 0 X X X X X X X X 0 0 0 0 0 0
|
|
|
* | | |
|
|
|
* trace_module_flag number
|
|
|
*
|
|
|
*/
|
|
|
typedef enum {
|
|
|
/* 0x10~0x1F */
|
|
|
SYS_ERROR = TRACE_SYS_FLAG | 0,
|
|
|
SYS_START = TRACE_SYS_FLAG | 1,
|
|
|
SYS_STOP = TRACE_SYS_FLAG | 2,
|
|
|
|
|
|
/* 0x20~0x2F */
|
|
|
HWI_CREATE = TRACE_HWI_FLAG | 0,
|
|
|
HWI_CREATE_SHARE = TRACE_HWI_FLAG | 1,
|
|
|
HWI_DELETE = TRACE_HWI_FLAG | 2,
|
|
|
HWI_DELETE_SHARE = TRACE_HWI_FLAG | 3,
|
|
|
HWI_RESPONSE_IN = TRACE_HWI_FLAG | 4,
|
|
|
HWI_RESPONSE_OUT = TRACE_HWI_FLAG | 5,
|
|
|
HWI_ENABLE = TRACE_HWI_FLAG | 6,
|
|
|
HWI_DISABLE = TRACE_HWI_FLAG | 7,
|
|
|
HWI_TRIGGER = TRACE_HWI_FLAG | 8,
|
|
|
HWI_SETPRI = TRACE_HWI_FLAG | 9,
|
|
|
HWI_CLEAR = TRACE_HWI_FLAG | 10,
|
|
|
HWI_SETAFFINITY = TRACE_HWI_FLAG | 11,
|
|
|
HWI_SENDIPI = TRACE_HWI_FLAG | 12,
|
|
|
|
|
|
/* 0x40~0x4F */
|
|
|
TASK_CREATE = TRACE_TASK_FLAG | 0,
|
|
|
TASK_PRIOSET = TRACE_TASK_FLAG | 1,
|
|
|
TASK_DELETE = TRACE_TASK_FLAG | 2,
|
|
|
TASK_SUSPEND = TRACE_TASK_FLAG | 3,
|
|
|
TASK_RESUME = TRACE_TASK_FLAG | 4,
|
|
|
TASK_SWITCH = TRACE_TASK_FLAG | 5,
|
|
|
TASK_SIGNAL = TRACE_TASK_FLAG | 6,
|
|
|
|
|
|
/* 0x80~0x8F */
|
|
|
SWTMR_CREATE = TRACE_SWTMR_FLAG | 0,
|
|
|
SWTMR_DELETE = TRACE_SWTMR_FLAG | 1,
|
|
|
SWTMR_START = TRACE_SWTMR_FLAG | 2,
|
|
|
SWTMR_STOP = TRACE_SWTMR_FLAG | 3,
|
|
|
SWTMR_EXPIRED = TRACE_SWTMR_FLAG | 4,
|
|
|
|
|
|
/* 0x100~0x10F */
|
|
|
MEM_ALLOC = TRACE_MEM_FLAG | 0,
|
|
|
MEM_ALLOC_ALIGN = TRACE_MEM_FLAG | 1,
|
|
|
MEM_REALLOC = TRACE_MEM_FLAG | 2,
|
|
|
MEM_FREE = TRACE_MEM_FLAG | 3,
|
|
|
MEM_INFO_REQ = TRACE_MEM_FLAG | 4,
|
|
|
MEM_INFO = TRACE_MEM_FLAG | 5,
|
|
|
|
|
|
/* 0x200~0x20F */
|
|
|
QUEUE_CREATE = TRACE_QUE_FLAG | 0,
|
|
|
QUEUE_DELETE = TRACE_QUE_FLAG | 1,
|
|
|
QUEUE_RW = TRACE_QUE_FLAG | 2,
|
|
|
|
|
|
/* 0x400~0x40F */
|
|
|
EVENT_CREATE = TRACE_EVENT_FLAG | 0,
|
|
|
EVENT_DELETE = TRACE_EVENT_FLAG | 1,
|
|
|
EVENT_READ = TRACE_EVENT_FLAG | 2,
|
|
|
EVENT_WRITE = TRACE_EVENT_FLAG | 3,
|
|
|
EVENT_CLEAR = TRACE_EVENT_FLAG | 4,
|
|
|
|
|
|
/* 0x800~0x80F */
|
|
|
SEM_CREATE = TRACE_SEM_FLAG | 0,
|
|
|
SEM_DELETE = TRACE_SEM_FLAG | 1,
|
|
|
SEM_PEND = TRACE_SEM_FLAG | 2,
|
|
|
SEM_POST = TRACE_SEM_FLAG | 3,
|
|
|
|
|
|
/* 0x1000~0x100F */
|
|
|
MUX_CREATE = TRACE_MUX_FLAG | 0,
|
|
|
MUX_DELETE = TRACE_MUX_FLAG | 1,
|
|
|
MUX_PEND = TRACE_MUX_FLAG | 2,
|
|
|
MUX_POST = TRACE_MUX_FLAG | 3,
|
|
|
} LOS_TRACE_TYPE;
|
|
|
/*这段代码定义了一个枚举类型 LOS_TRACE_TYPE,用于表示不同的追踪事件类型。每个事件类型都由一个唯一的标志位组成,用户可以根据需要定义自己模块的事件类型。
|
|
|
该枚举类型包括了各种事件类型,如系统事件、硬件中断事件、任务事件、软件定时器事件、内存事件、队列事件、事件事件、信号量事件和互斥锁事件等。
|
|
|
每个事件类型都使用了特定的跟踪掩码,以便在运行时进行事件过滤和分析。
|
|
|
通过定义自己模块的事件类型,用户可以灵活地追踪和记录特定模块的事件,以便进行调试和性能分析*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* struct to store the trace config information.
|
|
|
*/
|
|
|
typedef struct {
|
|
|
UINT32 bigLittleEndian; /**< big little endian flag */
|
|
|
UINT32 clockFreq; /**< system clock frequency */
|
|
|
UINT32 version; /**< trace version */
|
|
|
} TraceBaseHeaderInfo;
|
|
|
/*这段代码是一个注释和结构体的定义,用于存储跟踪配置信息。*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* struct to store the event infomation
|
|
|
*/
|
|
|
typedef struct {
|
|
|
UINT32 eventType; /**< event type */
|
|
|
UINT32 curTask; /**< current running task */
|
|
|
UINT64 curTime; /**< current timestamp */
|
|
|
UINTPTR identity; /**< subject of the event description */
|
|
|
#ifdef LOSCFG_TRACE_FRAME_CORE_MSG
|
|
|
struct CoreStatus {
|
|
|
UINT32 cpuId : 8, /**< cpuid */
|
|
|
hwiActive : 4, /**< whether is in hwi response */
|
|
|
taskLockCnt : 4, /**< task lock count */
|
|
|
paramCount : 4, /**< event frame params' number */
|
|
|
reserves : 12; /**< reserves */
|
|
|
} core;
|
|
|
#endif
|
|
|
|
|
|
#ifdef LOSCFG_TRACE_FRAME_EVENT_COUNT
|
|
|
UINT32 eventCount; /**< the sequence of happend events */
|
|
|
#endif
|
|
|
|
|
|
#ifdef LOSCFG_TRACE_FRAME_MAX_PARAMS
|
|
|
UINTPTR params[LOSCFG_TRACE_FRAME_MAX_PARAMS]; /**< event frame's params */
|
|
|
#endif
|
|
|
} TraceEventFrame;
|
|
|
/*这段代码是一个注释和结构体的定义,用于存储事件信息*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* struct to store the kernel obj information, we defined task as kernel obj in this system.
|
|
|
*/
|
|
|
typedef struct {
|
|
|
UINT32 id; /**< kernel obj's id */
|
|
|
UINT32 prio; /**< kernel obj's priority */
|
|
|
CHAR name[LOSCFG_TRACE_OBJ_MAX_NAME_SIZE]; /**< kernel obj's name */
|
|
|
} ObjData;
|
|
|
/*这段代码是一个注释和结构体的定义,用于存储内核对象信息*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* struct to store the trace data.
|
|
|
*/
|
|
|
typedef struct {
|
|
|
TraceBaseHeaderInfo baseInfo; /**< basic info, include bigLittleEndian flag, system clock freq */
|
|
|
UINT16 totalLen; /**< trace data's total length */
|
|
|
UINT16 objSize; /**< sizeof #ObjData */
|
|
|
UINT16 frameSize; /**< sizeof #TraceEventFrame */
|
|
|
UINT16 objOffset; /**< the offset of the first obj data to record beginning */
|
|
|
UINT16 frameOffset; /**< the offset of the first event frame data to record beginning */
|
|
|
} OfflineHead;
|
|
|
/*这段代码是一个注释和结构体的定义,用于存储跟踪数据。*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* @brief Define the type of trace hardware interrupt filter hook function.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* User can register fliter function by LOS_TraceHwiFilterHookReg to filter hardware interrupt events. Return true if
|
|
|
* user don't need trace the certain number.
|
|
|
*
|
|
|
* @attention
|
|
|
* None.
|
|
|
*
|
|
|
* @param hwiNum [IN] Type #UINT32. The hardware interrupt number.
|
|
|
* @retval #TRUE 0x00000001: Not record the certain number.
|
|
|
* @retval #FALSE 0x00000000: Need record the certain number.
|
|
|
*
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @since Huawei LiteOS V200R005C00
|
|
|
*/
|
|
|
typedef BOOL (*TRACE_HWI_FILTER_HOOK)(UINT32 hwiNum);
|
|
|
|
|
|
typedef VOID (*TRACE_EVENT_HOOK)(UINT32 eventType, UINTPTR identity, const UINTPTR *params, UINT16 paramCount);
|
|
|
extern TRACE_EVENT_HOOK g_traceEventHook;
|
|
|
/*这段代码定义了两个函数指针类型和一个函数指针变量,这些函数指针类型和变量用于实现 Huawei LiteOS 操作系统的事件跟踪功能。*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* Trace event params:
|
|
|
1. Configure the macro without parameters so as not to record events of this type;
|
|
|
2. Configure the macro at least with one parameter to record this type of event;
|
|
|
3. User can delete unnecessary parameters which defined in corresponding marco;
|
|
|
* @attention
|
|
|
* <ul>
|
|
|
* <li>The first param is treat as key, keep at least this param if you want trace this event.</li>
|
|
|
* <li>All parameters were treated as UINTPTR.</li>
|
|
|
* </ul>
|
|
|
* eg. Trace a event as:
|
|
|
* #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio
|
|
|
* eg. Not Trace a event as:
|
|
|
* #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio)
|
|
|
* eg. Trace only you need parmas as:
|
|
|
* #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId
|
|
|
*/
|
|
|
#define TASK_SWITCH_PARAMS(taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus) \/*这段代码是一个宏定义,用于定义任务切换所需的参数集合*/
|
|
|
taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus
|
|
|
#define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio/*这段代码是一个宏定义,用于定义任务优先级设置所需的参数集合*/
|
|
|
#define TASK_CREATE_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio/*这段代码是一个宏定义,用于定义任务创建所需的参数集合*/
|
|
|
#define TASK_DELETE_PARAMS(taskId, taskStatus, usrStack) taskId, taskStatus, usrStack/*这段代码是一个宏定义,用于定义任务删除所需的参数集合*/
|
|
|
#define TASK_SUSPEND_PARAMS(taskId, taskStatus, runTaskId) taskId, taskStatus, runTaskId/*这段代码是一个宏定义,用于定义任务挂起所需的参数集合*/
|
|
|
#define TASK_RESUME_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio/*这段代码是一个宏定义,用于定义任务恢复所需的参数集合*/
|
|
|
#define TASK_SIGNAL_PARAMS(taskId, signal, schedFlag) // taskId, signal, schedFlag/*这段代码是一个宏定义,用于定义任务信号所需的参数集合
|
|
|
|
|
|
#define SWTMR_START_PARAMS(swtmrId, mode, overrun, interval, expiry) swtmrId, mode, overrun, interval, expiry/*这段代码是一个宏定义,用于定义软定时器启动所需的参数集合*/
|
|
|
#define SWTMR_DELETE_PARAMS(swtmrId) swtmrId/*这段代码是一个宏定义,用于定义软定时器删除所需的参数集合*/
|
|
|
#define SWTMR_EXPIRED_PARAMS(swtmrId) swtmrId/*这段代码是一个宏定义,用于定义软定时器到期所需的参数集合。*/
|
|
|
#define SWTMR_STOP_PARAMS(swtmrId) swtmrId/*这段代码是一个宏定义,用于定义软定时器停止所需的参数集合*/
|
|
|
#define SWTMR_CREATE_PARAMS(swtmrId) swtmrId
|
|
|
|
|
|
#define HWI_CREATE_PARAMS(hwiNum, hwiPrio, hwiMode, hwiHandler) hwiNum, hwiPrio, hwiMode, hwiHandler/*这段代码是一个宏定义,用于定义创建软定时器所需的参数集合*/
|
|
|
#define HWI_CREATE_SHARE_PARAMS(hwiNum, pDevId, ret) hwiNum, pDevId, ret/*这段代码是一个宏定义,用于定义创建硬件中断所需的参数集合*/
|
|
|
#define HWI_DELETE_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义中断删除所需的参数集合*/
|
|
|
#define HWI_DELETE_SHARE_PARAMS(hwiNum, pDevId, ret) hwiNum, pDevId, ret/*这段代码是一个宏定义,用于定义共享中断删除所需的参数集合*/
|
|
|
#define HWI_RESPONSE_IN_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义中断响应输入参数*/
|
|
|
#define HWI_RESPONSE_OUT_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义中断响应输出参数*/
|
|
|
#define HWI_ENABLE_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义中断使能所需的参数集合*/
|
|
|
#define HWI_DISABLE_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义中断禁用所需的参数集合*/
|
|
|
#define HWI_TRIGGER_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义触发中断所需的参数集合*/
|
|
|
#define HWI_SETPRI_PARAMS(hwiNum, priority) hwiNum, priority/*这段代码是一个宏定义,用于定义设置中断优先级所需的参数集合*/
|
|
|
#define HWI_CLEAR_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义清除中断所需的参数集合*/
|
|
|
#define HWI_SETAFFINITY_PARAMS(hwiNum, cpuMask) hwiNum, cpuMask/*这段代码是一个宏定义,用于定义设置中断亲和性(affinity)所需的参数集合*/
|
|
|
#define HWI_SENDIPI_PARAMS(hwiNum, cpuMask) hwiNum, cpuMask/*这段代码是一个宏定义,用于定义发送中断处理器间中断(IPI)所需的参数集合*/
|
|
|
|
|
|
#define EVENT_CREATE_PARAMS(eventCB) eventCB/*这段代码是一个宏定义,用于定义创建事件(event)所需的参数集合*/
|
|
|
#define EVENT_DELETE_PARAMS(eventCB, delRetCode) eventCB, delRetCode/*这段代码是一个宏定义,用于定义删除事件(event)所需的参数集合*/
|
|
|
#define EVENT_READ_PARAMS(eventCB, eventId, mask, mode, timeout) \
|
|
|
eventCB, eventId, mask, mode, timeout
|
|
|
#define EVENT_WRITE_PARAMS(eventCB, eventId, events) eventCB, eventId, events/*这段代码是一个宏定义,用于定义读取事件(event)所需的参数集合*/
|
|
|
#define EVENT_CLEAR_PARAMS(eventCB, eventId, events) eventCB, eventId, events/*这段代码是一个宏定义,用于定义清除事件(event)所需的参数集合*/
|
|
|
|
|
|
#define QUEUE_CREATE_PARAMS(queueId, queueSz, itemSz, queueAddr, memType) \/*这段代码是一个宏定义,用于定义创建队列(queue)所需的参数*/
|
|
|
queueId, queueSz, itemSz, queueAddr, memType
|
|
|
#define QUEUE_DELETE_PARAMS(queueId, state, readable) queueId, state, readable/*这段代码是一个宏定义,用于定义删除队列(queue)所需的参数集合*/
|
|
|
#define QUEUE_RW_PARAMS(queueId, queueSize, bufSize, operateType, readable, writeable, timeout) \/*这段代码是一个宏定义,用于定义读写队列(queue)所需的参数集合*/
|
|
|
queueId, queueSize, bufSize, operateType, readable, writeable, timeout
|
|
|
|
|
|
#define SEM_CREATE_PARAMS(semId, type, count) semId, type, count/*这段代码是一个宏定义,用于定义创建信号量(semaphore)所需的参数集合*/
|
|
|
#define SEM_DELETE_PARAMS(semId, delRetCode) semId, delRetCode/*这段代码是一个宏定义,用于定义删除信号量(semaphore)所需的参数集合*/
|
|
|
#define SEM_PEND_PARAMS(semId, count, timeout) semId, count, timeout/*这段代码是一个宏定义,用于定义等待信号量(semaphore)所需的参数集合*/
|
|
|
#define SEM_POST_PARAMS(semId, type, count) semId, type, count/*这段代码是一个宏定义,用于定义发送信号量(semaphore)所需的参数集合*/
|
|
|
|
|
|
#define MUX_CREATE_PARAMS(muxId) muxId/*这段代码是一个宏定义,用于定义创建互斥量(mutex)所需的参数*/
|
|
|
#define MUX_DELETE_PARAMS(muxId, state, count, owner) muxId, state, count, owner/*这段代码是一个宏定义,用于定义删除互斥量(mutex)所需的参数集合*/
|
|
|
#define MUX_PEND_PARAMS(muxId, count, owner, timeout) muxId, count, owner, timeout/*这段代码是一个宏定义,用于定义等待互斥量(mutex)所需的参数集合*/
|
|
|
#define MUX_POST_PARAMS(muxId, count, owner) muxId, count, owner/*这段代码是一个宏定义,用于定义发送互斥量(mutex)所需的参数集合*/
|
|
|
|
|
|
#define MEM_ALLOC_PARAMS(pool, ptr, size) pool, ptr, size/*这段代码是一个宏定义,用于定义内存分配(memory allocation)所需的参数集合*/
|
|
|
#define MEM_ALLOC_ALIGN_PARAMS(pool, ptr, size, boundary) pool, ptr, size, boundary/*这段代码是一个宏定义,用于定义内存分配对齐(alignment)所需的参数集合*/
|
|
|
#define MEM_REALLOC_PARAMS(pool, ptr, size) pool, ptr, size/*这段代码是一个宏定义,用于定义重新分配内存(memory reallocation)所需的参数集合*/
|
|
|
#define MEM_FREE_PARAMS(pool, ptr) pool, ptr/*这段代码是一个宏定义,用于定义内存释放(memory deallocation)所需的参数集合*/
|
|
|
#define MEM_INFO_REQ_PARAMS(pool) pool/*这段代码是一个宏定义,用于定义获取内存信息请求(memory information request)所需的参数集合*/
|
|
|
#define MEM_INFO_PARAMS(pool, usedSize, freeSize) pool, usedSize, freeSize/*这段代码是一个宏定义,用于定义内存信息(memory information)所需的参数集合*/
|
|
|
|
|
|
#define SYS_ERROR_PARAMS(errno) errno
|
|
|
|
|
|
#ifdef LOSCFG_KERNEL_TRACE
|
|
|
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* @brief Trace static code stub.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* This API is used to instrument trace code stub in source code, to track events.
|
|
|
* @attention
|
|
|
* None.
|
|
|
*
|
|
|
* @param TYPE [IN] Type #LOS_TRACE_TYPE. The event type.
|
|
|
* @param IDENTITY [IN] Type #UINTPTR. The subject of this event description.
|
|
|
* @param ... [IN] Type #UINTPTR. This piece of event's params.
|
|
|
* @retval None.
|
|
|
*
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @since Huawei LiteOS V200R005C00
|
|
|
*/
|
|
|
#define LOS_TRACE(TYPE, IDENTITY, ...) \
|
|
|
do { \
|
|
|
LOS_PERF(TYPE); \
|
|
|
UINTPTR _inner[] = {0, TYPE##_PARAMS((UINTPTR)IDENTITY, ##__VA_ARGS__)}; \
|
|
|
UINTPTR _n = sizeof(_inner) / sizeof(UINTPTR); \
|
|
|
if ((_n > 1) && (g_traceEventHook != NULL)) { \
|
|
|
g_traceEventHook(TYPE, _inner[1], _n > 2 ? &_inner[2] : NULL, _n - 2); \
|
|
|
} \
|
|
|
} while (0)
|
|
|
#else
|
|
|
#define LOS_TRACE(TYPE, ...) LOS_PERF(TYPE)
|
|
|
#endif
|
|
|
/*这段代码是一个宏定义,用于在源代码中插入跟踪代码存根,以追踪事件
|
|
|
|
|
|
宏定义内部的实现逻辑如下:
|
|
|
|
|
|
首先调用LOS_PERF宏,执行与性能相关的操作。
|
|
|
创建一个名为_inner的数组,将事件类型和参数存储其中。数组的第一个元素为0,表示未知。
|
|
|
获取_inner数组的长度,并判断是否大于1,并且全局变量g_traceEventHook不为空。
|
|
|
如果满足条件,则调用g_traceEventHook函数,将事件类型、第二个元素以及后续元素传递给该函数。
|
|
|
宏定义结束。*/
|
|
|
#ifdef LOSCFG_KERNEL_TRACE
|
|
|
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* @brief Trace static easier user-defined code stub.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* This API is used to instrument user-defined trace code stub in source code, to track events simply.
|
|
|
* @attention
|
|
|
* None.
|
|
|
*
|
|
|
* @param TYPE [IN] Type #UINT32. The event type, only low 4 bits take effect.
|
|
|
* @param IDENTITY [IN] Type #UINTPTR. The subject of this event description.
|
|
|
* @param ... [IN] Type #UINTPTR. This piece of event's params.
|
|
|
* @retval None.
|
|
|
*
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @since Huawei LiteOS V200R005C00
|
|
|
*/
|
|
|
#define LOS_TRACE_EASY(TYPE, IDENTITY, ...) \
|
|
|
do { \
|
|
|
UINTPTR _inner[] = {0, ##__VA_ARGS__}; \
|
|
|
UINTPTR _n = sizeof(_inner) / sizeof(UINTPTR); \
|
|
|
if (g_traceEventHook != NULL) { \
|
|
|
g_traceEventHook(TRACE_USER_DEFAULT_FLAG | TYPE, (UINTPTR)IDENTITY, _n > 1 ? &_inner[1] : NULL, _n - 1); \
|
|
|
} \
|
|
|
} while (0)
|
|
|
#else
|
|
|
#define LOS_TRACE_EASY(...)
|
|
|
#endif
|
|
|
/*这段代码是一个宏定义,用于在源代码中插入用户自定义的跟踪代码存根,以简单地追踪事件
|
|
|
宏定义内部的实现逻辑如下:
|
|
|
|
|
|
创建一个名为_inner的数组,将参数存储其中。数组的第一个元素为0,表示未知。
|
|
|
获取_inner数组的长度,并判断是否大于1,并且全局变量g_traceEventHook不为空。
|
|
|
如果满足条件,则调用g_traceEventHook函数,将标志为TRACE_USER_DEFAULT_FLAG | TYPE的事件类型、身份标识、第二个元素以及后续元素传递给该函数。
|
|
|
宏定义结束*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* @brief Intialize the trace when the system startup.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* This API is used to intilize the trace for system level.
|
|
|
* @attention
|
|
|
* <ul>
|
|
|
* <li>This API can be called only after the memory is initialized. Otherwise, the Trace Init will be fail.</li>
|
|
|
* </ul>
|
|
|
*
|
|
|
* @param buf [IN] Type #VOID *. The ptr is trace buffer address, if ptr is NULL, system will malloc a new one in
|
|
|
* trace offline mode.
|
|
|
* @param size [IN] Type #UINT32. The trace buffer's size.
|
|
|
*
|
|
|
* @retval #LOS_ERRNO_TRACE_ERROR_STATUS 0x02001400: The trace status is not TRACE_UNINIT.
|
|
|
* @retval #LOS_ERRNO_TRACE_NO_MEMORY 0x02001401: The memory is not enough for initilize.
|
|
|
* @retval #LOS_ERRNO_TRACE_BUF_TOO_SMALL 0x02001402: Trace buf size not enough.
|
|
|
* @retval #LOS_ERRNO_TSK_TCB_UNAVAILABLE 0x02000211: No free task control block is available.
|
|
|
* @retval #LOS_ERRNO_TSK_MP_SYNC_RESOURCE 0x02000225: Mp sync resource create failed
|
|
|
* @retval #LOS_OK 0x00000000: The intialization is successful.
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_TraceInit
|
|
|
* @since Huawei LiteOS V200R005C00
|
|
|
*/
|
|
|
extern UINT32 LOS_TraceInit(VOID *buf, UINT32 size);
|
|
|
/*这段代码定义了一个名为LOS_TraceInit的函数,用于初始化系统级别的跟踪功能
|
|
|
函数实现逻辑如下:
|
|
|
|
|
|
首先判断跟踪状态是否为TRACE_UNINIT,如果不是则返回错误码LOS_ERRNO_TRACE_ERROR_STATUS。
|
|
|
然后检查是否有足够的内存来初始化跟踪,如果没有则返回LOS_ERRNO_TRACE_NO_MEMORY。
|
|
|
检查跟踪缓冲区的大小是否足够,如果不够则返回LOS_ERRNO_TRACE_BUF_TOO_SMALL。
|
|
|
调用LOS_MpCreate接口创建跟踪任务的同步资源,如果失败则返回错误码LOS_ERRNO_TSK_MP_SYNC_RESOURCE。
|
|
|
创建跟踪任务的控制块,如果失败则返回错误码LOS_ERRNO_TSK_TCB_UNAVAILABLE。
|
|
|
初始化跟踪任务的消息队列。
|
|
|
完成跟踪缓冲区的初始化。
|
|
|
初始化其他跟踪相关参数。
|
|
|
设置跟踪状态为TRACE_IDLE。
|
|
|
完成初始化。*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* @brief Start trace.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* This API is used to start trace.
|
|
|
* @attention
|
|
|
* <ul>
|
|
|
* <li>Start trace</li>
|
|
|
* </ul>
|
|
|
*
|
|
|
* @param None.
|
|
|
* @retval #LOS_ERRNO_TRACE_ERROR_STATUS 0x02001400: Trace start failed.
|
|
|
* @retval #LOS_OK 0x00000000: Trace start success.
|
|
|
*
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_TraceStart
|
|
|
* @since Huawei LiteOS V200R005C00
|
|
|
*/
|
|
|
extern UINT32 LOS_TraceStart(VOID);
|
|
|
/*这段代码定义了一个名为LOS_TraceStart的函数,用于启动跟踪功能*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* @brief Stop trace sample.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* This API is used to start trace sample.
|
|
|
* @attention
|
|
|
* <ul>
|
|
|
* <li>Stop trace sample</li>
|
|
|
* </ul>
|
|
|
*
|
|
|
* @param None.
|
|
|
* @retval #None.
|
|
|
*
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_TraceStop
|
|
|
* @since Huawei LiteOS V200R005C00
|
|
|
*/
|
|
|
extern VOID LOS_TraceStop(VOID);
|
|
|
/*这段代码定义了一个名为LOS_TraceStop的函数,用于停止跟踪采样*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* @brief Clear the trace buf.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* Clear the event frames in trace buf only at offline mode.
|
|
|
* @attention
|
|
|
* <ul>
|
|
|
* <li>This API can be called only after that trace buffer has been established.</li>
|
|
|
* Otherwise, the trace will be failed.</li>
|
|
|
* </ul>
|
|
|
*
|
|
|
* @param None.
|
|
|
* @retval #NA
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_TraceReset
|
|
|
* @since Huawei LiteOS V200R005C00
|
|
|
*/
|
|
|
extern VOID LOS_TraceReset(VOID);
|
|
|
/*这段代码定义了一个名为LOS_TraceReset的函数,用于清空跟踪缓冲区中的事件帧,仅在离线模式下有效*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* @brief Set trace event mask.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* Set trace event mask.
|
|
|
* @attention
|
|
|
* <ul>
|
|
|
* <li>Set trace event filter mask.</li>
|
|
|
* <li>The Default mask is (TRACE_HWI_FLAG | TRACE_TASK_FLAG), stands for switch on task and hwi events.</li>
|
|
|
* <li>Customize mask according to the type defined in enum LOS_TRACE_MASK to switch on corresponding module's
|
|
|
* trace.</li>
|
|
|
* <li>The system's trace mask will be overrode by the input parameter.</li>
|
|
|
* </ul>
|
|
|
*
|
|
|
* @param mask [IN] Type #UINT32. The mask used to filter events of LOS_TRACE_MASK.
|
|
|
* @retval #NA.
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_TraceEventMaskSet
|
|
|
* @since Huawei LiteOS V200R005C00
|
|
|
*/
|
|
|
extern VOID LOS_TraceEventMaskSet(UINT32 mask);
|
|
|
/*这段代码定义了一个名为LOS_TraceEventMaskSet的函数,用于设置跟踪事件的掩码*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* @brief Offline trace buffer display.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* Display trace buf data only at offline mode.
|
|
|
* @attention
|
|
|
* <ul>
|
|
|
* <li>This API can be called only after that trace stopped. Otherwise the trace dump will be failed.</li>
|
|
|
* <li>Trace data will be send to pipeline when user set toClient = TRUE. Otherwise it will be formatted and printed
|
|
|
* out.</li>
|
|
|
* </ul>
|
|
|
*
|
|
|
* @param toClient [IN] Type #BOOL. Whether send trace data to Client through pipeline.
|
|
|
* @retval #NA
|
|
|
*
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_TraceRecordDump
|
|
|
* @since Huawei LiteOS V200R005C00
|
|
|
*/
|
|
|
extern VOID LOS_TraceRecordDump(BOOL toClient);
|
|
|
/*这段代码定义了一个名为LOS_TraceRecordDump的函数,用于在离线模式下显示跟踪缓冲区数据*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* @brief Offline trace buffer export.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* Return the trace buf only at offline mode.
|
|
|
* @attention
|
|
|
* <ul>
|
|
|
* <li>This API can be called only after that trace buffer has been established. </li>
|
|
|
* <li>The return buffer's address is a critical resource, user can only ready.</li>
|
|
|
* </ul>
|
|
|
*
|
|
|
* @param NA
|
|
|
* @retval #OfflineHead* The trace buffer's address, analyze this buffer according to the structure of
|
|
|
* OfflineHead.
|
|
|
*
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_TraceRecordGet
|
|
|
* @since Huawei LiteOS V200R005C00
|
|
|
*/
|
|
|
extern OfflineHead *LOS_TraceRecordGet(VOID);
|
|
|
/*这段代码定义了一个名为LOS_TraceRecordGet的函数,用于在离线模式下导出跟踪缓冲区数据*/
|
|
|
/**
|
|
|
* @ingroup los_trace
|
|
|
* @brief Hwi num fliter hook.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* Hwi fliter function.
|
|
|
* @attention
|
|
|
* <ul>
|
|
|
* <li>Filter the hwi events by hwi num</li>
|
|
|
* </ul>
|
|
|
*
|
|
|
* @param hook [IN] Type #TRACE_HWI_FILTER_HOOK. The user defined hook for hwi num filter,
|
|
|
* the hook should return true if you don't want trace this hwi num.
|
|
|
* @retval #None
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_TraceHwiFilterHookReg
|
|
|
* @since Huawei LiteOS V200R005C00
|
|
|
*/
|
|
|
extern VOID LOS_TraceHwiFilterHookReg(TRACE_HWI_FILTER_HOOK hook);
|
|
|
/*这段代码定义了一个名为LOS_TraceHwiFilterHookReg的函数,用于注册硬件中断(Hwi)号码过滤钩子函数*/
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
}
|
|
|
#endif /* __cplusplus */
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
#endif /* _LOS_TRACE_H */
|