Ignore:
Timestamp:
Jul 18, 2015, 3:04:15 PM (9 years ago)
Author:
alain
Message:

Update the peripheral drivers using descheduling,
to comply with the modified NORUN bit-vector in task context.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_drivers/hba_driver.c

    r603 r630  
    2323#include <vmem.h>
    2424
    25 ///////////////////////////////////////////////////////////////////////////////////
     25//////////////////////////////////////////////////////////////////////////////////
     26//      Extern variables
     27//////////////////////////////////////////////////////////////////////////////////
     28
     29// allocated in the boot.c or kernel_init.c files
     30extern static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX];
     31
     32//////////////////////////////////////////////////////////////////////////////////
    2633//               Global variables
    27 ///////////////////////////////////////////////////////////////////////////////////
    28 
    2934//////////////////////////////////////////////////////////////////////////////////
    3035// The global variable hba_boot_mode defines the way the HBA component is used
    3136// and must be defined in both kernel_init.c and boot.c files.
    32 // - during the boot phase, only one processor has access to the HBA in synchronous
    33 //   mode, there is no need for the allocator to use a lock
     37// - during the boot phase, only one processor access the HBA in synchronous
     38//   mode. There is no need for the allocator to use a lock.
    3439// - after the boot phase, the HBA device can be used by several processors. The
    3540//   allocator is protected by a sqt_lock.
     
    278283    // in descheduling mode, we deschedule the task
    279284    // and use an interrupt to reschedule the task.
    280     // We need a critical section, because we must reset the RUN bit
     285    // We need a critical section, because we must set the NORUN bit
    281286        // before to launch the transfer, and we don't want to be
    282287    // descheduled between these two operations.
     
    303308        _it_disable( &save_sr );
    304309
    305         // reset runnable
    306         _set_task_slot( x, y, p, ltid, CTX_RUN_ID, 0 ); 
    307 
     310        // Set NORUN_MASK_IOC bit
     311        static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
     312        unsigned int*       ptr     = &psched->context[ltid][CTX_NORUN_ID];
     313        _atomic_or( ptr , NORUN_MASK_IOC );
     314     
    308315        // start HBA transfer
    309316        _hba_set_register( HBA_PXCI, (1<<cmd_id) );
     
    432439
    433440            // identify waiting task
    434             unsigned int remote_procid  = _hba_gtid[cmd_id]>>16;
    435             unsigned int ltid           = _hba_gtid[cmd_id] & 0xFFFF;
    436             unsigned int remote_cluster = remote_procid >> P_WIDTH;
    437             unsigned int remote_x       = remote_cluster >> Y_WIDTH;
    438             unsigned int remote_y       = remote_cluster & ((1<<Y_WIDTH)-1);
    439             unsigned int remote_p       = remote_procid & ((1<<P_WIDTH)-1);
     441            unsigned int procid  = _hba_gtid[cmd_id]>>16;
     442            unsigned int ltid    = _hba_gtid[cmd_id] & 0xFFFF;
     443            unsigned int cluster = procid >> P_WIDTH;
     444            unsigned int x       = cluster >> Y_WIDTH;
     445            unsigned int y       = cluster & ((1<<Y_WIDTH)-1);
     446            unsigned int p       = procid & ((1<<P_WIDTH)-1);
    440447 
    441             // re-activates waiting task
    442             _set_task_slot( remote_x,
    443                             remote_y,
    444                             remote_p,
    445                             ltid,
    446                             CTX_RUN_ID,
    447                             1 );
     448            // Reset NORUN_MASK_IOC bit
     449            static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
     450            unsigned int*       ptr     = &psched->context[ltid][CTX_NORUN_ID];
     451            _atomic_and( ptr , ~NORUN_MASK_IOC );
    448452
    449453            // send a WAKUP WTI to processor running the waiting task
    450             _xcu_send_wti( remote_cluster ,
    451                            remote_p ,
     454            _xcu_send_wti( cluster ,
     455                           p ,
    452456                           0 );          // don't force context switch
    453457
     
    457461        "  resume task %d running on P[%d,%d,%d]\n",
    458462        cmd_id , _get_proctime() ,
    459         ltid , remote_x , remote_y , remote_p );
     463        ltid , x , y , p );
    460464#endif
    461465        }
Note: See TracChangeset for help on using the changeset viewer.