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

Last change on this file since 675 was 669, checked in by alain, 4 years ago

1) Introduce up to 4 command lines arguments in the KSH "load" command.
These arguments are transfered to the user process through the
argc/argv mechanism, using the user space "args" vseg.

2) Introduce the named and anonymous "pipes", for inter-process communication
through the pipe() and mkfifo() syscalls.

3) Introduce the "chat" application to validate the two above mechanisms.

4) Improve printk() and assert() fonctions in printk.c.

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