Changeset 610 for trunk/hal/tsar_mips32


Ignore:
Timestamp:
Dec 27, 2018, 7:38:58 PM (5 years ago)
Author:
alain
Message:

Fix several bugs in VFS to support the following
ksh commandis : cp, mv, rm, mkdir, cd, pwd

Location:
trunk/hal/tsar_mips32
Files:
5 edited

Legend:

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

    r587 r610  
    158158// This function is called when an MMU exception has been detected (IBE / DBE).
    159159// It get the relevant exception arguments from the MMU.
    160 // It signal a fatal error in case of illegal access. In case of page unmapped
    161 // it checks that the faulty address belongs to a registered vseg. It update the local
     160// It signal a fatal error in case of illegal access. In case of page unmapped,
     161// it get the client process to access the relevant VMM: for a RPC thread, the client
     162// process is NOT the calling thread process.
     163// Then, it checks that the faulty address belongs to a registered vseg, update the local
    162164// vseg list from the reference cluster if required, and signal a fatal user error
    163165// in case of illegal virtual address. Finally, it updates the local page table from the
     
    183185    uint32_t         bad_vaddr;
    184186    uint32_t         excp_code;
    185        
     187
     188    // check thread type
     189    if( CURRENT_THREAD->type != THREAD_USER )
     190    {
     191        printk("\n[KERNEL PANIC] in %s : illegal thread type %s\n",
     192        __FUNCTION__, thread_type_str(CURRENT_THREAD->type) );
     193
     194        return EXCP_KERNEL_PANIC;
     195    }
     196
     197    // get faulty thread process 
    186198    process = this->process;
    187199
     
    207219uint32_t cycle = (uint32_t)hal_get_cycles();
    208220if( DEBUG_HAL_EXCEPTIONS < cycle )
    209 printk("\n[DBG] %s : thread[%x,%x] enter / is_ins %d / %s / vaddr %x / cycle %d\n",
    210 __FUNCTION__, process->pid, this->trdid,
     221printk("\n[%s] thread[%x,%x] on core [%x,%x] enter / is_ins %d / %s / vaddr %x / cycle %d\n",
     222__FUNCTION__, process->pid, this->trdid, local_cxy, this->core->lid,
    211223is_ins, hal_mmu_exception_str(excp_code), bad_vaddr, cycle);
    212224#endif
     
    215227    switch( excp_code )
    216228    {
    217         case MMU_WRITE_PT1_UNMAPPED:      // non fatal
    218         case MMU_WRITE_PT2_UNMAPPED:
    219         case MMU_READ_PT1_UNMAPPED:
    220         case MMU_READ_PT2_UNMAPPED:
     229        case MMU_WRITE_PT1_UNMAPPED:      // can be non fatal
     230        case MMU_WRITE_PT2_UNMAPPED:      // can be non fatal
     231        case MMU_READ_PT1_UNMAPPED:       // can be non fatal
     232        case MMU_READ_PT2_UNMAPPED:       // can be non fatal
    221233        {
    222234            // try to map the unmapped PTE
     
    230242cycle = (uint32_t)hal_get_cycles();
    231243if( DEBUG_HAL_EXCEPTIONS < cycle )
    232 printk("\n[DBG] %s : thread[%x,%x] exit / page-fault handled for vaddr = %x\n",
    233 __FUNCTION__, process->pid, this->trdid, bad_vaddr );
     244printk("\n[%s] thread[%x,%x] on core [%x,%x] exit / page-fault handled for vaddr = %x\n",
     245__FUNCTION__, process->pid, this->trdid, local_cxy, this->core->lid, bad_vaddr );
    234246#endif
    235247 
     
    238250            else if( error == EXCP_USER_ERROR )      // illegal vaddr
    239251            {
    240                 printk("\n[USER ERROR] in %s for thread %x in process %x\n"
    241                 "   illegal vaddr = %x / is_ins %d / epc %x\n",
    242                 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
     252                printk("\n[USER ERROR] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n"
     253                "  %s : epc %x / badvaddr %x / is_ins %d\n",
     254                __FUNCTION__, this->process->pid, this->trdid, local_cxy,
     255                this->core->lid, (uint32_t)hal_get_cycles(),
     256                hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins );
    243257
    244258                        return EXCP_USER_ERROR;
     
    246260            else  // error == EXCP_KERNEL_PANIC 
    247261            {
    248                 printk("\n[KERNEL ERROR] in %s for thread %x in process %x\n"
    249                 "   no memory to map vaddr = %x / is_ins %d / epc %x\n",
    250                 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
     262                printk("\n[KERNEL PANIC] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n"
     263                "  %s : epc %x / badvaddr %x / is_ins %d\n",
     264                __FUNCTION__, this->process->pid, this->trdid, local_cxy,
     265                this->core->lid, (uint32_t)hal_get_cycles(),
     266                hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins );
    251267
    252268                        return EXCP_KERNEL_PANIC;
    253269            }
    254270        }
    255         case MMU_WRITE_PRIVILEGE_VIOLATION:  // illegal access user error
    256         case MMU_READ_PRIVILEGE_VIOLATION:
    257         {
    258             printk("\n[USER ERROR] in %s : thread %x in process %x\n"
    259             "   illegal user access to vaddr = %x / is_ins %d / epc %x\n",
    260             __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
     271        case MMU_WRITE_PRIVILEGE_VIOLATION:  // illegal user error
     272        case MMU_READ_PRIVILEGE_VIOLATION:   // illegal
     273        {
     274            printk("\n[USER ERROR] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n"
     275            "  %s : epc %x / badvaddr %x / is_ins %d\n",
     276            __FUNCTION__, this->process->pid, this->trdid, local_cxy,
     277            this->core->lid, (uint32_t)hal_get_cycles(),
     278            hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins );
    261279
    262280            return EXCP_USER_ERROR;
    263281        }
    264         case MMU_WRITE_ACCESS_VIOLATION:     // user error, or Copy-on-Write
    265         {
    266             // access page table to get GPT_COW flag
    267             bool_t cow = hal_gpt_pte_is_cow( &(process->vmm.gpt),
    268                                              bad_vaddr >> CONFIG_PPM_PAGE_SHIFT );
    269 
    270             if( cow )                        // Copy-on-Write
    271             {
    272                 // try to allocate and copy the page
    273                 error = vmm_handle_cow( process,
    274                                         bad_vaddr >> CONFIG_PPM_PAGE_SHIFT );
    275 
    276                 if( error == EXCP_NON_FATAL )        // Copy on write successfull
    277                 {
     282        case MMU_WRITE_ACCESS_VIOLATION:    // can be non fatal if COW
     283        {
     284            // try to handle a possible COW
     285            error = vmm_handle_cow( process,
     286                                    bad_vaddr >> CONFIG_PPM_PAGE_SHIFT );
     287
     288            if( error == EXCP_NON_FATAL )        // COW successfully handled
     289            {
    278290
    279291#if DEBUG_HAL_EXCEPTIONS
    280292cycle = (uint32_t)hal_get_cycles();
    281293if( DEBUG_HAL_EXCEPTIONS < cycle )
    282 printk("\n[DBG] %s : thread[%x,%x] exit / copy-on-write handled for vaddr = %x\n",
     294printk("\n[%s] thread[%x,%x] exit / copy-on-write handled for vaddr = %x\n",
    283295__FUNCTION__, process->pid, this->trdid, bad_vaddr );
    284296#endif
    285 
    286                     return EXCP_NON_FATAL;
    287                 }
    288                 else if( error == EXCP_USER_ERROR )  // illegal user access
    289                 {
    290                     printk("\n[USER ERROR] in %s : thread %x in process %x\n"
    291                     "   cannot cow vaddr = %x / is_ins %d / epc %x\n",
    292                     __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
     297                return EXCP_NON_FATAL;
     298            }
     299            else if( error == EXCP_USER_ERROR )  // illegal write access
     300            {
     301                    printk("\n[USER ERROR] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n"
     302                    "  %s : epc %x / badvaddr %x / is_ins %d\n",
     303                    __FUNCTION__, this->process->pid, this->trdid, local_cxy,
     304                    this->core->lid, (uint32_t)hal_get_cycles(),
     305                    hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins );
    293306
    294307                            return EXCP_USER_ERROR;
    295                 }
    296                 else   // error == EXCP_KERNEL_PANIC
    297                 {
    298                     printk("\n[KERNEL ERROR] in %s : thread %x in process %x\n"
    299                     "   no memoty to cow vaddr = %x / is_ins %d / epc %x\n",
    300                     __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
    301 
    302                             return EXCP_USER_ERROR;
    303                 }
    304308            }
    305             else                             // non writable user error
    306             {
    307                 printk("\n[USER ERROR] in %s : thread %x in process %x\n"
    308                 "   non-writable vaddr = %x / is_ins %d / epc %x\n",
    309                 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
    310 
    311                 return EXCP_USER_ERROR;
     309            else   // error == EXCP_KERNEL_PANIC
     310            {
     311                printk("\n[KERNEL PANIC] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n"
     312                "  %s : epc %x / badvaddr %x / is_ins %d\n",
     313                __FUNCTION__, this->process->pid, this->trdid, local_cxy,
     314                this->core->lid, (uint32_t)hal_get_cycles(),
     315                hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins );
     316
     317                        return EXCP_USER_ERROR;
    312318            }
    313319        }
    314320        case MMU_READ_EXEC_VIOLATION:        // user error
    315321        {
    316             printk("\n[USER_ERROR] in %s : thread %x in process %x\n"
    317             "   non-executable vaddr = %x / is_ins %d / epc %x\n",
    318             __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
     322            printk("\n[USER ERROR] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n"
     323            "  %s : epc %x / badvaddr %x / is_ins %d\n",
     324            __FUNCTION__, this->process->pid, this->trdid, local_cxy,
     325            this->core->lid, (uint32_t)hal_get_cycles(),
     326            hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins );
    319327
    320328            return EXCP_USER_ERROR;
     
    322330        default:                             // this is a kernel error   
    323331        {
    324             printk("\n[KERNEL ERROR] in %s : thread %x in process %x\n"
    325             "  epc %x / badvaddr %x / is_ins %d\n",
    326             __FUNCTION__, this->trdid, this->process->pid, excPC, bad_vaddr, is_ins );
     332            printk("\n[KERNEL PANIC] in %s : thread[%x,%x] on core[%x,%x] / cycle %d\n"
     333            "  %s : epc %x / badvaddr %x / is_ins %d\n",
     334            __FUNCTION__, this->process->pid, this->trdid, local_cxy,
     335            this->core->lid, (uint32_t)hal_get_cycles(),
     336            hal_mmu_exception_str(excp_code), excPC, bad_vaddr, is_ins );
    327337
    328338            return EXCP_KERNEL_PANIC;
     
    359369    if( error == EXCP_USER_ERROR )
    360370    {
    361         nolock_printk("\n=== USER ERROR / trdid %x / pid %x / core[%x,%d] / cycle %d ===\n",
    362         this->trdid, process->pid, local_cxy, core->lid , (uint32_t)hal_get_cycles() );
     371        nolock_printk("\n=== USER ERROR / thread(%x,%x) / core[%d] / cycle %d ===\n",
     372        process->pid, this->trdid, core->lid, (uint32_t)hal_get_cycles() );
    363373    }
    364374    else
    365375    {
    366         nolock_printk("\n=== KERNEL ERROR / trdid %x / pid %x / core[%x,%d] / cycle %d ===\n",
    367         this->trdid, process->pid, local_cxy, core->lid , (uint32_t)hal_get_cycles() );
     376        nolock_printk("\n=== KERNEL PANIC / thread(%x,%x) / core[%d] / cycle %d ===\n",
     377        process->pid, this->trdid, core->lid, (uint32_t)hal_get_cycles() );
    368378    }
    369379
     
    400410}  // end hal_exception_dump()
    401411
    402 ///////////////////////
     412/////////////////////////////
    403413void hal_do_exception( void )
    404414{
     
    420430uint32_t cycle = (uint32_t)hal_get_cycles();
    421431if( DEBUG_HAL_EXCEPTIONS < cycle )
    422 printk("\n[DBG] %s : thread %x in process %x enter / core[%x,%d] / epc %x / xcode %x / cycle %d\n",
    423 __FUNCTION__, this->trdid, this->process->pid, local_cxy, this->core->lid, excPC, excCode, cycle );
     432printk("\n[%s] thread[%x,%x] enter / core[%x,%d] / epc %x / xcode %x / cycle %d\n",
     433__FUNCTION__, this->process->pid, this->trdid,
     434local_cxy, this->core->lid, excPC, excCode, cycle );
    424435#endif
    425436
     
    473484        {
    474485            printk("\n[USER_ERROR] in %s for thread %x in process %x\n"
    475             "   illegal data load address / epc %x\n",
    476             __FUNCTION__, this->trdid, this->process->pid, excPC );
     486            "   illegal data load address / epc %x / bad_address %x\n",
     487            __FUNCTION__, this->trdid, this->process->pid, excPC, hal_get_bad_vaddr() );
    477488
    478489                    error = EXCP_USER_ERROR;
     
    482493        {
    483494            printk("\n[USER_ERROR] in %s for thread %x in process %x\n"
    484             "   illegal data store address / epc %x\n",
    485             __FUNCTION__, this->trdid, this->process->pid, excPC );
     495            "   illegal data store address / epc %x / bad_address %x\n",
     496            __FUNCTION__, this->trdid, this->process->pid, excPC, hal_get_bad_vaddr() );
    486497
    487498                    error = EXCP_USER_ERROR;
     
    505516        hal_exception_dump( this , uzone , error );
    506517
    507         assert( false , "Exception raised kernel panic see information below.\n" );
     518        hal_core_sleep();
    508519    }
    509520
     
    511522cycle = (uint32_t)hal_get_cycles();
    512523if( DEBUG_HAL_EXCEPTIONS < cycle )
    513 printk("\n[DBG] %s : thread %x in process %x exit / core[%x,%d] / epc %x / xcode %x / cycle %d\n",
    514 __FUNCTION__, this->trdid, this->process->pid, local_cxy, this->core->lid, excPC, excCode, cycle );
     524printk("\n[%s] thread[%x,%x] exit / core[%x,%d] / epc %x / xcode %x / cycle %d\n",
     525__FUNCTION__, this->process->pid, this->trdid,
     526local_cxy, this->core->lid, excPC, excCode, cycle );
    515527#endif
    516528
  • trunk/hal/tsar_mips32/core/hal_ppm.c

    r570 r610  
    22 * hal_ppm.c - Generic Physical Page Manager API implementation for TSAR
    33 *
    4  * Authors  Alain Greiner (2016,2017)
     4 * Authors  Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    6363
    6464        // initialize lock protecting the dirty_pages list
    65         queuelock_init( &ppm->dirty_lock , LOCK_PPM_DIRTY );
     65        remote_queuelock_init( XPTR( local_cxy , &ppm->dirty_lock ) , LOCK_PPM_DIRTY );
    6666
    6767        // initialize all free_pages[] lists as empty
  • trunk/hal/tsar_mips32/core/hal_remote.c

    r570 r610  
    381381    uint32_t scxy = (uint32_t)GET_CXY( src );
    382382
     383/*
     384if( local_cxy == 1 )
     385printk("\n@@@ %s : scxy %x / sptr %x / dcxy %x / dptr %x\n",
     386__FUNCTION__, scxy, sptr, dcxy, dptr );
     387*/
    383388    hal_disable_irq( &save_sr );
    384389
  • trunk/hal/tsar_mips32/core/hal_uspace.c

    r457 r610  
    4343    uint32_t dst = (uint32_t)k_dst;
    4444
     45#if DEBUG_HAL_USPACE
     46thread_t * this = CURRENT_THREAD;
     47printk("\n[%s] thread[%x,%x] enter in cluster %x / u_src %x / k_dst %x / size %d\n",
     48__FUNCTION__, this->process->pid, this->trdid, local_cxy, u_src, k_dst, size );
     49#endif
     50
    4551        if( (dst & 0x3) || (src & 0x3) ) wsize = 0;          // do it all in bytes
    4652    else                             wsize = size >> 2;
     
    8086
    8187    hal_restore_irq( save_sr );
     88
     89#if DEBUG_HAL_USPACE
     90printk("\n[%s] thread[%x,%x] exit\n",
     91__FUNCTION__, this->process->pid, this->trdid );
     92#endif
    8293
    8394}  // end hal_copy_from_uspace()
     
    94105    uint32_t dst = (uint32_t)u_dst;
    95106
     107#if DEBUG_HAL_USPACE
     108thread_t * this = CURRENT_THREAD;
     109printk("\n[%s] thread[%x,%x] enter in cluster %x / k_src %x / u_dst %x / size %d\n",
     110__FUNCTION__, this->process->pid, this->trdid, local_cxy, k_src, u_dst, size );
     111#endif
     112
    96113        if( (dst & 0x3) || (src & 0x3) ) wsize = 0;          // not aligned
    97114    else                             wsize = size >> 2;
     
    118135        asm volatile(
    119136        "mfc2   $15,   $1           \n"   /* save   MMU_MODE                */
    120         "lw         $13,   0(%0)        \n"   /* read data from kernel space    */
     137        "lb         $13,   0(%0)        \n"   /* read data from kernel space    */
    121138        "ori    $14,   $0,  0x7     \n" 
    122139        "mtc2   $14,   $1                       \n"   /* MMU_MODE <= DTLB ON            */
     
    130147
    131148    hal_restore_irq( save_sr );
     149
     150#if DEBUG_HAL_USPACE
     151printk("\n[%s] thread[%x,%x] exit\n",
     152__FUNCTION__, this->process->pid, this->trdid );
     153#endif
    132154
    133155}  // end hal_copy_to_uspace()
  • trunk/hal/tsar_mips32/drivers/soclib_bdv.c

    r570 r610  
    3232void soclib_bdv_init( chdev_t * chdev )
    3333{
    34     // get extended pointer on SOCLIB_BDV peripheral base address
     34    // get extended pointer on SOCLIB_BDV peripheral base
    3535        xptr_t  bdv_xp = chdev->base;
    3636
     
    6262    xptr_t     buf_xp;
    6363    xptr_t     ioc_xp;
     64    uint32_t   status;      // I/0 operation status (from BDV)
     65    reg_t      save_sr;     // for critical section
     66    uint32_t   op;          // BDV_OP_READ / BDV_OP_WRITE
    6467
    6568    // get client thread cluster and local pointer
     
    6770    thread_t * th_ptr = GET_PTR( th_xp );
    6871
     72#if (DEBUG_HAL_IOC_RX || DEBUG_HAL_IOC_TX)
     73uint32_t    cycle        = (uint32_t)hal_get_cycles();
     74thread_t  * this         = CURRENT_THREAD;
     75process_t * process      = hal_remote_lpt( XPTR( th_cxy , &th_ptr->process ) );
     76pid_t       client_pid   = hal_remote_l32( XPTR( th_cxy , &process->pid ) );
     77trdid_t     client_trdid = hal_remote_l32( XPTR( th_cxy , &th_ptr->trdid ) );
     78#endif
     79
    6980    // get command arguments and extended pointer on IOC device
    70     cmd_type =         hal_remote_l32 ( XPTR( th_cxy , &th_ptr->ioc_cmd.type   ) );
    71     lba      =         hal_remote_l32 ( XPTR( th_cxy , &th_ptr->ioc_cmd.lba    ) );
    72     count    =         hal_remote_l32 ( XPTR( th_cxy , &th_ptr->ioc_cmd.count  ) );
     81    cmd_type =         hal_remote_l32( XPTR( th_cxy , &th_ptr->ioc_cmd.type   ) );
     82    lba      =         hal_remote_l32( XPTR( th_cxy , &th_ptr->ioc_cmd.lba    ) );
     83    count    =         hal_remote_l32( XPTR( th_cxy , &th_ptr->ioc_cmd.count  ) );
    7384    buf_xp   = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->ioc_cmd.buf_xp ) );
    7485    ioc_xp   = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->ioc_cmd.dev_xp ) );
    7586
    7687#if DEBUG_HAL_IOC_RX
    77 uint32_t cycle = (uint32_t)hal_get_cycles();
    7888if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type != IOC_WRITE ) )
    79 printk("\n[DBG] %s : thread %x enter for RX / cycle %d\n",
    80 __FUNCTION__ , CURRENT_THREAD , cycle );
    81 #endif
    82 
    83 #if DEBUG_HAL_IOC_TX
    84 uint32_t cycle = (uint32_t)hal_get_cycles();
     89printk("\n[%s] thread[%x,%x] enters for client thread[%x,%x] / RX / cycle %d\n",
     90__FUNCTION__ , this->process->pid, this->trdid, client_pid, client_trdid, cycle );
     91#endif
     92
     93#if DEBUG_HAL_IOC_TX
    8594if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_WRITE) )
    86 printk("\n[DBG] %s : thread %x enter for TX / cycle %d\n",
    87 __FUNCTION__ , CURRENT_THREAD , cycle );
     95printk("\n[%s] thread[%x,%x] enters for client thread[%x,%x] / TX / cycle %d\n",
     96__FUNCTION__ , this->process->pid, this->trdid, client_pid, client_trdid, cycle );
    8897#endif
    8998
     
    101110    uint32_t   buf_msb = (uint32_t)(buf_xp>>32);
    102111
    103     // set operation
    104     uint32_t   op;
     112    // select operation
    105113    if( cmd_type == IOC_WRITE ) op = BDV_OP_WRITE;
    106114    else                        op = BDV_OP_READ;
    107115
    108     // set SOCLIB_BDV registers to start one I/O operation
     116    // set SOCLIB_BDV registers to configure the I/O operation
    109117    hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_IRQ_ENABLE_REG ) , 1       );
    110118    hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_BUFFER_REG     ) , buf_lsb );
     
    112120    hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_LBA_REG        ) , lba     );
    113121    hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_COUNT_REG      ) , count   );
    114     hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_OP_REG         ) , op      );
    115122
    116123    // waiting policy  depends on the command type
    117124    // - for IOC_READ / IOC_WRITE commands, this function is called by the server thread
    118     // - for IOC_SYNC_READ command, this function is directly called by the client thread
     125    //   that blocks and deschedules after launching the I/O transfer.
     126    //   The I/O operation status is reported in the command by the ISR.
     127    // - for IOC_SYNC_READ command, this function is called by the client thread
     128    //   that polls the BDV status register until I/O transfer completion.
    119129
    120130    if( cmd_type == IOC_SYNC_READ )                   // status polling policy
    121131    {
    122         uint32_t status;
     132        // launch I/O operation on BDV device
     133        hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_OP_REG ) , op );
     134       
     135        // wait completion
    123136        while (1)
    124137        {
     
    143156    else                                            // descheduling + IRQ policy
    144157    {
     158        // enter critical section to atomically
     159        // lauch I/O operation and deschedule 
     160        hal_disable_irq( &save_sr );
     161
     162        // launch I/O operation on BDV device
     163        hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_OP_REG ) , op );
     164       
     165        // server thread blocks on ISR
    145166        thread_block( XPTR( local_cxy , CURRENT_THREAD ) , THREAD_BLOCKED_ISR );
     167
     168#if DEBUG_HAL_IOC_RX
     169if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type != IOC_WRITE ) )
     170printk("\n[%s] thread[%x,%x] blocks & deschedules after lauching RX transfer\n",
     171__FUNCTION__ , this->process->pid, this->trdid );
     172#endif
     173
     174#if DEBUG_HAL_IOC_TX
     175if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_WRITE) )
     176printk("\n[%s] thread[%x,%x] blocks & deschedules after lauching TX transfer\n",
     177__FUNCTION__ , this->process->pid, this->trdid );
     178#endif
     179        // server thread deschedules
    146180        sched_yield("blocked on ISR");
    147181
    148         // the IO operation status is reported in the command by the ISR
     182        // exit critical section
     183        hal_restore_irq( save_sr );
    149184    }
    150185   
    151186#if DEBUG_HAL_IOC_RX
    152187cycle = (uint32_t)hal_get_cycles();
    153 if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type != TXT_WRITE) )
    154 printk("\n[DBG] %s : thread %x exit after RX / cycle %d\n",
    155 __FUNCTION__ , CURRENT_THREAD , cycle );
     188if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type != IOC_WRITE) )
     189printk("\n[%s] thread[%x,%x] exit after RX for client thread[%x,%x] / cycle %d\n",
     190__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
    156191#endif
    157192
    158193#if DEBUG_HAL_IOC_TX
    159194cycle = (uint32_t)hal_get_cycles();
    160 if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == TXT_WRITE) )
    161 printk("\n[DBG] %s : thread %x exit after TX / cycle %d\n",
    162 __FUNCTION__ , CURRENT_THREAD , cycle );
     195if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_WRITE) )
     196printk("\n[%s] thread[%x,%x] exit after TX for client thread[%x,%x] / cycle %d\n",
     197__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
    163198#endif
    164199
     
    171206    error_t  error = 0;
    172207
     208    // get extended pointer on server thread
     209    xptr_t server_xp = XPTR( local_cxy , chdev->server );
     210
    173211    // get extended pointer on client thread
    174     xptr_t root = XPTR( local_cxy , &chdev->wait_root );
     212    xptr_t root      = XPTR( local_cxy , &chdev->wait_root );
    175213    xptr_t client_xp = XLIST_FIRST( root , thread_t , wait_list );
    176 
    177     // get extended pointer on server thread
    178     xptr_t server_xp = XPTR( local_cxy , &chdev->server );
    179214
    180215    // get client thread cluster and local pointer
    181216    cxy_t      client_cxy = GET_CXY( client_xp );
    182     thread_t * client_ptr = (thread_t *)GET_PTR( client_xp );
     217    thread_t * client_ptr = GET_PTR( client_xp );
    183218
    184219    // get command type
    185220    uint32_t   cmd_type = hal_remote_l32( XPTR( client_cxy , &client_ptr->ioc_cmd.type ) );
    186221   
     222#if (DEBUG_HAL_IOC_RX || DEBUG_HAL_IOC_TX)
     223uint32_t    cycle        = (uint32_t)hal_get_cycles();
     224process_t * process      = hal_remote_lpt( XPTR( client_cxy , &client_ptr->process ) );
     225pid_t       client_pid   = hal_remote_l32( XPTR( client_cxy , &process->pid ) );
     226trdid_t     client_trdid = hal_remote_l32( XPTR( client_cxy , &client_ptr->trdid ) );
     227thread_t  * server       = GET_PTR( server_xp );
     228pid_t       server_pid   = server->process->pid;
     229trdid_t     server_trdid = server->trdid;
     230#endif
     231
    187232    // get SOCLIB_BDV device cluster and local pointer
    188233    cxy_t      bdv_cxy  = GET_CXY( chdev->base );
    189     uint32_t * bdv_ptr  = (uint32_t *)GET_PTR( chdev->base );
     234    uint32_t * bdv_ptr  = GET_PTR( chdev->base );
    190235
    191236    // get BDV status register and acknowledge IRQ
     
    197242
    198243#if DEBUG_HAL_IOC_RX
    199 uint32_t cycle = (uint32_t)hal_get_cycles();
    200244if( DEBUG_HAL_IOC_RX < cycle )
    201 printk("\n[DBG] %s : IOC_IRQ / RX transfer / client %x / server %x / cycle %d\n",
    202 __FUNCTION__, client_ptr , chdev->server , cycle );
     245printk("\n[%s] RX transfer completed for client[%x,%x] / server[%x,%x] / cycle %d\n",
     246__FUNCTION__, client_pid, client_trdid, server_pid, server_trdid, cycle );
    203247#endif
    204248
     
    209253
    210254#if DEBUG_HAL_IOC_TX
    211 uint32_t cycle = (uint32_t)hal_get_cycles();
    212255if( DEBUG_HAL_IOC_TX < cycle )
    213 printk("\n[DBG] %s : IOC_IRQ / RX transfer / client %x / server %x / cycle %d\n",
    214 __FUNCTION__, client_ptr , chdev->server , cycle );
     256printk("\n[%s] TX transfer completed for client[%x,%x] / server[%x,%x] / cycle %d\n",
     257__FUNCTION__, client_pid, client_trdid, server_pid, server_trdid, cycle );
    215258#endif
    216259
Note: See TracChangeset for help on using the changeset viewer.