mirror of
https://github.com/libretro/Play-.git
synced 2025-01-27 03:35:13 +00:00
git-svn-id: http://svn.purei.org/purei/trunk@179 b36208d7-6611-0410-8bec-b1987f11c4a2
This commit is contained in:
parent
50c1db6776
commit
a8cd8c05d7
@ -50,7 +50,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="$(FrameworkRoot)\include"
|
||||
PreprocessorDefinitions="WIN32;_MSVC_DEBUG;_WINDOWS;DEBUGGER_INCLUDED;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;GLEW_STATIC"
|
||||
PreprocessorDefinitions="WIN32;_MSVC;_DEBUG;_WINDOWS;DEBUGGER_INCLUDED;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;GLEW_STATIC"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
|
@ -94,7 +94,7 @@ void CX86Assembler::ResolveLabelReferences()
|
||||
{
|
||||
throw runtime_error("Label reference too small.");
|
||||
}
|
||||
m_WriteAtFunction(referencePos, static_cast<uint8>(offset));
|
||||
m_WriteAtFunction(static_cast<unsigned int>(referencePos), static_cast<uint8>(offset));
|
||||
}
|
||||
}
|
||||
m_labelReferences.clear();
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "Iop_Thsema.h"
|
||||
#include "Iop_Thevent.h"
|
||||
#include "Iop_Timrman.h"
|
||||
#include "Iop_Intrman.h"
|
||||
#include "Log.h"
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
@ -66,6 +67,9 @@ m_currentThreadId(-1)
|
||||
{
|
||||
RegisterModule(new Iop::CTimrman());
|
||||
}
|
||||
{
|
||||
RegisterModule(new Iop::CIntrman(m_ram));
|
||||
}
|
||||
}
|
||||
|
||||
CIopBios::~CIopBios()
|
||||
@ -138,31 +142,31 @@ void CIopBios::LoadAndStartModule(const char* path, const char* args, unsigned i
|
||||
// {
|
||||
// printf("Allo: 0x%0.8X\r\n", i * 4);
|
||||
// }
|
||||
|
||||
if((nVal & 0xFFFF) == 0xC958)
|
||||
/*
|
||||
if((nVal & 0xFFFF) == 0xB730)
|
||||
{
|
||||
char mnemonic[256];
|
||||
m_cpu.m_pArch->GetInstructionMnemonic(&m_cpu, i * 4, nVal, mnemonic, 256);
|
||||
printf("Allo: %s, 0x%0.8X\r\n", mnemonic, i * 4);
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
if(nVal == 0x2F9B50)
|
||||
{
|
||||
printf("Allo: 0x%0.8X\r\n", i * 4);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
|
||||
if((nVal & 0xFC000000) == 0x0C000000)
|
||||
{
|
||||
nVal &= 0x3FFFFFF;
|
||||
nVal *= 4;
|
||||
if(nVal == 0x034C00)
|
||||
if(nVal == 0x41410)
|
||||
{
|
||||
printf("Allo: 0x%0.8X\r\n", i * 4);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
*reinterpret_cast<uint32*>(&m_ram[0x41674]) = 0;
|
||||
@ -330,18 +334,37 @@ void CIopBios::Reschedule()
|
||||
|
||||
uint32 CIopBios::GetNextReadyThread(bool checkActivateTime)
|
||||
{
|
||||
for(ThreadMapType::const_iterator thread(m_threads.begin());
|
||||
thread != m_threads.end(); thread++)
|
||||
if(checkActivateTime)
|
||||
{
|
||||
const THREAD& nextThread = thread->second;
|
||||
if(checkActivateTime && (GetCurrentTime() <= nextThread.nextActivateTime)) continue;
|
||||
if(nextThread.status == THREAD_STATUS_RUNNING)
|
||||
for(ThreadMapType::const_iterator thread(m_threads.begin());
|
||||
thread != m_threads.end(); thread++)
|
||||
{
|
||||
return nextThread.id;
|
||||
const THREAD& nextThread = thread->second;
|
||||
if(GetCurrentTime() <= nextThread.nextActivateTime) continue;
|
||||
if(nextThread.status == THREAD_STATUS_RUNNING)
|
||||
{
|
||||
return nextThread.id;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Find the thread with the earliest wakeup time
|
||||
uint64 activateTime = -1;
|
||||
uint32 nextThreadId = -1;
|
||||
for(ThreadMapType::const_iterator thread(m_threads.begin());
|
||||
thread != m_threads.end(); thread++)
|
||||
{
|
||||
const THREAD& nextThread = thread->second;
|
||||
if(nextThread.status != THREAD_STATUS_RUNNING) continue;
|
||||
if(nextThread.nextActivateTime < activateTime)
|
||||
{
|
||||
nextThreadId = nextThread.id;
|
||||
}
|
||||
}
|
||||
return nextThreadId;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint64 CIopBios::GetCurrentTime()
|
||||
|
@ -1,12 +1,14 @@
|
||||
#include "Iop_Intrman.h"
|
||||
#include "Log.h"
|
||||
#include "COP_SCU.h"
|
||||
|
||||
#define LOGNAME "iop_intrman"
|
||||
|
||||
using namespace Iop;
|
||||
using namespace std;
|
||||
|
||||
CIntrman::CIntrman()
|
||||
CIntrman::CIntrman(uint8* ram) :
|
||||
m_ram(ram)
|
||||
{
|
||||
|
||||
}
|
||||
@ -25,8 +27,65 @@ void CIntrman::Invoke(CMIPS& context, unsigned int functionId)
|
||||
{
|
||||
switch(functionId)
|
||||
{
|
||||
case 9:
|
||||
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(EnableInterrupts(
|
||||
context
|
||||
));
|
||||
break;
|
||||
case 17:
|
||||
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(SuspendInterrupts(
|
||||
context,
|
||||
reinterpret_cast<uint32*>(&m_ram[context.m_State.nGPR[CMIPS::A0].nV0])
|
||||
));
|
||||
break;
|
||||
case 18:
|
||||
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(ResumeInterrupts(
|
||||
context,
|
||||
context.m_State.nGPR[CMIPS::A0].nV0
|
||||
));
|
||||
break;
|
||||
case 23:
|
||||
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(QueryIntrContext(
|
||||
context
|
||||
));
|
||||
break;
|
||||
default:
|
||||
CLog::GetInstance().Print(LOGNAME, "%0.8X: Unknown function (%d) called.\r\n", context.m_State.nPC, functionId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 CIntrman::EnableInterrupts(CMIPS& context)
|
||||
{
|
||||
uint32& statusRegister = context.m_State.nCOP0[CCOP_SCU::STATUS];
|
||||
statusRegister |= 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 CIntrman::SuspendInterrupts(CMIPS& context, uint32* state)
|
||||
{
|
||||
uint32& statusRegister = context.m_State.nCOP0[CCOP_SCU::STATUS];
|
||||
(*state) = statusRegister & 1;
|
||||
statusRegister &= ~1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 CIntrman::ResumeInterrupts(CMIPS& context, uint32 state)
|
||||
{
|
||||
uint32& statusRegister = context.m_State.nCOP0[CCOP_SCU::STATUS];
|
||||
if(state)
|
||||
{
|
||||
statusRegister |= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
statusRegister &= ~1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 CIntrman::QueryIntrContext(CMIPS& context)
|
||||
{
|
||||
uint32& statusRegister = context.m_State.nCOP0[CCOP_SCU::STATUS];
|
||||
return (statusRegister & 0x02 ? 1 : 0);
|
||||
}
|
||||
|
@ -8,14 +8,18 @@ namespace Iop
|
||||
class CIntrman : public CModule
|
||||
{
|
||||
public:
|
||||
CIntrman();
|
||||
CIntrman(uint8*);
|
||||
virtual ~CIntrman();
|
||||
|
||||
std::string GetId() const;
|
||||
void Invoke(CMIPS&, unsigned int);
|
||||
|
||||
private:
|
||||
|
||||
uint32 EnableInterrupts(CMIPS&);
|
||||
uint32 SuspendInterrupts(CMIPS&, uint32*);
|
||||
uint32 ResumeInterrupts(CMIPS&, uint32);
|
||||
uint32 QueryIntrContext(CMIPS&);
|
||||
uint8* m_ram;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -169,10 +169,10 @@ void CPsfVm::CheckInterrupts()
|
||||
{
|
||||
if(m_intc.HasPendingInterrupt())
|
||||
{
|
||||
if(m_cpu.GenerateInterrupt(0x1FC00000))
|
||||
{
|
||||
m_cpu.m_State.nHasException = 1;
|
||||
}
|
||||
// if(m_cpu.GenerateInterrupt(0x1FC00000))
|
||||
// {
|
||||
// m_cpu.m_State.nHasException = 1;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user