示例#1
0
void CycleCounter::configure()
{
	if (emulationLevel >= EMEX_EXTRA_SMALL_5XX)
	{
		MemoryManager* mm = deviceHandle->getMemoryManager();
		EemMemoryAccess* ema = (EemMemoryAccess*)mm->getMemoryArea("EEM");

		cycleCounterControl = defaultMode;
		ema->writeEemRegister(CCNT0CTL, cycleCounterControl) && ema->sync();
	}
}
示例#2
0
uint64_t CycleCounter::read()
{
	if (emulationLevel >= EMEX_EXTRA_SMALL_5XX)
	{ 
		MemoryManager* mm = deviceHandle->getMemoryManager();
		EemMemoryAccess* ema = (EemMemoryAccess*)mm->getMemoryArea("EEM");

		union CycleCount { struct { uint32_t low, high; }; uint64_t value; };
		CycleCount cycleCount;

		ema->readEemRegister(CCNT0L, &cycleCount.low) && ema->sync();
		ema->readEemRegister(CCNT0H, &cycleCount.high) && ema->sync();
		
		counterValue = 0;

		uint32_t factor = 1;
		uint32_t lsfr2hex[16] = {0x0, 0x1, 0x2, 0x7, 0x5, 0x3, 0x8, 0xb, 0xe, 0x6, 0x4, 0xa, 0xd, 0x9, 0xc, 0};
		for (int i = 0; i < 10; ++i)
		{
			counterValue += factor * lsfr2hex[(cycleCount.value & 0xf)];
			cycleCount.value >>= 4;
			factor *= 15;
		}	
	}
bool DebugManagerV3::run (uint16_t controlMask, DebugEventTarget * cb, bool releaseJtag)
{
	MemoryManager* mm = this->parent->getMemoryManager();
	MemoryArea* cpu = mm->getMemoryArea("CPU"); 
	if (!cpu)
    {
		return false;
    }

	lpm5WakeupDetected = false;

	if(cb!=0)
	{
		cbx=cb;	
	}

	uint32_t pc, sr;
	cpu->read(0, &pc, 1);
	cpu->read(2, &sr, 1);

	if(mm->flushAll()==false)
	{
		return false;
	}
	
	cycleCounter_.reset();
	ConfigManager *cm = parent->getFetHandle()->getConfigManager();

	const uint16_t mdb = parent->getEmulationManager()->getSoftwareBreakpoints()->getSwbpManager()->getInstructionAt(pc);
	if (mdb != 0)
	{
		mdbPatchValue = mdb;
	}

	HalExecElement* el = new HalExecElement(this->parent->checkHalId(ID_RestoreContext_ReleaseJtag));
	this->parent->getWatchdogControl()->addParamsTo(el);
	el->appendInputData32(pc);
	el->appendInputData16(sr);
	el->appendInputData16(controlMask!=0? 0x0007: 0x0006);	// eem control bits 
	el->appendInputData16(mdbPatchValue);		// mdb
	el->appendInputData16(releaseJtag ? 1 : 0);
	el->appendInputData16(cm->ulpDebugEnabled() ? 1 : 0);

	mdbPatchValue = 0;

	HalExecCommand cmd;
	cmd.elements.push_back(el);

	if (!this->parent->send(cmd))
	{
		return false;
	}
	
	// handle lpmx5 polling
	if (releaseJtag)
	{
		pausePolling();
	}
	else
	{
		this->resumePolling();
	}	

	if (controlMask!=0 && !releaseJtag)
	{
		if (!activatePolling(controlMask))
		{
			return false;
		}
	}

	resetCycleCounterBeforeNextStep = true;

	return true;
}