Merge pull request #83 from Bigpet/master

Make buildable with GCC in Linux
This commit is contained in:
DHrpcs3 2014-02-24 09:14:21 +02:00
commit d9d80d8fb4
50 changed files with 232 additions and 192 deletions

View File

@ -50,10 +50,10 @@ class be_t
public:
typedef T type;
be_t()
{
}
#ifdef __GNUG__
be_t() noexcept = default
#endif
be_t(){}
be_t(const T& value)
{

View File

@ -1,8 +1,8 @@
#pragma once
#if defined(__GNUG__)
#include <math.h>
#define _fpclass(x) fpclassify(x)
#include <cmath>
#define _fpclass(x) std::fpclassify(x)
#define __forceinline __attribute__((always_inline))
#define _byteswap_ushort(x) __builtin_bswap16(x)
#define _byteswap_ulong(x) __builtin_bswap32(x)
@ -11,4 +11,9 @@
#define mkdir(x) mkdir(x, 0777)
#define INFINITE 0xFFFFFFFF
#define _CRT_ALIGN(x) __attribute__((aligned(x)))
#define InterlockedCompareExchange(ptr,new_val,old_val) __sync_val_compare_and_swap(ptr,old_val,new_val)
#define InterlockedCompareExchange64(ptr,new_val,old_val) __sync_val_compare_and_swap(ptr,old_val,new_val)
#define _aligned_malloc(size,alignment) aligned_alloc(alignment,size)
#define _aligned_free(pointer) free(pointer)
#define DWORD int64_t
#endif

View File

@ -96,7 +96,11 @@ public:
m_cur_id = s_first_id;
}
template<typename T>
template<typename T
#ifdef __GNUG__
= char
#endif
>
ID_TYPE GetNewID(const std::string& name = "", T* data = nullptr, const u32 attr = 0)
{
std::lock_guard<std::mutex> lock(m_mtx_main);
@ -155,4 +159,4 @@ public:
return true;
}
};
};

View File

@ -95,4 +95,4 @@ public:
wxDialog::Close(force);
}
};
};

View File

@ -6,9 +6,9 @@ __forceinline void SM_Sleep()
Sleep(1);
}
__forceinline DWORD SM_GetCurrentThreadId()
__forceinline std::thread::id SM_GetCurrentThreadId()
{
return GetCurrentThreadId();
return std::this_thread::get_id();
}
__forceinline u32 SM_GetCurrentCPUThreadId()
@ -23,4 +23,4 @@ __forceinline u32 SM_GetCurrentCPUThreadId()
__forceinline be_t<u32> SM_GetCurrentCPUThreadIdBE()
{
return SM_GetCurrentCPUThreadId();
}
}

View File

@ -1,7 +1,7 @@
#pragma once
extern void SM_Sleep();
extern DWORD SM_GetCurrentThreadId();
extern std::thread::id SM_GetCurrentThreadId();
extern u32 SM_GetCurrentCPUThreadId();
extern be_t<u32> SM_GetCurrentCPUThreadIdBE();
@ -22,7 +22,7 @@ template
typename T,
u32 free_value = 0,
u32 dead_value = ~0,
void (wait)() = SM_Sleep
void (*wait)() = SM_Sleep
>
class SMutexBase
{
@ -164,9 +164,9 @@ typedef SMutexBase<u32>
typedef SMutexBase<be_t<u32>>
SMutexBE;
typedef SMutexLockerBase<DWORD, SM_GetCurrentThreadId>
typedef SMutexLockerBase<std::thread::id, SM_GetCurrentThreadId>
SMutexGeneralLocker;
typedef SMutexLockerBase<u32, SM_GetCurrentCPUThreadId>
SMutexLocker;
typedef SMutexLockerBase<be_t<u32>, SM_GetCurrentCPUThreadIdBE>
SMutexBELocker;
SMutexBELocker;

View File

@ -1,7 +1,12 @@
#include "stdafx.h"
#include "Thread.h"
__declspec(thread) NamedThreadBase* g_tls_this_thread = nullptr;
#ifdef _WIN32
__declspec(thread)
#else
thread_local
#endif
NamedThreadBase* g_tls_this_thread = nullptr;
NamedThreadBase* GetCurrentNamedThread()
{
@ -125,7 +130,7 @@ void thread::start(std::function<void()> func)
catch(...)
{
ConLog.Error("Crash :(");
terminate();
std::terminate();
}
});
}
@ -143,4 +148,4 @@ void thread::join()
bool thread::joinable() const
{
return m_thr.joinable();
}
}

View File

@ -141,7 +141,7 @@ class StepThread : public ThreadBase
volatile bool m_exit;
protected:
StepThread(const wxString& name = "Unknown StepThread")
StepThread(const std::string& name = "Unknown StepThread")
: ThreadBase(true, name)
, m_exit(false)
{

View File

@ -3,14 +3,15 @@ cmake_minimum_required(VERSION 2.8)
project(rpcs3)
if (CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-std=gnu++11)
add_definitions(-D__WXGTK__)
#add_definitions(-Wfatal-errors)
add_definitions(-w) # TODO: remove me
add_definitions(-DwxUSE_UNICODE=0)
add_definitions(-fpermissive) # TODO: remove me
add_definitions(-std=gnu++11)
#add_definitions(-D__WXGTK__)
#add_definitions(-Wfatal-errors)
add_definitions(-w) # TODO: remove me
add_definitions(-fpermissive) # TODO: remove me
endif()
SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/../bin")
add_definitions(-DGL_GLEXT_PROTOTYPES)
add_definitions(-DGLX_GLXEXT_PROTOTYPES)

View File

@ -21,7 +21,7 @@ struct reservation_struct
extern reservation_struct reservation;
enum CPUThreadType
enum CPUThreadType :unsigned char
{
CPU_THREAD_PPU,
CPU_THREAD_SPU,

View File

@ -1,5 +1,6 @@
#pragma once
#include "CPUThread.h"
class CPUThread;
enum CPUThreadType : unsigned char;
class CPUThreadManager
{
@ -24,4 +25,4 @@ public:
void Exec();
void Task();
};
};

View File

@ -1,3 +1,4 @@
#if 0
#include "stdafx.h"
#include "PPCThreadManager.h"
#include "PPUThread.h"
@ -33,7 +34,7 @@ PPCThread& PPCThreadManager::AddThread(PPCThreadType type)
default: assert(0);
}
new_thread->SetId(Emu.GetIdManager().GetNewID(wxString::Format("%s Thread", name), new_thread));
new_thread->SetId(Emu.GetIdManager().GetNewID(wxString::Format("%s Thread", name).ToStdString(), new_thread));
m_threads.Add(new_thread);
wxGetApp().SendDbgCommand(DID_CREATE_THREAD, new_thread);
@ -106,3 +107,4 @@ void PPCThreadManager::Exec()
m_threads[i].Exec();
}
}
#endif

View File

@ -3,9 +3,9 @@
enum PPCThreadType
{
PPC_THREAD_PPU,
PPC_THREAD_SPU,
PPC_THREAD_RAW_SPU
PPC_THREAD_PPU,
PPC_THREAD_SPU,
PPC_THREAD_RAW_SPU
};
class PPCThreadManager
@ -17,7 +17,7 @@ class PPCThreadManager
std::mutex m_mtx_thread;
wxSemaphore m_sem_task;
Stack<u32> m_delete_threads;
u32 m_raw_spu_num;
u32 m_raw_spu_num;
public:
PPCThreadManager();

View File

@ -97,7 +97,7 @@ private:
const int fpc = _fpclass(v);
#ifdef __GNUG__
if(fpc == FP_SUBNORMAL)
return signbit(v) ? -0.0f : 0.0f;
return std::signbit(v) ? -0.0f : 0.0f;
#else
if(fpc & _FPCLASS_ND) return -0.0f;
if(fpc & _FPCLASS_PD) return 0.0f;
@ -3364,7 +3364,7 @@ private:
#ifdef _MSC_VER
if(_fpclass(CPU.FPR[frb]) >= _FPCLASS_NZ)
#else
if(_fpclass(CPU.FPR[frb]) == FP_ZERO || signbit(CPU.FPR[frb]) == 0)
if(_fpclass(CPU.FPR[frb]) == FP_ZERO || std::signbit(CPU.FPR[frb]) == 0)
#endif
{
res = static_cast<float>(1.0 / CPU.FPR[frb]);

View File

@ -2,6 +2,7 @@
#include "Emu/Cell/PPCThread.h"
#include "Emu/SysCalls/SysCalls.h"
#include "rpcs3.h"
#include <cmath>
enum
{
@ -373,10 +374,10 @@ struct PPCdouble
switch (fpc)
{
case FP_NAN: return FPR_QNAN;
case FP_INFINITE: return signbit(_double) ? FPR_NINF : FPR_PINF;
case FP_SUBNORMAL: return signbit(_double) ? FPR_ND : FPR_PD;
case FP_ZERO: return signbit(_double) ? FPR_NZ : FPR_PZ;
default: return signbit(_double) ? FPR_NN : FPR_PN;
case FP_INFINITE: return std::signbit(_double) ? FPR_NINF : FPR_PINF;
case FP_SUBNORMAL: return std::signbit(_double) ? FPR_ND : FPR_PD;
case FP_ZERO: return std::signbit(_double) ? FPR_NZ : FPR_PZ;
default: return std::signbit(_double) ? FPR_NN : FPR_PN;
}
#endif

View File

@ -26,9 +26,9 @@ bool EventManager::RegisterKey(EventQueue* data, u64 key)
if (key_map.find(key) != key_map.end()) return false;
for (auto& v = key_map.begin(); v != key_map.end(); ++v)
for (auto& v : key_map)
{
if (v->second == data) return false;
if (v.second == data) return false;
}
key_map[key] = data;
@ -79,4 +79,4 @@ bool EventManager::SendEvent(u64 key, u64 source, u64 d1, u64 d2, u64 d3)
eq->events.push(source, d1, d2, d3);
return true;
}
}

View File

@ -1,6 +1,5 @@
#include "stdafx.h"
#include "vfsLocalDir.h"
#include <direct.h>
vfsLocalDir::vfsLocalDir(vfsDevice* device) : vfsDirBase(device)
{
@ -50,4 +49,4 @@ bool vfsLocalDir::Rename(const wxString& from, const wxString& to)
bool vfsLocalDir::Remove(const wxString& path)
{
return wxRmdir(path);
}
}

View File

@ -2,6 +2,7 @@
#include "GLGSRender.h"
#include "Emu/Cell/PPCInstrTable.h"
#include "Gui/RSXDebugger.h"
#include "OpenGL.h"
#define CMD_DEBUG 0
#define DUMP_VERTEX_DATA 0
@ -650,10 +651,10 @@ void GLGSRender::OnInitThread()
#ifdef _WIN32
glSwapInterval(Ini.GSVSyncEnable.GetValue() ? 1 : 0);
#else
if (GLXDrawable drawable = glXGetCurrentDrawable())
glXSwapIntervalEXT(glXGetCurrentDisplay(), drawable, Ini.GSVSyncEnable.GetValue() ? 1 : 0);
if (GLXDrawable drawable = glXGetCurrentDrawable()){
glXSwapIntervalEXT(glXGetCurrentDisplay(), drawable, Ini.GSVSyncEnable.GetValue() ? 1 : 0);
}
#endif
glGenTextures(1, &g_depth_tex);
glGenTextures(1, &g_flip_tex);
}

View File

@ -4,7 +4,7 @@
#include "GL/GLGSRender.h"
BEGIN_EVENT_TABLE(GSFrame, wxFrame)
EVT_PAINT(GSFrame::OnPaint)
EVT_PAINT(GSFrame::OnPaint)
EVT_SIZE(GSFrame::OnSize)
END_EVENT_TABLE()
@ -45,4 +45,4 @@ u8 GSManager::GetState()
u8 GSManager::GetColorSpace()
{
return CELL_VIDEO_OUT_COLOR_SPACE_RGB;
}
}

View File

@ -78,4 +78,4 @@ void GSFrame::SetSize(int width, int height)
GSLockCurrent::GSLockCurrent(GSLockType type) : GSLock(Emu.GetGSManager().GetRender(), type)
{
}
}

View File

@ -75,7 +75,7 @@ enum CellVideoOutPortType
enum CellVideoOutDisplayAspect
{
CELL_VIDEO_OUT_ASPECT_AUTO,
CELL_VIDEO_OUT_ASPECT_AUTO,
CELL_VIDEO_OUT_ASPECT_4_3,
CELL_VIDEO_OUT_ASPECT_16_9,
};

View File

@ -482,7 +482,7 @@ public:
int OpenDir(const wxString& name)
{
ConLog.Warning("OpenDir(%s)", name.mb_str());
ConLog.Warning("OpenDir(%s)", name.wx_str());
u64 entry_block;
if(!SearchEntry(name, entry_block))
return -1;
@ -769,7 +769,7 @@ public:
if(entry.type == vfsHDD_Entry_Dir && name != "." && name != "..")
{
ConLog.Warning("removing sub folder '%s'", name.mb_str());
ConLog.Warning("removing sub folder '%s'", name.wx_str());
RemoveBlocksDir(entry.data_block);
}
else if(entry.type == vfsHDD_Entry_File)
@ -869,4 +869,4 @@ public:
{
return m_file.GetSize();
}
};
};

View File

@ -1,5 +1,6 @@
#pragma once
#include "MemoryBlock.h"
#include <vector>
enum MemoryType
{

View File

@ -557,36 +557,40 @@ struct CellAdecM4AacInfo
be_t<u32> pad1; // TODO: check alignment
union {
struct { struct
{
be_t<u32> copyrightIdPresent;
char copyrightId[9];
be_t<u32> originalCopy;
be_t<u32> home;
be_t<u32> bitstreamType;
be_t<u32> bitrate;
be_t<u32> numberOfProgramConfigElements;
be_t<u32> bufferFullness;
} adif; };
struct {
struct
{
be_t<u32> copyrightIdPresent;
char copyrightId[9];
be_t<u32> originalCopy;
be_t<u32> home;
be_t<u32> bitstreamType;
be_t<u32> bitrate;
be_t<u32> numberOfProgramConfigElements;
be_t<u32> bufferFullness;
} adif;
};
struct { struct
{
be_t<u32> id;
be_t<u32> layer;
be_t<u32> protectionAbsent;
be_t<u32> profile;
be_t<u32> samplingFreqIndex;
be_t<u32> privateBit;
be_t<u32> channelConfiguration;
be_t<u32> originalCopy;
be_t<u32> home;
be_t<u32> copyrightIdBit;
be_t<u32> copyrightIdStart;
be_t<u32> frameLength;
be_t<u32> bufferFullness;
be_t<u32> numberOfRawDataBlocks;
be_t<u32> crcCheck;
} adts; };
struct {
struct
{
be_t<u32> id;
be_t<u32> layer;
be_t<u32> protectionAbsent;
be_t<u32> profile;
be_t<u32> samplingFreqIndex;
be_t<u32> privateBit;
be_t<u32> channelConfiguration;
be_t<u32> originalCopy;
be_t<u32> home;
be_t<u32> copyrightIdBit;
be_t<u32> copyrightIdStart;
be_t<u32> frameLength;
be_t<u32> bufferFullness;
be_t<u32> numberOfRawDataBlocks;
be_t<u32> crcCheck;
} adts;
};
} bsi;
be_t<u32> pad2; // TODO: check alignment
@ -980,4 +984,4 @@ struct CellAdecMpmcInfo
be_t<u32> multiCodecMode;
be_t<u32> lfePresent;
be_t<u32> channelCoufiguration;
};
};

View File

@ -96,20 +96,7 @@ struct CellDmuxResource2
be_t<u32> memSize;
be_t<u32> ppuThreadPriority;
be_t<u32> ppuThreadStackSize;
union
{
struct
{
be_t<u32> noex_spuThreadPriority;
be_t<u32> noex_numOfSpus;
};
struct
{
be_t<u32> ex_spurs_addr;
u8 ex_priority[8];
be_t<u32> ex_maxContention;
};
};
be_t<u32> shit[4];
};
struct CellDmuxCb
@ -140,8 +127,8 @@ struct CellDmuxEsAttr
struct CellDmuxEsResource
{
be_t<u32> memAddr;
be_t<u32> memSize;
be_t<u32> memAddr;
be_t<u32> memSize;
};
struct CellDmuxAuInfo
@ -149,7 +136,7 @@ struct CellDmuxAuInfo
be_t<u32> auAddr;
be_t<u32> auSize;
be_t<u32> auMaxSize;
be_t<u64> userData;
be_t<u64> userData;
be_t<u32> ptsUpper;
be_t<u32> ptsLower;
be_t<u32> dtsUpper;
@ -165,4 +152,4 @@ struct CellDmuxAuInfoEx
be_t<u64> userData;
CellCodecTimeStamp pts;
CellCodecTimeStamp dts;
};
};

View File

@ -292,7 +292,7 @@ int cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, u32 dirName_addr)
}
std::string errorMsg = wxString::Format("%s\nSpace needed: %d KB\nDirectory name: %s",
wxString(errorName).wx_str(), errNeedSizeKB, wxString(dirName).wx_str());
wxString(errorName).wx_str(), errNeedSizeKB, wxString(dirName).wx_str()).ToStdString();
wxMessageBox(errorMsg, wxGetApp().GetAppName(), wxICON_ERROR | wxOK);
return CELL_OK;
}

View File

@ -728,9 +728,9 @@ int cellRescSetBufferAddress(mem32_t colorBuffers, mem32_t vertexArray, mem32_t
if(!colorBuffers.IsGood() || !vertexArray.IsGood() || !fragmentShader.IsGood())
return CELL_RESC_ERROR_BAD_ARGUMENT;
if(colorBuffers.GetAddr() % COLOR_BUFFER_ALIGNMENT ||
vertexArray.GetAddr() % VERTEX_BUFFER_ALIGNMENT ||
fragmentShader.GetAddr() % FRAGMENT_SHADER_ALIGNMENT)
return CELL_RESC_ERROR_BAD_ALIGNMENT;
vertexArray.GetAddr() % VERTEX_BUFFER_ALIGNMENT ||
fragmentShader.GetAddr() % FRAGMENT_SHADER_ALIGNMENT)
return CELL_RESC_ERROR_BAD_ALIGNMENT;
s_rescInternalInstance->m_colorBuffersEA_addr = colorBuffers.GetAddr();
s_rescInternalInstance->m_vertexArrayEA_addr = vertexArray.GetAddr();
@ -813,4 +813,4 @@ void cellResc_init()
void cellResc_unload()
{
s_rescInternalInstance->m_bInitialized = false;
}
}

View File

@ -25,13 +25,11 @@ enum
#pragma pack(push, 1)
struct CellSyncMutex {
union {
struct {
be_t<u16> m_freed;
be_t<u16> m_order;
be_t<u16> m_freed;
be_t<u16> m_order;
volatile u32& m_data(){
return *reinterpret_cast<u32*>(this);
};
volatile u32 m_data;
};
/*
(???) Initialize: set zeros
(???) Lock: increase m_order and wait until m_freed == old m_order
@ -61,7 +59,7 @@ int cellSyncMutexInitialize(mem_ptr_t<CellSyncMutex> mutex)
{
reservation.clear();
}
mutex->m_data = 0;
mutex->m_data() = 0;
return CELL_OK;
}
}
@ -167,4 +165,4 @@ void cellSync_init()
cellSync.AddFunc(0x1bb675c2, cellSyncMutexLock);
cellSync.AddFunc(0xd06918c4, cellSyncMutexTryLock);
cellSync.AddFunc(0x91f2b7b0, cellSyncMutexUnlock);
}
}

View File

@ -1010,4 +1010,4 @@ void cellSysutil_init()
cellSysutil.AddFunc(0x1e7bff94, cellSysCacheMount);
cellSysutil.AddFunc(0x744c1544, cellSysCacheClear);
}
}

View File

@ -1,12 +1,16 @@
#if 0
#include "stdafx.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/SysCalls/SC_FUNC.h"
#include "sceNp.h"
void sceNp_init();
void sceNpTrophy_init();
Module sceNp(0x0016, sceNpTrophy_init);
void sceNpTrophy_init()
{
}
#endif

View File

@ -129,8 +129,8 @@ int cellFsSdataOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size)
return CELL_OK;
}
std::atomic<u32> g_FsAioReadID = 0;
std::atomic<u32> g_FsAioReadCur = 0;
std::atomic<u32> g_FsAioReadID( 0 );
std::atomic<u32> g_FsAioReadCur( 0 );
bool aio_init = false;
void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, int xid, mem_func_ptr_t<void (*)(mem_ptr_t<CellFsAio> xaio, int error, int xid, u64 size)> func)

View File

@ -1,4 +1,5 @@
#pragma once
#include "Modules.h"
#define RESULT(x) SC_ARGS_1 = (x)

View File

@ -3,6 +3,13 @@
#include "Modules.h"
#include "SC_FUNC.h"
namespace detail{
template<> bool CheckId(u32 id, ID*& _id,const std::string &name)
{
return Emu.GetIdManager().CheckID(id) && (_id = &Emu.GetIdManager().GetID(id))->m_name == name;
}
}
void default_syscall();
static func_caller *null_func = bind_func(default_syscall);
@ -358,4 +365,4 @@ void SysCalls::DoSyscall(u32 code)
//TODO: remove this
declCPU();
RESULT(DoFunc(code));
}
}

View File

@ -14,6 +14,20 @@
#define declCPU PPUThread& CPU = GetCurrentPPUThread
class SysCallBase;
namespace detail{
template<typename T> bool CheckId(u32 id, T*& data,const std::string &name)
{
ID* id_data;
if(!CheckId(id, id_data,name)) return false;
data = id_data->m_data->get<T>();
return true;
}
template<> bool CheckId<ID>(u32 id, ID*& _id,const std::string &name);
}
class SysCallBase //Module
{
private:
@ -94,18 +108,7 @@ public:
template<typename T> bool CheckId(u32 id, T*& data)
{
ID* id_data;
if(!CheckId(id, id_data)) return false;
data = id_data->m_data->get<T>();
return true;
}
template<> bool CheckId(u32 id, ID*& _id)
{
return Emu.GetIdManager().CheckID(id) && (_id = &Emu.GetIdManager().GetID(id))->m_name == GetName();
return detail::CheckId(id,data,GetName());
}
template<typename T>

View File

@ -386,4 +386,4 @@ int sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3)
}
return CELL_OK;
}
}

View File

@ -86,11 +86,11 @@ int sys_lwcond_signal(mem_ptr_t<sys_lwcond_t> lwcond)
if (be_t<u32> target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop()))
{
if (mutex->owner.trylock(target) != SMR_OK)
if (mutex->mutex.owner.trylock(target) != SMR_OK)
{
mutex->owner.lock(tid);
mutex->mutex.owner.lock(tid);
mutex->recursive_count = 1;
mutex->owner.unlock(tid, target);
mutex->mutex.owner.unlock(tid, target);
}
}
@ -122,11 +122,11 @@ int sys_lwcond_signal_all(mem_ptr_t<sys_lwcond_t> lwcond)
while (be_t<u32> target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop()))
{
if (mutex->owner.trylock(target) != SMR_OK)
if (mutex->mutex.owner.trylock(target) != SMR_OK)
{
mutex->owner.lock(tid);
mutex->mutex.owner.lock(tid);
mutex->recursive_count = 1;
mutex->owner.unlock(tid, target);
mutex->mutex.owner.unlock(tid, target);
}
}
@ -163,11 +163,11 @@ int sys_lwcond_signal_to(mem_ptr_t<sys_lwcond_t> lwcond, u32 ppu_thread_id)
be_t<u32> target = ppu_thread_id;
if (mutex->owner.trylock(target) != SMR_OK)
if (mutex->mutex.owner.trylock(target) != SMR_OK)
{
mutex->owner.lock(tid);
mutex->mutex.owner.lock(tid);
mutex->recursive_count = 1;
mutex->owner.unlock(tid, target);
mutex->mutex.owner.unlock(tid, target);
}
if (Emu.IsStopped())
@ -197,7 +197,7 @@ int sys_lwcond_wait(mem_ptr_t<sys_lwcond_t> lwcond, u64 timeout)
u32 tid_le = GetCurrentPPUThread().GetId();
be_t<u32> tid = tid_le;
if (mutex->owner.GetOwner() != tid)
if (mutex->mutex.owner.GetOwner() != tid)
{
return CELL_EPERM; // caller must own this lwmutex
}
@ -205,7 +205,7 @@ int sys_lwcond_wait(mem_ptr_t<sys_lwcond_t> lwcond, u64 timeout)
sq->push(tid_le);
mutex->recursive_count = 0;
mutex->owner.unlock(tid);
mutex->mutex.owner.unlock(tid);
u32 counter = 0;
const u32 max_counter = timeout ? (timeout / 1000) : ~0;
@ -216,7 +216,7 @@ int sys_lwcond_wait(mem_ptr_t<sys_lwcond_t> lwcond, u64 timeout)
case SMR_OK: mutex->unlock(tid); break;
case SMR_SIGNAL: return CELL_OK;
} */
if (mutex->owner.GetOwner() == tid)
if (mutex->mutex.owner.GetOwner() == tid)
{
_mm_mfence();
mutex->recursive_count = 1;

View File

@ -28,8 +28,9 @@ int sys_lwmutex_create(mem_ptr_t<sys_lwmutex_t> lwmutex, mem_ptr_t<sys_lwmutex_a
}
lwmutex->attribute = attr->attr_protocol | attr->attr_recursive;
lwmutex->all_info = 0;
lwmutex->owner.initialize();
lwmutex->mutex.all_info() = 0;
lwmutex->mutex.all_info() = 0;
lwmutex->mutex.owner.initialize();
//lwmutex->waiter = lwmutex->owner.GetOwner();
lwmutex->pad = 0;
lwmutex->recursive_count = 0;
@ -53,10 +54,10 @@ int sys_lwmutex_destroy(mem_ptr_t<sys_lwmutex_t> lwmutex)
if (!Emu.GetIdManager().CheckID(sq_id)) return CELL_ESRCH;
// try to make it unable to lock
switch (int res = lwmutex->trylock(lwmutex->owner.GetDeadValue()))
switch (int res = lwmutex->trylock(lwmutex->mutex.owner.GetDeadValue()))
{
case CELL_OK:
lwmutex->all_info = 0;
lwmutex->mutex.all_info() = 0;
lwmutex->attribute = 0;
lwmutex->sleep_queue = 0;
Emu.GetIdManager().RemoveID(sq_id);
@ -71,7 +72,7 @@ int sys_lwmutex_lock(mem_ptr_t<sys_lwmutex_t> lwmutex, u64 timeout)
if (!lwmutex.IsGood()) return CELL_EFAULT;
//ConLog.Write("*** lock mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)",
//lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, lwmutex->owner.GetOwner(), (u32)lwmutex->waiter);
//lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter);
return lwmutex->lock(GetCurrentPPUThread().GetId(), timeout ? ((timeout < 1000) ? 1 : (timeout / 1000)) : 0);
}
@ -92,7 +93,7 @@ int sys_lwmutex_unlock(mem_ptr_t<sys_lwmutex_t> lwmutex)
if (!lwmutex.IsGood()) return CELL_EFAULT;
//ConLog.Write("*** unlocking mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)",
//lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, (u32)lwmutex->owner.GetOwner(), (u32)lwmutex->waiter);
//lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, (u32)lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter);
return lwmutex->unlock(GetCurrentPPUThread().GetId());
}
@ -207,7 +208,7 @@ int sys_lwmutex_t::trylock(be_t<u32> tid)
{
if (!attribute.ToBE()) return CELL_EINVAL;
if (tid == owner.GetOwner())
if (tid == mutex.owner.GetOwner())
{
if (attribute.ToBE() & se32(SYS_SYNC_RECURSIVE))
{
@ -221,7 +222,7 @@ int sys_lwmutex_t::trylock(be_t<u32> tid)
}
}
switch (owner.trylock(tid))
switch (mutex.owner.trylock(tid))
{
case SMR_OK: recursive_count = 1; return CELL_OK;
case SMR_FAILED: return CELL_EBUSY;
@ -231,7 +232,7 @@ int sys_lwmutex_t::trylock(be_t<u32> tid)
int sys_lwmutex_t::unlock(be_t<u32> tid)
{
if (tid != owner.GetOwner())
if (tid != mutex.owner.GetOwner())
{
return CELL_EPERM;
}
@ -250,8 +251,8 @@ int sys_lwmutex_t::unlock(be_t<u32> tid)
target = attribute.ToBE() & se32(SYS_SYNC_FIFO) ? sq->pop() : sq->pop_prio();
case se32(SYS_SYNC_RETRY): break;
}
if (target) owner.unlock(tid, target);
else owner.unlock(tid);
if (target) mutex.owner.unlock(tid, target);
else mutex.owner.unlock(tid);
}
return CELL_OK;
}
@ -276,7 +277,7 @@ int sys_lwmutex_t::lock(be_t<u32> tid, u64 timeout)
default: break;
}
switch (owner.lock(tid, timeout))
switch (mutex.owner.lock(tid, timeout))
{
case SMR_OK:
sq->invalidate(tid);
@ -289,4 +290,4 @@ int sys_lwmutex_t::lock(be_t<u32> tid, u64 timeout)
default:
sq->invalidate(tid); return CELL_EINVAL;
}
}
}

View File

@ -65,18 +65,13 @@ struct SleepQueue
struct sys_lwmutex_t
{
union // sys_lwmutex_variable_t
struct sys_lwmutex_lock_info_t
{
struct // sys_lwmutex_lock_info_t
{
/* volatile */ SMutexBase<be_t<u32>, 0xffffffff, 0> owner;
/* volatile */ be_t<u32> waiter; // not used
};
struct
{
/* volatile */ be_t<u64> all_info;
};
};
/* volatile */ SMutexBase<be_t<u32>, 0xffffffff, 0> owner;
/* volatile */ be_t<u32> waiter; // not used
u64 &all_info(){return *(reinterpret_cast<u64*>(this));
}
}mutex;
be_t<u32> attribute;
be_t<u32> recursive_count;
be_t<u32> sleep_queue;
@ -85,4 +80,4 @@ struct sys_lwmutex_t
int trylock(be_t<u32> tid);
int unlock(be_t<u32> tid);
int lock(be_t<u32> tid, u64 timeout);
};
};

View File

@ -1,3 +1,4 @@
#if 0
#include "stdafx.h"
#include "Emu/SysCalls/SysCalls.h"
@ -19,3 +20,4 @@ int sys_raw_spu_create(u32 id_addr, u32 attr_addr)
Memory.Write32(id_addr, Emu.GetIdManager().GetNewID("raw_spu"));
return CELL_OK;
}
#endif

View File

@ -28,6 +28,7 @@ Emulator::Emulator()
, m_dbg_console(nullptr)
, m_rsx_callback(0)
, m_ppu_callback_thr(0)
, m_event_manager(new EventManager())
{
}
@ -190,8 +191,8 @@ void Emulator::Load()
if(IsSelf(m_path.ToStdString()))
{
std::string self_path = m_path.mb_str();
std::string elf_path = wxFileName(m_path).GetPath().c_str();
std::string self_path = m_path.ToStdString();
std::string elf_path = wxFileName(m_path).GetPath().ToStdString();
if(wxFileName(m_path).GetFullName().CmpNoCase("EBOOT.BIN") == 0)
{
@ -216,7 +217,7 @@ void Emulator::Load()
ConLog.Write("Mount info:");
for(uint i=0; i<m_vfs.m_devices.GetCount(); ++i)
{
ConLog.Write("%s -> %s", m_vfs.m_devices[i].GetPs3Path().wx_str(), m_vfs.m_devices[i].GetLocalPath().wx_str());
ConLog.Write("%s -> %s", static_cast<const char *>(m_vfs.m_devices[i].GetPs3Path()), static_cast<const char *>(m_vfs.m_devices[i].GetLocalPath().ToAscii()));
}
ConLog.SkipLn();

View File

@ -12,8 +12,9 @@
#include "Emu/DbgConsole.h"
#include "Loader/Loader.h"
#include "SysCalls/Callback.h"
#include "SysCalls/Modules.h"
#include "event.h"
class EventManager;
extern void UnloadModules();
struct EmuInfo
{
@ -90,7 +91,7 @@ class Emulator
AudioManager m_audio_manager;
CallbackManager m_callback_manager;
CPUThread* m_ppu_callback_thr;
EventManager m_event_manager;
std::unique_ptr<EventManager> m_event_manager;
VFS m_vfs;
@ -120,7 +121,7 @@ public:
Array<u64>& GetBreakPoints() { return m_break_points; }
Array<u64>& GetMarkedPoints() { return m_marked_points; }
CPUThread& GetCallbackThread() { return *m_ppu_callback_thr; }
EventManager& GetEventManager() { return m_event_manager; }
EventManager& GetEventManager() { return *m_event_manager; }
void AddModuleInit(ModuleInitializer* m)
{
@ -164,4 +165,4 @@ public:
__forceinline bool IsReady() const { return m_status == Ready; }
};
extern Emulator Emu;
extern Emulator Emu;

View File

@ -167,7 +167,7 @@ void InterpreterDisAsmFrame::OnKeyDown(wxKeyEvent& event)
{
if(event.GetKeyCode() == WXK_SPACE)
{
wxCommandEvent ce;
wxCommandEvent ce;
DoStep(ce);
return;
}
@ -222,7 +222,7 @@ void InterpreterDisAsmFrame::OnResize(wxSizeEvent& event)
void InterpreterDisAsmFrame::DoUpdate()
{
wxCommandEvent ce;
wxCommandEvent ce;
Show_PC(ce);
WriteRegs();
WriteCallStack();

View File

@ -228,7 +228,7 @@ void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event))
Emu.Stop();
// Open and install PKG file
std::string filePath = ctrl.GetPath();
std::string filePath = ctrl.GetPath().ToStdString();
wxFile pkg_f(filePath, wxFile::read); // TODO: Use VFS to install PKG files
if (pkg_f.IsOpened())

View File

@ -25,7 +25,7 @@ MemoryViewerPanel::MemoryViewerPanel(wxWindow* parent)
wxStaticBoxSizer& s_tools_mem_bytes = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Bytes");
sc_bytes = new wxSpinCtrl(this, wxID_ANY, "16", wxDefaultPosition, wxSize(44,-1));
sc_bytes->SetRange(1, 16);
sc_bytes->SetRange(1, 16);
s_tools_mem_bytes.Add(sc_bytes);
wxStaticBoxSizer& s_tools_mem_buttons = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Control");
@ -52,7 +52,7 @@ MemoryViewerPanel::MemoryViewerPanel(wxWindow* parent)
s_tools_img_size.Add(new wxStaticText(this, wxID_ANY, " x "));
s_tools_img_size.Add(sc_img_size_y);
sc_img_size_x->SetRange(1, 8192);
sc_img_size_x->SetRange(1, 8192);
sc_img_size_y->SetRange(1, 8192);
wxStaticBoxSizer& s_tools_img_mode = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Mode");

View File

@ -58,7 +58,7 @@ VFSEntrySettingsDialog::VFSEntrySettingsDialog(wxWindow* parent, VFSManagerEntry
m_tctrl_mount->SetValue(m_entry.mount);
m_ch_type->SetSelection(m_entry.device);
wxCommandEvent ce;
wxCommandEvent ce;
OnSelectType(ce);
}

View File

@ -347,10 +347,10 @@ VHDDSetInfoDialog::VHDDSetInfoDialog(wxWindow* parent) : wxDialog(parent, wxID_A
m_ch_type->Append("MB");
m_ch_type->Append("GB");
m_spin_size->SetRange(1, 0x7fffffff);
m_spin_size->SetRange(1, 0x7fffffff);
m_spin_size->SetValue(64);
m_ch_type->SetSelection(3);
m_spin_block_size->SetRange(64, 0x7fffffff);
m_spin_block_size->SetRange(64, 0x7fffffff);
m_spin_block_size->SetValue(2048);
Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VHDDSetInfoDialog::OnOk));
}

View File

@ -155,7 +155,7 @@ Ini::Ini()
wxGetCwd() + "\\rpcs3.ini",
wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
#else
m_Config = new wxConfig("rpcs3");
m_Config = new wxConfig("rpcs3");
#endif
}

View File

@ -23,7 +23,7 @@ bool PKGLoader::Install(std::string dest, bool show)
return false;
std::string titleID = std::string(m_header.title_id).substr(7, 9);
std::string decryptedFile = wxGetCwd() + "/dev_hdd1/" + titleID + ".dec";
std::string decryptedFile = wxGetCwd().ToStdString() + "/dev_hdd1/" + titleID + ".dec";
if (wxDirExists(dest+titleID)) {
wxMessageDialog d_overwrite(NULL, "Another installation was found. Do you want to overwrite it?", "PKG Decrypter / Installer", wxYES_NO|wxCENTRE);

View File

@ -1,5 +1,4 @@
#pragma once
#include "Gui/MainFrame.h"
template<typename T> T min(const T a, const T b) { return a < b ? a : b; }
@ -66,4 +65,4 @@ DECLARE_APP(Rpcs3App)
//extern CPUThread& GetCPU(const u8 core);
extern Rpcs3App* TheApp;
static const u64 PS3_CLK = 3200000000;
static const u64 PS3_CLK = 3200000000;

View File

@ -3,19 +3,33 @@
#define NOMINMAX
#ifndef QT_UI
#ifdef _WIN32
#include <wx/msw/setup.h>
#include <wx/wx.h>
#endif
#include <wx/config.h>
#include <wx/string.h>
#include <wx/propdlg.h>
#include <wx/stdpaths.h>
#include <wx/filename.h>
#include <wx/filefn.h>
#include <wx/dcclient.h>
#include <wx/wfstream.h>
#include <wx/dir.h>
#include <wx/spinctrl.h>
#include <wx/datetime.h>
#include <wx/filepicker.h>
#include <wx/menu.h>
#include <wx/menuitem.h>
#include <wx/stattext.h>
#include <wx/msgdlg.h>
#include "wx/gauge.h"
#include <wx/stattext.h>
#include "wx/scrolbar.h"
#include "wx/frame.h"
#include <wx/combobox.h>
#include <wx/checkbox.h>
#include "wx/app.h"
#include <wx/wxprec.h>
#endif
@ -199,12 +213,15 @@ enum Status
#include "AppConnector.h"
#include "Emu/SysCalls/Callback.h"
#include "Ini.h"
#include "Gui/FrameBase.h"
#include "Gui/ConLog.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/vfsDirBase.h"
#include "Emu/FS/vfsFileBase.h"