Exemplo n.º 1
0
u64 PPUThread::FastCall2(u32 addr, u32 rtoc)
{
	auto old_status = m_status;
	auto old_PC = PC;
	auto old_stack = GPR[1]; // only saved and restored (may be wrong)
	auto old_rtoc = GPR[2];
	auto old_LR = LR;
	auto old_thread = GetCurrentNamedThread();

	m_status = Running;
	PC = addr;
	GPR[2] = rtoc;
	LR = Emu.m_ppu_thr_stop;
	SetCurrentNamedThread(this);

	Task();

	m_status = old_status;
	PC = old_PC;
	GPR[1] = old_stack;
	GPR[2] = old_rtoc;
	LR = old_LR;
	SetCurrentNamedThread(old_thread);

	return GPR[3];
}
Exemplo n.º 2
0
void LogWriter::WriteToLog(wxString prefix, wxString value, wxString colour/*, wxColour bgcolour*/)
{
	if(ThreadBase* thr = GetCurrentNamedThread())
	{
		prefix = (prefix.IsEmpty() ? "" : prefix + " : ") + thr->GetThreadName();
	}

	if(m_logfile.IsOpened())
		m_logfile.Write((prefix.IsEmpty() ? wxEmptyString : "[" + prefix + "]: ") + value + "\n");

	if(!ConLogFrame) return;

	wxCriticalSectionLocker lock(g_cs_conlog);

	if(wxThread::IsMain())
	{
		while(LogBuffer.IsBusy()) wxYieldIfNeeded();
	}
	else
	{
		while(LogBuffer.IsBusy()) Sleep(1);
	}

	//if(LogBuffer.put == LogBuffer.get) LogBuffer.Flush();

	LogBuffer.Push(LogPacket(prefix, value, colour));
}
Exemplo n.º 3
0
__forceinline void SM_Sleep()
{
	if (NamedThreadBase* t = GetCurrentNamedThread())
	{
		t->WaitForAnySignal();
	}
	else
	{
		std::this_thread::sleep_for(std::chrono::milliseconds(1));
	}
}
Exemplo n.º 4
0
void LogWriter::WriteToLog(const std::string& prefix, const std::string& value, u8 lvl/*, wxColour bgcolour*/)
{
	std::string new_prefix = prefix;
	if(!prefix.empty())
	{
		if(NamedThreadBase* thr = GetCurrentNamedThread())
		{
			new_prefix += " : " + thr->GetThreadName();
		}
	}

	if(m_logfile.IsOpened() && !new_prefix.empty())
		m_logfile.Write(fmt::FromUTF8("[" + new_prefix + "]: " + value + "\n"));

	if(!ConLogFrame || Ini.HLELogLvl.GetValue() == 4 || (lvl != 0 && lvl <= Ini.HLELogLvl.GetValue()))
		return;

	std::lock_guard<std::mutex> lock(g_cs_conlog);

#ifdef QT_UI
	// TODO: Use ThreadBase instead, track main thread id
	if(QThread::currentThread() == qApp->thread())
#else
	if(wxThread::IsMain())
#endif
	{
		while(LogBuffer.IsBusy())
		{
			// need extra break condition?
			wxYieldIfNeeded();
		}
	}
	else
	{
		while (LogBuffer.IsBusy())
		{
			if (Emu.IsStopped())
			{
				break;
			}
			Sleep(1);
		}
	}

	//if(LogBuffer.put == LogBuffer.get) LogBuffer.Flush();

	LogBuffer.Push(LogPacket(new_prefix, value, g_log_colors[lvl]));
}
Exemplo n.º 5
0
void CPUThread::Stop()
{
	if(IsStopped()) return;

	SendDbgCommand(DID_STOP_THREAD, this);

	m_status = Stopped;

	if(static_cast<NamedThreadBase*>(this) != GetCurrentNamedThread())
	{
		ThreadBase::Stop();
	}

	Emu.CheckStatus();

	SendDbgCommand(DID_STOPED_THREAD, this);
}
Exemplo n.º 6
0
void ARMv7Thread::FastCall(u32 addr)
{
	auto old_status = m_status;
	auto old_PC = PC;
	auto old_stack = SP;
	auto old_LR = LR;
	auto old_thread = GetCurrentNamedThread();

	m_status = Running;
	PC = addr;
	LR = Emu.GetCPUThreadStop();
	SetCurrentNamedThread(this);

	CPUThread::Task();

	m_status = old_status;
	PC = old_PC;
	SP = old_stack;
	LR = old_LR;
	SetCurrentNamedThread(old_thread);
}
Exemplo n.º 7
0
u64 PPUThread::FastCall2(u64 addr, u64 rtoc)
{
	auto old_status = m_status;
	auto old_PC = PC;
	auto old_rtoc = GPR[2];
	auto old_LR = LR;
	auto old_thread = GetCurrentNamedThread();

	m_status = Running;
	PC = addr;
	GPR[2] = rtoc;
	LR = Emu.m_ppu_thr_stop;
	SetCurrentNamedThread(this);

	Task();

	m_status = old_status;
	PC = old_PC;
	GPR[2] = old_rtoc;
	LR = old_LR;
	SetCurrentNamedThread(old_thread);

	return GPR[3];
}
Exemplo n.º 8
0
CPUThread* GetCurrentCPUThread()
{
	return (CPUThread*)GetCurrentNamedThread();
}
Exemplo n.º 9
0
CPUThread* GetCurrentCPUThread()
{
	return dynamic_cast<CPUThread*>(GetCurrentNamedThread());
}
Exemplo n.º 10
0
PPCThread* GetCurrentPPCThread()
{
	return (PPCThread*)GetCurrentNamedThread();
}