mirror of
https://github.com/libretro/Play-.git
synced 2025-01-09 18:10:57 +00:00
Cleaned up some Iop/Sif stuff for potential state support.
git-svn-id: http://svn.purei.org/purei/trunk@465 b36208d7-6611-0410-8bec-b1987f11c4a2
This commit is contained in:
parent
351a79ab7c
commit
d05c0edff3
@ -5,8 +5,9 @@
|
||||
#include "Profiler.h"
|
||||
#include "Log.h"
|
||||
#include "RegisterStateFile.h"
|
||||
#include "iop/IopBios.h"
|
||||
|
||||
#define CMD_RECVADDR 0x00001000
|
||||
#define CMD_RECVADDR (CIopBios::CONTROL_BLOCK_END)
|
||||
#define RPC_RECVADDR 0xDEADBEEF
|
||||
|
||||
#define LOG_NAME ("sif")
|
||||
@ -59,9 +60,9 @@ void CSIF::Reset()
|
||||
DeleteModules();
|
||||
}
|
||||
|
||||
void CSIF::SetDmaBuffer(uint8* buffer, uint32 size)
|
||||
void CSIF::SetDmaBuffer(uint32 bufferAddress, uint32 size)
|
||||
{
|
||||
m_dmaBuffer = buffer;
|
||||
m_dmaBuffer = m_iopRam + bufferAddress;
|
||||
m_dmaBufferSize = size;
|
||||
}
|
||||
|
||||
@ -155,7 +156,14 @@ uint32 CSIF::ReceiveDMA6(uint32 nSrcAddr, uint32 nSize, uint32 nDstAddr, bool is
|
||||
else
|
||||
{
|
||||
assert(nDstAddr < PS2::IOP_RAM_SIZE);
|
||||
memcpy(m_iopRam + nDstAddr, m_eeRam + nSrcAddr, nSize);
|
||||
if(nDstAddr >= 0 && nDstAddr <= CMD_RECVADDR)
|
||||
{
|
||||
CLog::GetInstance().Print(LOG_NAME, "Warning: Trying to DMA in Bios Control Area.\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(m_iopRam + nDstAddr, m_eeRam + nSrcAddr, nSize);
|
||||
}
|
||||
return nSize;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
void ProcessPackets();
|
||||
|
||||
void RegisterModule(uint32, CSifModule*);
|
||||
void SetDmaBuffer(uint8*, uint32);
|
||||
void SetDmaBuffer(uint32, uint32);
|
||||
void SendCallReply(uint32, void*);
|
||||
|
||||
uint32 ReceiveDMA5(uint32, uint32, uint32, bool);
|
||||
|
@ -5,7 +5,9 @@
|
||||
#include "PtrStream.h"
|
||||
#include "Iop_Intc.h"
|
||||
#include "lexical_cast_ex.h"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "xml/FilteringNodeIterator.h"
|
||||
//#include "../StructCollectionStateFile.h"
|
||||
|
||||
#ifdef _IOP_EMULATE_MODULES
|
||||
#include "Iop_DbcMan320.h"
|
||||
@ -31,16 +33,22 @@
|
||||
|
||||
#define LOGNAME "iop_bios"
|
||||
|
||||
#define STATE_THREADS_FILE ("iopbios/threads")
|
||||
#define STATE_THREADS_PRIORITY_FIELD ("priority")
|
||||
|
||||
#define BIOS_NEXT_THREAD_ID_BASE (CONTROL_BLOCK_START + 0x0000)
|
||||
#define BIOS_NEXT_SEMAPHORE_ID_BASE (CONTROL_BLOCK_START + 0x0004)
|
||||
#define BIOS_CURRENT_THREAD_ID_BASE (CONTROL_BLOCK_START + 0x0008)
|
||||
#define BIOS_CURRENT_TIME_BASE (CONTROL_BLOCK_START + 0x0010)
|
||||
#define BIOS_HANDLERS_BASE (CONTROL_BLOCK_START + 0x0800)
|
||||
|
||||
using namespace std;
|
||||
using namespace Framework;
|
||||
|
||||
CIopBios::CIopBios(uint32 baseAddress, uint32 clockFrequency, CMIPS& cpu, uint8* ram, uint32 ramSize) :
|
||||
m_baseAddress(baseAddress),
|
||||
CIopBios::CIopBios(uint32 clockFrequency, CMIPS& cpu, uint8* ram, uint32 ramSize) :
|
||||
m_cpu(cpu),
|
||||
m_ram(ram),
|
||||
m_ramSize(ramSize),
|
||||
m_nextThreadId(1),
|
||||
m_nextSemaphoreId(1),
|
||||
m_sifMan(NULL),
|
||||
m_stdio(NULL),
|
||||
m_sysmem(NULL),
|
||||
@ -51,10 +59,8 @@ m_dbcman(NULL),
|
||||
m_padman(NULL),
|
||||
#endif
|
||||
m_rescheduleNeeded(false),
|
||||
m_currentThreadId(-1),
|
||||
m_threadFinishAddress(0),
|
||||
m_clockFrequency(clockFrequency),
|
||||
m_currentTime(0)
|
||||
m_clockFrequency(clockFrequency)
|
||||
{
|
||||
|
||||
}
|
||||
@ -67,17 +73,22 @@ CIopBios::~CIopBios()
|
||||
void CIopBios::Reset(Iop::CSifMan* sifMan)
|
||||
{
|
||||
{
|
||||
CMIPSAssembler assembler(reinterpret_cast<uint32*>(&m_ram[m_baseAddress]));
|
||||
CMIPSAssembler assembler(reinterpret_cast<uint32*>(&m_ram[BIOS_HANDLERS_BASE]));
|
||||
m_threadFinishAddress = AssembleThreadFinish(assembler);
|
||||
m_returnFromExceptionAddress = AssembleReturnFromException(assembler);
|
||||
m_idleFunctionAddress = AssembleIdleFunction(assembler);
|
||||
}
|
||||
|
||||
//0xBE00000 = Stupid constant to make FFX PSF happy
|
||||
m_currentTime = 0xBE00000;
|
||||
CurrentTime() = 0xBE00000;
|
||||
NextThreadId() = 1;
|
||||
NextSemaphoreId() = 1;
|
||||
CurrentThreadId() = -1;
|
||||
|
||||
m_cpu.m_State.nCOP0[CCOP_SCU::STATUS] |= CMIPS::STATUS_INT;
|
||||
m_cpu.m_State.nCOP0[CCOP_SCU::STATUS] |= CMIPS::STATUS_INT;
|
||||
|
||||
m_threads.clear();
|
||||
m_semaphores.clear();
|
||||
m_intrHandlers.clear();
|
||||
m_moduleTags.clear();
|
||||
|
||||
@ -102,7 +113,7 @@ void CIopBios::Reset(Iop::CSifMan* sifMan)
|
||||
RegisterModule(m_ioman);
|
||||
}
|
||||
{
|
||||
m_sysmem = new Iop::CSysmem(0x1000, m_ramSize, *m_stdio, *m_sifMan);
|
||||
m_sysmem = new Iop::CSysmem(CONTROL_BLOCK_END, m_ramSize, *m_stdio, *m_sifMan);
|
||||
RegisterModule(m_sysmem);
|
||||
}
|
||||
{
|
||||
@ -177,12 +188,62 @@ void CIopBios::Reset(Iop::CSifMan* sifMan)
|
||||
const int sifDmaBufferSize = 0x1000;
|
||||
uint32 sifDmaBufferPtr = m_sysmem->AllocateMemory(sifDmaBufferSize, 0);
|
||||
#ifndef _NULL_SIFMAN
|
||||
m_sifMan->SetDmaBuffer(m_ram + sifDmaBufferPtr, sifDmaBufferSize);
|
||||
m_sifMan->SetDmaBuffer(sifDmaBufferPtr, sifDmaBufferSize);
|
||||
#endif
|
||||
|
||||
Reschedule();
|
||||
}
|
||||
|
||||
uint32& CIopBios::NextThreadId() const
|
||||
{
|
||||
return *reinterpret_cast<uint32*>(m_ram + BIOS_NEXT_THREAD_ID_BASE);
|
||||
}
|
||||
|
||||
uint32& CIopBios::NextSemaphoreId() const
|
||||
{
|
||||
return *reinterpret_cast<uint32*>(m_ram + BIOS_NEXT_SEMAPHORE_ID_BASE);
|
||||
}
|
||||
|
||||
uint32& CIopBios::CurrentThreadId() const
|
||||
{
|
||||
return *reinterpret_cast<uint32*>(m_ram + BIOS_CURRENT_THREAD_ID_BASE);
|
||||
}
|
||||
|
||||
uint64& CIopBios::CurrentTime() const
|
||||
{
|
||||
return *reinterpret_cast<uint64*>(m_ram + BIOS_CURRENT_TIME_BASE);
|
||||
}
|
||||
|
||||
void CIopBios::SaveState(CZipArchiveWriter& archive)
|
||||
{
|
||||
//CStructCollectionStateFile* threadsFile = new CStructCollectionStateFile(STATE_THREADS_FILE);
|
||||
//for(ThreadMapType::const_iterator threadIterator(m_threads.begin());
|
||||
// threadIterator != m_threads.end(); threadIterator++)
|
||||
//{
|
||||
// const THREAD& thread(threadIterator->second);
|
||||
// CStructFile structFile;
|
||||
// structFile.SetRegister32(STATE_THREADS_PRIORITY_FIELD, thread.priority);
|
||||
// threadsFile->InsertStruct(("thread" + boost::lexical_cast<string>(threadIterator->first)).c_str(), structFile);
|
||||
//}
|
||||
//archive.InsertFile(threadsFile);
|
||||
}
|
||||
|
||||
void CIopBios::LoadState(CZipArchiveReader& archive)
|
||||
{
|
||||
//CStructCollectionStateFile threadsFile(*archive.BeginReadFile(STATE_THREADS_FILE));
|
||||
//for(CStructCollectionStateFile::StructIterator threadIterator(threadsFile.GetStructBegin());
|
||||
// threadIterator != threadsFile.GetStructEnd(); threadIterator++)
|
||||
//{
|
||||
// const CStructFile& structFile(threadIterator->second);
|
||||
// uint32 priority = structFile.GetRegister32(STATE_THREADS_PRIORITY_FIELD);
|
||||
//}
|
||||
}
|
||||
|
||||
bool CIopBios::IsIdle()
|
||||
{
|
||||
return (m_cpu.m_State.nPC == m_idleFunctionAddress + 8);
|
||||
}
|
||||
|
||||
void CIopBios::LoadAndStartModule(const char* path, const char* args, unsigned int argsLength)
|
||||
{
|
||||
uint32 handle = m_ioman->Open(Iop::Ioman::CDevice::O_RDONLY, path);
|
||||
@ -254,7 +315,7 @@ void CIopBios::LoadAndStartModule(CELF& elf, const char* path, const char* args,
|
||||
thread.context.gpr[CMIPS::SP] -= 4;
|
||||
|
||||
StartThread(threadId);
|
||||
if(m_currentThreadId == -1)
|
||||
if(CurrentThreadId() == -1)
|
||||
{
|
||||
Reschedule();
|
||||
}
|
||||
@ -363,7 +424,7 @@ uint32 CIopBios::CreateThread(uint32 threadProc, uint32 priority, uint32 stackSi
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
CLog::GetInstance().Print(LOGNAME, "%i: CreateThread(threadProc = 0x%0.8X, priority = %d);\r\n",
|
||||
m_currentThreadId, threadProc, priority);
|
||||
CurrentThreadId(), threadProc, priority);
|
||||
#endif
|
||||
|
||||
if(stackSize == 0)
|
||||
@ -377,7 +438,7 @@ uint32 CIopBios::CreateThread(uint32 threadProc, uint32 priority, uint32 stackSi
|
||||
thread.stackSize = stackSize;
|
||||
thread.stackBase = m_sysmem->AllocateMemory(thread.stackSize, 0);
|
||||
memset(m_ram + thread.stackBase, 0, thread.stackSize);
|
||||
thread.id = m_nextThreadId++;
|
||||
thread.id = NextThreadId()++;
|
||||
thread.priority = priority;
|
||||
thread.status = THREAD_STATUS_CREATED;
|
||||
thread.context.epc = threadProc;
|
||||
@ -392,7 +453,7 @@ void CIopBios::StartThread(uint32 threadId, uint32* param)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
CLog::GetInstance().Print(LOGNAME, "%i: StartThread(threadId = %i, param = 0x%0.8X);\r\n",
|
||||
m_currentThreadId, threadId, param);
|
||||
CurrentThreadId(), threadId, param);
|
||||
#endif
|
||||
|
||||
THREAD& thread = GetThread(threadId);
|
||||
@ -412,11 +473,11 @@ void CIopBios::DelayThread(uint32 delay)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
CLog::GetInstance().Print(LOGNAME, "%i: DelayThread(delay = %i);\r\n",
|
||||
m_currentThreadId, delay);
|
||||
CurrentThreadId(), delay);
|
||||
#endif
|
||||
|
||||
//TODO : Need to delay or something...
|
||||
THREAD& thread = GetThread(m_currentThreadId);
|
||||
THREAD& thread = GetThread(CurrentThreadId());
|
||||
thread.nextActivateTime = GetCurrentTime() + MicroSecToClock(delay);
|
||||
m_rescheduleNeeded = true;
|
||||
}
|
||||
@ -425,10 +486,10 @@ void CIopBios::SleepThread()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
CLog::GetInstance().Print(LOGNAME, "%i: SleepThread();\r\n",
|
||||
m_currentThreadId);
|
||||
CurrentThreadId());
|
||||
#endif
|
||||
|
||||
THREAD& thread = GetThread(m_currentThreadId);
|
||||
THREAD& thread = GetThread(CurrentThreadId());
|
||||
if(thread.status != THREAD_STATUS_RUNNING)
|
||||
{
|
||||
throw runtime_error("Thread isn't running.");
|
||||
@ -448,7 +509,7 @@ uint32 CIopBios::WakeupThread(uint32 threadId, bool inInterrupt)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
CLog::GetInstance().Print(LOGNAME, "%i: WakeupThread(threadId = %i);\r\n",
|
||||
m_currentThreadId, threadId);
|
||||
CurrentThreadId(), threadId);
|
||||
#endif
|
||||
|
||||
THREAD& thread = GetThread(threadId);
|
||||
@ -469,17 +530,17 @@ uint32 CIopBios::WakeupThread(uint32 threadId, bool inInterrupt)
|
||||
|
||||
uint32 CIopBios::GetCurrentThreadId()
|
||||
{
|
||||
return m_currentThreadId;
|
||||
return CurrentThreadId();
|
||||
}
|
||||
|
||||
void CIopBios::ExitCurrentThread()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
CLog::GetInstance().Print(LOGNAME, "%d : ExitCurrentThread();\r\n", m_currentThreadId);
|
||||
CLog::GetInstance().Print(LOGNAME, "%d : ExitCurrentThread();\r\n", CurrentThreadId());
|
||||
#endif
|
||||
ThreadMapType::iterator thread = GetThreadPosition(m_currentThreadId);
|
||||
ThreadMapType::iterator thread = GetThreadPosition(CurrentThreadId());
|
||||
m_threads.erase(thread);
|
||||
m_currentThreadId = -1;
|
||||
CurrentThreadId() = -1;
|
||||
m_rescheduleNeeded = true;
|
||||
}
|
||||
|
||||
@ -513,11 +574,11 @@ void CIopBios::SaveThreadContext(uint32 threadId)
|
||||
|
||||
void CIopBios::Reschedule()
|
||||
{
|
||||
if(m_currentThreadId != -1)
|
||||
if(CurrentThreadId() != -1)
|
||||
{
|
||||
SaveThreadContext(m_currentThreadId);
|
||||
SaveThreadContext(CurrentThreadId());
|
||||
//Reinsert the thread into the map
|
||||
ThreadMapType::iterator threadPosition = GetThreadPosition(m_currentThreadId);
|
||||
ThreadMapType::iterator threadPosition = GetThreadPosition(CurrentThreadId());
|
||||
THREAD thread(threadPosition->second);
|
||||
m_threads.erase(threadPosition);
|
||||
m_threads.insert(ThreadMapType::value_type(thread.priority, thread));
|
||||
@ -542,12 +603,12 @@ void CIopBios::Reschedule()
|
||||
LoadThreadContext(nextThreadId);
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if(nextThreadId != m_currentThreadId)
|
||||
if(nextThreadId != CurrentThreadId())
|
||||
{
|
||||
CLog::GetInstance().Print(LOGNAME, "Switched over to thread %i.\r\n", nextThreadId);
|
||||
}
|
||||
#endif
|
||||
m_currentThreadId = nextThreadId;
|
||||
CurrentThreadId() = nextThreadId;
|
||||
m_cpu.m_nQuota = 1;
|
||||
}
|
||||
|
||||
@ -588,7 +649,7 @@ uint32 CIopBios::GetNextReadyThread(bool checkActivateTime)
|
||||
|
||||
uint64 CIopBios::GetCurrentTime()
|
||||
{
|
||||
return m_currentTime;
|
||||
return CurrentTime();
|
||||
}
|
||||
|
||||
uint64 CIopBios::MilliSecToClock(uint32 value)
|
||||
@ -608,7 +669,7 @@ uint64 CIopBios::ClockToMicroSec(uint64 clock)
|
||||
|
||||
void CIopBios::CountTicks(uint32 ticks)
|
||||
{
|
||||
m_currentTime += ticks;
|
||||
CurrentTime() += ticks;
|
||||
}
|
||||
|
||||
CIopBios::SEMAPHORE& CIopBios::GetSemaphore(uint32 semaphoreId)
|
||||
@ -625,14 +686,14 @@ uint32 CIopBios::CreateSemaphore(uint32 initialCount, uint32 maxCount)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
CLog::GetInstance().Print(LOGNAME, "%i: CreateSemaphore(initialCount = %i, maxCount = %i);\r\n",
|
||||
m_currentThreadId, initialCount, maxCount);
|
||||
CurrentThreadId(), initialCount, maxCount);
|
||||
#endif
|
||||
|
||||
SEMAPHORE semaphore;
|
||||
memset(&semaphore, 0, sizeof(SEMAPHORE));
|
||||
semaphore.count = initialCount;
|
||||
semaphore.maxCount = maxCount;
|
||||
semaphore.id = m_nextSemaphoreId++;
|
||||
semaphore.id = NextSemaphoreId()++;
|
||||
semaphore.waitCount = 0;
|
||||
m_semaphores[semaphore.id] = semaphore;
|
||||
return semaphore.id;
|
||||
@ -642,7 +703,7 @@ uint32 CIopBios::SignalSemaphore(uint32 semaphoreId, bool inInterrupt)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
CLog::GetInstance().Print(LOGNAME, "%i: SignalSemaphore(semaphoreId = %i);\r\n",
|
||||
m_currentThreadId, semaphoreId);
|
||||
CurrentThreadId(), semaphoreId);
|
||||
#endif
|
||||
|
||||
SEMAPHORE& semaphore = GetSemaphore(semaphoreId);
|
||||
@ -683,13 +744,13 @@ uint32 CIopBios::WaitSemaphore(uint32 semaphoreId)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
CLog::GetInstance().Print(LOGNAME, "%i: WaitSemaphore(semaphoreId = %i);\r\n",
|
||||
m_currentThreadId, semaphoreId);
|
||||
CurrentThreadId(), semaphoreId);
|
||||
#endif
|
||||
|
||||
SEMAPHORE& semaphore = GetSemaphore(semaphoreId);
|
||||
if(semaphore.count == 0)
|
||||
{
|
||||
THREAD& thread = GetThread(m_currentThreadId);
|
||||
THREAD& thread = GetThread(CurrentThreadId());
|
||||
thread.status = THREAD_STATUS_WAITING;
|
||||
thread.waitSemaphore = semaphoreId;
|
||||
semaphore.waitCount++;
|
||||
@ -747,7 +808,7 @@ bool CIopBios::ReleaseIntrHandler(uint32 line)
|
||||
|
||||
uint32 CIopBios::AssembleThreadFinish(CMIPSAssembler& assembler)
|
||||
{
|
||||
uint32 address = m_baseAddress + assembler.GetProgramSize() * 4;
|
||||
uint32 address = BIOS_HANDLERS_BASE + assembler.GetProgramSize() * 4;
|
||||
assembler.ADDIU(CMIPS::V0, CMIPS::R0, 0x0666);
|
||||
assembler.SYSCALL();
|
||||
return address;
|
||||
@ -755,7 +816,7 @@ uint32 CIopBios::AssembleThreadFinish(CMIPSAssembler& assembler)
|
||||
|
||||
uint32 CIopBios::AssembleReturnFromException(CMIPSAssembler& assembler)
|
||||
{
|
||||
uint32 address = m_baseAddress + assembler.GetProgramSize() * 4;
|
||||
uint32 address = BIOS_HANDLERS_BASE + assembler.GetProgramSize() * 4;
|
||||
assembler.ADDIU(CMIPS::V0, CMIPS::R0, 0x0667);
|
||||
assembler.SYSCALL();
|
||||
return address;
|
||||
@ -763,7 +824,7 @@ uint32 CIopBios::AssembleReturnFromException(CMIPSAssembler& assembler)
|
||||
|
||||
uint32 CIopBios::AssembleIdleFunction(CMIPSAssembler& assembler)
|
||||
{
|
||||
uint32 address = m_baseAddress + assembler.GetProgramSize() * 4;
|
||||
uint32 address = BIOS_HANDLERS_BASE + assembler.GetProgramSize() * 4;
|
||||
assembler.ADDIU(CMIPS::V0, CMIPS::R0, 0x0668);
|
||||
assembler.SYSCALL();
|
||||
return address;
|
||||
@ -868,11 +929,11 @@ void CIopBios::HandleInterrupt()
|
||||
else
|
||||
{
|
||||
//Snap out of current thread
|
||||
if(m_currentThreadId != -1)
|
||||
if(CurrentThreadId() != -1)
|
||||
{
|
||||
SaveThreadContext(m_currentThreadId);
|
||||
SaveThreadContext(CurrentThreadId());
|
||||
}
|
||||
m_currentThreadId = -1;
|
||||
CurrentThreadId() = -1;
|
||||
m_cpu.m_State.nPC = handlerIterator->second.handler;
|
||||
m_cpu.m_State.nGPR[CMIPS::A0].nD0 = static_cast<int32>(handlerIterator->second.arg);
|
||||
m_cpu.m_State.nGPR[CMIPS::RA].nD0 = static_cast<int32>(m_returnFromExceptionAddress);
|
||||
|
@ -21,6 +21,12 @@
|
||||
class CIopBios : public Iop::CBiosBase
|
||||
{
|
||||
public:
|
||||
enum CONTROL_BLOCK
|
||||
{
|
||||
CONTROL_BLOCK_START = 0x10,
|
||||
CONTROL_BLOCK_END = 0x1000,
|
||||
};
|
||||
|
||||
struct THREADCONTEXT
|
||||
{
|
||||
uint32 gpr[0x20];
|
||||
@ -43,7 +49,7 @@ public:
|
||||
|
||||
typedef MipsModuleList::iterator ModuleListIterator;
|
||||
|
||||
CIopBios(uint32, uint32, CMIPS&, uint8*, uint32);
|
||||
CIopBios(uint32, CMIPS&, uint8*, uint32);
|
||||
virtual ~CIopBios();
|
||||
|
||||
void LoadAndStartModule(const char*, const char*, unsigned int);
|
||||
@ -58,6 +64,12 @@ public:
|
||||
uint64 ClockToMicroSec(uint64);
|
||||
|
||||
void Reset(Iop::CSifMan*);
|
||||
|
||||
virtual void SaveState(CZipArchiveWriter&);
|
||||
virtual void LoadState(CZipArchiveReader&);
|
||||
|
||||
bool IsIdle();
|
||||
|
||||
#ifdef DEBUGGER_INCLUDED
|
||||
void LoadDebugTags(Framework::Xml::CNode*);
|
||||
void SaveDebugTags(Framework::Xml::CNode*);
|
||||
@ -137,6 +149,11 @@ private:
|
||||
uint32 GetNextReadyThread(bool);
|
||||
void ReturnFromException();
|
||||
|
||||
uint32& NextThreadId() const;
|
||||
uint32& NextSemaphoreId() const;
|
||||
uint32& CurrentThreadId() const;
|
||||
uint64& CurrentTime() const;
|
||||
|
||||
SEMAPHORE& GetSemaphore(uint32);
|
||||
|
||||
void LoadAndStartModule(CELF&, const char*, const char*, unsigned int);
|
||||
@ -162,19 +179,16 @@ private:
|
||||
CMIPS& m_cpu;
|
||||
uint8* m_ram;
|
||||
uint32 m_ramSize;
|
||||
uint32 m_baseAddress;
|
||||
uint32 m_threadFinishAddress;
|
||||
uint32 m_returnFromExceptionAddress;
|
||||
uint32 m_idleFunctionAddress;
|
||||
uint32 m_nextThreadId;
|
||||
uint32 m_nextSemaphoreId;
|
||||
uint32 m_currentThreadId;
|
||||
uint32 m_clockFrequency;
|
||||
uint64 m_currentTime;
|
||||
|
||||
bool m_rescheduleNeeded;
|
||||
ThreadMapType m_threads;
|
||||
SemaphoreMapType m_semaphores;
|
||||
IntrHandlerMapType m_intrHandlers;
|
||||
|
||||
IopModuleMapType m_modules;
|
||||
MipsModuleList m_moduleTags;
|
||||
Iop::CSifMan* m_sifMan;
|
||||
|
@ -2,6 +2,8 @@
|
||||
#define _IOP_BIOSBASE_H_
|
||||
|
||||
#include "Types.h"
|
||||
#include "zip/ZipArchiveWriter.h"
|
||||
#include "zip/ZipArchiveReader.h"
|
||||
#ifdef DEBUGGER_INCLUDED
|
||||
#include "xml/Node.h"
|
||||
#include "../MipsModule.h"
|
||||
@ -17,6 +19,11 @@ namespace Iop
|
||||
virtual void HandleInterrupt() = 0;
|
||||
virtual void CountTicks(uint32) = 0;
|
||||
|
||||
virtual bool IsIdle() = 0;
|
||||
|
||||
virtual void SaveState(CZipArchiveWriter&) = 0;
|
||||
virtual void LoadState(CZipArchiveReader&) = 0;
|
||||
|
||||
#ifdef DEBUGGER_INCLUDED
|
||||
virtual void SaveDebugTags(Framework::Xml::CNode*) = 0;
|
||||
virtual void LoadDebugTags(Framework::Xml::CNode*) = 0;
|
||||
|
@ -12,7 +12,7 @@ void CSifManNull::SendPacket(void*, uint32)
|
||||
|
||||
}
|
||||
|
||||
void CSifManNull::SetDmaBuffer(uint8*, uint32)
|
||||
void CSifManNull::SetDmaBuffer(uint32, uint32)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace Iop
|
||||
public:
|
||||
virtual void RegisterModule(uint32, CSifModule*);
|
||||
virtual void SendPacket(void*, uint32);
|
||||
virtual void SetDmaBuffer(uint8*, uint32);
|
||||
virtual void SetDmaBuffer(uint32, uint32);
|
||||
virtual void SendCallReply(uint32, void*);
|
||||
};
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ void CSifManPs2::SendPacket(void* packet, uint32 size)
|
||||
m_sif.SendPacket(packet, size);
|
||||
}
|
||||
|
||||
void CSifManPs2::SetDmaBuffer(uint8* buffer, uint32 size)
|
||||
void CSifManPs2::SetDmaBuffer(uint32 bufferAddress, uint32 size)
|
||||
{
|
||||
m_sif.SetDmaBuffer(buffer, size);
|
||||
m_sif.SetDmaBuffer(bufferAddress, size);
|
||||
}
|
||||
|
||||
void CSifManPs2::SendCallReply(uint32 serverId, void* returnData)
|
||||
|
@ -14,7 +14,7 @@ namespace Iop
|
||||
|
||||
virtual void RegisterModule(uint32, CSifModule*);
|
||||
virtual void SendPacket(void*, uint32);
|
||||
virtual void SetDmaBuffer(uint8*, uint32);
|
||||
virtual void SetDmaBuffer(uint32, uint32);
|
||||
virtual void SendCallReply(uint32, void*);
|
||||
|
||||
private:
|
||||
|
@ -18,7 +18,7 @@ namespace Iop
|
||||
|
||||
virtual void RegisterModule(uint32, CSifModule*) = 0;
|
||||
virtual void SendPacket(void*, uint32) = 0;
|
||||
virtual void SetDmaBuffer(uint8*, uint32) = 0;
|
||||
virtual void SetDmaBuffer(uint32, uint32) = 0;
|
||||
virtual void SendCallReply(uint32, void*) = 0;
|
||||
|
||||
private:
|
||||
|
@ -73,6 +73,7 @@ void CSubSystem::SaveState(CZipArchiveWriter& archive)
|
||||
archive.InsertFile(new CMemoryStateFile(STATE_CPU, &m_cpu.m_State, sizeof(MIPSSTATE)));
|
||||
archive.InsertFile(new CMemoryStateFile(STATE_RAM, m_ram, IOP_RAM_SIZE));
|
||||
archive.InsertFile(new CMemoryStateFile(STATE_SCRATCH, m_scratchPad, IOP_SCRATCH_SIZE));
|
||||
m_bios->SaveState(archive);
|
||||
}
|
||||
|
||||
void CSubSystem::LoadState(CZipArchiveReader& archive)
|
||||
@ -80,6 +81,7 @@ void CSubSystem::LoadState(CZipArchiveReader& archive)
|
||||
archive.BeginReadFile(STATE_CPU )->Read(&m_cpu.m_State, sizeof(MIPSSTATE));
|
||||
archive.BeginReadFile(STATE_RAM )->Read(m_ram, IOP_RAM_SIZE);
|
||||
archive.BeginReadFile(STATE_SCRATCH )->Read(m_scratchPad, IOP_SCRATCH_SIZE);
|
||||
m_bios->LoadState(archive);
|
||||
}
|
||||
|
||||
void CSubSystem::Reset()
|
||||
@ -188,7 +190,7 @@ unsigned int CSubSystem::ExecuteCpu(bool singleStep)
|
||||
ticks = quota - m_executor.Execute(quota);
|
||||
assert(ticks >= 0);
|
||||
{
|
||||
if(m_cpu.m_State.nPC == 0x1018)
|
||||
if(m_bios->IsIdle())
|
||||
{
|
||||
ticks += (quota * 2);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""$(FrameworkRoot)\include";"$(ProjectDir)\..\..\Source";"$(ProjectDir)\Source""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MSVC;_CRT_SECURE_NO_WARNINGS;_PSX;_NULL_SIFMAN;DEBUGGER_INCLUDED"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MSVC;_CRT_SECURE_NO_WARNINGS;_PSX;_NULL_SIFMAN"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
@ -61,7 +61,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="comctl32.lib OpenAL32.lib"
|
||||
AdditionalDependencies="comctl32.lib winmm.lib OpenAL32.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
|
@ -7,7 +7,7 @@ using namespace std;
|
||||
#define PSF_DEVICENAME "psf"
|
||||
|
||||
CPsfBios::CPsfBios(CMIPS& cpu, uint8* ram, uint32 ramSize) :
|
||||
m_bios(0x1000, PS2::IOP_CLOCK_FREQ, cpu, ram, ramSize),
|
||||
m_bios(PS2::IOP_CLOCK_FREQ, cpu, ram, ramSize),
|
||||
m_psfDevice(new CPsfDevice())
|
||||
{
|
||||
m_bios.Reset(NULL);
|
||||
@ -48,6 +48,21 @@ void CPsfBios::CountTicks(uint32 ticks)
|
||||
m_bios.CountTicks(ticks);
|
||||
}
|
||||
|
||||
void CPsfBios::SaveState(CZipArchiveWriter& archive)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CPsfBios::LoadState(CZipArchiveReader& archive)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CPsfBios::IsIdle()
|
||||
{
|
||||
return m_bios.IsIdle();
|
||||
}
|
||||
|
||||
#ifdef DEBUGGER_INCLUDED
|
||||
|
||||
void CPsfBios::LoadDebugTags(Framework::Xml::CNode* root)
|
||||
|
@ -16,6 +16,11 @@ namespace PS2
|
||||
void HandleInterrupt();
|
||||
void CountTicks(uint32);
|
||||
|
||||
void SaveState(CZipArchiveWriter&);
|
||||
void LoadState(CZipArchiveReader&);
|
||||
|
||||
bool IsIdle();
|
||||
|
||||
#ifdef DEBUGGER_INCLUDED
|
||||
void LoadDebugTags(Framework::Xml::CNode*);
|
||||
void SaveDebugTags(Framework::Xml::CNode*);
|
||||
|
@ -110,6 +110,21 @@ void CPsxBios::LoadExe(uint8* exe)
|
||||
}
|
||||
}
|
||||
|
||||
void CPsxBios::SaveState(CZipArchiveWriter& archive)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CPsxBios::LoadState(CZipArchiveReader& archive)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CPsxBios::IsIdle()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEBUGGER_INCLUDED
|
||||
|
||||
void CPsxBios::LoadDebugTags(Framework::Xml::CNode* root)
|
||||
|
@ -17,6 +17,11 @@ public:
|
||||
|
||||
void LoadExe(uint8*);
|
||||
|
||||
void SaveState(CZipArchiveWriter&);
|
||||
void LoadState(CZipArchiveReader&);
|
||||
|
||||
bool IsIdle();
|
||||
|
||||
#ifdef DEBUGGER_INCLUDED
|
||||
void LoadDebugTags(Framework::Xml::CNode*);
|
||||
void SaveDebugTags(Framework::Xml::CNode*);
|
||||
|
Loading…
Reference in New Issue
Block a user