void QEMUReader::syscall(uint32_t num, Time_t time, FlowID fid) /* Create an syscall instruction and inject in the pipeline {{{1 */ { RAWDInst *rinst = tsfifo[fid].getTailRef(); rinst->set(0xdeaddead,0,iRALU,LREG_R0,LREG_R0,LREG_InvalidOutput, LREG_InvalidOutput,true); tsfifo[fid].push(); }
void QEMUReader::queueInstruction(AddrType pc, AddrType addr, FlowID fid, int op, int src1, int src2, int dest, int dest2, bool keepStats) /* queue instruction (called by QEMU) {{{1 */ { uint64_t conta=0; I(src1<LREG_MAX); I(src2<LREG_MAX); I(dest<LREG_MAX); I(dest2<LREG_MAX); while (tsfifo[fid].full()) { pthread_mutex_lock(&mutex_ctrl); // BEGIN #if 0 if (tsfifo_rcv_mutex_blocked) { tsfifo_rcv_mutex_blocked = 0; pthread_mutex_unlock(&tsfifo_rcv_mutex); //MSG("1.alarmto rcv%d",fid); } #endif bool doblock = false; if (tsfifo_snd_mutex_blocked[fid] == 0) { tsfifo_snd_mutex_blocked[fid] = 1; doblock = true; } pthread_mutex_unlock(&mutex_ctrl); // END //MSG("2.sleep snd%d",fid); if (doblock) pthread_mutex_lock(&tsfifo_snd_mutex[fid]); else MSG("INTERESTING"); //MSG("2.wakeup snd%d",fid); } RAWDInst *rinst = tsfifo[fid].getTailRef(); I(rinst); rinst->set(pc,addr,static_cast<InstOpcode>(op), static_cast<RegType>(src1),static_cast<RegType>(src2),static_cast<RegType>(dest), static_cast<RegType>(dest2), keepStats); tsfifo[fid].push(); }
void initialize(){ if(!pluggedin){ #if 0 BootLoader::plug(arg1,arg2); #else int arg1 = 1; const char *arg2[] = {"cachetest", 0}; setenv("ESESC_tradCORE_DL1","DL1_core DL1",1); SescConf = new SConfig(arg1, arg2); unsetenv("ESESC_tradCore_DL1"); gms_p0 = new MemorySystem(0); gms_p0->buildMemorySystem(); gms_p1 = new MemorySystem(1); gms_p1->buildMemorySystem(); #endif pluggedin=true; } // Create a LD (e5d33000) with PC = 0xfeeffeef and address 1203 rinst.set(0xe5d33000,0xfeeffeef,1203,true); crackInstARM.expand(&rinst); ld = DInst::create(rinst.getInstRef(0), &rinst, rinst.getPC(), 0); // Create a ST (e5832000) with PC = 0x410 and address 0x400 rinst.set(0xe5832000,0x410,0x400,true); crackInstARM.expand(&rinst); st = DInst::create(rinst.getInstRef(0), &rinst, rinst.getPC(), 0); }
DInst *QEMUReader::executeHead(FlowID fid) /* speculative advance of execution {{{1 */ { if (!ruffer[fid].empty()) { DInst *dinst = ruffer[fid].getHead(); ruffer[fid].popHead(); I(dinst); // We just added, there should be one or more return dinst; } int conta = 0; while(!tsfifo[fid].full()) { pthread_mutex_lock(&mutex_ctrl); // BEGIN if (tsfifo_snd_mutex_blocked[fid]) { tsfifo_snd_mutex_blocked[fid] = 0; pthread_mutex_unlock(&tsfifo_snd_mutex[fid]); //MSG("2.alarmt snd%d",fid); } #if 0 if (tsfifo_rcv_mutex_blocked == 0) { tsfifo_rcv_mutex_blocked = 1; pthread_mutex_unlock(&mutex_ctrl); // END //MSG("1.sleep rcv%d",fid); pthread_mutex_lock(&tsfifo_rcv_mutex); //MSG("1.wakeup rcv%d",fid); }else{ pthread_mutex_unlock(&mutex_ctrl); // END } #else pthread_mutex_unlock(&mutex_ctrl); // END #endif if (qsamplerlist[fid]->isActive(fid) == false) { MSG("DOWN"); return 0; } if (!live_qemu_active) { pthread_mutex_lock(&mutex_live); pthread_cond_wait(&cond_live, &mutex_live); pthread_mutex_unlock(&mutex_live); } if (conta++>100) { //printf("+%d",fid); return 0; } } for(int i=32;i<tsfifo[fid].size();i++) { RAWDInst *rinst = tsfifo[fid].getHeadRef(); DInst **dinsth = ruffer[fid].getInsertPointRef(); *dinsth = DInst::create(rinst->getInst(), rinst->getPC(), rinst->getAddr(), fid, rinst->getStatsFlag()); ruffer[fid].add(); tsfifo[fid].pop(); } if (tsfifo_snd_mutex_blocked[fid]) { tsfifo_snd_mutex_blocked[fid] = 0; pthread_mutex_unlock(&tsfifo_snd_mutex[fid]); } if (ruffer[fid].empty()) return 0; DInst *dinst = ruffer[fid].getHead(); ruffer[fid].popHead(); I(dinst); // We just added, there should be one or more return dinst; }