Ignore:
Timestamp:
Nov 20, 2020, 12:30:31 AM (4 years ago)
Author:
alain
Message:

Mainly cosmetic.

Location:
trunk/hal/tsar_mips32/core
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/core/hal_context.c

    r654 r679  
    120120error_t hal_cpu_context_alloc( thread_t * thread )
    121121{
    122     assert( (sizeof(hal_cpu_context_t) <= CONFIG_CPU_CTX_SIZE) ,
    123     "illegal CPU context size" );
     122
     123assert( __FUNCTION__, (sizeof(hal_cpu_context_t) <= CONFIG_CPU_CTX_SIZE), "illegal CPU context size" );
    124124
    125125    // allocate memory for cpu_context
     
    139139}   // end hal_cpu_context_alloc()
    140140
    141 /////////////////////////////////////////////////
    142 // The following context slots are initialised
    143 // GPR : a0_04 / sp_29 / ra_31
     141//////////////////////////////////////////////////////////////////////////////
     142// The following context slots are initialised for the MIPS32 architecture
     143// GPR : a0_04 / a1_05 / sp_29 / ra_31
    144144// CP0 : c0_sr / c0_th / c0_epc
    145145// CP2 : c2_ptpr / c2_mode
    146 /////////////////////////////////////////////////
    147 void hal_cpu_context_init( thread_t * thread )
     146//////////////////////////////////////////////////////////////////////////////
     147void hal_cpu_context_init( thread_t * thread,
     148                           bool_t     is_main,
     149                           uint32_t   argc,
     150                           intptr_t   argv )
    148151{
    149152    hal_cpu_context_t * context = (hal_cpu_context_t *)thread->cpu_context;
    150153
    151     assert( (context != NULL ), "CPU context not allocated" );
     154assert( __FUNCTION__, (context != NULL ), "CPU context not allocated" );
    152155
    153156    // compute the PPN for the GPT PT1
     
    155158
    156159    // initialisation depends on thread type
    157     if( thread->type == THREAD_USER )
     160    if( (thread->type == THREAD_USER) && (is_main != 0) )
     161    {
     162        context->a0_04   = (uint32_t)argc;
     163        context->a1_05   = (uint32_t)argv;
     164        context->sp_29   = (uint32_t)thread->user_stack_vseg->max - 8;
     165        context->ra_31   = (uint32_t)&hal_kentry_eret;
     166        context->c0_epc  = (uint32_t)thread->entry_func;
     167        context->c0_sr   = SR_USR_MODE;
     168            context->c0_th   = (uint32_t)thread;
     169            context->c2_ptpr = (uint32_t)(gpt_pt1_ppn >> 1);
     170        context->c2_mode = 0xF;
     171    }
     172    else if( (thread->type == THREAD_USER) && (is_main == 0) )
    158173    {
    159174        context->a0_04   = (uint32_t)thread->entry_args;
     
    353368}  // end hal_cpu_context_fork()
    354369
    355 //////////////////////////////////////////////
    356 void hal_cpu_context_exec( thread_t * thread )
    357 {
    358     // re_initialize CPU context
    359     hal_cpu_context_init( thread );
    360 
    361     // restore CPU registers ... and jump to user code
    362     hal_do_cpu_restore( (hal_cpu_context_t *)thread->cpu_context );
    363 
    364 } // end hal_cpu_context_exec()
    365 
    366370/////////////////////////////////////////////////
    367371void hal_cpu_context_display( xptr_t  thread_xp )
     
    379383    uint32_t sp_29   = hal_remote_l32( XPTR( cxy , &ctx->sp_29   ) );
    380384    uint32_t ra_31   = hal_remote_l32( XPTR( cxy , &ctx->ra_31   ) );
     385    uint32_t a0_04   = hal_remote_l32( XPTR( cxy , &ctx->a0_04   ) );
     386    uint32_t a1_05   = hal_remote_l32( XPTR( cxy , &ctx->a1_05   ) );
    381387    uint32_t c0_sr   = hal_remote_l32( XPTR( cxy , &ctx->c0_sr   ) );
    382388    uint32_t c0_epc  = hal_remote_l32( XPTR( cxy , &ctx->c0_epc  ) );
     
    386392   
    387393    printk("\n***** CPU context for thread %x in process %x / cycle %d\n"
    388            " sp_29   = %X    ra_31  = %X\n"
    389            " c0_sr   = %X    c0_epc  = %X    c0_th = %X\n"
    390            " c2_ptpr = %X    c2_mode = %X\n",
     394           " sp_29   = %X  ra_31   = %X  a0_04 = %X   a1_05 = %X\n"
     395           " c0_sr   = %X  c0_epc  = %X  c0_th = %X\n"
     396           " c2_ptpr = %X  c2_mode = %X\n",
    391397           ptr, ptr->process->pid, (uint32_t)hal_get_cycles(),
    392            sp_29   , ra_31,
     398           sp_29   , ra_31   , a0_04 , a1_05,
    393399           c0_sr   , c0_epc  , c0_th,
    394400           c2_ptpr , c2_mode );
     
    417423
    418424
     425
     426
     427
     428
    419429//////////////////////////////////////////////////
    420430error_t hal_fpu_context_alloc( thread_t * thread )
    421431{
    422     assert( (sizeof(hal_fpu_context_t) <= CONFIG_FPU_CTX_SIZE) ,
     432    assert( __FUNCTION__, (sizeof(hal_fpu_context_t) <= CONFIG_FPU_CTX_SIZE) ,
    423433    "illegal CPU context size" );
    424434
     
    444454    hal_fpu_context_t * context = thread->fpu_context;
    445455
    446     assert( (context != NULL) , "fpu context not allocated" );
     456    assert( __FUNCTION__, (context != NULL) , "fpu context not allocated" );
    447457
    448458    memset( context , 0 , sizeof(hal_fpu_context_t) );
     
    453463                           thread_t * src )
    454464{
    455     assert( (src != NULL) , "src thread pointer is NULL\n");
    456     assert( (dst != NULL) , "dst thread pointer is NULL\n");
     465    assert( __FUNCTION__, (src != NULL) , "src thread pointer is NULL\n");
     466    assert( __FUNCTION__, (dst != NULL) , "dst thread pointer is NULL\n");
    457467
    458468    // get fpu context pointers
  • trunk/hal/tsar_mips32/core/hal_drivers.c

    r647 r679  
    6262    else
    6363    {
    64         assert( false, "undefined implementation" );
     64        assert( __FUNCTION__, false, "undefined implementation" );
    6565    }
    6666}
     
    7575    uint32_t   impl = pic->impl;
    7676
    77     assert( (impl == IMPL_PIC_SCL), "undefined implementation" );
     77    assert( __FUNCTION__, (impl == IMPL_PIC_SCL), "undefined implementation" );
    7878
    7979        soclib_pic_init( pic );
     
    9999    uint32_t   impl = iob->impl;
    100100
    101         assert( (impl == IMPL_IOB_TSR), "undefined implementation" );
     101        assert( __FUNCTION__, (impl == IMPL_IOB_TSR), "undefined implementation" );
    102102
    103103        soclib_iob_init( iob );
     
    135135    else
    136136    {
    137                 assert( false , "undefined IOC device implementation" );
     137                assert( __FUNCTION__, false , "undefined IOC device implementation" );
    138138        }
    139139}
     
    148148    uint32_t   impl = mmc->impl;
    149149
    150         assert( (impl == IMPL_MMC_TSR), "undefined implementation" );
     150        assert( __FUNCTION__, (impl == IMPL_MMC_TSR), "undefined implementation" );
    151151 
    152152    soclib_mmc_init( mmc );
     
    162162    uint32_t   impl = nic->impl;
    163163
    164         assert( (impl == IMPL_NIC_CBF), "undefined implementation" );
     164        assert( __FUNCTION__, (impl == IMPL_NIC_CBF), "undefined implementation" );
    165165 
    166166    soclib_nic_init( nic );
     
    176176    uint32_t   impl = dma->impl;
    177177
    178         assert( (impl == IMPL_DMA_SCL), "undefined implementation" );
     178        assert( __FUNCTION__, (impl == IMPL_DMA_SCL), "undefined implementation" );
    179179 
    180180    soclib_dma_init( dma );
     
    190190    uint32_t   impl = fbf->impl;
    191191
    192         assert( (impl == IMPL_FBF_SCL), "undefined implementation" );
     192        assert( __FUNCTION__, (impl == IMPL_FBF_SCL), "undefined implementation" );
    193193 
    194194    soclib_fbf_init( fbf );
  • trunk/hal/tsar_mips32/core/hal_gpt.c

    r658 r679  
    152152
    153153// check page size
    154 assert( (CONFIG_PPM_PAGE_SIZE == 4096) , "the TSAR page size must be 4 Kbytes\n" );
     154assert( __FUNCTION__, (CONFIG_PPM_PAGE_SIZE == 4096) , "the TSAR page size must be 4 Kbytes\n" );
    155155
    156156    // allocates 2 physical pages for PT1
     
    423423 
    424424// check PTE1 : only small and mapped pages can be locked
    425 assert( (pte1 & (TSAR_PTE_SMALL | TSAR_PTE_MAPPED)) , "cannot lock a big or unmapped page\n");
     425assert( __FUNCTION__, (pte1 & (TSAR_PTE_SMALL | TSAR_PTE_MAPPED)) , "cannot lock a big or unmapped page\n");
    426426
    427427#if DEBUG_HAL_GPT_LOCK_PTE
     
    537537    pte1 = hal_remote_l32( pte1_xp );
    538538
    539 assert( ((pte1 & TSAR_PTE_MAPPED) != 0),
     539assert( __FUNCTION__, ((pte1 & TSAR_PTE_MAPPED) != 0),
    540540"PTE1 for vpn %x in cluster %x is unmapped / pte1 = %x\n", vpn, gpt_cxy, pte1 );
    541541
    542 assert( ((pte1 & TSAR_PTE_SMALL ) != 0),
     542assert( __FUNCTION__, ((pte1 & TSAR_PTE_SMALL ) != 0),
    543543"PTE1 for vpn %x in cluster %x is not small / pte1 = %x\n", vpn, gpt_cxy, pte1 );
    544544
     
    553553    pte2_attr = hal_remote_l32( pte2_xp );
    554554
    555 assert( ((pte2_attr & TSAR_PTE_LOCKED) != 0),
     555assert( __FUNCTION__, ((pte2_attr & TSAR_PTE_LOCKED) != 0),
    556556"PTE2 for vpn %x in cluster %x is unlocked / pte2_attr = %x\n", vpn, gpt_cxy, pte2_attr );
    557557
     
    630630
    631631// check PT1 entry not mapped
    632 assert( (pte1 == 0) , "try to set a big page in an already mapped PTE1\n" );
     632assert( __FUNCTION__, (pte1 == 0) , "try to set a big page in an already mapped PTE1\n" );
    633633
    634634// check VPN aligned
    635 assert( (ix2 == 0) , "illegal vpn for a big page\n" );
     635assert( __FUNCTION__, (ix2 == 0) , "illegal vpn for a big page\n" );
    636636
    637637// check PPN aligned
    638 assert( ((ppn & 0x1FF) == 0) , "illegal ppn for a big page\n" );
     638assert( __FUNCTION__, ((ppn & 0x1FF) == 0) , "illegal ppn for a big page\n" );
    639639
    640640        // set the PTE1 value in PT1
     
    654654
    655655// PTE1 must be mapped because PTE2 must be locked
    656 assert( (pte1 & TSAR_PTE_MAPPED),
     656assert( __FUNCTION__, (pte1 & TSAR_PTE_MAPPED),
    657657"PTE1 for vpn %x in cluster %x must be mapped / pte1 = %x\n", vpn, gpt_cxy, pte1 );
    658658
     
    669669
    670670// PTE2 must be locked
    671 assert( (pte2_attr & TSAR_PTE_LOCKED),
     671assert( __FUNCTION__, (pte2_attr & TSAR_PTE_LOCKED),
    672672"PTE2 for vpn %x in cluster %x must be locked / pte2_attr = %x\n", vpn, gpt_cxy, pte2_attr );
    673673 
     
    894894
    895895    // check src_pt1 and dst_pt1 existence
    896     assert( (src_pt1 != NULL) , "src_pt1 does not exist\n");
    897     assert( (dst_pt1 != NULL) , "dst_pt1 does not exist\n");
     896    assert( __FUNCTION__, (src_pt1 != NULL) , "src_pt1 does not exist\n");
     897    assert( __FUNCTION__, (dst_pt1 != NULL) , "dst_pt1 does not exist\n");
    898898
    899899    // compute SRC indexes
     
    11431143
    11441144// check MAPPED, SMALL, and not LOCKED in attr argument
    1145 assert( ((attr & GPT_MAPPED) != 0), "attribute MAPPED must be set in new attributes\n" );
    1146 assert( ((attr & GPT_SMALL ) != 0), "attribute SMALL  must be set in new attributes\n" );
    1147 assert( ((attr & GPT_LOCKED) == 0), "attribute LOCKED must not be set in new attributes\n" );
     1145assert( __FUNCTION__, ((attr & GPT_MAPPED) != 0), "attribute MAPPED must be set in new attributes\n" );
     1146assert( __FUNCTION__, ((attr & GPT_SMALL ) != 0), "attribute SMALL  must be set in new attributes\n" );
     1147assert( __FUNCTION__, ((attr & GPT_LOCKED) == 0), "attribute LOCKED must not be set in new attributes\n" );
    11481148
    11491149    // get cluster and local pointer on remote GPT
     
    11621162
    11631163// check MAPPED and SMALL in target PTE1
    1164 assert( ((pte1 & TSAR_PTE_MAPPED) != 0), "attribute MAPPED must be set in target PTE1\n" );
    1165 assert( ((pte1 & TSAR_PTE_SMALL ) != 0), "attribute SMALL  must be set in target PTE1\n" );
     1164assert( __FUNCTION__, ((pte1 & TSAR_PTE_MAPPED) != 0), "attribute MAPPED must be set in target PTE1\n" );
     1165assert( __FUNCTION__, ((pte1 & TSAR_PTE_SMALL ) != 0), "attribute SMALL  must be set in target PTE1\n" );
    11661166
    11671167    // get PT2 base
     
    11751175   
    11761176// check MAPPED in target PTE2
    1177 assert( ((hal_remote_l32(pte2_attr_xp) & TSAR_PTE_MAPPED) != 0),
     1177assert( __FUNCTION__, ((hal_remote_l32(pte2_attr_xp) & TSAR_PTE_MAPPED) != 0),
    11781178"attribute MAPPED must be set in target PTE2\n" );
    11791179
  • trunk/hal/tsar_mips32/core/hal_switch.S

    r625 r679  
    22 * hal_witch.S - CPU context switch function for TSAR-MIPS32
    33 *
    4  * Author  Alain Greiner    (2016,2017,2018,2019)
     4 * Author  Alain Greiner    (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c)  UPMC Sorbonne Universites
  • trunk/hal/tsar_mips32/core/hal_uspace.c

    r658 r679  
    4949    uint32_t cxy = (uint32_t)GET_CXY( k_dst_xp );
    5050 
    51 assert( (CURRENT_THREAD->process->pid > 0), "must be called by an user thread" );
     51assert( __FUNCTION__, (CURRENT_THREAD->process->pid > 0), "must be called by an user thread" );
    5252
    5353#if DEBUG_HAL_USPACE
     
    147147    uint32_t cxy = (uint32_t)GET_CXY( k_src_xp );
    148148
    149 assert( (CURRENT_THREAD->process->pid > 0), "must be called by an user thread" );
     149assert( __FUNCTION__, (CURRENT_THREAD->process->pid > 0), "must be called by an user thread" );
    150150
    151151#if DEBUG_HAL_USPACE
     
    236236    uint32_t cxy = (uint32_t)GET_CXY( k_dst_xp );
    237237
    238 assert( (CURRENT_THREAD->process->pid > 0), "must be called by an user thread" );
     238assert( __FUNCTION__, (CURRENT_THREAD->process->pid > 0), "must be called by an user thread" );
    239239
    240240    hal_disable_irq( &save_sr );
     
    291291    uint32_t cxy = (uint32_t)GET_CXY( k_src_xp );
    292292
    293 assert( (CURRENT_THREAD->process->pid > 0), "must be called by an user thread" );
     293assert( __FUNCTION__, (CURRENT_THREAD->process->pid > 0), "must be called by an user thread" );
    294294
    295295    hal_disable_irq( &save_sr );
     
    343343    uint32_t str   = (uint32_t)u_str;
    344344
    345 assert( (CURRENT_THREAD->process->pid > 0), "must be called by an user thread" );
     345assert( __FUNCTION__, (CURRENT_THREAD->process->pid > 0), "must be called by an user thread" );
    346346
    347347    hal_disable_irq( &save_sr );
  • trunk/hal/tsar_mips32/core/hal_vmm.c

    r656 r679  
    22 * hal_vmm.c - Virtual Memory Manager Initialisation for TSAR
    33 *
    4  * Authors  Alain Greiner (2016,2017,2018,2019)
     4 * Authors  Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    167167
    168168// check vsegs_nr
    169 assert( (process_zero.vmm.vsegs_nr == 1 ) ,
     169assert( __FUNCTION__, (process_zero.vmm.vsegs_nr == 1 ) ,
    170170"bad vsegs number in kernel VSL = %d\n", process_zero.vmm.vsegs_nr );
    171171
     
    227227    uint32_t * pt1 = hal_remote_lpt( XPTR( process_cxy , &vmm->gpt.ptr ) );
    228228
    229     nolock_printk("\n***** VSL and GPT / process %x / cluster %x / PT1 %x / cycle %d\n",
    230     pid , process_cxy , pt1 , (uint32_t)hal_get_cycles() );
     229    nolock_printk("\n***** VSL and GPT / pid %x / cxy %x / PT1 %x / entry %x / cycle %d\n",
     230    pid , process_cxy , pt1 , vmm->entry_point , (uint32_t)hal_get_cycles() );
    231231
    232232    if( xlist_is_empty( vsl_root_xp ) )
Note: See TracChangeset for help on using the changeset viewer.