Changeset 372


Ignore:
Timestamp:
Aug 14, 2017, 2:40:49 PM (7 years ago)
Author:
max@…
Message:

Add a panic function.

Location:
trunk/kernel/kern
Files:
2 edited

Legend:

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

    r337 r372  
    412412}
    413413
     414/////////////////////////////////
     415void _panic( char * format , ... )
     416{
     417    va_list       args;
     418    uint32_t      save_sr;
     419
     420    // get pointers on TXT0 chdev
     421    xptr_t    txt0_xp  = chdev_dir.txt[0];
     422    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
     423    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
     424
     425    // get extended pointer on remote TXT0 chdev lock
     426    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
     427
     428    // get TXT0 lock in busy waiting mode
     429    remote_spinlock_lock_busy( lock_xp , &save_sr );
     430
     431    // call kernel_printf on TXT0, in busy waiting mode
     432    va_start( args , format );
     433    kernel_printf( 0 , 1 , format , &args );
     434    va_end( args );
     435
     436    // release lock
     437    remote_spinlock_unlock_busy( lock_xp , save_sr );
     438
     439    hal_disable_irq( NULL );
     440
     441    while (1)
     442    {
     443        hal_core_sleep();
     444    }
     445}
     446
    414447////////////////////////////////////
    415448void assert( bool_t       condition,
  • trunk/kernel/kern/printk.h

    r367 r372  
    11/*
    22 * printk.h - Kernel Log & debug messages API definition.
    3  * 
     3 *
    44 * authors  Alain Greiner (2016)
    55 *
     
    2424///////////////////////////////////////////////////////////////////////////////////
    2525// The printk.c and printk.h files define the functions used by the kernel
    26 // to display messages on a text terminal. 
     26// to display messages on a text terminal.
    2727// Two access modes are supported:
    2828// - The printk() function displays kernel messages on the kernel terminal TXT0,
    29 //   using a busy waiting policy: It calls directly the relevant TXT driver, 
     29//   using a busy waiting policy: It calls directly the relevant TXT driver,
    3030//   after taking the TXT0 chdev lock for exclusive access to the TXT0 terminal.
    3131// - The user_printk() function displays messages on the calling thread private
    3232//   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.
     33//   TXT chdev waiting queue and deschedule. The calling thread is reactivated by
     34//   the IRQ signalling completion.
    3535// Both functions use the generic TXT device to call the proper implementation
    3636// dependant TXT driver.
    37 // Finally these files define a set of conditionnal trace <***_dmsg> for debug.
     37// Finally these files define a set of conditional trace <***_dmsg> for debug.
    3838///////////////////////////////////////////////////////////////////////////////////
    3939
     
    4646
    4747/**********************************************************************************
    48  * This function build a formated string.
     48 * This function build a formatted string.
    4949 * The supported formats are defined below :
    5050 *   %c : single character
     
    6565
    6666/**********************************************************************************
    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, 
     67 * This function displays a formatted string on the kernel terminal TXT0,
     68 * using a busy waiting policy: It calls directly the relevant TXT driver,
    6969 * after taking the TXT0 lock.
    7070 **********************************************************************************
    71  * @ format     : formated string.
     71 * @ format     : formatted string.
    7272 *********************************************************************************/
    7373void printk( char* format, ... );
    7474
    7575/**********************************************************************************
    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, 
     76 * This function displays a formatted string on the kernel terminal TXT0,
     77 * using a busy waiting policy: It calls directly the relevant TXT driver,
    7878 * without taking the TXT0 lock.
    7979 **********************************************************************************
    80  * @ format     : formated string.
     80 * @ format     : formatted string.
    8181 *********************************************************************************/
    8282void nolock_printk( char* format, ... );
    8383
    8484/**********************************************************************************
    85  * This function displays a "PANIC" message and force the calling core in
     85 * This function displays a message and forces the calling core in sleeping mode.
     86 **********************************************************************************
     87 * @ format        : formatted string
     88 *********************************************************************************/
     89void _panic( char* format, ... );
     90
     91/**********************************************************************************
     92 * This function displays a "PANIC" message and forces the calling core in
    8693 * sleeping mode if a Boolean condition is false.
    8794 * These functions are actually used to debug the kernel...
     
    8996 * @ condition     : condition that must be true.
    9097 * @ function_name : name of the calling function.
    91  * @ format        : formated string
     98 * @ format        : formatted string
    9299 *********************************************************************************/
    93100void assert( bool_t       condition,
     
    95102             char       * format , ... );
    96103
     104#define panic(fmt, ...)     _panic("[PANIC] %s(): " fmt, __func__, ##__VA_ARGS__)
     105
    97106///////////////////////////////////////////////////////////////////////////////////
    98 //       Conditionnal debug macros
     107//       Conditional debug macros
    99108///////////////////////////////////////////////////////////////////////////////////
    100109
     
    250259
    251260#if CONFIG_RPC_DEBUG
    252 #define rpc_dmsg(...)   if(hal_time_stamp() > CONFIG_RPC_DEBUG) printk(__VA_ARGS__) 
     261#define rpc_dmsg(...)   if(hal_time_stamp() > CONFIG_RPC_DEBUG) printk(__VA_ARGS__)
    253262#else
    254263#define rpc_dmsg(...)
     
    292301
    293302#if CONFIG_VFS_DEBUG
    294 #define vfs_dmsg(...)   if(hal_time_stamp() > CONFIG_VFS_DEBUG) printk(__VA_ARGS__) 
     303#define vfs_dmsg(...)   if(hal_time_stamp() > CONFIG_VFS_DEBUG) printk(__VA_ARGS__)
    295304#else
    296305#define vfs_dmsg(...)
Note: See TracChangeset for help on using the changeset viewer.