[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 | /********************************************************************************** |
---|
[23] | 48 | * This function build a formated string. |
---|
| 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 | /********************************************************************************** |
---|
[5] | 67 | * This function displays a formated string on the kernel terminal TXT0, |
---|
| 68 | * using a busy waiting policy: It calls directly the relevant TXT driver, |
---|
[103] | 69 | * after taking the lock for exclusive access to the TXT0 terminal. |
---|
[5] | 70 | ********************************************************************************** |
---|
| 71 | * @ format : formated string. |
---|
| 72 | *********************************************************************************/ |
---|
[103] | 73 | void printk( char* format, ... ); |
---|
[1] | 74 | |
---|
[5] | 75 | /********************************************************************************** |
---|
[188] | 76 | * This function displays a "PANIC" message and force the calling core in |
---|
[5] | 77 | * sleeping mode if a Boolean condition is false. |
---|
| 78 | * These functions are actually used to debug the kernel... |
---|
| 79 | ********************************************************************************** |
---|
| 80 | * @ condition : condition that must be true. |
---|
| 81 | * @ function_name : name of the calling function. |
---|
| 82 | * @ string : error message if condition is false. |
---|
| 83 | *********************************************************************************/ |
---|
| 84 | inline void assert( bool_t condition, |
---|
| 85 | const char * function_name, |
---|
| 86 | char * string ); |
---|
| 87 | |
---|
[1] | 88 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 89 | // Conditionnal debug macros |
---|
| 90 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 91 | |
---|
[50] | 92 | #if CONFIG_CLUSTER_DEBUG |
---|
| 93 | #define cluster_dmsg(...) printk(__VA_ARGS__) |
---|
| 94 | #else |
---|
| 95 | #define cluster_dmsg(...) |
---|
| 96 | #endif |
---|
| 97 | |
---|
[5] | 98 | #if CONFIG_CONTEXT_DEBUG |
---|
| 99 | #define context_dmsg(...) printk(__VA_ARGS__) |
---|
| 100 | #else |
---|
| 101 | #define context_dmsg(...) |
---|
| 102 | #endif |
---|
| 103 | |
---|
[1] | 104 | #if CONFIG_CORE_DEBUG |
---|
[5] | 105 | #define core_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 106 | #else |
---|
| 107 | #define core_dmsg(...) |
---|
| 108 | #endif |
---|
| 109 | |
---|
[50] | 110 | #if CONFIG_DEVFS_DEBUG |
---|
| 111 | #define devfs_dmsg(...) printk(__VA_ARGS__) |
---|
| 112 | #else |
---|
| 113 | #define devfs_dmsg(...) |
---|
| 114 | #endif |
---|
| 115 | |
---|
| 116 | #if CONFIG_DMA_DEBUG |
---|
| 117 | #define dma_dmsg(...) printk(__VA_ARGS__) |
---|
| 118 | #else |
---|
| 119 | #define dma_dmsg(...) |
---|
| 120 | #endif |
---|
| 121 | |
---|
[1] | 122 | #if CONFIG_DQDT_DEBUG |
---|
[5] | 123 | #define dma_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 124 | #else |
---|
[5] | 125 | #define dma_dmsg(...) |
---|
| 126 | #endif |
---|
| 127 | |
---|
| 128 | #if CONFIG_DQDT_DEBUG |
---|
| 129 | #define dqdt_dmsg(...) printk(__VA_ARGS__) |
---|
| 130 | #else |
---|
[1] | 131 | #define dqdt_dmsg(...) |
---|
| 132 | #endif |
---|
| 133 | |
---|
| 134 | #if CONFIG_ELF_DEBUG |
---|
[5] | 135 | #define elf_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 136 | #else |
---|
| 137 | #define elf_dmsg(...) |
---|
| 138 | #endif |
---|
| 139 | |
---|
[5] | 140 | #if CONFIG_EXEC_DEBUG |
---|
| 141 | #define exec_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 142 | #else |
---|
[5] | 143 | #define exec_dmsg(...) |
---|
[1] | 144 | #endif |
---|
| 145 | |
---|
[50] | 146 | #if CONFIG_FATFS_DEBUG |
---|
| 147 | #define fatfs_dmsg(...) printk(__VA_ARGS__) |
---|
| 148 | #else |
---|
| 149 | #define fatfs_dmsg(...) |
---|
| 150 | #endif |
---|
| 151 | |
---|
[5] | 152 | #if CONFIG_FBF_DEBUG |
---|
| 153 | #define fbf_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 154 | #else |
---|
[5] | 155 | #define fbf_dmsg(...) |
---|
[1] | 156 | #endif |
---|
| 157 | |
---|
[5] | 158 | #if CONFIG_FORK_DEBUG |
---|
| 159 | #define fork_dmsg(...) printk(__VA_ARGS__) |
---|
| 160 | #else |
---|
| 161 | #define fork_dmsg(...) |
---|
| 162 | #endif |
---|
| 163 | |
---|
[50] | 164 | #if CONFIG_IDLE_DEBUG |
---|
| 165 | #define idle_dmsg(...) printk(__VA_ARGS__) |
---|
| 166 | #else |
---|
| 167 | #define idle_dmsg(...) |
---|
| 168 | #endif |
---|
| 169 | |
---|
[1] | 170 | #if CONFIG_IOC_DEBUG |
---|
[5] | 171 | #define ioc_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 172 | #else |
---|
| 173 | #define ioc_dmsg(...) |
---|
| 174 | #endif |
---|
| 175 | |
---|
[188] | 176 | #if CONFIG_IRQ_DEBUG |
---|
| 177 | #define irq_dmsg(...) printk(__VA_ARGS__) |
---|
| 178 | #else |
---|
| 179 | #define irq_dmsg(...) |
---|
| 180 | #endif |
---|
| 181 | |
---|
[5] | 182 | #if CONFIG_KCM_DEBUG |
---|
| 183 | #define kcm_dmsg(...) printk(__VA_ARGS__) |
---|
| 184 | #else |
---|
| 185 | #define kcm_dmsg(...) |
---|
| 186 | #endif |
---|
| 187 | |
---|
| 188 | #if CONFIG_KHM_DEBUG |
---|
| 189 | #define khm_dmsg(...) printk(__VA_ARGS__) |
---|
| 190 | #else |
---|
| 191 | #define khm_dmsg(...) |
---|
| 192 | #endif |
---|
| 193 | |
---|
[1] | 194 | #if CONFIG_KINIT_DEBUG |
---|
[279] | 195 | #define kinit_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 196 | #else |
---|
| 197 | #define kinit_dmsg(...) |
---|
| 198 | #endif |
---|
| 199 | |
---|
| 200 | #if CONFIG_KMEM_DEBUG |
---|
| 201 | #define kmem_dmsg(...) printk(__VA_ARGS__) |
---|
| 202 | #else |
---|
| 203 | #define kmem_dmsg(...) |
---|
| 204 | #endif |
---|
| 205 | |
---|
[5] | 206 | #if CONFIG_MAPPER_DEBUG |
---|
| 207 | #define mapper_dmsg(...) printk(__VA_ARGS__) |
---|
| 208 | #else |
---|
| 209 | #define mapper_dmsg(...) |
---|
| 210 | #endif |
---|
| 211 | |
---|
[1] | 212 | #if CONFIG_MMC_DEBUG |
---|
[5] | 213 | #define mmc_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 214 | #else |
---|
| 215 | #define mmc_dmsg(...) |
---|
| 216 | #endif |
---|
| 217 | |
---|
| 218 | #if CONFIG_NIC_DEBUG |
---|
[5] | 219 | #define nic_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 220 | #else |
---|
| 221 | #define nic_dmsg(...) |
---|
| 222 | #endif |
---|
| 223 | |
---|
| 224 | #if CONFIG_PIC_DEBUG |
---|
[5] | 225 | #define pic_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 226 | #else |
---|
| 227 | #define pic_dmsg(...) |
---|
| 228 | #endif |
---|
| 229 | |
---|
[5] | 230 | #if CONFIG_PPM_DEBUG |
---|
| 231 | #define ppm_dmsg(...) printk(__VA_ARGS__) |
---|
| 232 | #else |
---|
| 233 | #define ppm_dmsg(...) |
---|
| 234 | #endif |
---|
| 235 | |
---|
[1] | 236 | #if CONFIG_PROCESS_DEBUG |
---|
[5] | 237 | #define process_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 238 | #else |
---|
| 239 | #define process_dmsg(...) |
---|
| 240 | #endif |
---|
| 241 | |
---|
| 242 | #if CONFIG_RPC_DEBUG |
---|
[5] | 243 | #define rpc_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 244 | #else |
---|
| 245 | #define rpc_dmsg(...) |
---|
| 246 | #endif |
---|
| 247 | |
---|
| 248 | #if CONFIG_SCHED_DEBUG |
---|
[5] | 249 | #define sched_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 250 | #else |
---|
| 251 | #define sched_dmsg(...) |
---|
| 252 | #endif |
---|
| 253 | |
---|
[23] | 254 | #if CONFIG_SIGNAL_DEBUG |
---|
| 255 | #define signal_dmsg(...) printk(__VA_ARGS__) |
---|
| 256 | #else |
---|
| 257 | #define signal_dmsg(...) |
---|
| 258 | #endif |
---|
| 259 | |
---|
[16] | 260 | #if CONFIG_SYSCALL_DEBUG |
---|
| 261 | #define syscall_dmsg(...) printk(__VA_ARGS__) |
---|
| 262 | #else |
---|
| 263 | #define syscall_dmsg(...) |
---|
| 264 | #endif |
---|
| 265 | |
---|
[1] | 266 | #if CONFIG_THREAD_DEBUG |
---|
[5] | 267 | #define thread_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 268 | #else |
---|
| 269 | #define thread_dmsg(...) |
---|
| 270 | #endif |
---|
| 271 | |
---|
| 272 | #if CONFIG_TXT_DEBUG |
---|
[5] | 273 | #define txt_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 274 | #else |
---|
| 275 | #define txt_dmsg(...) |
---|
| 276 | #endif |
---|
| 277 | |
---|
| 278 | #if CONFIG_VFS_DEBUG |
---|
[5] | 279 | #define vfs_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 280 | #else |
---|
| 281 | #define vfs_dmsg(...) |
---|
| 282 | #endif |
---|
| 283 | |
---|
| 284 | #if CONFIG_VMM_DEBUG |
---|
[5] | 285 | #define vmm_dmsg(...) printk(__VA_ARGS__) |
---|
[1] | 286 | #else |
---|
| 287 | #define vmm_dmsg(...) |
---|
| 288 | #endif |
---|
| 289 | |
---|
| 290 | |
---|
| 291 | #endif // _PRINTK_H |
---|
| 292 | |
---|
| 293 | // Local Variables: |
---|
| 294 | // tab-width: 4 |
---|
| 295 | // c-basic-offset: 4 |
---|
| 296 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 297 | // indent-tabs-mode: nil |
---|
| 298 | // End: |
---|
| 299 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 300 | |
---|