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: OS Abstract Layer. 15 */ 16 17 /** 18 * @defgroup osal_debug osal_debug 19 */ 20 #ifndef __OSAL_DEBUG_H__ 21 #define __OSAL_DEBUG_H__ 22 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif 27 #endif 28 29 #ifdef OSAL_DEBUG 30 #define OSAL_BUG() \ 31 do { \ 32 } while (1) 33 #else 34 #define OSAL_BUG() 35 #endif 36 #define OSAL_ASSERT(expr) \ 37 do { \ 38 if (!(expr)) { \ 39 osal_printk("\nASSERT failed at:\n" \ 40 " >Condition: %s\n", \ 41 #expr); \ 42 OSAL_BUG(); \ 43 } \ 44 } while (0) 45 46 47 #define OSAL_BUG_ON(expr) \ 48 do { \ 49 if (expr) { \ 50 osal_printk("BUG: failure at %d/%s()!\n", __LINE__, __func__); \ 51 OSAL_BUG(); \ 52 } \ 53 } while (0) 54 55 /** 56 * @ingroup osal_debug 57 * @brief Log printing function. 58 * 59 * @par Support System: 60 * linux liteos seliteos freertos. 61 */ 62 void osal_printk(const char *fmt, ...); 63 64 /** 65 * @ingroup osal_debug 66 * @brief Kernel panic function. 67 * 68 * @par Description: 69 * Stack function that prints kernel panics. 70 * After this function is called and stack information is printed, the system will fail to respond. 71 * 72 * @par Support System: 73 * linux liteos. 74 */ 75 void osal_panic(const char *fmt, const char *fun, int line, const char *cond); 76 77 /** 78 * @ingroup osal_debug 79 * @brief Kernel backtrace function. 80 * 81 * @par Description: 82 * Backtrace function that prints task call stack information traced from the running task. 83 * 84 * @par Support System: 85 * linux liteos. 86 */ 87 void osal_dump_stack(void); 88 89 /** 90 * @ingroup osal_debug 91 * @brief Kernel panic function. 92 * 93 * @par Description: 94 * If the condition is true, the system panics. 95 * 96 * @par Support System: 97 * nonos. 98 */ 99 void osal_bug_on(unsigned char condition); 100 101 /** 102 * @ingroup osal_debug 103 * @brief Kernel dcache flush function. 104 * 105 * @par Description: 106 * Flush cpu dcache 107 * 108 * @par Support System: 109 * liteos. 110 */ 111 void osal_flush_cache(void); 112 113 #ifdef __cplusplus 114 #if __cplusplus 115 } 116 #endif 117 #endif 118 #endif /* __OSAL_DEBUG_H__ */ 119