mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 19:34:39 +01:00
Merge pull request #22089 from hrydgard/interpreter-mips-state
Interpreter: Plumb through MIPSState *mips as a function parameter, instead of global currentMIPS
This commit is contained in:
106 files changed
+1275
-1229
No files matched your search
@@ -640,6 +640,7 @@ const char *ExecExceptionTypeAsString(ExecExceptionType type) {
|
||||
switch (type) {
|
||||
case ExecExceptionType::JUMP: return "CPU Jump";
|
||||
case ExecExceptionType::THREAD: return "Thread switch";
|
||||
case ExecExceptionType::ILLEGAL: return "Illegal instruction"; // or unknown, but I think we have all now.
|
||||
default:
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
@@ -207,6 +207,7 @@ enum class MemoryExceptionType {
|
||||
enum class ExecExceptionType {
|
||||
JUMP,
|
||||
THREAD,
|
||||
ILLEGAL,
|
||||
};
|
||||
|
||||
void Core_MemoryException(u32 address, u32 accessSize, u32 pc, MemoryExceptionType type, std::string_view additionalInfo = "");
|
||||
|
||||
+29
-32
@@ -75,7 +75,7 @@ bool SetClockFrequencyHz(int cpuHz) {
|
||||
// When the mhz changes, we keep track of what "time" it was before hand.
|
||||
// This way, time always moves forward, even if mhz is changed.
|
||||
lastGlobalTimeUs = GetGlobalTimeUs();
|
||||
lastGlobalTimeTicks = GetTicks();
|
||||
lastGlobalTimeTicks = GetTicks(currentMIPS);
|
||||
|
||||
CPU_HZ = cpuHz;
|
||||
|
||||
@@ -93,13 +93,13 @@ u64 GetGlobalTimeUsScaled() {
|
||||
}
|
||||
|
||||
u64 GetGlobalTimeUs() {
|
||||
s64 ticksSinceLast = GetTicks() - lastGlobalTimeTicks;
|
||||
s64 ticksSinceLast = GetTicks(currentMIPS) - lastGlobalTimeTicks;
|
||||
int freq = GetClockFrequencyHz();
|
||||
s64 usSinceLast = ticksSinceLast * 1000000 / freq;
|
||||
if (ticksSinceLast > UINT_MAX) {
|
||||
// Adjust the calculated value to avoid overflow errors.
|
||||
lastGlobalTimeUs += usSinceLast;
|
||||
lastGlobalTimeTicks = GetTicks();
|
||||
lastGlobalTimeTicks = GetTicks(currentMIPS);
|
||||
usSinceLast = 0;
|
||||
}
|
||||
return lastGlobalTimeUs + usSinceLast;
|
||||
@@ -178,9 +178,8 @@ void UnregisterAllEvents() {
|
||||
restoredEventTypes.clear();
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
currentMIPS->downcount = INITIAL_SLICE_LENGTH;
|
||||
void Init(MIPSState *mips) {
|
||||
mips->downcount = INITIAL_SLICE_LENGTH;
|
||||
slicelength = INITIAL_SLICE_LENGTH;
|
||||
globalTimer = 0;
|
||||
idledCycles = 0;
|
||||
@@ -201,18 +200,16 @@ void Shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
u64 GetTicks()
|
||||
{
|
||||
if (currentMIPS) {
|
||||
return (u64)globalTimer + slicelength - currentMIPS->downcount;
|
||||
u64 GetTicks(MIPSState *mips) {
|
||||
if (mips) {
|
||||
return (u64)globalTimer + slicelength - mips->downcount;
|
||||
} else {
|
||||
// Reporting can actually end up here during weird task switching sequences on Android
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
u64 GetIdleTicks()
|
||||
{
|
||||
u64 GetIdleTicks() {
|
||||
return (u64)idledCycles;
|
||||
}
|
||||
|
||||
@@ -252,7 +249,7 @@ void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata)
|
||||
Event *ne = GetNewEvent();
|
||||
ne->userdata = userdata;
|
||||
ne->type = event_type;
|
||||
ne->time = GetTicks() + cyclesIntoFuture;
|
||||
ne->time = GetTicks(currentMIPS) + cyclesIntoFuture;
|
||||
AddEventToQueue(ne);
|
||||
}
|
||||
|
||||
@@ -266,7 +263,7 @@ s64 UnscheduleEvent(int event_type, u64 userdata)
|
||||
{
|
||||
if (first->type == event_type && first->userdata == userdata)
|
||||
{
|
||||
result = first->time - GetTicks();
|
||||
result = first->time - GetTicks(currentMIPS);
|
||||
|
||||
Event *next = first->next;
|
||||
FreeEvent(first);
|
||||
@@ -285,7 +282,7 @@ s64 UnscheduleEvent(int event_type, u64 userdata)
|
||||
{
|
||||
if (ptr->type == event_type && ptr->userdata == userdata)
|
||||
{
|
||||
result = ptr->time - GetTicks();
|
||||
result = ptr->time - GetTicks(currentMIPS);
|
||||
|
||||
prev->next = ptr->next;
|
||||
FreeEvent(ptr);
|
||||
@@ -352,12 +349,12 @@ void RemoveEvent(int event_type)
|
||||
|
||||
void ProcessEvents() {
|
||||
while (first) {
|
||||
if (first->time <= (s64)GetTicks()) {
|
||||
// INFO_LOG(Log::CPU, "%s (%lld, %lld) ", first->name ? first->name : "?", (u64)GetTicks(), (u64)first->time);
|
||||
if (first->time <= (s64)GetTicks(currentMIPS)) {
|
||||
// INFO_LOG(Log::CPU, "%s (%lld, %lld) ", first->name ? first->name : "?", (u64)GetTicks(currentMIPS), (u64)first->time);
|
||||
Event *evt = first;
|
||||
first = first->next;
|
||||
if (evt->type >= 0 && evt->type < (int)event_types.size()) {
|
||||
event_types[evt->type].callback(evt->userdata, (int)(GetTicks() - evt->time));
|
||||
event_types[evt->type].callback(evt->userdata, (int)(GetTicks(currentMIPS) - evt->time));
|
||||
} else {
|
||||
_dbg_assert_msg_(false, "Bad event type %d", evt->type);
|
||||
}
|
||||
@@ -369,12 +366,11 @@ void ProcessEvents() {
|
||||
}
|
||||
}
|
||||
|
||||
void ForceCheck()
|
||||
{
|
||||
int cyclesExecuted = slicelength - currentMIPS->downcount;
|
||||
void ForceCheck(MIPSState *mips) {
|
||||
int cyclesExecuted = slicelength - mips->downcount;
|
||||
globalTimer += cyclesExecuted;
|
||||
// This will cause us to check for new events immediately.
|
||||
currentMIPS->downcount = -1;
|
||||
mips->downcount = -1;
|
||||
// But let's not eat a bunch more time in Advance() because of this.
|
||||
slicelength = -1;
|
||||
|
||||
@@ -384,10 +380,11 @@ void ForceCheck()
|
||||
}
|
||||
|
||||
void Advance() {
|
||||
MIPSState *mips = currentMIPS; // TODO: Move to parameter
|
||||
PROFILE_THIS_SCOPE("advance");
|
||||
int cyclesExecuted = slicelength - currentMIPS->downcount;
|
||||
int cyclesExecuted = slicelength - mips->downcount;
|
||||
globalTimer += cyclesExecuted;
|
||||
currentMIPS->downcount = slicelength;
|
||||
mips->downcount = slicelength;
|
||||
|
||||
ProcessEvents();
|
||||
|
||||
@@ -395,7 +392,7 @@ void Advance() {
|
||||
// This should never happen in PPSSPP.
|
||||
if (slicelength < 10000) {
|
||||
slicelength += 10000;
|
||||
currentMIPS->downcount += 10000;
|
||||
mips->downcount += 10000;
|
||||
}
|
||||
} else {
|
||||
// Note that events can eat cycles as well.
|
||||
@@ -405,7 +402,7 @@ void Advance() {
|
||||
|
||||
const int diff = target - slicelength;
|
||||
slicelength += diff;
|
||||
currentMIPS->downcount += diff;
|
||||
mips->downcount += diff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,13 +414,13 @@ void LogPendingEvents() {
|
||||
}
|
||||
}
|
||||
|
||||
void Idle(int maxIdle) {
|
||||
int cyclesDown = currentMIPS->downcount;
|
||||
void Idle(MIPSState *mips, int maxIdle) {
|
||||
int cyclesDown = mips->downcount;
|
||||
if (maxIdle != 0 && cyclesDown > maxIdle)
|
||||
cyclesDown = maxIdle;
|
||||
|
||||
if (first && cyclesDown > 0) {
|
||||
int cyclesExecuted = slicelength - currentMIPS->downcount;
|
||||
int cyclesExecuted = slicelength - mips->downcount;
|
||||
int cyclesNextEvent = (int) (first->time - globalTimer);
|
||||
|
||||
if (cyclesNextEvent < cyclesExecuted + cyclesDown)
|
||||
@@ -437,9 +434,9 @@ void Idle(int maxIdle) {
|
||||
// VERBOSE_LOG(Log::CPU, "Idle for %i cycles! (%f ms)", cyclesDown, cyclesDown / (float)(CPU_HZ * 0.001f));
|
||||
|
||||
idledCycles += cyclesDown;
|
||||
currentMIPS->downcount -= cyclesDown;
|
||||
if (currentMIPS->downcount == 0)
|
||||
currentMIPS->downcount = -1;
|
||||
mips->downcount -= cyclesDown;
|
||||
if (mips->downcount == 0)
|
||||
mips->downcount = -1;
|
||||
}
|
||||
|
||||
std::string GetScheduledEventsSummary() {
|
||||
|
||||
+6
-4
@@ -72,6 +72,8 @@ inline s64 cyclesToUs(s64 cycles) {
|
||||
return (cycles * 1000000) / CPU_HZ;
|
||||
}
|
||||
|
||||
class MIPSState;
|
||||
|
||||
namespace CoreTiming {
|
||||
typedef void (*TimedCallback)(u64 userdata, int cyclesLate);
|
||||
|
||||
@@ -87,10 +89,10 @@ namespace CoreTiming {
|
||||
};
|
||||
typedef LinkedListItem<BaseEvent> Event;
|
||||
|
||||
void Init();
|
||||
void Init(MIPSState *mips);
|
||||
void Shutdown();
|
||||
|
||||
u64 GetTicks();
|
||||
u64 GetTicks(MIPSState *mips);
|
||||
u64 GetIdleTicks();
|
||||
u64 GetGlobalTimeUs();
|
||||
u64 GetGlobalTimeUsScaled();
|
||||
@@ -112,10 +114,10 @@ namespace CoreTiming {
|
||||
void RemoveEvent(int event_type);
|
||||
bool IsScheduled(int event_type);
|
||||
void Advance();
|
||||
void ForceCheck();
|
||||
void ForceCheck(MIPSState *mips);
|
||||
|
||||
// Pretend that the main CPU has executed enough cycles to reach the next event.
|
||||
void Idle(int maxIdle = 0);
|
||||
void Idle(MIPSState *mips, int maxIdle = 0);
|
||||
|
||||
// Clear all pending events. This should ONLY be done on exit or state load.
|
||||
void ClearPendingEvents();
|
||||
|
||||
@@ -475,7 +475,7 @@ BreakAction BreakpointManager::ExecOpMemCheck(u32 address, u32 pc) {
|
||||
int mask = MEMCHECK_WRITE | MEMCHECK_WRITE_ONCHANGE;
|
||||
bool apply = false;
|
||||
if (write && (check->cond & mask) == mask) {
|
||||
if (MIPSAnalyst::OpWouldChangeMemory(pc, address, size)) {
|
||||
if (MIPSAnalyst::OpWouldChangeMemory(currentMIPS, pc, address, size)) {
|
||||
apply = true;
|
||||
}
|
||||
} else {
|
||||
@@ -495,12 +495,12 @@ BreakAction BreakpointManager::ExecOpMemCheck(u32 address, u32 pc) {
|
||||
|
||||
void BreakpointManager::SetSkipFirst(u32 pc) {
|
||||
breakSkipFirstAt_ = pc;
|
||||
breakSkipFirstTicks_ = CoreTiming::GetTicks();
|
||||
breakSkipFirstTicks_ = CoreTiming::GetTicks(currentMIPS);
|
||||
}
|
||||
|
||||
u32 BreakpointManager::CheckSkipFirst() {
|
||||
u32 pc = breakSkipFirstAt_;
|
||||
if (breakSkipFirstTicks_ == CoreTiming::GetTicks())
|
||||
if (breakSkipFirstTicks_ == CoreTiming::GetTicks(currentMIPS))
|
||||
return pc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ void NotifyMemInfoPC(MemBlockFlags flags, uint32_t start, uint32_t size, uint32_
|
||||
// When the setting is off, we skip smaller info to keep things fast.
|
||||
if (MemBlockInfoDetailed(size) && flags != MemBlockFlags::READ) {
|
||||
PendingNotifyMem info{ flags, start, size };
|
||||
info.ticks = CoreTiming::GetTicks();
|
||||
info.ticks = CoreTiming::GetTicks(currentMIPS);
|
||||
info.pc = pc;
|
||||
|
||||
size_t copyLength = strLength;
|
||||
@@ -565,7 +565,7 @@ void NotifyMemInfoCopy(uint32_t destPtr, uint32_t srcPtr, uint32_t size, const c
|
||||
|
||||
PendingNotifyMem info{ MemBlockFlags::WRITE, destPtr, size };
|
||||
info.copySrc = srcPtr;
|
||||
info.ticks = CoreTiming::GetTicks();
|
||||
info.ticks = CoreTiming::GetTicks(currentMIPS);
|
||||
info.pc = currentMIPS->pc;
|
||||
|
||||
// Store the prefix for now. The correct tag will be calculated on flush.
|
||||
|
||||
@@ -126,7 +126,7 @@ void WebSocketCPUStatus(DebuggerRequest &req) {
|
||||
// Avoid NULL deference.
|
||||
json.writeUint("pc", pspInited ? currentMIPS->pc : 0);
|
||||
// A double ought to be good enough for a 156 day debug session.
|
||||
json.writeFloat("ticks", pspInited ? CoreTiming::GetTicks() : 0);
|
||||
json.writeFloat("ticks", pspInited ? CoreTiming::GetTicks(currentMIPS) : 0);
|
||||
}
|
||||
|
||||
// Retrieve all regs and their values (cpu.getAllRegs)
|
||||
|
||||
@@ -32,7 +32,7 @@ struct CPUSteppingEvent {
|
||||
j.writeString("event", "cpu.stepping");
|
||||
j.writeUint("pc", currentMIPS->pc);
|
||||
// A double ought to be good enough for a 156 day debug session.
|
||||
j.writeFloat("ticks", CoreTiming::GetTicks());
|
||||
j.writeFloat("ticks", CoreTiming::GetTicks(currentMIPS));
|
||||
if (reason_.reason != BreakReason::None) {
|
||||
j.writeString("reason", BreakReasonToString(reason_.reason));
|
||||
j.writeUint("relatedAddress", reason_.relatedAddress);
|
||||
|
||||
@@ -85,7 +85,7 @@ void PSPDialog::UpdateCommon() {
|
||||
}
|
||||
|
||||
PSPDialog::DialogStatus PSPDialog::GetStatus() {
|
||||
if (pendingStatusTicks != 0 && CoreTiming::GetTicks() >= pendingStatusTicks) {
|
||||
if (pendingStatusTicks != 0 && CoreTiming::GetTicks(currentMIPS) >= pendingStatusTicks) {
|
||||
bool changeAllowed = true;
|
||||
if (pendingStatus == SCE_UTILITY_STATUS_NONE && status == SCE_UTILITY_STATUS_SHUTDOWN) {
|
||||
FinishVolatile();
|
||||
@@ -126,7 +126,7 @@ void PSPDialog::ChangeStatus(DialogStatus newStatus, int delayUs) {
|
||||
pendingStatusTicks = 0;
|
||||
} else {
|
||||
pendingStatus = newStatus;
|
||||
pendingStatusTicks = CoreTiming::GetTicks() + usToCycles(delayUs);
|
||||
pendingStatusTicks = CoreTiming::GetTicks(currentMIPS) + usToCycles(delayUs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -265,11 +265,11 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
||||
}
|
||||
if (reqsz > 0) {
|
||||
if (hleCall(sceNetAdhocctl, int, sceNetAdhocctlGetScanInfo, scanInfosAddr, scanInfosAddr + (u32)sizeof(s32)) >= 0) {
|
||||
ScanInfos* scanInfos = (ScanInfos*)Memory::GetPointer(scanInfosAddr);
|
||||
ScanInfos* scanInfos = (ScanInfos*)Memory::GetPointerOrException(scanInfosAddr);
|
||||
int n = scanInfos->sz / sizeof(SceNetAdhocctlScanInfoEmu);
|
||||
// Assuming returned SceNetAdhocctlScanInfoEmu(s) are contiguous where next is pointing to current addr + sizeof(SceNetAdhocctlScanInfoEmu)
|
||||
while (n > 0) {
|
||||
SceNetAdhocctlScanInfoEmu* si = (SceNetAdhocctlScanInfoEmu*)Memory::GetPointer(scanInfosAddr + sizeof(s32) + sizeof(SceNetAdhocctlScanInfoEmu) * (n - 1LL));
|
||||
SceNetAdhocctlScanInfoEmu* si = (SceNetAdhocctlScanInfoEmu*)Memory::GetPointerOrException(scanInfosAddr + sizeof(s32) + sizeof(SceNetAdhocctlScanInfoEmu) * (n - 1LL));
|
||||
if (memcmp(si->group_name.data, request.NetconfData->groupName, ADHOCCTL_GROUPNAME_LEN) == 0) {
|
||||
// Moving found group info to the front so we can use it on sceNetAdhocctlJoin easily
|
||||
memcpy((char*)scanInfos + sizeof(s32), si, sizeof(SceNetAdhocctlScanInfoEmu));
|
||||
|
||||
@@ -678,7 +678,7 @@ int PSPSaveDialog::Update(int animSpeed) {
|
||||
// Check if it has changed, reload it.
|
||||
// TODO: Cut down on preloading? This rebuilds the list from scratch.
|
||||
int size = std::min((u32)sizeof(originalRequest), Memory::ReadUnchecked_U32(requestAddr));
|
||||
const u8 *updatedRequest = Memory::GetPointerRange(requestAddr, size);
|
||||
const u8 *updatedRequest = Memory::GetPointerRangeOrException(requestAddr, size);
|
||||
if (updatedRequest && memcmp(updatedRequest, &originalRequest, size) != 0) {
|
||||
memset(&request, 0, sizeof(request));
|
||||
Memory::Memcpy(&request, requestAddr, size);
|
||||
|
||||
@@ -544,7 +544,7 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) {
|
||||
}
|
||||
const u32 srcSize = p->p_filesz;
|
||||
const u32 dstSize = p->p_memsz; // can be bigger than size-in-file (p_filesz), we'll zero the rest below. But cannot be smaller!
|
||||
u8 *dst = Memory::GetPointerWriteRange(writeAddr, dstSize);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(writeAddr, dstSize);
|
||||
if (dst) {
|
||||
if (srcSize < dstSize) {
|
||||
memset(dst + srcSize, 0, dstSize - srcSize); // zero out the rest of the segment, this also applies to bss (which is all-zero)
|
||||
|
||||
@@ -455,7 +455,7 @@ int ISOFileSystem::Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outd
|
||||
} else {
|
||||
int block = (u16)desc.firstLETableSector;
|
||||
u32 size = Memory::ClampValidSizeAt(outdataPtr, (u32)desc.pathTableLength);
|
||||
u8 *out = Memory::GetPointerWriteRange(outdataPtr, size);
|
||||
u8 *out = Memory::GetPointerWriteRangeOrException(outdataPtr, size);
|
||||
|
||||
int blocks = size / blockDevice->GetBlockSize();
|
||||
blockDevice->ReadBlocks(block, blocks, out);
|
||||
|
||||
@@ -165,7 +165,7 @@ void Atrac::ResetData() {
|
||||
}
|
||||
|
||||
u8 *Atrac::BufferStart() {
|
||||
return ignoreDataBuf_ ? Memory::GetPointerWrite(first_.addr) : dataBuf_;
|
||||
return ignoreDataBuf_ ? Memory::GetPointerWriteOrException(first_.addr) : dataBuf_;
|
||||
}
|
||||
|
||||
AtracBase::~AtracBase() {
|
||||
|
||||
@@ -863,7 +863,7 @@ u32 Atrac2::DecodeInternal(u32 outbufAddr, int *SamplesNum, int *finish) {
|
||||
}
|
||||
outPtr = decodeTemp_;
|
||||
} else {
|
||||
outPtr = outbufAddr ? (int16_t *)Memory::GetPointer(outbufAddr) : 0; // outbufAddr can be 0 during skip!
|
||||
outPtr = outbufAddr ? (int16_t *)Memory::GetPointerOrException(outbufAddr) : 0; // outbufAddr can be 0 during skip!
|
||||
}
|
||||
|
||||
context_->codec.inBuf = inAddr;
|
||||
@@ -899,7 +899,7 @@ u32 Atrac2::DecodeInternal(u32 outbufAddr, int *SamplesNum, int *finish) {
|
||||
} else {
|
||||
*finish = 0;
|
||||
}
|
||||
u8 *outBuf = outbufAddr ? Memory::GetPointerWrite(outbufAddr) : nullptr;
|
||||
u8 *outBuf = outbufAddr ? Memory::GetPointerWriteOrException(outbufAddr) : nullptr;
|
||||
if (samplesToDecode != info.SamplesPerFrame() && samplesToDecode != 0 && outBuf) {
|
||||
memcpy(outBuf, decodeTemp_, samplesToDecode * outputChannels_ * sizeof(int16_t));
|
||||
}
|
||||
@@ -958,8 +958,8 @@ u32 Atrac2::DecodeInternal(u32 outbufAddr, int *SamplesNum, int *finish) {
|
||||
size_t copyLen = info.secondBufferByte % info.sampleSize;
|
||||
if (copyLen > info.bufferByte)
|
||||
copyLen = info.bufferByte;
|
||||
memcpy(Memory::GetPointerWrite(info.buffer),
|
||||
Memory::GetPointer(info.secondBuffer + (info.secondBufferByte - info.secondBufferByte % info.sampleSize)),
|
||||
memcpy(Memory::GetPointerWriteOrException(info.buffer),
|
||||
Memory::GetPointerOrException(info.secondBuffer + (info.secondBufferByte - info.secondBufferByte % info.sampleSize)),
|
||||
copyLen);
|
||||
}
|
||||
}
|
||||
@@ -1214,7 +1214,7 @@ void Atrac2::DecodeForSas(s16 *dstData, int *bytesWritten, int *finish) {
|
||||
// Keep decoding from the current buffer until it runs out.
|
||||
if (sas_.streamOffset + (int)info.sampleSize <= (int)sas_.bufSize[sas_.curBuffer]) {
|
||||
// Just decode.
|
||||
const u8 *srcData = Memory::GetPointer(sas_.bufPtr[sas_.curBuffer] + sas_.streamOffset);
|
||||
const u8 *srcData = Memory::GetPointerOrException(sas_.bufPtr[sas_.curBuffer] + sas_.streamOffset);
|
||||
int bytesConsumed = 0;
|
||||
bool decodeResult = decoder_->Decode(srcData, info.sampleSize, &bytesConsumed, 1, dstData, bytesWritten);
|
||||
if (!decodeResult) {
|
||||
|
||||
+11
-11
@@ -106,7 +106,7 @@ template<u32 func()> void WrapU_V() {
|
||||
}
|
||||
|
||||
template<u32 func(int, void *, int)> void WrapU_IVI() {
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWrite(PARAM(1)), PARAM(2));
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWriteOrException(PARAM(1)), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ template<int func(const char *, int, int, u32)> void WrapI_CIIU() {
|
||||
}
|
||||
|
||||
template<int func(int, const char *, u32, void *, void *, u32, int)> void WrapI_ICUVVUI() {
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointerWrite(PARAM(3)),Memory::GetPointerWrite(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointerWriteOrException(PARAM(3)),Memory::GetPointerWriteOrException(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -147,13 +147,13 @@ template<int func(int, int, int, int, int, int, u32)> void WrapI_IIIIIIU() {
|
||||
|
||||
// Hm, do so many params get passed in registers?
|
||||
template<int func(int, int, int, int, int, int, int, int, u32)> void WrapI_IIIIIIIIU() {
|
||||
u32 param8 = *(const u32_le *)Memory::GetPointerWrite(currentMIPS->r[29]); //Fixed 9th parameter, thanks to Kingcom
|
||||
u32 param8 = *(const u32_le *)Memory::GetPointerWriteOrException(currentMIPS->r[29]); //Fixed 9th parameter, thanks to Kingcom
|
||||
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6), PARAM(7), param8);
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(int, void *)> void WrapU_IV() {
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWrite(PARAM(1)));
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWriteOrException(PARAM(1)));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -881,27 +881,27 @@ template <int func(int, const char *, int)> void WrapI_ICI() {
|
||||
}
|
||||
|
||||
template<int func(int, void *, void *, void *, void *, u32, int)> void WrapI_IVVVVUI(){
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWrite(PARAM(1)), Memory::GetPointerWrite(PARAM(2)), Memory::GetPointerWrite(PARAM(3)), Memory::GetPointerWrite(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWriteOrException(PARAM(1)), Memory::GetPointerWriteOrException(PARAM(2)), Memory::GetPointerWriteOrException(PARAM(3)), Memory::GetPointerWriteOrException(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(int, const char *, u32, void *, int, int, int)> void WrapI_ICUVIII(){
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointerWrite(PARAM(3)), PARAM(4), PARAM(5), PARAM(6));
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointerWriteOrException(PARAM(3)), PARAM(4), PARAM(5), PARAM(6));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(void *, u32, int)> void WrapI_VUI(){
|
||||
u32 retval = func(Memory::GetPointerWrite(PARAM(0)), PARAM(1), PARAM(2));
|
||||
u32 retval = func(Memory::GetPointerWriteOrException(PARAM(0)), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(void *, u32, u32)> void WrapU_VUU() {
|
||||
u32 retval = func(Memory::GetPointerWrite(PARAM(0)), PARAM(1), PARAM(2));
|
||||
u32 retval = func(Memory::GetPointerWriteOrException(PARAM(0)), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(void *, const char *)> void WrapU_VC() {
|
||||
u32 retval = func(Memory::GetPointerWrite(PARAM(0)), Memory::GetCharPointer(PARAM(1)));
|
||||
u32 retval = func(Memory::GetPointerWriteOrException(PARAM(0)), Memory::GetCharPointer(PARAM(1)));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -916,11 +916,11 @@ template<int func(const char *, const char*)> void WrapI_CC() {
|
||||
}
|
||||
|
||||
template<u32 func(void *, const char *, u32)> void WrapU_VCU() {
|
||||
u32 retval = func(Memory::GetPointerWrite(PARAM(0)), Memory::GetCharPointer(PARAM(1)), PARAM(2));
|
||||
u32 retval = func(Memory::GetPointerWriteOrException(PARAM(0)), Memory::GetCharPointer(PARAM(1)), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(void *, int)> void WrapU_VI() {
|
||||
u32 retval = func(Memory::GetPointerWrite(PARAM(0)), PARAM(1));
|
||||
u32 retval = func(Memory::GetPointerWriteOrException(PARAM(0)), PARAM(1));
|
||||
RETURN(retval);
|
||||
}
|
||||
+1
-1
@@ -770,7 +770,7 @@ static void hleFinishSyscall(const HLEFunction *info) {
|
||||
}
|
||||
|
||||
if (hleAfterSyscall & HLE_AFTER_CORETIMING_FORCE_CHECK) {
|
||||
CoreTiming::ForceCheck();
|
||||
CoreTiming::ForceCheck(currentMIPS);
|
||||
}
|
||||
|
||||
if ((hleAfterSyscall & HLE_AFTER_SKIP_DEADBEEF) == 0)
|
||||
|
||||
@@ -144,7 +144,7 @@ WaitBeginEndCallbackResult WaitBeginCallback(SceUID threadID, SceUID prevCallbac
|
||||
u64 pausedTimeout = 0;
|
||||
if (doTimeout && waitTimer != -1) {
|
||||
s64 cyclesLeft = CoreTiming::UnscheduleEvent(waitTimer, threadID);
|
||||
pausedTimeout = CoreTiming::GetTicks() + cyclesLeft;
|
||||
pausedTimeout = CoreTiming::GetTicks(currentMIPS) + cyclesLeft;
|
||||
}
|
||||
|
||||
if (!WaitPauseHelperUpdate(pauseKey, threadID, waitingThreads, pausedWaits, pausedTimeout)) {
|
||||
@@ -214,7 +214,7 @@ WaitBeginEndCallbackResult WaitEndCallback(SceUID threadID, SceUID prevCallbackI
|
||||
}
|
||||
|
||||
// We only check if it timed out if it couldn't unlock.
|
||||
s64 cyclesLeft = waitDeadline - CoreTiming::GetTicks();
|
||||
s64 cyclesLeft = waitDeadline - CoreTiming::GetTicks(currentMIPS);
|
||||
if (cyclesLeft < 0 && waitDeadline != 0) {
|
||||
if (timeoutPtr != 0 && waitTimer != -1) {
|
||||
Memory::WriteOrException_U32(0, timeoutPtr);
|
||||
|
||||
+30
-30
@@ -133,8 +133,8 @@ static int Replace_memcpy() {
|
||||
}
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRange(srcPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRangeOrException(srcPtr, bytes);
|
||||
|
||||
if (!dst || !src) {
|
||||
// Already logged.
|
||||
@@ -200,8 +200,8 @@ static int Replace_memcpy_jak() {
|
||||
sliced = true;
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRange(srcPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRangeOrException(srcPtr, bytes);
|
||||
|
||||
if (dst && src) {
|
||||
// Jak style overlap.
|
||||
@@ -265,8 +265,8 @@ static int Replace_memcpy16() {
|
||||
}
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRange(srcPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRangeOrException(srcPtr, bytes);
|
||||
if (dst && src) {
|
||||
memmove(dst, src, bytes);
|
||||
}
|
||||
@@ -290,8 +290,8 @@ static int Replace_memcpy_swizzled() {
|
||||
gpu->PerformReadbackToMemory(srcPtr, pitch * h);
|
||||
}
|
||||
}
|
||||
u8 *dstp = Memory::GetPointerWriteRange(destPtr, pitch * h);
|
||||
const u8 *srcp = Memory::GetPointerRange(srcPtr, pitch * h);
|
||||
u8 *dstp = Memory::GetPointerWriteRangeOrException(destPtr, pitch * h);
|
||||
const u8 *srcp = Memory::GetPointerRangeOrException(srcPtr, pitch * h);
|
||||
|
||||
if (dstp && srcp) {
|
||||
const u8 *ysrcp = srcp;
|
||||
@@ -333,8 +333,8 @@ static int Replace_memmove() {
|
||||
}
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRange(srcPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRangeOrException(srcPtr, bytes);
|
||||
if (dst && src) {
|
||||
memmove(dst, src, bytes);
|
||||
}
|
||||
@@ -357,7 +357,7 @@ static int Replace_memset() {
|
||||
skip = gpu->PerformMemorySet(destPtr, value, bytes);
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
if (dst) {
|
||||
memset(dst, value, bytes);
|
||||
}
|
||||
@@ -391,7 +391,7 @@ static int Replace_memset_jak() {
|
||||
sliced = true;
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
if (dst) {
|
||||
memset(dst, value, bytes);
|
||||
}
|
||||
@@ -419,7 +419,7 @@ static int Replace_memset_jak() {
|
||||
|
||||
static uint32_t SafeStringLen(const uint32_t ptr, uint32_t maxLen = 0x07FFFFFF) {
|
||||
maxLen = Memory::ClampValidSizeAt(ptr, 0x07FFFFFF);
|
||||
const uint8_t *p = Memory::GetPointerRange(ptr, maxLen);
|
||||
const uint8_t *p = Memory::GetPointerRangeOrException(ptr, maxLen);
|
||||
if (!p)
|
||||
return 0;
|
||||
const uint8_t *end = (const uint8_t *)memchr(p, '\0', maxLen);
|
||||
@@ -439,8 +439,8 @@ static int Replace_strcpy() {
|
||||
u32 destPtr = PARAM(0);
|
||||
u32 srcPtr = PARAM(1);
|
||||
u32 len = SafeStringLen(srcPtr);
|
||||
char *dst = (char *)Memory::GetPointerWriteRange(destPtr, len);
|
||||
const char *src = (const char *)Memory::GetPointerRange(srcPtr, len);
|
||||
char *dst = (char *)Memory::GetPointerWriteRangeOrException(destPtr, len);
|
||||
const char *src = (const char *)Memory::GetPointerRangeOrException(srcPtr, len);
|
||||
if (dst && src && len != 0) {
|
||||
strcpy(dst, src);
|
||||
}
|
||||
@@ -452,9 +452,9 @@ static int Replace_strncpy() {
|
||||
u32 destPtr = PARAM(0);
|
||||
u32 srcPtr = PARAM(1);
|
||||
u32 bytes = PARAM(2);
|
||||
char *dst = (char *)Memory::GetPointerRange(destPtr, bytes);
|
||||
char *dst = (char *)Memory::GetPointerRangeOrException(destPtr, bytes);
|
||||
u32 srcLen = SafeStringLen(srcPtr, bytes);
|
||||
const char *src = (const char *)Memory::GetPointerRange(srcPtr, srcLen == 0 ? bytes : srcLen);
|
||||
const char *src = (const char *)Memory::GetPointerRangeOrException(srcPtr, srcLen == 0 ? bytes : srcLen);
|
||||
if (dst && src && bytes != 0) {
|
||||
strncpy(dst, src, bytes);
|
||||
}
|
||||
@@ -464,9 +464,9 @@ static int Replace_strncpy() {
|
||||
|
||||
static int Replace_strcmp() {
|
||||
u32 aLen = SafeStringLen(PARAM(0));
|
||||
const char *a = (const char *)Memory::GetPointerRange(PARAM(0), aLen);
|
||||
const char *a = (const char *)Memory::GetPointerRangeOrException(PARAM(0), aLen);
|
||||
u32 bLen = SafeStringLen(PARAM(1));
|
||||
const char *b = (const char *)Memory::GetPointerRange(PARAM(1), bLen);
|
||||
const char *b = (const char *)Memory::GetPointerRangeOrException(PARAM(1), bLen);
|
||||
if (a && b && aLen != 0 && bLen != 0) {
|
||||
RETURN(strcmp(a, b));
|
||||
} else {
|
||||
@@ -478,9 +478,9 @@ static int Replace_strcmp() {
|
||||
static int Replace_strncmp() {
|
||||
u32 bytes = PARAM(2);
|
||||
u32 aLen = SafeStringLen(PARAM(0), bytes);
|
||||
const char *a = (const char *)Memory::GetPointerRange(PARAM(0), aLen == 0 ? bytes : aLen);
|
||||
const char *a = (const char *)Memory::GetPointerRangeOrException(PARAM(0), aLen == 0 ? bytes : aLen);
|
||||
u32 bLen = SafeStringLen(PARAM(1), bytes);
|
||||
const char *b = (const char *)Memory::GetPointerRange(PARAM(1), bLen == 0 ? bytes : bLen);
|
||||
const char *b = (const char *)Memory::GetPointerRangeOrException(PARAM(1), bLen == 0 ? bytes : bLen);
|
||||
if (a && b && bytes != 0) {
|
||||
RETURN(strncmp(a, b, bytes));
|
||||
} else {
|
||||
@@ -495,9 +495,9 @@ static int Replace_fabsf() {
|
||||
}
|
||||
|
||||
static int Replace_vmmul_q_transp() {
|
||||
float_le *out = (float_le *)Memory::GetPointerRange(PARAM(0), 16 * 4);
|
||||
const float_le *a = (const float_le *)Memory::GetPointerRange(PARAM(1), 16 * 4);
|
||||
const float_le *b = (const float_le *)Memory::GetPointerRange(PARAM(2), 16 * 4);
|
||||
float_le *out = (float_le *)Memory::GetPointerRangeOrException(PARAM(0), 16 * 4);
|
||||
const float_le *a = (const float_le *)Memory::GetPointerRangeOrException(PARAM(1), 16 * 4);
|
||||
const float_le *b = (const float_le *)Memory::GetPointerRangeOrException(PARAM(2), 16 * 4);
|
||||
|
||||
// TODO: Actually use an optimized matrix multiply here...
|
||||
if (out && b && a) {
|
||||
@@ -522,8 +522,8 @@ static int Replace_vmmul_q_transp() {
|
||||
// a1 = matrix
|
||||
// a2 = source address
|
||||
static int Replace_gta_dl_write_matrix() {
|
||||
u32_le *ptr = (u32_le *)Memory::GetPointerWriteRange(PARAM(0), 4);
|
||||
const u32_le *src = (const u32_le *)Memory::GetPointerRange(PARAM(2), 16);
|
||||
u32_le *ptr = (u32_le *)Memory::GetPointerWriteRangeOrException(PARAM(0), 4);
|
||||
const u32_le *src = (const u32_le *)Memory::GetPointerRangeOrException(PARAM(2), 16);
|
||||
u32 matrix = PARAM(1) << 24;
|
||||
|
||||
if (!ptr || !src) {
|
||||
@@ -531,7 +531,7 @@ static int Replace_gta_dl_write_matrix() {
|
||||
return 38;
|
||||
}
|
||||
|
||||
u32_le *dest = (u32_le *)Memory::GetPointerWriteRange(ptr[0], 12 * 4);
|
||||
u32_le *dest = (u32_le *)Memory::GetPointerWriteRangeOrException(ptr[0], 12 * 4);
|
||||
if (!dest) {
|
||||
RETURN(0);
|
||||
return 38;
|
||||
@@ -581,8 +581,8 @@ static int Replace_gta_dl_write_matrix() {
|
||||
// TODO: Inline into a few NEON or SSE instructions - especially if a1 is a known immediate!
|
||||
// Anyway, not sure if worth it. There's not that many matrices written per frame normally.
|
||||
static int Replace_dl_write_matrix() {
|
||||
u32_le *dlStruct = (u32_le *)Memory::GetPointerWriteRange(PARAM(0), 3 * 4);
|
||||
const u32_le *src = (const u32_le *)Memory::GetPointerRange(PARAM(2), 16 * 4);
|
||||
u32_le *dlStruct = (u32_le *)Memory::GetPointerWriteRangeOrException(PARAM(0), 3 * 4);
|
||||
const u32_le *src = (const u32_le *)Memory::GetPointerRangeOrException(PARAM(2), 16 * 4);
|
||||
|
||||
if (!dlStruct || !src) {
|
||||
RETURN(0);
|
||||
@@ -607,7 +607,7 @@ static int Replace_dl_write_matrix() {
|
||||
break;
|
||||
}
|
||||
|
||||
u32_le *dest = (u32_le *)Memory::GetPointerWriteRange(dlStruct[2], 4 + count * 4);
|
||||
u32_le *dest = (u32_le *)Memory::GetPointerWriteRangeOrException(dlStruct[2], 4 + count * 4);
|
||||
if (!dest) {
|
||||
RETURN(0);
|
||||
return 60;
|
||||
|
||||
@@ -259,7 +259,7 @@ u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking) {
|
||||
if (chan.format == PSP_AUDIO_FORMAT_STEREO) {
|
||||
const u32 totalSamples = chan.sampleCount * 2;
|
||||
|
||||
s16_le *sampleData = (s16_le *) Memory::GetPointer(chan.sampleAddress);
|
||||
s16_le *sampleData = (s16_le *) Memory::GetPointerOrException(chan.sampleAddress);
|
||||
|
||||
// Walking a pointer for speed. But let's make sure we wouldn't trip on an invalid ptr.
|
||||
if (Memory::IsValidAddress(chan.sampleAddress + (totalSamples - 1) * sizeof(s16_le))) {
|
||||
|
||||
@@ -1202,7 +1202,7 @@ void AfterMatchingMipsCall::run(MipsCall &call) {
|
||||
u32 v0 = currentMIPS->r[MIPS_REG_V0];
|
||||
if (__IsInInterrupt()) ERROR_LOG(Log::sceNet, "AfterMatchingMipsCall::run [ID=%i][Event=%d] is Returning Inside an Interrupt!", contextID, EventID);
|
||||
//SetMatchingInCallback(context, false);
|
||||
DEBUG_LOG(Log::sceNet, "AfterMatchingMipsCall::run [ID=%i][Event=%d][%s] [cbId: %u][retV0: %08x]", contextID, EventID, mac2str((SceNetEtherAddr*)Memory::GetPointer(bufAddr)).c_str(), call.cbId, v0);
|
||||
DEBUG_LOG(Log::sceNet, "AfterMatchingMipsCall::run [ID=%i][Event=%d][%s] [cbId: %u][retV0: %08x]", contextID, EventID, mac2str((SceNetEtherAddr*)Memory::GetPointerOrException(bufAddr)).c_str(), call.cbId, v0);
|
||||
if (Memory::IsValidAddress(bufAddr)) userMemory.Free(bufAddr);
|
||||
//call.setReturnValue(v0);
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ static u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32
|
||||
return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_SIZE_TOO_SMALL);
|
||||
}
|
||||
|
||||
u8 *outPtr = outAddr ? Memory::GetPointerWrite(outAddr) : nullptr;
|
||||
u8 *outPtr = outAddr ? Memory::GetPointerWriteOrException(outAddr) : nullptr;
|
||||
|
||||
int ret = atrac->DecodeData(outPtr, outAddr, &numSamplesWritten, &finish, &remains);
|
||||
if (ret != (int)SCE_ERROR_ATRAC_BAD_ATRACID && ret != (int)SCE_ERROR_ATRAC_NO_DATA) {
|
||||
|
||||
@@ -256,9 +256,9 @@ static int sceAudiocodecDecode(u32 ctxPtr, int codec) {
|
||||
|
||||
DEBUG_LOG(Log::ME, "decoder. in: %08x out: %08x unk40: %02x unk41: %02x", ctx->inBuf, ctx->outBuf, ctx->unk40, ctx->unk41);
|
||||
|
||||
int16_t *outBuf = (int16_t *)Memory::GetPointerWrite(ctx->outBuf);
|
||||
int16_t *outBuf = (int16_t *)Memory::GetPointerWriteOrException(ctx->outBuf);
|
||||
|
||||
bool result = decoder->Decode(Memory::GetPointer(ctx->inBuf), bytesPerFrame, &inDataConsumed, 2, outBuf, &outSamples);
|
||||
bool result = decoder->Decode(Memory::GetPointerOrException(ctx->inBuf), bytesPerFrame, &inDataConsumed, 2, outBuf, &outSamples);
|
||||
if (!result) {
|
||||
ctx->err = 0x20b;
|
||||
ERROR_LOG(Log::ME, "AudioCodec decode failed. Setting error to %08x", ctx->err);
|
||||
|
||||
@@ -218,10 +218,10 @@ static int sub_17A8(KirkState *kirk, u8* data)
|
||||
|
||||
static int sceSdGetLastIndex(u32 addressCtx, u32 addressHash, u32 addressKey) {
|
||||
auto ctx = PSPPointer<pspChnnlsvContext1>::Create(addressCtx);
|
||||
u8 *hash = Memory::GetPointerWrite(addressHash);
|
||||
u8 *hash = Memory::GetPointerWriteOrException(addressHash);
|
||||
if (!ctx.IsValid() || !hash)
|
||||
return hleLogError(Log::sceMisc, 0, "Invalid pointer");
|
||||
return hleLogDebug(Log::sceMisc, sceSdMacFinal(*ctx, hash, Memory::GetPointerWrite(addressKey)));
|
||||
return hleLogDebug(Log::sceMisc, sceSdMacFinal(*ctx, hash, Memory::GetPointerWriteOrException(addressKey)));
|
||||
}
|
||||
|
||||
int sceSdMacFinal(pspChnnlsvContext1& ctx, u8* in_hash, const u8* in_key)
|
||||
@@ -347,7 +347,7 @@ static int sceSdRemoveValue(u32 addressCtx, u32 addressData, int length) {
|
||||
auto ctx = PSPPointer<pspChnnlsvContext1>::Create(addressCtx);
|
||||
if (!ctx.IsValid() || !Memory::IsValidAddress(addressData))
|
||||
return hleLogError(Log::sceMisc, 0, "Invalid pointer");
|
||||
return hleLogDebug(Log::sceMisc, sceSdMacUpdate(*ctx, Memory::GetPointerWrite(addressData), length));
|
||||
return hleLogDebug(Log::sceMisc, sceSdMacUpdate(*ctx, Memory::GetPointerWriteOrException(addressData), length));
|
||||
}
|
||||
|
||||
int sceSdMacUpdate(pspChnnlsvContext1& ctx, const u8* data, int length)
|
||||
@@ -394,8 +394,8 @@ int sceSdMacUpdate(pspChnnlsvContext1& ctx, const u8* data, int length)
|
||||
|
||||
static int sceSdCreateList(u32 ctx2Addr, int mode, int unkwn, u32 dataAddr, u32 cryptkeyAddr) {
|
||||
auto ctx2 = PSPPointer<pspChnnlsvContext2>::Create(ctx2Addr);
|
||||
u8* data = Memory::GetPointerWrite(dataAddr);
|
||||
u8* cryptkey = Memory::GetPointerWrite(cryptkeyAddr);
|
||||
u8* data = Memory::GetPointerWriteOrException(dataAddr);
|
||||
u8* cryptkey = Memory::GetPointerWriteOrException(cryptkeyAddr);
|
||||
if (!ctx2.IsValid() || !data)
|
||||
return hleLogError(Log::sceMisc, 0, "Invalid pointer");
|
||||
|
||||
@@ -458,7 +458,7 @@ int sceSdCipherInit(pspChnnlsvContext2& ctx2, int mode, int uknw, u8* data, cons
|
||||
|
||||
static int sceSdSetMember(u32 ctxAddr, u32 dataAddr, int alignedLen) {
|
||||
auto ctx = PSPPointer<pspChnnlsvContext2>::Create(ctxAddr);
|
||||
u8 *data = Memory::GetPointerWrite(dataAddr);
|
||||
u8 *data = Memory::GetPointerWriteOrException(dataAddr);
|
||||
if (!ctx.IsValid() || !data)
|
||||
return hleLogError(Log::sceMisc, 0, "Invalid pointer");
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ static int CommonDecompress(int windowBits, u32 OutBuffer, int OutBufferLength,
|
||||
}
|
||||
|
||||
z_stream stream{};
|
||||
u8 *outBufferPtr = Memory::GetPointerWrite(OutBuffer);
|
||||
stream.next_in = (Bytef*)Memory::GetPointer(InBuffer);
|
||||
u8 *outBufferPtr = Memory::GetPointerWriteOrException(OutBuffer);
|
||||
stream.next_in = (Bytef*)Memory::GetPointerOrException(InBuffer);
|
||||
// We don't know the available length, just let it use as much as it wants.
|
||||
stream.avail_in = (uInt)Memory::ClampValidSizeAt(InBuffer, Memory::g_MemorySize);
|
||||
stream.next_out = outBufferPtr;
|
||||
|
||||
@@ -284,7 +284,7 @@ void __DisplayDoState(PointerWrap &p) {
|
||||
}
|
||||
|
||||
if (s < 7) {
|
||||
u64 now = CoreTiming::GetTicks();
|
||||
u64 now = CoreTiming::GetTicks(currentMIPS);
|
||||
lastFlipCycles = now;
|
||||
nextFlipCycles = now;
|
||||
} else {
|
||||
@@ -796,7 +796,7 @@ static u32 sceDisplayIsVblank() {
|
||||
}
|
||||
|
||||
void __DisplayWaitForVblanks(const char *reason, int vblanks, bool callbacks) {
|
||||
const s64 ticksIntoFrame = CoreTiming::GetTicks() - DisplayFrameStartTicks();
|
||||
const s64 ticksIntoFrame = CoreTiming::GetTicks(currentMIPS) - DisplayFrameStartTicks();
|
||||
const s64 cyclesToNextVblank = msToCycles(frameMs) - ticksIntoFrame;
|
||||
|
||||
// These syscalls take about 115 us, so if the next vblank is before then, we're waiting extra.
|
||||
@@ -905,7 +905,7 @@ int sceDisplaySetFramebuf(u32 topaddr, int linesize, int pixelformat, int sync)
|
||||
// Otherwise it'll always be ahead if the game messes up even once.
|
||||
const s64 LEEWAY_CYCLES_PER_FLIP = usToCycles(10);
|
||||
|
||||
u64 now = CoreTiming::GetTicks();
|
||||
u64 now = CoreTiming::GetTicks(currentMIPS);
|
||||
s64 cyclesAhead = nextFlipCycles - now;
|
||||
if (cyclesAhead > FLIP_DELAY_CYCLES_MIN) {
|
||||
if (lastFlipsTooFrequent >= FLIP_DELAY_MIN_FLIPS) {
|
||||
@@ -1078,7 +1078,7 @@ static u32 sceDisplayGetMode(u32 modeAddr, u32 widthAddr, u32 heightAddr) {
|
||||
}
|
||||
|
||||
static u32 sceDisplayIsVsync() {
|
||||
u64 now = CoreTiming::GetTicks();
|
||||
u64 now = CoreTiming::GetTicks(currentMIPS);
|
||||
u64 start = DisplayFrameStartTicks() + msToCycles(vsyncStartMs);
|
||||
u64 end = DisplayFrameStartTicks() + msToCycles(vsyncEndMs);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ static int __DmacMemcpy(u32 dst, u32 src, u32 size) {
|
||||
if (size >= 272) {
|
||||
// Approx. 225 MiB/s or 235929600 B/s, so let's go with 236 B/us.
|
||||
int delayUs = size / 236;
|
||||
dmacMemcpyDeadline = CoreTiming::GetTicks() + usToCycles(delayUs);
|
||||
dmacMemcpyDeadline = CoreTiming::GetTicks(currentMIPS) + usToCycles(delayUs);
|
||||
return delayUs;
|
||||
} else {
|
||||
return 0;
|
||||
@@ -85,7 +85,7 @@ static u32 sceDmacMemcpy(u32 dst, u32 src, u32 size) {
|
||||
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_PRIV_REQUIRED, "illegal size");
|
||||
}
|
||||
|
||||
if (dmacMemcpyDeadline > CoreTiming::GetTicks()) {
|
||||
if (dmacMemcpyDeadline > CoreTiming::GetTicks(currentMIPS)) {
|
||||
WARN_LOG(Log::HLE, "sceDmacMemcpy(dest=%08x, src=%08x, size=%d): overlapping read", dst, src, size);
|
||||
// TODO: Should block, seems like copy doesn't start until previous finishes.
|
||||
// Might matter for overlapping copies.
|
||||
@@ -107,7 +107,7 @@ static u32 sceDmacTryMemcpy(u32 dst, u32 src, u32 size) {
|
||||
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_PRIV_REQUIRED, "illegal size");
|
||||
}
|
||||
|
||||
if (dmacMemcpyDeadline > CoreTiming::GetTicks()) {
|
||||
if (dmacMemcpyDeadline > CoreTiming::GetTicks(currentMIPS)) {
|
||||
return hleLogDebug(Log::HLE, SCE_KERNEL_ERROR_BUSY, "busy");
|
||||
}
|
||||
|
||||
|
||||
@@ -1096,7 +1096,7 @@ static u32 sceFontOpenUserMemory(u32 libHandle, u32 memoryFontPtr, u32 memoryFon
|
||||
return hleReportError(Log::sceFont, 0, "invalid size");
|
||||
}
|
||||
|
||||
const u8 *fontData = Memory::GetPointer(memoryFontPtr);
|
||||
const u8 *fontData = Memory::GetPointerOrException(memoryFontPtr);
|
||||
// Games are able to overstate the size of a font. Let's avoid crashing when we memcpy() it.
|
||||
// Unsigned 0xFFFFFFFF is treated as max, but that's impossible, so let's clamp to 64MB.
|
||||
if (memoryFontLength > 0x03FFFFFF)
|
||||
|
||||
+6
-6
@@ -274,7 +274,7 @@ void __GeShutdown() {
|
||||
|
||||
bool __GeTriggerSync(GPUSyncType type, int id, u64 atTicks) {
|
||||
u64 userdata = (u64)id << 32 | (u64)type;
|
||||
s64 future = atTicks - CoreTiming::GetTicks();
|
||||
s64 future = atTicks - CoreTiming::GetTicks(currentMIPS);
|
||||
if (type == GPU_SYNC_DRAW) {
|
||||
s64 left = CoreTiming::UnscheduleEvent(geSyncEvent, userdata);
|
||||
if (left > future)
|
||||
@@ -293,7 +293,7 @@ bool __GeTriggerInterrupt(int listid, u32 pc, u64 atTicks) {
|
||||
ge_pending_cb.push_back(intrdata);
|
||||
|
||||
u64 userdata = (u64)listid << 32 | (u64) pc;
|
||||
CoreTiming::ScheduleEvent(atTicks - CoreTiming::GetTicks(), geInterruptEvent, userdata);
|
||||
CoreTiming::ScheduleEvent(atTicks - CoreTiming::GetTicks(currentMIPS), geInterruptEvent, userdata);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -370,14 +370,14 @@ u32 sceGeListEnQueue(u32 listAddress, u32 stallAddress, int callbackId, u32 optP
|
||||
hleCoreTimingForceCheck();
|
||||
DEBUG_LOG(Log::sceGe,
|
||||
"%08x=sceGeListEnQueue(addr=%08x, stall=%08x, cbid=%08x, param=%08x) ticks=%lld", listID,
|
||||
listAddress, stallAddress, callbackId, optParamAddr, (long long)CoreTiming::GetTicks());
|
||||
listAddress, stallAddress, callbackId, optParamAddr, (long long)CoreTiming::GetTicks(currentMIPS));
|
||||
return hleNoLog(listID); // We already logged above, logs get confusing if we use hleLogSuccess.
|
||||
}
|
||||
|
||||
u32 sceGeListEnQueueHead(u32 listAddress, u32 stallAddress, int callbackId, u32 optParamAddr) {
|
||||
DEBUG_LOG(Log::sceGe,
|
||||
"sceGeListEnQueueHead(addr=%08x, stall=%08x, cbid=%08x, param=%08x) ticks=%lld",
|
||||
listAddress, stallAddress, callbackId, optParamAddr, (long long)CoreTiming::GetTicks());
|
||||
listAddress, stallAddress, callbackId, optParamAddr, (long long)CoreTiming::GetTicks(currentMIPS));
|
||||
auto optParam = PSPPointer<PspGeListArgs>::Create(optParamAddr);
|
||||
|
||||
bool runList;
|
||||
@@ -540,7 +540,7 @@ u32 sceGeSaveContext(u32 ctxAddr) {
|
||||
|
||||
// Let's just dump gstate.
|
||||
if (Memory::IsValidAddress(ctxAddr)) {
|
||||
gstate.Save((u32_le *)Memory::GetPointer(ctxAddr));
|
||||
gstate.Save((u32_le *)Memory::GetPointerOrException(ctxAddr));
|
||||
}
|
||||
|
||||
// This action should probably be pushed to the end of the queue of the display thread -
|
||||
@@ -554,7 +554,7 @@ u32 sceGeRestoreContext(u32 ctxAddr) {
|
||||
}
|
||||
|
||||
if (Memory::IsValidAddress(ctxAddr)) {
|
||||
gstate.Restore((u32_le *)Memory::GetPointer(ctxAddr));
|
||||
gstate.Restore((u32_le *)Memory::GetPointerOrException(ctxAddr));
|
||||
}
|
||||
|
||||
gpu->ReapplyGfxState();
|
||||
|
||||
@@ -158,7 +158,7 @@ int HTTPRequest::getAllResponseHeaders(u32 headerAddrPtr, u32 headerSizePtr) {
|
||||
headerSize_ = sz;
|
||||
}
|
||||
|
||||
u8* header = Memory::GetPointerWrite(headerAddr_);
|
||||
u8* header = Memory::GetPointerWriteOrException(headerAddr_);
|
||||
DEBUG_LOG(Log::sceNet, "headerAddr: %08x => %08x", headerAddr.IsValid() ? *headerAddr : 0, headerAddr_);
|
||||
DEBUG_LOG(Log::sceNet, "headerSize: %d => %d", headerSize.IsValid() ? *headerSize : 0, sz);
|
||||
if (!header && sz > 0) {
|
||||
|
||||
+8
-8
@@ -446,9 +446,9 @@ static void __IoAsyncNotify(u64 userdata, int cyclesLate) {
|
||||
__IoCompleteAsyncIO(f);
|
||||
} else if (ioTimingMethod == IOTIMING_REALISTIC) {
|
||||
u64 finishTicks = __IoCompleteAsyncIO(f);
|
||||
if (finishTicks > CoreTiming::GetTicks()) {
|
||||
if (finishTicks > CoreTiming::GetTicks(currentMIPS)) {
|
||||
// Reschedule for later, since we now know how long it ought to take.
|
||||
CoreTiming::ScheduleEvent(finishTicks - CoreTiming::GetTicks(), asyncNotifyEvent, userdata);
|
||||
CoreTiming::ScheduleEvent(finishTicks - CoreTiming::GetTicks(currentMIPS), asyncNotifyEvent, userdata);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -502,9 +502,9 @@ static void __IoSyncNotify(u64 userdata, int cyclesLate) {
|
||||
}
|
||||
} else if (ioTimingMethod == IOTIMING_REALISTIC) {
|
||||
u64 finishTicks = ioManager.ResultFinishTicks(f->handle);
|
||||
if (finishTicks > CoreTiming::GetTicks()) {
|
||||
if (finishTicks > CoreTiming::GetTicks(currentMIPS)) {
|
||||
// Reschedule for later when the result should finish.
|
||||
CoreTiming::ScheduleEvent(finishTicks - CoreTiming::GetTicks(), syncNotifyEvent, userdata);
|
||||
CoreTiming::ScheduleEvent(finishTicks - CoreTiming::GetTicks(currentMIPS), syncNotifyEvent, userdata);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -587,7 +587,7 @@ static void __IoManagerThread() {
|
||||
INFO_LOG(Log::sceIo, "Entering __IoManagerThread");
|
||||
AndroidJNIThreadContext jniContext;
|
||||
while (ioManagerThreadEnabled) {
|
||||
ioManager.RunEventsUntil(CoreTiming::GetTicks() + msToCycles(1000));
|
||||
ioManager.RunEventsUntil(CoreTiming::GetTicks(currentMIPS) + msToCycles(1000));
|
||||
}
|
||||
INFO_LOG(Log::sceIo, "Leaving __IoManagerThread");
|
||||
}
|
||||
@@ -887,7 +887,7 @@ u64 __IoCompleteAsyncIO(FileNode *f) {
|
||||
int ioTimingMethod = GetIOTimingMethod();
|
||||
if (ioTimingMethod == IOTIMING_REALISTIC) {
|
||||
u64 finishTicks = ioManager.ResultFinishTicks(f->handle);
|
||||
if (finishTicks > CoreTiming::GetTicks()) {
|
||||
if (finishTicks > CoreTiming::GetTicks(currentMIPS)) {
|
||||
return finishTicks;
|
||||
}
|
||||
}
|
||||
@@ -1196,7 +1196,7 @@ static bool __IoWrite(int &result, int id, u32 data_addr, int size, int &us) {
|
||||
us = 100;
|
||||
}
|
||||
|
||||
const void *data_ptr = Memory::GetPointer(data_addr);
|
||||
const void *data_ptr = Memory::GetPointerOrException(data_addr);
|
||||
const u32 validSize = Memory::ClampValidSizeAt(data_addr, size);
|
||||
// Let's handle stdout/stderr specially.
|
||||
if (id == PSP_STDOUT || id == PSP_STDERR) {
|
||||
@@ -2522,7 +2522,7 @@ static u32 sceIoDread(int id, u32 dirent_addr) {
|
||||
Core_MemoryException(dirent_addr, sizeof(SceIoDirEnt), currentMIPS->pc, MemoryExceptionType::WRITE_BLOCK, "sceIoDread");
|
||||
return hleLogError(Log::sceIo, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid address");
|
||||
}
|
||||
SceIoDirEnt *entry = (SceIoDirEnt*) Memory::GetPointer(dirent_addr);
|
||||
SceIoDirEnt *entry = (SceIoDirEnt*) Memory::GetPointerOrException(dirent_addr);
|
||||
|
||||
if (dir->index == (int) dir->listing.size()) {
|
||||
entry->d_name[0] = '\0';
|
||||
|
||||
@@ -396,7 +396,7 @@ static int JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) {
|
||||
}
|
||||
|
||||
#ifdef JPEG_DEBUG
|
||||
const u8 *jpegDumpBuf = Memory::GetPointer(jpegAddr);
|
||||
const u8 *jpegDumpBuf = Memory::GetPointerOrException(jpegAddr);
|
||||
u32 jpeg_xxhash = XXH32((const char *)jpegDumpBuf, jpegSize, 0xC0108888);
|
||||
Path jpegDir("Jpeg");
|
||||
Path jpegFile = jpegDir / StringFromFormat("%X.jpg", jpeg_xxhash);
|
||||
|
||||
@@ -927,7 +927,7 @@ static bool KernelImportModuleFuncs(PSPModule *module, u32 *firstImportStubAddr,
|
||||
|
||||
if (needReport) {
|
||||
std::string debugInfo;
|
||||
entryPos = (const u32_le *)Memory::GetPointer(module->libstub);
|
||||
entryPos = (const u32_le *)Memory::GetPointerOrException(module->libstub);
|
||||
while (entryPos < entryEnd) {
|
||||
const PspLibStubEntry *entry = (const PspLibStubEntry *)entryPos;
|
||||
entryPos += entry->size;
|
||||
@@ -1453,8 +1453,8 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
|
||||
module->nm.stub_top = modinfo->libstub;
|
||||
module->nm.stub_size = modinfo->libstubend - modinfo->libstub;
|
||||
|
||||
const u32_le *entPos = (u32_le *)Memory::GetPointer(modinfo->libent);
|
||||
const u32_le *entEnd = (u32_le *)Memory::GetPointer(modinfo->libentend);
|
||||
const u32_le *entPos = (u32_le *)Memory::GetPointerOrException(modinfo->libent);
|
||||
const u32_le *entEnd = (u32_le *)Memory::GetPointerOrException(modinfo->libentend);
|
||||
|
||||
for (int m = 0; entPos < entEnd; ++m) {
|
||||
const PspLibEntEntry *ent = (const PspLibEntEntry *)entPos;
|
||||
@@ -1781,7 +1781,7 @@ void __KernelLoadReset() {
|
||||
__KernelInit();
|
||||
}
|
||||
|
||||
bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_string) {
|
||||
bool __KernelLoadExec(MIPSState *mips, const char *filename, u32 paramPtr, std::string *error_string) {
|
||||
SceKernelLoadExecParam param{};
|
||||
|
||||
auto paramData = PSPPointer<SceKernelLoadExecParam>::Create(paramPtr);
|
||||
@@ -1836,9 +1836,9 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str
|
||||
truncate_cpy(moduleName, module->nm.name);
|
||||
Reporting::NotifyExecModule(moduleName, moduleVersion, module->crc);
|
||||
|
||||
mipsr4k.pc = module->nm.entry_addr;
|
||||
currentMIPS->pc = module->nm.entry_addr;
|
||||
|
||||
INFO_LOG(Log::Loader, "Module entry: %08x (%s %04x)", mipsr4k.pc, moduleName, moduleVersion);
|
||||
INFO_LOG(Log::Loader, "Module entry: %08x (%s %04x)", currentMIPS->pc, moduleName, moduleVersion);
|
||||
|
||||
SceKernelSMOption option;
|
||||
option.size = sizeof(SceKernelSMOption);
|
||||
@@ -1957,7 +1957,7 @@ int sceKernelLoadExec(const char *filename, u32 paramPtr) {
|
||||
|
||||
DEBUG_LOG(Log::sceModule, "sceKernelLoadExec(name=%s,...): loading %s", filename, exec_filename.c_str());
|
||||
std::string error_string;
|
||||
if (!__KernelLoadExec(exec_filename.c_str(), paramPtr, &error_string)) {
|
||||
if (!__KernelLoadExec(currentMIPS, exec_filename.c_str(), paramPtr, &error_string)) {
|
||||
Core_UpdateState(CORE_RUNTIME_ERROR);
|
||||
return hleLogError(Log::sceModule, -1, "failed: %s", error_string.c_str());;
|
||||
}
|
||||
@@ -2017,7 +2017,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
|
||||
}
|
||||
const SceKernelLMOption *lmoption = 0;
|
||||
if (optionAddr) {
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointer(optionAddr);
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointerOrException(optionAddr);
|
||||
if (lmoption->position < PSP_SMEM_Low || lmoption->position > PSP_SMEM_HighAligned) {
|
||||
ERROR_LOG_REPORT(Log::Loader, "sceKernelLoadModule(%s): invalid position (%i)", name, (int)lmoption->position);
|
||||
return hleDelayResult(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE, "module loaded", 500);
|
||||
@@ -2054,7 +2054,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
|
||||
if (gpu) {
|
||||
gpu->Reinitialize();
|
||||
}
|
||||
return __KernelLoadExec(safeName.c_str(), 0, &error_string);
|
||||
return __KernelLoadExec(currentMIPS, safeName.c_str(), 0, &error_string);
|
||||
} else {
|
||||
return hleDelayResult(hleLogError(Log::Loader, error, "failed to load"), "module loaded", 500);
|
||||
}
|
||||
@@ -2486,7 +2486,7 @@ static u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr) {
|
||||
}
|
||||
const SceKernelLMOption *lmoption = 0;
|
||||
if (lmoptionPtr) {
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointer(lmoptionPtr);
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointerOrException(lmoptionPtr);
|
||||
WARN_LOG_REPORT(Log::Loader, "sceKernelLoadModuleByID: unsupported options size=%08x, flags=%08x, pos=%d, access=%d, data=%d, text=%d", lmoption->size, lmoption->flags, lmoption->position, lmoption->access, lmoption->mpiddata, lmoption->mpidtext);
|
||||
}
|
||||
u32 pos = (u32)pspFileSystem.SeekFile(handle, 0, FILEMOVE_CURRENT);
|
||||
@@ -2547,7 +2547,7 @@ SceUID sceKernelLoadModuleBufferUsbWlan(u32 size, u32 bufPtr, u32 flags, u32 lmo
|
||||
}
|
||||
const SceKernelLMOption *lmoption = 0;
|
||||
if (lmoptionPtr) {
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointer(lmoptionPtr);
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointerOrException(lmoptionPtr);
|
||||
WARN_LOG_REPORT(Log::Loader, "sceKernelLoadModuleBufferUsbWlan: unsupported options size=%08x, flags=%08x, pos=%d, access=%d, data=%d, text=%d", lmoption->size, lmoption->flags, lmoption->position, lmoption->access, lmoption->mpiddata, lmoption->mpidtext);
|
||||
}
|
||||
std::string error_string;
|
||||
@@ -2559,7 +2559,7 @@ SceUID sceKernelLoadModuleBufferUsbWlan(u32 size, u32 bufPtr, u32 flags, u32 lmo
|
||||
char fakeDebugFilename[512];
|
||||
snprintf(fakeDebugFilename, sizeof(fakeDebugFilename), "moduleByPtr_%08x_%d", bufPtr, (int)size);
|
||||
|
||||
module = __KernelLoadELFFromPtr(Memory::GetPointer(bufPtr), size, 0, lmoption ? lmoption->position == PSP_SMEM_High : false, &error_string, &magic, fakeDebugFilename, error);
|
||||
module = __KernelLoadELFFromPtr(Memory::GetPointerOrException(bufPtr), size, 0, lmoption ? lmoption->position == PSP_SMEM_High : false, &error_string, &magic, fakeDebugFilename, error);
|
||||
|
||||
if (!module) {
|
||||
// Some games try to load strange stuff as PARAM.SFO as modules and expect it to fail.
|
||||
|
||||
@@ -231,10 +231,12 @@ KernelObject *__KernelModuleObject();
|
||||
void __KernelModuleDoState(PointerWrap &p);
|
||||
void __KernelModuleShutdown();
|
||||
|
||||
class MIPSState;
|
||||
|
||||
u32 __KernelGetModuleGP(SceUID module);
|
||||
bool KernelModuleIsKernelMode(SceUID module);
|
||||
bool __KernelLoadGEDump(std::string_view base_filename, std::string *error_string);
|
||||
bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_string);
|
||||
bool __KernelLoadExec(MIPSState *mips, const char *filename, u32 paramPtr, std::string *error_string);
|
||||
bool KernelFindImportByStubAddr(u32 stubAddr, std::string *importModuleName, u32 *nid, std::string *importingModuleName);
|
||||
// Describes which loaded module (and section within it) an address falls in, e.g. "EBOOT.BIN.text+1234".
|
||||
// Returns an empty string if the address isn't inside any currently loaded module.
|
||||
|
||||
@@ -222,7 +222,7 @@ struct MsgPipe : public KernelObject
|
||||
// Receive as much as possible, even if it's not enough to wake up.
|
||||
u32 bytesToSend = std::min(thread->freeSize, GetUsedSize());
|
||||
|
||||
u8* ptr = Memory::GetPointerWrite(buffer);
|
||||
u8* ptr = Memory::GetPointerWriteOrException(buffer);
|
||||
thread->WriteBuffer(buffer, bytesToSend);
|
||||
// Put the unused data at the start of the buffer.
|
||||
nmp.freeSize += bytesToSend;
|
||||
@@ -496,7 +496,7 @@ static int __KernelReceiveMsgPipe(MsgPipe *m, u32 receiveBufAddr, u32 receiveSiz
|
||||
{
|
||||
Memory::Memcpy(curReceiveAddr, m->buffer, bytesToReceive, "MsgPipeReceive");
|
||||
m->nmp.freeSize += bytesToReceive;
|
||||
memmove(Memory::GetPointerWrite(m->buffer), Memory::GetPointer(m->buffer) + bytesToReceive, m->GetUsedSize());
|
||||
memmove(Memory::GetPointerWriteOrException(m->buffer), Memory::GetPointerOrException(m->buffer) + bytesToReceive, m->GetUsedSize());
|
||||
curReceiveAddr += bytesToReceive;
|
||||
receiveSize -= bytesToReceive;
|
||||
|
||||
|
||||
@@ -664,7 +664,7 @@ static void __KernelDelayEndCallback(SceUID threadID, SceUID prevCallbackId) {
|
||||
|
||||
// TODO: Don't wake up if __KernelCurHasReadyCallbacks()?
|
||||
|
||||
s64 cyclesLeft = delayDeadline - CoreTiming::GetTicks();
|
||||
s64 cyclesLeft = delayDeadline - CoreTiming::GetTicks(currentMIPS);
|
||||
if (cyclesLeft < 0) {
|
||||
__KernelResumeThreadFromWait(threadID, 0);
|
||||
} else {
|
||||
@@ -884,7 +884,7 @@ void __KernelThreadingDoState(PointerWrap &p)
|
||||
Do(p, pausedDelays);
|
||||
|
||||
__SetCurrentThread(kernelObjects.GetFast<PSPThread>(currentThread), currentThread, __KernelGetThreadName(currentThread));
|
||||
lastSwitchCycles = CoreTiming::GetTicks();
|
||||
lastSwitchCycles = CoreTiming::GetTicks(currentMIPS);
|
||||
|
||||
if (s >= 2)
|
||||
Do(p, threadEventHandlers);
|
||||
@@ -1037,7 +1037,7 @@ void __KernelIdle()
|
||||
// Don't skip 0xDEADBEEF here, this is called directly bypassing CallSyscall().
|
||||
// That means the hle flag would stick around until the next call.
|
||||
|
||||
CoreTiming::Idle();
|
||||
CoreTiming::Idle(currentMIPS);
|
||||
// We Advance within __KernelReSchedule(), so anything that has now happened after idle
|
||||
// will be triggered properly upon reschedule.
|
||||
__KernelReSchedule("idle");
|
||||
@@ -2943,7 +2943,7 @@ void __KernelSwitchContext(PSPThread *target, const char *reason) {
|
||||
#if DEBUG_LEVEL <= MAX_LOGLEVEL || DEBUG_LOG == NOTICE_LOG
|
||||
if (!(fromIdle && toIdle))
|
||||
{
|
||||
u64 nowCycles = CoreTiming::GetTicks();
|
||||
u64 nowCycles = CoreTiming::GetTicks(currentMIPS);
|
||||
s64 consumedCycles = nowCycles - lastSwitchCycles;
|
||||
lastSwitchCycles = nowCycles;
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ u32 sceKernelLibcGettimeofday(u32 timeAddr, u32 tzAddr)
|
||||
// TODO: tzAddr?
|
||||
if (Memory::IsValidAddress(timeAddr))
|
||||
{
|
||||
PSPTimeval *tv = (PSPTimeval *)Memory::GetPointer(timeAddr);
|
||||
PSPTimeval *tv = (PSPTimeval *)Memory::GetPointerOrException(timeAddr);
|
||||
__RtcTimeOfDay(tv);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ u32 sceKernelUtilsMt19937Init(u32 ctx, u32 seed) {
|
||||
DEBUG_LOG(Log::HLE, "sceKernelUtilsMt19937Init(%08x, %08x)", ctx, seed);
|
||||
if (!Memory::IsValidAddress(ctx))
|
||||
return -1;
|
||||
void *ptr = Memory::GetPointerWrite(ctx);
|
||||
void *ptr = Memory::GetPointerWriteOrException(ctx);
|
||||
// This is made to match the memory layout of a PSP MT structure exactly.
|
||||
// Let's just construct it in place with placement new. Elite C++ hackery FTW.
|
||||
new (ptr) MersenneTwister(seed);
|
||||
|
||||
@@ -923,7 +923,7 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
|
||||
for (int i = 0; i < pmp_nBlocks; i++){
|
||||
auto lli = PSPPointer<SceMpegLLI>::Create(pmp_videoSource);
|
||||
// add source block into pmpframes
|
||||
const uint8_t *ptr = Memory::GetPointerRange(lli->pSrc, lli->iSize);
|
||||
const uint8_t *ptr = Memory::GetPointerRangeOrException(lli->pSrc, lli->iSize);
|
||||
if (ptr)
|
||||
pmpframes->add(ptr, lli->iSize);
|
||||
// get next block
|
||||
@@ -1449,7 +1449,7 @@ void PostPutAction::run(MipsCall &call) {
|
||||
auto demuxer = std::make_unique<MpegDemux>(packetsAddedThisRound * 2048, 0);
|
||||
int readOffset = ringbuffer->packetsRead % (s32)ringbuffer->packets;
|
||||
uint32_t bufSize = Memory::ClampValidSizeAt(ringbuffer->data + readOffset * 2048, packetsAddedThisRound * 2048);
|
||||
const u8 *buf = Memory::GetPointer(ringbuffer->data + readOffset * 2048);
|
||||
const u8 *buf = Memory::GetPointerOrException(ringbuffer->data + readOffset * 2048);
|
||||
bool invalid = false;
|
||||
for (uint32_t i = 0; i < bufSize / 2048; ++i) {
|
||||
demuxer->addStreamData(buf, 2048);
|
||||
@@ -1484,7 +1484,7 @@ void PostPutAction::run(MipsCall &call) {
|
||||
WARN_LOG(Log::Mpeg, "sceMpegRingbufferPut clamping packetsAdded old=%i new=%i", packetsAddedThisRound, ringbuffer->packets - ringbuffer->packetsAvail);
|
||||
packetsAddedThisRound = ringbuffer->packets - ringbuffer->packetsAvail;
|
||||
}
|
||||
const u8 *data = Memory::GetPointer(ringbuffer->data + writeOffset * 2048);
|
||||
const u8 *data = Memory::GetPointerOrException(ringbuffer->data + writeOffset * 2048);
|
||||
uint32_t dataSize = Memory::ClampValidSizeAt(ringbuffer->data + writeOffset * 2048, packetsAddedThisRound * 2048);
|
||||
int actuallyAdded = ctx->mediaengine == NULL ? 8 : ctx->mediaengine->addStreamData(data, dataSize) / 2048;
|
||||
if (actuallyAdded != packetsAddedThisRound) {
|
||||
@@ -2102,7 +2102,7 @@ static int __MpegAvcConvertToYuv420(const void *data, u32 bufferOutputAddr, int
|
||||
u32 *imageBuffer = (u32*)data;
|
||||
int sizeY = width * height;
|
||||
int sizeCb = sizeY >> 2;
|
||||
u8 *Y = Memory::GetPointerWriteRange(bufferOutputAddr, sizeY + sizeCb + sizeCb);
|
||||
u8 *Y = Memory::GetPointerWriteRangeOrException(bufferOutputAddr, sizeY + sizeCb + sizeCb);
|
||||
u8 *Cb = Y + sizeY;
|
||||
u8 *Cr = Cb + sizeCb;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ static u32 sceMt19937UInt(u32 mt19937Addr)
|
||||
{
|
||||
if (!Memory::IsValidAddress(mt19937Addr))
|
||||
return hleLogError(Log::HLE, -1);
|
||||
MersenneTwister *mt = (MersenneTwister *)Memory::GetPointer(mt19937Addr);
|
||||
MersenneTwister *mt = (MersenneTwister *)Memory::GetPointerOrException(mt19937Addr);
|
||||
return hleLogVerbose(Log::HLE, mt->R32());
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1098,7 +1098,7 @@ static void sceNetEtherStrton(u32 bufferPtr, u32 macPtr) {
|
||||
|
||||
if (Memory::IsValidAddress(bufferPtr) && Memory::IsValidAddress(macPtr)) {
|
||||
const char *buffer = (const char *)Memory::GetPointerUnchecked(bufferPtr);
|
||||
u8 *mac = Memory::GetPointerWrite(macPtr);
|
||||
u8 *mac = Memory::GetPointerWriteOrException(macPtr);
|
||||
|
||||
// MAC address is always 6 pairs of hex digits.
|
||||
// TODO: Funny stuff happens if it's too short.
|
||||
@@ -1124,7 +1124,7 @@ static void sceNetEtherStrton(u32 bufferPtr, u32 macPtr) {
|
||||
}
|
||||
}
|
||||
|
||||
VERBOSE_LOG(Log::sceNet, "sceNetEtherStrton - [%s]", mac2str((SceNetEtherAddr*)Memory::GetPointer(macPtr)).c_str());
|
||||
VERBOSE_LOG(Log::sceNet, "sceNetEtherStrton - [%s]", mac2str((SceNetEtherAddr*)Memory::GetPointerOrException(macPtr)).c_str());
|
||||
// Seems to maybe kinda return the last value. Probably returns void.
|
||||
//return value;
|
||||
}
|
||||
|
||||
+21
-21
@@ -2986,7 +2986,7 @@ int sceNetAdhocPollSocket(u32 socketStructAddr, int count, int timeout, int nonb
|
||||
if (netAdhocInited)
|
||||
{
|
||||
SceNetAdhocPollSd * sds = NULL;
|
||||
if (Memory::IsValidAddress(socketStructAddr)) sds = (SceNetAdhocPollSd *)Memory::GetPointer(socketStructAddr);
|
||||
if (Memory::IsValidAddress(socketStructAddr)) sds = (SceNetAdhocPollSd *)Memory::GetPointerOrException(socketStructAddr);
|
||||
|
||||
// Valid Arguments
|
||||
if (sds != NULL && count > 0)
|
||||
@@ -3201,11 +3201,11 @@ int sceNetAdhocctlScan() {
|
||||
int sceNetAdhocctlGetScanInfo(u32 sizeAddr, u32 bufAddr) {
|
||||
s32_le *buflen = NULL;
|
||||
if (Memory::IsValidAddress(sizeAddr)) {
|
||||
buflen = (s32_le *)Memory::GetPointer(sizeAddr);
|
||||
buflen = (s32_le *)Memory::GetPointerOrException(sizeAddr);
|
||||
}
|
||||
SceNetAdhocctlScanInfoEmu *buf = NULL;
|
||||
if (Memory::IsValidAddress(bufAddr)) {
|
||||
buf = (SceNetAdhocctlScanInfoEmu *)Memory::GetPointer(bufAddr);
|
||||
buf = (SceNetAdhocctlScanInfoEmu *)Memory::GetPointerOrException(bufAddr);
|
||||
}
|
||||
|
||||
INFO_LOG(Log::sceNet, "sceNetAdhocctlGetScanInfo([%08x]=%i, %08x) at %08x", sizeAddr, Memory::ReadUnchecked_U32(sizeAddr), bufAddr, currentMIPS->pc);
|
||||
@@ -3518,7 +3518,7 @@ static int sceNetAdhocctlGetNameByAddr(const char *mac, u32 nameAddr) {
|
||||
// Valid Arguments
|
||||
if (mac != NULL && Memory::IsValidAddress(nameAddr))
|
||||
{
|
||||
SceNetAdhocctlNickname * nickname = (SceNetAdhocctlNickname *)Memory::GetPointer(nameAddr);
|
||||
SceNetAdhocctlNickname * nickname = (SceNetAdhocctlNickname *)Memory::GetPointerOrException(nameAddr);
|
||||
// Get Local MAC Address
|
||||
SceNetEtherAddr localmac;
|
||||
getLocalMac(&localmac);
|
||||
@@ -3584,7 +3584,7 @@ int sceNetAdhocctlGetPeerInfo(const char *mac, int size, u32 peerInfoAddr) {
|
||||
SceNetEtherAddr * maddr = (SceNetEtherAddr *)mac;
|
||||
SceNetAdhocctlPeerInfoEmu * buf = NULL;
|
||||
if (Memory::IsValidAddress(peerInfoAddr)) {
|
||||
buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointer(peerInfoAddr);
|
||||
buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointerOrException(peerInfoAddr);
|
||||
}
|
||||
// Library initialized
|
||||
if (netAdhocctlInited) {
|
||||
@@ -3755,7 +3755,7 @@ int sceNetAdhocctlJoin(u32 scanInfoAddr) {
|
||||
// Valid Argument
|
||||
if (Memory::IsValidAddress(scanInfoAddr))
|
||||
{
|
||||
SceNetAdhocctlScanInfoEmu* sinfo = (SceNetAdhocctlScanInfoEmu*)Memory::GetPointer(scanInfoAddr);
|
||||
SceNetAdhocctlScanInfoEmu* sinfo = (SceNetAdhocctlScanInfoEmu*)Memory::GetPointerOrException(scanInfoAddr);
|
||||
char grpName[ADHOCCTL_GROUPNAME_LEN + 1] = { 0 };
|
||||
memcpy(grpName, sinfo->group_name.data, ADHOCCTL_GROUPNAME_LEN); // For logging purpose, must not be truncated
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocctlJoin - Group: %s", grpName);
|
||||
@@ -3943,9 +3943,9 @@ static int sceNetAdhocGetPdpStat(u32 structSize, u32 structAddr) {
|
||||
if (netAdhocInited)
|
||||
{
|
||||
s32_le *buflen = NULL;
|
||||
if (Memory::IsValidAddress(structSize)) buflen = (s32_le *)Memory::GetPointer(structSize);
|
||||
if (Memory::IsValidAddress(structSize)) buflen = (s32_le *)Memory::GetPointerOrException(structSize);
|
||||
SceNetAdhocPdpStat *buf = NULL;
|
||||
if (Memory::IsValidAddress(structAddr)) buf = (SceNetAdhocPdpStat *)Memory::GetPointer(structAddr);
|
||||
if (Memory::IsValidAddress(structAddr)) buf = (SceNetAdhocPdpStat *)Memory::GetPointerOrException(structAddr);
|
||||
|
||||
// Socket Count
|
||||
int socketcount = getPDPSocketCount();
|
||||
@@ -4049,9 +4049,9 @@ static int sceNetAdhocGetPtpStat(u32 structSize, u32 structAddr) {
|
||||
VERBOSE_LOG(Log::sceNet,"sceNetAdhocGetPtpStat(%08x, %08x) at %08x",structSize,structAddr,currentMIPS->pc);
|
||||
|
||||
s32_le *buflen = NULL;
|
||||
if (Memory::IsValidAddress(structSize)) buflen = (s32_le *)Memory::GetPointer(structSize);
|
||||
if (Memory::IsValidAddress(structSize)) buflen = (s32_le *)Memory::GetPointerOrException(structSize);
|
||||
SceNetAdhocPtpStat *buf = NULL;
|
||||
if (Memory::IsValidAddress(structAddr)) buf = (SceNetAdhocPtpStat *)Memory::GetPointer(structAddr);
|
||||
if (Memory::IsValidAddress(structAddr)) buf = (SceNetAdhocPtpStat *)Memory::GetPointerOrException(structAddr);
|
||||
|
||||
// Library is initialized
|
||||
if (netAdhocInited) {
|
||||
@@ -4637,7 +4637,7 @@ static int sceNetAdhocPtpAccept(int id, u32 peerMacAddrPtr, u32 peerPortPtr, int
|
||||
}
|
||||
uint16_t * port = NULL; //
|
||||
if (Memory::IsValidAddress(peerPortPtr)) {
|
||||
port = (uint16_t *)Memory::GetPointer(peerPortPtr);
|
||||
port = (uint16_t *)Memory::GetPointerOrException(peerPortPtr);
|
||||
}
|
||||
if (flag == 0) { // Prevent spamming Debug Log with retries of non-bocking socket
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocPtpAccept(%d, [%08x]=%s, [%08x]=%u, %d, %u) at %08x", id, peerMacAddrPtr, mac2str(addr).c_str(), peerPortPtr, port ? *port : -1, timeout, flag, currentMIPS->pc);
|
||||
@@ -5211,7 +5211,7 @@ static int sceNetAdhocPtpListen(const char *srcmac, int sport, int bufsize, int
|
||||
static int sceNetAdhocPtpSend(int id, u32 dataAddr, u32 dataSizeAddr, int timeout, int flag) {
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocPtpSend(%d,%08x,%08x,%d,%d) at %08x", id, dataAddr, dataSizeAddr, timeout, flag, currentMIPS->pc);
|
||||
|
||||
int * len = (int *)Memory::GetPointer(dataSizeAddr);
|
||||
int * len = (int *)Memory::GetPointerOrException(dataSizeAddr);
|
||||
const char * data = Memory::GetCharPointer(dataAddr);
|
||||
// Library is initialized
|
||||
if (netAdhocInited) {
|
||||
@@ -5331,8 +5331,8 @@ static int sceNetAdhocPtpSend(int id, u32 dataAddr, u32 dataSizeAddr, int timeou
|
||||
static int sceNetAdhocPtpRecv(int id, u32 dataAddr, u32 dataSizeAddr, int timeout, int flag) {
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocPtpRecv(%d,%08x,%08x,%d,%d) at %08x", id, dataAddr, dataSizeAddr, timeout, flag, currentMIPS->pc);
|
||||
|
||||
void * buf = (void *)Memory::GetPointer(dataAddr);
|
||||
int * len = (int *)Memory::GetPointer(dataSizeAddr);
|
||||
void * buf = (void *)Memory::GetPointerOrException(dataAddr);
|
||||
int * len = (int *)Memory::GetPointerOrException(dataSizeAddr);
|
||||
// Library is initialized
|
||||
if (netAdhocInited) {
|
||||
// Valid Arguments
|
||||
@@ -5726,7 +5726,7 @@ static int sceNetAdhocGameModeUpdateReplica(int id, u32 infoAddr) {
|
||||
// Bomberman Panic Bomber is using 0/null on infoAddr, so i guess it's optional.
|
||||
GameModeUpdateInfo* gmuinfo = NULL;
|
||||
if (Memory::IsValidAddress(infoAddr)) {
|
||||
gmuinfo = (GameModeUpdateInfo*)Memory::GetPointer(infoAddr);
|
||||
gmuinfo = (GameModeUpdateInfo*)Memory::GetPointerOrException(infoAddr);
|
||||
}
|
||||
|
||||
for (auto& gma : replicaGameModeAreas) {
|
||||
@@ -5943,7 +5943,7 @@ static int sceNetAdhocctlGetGameModeInfo(u32 infoAddr) {
|
||||
if (!Memory::IsValidAddress(infoAddr))
|
||||
return hleLogError(Log::sceNet, SCE_NET_ADHOCCTL_ERROR_INVALID_ARG, "invalid arg");
|
||||
|
||||
SceNetAdhocctlGameModeInfo* gmInfo = (SceNetAdhocctlGameModeInfo*)Memory::GetPointer(infoAddr);
|
||||
SceNetAdhocctlGameModeInfo* gmInfo = (SceNetAdhocctlGameModeInfo*)Memory::GetPointerOrException(infoAddr);
|
||||
// Writes number of participants and each participating MAC address into infoAddr/gmInfo
|
||||
gmInfo->num = static_cast<s32_le>(gameModeMacs.size());
|
||||
int i = 0;
|
||||
@@ -5961,11 +5961,11 @@ static int sceNetAdhocctlGetGameModeInfo(u32 infoAddr) {
|
||||
static int sceNetAdhocctlGetPeerList(u32 sizeAddr, u32 bufAddr) {
|
||||
s32_le *buflen = NULL;
|
||||
if (Memory::IsValidAddress(sizeAddr)) {
|
||||
buflen = (s32_le *)Memory::GetPointer(sizeAddr);
|
||||
buflen = (s32_le *)Memory::GetPointerOrException(sizeAddr);
|
||||
}
|
||||
SceNetAdhocctlPeerInfoEmu *buf = NULL;
|
||||
if (Memory::IsValidAddress(bufAddr)) {
|
||||
buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointer(bufAddr);
|
||||
buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointerOrException(bufAddr);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocctlGetPeerList([%08x]=%i, %08x) at %08x", sizeAddr, /*buflen ? *buflen : -1*/Memory::ReadUnchecked_U32(sizeAddr), bufAddr, currentMIPS->pc);
|
||||
@@ -6058,7 +6058,7 @@ static int sceNetAdhocctlGetPeerList(u32 sizeAddr, u32 bufAddr) {
|
||||
|
||||
static int sceNetAdhocctlGetAddrByName(const char *nickName, u32 sizeAddr, u32 bufAddr) {
|
||||
s32_le *buflen = NULL; //int32_t
|
||||
if (Memory::IsValidAddress(sizeAddr)) buflen = (s32_le *)Memory::GetPointer(sizeAddr);
|
||||
if (Memory::IsValidAddress(sizeAddr)) buflen = (s32_le *)Memory::GetPointerOrException(sizeAddr);
|
||||
|
||||
if (!nickName || !buflen) {
|
||||
return hleLogError(Log::sceNet, SCE_NET_ADHOCCTL_ERROR_INVALID_ARG);
|
||||
@@ -6075,7 +6075,7 @@ static int sceNetAdhocctlGetAddrByName(const char *nickName, u32 sizeAddr, u32 b
|
||||
{
|
||||
{
|
||||
SceNetAdhocctlPeerInfoEmu *buf = NULL;
|
||||
if (Memory::IsValidAddress(bufAddr)) buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointer(bufAddr);
|
||||
if (Memory::IsValidAddress(bufAddr)) buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointerOrException(bufAddr);
|
||||
|
||||
// Multithreading Lock
|
||||
peerlock.lock();
|
||||
@@ -6219,7 +6219,7 @@ int sceNetAdhocDiscoverInitStart(u32 paramAddr) {
|
||||
//if (Memory::ReadOrException_U32(netAdhocDiscoverBufAddr + 0x80) != 0) //if (*((int*)Memory::GetPointer(0x000010B0)) != 0)
|
||||
// return 0x80411301; // Already Initialized/Started?
|
||||
// TODO: Need to findout whether using invalid params or param address will return an error code or not
|
||||
netAdhocDiscoverParam = (SceNetAdhocDiscoverParam*)Memory::GetPointer(paramAddr);
|
||||
netAdhocDiscoverParam = (SceNetAdhocDiscoverParam*)Memory::GetPointerOrException(paramAddr);
|
||||
if (!netAdhocDiscoverParam)
|
||||
return hleLogError(Log::sceNet, -1, "invalid param?");
|
||||
// FIXME: paramAddr seems to be stored at 0x000010D8 without validating the value first
|
||||
|
||||
@@ -86,7 +86,7 @@ void notifyMatchingHandler(SceNetAdhocMatchingContext * context, ThreadMessage *
|
||||
MatchingArgs argsNew = { 0 };
|
||||
u32_le dataBufLen = msg->optlen + 8; //max(bufLen, msg->optlen + 8);
|
||||
u32_le dataBufAddr = userMemory.Alloc(dataBufLen); // We will free this memory after returning from mipscall. FIXME: Are these buffers supposed to be taken/pre-allocated from the memory pool during sceNetAdhocMatchingInit?
|
||||
uint8_t *dataPtr = Memory::GetPointerWriteRange(dataBufAddr, dataBufLen);
|
||||
uint8_t *dataPtr = Memory::GetPointerWriteRangeOrException(dataBufAddr, dataBufLen);
|
||||
if (dataPtr) {
|
||||
memcpy(dataPtr, &msg->mac, sizeof(msg->mac));
|
||||
if (msg->optlen > 0)
|
||||
@@ -2594,7 +2594,7 @@ int sceNetAdhocMatchingGetPoolStat(u32 poolstatPtr) {
|
||||
}
|
||||
|
||||
SceNetMallocStat * poolstat = NULL;
|
||||
if (Memory::IsValidAddress(poolstatPtr)) poolstat = (SceNetMallocStat *)Memory::GetPointer(poolstatPtr);
|
||||
if (Memory::IsValidAddress(poolstatPtr)) poolstat = (SceNetMallocStat *)Memory::GetPointerOrException(poolstatPtr);
|
||||
|
||||
if (poolstat == NULL) {
|
||||
// Invalid Argument
|
||||
@@ -2628,10 +2628,10 @@ void __NetMatchingCallbacks() { //(int matchingId)
|
||||
actionAfterMatchingMipsCall = __KernelRegisterActionType(AfterMatchingMipsCall::Create);
|
||||
}
|
||||
DEBUG_LOG(Log::sceNet, "AdhocMatching - Remaining Events: %zu", matchingEvents.size());
|
||||
auto peer = findPeer(context, (SceNetEtherAddr*)Memory::GetPointer(args[2]));
|
||||
auto peer = findPeer(context, (SceNetEtherAddr*)Memory::GetPointerOrException(args[2]));
|
||||
// Discard HELLO Events when in the middle of joining, as some games (ie. Super Pocket Tennis) might tried to join again (TODO: Need to confirm whether sceNetAdhocMatchingSelectTarget supposed to be blocking the current thread or not)
|
||||
if (peer == NULL || (args[1] != PSP_ADHOC_MATCHING_EVENT_HELLO || (peer->state != PSP_ADHOC_MATCHING_PEER_OUTGOING_REQUEST && peer->state != PSP_ADHOC_MATCHING_PEER_INCOMING_REQUEST && peer->state != PSP_ADHOC_MATCHING_PEER_CANCEL_IN_PROGRESS))) {
|
||||
DEBUG_LOG(Log::sceNet, "AdhocMatchingCallback: [ID=%i][EVENT=%i][%s]", args[0], args[1], mac2str((SceNetEtherAddr *)Memory::GetPointer(args[2])).c_str());
|
||||
DEBUG_LOG(Log::sceNet, "AdhocMatchingCallback: [ID=%i][EVENT=%i][%s]", args[0], args[1], mac2str((SceNetEtherAddr *)Memory::GetPointerOrException(args[2])).c_str());
|
||||
|
||||
AfterMatchingMipsCall* after = (AfterMatchingMipsCall*)__KernelCreateAction(actionAfterMatchingMipsCall);
|
||||
after->SetData(args[0], args[1], args[2]);
|
||||
@@ -2639,7 +2639,7 @@ void __NetMatchingCallbacks() { //(int matchingId)
|
||||
matchingEvents.pop_front();
|
||||
}
|
||||
else {
|
||||
DEBUG_LOG(Log::sceNet, "AdhocMatching - Discarding Callback: [ID=%i][EVENT=%i][%s]", args[0], args[1], mac2str((SceNetEtherAddr*)Memory::GetPointer(args[2])).c_str());
|
||||
DEBUG_LOG(Log::sceNet, "AdhocMatching - Discarding Callback: [ID=%i][EVENT=%i][%s]", args[0], args[1], mac2str((SceNetEtherAddr*)Memory::GetPointerOrException(args[2])).c_str());
|
||||
matchingEvents.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
+31
-31
@@ -106,7 +106,7 @@ static int sceNetInetInetPton(int af, const char* hostname, u32 inAddrPtr) {
|
||||
return hleLogError(Log::sceNet, 0, "invalid arg"); //-1
|
||||
}
|
||||
|
||||
int retval = inet_pton(convertSocketDomainPSP2Host(af), hostname, (void*)Memory::GetPointer(inAddrPtr));
|
||||
int retval = inet_pton(convertSocketDomainPSP2Host(af), hostname, (void*)Memory::GetPointerOrException(inAddrPtr));
|
||||
// Note that inet_pton can set errno!
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
@@ -121,7 +121,7 @@ static int sceNetInetInetAton(const char* hostname, u32 inAddrPtr) {
|
||||
}
|
||||
|
||||
// TODO: Wait what, we're calling pton in aton?
|
||||
int retval = inet_pton(AF_INET, hostname, (void*)Memory::GetPointer(inAddrPtr));
|
||||
int retval = inet_pton(AF_INET, hostname, (void*)Memory::GetPointerOrException(inAddrPtr));
|
||||
// inet_aton() returns nonzero if the address is valid, zero if not.
|
||||
return hleLogDebug(Log::sceNet, retval);
|
||||
}
|
||||
@@ -165,8 +165,8 @@ static int sceNetInetGetpeername(int socket, u32 namePtr, u32 namelenPtr) {
|
||||
return hleLogError(Log::sceNet, ERROR_INET_EBADF, "Bad socket #%d", socket);
|
||||
}
|
||||
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointer(namePtr);
|
||||
int* namelen = (int*)Memory::GetPointer(namelenPtr);
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointerOrException(namePtr);
|
||||
int* namelen = (int*)Memory::GetPointerOrException(namelenPtr);
|
||||
SockAddrIN4 saddr{};
|
||||
// TODO: Should've created convertSockaddrPSP2Host (and Host2PSP too) function as it's being used pretty often, thus fixing a bug on it will be tedious when scattered all over the places
|
||||
saddr.addr.sa_family = name->sa_family;
|
||||
@@ -199,8 +199,8 @@ static int sceNetInetGetsockname(int socket, u32 namePtr, u32 namelenPtr) {
|
||||
return hleLogError(Log::sceNet, ERROR_INET_EBADF, "Bad socket #%d", socket);
|
||||
}
|
||||
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointer(namePtr);
|
||||
int* namelen = (int*)Memory::GetPointer(namelenPtr);
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointerOrException(namePtr);
|
||||
int* namelen = (int*)Memory::GetPointerOrException(namelenPtr);
|
||||
SockAddrIN4 saddr{};
|
||||
saddr.addr.sa_family = name->sa_family;
|
||||
int len = std::min(*namelen > 0 ? *namelen : 0, static_cast<int>(sizeof(saddr)));
|
||||
@@ -223,10 +223,10 @@ static int sceNetInetGetsockname(int socket, u32 namePtr, u32 namelenPtr) {
|
||||
|
||||
// FIXME: nfds is number of fd(s) as in posix poll, or was it maximum fd value as in posix select? Star Wars Battlefront Renegade seems to set the nfds to 64, while Coded Arms Contagion is using 256
|
||||
int sceNetInetSelect(int nfds, u32 readfdsPtr, u32 writefdsPtr, u32 exceptfdsPtr, u32 timeoutPtr) {
|
||||
SceNetInetFdSet *readfds = readfdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWrite(readfdsPtr) : nullptr;
|
||||
SceNetInetFdSet *writefds = writefdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWrite(writefdsPtr) : nullptr;
|
||||
SceNetInetFdSet *exceptfds = exceptfdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWrite(exceptfdsPtr) : nullptr;
|
||||
SceNetInetTimeval *timeout = timeoutPtr ? (SceNetInetTimeval*)Memory::GetPointerWrite(timeoutPtr) : nullptr;
|
||||
SceNetInetFdSet *readfds = readfdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWriteOrException(readfdsPtr) : nullptr;
|
||||
SceNetInetFdSet *writefds = writefdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWriteOrException(writefdsPtr) : nullptr;
|
||||
SceNetInetFdSet *exceptfds = exceptfdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWriteOrException(exceptfdsPtr) : nullptr;
|
||||
SceNetInetTimeval *timeout = timeoutPtr ? (SceNetInetTimeval*)Memory::GetPointerWriteOrException(timeoutPtr) : nullptr;
|
||||
|
||||
// First, translate the specified fd_sets to host sockets.
|
||||
|
||||
@@ -357,7 +357,7 @@ int sceNetInetPoll(u32 fdsPtr, u32 nfds, int timeout) { // timeout in milisecond
|
||||
DEBUG_LOG(Log::sceNet, "UNTESTED sceNetInetPoll(%08x, %d, %i) at %08x", fdsPtr, nfds, timeout, currentMIPS->pc);
|
||||
int retval = -1;
|
||||
int maxHostFd = 0;
|
||||
SceNetInetPollfd *fdarray = (SceNetInetPollfd*)Memory::GetPointer(fdsPtr); // SceNetInetPollfd/pollfd, sceNetInetPoll() have similarity to BSD poll() but pollfd have different size on 64bit
|
||||
SceNetInetPollfd *fdarray = (SceNetInetPollfd*)Memory::GetPointerOrException(fdsPtr); // SceNetInetPollfd/pollfd, sceNetInetPoll() have similarity to BSD poll() but pollfd have different size on 64bit
|
||||
|
||||
if (nfds > FD_SETSIZE)
|
||||
nfds = FD_SETSIZE;
|
||||
@@ -419,7 +419,7 @@ static int sceNetInetRecv(int socket, u32 bufPtr, u32 bufLen, u32 flags) {
|
||||
|
||||
int flgs = flags & ~PSP_NET_INET_MSG_DONTWAIT; // removing non-POSIX flag, which is an alternative way to use non-blocking mode
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
int retval = recv(inetSock->sock, (char*)Memory::GetPointer(bufPtr), bufLen, flgs | MSG_NOSIGNAL);
|
||||
int retval = recv(inetSock->sock, (char*)Memory::GetPointerOrException(bufPtr), bufLen, flgs | MSG_NOSIGNAL);
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
retval = hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
@@ -430,7 +430,7 @@ static int sceNetInetRecv(int socket, u32 bufPtr, u32 bufLen, u32 flags) {
|
||||
}
|
||||
|
||||
std::string datahex;
|
||||
DataToHexString(10, 0, Memory::GetPointer(bufPtr), retval, &datahex);
|
||||
DataToHexString(10, 0, Memory::GetPointerOrException(bufPtr), retval, &datahex);
|
||||
VERBOSE_LOG(Log::sceNet, "Data Dump (%d bytes):\n%s", retval, datahex.c_str());
|
||||
|
||||
return hleDelayResult(hleLogInfo(Log::sceNet, retval), "workaround until blocking-socket", 500); // Using hleDelayResult as a workaround for games that need blocking-socket to be implemented
|
||||
@@ -443,12 +443,12 @@ static int sceNetInetSend(int socket, u32 bufPtr, u32 bufLen, u32 flags) {
|
||||
}
|
||||
|
||||
std::string datahex;
|
||||
DataToHexString(10, 0, Memory::GetPointer(bufPtr), bufLen, &datahex);
|
||||
DataToHexString(10, 0, Memory::GetPointerOrException(bufPtr), bufLen, &datahex);
|
||||
VERBOSE_LOG(Log::sceNet, "Data Dump (%d bytes):\n%s", bufLen, datahex.c_str());
|
||||
|
||||
int flgs = flags & ~PSP_NET_INET_MSG_DONTWAIT; // removing non-POSIX flag, which is an alternative way to use non-blocking mode
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
int retval = send(inetSock->sock, (char*)Memory::GetPointer(bufPtr), bufLen, flgs | MSG_NOSIGNAL);
|
||||
int retval = send(inetSock->sock, (char*)Memory::GetPointerOrException(bufPtr), bufLen, flgs | MSG_NOSIGNAL);
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
@@ -561,8 +561,8 @@ static int sceNetInetGetsockopt(int socket, int level, int optname, u32 optvalPt
|
||||
return hleLogError(Log::sceNet, ERROR_INET_EBADF, "Bad socket #%d", socket);
|
||||
}
|
||||
|
||||
u32_le* optval = (u32_le*)Memory::GetPointer(optvalPtr);
|
||||
socklen_t* optlen = (socklen_t*)Memory::GetPointer(optlenPtr);
|
||||
u32_le* optval = (u32_le*)Memory::GetPointerOrException(optvalPtr);
|
||||
socklen_t* optlen = (socklen_t*)Memory::GetPointerOrException(optlenPtr);
|
||||
DEBUG_LOG(Log::sceNet, "SockOpt: Level = %s, OptName = %s", inetSockoptLevel2str(level).c_str(), inetSockoptName2str(optname, level).c_str());
|
||||
timeval tval{};
|
||||
// TODO: Ignoring SO_NBIO/SO_NONBLOCK flag if we always use non-bloking mode (ie. simulated blocking mode)
|
||||
@@ -626,7 +626,7 @@ static int sceNetInetBind(int socket, u32 namePtr, int namelen) {
|
||||
return hleLogError(Log::sceNet, ERROR_INET_EBADF, "Bad socket #%d", socket);
|
||||
}
|
||||
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointer(namePtr);
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointerOrException(namePtr);
|
||||
SockAddrIN4 saddr{};
|
||||
// TODO: Should've created convertSockaddrPSP2Host (and Host2PSP too) function as it's being used pretty often, thus fixing a bug on it will be tedious when scattered all over the places
|
||||
saddr.addr.sa_family = name->sa_family;
|
||||
@@ -687,7 +687,7 @@ static int sceNetInetConnect(int socket, u32 sockAddrPtr, int sockAddrLen) {
|
||||
|
||||
// Still using warn log here so it stands out in the log
|
||||
|
||||
SceNetInetSockaddr* dst = (SceNetInetSockaddr*)Memory::GetPointer(sockAddrPtr);
|
||||
SceNetInetSockaddr* dst = (SceNetInetSockaddr*)Memory::GetPointerOrException(sockAddrPtr);
|
||||
SockAddrIN4 saddr{};
|
||||
int dstlen = std::min(sockAddrLen > 0 ? sockAddrLen : 0, static_cast<int>(sizeof(saddr)));
|
||||
saddr.addr.sa_family = dst->sa_family;
|
||||
@@ -852,7 +852,7 @@ static int sceNetInetRecvfrom(int socket, u32 bufferPtr, int len, int flags, u32
|
||||
*srclen = std::min((*srclen) > 0 ? *srclen : 0, static_cast<socklen_t>(sizeof(saddr)));
|
||||
int flgs = flags & ~PSP_NET_INET_MSG_DONTWAIT; // removing non-POSIX flag, which is an alternative way to use non-blocking mode
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
int retval = recvfrom(inetSock->sock, (char*)Memory::GetPointer(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, srclen);
|
||||
int retval = recvfrom(inetSock->sock, (char*)Memory::GetPointerOrException(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, srclen);
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
retval = hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
@@ -879,7 +879,7 @@ static int sceNetInetRecvfrom(int socket, u32 bufferPtr, int len, int flags, u32
|
||||
}*/
|
||||
|
||||
std::string datahex;
|
||||
DataToHexString(0, 0, Memory::GetPointer(bufferPtr), retval, &datahex);
|
||||
DataToHexString(0, 0, Memory::GetPointerOrException(bufferPtr), retval, &datahex);
|
||||
VERBOSE_LOG(Log::sceNet, "Data Dump (%d bytes):\n%s", retval, datahex.c_str());
|
||||
|
||||
// Using hleDelayResult as a workaround for games that need blocking-socket to be implemented (ie. Coded Arms Contagion)
|
||||
@@ -904,7 +904,7 @@ static int sceNetInetSendto(int socket, u32 bufferPtr, int len, int flags, u32 t
|
||||
}
|
||||
|
||||
std::string datahex;
|
||||
DataToHexString(0, 0, Memory::GetPointer(bufferPtr), len, &datahex);
|
||||
DataToHexString(0, 0, Memory::GetPointerOrException(bufferPtr), len, &datahex);
|
||||
VERBOSE_LOG(Log::sceNet, "Data Dump (%d bytes):\n%s", len, datahex.c_str());
|
||||
|
||||
int retval;
|
||||
@@ -920,7 +920,7 @@ static int sceNetInetSendto(int socket, u32 bufferPtr, int len, int flags, u32 t
|
||||
continue;
|
||||
|
||||
saddr.in.sin_addr.s_addr = peer->ip_addr;
|
||||
retval = sendto(inetSock->sock, (char*)Memory::GetPointer(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, dstlen);
|
||||
retval = sendto(inetSock->sock, (char*)Memory::GetPointerOrException(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, dstlen);
|
||||
if (retval < 0) {
|
||||
DEBUG_LOG(Log::sceNet, "SendTo(BC): Socket error %d", socket_errno);
|
||||
} else {
|
||||
@@ -946,7 +946,7 @@ static int sceNetInetSendto(int socket, u32 bufferPtr, int len, int flags, u32 t
|
||||
saddr.in.sin_addr.s_addr = sockAddr.sin_addr.s_addr;
|
||||
DEBUG_LOG(Log::sceNet, "SendTo(BC): Address Replacement = %s", ip2str(saddr.in.sin_addr).c_str());
|
||||
}*/
|
||||
retval = sendto(inetSock->sock, (char*)Memory::GetPointer(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, dstlen);
|
||||
retval = sendto(inetSock->sock, (char*)Memory::GetPointerOrException(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, dstlen);
|
||||
}
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
@@ -974,7 +974,7 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
return hleLogError(Log::sceNet, ERROR_INET_EBADF, "Bad socket #%d", socket);
|
||||
}
|
||||
|
||||
InetMsghdr* pspMsghdr = (InetMsghdr*)Memory::GetPointer(msghdrPtr);
|
||||
InetMsghdr* pspMsghdr = (InetMsghdr*)Memory::GetPointerOrException(msghdrPtr);
|
||||
int flgs = flags & ~PSP_NET_INET_MSG_DONTWAIT; // removing non-POSIX flag, which is an alternative way to use non-blocking mode
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
SockAddrIN4 saddr{};
|
||||
@@ -996,7 +996,7 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
memset(iov, 0, pspMsghdr->msg_iovlen * iovecsize);
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
if (pspMsghdr->msg_name != 0) {
|
||||
SceNetInetSockaddr* pspSaddr = (SceNetInetSockaddr*)Memory::GetPointer(pspMsghdr->msg_name);
|
||||
SceNetInetSockaddr* pspSaddr = (SceNetInetSockaddr*)Memory::GetPointerOrException(pspMsghdr->msg_name);
|
||||
saddr.addr.sa_family = pspSaddr->sa_family;
|
||||
size_t datalen = std::min(pspMsghdr->msg_namelen - (sizeof(pspSaddr->sa_len) + sizeof(pspSaddr->sa_family)), sizeof(saddr.addr.sa_data));
|
||||
memcpy(saddr.addr.sa_data, pspSaddr->sa_data, datalen);
|
||||
@@ -1017,14 +1017,14 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
hdr.msg_iovlen = pspMsghdr->msg_iovlen;
|
||||
#endif
|
||||
if (pspMsghdr->msg_iov != 0) {
|
||||
SceNetIovec* pspIov = (SceNetIovec*)Memory::GetPointer(pspMsghdr->msg_iov);
|
||||
SceNetIovec* pspIov = (SceNetIovec*)Memory::GetPointerOrException(pspMsghdr->msg_iov);
|
||||
for (int i = 0; i < pspMsghdr->msg_iovlen; i++) {
|
||||
if (pspIov[i].iov_base != 0) {
|
||||
#if defined(_WIN32)
|
||||
iov[i].buf = (char*)Memory::GetPointer(pspIov[i].iov_base);
|
||||
iov[i].buf = (char*)Memory::GetPointerOrException(pspIov[i].iov_base);
|
||||
iov[i].len = pspIov[i].iov_len;
|
||||
#else
|
||||
iov[i].iov_base = (char*)Memory::GetPointer(pspIov[i].iov_base);
|
||||
iov[i].iov_base = (char*)Memory::GetPointerOrException(pspIov[i].iov_base);
|
||||
iov[i].iov_len = pspIov[i].iov_len;
|
||||
#endif
|
||||
}
|
||||
@@ -1042,7 +1042,7 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
free(iov);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
InetCmsghdr* pspCmsghdr = (InetCmsghdr*)Memory::GetPointer(pspMsghdr->msg_control);
|
||||
InetCmsghdr* pspCmsghdr = (InetCmsghdr*)Memory::GetPointerOrException(pspMsghdr->msg_control);
|
||||
// TODO: Convert InetCmsghdr into platform-specific struct as they're affected by 32/64bit
|
||||
memcpy(chdr, pspCmsghdr, pspMsghdr->msg_controllen);
|
||||
#if defined(_WIN32)
|
||||
@@ -1173,7 +1173,7 @@ static int sceNetInetRecvmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), EFAULT, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
InetMsghdr* pspMsghdr = (InetMsghdr*)Memory::GetPointer(msghdrPtr);
|
||||
InetMsghdr* pspMsghdr = (InetMsghdr*)Memory::GetPointerOrException(msghdrPtr);
|
||||
int flgs = flags & ~PSP_NET_INET_MSG_DONTWAIT; // removing non-POSIX flag, which is an alternative way to use non-blocking mode
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
SockAddrIN4 saddr{};
|
||||
|
||||
@@ -117,7 +117,7 @@ u32 sceNetStrlen(const char* str) {
|
||||
|
||||
s32 sceNetMemcmp(u32 lhsPtr, u32 rhsPtr, u32 count) {
|
||||
// Redirect that to libc
|
||||
s32 res = std::memcmp(Memory::GetPointer(lhsPtr), Memory::GetPointer(rhsPtr), count);
|
||||
s32 res = std::memcmp(Memory::GetPointerOrException(lhsPtr), Memory::GetPointerOrException(rhsPtr), count);
|
||||
|
||||
return hleLogDebug(Log::sceNet, res);
|
||||
}
|
||||
|
||||
+3
-3
@@ -432,7 +432,7 @@ int sceNpAuthGetTicket(u32 requestId, u32 bufferAddr, u32 length) {
|
||||
// Dummy Login ticket returned as Login response. Dummy ticket contents were taken from https://www.psdevwiki.com/ps3/X-I-5-Ticket
|
||||
ticket.header.version = TICKET_VER_2_1;
|
||||
ticket.header.size = 0xF0; // size excluding the header
|
||||
u8* buf = Memory::GetPointerWrite(bufferAddr + sizeof(ticket));
|
||||
u8* buf = Memory::GetPointerWriteOrException(bufferAddr + sizeof(ticket));
|
||||
int ofs = 0;
|
||||
ofs += writeTicketParam(buf, PARAM_TYPE_STRING_ASCII, "\x4c\x47\x56\x3b\x81\x39\x4a\x22\xd8\x6b\xc1\x57\x71\x6e\xfd\xb8\xab\x63\xcc\x51", 20); // 20 random letters, token key or SceNpSignature?
|
||||
ofs += writeTicketU32Param(buf + ofs, PARAM_TYPE_INT, 0x0100); // a flags?
|
||||
@@ -516,13 +516,13 @@ int sceNpAuthGetTicketParam(u32 ticketBufPtr, int ticketLen, int paramNum, u32 b
|
||||
return hleLogError(Log::sceNet, SCE_NP_MANAGER_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
SceNpTicket* ticket = (SceNpTicket*)Memory::GetPointer(ticketBufPtr);
|
||||
SceNpTicket* ticket = (SceNpTicket*)Memory::GetPointerOrException(ticketBufPtr);
|
||||
u32 inbuf = ticketBufPtr;
|
||||
inbuf += sizeof(ticket->header);
|
||||
inbuf += ticket->section.size + sizeof(ticket->section);
|
||||
u32 outbuf = bufferPtr;
|
||||
for (int i = 0; i < paramNum; i++) {
|
||||
SceNpTicketParamData* ticketParam = (SceNpTicketParamData*)Memory::GetPointer(inbuf);
|
||||
SceNpTicketParamData* ticketParam = (SceNpTicketParamData*)Memory::GetPointerOrException(inbuf);
|
||||
u32 sz = (u32)sizeof(SceNpTicketParamData) + ticketParam->length;
|
||||
Memory::Memcpy(outbuf, inbuf, sz);
|
||||
DEBUG_LOG(Log::sceNet, "%s - Param #%d: Type = %04x, Length = %u", __FUNCTION__, i, static_cast<unsigned int>(ticketParam->type), static_cast<unsigned int>(ticketParam->length));
|
||||
|
||||
+2
-2
@@ -72,9 +72,9 @@ bool NpMatching2ProcessEvents() {
|
||||
}
|
||||
|
||||
// Per npMatching2 function callback
|
||||
u32* inStruct = (u32*)Memory::GetPointer(inStructPtr);
|
||||
u32* inStruct = (u32*)Memory::GetPointerOrException(inStructPtr);
|
||||
if (Memory::IsValidAddress(inStruct[0])) {
|
||||
DEBUG_LOG(Log::sceNet, "NpMatching2Callback [ServerID=%i][EventID=%04x][State=%04x][FuncAddr=%08x][ArgsPtr=%08x]", *(u32*)Memory::GetPointer(serverIdPtr), event, stat, inStruct[0], inStruct[1]);
|
||||
DEBUG_LOG(Log::sceNet, "NpMatching2Callback [ServerID=%i][EventID=%04x][State=%04x][FuncAddr=%08x][ArgsPtr=%08x]", *(u32*)Memory::GetPointerOrException(serverIdPtr), event, stat, inStruct[0], inStruct[1]);
|
||||
hleEnqueueCall(inStruct[0], 7, args.data);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -770,7 +770,7 @@ static u32 scePsmfSetPsmf(u32 psmfStruct, u32 psmfData) {
|
||||
return hleReportError(Log::ME, SCE_KERNEL_ERROR_ILLEGAL_ADDRESS, "bad address");
|
||||
}
|
||||
|
||||
Psmf *psmf = new Psmf(Memory::GetPointer(psmfData), psmfData);
|
||||
Psmf *psmf = new Psmf(Memory::GetPointerOrException(psmfData), psmfData);
|
||||
if (psmf->magic != PSMF_MAGIC) {
|
||||
delete psmf;
|
||||
return hleLogError(Log::ME, SCE_PSMF_ERROR_INVALID_PSMF, "invalid psmf data");
|
||||
|
||||
+2
-2
@@ -1145,7 +1145,7 @@ int sceRegGetKeys(int catHandle, u32 bufAddr, int num) {
|
||||
count = std::min(count, num);
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
char *dest = (char *)Memory::GetPointerWrite(bufAddr + i * keyLen);
|
||||
char *dest = (char *)Memory::GetPointerWriteOrException(bufAddr + i * keyLen);
|
||||
strncpy(dest, keyvals[i].name.c_str(), keyLen);
|
||||
}
|
||||
|
||||
@@ -1366,7 +1366,7 @@ int sceRegGetCategoryListAtRoot(int regHandle, u32 bufPtr, int numCategories) {
|
||||
for (int i = 0; i < numCategories; i++) {
|
||||
const KeyValue &kv = ROOT[i];
|
||||
_dbg_assert_msg_(kv.type == ValueType::DIR, "Unexpected non-dir in ROOT");
|
||||
char *dest = (char *)Memory::GetPointerWrite(bufPtr + i * 27);
|
||||
char *dest = (char *)Memory::GetPointerWriteOrException(bufPtr + i * 27);
|
||||
if (dest) {
|
||||
strncpy(dest, kv.name.c_str(), 27);
|
||||
}
|
||||
|
||||
+2
-2
@@ -207,7 +207,7 @@ static void __UmdBeginCallback(SceUID threadID, SceUID prevCallbackId)
|
||||
_dbg_assert_msg_(umdStatTimeoutEvent != -1, "Must have a umd timer");
|
||||
s64 cyclesLeft = CoreTiming::UnscheduleEvent(umdStatTimeoutEvent, threadID);
|
||||
if (cyclesLeft != 0)
|
||||
umdPausedWaits[pauseKey] = CoreTiming::GetTicks() + cyclesLeft;
|
||||
umdPausedWaits[pauseKey] = CoreTiming::GetTicks(currentMIPS) + cyclesLeft;
|
||||
else
|
||||
umdPausedWaits[pauseKey] = 0;
|
||||
|
||||
@@ -244,7 +244,7 @@ static void __UmdEndCallback(SceUID threadID, SceUID prevCallbackId)
|
||||
return;
|
||||
}
|
||||
|
||||
s64 cyclesLeft = waitDeadline - CoreTiming::GetTicks();
|
||||
s64 cyclesLeft = waitDeadline - CoreTiming::GetTicks(currentMIPS);
|
||||
if (cyclesLeft < 0 && waitDeadline != 0)
|
||||
__KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT);
|
||||
else
|
||||
|
||||
@@ -55,7 +55,7 @@ struct AsyncIOResult {
|
||||
explicit AsyncIOResult(s64 r) : result(r), finishTicks(0), invalidateAddr(0) {}
|
||||
|
||||
AsyncIOResult(s64 r, int usec, u32 addr = 0) : result(r), invalidateAddr(addr) {
|
||||
finishTicks = CoreTiming::GetTicks() + usToCycles(usec);
|
||||
finishTicks = CoreTiming::GetTicks(currentMIPS) + usToCycles(usec);
|
||||
}
|
||||
|
||||
void DoState(PointerWrap &p) {
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
for (AsyncIOEvent ev = GetNextEvent(); AsyncIOEventType(ev) != IO_EVENT_INVALID; ev = GetNextEvent()) {
|
||||
ProcessEventIfApplicable(ev, globalticks);
|
||||
}
|
||||
} while (CoreTiming::GetTicks() < globalticks);
|
||||
} while (CoreTiming::GetTicks(currentMIPS) < globalticks);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ public:
|
||||
ProcessEventIfApplicable(ev, globalticks);
|
||||
guard.lock();
|
||||
}
|
||||
} while (CoreTiming::GetTicks() < globalticks);
|
||||
} while (CoreTiming::GetTicks(currentMIPS) < globalticks);
|
||||
|
||||
// This will force the waiter to check coreState, even if we didn't actually drain.
|
||||
NotifyDrain();
|
||||
|
||||
+3
-2
@@ -26,6 +26,7 @@
|
||||
#include "Common/Data/Text/StringWriter.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/HLE/sceKernel.h"
|
||||
#include "Core/HLE/sceCtrl.h"
|
||||
@@ -155,7 +156,7 @@ uint64_t DisplayFrameStartTicks() {
|
||||
}
|
||||
|
||||
uint32_t __DisplayGetCurrentHcount() {
|
||||
const int ticksIntoFrame = (int)(CoreTiming::GetTicks() - frameStartTicks);
|
||||
const int ticksIntoFrame = (int)(CoreTiming::GetTicks(currentMIPS) - frameStartTicks);
|
||||
const int ticksPerVblank = CoreTiming::GetClockFrequencyHz() / 60 / hCountPerVblank;
|
||||
// Can't seem to produce a 0 on real hardware, offsetting by 1 makes things look right.
|
||||
return 1 + (ticksIntoFrame / ticksPerVblank);
|
||||
@@ -227,7 +228,7 @@ bool DisplayIsRunningSlow() {
|
||||
}
|
||||
|
||||
void DisplayFireVblankStart() {
|
||||
frameStartTicks = CoreTiming::GetTicks();
|
||||
frameStartTicks = CoreTiming::GetTicks(currentMIPS);
|
||||
numVBlanks++;
|
||||
|
||||
isVblank = 1;
|
||||
|
||||
@@ -1077,7 +1077,7 @@ int MediaEngine::getNextAudioFrame(u8 **buf, int *headerCode1, int *headerCode2)
|
||||
}
|
||||
|
||||
int MediaEngine::getAudioSamples(u32 bufferPtr) {
|
||||
int16_t *buffer = (int16_t *)Memory::GetPointerWriteRange(bufferPtr, 8192);
|
||||
int16_t *buffer = (int16_t *)Memory::GetPointerWriteRangeOrException(bufferPtr, 8192);
|
||||
if (buffer == nullptr) {
|
||||
ERROR_LOG_REPORT(Log::ME, "Ignoring bad audio decode address %08x during video playback", bufferPtr);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "Core/FileSystems/MetaFileSystem.h"
|
||||
#include "Core/HW/MemoryStick.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/Thread/Promise.h"
|
||||
@@ -85,7 +86,7 @@ MemStickState MemoryStick_State() {
|
||||
}
|
||||
|
||||
MemStickFatState MemoryStick_FatState() {
|
||||
if (memStickNeedsAssign && CoreTiming::GetTicks() > memStickInsertedAt + msToCycles(500)) {
|
||||
if (memStickNeedsAssign && CoreTiming::GetTicks(currentMIPS) > memStickInsertedAt + msToCycles(500)) {
|
||||
// It's been long enough for us to be done mounting the memory stick.
|
||||
memStickFatState = PSP_FAT_MEMORYSTICK_STATE_ASSIGNED;
|
||||
memStickNeedsAssign = false;
|
||||
@@ -181,7 +182,7 @@ void MemoryStick_SetState(MemStickState state) {
|
||||
if (state == PSP_MEMORYSTICK_STATE_NOT_INSERTED) {
|
||||
MemoryStick_SetFatState(PSP_FAT_MEMORYSTICK_STATE_UNASSIGNED);
|
||||
} else {
|
||||
memStickInsertedAt = CoreTiming::GetTicks();
|
||||
memStickInsertedAt = CoreTiming::GetTicks(currentMIPS);
|
||||
memStickNeedsAssign = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,8 +641,8 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol, bool m
|
||||
// Then mix the send buffer in with the rest.
|
||||
|
||||
// Alright, all voices mixed. Let's convert and clip, and at the same time, wipe mixBuffer for next time. Could also dither.
|
||||
s16 *outp = (s16 *)Memory::GetPointerWriteRange(outAddr, 4 * grainSize);
|
||||
const s16 *inp = inAddr ? (const s16 *)Memory::GetPointerRange(inAddr, 4 * grainSize) : 0;
|
||||
s16 *outp = (s16 *)Memory::GetPointerWriteRangeOrException(outAddr, 4 * grainSize);
|
||||
const s16 *inp = inAddr ? (const s16 *)Memory::GetPointerRangeOrException(inAddr, 4 * grainSize) : 0;
|
||||
if (!outp) {
|
||||
WARN_LOG_REPORT(Log::sceSas, "Bad SAS Mix output address: %08x, grain=%d", outAddr, grainSize);
|
||||
} else if (outputMode == PSP_SAS_OUTPUTMODE_MIXED) {
|
||||
|
||||
@@ -497,7 +497,7 @@ size_t AuCtx::FindNextMp3Sync() {
|
||||
// return output pcm size, <0 error
|
||||
u32 AuCtx::AuDecode(u32 pcmAddr) {
|
||||
u32 outptr = PCMBuf + nextOutputHalf * PCMBufSize / 2;
|
||||
auto outbuf = Memory::GetPointerWriteRange(outptr, PCMBufSize / 2);
|
||||
auto outbuf = Memory::GetPointerWriteRangeOrException(outptr, PCMBufSize / 2);
|
||||
int outpcmbufsize = 0;
|
||||
|
||||
if (pcmAddr)
|
||||
|
||||
@@ -569,7 +569,7 @@ void ArmJit::Comp_Generic(MIPSOpcode op)
|
||||
gpr.SetRegImm(SCRATCHREG1, GetCompilerPC());
|
||||
MovToPC(SCRATCHREG1);
|
||||
gpr.SetRegImm(R0, op.encoding);
|
||||
QuickCallFunction(R1, (void *)func);
|
||||
QuickCallFunction(R1, (void *)&MIPSInterpretTrampoline);
|
||||
ApplyRoundingMode();
|
||||
RestoreDowncount();
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ void Arm64JitBackend::CompIR_Interpret(IRInst inst) {
|
||||
QuickCallFunction(SCRATCH2_64, &NotifyMIPSInterpret);
|
||||
}
|
||||
MOVI2R(X0, inst.constant);
|
||||
QuickCallFunction(SCRATCH2_64, MIPSGetInterpretFunc(op));
|
||||
QuickCallFunction(SCRATCH2_64, &MIPSInterpretTrampoline);
|
||||
WriteDebugProfilerStatus(IRProfilerStatus::IN_JIT);
|
||||
LoadStaticRegisters();
|
||||
}
|
||||
|
||||
@@ -581,7 +581,7 @@ void Arm64Jit::Comp_Generic(MIPSOpcode op) {
|
||||
MOVI2R(SCRATCH1, GetCompilerPC());
|
||||
MovToPC(SCRATCH1);
|
||||
MOVI2R(W0, op.encoding);
|
||||
QuickCallFunction(SCRATCH2_64, (void *)func);
|
||||
QuickCallFunction(SCRATCH2_64, (void *)&MIPSInterpretTrampoline);
|
||||
ApplyRoundingMode();
|
||||
LoadStaticRegisters();
|
||||
}
|
||||
|
||||
@@ -1206,7 +1206,7 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst) {
|
||||
MIPSOpcode op(inst->constant);
|
||||
CallSyscall(op);
|
||||
if (coreState != CORE_RUNNING_CPU)
|
||||
CoreTiming::ForceCheck();
|
||||
CoreTiming::ForceCheck(mips);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1258,39 +1258,39 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst) {
|
||||
|
||||
case IROp::Breakpoint:
|
||||
if (IRRunBreakpoint(inst->constant)) {
|
||||
CoreTiming::ForceCheck();
|
||||
CoreTiming::ForceCheck(mips);
|
||||
return mips->pc;
|
||||
}
|
||||
break;
|
||||
|
||||
case IROp::MemoryCheck:
|
||||
if (IRRunMemCheck(mips->pc + inst->dest, mips->r[inst->src1] + inst->constant)) {
|
||||
CoreTiming::ForceCheck();
|
||||
CoreTiming::ForceCheck(mips);
|
||||
return mips->pc;
|
||||
}
|
||||
break;
|
||||
|
||||
case IROp::ValidateAddress8:
|
||||
if (RunValidateAddress<1>(mips->pc, mips->r[inst->src1] + inst->constant, inst->src2)) {
|
||||
CoreTiming::ForceCheck();
|
||||
CoreTiming::ForceCheck(mips);
|
||||
return mips->pc;
|
||||
}
|
||||
break;
|
||||
case IROp::ValidateAddress16:
|
||||
if (RunValidateAddress<2>(mips->pc, mips->r[inst->src1] + inst->constant, inst->src2)) {
|
||||
CoreTiming::ForceCheck();
|
||||
CoreTiming::ForceCheck(mips);
|
||||
return mips->pc;
|
||||
}
|
||||
break;
|
||||
case IROp::ValidateAddress32:
|
||||
if (RunValidateAddress<4>(mips->pc, mips->r[inst->src1] + inst->constant, inst->src2)) {
|
||||
CoreTiming::ForceCheck();
|
||||
CoreTiming::ForceCheck(mips);
|
||||
return mips->pc;
|
||||
}
|
||||
break;
|
||||
case IROp::ValidateAddress128:
|
||||
if (RunValidateAddress<16>(mips->pc, mips->r[inst->src1] + inst->constant, inst->src2)) {
|
||||
CoreTiming::ForceCheck();
|
||||
CoreTiming::ForceCheck(mips);
|
||||
return mips->pc;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -172,6 +172,7 @@ void IRJit::RunLoopUntil(u64 globalticks) {
|
||||
// ApplyRoundingMode(true);
|
||||
// IR Dispatcher
|
||||
|
||||
MIPSState *mips = mips_;
|
||||
while (true) {
|
||||
// RestoreRoundingMode(true);
|
||||
CoreTiming::Advance();
|
||||
@@ -180,7 +181,6 @@ void IRJit::RunLoopUntil(u64 globalticks) {
|
||||
break;
|
||||
}
|
||||
|
||||
MIPSState *mips = mips_;
|
||||
#ifdef _DEBUG
|
||||
compilerEnabled_ = false;
|
||||
#endif
|
||||
|
||||
+188
-162
@@ -35,11 +35,11 @@
|
||||
#include "Core/HLE/HLETables.h"
|
||||
#include "Core/HLE/ReplaceTables.h"
|
||||
|
||||
#define R(i) (currentMIPS->r[i])
|
||||
#define F(i) (currentMIPS->f[i])
|
||||
#define FI(i) (currentMIPS->fi[i])
|
||||
#define FsI(i) (currentMIPS->fs[i])
|
||||
#define PC (currentMIPS->pc)
|
||||
#define R(i) (mips->r[i])
|
||||
#define F(i) (mips->f[i])
|
||||
#define FI(i) (mips->fi[i])
|
||||
#define FsI(i) (mips->fs[i])
|
||||
#define PC (mips->pc)
|
||||
|
||||
#define _SIMM16_SHL2 ((u32)(s32)(s16)(op & 0xFFFF) << 2)
|
||||
#define _RS ((op>>21) & 0x1F)
|
||||
@@ -51,27 +51,26 @@
|
||||
#define _POS ((op>>6 ) & 0x1F)
|
||||
#define _SIZE ((op>>11) & 0x1F)
|
||||
|
||||
#define HI currentMIPS->hi
|
||||
#define LO currentMIPS->lo
|
||||
#define HI mips->hi
|
||||
#define LO mips->lo
|
||||
|
||||
static inline void DelayBranchTo(u32 where)
|
||||
{
|
||||
static inline void DelayBranchTo(MIPSState *mips, u32 where) {
|
||||
if (!Memory::IsValidAddress(where) || (where & 3) != 0) {
|
||||
Core_ExecException(where, PC, ExecExceptionType::JUMP);
|
||||
}
|
||||
PC += 4;
|
||||
mipsr4k.nextPC = where;
|
||||
mipsr4k.inDelaySlot = true;
|
||||
mips->nextPC = where;
|
||||
mips->inDelaySlot = true;
|
||||
}
|
||||
|
||||
static inline void SkipLikely() {
|
||||
static inline void SkipLikely(MIPSState *mips) {
|
||||
MIPSInfo delaySlot = MIPSGetInfo(Memory::Read_Instruction(PC + 4, true));
|
||||
// Don't actually skip if it is a jump (seen in Brooktown High.)
|
||||
if (delaySlot & IS_JUMP) {
|
||||
PC += 4;
|
||||
} else {
|
||||
PC += 8;
|
||||
--mipsr4k.downcount;
|
||||
--mips->downcount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,10 +92,34 @@ int MIPS_SingleStep(MIPSState *mips) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
namespace MIPSInt
|
||||
{
|
||||
void Int_Cache(MIPSOpcode op)
|
||||
{
|
||||
// Dummy functions, for any future MMIO support.
|
||||
static u8 ReadMMIO_U8(MIPSState *mips, u32 addr) {
|
||||
WARN_LOG(Log::CPU, "MMIO Read8 at %08x", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u16 ReadMMIO_U16(MIPSState *mips, u32 addr) {
|
||||
WARN_LOG(Log::CPU, "MMIO Read16 at %08x", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u32 ReadMMIO_U32(MIPSState *mips, u32 addr) {
|
||||
WARN_LOG(Log::CPU, "MMIO Read32 at %08x", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WriteMMIO_U8(MIPSState *mips, u32 addr, u8 value) {
|
||||
WARN_LOG(Log::CPU, "MMIO Write8 at %08x = %02x", addr, value);
|
||||
}
|
||||
void WriteMMIO_U16(MIPSState *mips, u32 addr, u16 value) {
|
||||
WARN_LOG(Log::CPU, "MMIO Write16 at %08x = %04x", addr, value);
|
||||
}
|
||||
void WriteMMIO_U32(MIPSState *mips, u32 addr, u32 value) {
|
||||
WARN_LOG(Log::CPU, "MMIO Write32 at %08x = %08x", addr, value);
|
||||
}
|
||||
|
||||
namespace MIPSInt {
|
||||
void Int_Cache(MIPSState *mips, MIPSOpcode op) {
|
||||
int imm = SignExtend16ToS32(op);
|
||||
int rs = _RS;
|
||||
uint32_t addr = R(rs) + imm;
|
||||
@@ -154,38 +177,31 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_Syscall(MIPSOpcode op)
|
||||
{
|
||||
void Int_Syscall(MIPSState *mips, MIPSOpcode op) {
|
||||
// Need to pre-move PC, as CallSyscall may result in a rescheduling!
|
||||
// To do this neater, we'll need a little generated kernel loop that syscall can jump to and then RFI from
|
||||
// but I don't see a need to bother.
|
||||
if (mipsr4k.inDelaySlot)
|
||||
{
|
||||
mipsr4k.pc = mipsr4k.nextPC;
|
||||
if (mips->inDelaySlot) {
|
||||
mips->pc = mips->nextPC;
|
||||
} else {
|
||||
mips->pc += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
mipsr4k.pc += 4;
|
||||
}
|
||||
mipsr4k.inDelaySlot = false;
|
||||
mips->inDelaySlot = false;
|
||||
CallSyscall(op);
|
||||
}
|
||||
|
||||
void Int_Sync(MIPSOpcode op)
|
||||
{
|
||||
void Int_Sync(MIPSState *mips, MIPSOpcode op) {
|
||||
//DEBUG_LOG(Log::CPU, "sync");
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_Break(MIPSOpcode op)
|
||||
{
|
||||
void Int_Break(MIPSState *mips, MIPSOpcode op) {
|
||||
Reporting::ReportMessage("BREAK instruction hit");
|
||||
Core_BreakException(PC);
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_RelBranch(MIPSOpcode op)
|
||||
{
|
||||
void Int_RelBranch(MIPSState *mips, MIPSOpcode op) {
|
||||
int imm = _SIMM16_SHL2;
|
||||
int rs = _RS;
|
||||
int rt = _RT;
|
||||
@@ -193,15 +209,15 @@ namespace MIPSInt
|
||||
|
||||
switch (op >> 26)
|
||||
{
|
||||
case 4: if (R(rt) == R(rs)) DelayBranchTo(addr); else PC += 4; break; //beq
|
||||
case 5: if (R(rt) != R(rs)) DelayBranchTo(addr); else PC += 4; break; //bne
|
||||
case 6: if ((s32)R(rs) <= 0) DelayBranchTo(addr); else PC += 4; break; //blez
|
||||
case 7: if ((s32)R(rs) > 0) DelayBranchTo(addr); else PC += 4; break; //bgtz
|
||||
case 4: if (R(rt) == R(rs)) DelayBranchTo(mips, addr); else PC += 4; break; //beq
|
||||
case 5: if (R(rt) != R(rs)) DelayBranchTo(mips, addr); else PC += 4; break; //bne
|
||||
case 6: if ((s32)R(rs) <= 0) DelayBranchTo(mips, addr); else PC += 4; break; //blez
|
||||
case 7: if ((s32)R(rs) > 0) DelayBranchTo(mips, addr); else PC += 4; break; //bgtz
|
||||
|
||||
case 20: if (R(rt) == R(rs)) DelayBranchTo(addr); else SkipLikely(); break; //beql
|
||||
case 21: if (R(rt) != R(rs)) DelayBranchTo(addr); else SkipLikely(); break; //bnel
|
||||
case 22: if ((s32)R(rs) <= 0) DelayBranchTo(addr); else SkipLikely(); break; //blezl
|
||||
case 23: if ((s32)R(rs) > 0) DelayBranchTo(addr); else SkipLikely(); break; //bgtzl
|
||||
case 20: if (R(rt) == R(rs)) DelayBranchTo(mips, addr); else SkipLikely(mips); break; //beql
|
||||
case 21: if (R(rt) != R(rs)) DelayBranchTo(mips, addr); else SkipLikely(mips); break; //bnel
|
||||
case 22: if ((s32)R(rs) <= 0) DelayBranchTo(mips, addr); else SkipLikely(mips); break; //blezl
|
||||
case 23: if ((s32)R(rs) > 0) DelayBranchTo(mips, addr); else SkipLikely(mips); break; //bgtzl
|
||||
|
||||
default:
|
||||
_dbg_assert_msg_(false,"Trying to interpret instruction that can't be interpreted");
|
||||
@@ -209,81 +225,75 @@ namespace MIPSInt
|
||||
}
|
||||
}
|
||||
|
||||
void Int_RelBranchRI(MIPSOpcode op)
|
||||
{
|
||||
void Int_RelBranchRI(MIPSState *mips, MIPSOpcode op) {
|
||||
int imm = _SIMM16_SHL2;
|
||||
int rs = _RS;
|
||||
u32 addr = PC + imm + 4;
|
||||
|
||||
switch ((op>>16) & 0x1F)
|
||||
{
|
||||
case 0: if ((s32)R(rs) < 0) DelayBranchTo(addr); else PC += 4; break;//bltz
|
||||
case 1: if ((s32)R(rs) >= 0) DelayBranchTo(addr); else PC += 4; break;//bgez
|
||||
case 2: if ((s32)R(rs) < 0) DelayBranchTo(addr); else SkipLikely(); break;//bltzl
|
||||
case 3: if ((s32)R(rs) >= 0) DelayBranchTo(addr); else SkipLikely(); break;//bgezl
|
||||
case 16: R(MIPS_REG_RA) = PC + 8; if ((s32)R(rs) < 0) DelayBranchTo(addr); else PC += 4; break;//bltzal
|
||||
case 17: R(MIPS_REG_RA) = PC + 8; if ((s32)R(rs) >= 0) DelayBranchTo(addr); else PC += 4; break;//bgezal
|
||||
case 18: R(MIPS_REG_RA) = PC + 8; if ((s32)R(rs) < 0) DelayBranchTo(addr); else SkipLikely(); break;//bltzall
|
||||
case 19: R(MIPS_REG_RA) = PC + 8; if ((s32)R(rs) >= 0) DelayBranchTo(addr); else SkipLikely(); break;//bgezall
|
||||
switch ((op>>16) & 0x1F) {
|
||||
case 0: if ((s32)R(rs) < 0) DelayBranchTo(mips, addr); else PC += 4; break;//bltz
|
||||
case 1: if ((s32)R(rs) >= 0) DelayBranchTo(mips, addr); else PC += 4; break;//bgez
|
||||
case 2: if ((s32)R(rs) < 0) DelayBranchTo(mips, addr); else SkipLikely(mips); break;//bltzl
|
||||
case 3: if ((s32)R(rs) >= 0) DelayBranchTo(mips, addr); else SkipLikely(mips); break;//bgezl
|
||||
case 16: R(MIPS_REG_RA) = PC + 8; if ((s32)R(rs) < 0) DelayBranchTo(mips, addr); else PC += 4; break;//bltzal
|
||||
case 17: R(MIPS_REG_RA) = PC + 8; if ((s32)R(rs) >= 0) DelayBranchTo(mips, addr); else PC += 4; break;//bgezal
|
||||
case 18: R(MIPS_REG_RA) = PC + 8; if ((s32)R(rs) < 0) DelayBranchTo(mips, addr); else SkipLikely(mips); break;//bltzall
|
||||
case 19: R(MIPS_REG_RA) = PC + 8; if ((s32)R(rs) >= 0) DelayBranchTo(mips, addr); else SkipLikely(mips); break;//bgezall
|
||||
default:
|
||||
_dbg_assert_msg_(false,"Trying to interpret instruction that can't be interpreted");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Int_VBranch(MIPSOpcode op)
|
||||
{
|
||||
void Int_VBranch(MIPSState *mips, MIPSOpcode op) {
|
||||
int imm = _SIMM16_SHL2;
|
||||
u32 addr = PC + imm + 4;
|
||||
|
||||
// x, y, z, w, any, all, (invalid), (invalid)
|
||||
int imm3 = (op>>18)&7;
|
||||
int val = (currentMIPS->vfpuCtrl[VFPU_CTRL_CC] >> imm3) & 1;
|
||||
int val = (mips->vfpuCtrl[VFPU_CTRL_CC] >> imm3) & 1;
|
||||
|
||||
switch ((op >> 16) & 3)
|
||||
{
|
||||
case 0: if (!val) DelayBranchTo(addr); else PC += 4; break; //bvf
|
||||
case 1: if ( val) DelayBranchTo(addr); else PC += 4; break; //bvt
|
||||
case 2: if (!val) DelayBranchTo(addr); else SkipLikely(); break; //bvfl
|
||||
case 3: if ( val) DelayBranchTo(addr); else SkipLikely(); break; //bvtl
|
||||
switch ((op >> 16) & 3) {
|
||||
case 0: if (!val) DelayBranchTo(mips, addr); else PC += 4; break; //bvf
|
||||
case 1: if ( val) DelayBranchTo(mips, addr); else PC += 4; break; //bvt
|
||||
case 2: if (!val) DelayBranchTo(mips, addr); else SkipLikely(mips); break; //bvfl
|
||||
case 3: if ( val) DelayBranchTo(mips, addr); else SkipLikely(mips); break; //bvtl
|
||||
}
|
||||
}
|
||||
|
||||
void Int_FPUBranch(MIPSOpcode op)
|
||||
{
|
||||
void Int_FPUBranch(MIPSState *mips, MIPSOpcode op) {
|
||||
int imm = _SIMM16_SHL2;
|
||||
u32 addr = PC + imm + 4;
|
||||
switch((op>>16)&0x1f)
|
||||
switch((op >> 16) & 0x1f)
|
||||
{
|
||||
case 0: if (!currentMIPS->fpcond) DelayBranchTo(addr); else PC += 4; break;//bc1f
|
||||
case 1: if ( currentMIPS->fpcond) DelayBranchTo(addr); else PC += 4; break;//bc1t
|
||||
case 2: if (!currentMIPS->fpcond) DelayBranchTo(addr); else SkipLikely(); break;//bc1fl
|
||||
case 3: if ( currentMIPS->fpcond) DelayBranchTo(addr); else SkipLikely(); break;//bc1tl
|
||||
case 0: if (!mips->fpcond) DelayBranchTo(mips, addr); else PC += 4; break;//bc1f
|
||||
case 1: if ( mips->fpcond) DelayBranchTo(mips, addr); else PC += 4; break;//bc1t
|
||||
case 2: if (!mips->fpcond) DelayBranchTo(mips, addr); else SkipLikely(mips); break;//bc1fl
|
||||
case 3: if ( mips->fpcond) DelayBranchTo(mips, addr); else SkipLikely(mips); break;//bc1tl
|
||||
default:
|
||||
_dbg_assert_msg_(false,"Trying to interpret instruction that can't be interpreted");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Int_JumpType(MIPSOpcode op)
|
||||
{
|
||||
if (mipsr4k.inDelaySlot)
|
||||
ERROR_LOG(Log::CPU, "Jump in delay slot :(");
|
||||
void Int_JumpType(MIPSState *mips, MIPSOpcode op) {
|
||||
if (mips->inDelaySlot) {
|
||||
// There's one of these in Star Soldier at 0881808c, which seems benign.
|
||||
ERROR_LOG(Log::CPU, "Jump in delay slot at %08x", mips->pc);
|
||||
}
|
||||
|
||||
u32 off = ((op & 0x03FFFFFF) << 2);
|
||||
u32 addr = (currentMIPS->pc & 0xF0000000) | off;
|
||||
const u32 off = ((op & 0x03FFFFFF) << 2);
|
||||
const u32 addr = (mips->pc & 0xF0000000) | off;
|
||||
|
||||
switch (op>>26)
|
||||
{
|
||||
switch (op >> 26) {
|
||||
case 2: //j
|
||||
if (!mipsr4k.inDelaySlot)
|
||||
DelayBranchTo(addr);
|
||||
if (!mips->inDelaySlot)
|
||||
DelayBranchTo(mips, addr);
|
||||
break;
|
||||
case 3: //jal
|
||||
R(MIPS_REG_RA) = PC + 8;
|
||||
if (!mipsr4k.inDelaySlot)
|
||||
DelayBranchTo(addr);
|
||||
if (!mips->inDelaySlot)
|
||||
DelayBranchTo(mips, addr);
|
||||
break;
|
||||
default:
|
||||
_dbg_assert_msg_(false,"Trying to interpret instruction that can't be interpreted");
|
||||
@@ -291,33 +301,31 @@ namespace MIPSInt
|
||||
}
|
||||
}
|
||||
|
||||
void Int_JumpRegType(MIPSOpcode op)
|
||||
{
|
||||
if (mipsr4k.inDelaySlot) {
|
||||
void Int_JumpRegType(MIPSState *mips, MIPSOpcode op) {
|
||||
if (mips->inDelaySlot) {
|
||||
// There's one of these in Star Soldier at 0881808c, which seems benign.
|
||||
ERROR_LOG(Log::CPU, "Jump in delay slot :(");
|
||||
ERROR_LOG(Log::CPU, "Jump in delay slot at %08x", mips->pc);
|
||||
}
|
||||
|
||||
int rs = _RS;
|
||||
int rd = _RD;
|
||||
u32 addr = R(rs);
|
||||
switch (op & 0x3f)
|
||||
{
|
||||
switch (op & 0x3f) {
|
||||
case 8: //jr
|
||||
if (!mipsr4k.inDelaySlot)
|
||||
DelayBranchTo(addr);
|
||||
if (!mips->inDelaySlot)
|
||||
DelayBranchTo(mips, addr);
|
||||
break;
|
||||
case 9: //jalr
|
||||
if (rd != 0)
|
||||
R(rd) = PC + 8;
|
||||
// Update rd, but otherwise do not take the branch if we're branching.
|
||||
if (!mipsr4k.inDelaySlot)
|
||||
DelayBranchTo(addr);
|
||||
if (!mips->inDelaySlot)
|
||||
DelayBranchTo(mips, addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Int_IType(MIPSOpcode op) {
|
||||
void Int_IType(MIPSState *mips, MIPSOpcode op) {
|
||||
u32 uimm = op & 0xFFFF;
|
||||
u32 suimm = SignExtend16ToU32(op);
|
||||
s32 simm = SignExtend16ToS32(op);
|
||||
@@ -347,14 +355,13 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_StoreSync(MIPSOpcode op) {
|
||||
void Int_StoreSync(MIPSState *mips, MIPSOpcode op) {
|
||||
int imm = (signed short)(op & 0xFFFF);
|
||||
int rt = _RT;
|
||||
int rs = _RS;
|
||||
u32 addr = R(rs) + imm;
|
||||
|
||||
switch (op >> 26)
|
||||
{
|
||||
switch (op >> 26) {
|
||||
case 48: // ll
|
||||
if (rt != 0) {
|
||||
if (!Memory::IsValid4AlignedAddress(addr)) {
|
||||
@@ -363,10 +370,10 @@ namespace MIPSInt
|
||||
}
|
||||
R(rt) = Memory::ReadUnchecked_U32(addr);
|
||||
}
|
||||
currentMIPS->llBit = 1;
|
||||
mips->llBit = 1;
|
||||
break;
|
||||
case 56: // sc
|
||||
if (currentMIPS->llBit) {
|
||||
if (mips->llBit) {
|
||||
if (!Memory::IsValid4AlignedAddress(addr)) {
|
||||
Core_MemoryException(addr, 4, PC, MemoryExceptionType::WRITE_WORD, "sc");
|
||||
return;
|
||||
@@ -386,8 +393,7 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
|
||||
void Int_RType3(MIPSOpcode op) {
|
||||
void Int_RType3(MIPSState *mips, MIPSOpcode op) {
|
||||
int rt = _RT;
|
||||
int rs = _RS;
|
||||
int rd = _RD;
|
||||
@@ -420,8 +426,7 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
|
||||
void Int_ITypeMem(MIPSOpcode op) {
|
||||
void Int_ITypeMem(MIPSState *mips, MIPSOpcode op) {
|
||||
int imm = (signed short)(op&0xFFFF);
|
||||
int rt = _RT;
|
||||
int rs = _RS;
|
||||
@@ -436,6 +441,11 @@ namespace MIPSInt
|
||||
switch (op >> 26) {
|
||||
case 32:
|
||||
if (!Memory::IsValidAddress(addr)) {
|
||||
if (Memory::IsMMIOAccess(addr)) {
|
||||
// This is a read from MMIO, so we can handle it.
|
||||
R(rt) = SignExtend8ToU32(ReadMMIO_U8(mips, addr));
|
||||
break;
|
||||
}
|
||||
Core_MemoryException(addr, 1, PC, MemoryExceptionType::READ_WORD, "lb");
|
||||
return;
|
||||
}
|
||||
@@ -443,6 +453,11 @@ namespace MIPSInt
|
||||
break; //lb
|
||||
case 33:
|
||||
if (!Memory::IsValid2AlignedAddress(addr)) {
|
||||
if (Memory::IsMMIOAccess(addr)) {
|
||||
// This is a read from MMIO, so we can handle it.
|
||||
R(rt) = SignExtend16ToU32(ReadMMIO_U16(mips, addr));
|
||||
break;
|
||||
}
|
||||
Core_MemoryException(addr, 2, PC, MemoryExceptionType::READ_WORD, "lh");
|
||||
return;
|
||||
}
|
||||
@@ -450,6 +465,11 @@ namespace MIPSInt
|
||||
break; //lh
|
||||
case 35:
|
||||
if (!Memory::IsValid4AlignedAddress(addr)) {
|
||||
if (Memory::IsMMIOAccess(addr)) {
|
||||
// This is a read from MMIO, so we can handle it.
|
||||
R(rt) = ReadMMIO_U32(mips, addr);
|
||||
break;
|
||||
}
|
||||
Core_MemoryException(addr, 4, PC, MemoryExceptionType::READ_WORD, "lw");
|
||||
return;
|
||||
}
|
||||
@@ -457,6 +477,11 @@ namespace MIPSInt
|
||||
break; //lw
|
||||
case 36:
|
||||
if (!Memory::IsValidAddress(addr)) {
|
||||
if (Memory::IsMMIOAccess(addr)) {
|
||||
// This is a read from MMIO, so we can handle it.
|
||||
R(rt) = ReadMMIO_U8(mips, addr);
|
||||
break;
|
||||
}
|
||||
Core_MemoryException(addr, 1, PC, MemoryExceptionType::READ_WORD, "lbu");
|
||||
return;
|
||||
}
|
||||
@@ -464,6 +489,11 @@ namespace MIPSInt
|
||||
break; //lbu
|
||||
case 37:
|
||||
if (!Memory::IsValid2AlignedAddress(addr)) {
|
||||
if (Memory::IsMMIOAccess(addr)) {
|
||||
// This is a read from MMIO, so we can handle it.
|
||||
R(rt) = ReadMMIO_U16(mips, addr);
|
||||
break;
|
||||
}
|
||||
Core_MemoryException(addr, 2, PC, MemoryExceptionType::READ_WORD, "lhu");
|
||||
return;
|
||||
}
|
||||
@@ -471,6 +501,11 @@ namespace MIPSInt
|
||||
break; //lhu
|
||||
case 40:
|
||||
if (!Memory::IsValidAddress(addr)) {
|
||||
if (Memory::IsMMIOAccess(addr)) {
|
||||
// This is a write to MMIO, so we can handle it.
|
||||
WriteMMIO_U8(mips, addr, (u8)(R(rt)));
|
||||
break;
|
||||
}
|
||||
Core_MemoryException(addr, 1, PC, MemoryExceptionType::WRITE_WORD, "sb");
|
||||
return;
|
||||
}
|
||||
@@ -478,6 +513,11 @@ namespace MIPSInt
|
||||
break; //sb
|
||||
case 41:
|
||||
if (!Memory::IsValid2AlignedAddress(addr)) {
|
||||
if (Memory::IsMMIOAccess(addr)) {
|
||||
// This is a write to MMIO, so we can handle it.
|
||||
WriteMMIO_U16(mips, addr, (u16)(R(rt)));
|
||||
break;
|
||||
}
|
||||
Core_MemoryException(addr, 2, PC, MemoryExceptionType::WRITE_WORD, "sh");
|
||||
return;
|
||||
}
|
||||
@@ -485,6 +525,11 @@ namespace MIPSInt
|
||||
break; //sh
|
||||
case 43:
|
||||
if (!Memory::IsValid4AlignedAddress(addr)) {
|
||||
if (Memory::IsMMIOAccess(addr)) {
|
||||
// This is a write to MMIO, so we can handle it.
|
||||
WriteMMIO_U32(mips, addr, R(rt));
|
||||
break;
|
||||
}
|
||||
Core_MemoryException(addr, 4, PC, MemoryExceptionType::WRITE_WORD, "sw");
|
||||
return;
|
||||
}
|
||||
@@ -557,7 +602,7 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_FPULS(MIPSOpcode op) {
|
||||
void Int_FPULS(MIPSState *mips, MIPSOpcode op) {
|
||||
s32 offset = (s16)(op & 0xFFFF);
|
||||
int ft = _FT;
|
||||
int rs = _RS;
|
||||
@@ -585,7 +630,7 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_mxc1(MIPSOpcode op)
|
||||
void Int_mxc1(MIPSState *mips, MIPSOpcode op)
|
||||
{
|
||||
int fs = _FS;
|
||||
int rt = _RT;
|
||||
@@ -599,8 +644,8 @@ namespace MIPSInt
|
||||
case 2: //cfc1
|
||||
if (rt != 0) {
|
||||
if (fs == 31) {
|
||||
currentMIPS->fcr31 = (currentMIPS->fcr31 & ~(1<<23)) | ((currentMIPS->fpcond & 1)<<23);
|
||||
R(rt) = currentMIPS->fcr31;
|
||||
mips->fcr31 = (mips->fcr31 & ~(1<<23)) | ((mips->fpcond & 1)<<23);
|
||||
R(rt) = mips->fcr31;
|
||||
} else if (fs == 0) {
|
||||
R(rt) = MIPSState::FCR0_VALUE;
|
||||
} else {
|
||||
@@ -619,8 +664,8 @@ namespace MIPSInt
|
||||
{
|
||||
u32 value = R(rt);
|
||||
if (fs == 31) {
|
||||
currentMIPS->fcr31 = value & 0x0181FFFF;
|
||||
currentMIPS->fpcond = (value >> 23) & 1;
|
||||
mips->fcr31 = value & 0x0181FFFF;
|
||||
mips->fpcond = (value >> 23) & 1;
|
||||
// Don't bother locking, assuming the CPU can't be reset now anyway.
|
||||
if (MIPSComp::jit) {
|
||||
// In case of DISABLE, we need to tell jit we updated FCR31.
|
||||
@@ -640,20 +685,17 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_RType2(MIPSOpcode op)
|
||||
{
|
||||
void Int_RType2(MIPSState *mips, MIPSOpcode op) {
|
||||
int rs = _RS;
|
||||
int rd = _RD;
|
||||
|
||||
// Don't change $zr.
|
||||
if (rd == 0)
|
||||
{
|
||||
if (rd == 0) {
|
||||
PC += 4;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (op & 63)
|
||||
{
|
||||
switch (op & 63) {
|
||||
case 22: //clz
|
||||
R(rd) = clz32(R(rs));
|
||||
break;
|
||||
@@ -667,7 +709,7 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_MulDivType(MIPSOpcode op)
|
||||
void Int_MulDivType(MIPSState *mips, MIPSOpcode op)
|
||||
{
|
||||
int rt = _RT;
|
||||
int rs = _RS;
|
||||
@@ -772,7 +814,7 @@ namespace MIPSInt
|
||||
}
|
||||
|
||||
|
||||
void Int_ShiftType(MIPSOpcode op)
|
||||
void Int_ShiftType(MIPSState *mips, MIPSOpcode op)
|
||||
{
|
||||
int rt = _RT;
|
||||
int rs = _RS;
|
||||
@@ -788,7 +830,7 @@ namespace MIPSInt
|
||||
|
||||
switch (op & 0x3f)
|
||||
{
|
||||
case 0: R(rd) = R(rt) << sa; break; //sll
|
||||
case 0: R(rd) = R(rt) << sa; break; //sll
|
||||
case 2:
|
||||
if (_RS == 0) //srl
|
||||
{
|
||||
@@ -803,21 +845,19 @@ namespace MIPSInt
|
||||
else
|
||||
goto wrong;
|
||||
|
||||
case 3: R(rd) = (u32)(((s32)R(rt)) >> sa); break; //sra
|
||||
case 4: R(rd) = R(rt) << (R(rs)&0x1F); break; //sllv
|
||||
case 3: R(rd) = (u32)(((s32)R(rt)) >> sa); break; //sra
|
||||
case 4: R(rd) = R(rt) << (R(rs) & 0x1F); break; //sllv
|
||||
case 6:
|
||||
if (_FD == 0) //srlv
|
||||
{
|
||||
if (_FD == 0) { //srlv
|
||||
R(rd) = R(rt) >> (R(rs)&0x1F);
|
||||
break;
|
||||
}
|
||||
else if (_FD == 1) // rotrv
|
||||
{
|
||||
} else if (_FD == 1) { // rotrv
|
||||
R(rd) = __rotr(R(rt), R(rs));
|
||||
break;
|
||||
} else {
|
||||
goto wrong;
|
||||
}
|
||||
else goto wrong;
|
||||
case 7: R(rd) = (u32)(((s32)R(rt)) >> (R(rs)&0x1F)); break; //srav
|
||||
case 7: R(rd) = (u32)(((s32)R(rt)) >> (R(rs) & 0x1F)); break; //srav
|
||||
default:
|
||||
wrong:
|
||||
_dbg_assert_msg_(false,"Trying to interpret instruction that can't be interpreted");
|
||||
@@ -826,20 +866,17 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_Allegrex(MIPSOpcode op)
|
||||
{
|
||||
void Int_Allegrex(MIPSState *mips, MIPSOpcode op) {
|
||||
int rt = _RT;
|
||||
int rd = _RD;
|
||||
|
||||
// Don't change $zr.
|
||||
if (rd == 0)
|
||||
{
|
||||
if (rd == 0) {
|
||||
PC += 4;
|
||||
return;
|
||||
}
|
||||
|
||||
switch((op>>6)&31)
|
||||
{
|
||||
switch ((op >> 6) & 31) {
|
||||
case 16: // seb
|
||||
R(rd) = SignExtend8ToU32(R(rt));
|
||||
break;
|
||||
@@ -859,20 +896,17 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_Allegrex2(MIPSOpcode op)
|
||||
{
|
||||
void Int_Allegrex2(MIPSState *mips, MIPSOpcode op) {
|
||||
int rt = _RT;
|
||||
int rd = _RD;
|
||||
|
||||
// Don't change $zr.
|
||||
if (rd == 0)
|
||||
{
|
||||
if (rd == 0) {
|
||||
PC += 4;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (op & 0x3ff)
|
||||
{
|
||||
switch (op & 0x3ff) {
|
||||
case 0xA0: //wsbh
|
||||
R(rd) = ((R(rt) & 0xFF00FF00) >> 8) | ((R(rt) & 0x00FF00FF) << 8);
|
||||
break;
|
||||
@@ -886,11 +920,9 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_Special2(MIPSOpcode op)
|
||||
{
|
||||
void Int_Special2(MIPSState *mips, MIPSOpcode op) {
|
||||
static int reported = 0;
|
||||
switch (op & 0x3F)
|
||||
{
|
||||
switch (op & 0x3F) {
|
||||
case 36: // mfic
|
||||
// move from interrupt controller, not implemented
|
||||
// See related report https://report.ppsspp.org/logs/kind/316 for possible locations.
|
||||
@@ -912,8 +944,7 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_Special3(MIPSOpcode op)
|
||||
{
|
||||
void Int_Special3(MIPSState *mips, MIPSOpcode op) {
|
||||
int rs = _RS;
|
||||
int rt = _RT;
|
||||
int pos = _POS;
|
||||
@@ -945,8 +976,7 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_FPU2op(MIPSOpcode op)
|
||||
{
|
||||
void Int_FPU2op(MIPSState *mips, MIPSOpcode op) {
|
||||
int fs = _FS;
|
||||
int fd = _FD;
|
||||
|
||||
@@ -992,7 +1022,7 @@ namespace MIPSInt
|
||||
FsI(fd) = my_isinf(F(fs)) && F(fs) < 0.0f ? -2147483648LL : 2147483647LL;
|
||||
break;
|
||||
}
|
||||
switch (currentMIPS->fcr31 & 3)
|
||||
switch (mips->fcr31 & 3)
|
||||
{
|
||||
case 0: FsI(fd) = (int)round_ieee_754(F(fs)); break; // RINT_0
|
||||
case 1: FsI(fd) = (int)F(fs); break; // CAST_1
|
||||
@@ -1007,8 +1037,7 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_FPUComp(MIPSOpcode op)
|
||||
{
|
||||
void Int_FPUComp(MIPSState *mips, MIPSOpcode op) {
|
||||
int fs = _FS;
|
||||
int ft = _FT;
|
||||
bool cond;
|
||||
@@ -1059,12 +1088,11 @@ namespace MIPSInt
|
||||
cond = false;
|
||||
break;
|
||||
}
|
||||
currentMIPS->fpcond = cond;
|
||||
mips->fpcond = cond;
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_FPU3op(MIPSOpcode op)
|
||||
{
|
||||
void Int_FPU3op(MIPSState *mips, MIPSOpcode op) {
|
||||
int ft = _FT;
|
||||
int fs = _FS;
|
||||
int fd = _FD;
|
||||
@@ -1089,15 +1117,14 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_Interrupt(MIPSOpcode op)
|
||||
{
|
||||
void Int_Interrupt(MIPSState *mips, MIPSOpcode op) {
|
||||
static int reported = 0;
|
||||
switch (op & 1)
|
||||
{
|
||||
case 0:
|
||||
// unlikely to be legitimately used
|
||||
if (!reported) {
|
||||
Reporting::ReportMessage("INTERRUPT instruction hit (%08x) at %08x", op.encoding, currentMIPS->pc);
|
||||
Reporting::ReportMessage("INTERRUPT instruction hit (%08x) at %08x", op.encoding, mips->pc);
|
||||
WARN_LOG(Log::CPU, "Disable/Enable Interrupt CPU instruction");
|
||||
reported = 1;
|
||||
}
|
||||
@@ -1106,8 +1133,7 @@ namespace MIPSInt
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
void Int_Emuhack(MIPSOpcode op)
|
||||
{
|
||||
void Int_Emuhack(MIPSState *mips, MIPSOpcode op) {
|
||||
if (((op >> 24) & 3) != EMUOP_CALL_REPLACEMENT) {
|
||||
_dbg_assert_msg_(false, "Trying to interpret emuhack instruction that can't be interpreted");
|
||||
}
|
||||
@@ -1122,20 +1148,20 @@ namespace MIPSInt
|
||||
|
||||
if (entry->flags & (REPFLAG_HOOKENTER | REPFLAG_HOOKEXIT)) {
|
||||
// Interpret the original instruction under the hook.
|
||||
MIPSInterpret(currentMIPS, Memory::Read_Instruction(PC, true));
|
||||
MIPSInterpret(mips, Memory::Read_Instruction(PC, true));
|
||||
} else if (cycles < 0) {
|
||||
// Leave PC unchanged, call the replacement again (assumes args are modified.)
|
||||
currentMIPS->downcount += cycles;
|
||||
mips->downcount += cycles;
|
||||
} else {
|
||||
PC = currentMIPS->r[MIPS_REG_RA];
|
||||
currentMIPS->downcount -= cycles;
|
||||
PC = mips->r[MIPS_REG_RA];
|
||||
mips->downcount -= cycles;
|
||||
}
|
||||
} else {
|
||||
if (!entry || !entry->replaceFunc) {
|
||||
ERROR_LOG(Log::CPU, "Bad replacement function index %i", index);
|
||||
}
|
||||
// Interpret the original instruction under it.
|
||||
MIPSInterpret(currentMIPS, Memory::Read_Instruction(PC, true));
|
||||
MIPSInterpret(mips, Memory::Read_Instruction(PC, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
-27
@@ -24,32 +24,32 @@ int MIPS_SingleStep(MIPSState *mips);
|
||||
|
||||
namespace MIPSInt
|
||||
{
|
||||
void Int_Syscall(MIPSOpcode op);
|
||||
void Int_Syscall(MIPSState *mips, MIPSOpcode op);
|
||||
|
||||
void Int_mxc1(MIPSOpcode op);
|
||||
void Int_RelBranch(MIPSOpcode op);
|
||||
void Int_RelBranchRI(MIPSOpcode op);
|
||||
void Int_IType(MIPSOpcode op);
|
||||
void Int_ITypeMem(MIPSOpcode op);
|
||||
void Int_RType2(MIPSOpcode op);
|
||||
void Int_RType3(MIPSOpcode op);
|
||||
void Int_ShiftType(MIPSOpcode op);
|
||||
void Int_MulDivType(MIPSOpcode op);
|
||||
void Int_JumpType(MIPSOpcode op);
|
||||
void Int_JumpRegType(MIPSOpcode op);
|
||||
void Int_Allegrex2(MIPSOpcode op);
|
||||
void Int_FPULS(MIPSOpcode op);
|
||||
void Int_FPU3op(MIPSOpcode op);
|
||||
void Int_FPU2op(MIPSOpcode op);
|
||||
void Int_Allegrex(MIPSOpcode op);
|
||||
void Int_FPUComp(MIPSOpcode op);
|
||||
void Int_FPUBranch(MIPSOpcode op);
|
||||
void Int_Emuhack(MIPSOpcode op);
|
||||
void Int_Special2(MIPSOpcode op);
|
||||
void Int_Special3(MIPSOpcode op);
|
||||
void Int_Interrupt(MIPSOpcode op);
|
||||
void Int_Cache(MIPSOpcode op);
|
||||
void Int_Sync(MIPSOpcode op);
|
||||
void Int_Break(MIPSOpcode op);
|
||||
void Int_StoreSync(MIPSOpcode op);
|
||||
void Int_mxc1(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_RelBranch(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_RelBranchRI(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_IType(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_ITypeMem(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_RType2(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_RType3(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_ShiftType(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_MulDivType(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_JumpType(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_JumpRegType(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Allegrex2(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_FPULS(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_FPU3op(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_FPU2op(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Allegrex(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_FPUComp(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_FPUBranch(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Emuhack(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Special2(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Special3(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Interrupt(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Cache(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Sync(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Break(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_StoreSync(MIPSState *mips, MIPSOpcode op);
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
// Returns the cycle count consumed, or -1 if op isn't a recognized instruction -
|
||||
// callers must fall back to MIPSInterpret() themselves in that case.
|
||||
int ExecInstruction(MIPSOpcode op) {
|
||||
int ExecInstruction(MIPSState *mips, MIPSOpcode op) {
|
||||
switch ((op.encoding >> 26) & 0x3f) {
|
||||
case 0:
|
||||
{
|
||||
@@ -36,12 +36,12 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 4:
|
||||
case 6:
|
||||
case 7:
|
||||
MIPSInt::Int_ShiftType(op);
|
||||
MIPSInt::Int_ShiftType(mips, op);
|
||||
return 1;
|
||||
// jr, jalr
|
||||
case 8:
|
||||
case 9:
|
||||
MIPSInt::Int_JumpRegType(op);
|
||||
MIPSInt::Int_JumpRegType(mips, op);
|
||||
return 1;
|
||||
// movz, movn, add, addu, sub, subu, and, or, xor, nor, slt, sltu, max, min
|
||||
case 10:
|
||||
@@ -58,19 +58,19 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 43:
|
||||
case 44:
|
||||
case 45:
|
||||
MIPSInt::Int_RType3(op);
|
||||
MIPSInt::Int_RType3(mips, op);
|
||||
return 1;
|
||||
// syscall
|
||||
case 12:
|
||||
MIPSInt::Int_Syscall(op);
|
||||
MIPSInt::Int_Syscall(mips, op);
|
||||
return 1;
|
||||
// break
|
||||
case 13:
|
||||
MIPSInt::Int_Break(op);
|
||||
MIPSInt::Int_Break(mips, op);
|
||||
return 1;
|
||||
// sync
|
||||
case 15:
|
||||
MIPSInt::Int_Sync(op);
|
||||
MIPSInt::Int_Sync(mips, op);
|
||||
return 1;
|
||||
// mfhi, mthi, mflo, mtlo, mult, multu, div, divu, madd, maddu, msub, msubu
|
||||
case 16:
|
||||
@@ -85,12 +85,12 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 29:
|
||||
case 46:
|
||||
case 47:
|
||||
MIPSInt::Int_MulDivType(op);
|
||||
MIPSInt::Int_MulDivType(mips, op);
|
||||
return 1;
|
||||
// clz, clo
|
||||
case 22:
|
||||
case 23:
|
||||
MIPSInt::Int_RType2(op);
|
||||
MIPSInt::Int_RType2(mips, op);
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
@@ -108,7 +108,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 17:
|
||||
case 18:
|
||||
case 19:
|
||||
MIPSInt::Int_RelBranchRI(op);
|
||||
MIPSInt::Int_RelBranchRI(mips, op);
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
@@ -117,7 +117,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
// j, jal
|
||||
case 2:
|
||||
case 3:
|
||||
MIPSInt::Int_JumpType(op);
|
||||
MIPSInt::Int_JumpType(mips, op);
|
||||
return 1;
|
||||
// beq, bne, blez, bgtz, beql, bnel, blezl, bgtzl
|
||||
case 4:
|
||||
@@ -128,7 +128,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
MIPSInt::Int_RelBranch(op);
|
||||
MIPSInt::Int_RelBranch(mips, op);
|
||||
return 1;
|
||||
// addi, addiu, slti, sltiu, andi, ori, xori, lui
|
||||
case 8:
|
||||
@@ -139,7 +139,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
MIPSInt::Int_IType(op);
|
||||
MIPSInt::Int_IType(mips, op);
|
||||
return 1;
|
||||
case 16:
|
||||
{
|
||||
@@ -175,7 +175,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
MIPSInt::Int_mxc1(op);
|
||||
MIPSInt::Int_mxc1(mips, op);
|
||||
return 1;
|
||||
case 8:
|
||||
{
|
||||
@@ -185,7 +185,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
MIPSInt::Int_FPUBranch(op);
|
||||
MIPSInt::Int_FPUBranch(mips, op);
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
@@ -198,11 +198,11 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
MIPSInt::Int_FPU3op(op);
|
||||
MIPSInt::Int_FPU3op(mips, op);
|
||||
return 1;
|
||||
// div.s
|
||||
case 3:
|
||||
MIPSInt::Int_FPU3op(op);
|
||||
MIPSInt::Int_FPU3op(mips, op);
|
||||
return 29;
|
||||
// sqrt.s, abs.s, mov.s, neg.s, round.w.s, trunc.w.s, ceil.w.s, floor.w.s, cvt.w.s
|
||||
case 4:
|
||||
@@ -214,11 +214,11 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 14:
|
||||
case 15:
|
||||
case 36:
|
||||
MIPSInt::Int_FPU2op(op);
|
||||
MIPSInt::Int_FPU2op(mips, op);
|
||||
return 1;
|
||||
// dis.int
|
||||
case 38:
|
||||
MIPSInt::Int_Interrupt(op);
|
||||
MIPSInt::Int_Interrupt(mips, op);
|
||||
return 1;
|
||||
// c.f.s, c.un.s, c.eq.s, c.ueq.s, c.olt.s, c.ult.s, c.ole.s, c.ule.s, c.sf.s, c.ngle.s, c.seq.s, c.ngl.s, c.lt.s, c.nge.s, c.le.s, c.ngt.s
|
||||
case 48:
|
||||
@@ -237,7 +237,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 61:
|
||||
case 62:
|
||||
case 63:
|
||||
MIPSInt::Int_FPUComp(op);
|
||||
MIPSInt::Int_FPUComp(mips, op);
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
@@ -248,7 +248,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
switch ((op.encoding >> 0) & 0x3f) {
|
||||
// cvt.s.w
|
||||
case 32:
|
||||
MIPSInt::Int_FPU2op(op);
|
||||
MIPSInt::Int_FPU2op(mips, op);
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
@@ -264,7 +264,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
// mfv, mtv
|
||||
case 3:
|
||||
case 7:
|
||||
MIPSInt::Int_Mftv(op);
|
||||
MIPSInt::Int_Mftv(mips, op);
|
||||
return 2;
|
||||
case 8:
|
||||
{
|
||||
@@ -274,7 +274,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
MIPSInt::Int_VBranch(op);
|
||||
MIPSInt::Int_VBranch(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
@@ -291,11 +291,11 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 7:
|
||||
MIPSInt::Int_VecDo3(op);
|
||||
MIPSInt::Int_VecDo3(mips, op);
|
||||
return 2;
|
||||
// vsbn
|
||||
case 2:
|
||||
MIPSInt::Int_Vsbn(op);
|
||||
MIPSInt::Int_Vsbn(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
@@ -306,27 +306,27 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
switch ((op.encoding >> 23) & 0x7) {
|
||||
// vmul
|
||||
case 0:
|
||||
MIPSInt::Int_VecDo3(op);
|
||||
MIPSInt::Int_VecDo3(mips, op);
|
||||
return 2;
|
||||
// vdot
|
||||
case 1:
|
||||
MIPSInt::Int_VDot(op);
|
||||
MIPSInt::Int_VDot(mips, op);
|
||||
return 2;
|
||||
// vscl
|
||||
case 2:
|
||||
MIPSInt::Int_VScl(op);
|
||||
MIPSInt::Int_VScl(mips, op);
|
||||
return 2;
|
||||
// vhdp
|
||||
case 4:
|
||||
MIPSInt::Int_VHdp(op);
|
||||
MIPSInt::Int_VHdp(mips, op);
|
||||
return 2;
|
||||
// vcrs
|
||||
case 5:
|
||||
MIPSInt::Int_Vcrs(op);
|
||||
MIPSInt::Int_Vcrs(mips, op);
|
||||
return 2;
|
||||
// vdet
|
||||
case 6:
|
||||
MIPSInt::Int_Vdet(op);
|
||||
MIPSInt::Int_Vdet(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
@@ -337,12 +337,12 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
switch ((op.encoding >> 24) & 0x3) {
|
||||
// RUNBLOCK
|
||||
case 0:
|
||||
MIPSInt::Int_Emuhack(op);
|
||||
MIPSInt::Int_Emuhack(mips, op);
|
||||
return 2;
|
||||
// RetKrnl, CallRepl
|
||||
case 1:
|
||||
case 2:
|
||||
MIPSInt::Int_Emuhack(op);
|
||||
MIPSInt::Int_Emuhack(mips, op);
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
@@ -353,24 +353,24 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
switch ((op.encoding >> 23) & 0x7) {
|
||||
// vcmp
|
||||
case 0:
|
||||
MIPSInt::Int_Vcmp(op);
|
||||
MIPSInt::Int_Vcmp(mips, op);
|
||||
return 2;
|
||||
// vmin, vmax
|
||||
case 2:
|
||||
case 3:
|
||||
MIPSInt::Int_Vminmax(op);
|
||||
MIPSInt::Int_Vminmax(mips, op);
|
||||
return 2;
|
||||
// vscmp
|
||||
case 5:
|
||||
MIPSInt::Int_Vscmp(op);
|
||||
MIPSInt::Int_Vscmp(mips, op);
|
||||
return 2;
|
||||
// vsge
|
||||
case 6:
|
||||
MIPSInt::Int_Vsge(op);
|
||||
MIPSInt::Int_Vsge(mips, op);
|
||||
return 2;
|
||||
// vslt
|
||||
case 7:
|
||||
MIPSInt::Int_Vslt(op);
|
||||
MIPSInt::Int_Vslt(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
@@ -382,7 +382,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
// mfic, mtic
|
||||
case 36:
|
||||
case 38:
|
||||
MIPSInt::Int_Special2(op);
|
||||
MIPSInt::Int_Special2(mips, op);
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
@@ -394,7 +394,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
// ext, ins
|
||||
case 0:
|
||||
case 4:
|
||||
MIPSInt::Int_Special3(op);
|
||||
MIPSInt::Int_Special3(mips, op);
|
||||
return 1;
|
||||
case 24:
|
||||
case 32:
|
||||
@@ -403,13 +403,13 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
// wsbh, wsbw
|
||||
case 2:
|
||||
case 3:
|
||||
MIPSInt::Int_Allegrex2(op);
|
||||
MIPSInt::Int_Allegrex2(mips, op);
|
||||
return 1;
|
||||
// seb, bitrev, seh
|
||||
case 16:
|
||||
case 20:
|
||||
case 24:
|
||||
MIPSInt::Int_Allegrex(op);
|
||||
MIPSInt::Int_Allegrex(mips, op);
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
@@ -432,26 +432,26 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 42:
|
||||
case 43:
|
||||
case 46:
|
||||
MIPSInt::Int_ITypeMem(op);
|
||||
MIPSInt::Int_ITypeMem(mips, op);
|
||||
return 1;
|
||||
// cache
|
||||
case 47:
|
||||
MIPSInt::Int_Cache(op);
|
||||
MIPSInt::Int_Cache(mips, op);
|
||||
return 1;
|
||||
// ll, sc
|
||||
case 48:
|
||||
case 56:
|
||||
MIPSInt::Int_StoreSync(op);
|
||||
MIPSInt::Int_StoreSync(mips, op);
|
||||
return 1;
|
||||
// lwc1, swc1
|
||||
case 49:
|
||||
case 57:
|
||||
MIPSInt::Int_FPULS(op);
|
||||
MIPSInt::Int_FPULS(mips, op);
|
||||
return 1;
|
||||
// lv.s, sv.s
|
||||
case 50:
|
||||
case 58:
|
||||
MIPSInt::Int_SV(op);
|
||||
MIPSInt::Int_SV(mips, op);
|
||||
return 2;
|
||||
case 52:
|
||||
{
|
||||
@@ -476,16 +476,16 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 24:
|
||||
case 26:
|
||||
case 28:
|
||||
MIPSInt::Int_VV2Op(op);
|
||||
MIPSInt::Int_VV2Op(mips, op);
|
||||
return 2;
|
||||
// vidt
|
||||
case 3:
|
||||
MIPSInt::Int_Vidt(op);
|
||||
MIPSInt::Int_Vidt(mips, op);
|
||||
return 2;
|
||||
// vzero, vone
|
||||
case 6:
|
||||
case 7:
|
||||
MIPSInt::Int_VVectorInit(op);
|
||||
MIPSInt::Int_VVectorInit(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
@@ -496,43 +496,43 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
switch ((op.encoding >> 16) & 0x1f) {
|
||||
// vrnds
|
||||
case 0:
|
||||
MIPSInt::Int_Vrnds(op);
|
||||
MIPSInt::Int_Vrnds(mips, op);
|
||||
return 2;
|
||||
// vrndi, vrndf1, vrndf2
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
MIPSInt::Int_VrndX(op);
|
||||
MIPSInt::Int_VrndX(mips, op);
|
||||
return 2;
|
||||
// vf2h
|
||||
case 18:
|
||||
MIPSInt::Int_Vf2h(op);
|
||||
MIPSInt::Int_Vf2h(mips, op);
|
||||
return 2;
|
||||
// vh2f
|
||||
case 19:
|
||||
MIPSInt::Int_Vh2f(op);
|
||||
MIPSInt::Int_Vh2f(mips, op);
|
||||
return 2;
|
||||
// vsbz
|
||||
case 22:
|
||||
MIPSInt::Int_Vsbz(op);
|
||||
MIPSInt::Int_Vsbz(mips, op);
|
||||
return 2;
|
||||
// vlgb
|
||||
case 23:
|
||||
MIPSInt::Int_Vlgb(op);
|
||||
MIPSInt::Int_Vlgb(mips, op);
|
||||
return 2;
|
||||
// vuc2ifs, vc2i, vus2i, vs2i
|
||||
case 24:
|
||||
case 25:
|
||||
case 26:
|
||||
case 27:
|
||||
MIPSInt::Int_Vx2i(op);
|
||||
MIPSInt::Int_Vx2i(mips, op);
|
||||
return 2;
|
||||
// vi2uc, vi2c, vi2us, vi2s
|
||||
case 28:
|
||||
case 29:
|
||||
case 30:
|
||||
case 31:
|
||||
MIPSInt::Int_Vi2x(op);
|
||||
MIPSInt::Int_Vi2x(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
@@ -543,58 +543,58 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
switch ((op.encoding >> 16) & 0x1f) {
|
||||
// vsrt1
|
||||
case 0:
|
||||
MIPSInt::Int_Vsrt1(op);
|
||||
MIPSInt::Int_Vsrt1(mips, op);
|
||||
return 2;
|
||||
// vsrt2
|
||||
case 1:
|
||||
MIPSInt::Int_Vsrt2(op);
|
||||
MIPSInt::Int_Vsrt2(mips, op);
|
||||
return 2;
|
||||
// vbfy1, vbfy2
|
||||
case 2:
|
||||
case 3:
|
||||
MIPSInt::Int_Vbfy(op);
|
||||
MIPSInt::Int_Vbfy(mips, op);
|
||||
return 2;
|
||||
// vocp
|
||||
case 4:
|
||||
MIPSInt::Int_Vocp(op);
|
||||
MIPSInt::Int_Vocp(mips, op);
|
||||
return 2;
|
||||
// vsocp
|
||||
case 5:
|
||||
MIPSInt::Int_Vsocp(op);
|
||||
MIPSInt::Int_Vsocp(mips, op);
|
||||
return 2;
|
||||
// vfad
|
||||
case 6:
|
||||
MIPSInt::Int_Vfad(op);
|
||||
MIPSInt::Int_Vfad(mips, op);
|
||||
return 2;
|
||||
// vavg
|
||||
case 7:
|
||||
MIPSInt::Int_Vavg(op);
|
||||
MIPSInt::Int_Vavg(mips, op);
|
||||
return 2;
|
||||
// vsrt3
|
||||
case 8:
|
||||
MIPSInt::Int_Vsrt3(op);
|
||||
MIPSInt::Int_Vsrt3(mips, op);
|
||||
return 2;
|
||||
// vsrt4
|
||||
case 9:
|
||||
MIPSInt::Int_Vsrt4(op);
|
||||
MIPSInt::Int_Vsrt4(mips, op);
|
||||
return 2;
|
||||
// vsgn
|
||||
case 10:
|
||||
MIPSInt::Int_Vsgn(op);
|
||||
MIPSInt::Int_Vsgn(mips, op);
|
||||
return 2;
|
||||
// vmfvc
|
||||
case 16:
|
||||
MIPSInt::Int_Vmfvc(op);
|
||||
MIPSInt::Int_Vmfvc(mips, op);
|
||||
return 2;
|
||||
// vmtvc
|
||||
case 17:
|
||||
MIPSInt::Int_Vmtvc(op);
|
||||
MIPSInt::Int_Vmtvc(mips, op);
|
||||
return 2;
|
||||
// vt4444, vt5551, vt5650
|
||||
case 25:
|
||||
case 26:
|
||||
case 27:
|
||||
MIPSInt::Int_ColorConv(op);
|
||||
MIPSInt::Int_ColorConv(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
@@ -602,22 +602,22 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
}
|
||||
// vcst
|
||||
case 3:
|
||||
MIPSInt::Int_Vcst(op);
|
||||
MIPSInt::Int_Vcst(mips, op);
|
||||
return 2;
|
||||
// vf2in, vf2iz, vf2iu, vf2id
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
case 19:
|
||||
MIPSInt::Int_Vf2i(op);
|
||||
MIPSInt::Int_Vf2i(mips, op);
|
||||
return 2;
|
||||
// vi2f
|
||||
case 20:
|
||||
MIPSInt::Int_Vi2f(op);
|
||||
MIPSInt::Int_Vi2f(mips, op);
|
||||
return 2;
|
||||
// vcmov
|
||||
case 21:
|
||||
MIPSInt::Int_Vcmov(op);
|
||||
MIPSInt::Int_Vcmov(mips, op);
|
||||
return 2;
|
||||
// vwbn, vwbn, vwbn, vwbn, vwbn, vwbn, vwbn, vwbn
|
||||
case 24:
|
||||
@@ -628,7 +628,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 29:
|
||||
case 30:
|
||||
case 31:
|
||||
MIPSInt::Int_Vwbn(op);
|
||||
MIPSInt::Int_Vwbn(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
@@ -639,7 +639,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 54:
|
||||
case 61:
|
||||
case 62:
|
||||
MIPSInt::Int_SVQ(op);
|
||||
MIPSInt::Int_SVQ(mips, op);
|
||||
return 2;
|
||||
case 55:
|
||||
{
|
||||
@@ -651,12 +651,12 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
MIPSInt::Int_VPFX(op);
|
||||
MIPSInt::Int_VPFX(mips, op);
|
||||
return 2;
|
||||
// viim.s, vfim.s
|
||||
case 6:
|
||||
case 7:
|
||||
MIPSInt::Int_Viim(op);
|
||||
MIPSInt::Int_Viim(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
@@ -670,7 +670,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
MIPSInt::Int_Vmmul(op);
|
||||
MIPSInt::Int_Vmmul(mips, op);
|
||||
return 2;
|
||||
// v(h)tfm2, v(h)tfm2, v(h)tfm2, v(h)tfm2, v(h)tfm3, v(h)tfm3, v(h)tfm3, v(h)tfm3, v(h)tfm4, v(h)tfm4, v(h)tfm4, v(h)tfm4
|
||||
case 4:
|
||||
@@ -685,34 +685,34 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
MIPSInt::Int_Vtfm(op);
|
||||
MIPSInt::Int_Vtfm(mips, op);
|
||||
return 2;
|
||||
// vmscl, vmscl, vmscl, vmscl
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
case 19:
|
||||
MIPSInt::Int_Vmscl(op);
|
||||
MIPSInt::Int_Vmscl(mips, op);
|
||||
return 2;
|
||||
// vcrsp.t/vqmul.q, vcrsp.t/vqmul.q, vcrsp.t/vqmul.q, vcrsp.t/vqmul.q
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
MIPSInt::Int_CrossQuat(op);
|
||||
MIPSInt::Int_CrossQuat(mips, op);
|
||||
return 2;
|
||||
case 28:
|
||||
{
|
||||
switch ((op.encoding >> 16) & 0xf) {
|
||||
// vmmov
|
||||
case 0:
|
||||
MIPSInt::Int_Vmmov(op);
|
||||
MIPSInt::Int_Vmmov(mips, op);
|
||||
return 2;
|
||||
// vmidt, vmzero, vmone
|
||||
case 3:
|
||||
case 6:
|
||||
case 7:
|
||||
MIPSInt::Int_VMatrixInit(op);
|
||||
MIPSInt::Int_VMatrixInit(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
@@ -720,7 +720,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
}
|
||||
// vrot
|
||||
case 29:
|
||||
MIPSInt::Int_Vrot(op);
|
||||
MIPSInt::Int_Vrot(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
@@ -728,7 +728,7 @@ int ExecInstruction(MIPSOpcode op) {
|
||||
}
|
||||
// vflush
|
||||
case 63:
|
||||
MIPSInt::Int_Vflush(op);
|
||||
MIPSInt::Int_Vflush(mips, op);
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
|
||||
// Fast switch-tree interpreter dispatcher, generated into InterpreterDispatch.cpp by
|
||||
// GenerateInterpreterDispatch() in MIPSTables.cpp. Executes op on the global currentMIPS
|
||||
// (same convention as the MIPSInt::Int_* handlers it calls into) and returns the number of
|
||||
// cycles it consumed - or -1 if op isn't a recognized instruction (an invalid encoding, or
|
||||
// one of the handful of real instructions with no interpreter implementation, e.g.
|
||||
// tge/tlt/teq/...). Not total by design: the caller must fall back to MIPSInterpret() on a
|
||||
// negative return, since deciding what "unhandled" means is a caller policy, not something
|
||||
// a mechanically generated dispatch tree should embed.
|
||||
int ExecInstruction(MIPSOpcode op);
|
||||
// GenerateInterpreterDispatch() in MIPSTables.cpp. Executes op on mips (same convention as
|
||||
// the MIPSInt::Int_* handlers it calls into) and returns the number of cycles it consumed -
|
||||
// or -1 if op isn't a recognized instruction (an invalid encoding, or one of the handful of
|
||||
// real instructions with no interpreter implementation, e.g. tge/tlt/teq/...). Not total by
|
||||
// design: the caller must fall back to MIPSInterpret() on a negative return, since deciding
|
||||
// what "unhandled" means is a caller policy, not something a mechanically generated dispatch
|
||||
// tree should embed.
|
||||
int ExecInstruction(MIPSState *mips, MIPSOpcode op);
|
||||
+423
-422
File diff suppressed because it is too large.
Load diff
+55
-57
@@ -20,63 +20,61 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
|
||||
int MIPS_SingleStep();
|
||||
|
||||
namespace MIPSInt
|
||||
{
|
||||
void Int_SV(MIPSOpcode op);
|
||||
void Int_SVQ(MIPSOpcode op);
|
||||
void Int_Mftv(MIPSOpcode op);
|
||||
void Int_VecDo3(MIPSOpcode op);
|
||||
void Int_Vcst(MIPSOpcode op);
|
||||
void Int_VMatrixInit(MIPSOpcode op);
|
||||
void Int_VVectorInit(MIPSOpcode op);
|
||||
void Int_Vmmul(MIPSOpcode op);
|
||||
void Int_Vmscl(MIPSOpcode op);
|
||||
void Int_Vmmov(MIPSOpcode op);
|
||||
void Int_VV2Op(MIPSOpcode op);
|
||||
void Int_Vrot(MIPSOpcode op);
|
||||
void Int_VDot(MIPSOpcode op);
|
||||
void Int_VHdp(MIPSOpcode op);
|
||||
void Int_Vavg(MIPSOpcode op);
|
||||
void Int_Vfad(MIPSOpcode op);
|
||||
void Int_Vocp(MIPSOpcode op);
|
||||
void Int_Vsocp(MIPSOpcode op);
|
||||
void Int_Vsgn(MIPSOpcode op);
|
||||
void Int_Vtfm(MIPSOpcode op);
|
||||
void Int_Viim(MIPSOpcode op);
|
||||
void Int_VScl(MIPSOpcode op);
|
||||
void Int_Vidt(MIPSOpcode op);
|
||||
void Int_Vcmp(MIPSOpcode op);
|
||||
void Int_Vminmax(MIPSOpcode op);
|
||||
void Int_Vscmp(MIPSOpcode op);
|
||||
void Int_Vcrs(MIPSOpcode op);
|
||||
void Int_Vdet(MIPSOpcode op);
|
||||
void Int_Vcmov(MIPSOpcode op);
|
||||
void Int_CrossQuat(MIPSOpcode op);
|
||||
void Int_VPFX(MIPSOpcode op);
|
||||
void Int_Vflush(MIPSOpcode op);
|
||||
void Int_Vbfy(MIPSOpcode op);
|
||||
void Int_Vsrt1(MIPSOpcode op);
|
||||
void Int_Vsrt2(MIPSOpcode op);
|
||||
void Int_Vsrt3(MIPSOpcode op);
|
||||
void Int_Vsrt4(MIPSOpcode op);
|
||||
void Int_Vf2i(MIPSOpcode op);
|
||||
void Int_Vi2f(MIPSOpcode op);
|
||||
void Int_Vi2x(MIPSOpcode op);
|
||||
void Int_Vx2i(MIPSOpcode op);
|
||||
void Int_VBranch(MIPSOpcode op);
|
||||
void Int_Vrnds(MIPSOpcode op);
|
||||
void Int_VrndX(MIPSOpcode op);
|
||||
void Int_ColorConv(MIPSOpcode op);
|
||||
void Int_Vh2f(MIPSOpcode op);
|
||||
void Int_Vf2h(MIPSOpcode op);
|
||||
void Int_Vsge(MIPSOpcode op);
|
||||
void Int_Vslt(MIPSOpcode op);
|
||||
void Int_Vmfvc(MIPSOpcode op);
|
||||
void Int_Vmtvc(MIPSOpcode op);
|
||||
void Int_Vlgb(MIPSOpcode op);
|
||||
void Int_Vwbn(MIPSOpcode op);
|
||||
void Int_Vsbn(MIPSOpcode op);
|
||||
void Int_Vsbz(MIPSOpcode op);
|
||||
void Int_SV(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_SVQ(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Mftv(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_VecDo3(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vcst(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_VMatrixInit(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_VVectorInit(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vmmul(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vmscl(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vmmov(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_VV2Op(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vrot(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_VDot(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_VHdp(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vavg(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vfad(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vocp(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vsocp(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vsgn(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vtfm(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Viim(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_VScl(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vidt(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vcmp(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vminmax(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vscmp(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vcrs(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vdet(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vcmov(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_CrossQuat(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_VPFX(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vflush(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vbfy(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vsrt1(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vsrt2(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vsrt3(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vsrt4(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vf2i(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vi2f(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vi2x(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vx2i(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_VBranch(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vrnds(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_VrndX(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_ColorConv(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vh2f(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vf2h(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vsge(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vslt(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vmfvc(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vmtvc(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vlgb(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vwbn(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vsbn(MIPSState *mips, MIPSOpcode op);
|
||||
void Int_Vsbz(MIPSState *mips, MIPSOpcode op);
|
||||
}
|
||||
@@ -259,7 +259,7 @@ void LoongArch64JitBackend::CompIR_Interpret(IRInst inst) {
|
||||
QuickCallFunction(&NotifyMIPSInterpret, SCRATCH2);
|
||||
}
|
||||
LI(R4, (int32_t)inst.constant);
|
||||
QuickCallFunction((const u8 *)MIPSGetInterpretFunc(op), SCRATCH2);
|
||||
QuickCallFunction((const u8 *)&MIPSInterpretTrampoline, SCRATCH2);
|
||||
WriteDebugProfilerStatus(IRProfilerStatus::IN_JIT);
|
||||
LoadStaticRegisters();
|
||||
}
|
||||
|
||||
+1
-1
@@ -382,7 +382,7 @@ void MIPSState::ClearJitCache() {
|
||||
if (coreState == CORE_RUNNING_CPU || insideJit) {
|
||||
pendingClears.emplace_back(0, 0);
|
||||
hasPendingClears = true;
|
||||
CoreTiming::ForceCheck();
|
||||
CoreTiming::ForceCheck(this);
|
||||
} else {
|
||||
MIPSComp::jit->ClearCache();
|
||||
}
|
||||
|
||||
+2
-1
@@ -273,7 +273,8 @@ public:
|
||||
|
||||
class MIPSDebugInterface;
|
||||
|
||||
//The one we are compiling or running currently
|
||||
// The one we are compiling or running currently
|
||||
// TODO: These globals should be refactored away.
|
||||
extern MIPSState *currentMIPS;
|
||||
extern MIPSDebugInterface *currentDebugMIPS;
|
||||
extern MIPSState mipsr4k;
|
||||
|
||||
@@ -634,7 +634,7 @@ namespace MIPSAnalyst {
|
||||
return (info & DELAYSLOT) != 0;
|
||||
}
|
||||
|
||||
bool OpWouldChangeMemory(u32 pc, u32 addr, u32 size) {
|
||||
bool OpWouldChangeMemory(MIPSState *mips, u32 pc, u32 addr, u32 size) {
|
||||
if (!Memory::IsValidRange(addr, 4)) {
|
||||
return false;
|
||||
}
|
||||
@@ -664,19 +664,19 @@ namespace MIPSAnalyst {
|
||||
|
||||
if (gprMask != 0) {
|
||||
MIPSGPReg rt = MIPS_GET_RT(op);
|
||||
writeVal = currentMIPS->r[rt] & gprMask;
|
||||
writeVal = mips->r[rt] & gprMask;
|
||||
prevVal = Memory::ReadUnchecked_U32(addr) & gprMask;
|
||||
}
|
||||
|
||||
if (IsSWC1Instr(op)) {
|
||||
int ft = MIPS_GET_FT(op);
|
||||
writeVal = currentMIPS->fi[ft];
|
||||
writeVal = mips->fi[ft];
|
||||
prevVal = Memory::ReadUnchecked_U32(addr);
|
||||
}
|
||||
|
||||
if (IsSVSInstr(op)) {
|
||||
int vt = ((op >> 16) & 0x1f) | ((op & 3) << 5);
|
||||
writeVal = currentMIPS->vi[voffset[vt]];
|
||||
writeVal = mips->vi[voffset[vt]];
|
||||
prevVal = Memory::ReadUnchecked_U32(addr);
|
||||
}
|
||||
|
||||
@@ -686,7 +686,7 @@ namespace MIPSAnalyst {
|
||||
}
|
||||
int vt = (((op >> 16) & 0x1f)) | ((op & 1) << 5);
|
||||
float rd[4];
|
||||
ReadVector(rd, V_Quad, vt);
|
||||
ReadVector(mips, rd, V_Quad, vt);
|
||||
return memcmp(rd, Memory::GetPointerUnchecked(addr), 16) != 0; // sizeof(float) * 4
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace MIPSAnalyst {
|
||||
bool IsDelaySlotNiceFPU(MIPSOpcode branchOp, MIPSOpcode op);
|
||||
bool IsSyscall(MIPSOpcode op);
|
||||
|
||||
bool OpWouldChangeMemory(u32 pc, u32 addr, u32 size);
|
||||
bool OpWouldChangeMemory(MIPSState *mips, u32 pc, u32 addr, u32 size);
|
||||
int OpMemoryAccessSize(u32 pc);
|
||||
bool IsOpMemoryWrite(u32 pc);
|
||||
bool OpHasDelaySlot(u32 pc);
|
||||
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
if (referenceIndex == REF_INDEX_USEC)
|
||||
return (uint32_t)CoreTiming::GetGlobalTimeUs(); // Loses information
|
||||
if (referenceIndex == REF_INDEX_TICKS)
|
||||
return (uint32_t)CoreTiming::GetTicks();
|
||||
return (uint32_t)CoreTiming::GetTicks(currentMIPS);
|
||||
if ((referenceIndex & ~(REF_INDEX_FPU | REF_INDEX_FPU_INT)) < 32)
|
||||
return cpu->GetRegValue(1, referenceIndex & ~(REF_INDEX_FPU | REF_INDEX_FPU_INT));
|
||||
if ((referenceIndex & ~(REF_INDEX_VFPU | REF_INDEX_VFPU_INT)) < 128)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
|
||||
class MIPSDebugInterface : public DebugInterface {
|
||||
private:
|
||||
MIPSState *cpu;
|
||||
public:
|
||||
MIPSDebugInterface(MIPSState *_cpu) { cpu = _cpu; }
|
||||
|
||||
+70
-78
@@ -976,7 +976,7 @@ static void EmitDispatchLevel(std::string &out, MipsEncoding encoding, int inden
|
||||
out += ind + StringFromFormat("// %s\n", names.c_str());
|
||||
for (u32 idx : group)
|
||||
out += ind + StringFromFormat("case %d:\n", idx);
|
||||
out += ind2 + StringFromFormat("MIPSInt::%s(op);\n", instr.interpretName);
|
||||
out += ind2 + StringFromFormat("MIPSInt::%s(mips, op);\n", instr.interpretName);
|
||||
out += ind2 + StringFromFormat("return %d;\n", (int)instr.flags.cycles);
|
||||
} else {
|
||||
for (u32 idx : group)
|
||||
@@ -985,7 +985,7 @@ static void EmitDispatchLevel(std::string &out, MipsEncoding encoding, int inden
|
||||
EmitDispatchLevel(out, instr.altEncoding, indent + 1);
|
||||
out += ind + "}\n";
|
||||
// No trailing return here - the nested switch above always either returns
|
||||
// a value directly from a case, or falls to its own default's "goto slow_path;".
|
||||
// a value directly from a case, or falls to its own default's "return -1;".
|
||||
}
|
||||
}
|
||||
|
||||
@@ -995,15 +995,15 @@ static void EmitDispatchLevel(std::string &out, MipsEncoding encoding, int inden
|
||||
}
|
||||
|
||||
// Generates a full, compilable Core/MIPS/InterpreterDispatch.cpp: a fast
|
||||
// int ExecInstruction(MIPSOpcode op) dispatcher, built by resolving the tables above into
|
||||
// a nested switch tree at generation time, so each real instruction is reached by a direct
|
||||
// call instead of MIPSGetInstruction()'s per-instruction table walk plus indirect call
|
||||
// through instr->interpret. Leaves call straight into the existing MIPSInt::Int_* handlers
|
||||
// - the tables only record which handler an opcode maps to, not the handler's behavior, so
|
||||
// that's the only thing there is to call - and return that instruction's fixed cycle count
|
||||
// (baked in at generation time, same value MIPSGetInstructionCycleEstimate() would have
|
||||
// returned) so the caller can still track downcount. Operates on the global currentMIPS,
|
||||
// same as the Int_* handlers do.
|
||||
// int ExecInstruction(MIPSState *mips, MIPSOpcode op) dispatcher, built by resolving the
|
||||
// tables above into a nested switch tree at generation time, so each real instruction is
|
||||
// reached by a direct call instead of MIPSGetInstruction()'s per-instruction table walk plus
|
||||
// indirect call through instr->interpret. Leaves call straight into the existing
|
||||
// MIPSInt::Int_* handlers - the tables only record which handler an opcode maps to, not the
|
||||
// handler's behavior, so that's the only thing there is to call - and return that
|
||||
// instruction's fixed cycle count (baked in at generation time, same value
|
||||
// MIPSGetInstructionCycleEstimate() would have returned) so the caller can still track
|
||||
// downcount.
|
||||
//
|
||||
// The generated function is deliberately not total: most of the 32-bit opcode space doesn't
|
||||
// decode to anything (either a genuinely invalid encoding, or a real-but-uninterpreted
|
||||
@@ -1036,7 +1036,7 @@ std::string GenerateInterpreterDispatch() {
|
||||
out += "#include \"Core/MIPS/InterpreterVFPU.h\"\n\n";
|
||||
out += "// Returns the cycle count consumed, or -1 if op isn't a recognized instruction -\n";
|
||||
out += "// callers must fall back to MIPSInterpret() themselves in that case.\n";
|
||||
out += "int ExecInstruction(MIPSOpcode op) {\n";
|
||||
out += "int ExecInstruction(MIPSState *mips, MIPSOpcode op) {\n";
|
||||
EmitDispatchLevel(out, Imme, 1);
|
||||
out += "}\n";
|
||||
return out;
|
||||
@@ -1082,24 +1082,11 @@ void MIPSDisAsm(MIPSOpcode op, u32 pc, char *out, size_t outSize, bool tabsToSpa
|
||||
}
|
||||
}
|
||||
|
||||
// Shared by both Interpret() below (the MIPSGetInstruction()-based slow path, still used by
|
||||
// RunUntilWithChecks) and RunUntilFast()'s -1 handling (ExecInstruction() is generated from
|
||||
// the exact same tables MIPSGetInstruction() walks, so it has no better information to offer
|
||||
// here - no point re-walking those tables just to rediscover "no interpreter for this op").
|
||||
static void HandleUnknownInstruction(MIPSState *mips, MIPSOpcode op) {
|
||||
ERROR_LOG_REPORT(Log::CPU, "Unknown instruction %08x at %08x", op.encoding, mips->pc);
|
||||
// Try to disassemble it
|
||||
char disasm[256];
|
||||
MIPSDisAsm(op, mips->pc, disasm, sizeof(disasm));
|
||||
_dbg_assert_msg_(0, "%s", disasm);
|
||||
mips->pc += 4;
|
||||
}
|
||||
|
||||
static inline void Interpret(MIPSState *mips, const MIPSInstruction *instr, MIPSOpcode op) {
|
||||
if (instr && instr->interpret) {
|
||||
instr->interpret(op);
|
||||
instr->interpret(mips, op);
|
||||
} else {
|
||||
HandleUnknownInstruction(mips, op);
|
||||
Core_ExecException(mips->pc, mips->pc, ExecExceptionType::ILLEGAL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1114,108 +1101,113 @@ void MIPSInterpret(MIPSState *mips, MIPSOpcode op) {
|
||||
Interpret(mips, instr, op);
|
||||
}
|
||||
|
||||
static inline void RunUntilFast(MIPSState *curMips) {
|
||||
// NEVER stop in a delay slot!
|
||||
while (curMips->downcount >= 0 && coreState == CORE_RUNNING_CPU) {
|
||||
// See the declaration comment in MIPSTables.h.
|
||||
void CDECL MIPSInterpretTrampoline(MIPSOpcode op) {
|
||||
MIPSInterpret(currentMIPS, op);
|
||||
}
|
||||
|
||||
static void RunUntilDowncountZeroFast(MIPSState *mips) {
|
||||
while (mips->downcount >= 0 && coreState == CORE_RUNNING_CPU) {
|
||||
// Don't stop in a delay slot!
|
||||
int cycleCount = 0;
|
||||
do {
|
||||
if (!Memory::IsValid4AlignedAddress(curMips->pc)) {
|
||||
Core_ExecException(curMips->pc, curMips->pc, ExecExceptionType::JUMP);
|
||||
if (!Memory::IsValid4AlignedAddress(mips->pc)) {
|
||||
Core_ExecException(mips->pc, mips->pc, ExecExceptionType::JUMP);
|
||||
return;
|
||||
}
|
||||
MIPSOpcode op = MIPSOpcode(Memory::ReadUnchecked_U32(curMips->pc));
|
||||
MIPSOpcode op = MIPSOpcode(Memory::ReadUnchecked_U32(mips->pc));
|
||||
|
||||
bool wasInDelaySlot = curMips->inDelaySlot;
|
||||
int cycles = ExecInstruction(op);
|
||||
bool wasInDelaySlot = mips->inDelaySlot;
|
||||
int cycles = ExecInstruction(mips, op);
|
||||
if (cycles < 0) {
|
||||
// Not a recognized instruction (invalid encoding, or a known instruction
|
||||
// with no interpreter implementation, e.g. tge/tlt/teq/...). No point
|
||||
// calling MIPSGetInstruction() here - see HandleUnknownInstruction()'s
|
||||
// comment. Every such case has cycles == 1 today (same as
|
||||
// GetInstructionCycleEstimate()'s default for a null/flagless instr).
|
||||
HandleUnknownInstruction(curMips, op);
|
||||
cycles = 1;
|
||||
// Not a recognized instruction (invalid encoding, or an unimplemented kernel-mode only instruction
|
||||
// with no interpreter implementation, e.g. tge/tlt/teq/).
|
||||
Core_ExecException(mips->pc, mips->pc, ExecExceptionType::ILLEGAL);
|
||||
break;
|
||||
}
|
||||
curMips->downcount -= cycles;
|
||||
cycleCount += cycles;
|
||||
|
||||
// The reason we have to check this is the delay slot hack in Int_Syscall.
|
||||
if (curMips->inDelaySlot && wasInDelaySlot) {
|
||||
curMips->pc = curMips->nextPC;
|
||||
curMips->inDelaySlot = false;
|
||||
if (mips->inDelaySlot && wasInDelaySlot) {
|
||||
mips->pc = mips->nextPC;
|
||||
mips->inDelaySlot = false;
|
||||
}
|
||||
} while (curMips->inDelaySlot);
|
||||
} while (mips->inDelaySlot);
|
||||
mips->downcount -= cycleCount;
|
||||
}
|
||||
}
|
||||
|
||||
#define _RS(op) ((op>>21) & 0x1F)
|
||||
static void RunUntilWithChecks(MIPSState *curMips, u64 globalTicks) {
|
||||
// NEVER stop in a delay slot!
|
||||
static void RunUntilDowncountZeroWithChecks(MIPSState *mips, u64 globalTicks) {
|
||||
bool hasBPs = g_breakpoints.HasBreakPoints();
|
||||
bool hasMCs = g_breakpoints.HasMemChecks();
|
||||
while (curMips->downcount >= 0 && coreState == CORE_RUNNING_CPU) {
|
||||
while (mips->downcount >= 0 && coreState == CORE_RUNNING_CPU) {
|
||||
// Don't stop in a delay slot! Well, unless we hit a memcheck in one, of course.
|
||||
do {
|
||||
if (!Memory::IsValid4AlignedAddress(curMips->pc)) {
|
||||
Core_ExecException(curMips->pc, curMips->pc, ExecExceptionType::JUMP);
|
||||
if (!Memory::IsValid4AlignedAddress(mips->pc)) {
|
||||
Core_ExecException(mips->pc, mips->pc, ExecExceptionType::JUMP);
|
||||
return;
|
||||
}
|
||||
MIPSOpcode op = MIPSOpcode(Memory::ReadUnchecked_U32(curMips->pc));
|
||||
MIPSOpcode op = MIPSOpcode(Memory::ReadUnchecked_U32(mips->pc));
|
||||
// Replacements and similar are processed here, intentionally.
|
||||
const MIPSInstruction *instr = MIPSGetInstruction(op);
|
||||
|
||||
// Check for breakpoint
|
||||
if (hasBPs && g_breakpoints.IsAddressBreakPoint(curMips->pc) && g_breakpoints.CheckSkipFirst() != curMips->pc) {
|
||||
auto cond = g_breakpoints.GetBreakPointCondition(curMips->pc);
|
||||
if (hasBPs && g_breakpoints.IsAddressBreakPoint(mips->pc) && g_breakpoints.CheckSkipFirst() != mips->pc) {
|
||||
auto cond = g_breakpoints.GetBreakPointCondition(mips->pc);
|
||||
if (!cond || cond->Evaluate()) {
|
||||
Core_Break(BreakReason::CpuBreakpoint, curMips->pc);
|
||||
if (g_breakpoints.IsTempBreakPoint(curMips->pc))
|
||||
g_breakpoints.RemoveBreakPoint(curMips->pc);
|
||||
Core_Break(BreakReason::CpuBreakpoint, mips->pc);
|
||||
if (g_breakpoints.IsTempBreakPoint(mips->pc))
|
||||
g_breakpoints.RemoveBreakPoint(mips->pc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasMCs && (instr->flags & (IN_MEM | OUT_MEM)) != 0 && g_breakpoints.CheckSkipFirst() != curMips->pc && instr->interpret != &Int_Syscall) {
|
||||
if (hasMCs && (instr->flags & (IN_MEM | OUT_MEM)) != 0 && g_breakpoints.CheckSkipFirst() != mips->pc && instr->interpret != &Int_Syscall) {
|
||||
// This is common for all IN_MEM/OUT_MEM funcs.
|
||||
int offset = (instr->flags & IS_VFPU) != 0 ? SignExtend16ToS32(op & 0xFFFC) : SignExtend16ToS32(op);
|
||||
u32 addr = (curMips->r[_RS(op)] + offset) & 0xFFFFFFFC;
|
||||
u32 addr = (mips->r[_RS(op)] + offset) & 0xFFFFFFFC;
|
||||
int sz = MIPSGetMemoryAccessSize(op);
|
||||
|
||||
if ((instr->flags & IN_MEM) != 0)
|
||||
g_breakpoints.ExecMemCheck(addr, false, sz, curMips->pc, "interpret");
|
||||
g_breakpoints.ExecMemCheck(addr, false, sz, mips->pc, "interpret");
|
||||
if ((instr->flags & OUT_MEM) != 0)
|
||||
g_breakpoints.ExecMemCheck(addr, true, sz, curMips->pc, "interpret");
|
||||
g_breakpoints.ExecMemCheck(addr, true, sz, mips->pc, "interpret");
|
||||
|
||||
// If it tripped, bail without running.
|
||||
if (coreState == CORE_STEPPING_CPU)
|
||||
break;
|
||||
}
|
||||
|
||||
bool wasInDelaySlot = curMips->inDelaySlot;
|
||||
Interpret(curMips, instr, op);
|
||||
curMips->downcount -= GetInstructionCycleEstimate(instr);
|
||||
bool wasInDelaySlot = mips->inDelaySlot;
|
||||
Interpret(mips, instr, op);
|
||||
mips->downcount -= GetInstructionCycleEstimate(instr);
|
||||
|
||||
// The reason we have to check this is the delay slot hack in Int_Syscall.
|
||||
if (curMips->inDelaySlot && wasInDelaySlot) {
|
||||
curMips->pc = curMips->nextPC;
|
||||
curMips->inDelaySlot = false;
|
||||
if (mips->inDelaySlot && wasInDelaySlot) {
|
||||
mips->pc = mips->nextPC;
|
||||
mips->inDelaySlot = false;
|
||||
}
|
||||
} while (curMips->inDelaySlot);
|
||||
} while (mips->inDelaySlot);
|
||||
|
||||
if (CoreTiming::GetTicks() > globalTicks)
|
||||
if (CoreTiming::GetTicks(currentMIPS) > globalTicks)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#undef _RS
|
||||
|
||||
int MIPSInterpret_RunUntil(MIPSState *curMips, u64 globalTicks) {
|
||||
int MIPSInterpret_RunUntil(MIPSState *mips, u64 globalTicks) {
|
||||
while (coreState == CORE_RUNNING_CPU) {
|
||||
CoreTiming::Advance();
|
||||
|
||||
uint64_t ticksLeft = globalTicks - CoreTiming::GetTicks();
|
||||
if (g_breakpoints.HasBreakPoints() || g_breakpoints.HasMemChecks() || ticksLeft <= curMips->downcount)
|
||||
RunUntilWithChecks(curMips, globalTicks);
|
||||
else
|
||||
RunUntilFast(curMips);
|
||||
uint64_t ticksLeft = globalTicks - CoreTiming::GetTicks(currentMIPS);
|
||||
if (g_breakpoints.HasBreakPoints() || g_breakpoints.HasMemChecks() || ticksLeft <= mips->downcount) {
|
||||
RunUntilDowncountZeroWithChecks(mips, globalTicks);
|
||||
} else {
|
||||
RunUntilDowncountZeroFast(mips);
|
||||
}
|
||||
|
||||
if (CoreTiming::GetTicks() > globalTicks) {
|
||||
// DEBUG_LOG(Log::CPU, "Hit the max ticks, bailing 1 : %llu, %llu", globalTicks, CoreTiming::GetTicks());
|
||||
if (CoreTiming::GetTicks(mips) > globalTicks) {
|
||||
// DEBUG_LOG(Log::CPU, "Hit the max ticks, bailing 1 : %llu, %llu", globalTicks, CoreTiming::GetTicks(mips));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-3
@@ -122,7 +122,7 @@ struct MIPSInfo {
|
||||
};
|
||||
|
||||
typedef void (CDECL *MIPSDisFunc)(MIPSOpcode opcode, uint32_t pc, char *out, size_t outSize);
|
||||
typedef void (CDECL *MIPSInterpretFunc)(MIPSOpcode opcode);
|
||||
typedef void (CDECL *MIPSInterpretFunc)(MIPSState *mips, MIPSOpcode opcode);
|
||||
|
||||
namespace MIPSComp {
|
||||
class MIPSFrontendInterface;
|
||||
@@ -135,12 +135,20 @@ void MIPSInterpret(MIPSState *mips, MIPSOpcode op); //only for those rare ones
|
||||
int MIPSInterpret_RunUntil(MIPSState *mips, u64 globalTicks);
|
||||
MIPSInterpretFunc MIPSGetInterpretFunc(MIPSOpcode op);
|
||||
|
||||
// 1-arg (MIPSOpcode only) trampoline around MIPSInterpret(currentMIPS, op), for JIT backends
|
||||
// (x86/ARM/ARM64/RiscV/LoongArch64 Comp_Generic / CompIR_Interpret) that bake a raw function
|
||||
// pointer directly into generated machine code as their interpreter fallback - that codegen
|
||||
// only arranges a single MIPSOpcode argument before the call, so it can't target a real
|
||||
// MIPSInterpretFunc (now 2-arg) without also being taught to pass an explicit MIPSState*.
|
||||
// TODO: teach each JIT's codegen to pass mips explicitly, then delete this.
|
||||
void CDECL MIPSInterpretTrampoline(MIPSOpcode op);
|
||||
|
||||
int MIPSGetInstructionCycleEstimate(MIPSOpcode op);
|
||||
int MIPSGetMemoryAccessSize(MIPSOpcode op);
|
||||
const char *MIPSGetName(MIPSOpcode op);
|
||||
std::string MIPSDisasmAt(u32 compilerPC);
|
||||
|
||||
// Generates the full contents of Core/MIPS/InterpreterDispatch.cpp: a fast switch-tree
|
||||
// int ExecInstruction(MIPSOpcode op) dispatcher, derived from the tables in MIPSTables.cpp.
|
||||
// See GenerateInterpreterDispatch()'s comment (in the .cpp) for details.
|
||||
// int ExecInstruction(MIPSState *mips, MIPSOpcode op) dispatcher, derived from the tables in
|
||||
// MIPSTables.cpp. See GenerateInterpreterDispatch()'s comment (in the .cpp) for details.
|
||||
std::string GenerateInterpreterDispatch();
|
||||
+24
-24
@@ -159,11 +159,11 @@ void GetMatrixRows(int matrixReg, MatrixSize msize, u8 vecs[4]) {
|
||||
}
|
||||
}
|
||||
|
||||
void ReadVector(float *rd, VectorSize size, int reg) {
|
||||
void ReadVector(const MIPSState *mips, float *rd, VectorSize size, int reg) {
|
||||
int row;
|
||||
int length;
|
||||
switch (size) {
|
||||
case V_Single: rd[0] = currentMIPS->v[voffset[reg]]; return; // transpose = 0; row=(reg>>5)&3; length = 1; break;
|
||||
case V_Single: rd[0] = mips->v[voffset[reg]]; return; // transpose = 0; row=(reg>>5)&3; length = 1; break;
|
||||
case V_Pair: row=(reg>>5)&2; length = 2; break;
|
||||
case V_Triple: row=(reg>>6)&1; length = 3; break;
|
||||
case V_Quad: row=(reg>>5)&2; length = 4; break;
|
||||
@@ -176,20 +176,20 @@ void ReadVector(float *rd, VectorSize size, int reg) {
|
||||
if (transpose) {
|
||||
const int base = mtx + col;
|
||||
for (int i = 0; i < length; i++)
|
||||
rd[i] = currentMIPS->v[base + ((row + i) & 3) * 4];
|
||||
rd[i] = mips->v[base + ((row + i) & 3) * 4];
|
||||
} else {
|
||||
const int base = mtx + col * 4;
|
||||
for (int i = 0; i < length; i++)
|
||||
rd[i] = currentMIPS->v[base + ((row + i) & 3)];
|
||||
rd[i] = mips->v[base + ((row + i) & 3)];
|
||||
}
|
||||
}
|
||||
|
||||
void WriteVector(const float *rd, VectorSize size, int reg) {
|
||||
void WriteVector(MIPSState *mips, const float *rd, VectorSize size, int reg) {
|
||||
int row;
|
||||
int length;
|
||||
|
||||
switch (size) {
|
||||
case V_Single: if (!currentMIPS->VfpuWriteMask(0)) currentMIPS->v[voffset[reg]] = rd[0]; return; // transpose = 0; row=(reg>>5)&3; length = 1; break;
|
||||
case V_Single: if (!mips->VfpuWriteMask(0)) mips->v[voffset[reg]] = rd[0]; return; // transpose = 0; row=(reg>>5)&3; length = 1; break;
|
||||
case V_Pair: row=(reg>>5)&2; length = 2; break;
|
||||
case V_Triple: row=(reg>>6)&1; length = 3; break;
|
||||
case V_Quad: row=(reg>>5)&2; length = 4; break;
|
||||
@@ -202,37 +202,37 @@ void WriteVector(const float *rd, VectorSize size, int reg) {
|
||||
// NOTE: We now skip the voffset lookups.
|
||||
if (transpose) {
|
||||
const int base = mtx + col;
|
||||
if (currentMIPS->VfpuWriteMask() == 0) {
|
||||
if (mips->VfpuWriteMask() == 0) {
|
||||
for (int i = 0; i < length; i++)
|
||||
currentMIPS->v[base + ((row+i) & 3) * 4] = rd[i];
|
||||
mips->v[base + ((row+i) & 3) * 4] = rd[i];
|
||||
} else {
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (!currentMIPS->VfpuWriteMask(i)) {
|
||||
currentMIPS->v[base + ((row+i) & 3) * 4] = rd[i];
|
||||
if (!mips->VfpuWriteMask(i)) {
|
||||
mips->v[base + ((row+i) & 3) * 4] = rd[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const int base = mtx + col * 4;
|
||||
if (currentMIPS->VfpuWriteMask() == 0) {
|
||||
if (mips->VfpuWriteMask() == 0) {
|
||||
for (int i = 0; i < length; i++)
|
||||
currentMIPS->v[base + ((row + i) & 3)] = rd[i];
|
||||
mips->v[base + ((row + i) & 3)] = rd[i];
|
||||
} else {
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (!currentMIPS->VfpuWriteMask(i)) {
|
||||
currentMIPS->v[base + ((row + i) & 3)] = rd[i];
|
||||
if (!mips->VfpuWriteMask(i)) {
|
||||
mips->v[base + ((row + i) & 3)] = rd[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 VFPURewritePrefix(int ctrl, u32 remove, u32 add) {
|
||||
u32 prefix = currentMIPS->vfpuCtrl[ctrl];
|
||||
u32 VFPURewritePrefix(MIPSState *mips, int ctrl, u32 remove, u32 add) {
|
||||
u32 prefix = mips->vfpuCtrl[ctrl];
|
||||
return (prefix & ~remove) | add;
|
||||
}
|
||||
|
||||
void ReadMatrix(float *rd, MatrixSize size, int reg) {
|
||||
void ReadMatrix(const MIPSState *mips, float *rd, MatrixSize size, int reg) {
|
||||
int row = 0;
|
||||
int side = 0;
|
||||
int transpose = (reg >> 5) & 1;
|
||||
@@ -250,7 +250,7 @@ void ReadMatrix(float *rd, MatrixSize size, int reg) {
|
||||
|
||||
// The voffset ordering is now integrated in these formulas,
|
||||
// eliminating a table lookup.
|
||||
const float *v = currentMIPS->v + (size_t)mtx * 16;
|
||||
const float *v = mips->v + (size_t)mtx * 16;
|
||||
if (transpose) {
|
||||
if (side == 4 && col == 0 && row == 0) {
|
||||
// Fast path: Simple 4x4 transpose. TODO: Optimize.
|
||||
@@ -282,7 +282,7 @@ void ReadMatrix(float *rd, MatrixSize size, int reg) {
|
||||
}
|
||||
}
|
||||
|
||||
void WriteMatrix(const float *rd, MatrixSize size, int reg) {
|
||||
void WriteMatrix(MIPSState *mips, const float *rd, MatrixSize size, int reg) {
|
||||
int mtx = (reg>>2)&7;
|
||||
int col = reg&3;
|
||||
|
||||
@@ -304,9 +304,9 @@ void WriteMatrix(const float *rd, MatrixSize size, int reg) {
|
||||
|
||||
// The voffset ordering is now integrated in these formulas,
|
||||
// eliminating a table lookup.
|
||||
float *v = currentMIPS->v + (size_t)mtx * 16;
|
||||
float *v = mips->v + (size_t)mtx * 16;
|
||||
if (transpose) {
|
||||
if (side == 4 && row == 0 && col == 0 && currentMIPS->VfpuWriteMask() == 0x0) {
|
||||
if (side == 4 && row == 0 && col == 0 && mips->VfpuWriteMask() == 0x0) {
|
||||
// Fast path: Simple 4x4 transpose. TODO: Optimize.
|
||||
for (int j = 0; j < side; j++) {
|
||||
for (int i = 0; i < side; i++) {
|
||||
@@ -316,7 +316,7 @@ void WriteMatrix(const float *rd, MatrixSize size, int reg) {
|
||||
} else {
|
||||
for (int j = 0; j < side; j++) {
|
||||
for (int i = 0; i < side; i++) {
|
||||
if (j != side - 1 || !currentMIPS->VfpuWriteMask(i)) {
|
||||
if (j != side - 1 || !mips->VfpuWriteMask(i)) {
|
||||
int index = ((row + i) & 3) * 4 + ((col + j) & 3);
|
||||
v[index] = rd[j * 4 + i];
|
||||
}
|
||||
@@ -324,12 +324,12 @@ void WriteMatrix(const float *rd, MatrixSize size, int reg) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (side == 4 && row == 0 && col == 0 && currentMIPS->VfpuWriteMask() == 0x0) {
|
||||
if (side == 4 && row == 0 && col == 0 && mips->VfpuWriteMask() == 0x0) {
|
||||
memcpy(v, rd, sizeof(float) * 16); // v[j * 4 + i] = rd[j * 4 + i];
|
||||
} else {
|
||||
for (int j = 0; j < side; j++) {
|
||||
for (int i = 0; i < side; i++) {
|
||||
if (j != side - 1 || !currentMIPS->VfpuWriteMask(i)) {
|
||||
if (j != side - 1 || !mips->VfpuWriteMask(i)) {
|
||||
int index = ((col + j) & 3) * 4 + ((row + i) & 3);
|
||||
v[index] = rd[j * 4 + i];
|
||||
}
|
||||
|
||||
@@ -167,13 +167,13 @@ inline u32 VFPU_MAKE_CONSTANTS(VFPUConst x, VFPUConst y, VFPUConst z, VFPUConst
|
||||
return result;
|
||||
}
|
||||
|
||||
u32 VFPURewritePrefix(int ctrl, u32 remove, u32 add);
|
||||
u32 VFPURewritePrefix(MIPSState *mips, int ctrl, u32 remove, u32 add);
|
||||
|
||||
void ReadMatrix(float *rd, MatrixSize size, int reg);
|
||||
void WriteMatrix(const float *rs, MatrixSize size, int reg);
|
||||
void ReadMatrix(const MIPSState *mips, float *rd, MatrixSize size, int reg);
|
||||
void WriteMatrix(MIPSState *mips,const float *rs, MatrixSize size, int reg);
|
||||
|
||||
void WriteVector(const float *rs, VectorSize N, int reg);
|
||||
void ReadVector(float *rd, VectorSize N, int reg);
|
||||
void ReadVector(const MIPSState *mips, float *rd, VectorSize N, int reg);
|
||||
void WriteVector(MIPSState *mips, const float *rs, VectorSize N, int reg);
|
||||
|
||||
void GetVectorRegs(u8 regs[4], VectorSize N, int vectorReg);
|
||||
void GetMatrixRegs(u8 regs[16], MatrixSize N, int matrixReg);
|
||||
|
||||
@@ -260,7 +260,7 @@ void RiscVJitBackend::CompIR_Interpret(IRInst inst) {
|
||||
QuickCallFunction(&NotifyMIPSInterpret, SCRATCH2);
|
||||
}
|
||||
LI(X10, (int32_t)inst.constant);
|
||||
QuickCallFunction((const u8 *)MIPSGetInterpretFunc(op), SCRATCH2);
|
||||
QuickCallFunction((const u8 *)&MIPSInterpretTrampoline, SCRATCH2);
|
||||
WriteDebugProfilerStatus(IRProfilerStatus::IN_JIT);
|
||||
LoadStaticRegisters();
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ static void JitBranchLog(MIPSOpcode op, u32 pc) {
|
||||
|
||||
MIPSInterpretFunc func = MIPSGetInterpretFunc(op);
|
||||
MIPSInfo info = MIPSGetInfo(op);
|
||||
func(op);
|
||||
func(currentMIPS, op);
|
||||
|
||||
// Branch taken, use nextPC.
|
||||
if (currentMIPS->inDelaySlot)
|
||||
|
||||
@@ -111,7 +111,7 @@ static void JitLogMiss(MIPSOpcode op)
|
||||
notJitOps[MIPSGetName(op)]++;
|
||||
|
||||
MIPSInterpretFunc func = MIPSGetInterpretFunc(op);
|
||||
func(op);
|
||||
func(currentMIPS, op);
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@@ -626,7 +626,7 @@ void Jit::Comp_Generic(MIPSOpcode op) {
|
||||
if (USE_JIT_MISSMAP)
|
||||
ABI_CallFunctionC(&JitLogMiss, op.encoding);
|
||||
else
|
||||
ABI_CallFunctionC(func, op.encoding);
|
||||
ABI_CallFunctionC(&MIPSInterpretTrampoline, op.encoding);
|
||||
ApplyRoundingMode();
|
||||
} else {
|
||||
// These are basically always due to some kind of crash or corruption now.
|
||||
|
||||
@@ -256,7 +256,7 @@ void X64JitBackend::CompIR_Interpret(IRInst inst) {
|
||||
if (DebugStatsEnabled()) {
|
||||
ABI_CallFunctionP((const void *)&NotifyMIPSInterpret, (void *)MIPSGetName(op));
|
||||
}
|
||||
ABI_CallFunctionC((const void *)MIPSGetInterpretFunc(op), inst.constant);
|
||||
ABI_CallFunctionC((const void *)&MIPSInterpretTrampoline, inst.constant);
|
||||
WriteDebugProfilerStatus(IRProfilerStatus::IN_JIT);
|
||||
LoadStaticRegisters();
|
||||
}
|
||||
|
||||
+6
-1
@@ -71,6 +71,11 @@ u8 *m_pUncachedKernelRAM[3];
|
||||
static u8 *m_pPhysicalVRAM[4];
|
||||
static u8 *m_pUncachedVRAM[4];
|
||||
|
||||
// Hardware registers are mapped at 0xbc000000 and forwards (physical address 0x1C000000, but we need
|
||||
// the 0x80000000 kernel flag and 0x40000000 uncached flag for these). Exception vectors are at 0xbfc00000.
|
||||
// Since we do HLE emulation, we currently don't bother with any of that.
|
||||
// Some limited documentation here: https://www.psdevwiki.com/psp/Hardware_Registers#Introduction
|
||||
|
||||
// Holds the ending address of the PSP's user space.
|
||||
// Required for HD Remasters to work properly.
|
||||
// This replaces RAM_NORMAL_SIZE at runtime.
|
||||
@@ -337,7 +342,7 @@ void Reinit() {
|
||||
}
|
||||
|
||||
static void DoMemoryVoid(PointerWrap &p, uint32_t start, uint32_t size) {
|
||||
uint8_t *d = GetPointerWrite(start);
|
||||
uint8_t *d = GetPointerWriteOrException(start);
|
||||
uint8_t *&storage = *p.ptr;
|
||||
|
||||
// We only handle aligned data and sizes.
|
||||
|
||||
+13
-7
@@ -242,19 +242,19 @@ void WriteOrException_U16(const u16 data, const u32 address);
|
||||
void WriteOrException_U32(const u32 data, const u32 address);
|
||||
void WriteOrException_U64(const u64 data, const u32 address);
|
||||
|
||||
u8* GetPointerWrite(const u32 address);
|
||||
const u8* GetPointer(const u32 address);
|
||||
u8* GetPointerWriteOrException(const u32 address);
|
||||
const u8* GetPointerOrException(const u32 address);
|
||||
|
||||
u8 *GetPointerWriteRange(const u32 address, const u32 size);
|
||||
u8 *GetPointerWriteRangeOrException(const u32 address, const u32 size);
|
||||
template<typename T>
|
||||
T* GetTypedPointerWriteRange(const u32 address, const u32 size) {
|
||||
return reinterpret_cast<T*>(GetPointerWriteRange(address, size));
|
||||
return reinterpret_cast<T*>(GetPointerWriteRangeOrException(address, size));
|
||||
}
|
||||
|
||||
const u8 *GetPointerRange(const u32 address, const u32 size);
|
||||
const u8 *GetPointerRangeOrException(const u32 address, const u32 size);
|
||||
template<typename T>
|
||||
const T* GetTypedPointerRange(const u32 address, const u32 size) {
|
||||
return reinterpret_cast<const T*>(GetPointerRange(address, size));
|
||||
return reinterpret_cast<const T*>(GetPointerRangeOrException(address, size));
|
||||
}
|
||||
|
||||
bool IsRAMAddress(const u32 address);
|
||||
@@ -267,6 +267,11 @@ inline bool IsDepthTexVRAMAddress(const u32 address) {
|
||||
return ((address & 0xBFE00000) == 0x04200000) || ((address & 0xBFE00000) == 0x04600000);
|
||||
}
|
||||
|
||||
// TODO: To re-evaluate.
|
||||
inline bool IsMMIOAccess(const u32 address) {
|
||||
return ((address & 0xFC000000) == 0xBC000000);
|
||||
}
|
||||
|
||||
// 0x08000000 -> 0x08800000
|
||||
inline bool IsKernelAddress(const u32 address) {
|
||||
return ((address & 0x3F800000) == 0x08000000);
|
||||
@@ -291,6 +296,7 @@ inline void MemcpyUnchecked(const u32 to_address, const u32 from_address, const
|
||||
MemcpyUnchecked(GetPointerWriteUnchecked(to_address), from_address, len);
|
||||
}
|
||||
|
||||
// Applies to user mode.
|
||||
// Without a length, IsValidAddress is generally semi-meaningless, unless it's about a single byte access. For larger accesses, use IsValid4AlignedAddress
|
||||
// etc when appropriate, or for longer sizes, use IsValidRange or IsValid4AlignedRange for example. Checking aligned-ness helps avoid the problem
|
||||
// of reading past the last byte, say reading 4 bytes at offset 5 of a memory sized 8.
|
||||
@@ -568,7 +574,7 @@ struct PSPPointer
|
||||
}
|
||||
|
||||
void FillWithZero() {
|
||||
memset(Memory::GetPointerWrite(ptr), 0, sizeof(T));
|
||||
memset(Memory::GetPointerWriteOrException(ptr), 0, sizeof(T));
|
||||
}
|
||||
|
||||
bool Equals(u32 addr) const {
|
||||
|
||||
+17
-17
@@ -27,7 +27,7 @@
|
||||
|
||||
namespace Memory {
|
||||
|
||||
u8 *GetPointerWrite(const u32 address) {
|
||||
u8 *GetPointerWriteOrException(const u32 address) {
|
||||
if ((address & 0x3E000000) == 0x08000000 || // RAM
|
||||
(address & 0xBF800000) == 0x04000000 || // VRAM
|
||||
(address & 0xBFFFC000) == 0x00010000 || // Scratchpad
|
||||
@@ -40,7 +40,7 @@ u8 *GetPointerWrite(const u32 address) {
|
||||
}
|
||||
}
|
||||
|
||||
const u8 *GetPointer(const u32 address) {
|
||||
const u8 *GetPointerOrException(const u32 address) {
|
||||
if ((address & 0x3E000000) == 0x08000000 || // RAM
|
||||
(address & 0xBF800000) == 0x04000000 || // VRAM
|
||||
(address & 0xBFFFC000) == 0x00010000 || // Scratchpad
|
||||
@@ -53,8 +53,8 @@ const u8 *GetPointer(const u32 address) {
|
||||
}
|
||||
}
|
||||
|
||||
u8 *GetPointerWriteRange(const u32 address, const u32 size) {
|
||||
u8 *ptr = GetPointerWrite(address);
|
||||
u8 *GetPointerWriteRangeOrException(const u32 address, const u32 size) {
|
||||
u8 *ptr = GetPointerWriteOrException(address);
|
||||
if (ptr) {
|
||||
if (ClampValidSizeAt(address, size) != size) {
|
||||
// That's a memory exception! TODO: Adjust reported address to the end of the range?
|
||||
@@ -69,8 +69,8 @@ u8 *GetPointerWriteRange(const u32 address, const u32 size) {
|
||||
}
|
||||
}
|
||||
|
||||
const u8 *GetPointerRange(const u32 address, const u32 size) {
|
||||
const u8 *ptr = GetPointer(address);
|
||||
const u8 *GetPointerRangeOrException(const u32 address, const u32 size) {
|
||||
const u8 *ptr = GetPointerOrException(address);
|
||||
if (ptr) {
|
||||
if (ClampValidSizeAt(address, size) != size) {
|
||||
// That's a memory exception! TODO: Adjust reported address to the end of the range?
|
||||
@@ -86,7 +86,7 @@ const u8 *GetPointerRange(const u32 address, const u32 size) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void ReadMemoryOrRaiseException(T &var, const u32 address) {
|
||||
inline void ReadMemoryOrException(T &var, const u32 address) {
|
||||
if ((address & 0x3E000000) == 0x08000000 || // RAM
|
||||
(address & 0xBF800000) == 0x04000000 || // VRAM
|
||||
(address & 0xBFFFC000) == 0x00010000 || // Scratchpad
|
||||
@@ -99,7 +99,7 @@ inline void ReadMemoryOrRaiseException(T &var, const u32 address) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void WriteMemoryOrRaiseException(u32 address, const T data) {
|
||||
inline void WriteMemoryOrException(u32 address, const T data) {
|
||||
if ((address & 0x3E000000) == 0x08000000 || // RAM
|
||||
(address & 0xBF800000) == 0x04000000 || // VRAM
|
||||
(address & 0xBFFFC000) == 0x00010000 || // Scratchpad
|
||||
@@ -126,42 +126,42 @@ bool IsScratchpadAddress(const u32 address) {
|
||||
|
||||
u8 ReadOrException_U8(const u32 address) {
|
||||
u8 value = 0;
|
||||
ReadMemoryOrRaiseException<u8>(value, address);
|
||||
ReadMemoryOrException<u8>(value, address);
|
||||
return (u8)value;
|
||||
}
|
||||
|
||||
u16 ReadOrException_U16(const u32 address) {
|
||||
u16_le value = 0;
|
||||
ReadMemoryOrRaiseException<u16_le>(value, address);
|
||||
ReadMemoryOrException<u16_le>(value, address);
|
||||
return (u16)value;
|
||||
}
|
||||
|
||||
u32 ReadOrException_U32(const u32 address) {
|
||||
u32_le value = 0;
|
||||
ReadMemoryOrRaiseException<u32_le>(value, address);
|
||||
ReadMemoryOrException<u32_le>(value, address);
|
||||
return value;
|
||||
}
|
||||
|
||||
u64 Read_U64(const u32 address) {
|
||||
u64 ReadOrException_U64(const u32 address) {
|
||||
u64_le value = 0;
|
||||
ReadMemoryOrRaiseException<u64_le>(value, address);
|
||||
ReadMemoryOrException<u64_le>(value, address);
|
||||
return value;
|
||||
}
|
||||
|
||||
void WriteOrException_U8(const u8 _Data, const u32 address) {
|
||||
WriteMemoryOrRaiseException<u8>(address, _Data);
|
||||
WriteMemoryOrException<u8>(address, _Data);
|
||||
}
|
||||
|
||||
void WriteOrException_U16(const u16 _Data, const u32 address) {
|
||||
WriteMemoryOrRaiseException<u16_le>(address, _Data);
|
||||
WriteMemoryOrException<u16_le>(address, _Data);
|
||||
}
|
||||
|
||||
void WriteOrException_U32(const u32 _Data, const u32 address) {
|
||||
WriteMemoryOrRaiseException<u32_le>(address, _Data);
|
||||
WriteMemoryOrException<u32_le>(address, _Data);
|
||||
}
|
||||
|
||||
void WriteOrException_U64(const u64 _Data, const u32 address) {
|
||||
WriteMemoryOrRaiseException<u64_le>(address, _Data);
|
||||
WriteMemoryOrException<u64_le>(address, _Data);
|
||||
}
|
||||
|
||||
} // namespace Memory
|
||||
@@ -32,7 +32,7 @@ namespace Memory
|
||||
{
|
||||
|
||||
inline void Memcpy(const u32 to_address, const void *from_data, const u32 len, const char *tag, size_t tagLen) {
|
||||
u8 *to = GetPointerWriteRange(to_address, len);
|
||||
u8 *to = GetPointerWriteRangeOrException(to_address, len);
|
||||
if (to) {
|
||||
memcpy(to, from_data, len);
|
||||
if (!tag) {
|
||||
@@ -45,7 +45,7 @@ inline void Memcpy(const u32 to_address, const void *from_data, const u32 len, c
|
||||
}
|
||||
|
||||
inline void Memcpy(void *to_data, const u32 from_address, const u32 len, const char *tag, size_t tagLen) {
|
||||
const u8 *from = GetPointerRange(from_address, len);
|
||||
const u8 *from = GetPointerRangeOrException(from_address, len);
|
||||
if (from) {
|
||||
memcpy(to_data, from, len);
|
||||
if (!tag) {
|
||||
@@ -58,11 +58,11 @@ inline void Memcpy(void *to_data, const u32 from_address, const u32 len, const c
|
||||
}
|
||||
|
||||
inline void Memcpy(const u32 to_address, const u32 from_address, const u32 len, const char *tag, size_t tagLen) {
|
||||
u8 *to = GetPointerWriteRange(to_address, len);
|
||||
u8 *to = GetPointerWriteRangeOrException(to_address, len);
|
||||
// If not, GetPointer will log.
|
||||
if (!to)
|
||||
return;
|
||||
const u8 *from = GetPointerRange(from_address, len);
|
||||
const u8 *from = GetPointerRangeOrException(from_address, len);
|
||||
if (!from)
|
||||
return;
|
||||
|
||||
|
||||
+3
-2
@@ -42,6 +42,7 @@
|
||||
#include "Core/MemMap.h"
|
||||
#include "Core/HDRemaster.h"
|
||||
#include "Core/Util/PathUtil.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
|
||||
#include "Core/Config.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
@@ -307,7 +308,7 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) {
|
||||
System_PostUIMessage(UIMessage::CONFIG_LOADED);
|
||||
INFO_LOG(Log::Loader, "Loading %s...", bootpath.c_str());
|
||||
// TODO: We can't use the initial error_string pointer.
|
||||
return __KernelLoadExec(bootpath.c_str(), 0, &PSP_CoreParameter().errorString);
|
||||
return __KernelLoadExec(currentMIPS, bootpath.c_str(), 0, &PSP_CoreParameter().errorString);
|
||||
}
|
||||
|
||||
// TODO: Move this to common. Merge with ResolvePath?
|
||||
@@ -451,7 +452,7 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string_view discId, bool load
|
||||
g_Config.LoadGameConfig(discID);
|
||||
}
|
||||
|
||||
return __KernelLoadExec(finalName.c_str(), 0, error_string);
|
||||
return __KernelLoadExec(currentMIPS, finalName.c_str(), 0, error_string);
|
||||
}
|
||||
|
||||
bool Load_PSP_GE_Dump(FileLoader *fileLoader, std::string *error_string) {
|
||||
|
||||
+2
-1
@@ -50,6 +50,7 @@ extern "C" {
|
||||
#include "Core/Loaders.h"
|
||||
#include "Core/SaveState.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
#include "Core/ELF/ParamSFO.h"
|
||||
#include "Core/FileSystems/BlockDevices.h"
|
||||
#include "Core/FileSystems/MetaFileSystem.h"
|
||||
@@ -457,7 +458,7 @@ namespace Reporting
|
||||
{
|
||||
// Just to get an idea of how long they played.
|
||||
if (PSP_GetBootState() == BootState::Complete)
|
||||
postdata.Add("ticks", (const uint64_t)CoreTiming::GetTicks());
|
||||
postdata.Add("ticks", (const uint64_t)CoreTiming::GetTicks(currentMIPS));
|
||||
|
||||
float vps, fps;
|
||||
__DisplayGetAveragedFPS(&vps, &fps);
|
||||
|
||||
+2
-2
@@ -437,7 +437,7 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin
|
||||
|
||||
mipsr4k.Reset();
|
||||
|
||||
CoreTiming::Init();
|
||||
CoreTiming::Init(&mipsr4k);
|
||||
|
||||
DisplayHWInit();
|
||||
|
||||
@@ -798,7 +798,7 @@ void PSP_RunLoopWhileState() {
|
||||
}
|
||||
|
||||
void PSP_RunLoopFor(int cycles) {
|
||||
Core_RunLoopUntil(CoreTiming::GetTicks() + cycles);
|
||||
Core_RunLoopUntil(CoreTiming::GetTicks(currentMIPS) + cycles);
|
||||
}
|
||||
|
||||
const char *DumpFileTypeToString(DumpFileType type) {
|
||||
|
||||
@@ -285,7 +285,7 @@ void __PPGeInit() {
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, palette.ptr, 16 * sizeof(u16_le), "PPGe Palette");
|
||||
|
||||
const u32_le *imagePtr = (u32_le *)imageData[0];
|
||||
u8 *ramPtr = atlasPtr == 0 ? nullptr : (u8 *)Memory::GetPointerRange(atlasPtr, atlasSize);
|
||||
u8 *ramPtr = atlasPtr == 0 ? nullptr : (u8 *)Memory::GetPointerRangeOrException(atlasPtr, atlasSize);
|
||||
|
||||
// Palettize to 4-bit, the easy way.
|
||||
for (int i = 0; i < width[0] * height[0] / 2; i++) {
|
||||
@@ -334,7 +334,7 @@ void __PPGeDoState(PointerWrap &p)
|
||||
} else {
|
||||
// Memory was already updated by this point, so check directly.
|
||||
if (atlasPtr != 0) {
|
||||
savedHash = XXH3_64bits(Memory::GetPointerRange(atlasPtr, atlasWidth * atlasHeight / 2), atlasWidth * atlasHeight / 2);
|
||||
savedHash = XXH3_64bits(Memory::GetPointerRangeOrException(atlasPtr, atlasWidth * atlasHeight / 2), atlasWidth * atlasHeight / 2);
|
||||
} else {
|
||||
savedHash ^= 1;
|
||||
}
|
||||
@@ -929,7 +929,7 @@ static PPGeTextDrawerImage PPGeGetTextImage(std::string_view text, const PPGeSty
|
||||
|
||||
if (im.ptr) {
|
||||
int wBytes = (im.entry.bmWidth + 1) / 2;
|
||||
u8 *ramPtr = Memory::GetPointerWriteRange(im.ptr, sz);
|
||||
u8 *ramPtr = Memory::GetPointerWriteRangeOrException(im.ptr, sz);
|
||||
for (int y = 0; y < im.entry.bmHeight; ++y) {
|
||||
for (int x = 0; x < wBytes; ++x) {
|
||||
uint8_t c1 = bitmapData[y * im.entry.bmWidth + x * 2];
|
||||
@@ -1373,7 +1373,7 @@ bool PPGeImage::Load() {
|
||||
int success;
|
||||
if (filename_.empty()) {
|
||||
_dbg_assert_(size_ < MAX_VALID_IMAGE_SIZE);
|
||||
const u8 *srcPtr = Memory::GetPointerRange(png_, (u32)size_);
|
||||
const u8 *srcPtr = Memory::GetPointerRangeOrException(png_, (u32)size_);
|
||||
if (!srcPtr) {
|
||||
ERROR_LOG(Log::sceGe, "Trying to load PPGeImage from invalid range: %08x, %08x bytes", png_, (int)size_);
|
||||
return false;
|
||||
|
||||
@@ -3144,7 +3144,7 @@ bool FramebufferManagerCommon::GetStencilbuffer(u32 fb_address, int fb_stride, G
|
||||
return false;
|
||||
// If there's no vfb and we're drawing there, must be memory?
|
||||
// TODO: Actually get the stencil.
|
||||
buffer = GPUDebugBuffer(Memory::GetPointerWrite(fb_address), fb_stride, 512, GPU_DBG_FORMAT_8888);
|
||||
buffer = GPUDebugBuffer(Memory::GetPointerWriteOrException(fb_address), fb_stride, 512, GPU_DBG_FORMAT_8888);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size,
|
||||
u8 usedBits = 0;
|
||||
bool useExportShader = draw_->GetDeviceCaps().fragmentShaderStencilWriteSupported;
|
||||
|
||||
const u8 *src = Memory::GetPointer(addr);
|
||||
const u8 *src = Memory::GetPointerOrException(addr);
|
||||
if (!src)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ static u32 ComputeTextureHash(TextureReplacer &replacer, u32 addr, int bufw, int
|
||||
} else {
|
||||
sizeInRAM = (textureBitsPerPixel[format] * bufw * h) >> 3;
|
||||
}
|
||||
const u32 *checkp = (const u32 *)Memory::GetPointer(addr);
|
||||
const u32 *checkp = (const u32 *)Memory::GetPointerOrException(addr);
|
||||
|
||||
if (Memory::IsValidAddress(addr + sizeInRAM)) {
|
||||
gpuStats.perFrame.numTextureDataBytesHashed += sizeInRAM;
|
||||
@@ -1956,7 +1956,7 @@ TextureAlpha TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETex
|
||||
|
||||
int w = gstate.getTextureWidth(level);
|
||||
int h = gstate.getTextureHeight(level);
|
||||
const u8 *texptr = Memory::GetPointer(texaddr);
|
||||
const u8 *texptr = Memory::GetPointerOrException(texaddr);
|
||||
const uint32_t byteSize = (textureBitsPerPixel[format] * bufw * h) / 8;
|
||||
|
||||
// Validate the texture data fits in mapped RAM, like the DXT path does.
|
||||
|
||||
@@ -135,7 +135,7 @@ inline void DeIndexTexture(/*WRITEONLY*/ ClutT *dest, const IndexT *indexed, int
|
||||
|
||||
template <typename IndexT, typename ClutT>
|
||||
inline void DeIndexTexture(/*WRITEONLY*/ ClutT *dest, const u32 texaddr, int length, const ClutT *clut, u32 *outAlphaSum) {
|
||||
const IndexT *indexed = (const IndexT *) Memory::GetPointer(texaddr);
|
||||
const IndexT *indexed = (const IndexT *) Memory::GetPointerOrException(texaddr);
|
||||
DeIndexTexture(dest, indexed, length, clut, outAlphaSum);
|
||||
}
|
||||
|
||||
@@ -221,12 +221,12 @@ inline void DeIndexTexture4OptimalRev(u16 *dest, const u8 *indexed, int length,
|
||||
|
||||
template <typename ClutT>
|
||||
inline void DeIndexTexture4(ClutT *dest, const u32 texaddr, int length, const ClutT *clut) {
|
||||
const u8 *indexed = (const u8 *) Memory::GetPointer(texaddr);
|
||||
const u8 *indexed = (const u8 *) Memory::GetPointerOrException(texaddr);
|
||||
DeIndexTexture4(dest, indexed, length, clut);
|
||||
}
|
||||
|
||||
template <typename ClutT>
|
||||
inline void DeIndexTexture4Optimal(ClutT *dest, const u32 texaddr, int length, ClutT color) {
|
||||
const u8 *indexed = (const u8 *) Memory::GetPointer(texaddr);
|
||||
const u8 *indexed = (const u8 *) Memory::GetPointerOrException(texaddr);
|
||||
DeIndexTexture4Optimal(dest, indexed, length, color);
|
||||
}
|
||||
@@ -409,7 +409,7 @@ void DumpExecute::SyncStall() {
|
||||
|
||||
s64 listTicks = gpu->GetListTicks(execListID);
|
||||
if (listTicks != -1) {
|
||||
s64 nowTicks = CoreTiming::GetTicks();
|
||||
s64 nowTicks = CoreTiming::GetTicks(currentMIPS);
|
||||
if (listTicks > nowTicks) {
|
||||
currentMIPS->downcount -= listTicks - nowTicks;
|
||||
}
|
||||
|
||||
@@ -466,10 +466,10 @@ void Recorder::FlushPrimState(int vcount) {
|
||||
}
|
||||
}
|
||||
|
||||
const void *verts = Memory::GetPointer(gstate_c.vertexAddr);
|
||||
const void *verts = Memory::GetPointerOrException(gstate_c.vertexAddr);
|
||||
const void *indices = nullptr;
|
||||
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
|
||||
indices = Memory::GetPointer(gstate_c.indexAddr);
|
||||
indices = Memory::GetPointerOrException(gstate_c.indexAddr);
|
||||
}
|
||||
|
||||
u32 ibytes = 0;
|
||||
|
||||
+12
-12
@@ -186,7 +186,7 @@ u32 GPUCommon::DrawSync(int mode) {
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_CONTEXT;
|
||||
}
|
||||
|
||||
if (drawCompleteTicks > CoreTiming::GetTicks()) {
|
||||
if (drawCompleteTicks > CoreTiming::GetTicks(currentMIPS)) {
|
||||
__GeWaitCurrentThread(GPU_SYNC_DRAW, 1, "GeDrawSync");
|
||||
} else {
|
||||
for (int i = 0; i < DisplayListMaxCount; ++i) {
|
||||
@@ -262,7 +262,7 @@ int GPUCommon::ListSync(int listid, int mode) {
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_CONTEXT;
|
||||
}
|
||||
|
||||
if (dl.waitUntilTicks > CoreTiming::GetTicks()) {
|
||||
if (dl.waitUntilTicks > CoreTiming::GetTicks(currentMIPS)) {
|
||||
__GeWaitCurrentThread(GPU_SYNC_LIST, listid, "GeListSync");
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ u32 GPUCommon::EnqueueList(u32 listpc, u32 stall, int subIntrBase, PSPPointer<Ps
|
||||
}
|
||||
|
||||
int id = -1;
|
||||
u64 currentTicks = CoreTiming::GetTicks();
|
||||
u64 currentTicks = CoreTiming::GetTicks(currentMIPS);
|
||||
u32 stackAddr = args.IsValid() && args->size >= 16 ? (u32)args->stackAddr : 0;
|
||||
// Check compatibility
|
||||
// TODO: Figure out what games are affected by this...
|
||||
@@ -735,7 +735,7 @@ inline void GPUCommon::UpdateState(GPURunState state) {
|
||||
// This is now called when coreState == CORE_RUNNING_GE, in addition to from the various sceGe commands.
|
||||
DLResult GPUCommon::ProcessDLQueue() {
|
||||
if (!resumingFromDebugBreak_) {
|
||||
startingTicks = CoreTiming::GetTicks();
|
||||
startingTicks = CoreTiming::GetTicks(currentMIPS);
|
||||
cyclesExecuted = 0;
|
||||
|
||||
// ?? Seems to be correct behaviour to process the list anyway?
|
||||
@@ -1768,8 +1768,8 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
|
||||
u32 dstLineStartAddr = dstBasePtr + (dstY * dstStride + dstX) * bpp;
|
||||
u32 bytesToCopy = width * height * bpp;
|
||||
|
||||
const u8 *srcp = Memory::GetPointer(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWrite(dstLineStartAddr);
|
||||
const u8 *srcp = Memory::GetPointerOrException(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWriteOrException(dstLineStartAddr);
|
||||
memcpy(dstp, srcp, bytesToCopy);
|
||||
|
||||
if (MemBlockInfoDetailed(bytesToCopy)) {
|
||||
@@ -1786,8 +1786,8 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
|
||||
}
|
||||
|
||||
auto notifyingMemmove = [&](u32 d, u32 s, u32 sz) {
|
||||
const u8 *srcp = Memory::GetPointer(s);
|
||||
u8 *dstp = Memory::GetPointerWrite(d);
|
||||
const u8 *srcp = Memory::GetPointerOrException(s);
|
||||
u8 *dstp = Memory::GetPointerWriteOrException(d);
|
||||
memmove(dstp, srcp, sz);
|
||||
|
||||
if (notifyDetail) {
|
||||
@@ -1809,8 +1809,8 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
|
||||
bool dstLineWrap = !Memory::IsValidRange(dstLineStartAddr, bytesToCopy);
|
||||
|
||||
if (!srcLineWrap && !dstLineWrap) {
|
||||
const u8 *srcp = Memory::GetPointer(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWrite(dstLineStartAddr);
|
||||
const u8 *srcp = Memory::GetPointerOrException(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWriteOrException(dstLineStartAddr);
|
||||
for (u32 i = 0; i < bytesToCopy; i += 64) {
|
||||
u32 chunk = i + 64 > bytesToCopy ? bytesToCopy - i : 64;
|
||||
memmove(dstp + i, srcp + i, chunk);
|
||||
@@ -1890,8 +1890,8 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
|
||||
u32 srcLineStartAddr = srcBasePtr + ((y + srcY) * srcStride + srcX) * bpp;
|
||||
u32 dstLineStartAddr = dstBasePtr + ((y + dstY) * dstStride + dstX) * bpp;
|
||||
|
||||
const u8 *srcp = Memory::GetPointer(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWrite(dstLineStartAddr);
|
||||
const u8 *srcp = Memory::GetPointerOrException(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWriteOrException(dstLineStartAddr);
|
||||
memcpy(dstp, srcp, bytesToCopy);
|
||||
|
||||
// If we're tracking detail, it's useful to have the gaps illustrated properly.
|
||||
|
||||
@@ -1850,7 +1850,7 @@ bool GetCurrentTexture(GPUDebugBuffer &buffer, int level)
|
||||
return false;
|
||||
}
|
||||
|
||||
u8 *texptr = Memory::GetPointerWrite(texaddr);
|
||||
u8 *texptr = Memory::GetPointerWriteOrException(texaddr);
|
||||
u32 *row = (u32 *)buffer.GetData();
|
||||
for (int y = 0; y < h; ++y) {
|
||||
for (int x = 0; x < w; ++x) {
|
||||
|
||||
@@ -395,8 +395,8 @@ const SoftwareCommandTableEntry softgpuCommandTable[] = {
|
||||
SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
||||
: GPUCommon(gfxCtx, draw)
|
||||
{
|
||||
fb.data = Memory::GetPointerWrite(0x44000000); // TODO: correct default address?
|
||||
depthbuf.data = Memory::GetPointerWrite(0x44000000); // TODO: correct default address?
|
||||
fb.data = Memory::GetPointerWriteOrException(0x44000000); // TODO: correct default address?
|
||||
depthbuf.data = Memory::GetPointerWriteOrException(0x44000000); // TODO: correct default address?
|
||||
|
||||
memset(softgpuCmdInfo, 0, sizeof(softgpuCmdInfo));
|
||||
|
||||
@@ -500,7 +500,7 @@ void SoftGPU::ConvertTextureDescFrom16(Draw::TextureDesc &desc, int srcwidth, in
|
||||
fbTexBuffer_.resize(srcwidth * srcheight);
|
||||
const uint16_t *displayBuffer = overrideData;
|
||||
if (!displayBuffer)
|
||||
displayBuffer = (const uint16_t *)Memory::GetPointer(displayFramebuf_);
|
||||
displayBuffer = (const uint16_t *)Memory::GetPointerOrException(displayFramebuf_);
|
||||
|
||||
for (int y = 0; y < srcheight; ++y) {
|
||||
u32 *buf_line = &fbTexBuffer_[y * srcwidth];
|
||||
@@ -564,7 +564,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(const DisplayLayoutConfig &config,
|
||||
bool hasPostShader = presentation_ && presentation_->HasPostShader();
|
||||
|
||||
if (PSP_CoreParameter().compat.flags().DarkStalkersPresentHack && displayFormat_ == GE_FORMAT_5551 && g_DarkStalkerStretch != DSStretch::Off) {
|
||||
const u8 *data = Memory::GetPointerWrite(0x04088000);
|
||||
const u8 *data = Memory::GetPointerWriteOrException(0x04088000);
|
||||
bool fillDesc = true;
|
||||
if (draw_->GetDataFormatSupport(Draw::DataFormat::A1B5G5R5_UNORM_PACK16) & Draw::FMT_TEXTURE) {
|
||||
// The perfect one.
|
||||
@@ -593,13 +593,13 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(const DisplayLayoutConfig &config,
|
||||
hasImage = false;
|
||||
u1 = 1.0f;
|
||||
} else if (displayFormat_ == GE_FORMAT_8888) {
|
||||
const u8 *data = Memory::GetPointer(displayFramebuf_);
|
||||
const u8 *data = Memory::GetPointerOrException(displayFramebuf_);
|
||||
desc.width = displayStride_ == 0 ? srcwidth : displayStride_;
|
||||
desc.height = srcheight;
|
||||
desc.initData.push_back(data);
|
||||
desc.format = Draw::DataFormat::R8G8B8A8_UNORM;
|
||||
} else if (displayFormat_ == GE_FORMAT_5551) {
|
||||
const u8 *data = Memory::GetPointer(displayFramebuf_);
|
||||
const u8 *data = Memory::GetPointerOrException(displayFramebuf_);
|
||||
bool fillDesc = true;
|
||||
if (draw_->GetDataFormatSupport(Draw::DataFormat::A1B5G5R5_UNORM_PACK16) & Draw::FMT_TEXTURE) {
|
||||
// The perfect one.
|
||||
@@ -1037,7 +1037,7 @@ void SoftGPU::Execute_ZbufPtr(u32 op, u32 diff) {
|
||||
drawEngine_->transformUnit.Flush(this, "depthbuf");
|
||||
// For the pointer, ignore memory mirrors. This also gives some buffer for draws that go outside.
|
||||
// TODO: Confirm how wrapping is handled in drawing. Adjust if we ever handle VRAM mirrors more accurately.
|
||||
depthbuf.data = Memory::GetPointerWrite(gstate.getDepthBufAddress() & 0x041FFFF0);
|
||||
depthbuf.data = Memory::GetPointerWriteOrException(gstate.getDepthBufAddress() & 0x041FFFF0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1365,7 +1365,7 @@ bool SoftGPU::GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferT
|
||||
size.y = 272;
|
||||
stride = displayStride_;
|
||||
fmt = displayFormat_;
|
||||
src = Memory::GetPointer(displayFramebuf_);
|
||||
src = Memory::GetPointerOrException(displayFramebuf_);
|
||||
}
|
||||
|
||||
buffer.Allocate(size.x, size.y, fmt);
|
||||
|
||||
@@ -75,7 +75,7 @@ def main():
|
||||
|
||||
# Sanity check before clobbering the tracked file - a stale/broken binary should
|
||||
# fail loudly here rather than silently truncating InterpreterDispatch.cpp.
|
||||
if b"int ExecInstruction(MIPSOpcode op)" not in generated:
|
||||
if b"int ExecInstruction(MIPSState *mips, MIPSOpcode op)" not in generated:
|
||||
sys.stderr.write("error: generated output doesn't look right (missing ExecInstruction) - not overwriting %s\n" % OUT_PATH)
|
||||
return 1
|
||||
|
||||
|
||||
Loaded 100 of 106 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user