Ignore:
Timestamp:
Oct 4, 2018, 11:47:36 PM (6 years ago)
Author:
alain
Message:

Complete restructuration of kernel locks.

File:
1 edited

Legend:

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

    r502 r564  
    2626#include <hal_special.h>
    2727#include <dev_txt.h>
    28 #include <remote_spinlock.h>
     28#include <remote_busylock.h>
    2929#include <cluster.h>
    3030#include <thread.h>
     
    201201// @ args      : va_list of arguments.
    202202//////////////////////////////////////////////////////////////////////////////////////
    203 static void kernel_printf( char    * format,
    204                            va_list  * args )
     203static void kernel_printf( const char * format,
     204                           va_list    * args )
    205205{
    206206
     
    352352{
    353353    va_list       args;
    354     reg_t         save_sr;
    355354
    356355    // get pointers on TXT0 chdev
     
    359358    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
    360359
    361     // get extended pointer on remote TXT0 chdev lock
     360    // get extended pointer on remote TXT0 lock
    362361    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
    363362
    364     // get TXT0 lock in busy waiting mode
    365     remote_spinlock_lock_busy( lock_xp , &save_sr );
    366 
    367     // call kernel_printf on TXT0, in busy waiting mode
     363    // get TXT0 lock
     364    remote_busylock_acquire( lock_xp );
     365
     366    // display format on TXT0 in busy waiting mode
    368367    va_start( args , format );
    369368    kernel_printf( format , &args );
    370369    va_end( args );
    371370
    372     // release lock
    373     remote_spinlock_unlock_busy( lock_xp , save_sr );
     371    // release TXT0 lock
     372    remote_busylock_release( lock_xp );
    374373}
    375374
     
    386385
    387386////////////////////////////////////
    388 void __panic( const char * file_name,
    389               const char * function_name,
    390               uint32_t     line,
    391               cycle_t      cycle,
    392               const char * format,
    393               ... )
     387void panic( const char * file_name,
     388            const char * function_name,
     389            uint32_t     line,
     390            cycle_t      cycle,
     391            const char * format,
     392            ... )
    394393{
    395394    // get pointers on TXT0 chdev
     
    399398
    400399    // get extended pointer on remote TXT0 lock
    401     xptr_t lock_txt0_xp = XPTR(txt0_cxy, &txt0_ptr->wait_lock);
    402 
    403     // get TXT0 lock in busy waiting mode
    404     {
    405         uint32_t save_sr;
    406         remote_spinlock_lock_busy(lock_txt0_xp, &save_sr);
    407 
    408         thread_t *current = CURRENT_THREAD;
    409         nolock_printk(
    410             "\n[PANIC] in %s: line %d | funct %s | cycle %d\n"
    411             "core[%x,%d] | thread %x in process %x\n"
    412             "            | thread_ptr %x | procress_ptr %x\n",
     400    xptr_t lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
     401
     402    // get TXT0 lock
     403    remote_busylock_acquire( lock_xp );
     404
     405    // get calling thread
     406    thread_t * current = CURRENT_THREAD;
     407
     408    // print generic infos
     409    nolock_printk(
     410            "\n[PANIC] in %s: line %d | function %s | cycle %d\n"
     411            "core[%x,%d] | thread %x (%x) in process %x (%x)\n",
    413412            file_name, line, function_name, (uint32_t) cycle,
    414             local_cxy, current->core->lid, current->trdid, current->process->pid,
    415             current, current->process);
    416 
    417         // call kernel_printf on TXT0, in busy waiting to print format
    418         va_list args;
    419         va_start(args, format);
    420         kernel_printf(format, &args);
    421         va_end(args);
    422 
    423         // release TXT0 lock
    424         remote_spinlock_unlock_busy(lock_txt0_xp, save_sr);
    425     }
     413            local_cxy, current->core->lid,
     414            current->trdid, current,
     415            current->process->pid, current->process );
     416
     417    // call kernel_printf to print format
     418    va_list args;
     419    va_start(args, format);
     420    kernel_printf(format, &args);
     421    va_end(args);
     422
     423    // release TXT0 lock
     424    remote_busylock_release( lock_xp );
    426425
    427426    // suicide
     
    432431void puts( char * string )
    433432{
    434     uint32_t   save_sr;
    435433    uint32_t   n = 0;
    436434
     
    443441    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
    444442
    445     // get extended pointer on remote TXT0 chdev lock
     443    // get extended pointer on remote TXT0 lock
    446444    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
    447445
    448     // get TXT0 lock in busy waiting mode
    449     remote_spinlock_lock_busy( lock_xp , &save_sr );
     446    // get TXT0 lock
     447    remote_busylock_acquire( lock_xp );
    450448
    451449    // display string on TTY0
    452450    dev_txt_sync_write( string , n );
    453451
    454     // release TXT0 lock in busy waiting mode
    455     remote_spinlock_unlock_busy( lock_xp , save_sr );
     452    // release TXT0 lock
     453    remote_busylock_release( lock_xp );
    456454}
    457455
     
    464462    char      buf[10];
    465463    uint32_t  c;
    466     uint32_t  save_sr;
    467464
    468465    buf[0] = '0';
     
    484481    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
    485482
    486     // get TXT0 lock in busy waiting mode
    487     remote_spinlock_lock_busy( lock_xp , &save_sr );
     483    // get TXT0 lock
     484    remote_busylock_acquire( lock_xp );
    488485
    489486    // display string on TTY0
    490487    dev_txt_sync_write( buf , 10 );
    491488
    492     // release TXT0 lock in busy waiting mode
    493     remote_spinlock_unlock_busy( lock_xp , save_sr );
     489    // release TXT0 lock
     490    remote_busylock_release( lock_xp );
    494491}
    495492
     
    501498    char      buf[18];
    502499    uint32_t  c;
    503     uint32_t  save_sr;
    504500
    505501    buf[0] = '0';
     
    521517    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
    522518
    523     // get TXT0 lock in busy waiting mode
    524     remote_spinlock_lock_busy( lock_xp , &save_sr );
     519    // get TXT0 lock
     520    remote_busylock_acquire( lock_xp );
    525521
    526522    // display string on TTY0
    527523    dev_txt_sync_write( buf , 18 );
    528524
    529     // release TXT0 lock in busy waiting mode
    530     remote_spinlock_unlock_busy( lock_xp , save_sr );
     525    // release TXT0 lock
     526    remote_busylock_release( lock_xp );
    531527}
    532528
Note: See TracChangeset for help on using the changeset viewer.