1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Another try

This commit is contained in:
Nekotekina 2014-08-22 20:36:27 +04:00
parent a8b5912340
commit 652c5901f8
12 changed files with 221 additions and 208 deletions

View File

@ -6,7 +6,12 @@
#include "Utilities/SMutex.h"
__forceinline void SM_Sleep()
bool SM_IsAborted()
{
return Emu.IsStopped();
}
void SM_Sleep()
{
if (NamedThreadBase* t = GetCurrentNamedThread())
{
@ -20,12 +25,12 @@ __forceinline void SM_Sleep()
thread_local size_t g_this_thread_id = 0;
__forceinline size_t SM_GetCurrentThreadId()
size_t SM_GetCurrentThreadId()
{
return g_this_thread_id ? g_this_thread_id : g_this_thread_id = std::hash<std::thread::id>()(std::this_thread::get_id());
}
__forceinline u32 SM_GetCurrentCPUThreadId()
u32 SM_GetCurrentCPUThreadId()
{
if (CPUThread* t = GetCurrentCPUThread())
{
@ -34,7 +39,7 @@ __forceinline u32 SM_GetCurrentCPUThreadId()
return 0;
}
__forceinline be_t<u32> SM_GetCurrentCPUThreadIdBE()
be_t<u32> SM_GetCurrentCPUThreadIdBE()
{
return be_t<u32>::MakeFromLE(SM_GetCurrentCPUThreadId());
}

View File

@ -1,11 +1,10 @@
#pragma once
#include "BEType.h"
#include "Emu/System.h"
extern void SM_Sleep();
extern size_t SM_GetCurrentThreadId();
extern u32 SM_GetCurrentCPUThreadId();
extern be_t<u32> SM_GetCurrentCPUThreadIdBE();
bool SM_IsAborted();
void SM_Sleep();
size_t SM_GetCurrentThreadId();
u32 SM_GetCurrentCPUThreadId();
be_t<u32> SM_GetCurrentCPUThreadIdBE();
enum SMutexResult
{
@ -66,7 +65,7 @@ public:
SMutexResult trylock(T tid)
{
if (Emu.IsStopped())
if (SM_IsAborted())
{
return SMR_ABORT;
}
@ -90,7 +89,7 @@ public:
SMutexResult unlock(T tid, T to = GetFreeValue())
{
if (Emu.IsStopped())
if (SM_IsAborted())
{
return SMR_ABORT;
}
@ -148,7 +147,7 @@ public:
{
if (!tid)
{
if (!Emu.IsStopped())
if (!SM_IsAborted())
{
assert(!"SMutexLockerBase: thread id == 0");
}

View File

@ -36,6 +36,10 @@ CPUThread::~CPUThread()
safe_delete(m_dec);
}
bool CPUThread::IsRunning() const { return m_status == Running; }
bool CPUThread::IsPaused() const { return m_status == Paused; }
bool CPUThread::IsStopped() const { return m_status == Stopped; }
void CPUThread::Close()
{
ThreadBase::Stop(m_sync_wait);

View File

@ -1,7 +1,5 @@
#pragma once
#include "Emu/Memory/MemoryBlock.h"
#include "Emu/CPU/CPUDecoder.h"
#include "Utilities/SMutex.h"
enum CPUThreadType :unsigned char
{
@ -147,13 +145,13 @@ public:
static std::vector<std::string> ErrorToString(const u32 error);
std::vector<std::string> ErrorToString() { return ErrorToString(m_error); }
bool IsOk() const { return m_error == 0; }
bool IsRunning() const { return m_status == Running; }
bool IsPaused() const { return m_status == Paused; }
bool IsStopped() const { return m_status == Stopped; }
bool IsOk() const { return m_error == 0; }
bool IsRunning() const;
bool IsPaused() const;
bool IsStopped() const;
bool IsJoinable() const { return m_joinable; }
bool IsJoining() const { return m_joining; }
bool IsJoining() const { return m_joining; }
void SetJoinable(bool joinable) { m_joinable = joinable; }
void SetJoining(bool joining) { m_joining = joining; }

View File

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "PPCThread.h"
#include "Emu/Memory/Memory.h"
PPCThread* GetCurrentPPCThread()
{

View File

@ -2,193 +2,9 @@
#define PAGE_4K(x) (x + 4095) & ~(4095)
union u128
{
struct
{
u64 hi;
u64 lo;
};
u64 _u64[2];
u32 _u32[4];
u16 _u16[8];
u8 _u8[16];
operator u64() const { return _u64[0]; }
operator u32() const { return _u32[0]; }
operator u16() const { return _u16[0]; }
operator u8() const { return _u8[0]; }
operator bool() const { return _u64[0] != 0 || _u64[1] != 0; }
static u128 From128( u64 hi, u64 lo )
{
u128 ret = {hi, lo};
return ret;
}
static u128 From64( u64 src )
{
u128 ret = {0, src};
return ret;
}
static u128 From32( u32 src )
{
u128 ret;
ret._u32[0] = src;
ret._u32[1] = 0;
ret._u32[2] = 0;
ret._u32[3] = 0;
return ret;
}
static u128 FromBit ( u32 bit )
{
u128 ret;
if (bit < 64)
{
ret.hi = 0;
ret.lo = (u64)1 << bit;
}
else if (bit < 128)
{
ret.hi = (u64)1 << (bit - 64);
ret.lo = 0;
}
else
{
ret.hi = 0;
ret.lo = 0;
}
return ret;
}
bool operator == ( const u128& right ) const
{
return (lo == right.lo) && (hi == right.hi);
}
bool operator != ( const u128& right ) const
{
return (lo != right.lo) || (hi != right.hi);
}
u128 operator | ( const u128& right ) const
{
return From128(hi | right.hi, lo | right.lo);
}
u128 operator & ( const u128& right ) const
{
return From128(hi & right.hi, lo & right.lo);
}
u128 operator ^ ( const u128& right ) const
{
return From128(hi ^ right.hi, lo ^ right.lo);
}
u128 operator ~ () const
{
return From128(~hi, ~lo);
}
};
union s128
{
struct
{
s64 hi;
s64 lo;
};
u64 _i64[2];
u32 _i32[4];
u16 _i16[8];
u8 _i8[16];
operator s64() const { return _i64[0]; }
operator s32() const { return _i32[0]; }
operator s16() const { return _i16[0]; }
operator s8() const { return _i8[0]; }
operator bool() const { return _i64[0] != 0 || _i64[1] != 0; }
static s128 From64( s64 src )
{
s128 ret = {src, 0};
return ret;
}
static s128 From32( s32 src )
{
s128 ret;
ret._i32[0] = src;
ret._i32[1] = 0;
ret.hi = 0;
return ret;
}
bool operator == ( const s128& right ) const
{
return (lo == right.lo) && (hi == right.hi);
}
bool operator != ( const s128& right ) const
{
return (lo != right.lo) || (hi != right.hi);
}
};
#include <memory>
#include <emmintrin.h>
//TODO: SSE style
/*
struct u128
{
__m128 m_val;
u128 GetValue128()
{
u128 ret;
_mm_store_ps( (float*)&ret, m_val );
return ret;
}
u64 GetValue64()
{
u64 ret;
_mm_store_ps( (float*)&ret, m_val );
return ret;
}
u32 GetValue32()
{
u32 ret;
_mm_store_ps( (float*)&ret, m_val );
return ret;
}
u16 GetValue16()
{
u16 ret;
_mm_store_ps( (float*)&ret, m_val );
return ret;
}
u8 GetValue8()
{
u8 ret;
_mm_store_ps( (float*)&ret, m_val );
return ret;
}
};
*/
struct MemInfo
{
u64 addr;

View File

@ -16,6 +16,8 @@
//Module sysPrxForUser("sysPrxForUser", sysPrxForUser_init);
Module *sysPrxForUser = nullptr;
extern u32 LoadSpuImage(vfsStream& stream, u32& spu_ep);
int _sys_heap_create_heap(const u32 heap_addr, const u32 align, const u32 size)
{
sysPrxForUser->Warning("_sys_heap_create_heap(heap_addr=0x%x, align=0x%x, size=0x%x)", heap_addr, align, size);

View File

@ -939,3 +939,8 @@ void SysCalls::DoSyscall(u32 code)
declCPU();
RESULT(0);
}
IdManager& SysCallBase::GetIdManager() const
{
return Emu.GetIdManager();
}

View File

@ -54,6 +54,7 @@ class SysCallBase : public LogBase
private:
std::string m_module_name;
//u32 m_id;
IdManager& GetIdManager() const;
public:
SysCallBase(const std::string& name/*, u32 id*/)
@ -69,7 +70,7 @@ public:
bool CheckId(u32 id) const
{
return Emu.GetIdManager().CheckID(id) && Emu.GetIdManager().GetID(id).m_name == GetName();
return GetIdManager().CheckID(id) && GetIdManager().GetID(id).m_name == GetName();
}
template<typename T> bool CheckId(u32 id, T*& data)
@ -80,7 +81,7 @@ public:
template<typename T>
u32 GetNewId(T* data, IDType type = TYPE_OTHER)
{
return Emu.GetIdManager().GetNewID<T>(GetName(), data, type);
return GetIdManager().GetNewID<T>(GetName(), data, type);
}
};

View File

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "sys_rwlock.h"

View File

@ -1,7 +1,5 @@
#pragma once
u32 LoadSpuImage(vfsStream& stream, u32& spu_ep);
enum
{
SYS_SPU_THREAD_GROUP_TYPE_NORMAL = 0x00,

View File

@ -55,6 +55,189 @@ typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
union u128
{
struct
{
u64 hi;
u64 lo;
};
u64 _u64[2];
u32 _u32[4];
u16 _u16[8];
u8 _u8[16];
operator u64() const { return _u64[0]; }
operator u32() const { return _u32[0]; }
operator u16() const { return _u16[0]; }
operator u8() const { return _u8[0]; }
operator bool() const { return _u64[0] != 0 || _u64[1] != 0; }
static u128 From128(u64 hi, u64 lo)
{
u128 ret = { hi, lo };
return ret;
}
static u128 From64(u64 src)
{
u128 ret = { 0, src };
return ret;
}
static u128 From32(u32 src)
{
u128 ret;
ret._u32[0] = src;
ret._u32[1] = 0;
ret._u32[2] = 0;
ret._u32[3] = 0;
return ret;
}
static u128 FromBit(u32 bit)
{
u128 ret;
if (bit < 64)
{
ret.hi = 0;
ret.lo = (u64)1 << bit;
}
else if (bit < 128)
{
ret.hi = (u64)1 << (bit - 64);
ret.lo = 0;
}
else
{
ret.hi = 0;
ret.lo = 0;
}
return ret;
}
bool operator == (const u128& right) const
{
return (lo == right.lo) && (hi == right.hi);
}
bool operator != (const u128& right) const
{
return (lo != right.lo) || (hi != right.hi);
}
u128 operator | (const u128& right) const
{
return From128(hi | right.hi, lo | right.lo);
}
u128 operator & (const u128& right) const
{
return From128(hi & right.hi, lo & right.lo);
}
u128 operator ^ (const u128& right) const
{
return From128(hi ^ right.hi, lo ^ right.lo);
}
u128 operator ~ () const
{
return From128(~hi, ~lo);
}
};
union s128
{
struct
{
s64 hi;
s64 lo;
};
u64 _i64[2];
u32 _i32[4];
u16 _i16[8];
u8 _i8[16];
operator s64() const { return _i64[0]; }
operator s32() const { return _i32[0]; }
operator s16() const { return _i16[0]; }
operator s8() const { return _i8[0]; }
operator bool() const { return _i64[0] != 0 || _i64[1] != 0; }
static s128 From64(s64 src)
{
s128 ret = { src, 0 };
return ret;
}
static s128 From32(s32 src)
{
s128 ret;
ret._i32[0] = src;
ret._i32[1] = 0;
ret.hi = 0;
return ret;
}
bool operator == (const s128& right) const
{
return (lo == right.lo) && (hi == right.hi);
}
bool operator != (const s128& right) const
{
return (lo != right.lo) || (hi != right.hi);
}
};
//TODO: SSE style
/*
struct u128
{
__m128 m_val;
u128 GetValue128()
{
u128 ret;
_mm_store_ps( (float*)&ret, m_val );
return ret;
}
u64 GetValue64()
{
u64 ret;
_mm_store_ps( (float*)&ret, m_val );
return ret;
}
u32 GetValue32()
{
u32 ret;
_mm_store_ps( (float*)&ret, m_val );
return ret;
}
u16 GetValue16()
{
u16 ret;
_mm_store_ps( (float*)&ret, m_val );
return ret;
}
u8 GetValue8()
{
u8 ret;
_mm_store_ps( (float*)&ret, m_val );
return ret;
}
};
*/
#include "Utilities/StrFmt.h"
#include "Utilities/GNU.h"
#include "Utilities/BEType.h"