Ignore:
Timestamp:
Nov 19, 2020, 11:44:34 PM (3 years ago)
Author:
alain
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/printk.h

    r657 r669  
    2626// to display messages on the kernel terminal TXT0, using a busy waiting policy.
    2727// 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
    2838///////////////////////////////////////////////////////////////////////////////////
    2939
     
    3747
    3848/**********************************************************************************
    39  * This function build a formatted string.
    40  * The supported formats are defined below :
    41  *   %b : exactly 2 digits hexadecimal integer (8 bits)
    42  *   %c : single ascii character (8 bits)
    43  *   %d : up to 10 digits decimal integer (32 bits)
    44  *   %u : up to 10 digits unsigned decimal (32 bits)
    45  *   %x : up to 8 digits hexadecimal integer (32 bits)
    46  *   %X : exactly 8 digits hexadecimal integer (32 bits)
    47  *   %l : up to 16 digits hexadecimal integer (64 bits)
    48  *   %L : exactly 16 digits hexadecimal integer (64 bits)
    49  *   %s : NUL terminated character string
     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.
    5051 **********************************************************************************
    51  * @ string     : pointer on target buffer (allocated by caller).
    52  * @ length     : target buffer length (number of bytes).
    53  * @ format     : format respecting the printf syntax.
    54  * @ returns the string length (including NUL) if success / return -1 if error.
    55  *********************************************************************************/
    56 uint32_t snprintf( char     * string,
    57                    uint32_t   length,
    58                    char     * format, ... );
    59 
    60 /**********************************************************************************
    61  * This function displays a formatted string on the kernel terminal TXT0,
    62  * after taking the TXT0 lock.
    63  * It uses a busy waiting policy, calling directly the relevant TXT driver,
     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.
    6459 **********************************************************************************
    6560 * @ format     : formatted string.
    6661 *********************************************************************************/
    67 void printk( char* format, ... );
     62void printk       ( char * format, ... );
     63void nolock_printk( char * format, ... );
    6864
    6965/**********************************************************************************
    70  * This function displays a formatted string on the kernel terminal TXT0,
    71  * without taking the TXT0 lock.
    72  * It uses a busy waiting policy, calling directly the relevant TXT driver,
     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
    7373 **********************************************************************************
    74  * @ format     : formatted string.
     74 * @ func_name  : calling function name.
     75 * @ expr       : Boolean expression to be checked.
     76 * @ format     : formated message argument.
    7577 *********************************************************************************/
    76 void nolock_printk( char* format, ... );
    77 
     78void assert( const char   * func_name,
     79             bool_t         expr,
     80             char         * format , ... );
    7881
    7982/**********************************************************************************
    80  * This function is called in case of kernel panic. It printt a detailed message
    81  * on the TXT0 terminal after taking the TXT0 lock, and call the hal_core_sleep()
    82  * function to block the calling core.  It is used by the assert macro (below).
     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>.
    8386 **********************************************************************************
    84  * @ file_name     : File where the assert macro was invoked
    85  * @ function_name : Name of the calling function.
    86  * @ line          : Line number where the assert macro was invoked
    87  * @ cycle         : Cycle where the macro was invoked
    88  * @ format        : Formatted string
    89  * ...             : arguments of the format string
    90  *
    91  * See assert macro documentation for information about printed information.
     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.
    9291 *********************************************************************************/
    93 void panic( const char * function_name,
    94             uint32_t     line,
    95             cycle_t      cycle,
    96             const char * format,
    97             ... ) __attribute__((__noreturn__));
     92int32_t snprintk( char       * buffer,
     93                  uint32_t     buf_size,
     94                  char       * format, ... );
    9895
    9996/**********************************************************************************
    100  * This macro displays a formated message on kernel TXT0 terminal,
    101  * and forces the calling core in sleeping mode if a Boolean condition is false.
    102  * Actually used to debug the kernel.
    103  *
    104  * Extra information printed by assert:
    105  * - Current thread, process, and core
    106  * - Function name / line number in file / cycle
     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.
    107100 **********************************************************************************
    108  * @ condition     : condition that must be true.
    109  * @ format        : formatted string
     101 * @ string   : non-formatted, NUL terminated string.
    110102 *********************************************************************************/
    111 #define assert( expr, format, ... )                                               \
    112 {                                                                                 \
    113     uint32_t __line_at_expansion = __LINE__;                                      \
    114     const volatile cycle_t __assert_cycle = hal_get_cycles();                     \
    115     if ( ( expr ) == false )                                                      \
    116     {                                                                             \
    117         panic( __FUNCTION__,                                                      \
    118                __line_at_expansion,                                               \
    119                __assert_cycle,                                                    \
    120                ( format ), ##__VA_ARGS__ );                                       \
    121     }                                                                             \
    122 }
     103void puts( const char * string );
     104void nolock_puts( const char * string );
    123105
    124106/**********************************************************************************
    125  * This debug function displays a non-formated message on TXT0 terminal.
    126  * This function is actually used to debug the assembly level kernel functions.
    127  **********************************************************************************
    128  * @ string   : non-formatted string.
    129  *********************************************************************************/
    130 void puts( char * string );
    131 
    132 /**********************************************************************************
    133  * This debug function displays a 32 bits value in hexadecimal on TXT0 terminal.
    134  * This function is actually used to debug the assembly level kernel functions.
     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.
    135110 **********************************************************************************
    136111 * @ val   : 32 bits unsigned value.
    137112 *********************************************************************************/
    138113void putx( uint32_t val );
     114void nolock_putx( uint32_t val );
    139115
    140116/**********************************************************************************
    141  * This debug function displays a 32 bits signed value in decimal on TXT0 terminal.
    142  * This function is actually used to debug the assembly level kernel functions.
     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.
    143120 **********************************************************************************
    144121 * @ val   : 32 bits signed value.
    145122 *********************************************************************************/
    146123void putd( int32_t val );
     124void nolock_putd( int32_t val );
    147125
    148126/**********************************************************************************
    149  * This debug function displays a 64 bits value in hexadecimal on TXT0 terminal.
    150  * This function is actually used to debug the assembly level kernel functions.
     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.
    151130 **********************************************************************************
    152131 * @ val   : 64 bits unsigned value.
    153132 *********************************************************************************/
    154133void putl( uint64_t val );
     134void nolock_putl( uint64_t val );
    155135
    156136/**********************************************************************************
Note: See TracChangeset for help on using the changeset viewer.