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: dfx print header file 15 */ 16 17 #ifndef DFX_PRINT_H 18 #define DFX_PRINT_H 19 20 #ifdef CONFIG_DFX_SUPPORT_PRINT 21 #include <stdint.h> 22 #include "debug_print.h" 23 #endif 24 25 typedef enum { 26 DFX_PRINT_LEVEL_INFO = 0, 27 DFX_PRINT_LEVEL_WARN = 1, 28 DFX_PRINT_LEVEL_ERROR = 2, 29 DFX_PRINT_LEVEL_MAX 30 } dfx_print_level; 31 32 #ifdef CONFIG_DFX_SUPPORT_PRINT 33 34 uint8_t dfx_print_get_level(void); 35 void dfx_print_set_level(uint8_t level); 36 37 #define dfx_print_info(fmt, args...) do { \ 38 if (dfx_print_get_level() <= DFX_PRINT_LEVEL_INFO) { \ 39 PRINT(fmt, ##args); \ 40 } \ 41 } while (0) 42 43 #define dfx_print_warn(fmt, args...) do { \ 44 if (dfx_print_get_level() <= DFX_PRINT_LEVEL_WARN) { \ 45 PRINT(fmt, ##args); \ 46 } \ 47 } while (0) 48 49 #define dfx_print_error(fmt, args...) do { \ 50 if (dfx_print_get_level() <= DFX_PRINT_LEVEL_ERROR) { \ 51 PRINT(fmt, ##args); \ 52 } \ 53 } while (0) 54 55 #define dfx_print(level, fmt, args...) do { \ 56 if (dfx_print_get_level() <= level) { \ 57 PRINT(fmt, ##args); \ 58 } \ 59 } while (0) 60 #else 61 62 #define dfx_print_info(fmt, args...) PRINT(fmt, ##args) 63 #define dfx_print_warn(fmt, args...) PRINT(fmt, ##args) 64 #define dfx_print_error(fmt, args...) PRINT(fmt, ##args) 65 #define dfx_print(level, fmt, args...) PRINT(fmt, ##args) 66 67 #endif 68 #endif /* DFX_PRINT_H */