Changeset 437 for trunk/hal


Ignore:
Timestamp:
Mar 28, 2018, 2:40:29 PM (6 years ago)
Author:
alain
Message:

Fix various bugs

Location:
trunk/hal/tsar_mips32
Files:
5 edited

Legend:

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

    r435 r437  
    154154
    155155//////////////////////////////////////////////////////////////////////////////////////////
    156 // This function is called when an MMU exception has been detected.
     156// This function is called when an MMU exception has been detected (IBE / DBE).
    157157// It get the relevant exception arguments from the MMU.
    158158// It signal a fatal error in case of illegal access. In case of page unmapped
     
    167167//////////////////////////////////////////////////////////////////////////////////////////
    168168error_t hal_mmu_exception( thread_t * this,
     169                           uint32_t   excPC,
    169170                           bool_t     is_ins )
    170171{
     
    294295        default:                             // this is a kernel error => panic   
    295296        {
    296             assert( false , __FUNCTION__ , "thread %x / excp_code = %x / vaddr = %x\n",
    297             this->trdid , excp_code , bad_vaddr );
     297            assert( false , __FUNCTION__ , "thread %x / epc %x / %s / vaddr = %x\n",
     298            this, excPC, hal_mmu_exception_str(excp_code) , bad_vaddr );
    298299
    299300            return EXCP_KERNEL_PANIC;
     
    379380        error_t      error;
    380381        uint32_t     excCode;                  // 4 bits XCODE from CP0_CR
     382        uint32_t     excPC;                    // fauty instruction address
    381383
    382384    // get pointer on faulty thread uzone
     
    384386    uzone = (uint32_t *)CURRENT_THREAD->uzone_current;
    385387
    386     // get 4 bits XCODE from CP0_CR register
     388    // get XCODE and EPC from UZONE
    387389        excCode        = (uzone[UZ_CR] >> 2) & 0xF;
     390    excPC          = uzone[UZ_EPC];
    388391
    389392#if CONFIG_DEBUG_HAL_EXCEPTIONS
    390393uint32_t cycle = (uint32_t)hal_get_cycles();
    391394if( CONFIG_DEBUG_HAL_EXCEPTIONS < cycle )
    392 printk("\n[DBG] %s : thread %x on core[%x,%d] enter / process %x / xcode %x / cycle %d\n",
    393 __FUNCTION__, this, local_cxy, this->core->lid, this->process->pid, excCode, cycle );
     395printk("\n[DBG] %s : thread %x enter / core[%x,%d] / pid %x / epc %x / xcode %x / cycle %d\n",
     396__FUNCTION__, this, local_cxy, this->core->lid, this->process->pid, excPC, excCode, cycle );
    394397#endif
    395398
     
    398401        case XCODE_DBE:     // can be non fatal
    399402        {
    400                     error = hal_mmu_exception( this , false );  // data MMU exception
     403                    error = hal_mmu_exception( this , excPC , false );  // data MMU exception
    401404            break;
    402405        }
    403406            case XCODE_IBE:     // can be non fatal
    404407        {
    405                     error = hal_mmu_exception( this , true );   // ins MMU exception
     408                    error = hal_mmu_exception( this , excPC , true );   // ins MMU exception
    406409                    break;
    407410        }
     
    450453cycle = (uint32_t)hal_get_cycles();
    451454if( CONFIG_DEBUG_HAL_EXCEPTIONS < cycle )
    452 printk("\n[DBG] %s : thread %x on core[%x,%d] exit / process %x / xcode %x / cycle %d\n",
    453 __FUNCTION__, this, local_cxy, this->core->lid, this->process->pid, excCode, cycle );
     455printk("\n[DBG] %s : thread %x exit / core[%x,%d] / pid %x / epc %x / xcode %x / cycle %d\n",
     456__FUNCTION__, this, local_cxy, this->core->lid, this->process->pid, excPC, excCode, cycle );
    454457#endif
    455458
  • trunk/hal/tsar_mips32/drivers/soclib_bdv.c

    r436 r437  
    22 * soclib_bdv.c - soclib simple block device driver implementation.
    33 *
    4  * Author     Alain Greiner (2016)
     4 * Author     Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    7474    buf_xp   = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->ioc_cmd.buf_xp ) );
    7575    ioc_xp   = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->ioc_cmd.dev_xp ) );
     76
     77#if CONFIG_DEBUG_HAL_IOC_RX
     78uint32_t cycle = (uint32_t)hal_get_cycles();
     79if( (CONFIG_DEBUG_HAL_IOC_RX < cycle) && (cmd_type != IOC_WRITE ) )
     80printk("\n[DBG] %s : thread %x enter for RX / cycle %d\n",
     81__FUNCTION__ , CURRENT_THREAD , cycle );
     82#endif
     83
     84#if CONFIG_DEBUG_HAL_IOC_TX
     85uint32_t cycle = (uint32_t)hal_get_cycles();
     86if( (CONFIG_DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_WRITE) )
     87printk("\n[DBG] %s : thread %x enter for TX / cycle %d\n",
     88__FUNCTION__ , CURRENT_THREAD , cycle );
     89#endif
    7690
    7791    // get IOC device cluster and local pointer
     
    138152    }
    139153   
     154#if CONFIG_DEBUG_HAL_IOC_RX
     155cycle = (uint32_t)hal_get_cycles();
     156if( (CONFIG_DEBUG_HAL_IOC_RX < cycle) && (cmd_type != TXT_WRITE) )
     157printk("\n[DBG] %s : thread %x exit after RX / cycle %d\n",
     158__FUNCTION__ , CURRENT_THREAD , cycle );
     159#endif
     160
     161#if CONFIG_DEBUG_HAL_IOC_TX
     162cycle = (uint32_t)hal_get_cycles();
     163if( (CONFIG_DEBUG_HAL_IOC_TX < cycle) && (cmd_type == TXT_WRITE) )
     164printk("\n[DBG] %s : thread %x exit after TX / cycle %d\n",
     165__FUNCTION__ , CURRENT_THREAD , cycle );
     166#endif
     167
    140168} // end soclib_bdv_cmd()
    141169
     
    144172void __attribute__ ((noinline)) soclib_bdv_isr( chdev_t * chdev )
    145173{
     174    error_t  error = 0;
     175
    146176    // get extended pointer on client thread
    147177    xptr_t root = XPTR( local_cxy , &chdev->wait_root );
     
    155185    thread_t * client_ptr = (thread_t *)GET_PTR( client_xp );
    156186
     187    // get command type
     188    uint32_t   cmd_type = hal_remote_lw( XPTR( client_cxy , &client_ptr->ioc_cmd.type ) );
     189   
    157190    // get SOCLIB_BDV device cluster and local pointer
    158191    cxy_t      bdv_cxy  = GET_CXY( chdev->base );
     
    162195        uint32_t status = hal_remote_lw( XPTR( bdv_cxy , bdv_ptr + BDV_STATUS_REG ) );   
    163196
     197    if( cmd_type == IOC_READ )
     198    {
     199            error = (status != BDV_READ_SUCCESS);
     200
     201#if CONFIG_DEBUG_HAL_IOC_RX
     202uint32_t cycle = (uint32_t)hal_get_cycles();
     203if( CONFIG_DEBUG_HAL_IOC_RX < cycle )
     204printk("\n[DBG] %s : IOC_IRQ / RX transfer / client %x / server %x / cycle %d\n",
     205__FUNCTION__, client_ptr , chdev->server , cycle );
     206#endif
     207
     208    }
     209        else if( cmd_type == IOC_WRITE )
     210    {
     211            error = (status != BDV_WRITE_SUCCESS);
     212
     213#if CONFIG_DEBUG_HAL_IOC_TX
     214uint32_t cycle = (uint32_t)hal_get_cycles();
     215if( CONFIG_DEBUG_HAL_IOC_TX < cycle )
     216printk("\n[DBG] %s : IOC_IRQ / RX transfer / client %x / server %x / cycle %d\n",
     217__FUNCTION__, client_ptr , chdev->server , cycle );
     218#endif
     219
     220    }
     221    else
     222    {
     223        assert( false , __FUNCTION__ , "IOC_SYNC_READ should not use IRQ" );
     224    }
     225
    164226    // set operation status in command
    165         if((status != BDV_READ_SUCCESS) && (status != BDV_WRITE_SUCCESS))
    166     {
    167         hal_remote_sw( XPTR( client_cxy , &client_ptr->ioc_cmd.error ) , 1 );
    168     }
    169         else
    170     {
    171         hal_remote_sw( XPTR( client_cxy , &client_ptr->ioc_cmd.error ) , 0 );
    172     }
     227    hal_remote_sw( XPTR( client_cxy , &client_ptr->ioc_cmd.error ) , error );
    173228
    174229    // unblock server thread
    175230    thread_unblock( server_xp , THREAD_BLOCKED_ISR );
    176231
    177     // unblock client thread
    178     thread_unblock( client_xp , THREAD_BLOCKED_IO );
    179 
    180232} // end soclib_bdv_isr()
    181233
  • trunk/hal/tsar_mips32/drivers/soclib_bdv.h

    r75 r437  
    22 * soclib_bdv.h - SOCLIB_BDV (simple block device) driver definition.
    33 *
    4  * Author    Alain Greiner
     4 * Author    Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
  • trunk/hal/tsar_mips32/drivers/soclib_hba.c

    r436 r437  
    22 * soclib_hba.c - soclib AHCI block device driver implementation.
    33 *
    4  * Author     Alain Greiner (2016)
     4 * Author     Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    290290            // unblock client thread
    291291            thread_unblock( client_xp , THREAD_BLOCKED_IO );
    292  
    293             ioc_dmsg("INFO in %s : thread %x at cycle %d\n",
    294             __FUNCTION__ , hal_remote_lw( XPTR( client_cxy , &client_ptr->trdid ) ) ,
    295             hal_get_cycles() );
    296292        }
    297293    }
  • trunk/hal/tsar_mips32/drivers/soclib_hba.h

    r75 r437  
    22 * soclib_hba.h - soclib AHCI block device driver definition.
    33 *
    4  * Author        Alain Greiner (2016)
     4 * Author        Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
Note: See TracChangeset for help on using the changeset viewer.