• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef PLATFORM_TRACE_H
10 #define PLATFORM_TRACE_H
11 #include "hdf_base.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif /* __cplusplus */
16 
17 typedef enum {
18     PLATFORM_TRACE_UINT_PARAM_SIZE_1 = 1,
19     PLATFORM_TRACE_UINT_PARAM_SIZE_2 = 2,
20     PLATFORM_TRACE_UINT_PARAM_SIZE_3 = 3,
21     PLATFORM_TRACE_UINT_PARAM_SIZE_4 = 4,
22     PLATFORM_TRACE_UINT_PARAM_SIZE_MAX = 5
23 } PLATFORM_TRACE_UINT_PARAM_SIZE;
24 
25 #define PLATFORM_TRACE_MODULE_MAX_NUM 255
26 /*
27  * if you want to use the trace function, please add your trace definition of the moudule.
28  * it can help you understand the meaning of the trace info.
29  */
30 typedef enum {
31     PLATFORM_TRACE_MODULE_I2S = 1,
32     PLATFORM_TRACE_MODULE_I2C,
33     PLATFORM_TRACE_MODULE_PWM,
34     PLATFORM_TRACE_MODULE_TIMER,
35     PLATFORM_TRACE_MODULE_UNITTEST,
36     PLATFORM_TRACE_MODULE_MAX = PLATFORM_TRACE_MODULE_MAX_NUM,
37 } PLATFORM_TRACE_MODULE;
38 
39 /*
40  * if you want to use the trace function, please add your trace definition of the moudule function.
41  * it can help you understand the meaning of the trace info.
42  */
43 typedef enum {
44     PLATFORM_TRACE_MODULE_I2S_FUN = PLATFORM_TRACE_MODULE_MAX_NUM + 1,
45     PLATFORM_TRACE_MODULE_I2S_READ_DATA,
46     PLATFORM_TRACE_MODULE_I2C_FUN = PLATFORM_TRACE_MODULE_I2S_FUN + 50,
47     PLATFORM_TRACE_MODULE_PWM_FUN = PLATFORM_TRACE_MODULE_I2C_FUN + 50,
48     PLATFORM_TRACE_MODULE_PWM_FUN_SET_CONFIG,
49     PLATFORM_TRACE_MODULE_TIMER_FUN = PLATFORM_TRACE_MODULE_PWM_FUN + 50,
50     PLATFORM_TRACE_MODULE_TIMER_FUN_SET,
51     PLATFORM_TRACE_MODULE_TIMER_FUN_ADD,
52     PLATFORM_TRACE_MODULE_TIMER_FUN_START,
53     PLATFORM_TRACE_MODULE_TIMER_FUN_STOP,
54     PLATFORM_TRACE_MODULE_UNITTEST_FUN = PLATFORM_TRACE_MODULE_TIMER_FUN + 50,
55     PLATFORM_TRACE_MODULE_UNITTEST_FUN_TEST,
56     PLATFORM_TRACE_MODULE_MAX_FUN = 5000,
57 } PLATFORM_TRACE_MODULE_FUN;
58 
59 struct PlatformTraceModuleExplain {
60     int moduleInfo;
61     const char *moduleMean;
62 };
63 
64 const char *PlatformTraceModuleExplainGet(PLATFORM_TRACE_MODULE traceModule);
65 const char *PlatformTraceFunExplainGet(PLATFORM_TRACE_MODULE_FUN traceFun);
66 const struct PlatformTraceModuleExplain *PlatformTraceModuleExplainGetAll(void);
67 int32_t PlatformTraceModuleExplainCount(void);
68 
69 int32_t PlatformTraceStart(void);
70 int32_t PlatformTraceStop(void);
71 void PlatformTraceInfoDump(void);
72 void PlatformTraceReset(void);
73 
74 void __attribute__((format(printf, 3, 4))) PlatformTraceAddMsg(const char *module, const char *moduleFun,
75     const char *fmt, ...);
76 void PlatformTraceAddUintMsg(int module, int moduleFun, const uint infos[], uint8_t size);
77 
78 #ifdef __cplusplus
79 }
80 #endif /* __cplusplus */
81 
82 #endif /* PLATFORM_TRACE_H */
83