Ignore:
Timestamp:
May 3, 2018, 5:51:22 PM (4 years ago)
Author:
alain
Message:

1/ Fix a bug in the Multithreaded "sort" applicationr:
The pthread_create() arguments must be declared as global variables.
2/ The exit syscall can be called by any thread of a process..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/drivers/soclib_mmc.c

    r279 r440  
    5252    xptr_t     dev_xp;       // extended pointer on MMC device
    5353    uint32_t   type;         // MMC command : type
    54     uint64_t   buf_paddr;    // MMC command : buffer physical address
     54    void     * buf_ptr;      // MMC command : buffer pointer
    5555    uint32_t   buf_size;     // MMC command : buffer size
    5656    uint32_t   reg_index;    // MMC command : register index in MMC peripheral
     
    5959    // get client thread cluster and local pointer
    6060    cxy_t      th_cxy = GET_CXY( th_xp );
    61     thread_t * th_ptr = (thread_t *)GET_PTR( th_xp );
     61    thread_t * th_ptr = GET_PTR( th_xp );
    6262
    6363    // get command type and extended pointer on MMC device
     
    6767    // get MMC device cluster and local pointer
    6868    cxy_t     dev_cxy = GET_CXY( dev_xp );
    69     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     69    chdev_t * dev_ptr = GET_PTR( dev_xp );
    7070
    71     // get extended pointer on SOCLIB-MMC peripheral
    72     xptr_t     mmc_xp = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->base ) );
    73 
    74     // get SOCLIB_MMC peripheral cluster and local pointer
    75     cxy_t      mmc_cxy = GET_CXY( mmc_xp );
    76     uint32_t * mmc_ptr = (uint32_t *)GET_PTR( mmc_xp );
     71    // get cluster and pointers for SOCLIB_MMC peripheral segment base
     72    xptr_t     seg_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
     73    cxy_t      seg_cxy = GET_CXY( seg_xp );
     74    uint32_t * seg_ptr = GET_PTR( seg_xp );
    7775
    7876    if( (type == MMC_CC_INVAL) || (type == MMC_CC_SYNC) )
    7977    {
    80         // get buffer paddr
    81         buf_paddr = hal_remote_lwd( XPTR( th_cxy , &th_ptr->mmc_cmd.buf_paddr ) );
     78        // get buffer pointer and size
     79        buf_ptr  = hal_remote_lpt( XPTR( th_cxy , &th_ptr->mmc_cmd.buf_ptr ) );
     80        buf_size = hal_remote_lw ( XPTR( th_cxy , &th_ptr->mmc_cmd.buf_size ) );
    8281
    83         // split buffer paddr in two 32 bits words
    84         uint32_t   buf_lo = (uint32_t)( buf_paddr );
    85         uint32_t   buf_hi = (uint32_t)( buf_paddr>>32 );
    86 
    87         // get buffer size
    88         buf_size   = hal_remote_lw( XPTR( th_cxy , &th_ptr->mmc_cmd.buf_size ) );
    89 
    90         // get command type
    91         uint32_t cc_cmd;
     82        // set command type
     83        uint32_t   cc_cmd;
    9284        if( type == MMC_CC_INVAL )  cc_cmd = SOCLIB_MMC_CC_INVAL;
    9385        else                        cc_cmd = SOCLIB_MMC_CC_SYNC;
    9486
    9587        // set SOCLIB_MMC registers to start INVAL/SYNC operation
    96         hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_ADDR_LO    ) , buf_lo );
    97         hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_ADDR_HI    ) , buf_hi );
    98         hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_BUF_LENGTH ) , buf_size );
    99         hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_CMD_TYPE   ) , cc_cmd );
     88        hal_remote_sw( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_ADDR_LO    ) , (uint32_t)buf_ptr );
     89        hal_remote_sw( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_ADDR_HI    ) , (uint32_t)dev_cxy );
     90        hal_remote_sw( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_BUF_LENGTH ) , buf_size );
     91        hal_remote_sw( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_CMD_TYPE   ) , cc_cmd );
    10092    }
    10193    else  // (type == MMC_GET_ERROR) or (type == MMC_GET_ERROR) pr (type == MMC_GET_INSTRU )
     
    108100        if( (type == MMC_GET_ERROR) || (type == MMC_GET_INSTRU) )
    109101        {
    110             *reg_ptr =  hal_remote_lw( XPTR( mmc_cxy , mmc_ptr + reg_index ) );
     102            *reg_ptr =  hal_remote_lw( XPTR( seg_cxy , seg_ptr + reg_index ) );
    111103        }
    112104        else  // type == MMC_SET_ERROR
    113105        {
    114             hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + reg_index ) , *reg_ptr );
     106            hal_remote_sw( XPTR( seg_cxy , seg_ptr + reg_index ) , *reg_ptr );
    115107        }
    116108    }
Note: See TracChangeset for help on using the changeset viewer.