Ignore:
Timestamp:
Aug 2, 2018, 11:47:13 AM (6 years ago)
Author:
alain
Message:

This version modifies the exec syscall and fixes a large number of small bugs.
The version number has been updated (0.1)

File:
1 edited

Legend:

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

    r432 r457  
    2222 */
    2323
    24 #include <hal_types.h>
     24#include <hal_kernel_types.h>
    2525#include <hal_switch.h>
    2626#include <memcpy.h>
     
    136136}   // end hal_cpu_context_alloc()
    137137
    138 ///////////////////////////////////////////////////
    139 // The following context slots are initialised :
     138/////////////////////////////////////////////////
     139// The following context slots are initialised
    140140// GPR : a0_04 / sp_29 / ra_31
    141141// CP0 : c0_sr / c0_th / c0_epc
    142142// CP2 : c2_ptpr / c2_mode
    143 ///////////////////////////////////////////////////
    144 error_t hal_cpu_context_create( thread_t * thread )
    145 {
    146     // allocate memory for a CPU context
    147     error_t error = hal_cpu_context_alloc( thread );
    148 
    149     if( error ) return error;
    150 
     143/////////////////////////////////////////////////
     144void hal_cpu_context_init( thread_t * thread )
     145{
    151146    hal_cpu_context_t * context = (hal_cpu_context_t *)thread->cpu_context;
     147
     148    assert( (context != NULL ), __FUNCTION__, "CPU context not allocated" );
    152149
    153150    // initialisation depends on thread type
     
    173170        context->c2_mode = 0x3;
    174171    }
    175 
    176     return 0;
    177 
    178 }  // end hal_cpu_context_create()
     172}  // end hal_cpu_context_init()
    179173
    180174////////////////////////////////////////////
     
    243237        assert( (current == child_ptr) , __FUNCTION__ , "current = %x / child = %x\n");
    244238    }
    245 
    246239}  // end hal_cpu_context_fork()
     240
     241//////////////////////////////////////////////
     242void hal_cpu_context_exec( thread_t * thread )
     243{
     244    // re_initialize CPU context
     245    hal_cpu_context_init( thread );
     246
     247    // restore CPU registers ... and jump
     248    hal_do_cpu_restore( (hal_cpu_context_t *)thread->cpu_context );
     249
     250} // end hal_cpu_context_exec()
    247251
    248252/////////////////////////////////////////////////
     
    312316
    313317}   // end hal_fpu_context_alloc()
     318
     319//////////////////////////////////////////////
     320void hal_fpu_context_init( thread_t * thread )
     321{
     322    hal_fpu_context_t * context = thread->fpu_context;
     323
     324    assert( (context != NULL) , __FUNCTION__ , "fpu context not allocated" );
     325
     326    memset( context , 0 , sizeof(hal_fpu_context_t) );
     327}
    314328
    315329//////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.