Changeset 103 for trunk/kernel/kern


Ignore:
Timestamp:
Jun 29, 2017, 6:22:27 PM (5 years ago)
Author:
alain
Message:

Introducing a nolock_printk() function used by kernel_init.

Location:
trunk/kernel/kern
Files:
3 edited

Legend:

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

    r101 r103  
    641641// To comply with the multi-kernels paradigm, it accesses only local cluster memory, using
    642642// only information contained in the local boot_info_t structure, set by the bootloader.
     643// Only CP0 in cluster 0 print the log messages.
    643644///////////////////////////////////////////////////////////////////////////////////////////
    644645// @ info    : pointer on the local boot-info structure.
     
    654655    error_t      error;
    655656
    656     // all cores get core identifiers
     657    // all cores get and check core identifiers
    657658    error = get_core_identifiers( info,
    658659                                  &core_lid,
     
    668669    // each core registers this thread pointer in hardware register
    669670    hal_set_current_thread( thread );
    670 
    671 #ifdef __HAL_x86_64__
    672         return;
    673 #endif
    674671
    675672    // CP0 in I/O cluster initialises TXT0 chdev descriptor
     
    683680    /////////////////////////////////////////////////////////////////////////////////
    684681
    685     kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 0 at cycle %d\n",
    686                __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
     682    if( (core_lid ==  0) && (local_cxy == info->io_cxy) )
     683    {
     684        kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 0 at cycle %d\n",
     685                   __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
     686    }
    687687
    688688    // all cores check core identifiers
    689689    if( error )
    690690    {
    691         printk("\n[PANIC] in %s : illegal core identifiers"
     691        nolock_printk("\n[PANIC] in %s : illegal core identifiers"
    692692               " gid = %x / cxy = %x / lid = %d\n",
    693693               __FUNCTION__ , core_lid , core_cxy , core_lid );
     
    702702        if( error )
    703703        {
    704             printk("\n[PANIC] in %s : cannot initialise cluster manager in cluster %x",
     704            nolock_printk("\n[PANIC] in %s : cannot initialise cluster manager in cluster %x",
    705705                   __FUNCTION__ , local_cxy );
    706706            hal_core_sleep();
     
    715715    /////////////////////////////////////////////////////////////////////////////////
    716716
    717     kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 1 at cycle %d\n",
    718                __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
     717    if( (core_lid ==  0) && (local_cxy == info->io_cxy) )
     718    {
     719        kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 1 at cycle %d\n",
     720                   __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
     721    }
    719722
    720723    // all cores get pointer on local cluster manager and on core descriptor
     
    744747            if( wti_id != lid )
    745748            {
    746                 printk("\n[PANIC] in %s : WTI index for IPI = %d / core_lid = %d",
    747                        __FUNCTION__ , wti_id , lid );
     749                nolock_printk("\n[PANIC] in %s : WTI index for IPI = %d / core_lid = %d",
     750                              __FUNCTION__ , wti_id , lid );
    748751                hal_core_sleep();
    749752            }
     
    766769    /////////////////////////////////////////////////////////////////////////////////
    767770
    768     kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 2 at cycle %d\n",
    769                __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
    770 
     771    if( (core_lid ==  0) && (local_cxy == info->io_cxy) )
     772    {
     773        kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 2 at cycle %d\n",
     774                   __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
     775    }
    771776
    772777    error = thread_kernel_init( thread,
     
    777782    if( error )
    778783    {
    779         printk("\n[PANIC] in %s : core[%x][%d] cannot initialize idle thread\n",
    780                __FUNCTION__ , local_cxy , core_lid );
     784        nolock_printk("\n[PANIC] in %s : core[%x][%d] cannot initialize idle thread\n",
     785                      __FUNCTION__ , local_cxy , core_lid );
    781786        hal_core_sleep();
    782787    }
    783     else
    784     {
    785         // register idle thread in scheduler
    786         core->scheduler.idle = thread;
    787 
    788         // activate the idle thread
    789         thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL );
    790 
     788
     789    // register idle thread in scheduler
     790    core->scheduler.idle = thread;
     791
     792    // activate the idle thread
     793    thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL );
     794
     795    if( (core_lid ==  0) && (local_cxy == info->io_cxy) )
     796    {
    791797        kinit_dmsg("\n[INFO] %s : core[%x][%d] created idle thread %x at cycle %d\n",
    792798                   __FUNCTION__ , core_cxy , core_lid , thread , hal_get_cycles());
     
    805811        else
    806812        {
    807             printk("\n[PANIC] in %s : root FS must be FATFS\n", __FUNCTION__ );
     813            nolock_printk("\n[PANIC] in %s : root FS must be FATFS\n", __FUNCTION__ );
    808814            hal_core_sleep();
    809815        }
     
    811817        if( root_inode_xp == XPTR_NULL )
    812818        {
    813             printk("\n[PANIC] in %s : core[%x][%d] cannot initialize file system\n",
     819            nolock_printk("\n[PANIC] in %s : core[%x][%d] cannot initialize file system\n",
    814820                   __FUNCTION__ , local_cxy , core_lid );
    815821            hal_core_sleep();
     
    882888    /////////////////////////////////////////////////////////////////////////////////
    883889
    884     kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 3 at cycle %d\n",
    885                __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
     890    if( (core_lid ==  0) && (local_cxy == info->io_cxy) )
     891    {
     892        kinit_dmsg("\n[INFO] %s : core[%x][%d] exit barrier 3 at cycle %d\n",
     893                   __FUNCTION__ , core_cxy , core_lid , hal_get_cycles() );
     894    }
    886895
    887896    // each core activates its private PTI IRQ
     
    895904    dev_icu_get_masks( core_lid , &hwi_mask , &wti_mask , &pti_mask );
    896905
    897     thread_dmsg("\n[INFO] %s : core[%x][%d] activates scheduler at cycle %d\n"
     906    thread_dmsg("\n[INFO] %s : core[%x][%d] complete kernel init at cycle %d\n"
    898907                "   hwi_mask = %x / wti_mask = %x / pti_mask = %x\n",
    899908                    __FUNCTION__ , local_cxy , core_lid , hal_get_cycles() ,
  • trunk/kernel/kern/printk.c

    r23 r103  
    375375    remote_spinlock_lock_busy( txt0_lock_xp , &save_sr );
    376376
    377     // call kernel_printf in busy waiting mode
     377    // call kernel_printf on TXT0, in busy waiting mode
    378378    va_start( args , format );
    379379    kernel_printf( 0 , 1 , format , &args );
     
    384384}
    385385
    386 //////////////////////////////////////
    387 void user_printk( char * format , ...)
     386////////////////////////////////////////
     387void nolock_printk( char * format , ...)
    388388{
    389389    va_list   args;
    390390
    391     // get calling thread TXT channel TODO
    392     uint32_t channel = 0;
    393 
    394    // call kernel_printf in descheduling mode
     391    // call kernel_printf on TXT0, in busy waiting mode
    395392    va_start( args , format );
    396     kernel_printf( channel, 0 , format , &args );
     393    kernel_printf( 0 , 1 , format , &args );
    397394    va_end( args );
    398395}
  • trunk/kernel/kern/printk.h

    r50 r103  
    6767 * This function displays a formated string on the kernel terminal TXT0,
    6868 * using a busy waiting policy: It calls directly the relevant TXT driver,
    69  * after taking the TXT0 chdev lock for exclusive access to the TXT0 terminal.
     69 * after taking the lock for exclusive access to the TXT0 terminal.
    7070 **********************************************************************************
    7171 * @ format     : formated string.
    7272 *********************************************************************************/
    73 void         printk( char* format, ... );
     73void printk( char* format, ... );
    7474
    7575/**********************************************************************************
    76  * Display a formated string on the calling thread private terminal, using a
    77  * descheduling policy: it register the request in the selected TXT chdev waiting
    78  * queue and deschedule. IT is reactivated by the IRQ signaling completion.
    79  * Not fully implemented yet ( use TXT0 in deschedling mode ).
     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,
     78 * without taking the the lock protecting exclusive access to TXT0 terminal.
    8079 **********************************************************************************
    8180 * @ format     : formated string.
    8281 *********************************************************************************/
    83 void         user_printk( char* format, ... );
     82void nolock_printk( char* format, ... );
    8483
    8584/**********************************************************************************
     
    203202
    204203#if CONFIG_KINIT_DEBUG
    205 #define kinit_dmsg(...) printk(__VA_ARGS__)
     204#define kinit_dmsg(...) nolock_printk(__VA_ARGS__)
    206205#else
    207206#define kinit_dmsg(...)
Note: See TracChangeset for help on using the changeset viewer.