Ignore:
Timestamp:
Jul 16, 2012, 10:26:27 AM (12 years ago)
Author:
alain
Message:

Fix several bugs to use the vci_block_device with MMU activated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/sys/ctx_handler.c

    r165 r167  
    1515// It contains copies of processor registers, when the task is not running,
    1616// and some general informations associated to the task.
     17//
    1718// - It contains GPR[i], generally stored in slot (i). $0, *26 & $27 are not saved.
    1819// - It contains HI & LO registers.
    1920// - It contains CP0 registers: EPC, SR, CR.
    2021// - It contains CP2 registers : PTPR and MODE.
    21 // - It contains the TTY index for the terminal allocated to the task.
    22 // ctx[0] <- SR   ctx[8] <- $8    ctx[16]<- $16   ctx[24]<- $24   ctx[32]<- EPC
    23 // ctx[1] <- $1   ctx[9] <- $9    ctx[17]<- $17   ctx[25]<- $25   ctx[33]<- CR
    24 // ctx[2] <- $2   ctx[10]<- $10   ctx[18]<- $18   ctx[26]<- LO    ctx[34]<- TTY
    25 // ctx[3] <- $3   ctx[11]<- $11   ctx[19]<- $19   ctx[27]<- HI    ctx[35]<- PTPR
    26 // ctx[4] <- $4   ctx[12]<- $12   ctx[20]<- $20   ctx[28]<- $28   ctx[36]<- MODE
    27 // ctx[5] <- $5   ctx[13]<- $13   ctx[21]<- $21   ctx[29]<- $29   ctx[37]<- FBDMA
    28 // ctx[6] <- $6   ctx[14]<- $14   ctx[22]<- $22   ctx[30]<- $30   ctx[38]<- reserved
    29 // ctx[7] <- $7   ctx[15]<- $15   ctx[23]<- $23   ctx[31]<- $31   ctx[39]<- reserved
     22// - It contains the TTY global index, the FBDMA global index, the virtual base
     23//   address of the page table (PTAB), and the task global index (TASK).
     24//
     25// ctx[0]<- SR|ctx[8] <- $8 |ctx[16]<- $16|ctx[24]<- $24|ctx[32]<- EPC |ctx[40]<- TTY
     26// ctx[1]<- $1|ctx[9] <- $9 |ctx[17]<- $17|ctx[25]<- $25|ctx[33]<- CR  |ctx[41]<- FBDMA
     27// ctx[2]<- $2|ctx[10]<- $10|ctx[18]<- $18|ctx[26]<- LO |ctx[34]<- *** |ctx[42]<- PTAB
     28// ctx[3]<- $3|ctx[11]<- $11|ctx[19]<- $19|ctx[27]<- HI |ctx[35]<- PTPR|ctx[43]<- TASK
     29// ctx[4]<- $4|ctx[12]<- $12|ctx[20]<- $20|ctx[28]<- $28|ctx[36]<- MODE|ctx[44]<- ***
     30// ctx[5]<- $5|ctx[13]<- $13|ctx[21]<- $21|ctx[29]<- SP |ctx[37]<- *** |ctx[45]<- ***
     31// ctx[6]<- $6|ctx[14]<- $14|ctx[22]<- $22|ctx[30]<- $30|ctx[38]<- *** |ctx[46]<- ***
     32// ctx[7]<- $7|ctx[15]<- $15|ctx[23]<- $23|ctx[31]<- RA |ctx[39]<- *** |ctx[47]<- ***
    3033/////////////////////////////////////////////////////////////////////////////////////
    3134
     
    4043
    4144/////////////////////////////////////////////////////////////////////////////////
    42 //      Global variables
     45//      Global variables : array of schedulers (one scheduler per processor)
    4346/////////////////////////////////////////////////////////////////////////////////
    4447
    45 static_scheduler_t _scheduler[NB_CLUSTERS * NB_PROCS];
     48__attribute__((section (".kdata"))) static_scheduler_t _scheduler[NB_CLUSTERS * NB_PROCS];
    4649
    4750/////////////////////////////////////////////////////////////////////////////////
     
    6467    unsigned int *next_context;
    6568
    66     unsigned int pid   = _procid();
    67     unsigned int time  = _proctime();
    68     unsigned int tasks = _scheduler[pid].tasks;
     69    unsigned int proc_id   = _procid();
     70    unsigned int tasks     = _scheduler[proc_id].tasks;
    6971
    7072    // return if only one task  */
     
    7274 
    7375    // compute the task context base address for the current task
    74     curr_task_id = _scheduler[pid].current;
    75     curr_context = &(_scheduler[pid].context[curr_task_id][0]);
     76    curr_task_id = _scheduler[proc_id].current;
     77    curr_context = &(_scheduler[proc_id].context[curr_task_id][0]);
    7678   
    7779    // select the next task using a round-robin scheduling policy
     
    7981   
    8082    // compute the task context base address for the next task
    81     next_context = &(_scheduler[pid].context[next_task_id][0]);
     83    next_context = &(_scheduler[proc_id].context[next_task_id][0]);
    8284
    8385#if GIET_DEBUG_SWITCH
    8486_get_lock( &_tty_put_lock );
    8587_puts( "\n[GIET] Context switch for processor ");
    86 _putw( pid );
     88_putw( proc_id );
    8789_puts( " at cycle ");
    88 _putw( time );
     90_putw( _proctime() );
    8991_puts("\n");
    9092_puts( " - tasks        = ");
     
    101103
    102104    //  update the scheduler state, and makes the task switch
    103     _scheduler[pid].current = next_task_id;
     105    _scheduler[proc_id].current = next_task_id;
    104106    _task_switch( curr_context, next_context );
    105107
Note: See TracChangeset for help on using the changeset viewer.