更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_printf.h
浏览该文件的文档.
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_printf Printf
34 * @ingroup kernel
35 */
36
37#ifndef _LOS_PRINTF_H
38#define _LOS_PRINTF_H
39
40#ifdef LOSCFG_LIB_LIBC
41#include "stdarg.h"
42#endif
43#include "los_typedef.h"
44
45#ifdef __cplusplus
46#if __cplusplus
47extern "C" {
48#endif /* __cplusplus */
49#endif /* __cplusplus */
50
51//见于\third_party\musl\kernel\include\*.h
52extern VOID LOS_LkPrint(INT32 level, const CHAR *func, INT32 line, const CHAR *fmt, ...);
53
54#define LOS_EMG_LEVEL 0 //用于紧急事件消息,它们一般是系统崩溃之前提示的消息
55
56#define LOS_COMMON_LEVEL (LOS_EMG_LEVEL + 1) //日志等级:普通
57
58#define LOS_ERR_LEVEL (LOS_COMMON_LEVEL + 1) //日志等级:错误类,用于报告错误状态,设备驱动程序会经常使用它来报告来自硬件的问题
59
60#define LOS_WARN_LEVEL (LOS_ERR_LEVEL + 1) //日志等级:警告类,对可能出现问题的情况进行警告,但这类错误通常不会对系统造成严重的问题
61
62#define LOS_INFO_LEVEL (LOS_WARN_LEVEL + 1) //日志等级:信息类,提示性信息,很多驱动程序在启动时用这个级别来打印硬件信息
63
64#define LOS_DEBUG_LEVEL (LOS_INFO_LEVEL + 1) //日志等级:调试类,用于调试信息
65
66#define LOS_TRACE_LEVEL (LOS_DEBUG_LEVEL + 1) //日志等级:跟踪类
67
68#define PRINT_LEVEL LOS_ERR_LEVEL //默认打印错误类
69
70typedef VOID (*pf_OUTPUT)(const CHAR *fmt, ...);
71
72/**
73 * @ingroup los_printf
74 * @brief Format and print data.
75 *
76 * @par Description:
77 * Print argument(s) according to fmt.
78 *
79 * @attention
80 * <ul>
81 * <li>None</li>
82 * </ul>
83 *
84 * @param fmt [IN] Type char* controls the ouput as in C printf.
85 *
86 * @retval None
87 * @par Dependency:
88 * <ul><li>los_printf.h: the header file that contains the API declaration.</li></ul>
89 * @see printf
90 */
91#ifndef LOSCFG_LIBC_NEWLIB
92extern void dprintf(const char *fmt, ...);
93#endif
94
95#define PRINT_DEBUG(fmt, args...) LOS_LkPrint(LOS_DEBUG_LEVEL, __FUNCTION__, __LINE__, fmt, ##args)
96#define PRINT_INFO(fmt, args...) LOS_LkPrint(LOS_INFO_LEVEL, __FUNCTION__, __LINE__, fmt, ##args)
97#define PRINT_WARN(fmt, args...) LOS_LkPrint(LOS_WARN_LEVEL, __FUNCTION__, __LINE__, fmt, ##args)
98#define PRINT_ERR(fmt, args...) LOS_LkPrint(LOS_ERR_LEVEL, __FUNCTION__, __LINE__, fmt, ##args)
99#define PRINTK(fmt, args...) LOS_LkPrint(LOS_COMMON_LEVEL, __FUNCTION__, __LINE__, fmt, ##args)
100#define PRINT_EMG(fmt, args...) LOS_LkPrint(LOS_EMG_LEVEL, __FUNCTION__, __LINE__, fmt, ##args)
101#define PRINT_RELEASE(fmt, args...) LOS_LkPrint(LOS_COMMON_LEVEL, __FUNCTION__, __LINE__, fmt, ##args)
102#define PRINT_TRACE(fmt, args...) LOS_LkPrint(LOS_TRACE_LEVEL, __FUNCTION__, __LINE__, fmt, ##args)
103
104typedef enum { //输出类型
106 UART_OUTPUT = 1, //串口输出
107 CONSOLE_OUTPUT = 2, //控制台输出
108 EXC_OUTPUT = 3 //出现异常时的输出
110
111extern VOID OsVprintf(const CHAR *fmt, va_list ap, OutputType type);
112
113#define UART_WITHOUT_LOCK 0
114#define UART_WITH_LOCK 1
115extern VOID UartPuts(const CHAR *s, UINT32 len, BOOL isLock);
116#ifdef __cplusplus
117#if __cplusplus
118}
119#endif /* __cplusplus */
120#endif /* __cplusplus */
121
122#endif /* _LOS_PRINTF_H */
void dprintf(const char *fmt,...)
Format and print data.
VOID OsVprintf(const CHAR *fmt, va_list ap, OutputType type)
printf由 print 和 format 两个单词构成,格式化输出函数, 一般用于向标准输出设备按规定格式输出信息
Definition: los_printf.c:138
VOID LOS_LkPrint(INT32 level, const CHAR *func, INT32 line, const CHAR *fmt,...)
打印
Definition: los_printf.c:276
OutputType
Definition: los_printf.h:104
@ EXC_OUTPUT
Definition: los_printf.h:108
@ NO_OUTPUT
Definition: los_printf.h:105
@ UART_OUTPUT
Definition: los_printf.h:106
@ CONSOLE_OUTPUT
Definition: los_printf.h:107
VOID UartPuts(const CHAR *s, UINT32 len, BOOL isLock)
VOID(* pf_OUTPUT)(const CHAR *fmt,...)
Definition: los_printf.h:70
signed int INT32
Definition: los_typedef.h:60
unsigned int UINT32
Definition: los_typedef.h:57
char CHAR
Definition: los_typedef.h:63
size_t BOOL
Definition: los_typedef.h:88