void CpuRiscV_Functional::updatePipeline() { IInstruction *instr; CpuContextType *pContext = getpContext(); if (dport.valid) { dport.valid = 0; updateDebugPort(); } pContext->pc = pContext->npc; if (isRunning()) { fetchInstruction(); } updateState(); if (pContext->reset) { updateQueue(); reset(); return; } instr = decodeInstruction(cacheline_); if (isRunning()) { last_hit_breakpoint_ = ~0; if (instr) { executeInstruction(instr, cacheline_); } else { pContext->npc += 4; generateException(EXCEPTION_InstrIllegal, pContext); RISCV_info("[%" RV_PRI64 "d] pc:%08x: %08x \t illegal instruction", getStepCounter(), static_cast<uint32_t>(pContext->pc), cacheline_[0]); } } updateQueue(); handleTrap(); }
extern "C" int supportSPU(SpuThreadData * spu_data, SpuJavaThreadData * thread, int chosenSpu) { unsigned int cmdSignal; char stop = 0; while (!stop) { if (spe_out_intr_mbox_read(spu_data->spus[chosenSpu].ctx, &cmdSignal, 1, SPE_MBOX_ALL_BLOCKING) < 0) { perror("Failed reading while waiting for a command signal from SPU"); exit(1); } switch (cmdSignal) { case TRAP_MESSAGE: handleTrap(chosenSpu); break; case FAKE_TRAP_MESSAGE: printf("Fake Trap Called from SPU\n"); break; case FAKE_TRAP_MESSAGE_STR: handleFakeTrap(chosenSpu); break; case FAKE_TRAP_MESSAGE_INT: handleFakeTrapInt(chosenSpu); break; case CONSOLE_WRITE_CHAR: handleConsoleWrite(chosenSpu); break; case CONSOLE_WRITE_INT: case CONSOLE_WRITE_INT_BOTH: case CONSOLE_WRITE_INT_HEX: handleConsoleIntWrite(chosenSpu, cmdSignal); break; case CONSOLE_WRITE_LONG: case CONSOLE_WRITE_LONG_BOTH: case CONSOLE_WRITE_LONG_HEX: handleConsoleLongWrite(chosenSpu, cmdSignal); break; case CONSOLE_WRITE_DOUBLE: handleConsoleDoubleWrite(chosenSpu); break; case RETURN_VALUE_V: stop = 1; break; case RETURN_VALUE_I: case RETURN_VALUE_F: case RETURN_VALUE_R: if (spe_out_mbox_read(global_spu_data->spus[chosenSpu].ctx, &(thread->retVal[0]), 1) < 0) { perror("Error reading return value from SPU migrated method\n"); exit(1); } stop = 1; break; case RETURN_VALUE_L_UPPER: case RETURN_VALUE_D_UPPER: if (spe_out_mbox_read(global_spu_data->spus[chosenSpu].ctx, &(thread->retVal[0]), 1) < 0) { perror("Error reading return value from SPU migrated method\n"); exit(1); } break; case RETURN_VALUE_L_LOWER: case RETURN_VALUE_D_LOWER: if (spe_out_mbox_read(global_spu_data->spus[chosenSpu].ctx, &(thread->retVal[1]), 1) < 0) { perror("Error reading return value from SPU migrated method\n"); exit(1); } stop = 1; break; default: { unsigned int err = 0; fprintf(stderr, "Unknown signal recieved from SPU: 0x%x", cmdSignal); spe_out_mbox_read(spu_data->spus[chosenSpu].ctx, &err, 1); fprintf(stderr, "Error signal was: 0x%x\n", err); exit(1); } } } return 0; }