Ignore:
Timestamp:
Jul 27, 2017, 12:23:29 AM (7 years ago)
Author:
alain
Message:

1) Introduce independant command fields for the various devices in the thread descriptor.
2) Introduce a new dev_pic_enable_ipi() function in the generic PIC device
3) Fix two bugs identified by Maxime in the scheduler initialisation, and in the sched_select().
4) fix several bugs in the TSAR hal_kentry.S.
5) Introduce a third kgiet segment (besides kdata and kcode) in the TSAR bootloader.

File:
1 edited

Legend:

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

    r265 r279  
    2828#include <hal_special.h>
    2929#include <hal_context.h>
     30#include <hal_irqmask.h>
    3031#include <barrier.h>
    3132#include <remote_barrier.h>
     
    5960
    6061///////////////////////////////////////////////////////////////////////////////////////////
    61 // All these global variables are replicated in all clusters.
     62// All the following global variables are replicated in all clusters.
    6263// They are initialised by the kernel_init() function.
    6364//
     
    135136           "    /_/        \\_\\ |______| |_|    |_|   \\_____/  |______/        |_|    |_|  |_|  \\_\\ |_|   |_|  \n"
    136137           "\n\n\t\t Advanced Locality Management Operating System / Multi Kernel Hybrid\n"
    137            "\n\n\t\t\t Version 0.0   :   %d clusters   /   %d cores per cluster\n\n", nclusters , ncores );
     138           "\n\n\t\t\t Version 0.0 : %d cluster(s)   /   %d core(s) per cluster\n\n", nclusters , ncores );
    138139}
    139140
     
    274275            }
    275276
    276             if( local_cxy == 0 )
    277             kinit_dmsg("\n[INFO] %s created MMC chdev in cluster 0 at cycle %d\n",
    278                        __FUNCTION__ , local_cxy , (uint32_t)hal_time_stamp() );
     277            kinit_dmsg("\n[INFO] %s created MMC in cluster %x / chdev = %x\n",
     278                       __FUNCTION__ , channel , local_cxy , chdev_ptr );
    279279        }
    280280        ///////////////////////////////
     
    301301                chdev_dir.dma[channel] = XPTR( local_cxy , chdev_ptr );
    302302
    303                 kinit_dmsg("\n[INFO] %s created DMA[%d] chdev in cluster 0 at cycle %d\n",
    304                            __FUNCTION__ , channel , (uint32_t)hal_time_stamp() );
     303                kinit_dmsg("\n[INFO] %s created DMA[%d] in cluster %x / chdev = %x\n",
     304                           __FUNCTION__ , channel , local_cxy , chdev_ptr );
    305305            }
    306306        }
     
    433433                    }
    434434
    435                             kinit_dmsg("\n[INFO] %s create chdev %s[%d] in cluster %x at cycle %d\n",
    436                                __FUNCTION__ , chdev_func_str( func ), channel,
    437                                local_cxy , (uint32_t)hal_time_stamp() );
     435                            kinit_dmsg("\n[INFO] %s create chdev %s[%d] in cluster %x / chdev = %x\n",
     436                    __FUNCTION__ , chdev_func_str( func ), channel , local_cxy , chdev );
    438437
    439438                }  // end if match
     
    658657}
    659658
     659////////////////////////////////////////////////////////////////////////////////////////////
     660// This function display on TXT0 the content of the external chdev directory,
     661// in the local cluster.
     662////////////////////////////////////////////////////////////////////////////////////////////
     663static void chdev_dir_display( )
     664{
     665    cxy_t     iob_cxy  = GET_CXY( chdev_dir.iob );
     666    chdev_t * iob_ptr  = (chdev_t *)GET_PTR( chdev_dir.iob );
     667    xptr_t    iob_base = hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
     668
     669    cxy_t     pic_cxy  = GET_CXY( chdev_dir.pic );
     670    chdev_t * pic_ptr  = (chdev_t *)GET_PTR( chdev_dir.pic );
     671    xptr_t    pic_base = hal_remote_lwd( XPTR( pic_cxy , &pic_ptr->base ) );
     672
     673    cxy_t     txt0_cxy  = GET_CXY( chdev_dir.txt[0] );
     674    chdev_t * txt0_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[0] );
     675    xptr_t    txt0_base = hal_remote_lwd( XPTR( txt0_cxy , &txt0_ptr->base ) );
     676
     677    cxy_t     txt1_cxy  = GET_CXY( chdev_dir.txt[1] );
     678    chdev_t * txt1_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[1] );
     679    xptr_t    txt1_base = hal_remote_lwd( XPTR( txt1_cxy , &txt1_ptr->base ) );
     680
     681    cxy_t     txt2_cxy  = GET_CXY( chdev_dir.txt[2] );
     682    chdev_t * txt2_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[2] );
     683    xptr_t    txt2_base = hal_remote_lwd( XPTR( txt2_cxy , &txt2_ptr->base ) );
     684
     685    cxy_t     ioc_cxy  = GET_CXY( chdev_dir.ioc[0] );
     686    chdev_t * ioc_ptr  = (chdev_t *)GET_PTR( chdev_dir.ioc[0] );
     687    xptr_t    ioc_base = hal_remote_lwd( XPTR( ioc_cxy , &ioc_ptr->base ) );
     688
     689    cxy_t     fbf_cxy  = GET_CXY( chdev_dir.fbf[0] );
     690    chdev_t * fbf_ptr  = (chdev_t *)GET_PTR( chdev_dir.fbf[0] );
     691    xptr_t    fbf_base = hal_remote_lwd( XPTR( fbf_cxy , &fbf_ptr->base ) );
     692
     693    cxy_t     nic_rx_cxy  = GET_CXY( chdev_dir.nic_rx[0] );
     694    chdev_t * nic_rx_ptr  = (chdev_t *)GET_PTR( chdev_dir.nic_rx[0] );
     695    xptr_t    nic_rx_base = hal_remote_lwd( XPTR( nic_rx_cxy , &nic_rx_ptr->base ) );
     696
     697    cxy_t     nic_tx_cxy  = GET_CXY( chdev_dir.nic_tx[0] );
     698    chdev_t * nic_tx_ptr  = (chdev_t *)GET_PTR( chdev_dir.nic_tx[0] );
     699    xptr_t    nic_tx_base = hal_remote_lwd( XPTR( nic_tx_cxy , &nic_tx_ptr->base ) );
     700
     701    printk("\n*** external chdev directory in cluster %x\n"
     702           "  - iob       = %l / base = %l\n"
     703           "  - pic       = %l / base = %l\n"
     704           "  - txt[0]    = %l / base = %l\n"
     705           "  - txt[1]    = %l / base = %l\n"
     706           "  - txt[2]    = %l / base = %l\n"
     707           "  - ioc[0]    = %l / base = %l\n"
     708           "  - fbf[0]    = %l / base = %l\n"
     709           "  - nic_rx[0] = %l / base = %l\n"
     710           "  - nic_tx[0] = %l / base = %l\n",
     711           local_cxy,
     712           chdev_dir.iob, iob_base,
     713           chdev_dir.pic, pic_base,
     714           chdev_dir.txt[0], txt0_base,
     715           chdev_dir.txt[1], txt1_base,
     716           chdev_dir.txt[2], txt2_base,
     717           chdev_dir.ioc[0], ioc_base,
     718           chdev_dir.fbf[0], fbf_base,
     719           chdev_dir.nic_rx[0], nic_rx_base,
     720           chdev_dir.nic_tx[0], nic_tx_base );
     721}
     722
    660723///////////////////////////////////////////////////////////////////////////////////////////
    661724// This function is the entry point for the kernel initialisation.
     
    683746
    684747    error_t      error;
     748    uint32_t     status;                    // running core status register
    685749
    686750    cxy_t        io_cxy = info->io_cxy;
     
    732796    if( error )
    733797    {
    734         nolock_printk("\n[PANIC] in %s : illegal core identifiers"
     798        printk("\n[PANIC] in %s : illegal core identifiers"
    735799               " gid = %x / cxy = %x / lid = %d\n",
    736800               __FUNCTION__ , core_lid , core_cxy , core_lid );
     
    745809        if( error )
    746810        {
    747             nolock_printk("\n[PANIC] in %s : cannot initialise cluster %x",
     811            printk("\n[PANIC] in %s : cannot initialise cluster %x",
    748812                   __FUNCTION__ , local_cxy );
    749813            hal_core_sleep();
     
    764828    // STEP 2 : all CP0s initialize the process_zero descriptor.
    765829    //          CP0 in cluster 0 initialises the IOPIC device.
    766     //          all CP0s complete the distibuted LAPIC initialization.
    767830    /////////////////////////////////////////////////////////////////////////////////
    768831
     
    777840    if( (core_lid == 0) && (local_cxy == 0) ) iopic_init( info );
    778841   
    779     // all CP0s initialize their local LAPIC extension,
    780     if( core_lid == 0 ) lapic_init( info );
    781 
    782842    ////////////////////////////////////////////////////////////////////////////////
    783843    if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ),
     
    791851
    792852    ////////////////////////////////////////////////////////////////////////////////
    793     // STEP 3 : all CP0s initialize their local chdev descriptors
    794     //          (both internal devices and external devices).
     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
    795856    ////////////////////////////////////////////////////////////////////////////////
     857
     858    // all CP0s initialize their local LAPIC extension,
     859    if( core_lid == 0 ) lapic_init( info );
    796860
    797861    // CP0 scan the internal (private) peripherals,
     
    818882
    819883    /////////////////////////////////////////////////////////////////////////////////
    820     // STEP 4 : Alls cores initialize their private IDLE thread.
     884    // STEP 4 : All cores enable IPI (Inter Procesor Interrupt),
     885    //          Alh cores initialize IDLE thread.
    821886    //          Only CP0 in cluster 0 creates the VFS root inode.
    822887    //          It access the boot device to initialize the file system context.
    823888    /////////////////////////////////////////////////////////////////////////////////
    824889
    825     // all cores create idle thread descriptor
     890    if( CONFIG_KINIT_DEBUG ) chdev_dir_display();
     891   
     892    // All cores enable the shared IPI channel
     893
     894// @@@
     895    hal_set_ebase( 0x1000 );
     896// @@@
     897
     898    dev_pic_enable_ipi();
     899    hal_enable_irq( &status );
     900
     901    kinit_dmsg("\n[INFO] %s : IRQs enabled for core[%x,%d] / SR = %x\n",
     902               __FUNCTION__ , local_cxy , core_lid , hal_get_sr() );
     903
     904    // all cores create the idle thread descriptor
    826905    error = thread_kernel_init( thread,
    827906                                THREAD_IDLE,
     
    831910    if( error )
    832911    {
    833         nolock_printk("\n[PANIC] in %s : core[%x][%d] cannot initialize idle thread\n",
     912        printk("\n[PANIC] in %s : core[%x][%d] cannot initialize idle thread\n",
    834913                      __FUNCTION__ , local_cxy , core_lid );
    835914        hal_core_sleep();
     
    860939            fatfs_ctx_t * fatfs_ctx = fatfs_ctx_alloc();
    861940
    862             nolock_assert( (fatfs_ctx != NULL) , __FUNCTION__ ,
    863                            "cannot create FATFS context in cluster 0\n" );
     941            assert( (fatfs_ctx != NULL) , __FUNCTION__ ,
     942                    "cannot create FATFS context in cluster 0\n" );
    864943
    865944            // 2. access boot device to initialize FATFS context
     
    883962                                      &vfs_root_inode_xp );                // return
    884963
    885             nolock_assert( (error == 0) , __FUNCTION__ ,
    886                            "cannot create VFS root inode\n" );
     964            assert( (error == 0) , __FUNCTION__ ,
     965                    "cannot create VFS root inode\n" );
    887966
    888967            // 5. initialize VFS context for FAT in cluster 0
     
    896975        else
    897976        {
    898             nolock_printk("\n[PANIC] in %s : root FS must be FATFS\n", __FUNCTION__ );
     977            printk("\n[PANIC] in %s : root FS must be FATFS\n", __FUNCTION__ );
    899978            hal_core_sleep();
    900979        }
     
    9311010            fatfs_ctx_t * fatfs_ctx = fatfs_ctx_alloc();
    9321011
    933             nolock_assert( (fatfs_ctx != NULL) , __FUNCTION__ ,
    934                            "cannot create FATFS context\n" );
     1012            assert( (fatfs_ctx != NULL) , __FUNCTION__ ,
     1013                    "cannot create FATFS context\n" );
    9351014
    9361015            // get local pointer on VFS context for FATFS
     
    9651044    /////////////////////////////////////////////////////////////////////////////////
    9661045
    967     if( (core_lid ==  0) && (local_cxy == 0) )
     1046//    if( (core_lid ==  0) && (local_cxy == 0) )
    9681047    kinit_dmsg("\n[INFO] %s exit barrier 5 at cycle %d : VFS OK in all clusters\n",
    9691048               __FUNCTION__, (uint32_t)hal_time_stamp());
     
    9861065        devfs_ctx_t * devfs_ctx = devfs_ctx_alloc();
    9871066
    988         nolock_assert( (devfs_ctx != NULL) , __FUNCTION__ ,
    989                        "cannot create DEVFS context in cluster IO\n");
     1067        assert( (devfs_ctx != NULL) , __FUNCTION__ ,
     1068                "cannot create DEVFS context in cluster IO\n");
    9901069
    9911070        // register DEVFS root and external directories
     
    9931072    }   
    9941073
     1074printk("\n@@@ %s : cluster %x reach barrier 6\n", __FUNCTION__ , local_cxy );
     1075
    9951076    /////////////////////////////////////////////////////////////////////////////////
    9961077    if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ),
     
    9991080    /////////////////////////////////////////////////////////////////////////////////
    10001081
    1001     if( (core_lid ==  0) && (local_cxy == 0) )
     1082//    if( (core_lid ==  0) && (local_cxy == 0) )
    10021083    kinit_dmsg("\n[INFO] %s exit barrier 6 at cycle %d : DEVFS OK in cluster IO\n",
    10031084               __FUNCTION__, (uint32_t)hal_time_stamp());
     
    10711152        print_banner( (info->x_size * info->y_size) , info->cores_nr );
    10721153
    1073         kinit_dmsg("\n\n*** memory fooprint of main kernet objects ***\n"
     1154        kinit_dmsg("\n\n*** memory fooprint for main kernet objects ***\n\n"
    10741155                   " - thread descriptor  : %d bytes\n"
    10751156                   " - process descriptor : %d bytes\n"
     
    11141195    }
    11151196
    1116     // each core activates its private PTI IRQ
     1197    // each core activates its private TICK IRQ
    11171198    dev_pic_enable_timer( CONFIG_SCHED_TICK_PERIOD );
    11181199
Note: See TracChangeset for help on using the changeset viewer.