Ignore:
Timestamp:
Aug 13, 2018, 1:43:20 PM (6 years ago)
Author:
alain
Message:

Introduce the math library, to support the floating point
data used by the multi-thread fft application.
Fix several bugs regarding the FPU context save/restore.
Introduce support for the %f format in printf.

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

Legend:

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

    r457 r459  
    186186    // get remote child thread cluster and local pointer
    187187    cxy_t      child_cxy = GET_CXY( child_xp );
    188     thread_t * child_ptr = (thread_t *)GET_PTR( child_xp );
     188    thread_t * child_ptr = GET_PTR( child_xp );
    189189
    190190    // get remote child cpu_context local pointer
     
    257257    // get thread cluster and local pointer
    258258    cxy_t      cxy = GET_CXY( thread_xp );
    259     thread_t * ptr = (thread_t *)GET_PTR( thread_xp );
     259    thread_t * ptr = GET_PTR( thread_xp );
    260260
    261261    // get context pointer
     
    358358{
    359359    // allocate a local FPU context in kernel stack
    360     hal_fpu_context_t  context;
     360    hal_fpu_context_t  src_context;
    361361
    362362    // get remote child cluster and local pointer
    363363    cxy_t      thread_cxy = GET_CXY( thread_xp );
    364     thread_t * thread_ptr = (thread_t *)GET_PTR( thread_xp );
     364    thread_t * thread_ptr = GET_PTR( thread_xp );
    365365
    366366    asm volatile(
     
    399399    "swc1    $f31,  31*4(%0)  \n"   
    400400    ".set reorder             \n"
    401     : : "r"(&context) );
     401    : : "r"(&src_context) );
     402
     403    // get local pointer on target thread FPU context
     404    void * dst_context = hal_remote_lpt( XPTR( thread_cxy , &thread_ptr->fpu_context ) );
    402405
    403406    // copy local context to remote child context)
    404     hal_remote_memcpy( XPTR( thread_cxy , &thread_ptr->fpu_context ),
    405                        XPTR( local_cxy  , &context ) ,
     407    hal_remote_memcpy( XPTR( thread_cxy , dst_context ),
     408                       XPTR( local_cxy  , &src_context ),
    406409                       sizeof( hal_fpu_context_t ) );
    407410
     
    411414void hal_fpu_context_restore( thread_t * thread )
    412415{
     416    // get pointer on FPU context and cast to uint32_t
    413417    uint32_t ctx = (uint32_t)thread->fpu_context;
    414418
  • trunk/hal/tsar_mips32/core/hal_exception.c

    r457 r459  
    311311        {
    312312            assert( false , __FUNCTION__ ,
    313             "thread %x in process %x / core[%x,%d] / epc %x / vaddr %x / cycle %d\n",
    314             this->trdid, this->process->pid, local_cxy, this->core->lid,
    315             excPC, bad_vaddr, (uint32_t)hal_get_cycles() );
     313            "thread %x in process %x / epc %x / badvaddr %x / cycle %d\n",
     314            this->trdid, this->process->pid, excPC, bad_vaddr, (uint32_t)hal_get_cycles() );
    316315
    317316            return EXCP_KERNEL_PANIC;
     
    428427            case XCODE_CPU:    // can be non fatal
    429428        {
    430             if( ((uzone[UZ_CR] >> 28) & 0x3) == 1 )     // unavailable FPU
    431             {
    432                 error = hal_fpu_exception( this );
     429            if( ((uzone[UZ_CR] >> 28) & 0x3) == 1 ) // FPU
     430            {
     431                error = hal_fpu_exception( this );              // FPU exception
    433432            }
    434433            else
  • trunk/hal/tsar_mips32/core/hal_shared_types.h

    r452 r459  
    11/*
    2  * hal_kernel_types.h - Data types shared by kernel & libraries for TSAR-MIPS32.
     2 * hal_shared_types.h - Data types shared by kernel & libraries for TSAR-MIPS32.
    33 *
    44 * Author  Alain Greiner (2016)
     
    2626
    2727/*******************i***************************************************************
    28  * This file defines - for the TSAR_MIPS32 architecture - the <reg_t> type, used
    29  * by the hal_user_syscall() function, called by several user-level libraries
    30  * to pass syscall arguments to the  kernel, and used by the do_syscall() function,
    31  * called by the kernel syscall handler, to analyse arguments.
    32  * It is also used by various kernel functions such as the hal_*_irq() functions
    33  * to save/restore the SR register value.
     28 * This file defines - for the TSAR_MIPS32 architecture - types that can be used
     29 * by both the kernel and the user applications.
     30 *
     31 * - the <reg_t> type, is used by the hal_user_syscall() function, called by
     32 *   several user-level libraries to pass syscall arguments to the  kernel,
     33 *   and used by the do_syscall() kernel function, to analyse arguments.
     34 *   It is also used by the hal_*_irq() kernel functions to save/restore
     35 *   the SR register value.
    3436 **********************************************************************************/
    3537
     
    4042typedef unsigned long int     reg_t;    // core register
    4143
    42 #endif  /* HAL_TYPES_H_ */
     44#endif
  • trunk/hal/tsar_mips32/core/hal_special.c

    r457 r459  
    113113void hal_fpu_enable()
    114114{
     115    // set CU1 bit (FPU enable) in c0_sr
    115116        asm volatile
    116117        ( ".set noat                         \n"
     
    120121      "mtc0   $27,    $12                \n"
    121122      ".set at                           \n" );
     123
     124    // set CU1 bit in calling thread UZONE
     125    uint32_t * uzone = CURRENT_THREAD->uzone_current;
     126    uzone[34] |= 0x20000000;
    122127}
    123128
     
    125130void hal_fpu_disable()
    126131{
     132    // reset CU1 bit (FPU enable) in c0_sr
    127133        asm volatile
    128134        ( ".set noat                         \n"
     
    133139      "mtc0   $27,    $12                \n"
    134140          ".set at                           \n");
     141
     142    // reset CU1 bit in calling thread UZONE
     143    uint32_t * uzone = CURRENT_THREAD->uzone_current;
     144    uzone[34] &= 0xDFFFFFFF;
    135145}
    136146
Note: See TracChangeset for help on using the changeset viewer.