• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: hcc commom types.
15  * Author:
16  * Create: 2021-05-13
17  */
18 
19 #ifndef HCC_COMMON_TYPE_H
20 #define HCC_COMMON_TYPE_H
21 
22 #include "td_type.h"
23 #if defined(HSO_SUPPORT)
24 #include "log_def.h"
25 #include "log_module_id.h"
26 #endif
27 
28 #if !(defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION))
29 #if defined(HSO_SUPPORT)
30 #if defined(CONFIG_HCC_SUPPORT_NON_OS)
31 #include "log_oam_logger.h"
32 #else
33 #include "soc_diag_util.h"
34 #endif
35 #endif
36 #include "debug_print.h"
37 #endif
38 
39 /* HCC 打印接口 */
40 #ifdef CONFIG_HCC_DEBUG_PRINT
41 #if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
42 #define hcc_printf(fmt, arg...) printk("[HCC] "fmt, ##arg)
43 #elif defined(CONFIG_HCC_SUPPORT_NON_OS)
44 #define hcc_printf(fmt, arg...)         print_str("[HCC] "fmt, ##arg)
45 #else
46 #define hcc_printf(fmt, arg...)         PRINT("[HCC] "fmt, ##arg)
47 #endif
48 
49 #else
50 #define hcc_printf(fmt, arg...)
51 #endif /* CONFIG_HCC_DEBUG_PRINT */
52 
53 #if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
54 #define hcc_debug(fmt, arg...) printk("[HCC] "fmt, ##arg)
55 #define hcc_printf_err_log(fmt, arg...) printk("[HCC] [ERROR] "fmt, ##arg)
56 #define hcc_dfx_print(fmt, arg...)         printk("[HCC] [DFX] "fmt, ##arg)
57 #elif defined(CONFIG_HCC_SUPPORT_NON_OS)
58 #define hcc_debug(fmt, arg...) print_str("[HCC] " fmt, ##arg)
59 #if defined(HSO_SUPPORT)
60 #define var_args_max_12(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, ...)     a12
61 #define var_args_cnt(unused, args...)   var_args_max_12(unused, ##args, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
62 #define hcc_printf_err_log(fmt, arg...) pf_log_alter(0, 0, 0, fmt, var_args_cnt(unused, ##arg), ##arg)
63 #else
64 #define hcc_printf_err_log(fmt, arg...) print_str("[HCC] [ERROR] "fmt, ##arg)
65 #endif
66 #define hcc_dfx_print(fmt, arg...) print_str("[HCC] " fmt, ##arg)
67 
68 #else
69 #define hcc_debug(fmt, arg...)         PRINT(fmt, ##arg)
70 #if defined(HSO_SUPPORT)
71 #define hcc_printf_err_log(fmt, arg...) uapi_diag_error_log(0, fmt, ##arg)
72 #else
73 #define hcc_printf_err_log(fmt, arg...) PRINT("[HCC] [ERROR] "fmt, ##arg)
74 #endif
75 
76 #define hcc_dfx_print(fmt, arg...)        PRINT(fmt, ##arg)
77 #endif
78 
79 #ifdef HCC_PRINT_PERFORM
80 #include "tcxo.h"
hcc_test_get_us(td_void)81 static inline td_u64 hcc_test_get_us(td_void)
82 {
83     return uapi_tcxo_get_us();
84 }
85 #else
hcc_test_get_us(td_void)86 static inline td_u64 hcc_test_get_us(td_void)
87 {
88     return 0;
89 }
90 #endif
hcc_calc_time_us(td_u64 start,td_u64 stop)91 static inline td_u64 hcc_calc_time_us(td_u64 start, td_u64 stop)
92 {
93     return start > stop ? (start - stop) : (stop - start);
94 }
95 #endif /* HCC_COMMON_TYPE_H */
96