mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-22 22:04:33 +01:00
Merge branch 'master' into armjit-fpu
Conflicts: Core/MIPS/ARM/ArmCompFPU.cpp Core/MIPS/x86/CompFPU.cpp
This commit is contained in:
commit
3a11b030d6
66 files changed
+2249
-324
No files matched your search
@@ -123,6 +123,12 @@ CISOFileBlockDevice::~CISOFileBlockDevice()
|
||||
|
||||
bool CISOFileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr)
|
||||
{
|
||||
if ((u32)blockNumber >= numBlocks)
|
||||
{
|
||||
memset(outPtr, 0, 2048);
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 idx = index[blockNumber];
|
||||
u32 idx2 = index[blockNumber+1];
|
||||
u8 inbuffer[4096]; //too big
|
||||
@@ -153,7 +159,7 @@ bool CISOFileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr)
|
||||
if(inflateInit2(&z, -15) != Z_OK)
|
||||
{
|
||||
ERROR_LOG(LOADER, "deflateInit ERROR : %s\n", (z.msg) ? z.msg : "???");
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
z.avail_in = readSize;
|
||||
z.next_out = outPtr;
|
||||
@@ -165,14 +171,17 @@ bool CISOFileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr)
|
||||
//if (status != Z_OK)
|
||||
{
|
||||
ERROR_LOG(LOADER, "block %d:inflate : %s[%d]\n", blockNumber, (z.msg) ? z.msg : "error", status);
|
||||
inflateEnd(&z);
|
||||
return 1;
|
||||
}
|
||||
int cmp_size = blockSize - z.avail_out;
|
||||
if (cmp_size != (int)blockSize)
|
||||
{
|
||||
ERROR_LOG(LOADER, "block %d : block size error %d != %d\n", blockNumber, cmp_size, blockSize);
|
||||
return 1;
|
||||
inflateEnd(&z);
|
||||
return false;
|
||||
}
|
||||
inflateEnd(&z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -31,9 +31,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
#undef DeleteFile
|
||||
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
|
||||
static bool FixFilenameCase(const std::string &path, std::string &filename)
|
||||
@@ -248,7 +245,7 @@ bool DirectoryFileSystem::RenameFile(const std::string &from, const std::string
|
||||
return retValue;
|
||||
}
|
||||
|
||||
bool DirectoryFileSystem::DeleteFile(const std::string &filename) {
|
||||
bool DirectoryFileSystem::RemoveFile(const std::string &filename) {
|
||||
std::string fullName = GetLocalPath(filename);
|
||||
#ifdef _WIN32
|
||||
bool retValue = (::DeleteFileA(fullName.c_str()) == TRUE);
|
||||
@@ -266,7 +263,7 @@ bool DirectoryFileSystem::DeleteFile(const std::string &filename) {
|
||||
fullName = GetLocalPath(fullName);
|
||||
|
||||
#ifdef _WIN32
|
||||
retValue = (::DeleteFile(fullName.c_str()) == TRUE);
|
||||
retValue = (::DeleteFileA(fullName.c_str()) == TRUE);
|
||||
#else
|
||||
retValue = (0 == unlink(fullName.c_str()));
|
||||
#endif
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
bool MkDir(const std::string &dirname);
|
||||
bool RmDir(const std::string &dirname);
|
||||
bool RenameFile(const std::string &from, const std::string &to);
|
||||
bool DeleteFile(const std::string &filename);
|
||||
bool RemoveFile(const std::string &filename);
|
||||
bool GetHostPath(const std::string &inpath, std::string &outpath);
|
||||
|
||||
private:
|
||||
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
virtual bool MkDir(const std::string &dirname) = 0;
|
||||
virtual bool RmDir(const std::string &dirname) = 0;
|
||||
virtual bool RenameFile(const std::string &from, const std::string &to) = 0;
|
||||
virtual bool DeleteFile(const std::string &filename) = 0;
|
||||
virtual bool RemoveFile(const std::string &filename) = 0;
|
||||
virtual bool GetHostPath(const std::string &inpath, std::string &outpath) = 0;
|
||||
};
|
||||
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
virtual bool MkDir(const std::string &dirname) {return false;}
|
||||
virtual bool RmDir(const std::string &dirname) {return false;}
|
||||
virtual bool RenameFile(const std::string &from, const std::string &to) {return false;}
|
||||
virtual bool DeleteFile(const std::string &filename) {return false;}
|
||||
virtual bool RemoveFile(const std::string &filename) {return false;}
|
||||
virtual bool GetHostPath(const std::string &inpath, std::string &outpath) {return false;}
|
||||
};
|
||||
|
||||
|
||||
@@ -178,80 +178,74 @@ ISOFileSystem::~ISOFileSystem()
|
||||
|
||||
void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root)
|
||||
{
|
||||
u8 buffer[2048];
|
||||
int offset = 0;
|
||||
u32 secnum = startsector;
|
||||
|
||||
u8 theSector[2048];
|
||||
blockDevice->ReadBlock(secnum, theSector);
|
||||
|
||||
while (secnum < (dirsize/2048 + startsector))
|
||||
for (u32 secnum = startsector, endsector = dirsize/2048 + startsector; secnum < endsector; ++secnum)
|
||||
{
|
||||
DirectoryEntry &dir = *((DirectoryEntry *)buffer);
|
||||
u8 sz = theSector[offset];
|
||||
if (sz == 0) // NOT the correct way
|
||||
goto nextblock; //done
|
||||
u8 theSector[2048];
|
||||
blockDevice->ReadBlock(secnum, theSector);
|
||||
|
||||
memcpy(&dir, theSector + offset, sz);
|
||||
|
||||
buffer[2047]=0;
|
||||
offset += dir.size;
|
||||
if (offset >= 2048)
|
||||
for (int offset = 0; offset < 2048; )
|
||||
{
|
||||
nextblock:
|
||||
offset=0;
|
||||
secnum++;
|
||||
blockDevice->ReadBlock(secnum, theSector);
|
||||
memcpy(&dir, theSector + offset, sz);
|
||||
}
|
||||
bool isFile = (dir.flags & 2) ? false : true;
|
||||
DirectoryEntry &dir = *(DirectoryEntry *)&theSector[offset];
|
||||
u8 sz = theSector[offset];
|
||||
|
||||
int fnLength = dir.identifierLength;
|
||||
// Nothing left in this sector. There might be more in the next one.
|
||||
if (sz == 0)
|
||||
break;
|
||||
|
||||
char name[256];
|
||||
for (int i = 0; i < fnLength; i++)
|
||||
name[i] = buffer[33+i] ? buffer[33+i] : '.';
|
||||
name[fnLength] = '\0';
|
||||
|
||||
bool relative = false;
|
||||
|
||||
if (!strcmp(name, ".")) // "." record
|
||||
{
|
||||
relative = true;
|
||||
}
|
||||
|
||||
if (strlen(name) == 1 && name[0] == '\x01') // ".." record
|
||||
{
|
||||
strcpy(name,"..");
|
||||
relative = true;
|
||||
}
|
||||
|
||||
TreeEntry *e = new TreeEntry;
|
||||
e->name = name;
|
||||
e->size = dir.dataLengthLE;
|
||||
e->startingPosition = dir.firstDataSectorLE * 2048;
|
||||
e->isDirectory = !isFile;
|
||||
e->flags = dir.flags;
|
||||
e->isBlockSectorMode = false;
|
||||
e->parent = root;
|
||||
|
||||
// Let's not excessively spam the log - I commented this line out.
|
||||
//DEBUG_LOG(FILESYS, "%s: %s %08x %08x %i", e->isDirectory?"D":"F", name, dir.firstDataSectorLE, e->startingPosition, e->startingPosition);
|
||||
|
||||
if (e->isDirectory && !relative)
|
||||
{
|
||||
if (dir.firstDataSectorLE == startsector)
|
||||
const int IDENTIFIER_OFFSET = 33;
|
||||
if (offset + IDENTIFIER_OFFSET + dir.identifierLength > 2048)
|
||||
{
|
||||
ERROR_LOG(FILESYS, "WARNING: Appear to have a recursive file system, breaking recursion");
|
||||
ERROR_LOG(FILESYS, "Directory entry crosses sectors, corrupt iso?");
|
||||
break;
|
||||
}
|
||||
|
||||
offset += dir.size;
|
||||
|
||||
bool isFile = (dir.flags & 2) ? false : true;
|
||||
bool relative;
|
||||
int fnLength = dir.identifierLength;
|
||||
|
||||
TreeEntry *e = new TreeEntry();
|
||||
if (dir.identifierLength == 1 && (dir.firstIdChar == '\x00' || dir.firstIdChar == '.'))
|
||||
{
|
||||
e->name = ".";
|
||||
relative = true;
|
||||
}
|
||||
else if (dir.identifierLength == 1 && dir.firstIdChar == '\x01')
|
||||
{
|
||||
e->name = "..";
|
||||
relative = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadDirectory(dir.firstDataSectorLE, dir.dataLengthLE, e);
|
||||
e->name = std::string((char *)&dir.firstIdChar, dir.identifierLength);
|
||||
relative = false;
|
||||
}
|
||||
}
|
||||
root->children.push_back(e);
|
||||
}
|
||||
|
||||
e->size = dir.dataLengthLE;
|
||||
e->startingPosition = dir.firstDataSectorLE * 2048;
|
||||
e->isDirectory = !isFile;
|
||||
e->flags = dir.flags;
|
||||
e->isBlockSectorMode = false;
|
||||
e->parent = root;
|
||||
|
||||
// Let's not excessively spam the log - I commented this line out.
|
||||
//DEBUG_LOG(FILESYS, "%s: %s %08x %08x %i", e->isDirectory?"D":"F", e->name.c_str(), dir.firstDataSectorLE, e->startingPosition, e->startingPosition);
|
||||
|
||||
if (e->isDirectory && !relative)
|
||||
{
|
||||
if (dir.firstDataSectorLE == startsector)
|
||||
{
|
||||
ERROR_LOG(FILESYS, "WARNING: Appear to have a recursive file system, breaking recursion");
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadDirectory(dir.firstDataSectorLE, dir.dataLengthLE, e);
|
||||
}
|
||||
}
|
||||
root->children.push_back(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ISOFileSystem::TreeEntry *ISOFileSystem::GetFromPath(std::string path, bool catchError)
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
virtual bool MkDir(const std::string &dirname) {return false;}
|
||||
virtual bool RmDir(const std::string &dirname) {return false;}
|
||||
virtual bool RenameFile(const std::string &from, const std::string &to) {return false;}
|
||||
virtual bool DeleteFile(const std::string &filename) {return false;}
|
||||
virtual bool RemoveFile(const std::string &filename) {return false;}
|
||||
|
||||
private:
|
||||
struct TreeEntry
|
||||
|
||||
@@ -363,13 +363,13 @@ bool MetaFileSystem::RenameFile(const std::string &from, const std::string &to)
|
||||
}
|
||||
}
|
||||
|
||||
bool MetaFileSystem::DeleteFile(const std::string &filename)
|
||||
bool MetaFileSystem::RemoveFile(const std::string &filename)
|
||||
{
|
||||
std::string of;
|
||||
IFileSystem *system;
|
||||
if (MapFilePath(filename, of, &system))
|
||||
{
|
||||
return system->DeleteFile(of);
|
||||
return system->RemoveFile(of);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
virtual bool MkDir(const std::string &dirname);
|
||||
virtual bool RmDir(const std::string &dirname);
|
||||
virtual bool RenameFile(const std::string &from, const std::string &to);
|
||||
virtual bool DeleteFile(const std::string &filename);
|
||||
virtual bool RemoveFile(const std::string &filename);
|
||||
|
||||
// TODO: void IoCtl(...)
|
||||
|
||||
|
||||
+15
-3
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "Thread.h"
|
||||
#include "../Core/CoreTiming.h"
|
||||
#include "../Core/CoreParameter.h"
|
||||
#include "../MIPS/MIPS.h"
|
||||
#include "../HLE/HLE.h"
|
||||
#include "sceAudio.h"
|
||||
@@ -78,7 +79,7 @@ static int hCountTotal; //unused
|
||||
static int vCount;
|
||||
static int isVblank;
|
||||
static bool hasSetMode;
|
||||
double lastFrameTime;
|
||||
static double lastFrameTime;
|
||||
|
||||
std::vector<WaitVBlankInfo> vblankWaitingThreads;
|
||||
|
||||
@@ -269,12 +270,11 @@ void hleEnterVblank(u64 userdata, int cyclesLate) {
|
||||
host->EndFrame();
|
||||
|
||||
#ifdef _WIN32
|
||||
static double lastFrameTime = 0.0;
|
||||
// Best place to throttle the frame rate on non vsynced platforms is probably here. Let's try it.
|
||||
time_update();
|
||||
if (lastFrameTime == 0.0)
|
||||
lastFrameTime = time_now_d();
|
||||
if (!GetAsyncKeyState(VK_TAB)) {
|
||||
if (!GetAsyncKeyState(VK_TAB) && !PSP_CoreParameter().headLess) {
|
||||
while (time_now_d() < lastFrameTime + 1.0 / 60.0) {
|
||||
Common::SleepCurrentThread(1);
|
||||
time_update();
|
||||
@@ -357,6 +357,18 @@ u32 sceDisplaySetFramebuf() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool __DisplayGetFramebuf(u8 **topaddr, u32 *linesize, u32 *pixelFormat, int mode) {
|
||||
const FrameBufferState &fbState = mode == 1 ? latchedFramebuf : framebuf;
|
||||
if (topaddr != NULL)
|
||||
*topaddr = Memory::GetPointer(fbState.topaddr);
|
||||
if (linesize != NULL)
|
||||
*linesize = fbState.pspFramebufLinesize;
|
||||
if (pixelFormat != NULL)
|
||||
*pixelFormat = fbState.pspFramebufFormat;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 sceDisplayGetFramebuf(u32 topaddrPtr, u32 linesizePtr, u32 pixelFormatPtr, int mode) {
|
||||
const FrameBufferState &fbState = mode == 1 ? latchedFramebuf : framebuf;
|
||||
DEBUG_LOG(HLE,"sceDisplayGetFramebuf(*%08x = %08x, *%08x = %08x, *%08x = %08x, %i)",
|
||||
|
||||
@@ -26,6 +26,9 @@ void Register_sceDisplay();
|
||||
// will return true once after every end-of-frame.
|
||||
bool __DisplayFrameDone();
|
||||
|
||||
// Get information about the current framebuffer.
|
||||
bool __DisplayGetFramebuf(u8 **topaddr, u32 *linesize, u32 *pixelFormat, int mode);
|
||||
|
||||
typedef void (*VblankCallback)();
|
||||
// Listen for vblank events. Only register during init.
|
||||
void __DisplayListenVblank(VblankCallback callback);
|
||||
+9
-4
@@ -33,6 +33,8 @@ struct GeInterruptData
|
||||
{
|
||||
int listid;
|
||||
u32 pc;
|
||||
u32 subIntrBase;
|
||||
u16 subIntrToken;
|
||||
};
|
||||
|
||||
static std::list<GeInterruptData> ge_pending_cb;
|
||||
@@ -50,20 +52,21 @@ public:
|
||||
if (dl == NULL)
|
||||
{
|
||||
WARN_LOG(HLE, "Unable to run GE interrupt: list doesn't exist: %d", intrdata.listid);
|
||||
return false;
|
||||
// TODO: Use dl instead of just saving everything instead?
|
||||
//return false;
|
||||
}
|
||||
|
||||
gpu->InterruptStart();
|
||||
|
||||
u32 cmd = Memory::ReadUnchecked_U32(intrdata.pc) >> 24;
|
||||
int subintr = dl->subIntrBase | (cmd == GE_CMD_FINISH ? PSP_GE_SUBINTR_FINISH : PSP_GE_SUBINTR_SIGNAL);
|
||||
int subintr = intrdata.subIntrBase | (cmd == GE_CMD_FINISH ? PSP_GE_SUBINTR_FINISH : PSP_GE_SUBINTR_SIGNAL);
|
||||
SubIntrHandler* handler = get(subintr);
|
||||
|
||||
if(handler != NULL)
|
||||
{
|
||||
DEBUG_LOG(CPU, "Entering interrupt handler %08x", handler->handlerAddress);
|
||||
currentMIPS->pc = handler->handlerAddress;
|
||||
u32 data = dl->subIntrToken;
|
||||
u32 data = intrdata.subIntrToken;
|
||||
currentMIPS->r[MIPS_REG_A0] = data & 0xFFFF;
|
||||
currentMIPS->r[MIPS_REG_A1] = handler->handlerArg;
|
||||
currentMIPS->r[MIPS_REG_A2] = sceKernelGetCompiledSdkVersion() <= 0x02000010 ? 0 : intrdata.pc + 4;
|
||||
@@ -109,11 +112,13 @@ void __GeShutdown()
|
||||
|
||||
}
|
||||
|
||||
void __GeTriggerInterrupt(int listid, u32 pc)
|
||||
void __GeTriggerInterrupt(int listid, u32 pc, u32 subIntrBase, u16 subIntrToken)
|
||||
{
|
||||
GeInterruptData intrdata;
|
||||
intrdata.listid = listid;
|
||||
intrdata.pc = pc;
|
||||
intrdata.subIntrBase = subIntrBase;
|
||||
intrdata.subIntrToken = subIntrToken;
|
||||
ge_pending_cb.push_back(intrdata);
|
||||
__TriggerInterrupt(PSP_INTR_HLE, PSP_GE_INTR, PSP_INTR_SUB_NONE);
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ void Register_sceGe_user();
|
||||
void __GeInit();
|
||||
void __GeDoState(PointerWrap &p);
|
||||
void __GeShutdown();
|
||||
void __GeTriggerInterrupt(int listid, u32 pc);
|
||||
void __GeTriggerInterrupt(int listid, u32 pc, u32 subIntrBase, u16 subIntrToken);
|
||||
bool __GeHasPendingInterrupt();
|
||||
|
||||
|
||||
|
||||
+21
-8
@@ -17,7 +17,6 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#undef DeleteFile
|
||||
#endif
|
||||
|
||||
#include "../Config.h"
|
||||
@@ -38,6 +37,9 @@
|
||||
#include "sceKernelMemory.h"
|
||||
#include "sceKernelThread.h"
|
||||
|
||||
// For headless screenshots.
|
||||
#include "sceDisplay.h"
|
||||
|
||||
#define ERROR_ERRNO_FILE_NOT_FOUND 0x80010002
|
||||
|
||||
#define ERROR_MEMSTICK_DEVCTL_BAD_PARAMS 0x80220081
|
||||
@@ -144,9 +146,10 @@ public:
|
||||
p.Do(callbackID);
|
||||
p.Do(callbackArg);
|
||||
p.Do(asyncResult);
|
||||
p.Do(closePending);
|
||||
p.Do(pendingAsyncResult);
|
||||
p.Do(sectorBlockMode);
|
||||
p.Do(closePending);
|
||||
p.Do(info);
|
||||
p.Do(openMode);
|
||||
p.DoMarker("File");
|
||||
}
|
||||
@@ -549,7 +552,7 @@ u32 sceIoRemove(const char *filename) {
|
||||
if(!pspFileSystem.GetFileInfo(filename).exists)
|
||||
return ERROR_ERRNO_FILE_NOT_FOUND;
|
||||
|
||||
pspFileSystem.DeleteFile(filename);
|
||||
pspFileSystem.RemoveFile(filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -782,6 +785,15 @@ u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 outPtr,
|
||||
SaveState::Verify();
|
||||
// TODO: Maybe save/load to a file just to be sure?
|
||||
return 0;
|
||||
|
||||
case 0x20: // EMULATOR_DEVCTL__EMIT_SCREENSHOT
|
||||
u8 *topaddr;
|
||||
u32 linesize, pixelFormat;
|
||||
|
||||
__DisplayGetFramebuf(&topaddr, &linesize, &pixelFormat, 0);
|
||||
// TODO: Convert based on pixel format / mode / something?
|
||||
host->SendDebugScreenshot(topaddr, linesize, 272);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ERROR_LOG(HLE, "sceIoDevCtl: UNKNOWN PARAMETERS");
|
||||
@@ -1019,26 +1031,27 @@ u32 sceIoDread(int id, u32 dirent_addr) {
|
||||
u32 error;
|
||||
DirListing *dir = kernelObjects.Get<DirListing>(id, error);
|
||||
if (dir) {
|
||||
SceIoDirEnt *entry = (SceIoDirEnt*) Memory::GetPointer(dirent_addr);
|
||||
|
||||
if (dir->index == (int) dir->listing.size()) {
|
||||
DEBUG_LOG(HLE, "sceIoDread( %d %08x ) - end of the line", id, dirent_addr);
|
||||
entry->d_name[0] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
PSPFileInfo &info = dir->listing[dir->index];
|
||||
|
||||
SceIoDirEnt *entry = (SceIoDirEnt*) Memory::GetPointer(dirent_addr);
|
||||
|
||||
__IoGetStat(&entry->d_stat, info);
|
||||
|
||||
strncpy(entry->d_name, info.name.c_str(), 256);
|
||||
entry->d_name[255] = '\0';
|
||||
entry->d_private = 0xC0DEBABE;
|
||||
DEBUG_LOG(HLE, "sceIoDread( %d %08x ) = %s", id, dirent_addr, entry->d_name);
|
||||
|
||||
dir->index++;
|
||||
return (u32)(dir->listing.size() - dir->index + 1);
|
||||
return 1;
|
||||
} else {
|
||||
DEBUG_LOG(HLE, "sceIoDread - invalid listing %i, error %08x", id, error);
|
||||
return -1; // TODO
|
||||
return SCE_KERNEL_ERROR_BADF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@ void __KernelDoState(PointerWrap &p)
|
||||
p.DoMarker("KernelObjects");
|
||||
|
||||
__InterruptsDoState(p);
|
||||
// Memory needs to be after kernel objects, which may free kernel memory.
|
||||
__KernelMemoryDoState(p);
|
||||
__KernelThreadingDoState(p);
|
||||
__KernelAlarmDoState(p);
|
||||
@@ -589,7 +590,7 @@ const HLEFunction ThreadManForUser[] =
|
||||
{0x75156e8f,sceKernelResumeThread,"sceKernelResumeThread"},
|
||||
{0x3ad58b8c,&WrapU_V<sceKernelSuspendDispatchThread>,"sceKernelSuspendDispatchThread"},
|
||||
{0x27e22ec2,&WrapU_U<sceKernelResumeDispatchThread>,"sceKernelResumeDispatchThread"},
|
||||
{0x912354a7,sceKernelRotateThreadReadyQueue,"sceKernelRotateThreadReadyQueue"},
|
||||
{0x912354a7,&WrapI_I<sceKernelRotateThreadReadyQueue>,"sceKernelRotateThreadReadyQueue"},
|
||||
{0x9ACE131E,sceKernelSleepThread,"sceKernelSleepThread"},
|
||||
{0x82826f70,sceKernelSleepThreadCB,"sceKernelSleepThreadCB"},
|
||||
{0xF475845D,&WrapI_IUU<sceKernelStartThread>,"sceKernelStartThread"},
|
||||
|
||||
@@ -446,16 +446,17 @@ int g_inCbCount = 0;
|
||||
// Normally, the same as currentThread. In an interrupt, remembers the callback's thread id.
|
||||
SceUID currentCallbackThreadID = 0;
|
||||
int readyCallbacksCount = 0;
|
||||
SceUID currentThread;
|
||||
SceUID currentThread = 0;
|
||||
u32 idleThreadHackAddr;
|
||||
u32 threadReturnHackAddr;
|
||||
u32 cbReturnHackAddr;
|
||||
u32 intReturnHackAddr;
|
||||
std::vector<ThreadCallback> threadEndListeners;
|
||||
|
||||
typedef std::vector<SceUID> ThreadList;
|
||||
// Lists all thread ids that aren't deleted/etc.
|
||||
ThreadList threadqueue;
|
||||
std::vector<SceUID> threadqueue;
|
||||
|
||||
typedef std::list<SceUID> ThreadList;
|
||||
// Lists only ready thread ids.
|
||||
std::map<u32, ThreadList> threadReadyQueue;
|
||||
|
||||
@@ -657,30 +658,23 @@ void __KernelFireThreadEnd(SceUID threadID)
|
||||
}
|
||||
|
||||
// TODO: Use __KernelChangeThreadState instead? It has other affects...
|
||||
void __KernelChangeReadyState(Thread *thread, SceUID threadID, bool ready, bool atStart = false)
|
||||
void __KernelChangeReadyState(Thread *thread, SceUID threadID, bool ready)
|
||||
{
|
||||
int prio = thread->nt.currentPriority;
|
||||
|
||||
if (thread->isReady())
|
||||
{
|
||||
if (!ready)
|
||||
threadReadyQueue[prio].erase(std::remove(threadReadyQueue[prio].begin(), threadReadyQueue[prio].end(), threadID), threadReadyQueue[prio].end());
|
||||
threadReadyQueue[prio].remove(threadID);
|
||||
}
|
||||
else if (ready)
|
||||
{
|
||||
if (atStart)
|
||||
{
|
||||
size_t oldSize = threadReadyQueue[prio].size();
|
||||
threadReadyQueue[prio].resize(oldSize + 1);
|
||||
if (oldSize > 0)
|
||||
memmove(&threadReadyQueue[prio][1], &threadReadyQueue[prio][0], oldSize * sizeof(SceUID));
|
||||
threadReadyQueue[prio][0] = threadID;
|
||||
}
|
||||
if (thread->isRunning())
|
||||
threadReadyQueue[prio].push_front(threadID);
|
||||
else
|
||||
threadReadyQueue[prio].push_back(threadID);
|
||||
thread->nt.status = THREADSTATUS_READY;
|
||||
}
|
||||
|
||||
thread->nt.status = THREADSTATUS_READY;
|
||||
}
|
||||
|
||||
void __KernelChangeReadyState(SceUID threadID, bool ready)
|
||||
@@ -1130,7 +1124,7 @@ void __KernelRemoveFromThreadQueue(SceUID threadID)
|
||||
{
|
||||
int prio = __KernelGetThreadPrio(threadID);
|
||||
if (prio != 0)
|
||||
threadReadyQueue[prio].erase(std::remove(threadReadyQueue[prio].begin(), threadReadyQueue[prio].end(), threadID), threadReadyQueue[prio].end());
|
||||
threadReadyQueue[prio].remove(threadID);
|
||||
|
||||
threadqueue.erase(std::remove(threadqueue.begin(), threadqueue.end(), threadID), threadqueue.end());
|
||||
}
|
||||
@@ -1168,7 +1162,7 @@ Thread *__KernelNextThread() {
|
||||
{
|
||||
if (!it->second.empty())
|
||||
{
|
||||
bestThread = it->second[0];
|
||||
bestThread = it->second.front();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1182,10 +1176,6 @@ Thread *__KernelNextThread() {
|
||||
|
||||
void __KernelReSchedule(const char *reason)
|
||||
{
|
||||
// TODO: Not sure if this is correct?
|
||||
if (__GetCurrentThread() && __GetCurrentThread()->isRunning())
|
||||
__KernelChangeReadyState(currentThread, true);
|
||||
|
||||
// cancel rescheduling when in interrupt or callback, otherwise everything will be fucked up
|
||||
if (__IsInInterrupt() || __KernelInCallback())
|
||||
{
|
||||
@@ -1208,6 +1198,10 @@ void __KernelReSchedule(const char *reason)
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Not sure if this is correct? Probably should remove.
|
||||
if (__GetCurrentThread() && __GetCurrentThread()->isRunning())
|
||||
__KernelChangeReadyState(currentThread, true);
|
||||
|
||||
retry:
|
||||
Thread *nextThread = __KernelNextThread();
|
||||
|
||||
@@ -1361,8 +1355,11 @@ void __KernelSetupRootThread(SceUID moduleID, int args, const char *argp, int pr
|
||||
Thread *thread = __KernelCreateThread(id, moduleID, "root", currentMIPS->pc, prio, stacksize, attr);
|
||||
__KernelResetThread(thread);
|
||||
|
||||
Thread *prevThread = __GetCurrentThread();
|
||||
if (prevThread && prevThread->isRunning())
|
||||
__KernelChangeReadyState(currentThread, true);
|
||||
currentThread = id;
|
||||
__KernelChangeReadyState(thread, id, true); // do not schedule
|
||||
thread->nt.status = THREADSTATUS_RUNNING; // do not schedule
|
||||
|
||||
strcpy(thread->nt.name, "root");
|
||||
|
||||
@@ -1439,7 +1436,6 @@ int sceKernelStartThread(SceUID threadToStartID, u32 argSize, u32 argBlockPtr)
|
||||
threadToStartID,argSize,argBlockPtr);
|
||||
|
||||
__KernelResetThread(startThread);
|
||||
__KernelChangeReadyState(startThread, threadToStartID, true, true);
|
||||
|
||||
u32 sp = startThread->context.r[MIPS_REG_SP];
|
||||
if (argBlockPtr && argSize > 0)
|
||||
@@ -1462,7 +1458,14 @@ int sceKernelStartThread(SceUID threadToStartID, u32 argSize, u32 argBlockPtr)
|
||||
WARN_LOG(HLE,"sceKernelStartThread : had NULL arg");
|
||||
}
|
||||
|
||||
hleReSchedule("thread started");
|
||||
Thread *cur = __GetCurrentThread();
|
||||
// Smaller is better for priority. Only switch if the new thread is better.
|
||||
if (cur && cur->nt.currentPriority > startThread->nt.currentPriority)
|
||||
{
|
||||
__KernelChangeReadyState(currentThread, true);
|
||||
hleReSchedule("thread started");
|
||||
}
|
||||
__KernelChangeReadyState(startThread, threadToStartID, true);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
@@ -1600,10 +1603,39 @@ u32 sceKernelResumeDispatchThread(u32 suspended)
|
||||
return oldDispatchSuspended;
|
||||
}
|
||||
|
||||
void sceKernelRotateThreadReadyQueue()
|
||||
int sceKernelRotateThreadReadyQueue(int priority)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceKernelRotateThreadReadyQueue : rescheduling");
|
||||
hleReSchedule("rotatethreadreadyqueue");
|
||||
DEBUG_LOG(HLE, "sceKernelRotateThreadReadyQueue(%x)", priority);
|
||||
|
||||
Thread *cur = __GetCurrentThread();
|
||||
|
||||
// 0 is special, it means "my current priority."
|
||||
if (priority == 0)
|
||||
priority = cur->nt.currentPriority;
|
||||
|
||||
if (priority <= 0x07 || priority > 0x77)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_PRIORITY;
|
||||
|
||||
if (!threadReadyQueue[priority].empty())
|
||||
{
|
||||
// In other words, yield to everyone else.
|
||||
if (cur->nt.currentPriority == priority)
|
||||
{
|
||||
threadReadyQueue[priority].push_back(currentThread);
|
||||
cur->nt.status = THREADSTATUS_READY;
|
||||
}
|
||||
// Yield the next thread of this priority to all other threads of same priority.
|
||||
else if (threadReadyQueue[priority].size() > 1)
|
||||
{
|
||||
SceUID first = threadReadyQueue[priority].front();
|
||||
threadReadyQueue[priority].pop_front();
|
||||
threadReadyQueue[priority].push_back(first);
|
||||
}
|
||||
|
||||
hleReSchedule("rotatethreadreadyqueue");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelDeleteThread(int threadHandle)
|
||||
@@ -2257,15 +2289,15 @@ void __KernelSwitchContext(Thread *target, const char *reason)
|
||||
oldName = cur->GetName();
|
||||
|
||||
if (cur->isRunning())
|
||||
{
|
||||
__KernelChangeReadyState(cur, oldUID, false);
|
||||
cur->nt.status = (cur->nt.status | THREADSTATUS_READY) & ~THREADSTATUS_RUNNING;
|
||||
}
|
||||
__KernelChangeReadyState(cur, oldUID, true);
|
||||
}
|
||||
|
||||
currentThread = target->GetUID();
|
||||
if (target && target->isRunning())
|
||||
__KernelChangeReadyState(target, currentThread, true);
|
||||
if (target)
|
||||
{
|
||||
__KernelChangeReadyState(target, currentThread, false);
|
||||
target->nt.status = (target->nt.status | THREADSTATUS_RUNNING) & ~THREADSTATUS_READY;
|
||||
}
|
||||
|
||||
__KernelLoadContext(&target->context);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ u32 sceKernelReferThreadStatus(u32 uid, u32 statusPtr);
|
||||
u32 sceKernelReferThreadRunStatus(u32 uid, u32 statusPtr);
|
||||
int sceKernelReleaseWaitThread(SceUID threadID);
|
||||
void sceKernelChangeCurrentThreadAttr();
|
||||
void sceKernelRotateThreadReadyQueue();
|
||||
int sceKernelRotateThreadReadyQueue(int priority);
|
||||
void sceKernelCheckThreadStack();
|
||||
void sceKernelSuspendThread();
|
||||
void sceKernelResumeThread();
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
|
||||
// Used for headless.
|
||||
virtual void SendDebugOutput(const std::string &output) {}
|
||||
virtual void SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) {}
|
||||
};
|
||||
|
||||
extern Host *host;
|
||||
@@ -277,6 +277,12 @@ namespace MIPSComp
|
||||
}
|
||||
}
|
||||
|
||||
void Jit::Comp_Special3(u32 op)
|
||||
{
|
||||
// ext, ins
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
void Jit::Comp_Allegrex(u32 op)
|
||||
{
|
||||
DISABLE
|
||||
|
||||
@@ -83,6 +83,10 @@ void Jit::Comp_FPULS(u32 op)
|
||||
}
|
||||
}
|
||||
|
||||
void Jit::Comp_FPUComp(u32 op) {
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
void Jit::Comp_FPU2op(u32 op)
|
||||
{
|
||||
DISABLE
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
#define _POS ((op>>6 ) & 0x1F)
|
||||
#define _SIZE ((op>>11 ) & 0x1F)
|
||||
|
||||
#define OLDD Comp_Generic(op); return;
|
||||
#define DISABLE Comp_Generic(op); return;
|
||||
|
||||
namespace MIPSComp
|
||||
{
|
||||
|
||||
@@ -29,4 +29,14 @@ namespace MIPSComp
|
||||
{
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
void Jit::Comp_Mftv(u32 op)
|
||||
{
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
void Jit::Comp_SV(u32 op) {
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -291,6 +291,7 @@ void Jit::LogBlockNumber()
|
||||
INFO_LOG(CPU, "Block number: %i", blocks.GetNumBlocks() - 1);
|
||||
}
|
||||
|
||||
void Jit::Comp_DoNothing(u32 op) { }
|
||||
|
||||
#define _RS ((op>>21) & 0x1F)
|
||||
#define _RT ((op>>16) & 0x1F)
|
||||
|
||||
@@ -87,6 +87,7 @@ public:
|
||||
void Comp_RelBranchRI(u32 op);
|
||||
void Comp_FPUBranch(u32 op);
|
||||
void Comp_FPULS(u32 op);
|
||||
void Comp_FPUComp(u32 op);
|
||||
void Comp_Jump(u32 op);
|
||||
void Comp_JumpReg(u32 op);
|
||||
void Comp_Syscall(u32 op);
|
||||
@@ -97,13 +98,18 @@ public:
|
||||
void Comp_ShiftType(u32 op);
|
||||
void Comp_Allegrex(u32 op);
|
||||
void Comp_VBranch(u32 op);
|
||||
void Comp_VDot(u32 op);
|
||||
void Comp_MulDivType(u32 op);
|
||||
void Comp_Special3(u32 op);
|
||||
|
||||
void Comp_FPU3op(u32 op);
|
||||
void Comp_FPU2op(u32 op);
|
||||
void Comp_mxc1(u32 op);
|
||||
void Comp_Mftv(u32 op);
|
||||
void Comp_VDot(u32 op);
|
||||
|
||||
void Comp_DoNothing(u32 op);
|
||||
|
||||
void Comp_SV(u32 op);
|
||||
void Comp_SVQ(u32 op);
|
||||
|
||||
ArmJitBlockCache *GetBlockCache() { return &blocks; }
|
||||
|
||||
+25
-25
@@ -147,7 +147,7 @@ const MIPSInstruction tableImmediate[64] = //xxxxxx .....
|
||||
//48
|
||||
INSTR("ll", &Jit::Comp_Generic, Dis_Generic, Int_StoreSync, 0),
|
||||
INSTR("lwc1", &Jit::Comp_FPULS, Dis_FPULS, Int_FPULS, IN_RT|IN_RS_ADDR),
|
||||
INSTR("lv.s", &Jit::Comp_Generic, Dis_SV, Int_SV, IS_VFPU),
|
||||
INSTR("lv.s", &Jit::Comp_SV, Dis_SV, Int_SV, IS_VFPU),
|
||||
{-2}, // HIT THIS IN WIPEOUT
|
||||
{VFPU4Jump},
|
||||
INSTR("lv", &Jit::Comp_SVQ, Dis_SVLRQ, Int_SVQ, IS_VFPU),
|
||||
@@ -156,7 +156,7 @@ const MIPSInstruction tableImmediate[64] = //xxxxxx .....
|
||||
//56
|
||||
INSTR("sc", &Jit::Comp_Generic, Dis_Generic, Int_StoreSync, 0),
|
||||
INSTR("swc1", &Jit::Comp_FPULS, Dis_FPULS, Int_FPULS, 0), //copU
|
||||
INSTR("sv.s", &Jit::Comp_Generic, Dis_SV, Int_SV,IS_VFPU),
|
||||
INSTR("sv.s", &Jit::Comp_SV, Dis_SV, Int_SV,IS_VFPU),
|
||||
{-2},
|
||||
//60
|
||||
{VFPU6},
|
||||
@@ -185,7 +185,7 @@ const MIPSInstruction tableSpecial[64] = /// 000000 ...... ...... .......... xxx
|
||||
INSTR("syscall", &Jit::Comp_Syscall, Dis_Syscall, Int_Syscall,0),
|
||||
INSTR("break", &Jit::Comp_Break, Dis_Generic, Int_Break, 0),
|
||||
{-2},
|
||||
INSTR("sync", &Jit::Comp_Generic, Dis_Generic, Int_Sync, 0),
|
||||
INSTR("sync", &Jit::Comp_DoNothing, Dis_Generic, Int_Sync, 0),
|
||||
|
||||
//16
|
||||
INSTR("mfhi", &Jit::Comp_MulDivType, Dis_FromHiloTransfer, Int_MulDivType, OUT_RD|IN_OTHER),
|
||||
@@ -224,8 +224,8 @@ const MIPSInstruction tableSpecial[64] = /// 000000 ...... ...... .......... xxx
|
||||
INSTR("sltu", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD),
|
||||
INSTR("max", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD),
|
||||
INSTR("min", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD),
|
||||
INSTR("msub", &Jit::Comp_Generic, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER),
|
||||
INSTR("msubu", &Jit::Comp_Generic, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER),
|
||||
INSTR("msub", &Jit::Comp_RType3, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER),
|
||||
INSTR("msubu", &Jit::Comp_RType3, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER),
|
||||
|
||||
//48
|
||||
INSTR("tge", &Jit::Comp_Generic, Dis_RType3, 0, 0),
|
||||
@@ -276,32 +276,32 @@ const MIPSInstruction tableSpecial2[64] =
|
||||
//40
|
||||
{-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2},
|
||||
//48
|
||||
INSTR("c.f", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.un", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.eq", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ueq", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.olt", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ult", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ole", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ule", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.sf", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ngle",&Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.seq", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ngl", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.lt", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.nge", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.le", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ngt", &Jit::Comp_Generic, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.f", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.un", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.eq", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ueq", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.olt", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ult", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ole", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ule", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.sf", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ngle",&Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.seq", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ngl", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.lt", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.nge", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.le", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
INSTR("c.ngt", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG),
|
||||
};
|
||||
|
||||
|
||||
const MIPSInstruction tableSpecial3[64] =
|
||||
{
|
||||
INSTR("ext", &Jit::Comp_Generic, Dis_Special3, Int_Special3, IN_RS|OUT_RT),
|
||||
INSTR("ext", &Jit::Comp_Special3, Dis_Special3, Int_Special3, IN_RS|OUT_RT),
|
||||
{-2},
|
||||
{-2},
|
||||
{-2},
|
||||
INSTR("ins", &Jit::Comp_Generic, Dis_Special3, Int_Special3, IN_RS|OUT_RT),
|
||||
INSTR("ins", &Jit::Comp_Special3, Dis_Special3, Int_Special3, IN_RS|OUT_RT),
|
||||
{-2},
|
||||
{-2},
|
||||
{-2},
|
||||
@@ -363,11 +363,11 @@ const MIPSInstruction tableCop2[32] =
|
||||
INSTR("mfc2", &Jit::Comp_Generic, Dis_Generic, 0, OUT_RT),
|
||||
{-2},
|
||||
INSTR("cfc2", &Jit::Comp_Generic, Dis_Generic, 0, 0),
|
||||
INSTR("mfv", &Jit::Comp_Generic, Dis_Mftv, Int_Mftv, 0),
|
||||
INSTR("mfv", &Jit::Comp_Mftv, Dis_Mftv, Int_Mftv, 0),
|
||||
INSTR("mtc2", &Jit::Comp_Generic, Dis_Generic, 0, IN_RT),
|
||||
{-2},
|
||||
INSTR("ctc2", &Jit::Comp_Generic, Dis_Generic, 0, 0),
|
||||
INSTR("mtv", &Jit::Comp_Generic, Dis_Mftv, Int_Mftv, 0),
|
||||
INSTR("mtv", &Jit::Comp_Mftv, Dis_Mftv, Int_Mftv, 0),
|
||||
|
||||
{Cop2BC2},
|
||||
INSTR("??", &Jit::Comp_Generic, Dis_Generic, 0, 0),
|
||||
|
||||
@@ -335,6 +335,13 @@ namespace MIPSComp
|
||||
}
|
||||
}
|
||||
|
||||
void Jit::Comp_Special3(u32 op)
|
||||
{
|
||||
// ext, ins
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
|
||||
void Jit::Comp_Allegrex(u32 op)
|
||||
{
|
||||
CONDITIONAL_DISABLE
|
||||
|
||||
@@ -148,10 +148,6 @@ static const u64 GC_ALIGNED16(ssOneBits[2]) = {0x0000000100000001ULL, 0x00000001
|
||||
static const u64 GC_ALIGNED16(ssSignBits2[2]) = {0x8000000080000000ULL, 0x8000000080000000ULL};
|
||||
static const u64 GC_ALIGNED16(ssNoSignMask[2]) = {0x7FFFFFFF7FFFFFFFULL, 0x7FFFFFFF7FFFFFFFULL};
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
void Jit::Comp_FPU2op(u32 op)
|
||||
{
|
||||
=======
|
||||
void Jit::Comp_FPUComp(u32 op) {
|
||||
// TODO: Doesn't work yet.
|
||||
DISABLE;
|
||||
@@ -207,7 +203,6 @@ void Jit::Comp_FPUComp(u32 op) {
|
||||
}
|
||||
|
||||
void Jit::Comp_FPU2op(u32 op) {
|
||||
>>>>>>> Stashed changes
|
||||
CONDITIONAL_DISABLE;
|
||||
|
||||
int fs = _FS;
|
||||
|
||||
+109
-1
@@ -141,11 +141,77 @@ void Jit::ApplyPrefixD(const u8 *vregs, u32 prefix, VectorSize sz, bool onlyWrit
|
||||
|
||||
static u32 GC_ALIGNED16(ssLoadStoreTemp[1]);
|
||||
|
||||
void Jit::Comp_SV(u32 op) {
|
||||
// DISABLE;
|
||||
|
||||
s32 imm = (signed short)(op&0xFFFC);
|
||||
int vt = ((op >> 16) & 0x1f) | ((op & 3) << 5);
|
||||
int rs = _RS;
|
||||
|
||||
switch (op >> 26)
|
||||
{
|
||||
case 50: //lv.s // VI(vt) = Memory::Read_U32(addr);
|
||||
{
|
||||
gpr.BindToRegister(rs, true, false);
|
||||
fpr.MapRegV(vt, MAP_NOINIT);
|
||||
|
||||
JitSafeMem safe(this, rs, imm);
|
||||
safe.SetFar();
|
||||
OpArg src;
|
||||
if (safe.PrepareRead(src))
|
||||
{
|
||||
MOVSS(fpr.VX(vt), safe.NextFastAddress(0));
|
||||
}
|
||||
if (safe.PrepareSlowRead((void *) &Memory::Read_U32))
|
||||
{
|
||||
safe.NextSlowRead((void *) &Memory::Read_U32, 0);
|
||||
MOV(32, M((void *)&ssLoadStoreTemp), R(EAX));
|
||||
MOVSS(fpr.VX(vt), M((void *)&ssLoadStoreTemp));
|
||||
}
|
||||
safe.Finish();
|
||||
|
||||
gpr.UnlockAll();
|
||||
fpr.ReleaseSpillLocks();
|
||||
}
|
||||
break;
|
||||
|
||||
case 58: //sv.s // Memory::Write_U32(VI(vt), addr);
|
||||
{
|
||||
gpr.BindToRegister(rs, true, true);
|
||||
|
||||
// Even if we don't use real SIMD there's still 8 or 16 scalar float registers.
|
||||
fpr.MapRegV(vt, 0);
|
||||
|
||||
JitSafeMem safe(this, rs, imm);
|
||||
safe.SetFar();
|
||||
OpArg dest;
|
||||
if (safe.PrepareWrite(dest))
|
||||
{
|
||||
MOVSS(safe.NextFastAddress(0), fpr.VX(vt));
|
||||
}
|
||||
if (safe.PrepareSlowWrite())
|
||||
{
|
||||
MOVSS(M((void *)&ssLoadStoreTemp), fpr.VX(vt));
|
||||
safe.DoSlowWrite((void *) &Memory::Write_U32, M((void *)&ssLoadStoreTemp), 0);
|
||||
}
|
||||
safe.Finish();
|
||||
|
||||
fpr.ReleaseSpillLocks();
|
||||
gpr.UnlockAll();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
_dbg_assert_msg_(CPU,0,"Trying to interpret instruction that can't be interpreted");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Jit::Comp_SVQ(u32 op)
|
||||
{
|
||||
int imm = (signed short)(op&0xFFFC);
|
||||
int rs = _RS;
|
||||
int vt = (((op >> 16) & 0x1f)) | ((op&1) << 5);
|
||||
int rs = _RS;
|
||||
|
||||
switch (op >> 26)
|
||||
{
|
||||
@@ -263,5 +329,47 @@ void Jit::Comp_VDot(u32 op) {
|
||||
js.EatPrefix();
|
||||
}
|
||||
|
||||
void Jit::Comp_Mftv(u32 op) {
|
||||
int imm = op & 0xFF;
|
||||
int rt = _RT;
|
||||
switch ((op >> 21) & 0x1f)
|
||||
{
|
||||
case 3: //mfv / mfvc
|
||||
if (imm < 128) { //R(rt) = VI(imm);
|
||||
fpr.StoreFromRegisterV(imm);
|
||||
gpr.BindToRegister(rt, false, true);
|
||||
MOV(32, gpr.R(rt), fpr.V(imm));
|
||||
} else if (imm < 128 + VFPU_CTRL_MAX) { //mtvc
|
||||
gpr.BindToRegister(rt, false, true);
|
||||
MOV(32, gpr.R(rt), M(¤tMIPS->vfpuCtrl[imm - 128]));
|
||||
} else if (rt == 0 && imm == 255) {
|
||||
// This appears to be used as a CPU interlock by some games. Do nothing.
|
||||
} else {
|
||||
//ERROR - maybe need to make this value too an "interlock" value?
|
||||
_dbg_assert_msg_(CPU,0,"mfv - invalid register");
|
||||
}
|
||||
break;
|
||||
|
||||
case 7: //mtv
|
||||
if (imm < 128) {
|
||||
fpr.StoreFromRegisterV(imm);
|
||||
gpr.BindToRegister(rt, true, false);
|
||||
MOV(32, fpr.V(imm), gpr.R(rt));
|
||||
// VI(imm) = R(rt);
|
||||
} else if (imm < 128 + VFPU_CTRL_MAX) { //mtvc //currentMIPS->vfpuCtrl[imm - 128] = R(rt);
|
||||
gpr.BindToRegister(rt, true, false);
|
||||
MOV(32, M(¤tMIPS->vfpuCtrl[imm - 128]), gpr.R(rt));
|
||||
} else {
|
||||
//ERROR
|
||||
_dbg_assert_msg_(CPU,0,"mtv - invalid register");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
DISABLE;
|
||||
_dbg_assert_msg_(CPU,0,"Trying to interpret instruction that can't be interpreted");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+31
-5
@@ -288,7 +288,31 @@ void Jit::WriteExitDestInEAX()
|
||||
// TODO: Some wasted potential, dispatcher will always read this back into EAX.
|
||||
MOV(32, M(&mips_->pc), R(EAX));
|
||||
WriteDowncount();
|
||||
JMP(asm_.dispatcher, true);
|
||||
|
||||
// Validate the jump to avoid a crash?
|
||||
if (!g_Config.bFastMemory)
|
||||
{
|
||||
CMP(32, R(EAX), Imm32(PSP_GetKernelMemoryBase()));
|
||||
FixupBranch tooLow = J_CC(CC_L);
|
||||
CMP(32, R(EAX), Imm32(PSP_GetUserMemoryEnd()));
|
||||
FixupBranch tooHigh = J_CC(CC_GE);
|
||||
|
||||
JMP(asm_.dispatcher, true);
|
||||
|
||||
SetJumpTarget(tooLow);
|
||||
SetJumpTarget(tooHigh);
|
||||
|
||||
ABI_CallFunctionA(thunks.ProtectFunction((void *) Memory::GetPointer, 1), R(EAX));
|
||||
CMP(32, R(EAX), Imm32(0));
|
||||
J_CC(CC_NE, asm_.dispatcher, true);
|
||||
|
||||
// TODO: "Ignore" this so other threads can continue?
|
||||
if (g_Config.bIgnoreBadMemAccess)
|
||||
MOV(32, M((void*)&coreState), Imm32(CORE_ERROR));
|
||||
JMP(asm_.dispatcherCheckCoreState, true);
|
||||
}
|
||||
else
|
||||
JMP(asm_.dispatcher, true);
|
||||
}
|
||||
|
||||
void Jit::WriteSyscallExit()
|
||||
@@ -413,9 +437,9 @@ OpArg Jit::JitSafeMem::PrepareMemoryOpArg()
|
||||
if (!g_Config.bFastMemory)
|
||||
{
|
||||
// Is it in physical ram?
|
||||
jit_->CMP(32, R(xaddr_), Imm32(PSP_GetKernelMemoryBase()));
|
||||
jit_->CMP(32, R(xaddr_), Imm32(PSP_GetKernelMemoryBase() - offset_));
|
||||
tooLow_ = jit_->J_CC(CC_L);
|
||||
jit_->CMP(32, R(xaddr_), Imm32(PSP_GetUserMemoryEnd()));
|
||||
jit_->CMP(32, R(xaddr_), Imm32(PSP_GetUserMemoryEnd() - offset_));
|
||||
tooHigh_ = jit_->J_CC(CC_GE);
|
||||
|
||||
// We may need to jump back up here.
|
||||
@@ -448,9 +472,9 @@ void Jit::JitSafeMem::PrepareSlowAccess()
|
||||
jit_->SetJumpTarget(tooHigh_);
|
||||
|
||||
// Might also be the scratchpad.
|
||||
jit_->CMP(32, R(xaddr_), Imm32(PSP_GetScratchpadMemoryBase()));
|
||||
jit_->CMP(32, R(xaddr_), Imm32(PSP_GetScratchpadMemoryBase() - offset_));
|
||||
FixupBranch tooLow = jit_->J_CC(CC_L);
|
||||
jit_->CMP(32, R(xaddr_), Imm32(PSP_GetScratchpadMemoryEnd()));
|
||||
jit_->CMP(32, R(xaddr_), Imm32(PSP_GetScratchpadMemoryEnd() - offset_));
|
||||
jit_->J_CC(CC_L, safe_);
|
||||
jit_->SetJumpTarget(tooLow);
|
||||
}
|
||||
@@ -545,4 +569,6 @@ void Jit::JitSafeMem::Finish()
|
||||
jit_->SetJumpTarget(skip_);
|
||||
}
|
||||
|
||||
void Jit::Comp_DoNothing(u32 op) { }
|
||||
|
||||
} // namespace
|
||||
+7
-1
@@ -118,6 +118,7 @@ public:
|
||||
void Comp_RelBranchRI(u32 op);
|
||||
void Comp_FPUBranch(u32 op);
|
||||
void Comp_FPULS(u32 op);
|
||||
void Comp_FPUComp(u32 op);
|
||||
void Comp_Jump(u32 op);
|
||||
void Comp_JumpReg(u32 op);
|
||||
void Comp_Syscall(u32 op);
|
||||
@@ -129,15 +130,20 @@ public:
|
||||
void Comp_Allegrex(u32 op);
|
||||
void Comp_VBranch(u32 op);
|
||||
void Comp_MulDivType(u32 op);
|
||||
void Comp_Special3(u32 op);
|
||||
|
||||
void Comp_FPU3op(u32 op);
|
||||
void Comp_FPU2op(u32 op);
|
||||
void Comp_mxc1(u32 op);
|
||||
|
||||
void Comp_SV(u32 op);
|
||||
void Comp_SVQ(u32 op);
|
||||
void Comp_VPFX(u32 op);
|
||||
void Comp_VDot(u32 op);
|
||||
|
||||
void Comp_Mftv(u32 op);
|
||||
|
||||
void Comp_DoNothing(u32 op);
|
||||
|
||||
void ApplyPrefixST(u8 *vregs, u32 prefix, VectorSize sz);
|
||||
void ApplyPrefixD(const u8 *vregs, u32 prefix, VectorSize sz, bool onlyWriteMask = false);
|
||||
|
||||
|
||||
@@ -59,6 +59,10 @@ void FPURegCache::SpillLockV(int vec, VectorSize sz) {
|
||||
SpillLockV(v, sz);
|
||||
}
|
||||
|
||||
void FPURegCache::MapRegV(int vreg, int flags) {
|
||||
BindToRegister(vreg + 32, (flags & MAP_NOINIT) == 0, (flags & MAP_DIRTY) != 0);
|
||||
}
|
||||
|
||||
void FPURegCache::MapRegsV(int vec, VectorSize sz, int flags) {
|
||||
u8 v[4];
|
||||
GetVectorRegs(v, sz, vec);
|
||||
|
||||
@@ -64,6 +64,9 @@ public:
|
||||
void Start(MIPSState *mips, MIPSAnalyst::AnalysisResults &stats);
|
||||
void BindToRegister(int preg, bool doLoad = true, bool makeDirty = true);
|
||||
void StoreFromRegister(int preg);
|
||||
void StoreFromRegisterV(int preg) {
|
||||
StoreFromRegister(preg + 32);
|
||||
}
|
||||
OpArg GetDefaultLocation(int reg) const;
|
||||
|
||||
void SetEmitter(XEmitter *emitter) {emit = emitter;}
|
||||
@@ -94,6 +97,7 @@ public:
|
||||
void SpillLock(int p1, int p2=0xff, int p3=0xff, int p4=0xff);
|
||||
void ReleaseSpillLocks();
|
||||
|
||||
void MapRegV(int vreg, int flags);
|
||||
void MapRegsV(int vec, VectorSize vsz, int flags);
|
||||
void MapRegsV(const u8 *v, VectorSize vsz, int flags);
|
||||
void SpillLockV(const u8 *v, VectorSize vsz);
|
||||
|
||||
+2
-1
@@ -77,9 +77,10 @@ namespace SaveState
|
||||
Memory::DoState(p);
|
||||
MemoryStick_DoState(p);
|
||||
currentMIPS->DoState(p);
|
||||
pspFileSystem.DoState(p);
|
||||
HLEDoState(p);
|
||||
__KernelDoState(p);
|
||||
// Kernel object destructors might close open files, so do the filesystem last.
|
||||
pspFileSystem.DoState(p);
|
||||
}
|
||||
|
||||
void Enqueue(SaveState::Operation op)
|
||||
|
||||
Reference in new issue
Block a user