• 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 = 0x1,
32     PLATFORM_TRACE_MODULE_I2C = 0x2,
33     PLATFORM_TRACE_MODULE_PWM = 0x3,
34     PLATFORM_TRACE_MODULE_TIMER = 0x4,
35     PLATFORM_TRACE_MODULE_ADC = 0x5,
36     PLATFORM_TRACE_MODULE_DAC = 0x6,
37     PLATFORM_TRACE_MODULE_PIN = 0x7,
38     PLATFORM_TRACE_MODULE_SPI = 0x8,
39     PLATFORM_TRACE_MODULE_WATCHDOG = 0x9,
40     PLATFORM_TRACE_MODULE_UNITTEST = 0xa,
41     PLATFORM_TRACE_MODULE_MAX = PLATFORM_TRACE_MODULE_MAX_NUM,
42 } PLATFORM_TRACE_MODULE;
43 
44 /*
45  * if you want to use the trace function, please add your trace definition of the moudule function.
46  * it can help you understand the meaning of the trace info.
47  */
48 typedef enum {
49     PLATFORM_TRACE_MODULE_I2S_FUN = PLATFORM_TRACE_MODULE_MAX_NUM + 1,
50     PLATFORM_TRACE_MODULE_I2S_READ_DATA,
51     PLATFORM_TRACE_MODULE_I2S_WRITE_DATA,
52     PLATFORM_TRACE_MODULE_I2C_FUN = PLATFORM_TRACE_MODULE_I2S_FUN + 50,
53     PLATFORM_TRACE_MODULE_PWM_FUN = PLATFORM_TRACE_MODULE_I2C_FUN + 50,
54     PLATFORM_TRACE_MODULE_PWM_FUN_SET_CONFIG,
55     PLATFORM_TRACE_MODULE_PWM_FUN_GET_CONFIG,
56     PLATFORM_TRACE_MODULE_TIMER_FUN = PLATFORM_TRACE_MODULE_PWM_FUN + 50,
57     PLATFORM_TRACE_MODULE_TIMER_FUN_SET,
58     PLATFORM_TRACE_MODULE_TIMER_FUN_ADD,
59     PLATFORM_TRACE_MODULE_TIMER_FUN_START,
60     PLATFORM_TRACE_MODULE_TIMER_FUN_STOP,
61     PLATFORM_TRACE_MODULE_ADC_FUN = PLATFORM_TRACE_MODULE_TIMER_FUN + 50,
62     PLATFORM_TRACE_MODULE_ADC_FUN_START,
63     PLATFORM_TRACE_MODULE_ADC_FUN_STOP,
64     PLATFORM_TRACE_MODULE_DAC_FUN = PLATFORM_TRACE_MODULE_ADC_FUN + 50,
65     PLATFORM_TRACE_MODULE_DAC_FUN_START,
66     PLATFORM_TRACE_MODULE_DAC_FUN_STOP,
67     PLATFORM_TRACE_MODULE_PIN_FUN = PLATFORM_TRACE_MODULE_DAC_FUN + 50,
68     PLATFORM_TRACE_MODULE_PIN_FUN_SET,
69     PLATFORM_TRACE_MODULE_PIN_FUN_GET,
70     PLATFORM_TRACE_MODULE_SPI_FUN = PLATFORM_TRACE_MODULE_PIN_FUN + 50,
71     PLATFORM_TRACE_MODULE_SPI_FUN_SET,
72     PLATFORM_TRACE_MODULE_SPI_FUN_GET,
73     PLATFORM_TRACE_MODULE_WATCHDOG_FUN = PLATFORM_TRACE_MODULE_SPI_FUN + 50,
74     PLATFORM_TRACE_MODULE_WATCHDOG_FUN_START,
75     PLATFORM_TRACE_MODULE_WATCHDOG_FUN_STOP,
76     PLATFORM_TRACE_MODULE_UNITTEST_FUN = PLATFORM_TRACE_MODULE_WATCHDOG_FUN + 50,
77     PLATFORM_TRACE_MODULE_UNITTEST_FUN_TEST,
78     PLATFORM_TRACE_MODULE_MAX_FUN = 5000,
79 } PLATFORM_TRACE_MODULE_FUN;
80 
81 struct PlatformTraceModuleExplain {
82     int moduleInfo;
83     const char *moduleMean;
84 };
85 
86 const char *PlatformTraceModuleExplainGet(PLATFORM_TRACE_MODULE traceModule);
87 const char *PlatformTraceFunExplainGet(PLATFORM_TRACE_MODULE_FUN traceFun);
88 const struct PlatformTraceModuleExplain *PlatformTraceModuleExplainGetAll(void);
89 int32_t PlatformTraceModuleExplainCount(void);
90 
91 int32_t PlatformTraceStart(void);
92 int32_t PlatformTraceStop(void);
93 void PlatformTraceInfoDump(void);
94 void PlatformTraceReset(void);
95 
96 void __attribute__((format(printf, 3, 4))) PlatformTraceAddMsg(const char *module, const char *moduleFun,
97     const char *fmt, ...);
98 void PlatformTraceAddUintMsg(int module, int moduleFun, const unsigned int infos[], uint8_t size);
99 
100 #ifdef __cplusplus
101 }
102 #endif /* __cplusplus */
103 
104 #endif /* PLATFORM_TRACE_H */
105