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

Last change on this file since 688 was 683, checked in by alain, 4 years ago

All modifications required to support the <tcp_chat> application
including error recovery in case of packet loss.A

File size: 7.7 KB
Line 
1/*
2 * printk.h - Kernel Log & debug messages API definition.
3 *
4 * authors  Alain Greiner (2016,2017,2018,2019,2020)
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
26// to build, or display on terminal TXT0, formated strings.
27// In case ofdisplay, it calls synchronously the TXT0 driver, without descheduling.
28//
29// The supported formats are defined below :
30//   %c : single ascii character (8 bits)
31//   %b : exactly 2 hexadecimal digits (8 bits)
32//   %d : up to 10 digits decimal integer (32 bits)
33//   %u : up to 10 digits unsigned decimal (32 bits)
34//   %x : up to 8 digits hexadecimal integer (32 bits)
35//   %X : exactly 8 digits hexadecimal integer (32 bits)
36//   %l : up to 16 digits hexadecimal integer (64 bits)
37//   %L : exactly 16 digits hexadecimal integer (64 bits)
38//   %s : NUL terminated character string
39///////////////////////////////////////////////////////////////////////////////////
40
41#ifndef _PRINTK_H
42#define _PRINTK_H
43
44#include <hal_kernel_types.h>
45#include <stdarg.h>
46
47#include <hal_special.h> 
48
49/**********************************************************************************
50 * These functions display a formated string defined by the <format,...>
51 * argument on the kernel terminal TXT0, with or without taking the TXT0 lock.
52 **********************************************************************************
53 * Implementation note:
54 * It uses a buffer allocated in the stack, defined by CONFIG_PRINTK_BUFFER_SIZE.
55 * It calls the snprintk() function to build a printable string in this buffer,
56 * and calls directly the dev_txt_sync_write() driver function without using the
57 * TXT server thread.
58 * It displays a [PANIC] message on kernel TXT0 terminal if the formated string
59 * exceeds the buffer size, or if the format is undefined.
60 **********************************************************************************
61 * @ format     : formatted string.
62 *********************************************************************************/
63void printk       ( char * format, ... );
64void nolock_printk( char * format, ... );
65
66/**********************************************************************************
67 * This function displays an [ASSERT] message on kernel TXT0 terminal
68 * if Boolean expression <expr> is false. It prints a detailed message including:
69 * - the calling core [cxy,lpid]
70 * - the calling thread[pid,trdid]
71 * - the current cycle
72 * - the <func_name> argument
73 * - the <string> argument
74 **********************************************************************************
75 * @ func_name  : calling function name.
76 * @ expr       : Boolean expression to be checked.
77 * @ format     : formated message argument.
78 *********************************************************************************/
79void assert( const char   * func_name,
80             bool_t         expr,
81             char         * format , ... );
82
83/**********************************************************************************
84 * This function build a formated string in a buffer defined by the <buffer>
85 * and <buf_size> arguments, from the format defined by the <format,...> argument.
86 * This function set the NUL terminating character in target <buffer>,
87 * but the returned length does not include this NUL character.
88 **********************************************************************************
89 * @ buffer     : pointer on target buffer (allocated by caller).
90 * @ buf_size   : target buffer length (number of bytes).
91 * @ format     : format respecting the printf syntax.
92 * @ returns  string length (not including NUL) if success / -1 if error.
93 *********************************************************************************/
94int32_t snprintk( char       * buffer,
95                  uint32_t     buf_size,
96                  char       * format, ... );
97
98/**********************************************************************************
99 * These functions displays a non-formated string on TXT0 terminal.
100 * They are actually used for low level debug, and call directly the TXT driver,
101 * without using the TXT server thread.
102 **********************************************************************************
103 * @ string   : non-formatted, NUL terminated string.
104 *********************************************************************************/
105void puts( const char * string );
106void nolock_puts( const char * string );
107
108/**********************************************************************************
109 * These functions display a 32 bits value in hexadecimal on TXT0 terminal.
110 * They are actually used for low level debug, and call directly the TXT driver,
111 * without using the TXT server thread.
112 **********************************************************************************
113 * @ val   : 32 bits unsigned value.
114 *********************************************************************************/
115void putx( uint32_t val );
116void nolock_putx( uint32_t val );
117
118/**********************************************************************************
119 * These functions display a 32 bits signed value in decimal on TXT0 terminal.
120 * They are actually used for low level debug, and call directly the TXT driver,
121 * without using the TXT server thread.
122 **********************************************************************************
123 * @ val   : 32 bits signed value.
124 *********************************************************************************/
125void putd( int32_t val );
126void nolock_putd( int32_t val );
127
128/**********************************************************************************
129 * These functions display a 64 bits value in hexadecimal on TXT0 terminal.
130 * They are actually used low level debug, and call directly the TXT driver,
131 * without using the TXT server thread.
132 **********************************************************************************
133 * @ val   : 64 bits unsigned value.
134 *********************************************************************************/
135void putl( uint64_t val );
136void nolock_putl( uint64_t val );
137
138/**********************************************************************************
139 * This debug function displays on the TXT0 terminal the content of an
140 * array of bytes defined by <buffer> and <size> arguments (16 bytes per line).
141 * The <string> argument is displayed before the buffer content.
142 * The line format is an address followed by 16 (hexa) bytes.
143 **********************************************************************************
144 * @ string   : buffer name or identifier.
145 * @ buffer   : local pointer on bytes array.
146 * @ size     : number of bytes to display.
147 *********************************************************************************/
148void putb( char     * string,
149           uint8_t  * buffer,
150           uint32_t   size );
151
152
153
154#endif  // _PRINTK_H
155
156// Local Variables:
157// tab-width: 4
158// c-basic-offset: 4
159// c-file-offsets:((innamespace . 0)(inline-open . 0))
160// indent-tabs-mode: nil
161// End:
162// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
163
Note: See TracBrowser for help on using the repository browser.