Changeset 311


Ignore:
Timestamp:
Aug 2, 2017, 2:17:00 PM (4 years ago)
Author:
max@…
Message:

Introduce hal_cpu_context_switch.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/generic/hal_context.h

    r296 r311  
    6969
    7070/****************************************************************************************
    71  * This function saves in the thread context the CPU registers values that must be
    72  * saved at context switch.
     71 * This function performs a context switch, saving the CPU register values into the
     72 * old thread, and initializing these registers with the values of the new thread.
    7373 ****************************************************************************************
    74  * @ ctx     : pointer on cpu context.
     74 * @ old     : pointer on current thread.
     75 * @ new     : pointer on the thread we want to switch to.
    7576 ***************************************************************************************/
    76 void hal_cpu_context_save( void * ctx );
    77 
    78 /****************************************************************************************
    79  * This function restores from the thread context the CPU registers values that must
    80  * be restored at context switch.
    81  ****************************************************************************************
    82  * @ ctx     : pointer on cpu context.
    83  ***************************************************************************************/
    84 void hal_cpu_context_restore( void * ctx );
     77void hal_cpu_context_switch( struct thread_s * old , struct thread_s * new );
    8578
    8679/****************************************************************************************
     
    9285 ***************************************************************************************/
    9386void hal_cpu_context_load( struct thread_s * thread );
    94 
    9587
    9688/****************************************************************************************
  • trunk/hal/tsar_mips32/core/hal_context.c

    r296 r311  
    335335    ".set at                       \n"
    336336    : : : "$26" , "$27" );
     337}
     338
     339void hal_cpu_context_switch( thread_t * old , thread_t * new )
     340{
     341    // XXX XXX: TODO
     342    hal_cpu_context_save( old->cpu_context );
     343    hal_cpu_context_restore( new->cpu_context );
    337344}
    338345
  • trunk/hal/x86_64/core/hal_context.c

    r298 r311  
    103103}
    104104
    105 void hal_cpu_context_save( void * ctx )
    106 {
    107         x86_panic((char *)__func__);
    108 }
    109 
    110 void hal_cpu_context_restore( void * ctx )
     105void hal_cpu_context_switch( thread_t * old , thread_t * new )
    111106{
    112107        x86_panic((char *)__func__);
  • trunk/kernel/kern/scheduler.c

    r306 r311  
    321321
    322322        // switch contexts
    323         hal_cpu_context_save( current->cpu_context );
    324         hal_cpu_context_restore( next->cpu_context );
     323        hal_cpu_context_switch( current , next );
    325324
    326325        // restore IRQs when calling thread resume
Note: See TracChangeset for help on using the changeset viewer.