[1] | 1 | /* |
---|
| 2 | * printk.h - Kernel Log & debug messages API definition. |
---|
[372] | 3 | * |
---|
[437] | 4 | * authors Alain Greiner (2016,2017,2018) |
---|
[1] | 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 |
---|
[372] | 26 | // to display messages on a text terminal. |
---|
[5] | 27 | // Two access modes are supported: |
---|
| 28 | // - The printk() function displays kernel messages on the kernel terminal TXT0, |
---|
[372] | 29 | // using a busy waiting policy: It calls directly the relevant TXT driver, |
---|
[5] | 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 |
---|
[372] | 33 | // TXT chdev waiting queue and deschedule. The calling thread is reactivated by |
---|
| 34 | // the IRQ signalling completion. |
---|
[5] | 35 | // Both functions use the generic TXT device to call the proper implementation |
---|
[1] | 36 | // dependant TXT driver. |
---|
[372] | 37 | // Finally these files define a set of conditional trace <***_dmsg> for debug. |
---|
[1] | 38 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 39 | |
---|
| 40 | #ifndef _PRINTK_H |
---|
| 41 | #define _PRINTK_H |
---|
| 42 | |
---|
[457] | 43 | #include <hal_kernel_types.h> |
---|
[5] | 44 | #include <stdarg.h> |
---|
[1] | 45 | |
---|
[5] | 46 | |
---|
| 47 | /********************************************************************************** |
---|
[372] | 48 | * This function build a formatted string. |
---|
[23] | 49 | * The supported formats are defined below : |
---|
| 50 | * %c : single character |
---|
| 51 | * %d : signed decimal 32 bits integer |
---|
| 52 | * %u : unsigned decimal 32 bits integer |
---|
| 53 | * %x : hexadecimal 32 bits integer |
---|
| 54 | * %l : hexadecimal 64 bits integer |
---|
| 55 | * %s : NUL terminated character string |
---|
| 56 | ********************************************************************************** |
---|
| 57 | * @ string : pointer on target buffer (allocated by caller). |
---|
| 58 | * @ length : target buffer length (number of bytes). |
---|
| 59 | * @ format : format respecting the printf syntax. |
---|
| 60 | * @ returns the string length (including NUL) if success / return -1 if error. |
---|
| 61 | *********************************************************************************/ |
---|
| 62 | uint32_t snprintf( char * string, |
---|
| 63 | uint32_t length, |
---|
| 64 | char * format, ... ); |
---|
| 65 | |
---|
| 66 | /********************************************************************************** |
---|
[372] | 67 | * This function displays a formatted string on the kernel terminal TXT0, |
---|
| 68 | * using a busy waiting policy: It calls directly the relevant TXT driver, |
---|
[296] | 69 | * after taking the TXT0 lock. |
---|
[5] | 70 | ********************************************************************************** |
---|
[372] | 71 | * @ format : formatted string. |
---|
[5] | 72 | *********************************************************************************/ |
---|
[103] | 73 | void printk( char* format, ... ); |
---|
[1] | 74 | |
---|
[5] | 75 | /********************************************************************************** |
---|
[372] | 76 | * This function displays a formatted string on the kernel terminal TXT0, |
---|
| 77 | * using a busy waiting policy: It calls directly the relevant TXT driver, |
---|
[296] | 78 | * without taking the TXT0 lock. |
---|
| 79 | ********************************************************************************** |
---|
[372] | 80 | * @ format : formatted string. |
---|
[296] | 81 | *********************************************************************************/ |
---|
| 82 | void nolock_printk( char* format, ... ); |
---|
| 83 | |
---|
| 84 | /********************************************************************************** |
---|
[408] | 85 | * This function displays a formated message on kernel TXT0 terminal, |
---|
| 86 | * and forces the calling core in sleeping mode if a Boolean condition is false. |
---|
| 87 | * This function is actually used to debug the kernel... |
---|
[5] | 88 | ********************************************************************************** |
---|
| 89 | * @ condition : condition that must be true. |
---|
| 90 | * @ function_name : name of the calling function. |
---|
[372] | 91 | * @ format : formatted string |
---|
[5] | 92 | *********************************************************************************/ |
---|
[337] | 93 | void assert( bool_t condition, |
---|
| 94 | const char * function_name, |
---|
| 95 | char * format , ... ); |
---|
[5] | 96 | |
---|
[408] | 97 | /********************************************************************************** |
---|
| 98 | * This function displays a non-formated message on kernel TXT0 terminal. |
---|
| 99 | * This function is actually used to debug the assembly level kernel functions. |
---|
| 100 | ********************************************************************************** |
---|
| 101 | * @ string : non-formatted string. |
---|
| 102 | *********************************************************************************/ |
---|
| 103 | void puts( char * string ); |
---|
| 104 | |
---|
| 105 | /********************************************************************************** |
---|
| 106 | * This function displays a 32 bits value in hexadecimal on kernel TXT0 terminal. |
---|
| 107 | * This function is actually used to debug the assembly level kernel functions. |
---|
| 108 | ********************************************************************************** |
---|
| 109 | * @ val : 32 bits unsigned value. |
---|
| 110 | *********************************************************************************/ |
---|
| 111 | void putx( uint32_t val ); |
---|
| 112 | |
---|
| 113 | /********************************************************************************** |
---|
| 114 | * This function displays a 64 bits value in hexadecimal on kernel TXT0 terminal. |
---|
| 115 | * This function is actually used to debug the assembly level kernel functions. |
---|
| 116 | ********************************************************************************** |
---|
| 117 | * @ val : 64 bits unsigned value. |
---|
| 118 | *********************************************************************************/ |
---|
| 119 | void putl( uint64_t val ); |
---|
| 120 | |
---|
| 121 | |
---|
[1] | 122 | |
---|
[437] | 123 | /* deprecated march 2018 [AG] |
---|
| 124 | |
---|
[407] | 125 | #if CONFIG_CHDEV_DEBUG |
---|
| 126 | #define chdev_dmsg(...) if(hal_time_stamp() > CONFIG_CHDEV_DEBUG) printk(__VA_ARGS__) |
---|
| 127 | #else |
---|
| 128 | #define chdev_dmsg(...) |
---|
| 129 | #endif |
---|
| 130 | |
---|
[50] | 131 | #if CONFIG_CLUSTER_DEBUG |
---|
[406] | 132 | #define cluster_dmsg(...) if(hal_time_stamp() > CONFIG_CLUSTER_DEBUG) printk(__VA_ARGS__) |
---|
[50] | 133 | #else |
---|
| 134 | #define cluster_dmsg(...) |
---|
| 135 | #endif |
---|
| 136 | |
---|
[5] | 137 | #if CONFIG_CONTEXT_DEBUG |
---|
[406] | 138 | #define context_dmsg(...) if(hal_time_stamp() > CONFIG_CONTEXT_DEBUG) printk(__VA_ARGS__) |
---|
[5] | 139 | #else |
---|
| 140 | #define context_dmsg(...) |
---|
| 141 | #endif |
---|
| 142 | |
---|
[1] | 143 | #if CONFIG_CORE_DEBUG |
---|
[406] | 144 | #define core_dmsg(...) if(hal_time_stamp() > CONFIG_CORE_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 145 | #else |
---|
| 146 | #define core_dmsg(...) |
---|
| 147 | #endif |
---|
| 148 | |
---|
[50] | 149 | #if CONFIG_DEVFS_DEBUG |
---|
[406] | 150 | #define devfs_dmsg(...) if(hal_time_stamp() > CONFIG_DEVFS_DEBUG) printk(__VA_ARGS__) |
---|
[50] | 151 | #else |
---|
| 152 | #define devfs_dmsg(...) |
---|
| 153 | #endif |
---|
| 154 | |
---|
| 155 | #if CONFIG_DMA_DEBUG |
---|
[406] | 156 | #define dma_dmsg(...) if(hal_time_stamp() > CONFIG_DMA_DEBUG) printk(__VA_ARGS__) |
---|
[50] | 157 | #else |
---|
| 158 | #define dma_dmsg(...) |
---|
| 159 | #endif |
---|
| 160 | |
---|
[1] | 161 | #if CONFIG_DQDT_DEBUG |
---|
[406] | 162 | #define dqdt_dmsg(...) if(hal_time_stamp() > CONFIG_DQDT_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 163 | #else |
---|
| 164 | #define dqdt_dmsg(...) |
---|
| 165 | #endif |
---|
| 166 | |
---|
| 167 | #if CONFIG_ELF_DEBUG |
---|
[406] | 168 | #define elf_dmsg(...) if(hal_time_stamp() > CONFIG_ELF_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 169 | #else |
---|
| 170 | #define elf_dmsg(...) |
---|
| 171 | #endif |
---|
| 172 | |
---|
[5] | 173 | #if CONFIG_EXEC_DEBUG |
---|
[406] | 174 | #define exec_dmsg(...) if(hal_time_stamp() > CONFIG_EXEC_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 175 | #else |
---|
[5] | 176 | #define exec_dmsg(...) |
---|
[1] | 177 | #endif |
---|
| 178 | |
---|
[406] | 179 | #if CONFIG_EXCP_DEBUG |
---|
| 180 | #define excp_dmsg(...) if(hal_time_stamp() > CONFIG_EXCP_DEBUG) printk(__VA_ARGS__) |
---|
| 181 | #else |
---|
| 182 | #define excp_dmsg(...) |
---|
| 183 | #endif |
---|
| 184 | |
---|
[50] | 185 | #if CONFIG_FATFS_DEBUG |
---|
[406] | 186 | #define fatfs_dmsg(...) if(hal_time_stamp() > CONFIG_FATFS_DEBUG) printk(__VA_ARGS__) |
---|
[50] | 187 | #else |
---|
| 188 | #define fatfs_dmsg(...) |
---|
| 189 | #endif |
---|
| 190 | |
---|
[5] | 191 | #if CONFIG_FBF_DEBUG |
---|
[406] | 192 | #define fbf_dmsg(...) if(hal_time_stamp() > CONFIG_FBF_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 193 | #else |
---|
[5] | 194 | #define fbf_dmsg(...) |
---|
[1] | 195 | #endif |
---|
| 196 | |
---|
[5] | 197 | #if CONFIG_FORK_DEBUG |
---|
[406] | 198 | #define fork_dmsg(...) if(hal_time_stamp() > CONFIG_FORK_DEBUG) printk(__VA_ARGS__) |
---|
[5] | 199 | #else |
---|
| 200 | #define fork_dmsg(...) |
---|
| 201 | #endif |
---|
| 202 | |
---|
[406] | 203 | #if CONFIG_GPT_DEBUG |
---|
| 204 | #define gpt_dmsg(...) if(hal_time_stamp() > CONFIG_GPT_DEBUG) printk(__VA_ARGS__) |
---|
| 205 | #else |
---|
| 206 | #define gpt_dmsg(...) |
---|
| 207 | #endif |
---|
| 208 | |
---|
[407] | 209 | #if CONFIG_GRPC_DEBUG |
---|
| 210 | #define grpc_dmsg(...) if(hal_time_stamp() > CONFIG_GRPC_DEBUG) printk(__VA_ARGS__) |
---|
| 211 | #else |
---|
| 212 | #define grpc_dmsg(...) |
---|
| 213 | #endif |
---|
| 214 | |
---|
[50] | 215 | #if CONFIG_IDLE_DEBUG |
---|
[406] | 216 | #define idle_dmsg(...) if(hal_time_stamp() > CONFIG_IDLE_DEBUG) printk(__VA_ARGS__) |
---|
[50] | 217 | #else |
---|
| 218 | #define idle_dmsg(...) |
---|
| 219 | #endif |
---|
| 220 | |
---|
[1] | 221 | #if CONFIG_IOC_DEBUG |
---|
[389] | 222 | #define ioc_dmsg(...) if(hal_time_stamp() > CONFIG_IOC_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 223 | #else |
---|
| 224 | #define ioc_dmsg(...) |
---|
| 225 | #endif |
---|
| 226 | |
---|
[188] | 227 | #if CONFIG_IRQ_DEBUG |
---|
[406] | 228 | #define irq_dmsg(...) if(hal_time_stamp() > CONFIG_IRQ_DEBUG) printk(__VA_ARGS__) |
---|
[188] | 229 | #else |
---|
| 230 | #define irq_dmsg(...) |
---|
| 231 | #endif |
---|
| 232 | |
---|
[5] | 233 | #if CONFIG_KCM_DEBUG |
---|
[406] | 234 | #define kcm_dmsg(...) if(hal_time_stamp() > CONFIG_KCM_DEBUG) printk(__VA_ARGS__) |
---|
[5] | 235 | #else |
---|
| 236 | #define kcm_dmsg(...) |
---|
| 237 | #endif |
---|
| 238 | |
---|
| 239 | #if CONFIG_KHM_DEBUG |
---|
[406] | 240 | #define khm_dmsg(...) if(hal_time_stamp() > CONFIG_KHM_DEBUG) printk(__VA_ARGS__) |
---|
[5] | 241 | #else |
---|
| 242 | #define khm_dmsg(...) |
---|
| 243 | #endif |
---|
| 244 | |
---|
[409] | 245 | #if CONFIG_KILL_DEBUG |
---|
| 246 | #define kill_dmsg(...) if(hal_time_stamp() > CONFIG_KILL_DEBUG) printk(__VA_ARGS__) |
---|
| 247 | #else |
---|
| 248 | #define kill_dmsg(...) |
---|
| 249 | #endif |
---|
| 250 | |
---|
[1] | 251 | #if CONFIG_KINIT_DEBUG |
---|
[406] | 252 | #define kinit_dmsg(...) if(hal_time_stamp() > CONFIG_KINIT_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 253 | #else |
---|
| 254 | #define kinit_dmsg(...) |
---|
| 255 | #endif |
---|
| 256 | |
---|
| 257 | #if CONFIG_KMEM_DEBUG |
---|
[406] | 258 | #define kmem_dmsg(...) if(hal_time_stamp() > CONFIG_KMEM_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 259 | #else |
---|
| 260 | #define kmem_dmsg(...) |
---|
| 261 | #endif |
---|
| 262 | |
---|
[5] | 263 | #if CONFIG_MAPPER_DEBUG |
---|
[406] | 264 | #define mapper_dmsg(...) if(hal_time_stamp() > CONFIG_MAPPER_DEBUG) printk(__VA_ARGS__) |
---|
[5] | 265 | #else |
---|
| 266 | #define mapper_dmsg(...) |
---|
| 267 | #endif |
---|
| 268 | |
---|
[407] | 269 | #if CONFIG_MMAP_DEBUG |
---|
| 270 | #define mmap_dmsg(...) if(hal_time_stamp() > CONFIG_MMAP_DEBUG) printk(__VA_ARGS__) |
---|
| 271 | #else |
---|
| 272 | #define mmap_dmsg(...) |
---|
| 273 | #endif |
---|
| 274 | |
---|
[1] | 275 | #if CONFIG_MMC_DEBUG |
---|
[406] | 276 | #define mmc_dmsg(...) if(hal_time_stamp() > CONFIG_MMC_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 277 | #else |
---|
| 278 | #define mmc_dmsg(...) |
---|
| 279 | #endif |
---|
| 280 | |
---|
| 281 | #if CONFIG_NIC_DEBUG |
---|
[406] | 282 | #define nic_dmsg(...) if(hal_time_stamp() > CONFIG_NIC_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 283 | #else |
---|
| 284 | #define nic_dmsg(...) |
---|
| 285 | #endif |
---|
| 286 | |
---|
| 287 | #if CONFIG_PIC_DEBUG |
---|
[406] | 288 | #define pic_dmsg(...) if(hal_time_stamp() > CONFIG_PIC_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 289 | #else |
---|
| 290 | #define pic_dmsg(...) |
---|
| 291 | #endif |
---|
| 292 | |
---|
[5] | 293 | #if CONFIG_PPM_DEBUG |
---|
[406] | 294 | #define ppm_dmsg(...) if(hal_time_stamp() > CONFIG_PPM_DEBUG) printk(__VA_ARGS__) |
---|
[5] | 295 | #else |
---|
| 296 | #define ppm_dmsg(...) |
---|
| 297 | #endif |
---|
| 298 | |
---|
[1] | 299 | #if CONFIG_PROCESS_DEBUG |
---|
[406] | 300 | #define process_dmsg(...) if(hal_time_stamp() > CONFIG_PROCESS_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 301 | #else |
---|
| 302 | #define process_dmsg(...) |
---|
| 303 | #endif |
---|
| 304 | |
---|
[407] | 305 | #if CONFIG_READ_DEBUG |
---|
| 306 | #define read_dmsg(...) if(hal_time_stamp() > CONFIG_READ_DEBUG) printk(__VA_ARGS__) |
---|
| 307 | #else |
---|
| 308 | #define read_dmsg(...) |
---|
| 309 | #endif |
---|
| 310 | |
---|
[1] | 311 | #if CONFIG_RPC_DEBUG |
---|
[372] | 312 | #define rpc_dmsg(...) if(hal_time_stamp() > CONFIG_RPC_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 313 | #else |
---|
| 314 | #define rpc_dmsg(...) |
---|
| 315 | #endif |
---|
| 316 | |
---|
| 317 | #if CONFIG_SCHED_DEBUG |
---|
[406] | 318 | #define sched_dmsg(...) if(hal_time_stamp() > CONFIG_SCHED_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 319 | #else |
---|
| 320 | #define sched_dmsg(...) |
---|
| 321 | #endif |
---|
| 322 | |
---|
[415] | 323 | #if CONFIG_SIGACTION_DEBUG |
---|
| 324 | #define sigaction_dmsg(...) if(hal_time_stamp() > CONFIG_SIGACTION_DEBUG) printk(__VA_ARGS__) |
---|
[23] | 325 | #else |
---|
[415] | 326 | #define sigaction_dmsg(...) |
---|
[23] | 327 | #endif |
---|
| 328 | |
---|
[16] | 329 | #if CONFIG_SYSCALL_DEBUG |
---|
[406] | 330 | #define syscall_dmsg(...) if(hal_time_stamp() > CONFIG_SYSCALL_DEBUG) printk(__VA_ARGS__) |
---|
[16] | 331 | #else |
---|
| 332 | #define syscall_dmsg(...) |
---|
| 333 | #endif |
---|
| 334 | |
---|
[1] | 335 | #if CONFIG_THREAD_DEBUG |
---|
[406] | 336 | #define thread_dmsg(...) if(hal_time_stamp() > CONFIG_THREAD_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 337 | #else |
---|
| 338 | #define thread_dmsg(...) |
---|
| 339 | #endif |
---|
| 340 | |
---|
| 341 | #if CONFIG_TXT_DEBUG |
---|
[406] | 342 | #define txt_dmsg(...) if(hal_time_stamp() > CONFIG_TXT_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 343 | #else |
---|
| 344 | #define txt_dmsg(...) |
---|
| 345 | #endif |
---|
| 346 | |
---|
| 347 | #if CONFIG_VFS_DEBUG |
---|
[372] | 348 | #define vfs_dmsg(...) if(hal_time_stamp() > CONFIG_VFS_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 349 | #else |
---|
| 350 | #define vfs_dmsg(...) |
---|
| 351 | #endif |
---|
| 352 | |
---|
| 353 | #if CONFIG_VMM_DEBUG |
---|
[406] | 354 | #define vmm_dmsg(...) if(hal_time_stamp() > CONFIG_VMM_DEBUG) printk(__VA_ARGS__) |
---|
[1] | 355 | #else |
---|
| 356 | #define vmm_dmsg(...) |
---|
| 357 | #endif |
---|
| 358 | |
---|
[407] | 359 | #if CONFIG_WRITE_DEBUG |
---|
| 360 | #define write_dmsg(...) if(hal_time_stamp() > CONFIG_WRITE_DEBUG) printk(__VA_ARGS__) |
---|
| 361 | #else |
---|
| 362 | #define write_dmsg(...) |
---|
| 363 | #endif |
---|
[1] | 364 | |
---|
[437] | 365 | */ |
---|
[407] | 366 | |
---|
[1] | 367 | #endif // _PRINTK_H |
---|
| 368 | |
---|
| 369 | // Local Variables: |
---|
| 370 | // tab-width: 4 |
---|
| 371 | // c-basic-offset: 4 |
---|
| 372 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 373 | // indent-tabs-mode: nil |
---|
| 374 | // End: |
---|
| 375 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 376 | |
---|