Ignore:
Timestamp:
Jan 13, 2021, 12:47:53 AM (3 years ago)
Author:
alain
Message:

cosmetic

File:
1 edited

Legend:

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

    r679 r686  
    22 * hal_context.c - implementation of Thread Context API for TSAR-MIPS32
    33 *
    4  * Author  Alain Greiner    (2016,2017,2018,2019)
     4 * Author  Alain Greiner    (2016,2017,2018,2019,2019)
    55 *
    66 * Copyright (c)  UPMC Sorbonne Universites
     
    121121{
    122122
    123 assert( __FUNCTION__, (sizeof(hal_cpu_context_t) <= CONFIG_CPU_CTX_SIZE), "illegal CPU context size" );
     123assert( __FUNCTION__, (sizeof(hal_cpu_context_t) <= CONFIG_CPU_CTX_SIZE),
     124"illegal CPU context size" );
    124125
    125126    // allocate memory for cpu_context
    126     kmem_req_t  req;
    127     req.type   = KMEM_KCM;
    128     req.order  = bits_log2( sizeof(hal_cpu_context_t) );
    129     req.flags  = AF_KERNEL | AF_ZERO;
    130 
    131     hal_cpu_context_t * context = kmem_alloc( &req );
    132 
     127    hal_cpu_context_t * context = kmem_alloc( bits_log2( sizeof(hal_cpu_context_t) ),
     128                                              AF_KERNEL | AF_ZERO);
    133129    if( context == NULL ) return -1;
    134130
     
    152148    hal_cpu_context_t * context = (hal_cpu_context_t *)thread->cpu_context;
    153149
    154 assert( __FUNCTION__, (context != NULL ), "CPU context not allocated" );
     150assert( __FUNCTION__, (context != NULL ),
     151"CPU context not allocated" );
    155152
    156153    // compute the PPN for the GPT PT1
     
    405402void hal_cpu_context_destroy( thread_t * thread )
    406403{
    407     kmem_req_t          req;
    408 
     404    // get pointer on CPU context
    409405    hal_cpu_context_t * ctx = thread->cpu_context;
    410406
    411407    // release CPU context if required
    412     if( ctx != NULL )
    413     {   
    414         req.type = KMEM_KCM;
    415         req.ptr  = ctx;
    416         kmem_free( &req );
    417     }
     408    if( ctx != NULL )  kmem_free( ctx , bits_log2( sizeof(hal_cpu_context_t)) );
    418409
    419410}  // end hal_cpu_context_destroy()
     
    434425
    435426    // allocate memory for fpu_context
    436     kmem_req_t  req;
    437     req.type   = KMEM_KCM;
    438     req.flags  = AF_KERNEL | AF_ZERO;
    439     req.order  = bits_log2( sizeof(hal_fpu_context_t) );
    440 
    441     hal_fpu_context_t * context = kmem_alloc( &req );
     427    hal_fpu_context_t * context = kmem_alloc( bits_log2( sizeof(hal_fpu_context_t) ),
     428                                              AF_KERNEL | AF_ZERO );
    442429
    443430    if( context == NULL ) return -1;
     
    454441    hal_fpu_context_t * context = thread->fpu_context;
    455442
    456     assert( __FUNCTION__, (context != NULL) , "fpu context not allocated" );
     443assert( __FUNCTION__, (context != NULL) ,
     444"fpu context not allocated" );
    457445
    458446    memset( context , 0 , sizeof(hal_fpu_context_t) );
     
    478466void hal_fpu_context_destroy( thread_t * thread )
    479467{
    480     kmem_req_t  req;
    481 
    482     hal_fpu_context_t * context = thread->fpu_context;
     468    // get pointer on FPU context
     469    hal_fpu_context_t * ctx = thread->fpu_context;
    483470
    484471    // release FPU context if required
    485     if( context != NULL )
    486     {   
    487         req.type = KMEM_KCM;
    488         req.ptr  = context;
    489         kmem_free( &req );
    490     }
     472    if( ctx != NULL ) kmem_free( ctx , bits_log2( sizeof(hal_fpu_context_t)) );
    491473
    492474}  // end hal_fpu_context_destroy()
Note: See TracChangeset for help on using the changeset viewer.