Attempt to remove some includes

This commit is contained in:
Nekotekina 2014-08-22 18:21:55 +04:00
parent a169c5bcac
commit 5abd3fabfa
43 changed files with 359 additions and 362 deletions

View file

@ -1,5 +1,7 @@
#include "stdafx.h"
#include "AutoPause.h"
#include "Utilities/Log.h"
#include "Emu/System.h"
using namespace Debug;

View file

@ -1,7 +1,4 @@
#pragma once
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
#include "Emu/System.h"
//Regarded as a Debugger Enchantment
namespace Debug {

View file

@ -1,7 +1,5 @@
#pragma once
#include "Utilities/GNU.h"
#include <algorithm>
using std::min;

View file

@ -7,9 +7,9 @@
#endif
#ifdef _WIN32
#define noinline __declspec(noinline)
#define __noinline __declspec(noinline)
#else
#define noinline __attribute__((noinline))
#define __noinline __attribute__((noinline))
#endif
template<size_t size>

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "rPlatform.h"
#include "Log.h"
#include "rMsgBox.h"
#include <iostream>
#include <string>
#include <cinttypes>

View file

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Log.h"
#include <wx/dir.h>
#ifdef _WIN32

View file

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "rMsgBox.h"
#ifndef QT_UI
rMessageDialog::rMessageDialog(void *parent, const std::string& msg, const std::string& title , long style )

View file

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "rTime.h"
#include <wx/datetime.h>

View file

@ -1,7 +1,5 @@
#pragma once
#include "Emu/Memory/Memory.h"
enum CPUDisAsmMode
{
CPUDisAsm_DumpMode,
@ -21,18 +19,18 @@ protected:
{
case CPUDisAsm_DumpMode:
last_opcode = fmt::Format("\t%08llx:\t%02x %02x %02x %02x\t%s\n", dump_pc,
Memory.Read8(offset + dump_pc),
Memory.Read8(offset + dump_pc + 1),
Memory.Read8(offset + dump_pc + 2),
Memory.Read8(offset + dump_pc + 3), value.c_str());
offset[dump_pc],
offset[dump_pc + 1],
offset[dump_pc + 2],
offset[dump_pc + 3], value.c_str());
break;
case CPUDisAsm_InterpreterMode:
last_opcode = fmt::Format("[%08llx] %02x %02x %02x %02x: %s", dump_pc,
Memory.Read8(offset + dump_pc),
Memory.Read8(offset + dump_pc + 1),
Memory.Read8(offset + dump_pc + 2),
Memory.Read8(offset + dump_pc + 3), value.c_str());
offset[dump_pc],
offset[dump_pc + 1],
offset[dump_pc + 2],
offset[dump_pc + 3], value.c_str());
break;
case CPUDisAsm_CompilerElfMode:
@ -44,7 +42,7 @@ protected:
public:
std::string last_opcode;
u64 dump_pc;
u64 offset;
u8* offset;
protected:
CPUDisAsm(CPUDisAsmMode mode)

View file

@ -1,5 +1,4 @@
#pragma once
#include <atomic>
enum
{

View file

@ -1,7 +1,6 @@
#pragma once
#include "Emu/CPU/CPUDisAsm.h"
#include "Emu/Memory/Memory.h"
class PPCDisAsm : public CPUDisAsm
{

View file

@ -1,7 +1,4 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "PPCThread.h"
PPCThread* GetCurrentPPCThread()

View file

@ -1,7 +1,6 @@
#pragma once
#include "Emu/Memory/MemoryBlock.h"
#include "Emu/CPU/CPUThread.h"
#include "Emu/Cell/PPCDecoder.h"
class PPCThread : public CPUThread
{

View file

@ -1,9 +1,6 @@
#pragma once
#include "Emu/Cell/PPUOpcodes.h"
#include "Emu/Cell/PPCDisAsm.h"
#include "Emu/Cell/PPCThread.h"
#include "Emu/Memory/Memory.h"
class PPUDisAsm
: public PPUOpcodes

View file

@ -2,8 +2,49 @@
#include "Emu/Cell/SPUOpcodes.h"
#include "Emu/Cell/PPCDisAsm.h"
#include "Emu/Cell/SPUThread.h"
#include "Emu/Memory/Memory.h"
static const char* spu_reg_name[128] =
{
"$LR", "$SP", "$2", "$3", "$4", "$5", "$6", "$7",
"$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15",
"$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23",
"$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31",
"$32", "$33", "$34", "$35", "$36", "$37", "$38", "$39",
"$40", "$41", "$42", "$43", "$44", "$45", "$46", "$47",
"$48", "$49", "$50", "$51", "$52", "$53", "$54", "$55",
"$56", "$57", "$58", "$59", "$60", "$61", "$62", "$63",
"$64", "$65", "$66", "$67", "$68", "$69", "$70", "$71",
"$72", "$73", "$74", "$75", "$76", "$77", "$78", "$79",
"$80", "$81", "$82", "$83", "$84", "$85", "$86", "$87",
"$88", "$89", "$90", "$91", "$92", "$93", "$94", "$95",
"$96", "$97", "$98", "$99", "$100", "$101", "$102", "$103",
"$104", "$105", "$106", "$107", "$108", "$109", "$110", "$111",
"$112", "$113", "$114", "$115", "$116", "$117", "$118", "$119",
"$120", "$121", "$122", "$123", "$124", "$125", "$126", "$127",
};
static const char* spu_ch_name[128] =
{
"$SPU_RdEventStat", "$SPU_WrEventMask", "$SPU_WrEventAck", "$SPU_RdSigNotify1",
"$SPU_RdSigNotify2", "$ch5", "$ch6", "$SPU_WrDec", "$SPU_RdDec",
"$MFC_WrMSSyncReq", "$ch10", "$SPU_RdEventMask", "$MFC_RdTagMask", "$SPU_RdMachStat",
"$SPU_WrSRR0", "$SPU_RdSRR0", "$MFC_LSA", "$MFC_EAH", "$MFC_EAL", "$MFC_Size",
"$MFC_TagID", "$MFC_Cmd", "$MFC_WrTagMask", "$MFC_WrTagUpdate", "$MFC_RdTagStat",
"$MFC_RdListStallStat", "$MFC_WrListStallAck", "$MFC_RdAtomicStat",
"$SPU_WrOutMbox", "$SPU_RdInMbox", "$SPU_WrOutIntrMbox", "$ch31", "$ch32",
"$ch33", "$ch34", "$ch35", "$ch36", "$ch37", "$ch38", "$ch39", "$ch40",
"$ch41", "$ch42", "$ch43", "$ch44", "$ch45", "$ch46", "$ch47", "$ch48",
"$ch49", "$ch50", "$ch51", "$ch52", "$ch53", "$ch54", "$ch55", "$ch56",
"$ch57", "$ch58", "$ch59", "$ch60", "$ch61", "$ch62", "$ch63", "$ch64",
"$ch65", "$ch66", "$ch67", "$ch68", "$ch69", "$ch70", "$ch71", "$ch72",
"$ch73", "$ch74", "$ch75", "$ch76", "$ch77", "$ch78", "$ch79", "$ch80",
"$ch81", "$ch82", "$ch83", "$ch84", "$ch85", "$ch86", "$ch87", "$ch88",
"$ch89", "$ch90", "$ch91", "$ch92", "$ch93", "$ch94", "$ch95", "$ch96",
"$ch97", "$ch98", "$ch99", "$ch100", "$ch101", "$ch102", "$ch103", "$ch104",
"$ch105", "$ch106", "$ch107", "$ch108", "$ch109", "$ch110", "$ch111", "$ch112",
"$ch113", "$ch114", "$ch115", "$ch116", "$ch117", "$ch118", "$ch119", "$ch120",
"$ch121", "$ch122", "$ch123", "$ch124", "$ch125", "$ch126", "$ch127",
};
class SPUDisAsm
: public SPUOpcodes

View file

@ -42,7 +42,7 @@ private:
//0 - 10
void STOP(u32 code)
{
CPU.DoStop(code);
CPU.StopAndSignal(code);
LOG2_OPCODE();
}
void LNOP()

View file

@ -1,8 +1,4 @@
#pragma once
#include "Emu/Cell/SPUOpcodes.h"
#include "Emu/Memory/Memory.h"
#include "Emu/Cell/SPUThread.h"
#include "Emu/SysCalls/SysCalls.h"
#define ASMJIT_STATIC
@ -438,7 +434,7 @@ private:
static void STOP(u32 code)
{
SPUThread& CPU = *(SPUThread*)GetCurrentCPUThread();
CPU.DoStop(code);
CPU.StopAndSignal(code);
LOG2_OPCODE();
}
};

View file

@ -43,6 +43,7 @@ void SPURecompilerCore::Compile(u16 pos)
u64 time0 = 0;
SPUDisAsm dis_asm(CPUDisAsm_InterpreterMode);
dis_asm.offset = Memory.GetMemFromAddr(CPU.dmac.ls_offset);
StringLogger stringLogger;
stringLogger.setOption(kLoggerOptionBinaryForm, true);
@ -102,7 +103,7 @@ void SPURecompilerCore::Compile(u16 pos)
{
const u64 stamp1 = get_system_time();
// disasm for logging:
dis_asm.dump_pc = CPU.dmac.ls_offset + pos * 4;
dis_asm.dump_pc = pos * 4;
(*SPU_instr::rrr_list)(&dis_asm, opcode);
compiler.addComment(fmt::Format("SPU data: PC=0x%05x %s", pos * 4, dis_asm.last_opcode.c_str()).c_str());
// compile single opcode:
@ -171,21 +172,28 @@ u8 SPURecompilerCore::DecodeMemory(const u64 address)
{
// check data (hard way)
bool is_valid = true;
/*for (u32 i = pos; i < (u32)(entry[pos].count + pos); i++)
{
if (entry[i].valid != ls[i])
{
is_valid = false;
break;
}
}*/
//for (u32 i = pos; i < (u32)(entry[pos].count + pos); i++)
//{
// if (entry[i].valid != ls[i])
// {
// is_valid = false;
// break;
// }
//}
// invalidate if necessary
if (!is_valid)
{
// TODO
LOG_ERROR(Log::SPU, "SPURecompilerCore::DecodeMemory(ls_addr=0x%x): code has changed", pos * sizeof(u32));
Emu.Pause();
return 0;
for (u32 i = 0; i < 0x10000; i++)
{
if (entry[i].pointer &&
i + (u32)entry[i].count > (u32)pos &&
i < (u32)pos + (u32)entry[pos].count)
{
runtime.release(entry[i].pointer);
entry[i].pointer = nullptr;
}
}
//LOG_ERROR(Log::SPU, "SPURecompilerCore::DecodeMemory(ls_addr=0x%x): code has changed", pos * sizeof(u32));
}
}

View file

@ -1,5 +1,7 @@
#pragma once
#include "PPUThread.h"
#include "SPUInstrTable.h"
#include "SPUDisAsm.h"
#include "Emu/Event.h"
#include "Emu/SysCalls/lv2/sys_spu.h"
#include "Emu/SysCalls/lv2/sys_event_flag.h"
@ -8,68 +10,6 @@
#include "Emu/SysCalls/ErrorCodes.h"
#include <mutex>
static const char* spu_reg_name[128] =
{
"$LR", "$SP", "$2", "$3", "$4", "$5", "$6", "$7",
"$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15",
"$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23",
"$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31",
"$32", "$33", "$34", "$35", "$36", "$37", "$38", "$39",
"$40", "$41", "$42", "$43", "$44", "$45", "$46", "$47",
"$48", "$49", "$50", "$51", "$52", "$53", "$54", "$55",
"$56", "$57", "$58", "$59", "$60", "$61", "$62", "$63",
"$64", "$65", "$66", "$67", "$68", "$69", "$70", "$71",
"$72", "$73", "$74", "$75", "$76", "$77", "$78", "$79",
"$80", "$81", "$82", "$83", "$84", "$85", "$86", "$87",
"$88", "$89", "$90", "$91", "$92", "$93", "$94", "$95",
"$96", "$97", "$98", "$99", "$100", "$101", "$102", "$103",
"$104", "$105", "$106", "$107", "$108", "$109", "$110", "$111",
"$112", "$113", "$114", "$115", "$116", "$117", "$118", "$119",
"$120", "$121", "$122", "$123", "$124", "$125", "$126", "$127",
};
//SPU reg $0 is a dummy reg, and is used for certain instructions.
static const char* spu_specialreg_name[128] = {
"$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7",
"$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15",
"$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23",
"$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31",
"$32", "$33", "$34", "$35", "$36", "$37", "$38", "$39",
"$40", "$41", "$42", "$43", "$44", "$45", "$46", "$47",
"$48", "$49", "$50", "$51", "$52", "$53", "$54", "$55",
"$56", "$57", "$58", "$59", "$60", "$61", "$62", "$63",
"$64", "$65", "$66", "$67", "$68", "$69", "$70", "$71",
"$72", "$73", "$74", "$75", "$76", "$77", "$78", "$79",
"$80", "$81", "$82", "$83", "$84", "$85", "$86", "$87",
"$88", "$89", "$90", "$91", "$92", "$93", "$94", "$95",
"$96", "$97", "$98", "$99", "$100", "$101", "$102", "$103",
"$104", "$105", "$106", "$107", "$108", "$109", "$110", "$111",
"$112", "$113", "$114", "$115", "$116", "$117", "$118", "$119",
"$120", "$121", "$122", "$123", "$124", "$125", "$126", "$127",
};
static const char* spu_ch_name[128] =
{
"$SPU_RdEventStat", "$SPU_WrEventMask", "$SPU_WrEventAck", "$SPU_RdSigNotify1",
"$SPU_RdSigNotify2", "$ch5", "$ch6", "$SPU_WrDec", "$SPU_RdDec",
"$MFC_WrMSSyncReq", "$ch10", "$SPU_RdEventMask", "$MFC_RdTagMask", "$SPU_RdMachStat",
"$SPU_WrSRR0", "$SPU_RdSRR0", "$MFC_LSA", "$MFC_EAH", "$MFC_EAL", "$MFC_Size",
"$MFC_TagID", "$MFC_Cmd", "$MFC_WrTagMask", "$MFC_WrTagUpdate", "$MFC_RdTagStat",
"$MFC_RdListStallStat", "$MFC_WrListStallAck", "$MFC_RdAtomicStat",
"$SPU_WrOutMbox", "$SPU_RdInMbox", "$SPU_WrOutIntrMbox", "$ch31", "$ch32",
"$ch33", "$ch34", "$ch35", "$ch36", "$ch37", "$ch38", "$ch39", "$ch40",
"$ch41", "$ch42", "$ch43", "$ch44", "$ch45", "$ch46", "$ch47", "$ch48",
"$ch49", "$ch50", "$ch51", "$ch52", "$ch53", "$ch54", "$ch55", "$ch56",
"$ch57", "$ch58", "$ch59", "$ch60", "$ch61", "$ch62", "$ch63", "$ch64",
"$ch65", "$ch66", "$ch67", "$ch68", "$ch69", "$ch70", "$ch71", "$ch72",
"$ch73", "$ch74", "$ch75", "$ch76", "$ch77", "$ch78", "$ch79", "$ch80",
"$ch81", "$ch82", "$ch83", "$ch84", "$ch85", "$ch86", "$ch87", "$ch88",
"$ch89", "$ch90", "$ch91", "$ch92", "$ch93", "$ch94", "$ch95", "$ch96",
"$ch97", "$ch98", "$ch99", "$ch100", "$ch101", "$ch102", "$ch103", "$ch104",
"$ch105", "$ch106", "$ch107", "$ch108", "$ch109", "$ch110", "$ch111", "$ch112",
"$ch113", "$ch114", "$ch115", "$ch116", "$ch117", "$ch118", "$ch119", "$ch120",
"$ch121", "$ch122", "$ch123", "$ch124", "$ch125", "$ch126", "$ch127",
};
enum SPUchannels
{
SPU_RdEventStat = 0, //Read event status with mask applied
@ -862,6 +802,19 @@ public:
{
LOG_WARNING(Log::SPU, "MFC_PUTLLC_CMD: Reservation impossibru (~x%d (mask=0x%x)) (opcode=0x%x, cmd=0x%x, lsa = 0x%x, ea = 0x%llx, tag = 0x%x, size = 0x%x)",
changed, mask, op, cmd, lsa, ea, tag, size);
SPUDisAsm dis_asm(CPUDisAsm_InterpreterMode);
for (s32 i = PC; i < PC + 4 * 7; i += 4)
{
dis_asm.dump_pc = i;
dis_asm.offset = Memory.GetMemFromAddr(dmac.ls_offset);
const u32 opcode = Memory.Read32(i + dmac.ls_offset);
(*SPU_instr::rrr_list)(&dis_asm, opcode);
if (i >= 0 && i < 0x40000)
{
LOG_NOTICE(Log::SPU, "*** %s", dis_asm.last_opcode.c_str());
}
}
}
}
else
@ -984,13 +937,6 @@ public:
return;
}
if (SPU.In_MBox.GetCount())
{
LOG_ERROR(Log::SPU, "sys_spu_thread_send_event(v=0x%x, spup=%d): In_MBox is not empty", v, spup);
SPU.In_MBox.PushUncond(CELL_EBUSY); // ???
return;
}
if (Ini.HLELogging.GetValue())
{
LOG_NOTICE(Log::SPU, "sys_spu_thread_send_event(spup=%d, data0=0x%x, data1=0x%x)", spup, v & 0x00ffffff, data);
@ -1356,7 +1302,7 @@ public:
if (Emu.IsStopped()) LOG_WARNING(Log::SPU, "%s(%s) aborted", __FUNCTION__, spu_ch_name[ch]);
}
void DoStop(u32 code)
void StopAndSignal(u32 code)
{
SetExitStatus(code); // exit code (not status)

View file

@ -170,12 +170,12 @@ bool DynamicMemoryBlockBase<PT>::Free(u64 addr)
}
}
LOG_ERROR(MEMORY, "DynamicMemoryBlock::Free(addr=0x%llx): failed", addr);
for (u32 i = 0; i < m_allocated.size(); i++)
{
LOG_NOTICE(MEMORY, "*** Memory Block: addr = 0x%llx, size = 0x%x", m_allocated[i].addr, m_allocated[i].size);
}
assert(0);
//LOG_ERROR(MEMORY, "DynamicMemoryBlock::Free(addr=0x%llx): failed", addr);
//for (u32 i = 0; i < m_allocated.size(); i++)
//{
// LOG_NOTICE(MEMORY, "*** Memory Block: addr = 0x%llx, size = 0x%x", m_allocated[i].addr, m_allocated[i].size);
//}
assert(!"DynamicMemoryBlock::Free() failed");
return false;
}
@ -189,7 +189,6 @@ template<typename PT>
bool DynamicMemoryBlockBase<PT>::IsLocked(u64 addr)
{
// TODO
LOG_ERROR(MEMORY, "IsLocked(0x%llx) not implemented", addr);
assert(0);
return false;
}
@ -198,7 +197,6 @@ template<typename PT>
bool DynamicMemoryBlockBase<PT>::Lock(u64 addr, u32 size)
{
// TODO
LOG_ERROR(MEMORY, "Lock(0x%llx, 0x%x) not implemented", addr, size);
assert(0);
return false;
}
@ -207,7 +205,6 @@ template<typename PT>
bool DynamicMemoryBlockBase<PT>::Unlock(u64 addr, u32 size)
{
// TODO
LOG_ERROR(MEMORY, "Unlock(0x%llx, 0x%x) not implemented", addr, size);
assert(0);
return false;
}

View file

@ -8,6 +8,207 @@
MemoryBase Memory;
void MemoryBase::InvalidAddress(const char* func, const u64 addr)
{
LOG_ERROR(MEMORY, "%s(): invalid address (0x%llx)", func, addr);
}
void MemoryBase::RegisterPages(u64 addr, u32 size)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
//LOG_NOTICE(MEMORY, "RegisterPages(addr=0x%llx, size=0x%x)", addr, size);
for (u64 i = addr / 4096; i < (addr + size) / 4096; i++)
{
if (i >= sizeof(m_pages) / sizeof(m_pages[0]))
{
InvalidAddress(__FUNCTION__, i * 4096);
break;
}
if (m_pages[i])
{
LOG_ERROR(MEMORY, "Page already registered (addr=0x%llx)", i * 4096);
}
m_pages[i] = 1; // TODO: define page parameters
}
}
void MemoryBase::UnregisterPages(u64 addr, u32 size)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
//LOG_NOTICE(MEMORY, "UnregisterPages(addr=0x%llx, size=0x%x)", addr, size);
for (u64 i = addr / 4096; i < (addr + size) / 4096; i++)
{
if (i >= sizeof(m_pages) / sizeof(m_pages[0]))
{
InvalidAddress(__FUNCTION__, i * 4096);
break;
}
if (!m_pages[i])
{
LOG_ERROR(MEMORY, "Page not registered (addr=0x%llx)", i * 4096);
}
m_pages[i] = 0; // TODO: define page parameters
}
}
u32 MemoryBase::InitRawSPU(MemoryBlock* raw_spu)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
u32 index;
for (index = 0; index < sizeof(RawSPUMem) / sizeof(RawSPUMem[0]); index++)
{
if (!RawSPUMem[index])
{
RawSPUMem[index] = raw_spu;
break;
}
}
MemoryBlocks.push_back(raw_spu->SetRange(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * index, RAW_SPU_PROB_OFFSET));
return index;
}
void MemoryBase::CloseRawSPU(MemoryBlock* raw_spu, const u32 num)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
for (int i = 0; i < MemoryBlocks.size(); ++i)
{
if (MemoryBlocks[i] == raw_spu)
{
MemoryBlocks.erase(MemoryBlocks.begin() + i);
break;
}
}
if (num < sizeof(RawSPUMem) / sizeof(RawSPUMem[0])) RawSPUMem[num] = nullptr;
}
void MemoryBase::Init(MemoryType type)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (m_inited) return;
m_inited = true;
memset(m_pages, 0, sizeof(m_pages));
memset(RawSPUMem, 0, sizeof(RawSPUMem));
#ifdef _WIN32
m_base_addr = VirtualAlloc(nullptr, 0x100000000, MEM_RESERVE, PAGE_NOACCESS);
if (!m_base_addr)
#else
m_base_addr = ::mmap(nullptr, 0x100000000, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (m_base_addr == (void*)-1)
#endif
{
m_base_addr = nullptr;
LOG_ERROR(MEMORY, "Initializing memory failed");
assert(0);
return;
}
else
{
LOG_NOTICE(MEMORY, "Initializing memory: m_base_addr = 0x%llx", (u64)m_base_addr);
}
switch (type)
{
case Memory_PS3:
MemoryBlocks.push_back(MainMem.SetRange(0x00010000, 0x2FFF0000));
MemoryBlocks.push_back(UserMemory = PRXMem.SetRange(0x30000000, 0x10000000));
MemoryBlocks.push_back(RSXCMDMem.SetRange(0x40000000, 0x10000000));
MemoryBlocks.push_back(MmaperMem.SetRange(0xB0000000, 0x10000000));
MemoryBlocks.push_back(RSXFBMem.SetRange(0xC0000000, 0x10000000));
MemoryBlocks.push_back(StackMem.SetRange(0xD0000000, 0x10000000));
break;
case Memory_PSV:
MemoryBlocks.push_back(PSV.RAM.SetRange(0x81000000, 0x10000000));
MemoryBlocks.push_back(UserMemory = PSV.Userspace.SetRange(0x91000000, 0x10000000));
PSV.Init(GetBaseAddr());
break;
case Memory_PSP:
MemoryBlocks.push_back(PSP.Scratchpad.SetRange(0x00010000, 0x00004000));
MemoryBlocks.push_back(PSP.VRAM.SetRange(0x04000000, 0x00200000));
MemoryBlocks.push_back(PSP.RAM.SetRange(0x08000000, 0x02000000));
MemoryBlocks.push_back(PSP.Kernel.SetRange(0x88000000, 0x00800000));
MemoryBlocks.push_back(UserMemory = PSP.Userspace.SetRange(0x08800000, 0x01800000));
PSP.Init(GetBaseAddr());
break;
}
LOG_NOTICE(MEMORY, "Memory initialized.");
}
void MemoryBase::Close()
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (!m_inited) return;
m_inited = false;
LOG_NOTICE(MEMORY, "Closing memory...");
for (auto block : MemoryBlocks)
{
block->Delete();
}
RSXIOMem.Delete();
MemoryBlocks.clear();
#ifdef _WIN32
if (!VirtualFree(m_base_addr, 0, MEM_RELEASE))
{
LOG_ERROR(MEMORY, "VirtualFree(0x%llx) failed", (u64)m_base_addr);
}
#else
if (::munmap(m_base_addr, 0x100000000))
{
LOG_ERROR(MEMORY, "::munmap(0x%llx) failed", (u64)m_base_addr);
}
#endif
}
bool MemoryBase::Map(const u64 dst_addr, const u64 src_addr, const u32 size)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (IsGoodAddr(dst_addr) || !IsGoodAddr(src_addr))
{
return false;
}
MemoryBlocks.push_back((new MemoryMirror())->SetRange(GetMemFromAddr(src_addr), dst_addr, size));
LOG_WARNING(MEMORY, "memory mapped 0x%llx to 0x%llx size=0x%x", src_addr, dst_addr, size);
return true;
}
bool MemoryBase::Unmap(const u64 addr)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
bool result = false;
for (uint i = 0; i<MemoryBlocks.size(); ++i)
{
if (MemoryBlocks[i]->IsMirror())
{
if (MemoryBlocks[i]->GetStartAddr() == addr)
{
delete MemoryBlocks[i];
MemoryBlocks.erase(MemoryBlocks.begin() + i);
return true;
}
}
}
return false;
}
MemBlockInfo::MemBlockInfo(u64 _addr, u32 _size)
: MemInfo(_addr, PAGE_4K(_size))
{

View file

@ -6,7 +6,6 @@
#include "MemoryBlock.h"
#include "Emu/SysCalls/Callback.h"
#include <vector>
/* OS X uses MAP_ANON instead of MAP_ANONYMOUS */
#ifndef MAP_ANONYMOUS
@ -107,50 +106,11 @@ public:
return m_base_addr;
}
noinline void InvalidAddress(const char* func, const u64 addr)
{
LOG_ERROR(MEMORY, "%s(): invalid address (0x%llx)", func, addr);
}
__noinline void InvalidAddress(const char* func, const u64 addr);
void RegisterPages(u64 addr, u32 size)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
void RegisterPages(u64 addr, u32 size);
//LOG_NOTICE(MEMORY, "RegisterPages(addr=0x%llx, size=0x%x)", addr, size);
for (u64 i = addr / 4096; i < (addr + size) / 4096; i++)
{
if (i >= sizeof(m_pages) / sizeof(m_pages[0]))
{
InvalidAddress(__FUNCTION__, i * 4096);
break;
}
if (m_pages[i])
{
LOG_ERROR(MEMORY, "Page already registered (addr=0x%llx)", i * 4096);
}
m_pages[i] = 1; // TODO: define page parameters
}
}
void UnregisterPages(u64 addr, u32 size)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
//LOG_NOTICE(MEMORY, "UnregisterPages(addr=0x%llx, size=0x%x)", addr, size);
for (u64 i = addr / 4096; i < (addr + size) / 4096; i++)
{
if (i >= sizeof(m_pages) / sizeof(m_pages[0]))
{
InvalidAddress(__FUNCTION__, i * 4096);
break;
}
if (!m_pages[i])
{
LOG_ERROR(MEMORY, "Page not registered (addr=0x%llx)", i * 4096);
}
m_pages[i] = 0; // TODO: define page parameters
}
}
void UnregisterPages(u64 addr, u32 size);
static __forceinline u16 Reverse16(const u16 val)
{
@ -215,96 +175,11 @@ public:
}
}
u32 InitRawSPU(MemoryBlock* raw_spu)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
u32 InitRawSPU(MemoryBlock* raw_spu);
u32 index;
for (index = 0; index < sizeof(RawSPUMem) / sizeof(RawSPUMem[0]); index++)
{
if (!RawSPUMem[index])
{
RawSPUMem[index] = raw_spu;
break;
}
}
void CloseRawSPU(MemoryBlock* raw_spu, const u32 num);
MemoryBlocks.push_back(raw_spu->SetRange(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * index, RAW_SPU_PROB_OFFSET));
return index;
}
void CloseRawSPU(MemoryBlock* raw_spu, const u32 num)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
for (int i = 0; i < MemoryBlocks.size(); ++i)
{
if (MemoryBlocks[i] == raw_spu)
{
MemoryBlocks.erase(MemoryBlocks.begin() + i);
break;
}
}
if (num < sizeof(RawSPUMem) / sizeof(RawSPUMem[0])) RawSPUMem[num] = nullptr;
}
void Init(MemoryType type)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if(m_inited) return;
m_inited = true;
memset(m_pages, 0, sizeof(m_pages));
memset(RawSPUMem, 0, sizeof(RawSPUMem));
#ifdef _WIN32
m_base_addr = VirtualAlloc(nullptr, 0x100000000, MEM_RESERVE, PAGE_NOACCESS);
if (!m_base_addr)
#else
m_base_addr = ::mmap(nullptr, 0x100000000, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (m_base_addr == (void*)-1)
#endif
{
m_base_addr = nullptr;
LOG_ERROR(MEMORY, "Initializing memory failed");
assert(0);
return;
}
else
{
LOG_NOTICE(MEMORY, "Initializing memory: m_base_addr = 0x%llx", (u64)m_base_addr);
}
switch(type)
{
case Memory_PS3:
MemoryBlocks.push_back(MainMem.SetRange(0x00010000, 0x2FFF0000));
MemoryBlocks.push_back(UserMemory = PRXMem.SetRange(0x30000000, 0x10000000));
MemoryBlocks.push_back(RSXCMDMem.SetRange(0x40000000, 0x10000000));
MemoryBlocks.push_back(MmaperMem.SetRange(0xB0000000, 0x10000000));
MemoryBlocks.push_back(RSXFBMem.SetRange(0xC0000000, 0x10000000));
MemoryBlocks.push_back(StackMem.SetRange(0xD0000000, 0x10000000));
break;
case Memory_PSV:
MemoryBlocks.push_back(PSV.RAM.SetRange(0x81000000, 0x10000000));
MemoryBlocks.push_back(UserMemory = PSV.Userspace.SetRange(0x91000000, 0x10000000));
PSV.Init(GetBaseAddr());
break;
case Memory_PSP:
MemoryBlocks.push_back(PSP.Scratchpad.SetRange(0x00010000, 0x00004000));
MemoryBlocks.push_back(PSP.VRAM.SetRange(0x04000000, 0x00200000));
MemoryBlocks.push_back(PSP.RAM.SetRange(0x08000000, 0x02000000));
MemoryBlocks.push_back(PSP.Kernel.SetRange(0x88000000, 0x00800000));
MemoryBlocks.push_back(UserMemory = PSP.Userspace.SetRange(0x08800000, 0x01800000));
PSP.Init(GetBaseAddr());
break;
}
LOG_NOTICE(MEMORY, "Memory initialized.");
}
void Init(MemoryType type);
template<typename T> bool IsGoodAddr(const T addr)
{
@ -334,36 +209,7 @@ public:
}
}
void Close()
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if(!m_inited) return;
m_inited = false;
LOG_NOTICE(MEMORY, "Closing memory...");
for (auto block : MemoryBlocks)
{
block->Delete();
}
RSXIOMem.Delete();
MemoryBlocks.clear();
#ifdef _WIN32
if (!VirtualFree(m_base_addr, 0, MEM_RELEASE))
{
LOG_ERROR(MEMORY, "VirtualFree(0x%llx) failed", (u64)m_base_addr);
}
#else
if (::munmap(m_base_addr, 0x100000000))
{
LOG_ERROR(MEMORY, "::munmap(0x%llx) failed", (u64)m_base_addr);
}
#endif
}
void Close();
//MemoryBase
template<typename T> void Write8(T addr, const u8 data)
@ -392,7 +238,7 @@ public:
}
}
noinline void WriteMMIO32(u32 addr, const u32 data)
__noinline void WriteMMIO32(u32 addr, const u32 data)
{
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
@ -479,7 +325,7 @@ public:
}
}
noinline u32 ReadMMIO32(u32 addr)
__noinline u32 ReadMMIO32(u32 addr)
{
u32 res;
{
@ -624,39 +470,9 @@ public:
return UserMemory->Unlock(addr, size);
}
bool Map(const u64 dst_addr, const u64 src_addr, const u32 size)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
bool Map(const u64 dst_addr, const u64 src_addr, const u32 size);
if(IsGoodAddr(dst_addr) || !IsGoodAddr(src_addr))
{
return false;
}
MemoryBlocks.push_back((new MemoryMirror())->SetRange(GetMemFromAddr(src_addr), dst_addr, size));
LOG_WARNING(MEMORY, "memory mapped 0x%llx to 0x%llx size=0x%x", src_addr, dst_addr, size);
return true;
}
bool Unmap(const u64 addr)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
bool result = false;
for(uint i=0; i<MemoryBlocks.size(); ++i)
{
if(MemoryBlocks[i]->IsMirror())
{
if(MemoryBlocks[i]->GetStartAddr() == addr)
{
delete MemoryBlocks[i];
MemoryBlocks.erase(MemoryBlocks.begin() + i);
return true;
}
}
}
return false;
}
bool Unmap(const u64 addr);
template<typename T> void* operator + (const T vaddr)
{

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rMsgBox.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/SC_FUNC.h"

View file

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/SysCalls.h"
#include "cellGem.h"

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rMsgBox.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rTime.h"
#include "Emu/Memory/Memory.h"
#include "Emu/SysCalls/Modules.h"

View file

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/System.h"
#include "cellRtc.h"

View file

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/SysCalls/Modules.h"
#include "cellRtc.h"
#include "sceNpCommerce2.h"

View file

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/SysCalls/Modules.h"
#include "sceNpSns.h"

View file

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/SysCalls/Modules.h"
#include "cellRtc.h"
#include "sceNp.h"

View file

@ -9,6 +9,23 @@
SysCallBase sys_mtx("sys_mutex");
Mutex::~Mutex()
{
if (u32 owner = m_mutex.GetOwner())
{
LOG_NOTICE(HLE, "Mutex(%d) was owned by thread %d (recursive=%d)", id, owner, recursive);
}
if (!m_queue.m_mutex.try_lock()) return;
for (u32 i = 0; i < m_queue.list.size(); i++)
{
if (u32 owner = m_queue.list[i]) LOG_NOTICE(HLE, "Mutex(%d) was waited by thread %d", id, owner);
}
m_queue.m_mutex.unlock();
}
s32 sys_mutex_create(mem32_t mutex_id, mem_ptr_t<sys_mutex_attribute> attr)
{
sys_mtx.Log("sys_mutex_create(mutex_id_addr=0x%x, attr_addr=0x%x)", mutex_id.GetAddr(), attr.GetAddr());

View file

@ -36,22 +36,7 @@ struct Mutex
{
}
~Mutex()
{
if (u32 owner = m_mutex.GetOwner())
{
LOG_NOTICE(HLE, "Mutex(%d) was owned by thread %d (recursive=%d)", id, owner, recursive);
}
if (!m_queue.m_mutex.try_lock()) return;
for (u32 i = 0; i < m_queue.list.size(); i++)
{
if (u32 owner = m_queue.list[i]) LOG_NOTICE(HLE, "Mutex(%d) was waited by thread %d", id, owner);
}
m_queue.m_mutex.unlock();
}
~Mutex();
};
// SysCalls

View file

@ -1,6 +1,11 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "AutoPauseManager.h"
#include "stdafx.h"
#include <iomanip>
#include <sstream>
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
enum
{

View file

@ -1,9 +1,4 @@
#pragma once
#include "stdafx.h"
#include <iomanip>
#include <sstream>
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
class AutoPauseManagerDialog : public wxDialog
{

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rMsgBox.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "CompilerELF.h"

View file

@ -7,14 +7,8 @@
#include <mutex>
#include "Ini.h"
#include "Utilities/Thread.h"
#include "Utilities/StrFmt.h"
#include "Utilities/Log.h"
#include "Utilities/Log.h"
#include "Gui/ConLogFrame.h"
#include "Utilities/BEType.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
wxDEFINE_EVENT(EVT_LOG_COMMAND, wxCommandEvent);

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "GLGSFrame.h"
#include "Utilities/Timer.h"
GLGSFrame::GLGSFrame()
: GSFrame(nullptr, "GSFrame[OpenGL]")

View file

@ -249,7 +249,7 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr)
}
else
{
disasm->offset = CPU->GetOffset();
disasm->offset = Memory.GetMemFromAddr(CPU->GetOffset());
for(uint i=0, count = 4; i<m_item_count; ++i, PC += count)
{
if(!Memory.IsGoodAddr(CPU->GetOffset() + PC, 4))

View file

@ -1,5 +1,10 @@
#include "stdafx.h"
#include "SaveDataUtility.h"
#include "stdafx.h"
#include <iomanip>
#include <sstream>
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
//Cause i can not decide what struct to be used to fill those. Just use no real data now.
//Currently variable info isn't used. it supposed to be a container for the information passed by other.

View file

@ -1,9 +1,4 @@
#pragma once
#include "stdafx.h"
#include <iomanip>
#include <sstream>
#include "Utilities/Log.h"
#include "Utilities/rFile.h"
//TODO: Implement function calls related to Save Data List.
//Those function calls may be needed to use this GUI.

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rMsgBox.h"
#include "PKG.h"
#include "../Crypto/unpkg.h"

View file

@ -1,6 +1,4 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "rpcs3.h"
#include "Ini.h"

View file

@ -56,13 +56,10 @@ typedef int32_t s32;
typedef int64_t s64;
#include "Utilities/StrFmt.h"
#include "Utilities/Log.h"
#include "Utilities/GNU.h"
#include "Utilities/BEType.h"
#include "Utilities/rFile.h"
#include "Utilities/rTime.h"
#include "Utilities/rMsgBox.h"
#include "Utilities/Thread.h"
#include "Utilities/Timer.h"
#include "Utilities/IdManager.h"
#define _PRGNAME_ "RPCS3"