Ignore:
Timestamp:
Jul 31, 2017, 1:59:52 PM (7 years ago)
Author:
alain
Message:

Several modifs in the generic scheduler and in the hal_context to
fix the context switch mechanism.

File:
1 edited

Legend:

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

    r285 r296  
    2929#include <hal_context.h>
    3030#include <hal_irqmask.h>
     31#include <hal_ppm.h>
    3132#include <barrier.h>
    3233#include <remote_barrier.h>
     
    784785
    785786    if( (core_lid ==  0) && (local_cxy == 0) )
    786     kinit_dmsg("\n[INFO] %s exit barrier 0 at cycle %d : TXT0 initialized\n",
    787                __FUNCTION__, (uint32_t)hal_time_stamp());
     787    kinit_dmsg("\n[INFO] %s : exit barrier 0 : TXT0 initialized / cycle %d\n",
     788    __FUNCTION__, hal_time_stamp() );
    788789
    789790    /////////////////////////////////////////////////////////////////////////////
     
    822823
    823824    if( (core_lid ==  0) && (local_cxy == 0) )
    824     kinit_dmsg("\n[INFO] %s exit barrier 1 at cycle %d : clusters initialised\n",
    825                __FUNCTION__, (uint32_t)hal_time_stamp());
     825    kinit_dmsg("\n[INFO] %s : exit barrier 1 : clusters initialised / cycle %d\n",
     826    __FUNCTION__, hal_time_stamp() );
    826827
    827828    /////////////////////////////////////////////////////////////////////////////////
    828829    // STEP 2 : all CP0s initialize the process_zero descriptor.
    829     //          CP0 in cluster 0 initialises the IOPIC device.
     830    //          CP0 in cluster 0 initializes the IOPIC device.
    830831    /////////////////////////////////////////////////////////////////////////////////
    831832
     
    847848
    848849    if( (core_lid ==  0) && (local_cxy == 0) )
    849     kinit_dmsg("\n[INFO] %s exit barrier 2 at cycle %d : PIC initialised\n",
    850                __FUNCTION__, (uint32_t)hal_time_stamp());
     850    kinit_dmsg("\n[INFO] %s : exit barrier 2 : PIC initialised / cycle %d\n",
     851    __FUNCTION__, hal_time_stamp() );
    851852
    852853    ////////////////////////////////////////////////////////////////////////////////
    853     // STEP 3 : all CP0s complete the distibuted LAPIC initialization.
    854     //          all CP0s initialize their internal chdev descriptors
    855     //          all CP0s initialize their local external chdev descriptors
     854    // STEP 3 : all CP0s initialize the distibuted LAPIC descriptor.
     855    //          all CP0s initialize the internal chdev descriptors
     856    //          all CP0s initialize the local external chdev descriptors
    856857    ////////////////////////////////////////////////////////////////////////////////
    857858
     
    878879
    879880    if( (core_lid ==  0) && (local_cxy == 0) )
    880     kinit_dmsg("\n[INFO] %s exit barrier 3 at cycle %d : all chdev initialised\n",
    881                __FUNCTION__, (uint32_t)hal_time_stamp());
     881    kinit_dmsg("\n[INFO] %s : exit barrier 3 : all chdev initialised / cycle %d\n",
     882               __FUNCTION__, hal_time_stamp());
    882883
    883884    /////////////////////////////////////////////////////////////////////////////////
    884885    // STEP 4 : All cores enable IPI (Inter Procesor Interrupt),
     886    //          All cores initialise specific core registers
    885887    //          Alh cores initialize IDLE thread.
    886888    //          Only CP0 in cluster 0 creates the VFS root inode.
     
    891893   
    892894    // All cores enable the shared IPI channel
    893 
    894 // @@@
    895     hal_set_ebase( 0x1000 );
    896 // @@@
    897 
    898895    dev_pic_enable_ipi();
    899896    hal_enable_irq( &status );
    900897
     898    // All cores initialize specific core registers
     899    hal_core_init( info );
     900
    901901    kinit_dmsg("\n[INFO] %s : IRQs enabled for core[%x,%d] / SR = %x\n",
    902902               __FUNCTION__ , local_cxy , core_lid , hal_get_sr() );
    903903
    904     // all cores create the idle thread descriptor
     904    // all cores initialize the idle thread descriptor
    905905    error = thread_kernel_init( thread,
    906906                                THREAD_IDLE,
     
    915915    }
    916916
    917     // all cores register idle thread in scheduler
     917    // all cores unblock idle thread, and register it in scheduler
     918    thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL );
    918919    core->scheduler.idle = thread;
    919920
    920     // all core activate the idle thread
    921     thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL );
    922 
    923921    if( (core_lid ==  0) && (local_cxy == 0) )
    924922    {
    925         kinit_dmsg("\n[INFO] %s : created idle thread %x at cycle %d\n",
    926                    __FUNCTION__ , thread , (uint32_t)hal_time_stamp());
    927     }
     923        kinit_dmsg("\n[INFO] %s : initialized idle thread %x on core[%x,%d] / cycle %d\n",
     924        __FUNCTION__ , thread->trdid , local_cxy, core_lid, (uint32_t)hal_time_stamp());
     925    }
     926
     927    #if CONFIG_KINIT_DEBUG
     928    sched_display();
     929    #endif
    928930
    929931    // CPO in cluster 0 creates the VFS root
     
    991993
    992994    if( (core_lid ==  0) && (local_cxy == 0) )
    993     kinit_dmsg("\n[INFO] %s exit barrier 4 at cycle %d : VFS OK in cluster 0\n",
    994                __FUNCTION__, (uint32_t)hal_time_stamp());
     995    kinit_dmsg("\n[INFO] %s : exit barrier 4 : VFS_root = %l in cluster 0 / cycle %d\n",
     996               __FUNCTION__, vfs_root_inode_xp , hal_time_stamp());
    995997
    996998    /////////////////////////////////////////////////////////////////////////////////
     
    10101012            fatfs_ctx_t * fatfs_ctx = fatfs_ctx_alloc();
    10111013
    1012             assert( (fatfs_ctx != NULL) , __FUNCTION__ ,
    1013                     "cannot create FATFS context\n" );
     1014            assert( (fatfs_ctx != NULL) , __FUNCTION__ , "cannot create FATFS context\n" );
    10141015
    10151016            // get local pointer on VFS context for FATFS
     
    10311032
    10321033        // get extended pointer on VFS root inode from cluster 0
    1033         vfs_root_inode_xp = hal_remote_lwd( XPTR( 0 , process_zero.vfs_root_xp ) );
     1034        vfs_root_inode_xp = hal_remote_lwd( XPTR( 0 , &process_zero.vfs_root_xp ) );
    10341035
    10351036        // update local process_zero descriptor
     
    10441045    /////////////////////////////////////////////////////////////////////////////////
    10451046
    1046 //    if( (core_lid ==  0) && (local_cxy == 0) )
    1047     kinit_dmsg("\n[INFO] %s exit barrier 5 at cycle %d : VFS OK in all clusters\n",
    1048                __FUNCTION__, (uint32_t)hal_time_stamp());
    1049 
     1047    if( (core_lid ==  0) && (local_cxy == io_cxy) )
     1048    kinit_dmsg("\n[INFO] %s : exit barrier 5 : VFS_root = %l in cluster IO / cycle %d\n",
     1049    __FUNCTION__, vfs_root_inode_xp , hal_time_stamp() );
    10501050
    10511051    /////////////////////////////////////////////////////////////////////////////////
     
    10721072    }   
    10731073
    1074 printk("\n@@@ %s : cluster %x reach barrier 6\n", __FUNCTION__ , local_cxy );
    1075 
    10761074    /////////////////////////////////////////////////////////////////////////////////
    10771075    if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ),
     
    10801078    /////////////////////////////////////////////////////////////////////////////////
    10811079
    1082 //    if( (core_lid ==  0) && (local_cxy == 0) )
    1083     kinit_dmsg("\n[INFO] %s exit barrier 6 at cycle %d : DEVFS OK in cluster IO\n",
    1084                __FUNCTION__, (uint32_t)hal_time_stamp());
     1080    if( (core_lid ==  0) && (local_cxy == io_cxy) )
     1081    kinit_dmsg("\n[INFO] %s : exit barrier 6 : dev_root = %l in cluster IO / cycle %d\n",
     1082    __FUNCTION__, devfs_dev_inode_xp , hal_time_stamp() );
    10851083
    10861084    /////////////////////////////////////////////////////////////////////////////////
     
    11181116
    11191117    if( (core_lid ==  0) && (local_cxy == 0) )
    1120     kinit_dmsg("\n[INFO] %s exit barrier 7 at cycle %d : DEVFS OK in all clusters\n",
    1121                __FUNCTION__, (uint32_t)hal_time_stamp());
     1118    kinit_dmsg("\n[INFO] %s : exit barrier 7 : dev_root = %l in cluster 0 / cycle %d\n",
     1119    __FUNCTION__, devfs_dev_inode_xp , hal_time_stamp() );
    11221120
    11231121    #if CONFIG_KINIT_DEBUG
     
    11411139
    11421140    if( (core_lid ==  0) && (local_cxy == 0) )
    1143     kinit_dmsg("\n[INFO] %s exit barrier 8 at cycle %d : process init created\n",
    1144                __FUNCTION__ , (uint32_t)hal_time_stamp() );
     1141    kinit_dmsg("\n[INFO] %s : exit barrier 8 : process init created / cycle %d\n",
     1142    __FUNCTION__ , hal_time_stamp() );
    11451143
    11461144    /////////////////////////////////////////////////////////////////////////////////
     
    11981196    dev_pic_enable_timer( CONFIG_SCHED_TICK_PERIOD );
    11991197
    1200     if( (core_lid ==  0) && (local_cxy == io_cxy) )
    1201     thread_dmsg("\n[INFO] %s complete kernel init in cluster 0 at cycle %d\n"
    1202                 __FUNCTION__ , (uint32_t)hal_time_stamp() )
    1203 
    12041198    // each core jump to idle thread
    12051199    thread_idle_func();
Note: See TracChangeset for help on using the changeset viewer.