//=========================================================================== // SceMiDispatcher johns 10-2-00 // // The SceMiDispatcher module provides an independent autonomous thread // the services the SCE-MI port proxies by making repeated calls to // the SceMi::ServiceLoop() function. // // Between each call, it yields to allow activity to occur in other // autonomous threads. //=========================================================================== class SceMiDispatcher: public sc_module { public: sc_slave<> Done; private: SC_HAS_PROCESS(SceMiDispatcher); //------------------------------------------------------- // Thread declarations void dispatchThread(); // Autonomous SCEMI dispatcher thread void doneThread(); //------------------------------------------------------- // Context declarations SceMi *dSceMi; static int dInterruptReceived; //------------------------------------------------------- // Context declarations static void signalHandler( int ){ cout << "Interrupt received ! Terminating SCEMI" << endl; dInterruptReceived = 1; } public: SceMiDispatcher( sc_module_name name, SceMi *sceMi ) : sc_module( name ), dSceMi(sceMi) { //-------------------------------------- // Thread bindings SC_THREAD( dispatchThread ); sensitive << UTick; // Sensitize to global "Untimed Tick" clock to provide for // atomic advance of this along with other autonomous threads // in the system. UTick is declared at the top of System.cpp. // -- johnS 8-3-00 // Clients of this dispatcher will be responsible for binding // to their respective message port proxies in their respective // constructors. SC_SLAVE( doneThread, Done ); signal( SIGINT, signalHandler ); } }; int SceMiDispatcher::dInterruptReceived = 0; void SceMiDispatcher::dispatchThread() { // This is all the dispatcher does !! Deceptively simple, eh ? // It just calls the SCEMI dispatcher poll function and returns. for(;;){ wait(); dSceMi->ServiceLoop(); if( dInterruptReceived ){ SceMi::Shutdown( dSceMi ); exit(1); } } } void SceMiDispatcher::doneThread() { SceMi::Shutdown( dSceMi ); exit(0); }