| [1] | 1 | /* | 
|---|
 | 2 |  * printk.h - Kernel Log & debug messages API definition. | 
|---|
 | 3 |  *  | 
|---|
 | 4 |  * authors  Alain Greiner (2016) | 
|---|
 | 5 |  * | 
|---|
 | 6 |  * Copyright (c) UPMC Sorbonne Universites | 
|---|
 | 7 |  * | 
|---|
 | 8 |  * This file is part of ALMOS-MKH. | 
|---|
 | 9 |  * | 
|---|
 | 10 |  * ALMOS-MKH is free software; you can redistribute it and/or modify it | 
|---|
 | 11 |  * under the terms of the GNU General Public License as published by | 
|---|
 | 12 |  * the Free Software Foundation; version 2.0 of the License. | 
|---|
 | 13 |  * | 
|---|
 | 14 |  * ALMOS-MKH is distributed in the hope that it will be useful, but | 
|---|
 | 15 |  * WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
 | 16 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
 | 17 |  * General Public License for more details. | 
|---|
 | 18 |  * | 
|---|
 | 19 |  * You should have received a copy of the GNU General Public License | 
|---|
 | 20 |  * along with ALMOS-MKH; if not, write to the Free Software Foundation, | 
|---|
 | 21 |  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 
|---|
 | 22 |  */ | 
|---|
 | 23 |  | 
|---|
 | 24 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
 | 25 | // The printk.c and printk.h files define the functions used by the kernel | 
|---|
| [5] | 26 | // to display messages on a text terminal.  | 
|---|
 | 27 | // Two access modes are supported: | 
|---|
 | 28 | // - The printk() function displays kernel messages on the kernel terminal TXT0, | 
|---|
 | 29 | //   using a busy waiting policy: It calls directly the relevant TXT driver,  | 
|---|
 | 30 | //   after taking the TXT0 chdev lock for exclusive access to the TXT0 terminal. | 
|---|
 | 31 | // - The user_printk() function displays messages on the calling thread private | 
|---|
 | 32 | //   terminal, using a descheduling policy: it register the request in the selected | 
|---|
 | 33 | //   TXT chdev waiting queue and deschedule. The calling thread is reactivated by  | 
|---|
 | 34 | //   the IRQ signaling completion. | 
|---|
 | 35 | // Both functions use the generic TXT device to call the proper implementation | 
|---|
| [1] | 36 | // dependant TXT driver. | 
|---|
| [5] | 37 | // Finally these files define a set of conditionnal trace <***_dmsg> for debug. | 
|---|
| [1] | 38 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
 | 39 |  | 
|---|
 | 40 | #ifndef _PRINTK_H | 
|---|
 | 41 | #define _PRINTK_H | 
|---|
 | 42 |  | 
|---|
| [5] | 43 | #include <hal_types.h> | 
|---|
 | 44 | #include <stdarg.h> | 
|---|
| [1] | 45 |  | 
|---|
| [5] | 46 |  | 
|---|
 | 47 | /********************************************************************************** | 
|---|
 | 48 |  * This function displays a formated string on the kernel terminal TXT0, | 
|---|
 | 49 |  * using a busy waiting policy: It calls directly the relevant TXT driver,  | 
|---|
 | 50 |  * after taking the TXT0 chdev lock for exclusive access to the TXT0 terminal. | 
|---|
 | 51 |  ********************************************************************************** | 
|---|
 | 52 |  * @ format     : formated string. | 
|---|
 | 53 |  *********************************************************************************/ | 
|---|
| [1] | 54 | extern void         printk( char* format, ... ); | 
|---|
 | 55 |  | 
|---|
| [5] | 56 | /********************************************************************************** | 
|---|
 | 57 |  * Display a formated string on the calling thread private terminal, using a  | 
|---|
 | 58 |  * descheduling policy: it register the request in the selected TXT chdev waiting | 
|---|
 | 59 |  * queue and deschedule. IT is reactivated by the IRQ signaling completion. | 
|---|
 | 60 |  * Not fully implemented yet ( use TXT0 in deschedling mode ). | 
|---|
 | 61 |  ********************************************************************************** | 
|---|
 | 62 |  * @ format     : formated string. | 
|---|
 | 63 |  *********************************************************************************/ | 
|---|
| [1] | 64 | extern void         user_printk( char* format, ... ); | 
|---|
 | 65 |  | 
|---|
| [5] | 66 | /********************************************************************************** | 
|---|
 | 67 |  * This function displaya "PANIC" message and force the calling core in | 
|---|
 | 68 |  * sleeping mode if a Boolean condition is false. | 
|---|
 | 69 |  * These functions are actually used to debug the kernel... | 
|---|
 | 70 |  ********************************************************************************** | 
|---|
 | 71 |  * @ condition     : condition that must be true. | 
|---|
 | 72 |  * @ function_name : name of the calling function. | 
|---|
 | 73 |  * @ string        : error message if condition is false.  | 
|---|
 | 74 |  *********************************************************************************/ | 
|---|
 | 75 | inline void assert( bool_t       condition, | 
|---|
 | 76 |                     const char * function_name, | 
|---|
 | 77 |                     char       * string ); | 
|---|
 | 78 |  | 
|---|
| [1] | 79 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
 | 80 | //       Conditionnal debug macros | 
|---|
 | 81 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
 | 82 |  | 
|---|
| [5] | 83 | #if CONFIG_CONTEXT_DEBUG | 
|---|
 | 84 | #define context_dmsg(...)   printk(__VA_ARGS__) | 
|---|
 | 85 | #else | 
|---|
 | 86 | #define context_dmsg(...) | 
|---|
 | 87 | #endif | 
|---|
 | 88 |  | 
|---|
| [1] | 89 | #if CONFIG_CORE_DEBUG | 
|---|
| [5] | 90 | #define core_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 91 | #else | 
|---|
 | 92 | #define core_dmsg(...) | 
|---|
 | 93 | #endif | 
|---|
 | 94 |  | 
|---|
 | 95 | #if CONFIG_DQDT_DEBUG | 
|---|
| [5] | 96 | #define dma_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 97 | #else | 
|---|
| [5] | 98 | #define dma_dmsg(...) | 
|---|
 | 99 | #endif | 
|---|
 | 100 |  | 
|---|
 | 101 | #if CONFIG_DQDT_DEBUG | 
|---|
 | 102 | #define dqdt_dmsg(...)   printk(__VA_ARGS__) | 
|---|
 | 103 | #else | 
|---|
| [1] | 104 | #define dqdt_dmsg(...) | 
|---|
 | 105 | #endif | 
|---|
 | 106 |  | 
|---|
 | 107 | #if CONFIG_ELF_DEBUG | 
|---|
| [5] | 108 | #define elf_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 109 | #else | 
|---|
 | 110 | #define elf_dmsg(...) | 
|---|
 | 111 | #endif | 
|---|
 | 112 |  | 
|---|
| [5] | 113 | #if CONFIG_EXEC_DEBUG | 
|---|
 | 114 | #define exec_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 115 | #else | 
|---|
| [5] | 116 | #define exec_dmsg(...) | 
|---|
| [1] | 117 | #endif | 
|---|
 | 118 |  | 
|---|
| [5] | 119 | #if CONFIG_FBF_DEBUG | 
|---|
 | 120 | #define fbf_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 121 | #else | 
|---|
| [5] | 122 | #define fbf_dmsg(...) | 
|---|
| [1] | 123 | #endif | 
|---|
 | 124 |  | 
|---|
| [5] | 125 | #if CONFIG_FORK_DEBUG | 
|---|
 | 126 | #define fork_dmsg(...)   printk(__VA_ARGS__) | 
|---|
 | 127 | #else | 
|---|
 | 128 | #define fork_dmsg(...) | 
|---|
 | 129 | #endif | 
|---|
 | 130 |  | 
|---|
| [1] | 131 | #if CONFIG_ICU_DEBUG | 
|---|
| [5] | 132 | #define icu_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 133 | #else | 
|---|
 | 134 | #define icu_dmsg(...) | 
|---|
 | 135 | #endif | 
|---|
 | 136 |  | 
|---|
 | 137 | #if CONFIG_IOC_DEBUG | 
|---|
| [5] | 138 | #define ioc_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 139 | #else | 
|---|
 | 140 | #define ioc_dmsg(...) | 
|---|
 | 141 | #endif | 
|---|
 | 142 |  | 
|---|
| [5] | 143 | #if CONFIG_KCM_DEBUG | 
|---|
 | 144 | #define kcm_dmsg(...) printk(__VA_ARGS__) | 
|---|
 | 145 | #else | 
|---|
 | 146 | #define kcm_dmsg(...) | 
|---|
 | 147 | #endif | 
|---|
 | 148 |  | 
|---|
 | 149 | #if CONFIG_KHM_DEBUG | 
|---|
 | 150 | #define khm_dmsg(...) printk(__VA_ARGS__) | 
|---|
 | 151 | #else | 
|---|
 | 152 | #define khm_dmsg(...) | 
|---|
 | 153 | #endif | 
|---|
 | 154 |  | 
|---|
| [1] | 155 | #if CONFIG_KINIT_DEBUG | 
|---|
 | 156 | #define kinit_dmsg(...) printk(__VA_ARGS__) | 
|---|
 | 157 | #else | 
|---|
 | 158 | #define kinit_dmsg(...) | 
|---|
 | 159 | #endif | 
|---|
 | 160 |  | 
|---|
 | 161 | #if CONFIG_KMEM_DEBUG | 
|---|
 | 162 | #define kmem_dmsg(...) printk(__VA_ARGS__) | 
|---|
 | 163 | #else | 
|---|
 | 164 | #define kmem_dmsg(...) | 
|---|
 | 165 | #endif | 
|---|
 | 166 |  | 
|---|
| [5] | 167 | #if CONFIG_MAPPER_DEBUG | 
|---|
 | 168 | #define mapper_dmsg(...)   printk(__VA_ARGS__) | 
|---|
 | 169 | #else | 
|---|
 | 170 | #define mapper_dmsg(...) | 
|---|
 | 171 | #endif | 
|---|
 | 172 |  | 
|---|
| [1] | 173 | #if CONFIG_MMC_DEBUG | 
|---|
| [5] | 174 | #define mmc_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 175 | #else | 
|---|
 | 176 | #define mmc_dmsg(...) | 
|---|
 | 177 | #endif | 
|---|
 | 178 |  | 
|---|
 | 179 | #if CONFIG_NIC_DEBUG | 
|---|
| [5] | 180 | #define nic_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 181 | #else | 
|---|
 | 182 | #define nic_dmsg(...) | 
|---|
 | 183 | #endif | 
|---|
 | 184 |  | 
|---|
 | 185 | #if CONFIG_PIC_DEBUG | 
|---|
| [5] | 186 | #define pic_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 187 | #else | 
|---|
 | 188 | #define pic_dmsg(...) | 
|---|
 | 189 | #endif | 
|---|
 | 190 |  | 
|---|
| [5] | 191 | #if CONFIG_PPM_DEBUG | 
|---|
 | 192 | #define ppm_dmsg(...)   printk(__VA_ARGS__) | 
|---|
 | 193 | #else | 
|---|
 | 194 | #define ppm_dmsg(...) | 
|---|
 | 195 | #endif | 
|---|
 | 196 |  | 
|---|
| [1] | 197 | #if CONFIG_PROCESS_DEBUG | 
|---|
| [5] | 198 | #define process_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 199 | #else | 
|---|
 | 200 | #define process_dmsg(...) | 
|---|
 | 201 | #endif | 
|---|
 | 202 |  | 
|---|
 | 203 | #if CONFIG_RPC_DEBUG | 
|---|
| [5] | 204 | #define rpc_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 205 | #else | 
|---|
 | 206 | #define rpc_dmsg(...) | 
|---|
 | 207 | #endif | 
|---|
 | 208 |  | 
|---|
 | 209 | #if CONFIG_SCHED_DEBUG | 
|---|
| [5] | 210 | #define sched_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 211 | #else | 
|---|
 | 212 | #define sched_dmsg(...) | 
|---|
 | 213 | #endif | 
|---|
 | 214 |  | 
|---|
 | 215 | #if CONFIG_THREAD_DEBUG | 
|---|
| [5] | 216 | #define thread_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 217 | #else | 
|---|
 | 218 | #define thread_dmsg(...) | 
|---|
 | 219 | #endif | 
|---|
 | 220 |  | 
|---|
 | 221 | #if CONFIG_TXT_DEBUG | 
|---|
| [5] | 222 | #define txt_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 223 | #else | 
|---|
 | 224 | #define txt_dmsg(...) | 
|---|
 | 225 | #endif | 
|---|
 | 226 |  | 
|---|
 | 227 | #if CONFIG_VFS_DEBUG | 
|---|
| [5] | 228 | #define vfs_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 229 | #else | 
|---|
 | 230 | #define vfs_dmsg(...) | 
|---|
 | 231 | #endif | 
|---|
 | 232 |  | 
|---|
 | 233 | #if CONFIG_VMM_DEBUG | 
|---|
| [5] | 234 | #define vmm_dmsg(...)   printk(__VA_ARGS__) | 
|---|
| [1] | 235 | #else | 
|---|
 | 236 | #define vmm_dmsg(...) | 
|---|
 | 237 | #endif | 
|---|
 | 238 |  | 
|---|
 | 239 |  | 
|---|
 | 240 | #endif  // _PRINTK_H | 
|---|
 | 241 |  | 
|---|
 | 242 | // Local Variables: | 
|---|
 | 243 | // tab-width: 4 | 
|---|
 | 244 | // c-basic-offset: 4 | 
|---|
 | 245 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) | 
|---|
 | 246 | // indent-tabs-mode: nil | 
|---|
 | 247 | // End: | 
|---|
 | 248 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 | 
|---|
 | 249 |  | 
|---|