更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
lk

类型定义

typedef VOID(* LK_FUNC) (INT32 level, const CHAR *func, INT32 line, const CHAR *fmt, va_list ap)
 Define an printf handling function hook. 更多...
 

函数

VOID LOS_LkPrint (INT32 level, const CHAR *func, INT32 line, const CHAR *fmt,...)
 print log. 更多...
 
VOID LOS_LkRegHook (LK_FUNC hook)
 register print func. 更多...
 

详细描述

类型定义说明

◆ LK_FUNC

typedef VOID(* LK_FUNC) (INT32 level, const CHAR *func, INT32 line, const CHAR *fmt, va_list ap)

Define an printf handling function hook.

Description:
This API is used to define the printf handling function hook.
注意
None.
参数
level[IN] print level.
func[IN] means which func calls print func.
line[IN] means which line calls print func.
fmt[IN] other infomation by user define.
ap[IN] the para list.
返回值
None.
Dependency:
shell_lk.h: the header file that contains the API declaration.
参见
None.

在文件 shell_lk.h74 行定义.

函数说明

◆ LOS_LkPrint()

VOID LOS_LkPrint ( INT32  level,
const CHAR func,
INT32  line,
const CHAR fmt,
  ... 
)

print log.

Description:
  • This API is used to LK print function.
参数
level[IN] print level.
func[IN] means which func calls print func.
line[IN] means which line calls print func.
fmt[IN] other infomation by user define
返回值
NONE
Dependency:
  • shell_lk.h: the header file that contains the API declaration.

print log.

在文件 los_printf.c276 行定义.

277{
278 va_list ap;
279
280 if (level > PRINT_LEVEL) {
281 return;
282 }
283
284 if ((level != LOS_COMMON_LEVEL) && ((level > LOS_EMG_LEVEL) && (level <= LOS_TRACE_LEVEL))) {
285 PRINTK("[%s][%s:%s]", g_logString[level],
286 ((OsCurrProcessGet() == NULL) ? "NULL" : OsCurrProcessGet()->processName),
287 ((OsCurrTaskGet() == NULL) ? "NULL" : OsCurrTaskGet()->taskName));
288 }
289
290 va_start(ap, fmt);
291 OsVprintf(fmt, ap, CONSOLE_OUTPUT);//控制台打印
292#ifdef LOSCFG_SAVE_EXCINFO
293 if (OsGetSystemStatus() == OS_SYSTEM_EXC_CURR_CPU) {
294 WriteExcBufVa(fmt, ap);
295 }
296#endif
297 va_end(ap);
298}
UINT32 OsGetSystemStatus(VOID)
获取系统状态
Definition: los_exc.c:181
VOID WriteExcBufVa(const CHAR *format, va_list arglist)
vsnprintf 为C标准库可变参数的实现函数 见于 ..\third_party\musl\kernel\src\stdio\vsnprintf.c
Definition: los_excinfo.c:99
VOID OsVprintf(const CHAR *fmt, va_list ap, OutputType type)
printf由 print 和 format 两个单词构成,格式化输出函数, 一般用于向标准输出设备按规定格式输出信息
Definition: los_printf.c:138
const CHAR * g_logString[]
Definition: los_printf.c:54
@ CONSOLE_OUTPUT
Definition: los_printf.h:107
STATIC INLINE LosProcessCB * OsCurrProcessGet(VOID)
STATIC INLINE LosTaskCB * OsCurrTaskGet(VOID)
函数调用图:

◆ LOS_LkRegHook()

VOID LOS_LkRegHook ( LK_FUNC  hook)

register print func.

Description:
  • This API is used to registe a hook function to LK.
参数
LK_FUNC[IN] the print func.
返回值
NONE
Dependency:
  • shell_lk.h: the header file that contains the API declaration.

register print func.

在文件 shell_lk.c228 行定义.

229{
230 g_osLkHook = hook;
231}
LK_FUNC g_osLkHook
Definition: shell_lk.c:71
这是这个函数的调用关系图: