source: trunk/kernel/kern/printk.h

Last change on this file was 683, checked in by alain, 3 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
RevLine 
[1]1/*
2 * printk.h - Kernel Log & debug messages API definition.
[372]3 *
[657]4 * authors  Alain Greiner (2016,2017,2018,2019,2020)
[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
[683]26// to build, or display on terminal TXT0, formated strings.
27// In case ofdisplay, it calls synchronously the TXT0 driver, without descheduling.
[669]28//
[683]29// The supported formats are defined below :
[669]30//   %c : single ascii character (8 bits)
[683]31//   %b : exactly 2 hexadecimal digits (8 bits)
[669]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
[1]39///////////////////////////////////////////////////////////////////////////////////
40
41#ifndef _PRINTK_H
42#define _PRINTK_H
43
[457]44#include <hal_kernel_types.h>
[5]45#include <stdarg.h>
[1]46
[623]47#include <hal_special.h> 
[5]48
49/**********************************************************************************
[683]50 * These functions display a formated string defined by the <format,...>
[669]51 * argument on the kernel terminal TXT0, with or without taking the TXT0 lock.
[23]52 **********************************************************************************
[669]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.
[5]60 **********************************************************************************
[372]61 * @ format     : formatted string.
[5]62 *********************************************************************************/
[669]63void printk       ( char * format, ... );
64void nolock_printk( char * format, ... );
[1]65
[5]66/**********************************************************************************
[683]67 * This function displays an [ASSERT] message on kernel TXT0 terminal
[669]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
[296]74 **********************************************************************************
[669]75 * @ func_name  : calling function name.
76 * @ expr       : Boolean expression to be checked.
77 * @ format     : formated message argument.
[296]78 *********************************************************************************/
[669]79void assert( const char   * func_name,
80             bool_t         expr,
81             char         * format , ... );
[296]82
83/**********************************************************************************
[669]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.
[683]86 * This function set the NUL terminating character in target <buffer>,
87 * but the returned length does not include this NUL character.
[491]88 **********************************************************************************
[669]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.
[491]93 *********************************************************************************/
[669]94int32_t snprintk( char       * buffer,
95                  uint32_t     buf_size,
96                  char       * format, ... );
[491]97
98/**********************************************************************************
[669]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.
[5]102 **********************************************************************************
[669]103 * @ string   : non-formatted, NUL terminated string.
[5]104 *********************************************************************************/
[669]105void puts( const char * string );
106void nolock_puts( const char * string );
[5]107
[408]108/**********************************************************************************
[669]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.
[408]112 **********************************************************************************
113 * @ val   : 32 bits unsigned value.
114 *********************************************************************************/
115void putx( uint32_t val );
[669]116void nolock_putx( uint32_t val );
[408]117
118/**********************************************************************************
[669]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.
[408]122 **********************************************************************************
[625]123 * @ val   : 32 bits signed value.
124 *********************************************************************************/
125void putd( int32_t val );
[669]126void nolock_putd( int32_t val );
[625]127
128/**********************************************************************************
[669]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.
[625]132 **********************************************************************************
[408]133 * @ val   : 64 bits unsigned value.
134 *********************************************************************************/
135void putl( uint64_t val );
[669]136void nolock_putl( uint64_t val );
[408]137
[623]138/**********************************************************************************
[625]139 * This debug function displays on the TXT0 terminal the content of an
[623]140 * array of bytes defined by <buffer> and <size> arguments (16 bytes per line).
141 * The <string> argument is displayed before the buffer content.
[657]142 * The line format is an address followed by 16 (hexa) bytes.
[623]143 **********************************************************************************
144 * @ string   : buffer name or identifier.
145 * @ buffer   : local pointer on bytes array.
[683]146 * @ size     : number of bytes to display.
[623]147 *********************************************************************************/
148void putb( char     * string,
149           uint8_t  * buffer,
150           uint32_t   size );
[408]151
[623]152
153
[1]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.