source: trunk/kernel/kern/printk.h @ 176

Last change on this file since 176 was 103, checked in by alain, 8 years ago

Introducing a nolock_printk() function used by kernel_init.

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