mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
commit
7e758970cf
91 changed files with 1919 additions and 1755 deletions
|
@ -6,26 +6,57 @@
|
|||
#define re128(val) u128::byteswap(val)
|
||||
|
||||
template<typename T, int size = sizeof(T)> struct se_t;
|
||||
template<typename T> struct se_t<T, 1> { static __forceinline void func(T& dst, const T src) { (u8&)dst = (u8&)src; } };
|
||||
template<typename T> struct se_t<T, 2> { static __forceinline void func(T& dst, const T src) { (u16&)dst = _byteswap_ushort((u16&)src); } };
|
||||
template<typename T> struct se_t<T, 4> { static __forceinline void func(T& dst, const T src) { (u32&)dst = _byteswap_ulong((u32&)src); } };
|
||||
template<typename T> struct se_t<T, 8> { static __forceinline void func(T& dst, const T src) { (u64&)dst = _byteswap_uint64((u64&)src); } };
|
||||
|
||||
template<typename T> T re(const T val) { T res; se_t<T>::func(res, val); return res; }
|
||||
template<typename T1, typename T2> void re(T1& dst, const T2 val) { se_t<T1>::func(dst, val); }
|
||||
template<typename T> struct se_t<T, 1>
|
||||
{
|
||||
static __forceinline T func(const T src)
|
||||
{
|
||||
return src;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, s64 _value, int size = sizeof(T)> struct const_se_t;
|
||||
template<typename T, s64 _value> struct const_se_t<T, _value, 1>
|
||||
template<typename T> struct se_t<T, 2>
|
||||
{
|
||||
static __forceinline T func(const T src)
|
||||
{
|
||||
const u16 res = _byteswap_ushort((u16&)src);
|
||||
return (T&)res;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> struct se_t<T, 4>
|
||||
{
|
||||
static __forceinline T func(const T src)
|
||||
{
|
||||
const u32 res = _byteswap_ulong((u32&)src);
|
||||
return (T&)res;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> struct se_t<T, 8>
|
||||
{
|
||||
static __forceinline T func(const T src)
|
||||
{
|
||||
const u64 res = _byteswap_uint64((u64&)src);
|
||||
return (T&)res;
|
||||
}
|
||||
};
|
||||
|
||||
//template<typename T> T re(const T val) { T res; se_t<T>::func(res, val); return res; }
|
||||
//template<typename T1, typename T2> void re(T1& dst, const T2 val) { se_t<T1>::func(dst, val); }
|
||||
|
||||
template<typename T, u64 _value, int size = sizeof(T)> struct const_se_t;
|
||||
template<typename T, u64 _value> struct const_se_t<T, _value, 1>
|
||||
{
|
||||
static const T value = (T)_value;
|
||||
};
|
||||
|
||||
template<typename T, s64 _value> struct const_se_t<T, _value, 2>
|
||||
template<typename T, u64 _value> struct const_se_t<T, _value, 2>
|
||||
{
|
||||
static const T value = ((_value >> 8) & 0xff) | ((_value << 8) & 0xff00);
|
||||
};
|
||||
|
||||
template<typename T, s64 _value> struct const_se_t<T, _value, 4>
|
||||
template<typename T, u64 _value> struct const_se_t<T, _value, 4>
|
||||
{
|
||||
static const T value =
|
||||
((_value >> 24) & 0x000000ff) |
|
||||
|
@ -34,7 +65,7 @@ template<typename T, s64 _value> struct const_se_t<T, _value, 4>
|
|||
((_value << 24) & 0xff000000);
|
||||
};
|
||||
|
||||
template<typename T, s64 _value> struct const_se_t<T, _value, 8>
|
||||
template<typename T, u64 _value> struct const_se_t<T, _value, 8>
|
||||
{
|
||||
static const T value =
|
||||
((_value >> 56) & 0x00000000000000ff) |
|
||||
|
@ -63,11 +94,7 @@ public:
|
|||
|
||||
T ToLE() const
|
||||
{
|
||||
T res;
|
||||
|
||||
se_t<T, sizeof(T2)>::func(res, m_data);
|
||||
|
||||
return res;
|
||||
return se_t<T, sizeof(T2)>::func(m_data);
|
||||
}
|
||||
|
||||
void FromBE(const T& value)
|
||||
|
@ -77,21 +104,18 @@ public:
|
|||
|
||||
void FromLE(const T& value)
|
||||
{
|
||||
se_t<T, sizeof(T2)>::func(m_data, value);
|
||||
m_data = se_t<T, sizeof(T2)>::func(value);
|
||||
}
|
||||
|
||||
static be_t MakeFromLE(const T value)
|
||||
{
|
||||
be_t res;
|
||||
res.FromLE(value);
|
||||
return res;
|
||||
T data = se_t<T, sizeof(T2)>::func(value);
|
||||
return (be_t&)data;
|
||||
}
|
||||
|
||||
static be_t MakeFromBE(const T value)
|
||||
{
|
||||
be_t res;
|
||||
res.FromBE(value);
|
||||
return res;
|
||||
return (be_t&)value;
|
||||
}
|
||||
|
||||
//template<typename T1>
|
||||
|
@ -103,30 +127,37 @@ public:
|
|||
template<typename T1>
|
||||
operator const be_t<T1>() const
|
||||
{
|
||||
be_t<T1> res;
|
||||
if (sizeof(T1) < sizeof(T))
|
||||
if (sizeof(T1) > sizeof(T) || std::is_floating_point<T>::value || std::is_floating_point<T1>::value)
|
||||
{
|
||||
res.FromBE(ToBE() >> ((sizeof(T)-sizeof(T1)) * 8));
|
||||
T1 res = se_t<T1, sizeof(T1)>::func(ToLE());
|
||||
return (be_t<T1>&)res;
|
||||
}
|
||||
else if (sizeof(T1) > sizeof(T))
|
||||
else if (sizeof(T1) < sizeof(T))
|
||||
{
|
||||
res.FromLE(ToLE());
|
||||
T1 res = ToBE() >> ((sizeof(T) - sizeof(T1)) * 8);
|
||||
return (be_t<T1>&)res;
|
||||
}
|
||||
else
|
||||
{
|
||||
res.FromBE(ToBE());
|
||||
T1 res = ToBE();
|
||||
return (be_t<T1>&)res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
be_t& operator = (const T& right)
|
||||
{
|
||||
FromLE(right);
|
||||
m_data = se_t<T, sizeof(T2)>::func(right);
|
||||
return *this;
|
||||
}
|
||||
|
||||
be_t& operator = (const be_t& right) = default;
|
||||
|
||||
be_t& operator = (const be_t<const T, const T2>& right)
|
||||
{
|
||||
m_data = right.ToBE();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T1> be_t& operator += (T1 right) { return *this = T(*this) + right; }
|
||||
template<typename T1> be_t& operator -= (T1 right) { return *this = T(*this) - right; }
|
||||
template<typename T1> be_t& operator *= (T1 right) { return *this = T(*this) * right; }
|
||||
|
@ -171,6 +202,81 @@ public:
|
|||
be_t& operator-- () { *this -= 1; return *this; }
|
||||
};
|
||||
|
||||
template<typename T, typename T2>
|
||||
class be_t<const T, T2>
|
||||
{
|
||||
static_assert(sizeof(T2) == 1 || sizeof(T2) == 2 || sizeof(T2) == 4 || sizeof(T2) == 8, "Bad be_t type");
|
||||
const T m_data;
|
||||
|
||||
public:
|
||||
typedef const T type;
|
||||
|
||||
const T& ToBE() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
const T ToLE() const
|
||||
{
|
||||
return se_t<const T, sizeof(T2)>::func(m_data);
|
||||
}
|
||||
|
||||
static be_t MakeFromLE(const T value)
|
||||
{
|
||||
const T data = se_t<const T, sizeof(T2)>::func(value);
|
||||
return (be_t&)data;
|
||||
}
|
||||
|
||||
static be_t MakeFromBE(const T value)
|
||||
{
|
||||
return (be_t&)value;
|
||||
}
|
||||
|
||||
//template<typename T1>
|
||||
operator const T() const
|
||||
{
|
||||
return ToLE();
|
||||
}
|
||||
|
||||
template<typename T1>
|
||||
operator const be_t<T1>() const
|
||||
{
|
||||
if (sizeof(T1) > sizeof(T) || std::is_floating_point<T>::value || std::is_floating_point<T1>::value)
|
||||
{
|
||||
T1 res = se_t<T1, sizeof(T1)>::func(ToLE());
|
||||
return (be_t<T1>&)res;
|
||||
}
|
||||
else if (sizeof(T1) < sizeof(T))
|
||||
{
|
||||
T1 res = ToBE() >> ((sizeof(T) - sizeof(T1)) * 8);
|
||||
return (be_t<T1>&)res;
|
||||
}
|
||||
else
|
||||
{
|
||||
T1 res = ToBE();
|
||||
return (be_t<T1>&)res;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T1> be_t operator & (const be_t<T1>& right) const { const T res; res = ToBE() & right.ToBE(); return (be_t&)res; }
|
||||
template<typename T1> be_t operator | (const be_t<T1>& right) const { const T res; res = ToBE() | right.ToBE(); return (be_t&)res; }
|
||||
template<typename T1> be_t operator ^ (const be_t<T1>& right) const { const T res; res = ToBE() ^ right.ToBE(); return (be_t&)res; }
|
||||
|
||||
template<typename T1> bool operator == (T1 right) const { return (T1)ToLE() == right; }
|
||||
template<typename T1> bool operator != (T1 right) const { return !(*this == right); }
|
||||
template<typename T1> bool operator > (T1 right) const { return (T1)ToLE() > right; }
|
||||
template<typename T1> bool operator < (T1 right) const { return (T1)ToLE() < right; }
|
||||
template<typename T1> bool operator >= (T1 right) const { return (T1)ToLE() >= right; }
|
||||
template<typename T1> bool operator <= (T1 right) const { return (T1)ToLE() <= right; }
|
||||
|
||||
template<typename T1> bool operator == (const be_t<T1>& right) const { return ToBE() == right.ToBE(); }
|
||||
template<typename T1> bool operator != (const be_t<T1>& right) const { return !(*this == right); }
|
||||
template<typename T1> bool operator > (const be_t<T1>& right) const { return (T1)ToLE() > right.ToLE(); }
|
||||
template<typename T1> bool operator < (const be_t<T1>& right) const { return (T1)ToLE() < right.ToLE(); }
|
||||
template<typename T1> bool operator >= (const be_t<T1>& right) const { return (T1)ToLE() >= right.ToLE(); }
|
||||
template<typename T1> bool operator <= (const be_t<T1>& right) const { return (T1)ToLE() <= right.ToLE(); }
|
||||
};
|
||||
|
||||
template<typename T, typename T2 = T>
|
||||
struct is_be_t : public std::integral_constant<bool, false> {};
|
||||
|
||||
|
@ -234,10 +340,22 @@ public:
|
|||
typedef const void type;
|
||||
};
|
||||
|
||||
template<typename T, typename T2 = T>
|
||||
struct invert_be_t
|
||||
{
|
||||
typedef typename to_be_t<T, T2>::type type;
|
||||
};
|
||||
|
||||
template<typename T, typename T2>
|
||||
struct invert_be_t<be_t<T, T2>>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<typename T, typename T1, T1 value> struct _se : public const_se_t<T, value> {};
|
||||
template<typename T, typename T1, T1 value> struct _se<be_t<T>, T1, value> : public const_se_t<T, value> {};
|
||||
|
||||
#define se(t, x) _se<decltype(t), decltype(x), x>::value
|
||||
//#define se(t, x) _se<decltype(t), decltype(x), x>::value
|
||||
#define se16(x) _se<u16, decltype(x), x>::value
|
||||
#define se32(x) _se<u32, decltype(x), x>::value
|
||||
#define se64(x) _se<u64, decltype(x), x>::value
|
||||
|
|
|
@ -139,9 +139,9 @@ std::string rDateTime::Format(const std::string &format, const rTimeZone &tz) co
|
|||
return fmt::ToUTF8(static_cast<wxDateTime*>(handle)->Format(fmt::FromUTF8(format),convertTZ(tz)));
|
||||
}
|
||||
|
||||
void rDateTime::ParseDateTime(const std::string & format)
|
||||
void rDateTime::ParseDateTime(const char* format)
|
||||
{
|
||||
static_cast<wxDateTime*>(handle)->ParseDateTime(fmt::FromUTF8(format));
|
||||
static_cast<wxDateTime*>(handle)->ParseDateTime(format);
|
||||
}
|
||||
|
||||
u32 rDateTime::GetAsDOS()
|
||||
|
|
|
@ -79,7 +79,7 @@ struct rDateTime
|
|||
void Close();
|
||||
std::string Format(const std::string &format = rDefaultDateTimeFormat, const rTimeZone &tz = Local) const;
|
||||
|
||||
void ParseDateTime(const std::string & format);
|
||||
void ParseDateTime(const char* format);
|
||||
|
||||
u32 GetAsDOS();
|
||||
rDateTime &SetFromDOS(u32 fromdos);
|
||||
|
|
|
@ -2366,7 +2366,7 @@ private:
|
|||
void LWARX(u32 rd, u32 ra, u32 rb)
|
||||
{
|
||||
CPU.R_ADDR = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
CPU.R_VALUE = (u32&)Memory[CPU.R_ADDR];
|
||||
CPU.R_VALUE = vm::get_ref<u32>(CPU.R_ADDR);
|
||||
CPU.GPR[rd] = re32((u32)CPU.R_VALUE);
|
||||
}
|
||||
void LDX(u32 rd, u32 ra, u32 rb)
|
||||
|
@ -2517,7 +2517,7 @@ private:
|
|||
void LDARX(u32 rd, u32 ra, u32 rb)
|
||||
{
|
||||
CPU.R_ADDR = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
CPU.R_VALUE = (u64&)Memory[CPU.R_ADDR];
|
||||
CPU.R_VALUE = vm::get_ref<u64>(CPU.R_ADDR);
|
||||
CPU.GPR[rd] = re64(CPU.R_VALUE);
|
||||
}
|
||||
void DCBF(u32 ra, u32 rb)
|
||||
|
@ -2635,7 +2635,8 @@ private:
|
|||
|
||||
if (CPU.R_ADDR == addr)
|
||||
{
|
||||
CPU.SetCR_EQ(0, InterlockedCompareExchange((volatile u32*)(Memory + addr), re32((u32)CPU.GPR[rs]), (u32)CPU.R_VALUE) == (u32)CPU.R_VALUE);
|
||||
CPU.SetCR_EQ(0, InterlockedCompareExchange(vm::get_ptr<volatile u32>(addr), re32((u32)CPU.GPR[rs]), (u32)CPU.R_VALUE) == (u32)CPU.R_VALUE);
|
||||
CPU.R_ADDR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2692,7 +2693,8 @@ private:
|
|||
|
||||
if (CPU.R_ADDR == addr)
|
||||
{
|
||||
CPU.SetCR_EQ(0, InterlockedCompareExchange((volatile u64*)(Memory + addr), re64(CPU.GPR[rs]), CPU.R_VALUE) == CPU.R_VALUE);
|
||||
CPU.SetCR_EQ(0, InterlockedCompareExchange(vm::get_ptr<volatile u64>(addr), re64(CPU.GPR[rs]), CPU.R_VALUE) == CPU.R_VALUE);
|
||||
CPU.R_ADDR = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2945,11 +2947,12 @@ private:
|
|||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
const u8 eb = addr & 0xf;
|
||||
|
||||
Memory.ReadLeft(CPU.VPR[vd]._u8 + eb, addr, 16 - eb);
|
||||
CPU.VPR[vd].Clear();
|
||||
for (u32 i = 0; i < 16 - eb; ++i) CPU.VPR[vd]._u8[15 - i] = Memory.Read8(addr + i);
|
||||
}
|
||||
void LDBRX(u32 rd, u32 ra, u32 rb)
|
||||
{
|
||||
CPU.GPR[rd] = (u64&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]];
|
||||
CPU.GPR[rd] = vm::get_ref<u64>(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]);
|
||||
}
|
||||
void LSWX(u32 rd, u32 ra, u32 rb)
|
||||
{
|
||||
|
@ -2957,7 +2960,7 @@ private:
|
|||
}
|
||||
void LWBRX(u32 rd, u32 ra, u32 rb)
|
||||
{
|
||||
CPU.GPR[rd] = (u32&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]];
|
||||
CPU.GPR[rd] = vm::get_ref<u32>(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]);
|
||||
}
|
||||
void LFSX(u32 frd, u32 ra, u32 rb)
|
||||
{
|
||||
|
@ -2987,7 +2990,8 @@ private:
|
|||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
const u8 eb = addr & 0xf;
|
||||
|
||||
Memory.ReadRight(CPU.VPR[vd]._u8, addr & ~0xf, eb);
|
||||
CPU.VPR[vd].Clear();
|
||||
for (u32 i = 16 - eb; i < 16; ++i) CPU.VPR[vd]._u8[15 - i] = Memory.Read8(addr + i - 16);
|
||||
}
|
||||
void LSWI(u32 rd, u32 ra, u32 nb)
|
||||
{
|
||||
|
@ -3043,7 +3047,7 @@ private:
|
|||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
const u8 eb = addr & 0xf;
|
||||
|
||||
Memory.WriteLeft(addr, 16 - eb, CPU.VPR[vs]._u8 + eb);
|
||||
for (u32 i = 0; i < 16 - eb; ++i) Memory.Write8(addr + i, CPU.VPR[vs]._u8[15 - i]);
|
||||
}
|
||||
void STSWX(u32 rs, u32 ra, u32 rb)
|
||||
{
|
||||
|
@ -3051,7 +3055,7 @@ private:
|
|||
}
|
||||
void STWBRX(u32 rs, u32 ra, u32 rb)
|
||||
{
|
||||
(u32&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]] = (u32)CPU.GPR[rs];
|
||||
vm::get_ref<u32>(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) = (u32)CPU.GPR[rs];
|
||||
}
|
||||
void STFSX(u32 frs, u32 ra, u32 rb)
|
||||
{
|
||||
|
@ -3062,7 +3066,7 @@ private:
|
|||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
const u8 eb = addr & 0xf;
|
||||
|
||||
Memory.WriteRight(addr - eb, eb, CPU.VPR[vs]._u8);
|
||||
for (u32 i = 16 - eb; i < 16; ++i) Memory.Write8(addr + i - 16, CPU.VPR[vs]._u8[15 - i]);
|
||||
}
|
||||
void STFSUX(u32 frs, u32 ra, u32 rb)
|
||||
{
|
||||
|
@ -3113,11 +3117,12 @@ private:
|
|||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
const u8 eb = addr & 0xf;
|
||||
|
||||
Memory.ReadLeft(CPU.VPR[vd]._u8 + eb, addr, 16 - eb);
|
||||
CPU.VPR[vd].Clear();
|
||||
for (u32 i = 0; i < 16 - eb; ++i) CPU.VPR[vd]._u8[15 - i] = Memory.Read8(addr + i);
|
||||
}
|
||||
void LHBRX(u32 rd, u32 ra, u32 rb)
|
||||
{
|
||||
CPU.GPR[rd] = (u16&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]];
|
||||
CPU.GPR[rd] = vm::get_ref<u16>(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]);
|
||||
}
|
||||
void SRAW(u32 ra, u32 rs, u32 rb, bool rc)
|
||||
{
|
||||
|
@ -3158,7 +3163,8 @@ private:
|
|||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
const u8 eb = addr & 0xf;
|
||||
|
||||
Memory.ReadRight(CPU.VPR[vd]._u8, addr & ~0xf, eb);
|
||||
CPU.VPR[vd].Clear();
|
||||
for (u32 i = 16 - eb; i < 16; ++i) CPU.VPR[vd]._u8[15 - i] = Memory.Read8(addr + i - 16);
|
||||
}
|
||||
void DSS(u32 strm, u32 a)
|
||||
{
|
||||
|
@ -3193,11 +3199,11 @@ private:
|
|||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
const u8 eb = addr & 0xf;
|
||||
|
||||
Memory.WriteLeft(addr, 16 - eb, CPU.VPR[vs]._u8 + eb);
|
||||
for (u32 i = 0; i < 16 - eb; ++i) Memory.Write8(addr + i, CPU.VPR[vs]._u8[15 - i]);
|
||||
}
|
||||
void STHBRX(u32 rs, u32 ra, u32 rb)
|
||||
{
|
||||
(u16&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]] = (u16)CPU.GPR[rs];
|
||||
vm::get_ref<u16>(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) = (u16)CPU.GPR[rs];
|
||||
}
|
||||
void EXTSH(u32 ra, u32 rs, bool rc)
|
||||
{
|
||||
|
@ -3209,7 +3215,7 @@ private:
|
|||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
const u8 eb = addr & 0xf;
|
||||
|
||||
Memory.WriteRight(addr - eb, eb, CPU.VPR[vs]._u8);
|
||||
for (u32 i = 16 - eb; i < 16; ++i) Memory.Write8(addr + i - 16, CPU.VPR[vs]._u8[15 - i]);
|
||||
}
|
||||
void EXTSB(u32 ra, u32 rs, bool rc)
|
||||
{
|
||||
|
@ -3232,7 +3238,7 @@ private:
|
|||
void DCBZ(u32 ra, u32 rb)
|
||||
{
|
||||
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
|
||||
u8 *const cache_line = Memory.GetMemFromAddr(addr & ~127);
|
||||
auto const cache_line = vm::get_ptr<u8>(addr & ~127);
|
||||
if (cache_line)
|
||||
memset(cache_line, 0, 128);
|
||||
_mm_mfence();
|
||||
|
|
|
@ -56,7 +56,7 @@ void PPUThread::AddArgv(const std::string& arg)
|
|||
m_stack_point -= arg.length() + 1;
|
||||
m_stack_point = AlignAddr(m_stack_point, 0x10) - 0x10;
|
||||
m_argv_addr.push_back(m_stack_point);
|
||||
Memory.WriteString(m_stack_point, arg);
|
||||
memcpy(vm::get_ptr<char>(m_stack_point), arg.c_str(), arg.size() + 1);
|
||||
}
|
||||
|
||||
void PPUThread::InitRegs()
|
||||
|
|
|
@ -516,7 +516,7 @@ union VPR_reg
|
|||
_u64[1] |= (value & 0x1) << bit;
|
||||
}
|
||||
|
||||
void Clear() { memset(this, 0, sizeof(*this)); }
|
||||
void Clear() { _u64[1] = _u64[0] = 0; }
|
||||
};
|
||||
|
||||
static const s32 MAX_INT_VALUE = 0x7fffffff;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#define UNIMPLEMENTED() UNK(__FUNCTION__)
|
||||
|
||||
#define MEM_AND_REG_HASH() \
|
||||
unsigned char mem_h[20]; sha1(&Memory[CPU.dmac.ls_offset], 256*1024, mem_h); \
|
||||
unsigned char mem_h[20]; sha1(vm::get_ptr<u8>(CPU.dmac.ls_offset), 256*1024, mem_h); \
|
||||
unsigned char reg_h[20]; sha1((const unsigned char*)CPU.GPR, sizeof(CPU.GPR), reg_h); \
|
||||
LOG_NOTICE(Log::SPU, "Mem hash: 0x%llx, reg hash: 0x%llx", *(u64*)mem_h, *(u64*)reg_h);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void SPURecompilerCore::Compile(u16 pos)
|
|||
u64 time0 = 0;
|
||||
|
||||
SPUDisAsm dis_asm(CPUDisAsm_InterpreterMode);
|
||||
dis_asm.offset = Memory.GetMemFromAddr(CPU.dmac.ls_offset);
|
||||
dis_asm.offset = vm::get_ptr<u8>(CPU.dmac.ls_offset);
|
||||
|
||||
StringLogger stringLogger;
|
||||
stringLogger.setOption(kLoggerOptionBinaryForm, true);
|
||||
|
@ -127,11 +127,11 @@ void SPURecompilerCore::Compile(u16 pos)
|
|||
m_enc->do_finalize = true;
|
||||
}
|
||||
bool fin = m_enc->do_finalize;
|
||||
if (entry[pos].valid == re(opcode))
|
||||
if (entry[pos].valid == re32(opcode))
|
||||
{
|
||||
excess++;
|
||||
}
|
||||
entry[pos].valid = re(opcode);
|
||||
entry[pos].valid = re32(opcode);
|
||||
|
||||
if (fin) break;
|
||||
CPU.PC += 4;
|
||||
|
@ -186,7 +186,7 @@ u8 SPURecompilerCore::DecodeMemory(const u64 address)
|
|||
const u16 pos = (u16)(CPU.PC >> 2);
|
||||
|
||||
//ConLog.Write("DecodeMemory: pos=%d", pos);
|
||||
u32* ls = (u32*)&Memory[m_offset];
|
||||
u32* ls = vm::get_ptr<u32>(m_offset);
|
||||
|
||||
if (entry[pos].pointer)
|
||||
{
|
||||
|
@ -252,7 +252,7 @@ u8 SPURecompilerCore::DecodeMemory(const u64 address)
|
|||
}
|
||||
|
||||
u32 res = pos;
|
||||
res = func(cpu, &Memory[m_offset], imm_table.data(), &g_imm_table);
|
||||
res = func(cpu, vm::get_ptr<void>(m_offset), imm_table.data(), &g_imm_table);
|
||||
|
||||
if (res > 0xffff)
|
||||
{
|
||||
|
|
|
@ -244,13 +244,13 @@ void SPUThread::ProcessCmd(u32 cmd, u32 tag, u32 lsa, u64 ea, u32 size)
|
|||
{
|
||||
case MFC_PUT_CMD:
|
||||
{
|
||||
memcpy(Memory + ea, Memory + (dmac.ls_offset + lsa), size);
|
||||
memcpy(vm::get_ptr<void>(ea), vm::get_ptr<void>(dmac.ls_offset + lsa), size);
|
||||
return;
|
||||
}
|
||||
|
||||
case MFC_GET_CMD:
|
||||
{
|
||||
memcpy(Memory + (dmac.ls_offset + lsa), Memory + ea, size);
|
||||
memcpy(vm::get_ptr<void>(dmac.ls_offset + lsa), vm::get_ptr<void>(ea), size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ void SPUThread::ListCmd(u32 lsa, u64 ea, u16 tag, u16 size, u32 cmd, MFCReg& MFC
|
|||
|
||||
lsa += std::max(size, (u32)16);
|
||||
|
||||
if (rec->s & se16(0x8000))
|
||||
if (rec->s.ToBE() & se16(0x8000))
|
||||
{
|
||||
StallStat.PushUncond_OR(1 << tag);
|
||||
|
||||
|
@ -389,8 +389,8 @@ void SPUThread::EnqMfcCmd(MFCReg& MFCArgs)
|
|||
R_ADDR = ea;
|
||||
for (u32 i = 0; i < 16; i++)
|
||||
{
|
||||
R_DATA[i] = *(u64*)&Memory[R_ADDR + i * 8];
|
||||
*(u64*)&Memory[dmac.ls_offset + lsa + i * 8] = R_DATA[i];
|
||||
R_DATA[i] = vm::get_ptr<u64>(R_ADDR)[i];
|
||||
vm::get_ptr<u64>(dmac.ls_offset + lsa)[i] = R_DATA[i];
|
||||
}
|
||||
MFCArgs.AtomicStat.PushUncond(MFC_GETLLAR_SUCCESS);
|
||||
}
|
||||
|
@ -404,12 +404,12 @@ void SPUThread::EnqMfcCmd(MFCReg& MFCArgs)
|
|||
u64 buf[16];
|
||||
for (u32 i = 0; i < 16; i++)
|
||||
{
|
||||
buf[i] = *(u64*)&Memory[dmac.ls_offset + lsa + i * 8];
|
||||
buf[i] = vm::get_ptr<u64>(dmac.ls_offset + lsa)[i];
|
||||
if (buf[i] != R_DATA[i])
|
||||
{
|
||||
changed++;
|
||||
mask |= (0x3 << (i * 2));
|
||||
if (*(u64*)&Memory[R_ADDR + i * 8] != R_DATA[i])
|
||||
if (vm::get_ptr<u64>(R_ADDR)[i] != R_DATA[i])
|
||||
{
|
||||
m_events |= SPU_EVENT_LR;
|
||||
MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_FAILURE);
|
||||
|
@ -423,7 +423,7 @@ void SPUThread::EnqMfcCmd(MFCReg& MFCArgs)
|
|||
{
|
||||
if (buf[i] != R_DATA[i])
|
||||
{
|
||||
if (InterlockedCompareExchange((volatile u64*)(Memory + (ea + i * 8)), buf[i], R_DATA[i]) != R_DATA[i])
|
||||
if (InterlockedCompareExchange(&vm::get_ptr<volatile u64>(ea)[i], buf[i], R_DATA[i]) != R_DATA[i])
|
||||
{
|
||||
m_events |= SPU_EVENT_LR;
|
||||
MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_FAILURE);
|
||||
|
@ -449,7 +449,7 @@ void SPUThread::EnqMfcCmd(MFCReg& MFCArgs)
|
|||
for (s32 i = (s32)PC; i < (s32)PC + 4 * 7; i += 4)
|
||||
{
|
||||
dis_asm.dump_pc = i;
|
||||
dis_asm.offset = Memory.GetMemFromAddr(dmac.ls_offset);
|
||||
dis_asm.offset = vm::get_ptr<u8>(dmac.ls_offset);
|
||||
const u32 opcode = Memory.Read32(i + dmac.ls_offset);
|
||||
(*SPU_instr::rrr_list)(&dis_asm, opcode);
|
||||
if (i >= 0 && i < 0x40000)
|
||||
|
@ -497,7 +497,7 @@ bool SPUThread::CheckEvents()
|
|||
{
|
||||
for (u32 i = 0; i < 16; i++)
|
||||
{
|
||||
if (*(u64*)&Memory[R_ADDR + i * 8] != R_DATA[i])
|
||||
if (vm::get_ptr<u64>(R_ADDR)[i] != R_DATA[i])
|
||||
{
|
||||
m_events |= SPU_EVENT_LR;
|
||||
R_ADDR = 0;
|
||||
|
|
|
@ -31,7 +31,7 @@ u64 vfsStreamMemory::Write(const void* src, u64 size)
|
|||
size = GetSize() - Tell();
|
||||
}
|
||||
|
||||
memcpy(Memory + (m_addr + Tell()), (void*)src, size);
|
||||
memcpy(vm::get_ptr<void>(m_addr + Tell()), src, size);
|
||||
|
||||
return vfsStream::Write(src, size);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ u64 vfsStreamMemory::Read(void* dst, u64 size)
|
|||
size = GetSize() - Tell();
|
||||
}
|
||||
|
||||
memcpy(dst, Memory + (m_addr + Tell()), size);
|
||||
memcpy(dst, vm::get_ptr<void>(m_addr + Tell()), size);
|
||||
|
||||
return vfsStream::Read(dst, size);
|
||||
}
|
||||
|
|
|
@ -1,210 +0,0 @@
|
|||
#pragma once
|
||||
//DynamicMemoryBlockBase
|
||||
template<typename PT>
|
||||
DynamicMemoryBlockBase<PT>::DynamicMemoryBlockBase()
|
||||
: PT()
|
||||
, m_max_size(0)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
const u32 DynamicMemoryBlockBase<PT>::GetUsedSize() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
||||
u32 size = 0;
|
||||
|
||||
for (u32 i = 0; i<m_allocated.size(); ++i)
|
||||
{
|
||||
size += m_allocated[i].size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
bool DynamicMemoryBlockBase<PT>::IsInMyRange(const u64 addr)
|
||||
{
|
||||
return addr >= MemoryBlock::GetStartAddr() && addr < MemoryBlock::GetStartAddr() + GetSize();
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
bool DynamicMemoryBlockBase<PT>::IsInMyRange(const u64 addr, const u32 size)
|
||||
{
|
||||
return IsInMyRange(addr) && IsInMyRange(addr + size - 1);
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
bool DynamicMemoryBlockBase<PT>::IsMyAddress(const u64 addr)
|
||||
{
|
||||
return IsInMyRange(addr);
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
MemoryBlock* DynamicMemoryBlockBase<PT>::SetRange(const u64 start, const u32 size)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
||||
m_max_size = PAGE_4K(size);
|
||||
if (!MemoryBlock::SetRange(start, 0))
|
||||
{
|
||||
assert(0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
void DynamicMemoryBlockBase<PT>::Delete()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
||||
m_allocated.clear();
|
||||
m_max_size = 0;
|
||||
|
||||
MemoryBlock::Delete();
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
bool DynamicMemoryBlockBase<PT>::AllocFixed(u64 addr, u32 size)
|
||||
{
|
||||
size = PAGE_4K(size + (addr & 4095)); // align size
|
||||
|
||||
addr &= ~4095; // align start address
|
||||
|
||||
if (!IsInMyRange(addr, size))
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
||||
for (u32 i = 0; i<m_allocated.size(); ++i)
|
||||
{
|
||||
if (addr >= m_allocated[i].addr && addr < m_allocated[i].addr + m_allocated[i].size) return false;
|
||||
}
|
||||
|
||||
AppendMem(addr, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
void DynamicMemoryBlockBase<PT>::AppendMem(u64 addr, u32 size) /* private */
|
||||
{
|
||||
m_allocated.emplace_back(addr, size);
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
u64 DynamicMemoryBlockBase<PT>::AllocAlign(u32 size, u32 align)
|
||||
{
|
||||
size = PAGE_4K(size);
|
||||
u32 exsize;
|
||||
|
||||
if (align <= 4096)
|
||||
{
|
||||
align = 0;
|
||||
exsize = size;
|
||||
}
|
||||
else
|
||||
{
|
||||
align &= ~4095;
|
||||
exsize = size + align - 1;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
||||
for (u64 addr = MemoryBlock::GetStartAddr(); addr <= MemoryBlock::GetEndAddr() - exsize;)
|
||||
{
|
||||
bool is_good_addr = true;
|
||||
|
||||
for (u32 i = 0; i<m_allocated.size(); ++i)
|
||||
{
|
||||
if ((addr >= m_allocated[i].addr && addr < m_allocated[i].addr + m_allocated[i].size) ||
|
||||
(m_allocated[i].addr >= addr && m_allocated[i].addr < addr + exsize))
|
||||
{
|
||||
is_good_addr = false;
|
||||
addr = m_allocated[i].addr + m_allocated[i].size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_good_addr) continue;
|
||||
|
||||
if (align)
|
||||
{
|
||||
addr = (addr + (align - 1)) & ~(align - 1);
|
||||
}
|
||||
|
||||
//LOG_NOTICE(MEMORY, "AllocAlign(size=0x%x) -> 0x%llx", size, addr);
|
||||
|
||||
AppendMem(addr, size);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
bool DynamicMemoryBlockBase<PT>::Alloc()
|
||||
{
|
||||
return AllocAlign(GetSize() - GetUsedSize()) != 0;
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
bool DynamicMemoryBlockBase<PT>::Free(u64 addr)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_lock);
|
||||
|
||||
for (u32 num = 0; num < m_allocated.size(); num++)
|
||||
{
|
||||
if (addr == m_allocated[num].addr)
|
||||
{
|
||||
//LOG_NOTICE(MEMORY, "Free(0x%llx)", addr);
|
||||
|
||||
m_allocated.erase(m_allocated.begin() + num);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
u8* DynamicMemoryBlockBase<PT>::GetMem(u64 addr) const
|
||||
{
|
||||
return MemoryBlock::GetMem(addr);
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
bool DynamicMemoryBlockBase<PT>::IsLocked(u64 addr)
|
||||
{
|
||||
// TODO
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
bool DynamicMemoryBlockBase<PT>::Lock(u64 addr, u32 size)
|
||||
{
|
||||
// TODO
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename PT>
|
||||
bool DynamicMemoryBlockBase<PT>::Unlock(u64 addr, u32 size)
|
||||
{
|
||||
// TODO
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
|
@ -24,7 +24,7 @@ void MemoryBase::InvalidAddress(const char* func, const u64 addr)
|
|||
|
||||
void MemoryBase::RegisterPages(u64 addr, u32 size)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
LV2_LOCK(0);
|
||||
|
||||
//LOG_NOTICE(MEMORY, "RegisterPages(addr=0x%llx, size=0x%x)", addr, size);
|
||||
for (u64 i = addr / 4096; i < (addr + size) / 4096; i++)
|
||||
|
@ -45,7 +45,7 @@ void MemoryBase::RegisterPages(u64 addr, u32 size)
|
|||
|
||||
void MemoryBase::UnregisterPages(u64 addr, u32 size)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
LV2_LOCK(0);
|
||||
|
||||
//LOG_NOTICE(MEMORY, "UnregisterPages(addr=0x%llx, size=0x%x)", addr, size);
|
||||
for (u64 i = addr / 4096; i < (addr + size) / 4096; i++)
|
||||
|
@ -66,7 +66,7 @@ void MemoryBase::UnregisterPages(u64 addr, u32 size)
|
|||
|
||||
u32 MemoryBase::InitRawSPU(MemoryBlock* raw_spu)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
LV2_LOCK(0);
|
||||
|
||||
u32 index;
|
||||
for (index = 0; index < sizeof(RawSPUMem) / sizeof(RawSPUMem[0]); index++)
|
||||
|
@ -84,7 +84,7 @@ u32 MemoryBase::InitRawSPU(MemoryBlock* raw_spu)
|
|||
|
||||
void MemoryBase::CloseRawSPU(MemoryBlock* raw_spu, const u32 num)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
LV2_LOCK(0);
|
||||
|
||||
for (int i = 0; i < MemoryBlocks.size(); ++i)
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ void MemoryBase::CloseRawSPU(MemoryBlock* raw_spu, const u32 num)
|
|||
|
||||
void MemoryBase::Init(MemoryType type)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
LV2_LOCK(0);
|
||||
|
||||
if (m_inited) return;
|
||||
m_inited = true;
|
||||
|
@ -152,7 +152,7 @@ void MemoryBase::Init(MemoryType type)
|
|||
|
||||
void MemoryBase::Close()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
LV2_LOCK(0);
|
||||
|
||||
if (!m_inited) return;
|
||||
m_inited = false;
|
||||
|
@ -167,24 +167,12 @@ void MemoryBase::Close()
|
|||
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 MemoryBase::WriteMMIO32(u32 addr, const u32 data)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
LV2_LOCK(0);
|
||||
|
||||
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
|
||||
((RawSPUThread*)RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET])->Write32(addr, data))
|
||||
|
@ -200,7 +188,7 @@ u32 MemoryBase::ReadMMIO32(u32 addr)
|
|||
{
|
||||
u32 res;
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
LV2_LOCK(0);
|
||||
|
||||
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
|
||||
((RawSPUThread*)RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET])->Read32(addr, &res))
|
||||
|
@ -213,35 +201,38 @@ u32 MemoryBase::ReadMMIO32(u32 addr)
|
|||
return res;
|
||||
}
|
||||
|
||||
bool MemoryBase::Map(const u64 dst_addr, const u64 src_addr, const u32 size)
|
||||
bool MemoryBase::Map(const u64 addr, const u32 size)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
LV2_LOCK(0);
|
||||
|
||||
if (IsGoodAddr(dst_addr) || !IsGoodAddr(src_addr))
|
||||
if ((u32)addr != addr || (u64)addr + (u64)size > 0x100000000ull)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (u32 i = (u32)addr / 4096; i <= ((u32)addr + size - 1) / 4096; i++)
|
||||
{
|
||||
if (m_pages[i]) 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);
|
||||
MemoryBlocks.push_back((new MemoryBlock())->SetRange(addr, size));
|
||||
LOG_WARNING(MEMORY, "MemoryBase::Map(0x%llx, 0x%x)", addr, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MemoryBase::Unmap(const u64 addr)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
LV2_LOCK(0);
|
||||
|
||||
bool result = false;
|
||||
for (uint i = 0; i<MemoryBlocks.size(); ++i)
|
||||
for (u32 i = 0; i < MemoryBlocks.size(); i++)
|
||||
{
|
||||
if (MemoryBlocks[i]->IsMirror())
|
||||
if (MemoryBlocks[i]->GetStartAddr() == addr)
|
||||
{
|
||||
if (MemoryBlocks[i]->GetStartAddr() == addr)
|
||||
{
|
||||
delete MemoryBlocks[i];
|
||||
MemoryBlocks.erase(MemoryBlocks.begin() + i);
|
||||
return true;
|
||||
}
|
||||
delete MemoryBlocks[i];
|
||||
MemoryBlocks.erase(MemoryBlocks.begin() + i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -308,14 +299,14 @@ void MemoryBlock::Init()
|
|||
range_start = 0;
|
||||
range_size = 0;
|
||||
|
||||
mem = Memory.GetMemFromAddr(0);
|
||||
mem = vm::get_ptr<u8>(0);
|
||||
}
|
||||
|
||||
void MemoryBlock::InitMemory()
|
||||
{
|
||||
if (!range_size)
|
||||
{
|
||||
mem = Memory.GetMemFromAddr(range_start);
|
||||
mem = vm::get_ptr<u8>(range_start);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -361,6 +352,198 @@ bool MemoryBlock::IsMyAddress(const u64 addr)
|
|||
return mem && addr >= GetStartAddr() && addr < GetEndAddr();
|
||||
}
|
||||
|
||||
DynamicMemoryBlockBase::DynamicMemoryBlockBase()
|
||||
: MemoryBlock()
|
||||
, m_max_size(0)
|
||||
{
|
||||
}
|
||||
|
||||
const u32 DynamicMemoryBlockBase::GetUsedSize() const
|
||||
{
|
||||
LV2_LOCK(0);
|
||||
|
||||
u32 size = 0;
|
||||
|
||||
for (u32 i = 0; i<m_allocated.size(); ++i)
|
||||
{
|
||||
size += m_allocated[i].size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
bool DynamicMemoryBlockBase::IsInMyRange(const u64 addr)
|
||||
{
|
||||
return addr >= MemoryBlock::GetStartAddr() && addr < MemoryBlock::GetStartAddr() + GetSize();
|
||||
}
|
||||
|
||||
bool DynamicMemoryBlockBase::IsInMyRange(const u64 addr, const u32 size)
|
||||
{
|
||||
return IsInMyRange(addr) && IsInMyRange(addr + size - 1);
|
||||
}
|
||||
|
||||
bool DynamicMemoryBlockBase::IsMyAddress(const u64 addr)
|
||||
{
|
||||
return IsInMyRange(addr);
|
||||
}
|
||||
|
||||
MemoryBlock* DynamicMemoryBlockBase::SetRange(const u64 start, const u32 size)
|
||||
{
|
||||
LV2_LOCK(0);
|
||||
|
||||
m_max_size = PAGE_4K(size);
|
||||
if (!MemoryBlock::SetRange(start, 0))
|
||||
{
|
||||
assert(0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
void DynamicMemoryBlockBase::Delete()
|
||||
{
|
||||
LV2_LOCK(0);
|
||||
|
||||
m_allocated.clear();
|
||||
m_max_size = 0;
|
||||
|
||||
MemoryBlock::Delete();
|
||||
}
|
||||
|
||||
bool DynamicMemoryBlockBase::AllocFixed(u64 addr, u32 size)
|
||||
{
|
||||
size = PAGE_4K(size + (addr & 4095)); // align size
|
||||
|
||||
addr &= ~4095; // align start address
|
||||
|
||||
if (!IsInMyRange(addr, size))
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
for (u32 i = 0; i<m_allocated.size(); ++i)
|
||||
{
|
||||
if (addr >= m_allocated[i].addr && addr < m_allocated[i].addr + m_allocated[i].size) return false;
|
||||
}
|
||||
|
||||
AppendMem(addr, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DynamicMemoryBlockBase::AppendMem(u64 addr, u32 size) /* private */
|
||||
{
|
||||
m_allocated.emplace_back(addr, size);
|
||||
}
|
||||
|
||||
u64 DynamicMemoryBlockBase::AllocAlign(u32 size, u32 align)
|
||||
{
|
||||
size = PAGE_4K(size);
|
||||
u32 exsize;
|
||||
|
||||
if (align <= 4096)
|
||||
{
|
||||
align = 0;
|
||||
exsize = size;
|
||||
}
|
||||
else
|
||||
{
|
||||
align &= ~4095;
|
||||
exsize = size + align - 1;
|
||||
}
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
for (u64 addr = MemoryBlock::GetStartAddr(); addr <= MemoryBlock::GetEndAddr() - exsize;)
|
||||
{
|
||||
bool is_good_addr = true;
|
||||
|
||||
for (u32 i = 0; i<m_allocated.size(); ++i)
|
||||
{
|
||||
if ((addr >= m_allocated[i].addr && addr < m_allocated[i].addr + m_allocated[i].size) ||
|
||||
(m_allocated[i].addr >= addr && m_allocated[i].addr < addr + exsize))
|
||||
{
|
||||
is_good_addr = false;
|
||||
addr = m_allocated[i].addr + m_allocated[i].size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_good_addr) continue;
|
||||
|
||||
if (align)
|
||||
{
|
||||
addr = (addr + (align - 1)) & ~(align - 1);
|
||||
}
|
||||
|
||||
//LOG_NOTICE(MEMORY, "AllocAlign(size=0x%x) -> 0x%llx", size, addr);
|
||||
|
||||
AppendMem(addr, size);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DynamicMemoryBlockBase::Alloc()
|
||||
{
|
||||
return AllocAlign(GetSize() - GetUsedSize()) != 0;
|
||||
}
|
||||
|
||||
bool DynamicMemoryBlockBase::Free(u64 addr)
|
||||
{
|
||||
LV2_LOCK(0);
|
||||
|
||||
for (u32 num = 0; num < m_allocated.size(); num++)
|
||||
{
|
||||
if (addr == m_allocated[num].addr)
|
||||
{
|
||||
//LOG_NOTICE(MEMORY, "Free(0x%llx)", addr);
|
||||
|
||||
m_allocated.erase(m_allocated.begin() + num);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
u8* DynamicMemoryBlockBase::GetMem(u64 addr) const
|
||||
{
|
||||
return MemoryBlock::GetMem(addr);
|
||||
}
|
||||
|
||||
bool DynamicMemoryBlockBase::IsLocked(u64 addr)
|
||||
{
|
||||
LOG_ERROR(MEMORY, "DynamicMemoryBlockBase::IsLocked() not implemented");
|
||||
Emu.Pause();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DynamicMemoryBlockBase::Lock(u64 addr, u32 size)
|
||||
{
|
||||
LOG_ERROR(MEMORY, "DynamicMemoryBlockBase::Lock() not implemented");
|
||||
Emu.Pause();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DynamicMemoryBlockBase::Unlock(u64 addr, u32 size)
|
||||
{
|
||||
LOG_ERROR(MEMORY, "DynamicMemoryBlockBase::Unlock() not implemented");
|
||||
Emu.Pause();
|
||||
return false;
|
||||
}
|
||||
|
||||
VirtualMemoryBlock::VirtualMemoryBlock() : MemoryBlock(), m_reserve_size(0)
|
||||
{
|
||||
}
|
||||
|
@ -465,24 +648,6 @@ u32 VirtualMemoryBlock::UnmapAddress(u64 addr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Read8(const u64 addr, u8* value)
|
||||
{
|
||||
u64 realAddr;
|
||||
if(!getRealAddr(addr, realAddr))
|
||||
return false;
|
||||
*value = Memory.Read8(realAddr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Read16(const u64 addr, u16* value)
|
||||
{
|
||||
u64 realAddr;
|
||||
if(!getRealAddr(addr, realAddr))
|
||||
return false;
|
||||
*value = Memory.Read16(realAddr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Read32(const u64 addr, u32* value)
|
||||
{
|
||||
u64 realAddr;
|
||||
|
@ -492,42 +657,6 @@ bool VirtualMemoryBlock::Read32(const u64 addr, u32* value)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Read64(const u64 addr, u64* value)
|
||||
{
|
||||
u64 realAddr;
|
||||
if(!getRealAddr(addr, realAddr))
|
||||
return false;
|
||||
*value = Memory.Read64(realAddr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Read128(const u64 addr, u128* value)
|
||||
{
|
||||
u64 realAddr;
|
||||
if(!getRealAddr(addr, realAddr))
|
||||
return false;
|
||||
*value = Memory.Read128(realAddr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Write8(const u64 addr, const u8 value)
|
||||
{
|
||||
u64 realAddr;
|
||||
if(!getRealAddr(addr, realAddr))
|
||||
return false;
|
||||
Memory.Write8(realAddr, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Write16(const u64 addr, const u16 value)
|
||||
{
|
||||
u64 realAddr;
|
||||
if(!getRealAddr(addr, realAddr))
|
||||
return false;
|
||||
Memory.Write16(realAddr, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Write32(const u64 addr, const u32 value)
|
||||
{
|
||||
u64 realAddr;
|
||||
|
@ -537,24 +666,6 @@ bool VirtualMemoryBlock::Write32(const u64 addr, const u32 value)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Write64(const u64 addr, const u64 value)
|
||||
{
|
||||
u64 realAddr;
|
||||
if(!getRealAddr(addr, realAddr))
|
||||
return false;
|
||||
Memory.Write64(realAddr, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::Write128(const u64 addr, const u128 value)
|
||||
{
|
||||
u64 realAddr;
|
||||
if(!getRealAddr(addr, realAddr))
|
||||
return false;
|
||||
Memory.Write128(realAddr, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VirtualMemoryBlock::getRealAddr(u64 addr, u64& result)
|
||||
{
|
||||
for(u32 i=0; i<m_mapped_memory.size(); ++i)
|
||||
|
|
|
@ -29,7 +29,6 @@ class MemoryBase
|
|||
{
|
||||
std::vector<MemoryBlock*> MemoryBlocks;
|
||||
u32 m_pages[0x100000000 / 4096]; // information about every page
|
||||
std::recursive_mutex m_mutex;
|
||||
|
||||
public:
|
||||
MemoryBlock* UserMemory;
|
||||
|
@ -60,17 +59,17 @@ public:
|
|||
|
||||
struct : Wrapper32LE
|
||||
{
|
||||
DynamicMemoryBlockLE RAM;
|
||||
DynamicMemoryBlockLE Userspace;
|
||||
DynamicMemoryBlock RAM;
|
||||
DynamicMemoryBlock Userspace;
|
||||
} PSV;
|
||||
|
||||
struct : Wrapper32LE
|
||||
{
|
||||
DynamicMemoryBlockLE Scratchpad;
|
||||
DynamicMemoryBlockLE VRAM;
|
||||
DynamicMemoryBlockLE RAM;
|
||||
DynamicMemoryBlockLE Kernel;
|
||||
DynamicMemoryBlockLE Userspace;
|
||||
DynamicMemoryBlock Scratchpad;
|
||||
DynamicMemoryBlock VRAM;
|
||||
DynamicMemoryBlock RAM;
|
||||
DynamicMemoryBlock Kernel;
|
||||
DynamicMemoryBlock Userspace;
|
||||
} PSP;
|
||||
|
||||
bool m_inited;
|
||||
|
@ -96,24 +95,6 @@ public:
|
|||
|
||||
void UnregisterPages(u64 addr, u32 size);
|
||||
|
||||
template<typename T> u8* GetMemFromAddr(const T addr)
|
||||
{
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
return (u8*)GetBaseAddr() + addr;
|
||||
}
|
||||
else
|
||||
{
|
||||
InvalidAddress(__FUNCTION__, addr);
|
||||
return (u8*)GetBaseAddr();
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> void* VirtualToRealAddr(const T vaddr)
|
||||
{
|
||||
return GetMemFromAddr<T>(vaddr);
|
||||
}
|
||||
|
||||
u32 RealToVirtualAddr(const void* addr)
|
||||
{
|
||||
const u64 res = (u64)addr - (u64)GetBaseAddr();
|
||||
|
@ -314,53 +295,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void ReadLeft(u8* dst, const u64 addr, const u32 size)
|
||||
{
|
||||
for (u32 i = 0; i < size; ++i) dst[size - 1 - i] = Read8(addr + i);
|
||||
}
|
||||
|
||||
void WriteLeft(const u64 addr, const u32 size, const u8* src)
|
||||
{
|
||||
for (u32 i = 0; i < size; ++i) Write8(addr + i, src[size - 1 - i]);
|
||||
}
|
||||
|
||||
void ReadRight(u8* dst, const u64 addr, const u32 size)
|
||||
{
|
||||
for (u32 i = 0; i < size; ++i) dst[i] = Read8(addr + (size - 1 - i));
|
||||
}
|
||||
|
||||
void WriteRight(const u64 addr, const u32 size, const u8* src)
|
||||
{
|
||||
for (u32 i = 0; i < size; ++i) Write8(addr + (size - 1 - i), src[i]);
|
||||
}
|
||||
|
||||
template<typename T, typename Td> void WriteData(const T addr, const Td* data)
|
||||
{
|
||||
memcpy(GetMemFromAddr<T>(addr), data, sizeof(Td));
|
||||
}
|
||||
|
||||
template<typename T, typename Td> void WriteData(const T addr, const Td data)
|
||||
{
|
||||
*(Td*)GetMemFromAddr<T>(addr) = data;
|
||||
}
|
||||
|
||||
template<typename T> std::string ReadString(const T addr, const u64 len)
|
||||
{
|
||||
std::string ret((const char *)GetMemFromAddr<T>(addr), len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename T> std::string ReadString(const T addr)
|
||||
{
|
||||
return std::string((const char*)GetMemFromAddr<T>(addr));
|
||||
}
|
||||
|
||||
template<typename T> void WriteString(const T addr, const std::string& str)
|
||||
{
|
||||
strcpy((char*)GetMemFromAddr<T>(addr), str.c_str());
|
||||
}
|
||||
|
||||
u32 GetUserMemTotalSize()
|
||||
{
|
||||
return UserMemory->GetSize();
|
||||
|
@ -381,29 +315,9 @@ public:
|
|||
return UserMemory->Free(addr);
|
||||
}
|
||||
|
||||
bool Lock(const u64 addr, const u32 size)
|
||||
{
|
||||
return UserMemory->Lock(addr, size);
|
||||
}
|
||||
|
||||
bool Unlock(const u64 addr, const u32 size)
|
||||
{
|
||||
return UserMemory->Unlock(addr, size);
|
||||
}
|
||||
|
||||
bool Map(const u64 dst_addr, const u64 src_addr, const u32 size);
|
||||
bool Map(const u64 addr, const u32 size);
|
||||
|
||||
bool Unmap(const u64 addr);
|
||||
|
||||
template<typename T> void* operator + (const T vaddr)
|
||||
{
|
||||
return GetMemFromAddr<T>(vaddr);
|
||||
}
|
||||
|
||||
template<typename T> u8& operator[] (const T vaddr)
|
||||
{
|
||||
return *GetMemFromAddr<T>(vaddr);
|
||||
}
|
||||
};
|
||||
|
||||
extern MemoryBase Memory;
|
||||
|
|
|
@ -93,9 +93,6 @@ private:
|
|||
public:
|
||||
virtual void Delete();
|
||||
|
||||
virtual bool IsNULL() { return false; }
|
||||
virtual bool IsMirror() { return false; }
|
||||
|
||||
u64 FixAddr(const u64 addr) const;
|
||||
|
||||
virtual MemoryBlock* SetRange(const u64 start, const u32 size);
|
||||
|
@ -117,40 +114,8 @@ public:
|
|||
virtual bool Unlock(u64 addr, u32 size) { return false; }
|
||||
};
|
||||
|
||||
class MemoryBlockLE : public MemoryBlock
|
||||
class DynamicMemoryBlockBase : public MemoryBlock
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
class MemoryMirror : public MemoryBlock
|
||||
{
|
||||
public:
|
||||
virtual bool IsMirror() { return true; }
|
||||
|
||||
virtual MemoryBlock* SetRange(const u64 start, const u32 size)
|
||||
{
|
||||
range_start = start;
|
||||
range_size = size;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
void SetMemory(u8* memory)
|
||||
{
|
||||
mem = memory;
|
||||
}
|
||||
|
||||
MemoryBlock* SetRange(u8* memory, const u64 start, const u32 size)
|
||||
{
|
||||
SetMemory(memory);
|
||||
return SetRange(start, size);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename PT>
|
||||
class DynamicMemoryBlockBase : public PT
|
||||
{
|
||||
mutable std::mutex m_lock;
|
||||
std::vector<MemBlockInfo> m_allocated; // allocation info
|
||||
u32 m_max_size;
|
||||
|
||||
|
@ -215,17 +180,9 @@ public:
|
|||
// Return the total amount of reserved memory
|
||||
virtual u32 GetReservedAmount();
|
||||
|
||||
bool Read8(const u64 addr, u8* value);
|
||||
bool Read16(const u64 addr, u16* value);
|
||||
bool Read32(const u64 addr, u32* value);
|
||||
bool Read64(const u64 addr, u64* value);
|
||||
bool Read128(const u64 addr, u128* value);
|
||||
|
||||
bool Write8(const u64 addr, const u8 value);
|
||||
bool Write16(const u64 addr, const u16 value);
|
||||
bool Write32(const u64 addr, const u32 value);
|
||||
bool Write64(const u64 addr, const u64 value);
|
||||
bool Write128(const u64 addr, const u128 value);
|
||||
|
||||
// try to get the real address given a mapped address
|
||||
// return true for success
|
||||
|
@ -242,8 +199,5 @@ public:
|
|||
u64 getMappedAddress(u64 realAddress);
|
||||
};
|
||||
|
||||
#include "DynamicMemoryBlockBase.h"
|
||||
|
||||
typedef DynamicMemoryBlockBase<MemoryBlock> DynamicMemoryBlock;
|
||||
typedef DynamicMemoryBlockBase<MemoryBlockLE> DynamicMemoryBlockLE;
|
||||
typedef DynamicMemoryBlockBase DynamicMemoryBlock;
|
||||
|
||||
|
|
|
@ -58,30 +58,29 @@ namespace vm
|
|||
return make(m_addr - count * sizeof(AT));
|
||||
}
|
||||
|
||||
__forceinline _ptr_base<T, lvl - 1, AT>& operator *()
|
||||
__forceinline _ptr_base<T, lvl - 1, AT>& operator *() const
|
||||
{
|
||||
return vm::get_ref<_ptr_base<T, lvl - 1, AT>>(m_addr);
|
||||
}
|
||||
|
||||
__forceinline const _ptr_base<T, lvl - 1, AT>& operator *() const
|
||||
{
|
||||
return vm::get_ref<const _ptr_base<T, lvl - 1, AT>>(m_addr);
|
||||
}
|
||||
|
||||
__forceinline _ptr_base<T, lvl - 1, AT>& operator [](int index)
|
||||
__forceinline _ptr_base<T, lvl - 1, AT>& operator [](int index) const
|
||||
{
|
||||
return vm::get_ref<_ptr_base<T, lvl - 1, AT>>(m_addr + sizeof(AT) * index);
|
||||
}
|
||||
|
||||
__forceinline const _ptr_base<T, lvl - 1, AT>& operator [](int index) const
|
||||
{
|
||||
return vm::get_ref<const _ptr_base<T, lvl - 1, AT>>(m_addr + sizeof(AT) * index);
|
||||
}
|
||||
|
||||
operator bool() const
|
||||
{
|
||||
return m_addr != 0;
|
||||
}
|
||||
|
||||
//typedef typename invert_be_t<AT>::type AT2;
|
||||
|
||||
template<typename AT2>
|
||||
operator const _ptr_base<T, lvl, AT2>() const
|
||||
{
|
||||
typename std::remove_const<AT2>::type addr; addr = m_addr;
|
||||
return (_ptr_base<T, lvl, AT2>&)addr;
|
||||
}
|
||||
|
||||
AT addr() const
|
||||
{
|
||||
|
@ -92,6 +91,8 @@ namespace vm
|
|||
{
|
||||
return (_ptr_base&)addr;
|
||||
}
|
||||
|
||||
_ptr_base& operator = (const _ptr_base& right) = default;
|
||||
};
|
||||
|
||||
template<typename T, typename AT>
|
||||
|
@ -100,16 +101,11 @@ namespace vm
|
|||
AT m_addr;
|
||||
|
||||
public:
|
||||
__forceinline T* const operator -> ()
|
||||
__forceinline T* const operator -> () const
|
||||
{
|
||||
return vm::get_ptr<T>(m_addr);
|
||||
}
|
||||
|
||||
__forceinline const T* const operator -> () const
|
||||
{
|
||||
return vm::get_ptr<const T>(m_addr);
|
||||
}
|
||||
|
||||
_ptr_base operator++ (int)
|
||||
{
|
||||
AT result = m_addr;
|
||||
|
@ -158,25 +154,15 @@ namespace vm
|
|||
return make(m_addr - count * sizeof(T));
|
||||
}
|
||||
|
||||
__forceinline T& operator *()
|
||||
__forceinline T& operator *() const
|
||||
{
|
||||
return get_ref<T>(m_addr);
|
||||
}
|
||||
|
||||
__forceinline const T& operator *() const
|
||||
{
|
||||
return get_ref<T>(m_addr);
|
||||
}
|
||||
|
||||
__forceinline T& operator [](int index)
|
||||
__forceinline T& operator [](int index) const
|
||||
{
|
||||
return get_ref<T>(m_addr + sizeof(T) * index);
|
||||
}
|
||||
|
||||
__forceinline const T& operator [](int index) const
|
||||
{
|
||||
return get_ref<const T>(m_addr + sizeof(T) * index);
|
||||
}
|
||||
|
||||
/*
|
||||
operator _ref_base<T, AT>()
|
||||
|
@ -200,6 +186,15 @@ namespace vm
|
|||
return m_addr != 0;
|
||||
}
|
||||
|
||||
//typedef typename invert_be_t<AT>::type AT2;
|
||||
|
||||
template<typename AT2>
|
||||
operator const _ptr_base<T, 1, AT2>() const
|
||||
{
|
||||
typename std::remove_const<AT2>::type addr; addr = m_addr;
|
||||
return (_ptr_base<T, 1, AT2>&)addr;
|
||||
}
|
||||
|
||||
T* const get_ptr() const
|
||||
{
|
||||
return vm::get_ptr<T>(m_addr);
|
||||
|
@ -209,6 +204,8 @@ namespace vm
|
|||
{
|
||||
return (_ptr_base&)addr;
|
||||
}
|
||||
|
||||
_ptr_base& operator = (const _ptr_base& right) = default;
|
||||
};
|
||||
|
||||
template<typename AT>
|
||||
|
@ -232,10 +229,21 @@ namespace vm
|
|||
return m_addr != 0;
|
||||
}
|
||||
|
||||
//typedef typename invert_be_t<AT>::type AT2;
|
||||
|
||||
template<typename AT2>
|
||||
operator const _ptr_base<void, 1, AT2>() const
|
||||
{
|
||||
typename std::remove_const<AT2>::type addr; addr = m_addr;
|
||||
return (_ptr_base<void, 1, AT2>&)addr;
|
||||
}
|
||||
|
||||
static _ptr_base make(AT addr)
|
||||
{
|
||||
return (_ptr_base&)addr;
|
||||
}
|
||||
|
||||
_ptr_base& operator = (const _ptr_base& right) = default;
|
||||
};
|
||||
|
||||
template<typename AT>
|
||||
|
@ -259,10 +267,21 @@ namespace vm
|
|||
return m_addr != 0;
|
||||
}
|
||||
|
||||
//typedef typename invert_be_t<AT>::type AT2;
|
||||
|
||||
template<typename AT2>
|
||||
operator const _ptr_base<const void, 1, AT2>() const
|
||||
{
|
||||
typename std::remove_const<AT2>::type addr; addr = m_addr;
|
||||
return (_ptr_base<const void, 1, AT2>&)addr;
|
||||
}
|
||||
|
||||
static _ptr_base make(AT addr)
|
||||
{
|
||||
return (_ptr_base&)addr;
|
||||
}
|
||||
|
||||
_ptr_base& operator = (const _ptr_base& right) = default;
|
||||
};
|
||||
|
||||
template<typename RT, typename AT>
|
||||
|
@ -304,6 +323,15 @@ namespace vm
|
|||
return m_addr != 0;
|
||||
}
|
||||
|
||||
//typedef typename invert_be_t<AT>::type AT2;
|
||||
|
||||
template<typename AT2>
|
||||
operator const _ptr_base<RT(*)(), 1, AT2>() const
|
||||
{
|
||||
typename std::remove_const<AT2>::type addr; addr = m_addr;
|
||||
return (_ptr_base<RT(*)(), 1, AT2>&)addr;
|
||||
}
|
||||
|
||||
static _ptr_base make(AT addr)
|
||||
{
|
||||
return (_ptr_base&)addr;
|
||||
|
@ -314,6 +342,8 @@ namespace vm
|
|||
const AT addr = m_addr;
|
||||
return [addr]() -> RT { return make(addr)(); };
|
||||
}
|
||||
|
||||
_ptr_base& operator = (const _ptr_base& right) = default;
|
||||
};
|
||||
|
||||
template<typename AT, typename RT, typename ...T>
|
||||
|
@ -371,16 +401,27 @@ namespace vm
|
|||
return m_addr != 0;
|
||||
}
|
||||
|
||||
//typedef typename invert_be_t<AT>::type AT2;
|
||||
|
||||
template<typename AT2>
|
||||
operator const _ptr_base<RT(*)(T...), 1, AT2>() const
|
||||
{
|
||||
typename std::remove_const<AT2>::type addr; addr = m_addr;
|
||||
return (_ptr_base<RT(*)(T...), 1, AT2>&)addr;
|
||||
}
|
||||
|
||||
static _ptr_base make(AT addr)
|
||||
{
|
||||
return (_ptr_base&)addr;
|
||||
}
|
||||
|
||||
operator std::function<RT(T...)>() const
|
||||
operator const std::function<RT(T...)>() const
|
||||
{
|
||||
const AT addr = m_addr;
|
||||
typename std::remove_const<AT>::type addr; addr = m_addr;
|
||||
return [addr](T... args) -> RT { return make(addr)(args...); };
|
||||
}
|
||||
|
||||
_ptr_base& operator = (const _ptr_base& right) = default;
|
||||
};
|
||||
|
||||
//BE pointer to LE data
|
||||
|
@ -392,6 +433,7 @@ namespace vm
|
|||
}
|
||||
|
||||
using _ptr_base<T, lvl, typename to_be_t<AT>::type>::operator=;
|
||||
//using _ptr_base<T, lvl, typename to_be_t<AT>::type>::operator const _ptr_base<T, lvl, AT>;
|
||||
};
|
||||
|
||||
//BE pointer to BE data
|
||||
|
@ -403,6 +445,7 @@ namespace vm
|
|||
}
|
||||
|
||||
using _ptr_base<typename to_be_t<T>::type, lvl, typename to_be_t<AT>::type>::operator=;
|
||||
//using _ptr_base<typename to_be_t<T>::type, lvl, typename to_be_t<AT>::type>::operator const _ptr_base<typename to_be_t<T>::type, lvl, AT>;
|
||||
};
|
||||
|
||||
//LE pointer to BE data
|
||||
|
@ -414,6 +457,7 @@ namespace vm
|
|||
}
|
||||
|
||||
using _ptr_base<typename to_be_t<T>::type, lvl, AT>::operator=;
|
||||
//using _ptr_base<typename to_be_t<T>::type, lvl, AT>::operator const _ptr_base<typename to_be_t<T>::type, lvl, typename to_be_t<AT>::type>;
|
||||
};
|
||||
|
||||
//LE pointer to LE data
|
||||
|
@ -425,6 +469,7 @@ namespace vm
|
|||
}
|
||||
|
||||
using _ptr_base<T, lvl, AT>::operator=;
|
||||
//using _ptr_base<T, lvl, AT>::operator const _ptr_base<T, lvl, typename to_be_t<AT>::type>;
|
||||
};
|
||||
|
||||
namespace ps3
|
||||
|
@ -438,6 +483,7 @@ namespace vm
|
|||
}
|
||||
|
||||
using lptrb<T, lvl, AT>::operator=;
|
||||
//using lptrb<T, lvl, AT>::operator const _ptr_base<typename to_be_t<T>::type, lvl, AT>;
|
||||
};
|
||||
|
||||
//default pointer for HLE structures (BE ptrerence to BE data)
|
||||
|
@ -449,6 +495,7 @@ namespace vm
|
|||
}
|
||||
|
||||
using bptrb<T, lvl, AT>::operator=;
|
||||
//using bptrb<T, lvl, AT>::operator const _ptr_base<typename to_be_t<T>::type, lvl, AT>;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -106,10 +106,15 @@ namespace vm
|
|||
}
|
||||
*/
|
||||
|
||||
template<typename AT> operator ps3::ptr<T, 1, AT>() const
|
||||
template<typename AT> operator const ps3::ptr<T, 1, AT>() const
|
||||
{
|
||||
return ps3::ptr<T, 1, AT>::make(m_addr);
|
||||
}
|
||||
|
||||
template<typename AT> operator const ps3::ptr<const T, 1, AT>() const
|
||||
{
|
||||
return ps3::ptr<const T, 1, AT>::make(m_addr);
|
||||
}
|
||||
|
||||
operator T&()
|
||||
{
|
||||
|
|
|
@ -116,7 +116,7 @@ void GLTexture::Init(RSXTexture& tex)
|
|||
int format = tex.GetFormat() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
|
||||
bool is_swizzled = !(tex.GetFormat() & CELL_GCM_TEXTURE_LN);
|
||||
|
||||
const u8 *pixels = const_cast<const u8 *>(Memory.GetMemFromAddr(texaddr));
|
||||
auto pixels = vm::get_ptr<const u8>(texaddr);
|
||||
u8 *unswizzledPixels;
|
||||
static const GLint glRemapStandard[4] = { GL_ALPHA, GL_RED, GL_GREEN, GL_BLUE };
|
||||
// NOTE: This must be in ARGB order in all forms below.
|
||||
|
@ -1201,6 +1201,8 @@ void GLGSRender::WriteDepthBuffer()
|
|||
LOG_WARNING(RSX, "Bad depth buffer address: address=0x%x, offset=0x%x, dma=0x%x", address, m_surface_offset_z, m_context_dma_z);
|
||||
return;
|
||||
}
|
||||
|
||||
auto ptr = vm::get_ptr<void>(address);
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, g_pbo[4]);
|
||||
checkForGlError("WriteDepthBuffer(): glBindBuffer");
|
||||
glReadPixels(0, 0, RSXThread::m_width, RSXThread::m_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
|
||||
|
@ -1208,7 +1210,7 @@ void GLGSRender::WriteDepthBuffer()
|
|||
GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
||||
if (packed)
|
||||
{
|
||||
memcpy(&Memory[address], packed, RSXThread::m_width * RSXThread::m_height * 4);
|
||||
memcpy(ptr, packed, RSXThread::m_width * RSXThread::m_height * 4);
|
||||
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
checkForGlError("WriteDepthBuffer(): glUnmapBuffer");
|
||||
}
|
||||
|
@ -1217,9 +1219,9 @@ void GLGSRender::WriteDepthBuffer()
|
|||
|
||||
checkForGlError("WriteDepthBuffer(): glReadPixels");
|
||||
glBindTexture(GL_TEXTURE_2D, g_depth_tex);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, RSXThread::m_width, RSXThread::m_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &Memory[address]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, RSXThread::m_width, RSXThread::m_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, ptr);
|
||||
checkForGlError("WriteDepthBuffer(): glTexImage2D");
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &Memory[address]);
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ptr);
|
||||
checkForGlError("WriteDepthBuffer(): glGetTexImage");
|
||||
}
|
||||
|
||||
|
@ -1246,7 +1248,7 @@ void GLGSRender::WriteColorBufferA()
|
|||
GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
||||
if (packed)
|
||||
{
|
||||
memcpy(&Memory[address], packed, RSXThread::m_width * RSXThread::m_height * 4);
|
||||
memcpy(vm::get_ptr<void>(address), packed, RSXThread::m_width * RSXThread::m_height * 4);
|
||||
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
checkForGlError("WriteColorBufferA(): glUnmapBuffer");
|
||||
}
|
||||
|
@ -1277,7 +1279,7 @@ void GLGSRender::WriteColorBufferB()
|
|||
GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
||||
if (packed)
|
||||
{
|
||||
memcpy(&Memory[address], packed, RSXThread::m_width * RSXThread::m_height * 4);
|
||||
memcpy(vm::get_ptr<void>(address), packed, RSXThread::m_width * RSXThread::m_height * 4);
|
||||
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
checkForGlError("WriteColorBufferB(): glUnmapBuffer");
|
||||
}
|
||||
|
@ -1308,7 +1310,7 @@ void GLGSRender::WriteColorBufferC()
|
|||
GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
||||
if (packed)
|
||||
{
|
||||
memcpy(&Memory[address], packed, RSXThread::m_width * RSXThread::m_height * 4);
|
||||
memcpy(vm::get_ptr<void>(address), packed, RSXThread::m_width * RSXThread::m_height * 4);
|
||||
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
checkForGlError("WriteColorBufferC(): glUnmapBuffer");
|
||||
}
|
||||
|
@ -1339,7 +1341,7 @@ void GLGSRender::WriteColorBufferD()
|
|||
GLubyte *packed = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
||||
if (packed)
|
||||
{
|
||||
memcpy(&Memory[address], packed, RSXThread::m_width * RSXThread::m_height * 4);
|
||||
memcpy(vm::get_ptr<void>(address), packed, RSXThread::m_width * RSXThread::m_height * 4);
|
||||
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
checkForGlError("WriteColorBufferD(): glUnmapBuffer");
|
||||
}
|
||||
|
@ -2005,14 +2007,14 @@ void GLGSRender::Flip()
|
|||
if (m_read_buffer)
|
||||
{
|
||||
format = GL_BGRA;
|
||||
CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(m_gcm_buffers_addr);
|
||||
CellGcmDisplayInfo* buffers = vm::get_ptr<CellGcmDisplayInfo>(m_gcm_buffers_addr);
|
||||
u32 addr = GetAddress(buffers[m_gcm_current_buffer].offset, CELL_GCM_LOCATION_LOCAL);
|
||||
|
||||
if (Memory.IsGoodAddr(addr))
|
||||
{
|
||||
width = buffers[m_gcm_current_buffer].width;
|
||||
height = buffers[m_gcm_current_buffer].height;
|
||||
src_buffer = (u8*)Memory.VirtualToRealAddr(addr);
|
||||
src_buffer = vm::get_ptr<u8>(addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ int GLProgramBuffer::SearchFp(const RSXShaderProgram& rsx_fp, GLShaderProgram& g
|
|||
{
|
||||
for(u32 i=0; i<m_buf.size(); ++i)
|
||||
{
|
||||
if(memcmp(&m_buf[i].fp_data[0], &Memory[rsx_fp.addr], m_buf[i].fp_data.size()) != 0) continue;
|
||||
if(memcmp(&m_buf[i].fp_data[0], vm::get_ptr<void>(rsx_fp.addr), m_buf[i].fp_data.size()) != 0) continue;
|
||||
|
||||
gl_fp.SetId(m_buf[i].fp_id);
|
||||
gl_fp.SetShaderText(m_buf[i].fp_shader);
|
||||
|
@ -104,7 +104,7 @@ void GLProgramBuffer::Add(GLProgram& prog, GLShaderProgram& gl_fp, RSXShaderProg
|
|||
new_buf.vp_id = gl_vp.id;
|
||||
new_buf.fp_id = gl_fp.GetId();
|
||||
|
||||
new_buf.fp_data.insert(new_buf.fp_data.end(),&Memory[rsx_fp.addr], &Memory[rsx_fp.addr] + rsx_fp.size);
|
||||
new_buf.fp_data.insert(new_buf.fp_data.end(), vm::get_ptr<u8>(rsx_fp.addr), vm::get_ptr<u8>(rsx_fp.addr + rsx_fp.size));
|
||||
new_buf.vp_data = rsx_vp.data;
|
||||
|
||||
new_buf.vp_shader = gl_vp.shader;
|
||||
|
|
|
@ -41,7 +41,7 @@ void RSXThread::nativeRescale(float width, float height)
|
|||
}
|
||||
}
|
||||
|
||||
u32 GetAddress(u32 offset, u8 location)
|
||||
u32 GetAddress(u32 offset, u32 location)
|
||||
{
|
||||
switch(location)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ void RSXVertexData::Load(u32 start, u32 count, u32 baseOffset, u32 baseIndex=0)
|
|||
|
||||
for(u32 i=start; i<start + count; ++i)
|
||||
{
|
||||
const u8* src = Memory.GetMemFromAddr(addr) + baseOffset + stride * (i+baseIndex);
|
||||
auto src = vm::get_ptr<const u8>(addr + baseOffset + stride * (i + baseIndex));
|
||||
u8* dst = &data[i * tsize * size];
|
||||
|
||||
switch(tsize)
|
||||
|
@ -99,7 +99,7 @@ void RSXVertexData::Load(u32 start, u32 count, u32 baseOffset, u32 baseIndex=0)
|
|||
{
|
||||
const u16* c_src = (const u16*)src;
|
||||
u16* c_dst = (u16*)dst;
|
||||
for(u32 j=0; j<size; ++j) *c_dst++ = re(*c_src++);
|
||||
for(u32 j=0; j<size; ++j) *c_dst++ = re16(*c_src++);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -107,7 +107,7 @@ void RSXVertexData::Load(u32 start, u32 count, u32 baseOffset, u32 baseIndex=0)
|
|||
{
|
||||
const u32* c_src = (const u32*)src;
|
||||
u32* c_dst = (u32*)dst;
|
||||
for(u32 j=0; j<size; ++j) *c_dst++ = re(*c_src++);
|
||||
for(u32 j=0; j<size; ++j) *c_dst++ = re32(*c_src++);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1341,7 +1341,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
|
|||
case 2: m_surface_pitch_a = ARGS(1);
|
||||
}
|
||||
|
||||
CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(m_gcm_buffers_addr);
|
||||
auto buffers = vm::get_ptr<CellGcmDisplayInfo>(m_gcm_buffers_addr);
|
||||
m_width = buffers[m_gcm_current_buffer].width;
|
||||
m_height = buffers[m_gcm_current_buffer].height;
|
||||
|
||||
|
@ -1774,11 +1774,11 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
|
|||
|
||||
if (lineCount == 1 && !inPitch && !outPitch && !notify)
|
||||
{
|
||||
memcpy(&Memory[GetAddress(outOffset, 0)], &Memory[GetAddress(inOffset, 0)], lineLength);
|
||||
memcpy(vm::get_ptr<void>(GetAddress(outOffset, 0)), vm::get_ptr<void>(GetAddress(inOffset, 0)), lineLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING(RSX, "NV0039_OFFSET_IN: TODO: offset(in=0x%x, out=0x%x), pitch(in=0x%x, out=0x%x), line(len=0x%x, cnt=0x%x), fmt(in=0x%x, out=0x%x), notify=0x%x",
|
||||
LOG_ERROR(RSX, "NV0039_OFFSET_IN: TODO: offset(in=0x%x, out=0x%x), pitch(in=0x%x, out=0x%x), line(len=0x%x, cnt=0x%x), fmt(in=0x%x, out=0x%x), notify=0x%x",
|
||||
inOffset, outOffset, inPitch, outPitch, lineLength, lineCount, inFormat, outFormat, notify);
|
||||
}
|
||||
}
|
||||
|
@ -1793,7 +1793,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
|
|||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING(RSX, "NV0039_OFFSET_OUT: TODO: offset=0x%x", offset);
|
||||
LOG_ERROR(RSX, "NV0039_OFFSET_OUT: TODO: offset=0x%x", offset);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1933,8 +1933,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
|
|||
u16 u = ARGS(3);
|
||||
u16 v = ARGS(3) >> 16;
|
||||
|
||||
u8* pixels_src = &Memory[GetAddress(offset, m_context_dma_img_src - 0xfeed0000)];
|
||||
u8* pixels_dst = &Memory[GetAddress(m_dst_offset, m_context_dma_img_dst - 0xfeed0000)];
|
||||
u8* pixels_src = vm::get_ptr<u8>(GetAddress(offset, m_context_dma_img_src - 0xfeed0000));
|
||||
u8* pixels_dst = vm::get_ptr<u8>(GetAddress(m_dst_offset, m_context_dma_img_dst - 0xfeed0000));
|
||||
|
||||
for(u16 y=0; y<m_color_conv_in_h; ++y)
|
||||
{
|
||||
|
@ -2168,8 +2168,8 @@ void RSXThread::Task()
|
|||
|
||||
u32 put, get;
|
||||
// this code produces only mov + bswap:
|
||||
se_t<u32>::func(put, std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, put))));
|
||||
se_t<u32>::func(get, std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, get))));
|
||||
put = se_t<u32>::func(std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, put))));
|
||||
get = se_t<u32>::func(std::atomic_load((volatile std::atomic<u32>*)((u8*)m_ctrl + offsetof(CellGcmControl, get))));
|
||||
/*
|
||||
se_t<u32>::func(put, InterlockedCompareExchange((volatile unsigned long*)((u8*)m_ctrl + offsetof(CellGcmControl, put)), 0, 0));
|
||||
se_t<u32>::func(get, InterlockedCompareExchange((volatile unsigned long*)((u8*)m_ctrl + offsetof(CellGcmControl, get)), 0, 0));
|
||||
|
@ -2269,7 +2269,7 @@ void RSXThread::Task()
|
|||
|
||||
void RSXThread::Init(const u32 ioAddress, const u32 ioSize, const u32 ctrlAddress, const u32 localAddress)
|
||||
{
|
||||
m_ctrl = (CellGcmControl*)&Memory[ctrlAddress];
|
||||
m_ctrl = vm::get_ptr<CellGcmControl>(ctrlAddress);
|
||||
m_ioAddress = ioAddress;
|
||||
m_ioSize = ioSize;
|
||||
m_ctrlAddress = ctrlAddress;
|
||||
|
|
|
@ -18,7 +18,7 @@ enum Method
|
|||
};
|
||||
|
||||
extern u32 methodRegisters[0xffff];
|
||||
u32 GetAddress(u32 offset, u8 location);
|
||||
u32 GetAddress(u32 offset, u32 location);
|
||||
|
||||
struct RSXVertexData
|
||||
{
|
||||
|
|
|
@ -160,7 +160,7 @@ struct CellVideoOutDisplayMode
|
|||
u8 conversion;
|
||||
u8 aspect;
|
||||
u8 reserved[2];
|
||||
u16 refreshRates;
|
||||
be_t<u16> refreshRates;
|
||||
};
|
||||
|
||||
struct CellVideoOutResolution
|
||||
|
@ -197,7 +197,12 @@ struct CellVideoOutConfiguration
|
|||
u8 format;
|
||||
u8 aspect;
|
||||
u8 reserved[9];
|
||||
u32 pitch;
|
||||
be_t<u32> pitch;
|
||||
};
|
||||
|
||||
struct CellVideoOutOption
|
||||
{
|
||||
be_t<u32> reserved;
|
||||
};
|
||||
|
||||
enum CellVideoOutEvent
|
||||
|
|
|
@ -155,8 +155,8 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], cons
|
|||
op.mask = ops[i] >> 32;
|
||||
op.crc = (u32)ops[i];
|
||||
if (op.mask) op.crc &= op.mask;
|
||||
op.mask = re(op.mask);
|
||||
op.crc = re(op.crc);
|
||||
op.mask = re32(op.mask);
|
||||
op.crc = re32(op.crc);
|
||||
sf->ops.push_back(op);
|
||||
}
|
||||
PushNewFuncSub(sf);
|
||||
|
|
|
@ -116,7 +116,7 @@ next:
|
|||
break;
|
||||
case adecDecodeAu:
|
||||
{
|
||||
memcpy(buf, Memory + adec.reader.addr, adec.reader.size);
|
||||
memcpy(buf, vm::get_ptr<void>(adec.reader.addr), adec.reader.size);
|
||||
|
||||
buf += adec.reader.size;
|
||||
buf_size -= adec.reader.size;
|
||||
|
@ -149,7 +149,7 @@ next:
|
|||
}
|
||||
else
|
||||
{
|
||||
memcpy(buf, Memory + adec.reader.addr, buf_size);
|
||||
memcpy(buf, vm::get_ptr<void>(adec.reader.addr), buf_size);
|
||||
|
||||
adec.reader.addr += buf_size;
|
||||
adec.reader.size -= buf_size;
|
||||
|
@ -724,9 +724,9 @@ int cellAdecDecodeAu(u32 handle, vm::ptr<CellAdecAuInfo> auInfo)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellAdecGetPcm(u32 handle, u32 outBuffer_addr)
|
||||
int cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
|
||||
{
|
||||
cellAdec->Log("cellAdecGetPcm(handle=%d, outBuffer_addr=0x%x)", handle, outBuffer_addr);
|
||||
cellAdec->Log("cellAdecGetPcm(handle=%d, outBuffer_addr=0x%x)", handle, outBuffer.addr());
|
||||
|
||||
AudioDecoder* adec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, adec))
|
||||
|
@ -752,11 +752,10 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr)
|
|||
float* in_f[2];
|
||||
in_f[0] = (float*)frame->extended_data[0];
|
||||
in_f[1] = (float*)frame->extended_data[1];
|
||||
be_t<float>* out_f = (be_t<float>*)Memory.GetMemFromAddr(outBuffer_addr);
|
||||
for (u32 i = 0; i < af.size / 8; i++)
|
||||
{
|
||||
out_f[i*2] = in_f[0][i];
|
||||
out_f[i*2+1] = in_f[1][i];
|
||||
outBuffer[i * 2 + 0] = in_f[0][i];
|
||||
outBuffer[i * 2 + 1] = in_f[1][i];
|
||||
}
|
||||
|
||||
if (af.data)
|
||||
|
|
|
@ -40,9 +40,9 @@ int cellAudioInit()
|
|||
|
||||
// alloc memory
|
||||
m_config.m_buffer = (u32)Memory.Alloc(128 * 1024 * m_config.AUDIO_PORT_COUNT, 1024);
|
||||
memset(Memory + m_config.m_buffer, 0, 128 * 1024 * m_config.AUDIO_PORT_COUNT);
|
||||
memset(vm::get_ptr<void>(m_config.m_buffer), 0, 128 * 1024 * m_config.AUDIO_PORT_COUNT);
|
||||
m_config.m_indexes = (u32)Memory.Alloc(sizeof(u64) * m_config.AUDIO_PORT_COUNT, 16);
|
||||
memset(Memory + m_config.m_indexes, 0, sizeof(u64) * m_config.AUDIO_PORT_COUNT);
|
||||
memset(vm::get_ptr<void>(m_config.m_indexes), 0, sizeof(u64) * m_config.AUDIO_PORT_COUNT);
|
||||
|
||||
thread t("Audio Thread", []()
|
||||
{
|
||||
|
@ -175,7 +175,7 @@ int cellAudioInit()
|
|||
const u32 position = port.tag % port.block; // old value
|
||||
const u32 buf_addr = m_config.m_buffer + (i * 128 * 1024) + (position * block_size * sizeof(float));
|
||||
|
||||
auto buf = (be_t<float>*)&Memory[buf_addr];
|
||||
auto buf = vm::get_ptr<be_t<float>>(buf_addr);
|
||||
|
||||
static const float k = 1.0f; // may be 1.0f
|
||||
const float m = port.level;
|
||||
|
|
|
@ -156,7 +156,7 @@ void ElementaryStream::push(DemuxerStream& stream, u32 sz, PesHeader& pes)
|
|||
|
||||
u32 data_addr = put + 128 + size;
|
||||
size += sz;
|
||||
memcpy(Memory + data_addr, Memory + stream.addr, sz);
|
||||
memcpy(vm::get_ptr<void>(data_addr), vm::get_ptr<void>(stream.addr), sz);
|
||||
stream.skip(sz);
|
||||
|
||||
auto info = vm::ptr<CellDmuxAuInfoEx>::make(put);
|
||||
|
@ -276,7 +276,7 @@ void dmuxQueryAttr(u32 info_addr /* may be 0 */, vm::ptr<CellDmuxAttr> attr)
|
|||
attr->memSize = 0x10000; // 0x3e8e6 from ps3
|
||||
}
|
||||
|
||||
void dmuxQueryEsAttr(u32 info_addr /* may be 0 */, const vm::ptr<CellCodecEsFilterId> esFilterId,
|
||||
void dmuxQueryEsAttr(u32 info_addr /* may be 0 */, vm::ptr<const CellCodecEsFilterId> esFilterId,
|
||||
const u32 esSpecificInfo_addr, vm::ptr<CellDmuxEsAttr> attr)
|
||||
{
|
||||
if (esFilterId->filterIdMajor >= 0xe0)
|
||||
|
@ -713,7 +713,7 @@ u32 dmuxOpen(Demuxer* data)
|
|||
return dmux_id;
|
||||
}
|
||||
|
||||
int cellDmuxQueryAttr(const vm::ptr<CellDmuxType> demuxerType, vm::ptr<CellDmuxAttr> demuxerAttr)
|
||||
int cellDmuxQueryAttr(vm::ptr<const CellDmuxType> demuxerType, vm::ptr<CellDmuxAttr> demuxerAttr)
|
||||
{
|
||||
cellDmux->Warning("cellDmuxQueryAttr(demuxerType_addr=0x%x, demuxerAttr_addr=0x%x)", demuxerType.addr(), demuxerAttr.addr());
|
||||
|
||||
|
@ -726,7 +726,7 @@ int cellDmuxQueryAttr(const vm::ptr<CellDmuxType> demuxerType, vm::ptr<CellDmuxA
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellDmuxQueryAttr2(const vm::ptr<CellDmuxType2> demuxerType2, vm::ptr<CellDmuxAttr> demuxerAttr)
|
||||
int cellDmuxQueryAttr2(vm::ptr<const CellDmuxType2> demuxerType2, vm::ptr<CellDmuxAttr> demuxerAttr)
|
||||
{
|
||||
cellDmux->Warning("cellDmuxQueryAttr2(demuxerType2_addr=0x%x, demuxerAttr_addr=0x%x)", demuxerType2.addr(), demuxerAttr.addr());
|
||||
|
||||
|
@ -739,8 +739,8 @@ int cellDmuxQueryAttr2(const vm::ptr<CellDmuxType2> demuxerType2, vm::ptr<CellDm
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellDmuxOpen(const vm::ptr<CellDmuxType> demuxerType, const vm::ptr<CellDmuxResource> demuxerResource,
|
||||
const vm::ptr<CellDmuxCb> demuxerCb, vm::ptr<be_t<u32>> demuxerHandle)
|
||||
int cellDmuxOpen(vm::ptr<const CellDmuxType> demuxerType, vm::ptr<const CellDmuxResource> demuxerResource,
|
||||
vm::ptr<const CellDmuxCb> demuxerCb, vm::ptr<be_t<u32>> demuxerHandle)
|
||||
{
|
||||
cellDmux->Warning("cellDmuxOpen(demuxerType_addr=0x%x, demuxerResource_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)",
|
||||
demuxerType.addr(), demuxerResource.addr(), demuxerCb.addr(), demuxerHandle.addr());
|
||||
|
@ -757,8 +757,8 @@ int cellDmuxOpen(const vm::ptr<CellDmuxType> demuxerType, const vm::ptr<CellDmux
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellDmuxOpenEx(const vm::ptr<CellDmuxType> demuxerType, const vm::ptr<CellDmuxResourceEx> demuxerResourceEx,
|
||||
const vm::ptr<CellDmuxCb> demuxerCb, vm::ptr<be_t<u32>> demuxerHandle)
|
||||
int cellDmuxOpenEx(vm::ptr<const CellDmuxType> demuxerType, vm::ptr<const CellDmuxResourceEx> demuxerResourceEx,
|
||||
vm::ptr<const CellDmuxCb> demuxerCb, vm::ptr<be_t<u32>> demuxerHandle)
|
||||
{
|
||||
cellDmux->Warning("cellDmuxOpenEx(demuxerType_addr=0x%x, demuxerResourceEx_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)",
|
||||
demuxerType.addr(), demuxerResourceEx.addr(), demuxerCb.addr(), demuxerHandle.addr());
|
||||
|
@ -775,8 +775,8 @@ int cellDmuxOpenEx(const vm::ptr<CellDmuxType> demuxerType, const vm::ptr<CellDm
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellDmuxOpen2(const vm::ptr<CellDmuxType2> demuxerType2, const vm::ptr<CellDmuxResource2> demuxerResource2,
|
||||
const vm::ptr<CellDmuxCb> demuxerCb, vm::ptr<be_t<u32>> demuxerHandle)
|
||||
int cellDmuxOpen2(vm::ptr<const CellDmuxType2> demuxerType2, vm::ptr<const CellDmuxResource2> demuxerResource2,
|
||||
vm::ptr<const CellDmuxCb> demuxerCb, vm::ptr<be_t<u32>> demuxerHandle)
|
||||
{
|
||||
cellDmux->Warning("cellDmuxOpen2(demuxerType2_addr=0x%x, demuxerResource2_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)",
|
||||
demuxerType2.addr(), demuxerResource2.addr(), demuxerCb.addr(), demuxerHandle.addr());
|
||||
|
@ -907,7 +907,7 @@ int cellDmuxResetStreamAndWaitDone(u32 demuxerHandle)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellDmuxQueryEsAttr(const vm::ptr<CellDmuxType> demuxerType, const vm::ptr<CellCodecEsFilterId> esFilterId,
|
||||
int cellDmuxQueryEsAttr(vm::ptr<const CellDmuxType> demuxerType, vm::ptr<const CellCodecEsFilterId> esFilterId,
|
||||
const u32 esSpecificInfo_addr, vm::ptr<CellDmuxEsAttr> esAttr)
|
||||
{
|
||||
cellDmux->Warning("cellDmuxQueryEsAttr(demuxerType_addr=0x%x, esFilterId_addr=0x%x, esSpecificInfo_addr=0x%x, esAttr_addr=0x%x)",
|
||||
|
@ -924,7 +924,7 @@ int cellDmuxQueryEsAttr(const vm::ptr<CellDmuxType> demuxerType, const vm::ptr<C
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellDmuxQueryEsAttr2(const vm::ptr<CellDmuxType2> demuxerType2, const vm::ptr<CellCodecEsFilterId> esFilterId,
|
||||
int cellDmuxQueryEsAttr2(vm::ptr<const CellDmuxType2> demuxerType2, vm::ptr<const CellCodecEsFilterId> esFilterId,
|
||||
const u32 esSpecificInfo_addr, vm::ptr<CellDmuxEsAttr> esAttr)
|
||||
{
|
||||
cellDmux->Warning("cellDmuxQueryEsAttr2(demuxerType2_addr=0x%x, esFilterId_addr=0x%x, esSpecificInfo_addr=0x%x, esAttr_addr=0x%x)",
|
||||
|
@ -941,8 +941,8 @@ int cellDmuxQueryEsAttr2(const vm::ptr<CellDmuxType2> demuxerType2, const vm::pt
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellDmuxEnableEs(u32 demuxerHandle, const vm::ptr<CellCodecEsFilterId> esFilterId,
|
||||
const vm::ptr<CellDmuxEsResource> esResourceInfo, const vm::ptr<CellDmuxEsCb> esCb,
|
||||
int cellDmuxEnableEs(u32 demuxerHandle, vm::ptr<const CellCodecEsFilterId> esFilterId,
|
||||
vm::ptr<const CellDmuxEsResource> esResourceInfo, vm::ptr<const CellDmuxEsCb> esCb,
|
||||
const u32 esSpecificInfo_addr, vm::ptr<be_t<u32>> esHandle)
|
||||
{
|
||||
cellDmux->Warning("cellDmuxEnableEs(demuxerHandle=%d, esFilterId_addr=0x%x, esResourceInfo_addr=0x%x, esCb_addr=0x%x, "
|
||||
|
|
|
@ -316,7 +316,7 @@ struct DemuxerStream
|
|||
{
|
||||
if (sizeof(T) > size) return false;
|
||||
|
||||
out = *(T*)Memory.VirtualToRealAddr(addr);
|
||||
out = vm::get_ref<T>(addr);
|
||||
addr += sizeof(T);
|
||||
size -= sizeof(T);
|
||||
|
||||
|
@ -328,7 +328,7 @@ struct DemuxerStream
|
|||
{
|
||||
if (sizeof(T) + shift > size) return false;
|
||||
|
||||
out = *(T*)Memory.VirtualToRealAddr(addr + shift);
|
||||
out = vm::get_ref<T>(addr + shift);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ int cellFontOpenFontMemory(vm::ptr<CellFontLibrary> library, u32 fontAddr, u32 f
|
|||
|
||||
font->stbfont = (stbtt_fontinfo*)((u8*)&(font->stbfont) + sizeof(void*)); // hack: use next bytes of the struct
|
||||
|
||||
if (!stbtt_InitFont(font->stbfont, (unsigned char*)Memory.VirtualToRealAddr(fontAddr), 0))
|
||||
if (!stbtt_InitFont(font->stbfont, vm::get_ptr<unsigned char>(fontAddr), 0))
|
||||
return CELL_FONT_ERROR_FONT_OPEN_FAILED;
|
||||
|
||||
font->renderer_addr = 0;
|
||||
|
@ -99,7 +99,7 @@ int cellFontOpenFontFile(vm::ptr<CellFontLibrary> library, vm::ptr<const char> f
|
|||
|
||||
u32 fileSize = (u32)f.GetSize();
|
||||
u32 bufferAddr = (u32)Memory.Alloc(fileSize, 1); // Freed in cellFontCloseFont
|
||||
f.Read(Memory.VirtualToRealAddr(bufferAddr), fileSize);
|
||||
f.Read(vm::get_ptr<void>(bufferAddr), fileSize);
|
||||
int ret = cellFontOpenFontMemory(library, bufferAddr, fileSize, subNum, uniqueId, font);
|
||||
font->origin = CELL_FONT_OPEN_FONT_FILE;
|
||||
return ret;
|
||||
|
@ -181,8 +181,8 @@ int cellFontOpenFontset(vm::ptr<CellFontLibrary> library, vm::ptr<CellFontType>
|
|||
return CELL_FONT_ERROR_NO_SUPPORT_FONTSET;
|
||||
}
|
||||
|
||||
vm::var<const char> f((u32)file.length() + 1, 1);
|
||||
Memory.WriteString(f.addr(), file);
|
||||
vm::var<char> f((u32)file.length() + 1, 1);
|
||||
memcpy(f.get_ptr(), file.c_str(), file.size() + 1);
|
||||
int ret = cellFontOpenFontFile(library, f, 0, 0, font); //TODO: Find the correct values of subNum, uniqueId
|
||||
font->origin = CELL_FONT_OPEN_FONTSET;
|
||||
return ret;
|
||||
|
@ -345,7 +345,7 @@ int cellFontRenderCharGlyphImage(vm::ptr<CellFont> font, u32 code, vm::ptr<CellF
|
|||
baseLineY = (int)((float)ascent * scale); // ???
|
||||
|
||||
// Move the rendered character to the surface
|
||||
unsigned char* buffer = (unsigned char*)Memory.VirtualToRealAddr(surface->buffer_addr);
|
||||
unsigned char* buffer = vm::get_ptr<unsigned char>(surface->buffer_addr);
|
||||
for (u32 ypos = 0; ypos < (u32)height; ypos++){
|
||||
if ((u32)y + ypos + yoff + baseLineY >= surface->height)
|
||||
break;
|
||||
|
|
|
@ -16,7 +16,7 @@ Module *cellGame = nullptr;
|
|||
std::string contentInfo = "";
|
||||
std::string usrdir = "";
|
||||
|
||||
int cellGameBootCheck(vm::ptr<be_t<u32>> type, vm::ptr<be_t<u32>> attributes, vm::ptr<CellGameContentSize> size, vm::ptr<char> dirName)
|
||||
int cellGameBootCheck(vm::ptr<be_t<u32>> type, vm::ptr<be_t<u32>> attributes, vm::ptr<CellGameContentSize> size, vm::ptr<char[CELL_GAME_DIRNAME_SIZE]> dirName)
|
||||
{
|
||||
cellGame->Warning("cellGameBootCheck(type_addr=0x%x, attributes_addr=0x%x, size_addr=0x%x, dirName_addr=0x%x)",
|
||||
type.addr(), attributes.addr(), size.addr(), dirName.addr());
|
||||
|
@ -50,7 +50,7 @@ int cellGameBootCheck(vm::ptr<be_t<u32>> type, vm::ptr<be_t<u32>> attributes, vm
|
|||
{
|
||||
*type = CELL_GAME_GAMETYPE_DISC;
|
||||
*attributes = 0; // TODO
|
||||
if (dirName) Memory.WriteString(dirName.addr(), ""); // ???
|
||||
if (dirName) strcpy_trunc(*dirName, ""); // ???
|
||||
contentInfo = "/dev_bdvd/PS3_GAME";
|
||||
usrdir = "/dev_bdvd/PS3_GAME/USRDIR";
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ int cellGameBootCheck(vm::ptr<be_t<u32>> type, vm::ptr<be_t<u32>> attributes, vm
|
|||
std::string titleId = psf.GetString("TITLE_ID");
|
||||
*type = CELL_GAME_GAMETYPE_HDD;
|
||||
*attributes = 0; // TODO
|
||||
if (dirName) Memory.WriteString(dirName.addr(), titleId);
|
||||
if (dirName) strcpy_trunc(*dirName, titleId);
|
||||
contentInfo = "/dev_hdd0/game/" + titleId;
|
||||
usrdir = "/dev_hdd0/game/" + titleId + "/USRDIR";
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ int cellGameBootCheck(vm::ptr<be_t<u32>> type, vm::ptr<be_t<u32>> attributes, vm
|
|||
std::string titleId = psf.GetString("TITLE_ID");
|
||||
*type = CELL_GAME_GAMETYPE_DISC;
|
||||
*attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO
|
||||
if (dirName) Memory.WriteString(dirName.addr(), titleId); // ???
|
||||
if (dirName) strcpy_trunc(*dirName, titleId); // ???
|
||||
contentInfo = "/dev_bdvd/PS3_GAME";
|
||||
usrdir = "/dev_bdvd/PS3_GAME/USRDIR";
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ int cellGameDataCheck(u32 type, vm::ptr<const char> dirName, vm::ptr<CellGameCon
|
|||
return CELL_GAME_RET_OK;
|
||||
}
|
||||
|
||||
int cellGameContentPermit(vm::ptr<char> contentInfoPath, vm::ptr<char> usrdirPath)
|
||||
int cellGameContentPermit(vm::ptr<char[CELL_GAME_PATH_MAX]> contentInfoPath, vm::ptr<char[CELL_GAME_PATH_MAX]> usrdirPath)
|
||||
{
|
||||
cellGame->Warning("cellGameContentPermit(contentInfoPath_addr=0x%x, usrdirPath_addr=0x%x)",
|
||||
contentInfoPath.addr(), usrdirPath.addr());
|
||||
|
@ -189,8 +189,8 @@ int cellGameContentPermit(vm::ptr<char> contentInfoPath, vm::ptr<char> usrdirPat
|
|||
}
|
||||
|
||||
// TODO: make it better
|
||||
Memory.WriteString(contentInfoPath.addr(), contentInfo);
|
||||
Memory.WriteString(usrdirPath.addr(), usrdir);
|
||||
strcpy_trunc(*contentInfoPath, contentInfo);
|
||||
strcpy_trunc(*usrdirPath, usrdir);
|
||||
|
||||
contentInfo = "";
|
||||
usrdir = "";
|
||||
|
@ -350,9 +350,9 @@ int cellGameGetParamInt(u32 id, vm::ptr<be_t<u32>> value)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellGameGetParamString(u32 id, u32 buf_addr, u32 bufsize)
|
||||
int cellGameGetParamString(u32 id, vm::ptr<char> buf, u32 bufsize)
|
||||
{
|
||||
cellGame->Warning("cellGameGetParamString(id=%d, buf_addr=0x%x, bufsize=%d)", id, buf_addr, bufsize);
|
||||
cellGame->Warning("cellGameGetParamString(id=%d, buf_addr=0x%x, bufsize=%d)", id, buf.addr(), bufsize);
|
||||
|
||||
// TODO: Access through cellGame***Check functions
|
||||
vfsFile f("/app_home/PARAM.SFO");
|
||||
|
@ -393,8 +393,8 @@ int cellGameGetParamString(u32 id, u32 buf_addr, u32 bufsize)
|
|||
return CELL_GAME_ERROR_INVALID_ID;
|
||||
}
|
||||
|
||||
data.resize(bufsize-1);
|
||||
Memory.WriteString(buf_addr, data.c_str());
|
||||
if (data.size() >= bufsize) data.resize(bufsize - 1);
|
||||
memcpy(buf.get_ptr(), data.c_str(), data.size() + 1);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -422,18 +422,11 @@ int cellGameGetLocalWebContentPath()
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, u32 dirName_addr)
|
||||
int cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::ptr<const char> dirName)
|
||||
{
|
||||
cellGame->Warning("cellGameContentErrorDialog(type=%d, errNeedSizeKB=%d, dirName_addr=0x%x)", type, errNeedSizeKB, dirName_addr);
|
||||
cellGame->Warning("cellGameContentErrorDialog(type=%d, errNeedSizeKB=%d, dirName_addr=0x%x)", type, errNeedSizeKB, dirName.addr());
|
||||
|
||||
std::string errorName;
|
||||
std::string errorMsg;
|
||||
char* dirName = "Unknown";
|
||||
|
||||
if (type == CELL_GAME_ERRDIALOG_NOSPACE || type == CELL_GAME_ERRDIALOG_NOSPACE_EXIT && dirName_addr)
|
||||
{
|
||||
dirName = (char*)Memory.VirtualToRealAddr(dirName_addr);
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CELL_GAME_ERRDIALOG_BROKEN_GAMEDATA: errorName = "Game data is corrupted (can be continued)."; break;
|
||||
|
@ -445,15 +438,21 @@ int cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, u32 dirName_addr)
|
|||
default: return CELL_GAME_ERROR_PARAM;
|
||||
}
|
||||
|
||||
std::string errorMsg;
|
||||
if (type == CELL_GAME_ERRDIALOG_NOSPACE || type == CELL_GAME_ERRDIALOG_NOSPACE_EXIT)
|
||||
{
|
||||
errorMsg = fmt::Format("ERROR: %s\nSpace needed: %d KB\nDirectory name: %s", errorName.c_str(), errNeedSizeKB, dirName);
|
||||
errorMsg = fmt::Format("ERROR: %s\nSpace needed: %d KB", errorName.c_str(), errNeedSizeKB, dirName);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMsg = fmt::Format("ERROR: %s", errorName.c_str());
|
||||
}
|
||||
|
||||
if (dirName)
|
||||
{
|
||||
errorMsg += fmt::Format("\nDirectory name: %s", dirName.get_ptr());
|
||||
}
|
||||
|
||||
rMessageBox(errorMsg, "Error", rICON_ERROR | rOK);
|
||||
|
||||
return CELL_OK;
|
||||
|
|
|
@ -68,8 +68,8 @@ void InitOffsetTable()
|
|||
offsetTable.ioAddress = (u32)Memory.Alloc(3072 * sizeof(u16), 1);
|
||||
offsetTable.eaAddress = (u32)Memory.Alloc(512 * sizeof(u16), 1);
|
||||
|
||||
_sys_memset(offsetTable.ioAddress, 0xFF, 3072 * sizeof(u16));
|
||||
_sys_memset(offsetTable.eaAddress, 0xFF, 512 * sizeof(u16));
|
||||
memset(vm::get_ptr<void>(offsetTable.ioAddress), 0xFF, 3072 * sizeof(u16));
|
||||
memset(vm::get_ptr<void>(offsetTable.eaAddress), 0xFF, 512 * sizeof(u16));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -377,10 +377,10 @@ s32 _cellGcmInitBody(vm::ptr<CellGcmContextData> context, u32 cmdSize, u32 ioSiz
|
|||
gcm_info.context_addr = (u32)Memory.MainMem.AllocAlign(0x1000);
|
||||
gcm_info.control_addr = gcm_info.context_addr + 0x40;
|
||||
|
||||
Memory.WriteData(gcm_info.context_addr, current_context);
|
||||
vm::get_ref<CellGcmContextData>(gcm_info.context_addr) = current_context;
|
||||
Memory.Write32(context.addr(), gcm_info.context_addr);
|
||||
|
||||
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
|
||||
auto& ctrl = vm::get_ref<CellGcmControl>(gcm_info.control_addr);
|
||||
ctrl.put = 0;
|
||||
ctrl.get = 0;
|
||||
ctrl.ref = -1;
|
||||
|
@ -434,7 +434,7 @@ int cellGcmSetDisplayBuffer(u32 id, u32 offset, u32 pitch, u32 width, u32 height
|
|||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(Emu.GetGSManager().GetRender().m_gcm_buffers_addr);
|
||||
auto buffers = vm::get_ptr<CellGcmDisplayInfo>(Emu.GetGSManager().GetRender().m_gcm_buffers_addr);
|
||||
|
||||
buffers[id].offset = offset;
|
||||
buffers[id].pitch = pitch;
|
||||
|
@ -510,11 +510,11 @@ s32 cellGcmSetPrepareFlip(vm::ptr<CellGcmContextData> ctxt, u32 id)
|
|||
//cellGcmCallback(ctxt.addr(), current + 8 - end);
|
||||
//copied:
|
||||
|
||||
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
|
||||
auto& ctrl = vm::get_ref<CellGcmControl>(gcm_info.control_addr);
|
||||
|
||||
const s32 res = ctxt->current - ctxt->begin - ctrl.put;
|
||||
|
||||
memmove(Memory + ctxt->begin, Memory + (ctxt->current - res), res);
|
||||
memmove(vm::get_ptr<void>(ctxt->begin), vm::get_ptr<void>(ctxt->current - res), res);
|
||||
|
||||
ctxt->current = ctxt->begin + res;
|
||||
|
||||
|
@ -530,7 +530,7 @@ s32 cellGcmSetPrepareFlip(vm::ptr<CellGcmContextData> ctxt, u32 id)
|
|||
|
||||
if(ctxt.addr() == gcm_info.context_addr)
|
||||
{
|
||||
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
|
||||
auto& ctrl = vm::get_ref<CellGcmControl>(gcm_info.control_addr);
|
||||
ctrl.put += 8;
|
||||
}
|
||||
|
||||
|
@ -591,8 +591,8 @@ int cellGcmSetTileInfo(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u
|
|||
tile.m_comp = comp;
|
||||
tile.m_base = base;
|
||||
tile.m_bank = bank;
|
||||
Memory.WriteData(Emu.GetGSManager().GetRender().m_tiles_addr + sizeof(CellGcmTileInfo)* index, tile.Pack());
|
||||
|
||||
vm::get_ptr<CellGcmTileInfo>(Emu.GetGSManager().GetRender().m_tiles_addr)[index] = tile.Pack();
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -642,8 +642,7 @@ int cellGcmSetZcull(u8 index, u32 offset, u32 width, u32 height, u32 cullStart,
|
|||
zcull.m_sRef = sRef;
|
||||
zcull.m_sMask = sMask;
|
||||
|
||||
Memory.WriteData(Emu.GetGSManager().GetRender().m_zculls_addr + sizeof(CellGcmZcullInfo)* index, zcull.Pack());
|
||||
|
||||
vm::get_ptr<CellGcmZcullInfo>(Emu.GetGSManager().GetRender().m_zculls_addr)[index] = zcull.Pack();
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -1149,8 +1148,8 @@ int cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 co
|
|||
tile.m_comp = comp;
|
||||
tile.m_base = base;
|
||||
tile.m_bank = bank;
|
||||
Memory.WriteData(Emu.GetGSManager().GetRender().m_tiles_addr + sizeof(CellGcmTileInfo) * index, tile.Pack());
|
||||
|
||||
vm::get_ptr<CellGcmTileInfo>(Emu.GetGSManager().GetRender().m_tiles_addr)[index] = tile.Pack();
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -1165,12 +1164,12 @@ int cellGcmCallback(u32 context_addr, u32 count)
|
|||
|
||||
GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH);
|
||||
|
||||
CellGcmContextData& ctx = (CellGcmContextData&)Memory[context_addr];
|
||||
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
|
||||
auto& ctx = vm::get_ref<CellGcmContextData>(context_addr);
|
||||
auto& ctrl = vm::get_ref<CellGcmControl>(gcm_info.control_addr);
|
||||
|
||||
const s32 res = ctx.current - ctx.begin - ctrl.put;
|
||||
|
||||
memmove(Memory + ctx.begin, Memory + (ctx.current - res), res);
|
||||
memmove(vm::get_ptr<void>(ctx.begin), vm::get_ptr<void>(ctx.current - res), res);
|
||||
|
||||
ctx.current = ctx.begin + res;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ int cellGifDecExtCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam, u
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellGifDecOpen(u32 mainHandle, vm::ptr<be_t<u32>> subHandle, const vm::ptr<CellGifDecSrc> src, vm::ptr<CellGifDecOpnInfo> openInfo)
|
||||
int cellGifDecOpen(u32 mainHandle, vm::ptr<be_t<u32>> subHandle, vm::ptr<CellGifDecSrc> src, vm::ptr<CellGifDecOpnInfo> openInfo)
|
||||
{
|
||||
cellGifDec->Warning("cellGifDecOpen(mainHandle=0x%x, subHandle_addr=0x%x, src_addr=0x%x, openInfo_addr=0x%x)",
|
||||
mainHandle, subHandle.addr(), src.addr(), openInfo.addr());
|
||||
|
@ -41,7 +41,7 @@ int cellGifDecOpen(u32 mainHandle, vm::ptr<be_t<u32>> subHandle, const vm::ptr<C
|
|||
case se32(CELL_GIFDEC_FILE):
|
||||
// Get file descriptor
|
||||
vm::var<be_t<u32>> fd;
|
||||
int ret = cellFsOpen(src->fileName, 0, fd, vm::ptr<be_t<u32>>::make(0), 0);
|
||||
int ret = cellFsOpen(vm::ptr<const char>::make(src->fileName.addr()), 0, fd, vm::ptr<be_t<u32>>::make(0), 0);
|
||||
current_subHandle->fd = fd->ToLE();
|
||||
if (ret != CELL_OK) return CELL_GIFDEC_ERROR_OPEN_FILE;
|
||||
|
||||
|
@ -79,12 +79,12 @@ int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellGifDecInfo>
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_GIFDEC_BUFFER):
|
||||
memmove(Memory + buffer.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.size());
|
||||
memmove(buffer.begin(), vm::get_ptr<void>(subHandle_data->src.streamPtr), buffer.size());
|
||||
break;
|
||||
|
||||
case se32(CELL_GIFDEC_FILE):
|
||||
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
|
||||
cellFsRead(fd, buffer.addr(), buffer.size(), nread);
|
||||
cellFsRead(fd, vm::ptr<void>::make(buffer.addr()), buffer.size(), nread);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellGifDecInfo>
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellGifDecSetParameter(u32 mainHandle, u32 subHandle, const vm::ptr<CellGifDecInParam> inParam, vm::ptr<CellGifDecOutParam> outParam)
|
||||
int cellGifDecSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellGifDecInParam> inParam, vm::ptr<CellGifDecOutParam> outParam)
|
||||
{
|
||||
cellGifDec->Warning("cellGifDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x)",
|
||||
mainHandle, subHandle, inParam.addr(), outParam.addr());
|
||||
|
@ -139,7 +139,7 @@ int cellGifDecSetParameter(u32 mainHandle, u32 subHandle, const vm::ptr<CellGifD
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const vm::ptr<CellGifDecDataCtrlParam> dataCtrlParam, vm::ptr<CellGifDecDataOutInfo> dataOutInfo)
|
||||
int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::ptr<const CellGifDecDataCtrlParam> dataCtrlParam, vm::ptr<CellGifDecDataOutInfo> dataOutInfo)
|
||||
{
|
||||
cellGifDec->Warning("cellGifDecDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x)",
|
||||
mainHandle, subHandle, data.addr(), dataCtrlParam.addr(), dataOutInfo.addr());
|
||||
|
@ -161,12 +161,12 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_GIFDEC_BUFFER):
|
||||
memmove(Memory + gif.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), gif.size());
|
||||
memmove(gif.begin(), vm::get_ptr<void>(subHandle_data->src.streamPtr), gif.size());
|
||||
break;
|
||||
|
||||
case se32(CELL_GIFDEC_FILE):
|
||||
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
|
||||
cellFsRead(fd, gif.addr(), gif.size(), nread);
|
||||
cellFsRead(fd, vm::ptr<void>::make(gif.addr()), gif.size(), nread);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -196,12 +196,12 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const
|
|||
{
|
||||
const int dstOffset = i * bytesPerLine;
|
||||
const int srcOffset = width * nComponents * i;
|
||||
memcpy(Memory + (data.addr() + dstOffset), &image.get()[srcOffset], linesize);
|
||||
memcpy(&data[dstOffset], &image.get()[srcOffset], linesize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(Memory + data.addr(), image.get(), image_size);
|
||||
memcpy(data.get_ptr(), image.get(), image_size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -224,7 +224,7 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const
|
|||
output[j + 2] = image.get()[srcOffset + j + 1];
|
||||
output[j + 3] = image.get()[srcOffset + j + 2];
|
||||
}
|
||||
memcpy(Memory + (data.addr() + dstOffset), output, linesize);
|
||||
memcpy(&data[dstOffset], output, linesize);
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ struct CellGifDecInfo
|
|||
struct CellGifDecSrc
|
||||
{
|
||||
be_t<u32> srcSelect;
|
||||
be_t<u32> fileName;
|
||||
vm::bptr<const char> fileName;
|
||||
be_t<s64> fileOffset;
|
||||
be_t<u64> fileSize;
|
||||
be_t<u32> streamPtr;
|
||||
|
|
|
@ -47,7 +47,7 @@ int cellJpgDecOpen(u32 mainHandle, vm::ptr<be_t<u32>> subHandle, vm::ptr<CellJpg
|
|||
case se32(CELL_JPGDEC_FILE):
|
||||
// Get file descriptor
|
||||
vm::var<be_t<u32>> fd;
|
||||
int ret = cellFsOpen(src->fileName, 0, fd, vm::ptr<be_t<u32>>::make(0), 0);
|
||||
int ret = cellFsOpen(vm::ptr<const char>::make(src->fileName.addr()), 0, fd, vm::ptr<be_t<u32>>::make(0), 0);
|
||||
current_subHandle->fd = fd->ToLE();
|
||||
if (ret != CELL_OK) return CELL_JPGDEC_ERROR_OPEN_FILE;
|
||||
|
||||
|
@ -99,12 +99,12 @@ int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDecInfo>
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_JPGDEC_BUFFER):
|
||||
memmove(Memory + buffer.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.size());
|
||||
memmove(buffer.begin(), vm::get_ptr<void>(subHandle_data->src.streamPtr), buffer.size());
|
||||
break;
|
||||
|
||||
case se32(CELL_JPGDEC_FILE):
|
||||
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
|
||||
cellFsRead(fd, buffer.addr(), buffer.size(), nread);
|
||||
cellFsRead(fd, vm::ptr<void>::make(buffer.addr()), buffer.size(), nread);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDecInfo>
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const vm::ptr<CellJpgDecDataCtrlParam> dataCtrlParam, vm::ptr<CellJpgDecDataOutInfo> dataOutInfo)
|
||||
int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::ptr<const CellJpgDecDataCtrlParam> dataCtrlParam, vm::ptr<CellJpgDecDataOutInfo> dataOutInfo)
|
||||
{
|
||||
cellJpgDec->Log("cellJpgDecDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x)",
|
||||
mainHandle, subHandle, data.addr(), dataCtrlParam.addr(), dataOutInfo.addr());
|
||||
|
@ -168,12 +168,12 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_JPGDEC_BUFFER):
|
||||
memmove(Memory + jpg.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), jpg.size());
|
||||
memmove(jpg.begin(), vm::get_ptr<void>(subHandle_data->src.streamPtr), jpg.size());
|
||||
break;
|
||||
|
||||
case se32(CELL_JPGDEC_FILE):
|
||||
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
|
||||
cellFsRead(fd, jpg.addr(), jpg.size(), nread);
|
||||
cellFsRead(fd, vm::ptr<void>::make(jpg.addr()), jpg.size(), nread);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -206,12 +206,12 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const
|
|||
{
|
||||
const int dstOffset = i * bytesPerLine;
|
||||
const int srcOffset = width * nComponents * (flip ? height - i - 1 : i);
|
||||
memcpy(Memory + (data.addr() + dstOffset), &image.get()[srcOffset], linesize);
|
||||
memcpy(&data[dstOffset], &image.get()[srcOffset], linesize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(Memory + data.addr(), image.get(), image_size);
|
||||
memcpy(data.get_ptr(), image.get(), image_size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -236,7 +236,7 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const
|
|||
output[j + 2] = image.get()[srcOffset + j + 1];
|
||||
output[j + 3] = image.get()[srcOffset + j + 2];
|
||||
}
|
||||
memcpy(Memory + (data.addr() + dstOffset), output, linesize);
|
||||
memcpy(&data[dstOffset], output, linesize);
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, const vm::ptr<CellJpgDecInParam> inParam, vm::ptr<CellJpgDecOutParam> outParam)
|
||||
int cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellJpgDecInParam> inParam, vm::ptr<CellJpgDecOutParam> outParam)
|
||||
{
|
||||
cellJpgDec->Log("cellJpgDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x)",
|
||||
mainHandle, subHandle, inParam.addr(), outParam.addr());
|
||||
|
|
|
@ -56,7 +56,7 @@ struct CellJpgDecInfo
|
|||
struct CellJpgDecSrc
|
||||
{
|
||||
be_t<u32> srcSelect; // CellJpgDecStreamSrcSel
|
||||
be_t<u32> fileName; // const char*
|
||||
vm::bptr<const char> fileName;
|
||||
be_t<u64> fileOffset; // int64_t
|
||||
be_t<u32> fileSize;
|
||||
be_t<u32> streamPtr;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Emu/SysCalls/Modules.h"
|
||||
|
||||
#include "Emu/Io/Keyboard.h"
|
||||
#include "SC_Keyboard.h"
|
||||
#include "cellKb.h"
|
||||
|
||||
extern Module *sys_io;
|
||||
|
||||
|
@ -163,3 +163,17 @@ int cellKbGetConfiguration(u32 port_no, vm::ptr<CellKbConfig> config)
|
|||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
void cellKb_init()
|
||||
{
|
||||
sys_io->AddFunc(0x433f6ec0, cellKbInit);
|
||||
sys_io->AddFunc(0xbfce3285, cellKbEnd);
|
||||
sys_io->AddFunc(0x2073b7f6, cellKbClearBuf);
|
||||
sys_io->AddFunc(0x4ab1fa77, cellKbCnvRawCode);
|
||||
sys_io->AddFunc(0x2f1774d5, cellKbGetInfo);
|
||||
sys_io->AddFunc(0xff0a21b7, cellKbRead);
|
||||
sys_io->AddFunc(0xa5f85e4d, cellKbSetCodeType);
|
||||
sys_io->AddFunc(0x3f72c56e, cellKbSetLEDStatus);
|
||||
sys_io->AddFunc(0xdeefdfa7, cellKbSetReadMode);
|
||||
sys_io->AddFunc(0x1f71ecbe, cellKbGetConfiguration);
|
||||
}
|
|
@ -36,7 +36,7 @@ int UTF16stoUTF8s(vm::lptrl<const char16_t> utf16, vm::ptr<be_t<u32>> utf16_len,
|
|||
}
|
||||
|
||||
*utf8_len = str.size();
|
||||
Memory.WriteString(utf8.addr(), str);
|
||||
memcpy(utf8.get_ptr(), str.c_str(), str.size());
|
||||
#endif
|
||||
return ConversionOK;
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ int L10nConvertStr(int src_code, vm::ptr<const void> src, vm::ptr<be_t<u32>> src
|
|||
|
||||
if (target.length() > *dst_len) return DSTExhausted;
|
||||
|
||||
Memory.WriteString(dst.addr(), target);
|
||||
memcpy(dst.get_ptr(), target.c_str(), target.size());
|
||||
|
||||
return ConversionOK;
|
||||
#else
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Emu/SysCalls/Modules.h"
|
||||
|
||||
#include "Emu/Io/Mouse.h"
|
||||
#include "SC_Mouse.h"
|
||||
#include "cellMouse.h"
|
||||
|
||||
extern Module *sys_io;
|
||||
|
||||
|
@ -128,3 +128,17 @@ int cellMouseGetRawData(u32 port_no, u32 data_addr)
|
|||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
void cellMouse_init()
|
||||
{
|
||||
sys_io->AddFunc(0xc9030138, cellMouseInit);
|
||||
sys_io->AddFunc(0x3ef66b95, cellMouseClearBuf);
|
||||
sys_io->AddFunc(0xe10183ce, cellMouseEnd);
|
||||
sys_io->AddFunc(0x5baf30fb, cellMouseGetInfo);
|
||||
sys_io->AddFunc(0x4d0b3b1f, cellMouseInfoTabletMode);
|
||||
sys_io->AddFunc(0x3138e632, cellMouseGetData);
|
||||
sys_io->AddFunc(0x6bd131f0, cellMouseGetDataList);
|
||||
sys_io->AddFunc(0x2d16da4f, cellMouseSetTabletMode);
|
||||
sys_io->AddFunc(0x21a62e9b, cellMouseGetTabletDataList);
|
||||
sys_io->AddFunc(0xa328cc35, cellMouseGetRawData);
|
||||
}
|
|
@ -4,55 +4,10 @@
|
|||
#include "Emu/SysCalls/Modules.h"
|
||||
|
||||
#include "Emu/Io/Pad.h"
|
||||
#include "cellPad.h"
|
||||
|
||||
extern Module *sys_io;
|
||||
|
||||
enum CELL_PAD_ERROR_CODE
|
||||
{
|
||||
CELL_PAD_ERROR_FATAL = 0x80121101,
|
||||
CELL_PAD_ERROR_INVALID_PARAMETER = 0x80121102,
|
||||
CELL_PAD_ERROR_ALREADY_INITIALIZED = 0x80121103,
|
||||
CELL_PAD_ERROR_UNINITIALIZED = 0x80121104,
|
||||
CELL_PAD_ERROR_RESOURCE_ALLOCATION_FAILED = 0x80121105,
|
||||
CELL_PAD_ERROR_DATA_READ_FAILED = 0x80121106,
|
||||
CELL_PAD_ERROR_NO_DEVICE = 0x80121107,
|
||||
CELL_PAD_ERROR_UNSUPPORTED_GAMEPAD = 0x80121108,
|
||||
CELL_PAD_ERROR_TOO_MANY_DEVICES = 0x80121109,
|
||||
CELL_PAD_ERROR_EBUSY = 0x8012110a,
|
||||
};
|
||||
|
||||
struct CellPadData
|
||||
{
|
||||
be_t<s32> len;
|
||||
be_t<u16> button[CELL_PAD_MAX_CODES];
|
||||
};
|
||||
|
||||
struct CellPadInfo
|
||||
{
|
||||
be_t<u32> max_connect;
|
||||
be_t<u32> now_connect;
|
||||
be_t<u32> system_info;
|
||||
be_t<u16> vendor_id[CELL_MAX_PADS];
|
||||
be_t<u16> product_id[CELL_MAX_PADS];
|
||||
u8 status[CELL_MAX_PADS];
|
||||
};
|
||||
|
||||
struct CellPadInfo2
|
||||
{
|
||||
be_t<u32> max_connect;
|
||||
be_t<u32> now_connect;
|
||||
be_t<u32> system_info;
|
||||
be_t<u32> port_status[CELL_PAD_MAX_PORT_NUM];
|
||||
be_t<u32> port_setting[CELL_PAD_MAX_PORT_NUM];
|
||||
be_t<u32> device_capability[CELL_PAD_MAX_PORT_NUM];
|
||||
be_t<u32> device_type[CELL_PAD_MAX_PORT_NUM];
|
||||
};
|
||||
|
||||
struct CellCapabilityInfo
|
||||
{
|
||||
be_t<u32> info[CELL_PAD_MAX_CAPABILITY_INFO];
|
||||
};
|
||||
|
||||
int cellPadInit(u32 max_connect)
|
||||
{
|
||||
sys_io->Warning("cellPadInit(max_connect=%d)", max_connect);
|
||||
|
@ -99,9 +54,10 @@ int cellPadClearBuf(u32 port_no)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellPadGetData(u32 port_no, u32 data_addr)
|
||||
int cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
|
||||
{
|
||||
sys_io->Log("cellPadGetData[port_no: %d, data_addr: 0x%x]", port_no, data_addr);
|
||||
sys_io->Log("cellPadGetData(port_no=%d, data_addr=0x%x)", port_no, data.addr());
|
||||
|
||||
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
||||
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
||||
const PadInfo& rinfo = Emu.GetPadManager().GetInfo();
|
||||
|
@ -110,7 +66,6 @@ int cellPadGetData(u32 port_no, u32 data_addr)
|
|||
if(port_no >= rinfo.now_connect) return CELL_PAD_ERROR_NO_DEVICE;
|
||||
|
||||
Pad& pad = pads[port_no];
|
||||
CellPadData data = {};
|
||||
|
||||
u16 d1Initial, d2Initial;
|
||||
d1Initial = pad.m_digital_1;
|
||||
|
@ -232,7 +187,7 @@ int cellPadGetData(u32 port_no, u32 data_addr)
|
|||
}
|
||||
|
||||
//not sure if this should officially change with capabilities/portsettings :(
|
||||
data.len = CELL_PAD_MAX_CODES;
|
||||
data->len = CELL_PAD_MAX_CODES;
|
||||
|
||||
//report len 0 if nothing changed and if we havent recently cleared buffer
|
||||
if (pad.m_buffer_cleared)
|
||||
|
@ -241,34 +196,32 @@ int cellPadGetData(u32 port_no, u32 data_addr)
|
|||
}
|
||||
else if (!btnChanged)
|
||||
{
|
||||
data.len = 0;
|
||||
data->len = 0;
|
||||
}
|
||||
|
||||
//lets still send new data anyway, not sure whats expected still
|
||||
data.button[CELL_PAD_BTN_OFFSET_DIGITAL1] = pad.m_digital_1;
|
||||
data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] = pad.m_digital_2;
|
||||
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] = pad.m_analog_right_x;
|
||||
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] = pad.m_analog_right_y;
|
||||
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] = pad.m_analog_left_x;
|
||||
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] = pad.m_analog_left_y;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_RIGHT] = pad.m_press_right;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_LEFT] = pad.m_press_left;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_UP] = pad.m_press_up;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_DOWN] = pad.m_press_down;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_TRIANGLE] = pad.m_press_triangle;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_CIRCLE] = pad.m_press_circle;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_CROSS] = pad.m_press_cross;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_SQUARE] = pad.m_press_square;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_L1] = pad.m_press_L1;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_L2] = pad.m_press_L2;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_R1] = pad.m_press_R1;
|
||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_R2] = pad.m_press_R2;
|
||||
data.button[CELL_PAD_BTN_OFFSET_SENSOR_X] = pad.m_sensor_x;
|
||||
data.button[CELL_PAD_BTN_OFFSET_SENSOR_Y] = pad.m_sensor_y;
|
||||
data.button[CELL_PAD_BTN_OFFSET_SENSOR_Z] = pad.m_sensor_z;
|
||||
data.button[CELL_PAD_BTN_OFFSET_SENSOR_G] = pad.m_sensor_g;
|
||||
|
||||
Memory.WriteData(data_addr, data);
|
||||
data->button[CELL_PAD_BTN_OFFSET_DIGITAL1] = pad.m_digital_1;
|
||||
data->button[CELL_PAD_BTN_OFFSET_DIGITAL2] = pad.m_digital_2;
|
||||
data->button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] = pad.m_analog_right_x;
|
||||
data->button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] = pad.m_analog_right_y;
|
||||
data->button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] = pad.m_analog_left_x;
|
||||
data->button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] = pad.m_analog_left_y;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_RIGHT] = pad.m_press_right;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_LEFT] = pad.m_press_left;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_UP] = pad.m_press_up;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_DOWN] = pad.m_press_down;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_TRIANGLE] = pad.m_press_triangle;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_CIRCLE] = pad.m_press_circle;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_CROSS] = pad.m_press_cross;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_SQUARE] = pad.m_press_square;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_L1] = pad.m_press_L1;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_L2] = pad.m_press_L2;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_R1] = pad.m_press_R1;
|
||||
data->button[CELL_PAD_BTN_OFFSET_PRESS_R2] = pad.m_press_R2;
|
||||
data->button[CELL_PAD_BTN_OFFSET_SENSOR_X] = pad.m_sensor_x;
|
||||
data->button[CELL_PAD_BTN_OFFSET_SENSOR_Y] = pad.m_sensor_y;
|
||||
data->button[CELL_PAD_BTN_OFFSET_SENSOR_Z] = pad.m_sensor_z;
|
||||
data->button[CELL_PAD_BTN_OFFSET_SENSOR_G] = pad.m_sensor_g;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -295,17 +248,16 @@ int cellPadSetActDirect(u32 port_no, u32 param_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellPadGetInfo(u32 info_addr)
|
||||
int cellPadGetInfo(vm::ptr<CellPadInfo> info)
|
||||
{
|
||||
sys_io->Log("cellPadGetInfo(info_addr=0x%x)", info_addr);
|
||||
sys_io->Log("cellPadGetInfo(info_addr=0x%x)", info.addr());
|
||||
|
||||
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
||||
|
||||
CellPadInfo info = {};
|
||||
|
||||
const PadInfo& rinfo = Emu.GetPadManager().GetInfo();
|
||||
info.max_connect = rinfo.max_connect;
|
||||
info.now_connect = rinfo.now_connect;
|
||||
info.system_info = rinfo.system_info;
|
||||
info->max_connect = rinfo.max_connect;
|
||||
info->now_connect = rinfo.now_connect;
|
||||
info->system_info = rinfo.system_info;
|
||||
|
||||
//Can't have this as const, we need to reset Assign Changes Flag here
|
||||
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
||||
|
@ -315,30 +267,25 @@ int cellPadGetInfo(u32 info_addr)
|
|||
if(i >= pads.size())
|
||||
break;
|
||||
|
||||
info.status[i] = pads[i].m_port_status;
|
||||
info->status[i] = pads[i].m_port_status;
|
||||
pads[i].m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES;
|
||||
info.product_id[i] = 0x0268;
|
||||
info.vendor_id[i] = 0x054C;
|
||||
info->product_id[i] = 0x0268;
|
||||
info->vendor_id[i] = 0x054C;
|
||||
}
|
||||
|
||||
Memory.WriteData(info_addr, info);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellPadGetInfo2(u32 info_addr)
|
||||
int cellPadGetInfo2(vm::ptr<CellPadInfo2> info)
|
||||
{
|
||||
sys_io->Log("cellPadGetInfo2(info_addr=0x%x)", info_addr);
|
||||
sys_io->Log("cellPadGetInfo2(info_addr=0x%x)", info.addr());
|
||||
|
||||
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
||||
|
||||
CellPadInfo2 info = {};
|
||||
//sys_io->Warning("*** info{}: max_connect=0x%x, now_connect=0x%x, system_info=0x%x, port_status[0]=0x%x, port_setting[0]=0x%x",
|
||||
// (u32)info.max_connect, (u32)info.now_connect, (u32)info.system_info, (u32)info.port_status[0], (u32)info.port_setting[0]);
|
||||
|
||||
const PadInfo& rinfo = Emu.GetPadManager().GetInfo();
|
||||
info.max_connect = rinfo.max_connect;
|
||||
info.now_connect = rinfo.now_connect;
|
||||
info.system_info = rinfo.system_info;
|
||||
info->max_connect = rinfo.max_connect;
|
||||
info->now_connect = rinfo.now_connect;
|
||||
info->system_info = rinfo.system_info;
|
||||
|
||||
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
||||
|
||||
|
@ -347,21 +294,20 @@ int cellPadGetInfo2(u32 info_addr)
|
|||
if(i >= pads.size())
|
||||
break;
|
||||
|
||||
info.port_status[i] = pads[i].m_port_status;
|
||||
info->port_status[i] = pads[i].m_port_status;
|
||||
pads[i].m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES;
|
||||
info.port_setting[i] = pads[i].m_port_setting;
|
||||
info.device_capability[i] = pads[i].m_device_capability;
|
||||
info.device_type[i] = pads[i].m_device_type;
|
||||
info->port_setting[i] = pads[i].m_port_setting;
|
||||
info->device_capability[i] = pads[i].m_device_capability;
|
||||
info->device_type[i] = pads[i].m_device_type;
|
||||
}
|
||||
|
||||
Memory.WriteData(info_addr, info);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellPadGetCapabilityInfo(u32 port_no, vm::ptr<be_t<u32>> info_addr)
|
||||
int cellPadGetCapabilityInfo(u32 port_no, vm::ptr<CellCapabilityInfo> info)
|
||||
{
|
||||
sys_io->Log("cellPadGetCapabilityInfo[port_no: %d, data_addr: 0x%x]", port_no, info_addr.addr());
|
||||
sys_io->Log("cellPadGetCapabilityInfo(port_no=%d, data_addr:=0x%x)", port_no, info.addr());
|
||||
|
||||
if (!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
||||
const PadInfo& rinfo = Emu.GetPadManager().GetInfo();
|
||||
if (port_no >= rinfo.max_connect) return CELL_PAD_ERROR_INVALID_PARAMETER;
|
||||
|
@ -369,12 +315,8 @@ int cellPadGetCapabilityInfo(u32 port_no, vm::ptr<be_t<u32>> info_addr)
|
|||
|
||||
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
||||
|
||||
CellCapabilityInfo data = {};
|
||||
|
||||
//Should return the same as device capability mask, psl1ght has it backwards in pad.h
|
||||
data.info[0] = pads[port_no].m_device_capability;
|
||||
|
||||
Memory.WriteData(info_addr.addr(), data);
|
||||
info->info[0] = pads[port_no].m_device_capability;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -456,3 +398,21 @@ int cellPadSetSensorMode(u32 port_no, u32 mode)
|
|||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
void cellPad_init()
|
||||
{
|
||||
sys_io->AddFunc(0x1cf98800, cellPadInit);
|
||||
sys_io->AddFunc(0x4d9b75d5, cellPadEnd);
|
||||
sys_io->AddFunc(0x0d5f2c14, cellPadClearBuf);
|
||||
sys_io->AddFunc(0x8b72cda1, cellPadGetData);
|
||||
sys_io->AddFunc(0x6bc09c61, cellPadGetDataExtra);
|
||||
sys_io->AddFunc(0xf65544ee, cellPadSetActDirect);
|
||||
sys_io->AddFunc(0x3aaad464, cellPadGetInfo);
|
||||
sys_io->AddFunc(0xa703a51d, cellPadGetInfo2);
|
||||
sys_io->AddFunc(0x578e3c98, cellPadSetPortSetting);
|
||||
sys_io->AddFunc(0x0e2dfaad, cellPadInfoPressMode);
|
||||
sys_io->AddFunc(0x78200559, cellPadInfoSensorMode);
|
||||
sys_io->AddFunc(0xf83f8182, cellPadSetPressMode);
|
||||
sys_io->AddFunc(0xbe5be3ba, cellPadSetSensorMode);
|
||||
sys_io->AddFunc(0xdbf4c59c, cellPadGetCapabilityInfo);
|
||||
}
|
62
rpcs3/Emu/SysCalls/Modules/cellPad.h
Normal file
62
rpcs3/Emu/SysCalls/Modules/cellPad.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
#pragma once
|
||||
|
||||
enum CELL_PAD_ERROR_CODE
|
||||
{
|
||||
CELL_PAD_ERROR_FATAL = 0x80121101,
|
||||
CELL_PAD_ERROR_INVALID_PARAMETER = 0x80121102,
|
||||
CELL_PAD_ERROR_ALREADY_INITIALIZED = 0x80121103,
|
||||
CELL_PAD_ERROR_UNINITIALIZED = 0x80121104,
|
||||
CELL_PAD_ERROR_RESOURCE_ALLOCATION_FAILED = 0x80121105,
|
||||
CELL_PAD_ERROR_DATA_READ_FAILED = 0x80121106,
|
||||
CELL_PAD_ERROR_NO_DEVICE = 0x80121107,
|
||||
CELL_PAD_ERROR_UNSUPPORTED_GAMEPAD = 0x80121108,
|
||||
CELL_PAD_ERROR_TOO_MANY_DEVICES = 0x80121109,
|
||||
CELL_PAD_ERROR_EBUSY = 0x8012110a,
|
||||
};
|
||||
|
||||
struct CellPadData
|
||||
{
|
||||
be_t<s32> len;
|
||||
be_t<u16> button[CELL_PAD_MAX_CODES];
|
||||
};
|
||||
|
||||
struct CellPadInfo
|
||||
{
|
||||
be_t<u32> max_connect;
|
||||
be_t<u32> now_connect;
|
||||
be_t<u32> system_info;
|
||||
be_t<u16> vendor_id[CELL_MAX_PADS];
|
||||
be_t<u16> product_id[CELL_MAX_PADS];
|
||||
u8 status[CELL_MAX_PADS];
|
||||
};
|
||||
|
||||
struct CellPadInfo2
|
||||
{
|
||||
be_t<u32> max_connect;
|
||||
be_t<u32> now_connect;
|
||||
be_t<u32> system_info;
|
||||
be_t<u32> port_status[CELL_PAD_MAX_PORT_NUM];
|
||||
be_t<u32> port_setting[CELL_PAD_MAX_PORT_NUM];
|
||||
be_t<u32> device_capability[CELL_PAD_MAX_PORT_NUM];
|
||||
be_t<u32> device_type[CELL_PAD_MAX_PORT_NUM];
|
||||
};
|
||||
|
||||
struct CellCapabilityInfo
|
||||
{
|
||||
be_t<u32> info[CELL_PAD_MAX_CAPABILITY_INFO];
|
||||
};
|
||||
|
||||
int cellPadInit(u32 max_connect);
|
||||
int cellPadEnd();
|
||||
int cellPadClearBuf(u32 port_no);
|
||||
int cellPadGetData(u32 port_no, vm::ptr<CellPadData> data);
|
||||
int cellPadGetDataExtra(u32 port_no, u32 device_type_addr, u32 data_addr);
|
||||
int cellPadSetActDirect(u32 port_no, u32 param_addr);
|
||||
int cellPadGetInfo(vm::ptr<CellPadInfo> info);
|
||||
int cellPadGetInfo2(vm::ptr<CellPadInfo2> info);
|
||||
int cellPadGetCapabilityInfo(u32 port_no, vm::ptr<CellCapabilityInfo> info);
|
||||
int cellPadSetPortSetting(u32 port_no, u32 port_setting);
|
||||
int cellPadInfoPressMode(u32 port_no);
|
||||
int cellPadInfoSensorMode(u32 port_no);
|
||||
int cellPadSetPressMode(u32 port_no, u32 mode);
|
||||
int cellPadSetSensorMode(u32 port_no, u32 mode);
|
|
@ -77,7 +77,7 @@ int pamfStreamTypeToEsFilterId(u8 type, u8 ch, vm::ptr<CellCodecEsFilterId> pEsF
|
|||
u8 pamfGetStreamType(vm::ptr<CellPamfReader> pSelf, u8 stream)
|
||||
{
|
||||
//TODO: get stream type correctly
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
|
||||
switch (pAddr->stream_headers[stream].type)
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ u8 pamfGetStreamType(vm::ptr<CellPamfReader> pSelf, u8 stream)
|
|||
u8 pamfGetStreamChannel(vm::ptr<CellPamfReader> pSelf, u8 stream)
|
||||
{
|
||||
//TODO: get stream channel correctly
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
|
||||
switch (pAddr->stream_headers[stream].type)
|
||||
{
|
||||
|
@ -169,7 +169,7 @@ int cellPamfVerify(vm::ptr<PamfHeader> pAddr, u64 fileSize)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellPamfReaderInitialize(vm::ptr<CellPamfReader> pSelf, vm::ptr<PamfHeader> pAddr, u64 fileSize, u32 attribute)
|
||||
int cellPamfReaderInitialize(vm::ptr<CellPamfReader> pSelf, vm::ptr<const PamfHeader> pAddr, u64 fileSize, u32 attribute)
|
||||
{
|
||||
cellPamf->Warning("cellPamfReaderInitialize(pSelf=0x%x, pAddr=0x%x, fileSize=%d, attribute=0x%x)", pSelf.addr(), pAddr.addr(), fileSize, attribute);
|
||||
|
||||
|
@ -181,7 +181,6 @@ int cellPamfReaderInitialize(vm::ptr<CellPamfReader> pSelf, vm::ptr<PamfHeader>
|
|||
{
|
||||
pSelf->fileSize = ((u64)pAddr->data_offset << 11) + ((u64)pAddr->data_size << 11);
|
||||
}
|
||||
|
||||
pSelf->pAddr = pAddr;
|
||||
|
||||
if (attribute & CELL_PAMF_ATTRIBUTE_VERIFY_ON)
|
||||
|
@ -197,7 +196,7 @@ int cellPamfReaderGetPresentationStartTime(vm::ptr<CellPamfReader> pSelf, vm::pt
|
|||
{
|
||||
cellPamf->Warning("cellPamfReaderGetPresentationStartTime(pSelf=0x%x, pTimeStamp_addr=0x%x)", pSelf.addr(), pTimeStamp.addr());
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
const u32 upper = (u16)pAddr->start_pts_high;
|
||||
pTimeStamp->upper = upper;
|
||||
pTimeStamp->lower = pAddr->start_pts_low;
|
||||
|
@ -208,7 +207,7 @@ int cellPamfReaderGetPresentationEndTime(vm::ptr<CellPamfReader> pSelf, vm::ptr<
|
|||
{
|
||||
cellPamf->Warning("cellPamfReaderGetPresentationEndTime(pSelf=0x%x, pTimeStamp_addr=0x%x)", pSelf.addr(), pTimeStamp.addr());
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
const u32 upper = (u16)pAddr->end_pts_high;
|
||||
pTimeStamp->upper = upper;
|
||||
pTimeStamp->lower = pAddr->end_pts_low;
|
||||
|
@ -219,7 +218,7 @@ int cellPamfReaderGetMuxRateBound(vm::ptr<CellPamfReader> pSelf)
|
|||
{
|
||||
cellPamf->Warning("cellPamfReaderGetMuxRateBound(pSelf=0x%x)", pSelf.addr());
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
return pAddr->mux_rate_max;
|
||||
}
|
||||
|
||||
|
@ -227,7 +226,7 @@ int cellPamfReaderGetNumberOfStreams(vm::ptr<CellPamfReader> pSelf)
|
|||
{
|
||||
cellPamf->Warning("cellPamfReaderGetNumberOfStreams(pSelf=0x%x)", pSelf.addr());
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
return pAddr->stream_count;
|
||||
}
|
||||
|
||||
|
@ -235,7 +234,7 @@ int cellPamfReaderGetNumberOfSpecificStreams(vm::ptr<CellPamfReader> pSelf, u8 s
|
|||
{
|
||||
cellPamf->Warning("cellPamfReaderGetNumberOfSpecificStreams(pSelf=0x%x, streamType=%d)", pSelf.addr(), streamType);
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
|
||||
int counts[6] = {0, 0, 0, 0, 0, 0};
|
||||
|
||||
|
@ -266,7 +265,7 @@ int cellPamfReaderSetStreamWithIndex(vm::ptr<CellPamfReader> pSelf, u8 streamInd
|
|||
{
|
||||
cellPamf->Warning("cellPamfReaderSetStreamWithIndex(pSelf=0x%x, streamIndex=%d)", pSelf.addr(), streamIndex);
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
|
||||
if (streamIndex < pAddr->stream_count)
|
||||
{
|
||||
|
@ -284,7 +283,7 @@ int cellPamfReaderSetStreamWithTypeAndChannel(vm::ptr<CellPamfReader> pSelf, u8
|
|||
{
|
||||
cellPamf->Warning("cellPamfReaderSetStreamWithTypeAndChannel(pSelf=0x%x, streamType=%d, ch=%d)", pSelf.addr(), streamType, ch);
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
|
||||
if (streamType > 5)
|
||||
{
|
||||
|
@ -312,7 +311,7 @@ int cellPamfReaderSetStreamWithTypeAndIndex(vm::ptr<CellPamfReader> pSelf, u8 st
|
|||
{
|
||||
cellPamf->Warning("cellPamfReaderSetStreamWithTypeAndIndex(pSelf=0x%x, streamType=%d, streamIndex=%d)", pSelf.addr(), streamType, streamIndex);
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
|
||||
u32 found = 0;
|
||||
|
||||
|
@ -389,11 +388,11 @@ int cellPamfReaderGetEsFilterId(vm::ptr<CellPamfReader> pSelf, vm::ptr<CellCodec
|
|||
|
||||
int cellPamfReaderGetStreamInfo(vm::ptr<CellPamfReader> pSelf, u32 pInfo_addr, u32 size)
|
||||
{
|
||||
cellPamf->Warning("cellPamfReaderGetStreamInfo(pSelf=0x%x, stream=%d, pInfo_addr=0x%x, size=%d)", pSelf.addr(), pSelf->stream, pInfo_addr, size);
|
||||
cellPamf->Warning("cellPamfReaderGetStreamInfo(pSelf=0x%x, stream=%d, pInfo_addr=0x%x, size=%d)", pSelf.addr(), pSelf->stream, pInfo_addr, size);
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
|
||||
memset(Memory + pInfo_addr, 0, size);
|
||||
memset(vm::get_ptr<void>(pInfo_addr), 0, size);
|
||||
|
||||
switch (pamfGetStreamType(pSelf, pSelf->stream))
|
||||
{
|
||||
|
@ -498,7 +497,7 @@ int cellPamfReaderGetNumberOfEp(vm::ptr<CellPamfReader> pSelf)
|
|||
{
|
||||
cellPamf->Warning("cellPamfReaderGetNumberOfEp(pSelf=0x%x, stream=%d)", pSelf.addr(), pSelf->stream);
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
return pAddr->stream_headers[pSelf->stream].ep_num;
|
||||
}
|
||||
|
||||
|
@ -506,7 +505,7 @@ int cellPamfReaderGetEpIteratorWithIndex(vm::ptr<CellPamfReader> pSelf, u32 epIn
|
|||
{
|
||||
cellPamf->Todo("cellPamfReaderGetEpIteratorWithIndex(pSelf=0x%x, stream=%d, epIndex=%d, pIt_addr=0x%x)", pSelf.addr(), pSelf->stream, epIndex, pIt.addr());
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
//TODO:
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -515,7 +514,7 @@ int cellPamfReaderGetEpIteratorWithTimeStamp(vm::ptr<CellPamfReader> pSelf, vm::
|
|||
{
|
||||
cellPamf->Todo("cellPamfReaderGetEpIteratorWithTimeStamp(pSelf=0x%x, pTimeStamp_addr=0x%x, pIt_addr=0x%x)", pSelf.addr(), pTimeStamp.addr(), pIt.addr());
|
||||
|
||||
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
|
||||
vm::ptr<const PamfHeader> pAddr(pSelf->pAddr);
|
||||
|
||||
//TODO:
|
||||
|
||||
|
|
|
@ -330,7 +330,7 @@ struct CellPamfReader
|
|||
{
|
||||
//this struct can be used in any way, if it is not accessed directly by virtual CPU
|
||||
//be_t<u64> internalData[16];
|
||||
vm::ptr<PamfHeader> pAddr;
|
||||
vm::ptr<const PamfHeader> pAddr;
|
||||
int stream;
|
||||
u64 fileSize;
|
||||
u32 internalData[28];
|
||||
|
|
|
@ -69,7 +69,7 @@ int cellPngDecOpen(u32 mainHandle, vm::ptr<be_t<u32>> subHandle, vm::ptr<CellPng
|
|||
case se32(CELL_PNGDEC_FILE):
|
||||
// Get file descriptor
|
||||
vm::var<be_t<u32>> fd;
|
||||
int ret = cellFsOpen(src->fileName_addr, 0, fd, vm::ptr<be_t<u32>>::make(0), 0);
|
||||
int ret = cellFsOpen(vm::ptr<const char>::make(src->fileName.addr()), 0, fd, vm::ptr<be_t<u32>>::make(0), 0);
|
||||
current_subHandle->fd = fd->ToLE();
|
||||
if(ret != CELL_OK) return CELL_PNGDEC_ERROR_OPEN_FILE;
|
||||
|
||||
|
@ -140,11 +140,11 @@ int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellPngDecInfo>
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_PNGDEC_BUFFER):
|
||||
memmove(Memory + buffer.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.size());
|
||||
memmove(buffer.begin(), vm::get_ptr<void>(subHandle_data->src.streamPtr), buffer.size());
|
||||
break;
|
||||
case se32(CELL_PNGDEC_FILE):
|
||||
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
|
||||
cellFsRead(fd, buffer.addr(), buffer.size(), nread);
|
||||
cellFsRead(fd, vm::ptr<void>::make(buffer.addr()), buffer.size(), nread);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ int cellPngDecExtReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellPngDecInf
|
|||
return cellPngDecReadHeader(mainHandle, subHandle, info);
|
||||
}
|
||||
|
||||
int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const vm::ptr<CellPngDecDataCtrlParam> dataCtrlParam, vm::ptr<CellPngDecDataOutInfo> dataOutInfo)
|
||||
int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::ptr<const CellPngDecDataCtrlParam> dataCtrlParam, vm::ptr<CellPngDecDataOutInfo> dataOutInfo)
|
||||
{
|
||||
cellPngDec->Warning("cellPngDecDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x)",
|
||||
mainHandle, subHandle, data.addr(), dataCtrlParam.addr(), dataOutInfo.addr());
|
||||
|
@ -205,12 +205,12 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_PNGDEC_BUFFER):
|
||||
memmove(Memory + png.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), png.size());
|
||||
memmove(png.begin(), vm::get_ptr<void>(subHandle_data->src.streamPtr), png.size());
|
||||
break;
|
||||
|
||||
case se32(CELL_PNGDEC_FILE):
|
||||
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
|
||||
cellFsRead(fd, png.addr(), png.size(), nread);
|
||||
cellFsRead(fd, vm::ptr<void>::make(png.addr()), png.size(), nread);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -241,12 +241,12 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const
|
|||
{
|
||||
const int dstOffset = i * bytesPerLine;
|
||||
const int srcOffset = width * nComponents * (flip ? height - i - 1 : i);
|
||||
memcpy(Memory + (data.addr() + dstOffset), &image.get()[srcOffset], linesize);
|
||||
memcpy(&data[dstOffset], &image.get()[srcOffset], linesize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(Memory + data.addr(), image.get(), image_size);
|
||||
memcpy(data.get_ptr(), image.get(), image_size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -271,7 +271,7 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const
|
|||
output[j + 2] = image.get()[srcOffset + j + 1];
|
||||
output[j + 3] = image.get()[srcOffset + j + 2];
|
||||
}
|
||||
memcpy(Memory + (data.addr() + dstOffset), output, linesize);
|
||||
memcpy(&data[dstOffset], output, linesize);
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellPngDecExtDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const vm::ptr<CellPngDecDataCtrlParam> dataCtrlParam,
|
||||
int cellPngDecExtDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::ptr<const CellPngDecDataCtrlParam> dataCtrlParam,
|
||||
vm::ptr<CellPngDecDataOutInfo> dataOutInfo, vm::ptr<CellPngDecCbCtrlDisp> cbCtrlDisp, vm::ptr<CellPngDecDispParam> dispParam)
|
||||
{
|
||||
cellPngDec->Warning("cellPngDecExtDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x, cbCtrlDisp_addr=0x%x, dispParam=0x%x)",
|
||||
|
@ -319,7 +319,7 @@ int cellPngDecExtDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, con
|
|||
return cellPngDecDecodeData(mainHandle, subHandle, data, dataCtrlParam, dataOutInfo);
|
||||
}
|
||||
|
||||
int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, const vm::ptr<CellPngDecInParam> inParam, vm::ptr<CellPngDecOutParam> outParam)
|
||||
int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellPngDecInParam> inParam, vm::ptr<CellPngDecOutParam> outParam)
|
||||
{
|
||||
cellPngDec->Warning("cellPngDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x)",
|
||||
mainHandle, subHandle, inParam.addr(), outParam.addr());
|
||||
|
@ -360,7 +360,7 @@ int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, const vm::ptr<CellPngD
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellPngDecExtSetParameter(u32 mainHandle, u32 subHandle, const vm::ptr<CellPngDecInParam> inParam, vm::ptr<CellPngDecOutParam> outParam,
|
||||
int cellPngDecExtSetParameter(u32 mainHandle, u32 subHandle, vm::ptr<const CellPngDecInParam> inParam, vm::ptr<CellPngDecOutParam> outParam,
|
||||
vm::ptr<CellPngDecExtInParam> extInParam, vm::ptr<CellPngDecExtOutParam> extOutParam)
|
||||
{
|
||||
cellPngDec->Warning("cellPngDecExtSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x, extInParam=0x%x, extOutParam=0x%x",
|
||||
|
|
|
@ -78,7 +78,7 @@ struct CellPngDecInfo
|
|||
struct CellPngDecSrc
|
||||
{
|
||||
be_t<u32> srcSelect; // CellPngDecStreamSrcSel
|
||||
be_t<u32> fileName_addr; // const char*
|
||||
vm::bptr<const char> fileName;
|
||||
be_t<s64> fileOffset;
|
||||
be_t<u32> fileSize;
|
||||
be_t<u32> streamPtr;
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
Module *cellResc = nullptr;
|
||||
|
||||
extern s32 cellVideoOutConfigure(u32 videoOut, vm::ptr<CellVideoOutConfiguration> config, vm::ptr<CellVideoOutOption> option, u32 waitForEvent);
|
||||
|
||||
static const float
|
||||
PICTURE_SIZE = (1.0f),
|
||||
UV_DELTA_PS = (1.f / 8.f),
|
||||
|
@ -732,7 +734,7 @@ int cellRescSetDisplayMode(u32 displayMode)
|
|||
videocfg->aspect = CELL_VIDEO_OUT_ASPECT_AUTO;
|
||||
videocfg->pitch = s_rescInternalInstance->m_dstPitch;
|
||||
|
||||
cellVideoOutConfigure(CELL_VIDEO_OUT_PRIMARY, videocfg.addr(), 0, 0);
|
||||
cellVideoOutConfigure(CELL_VIDEO_OUT_PRIMARY, videocfg, vm::ptr<CellVideoOutOption>::make(0), 0);
|
||||
|
||||
if (IsPalInterpolate())
|
||||
{
|
||||
|
|
|
@ -71,9 +71,9 @@ int cellRtcGetCurrentClockLocalTime(vm::ptr<CellRtcDateTime> pClock)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellRtcFormatRfc2822(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
|
||||
int cellRtcFormatRfc2822(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
|
||||
{
|
||||
cellRtc->Log("cellRtcFormatRfc2822(pszDateTime_addr=0x%x, pUtc=0x%x, time_zone=%d)", pszDateTime_addr, pUtc.addr(), iTimeZone);
|
||||
cellRtc->Log("cellRtcFormatRfc2822(pszDateTime_addr=0x%x, pUtc=0x%x, time_zone=%d)", pszDateTime.addr(), pUtc.addr(), iTimeZone);
|
||||
|
||||
// Add time_zone as offset in minutes.
|
||||
rTimeSpan tz = rTimeSpan(0, (long) iTimeZone, 0, 0);
|
||||
|
@ -84,28 +84,28 @@ int cellRtcFormatRfc2822(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc, s32 iT
|
|||
|
||||
// Format date string in RFC2822 format (e.g.: Mon, 01 Jan 1990 12:00:00 +0000).
|
||||
const std::string& str = date.Format("%a, %d %b %Y %T %z", rDateTime::TZ::UTC);
|
||||
Memory.WriteString(pszDateTime_addr, str);
|
||||
memcpy(pszDateTime.get_ptr(), str.c_str(), str.size() + 1);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellRtcFormatRfc2822LocalTime(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc)
|
||||
int cellRtcFormatRfc2822LocalTime(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc)
|
||||
{
|
||||
cellRtc->Log("cellRtcFormatRfc2822LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime_addr, pUtc.addr());
|
||||
cellRtc->Log("cellRtcFormatRfc2822LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime.addr(), pUtc.addr());
|
||||
|
||||
// Get date from ticks.
|
||||
rDateTime date = rDateTime((time_t)pUtc->tick);
|
||||
|
||||
// Format date string in RFC2822 format (e.g.: Mon, 01 Jan 1990 12:00:00 +0000).
|
||||
const std::string& str = date.Format("%a, %d %b %Y %T %z", rDateTime::TZ::Local);
|
||||
Memory.WriteString(pszDateTime_addr, str);
|
||||
memcpy(pszDateTime.get_ptr(), str.c_str(), str.size() + 1);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellRtcFormatRfc3339(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
|
||||
int cellRtcFormatRfc3339(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
|
||||
{
|
||||
cellRtc->Log("cellRtcFormatRfc3339(pszDateTime_addr=0x%x, pUtc=0x%x, iTimeZone=%d)", pszDateTime_addr, pUtc.addr(), iTimeZone);
|
||||
cellRtc->Log("cellRtcFormatRfc3339(pszDateTime_addr=0x%x, pUtc=0x%x, iTimeZone=%d)", pszDateTime.addr(), pUtc.addr(), iTimeZone);
|
||||
|
||||
// Add time_zone as offset in minutes.
|
||||
rTimeSpan tz = rTimeSpan(0, (long) iTimeZone, 0, 0);
|
||||
|
@ -116,47 +116,45 @@ int cellRtcFormatRfc3339(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc, s32 iT
|
|||
|
||||
// Format date string in RFC3339 format (e.g.: 1990-01-01T12:00:00.00Z).
|
||||
const std::string& str = date.Format("%FT%T.%zZ", rDateTime::TZ::UTC);
|
||||
Memory.WriteString(pszDateTime_addr, str);
|
||||
memcpy(pszDateTime.get_ptr(), str.c_str(), str.size() + 1);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellRtcFormatRfc3339LocalTime(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc)
|
||||
int cellRtcFormatRfc3339LocalTime(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc)
|
||||
{
|
||||
cellRtc->Log("cellRtcFormatRfc3339LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime_addr, pUtc.addr());
|
||||
cellRtc->Log("cellRtcFormatRfc3339LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime.addr(), pUtc.addr());
|
||||
|
||||
// Get date from ticks.
|
||||
rDateTime date = rDateTime((time_t) pUtc->tick);
|
||||
|
||||
// Format date string in RFC3339 format (e.g.: 1990-01-01T12:00:00.00Z).
|
||||
const std::string& str = date.Format("%FT%T.%zZ", rDateTime::TZ::Local);
|
||||
Memory.WriteString(pszDateTime_addr, str);
|
||||
memcpy(pszDateTime.get_ptr(), str.c_str(), str.size() + 1);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellRtcParseDateTime(vm::ptr<CellRtcTick> pUtc, u32 pszDateTime_addr)
|
||||
int cellRtcParseDateTime(vm::ptr<CellRtcTick> pUtc, vm::ptr<const char> pszDateTime)
|
||||
{
|
||||
cellRtc->Log("cellRtcParseDateTime(pUtc=0x%x, pszDateTime_addr=0x%x)", pUtc.addr(), pszDateTime_addr);
|
||||
cellRtc->Log("cellRtcParseDateTime(pUtc=0x%x, pszDateTime_addr=0x%x)", pUtc.addr(), pszDateTime.addr());
|
||||
|
||||
// Get date from formatted string.
|
||||
rDateTime date;
|
||||
const std::string& format = Memory.ReadString(pszDateTime_addr);
|
||||
date.ParseDateTime(format);
|
||||
date.ParseDateTime(pszDateTime.get_ptr());
|
||||
|
||||
pUtc->tick = date.GetTicks();
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellRtcParseRfc3339(vm::ptr<CellRtcTick> pUtc, u32 pszDateTime_addr)
|
||||
int cellRtcParseRfc3339(vm::ptr<CellRtcTick> pUtc, vm::ptr<const char> pszDateTime)
|
||||
{
|
||||
cellRtc->Log("cellRtcParseRfc3339(pUtc=0x%x, pszDateTime_addr=0x%x)", pUtc.addr(), pszDateTime_addr);
|
||||
cellRtc->Log("cellRtcParseRfc3339(pUtc=0x%x, pszDateTime_addr=0x%x)", pUtc.addr(), pszDateTime.addr());
|
||||
|
||||
// Get date from RFC3339 formatted string.
|
||||
rDateTime date;
|
||||
const std::string& format = Memory.ReadString(pszDateTime_addr);
|
||||
date.ParseDateTime(format);
|
||||
date.ParseDateTime(pszDateTime.get_ptr());
|
||||
|
||||
pUtc->tick = date.GetTicks();
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "Emu/FS/vfsFile.h"
|
||||
#include "Emu/FS/vfsDir.h"
|
||||
#include "Loader/PSF.h"
|
||||
#include "cellSysutil_SaveData.h"
|
||||
#include "cellSaveData.h"
|
||||
|
||||
extern Module *cellSysutil;
|
||||
|
||||
|
@ -88,10 +88,10 @@ void addSaveDataEntry(std::vector<SaveDataEntry>& saveEntries, const std::string
|
|||
void addNewSaveDataEntry(std::vector<SaveDataEntry>& saveEntries, vm::ptr<CellSaveDataListNewData> newData)
|
||||
{
|
||||
SaveDataEntry saveEntry;
|
||||
saveEntry.dirName = (char*)Memory.VirtualToRealAddr(newData->dirName_addr);
|
||||
saveEntry.title = (char*)Memory.VirtualToRealAddr(newData->icon->title_addr);
|
||||
saveEntry.subtitle = (char*)Memory.VirtualToRealAddr(newData->icon->title_addr);
|
||||
saveEntry.iconBuf = Memory.VirtualToRealAddr(newData->icon->iconBuf_addr);
|
||||
saveEntry.dirName = newData->dirName.get_ptr();
|
||||
saveEntry.title = newData->icon->title.get_ptr();
|
||||
saveEntry.subtitle = newData->icon->title.get_ptr();
|
||||
saveEntry.iconBuf = newData->icon->iconBuf.get_ptr();
|
||||
saveEntry.iconBufSize = newData->icon->iconBufSize;
|
||||
saveEntry.isNew = true;
|
||||
// TODO: Add information stored in newData->iconPosition. (It's not very relevant)
|
||||
|
@ -131,7 +131,7 @@ void setSaveDataFixed(std::vector<SaveDataEntry>& saveEntries, vm::ptr<CellSaveD
|
|||
std::vector<SaveDataEntry>::iterator entry = saveEntries.begin();
|
||||
while (entry != saveEntries.end())
|
||||
{
|
||||
if (entry->dirName == (char*)Memory.VirtualToRealAddr(fixedSet->dirName_addr))
|
||||
if (entry->dirName == fixedSet->dirName.get_ptr())
|
||||
entry = saveEntries.erase(entry);
|
||||
else
|
||||
entry++;
|
||||
|
@ -140,17 +140,17 @@ void setSaveDataFixed(std::vector<SaveDataEntry>& saveEntries, vm::ptr<CellSaveD
|
|||
if (saveEntries.size() == 0)
|
||||
{
|
||||
SaveDataEntry entry;
|
||||
entry.dirName = (char*)Memory.VirtualToRealAddr(fixedSet->dirName_addr);
|
||||
entry.dirName = fixedSet->dirName.get_ptr();
|
||||
entry.isNew = true;
|
||||
saveEntries.push_back(entry);
|
||||
}
|
||||
|
||||
if (fixedSet->newIcon)
|
||||
{
|
||||
saveEntries[0].iconBuf = Memory.VirtualToRealAddr(fixedSet->newIcon->iconBuf_addr);
|
||||
saveEntries[0].iconBuf = fixedSet->newIcon->iconBuf.get_ptr();
|
||||
saveEntries[0].iconBufSize = fixedSet->newIcon->iconBufSize;
|
||||
saveEntries[0].title = (char*)Memory.VirtualToRealAddr(fixedSet->newIcon->title_addr);
|
||||
saveEntries[0].subtitle = (char*)Memory.VirtualToRealAddr(fixedSet->newIcon->title_addr);
|
||||
saveEntries[0].title = fixedSet->newIcon->title.get_ptr();
|
||||
saveEntries[0].subtitle = fixedSet->newIcon->title.get_ptr();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,13 +168,13 @@ void getSaveDataStat(SaveDataEntry entry, vm::ptr<CellSaveDataStatGet> statGet)
|
|||
statGet->dir.st_atime_ = 0; // TODO ?
|
||||
statGet->dir.st_mtime_ = 0; // TODO ?
|
||||
statGet->dir.st_ctime_ = 0; // TODO ?
|
||||
memcpy(statGet->dir.dirName, entry.dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE);
|
||||
strcpy_trunc(statGet->dir.dirName, entry.dirName);
|
||||
|
||||
statGet->getParam.attribute = 0; // TODO ?
|
||||
memcpy(statGet->getParam.title, entry.title.c_str(), CELL_SAVEDATA_SYSP_TITLE_SIZE);
|
||||
memcpy(statGet->getParam.subTitle, entry.subtitle.c_str(), CELL_SAVEDATA_SYSP_SUBTITLE_SIZE);
|
||||
memcpy(statGet->getParam.detail, entry.details.c_str(), CELL_SAVEDATA_SYSP_DETAIL_SIZE);
|
||||
memcpy(statGet->getParam.listParam, entry.listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
|
||||
strcpy_trunc(statGet->getParam.title, entry.title);
|
||||
strcpy_trunc(statGet->getParam.subTitle, entry.subtitle);
|
||||
strcpy_trunc(statGet->getParam.detail, entry.details);
|
||||
strcpy_trunc(statGet->getParam.listParam, entry.listParam);
|
||||
|
||||
statGet->fileNum = 0;
|
||||
statGet->fileList = vm::bptr<CellSaveDataFileStat>::make(0);
|
||||
|
@ -203,7 +203,7 @@ void getSaveDataStat(SaveDataEntry entry, vm::ptr<CellSaveDataStatGet> statGet)
|
|||
fileEntry.st_atime_ = 0; // TODO ?
|
||||
fileEntry.st_mtime_ = 0; // TODO ?
|
||||
fileEntry.st_ctime_ = 0; // TODO ?
|
||||
memcpy(fileEntry.fileName, dirEntry->name.c_str(), CELL_SAVEDATA_FILENAME_SIZE);
|
||||
strcpy_trunc(fileEntry.fileName, dirEntry->name);
|
||||
|
||||
fileEntries.push_back(fileEntry);
|
||||
}
|
||||
|
@ -236,12 +236,12 @@ s32 modifySaveDataFiles(vm::ptr<CellSaveDataFileCallback> funcFile, vm::ptr<Cell
|
|||
|
||||
std::string filepath = saveDataDir + '/';
|
||||
vfsStream* file = NULL;
|
||||
void* buf = Memory.VirtualToRealAddr(fileSet->fileBuf_addr);
|
||||
void* buf = fileSet->fileBuf.get_ptr();
|
||||
|
||||
switch ((u32)fileSet->fileType)
|
||||
{
|
||||
case CELL_SAVEDATA_FILETYPE_SECUREFILE: filepath += (char*)Memory.VirtualToRealAddr(fileSet->fileName_addr); break;
|
||||
case CELL_SAVEDATA_FILETYPE_NORMALFILE: filepath += (char*)Memory.VirtualToRealAddr(fileSet->fileName_addr); break;
|
||||
case CELL_SAVEDATA_FILETYPE_SECUREFILE: filepath += fileSet->fileName.get_ptr(); break;
|
||||
case CELL_SAVEDATA_FILETYPE_NORMALFILE: filepath += fileSet->fileName.get_ptr(); break;
|
||||
case CELL_SAVEDATA_FILETYPE_CONTENT_ICON0: filepath += "ICON0.PNG"; break;
|
||||
case CELL_SAVEDATA_FILETYPE_CONTENT_ICON1: filepath += "ICON1.PAM"; break;
|
||||
case CELL_SAVEDATA_FILETYPE_CONTENT_PIC1: filepath += "PIC1.PNG"; break;
|
||||
|
@ -289,10 +289,10 @@ s32 modifySaveDataFiles(vm::ptr<CellSaveDataFileCallback> funcFile, vm::ptr<Cell
|
|||
// Functions
|
||||
int cellSaveDataListSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataListCallback> funcList, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr)
|
||||
u32 container, vm::ptr<void> userdata)
|
||||
{
|
||||
cellSysutil->Warning("cellSaveDataListSave2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcList_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=0x%x, userdata_addr=0x%x)",
|
||||
version, setList.addr(), setBuf.addr(), funcList.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr);
|
||||
version, setList.addr(), setBuf.addr(), funcList.addr(), funcStat.addr(), funcFile.addr(), container, userdata.addr());
|
||||
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataListGet> listGet;
|
||||
|
@ -305,7 +305,7 @@ int cellSaveDataListSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm:
|
|||
if(!dir.IsOpened())
|
||||
return CELL_SAVEDATA_ERROR_INTERNAL;
|
||||
|
||||
std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr);
|
||||
std::string dirNamePrefix = setList->dirNamePrefix.get_ptr();
|
||||
std::vector<SaveDataEntry> saveEntries;
|
||||
|
||||
for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
|
||||
|
@ -325,12 +325,13 @@ int cellSaveDataListSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm:
|
|||
|
||||
// Sort the entries and fill the listGet->dirList array
|
||||
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
|
||||
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf_addr);
|
||||
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr());
|
||||
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf.addr());
|
||||
auto dirList = vm::get_ptr<CellSaveDataDirList>(listGet->dirList.addr());
|
||||
|
||||
for (u32 i=0; i<saveEntries.size(); i++) {
|
||||
memcpy(dirList[i].dirName, saveEntries[i].dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE);
|
||||
memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
|
||||
strcpy_trunc(dirList[i].dirName, saveEntries[i].dirName);
|
||||
strcpy_trunc(dirList[i].listParam, saveEntries[i].listParam);
|
||||
*dirList[i].reserved = {};
|
||||
}
|
||||
|
||||
funcList(result, listGet, listSet);
|
||||
|
@ -352,7 +353,7 @@ int cellSaveDataListSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm:
|
|||
// TODO: Display the dialog here
|
||||
u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry
|
||||
getSaveDataStat(saveEntries[selectedIndex], statGet);
|
||||
result->userdata_addr = userdata_addr;
|
||||
result->userdata = userdata;
|
||||
|
||||
funcStat(result, statGet, statSet);
|
||||
Memory.Free(statGet->fileList.addr());
|
||||
|
@ -373,10 +374,10 @@ int cellSaveDataListSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm:
|
|||
|
||||
int cellSaveDataListLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataListCallback> funcList, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr)
|
||||
u32 container, vm::ptr<void> userdata)
|
||||
{
|
||||
cellSysutil->Warning("cellSaveDataListLoad2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcList_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=0x%x, userdata_addr=0x%x)",
|
||||
version, setList.addr(), setBuf.addr(), funcList.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr);
|
||||
version, setList.addr(), setBuf.addr(), funcList.addr(), funcStat.addr(), funcFile.addr(), container, userdata.addr());
|
||||
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataListGet> listGet;
|
||||
|
@ -390,7 +391,7 @@ int cellSaveDataListLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm:
|
|||
if(!dir.IsOpened())
|
||||
return CELL_SAVEDATA_ERROR_INTERNAL;
|
||||
|
||||
std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr);
|
||||
std::string dirNamePrefix = setList->dirNamePrefix.get_ptr();
|
||||
std::vector<SaveDataEntry> saveEntries;
|
||||
|
||||
for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
|
||||
|
@ -410,12 +411,13 @@ int cellSaveDataListLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm:
|
|||
|
||||
// Sort the entries and fill the listGet->dirList array
|
||||
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
|
||||
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf_addr);
|
||||
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr());
|
||||
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf.addr());
|
||||
auto dirList = vm::get_ptr<CellSaveDataDirList>(listGet->dirList.addr());
|
||||
|
||||
for (u32 i=0; i<saveEntries.size(); i++) {
|
||||
memcpy(dirList[i].dirName, saveEntries[i].dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE);
|
||||
memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
|
||||
strcpy_trunc(dirList[i].dirName, saveEntries[i].dirName);
|
||||
strcpy_trunc(dirList[i].listParam, saveEntries[i].listParam);
|
||||
*dirList[i].reserved = {};
|
||||
}
|
||||
|
||||
funcList(result, listGet, listSet);
|
||||
|
@ -437,7 +439,7 @@ int cellSaveDataListLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm:
|
|||
// TODO: Display the dialog here
|
||||
u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry
|
||||
getSaveDataStat(saveEntries[selectedIndex], statGet);
|
||||
result->userdata_addr = userdata_addr;
|
||||
result->userdata = userdata;
|
||||
|
||||
funcStat(result, statGet, statSet);
|
||||
Memory.Free(statGet->fileList.addr());
|
||||
|
@ -458,10 +460,10 @@ int cellSaveDataListLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm:
|
|||
|
||||
int cellSaveDataFixedSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataFixedCallback> funcFixed, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr)
|
||||
u32 container, vm::ptr<void> userdata)
|
||||
{
|
||||
cellSysutil->Warning("cellSaveDataFixedSave2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcFixed_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=0x%x, userdata_addr=0x%x)",
|
||||
version, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr);
|
||||
version, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata.addr());
|
||||
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataListGet> listGet;
|
||||
|
@ -474,7 +476,7 @@ int cellSaveDataFixedSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, v
|
|||
if (!dir.IsOpened())
|
||||
return CELL_SAVEDATA_ERROR_INTERNAL;
|
||||
|
||||
std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr);
|
||||
std::string dirNamePrefix = setList->dirNamePrefix.get_ptr();
|
||||
std::vector<SaveDataEntry> saveEntries;
|
||||
for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
|
||||
{
|
||||
|
@ -493,11 +495,12 @@ int cellSaveDataFixedSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, v
|
|||
|
||||
// Sort the entries and fill the listGet->dirList array
|
||||
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
|
||||
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf_addr);
|
||||
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr());
|
||||
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf.addr());
|
||||
auto dirList = vm::get_ptr<CellSaveDataDirList>(listGet->dirList.addr());
|
||||
for (u32 i = 0; i<saveEntries.size(); i++) {
|
||||
memcpy(dirList[i].dirName, saveEntries[i].dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE);
|
||||
memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
|
||||
strcpy_trunc(dirList[i].dirName, saveEntries[i].dirName);
|
||||
strcpy_trunc(dirList[i].listParam, saveEntries[i].listParam);
|
||||
*dirList[i].reserved = {};
|
||||
}
|
||||
funcFixed(result, listGet, fixedSet);
|
||||
if (result->result < 0) {
|
||||
|
@ -507,7 +510,7 @@ int cellSaveDataFixedSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, v
|
|||
setSaveDataFixed(saveEntries, fixedSet);
|
||||
getSaveDataStat(saveEntries[0], statGet); // There should be only one element in this list
|
||||
// TODO: Display the Yes|No dialog here
|
||||
result->userdata_addr = userdata_addr;
|
||||
result->userdata = userdata;
|
||||
|
||||
funcStat(result, statGet, statSet);
|
||||
Memory.Free(statGet->fileList.addr());
|
||||
|
@ -527,10 +530,10 @@ int cellSaveDataFixedSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, v
|
|||
|
||||
int cellSaveDataFixedLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataFixedCallback> funcFixed, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr)
|
||||
u32 container, vm::ptr<void> userdata)
|
||||
{
|
||||
cellSysutil->Warning("cellSaveDataFixedLoad2(version=%d, setList_addr=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)",
|
||||
version, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr);
|
||||
version, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata.addr());
|
||||
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataListGet> listGet;
|
||||
|
@ -543,7 +546,7 @@ int cellSaveDataFixedLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, v
|
|||
if (!dir.IsOpened())
|
||||
return CELL_SAVEDATA_ERROR_INTERNAL;
|
||||
|
||||
std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr);
|
||||
std::string dirNamePrefix = setList->dirNamePrefix.get_ptr();
|
||||
std::vector<SaveDataEntry> saveEntries;
|
||||
for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
|
||||
{
|
||||
|
@ -562,11 +565,12 @@ int cellSaveDataFixedLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, v
|
|||
|
||||
// Sort the entries and fill the listGet->dirList array
|
||||
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
|
||||
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf_addr);
|
||||
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr());
|
||||
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf.addr());
|
||||
auto dirList = vm::get_ptr<CellSaveDataDirList>(listGet->dirList.addr());
|
||||
for (u32 i = 0; i<saveEntries.size(); i++) {
|
||||
memcpy(dirList[i].dirName, saveEntries[i].dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE);
|
||||
memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
|
||||
strcpy_trunc(dirList[i].dirName, saveEntries[i].dirName);
|
||||
strcpy_trunc(dirList[i].listParam, saveEntries[i].listParam);
|
||||
*dirList[i].reserved = {};
|
||||
}
|
||||
funcFixed(result, listGet, fixedSet);
|
||||
if (result->result < 0) {
|
||||
|
@ -576,7 +580,7 @@ int cellSaveDataFixedLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, v
|
|||
setSaveDataFixed(saveEntries, fixedSet);
|
||||
getSaveDataStat(saveEntries[0], statGet); // There should be only one element in this list
|
||||
// TODO: Display the Yes|No dialog here
|
||||
result->userdata_addr = userdata_addr;
|
||||
result->userdata = userdata;
|
||||
|
||||
funcStat(result, statGet, statSet);
|
||||
Memory.Free(statGet->fileList.addr());
|
||||
|
@ -594,12 +598,12 @@ int cellSaveDataFixedLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, v
|
|||
return ret;
|
||||
}
|
||||
|
||||
int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
int cellSaveDataAutoSave2(u32 version, vm::ptr<const char> dirName, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr)
|
||||
u32 container, vm::ptr<void> userdata)
|
||||
{
|
||||
cellSysutil->Warning("cellSaveDataAutoSave2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)",
|
||||
version, dirName_addr, errDialog, setBuf.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr);
|
||||
version, dirName.addr(), errDialog, setBuf.addr(), funcStat.addr(), funcFile.addr(), container, userdata.addr());
|
||||
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataStatGet> statGet;
|
||||
|
@ -610,26 +614,26 @@ int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<
|
|||
if (!dir.IsOpened())
|
||||
return CELL_SAVEDATA_ERROR_INTERNAL;
|
||||
|
||||
std::string dirName = Memory.ReadString(dirName_addr);
|
||||
std::string dirN = dirName.get_ptr();
|
||||
std::vector<SaveDataEntry> saveEntries;
|
||||
for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
|
||||
{
|
||||
if (entry->flags & DirEntry_TypeDir && entry->name == dirName) {
|
||||
addSaveDataEntry(saveEntries, saveBaseDir+dirName);
|
||||
if (entry->flags & DirEntry_TypeDir && entry->name == dirN) {
|
||||
addSaveDataEntry(saveEntries, saveBaseDir + dirN);
|
||||
}
|
||||
}
|
||||
|
||||
// The target entry does not exist
|
||||
if (saveEntries.size() == 0) {
|
||||
SaveDataEntry entry;
|
||||
entry.dirName = dirName;
|
||||
entry.dirName = dirN;
|
||||
entry.sizeKB = 0;
|
||||
entry.isNew = true;
|
||||
saveEntries.push_back(entry);
|
||||
}
|
||||
|
||||
getSaveDataStat(saveEntries[0], statGet); // There should be only one element in this list
|
||||
result->userdata_addr = userdata_addr;
|
||||
result->userdata = userdata;
|
||||
funcStat(result, statGet, statSet);
|
||||
|
||||
Memory.Free(statGet->fileList.addr());
|
||||
|
@ -647,12 +651,12 @@ int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<
|
|||
return CELL_SAVEDATA_RET_OK;
|
||||
}
|
||||
|
||||
int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
int cellSaveDataAutoLoad2(u32 version, vm::ptr<const char> dirName, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr)
|
||||
u32 container, vm::ptr<void> userdata)
|
||||
{
|
||||
cellSysutil->Warning("cellSaveDataAutoLoad2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)",
|
||||
version, dirName_addr, errDialog, setBuf.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr);
|
||||
version, dirName.addr(), errDialog, setBuf.addr(), funcStat.addr(), funcFile.addr(), container, userdata.addr());
|
||||
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataStatGet> statGet;
|
||||
|
@ -663,23 +667,23 @@ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<
|
|||
if (!dir.IsOpened())
|
||||
return CELL_SAVEDATA_ERROR_INTERNAL;
|
||||
|
||||
std::string dirName = Memory.ReadString(dirName_addr);
|
||||
std::string dirN = dirName.get_ptr();
|
||||
std::vector<SaveDataEntry> saveEntries;
|
||||
for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
|
||||
{
|
||||
if (entry->flags & DirEntry_TypeDir && entry->name == dirName) {
|
||||
addSaveDataEntry(saveEntries, saveBaseDir+dirName);
|
||||
if (entry->flags & DirEntry_TypeDir && entry->name == dirN) {
|
||||
addSaveDataEntry(saveEntries, saveBaseDir + dirN);
|
||||
}
|
||||
}
|
||||
|
||||
// The target entry does not exist
|
||||
if (saveEntries.size() == 0) {
|
||||
cellSysutil->Warning("cellSaveDataAutoLoad2: Couldn't find save entry (%s)", dirName.c_str());
|
||||
cellSysutil->Warning("cellSaveDataAutoLoad2: Couldn't find save entry (%s)", dirN.c_str());
|
||||
return CELL_OK; // TODO: Can anyone check the actual behaviour of a PS3 when saves are not found?
|
||||
}
|
||||
|
||||
getSaveDataStat(saveEntries[0], statGet); // There should be only one element in this list
|
||||
result->userdata_addr = userdata_addr;
|
||||
result->userdata = userdata;
|
||||
funcStat(result, statGet, statSet);
|
||||
|
||||
Memory.Free(statGet->fileList.addr());
|
||||
|
@ -698,18 +702,171 @@ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<
|
|||
}
|
||||
|
||||
int cellSaveDataListAutoSave(u32 version, u32 errDialog, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf, vm::ptr<CellSaveDataFixedCallback> funcFixed,
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr)
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, vm::ptr<void> userdata)
|
||||
{
|
||||
cellSysutil->Todo("cellSaveDataListAutoSave(version=%d, errDialog=%d, setList=0x%x, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)",
|
||||
version, errDialog, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr);
|
||||
cellSysutil->Todo("cellSaveDataListAutoSave(version=%d, errDialog=%d, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)",
|
||||
version, errDialog, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata.addr());
|
||||
|
||||
//vm::var<CellSaveDataCBResult> result;
|
||||
//vm::var<CellSaveDataListGet> listGet;
|
||||
//vm::var<CellSaveDataFixedSet> fixedSet;
|
||||
//vm::var<CellSaveDataStatGet> statGet;
|
||||
//vm::var<CellSaveDataStatSet> statSet;
|
||||
|
||||
//std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user
|
||||
//vfsDir dir(saveBaseDir);
|
||||
|
||||
//if (!dir.IsOpened())
|
||||
// return CELL_SAVEDATA_ERROR_INTERNAL;
|
||||
|
||||
//std::string dirNamePrefix = setList->dirNamePrefix.get_ptr();
|
||||
//std::vector<SaveDataEntry> saveEntries;
|
||||
|
||||
//for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
|
||||
//{
|
||||
// if (entry->flags & DirEntry_TypeDir && entry->name.substr(0, dirNamePrefix.size()) == dirNamePrefix)
|
||||
// {
|
||||
// // Count the amount of matches and the amount of listed directories
|
||||
// listGet->dirListNum++;
|
||||
// if (listGet->dirListNum > setBuf->dirListMax)
|
||||
// continue;
|
||||
// listGet->dirNum++;
|
||||
|
||||
// std::string saveDir = saveBaseDir + entry->name;
|
||||
// addSaveDataEntry(saveEntries, saveDir);
|
||||
// }
|
||||
//}
|
||||
|
||||
//// Sort the entries and fill the listGet->dirList array
|
||||
//std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
|
||||
//listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf.addr());
|
||||
//auto dirList = vm::get_ptr<CellSaveDataDirList>(listGet->dirList.addr());
|
||||
|
||||
//for (u32 i = 0; i<saveEntries.size(); i++) {
|
||||
// strcpy_trunc(dirList[i].dirName, saveEntries[i].dirName.c_str());
|
||||
// strcpy_trunc(dirList[i].listParam, saveEntries[i].listParam.c_str());
|
||||
// *dirList[i].reserved = {};
|
||||
//}
|
||||
|
||||
//funcFixed(result, listGet, fixedSet);
|
||||
|
||||
//if (result->result < 0) {
|
||||
// cellSysutil->Error("cellSaveDataListAutoSave: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
|
||||
// return CELL_SAVEDATA_ERROR_CBRESULT;
|
||||
//}
|
||||
|
||||
//setSaveDataList(saveEntries, (u32)listSet->fixedList.addr(), listSet->fixedListNum);
|
||||
//if (listSet->newData)
|
||||
// addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr());
|
||||
//if (saveEntries.size() == 0) {
|
||||
// cellSysutil->Warning("cellSaveDataListAutoSave: No save entries found!"); // TODO: Find a better way to handle this error
|
||||
// return CELL_SAVEDATA_RET_OK;
|
||||
//}
|
||||
|
||||
//u32 focusIndex = focusSaveDataEntry(saveEntries, listSet->focusPosition);
|
||||
//// TODO: Display the dialog here
|
||||
//u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry
|
||||
//getSaveDataStat(saveEntries[selectedIndex], statGet.addr());
|
||||
//result->userdata_addr = userdata_addr;
|
||||
|
||||
//funcStat(result, statGet, statSet);
|
||||
//Memory.Free(statGet->fileList.addr());
|
||||
//if (result->result < 0) {
|
||||
// cellSysutil->Error("cellSaveDataListAutoSave: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
|
||||
// return CELL_SAVEDATA_ERROR_CBRESULT;
|
||||
//}
|
||||
|
||||
///*if (statSet->setParam)
|
||||
//addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr()); // TODO: This *is* wrong
|
||||
//*/
|
||||
|
||||
//// Enter the loop where the save files are read/created/deleted.
|
||||
//s32 ret = modifySaveDataFiles(funcFile, result, saveBaseDir + (char*)statGet->dir.dirName);
|
||||
return CELL_SAVEDATA_RET_OK;
|
||||
}
|
||||
|
||||
int cellSaveDataListAutoLoad(u32 version, u32 errDialog, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf, vm::ptr<CellSaveDataFixedCallback> funcFixed,
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr)
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, vm::ptr<void> userdata)
|
||||
{
|
||||
cellSysutil->Todo("cellSaveDataListAutoLoad(version=%d, errDialog=%d, setList=0x%x, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)",
|
||||
version, errDialog, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr);
|
||||
cellSysutil->Todo("cellSaveDataListAutoLoad(version=%d, errDialog=%d, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)",
|
||||
version, errDialog, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata.addr());
|
||||
|
||||
//vm::var<CellSaveDataCBResult> result;
|
||||
//vm::var<CellSaveDataListGet> listGet;
|
||||
//vm::var<CellSaveDataFixedSet> fixedSet;
|
||||
//vm::var<CellSaveDataStatGet> statGet;
|
||||
//vm::var<CellSaveDataStatSet> statSet;
|
||||
|
||||
//std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user
|
||||
//vfsDir dir(saveBaseDir);
|
||||
|
||||
//if (!dir.IsOpened())
|
||||
// return CELL_SAVEDATA_ERROR_INTERNAL;
|
||||
|
||||
//std::string dirNamePrefix = setList->dirNamePrefix.get_ptr();
|
||||
//std::vector<SaveDataEntry> saveEntries;
|
||||
|
||||
//for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
|
||||
//{
|
||||
// if (entry->flags & DirEntry_TypeDir && entry->name.substr(0, dirNamePrefix.size()) == dirNamePrefix)
|
||||
// {
|
||||
// // Count the amount of matches and the amount of listed directories
|
||||
// listGet->dirListNum++;
|
||||
// if (listGet->dirListNum > setBuf->dirListMax)
|
||||
// continue;
|
||||
// listGet->dirNum++;
|
||||
|
||||
// std::string saveDir = saveBaseDir + entry->name;
|
||||
// addSaveDataEntry(saveEntries, saveDir);
|
||||
// }
|
||||
//}
|
||||
|
||||
//// Sort the entries and fill the listGet->dirList array
|
||||
//std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
|
||||
//listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf.addr());
|
||||
//auto dirList = vm::get_ptr<CellSaveDataDirList>(listGet->dirList.addr());
|
||||
|
||||
//for (u32 i = 0; i<saveEntries.size(); i++) {
|
||||
// strcpy_trunc(dirList[i].dirName, saveEntries[i].dirName);
|
||||
// strcpy_trunc(dirList[i].listParam, saveEntries[i].listParam);
|
||||
// *dirList[i].reserved = {};
|
||||
//}
|
||||
|
||||
//funcFixed(result, listGet, fixedSet);
|
||||
|
||||
//if (result->result < 0) {
|
||||
// cellSysutil->Error("cellSaveDataListAutoLoad: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
|
||||
// return CELL_SAVEDATA_ERROR_CBRESULT;
|
||||
//}
|
||||
|
||||
//setSaveDataList(saveEntries, (u32)listSet->fixedList.addr(), listSet->fixedListNum);
|
||||
//if (listSet->newData)
|
||||
// addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr());
|
||||
//if (saveEntries.size() == 0) {
|
||||
// cellSysutil->Warning("cellSaveDataListAutoLoad: No save entries found!"); // TODO: Find a better way to handle this error
|
||||
// return CELL_SAVEDATA_RET_OK;
|
||||
//}
|
||||
|
||||
//u32 focusIndex = focusSaveDataEntry(saveEntries, listSet->focusPosition);
|
||||
//// TODO: Display the dialog here
|
||||
//u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry
|
||||
//getSaveDataStat(saveEntries[selectedIndex], statGet.addr());
|
||||
//result->userdata_addr = userdata_addr;
|
||||
|
||||
//funcStat(result.addr(), statGet.addr(), statSet.addr());
|
||||
//Memory.Free(statGet->fileList.addr());
|
||||
|
||||
//if (result->result < 0) {
|
||||
// cellSysutil->Error("cellSaveDataListAutoLoad: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
|
||||
// return CELL_SAVEDATA_ERROR_CBRESULT;
|
||||
//}
|
||||
|
||||
///*if (statSet->setParam)
|
||||
//// TODO: Write PARAM.SFO file
|
||||
//*/
|
||||
|
||||
//// Enter the loop where the save files are read/created/deleted.
|
||||
//s32 ret = modifySaveDataFiles(funcFile, result, saveBaseDir + (char*)statGet->dir.dirName);
|
||||
return CELL_SAVEDATA_RET_OK;
|
||||
}
|
||||
|
|
@ -93,7 +93,8 @@ struct CellSaveDataSetList
|
|||
{
|
||||
be_t<u32> sortType;
|
||||
be_t<u32> sortOrder;
|
||||
be_t<u32> dirNamePrefix_addr; // char*
|
||||
vm::bptr<char> dirNamePrefix;
|
||||
vm::bptr<void> reserved;
|
||||
};
|
||||
|
||||
struct CellSaveDataSetBuf
|
||||
|
@ -102,27 +103,30 @@ struct CellSaveDataSetBuf
|
|||
be_t<u32> fileListMax;
|
||||
be_t<u32> reserved[6];
|
||||
be_t<u32> bufSize;
|
||||
be_t<u32> buf_addr; // void*
|
||||
vm::bptr<void> buf;
|
||||
};
|
||||
|
||||
struct CellSaveDataNewDataIcon
|
||||
{
|
||||
be_t<u32> title_addr; // char*
|
||||
vm::bptr<char> title;
|
||||
be_t<u32> iconBufSize;
|
||||
be_t<u32> iconBuf_addr; // void*
|
||||
vm::bptr<void> iconBuf;
|
||||
vm::bptr<void> reserved;
|
||||
};
|
||||
|
||||
struct CellSaveDataListNewData
|
||||
{
|
||||
be_t<u32> iconPosition;
|
||||
be_t<u32> dirName_addr; // char*
|
||||
vm::bptr<char> dirName;
|
||||
vm::bptr<CellSaveDataNewDataIcon> icon;
|
||||
vm::bptr<void> reserved;
|
||||
};
|
||||
|
||||
struct CellSaveDataDirList
|
||||
{
|
||||
s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE];
|
||||
s8 listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE];
|
||||
char dirName[CELL_SAVEDATA_DIRNAME_SIZE];
|
||||
char listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE];
|
||||
char reserved[8];
|
||||
};
|
||||
|
||||
struct CellSaveDataListGet
|
||||
|
@ -130,34 +134,35 @@ struct CellSaveDataListGet
|
|||
be_t<u32> dirNum;
|
||||
be_t<u32> dirListNum;
|
||||
vm::bptr<CellSaveDataDirList> dirList;
|
||||
char reserved[64];
|
||||
};
|
||||
|
||||
struct CellSaveDataListSet
|
||||
{
|
||||
be_t<u32> focusPosition;
|
||||
be_t<u32> focusDirName_addr; // char*
|
||||
vm::bptr<char> focusDirName;
|
||||
be_t<u32> fixedListNum;
|
||||
vm::bptr<CellSaveDataDirList> fixedList;
|
||||
vm::bptr<CellSaveDataListNewData> newData;
|
||||
be_t<u32> reserved_addr; // void*
|
||||
vm::bptr<void> reserved;
|
||||
};
|
||||
|
||||
struct CellSaveDataFixedSet
|
||||
{
|
||||
be_t<u32> dirName_addr; // char*
|
||||
vm::bptr<char> dirName;
|
||||
vm::bptr<CellSaveDataNewDataIcon> newIcon;
|
||||
be_t<u32> option;
|
||||
};
|
||||
|
||||
struct CellSaveDataSystemFileParam
|
||||
{
|
||||
s8 title[CELL_SAVEDATA_SYSP_TITLE_SIZE];
|
||||
s8 subTitle[CELL_SAVEDATA_SYSP_SUBTITLE_SIZE];
|
||||
s8 detail[CELL_SAVEDATA_SYSP_DETAIL_SIZE];
|
||||
char title[CELL_SAVEDATA_SYSP_TITLE_SIZE];
|
||||
char subTitle[CELL_SAVEDATA_SYSP_SUBTITLE_SIZE];
|
||||
char detail[CELL_SAVEDATA_SYSP_DETAIL_SIZE];
|
||||
be_t<u32> attribute;
|
||||
s8 reserved2[4];
|
||||
s8 listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE];
|
||||
s8 reserved[256];
|
||||
char reserved2[4];
|
||||
char listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE];
|
||||
char reserved[256];
|
||||
};
|
||||
|
||||
struct CellSaveDataDirStat
|
||||
|
@ -165,7 +170,7 @@ struct CellSaveDataDirStat
|
|||
be_t<s64> st_atime_;
|
||||
be_t<s64> st_mtime_;
|
||||
be_t<s64> st_ctime_;
|
||||
s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE];
|
||||
char dirName[CELL_SAVEDATA_DIRNAME_SIZE];
|
||||
};
|
||||
|
||||
struct CellSaveDataFileStat
|
||||
|
@ -176,7 +181,7 @@ struct CellSaveDataFileStat
|
|||
be_t<s64> st_atime_;
|
||||
be_t<s64> st_mtime_;
|
||||
be_t<s64> st_ctime_;
|
||||
u8 fileName[CELL_SAVEDATA_FILENAME_SIZE];
|
||||
char fileName[CELL_SAVEDATA_FILENAME_SIZE];
|
||||
u8 reserved2[3];
|
||||
};
|
||||
|
||||
|
@ -192,15 +197,17 @@ struct CellSaveDataStatGet
|
|||
be_t<u32> fileNum;
|
||||
be_t<u32> fileListNum;
|
||||
vm::bptr<CellSaveDataFileStat> fileList;
|
||||
char reserved[64];
|
||||
};
|
||||
|
||||
struct CellSaveDataAutoIndicator
|
||||
{
|
||||
be_t<u32> dispPosition;
|
||||
be_t<u32> dispMode;
|
||||
be_t<u32> dispMsg_addr; // char*
|
||||
vm::bptr<char> dispMsg;
|
||||
be_t<u32> picBufSize;
|
||||
be_t<u32> picBuf_addr; // void*
|
||||
vm::bptr<void> picBuf;
|
||||
vm::bptr<void> reserved;
|
||||
};
|
||||
|
||||
struct CellSaveDataStatSet
|
||||
|
@ -213,19 +220,20 @@ struct CellSaveDataStatSet
|
|||
struct CellSaveDataFileGet
|
||||
{
|
||||
be_t<u32> excSize;
|
||||
char reserved[64];
|
||||
};
|
||||
|
||||
struct CellSaveDataFileSet
|
||||
{
|
||||
be_t<u32> fileOperation;
|
||||
be_t<u32> reserved_addr; // void*
|
||||
vm::bptr<void> reserved;
|
||||
be_t<u32> fileType;
|
||||
u8 secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE];
|
||||
be_t<u32> fileName_addr; // char*
|
||||
vm::bptr<char> fileName;
|
||||
be_t<u32> fileOffset;
|
||||
be_t<u32> fileSize;
|
||||
be_t<u32> fileBufSize;
|
||||
be_t<u32> fileBuf_addr; // void*
|
||||
vm::bptr<void> fileBuf;
|
||||
};
|
||||
|
||||
struct CellSaveDataCBResult
|
||||
|
@ -233,16 +241,17 @@ struct CellSaveDataCBResult
|
|||
be_t<s32> result;
|
||||
be_t<u32> progressBarInc;
|
||||
be_t<s32> errNeedSizeKB;
|
||||
be_t<u32> invalidMsg_addr; // char*
|
||||
be_t<u32> userdata_addr; // void*
|
||||
vm::bptr<char> invalidMsg;
|
||||
vm::bptr<void> userdata;
|
||||
};
|
||||
|
||||
struct CellSaveDataDoneGet
|
||||
{
|
||||
be_t<s32> excResult;
|
||||
s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE];
|
||||
char dirName[CELL_SAVEDATA_DIRNAME_SIZE];
|
||||
be_t<s32> sizeKB;
|
||||
be_t<s32> hddFreeSizeKB;
|
||||
char reserved[64];
|
||||
};
|
||||
|
||||
|
||||
|
@ -275,30 +284,30 @@ struct SaveDataEntry
|
|||
// Function declarations
|
||||
int cellSaveDataListSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataListCallback> funcList, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr);
|
||||
u32 container, vm::ptr<void> userdata);
|
||||
|
||||
int cellSaveDataListLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataListCallback> funcList, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr);
|
||||
u32 container, vm::ptr<void> userdata);
|
||||
|
||||
int cellSaveDataFixedSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataFixedCallback> funcFixed, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr);
|
||||
u32 container, vm::ptr<void> userdata);
|
||||
|
||||
int cellSaveDataFixedLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataFixedCallback> funcFixed, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr);
|
||||
u32 container, vm::ptr<void> userdata);
|
||||
|
||||
int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
int cellSaveDataAutoSave2(u32 version, vm::ptr<const char> dirName, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr);
|
||||
u32 container, vm::ptr<void> userdata);
|
||||
|
||||
int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
int cellSaveDataAutoLoad2(u32 version, vm::ptr<const char> dirName, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
|
||||
u32 container, u32 userdata_addr);
|
||||
u32 container, vm::ptr<void> userdata);
|
||||
|
||||
int cellSaveDataListAutoSave(u32 version, u32 errDialog, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf, vm::ptr<CellSaveDataFixedCallback> funcFixed,
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr);
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, vm::ptr<void> userdata);
|
||||
|
||||
int cellSaveDataListAutoLoad(u32 version, u32 errDialog, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf, vm::ptr<CellSaveDataFixedCallback> funcFixed,
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr);
|
||||
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, vm::ptr<void> userdata);
|
|
@ -41,7 +41,7 @@ s64 cellSpursFinalize(vm::ptr<CellSpurs> spurs)
|
|||
#endif
|
||||
}
|
||||
|
||||
s64 cellSpursInitializeWithAttribute(vm::ptr<CellSpurs> spurs, const vm::ptr<CellSpursAttribute> attr)
|
||||
s64 cellSpursInitializeWithAttribute(vm::ptr<CellSpurs> spurs, vm::ptr<const CellSpursAttribute> attr)
|
||||
{
|
||||
cellSpurs->Warning("cellSpursInitializeWithAttribute(spurs_addr=0x%x, spurs_addr=0x%x)", spurs.addr(), attr.addr());
|
||||
|
||||
|
@ -54,7 +54,7 @@ s64 cellSpursInitializeWithAttribute(vm::ptr<CellSpurs> spurs, const vm::ptr<Cel
|
|||
#endif
|
||||
}
|
||||
|
||||
s64 cellSpursInitializeWithAttribute2(vm::ptr<CellSpurs2> spurs, const vm::ptr<CellSpursAttribute> attr)
|
||||
s64 cellSpursInitializeWithAttribute2(vm::ptr<CellSpurs2> spurs, vm::ptr<const CellSpursAttribute> attr)
|
||||
{
|
||||
cellSpurs->Warning("cellSpursInitializeWithAttribute2(spurs_addr=0x%x, spurs_addr=0x%x)", spurs.addr(), attr.addr());
|
||||
|
||||
|
|
|
@ -194,11 +194,11 @@ struct CellSpursTracePacket
|
|||
};
|
||||
|
||||
// Exception handlers.
|
||||
//typedef void (*CellSpursGlobalExceptionEventHandler)(vm::ptr<CellSpurs> spurs, const vm::ptr<CellSpursExceptionInfo> info,
|
||||
// u32 id, vm::ptr<void> arg);
|
||||
//typedef void (*CellSpursGlobalExceptionEventHandler)(vm::ptr<CellSpurs> spurs, vm::ptr<const CellSpursExceptionInfo> info,
|
||||
// u32 id, vm::ptr<void> arg);
|
||||
//
|
||||
//typedef void (*CellSpursTasksetExceptionEventHandler)(vm::ptr<CellSpurs> spurs, vm::ptr<CellSpursTaskset> taskset,
|
||||
// u32 idTask, const vm::ptr<CellSpursExceptionInfo> info, vm::ptr<void> arg);
|
||||
// u32 idTask, vm::ptr<const CellSpursExceptionInfo> info, vm::ptr<void> arg);
|
||||
|
||||
struct CellSpursTasksetInfo
|
||||
{
|
||||
|
|
|
@ -765,7 +765,7 @@ void cellSpursJq_init()
|
|||
CallAfter([]()
|
||||
{
|
||||
libspurs_jq = (u32)Memory.PRXMem.AllocAlign(sizeof(libspurs_jq_data), 4096);
|
||||
memcpy(Memory + libspurs_jq, libspurs_jq_data, sizeof(libspurs_jq_data));
|
||||
memcpy(vm::get_ptr<void>(libspurs_jq), libspurs_jq_data, sizeof(libspurs_jq_data));
|
||||
libspurs_jq_rtoc = libspurs_jq + 0x17E80;
|
||||
|
||||
extern Module* sysPrxForUser;
|
||||
|
|
|
@ -346,13 +346,13 @@ s32 cellSyncBarrierTryWait(vm::ptr<CellSyncBarrier> barrier)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 syncRwmInitialize(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr, u32 buffer_size)
|
||||
s32 syncRwmInitialize(vm::ptr<CellSyncRwm> rwm, vm::ptr<void> buffer, u32 buffer_size)
|
||||
{
|
||||
if (!rwm || !buffer_addr)
|
||||
if (!rwm || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (rwm.addr() % 16 || buffer_addr % 128)
|
||||
if (rwm.addr() % 16 || buffer.addr() % 128)
|
||||
{
|
||||
return CELL_SYNC_ERROR_ALIGN;
|
||||
}
|
||||
|
@ -364,23 +364,23 @@ s32 syncRwmInitialize(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr, u32 buffer_size
|
|||
// prx: zeroize first u16 and second u16, write buffer_size in second u32, write buffer_addr in second u64 and sync
|
||||
rwm->m_data() = 0;
|
||||
rwm->m_size = buffer_size;
|
||||
rwm->m_addr = (u64)buffer_addr;
|
||||
rwm->m_buffer = buffer;
|
||||
InterlockedCompareExchange(&rwm->m_data(), 0, 0);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncRwmInitialize(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr, u32 buffer_size)
|
||||
s32 cellSyncRwmInitialize(vm::ptr<CellSyncRwm> rwm, vm::ptr<void> buffer, u32 buffer_size)
|
||||
{
|
||||
cellSync->Log("cellSyncRwmInitialize(rwm_addr=0x%x, buffer_addr=0x%x, buffer_size=0x%x)", rwm.addr(), buffer_addr, buffer_size);
|
||||
cellSync->Log("cellSyncRwmInitialize(rwm_addr=0x%x, buffer_addr=0x%x, buffer_size=0x%x)", rwm.addr(), buffer.addr(), buffer_size);
|
||||
|
||||
return syncRwmInitialize(rwm, buffer_addr, buffer_size);
|
||||
return syncRwmInitialize(rwm, buffer, buffer_size);
|
||||
}
|
||||
|
||||
s32 cellSyncRwmRead(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
||||
s32 cellSyncRwmRead(vm::ptr<CellSyncRwm> rwm, vm::ptr<void> buffer)
|
||||
{
|
||||
cellSync->Log("cellSyncRwmRead(rwm_addr=0x%x, buffer_addr=0x%x)", rwm.addr(), buffer_addr);
|
||||
cellSync->Log("cellSyncRwmRead(rwm_addr=0x%x, buffer_addr=0x%x)", rwm.addr(), buffer.addr());
|
||||
|
||||
if (!rwm || !buffer_addr)
|
||||
if (!rwm || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ s32 cellSyncRwmRead(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
|||
}
|
||||
|
||||
// copy data to buffer_addr
|
||||
memcpy(Memory + buffer_addr, Memory + (u64)rwm->m_addr, (u32)rwm->m_size);
|
||||
memcpy(buffer.get_ptr(), rwm->m_buffer.get_ptr(), (u32)rwm->m_size);
|
||||
|
||||
// prx: load first u32, return 0x8041010C if first u16 == 0, atomically decrease it
|
||||
while (true)
|
||||
|
@ -433,11 +433,11 @@ s32 cellSyncRwmRead(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncRwmTryRead(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
||||
s32 cellSyncRwmTryRead(vm::ptr<CellSyncRwm> rwm, vm::ptr<void> buffer)
|
||||
{
|
||||
cellSync->Log("cellSyncRwmTryRead(rwm_addr=0x%x, buffer_addr=0x%x)", rwm.addr(), buffer_addr);
|
||||
cellSync->Log("cellSyncRwmTryRead(rwm_addr=0x%x, buffer_addr=0x%x)", rwm.addr(), buffer.addr());
|
||||
|
||||
if (!rwm || !buffer_addr)
|
||||
if (!rwm || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -461,7 +461,7 @@ s32 cellSyncRwmTryRead(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
|||
if (InterlockedCompareExchange(&rwm->m_data(), new_rwm.m_data(), old_data) == old_data) break;
|
||||
}
|
||||
|
||||
memcpy(Memory + buffer_addr, Memory + (u64)rwm->m_addr, (u32)rwm->m_size);
|
||||
memcpy(buffer.get_ptr(), rwm->m_buffer.get_ptr(), (u32)rwm->m_size);
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
@ -481,11 +481,11 @@ s32 cellSyncRwmTryRead(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncRwmWrite(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
||||
s32 cellSyncRwmWrite(vm::ptr<CellSyncRwm> rwm, vm::ptr<const void> buffer)
|
||||
{
|
||||
cellSync->Log("cellSyncRwmWrite(rwm_addr=0x%x, buffer_addr=0x%x)", rwm.addr(), buffer_addr);
|
||||
cellSync->Log("cellSyncRwmWrite(rwm_addr=0x%x, buffer_addr=0x%x)", rwm.addr(), buffer.addr());
|
||||
|
||||
if (!rwm || !buffer_addr)
|
||||
if (!rwm || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -528,7 +528,7 @@ s32 cellSyncRwmWrite(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
|||
}
|
||||
|
||||
// prx: copy data from buffer_addr
|
||||
memcpy(Memory + (u64)rwm->m_addr, Memory + buffer_addr, (u32)rwm->m_size);
|
||||
memcpy(rwm->m_buffer.get_ptr(), buffer.get_ptr(), (u32)rwm->m_size);
|
||||
|
||||
// prx: sync and zeroize m_readers and m_writers
|
||||
InterlockedCompareExchange(&rwm->m_data(), 0, 0);
|
||||
|
@ -536,11 +536,11 @@ s32 cellSyncRwmWrite(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncRwmTryWrite(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
||||
s32 cellSyncRwmTryWrite(vm::ptr<CellSyncRwm> rwm, vm::ptr<const void> buffer)
|
||||
{
|
||||
cellSync->Log("cellSyncRwmTryWrite(rwm_addr=0x%x, buffer_addr=0x%x)", rwm.addr(), buffer_addr);
|
||||
cellSync->Log("cellSyncRwmTryWrite(rwm_addr=0x%x, buffer_addr=0x%x)", rwm.addr(), buffer.addr());
|
||||
|
||||
if (!rwm || !buffer_addr)
|
||||
if (!rwm || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ s32 cellSyncRwmTryWrite(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
|||
if (InterlockedCompareExchange(&rwm->m_data(), se32(1), 0) != 0) return CELL_SYNC_ERROR_BUSY;
|
||||
|
||||
// prx: copy data from buffer_addr
|
||||
memcpy(Memory + (u64)rwm->m_addr, Memory + buffer_addr, (u32)rwm->m_size);
|
||||
memcpy(rwm->m_buffer.get_ptr(), buffer.get_ptr(), (u32)rwm->m_size);
|
||||
|
||||
// prx: sync and zeroize m_readers and m_writers
|
||||
InterlockedCompareExchange(&rwm->m_data(), 0, 0);
|
||||
|
@ -561,17 +561,17 @@ s32 cellSyncRwmTryWrite(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 syncQueueInitialize(vm::ptr<CellSyncQueue> queue, u32 buffer_addr, u32 size, u32 depth)
|
||||
s32 syncQueueInitialize(vm::ptr<CellSyncQueue> queue, vm::ptr<u8> buffer, u32 size, u32 depth)
|
||||
{
|
||||
if (!queue)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (size && !buffer_addr)
|
||||
if (size && !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (queue.addr() % 32 || buffer_addr % 16)
|
||||
if (queue.addr() % 32 || buffer.addr() % 16)
|
||||
{
|
||||
return CELL_SYNC_ERROR_ALIGN;
|
||||
}
|
||||
|
@ -584,23 +584,23 @@ s32 syncQueueInitialize(vm::ptr<CellSyncQueue> queue, u32 buffer_addr, u32 size,
|
|||
queue->m_data() = 0;
|
||||
queue->m_size = size;
|
||||
queue->m_depth = depth;
|
||||
queue->m_addr = (u64)buffer_addr;
|
||||
queue->m_buffer = buffer;
|
||||
InterlockedCompareExchange(&queue->m_data(), 0, 0);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncQueueInitialize(vm::ptr<CellSyncQueue> queue, u32 buffer_addr, u32 size, u32 depth)
|
||||
s32 cellSyncQueueInitialize(vm::ptr<CellSyncQueue> queue, vm::ptr<u8> buffer, u32 size, u32 depth)
|
||||
{
|
||||
cellSync->Log("cellSyncQueueInitialize(queue_addr=0x%x, buffer_addr=0x%x, size=0x%x, depth=0x%x)", queue.addr(), buffer_addr, size, depth);
|
||||
cellSync->Log("cellSyncQueueInitialize(queue_addr=0x%x, buffer_addr=0x%x, size=0x%x, depth=0x%x)", queue.addr(), buffer.addr(), size, depth);
|
||||
|
||||
return syncQueueInitialize(queue, buffer_addr, size, depth);
|
||||
return syncQueueInitialize(queue, buffer, size, depth);
|
||||
}
|
||||
|
||||
s32 cellSyncQueuePush(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
||||
s32 cellSyncQueuePush(vm::ptr<CellSyncQueue> queue, vm::ptr<const void> buffer)
|
||||
{
|
||||
cellSync->Log("cellSyncQueuePush(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer_addr);
|
||||
cellSync->Log("cellSyncQueuePush(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer.addr());
|
||||
|
||||
if (!queue || !buffer_addr)
|
||||
if (!queue || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -645,7 +645,7 @@ s32 cellSyncQueuePush(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
|||
}
|
||||
|
||||
// prx: memcpy(position * m_size + m_addr, buffer_addr, m_size), sync
|
||||
memcpy(Memory + ((u64)queue->m_addr + position * size), Memory + buffer_addr, size);
|
||||
memcpy(&queue->m_buffer[position * size], buffer.get_ptr(), size);
|
||||
|
||||
// prx: atomically insert 0 in 5th u8
|
||||
while (true)
|
||||
|
@ -660,11 +660,11 @@ s32 cellSyncQueuePush(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncQueueTryPush(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
||||
s32 cellSyncQueueTryPush(vm::ptr<CellSyncQueue> queue, vm::ptr<const void> buffer)
|
||||
{
|
||||
cellSync->Log("cellSyncQueueTryPush(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer_addr);
|
||||
cellSync->Log("cellSyncQueueTryPush(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer.addr());
|
||||
|
||||
if (!queue || !buffer_addr)
|
||||
if (!queue || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -697,7 +697,7 @@ s32 cellSyncQueueTryPush(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
|||
if (InterlockedCompareExchange(&queue->m_data(), new_queue.m_data(), old_data) == old_data) break;
|
||||
}
|
||||
|
||||
memcpy(Memory + ((u64)queue->m_addr + position * size), Memory + buffer_addr, size);
|
||||
memcpy(&queue->m_buffer[position * size], buffer.get_ptr(), size);
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
@ -711,11 +711,11 @@ s32 cellSyncQueueTryPush(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncQueuePop(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
||||
s32 cellSyncQueuePop(vm::ptr<CellSyncQueue> queue, vm::ptr<void> buffer)
|
||||
{
|
||||
cellSync->Log("cellSyncQueuePop(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer_addr);
|
||||
cellSync->Log("cellSyncQueuePop(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer.addr());
|
||||
|
||||
if (!queue || !buffer_addr)
|
||||
if (!queue || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -760,7 +760,7 @@ s32 cellSyncQueuePop(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
|||
}
|
||||
|
||||
// prx: (sync), memcpy(buffer_addr, position * m_size + m_addr, m_size)
|
||||
memcpy(Memory + buffer_addr, Memory + ((u64)queue->m_addr + position * size), size);
|
||||
memcpy(buffer.get_ptr(), &queue->m_buffer[position * size], size);
|
||||
|
||||
// prx: atomically insert 0 in first u8
|
||||
while (true)
|
||||
|
@ -775,11 +775,11 @@ s32 cellSyncQueuePop(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncQueueTryPop(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
||||
s32 cellSyncQueueTryPop(vm::ptr<CellSyncQueue> queue, vm::ptr<void> buffer)
|
||||
{
|
||||
cellSync->Log("cellSyncQueueTryPop(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer_addr);
|
||||
cellSync->Log("cellSyncQueueTryPop(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer.addr());
|
||||
|
||||
if (!queue || !buffer_addr)
|
||||
if (!queue || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -812,7 +812,7 @@ s32 cellSyncQueueTryPop(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
|||
if (InterlockedCompareExchange(&queue->m_data(), new_queue.m_data(), old_data) == old_data) break;
|
||||
}
|
||||
|
||||
memcpy(Memory + buffer_addr, Memory + ((u64)queue->m_addr + position * size), size);
|
||||
memcpy(buffer.get_ptr(), &queue->m_buffer[position * size], size);
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
@ -826,11 +826,11 @@ s32 cellSyncQueueTryPop(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncQueuePeek(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
||||
s32 cellSyncQueuePeek(vm::ptr<CellSyncQueue> queue, vm::ptr<void> buffer)
|
||||
{
|
||||
cellSync->Log("cellSyncQueuePeek(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer_addr);
|
||||
cellSync->Log("cellSyncQueuePeek(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer.addr());
|
||||
|
||||
if (!queue || !buffer_addr)
|
||||
if (!queue || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -868,7 +868,7 @@ s32 cellSyncQueuePeek(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
|||
if (InterlockedCompareExchange(&queue->m_data(), new_queue.m_data(), old_data) == old_data) break;
|
||||
}
|
||||
|
||||
memcpy(Memory + buffer_addr, Memory + ((u64)queue->m_addr + position * size), size);
|
||||
memcpy(buffer.get_ptr(), &queue->m_buffer[position * size], size);
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
@ -882,11 +882,11 @@ s32 cellSyncQueuePeek(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncQueueTryPeek(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
||||
s32 cellSyncQueueTryPeek(vm::ptr<CellSyncQueue> queue, vm::ptr<void> buffer)
|
||||
{
|
||||
cellSync->Log("cellSyncQueueTryPeek(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer_addr);
|
||||
cellSync->Log("cellSyncQueueTryPeek(queue_addr=0x%x, buffer_addr=0x%x)", queue.addr(), buffer.addr());
|
||||
|
||||
if (!queue || !buffer_addr)
|
||||
if (!queue || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ s32 cellSyncQueueTryPeek(vm::ptr<CellSyncQueue> queue, u32 buffer_addr)
|
|||
if (InterlockedCompareExchange(&queue->m_data(), new_queue.m_data(), old_data) == old_data) break;
|
||||
}
|
||||
|
||||
memcpy(Memory + buffer_addr, Memory + ((u64)queue->m_addr + position * size), size);
|
||||
memcpy(buffer.get_ptr(), &queue->m_buffer[position * size], size);
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
@ -1029,7 +1029,7 @@ void syncLFQueueDump(vm::ptr<CellSyncLFQueue> queue)
|
|||
}
|
||||
}
|
||||
|
||||
void syncLFQueueInit(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 size, u32 depth, CellSyncQueueDirection direction, u32 eaSignal_addr)
|
||||
void syncLFQueueInit(vm::ptr<CellSyncLFQueue> queue, vm::ptr<u8> buffer, u32 size, u32 depth, CellSyncQueueDirection direction, vm::ptr<void> eaSignal)
|
||||
{
|
||||
queue->m_h1 = 0;
|
||||
queue->m_h2 = 0;
|
||||
|
@ -1039,19 +1039,20 @@ void syncLFQueueInit(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 size,
|
|||
queue->m_h8 = 0;
|
||||
queue->m_size = size;
|
||||
queue->m_depth = depth;
|
||||
queue->m_buffer = (u64)buffer_addr;
|
||||
queue->m_buffer = buffer;
|
||||
queue->m_direction = direction;
|
||||
for (u32 i = 0; i < sizeof(queue->m_hs) / sizeof(queue->m_hs[0]); i++)
|
||||
{
|
||||
queue->m_hs[i] = 0;
|
||||
}
|
||||
queue->m_eaSignal = (u64)eaSignal_addr;
|
||||
queue->m_eaSignal = eaSignal;
|
||||
|
||||
if (direction == CELL_SYNC_QUEUE_ANY2ANY)
|
||||
{
|
||||
queue->m_h3 = 0;
|
||||
queue->m_h7 = 0;
|
||||
queue->m_buffer = (u64)buffer_addr | 1;
|
||||
queue->m_buffer = buffer + 1;
|
||||
assert(queue->m_buffer.addr() % 2);
|
||||
queue->m_bs[0] = -1;
|
||||
queue->m_bs[1] = -1;
|
||||
//m_bs[2]
|
||||
|
@ -1076,7 +1077,7 @@ void syncLFQueueInit(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 size,
|
|||
}
|
||||
}
|
||||
|
||||
s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 size, u32 depth, CellSyncQueueDirection direction, u32 eaSignal_addr)
|
||||
s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, vm::ptr<u8> buffer, u32 size, u32 depth, CellSyncQueueDirection direction, vm::ptr<void> eaSignal)
|
||||
{
|
||||
#ifdef PRX_DEBUG_XXX
|
||||
return GetCurrentPPUThread().FastCall(libsre + 0x205C, libsre_rtoc, queue.addr(), buffer_addr, size, depth, direction, eaSignal_addr);
|
||||
|
@ -1088,7 +1089,7 @@ s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 s
|
|||
}
|
||||
if (size)
|
||||
{
|
||||
if (!buffer_addr)
|
||||
if (!buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -1101,7 +1102,7 @@ s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 s
|
|||
{
|
||||
return CELL_SYNC_ERROR_INVAL;
|
||||
}
|
||||
if (queue.addr() % 128 || buffer_addr % 16)
|
||||
if (queue.addr() % 128 || buffer.addr() % 16)
|
||||
{
|
||||
return CELL_SYNC_ERROR_ALIGN;
|
||||
}
|
||||
|
@ -1138,9 +1139,10 @@ s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 s
|
|||
{
|
||||
if (sdk_ver > 0x17ffff)
|
||||
{
|
||||
auto data = vm::get_ptr<u64>(queue.addr());
|
||||
for (u32 i = 0; i < sizeof(CellSyncLFQueue) / sizeof(u64); i++)
|
||||
{
|
||||
if ((u64&)Memory[queue.addr() + i * sizeof(u64)])
|
||||
if (data[i])
|
||||
{
|
||||
return CELL_SYNC_ERROR_STAT;
|
||||
}
|
||||
|
@ -1155,13 +1157,13 @@ s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 s
|
|||
|
||||
if (old_value == se32(2))
|
||||
{
|
||||
if ((u32)queue->m_size != size || (u32)queue->m_depth != depth || (u64)queue->m_buffer != (u64)buffer_addr)
|
||||
if ((u32)queue->m_size != size || (u32)queue->m_depth != depth || queue->m_buffer.addr() != buffer.addr())
|
||||
{
|
||||
return CELL_SYNC_ERROR_INVAL;
|
||||
}
|
||||
if (sdk_ver > 0x17ffff)
|
||||
{
|
||||
if ((u64)queue->m_eaSignal != (u64)eaSignal_addr || (u32)queue->m_direction != direction)
|
||||
if (queue->m_eaSignal.addr() != eaSignal.addr() || (u32)queue->m_direction != direction)
|
||||
{
|
||||
return CELL_SYNC_ERROR_INVAL;
|
||||
}
|
||||
|
@ -1170,7 +1172,7 @@ s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 s
|
|||
else
|
||||
{
|
||||
// prx: call internal function with same arguments
|
||||
syncLFQueueInit(queue, buffer_addr, size, depth, direction, eaSignal_addr);
|
||||
syncLFQueueInit(queue, buffer, size, depth, direction, eaSignal);
|
||||
|
||||
// prx: sync, zeroize u32 at 0x2c offset
|
||||
InterlockedCompareExchange(&queue->m_data(), 0, 0);
|
||||
|
@ -1183,12 +1185,12 @@ s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 s
|
|||
#endif
|
||||
}
|
||||
|
||||
s32 cellSyncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 size, u32 depth, CellSyncQueueDirection direction, u32 eaSignal_addr)
|
||||
s32 cellSyncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, vm::ptr<u8> buffer, u32 size, u32 depth, CellSyncQueueDirection direction, vm::ptr<void> eaSignal)
|
||||
{
|
||||
cellSync->Warning("cellSyncLFQueueInitialize(queue_addr=0x%x, buffer_addr=0x%x, size=0x%x, depth=0x%x, direction=%d, eaSignal_addr=0x%x)",
|
||||
queue.addr(), buffer_addr, size, depth, direction, eaSignal_addr);
|
||||
queue.addr(), buffer.addr(), size, depth, direction, eaSignal.addr());
|
||||
|
||||
return syncLFQueueInitialize(queue, buffer_addr, size, depth, direction, eaSignal_addr);
|
||||
return syncLFQueueInitialize(queue, buffer, size, depth, direction, eaSignal);
|
||||
}
|
||||
|
||||
s32 syncLFQueueGetPushPointer(vm::ptr<CellSyncLFQueue> queue, s32& pointer, u32 isBlocking, u32 useEventQueue)
|
||||
|
@ -1451,7 +1453,7 @@ s32 syncLFQueueCompletePushPointer(vm::ptr<CellSyncLFQueue> queue, s32 pointer,
|
|||
if (exch)
|
||||
{
|
||||
assert(fpSendSignal);
|
||||
return fpSendSignal((u32)queue->m_eaSignal, var6);
|
||||
return fpSendSignal((u32)queue->m_eaSignal.addr(), var6);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1496,16 +1498,16 @@ s32 _cellSyncLFQueueCompletePushPointer2(vm::ptr<CellSyncLFQueue> queue, s32 poi
|
|||
return syncLFQueueCompletePushPointer2(queue, pointer, fpSendSignal);
|
||||
}
|
||||
|
||||
s32 _cellSyncLFQueuePushBody(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 isBlocking)
|
||||
s32 _cellSyncLFQueuePushBody(vm::ptr<CellSyncLFQueue> queue, vm::ptr<const void> buffer, u32 isBlocking)
|
||||
{
|
||||
// cellSyncLFQueuePush has 1 in isBlocking param, cellSyncLFQueueTryPush has 0
|
||||
cellSync->Warning("_cellSyncLFQueuePushBody(queue_addr=0x%x, buffer_addr=0x%x, isBlocking=%d)", queue.addr(), buffer_addr, isBlocking);
|
||||
cellSync->Warning("_cellSyncLFQueuePushBody(queue_addr=0x%x, buffer_addr=0x%x, isBlocking=%d)", queue.addr(), buffer.addr(), isBlocking);
|
||||
|
||||
if (!queue || !buffer_addr)
|
||||
if (!queue || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (queue.addr() % 128 || buffer_addr % 16)
|
||||
if (queue.addr() % 128 || buffer.addr() % 16)
|
||||
{
|
||||
return CELL_SYNC_ERROR_ALIGN;
|
||||
}
|
||||
|
@ -1561,7 +1563,7 @@ s32 _cellSyncLFQueuePushBody(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u3
|
|||
|
||||
s32 depth = (u32)queue->m_depth;
|
||||
s32 size = (u32)queue->m_size;
|
||||
memcpy(Memory + (((u64)queue->m_buffer & ~1ull) + size * (position >= depth ? position - depth : position)), Memory + buffer_addr, size);
|
||||
memcpy(vm::get_ptr<void>((queue->m_buffer.addr() & ~1ull) + size * (position >= depth ? position - depth : position)), buffer.get_ptr(), size);
|
||||
|
||||
s32 res;
|
||||
if (queue->m_direction.ToBE() != se32(CELL_SYNC_QUEUE_ANY2ANY))
|
||||
|
@ -1844,7 +1846,7 @@ s32 syncLFQueueCompletePopPointer(vm::ptr<CellSyncLFQueue> queue, s32 pointer, c
|
|||
if (exch)
|
||||
{
|
||||
assert(fpSendSignal);
|
||||
return fpSendSignal((u32)queue->m_eaSignal, var6);
|
||||
return fpSendSignal((u32)queue->m_eaSignal.addr(), var6);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1890,16 +1892,16 @@ s32 _cellSyncLFQueueCompletePopPointer2(vm::ptr<CellSyncLFQueue> queue, s32 poin
|
|||
return syncLFQueueCompletePopPointer2(queue, pointer, fpSendSignal, noQueueFull);
|
||||
}
|
||||
|
||||
s32 _cellSyncLFQueuePopBody(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 isBlocking)
|
||||
s32 _cellSyncLFQueuePopBody(vm::ptr<CellSyncLFQueue> queue, vm::ptr<void> buffer, u32 isBlocking)
|
||||
{
|
||||
// cellSyncLFQueuePop has 1 in isBlocking param, cellSyncLFQueueTryPop has 0
|
||||
cellSync->Warning("_cellSyncLFQueuePopBody(queue_addr=0x%x, buffer_addr=0x%x, isBlocking=%d)", queue.addr(), buffer_addr, isBlocking);
|
||||
cellSync->Warning("_cellSyncLFQueuePopBody(queue_addr=0x%x, buffer_addr=0x%x, isBlocking=%d)", queue.addr(), buffer.addr(), isBlocking);
|
||||
|
||||
if (!queue || !buffer_addr)
|
||||
if (!queue || !buffer)
|
||||
{
|
||||
return CELL_SYNC_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (queue.addr() % 128 || buffer_addr % 16)
|
||||
if (queue.addr() % 128 || buffer.addr() % 16)
|
||||
{
|
||||
return CELL_SYNC_ERROR_ALIGN;
|
||||
}
|
||||
|
@ -1949,7 +1951,7 @@ s32 _cellSyncLFQueuePopBody(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32
|
|||
|
||||
s32 depth = (u32)queue->m_depth;
|
||||
s32 size = (u32)queue->m_size;
|
||||
memcpy(Memory + buffer_addr, Memory + (((u64)queue->m_buffer & ~1ull) + size * (position >= depth ? position - depth : position)), size);
|
||||
memcpy(buffer.get_ptr(), vm::get_ptr<void>((queue->m_buffer.addr() & ~1ull) + size * (position >= depth ? position - depth : position)), size);
|
||||
|
||||
s32 res;
|
||||
if (queue->m_direction.ToBE() != se32(CELL_SYNC_QUEUE_ANY2ANY))
|
||||
|
@ -2075,7 +2077,7 @@ s32 cellSyncLFQueueDepth(vm::ptr<CellSyncLFQueue> queue, vm::ptr<be_t<u32>> dept
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 _cellSyncLFQueueGetSignalAddress(vm::ptr<CellSyncLFQueue> queue, vm::ptr<be_t<u32>> ppSignal)
|
||||
s32 _cellSyncLFQueueGetSignalAddress(vm::ptr<const CellSyncLFQueue> queue, vm::ptr<be_t<u32>> ppSignal)
|
||||
{
|
||||
cellSync->Log("_cellSyncLFQueueGetSignalAddress(queue_addr=0x%x, ppSignal_addr=0x%x)", queue.addr(), ppSignal.addr());
|
||||
|
||||
|
@ -2088,11 +2090,11 @@ s32 _cellSyncLFQueueGetSignalAddress(vm::ptr<CellSyncLFQueue> queue, vm::ptr<be_
|
|||
return CELL_SYNC_ERROR_ALIGN;
|
||||
}
|
||||
|
||||
*ppSignal = (u32)queue->m_eaSignal;
|
||||
*ppSignal = (u32)queue->m_eaSignal.addr();
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncLFQueueGetDirection(vm::ptr<CellSyncLFQueue> queue, vm::ptr<be_t<CellSyncQueueDirection>> direction)
|
||||
s32 cellSyncLFQueueGetDirection(vm::ptr<const CellSyncLFQueue> queue, vm::ptr<be_t<CellSyncQueueDirection>> direction)
|
||||
{
|
||||
cellSync->Log("cellSyncLFQueueGetDirection(queue_addr=0x%x, direction_addr=0x%x)", queue.addr(), direction.addr());
|
||||
|
||||
|
@ -2109,7 +2111,7 @@ s32 cellSyncLFQueueGetDirection(vm::ptr<CellSyncLFQueue> queue, vm::ptr<be_t<Cel
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSyncLFQueueGetEntrySize(vm::ptr<CellSyncLFQueue> queue, vm::ptr<be_t<u32>> entry_size)
|
||||
s32 cellSyncLFQueueGetEntrySize(vm::ptr<const CellSyncLFQueue> queue, vm::ptr<be_t<u32>> entry_size)
|
||||
{
|
||||
cellSync->Log("cellSyncLFQueueGetEntrySize(queue_addr=0x%x, entry_size_addr=0x%x)", queue.addr(), entry_size.addr());
|
||||
|
||||
|
@ -2207,7 +2209,7 @@ void cellSync_init()
|
|||
CallAfter([]()
|
||||
{
|
||||
libsre = (u32)Memory.PRXMem.AllocAlign(sizeof(libsre_data), 4096);
|
||||
memcpy(Memory + libsre, libsre_data, sizeof(libsre_data));
|
||||
memcpy(vm::get_ptr<void>(libsre), libsre_data, sizeof(libsre_data));
|
||||
libsre_rtoc = libsre + 0x399B0;
|
||||
|
||||
extern Module* sysPrxForUser;
|
||||
|
|
|
@ -60,7 +60,7 @@ struct CellSyncRwm
|
|||
be_t<u16> m_readers;
|
||||
be_t<u16> m_writers;
|
||||
be_t<u32> m_size;
|
||||
be_t<u64> m_addr;
|
||||
vm::bptr<void, 1, u64> m_buffer;
|
||||
|
||||
volatile u32& m_data()
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ struct CellSyncQueue
|
|||
be_t<u32> m_v2;
|
||||
be_t<u32> m_size;
|
||||
be_t<u32> m_depth;
|
||||
be_t<u64> m_addr;
|
||||
vm::bptr<u8, 1, u64> m_buffer;
|
||||
be_t<u64> reserved;
|
||||
|
||||
volatile u64& m_data()
|
||||
|
@ -107,13 +107,13 @@ struct CellSyncLFQueue
|
|||
be_t<u16> m_h8; // 0xE
|
||||
be_t<u32> m_size; // 0x10
|
||||
be_t<u32> m_depth; // 0x14
|
||||
be_t<u64> m_buffer; // 0x18
|
||||
vm::bptr<u8, 1, u64> m_buffer; // 0x18
|
||||
u8 m_bs[4]; // 0x20
|
||||
be_t<CellSyncQueueDirection> m_direction; // 0x24
|
||||
be_t<u32> m_v1; // 0x28
|
||||
be_t<u32> m_sync; // 0x2C
|
||||
be_t<u16> m_hs[32]; // 0x30
|
||||
be_t<u64> m_eaSignal;// 0x70
|
||||
vm::bptr<void, 1, u64> m_eaSignal; // 0x70
|
||||
be_t<u32> m_v2; // 0x78
|
||||
be_t<u32> m_v3; // 0x7C
|
||||
|
||||
|
@ -159,11 +159,11 @@ s32 syncMutexInitialize(vm::ptr<CellSyncMutex> mutex);
|
|||
|
||||
s32 syncBarrierInitialize(vm::ptr<CellSyncBarrier> barrier, u16 total_count);
|
||||
|
||||
s32 syncRwmInitialize(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr, u32 buffer_size);
|
||||
s32 syncRwmInitialize(vm::ptr<CellSyncRwm> rwm, vm::ptr<void> buffer, u32 buffer_size);
|
||||
|
||||
s32 syncQueueInitialize(vm::ptr<CellSyncQueue> queue, u32 buffer_addr, u32 size, u32 depth);
|
||||
s32 syncQueueInitialize(vm::ptr<CellSyncQueue> queue, vm::ptr<u8> buffer, u32 size, u32 depth);
|
||||
|
||||
s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 size, u32 depth, CellSyncQueueDirection direction, u32 eaSignal_addr);
|
||||
s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, vm::ptr<u8> buffer, u32 size, u32 depth, CellSyncQueueDirection direction, vm::ptr<void> eaSignal);
|
||||
s32 syncLFQueueGetPushPointer(vm::ptr<CellSyncLFQueue> queue, s32& pointer, u32 isBlocking, u32 useEventQueue);
|
||||
s32 syncLFQueueGetPushPointer2(vm::ptr<CellSyncLFQueue> queue, s32& pointer, u32 isBlocking, u32 useEventQueue);
|
||||
s32 syncLFQueueCompletePushPointer(vm::ptr<CellSyncLFQueue> queue, s32 pointer, const std::function<s32(u32 addr, u32 arg)> fpSendSignal);
|
||||
|
|
|
@ -455,7 +455,7 @@ void cellSync2_init()
|
|||
CallAfter([]()
|
||||
{
|
||||
libsync2 = (u32)Memory.PRXMem.AllocAlign(sizeof(libsync2_data), 4096);
|
||||
memcpy(Memory + libsync2, libsync2_data, sizeof(libsync2_data));
|
||||
memcpy(vm::get_ptr<void>(libsync2), libsync2_data, sizeof(libsync2_data));
|
||||
libsync2_rtoc = libsync2 + 0xF280;
|
||||
|
||||
extern Module* sysPrxForUser;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "cellMsgDialog.h"
|
||||
#include "cellGame.h"
|
||||
#include "cellSysutil.h"
|
||||
#include "cellSysutil_SaveData.h"
|
||||
#include "cellSaveData.h"
|
||||
|
||||
typedef void (*CellHddGameStatCallback)(vm::ptr<CellHddGameCBResult> cbResult, vm::ptr<CellHddGameStatGet> get, vm::ptr<CellHddGameStatSet> set);
|
||||
|
||||
|
@ -137,37 +137,26 @@ int cellSysutilGetSystemParamString(s32 id, vm::ptr<char> buf, u32 bufsize)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellVideoOutGetState(u32 videoOut, u32 deviceIndex, u32 state_addr)
|
||||
int cellVideoOutGetState(u32 videoOut, u32 deviceIndex, vm::ptr<CellVideoOutState> state)
|
||||
{
|
||||
cellSysutil->Log("cellVideoOutGetState(videoOut=0x%x, deviceIndex=0x%x, state_addr=0x%x)", videoOut, deviceIndex, state_addr);
|
||||
cellSysutil->Log("cellVideoOutGetState(videoOut=0x%x, deviceIndex=0x%x, state_addr=0x%x)", videoOut, deviceIndex, state.addr());
|
||||
|
||||
if(deviceIndex) return CELL_VIDEO_OUT_ERROR_DEVICE_NOT_FOUND;
|
||||
|
||||
CellVideoOutState state = {};
|
||||
|
||||
switch(videoOut)
|
||||
{
|
||||
case CELL_VIDEO_OUT_PRIMARY:
|
||||
{
|
||||
state.colorSpace = Emu.GetGSManager().GetColorSpace();
|
||||
state.state = Emu.GetGSManager().GetState();
|
||||
state.displayMode.resolutionId = Emu.GetGSManager().GetInfo().mode.resolutionId;
|
||||
state.displayMode.scanMode = Emu.GetGSManager().GetInfo().mode.scanMode;
|
||||
state.displayMode.conversion = Emu.GetGSManager().GetInfo().mode.conversion;
|
||||
state.displayMode.aspect = Emu.GetGSManager().GetInfo().mode.aspect;
|
||||
state.displayMode.refreshRates = re(Emu.GetGSManager().GetInfo().mode.refreshRates);
|
||||
|
||||
Memory.WriteData(state_addr, state);
|
||||
}
|
||||
case CELL_VIDEO_OUT_PRIMARY:
|
||||
state->state = Emu.GetGSManager().GetState();
|
||||
state->colorSpace = Emu.GetGSManager().GetColorSpace();
|
||||
state->displayMode.resolutionId = Emu.GetGSManager().GetInfo().mode.resolutionId;
|
||||
state->displayMode.scanMode = Emu.GetGSManager().GetInfo().mode.scanMode;
|
||||
state->displayMode.conversion = Emu.GetGSManager().GetInfo().mode.conversion;
|
||||
state->displayMode.aspect = Emu.GetGSManager().GetInfo().mode.aspect;
|
||||
state->displayMode.refreshRates = Emu.GetGSManager().GetInfo().mode.refreshRates;
|
||||
return CELL_VIDEO_OUT_SUCCEEDED;
|
||||
|
||||
case CELL_VIDEO_OUT_SECONDARY:
|
||||
{
|
||||
state.colorSpace = CELL_VIDEO_OUT_COLOR_SPACE_RGB;
|
||||
state.state = CELL_VIDEO_OUT_OUTPUT_STATE_ENABLED;
|
||||
|
||||
Memory.WriteData(state_addr, state);
|
||||
}
|
||||
|
||||
case CELL_VIDEO_OUT_SECONDARY:
|
||||
*state = { CELL_VIDEO_OUT_OUTPUT_STATE_DISABLED }; // ???
|
||||
return CELL_VIDEO_OUT_SUCCEEDED;
|
||||
}
|
||||
|
||||
|
@ -189,31 +178,29 @@ int cellVideoOutGetResolution(u32 resolutionId, vm::ptr<CellVideoOutResolution>
|
|||
return CELL_VIDEO_OUT_SUCCEEDED;
|
||||
}
|
||||
|
||||
s32 cellVideoOutConfigure(u32 videoOut, u32 config_addr, u32 option_addr, u32 waitForEvent)
|
||||
s32 cellVideoOutConfigure(u32 videoOut, vm::ptr<CellVideoOutConfiguration> config, vm::ptr<CellVideoOutOption> option, u32 waitForEvent)
|
||||
{
|
||||
cellSysutil->Warning("cellVideoOutConfigure(videoOut=%d, config_addr=0x%x, option_addr=0x%x, waitForEvent=0x%x)",
|
||||
videoOut, config_addr, option_addr, waitForEvent);
|
||||
|
||||
CellVideoOutConfiguration& config = (CellVideoOutConfiguration&)Memory[config_addr];
|
||||
videoOut, config.addr(), option.addr(), waitForEvent);
|
||||
|
||||
switch(videoOut)
|
||||
{
|
||||
case CELL_VIDEO_OUT_PRIMARY:
|
||||
if(config.resolutionId)
|
||||
if(config->resolutionId)
|
||||
{
|
||||
Emu.GetGSManager().GetInfo().mode.resolutionId = config.resolutionId;
|
||||
Emu.GetGSManager().GetInfo().mode.resolutionId = config->resolutionId;
|
||||
}
|
||||
|
||||
Emu.GetGSManager().GetInfo().mode.format = config.format;
|
||||
Emu.GetGSManager().GetInfo().mode.format = config->format;
|
||||
|
||||
if(config.aspect)
|
||||
if(config->aspect)
|
||||
{
|
||||
Emu.GetGSManager().GetInfo().mode.aspect = config.aspect;
|
||||
Emu.GetGSManager().GetInfo().mode.aspect = config->aspect;
|
||||
}
|
||||
|
||||
if(config.pitch)
|
||||
if(config->pitch)
|
||||
{
|
||||
Emu.GetGSManager().GetInfo().mode.pitch = re(config.pitch);
|
||||
Emu.GetGSManager().GetInfo().mode.pitch = config->pitch;
|
||||
}
|
||||
|
||||
return CELL_VIDEO_OUT_SUCCEEDED;
|
||||
|
@ -225,27 +212,26 @@ s32 cellVideoOutConfigure(u32 videoOut, u32 config_addr, u32 option_addr, u32 wa
|
|||
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
|
||||
}
|
||||
|
||||
int cellVideoOutGetConfiguration(u32 videoOut, u32 config_addr, u32 option_addr)
|
||||
int cellVideoOutGetConfiguration(u32 videoOut, vm::ptr<CellVideoOutConfiguration> config, vm::ptr<CellVideoOutOption> option)
|
||||
{
|
||||
cellSysutil->Warning("cellVideoOutGetConfiguration(videoOut=%d, config_addr=0x%x, option_addr=0x%x)",
|
||||
videoOut, config_addr, option_addr);
|
||||
videoOut, config.addr(), option.addr());
|
||||
|
||||
CellVideoOutConfiguration config = {};
|
||||
if (option) *option = {};
|
||||
|
||||
switch(videoOut)
|
||||
{
|
||||
case CELL_VIDEO_OUT_PRIMARY:
|
||||
config.resolutionId = Emu.GetGSManager().GetInfo().mode.resolutionId;
|
||||
config.format = Emu.GetGSManager().GetInfo().mode.format;
|
||||
config.aspect = Emu.GetGSManager().GetInfo().mode.aspect;
|
||||
config.pitch = re(Emu.GetGSManager().GetInfo().mode.pitch);
|
||||
|
||||
Memory.WriteData(config_addr, config);
|
||||
config->resolutionId = Emu.GetGSManager().GetInfo().mode.resolutionId;
|
||||
config->format = Emu.GetGSManager().GetInfo().mode.format;
|
||||
config->aspect = Emu.GetGSManager().GetInfo().mode.aspect;
|
||||
*config->reserved = {};
|
||||
config->pitch = Emu.GetGSManager().GetInfo().mode.pitch;
|
||||
|
||||
return CELL_VIDEO_OUT_SUCCEEDED;
|
||||
|
||||
case CELL_VIDEO_OUT_SECONDARY:
|
||||
Memory.WriteData(config_addr, config);
|
||||
*config = {}; // ???
|
||||
|
||||
return CELL_VIDEO_OUT_SUCCEEDED;
|
||||
}
|
||||
|
@ -371,31 +357,31 @@ int cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option)
|
|||
|
||||
switch(fs)
|
||||
{
|
||||
case CELL_AUDIO_OUT_FS_32KHZ:
|
||||
case CELL_AUDIO_OUT_FS_44KHZ:
|
||||
case CELL_AUDIO_OUT_FS_48KHZ:
|
||||
case CELL_AUDIO_OUT_FS_88KHZ:
|
||||
case CELL_AUDIO_OUT_FS_96KHZ:
|
||||
case CELL_AUDIO_OUT_FS_176KHZ:
|
||||
case CELL_AUDIO_OUT_FS_192KHZ:
|
||||
break;
|
||||
case CELL_AUDIO_OUT_FS_32KHZ:
|
||||
case CELL_AUDIO_OUT_FS_44KHZ:
|
||||
case CELL_AUDIO_OUT_FS_48KHZ:
|
||||
case CELL_AUDIO_OUT_FS_88KHZ:
|
||||
case CELL_AUDIO_OUT_FS_96KHZ:
|
||||
case CELL_AUDIO_OUT_FS_176KHZ:
|
||||
case CELL_AUDIO_OUT_FS_192KHZ:
|
||||
break;
|
||||
|
||||
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
|
||||
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
|
||||
}
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case CELL_AUDIO_OUT_CODING_TYPE_LPCM: break;
|
||||
case CELL_AUDIO_OUT_CODING_TYPE_AC3: available = 0; break;
|
||||
case CELL_AUDIO_OUT_CODING_TYPE_DTS: available = 0; break;
|
||||
case CELL_AUDIO_OUT_CODING_TYPE_LPCM: break;
|
||||
case CELL_AUDIO_OUT_CODING_TYPE_AC3: available = 0; break;
|
||||
case CELL_AUDIO_OUT_CODING_TYPE_DTS: available = 0; break;
|
||||
|
||||
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
|
||||
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
|
||||
}
|
||||
|
||||
switch(audioOut)
|
||||
{
|
||||
case CELL_AUDIO_OUT_PRIMARY: return available;
|
||||
case CELL_AUDIO_OUT_SECONDARY: return 0;
|
||||
case CELL_AUDIO_OUT_PRIMARY: return available;
|
||||
case CELL_AUDIO_OUT_SECONDARY: return 0;
|
||||
}
|
||||
|
||||
return CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION;
|
||||
|
@ -451,31 +437,26 @@ int cellAudioOutGetSoundAvailability2(u32 audioOut, u32 type, u32 fs, u32 ch, u3
|
|||
return CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION;
|
||||
}
|
||||
|
||||
int cellAudioOutGetState(u32 audioOut, u32 deviceIndex, u32 state_addr)
|
||||
int cellAudioOutGetState(u32 audioOut, u32 deviceIndex, vm::ptr<CellAudioOutState> state)
|
||||
{
|
||||
cellSysutil->Warning("cellAudioOutGetState(audioOut=0x%x,deviceIndex=0x%x,state_addr=0x%x)",audioOut,deviceIndex,state_addr);
|
||||
CellAudioOutState state = {};
|
||||
cellSysutil->Warning("cellAudioOutGetState(audioOut=0x%x, deviceIndex=0x%x, state_addr=0x%x)", audioOut, deviceIndex, state.addr());
|
||||
|
||||
switch(audioOut)
|
||||
{
|
||||
case CELL_AUDIO_OUT_PRIMARY:
|
||||
{
|
||||
state.state = Emu.GetAudioManager().GetState();
|
||||
state.soundMode.type = Emu.GetAudioManager().GetInfo().mode.type;
|
||||
state.soundMode.channel = Emu.GetAudioManager().GetInfo().mode.channel;
|
||||
state.soundMode.fs = Emu.GetAudioManager().GetInfo().mode.fs;
|
||||
state.soundMode.layout = Emu.GetAudioManager().GetInfo().mode.layout;
|
||||
|
||||
Memory.WriteData(state_addr, state);
|
||||
}
|
||||
case CELL_AUDIO_OUT_PRIMARY:
|
||||
state->state = Emu.GetAudioManager().GetState();
|
||||
state->encoder = Emu.GetAudioManager().GetInfo().mode.encoder;
|
||||
*state->reserved = {};
|
||||
state->downMixer = Emu.GetAudioManager().GetInfo().mode.downMixer;
|
||||
state->soundMode.type = Emu.GetAudioManager().GetInfo().mode.type;
|
||||
state->soundMode.channel = Emu.GetAudioManager().GetInfo().mode.channel;
|
||||
state->soundMode.fs = Emu.GetAudioManager().GetInfo().mode.fs;
|
||||
state->soundMode.reserved = 0;
|
||||
state->soundMode.layout = Emu.GetAudioManager().GetInfo().mode.layout;
|
||||
return CELL_AUDIO_OUT_SUCCEEDED;
|
||||
|
||||
case CELL_AUDIO_OUT_SECONDARY:
|
||||
{
|
||||
state.state = CELL_AUDIO_OUT_OUTPUT_STATE_ENABLED;
|
||||
|
||||
Memory.WriteData(state_addr, state);
|
||||
}
|
||||
case CELL_AUDIO_OUT_SECONDARY:
|
||||
*state = { CELL_AUDIO_OUT_OUTPUT_STATE_DISABLED };
|
||||
return CELL_AUDIO_OUT_SUCCEEDED;
|
||||
}
|
||||
|
||||
|
@ -484,7 +465,7 @@ int cellAudioOutGetState(u32 audioOut, u32 deviceIndex, u32 state_addr)
|
|||
|
||||
int cellAudioOutConfigure(u32 audioOut, vm::ptr<CellAudioOutConfiguration> config, vm::ptr<CellAudioOutOption> option, u32 waitForEvent)
|
||||
{
|
||||
cellSysutil->Warning("cellAudioOutConfigure(audioOut=%d, config_addr=0x%x, option_addr=0x%x, (!)waitForEvent=%d)",
|
||||
cellSysutil->Warning("cellAudioOutConfigure(audioOut=%d, config_addr=0x%x, option_addr=0x%x, waitForEvent=%d)",
|
||||
audioOut, config.addr(), option.addr(), waitForEvent);
|
||||
|
||||
switch(audioOut)
|
||||
|
@ -511,26 +492,24 @@ int cellAudioOutConfigure(u32 audioOut, vm::ptr<CellAudioOutConfiguration> confi
|
|||
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
|
||||
}
|
||||
|
||||
int cellAudioOutGetConfiguration(u32 audioOut, u32 config_addr, u32 option_addr)
|
||||
int cellAudioOutGetConfiguration(u32 audioOut, vm::ptr<CellAudioOutConfiguration> config, vm::ptr<CellAudioOutOption> option)
|
||||
{
|
||||
cellSysutil->Warning("cellAudioOutGetConfiguration(audioOut=%d, config_addr=0x%x, option_addr=0x%x)",
|
||||
audioOut, config_addr, option_addr);
|
||||
cellSysutil->Warning("cellAudioOutGetConfiguration(audioOut=%d, config_addr=0x%x, option_addr=0x%x)", audioOut, config.addr(), option.addr());
|
||||
|
||||
CellAudioOutConfiguration config = {};
|
||||
if (option) *option = {};
|
||||
|
||||
switch(audioOut)
|
||||
{
|
||||
case CELL_AUDIO_OUT_PRIMARY:
|
||||
config.channel = Emu.GetAudioManager().GetInfo().mode.channel;
|
||||
config.encoder = Emu.GetAudioManager().GetInfo().mode.encoder;
|
||||
config.downMixer = Emu.GetAudioManager().GetInfo().mode.downMixer;
|
||||
|
||||
Memory.WriteData(config_addr, config);
|
||||
case CELL_AUDIO_OUT_PRIMARY:
|
||||
config->channel = Emu.GetAudioManager().GetInfo().mode.channel;
|
||||
config->encoder = Emu.GetAudioManager().GetInfo().mode.encoder;
|
||||
*config->reserved = {};
|
||||
config->downMixer = Emu.GetAudioManager().GetInfo().mode.downMixer;
|
||||
|
||||
return CELL_AUDIO_OUT_SUCCEEDED;
|
||||
|
||||
case CELL_AUDIO_OUT_SECONDARY:
|
||||
Memory.WriteData(config_addr, config);
|
||||
*config = {};
|
||||
|
||||
return CELL_AUDIO_OUT_SUCCEEDED;
|
||||
}
|
||||
|
@ -540,12 +519,12 @@ int cellAudioOutGetConfiguration(u32 audioOut, u32 config_addr, u32 option_addr)
|
|||
|
||||
int cellAudioOutGetNumberOfDevice(u32 audioOut)
|
||||
{
|
||||
cellSysutil->Warning("cellAudioOutGetNumberOfDevice(videoOut=%d)",audioOut);
|
||||
cellSysutil->Warning("cellAudioOutGetNumberOfDevice(audioOut=%d)", audioOut);
|
||||
|
||||
switch(audioOut)
|
||||
{
|
||||
case CELL_AUDIO_OUT_PRIMARY: return 1;
|
||||
case CELL_AUDIO_OUT_SECONDARY: return 0;
|
||||
case CELL_AUDIO_OUT_PRIMARY: return 1;
|
||||
case CELL_AUDIO_OUT_SECONDARY: return 0;
|
||||
}
|
||||
|
||||
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
|
||||
|
@ -553,8 +532,7 @@ int cellAudioOutGetNumberOfDevice(u32 audioOut)
|
|||
|
||||
int cellAudioOutGetDeviceInfo(u32 audioOut, u32 deviceIndex, vm::ptr<CellAudioOutDeviceInfo> info)
|
||||
{
|
||||
cellSysutil->Todo("cellAudioOutGetDeviceInfo(audioOut=%u, deviceIndex=%u, info_addr=0x%x)",
|
||||
audioOut, deviceIndex, info.addr());
|
||||
cellSysutil->Todo("cellAudioOutGetDeviceInfo(audioOut=%d, deviceIndex=%d, info_addr=0x%x)", audioOut, deviceIndex, info.addr());
|
||||
|
||||
if(deviceIndex) return CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND;
|
||||
|
||||
|
@ -576,11 +554,11 @@ int cellAudioOutSetCopyControl(u32 audioOut, u32 control)
|
|||
|
||||
switch(audioOut)
|
||||
{
|
||||
case CELL_AUDIO_OUT_PRIMARY:
|
||||
case CELL_AUDIO_OUT_SECONDARY:
|
||||
break;
|
||||
case CELL_AUDIO_OUT_PRIMARY:
|
||||
case CELL_AUDIO_OUT_SECONDARY:
|
||||
break;
|
||||
|
||||
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
|
||||
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
|
||||
}
|
||||
|
||||
switch(control)
|
||||
|
@ -672,13 +650,13 @@ int cellSysCacheMount(vm::ptr<CellSysCacheParam> param)
|
|||
return CELL_SYSCACHE_RET_OK_RELAYED;
|
||||
}
|
||||
|
||||
int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellHddGameStatCallback> funcStat, u32 container)
|
||||
int cellHddGameCheck(u32 version, vm::ptr<const char> dirName, u32 errDialog, vm::ptr<CellHddGameStatCallback> funcStat, u32 container)
|
||||
{
|
||||
cellSysutil->Warning("cellHddGameCheck(version=%d, dirName_addr=0x%xx, errDialog=%d, funcStat_addr=0x%x, container=%d)",
|
||||
version, dirName_addr, errDialog, funcStat.addr(), container);
|
||||
cellSysutil->Warning("cellHddGameCheck(version=%d, dirName_addr=0x%x, errDialog=%d, funcStat_addr=0x%x, container=%d)",
|
||||
version, dirName.addr(), errDialog, funcStat.addr(), container);
|
||||
|
||||
std::string dirName = Memory.ReadString(dirName_addr);
|
||||
if (dirName.size() != 9)
|
||||
std::string dir = dirName.get_ptr();
|
||||
if (dir.size() != 9)
|
||||
return CELL_HDDGAME_ERROR_PARAM;
|
||||
|
||||
vm::var<CellHddGameSystemFileParam> param;
|
||||
|
@ -693,10 +671,10 @@ int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellH
|
|||
get->st_ctime__ = 0; // TODO
|
||||
get->st_mtime__ = 0; // TODO
|
||||
get->sizeKB = CELL_HDDGAME_SIZEKB_NOTCALC;
|
||||
memcpy(get->contentInfoPath, ("/dev_hdd0/game/"+dirName).c_str(), CELL_HDDGAME_PATH_MAX);
|
||||
memcpy(get->hddGamePath, ("/dev_hdd0/game/"+dirName+"/USRDIR").c_str(), CELL_HDDGAME_PATH_MAX);
|
||||
memcpy(get->contentInfoPath, ("/dev_hdd0/game/" + dir).c_str(), CELL_HDDGAME_PATH_MAX);
|
||||
memcpy(get->hddGamePath, ("/dev_hdd0/game/" + dir + "/USRDIR").c_str(), CELL_HDDGAME_PATH_MAX);
|
||||
|
||||
if (!Emu.GetVFS().ExistsDir(("/dev_hdd0/game/"+dirName).c_str()))
|
||||
if (!Emu.GetVFS().ExistsDir(("/dev_hdd0/game/" + dir).c_str()))
|
||||
{
|
||||
get->isNewData = CELL_HDDGAME_ISNEWDATA_NODIR;
|
||||
}
|
||||
|
@ -704,7 +682,7 @@ int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellH
|
|||
{
|
||||
// TODO: Is cellHddGameCheck really responsible for writing the information in get->getParam ? (If not, delete this else)
|
||||
|
||||
vfsFile f(("/dev_hdd0/game/"+dirName+"/PARAM.SFO").c_str());
|
||||
vfsFile f(("/dev_hdd0/game/" + dir + "/PARAM.SFO").c_str());
|
||||
PSFLoader psf(f);
|
||||
if (!psf.Load(false)) {
|
||||
return CELL_HDDGAME_ERROR_BROKEN;
|
||||
|
@ -715,16 +693,16 @@ int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellH
|
|||
get->getParam.resolution = psf.GetInteger("RESOLUTION");
|
||||
get->getParam.soundFormat = psf.GetInteger("SOUND_FORMAT");
|
||||
std::string title = psf.GetString("TITLE");
|
||||
memcpy(get->getParam.title, title.c_str(), std::min<size_t>(CELL_HDDGAME_SYSP_TITLE_SIZE,title.length()+1));
|
||||
strcpy_trunc(get->getParam.title, title);
|
||||
std::string app_ver = psf.GetString("APP_VER");
|
||||
memcpy(get->getParam.dataVersion, app_ver.c_str(), std::min<size_t>(CELL_HDDGAME_SYSP_VERSION_SIZE,app_ver.length()+1));
|
||||
memcpy(get->getParam.titleId, dirName.c_str(), std::min<size_t>(CELL_HDDGAME_SYSP_TITLEID_SIZE,dirName.length()+1));
|
||||
strcpy_trunc(get->getParam.dataVersion, app_ver);
|
||||
strcpy_trunc(get->getParam.titleId, dir);
|
||||
|
||||
for (u32 i=0; i<CELL_HDDGAME_SYSP_LANGUAGE_NUM; i++) {
|
||||
char key [16];
|
||||
sprintf(key, "TITLE_%02d", i);
|
||||
title = psf.GetString(key);
|
||||
memcpy(get->getParam.titleLang[i], title.c_str(), std::min<size_t>(CELL_HDDGAME_SYSP_TITLE_SIZE, title.length() + 1));
|
||||
strcpy_trunc(get->getParam.titleLang[i], title);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -807,9 +785,9 @@ int cellSysutilGetBgmPlaybackStatus2(vm::ptr<CellSysutilBgmPlaybackStatus2> stat
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellWebBrowserEstimate2(const vm::ptr<const u8> _config, vm::ptr<be_t<u32>> memSize)
|
||||
int cellWebBrowserEstimate2(const vm::ptr<const CellWebBrowserConfig2> config, vm::ptr<be_t<u32>> memSize)
|
||||
{
|
||||
cellSysutil->Warning("cellWebBrowserEstimate2(config_addr=0x%x, memSize_addr=0x%x)", _config.addr(), memSize.addr());
|
||||
cellSysutil->Warning("cellWebBrowserEstimate2(config_addr=0x%x, memSize_addr=0x%x)", config.addr(), memSize.addr());
|
||||
|
||||
// TODO: When cellWebBrowser stuff is implemented, change this to some real
|
||||
// needed memory buffer size.
|
||||
|
|
|
@ -171,11 +171,11 @@ enum
|
|||
|
||||
struct CellHddGameSystemFileParam
|
||||
{
|
||||
u8 title[CELL_HDDGAME_SYSP_TITLE_SIZE];
|
||||
u8 titleLang[CELL_HDDGAME_SYSP_LANGUAGE_NUM][CELL_HDDGAME_SYSP_TITLE_SIZE];
|
||||
u8 titleId[CELL_HDDGAME_SYSP_TITLEID_SIZE];
|
||||
char title[CELL_HDDGAME_SYSP_TITLE_SIZE];
|
||||
char titleLang[CELL_HDDGAME_SYSP_LANGUAGE_NUM][CELL_HDDGAME_SYSP_TITLE_SIZE];
|
||||
char titleId[CELL_HDDGAME_SYSP_TITLEID_SIZE];
|
||||
u8 reserved0[2];
|
||||
u8 dataVersion[CELL_HDDGAME_SYSP_VERSION_SIZE];
|
||||
char dataVersion[CELL_HDDGAME_SYSP_VERSION_SIZE];
|
||||
u8 reserved1[2];
|
||||
be_t<u32> attribute;
|
||||
be_t<u32> parentalLevel;
|
||||
|
@ -214,5 +214,70 @@ struct CellHddGameCBResult
|
|||
be_t<u32> reserved_addr; // void*
|
||||
};
|
||||
|
||||
// SysCalls
|
||||
s32 cellVideoOutConfigure(u32 videoOut, u32 config_addr, u32 option_addr, u32 waitForEvent);
|
||||
typedef s32 CellWebBrowserId;
|
||||
typedef void* CellWebBrowserClientSession;
|
||||
typedef void(*CellWebBrowserCallback)(s32 cb_type, vm::ptr<CellWebBrowserClientSession>, vm::ptr<void> usrdata);
|
||||
typedef void(*CellWebComponentCallback)(CellWebBrowserId, s32 cb_type, vm::ptr<CellWebBrowserClientSession>, vm::ptr<void> usrdata);
|
||||
typedef void(*CellWebBrowserSystemCallback)(s32 cb_type, vm::ptr<void> usrdata);
|
||||
|
||||
typedef void(*CellWebBrowserMIMETypeCallback)(vm::ptr<const char> mimetype, vm::ptr<const char> url, vm::ptr<void> usrdata);
|
||||
typedef void(*CellWebBrowserErrorCallback)(s32 err_type, vm::ptr<void> usrdata);
|
||||
typedef void(*CellWebBrowserStatusCallback)(s32 err_type, vm::ptr<void> usrdata);
|
||||
typedef void(*CellWebBrowserNotify)(vm::ptr<const char> message, vm::ptr<void> usrdata);
|
||||
typedef void(*CellWebBrowserUsrdata)(vm::ptr<void> usrdata);
|
||||
|
||||
struct CellWebBrowserMimeSet
|
||||
{
|
||||
vm::bptr<const char> const type;
|
||||
vm::bptr<const char> const directory;
|
||||
};
|
||||
|
||||
struct CellWebBrowserPos
|
||||
{
|
||||
be_t<s32> x;
|
||||
be_t<s32> y;
|
||||
};
|
||||
|
||||
struct CellWebBrowserSize
|
||||
{
|
||||
be_t<s32> width;
|
||||
be_t<s32> height;
|
||||
};
|
||||
|
||||
struct CellWebBrowserRect
|
||||
{
|
||||
CellWebBrowserPos pos;
|
||||
CellWebBrowserSize size;
|
||||
};
|
||||
|
||||
struct CellWebBrowserConfig
|
||||
{
|
||||
be_t<s32> version;
|
||||
be_t<s32> heap_size;
|
||||
vm::bptr<const CellWebBrowserMimeSet> mimesets;
|
||||
be_t<s32> mimeset_num;
|
||||
be_t<s32> functions;
|
||||
be_t<s32> tab_count;
|
||||
vm::bptr<CellWebBrowserCallback> exit_cb;
|
||||
vm::bptr<CellWebBrowserCallback> download_cb;
|
||||
vm::bptr<CellWebBrowserCallback> navigated_cb;
|
||||
};
|
||||
|
||||
struct CellWebBrowserConfig2
|
||||
{
|
||||
be_t<s32> version;
|
||||
be_t<s32> heap_size;
|
||||
be_t<s32> functions;
|
||||
be_t<s32> tab_count;
|
||||
be_t<s32> size_mode;
|
||||
be_t<s32> view_restriction;
|
||||
vm::bptr<CellWebBrowserMIMETypeCallback> unknown_mimetype_cb;
|
||||
vm::bptr<CellWebBrowserErrorCallback> error_cb;
|
||||
vm::bptr<CellWebBrowserStatusCallback> status_error_cb;
|
||||
vm::bptr<CellWebBrowserNotify> notify_cb;
|
||||
vm::bptr<CellWebBrowserCallback> request_cb;
|
||||
CellWebBrowserRect rect;
|
||||
be_t<float> resolution_factor;
|
||||
be_t<s32> magic_number_;
|
||||
};
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ next:
|
|||
break;
|
||||
case vdecDecodeAu:
|
||||
{
|
||||
memcpy(buf, Memory + vdec.reader.addr, vdec.reader.size);
|
||||
memcpy(buf, vm::get_ptr<void>(vdec.reader.addr), vdec.reader.size);
|
||||
|
||||
buf += vdec.reader.size;
|
||||
buf_size -= vdec.reader.size;
|
||||
|
@ -153,7 +153,7 @@ next:
|
|||
}
|
||||
else
|
||||
{
|
||||
memcpy(buf, Memory + vdec.reader.addr, buf_size);
|
||||
memcpy(buf, vm::get_ptr<void>(vdec.reader.addr), buf_size);
|
||||
|
||||
vdec.reader.addr += buf_size;
|
||||
vdec.reader.size -= buf_size;
|
||||
|
@ -482,21 +482,21 @@ u32 vdecOpen(VideoDecoder* data)
|
|||
return vdec_id;
|
||||
}
|
||||
|
||||
int cellVdecQueryAttr(const vm::ptr<CellVdecType> type, vm::ptr<CellVdecAttr> attr)
|
||||
int cellVdecQueryAttr(vm::ptr<const CellVdecType> type, vm::ptr<CellVdecAttr> attr)
|
||||
{
|
||||
cellVdec->Warning("cellVdecQueryAttr(type_addr=0x%x, attr_addr=0x%x)", type.addr(), attr.addr());
|
||||
|
||||
return vdecQueryAttr(type->codecType, type->profileLevel, 0, attr);
|
||||
}
|
||||
|
||||
int cellVdecQueryAttrEx(const vm::ptr<CellVdecTypeEx> type, vm::ptr<CellVdecAttr> attr)
|
||||
int cellVdecQueryAttrEx(vm::ptr<const CellVdecTypeEx> type, vm::ptr<CellVdecAttr> attr)
|
||||
{
|
||||
cellVdec->Warning("cellVdecQueryAttrEx(type_addr=0x%x, attr_addr=0x%x)", type.addr(), attr.addr());
|
||||
|
||||
return vdecQueryAttr(type->codecType, type->profileLevel, type->codecSpecificInfo_addr, attr);
|
||||
}
|
||||
|
||||
int cellVdecOpen(const vm::ptr<CellVdecType> type, const vm::ptr<CellVdecResource> res, const vm::ptr<CellVdecCb> cb, vm::ptr<be_t<u32>> handle)
|
||||
int cellVdecOpen(vm::ptr<const CellVdecType> type, vm::ptr<const CellVdecResource> res, vm::ptr<const CellVdecCb> cb, vm::ptr<be_t<u32>> handle)
|
||||
{
|
||||
cellVdec->Warning("cellVdecOpen(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)",
|
||||
type.addr(), res.addr(), cb.addr(), handle.addr());
|
||||
|
@ -506,7 +506,7 @@ int cellVdecOpen(const vm::ptr<CellVdecType> type, const vm::ptr<CellVdecResourc
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellVdecOpenEx(const vm::ptr<CellVdecTypeEx> type, const vm::ptr<CellVdecResourceEx> res, const vm::ptr<CellVdecCb> cb, vm::ptr<be_t<u32>> handle)
|
||||
int cellVdecOpenEx(vm::ptr<const CellVdecTypeEx> type, vm::ptr<const CellVdecResourceEx> res, vm::ptr<const CellVdecCb> cb, vm::ptr<be_t<u32>> handle)
|
||||
{
|
||||
cellVdec->Warning("cellVdecOpenEx(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)",
|
||||
type.addr(), res.addr(), cb.addr(), handle.addr());
|
||||
|
@ -593,7 +593,7 @@ int cellVdecEndSeq(u32 handle)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, const vm::ptr<CellVdecAuInfo> auInfo)
|
||||
int cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, vm::ptr<const CellVdecAuInfo> auInfo)
|
||||
{
|
||||
cellVdec->Log("cellVdecDecodeAu(handle=%d, mode=0x%x, auInfo_addr=0x%x)", handle, mode, auInfo.addr());
|
||||
|
||||
|
@ -617,9 +617,9 @@ int cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, const vm::ptr<CellVdec
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellVdecGetPicture(u32 handle, const vm::ptr<CellVdecPicFormat> format, u32 out_addr)
|
||||
int cellVdecGetPicture(u32 handle, vm::ptr<const CellVdecPicFormat> format, vm::ptr<u8> outBuff)
|
||||
{
|
||||
cellVdec->Log("cellVdecGetPicture(handle=%d, format_addr=0x%x, out_addr=0x%x)", handle, format.addr(), out_addr);
|
||||
cellVdec->Log("cellVdecGetPicture(handle=%d, format_addr=0x%x, outBuff_addr=0x%x)", handle, format.addr(), outBuff.addr());
|
||||
|
||||
VideoDecoder* vdec;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, vdec))
|
||||
|
@ -632,7 +632,7 @@ int cellVdecGetPicture(u32 handle, const vm::ptr<CellVdecPicFormat> format, u32
|
|||
return CELL_VDEC_ERROR_EMPTY;
|
||||
}
|
||||
|
||||
if (out_addr)
|
||||
if (outBuff)
|
||||
{
|
||||
u32 buf_size = a128(av_image_get_buffer_size(vdec->ctx->pix_fmt, vdec->ctx->width, vdec->ctx->height, 1));
|
||||
|
||||
|
@ -656,7 +656,7 @@ int cellVdecGetPicture(u32 handle, const vm::ptr<CellVdecPicFormat> format, u32
|
|||
|
||||
// TODO: zero padding bytes
|
||||
|
||||
int err = av_image_copy_to_buffer(Memory.GetMemFromAddr(out_addr), buf_size, frame.data, frame.linesize, vdec->ctx->pix_fmt, frame.width, frame.height, 1);
|
||||
int err = av_image_copy_to_buffer(outBuff.get_ptr(), buf_size, frame.data, frame.linesize, vdec->ctx->pix_fmt, frame.width, frame.height, 1);
|
||||
if (err < 0)
|
||||
{
|
||||
cellVdec->Error("cellVdecGetPicture: av_image_copy_to_buffer failed(%d)", err);
|
||||
|
|
|
@ -14,7 +14,7 @@ extern "C"
|
|||
//Module cellVpost(0x0008, cellVpost_init);
|
||||
Module *cellVpost = nullptr;
|
||||
|
||||
int cellVpostQueryAttr(const vm::ptr<CellVpostCfgParam> cfgParam, vm::ptr<CellVpostAttr> attr)
|
||||
int cellVpostQueryAttr(vm::ptr<const CellVpostCfgParam> cfgParam, vm::ptr<CellVpostAttr> attr)
|
||||
{
|
||||
cellVpost->Warning("cellVpostQueryAttr(cfgParam_addr=0x%x, attr_addr=0x%x)", cfgParam.addr(), attr.addr());
|
||||
|
||||
|
@ -37,7 +37,7 @@ u32 vpostOpen(VpostInstance* data)
|
|||
return id;
|
||||
}
|
||||
|
||||
int cellVpostOpen(const vm::ptr<CellVpostCfgParam> cfgParam, const vm::ptr<CellVpostResource> resource, vm::ptr<be_t<u32>> handle)
|
||||
int cellVpostOpen(vm::ptr<const CellVpostCfgParam> cfgParam, vm::ptr<const CellVpostResource> resource, vm::ptr<be_t<u32>> handle)
|
||||
{
|
||||
cellVpost->Warning("cellVpostOpen(cfgParam_addr=0x%x, resource_addr=0x%x, handle_addr=0x%x)",
|
||||
cfgParam.addr(), resource.addr(), handle.addr());
|
||||
|
@ -47,7 +47,7 @@ int cellVpostOpen(const vm::ptr<CellVpostCfgParam> cfgParam, const vm::ptr<CellV
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellVpostOpenEx(const vm::ptr<CellVpostCfgParam> cfgParam, const vm::ptr<CellVpostResourceEx> resource, vm::ptr<be_t<u32>> handle)
|
||||
int cellVpostOpenEx(vm::ptr<const CellVpostCfgParam> cfgParam, vm::ptr<const CellVpostResourceEx> resource, vm::ptr<be_t<u32>> handle)
|
||||
{
|
||||
cellVpost->Warning("cellVpostOpenEx(cfgParam_addr=0x%x, resource_addr=0x%x, handle_addr=0x%x)",
|
||||
cfgParam.addr(), resource.addr(), handle.addr());
|
||||
|
@ -71,11 +71,11 @@ int cellVpostClose(u32 handle)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const vm::ptr<CellVpostCtrlParam> ctrlParam,
|
||||
u32 outPicBuff_addr, vm::ptr<CellVpostPictureInfo> picInfo)
|
||||
int cellVpostExec(u32 handle, vm::ptr<const u8> inPicBuff, vm::ptr<const CellVpostCtrlParam> ctrlParam,
|
||||
vm::ptr<u8> outPicBuff, vm::ptr<CellVpostPictureInfo> picInfo)
|
||||
{
|
||||
cellVpost->Log("cellVpostExec(handle=0x%x, inPicBuff_addr=0x%x, ctrlParam_addr=0x%x, outPicBuff_addr=0x%x, picInfo_addr=0x%x)",
|
||||
handle, inPicBuff_addr, ctrlParam.addr(), outPicBuff_addr, picInfo.addr());
|
||||
handle, inPicBuff.addr(), ctrlParam.addr(), outPicBuff.addr(), picInfo.addr());
|
||||
|
||||
VpostInstance* vpost;
|
||||
if (!Emu.GetIdManager().GetIDData(handle, vpost))
|
||||
|
@ -137,9 +137,9 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const vm::ptr<CellVpostC
|
|||
|
||||
//u64 stamp2 = get_system_time();
|
||||
|
||||
u8* in_data[4] = { Memory.GetMemFromAddr(inPicBuff_addr), Memory.GetMemFromAddr(inPicBuff_addr + w*h), Memory.GetMemFromAddr(inPicBuff_addr + w*h + w*h / 4), pA.get() };
|
||||
const u8* in_data[4] = { &inPicBuff[0], &inPicBuff[w * h], &inPicBuff[w * h * 5 / 4], pA.get() };
|
||||
int in_line[4] = { w, w/2, w/2, w };
|
||||
u8* out_data[4] = { Memory.GetMemFromAddr(outPicBuff_addr), NULL, NULL, NULL };
|
||||
u8* out_data[4] = { outPicBuff.get_ptr(), NULL, NULL, NULL };
|
||||
int out_line[4] = { static_cast<int>(ow*4), 0, 0, 0 };
|
||||
|
||||
sws_scale(sws, in_data, in_line, 0, h, out_data, out_line);
|
||||
|
|
|
@ -22,10 +22,10 @@ u64 mixcount;
|
|||
|
||||
std::vector<SSPlayer> ssp;
|
||||
|
||||
int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, u32 addr, u32 samples)
|
||||
int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, vm::ptr<float> addr, u32 samples)
|
||||
{
|
||||
libmixer->Log("cellAANAddData(handle=%d, port=%d, offset=0x%x, addr=0x%x, samples=%d)",
|
||||
aan_handle, aan_port, offset, addr, samples);
|
||||
aan_handle, aan_port, offset, addr.addr(), samples);
|
||||
|
||||
u32 type = aan_port >> 16;
|
||||
u32 port = aan_port & 0xffff;
|
||||
|
@ -58,7 +58,7 @@ int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, u32 addr, u32 sampl
|
|||
// mono upmixing
|
||||
for (u32 i = 0; i < samples; i++)
|
||||
{
|
||||
const float center = *(be_t<float>*)&Memory[addr + i * sizeof(float)];
|
||||
const float center = addr[i];
|
||||
mixdata[i * 8 + 0] += center;
|
||||
mixdata[i * 8 + 1] += center;
|
||||
}
|
||||
|
@ -68,8 +68,8 @@ int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, u32 addr, u32 sampl
|
|||
// stereo upmixing
|
||||
for (u32 i = 0; i < samples; i++)
|
||||
{
|
||||
const float left = *(be_t<float>*)&Memory[addr + i * 2 * sizeof(float)];
|
||||
const float right = *(be_t<float>*)&Memory[addr + (i * 2 + 1) * sizeof(float)];
|
||||
const float left = addr[i * 2 + 0];
|
||||
const float right = addr[i * 2 + 1];
|
||||
mixdata[i * 8 + 0] += left;
|
||||
mixdata[i * 8 + 1] += right;
|
||||
}
|
||||
|
@ -79,12 +79,12 @@ int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, u32 addr, u32 sampl
|
|||
// 5.1 upmixing
|
||||
for (u32 i = 0; i < samples; i++)
|
||||
{
|
||||
const float left = *(be_t<float>*)&Memory[addr + i * 6 * sizeof(float)];
|
||||
const float right = *(be_t<float>*)&Memory[addr + (i * 6 + 1) * sizeof(float)];
|
||||
const float center = *(be_t<float>*)&Memory[addr + (i * 6 + 2) * sizeof(float)];
|
||||
const float low_freq = *(be_t<float>*)&Memory[addr + (i * 6 + 3) * sizeof(float)];
|
||||
const float rear_left = *(be_t<float>*)&Memory[addr + (i * 6 + 4) * sizeof(float)];
|
||||
const float rear_right = *(be_t<float>*)&Memory[addr + (i * 6 + 5) * sizeof(float)];
|
||||
const float left = addr[i * 6 + 0];
|
||||
const float right = addr[i * 6 + 1];
|
||||
const float center = addr[i * 6 + 2];
|
||||
const float low_freq = addr[i * 6 + 3];
|
||||
const float rear_left = addr[i * 6 + 4];
|
||||
const float rear_right = addr[i * 6 + 5];
|
||||
mixdata[i * 8 + 0] += left;
|
||||
mixdata[i * 8 + 1] += right;
|
||||
mixdata[i * 8 + 2] += center;
|
||||
|
@ -98,7 +98,7 @@ int cellAANAddData(u32 aan_handle, u32 aan_port, u32 offset, u32 addr, u32 sampl
|
|||
// 7.1
|
||||
for (u32 i = 0; i < samples * 8; i++)
|
||||
{
|
||||
mixdata[i] += *(be_t<float>*)&Memory[addr + i * sizeof(float)];
|
||||
mixdata[i] += addr[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ int cellSSPlayerGetState(u32 handle)
|
|||
return CELL_SSPLAYER_STATE_OFF;
|
||||
}
|
||||
|
||||
int cellSurMixerCreate(const vm::ptr<CellSurMixerConfig> config)
|
||||
int cellSurMixerCreate(vm::ptr<const CellSurMixerConfig> config)
|
||||
{
|
||||
libmixer->Warning("cellSurMixerCreate(config_addr=0x%x)", config.addr());
|
||||
|
||||
|
@ -435,7 +435,7 @@ int cellSurMixerCreate(const vm::ptr<CellSurMixerConfig> config)
|
|||
|
||||
//u64 stamp2 = get_system_time();
|
||||
|
||||
auto buf = (be_t<float>*)&Memory[m_config.m_buffer + (128 * 1024 * SUR_PORT) + (mixcount % port.block) * port.channel * 256 * sizeof(float)];
|
||||
auto buf = vm::get_ptr<be_t<float>>(m_config.m_buffer + (128 * 1024 * SUR_PORT) + (mixcount % port.block) * port.channel * 256 * sizeof(float));
|
||||
|
||||
for (u32 i = 0; i < (sizeof(mixdata) / sizeof(float)); i++)
|
||||
{
|
||||
|
|
|
@ -25,14 +25,11 @@ int sceNpTerm()
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr)
|
||||
int npDrmIsAvailable(u32 k_licensee_addr, vm::ptr<const char> drm_path)
|
||||
{
|
||||
sceNp->Warning("sceNpDrmIsAvailable(k_licensee_addr=0x%x, drm_path_addr=0x%x)", k_licensee_addr, drm_path_addr);
|
||||
|
||||
std::string drm_path = Memory.ReadString(drm_path_addr);
|
||||
if (!Emu.GetVFS().ExistsFile(drm_path))
|
||||
if (!Emu.GetVFS().ExistsFile(drm_path.get_ptr()))
|
||||
{
|
||||
sceNp->Warning("sceNpDrmIsAvailable(): '%s' not found", drm_path.c_str());
|
||||
sceNp->Warning("npDrmIsAvailable(): '%s' not found", drm_path.get_ptr());
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
|
@ -48,94 +45,24 @@ int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr)
|
|||
}
|
||||
}
|
||||
|
||||
sceNp->Warning("sceNpDrmIsAvailable: Found DRM license file at %s", drm_path.c_str());
|
||||
sceNp->Warning("sceNpDrmIsAvailable: Using k_licensee 0x%s", k_licensee_str.c_str());
|
||||
sceNp->Warning("npDrmIsAvailable: Found DRM license file at %s", drm_path.get_ptr());
|
||||
sceNp->Warning("npDrmIsAvailable: Using k_licensee 0x%s", k_licensee_str.c_str());
|
||||
|
||||
// Set the necessary file paths.
|
||||
std::string drm_file_name = fmt::AfterLast(drm_path,'/');
|
||||
std::string drm_file_name = fmt::AfterLast(drm_path.get_ptr(), '/');
|
||||
|
||||
// TODO: Make more explicit what this actually does (currently it copies "XXXXXXXX" from drm_path (== "/dev_hdd0/game/XXXXXXXXX/*" assumed)
|
||||
std::string titleID = drm_path.substr(15, 9);
|
||||
std::string titleID(&drm_path[15], 9);
|
||||
|
||||
// TODO: These shouldn't use current dir
|
||||
std::string enc_drm_path = drm_path;
|
||||
std::string dec_drm_path = "/dev_hdd1/" + titleID + "/" + drm_file_name;
|
||||
std::string rap_path = "/dev_usb000/";
|
||||
|
||||
// Search dev_usb000 for a compatible RAP file.
|
||||
vfsDir *raps_dir = new vfsDir(rap_path);
|
||||
if (!raps_dir->IsOpened())
|
||||
sceNp->Warning("sceNpDrmIsAvailable: Can't find RAP file for DRM!");
|
||||
else
|
||||
{
|
||||
const std::vector<DirEntryInfo> &entries = raps_dir->GetEntries();
|
||||
for (auto &entry: entries)
|
||||
{
|
||||
if (entry.name.find(titleID) != std::string::npos )
|
||||
{
|
||||
rap_path += entry.name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new directory under dev_hdd1/titleID to hold the decrypted data.
|
||||
// TODO: These shouldn't use current dir
|
||||
std::string tmp_dir = "./dev_hdd1/" + titleID;
|
||||
if (!rExists(tmp_dir))
|
||||
rMkdir("./dev_hdd1/" + titleID);
|
||||
|
||||
// Decrypt this EDAT using the supplied k_licensee and matching RAP file.
|
||||
std::string enc_drm_path_local, dec_drm_path_local, rap_path_local;
|
||||
Emu.GetVFS().GetDevice(enc_drm_path, enc_drm_path_local);
|
||||
Emu.GetVFS().GetDevice(dec_drm_path, dec_drm_path_local);
|
||||
Emu.GetVFS().GetDevice(rap_path, rap_path_local);
|
||||
|
||||
DecryptEDAT(enc_drm_path_local, dec_drm_path_local, 8, rap_path_local, k_licensee, false);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
int sceNpDrmIsAvailable2(u32 k_licensee_addr, u32 drm_path_addr)
|
||||
{
|
||||
sceNp->Warning("sceNpDrmIsAvailable2(k_licensee_addr=0x%x, drm_path_addr=0x%x)", k_licensee_addr, drm_path_addr);
|
||||
|
||||
std::string drm_path = Memory.ReadString(drm_path_addr);
|
||||
if (!Emu.GetVFS().ExistsFile(drm_path))
|
||||
{
|
||||
sceNp->Warning("sceNpDrmIsAvailable2(): '%s' not found", drm_path.c_str());
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
std::string k_licensee_str = "0";
|
||||
u8 k_licensee[0x10];
|
||||
|
||||
if (k_licensee_addr)
|
||||
{
|
||||
for (int i = 0; i < 0x10; i++)
|
||||
{
|
||||
k_licensee[i] = Memory.Read8(k_licensee_addr + i);
|
||||
k_licensee_str += fmt::Format("%02x", k_licensee[i]);
|
||||
}
|
||||
}
|
||||
|
||||
sceNp->Warning("sceNpDrmIsAvailable2: Found DRM license file at %s", drm_path.c_str());
|
||||
sceNp->Warning("sceNpDrmIsAvailable2: Using k_licensee 0x%s", k_licensee_str.c_str());
|
||||
|
||||
// Set the necessary file paths.
|
||||
std::string drm_file_name = fmt::AfterLast(drm_path, '/');
|
||||
|
||||
// TODO: Make more explicit what this actually does (currently it copies "XXXXXXXX" from drm_path (== "/dev_hdd0/game/XXXXXXXXX/*" assumed)
|
||||
std::string titleID = drm_path.substr(15, 9);
|
||||
|
||||
// TODO: These shouldn't use current dir
|
||||
std::string enc_drm_path = drm_path;
|
||||
std::string enc_drm_path = drm_path.get_ptr();
|
||||
std::string dec_drm_path = "/dev_hdd1/" + titleID + "/" + drm_file_name;
|
||||
std::string rap_path = "/dev_usb000/";
|
||||
|
||||
// Search dev_usb000 for a compatible RAP file.
|
||||
vfsDir *raps_dir = new vfsDir(rap_path);
|
||||
if (!raps_dir->IsOpened())
|
||||
sceNp->Warning("sceNpDrmIsAvailable2: Can't find RAP file for DRM!");
|
||||
sceNp->Warning("npDrmIsAvailable: Can't find RAP file for DRM!");
|
||||
else
|
||||
{
|
||||
const std::vector<DirEntryInfo> &entries = raps_dir->GetEntries();
|
||||
|
@ -165,6 +92,20 @@ int sceNpDrmIsAvailable2(u32 k_licensee_addr, u32 drm_path_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int sceNpDrmIsAvailable(u32 k_licensee_addr, vm::ptr<const char> drm_path)
|
||||
{
|
||||
sceNp->Warning("sceNpDrmIsAvailable(k_licensee_addr=0x%x, drm_path_addr=0x%x('%s'))", k_licensee_addr, drm_path.addr(), drm_path.get_ptr());
|
||||
|
||||
return npDrmIsAvailable(k_licensee_addr, drm_path);
|
||||
}
|
||||
|
||||
int sceNpDrmIsAvailable2(u32 k_licensee_addr, vm::ptr<const char> drm_path)
|
||||
{
|
||||
sceNp->Warning("sceNpDrmIsAvailable2(k_licensee_addr=0x%x, drm_path_addr=0x%x('%s'))", k_licensee_addr, drm_path.addr(), drm_path.get_ptr());
|
||||
|
||||
return npDrmIsAvailable(k_licensee_addr, drm_path);
|
||||
}
|
||||
|
||||
int sceNpDrmVerifyUpgradeLicense(u32 content_id_addr)
|
||||
{
|
||||
UNIMPLEMENTED_FUNC(sceNp);
|
||||
|
|
|
@ -117,16 +117,15 @@ int sys_spu_image_close(vm::ptr<sys_spu_image> img)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int sys_raw_spu_load(int id, u32 path_addr, vm::ptr<be_t<u32>> entry)
|
||||
int sys_raw_spu_load(s32 id, vm::ptr<const char> path, vm::ptr<be_t<u32>> entry)
|
||||
{
|
||||
const std::string path = Memory.ReadString(path_addr);
|
||||
sysPrxForUser->Warning("sys_raw_spu_load(id=0x%x, path=0x%x [%s], entry_addr=0x%x)",
|
||||
id, path_addr, path.c_str(), entry.addr());
|
||||
sysPrxForUser->Warning("sys_raw_spu_load(id=0x%x, path_addr=0x%x('%s'), entry_addr=0x%x)",
|
||||
id, path.addr(), path.get_ptr(), entry.addr());
|
||||
|
||||
vfsFile f(path);
|
||||
vfsFile f(path.get_ptr());
|
||||
if(!f.IsOpened())
|
||||
{
|
||||
sysPrxForUser->Error("sys_raw_spu_load error: '%s' not found!", path.c_str());
|
||||
sysPrxForUser->Error("sys_raw_spu_load error: '%s' not found!", path.get_ptr());
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
|
@ -143,83 +142,84 @@ int sys_raw_spu_image_load(int id, vm::ptr<sys_spu_image> img)
|
|||
{
|
||||
sysPrxForUser->Warning("sys_raw_spu_image_load(id=0x%x, img_addr=0x%x)", id, img.addr());
|
||||
|
||||
memcpy(Memory + (RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id), Memory + (u32)img->segs_addr, 256 * 1024);
|
||||
// TODO: use segment info
|
||||
memcpy(vm::get_ptr<void>(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id), vm::get_ptr<void>(img->segs_addr), 256 * 1024);
|
||||
Memory.Write32(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id + RAW_SPU_PROB_OFFSET + SPU_NPC_offs, (u32)img->entry_point);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
u32 _sys_memset(u32 addr, s32 value, u32 size)
|
||||
vm::ptr<void> _sys_memset(vm::ptr<void> dst, s32 value, u32 size)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_memset(addr=0x%x, value=%d, size=%d)", addr, value, size);
|
||||
sysPrxForUser->Log("_sys_memset(dst_addr=0x%x, value=%d, size=%d)", dst.addr(), value, size);
|
||||
|
||||
memset(Memory + addr, value, size);
|
||||
return addr;
|
||||
memset(dst.get_ptr(), value, size);
|
||||
return dst;
|
||||
}
|
||||
|
||||
u32 _sys_memcpy(u32 dest, u32 source, u32 size)
|
||||
vm::ptr<void> _sys_memcpy(vm::ptr<void> dst, vm::ptr<const void> src, u32 size)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_memcpy(dest=0x%x, source=0x%x, size=%d)", dest, source, size);
|
||||
sysPrxForUser->Log("_sys_memcpy(dst_addr=0x%x, src_addr=0x%x, size=%d)", dst.addr(), src.addr(), size);
|
||||
|
||||
memcpy(Memory + dest, Memory + source, size);
|
||||
memcpy(dst.get_ptr(), src.get_ptr(), size);
|
||||
return dst;
|
||||
}
|
||||
|
||||
s32 _sys_memcmp(vm::ptr<const void> buf1, vm::ptr<const void> buf2, u32 size)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_memcmp(buf1_addr=0x%x, buf2_addr=0x%x, size=%d)", buf1.addr(), buf2.addr(), size);
|
||||
|
||||
return memcmp(buf1.get_ptr(), buf2.get_ptr(), size);
|
||||
}
|
||||
|
||||
s64 _sys_strlen(vm::ptr<const char> str)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_strlen(str_addr=0x%x)", str.addr());
|
||||
|
||||
return strlen(str.get_ptr());
|
||||
}
|
||||
|
||||
s32 _sys_strncmp(vm::ptr<const char> str1, vm::ptr<const char> str2, s32 max)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_strncmp(str1_addr=0x%x, str2_addr=0x%x, max=%d)", str1.addr(), str2.addr(), max);
|
||||
|
||||
return strncmp(str1.get_ptr(), str2.get_ptr(), max);
|
||||
}
|
||||
|
||||
vm::ptr<char> _sys_strcat(vm::ptr<char> dest, vm::ptr<const char> source)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_strcat(dest_addr=0x%x, source_addr=0x%x)", dest.addr(), source.addr());
|
||||
|
||||
assert(strcat(dest.get_ptr(), source.get_ptr()) == dest.get_ptr());
|
||||
return dest;
|
||||
}
|
||||
|
||||
s32 _sys_memcmp(u32 addr1, u32 addr2, u32 size)
|
||||
vm::ptr<char> _sys_strncat(vm::ptr<char> dest, vm::ptr<const char> source, u32 len)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_memcmp(addr1=0x%x, addr2=0x%x, size=%d)", addr1, addr2, size);
|
||||
sysPrxForUser->Log("_sys_strncat(dest_addr=0x%x, source_addr=0x%x, len=%d)", dest.addr(), source.addr(), len);
|
||||
|
||||
return memcmp(Memory + addr1, Memory + addr2, size);
|
||||
}
|
||||
|
||||
s64 _sys_strlen(u32 addr)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_strlen(addr=0x%x)", addr);
|
||||
|
||||
return strlen((char*)(Memory + addr));
|
||||
}
|
||||
|
||||
s32 _sys_strncmp(u32 str1, u32 str2, s32 max)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_strncmp(str1=0x%x, str2=0x%x, max=%d)", str1, str2, max);
|
||||
|
||||
return strncmp((char*)(Memory + str1), (char*)(Memory + str2), max);
|
||||
}
|
||||
|
||||
u32 _sys_strcat(u32 dest, u32 source)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_strcat(dest=0x%x, source=0x%x)", dest, source);
|
||||
|
||||
assert(Memory.RealToVirtualAddr(strcat((char*)(Memory + dest), (char*)(Memory + source))) == dest);
|
||||
assert(strncat(dest.get_ptr(), source.get_ptr(), len) == dest.get_ptr());
|
||||
return dest;
|
||||
}
|
||||
|
||||
u32 _sys_strncat(u32 dest, u32 source, u32 len)
|
||||
vm::ptr<char> _sys_strcpy(vm::ptr<char> dest, vm::ptr<const char> source)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_strncat(dest=0x%x, source=0x%x, len=%d)", dest, source, len);
|
||||
sysPrxForUser->Log("_sys_strcpy(dest_addr=0x%x, source_addr=0x%x)", dest.addr(), source.addr());
|
||||
|
||||
assert(Memory.RealToVirtualAddr(strncat((char*)(Memory + dest), (char*)(Memory + source), len)) == dest);
|
||||
assert(strcpy(dest.get_ptr(), source.get_ptr()) == dest.get_ptr());
|
||||
return dest;
|
||||
}
|
||||
|
||||
u32 _sys_strcpy(u32 dest, u32 source)
|
||||
vm::ptr<char> _sys_strncpy(vm::ptr<char> dest, vm::ptr<const char> source, u32 len)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_strcpy(dest=0x%x, source=0x%x)", dest, source);
|
||||
|
||||
assert(Memory.RealToVirtualAddr(strcpy((char*)(Memory + dest), (char*)(Memory + source))) == dest);
|
||||
return dest;
|
||||
}
|
||||
|
||||
u32 _sys_strncpy(u32 dest, u32 source, u32 len)
|
||||
{
|
||||
sysPrxForUser->Log("_sys_strncpy(dest=0x%x, source=0x%x, len=%d)", dest, source, len);
|
||||
sysPrxForUser->Log("_sys_strncpy(dest_addr=0x%x, source_addr=0x%x, len=%d)", dest.addr(), source.addr(), len);
|
||||
|
||||
if (!dest || !source)
|
||||
{
|
||||
return 0;
|
||||
return vm::ptr<char>::make(0);
|
||||
}
|
||||
|
||||
assert(Memory.RealToVirtualAddr(strncpy((char*)(Memory + dest), (char*)(Memory + source), len)) == dest);
|
||||
assert(strncpy(dest.get_ptr(), source.get_ptr(), len) == dest.get_ptr());
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
@ -299,12 +299,12 @@ s64 _sys_spu_printf_detach_thread(u32 arg)
|
|||
return GetCurrentPPUThread().FastCall(Memory.Read32(spu_printf_dtcb), Memory.Read32(spu_printf_dtcb + 4), arg);
|
||||
}
|
||||
|
||||
s32 _sys_printf(u32 arg1)
|
||||
s32 _sys_printf(vm::ptr<const char> fmt)
|
||||
{
|
||||
sysPrxForUser->Todo("_sys_printf(arg1=0x%x)", arg1);
|
||||
sysPrxForUser->Todo("_sys_printf(fmt_addr=0x%x, ...)", fmt.addr());
|
||||
|
||||
// probably, assertion failed
|
||||
sysPrxForUser->Warning("_sys_printf: \n%s", (char*)(Memory + arg1));
|
||||
sysPrxForUser->Warning("_sys_printf: \n%s", fmt.get_ptr());
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,4 +15,4 @@ struct HeapInfo
|
|||
};
|
||||
|
||||
// SysCalls
|
||||
u32 _sys_memset(u32 addr, s32 value, u32 size);
|
||||
vm::ptr<void> _sys_memset(vm::ptr<void> dst, s32 value, u32 size);
|
||||
|
|
|
@ -110,11 +110,10 @@ int sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil
|
|||
}
|
||||
|
||||
|
||||
int cellFsSdataOpen(u32 path_addr, int flags, vm::ptr<be_t<u32>> fd, vm::ptr<be_t<u32>> arg, u64 size)
|
||||
int cellFsSdataOpen(vm::ptr<const char> path, int flags, vm::ptr<be_t<u32>> fd, vm::ptr<be_t<u32>> arg, u64 size)
|
||||
{
|
||||
const std::string& path = Memory.ReadString(path_addr);
|
||||
sys_fs->Warning("cellFsSdataOpen(path=\"%s\", flags=0x%x, fd_addr=0x%x, arg_addr=0x%x, size=0x%llx) -> cellFsOpen()",
|
||||
path.c_str(), flags, fd.addr(), arg.addr(), size);
|
||||
path.get_ptr(), flags, fd.addr(), arg.addr(), size);
|
||||
|
||||
/*if (flags != CELL_O_RDONLY)
|
||||
return CELL_EINVAL;
|
||||
|
@ -133,7 +132,7 @@ int cellFsSdataOpen(u32 path_addr, int flags, vm::ptr<be_t<u32>> fd, vm::ptr<be_
|
|||
|
||||
return CELL_OK;*/
|
||||
|
||||
return cellFsOpen(path_addr, flags, fd, arg, size);
|
||||
return cellFsOpen(path, flags, fd, arg, size);
|
||||
}
|
||||
|
||||
int cellFsSdataOpenByFd(int mself_fd, int flags, vm::ptr<be_t<u32>> sdata_fd, u64 offset, vm::ptr<be_t<u32>> arg, u64 size)
|
||||
|
@ -162,34 +161,40 @@ void fsAioRead(u32 fd, vm::ptr<CellFsAio> aio, int xid, vm::ptr<void (*)(vm::ptr
|
|||
}
|
||||
}
|
||||
|
||||
vfsFileBase* orig_file;
|
||||
if(!sys_fs->CheckId(fd, orig_file)) return;
|
||||
|
||||
u64 nbytes = aio->size;
|
||||
u32 buf_addr = aio->buf_addr;
|
||||
|
||||
u32 error = CELL_OK;
|
||||
|
||||
vfsStream& file = *(vfsStream*)orig_file;
|
||||
const u64 old_pos = file.Tell();
|
||||
file.Seek((u64)aio->offset);
|
||||
|
||||
// TODO: use code from cellFsRead or something
|
||||
|
||||
u64 res = 0;
|
||||
if (nbytes != (u32)nbytes)
|
||||
{
|
||||
error = CELL_ENOMEM;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = nbytes ? file.Read(Memory.GetMemFromAddr(buf_addr), nbytes) : 0;
|
||||
}
|
||||
LV2_LOCK(0);
|
||||
|
||||
file.Seek(old_pos);
|
||||
vfsFileBase* orig_file;
|
||||
if (!sys_fs->CheckId(fd, orig_file))
|
||||
{
|
||||
sys_fs->Error("Wrong fd (%s)", fd);
|
||||
Emu.Pause();
|
||||
return;
|
||||
}
|
||||
|
||||
sys_fs->Log("*** fsAioRead(fd=%d, offset=0x%llx, buf_addr=0x%x, size=0x%x, error=0x%x, res=0x%x, xid=0x%x [%s])",
|
||||
fd, (u64)aio->offset, buf_addr, (u64)aio->size, error, res, xid, orig_file->GetPath().c_str());
|
||||
u64 nbytes = aio->size;
|
||||
|
||||
vfsStream& file = *(vfsStream*)orig_file;
|
||||
const u64 old_pos = file.Tell();
|
||||
file.Seek((u64)aio->offset);
|
||||
|
||||
// TODO: use code from cellFsRead or something
|
||||
if (nbytes != (u32)nbytes)
|
||||
{
|
||||
error = CELL_ENOMEM;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = nbytes ? file.Read(aio->buf.get_ptr(), nbytes) : 0;
|
||||
}
|
||||
|
||||
file.Seek(old_pos);
|
||||
|
||||
sys_fs->Log("*** fsAioRead(fd=%d, offset=0x%llx, buf_addr=0x%x, size=0x%x, error=0x%x, res=0x%x, xid=0x%x [%s])",
|
||||
fd, (u64)aio->offset, aio->buf.addr(), (u64)aio->size, error, res, xid, orig_file->GetPath().c_str());
|
||||
}
|
||||
|
||||
if (func) // start callback thread
|
||||
{
|
||||
|
@ -203,6 +208,8 @@ int cellFsAioRead(vm::ptr<CellFsAio> aio, vm::ptr<be_t<u32>> aio_id, vm::ptr<voi
|
|||
{
|
||||
sys_fs->Warning("cellFsAioRead(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.addr(), aio_id.addr(), func.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
if (!aio_init)
|
||||
{
|
||||
return CELL_ENXIO;
|
||||
|
@ -232,6 +239,8 @@ int cellFsAioWrite(vm::ptr<CellFsAio> aio, vm::ptr<be_t<u32>> aio_id, vm::ptr<vo
|
|||
{
|
||||
sys_fs->Todo("cellFsAioWrite(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.addr(), aio_id.addr(), func.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
// TODO:
|
||||
|
||||
return CELL_OK;
|
||||
|
@ -240,6 +249,9 @@ int cellFsAioWrite(vm::ptr<CellFsAio> aio, vm::ptr<be_t<u32>> aio_id, vm::ptr<vo
|
|||
int cellFsAioInit(vm::ptr<const char> mount_point)
|
||||
{
|
||||
sys_fs->Warning("cellFsAioInit(mount_point_addr=0x%x (%s))", mount_point.addr(), mount_point.get_ptr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
aio_init = true;
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -247,14 +259,19 @@ int cellFsAioInit(vm::ptr<const char> mount_point)
|
|||
int cellFsAioFinish(vm::ptr<const char> mount_point)
|
||||
{
|
||||
sys_fs->Warning("cellFsAioFinish(mount_point_addr=0x%x (%s))", mount_point.addr(), mount_point.get_ptr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
aio_init = false;
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
int cellFsReadWithOffset(u32 fd, u64 offset, u32 buf_addr, u64 buffer_size, vm::ptr<be_t<u64>> nread)
|
||||
int cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr<void> buf, u64 buffer_size, vm::ptr<be_t<u64>> nread)
|
||||
{
|
||||
sys_fs->Warning("cellFsReadWithOffset(fd=%d, offset=0x%llx, buf_addr=0x%x, buffer_size=%lld nread=0x%llx)",
|
||||
fd, offset, buf_addr, buffer_size, nread.addr());
|
||||
fd, offset, buf.addr(), buffer_size, nread.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
int ret;
|
||||
vm::var<be_t<u64>> oldPos, newPos;
|
||||
|
@ -262,7 +279,7 @@ int cellFsReadWithOffset(u32 fd, u64 offset, u32 buf_addr, u64 buffer_size, vm::
|
|||
if (ret) return ret;
|
||||
ret = cellFsLseek(fd, offset, CELL_SEEK_SET, newPos); // Move to the specified offset
|
||||
if (ret) return ret;
|
||||
ret = cellFsRead(fd, buf_addr, buffer_size, nread); // Read the file
|
||||
ret = cellFsRead(fd, buf, buffer_size, nread); // Read the file
|
||||
if (ret) return ret;
|
||||
ret = cellFsLseek(fd, oldPos.value(), CELL_SEEK_SET, newPos); // Return to the old position
|
||||
if (ret) return ret;
|
||||
|
@ -317,5 +334,7 @@ void sys_fs_init()
|
|||
|
||||
void sys_fs_load()
|
||||
{
|
||||
g_FsAioReadID = 0;
|
||||
g_FsAioReadCur = 0;
|
||||
aio_init = false;
|
||||
}
|
||||
|
|
|
@ -1,66 +1,17 @@
|
|||
#include "stdafx.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/SysCalls/Modules.h"
|
||||
|
||||
#include "SC_Keyboard.h"
|
||||
#include "SC_Mouse.h"
|
||||
|
||||
//void sys_io_init();
|
||||
//Module sys_io(0x0017, sys_io_init);
|
||||
Module *sys_io = nullptr;
|
||||
|
||||
//cellPad
|
||||
extern int cellPadInit(u32 max_connect);
|
||||
extern int cellPadEnd();
|
||||
extern int cellPadClearBuf(u32 port_no);
|
||||
extern int cellPadGetData(u32 port_no, u32 data_addr);
|
||||
extern int cellPadGetDataExtra(u32 port_no, u32 device_type_addr, u32 data_addr);
|
||||
extern int cellPadSetActDirect(u32 port_no, u32 param_addr);
|
||||
extern int cellPadGetInfo(u32 info_addr);
|
||||
extern int cellPadGetInfo2(u32 info_addr);
|
||||
extern int cellPadSetPortSetting(u32 port_no, u32 port_setting);
|
||||
extern int cellPadInfoPressMode(u32 port_no);
|
||||
extern int cellPadInfoSensorMode(u32 port_no);
|
||||
extern int cellPadSetPressMode(u32 port_no, u32 mode);
|
||||
extern int cellPadSetSensorMode(u32 port_no, u32 mode);
|
||||
extern int cellPadGetCapabilityInfo(u32 port_no, vm::ptr<be_t<u32>> info_addr);
|
||||
extern void cellPad_init();
|
||||
extern void cellKb_init();
|
||||
extern void cellMouse_init();
|
||||
|
||||
void sys_io_init()
|
||||
{
|
||||
sys_io->AddFunc(0x1cf98800, cellPadInit);
|
||||
sys_io->AddFunc(0x4d9b75d5, cellPadEnd);
|
||||
sys_io->AddFunc(0x0d5f2c14, cellPadClearBuf);
|
||||
sys_io->AddFunc(0x8b72cda1, cellPadGetData);
|
||||
sys_io->AddFunc(0x6bc09c61, cellPadGetDataExtra);
|
||||
sys_io->AddFunc(0xf65544ee, cellPadSetActDirect);
|
||||
sys_io->AddFunc(0x3aaad464, cellPadGetInfo);
|
||||
sys_io->AddFunc(0xa703a51d, cellPadGetInfo2);
|
||||
sys_io->AddFunc(0x578e3c98, cellPadSetPortSetting);
|
||||
sys_io->AddFunc(0x0e2dfaad, cellPadInfoPressMode);
|
||||
sys_io->AddFunc(0x78200559, cellPadInfoSensorMode);
|
||||
sys_io->AddFunc(0xf83f8182, cellPadSetPressMode);
|
||||
sys_io->AddFunc(0xbe5be3ba, cellPadSetSensorMode);
|
||||
sys_io->AddFunc(0xdbf4c59c, cellPadGetCapabilityInfo);
|
||||
|
||||
sys_io->AddFunc(0x433f6ec0, cellKbInit);
|
||||
sys_io->AddFunc(0xbfce3285, cellKbEnd);
|
||||
sys_io->AddFunc(0x2073b7f6, cellKbClearBuf);
|
||||
sys_io->AddFunc(0x4ab1fa77, cellKbCnvRawCode);
|
||||
sys_io->AddFunc(0x2f1774d5, cellKbGetInfo);
|
||||
sys_io->AddFunc(0xff0a21b7, cellKbRead);
|
||||
sys_io->AddFunc(0xa5f85e4d, cellKbSetCodeType);
|
||||
sys_io->AddFunc(0x3f72c56e, cellKbSetLEDStatus);
|
||||
sys_io->AddFunc(0xdeefdfa7, cellKbSetReadMode);
|
||||
sys_io->AddFunc(0x1f71ecbe, cellKbGetConfiguration);
|
||||
|
||||
sys_io->AddFunc(0xc9030138, cellMouseInit);
|
||||
sys_io->AddFunc(0x3ef66b95, cellMouseClearBuf);
|
||||
sys_io->AddFunc(0xe10183ce, cellMouseEnd);
|
||||
sys_io->AddFunc(0x5baf30fb, cellMouseGetInfo);
|
||||
sys_io->AddFunc(0x4d0b3b1f, cellMouseInfoTabletMode);
|
||||
sys_io->AddFunc(0x3138e632, cellMouseGetData);
|
||||
sys_io->AddFunc(0x6bd131f0, cellMouseGetDataList);
|
||||
sys_io->AddFunc(0x2d16da4f, cellMouseSetTabletMode);
|
||||
sys_io->AddFunc(0x21a62e9b, cellMouseGetTabletDataList);
|
||||
sys_io->AddFunc(0xa328cc35, cellMouseGetRawData);
|
||||
cellPad_init();
|
||||
cellKb_init();
|
||||
cellMouse_init();
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ using pck_len_t = u32;
|
|||
#endif
|
||||
|
||||
// Functions
|
||||
int sys_net_accept(s32 s, vm::ptr<sys_net_sockaddr> addr, vm::ptr<be_t<u32>> paddrlen)
|
||||
int sys_net_accept(s32 s, vm::ptr<sys_net_sockaddr> addr, vm::ptr<pck_len_t> paddrlen)
|
||||
{
|
||||
sys_net->Warning("accept(s=%d, family_addr=0x%x, paddrlen=0x%x)", s, addr.addr(), paddrlen.addr());
|
||||
if (!addr) {
|
||||
|
@ -106,8 +106,9 @@ int sys_net_accept(s32 s, vm::ptr<sys_net_sockaddr> addr, vm::ptr<be_t<u32>> pad
|
|||
sockaddr _addr;
|
||||
memcpy(&_addr, addr.get_ptr(), sizeof(sockaddr));
|
||||
_addr.sa_family = addr->sa_family;
|
||||
pck_len_t *_paddrlen = (pck_len_t *)Memory.VirtualToRealAddr(paddrlen.addr());
|
||||
int ret = accept(s, &_addr, _paddrlen);
|
||||
pck_len_t _paddrlen;
|
||||
int ret = accept(s, &_addr, &_paddrlen);
|
||||
*paddrlen = _paddrlen;
|
||||
*g_lastError = getLastError();
|
||||
return ret;
|
||||
}
|
||||
|
@ -217,12 +218,11 @@ int inet_ntop()
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int sys_net_inet_pton(s32 af, u32 src_addr, u32 dst_addr)
|
||||
int sys_net_inet_pton(s32 af, vm::ptr<const char> src, vm::ptr<char> dst)
|
||||
{
|
||||
sys_net->Warning("inet_pton(af=%d, src_addr=0x%x, dst_addr=0x%x)", af, src_addr, dst_addr);
|
||||
char *src = (char *)Memory.VirtualToRealAddr(src_addr);
|
||||
char *dst = (char *)Memory.VirtualToRealAddr(dst_addr);
|
||||
return inet_pton(af, src, dst);
|
||||
sys_net->Warning("inet_pton(af=%d, src_addr=0x%x, dst_addr=0x%x)", af, src.addr(), dst.addr());
|
||||
|
||||
return inet_pton(af, src.get_ptr(), dst.get_ptr());
|
||||
}
|
||||
|
||||
int sys_net_listen(s32 s, s32 backlog)
|
||||
|
@ -233,26 +233,26 @@ int sys_net_listen(s32 s, s32 backlog)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sys_net_recv(s32 s, u32 buf_addr, u32 len, s32 flags)
|
||||
int sys_net_recv(s32 s, vm::ptr<char> buf, u32 len, s32 flags)
|
||||
{
|
||||
sys_net->Warning("recv(s=%d, buf_addr=0x%x, len=%d, flags=0x%x)", s, buf_addr, len, flags);
|
||||
char *buf = (char *)Memory.VirtualToRealAddr(buf_addr);
|
||||
int ret = recv(s, buf, len, flags);
|
||||
sys_net->Warning("recv(s=%d, buf_addr=0x%x, len=%d, flags=0x%x)", s, buf.addr(), len, flags);
|
||||
|
||||
int ret = recv(s, buf.get_ptr(), len, flags);
|
||||
*g_lastError = getLastError();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int sys_net_recvfrom(s32 s, u32 buf_addr, u32 len, s32 flags, vm::ptr<sys_net_sockaddr> addr, vm::ptr<be_t<u32>> paddrlen)
|
||||
int sys_net_recvfrom(s32 s, vm::ptr<char> buf, u32 len, s32 flags, vm::ptr<sys_net_sockaddr> addr, vm::ptr<pck_len_t> paddrlen)
|
||||
{
|
||||
sys_net->Warning("recvfrom(s=%d, buf_addr=0x%x, len=%u, flags=0x%x, addr_addr=0x%x, paddrlen=0x%x)",
|
||||
s, buf_addr, len, flags, addr.addr(), paddrlen.addr());
|
||||
s, buf.addr(), len, flags, addr.addr(), paddrlen.addr());
|
||||
|
||||
char *_buf_addr = (char *)Memory.VirtualToRealAddr(buf_addr);
|
||||
sockaddr _addr;
|
||||
memcpy(&_addr, addr.get_ptr(), sizeof(sockaddr));
|
||||
_addr.sa_family = addr->sa_family;
|
||||
pck_len_t *_paddrlen = (pck_len_t *) Memory.VirtualToRealAddr(paddrlen.addr());
|
||||
int ret = recvfrom(s, _buf_addr, len, flags, &_addr, _paddrlen);
|
||||
pck_len_t _paddrlen;
|
||||
int ret = recvfrom(s, buf.get_ptr(), len, flags, &_addr, &_paddrlen);
|
||||
*paddrlen = _paddrlen;
|
||||
*g_lastError = getLastError();
|
||||
return ret;
|
||||
}
|
||||
|
@ -263,11 +263,11 @@ int recvmsg()
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int sys_net_send(s32 s, u32 buf_addr, u32 len, s32 flags)
|
||||
int sys_net_send(s32 s, vm::ptr<const char> buf, u32 len, s32 flags)
|
||||
{
|
||||
sys_net->Warning("send(s=%d, buf_addr=0x%x, len=%d, flags=0x%x)", s, buf_addr, len, flags);
|
||||
char *buf = (char *)Memory.VirtualToRealAddr(buf_addr);
|
||||
int ret = send(s, buf, len, flags);
|
||||
sys_net->Warning("send(s=%d, buf_addr=0x%x, len=%d, flags=0x%x)", s, buf.addr(), len, flags);
|
||||
|
||||
int ret = send(s, buf.get_ptr(), len, flags);
|
||||
*g_lastError = getLastError();
|
||||
return ret;
|
||||
}
|
||||
|
@ -278,25 +278,24 @@ int sendmsg()
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
int sys_net_sendto(s32 s, u32 buf_addr, u32 len, s32 flags, vm::ptr<sys_net_sockaddr> addr, u32 addrlen)
|
||||
int sys_net_sendto(s32 s, vm::ptr<const char> buf, u32 len, s32 flags, vm::ptr<sys_net_sockaddr> addr, u32 addrlen)
|
||||
{
|
||||
sys_net->Warning("sendto(s=%d, buf_addr=0x%x, len=%u, flags=0x%x, addr=0x%x, addrlen=%u)",
|
||||
s, buf_addr, len, flags, addr.addr(), addrlen);
|
||||
s, buf.addr(), len, flags, addr.addr(), addrlen);
|
||||
|
||||
char *_buf_addr = (char *)Memory.VirtualToRealAddr(buf_addr);
|
||||
sockaddr _addr;
|
||||
memcpy(&_addr, addr.get_ptr(), sizeof(sockaddr));
|
||||
_addr.sa_family = addr->sa_family;
|
||||
int ret = sendto(s, _buf_addr, len, flags, &_addr, addrlen);
|
||||
int ret = sendto(s, buf.get_ptr(), len, flags, &_addr, addrlen);
|
||||
*g_lastError = getLastError();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int sys_net_setsockopt(s32 s, s32 level, s32 optname, u32 optval_addr, u32 optlen)
|
||||
int sys_net_setsockopt(s32 s, s32 level, s32 optname, vm::ptr<const char> optval, u32 optlen)
|
||||
{
|
||||
sys_net->Warning("socket(s=%d, level=%d, optname=%d, optval_addr=0x%x, optlen=%u)", s, level, optname, optval_addr, optlen);
|
||||
char *_optval_addr = (char *)Memory.VirtualToRealAddr(optval_addr);
|
||||
int ret = setsockopt(s, level, optname, _optval_addr, optlen);
|
||||
sys_net->Warning("socket(s=%d, level=%d, optname=%d, optval_addr=0x%x, optlen=%u)", s, level, optname, optval.addr(), optlen);
|
||||
|
||||
int ret = setsockopt(s, level, optname, optval.get_ptr(), optlen);
|
||||
*g_lastError = getLastError();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -30,20 +30,20 @@ struct FsRingBufferConfig
|
|||
} fs_config;
|
||||
|
||||
|
||||
s32 cellFsOpen(u32 path_addr, s32 flags, vm::ptr<be_t<u32>> fd, vm::ptr<be_t<u32>> arg, u64 size)
|
||||
s32 cellFsOpen(vm::ptr<const char> path, s32 flags, vm::ptr<be_t<u32>> fd, vm::ptr<be_t<u32>> arg, u64 size)
|
||||
{
|
||||
const std::string& path = Memory.ReadString(path_addr);
|
||||
sys_fs->Log("cellFsOpen(path=\"%s\", flags=0x%x, fd_addr=0x%x, arg_addr=0x%x, size=0x%llx)",
|
||||
path.c_str(), flags, fd.addr(), arg.addr(), size);
|
||||
path.get_ptr(), flags, fd.addr(), arg.addr(), size);
|
||||
|
||||
const std::string& ppath = path;
|
||||
//ConLog.Warning("path: %s [%s]", ppath.c_str(), path.c_str());
|
||||
const std::string _path = path.get_ptr();
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
s32 _oflags = flags;
|
||||
if(flags & CELL_O_CREAT)
|
||||
{
|
||||
_oflags &= ~CELL_O_CREAT;
|
||||
Emu.GetVFS().CreateFile(ppath);
|
||||
Emu.GetVFS().CreateFile(_path);
|
||||
}
|
||||
|
||||
vfsOpenMode o_mode;
|
||||
|
@ -81,7 +81,7 @@ s32 cellFsOpen(u32 path_addr, s32 flags, vm::ptr<be_t<u32>> fd, vm::ptr<be_t<u32
|
|||
{
|
||||
_oflags &= ~CELL_O_TRUNC;
|
||||
//truncate file before opening it as read/write
|
||||
auto filePtr = Emu.GetVFS().OpenFile(ppath, vfsWrite);
|
||||
auto filePtr = Emu.GetVFS().OpenFile(_path, vfsWrite);
|
||||
delete filePtr;
|
||||
}
|
||||
o_mode = vfsReadWrite;
|
||||
|
@ -90,36 +90,39 @@ s32 cellFsOpen(u32 path_addr, s32 flags, vm::ptr<be_t<u32>> fd, vm::ptr<be_t<u32
|
|||
|
||||
if(_oflags != 0)
|
||||
{
|
||||
sys_fs->Error("\"%s\" has unknown flags! flags: 0x%08x", ppath.c_str(), flags);
|
||||
sys_fs->Error("\"%s\" has unknown flags! flags: 0x%08x", path.get_ptr(), flags);
|
||||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
if (!Emu.GetVFS().ExistsFile(ppath))
|
||||
if (!Emu.GetVFS().ExistsFile(_path))
|
||||
{
|
||||
sys_fs->Error("\"%s\" not found! flags: 0x%08x", ppath.c_str(), flags);
|
||||
sys_fs->Error("\"%s\" not found! flags: 0x%08x", path.get_ptr(), flags);
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
vfsFileBase* stream = Emu.GetVFS().OpenFile(ppath, o_mode);
|
||||
vfsFileBase* stream = Emu.GetVFS().OpenFile(_path, o_mode);
|
||||
|
||||
if(!stream || !stream->IsOpened())
|
||||
{
|
||||
delete stream;
|
||||
sys_fs->Error("\"%s\" not found! flags: 0x%08x", ppath.c_str(), flags);
|
||||
sys_fs->Error("\"%s\" not found! flags: 0x%08x", path.get_ptr(), flags);
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
u32 id = sys_fs->GetNewId(stream, TYPE_FS_FILE);
|
||||
*fd = id;
|
||||
sys_fs->Notice("\"%s\" opened: fd = %d", path.c_str(), id);
|
||||
sys_fs->Notice("\"%s\" opened: fd = %d", path.get_ptr(), id);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellFsRead(u32 fd, u32 buf_addr, u64 nbytes, vm::ptr<be_t<u64>> nread)
|
||||
s32 cellFsRead(u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<be_t<u64>> nread)
|
||||
{
|
||||
sys_fs->Log("cellFsRead(fd=%d, buf_addr=0x%x, nbytes=0x%llx, nread_addr=0x%x)",
|
||||
fd, buf_addr, nbytes, nread.addr());
|
||||
fd, buf.addr(), nbytes, nread.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
@ -127,17 +130,20 @@ s32 cellFsRead(u32 fd, u32 buf_addr, u64 nbytes, vm::ptr<be_t<u64>> nread)
|
|||
|
||||
// TODO: checks
|
||||
|
||||
const u64 res = nbytes ? file->Read(Memory.GetMemFromAddr(buf_addr), nbytes) : 0;
|
||||
const u64 res = nbytes ? file->Read(buf.get_ptr(), nbytes) : 0;
|
||||
|
||||
if (nread) *nread = res;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellFsWrite(u32 fd, u32 buf_addr, u64 nbytes, vm::ptr<be_t<u64>> nwrite)
|
||||
s32 cellFsWrite(u32 fd, vm::ptr<const void> buf, u64 nbytes, vm::ptr<be_t<u64>> nwrite)
|
||||
{
|
||||
sys_fs->Log("cellFsWrite(fd=%d, buf_addr=0x%x, nbytes=0x%llx, nwrite_addr=0x%x)",
|
||||
fd, buf_addr, nbytes, nwrite.addr());
|
||||
fd, buf.addr(), nbytes, nwrite.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
@ -145,7 +151,7 @@ s32 cellFsWrite(u32 fd, u32 buf_addr, u64 nbytes, vm::ptr<be_t<u64>> nwrite)
|
|||
|
||||
// TODO: checks
|
||||
|
||||
const u64 res = nbytes ? file->Write(Memory.GetMemFromAddr(buf_addr), nbytes) : 0;
|
||||
const u64 res = nbytes ? file->Write(buf.get_ptr(), nbytes) : 0;
|
||||
|
||||
if (nwrite) *nwrite = res;
|
||||
|
||||
|
@ -156,18 +162,21 @@ s32 cellFsClose(u32 fd)
|
|||
{
|
||||
sys_fs->Warning("cellFsClose(fd=%d)", fd);
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
if(!Emu.GetIdManager().RemoveID(fd))
|
||||
return CELL_ESRCH;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellFsOpendir(u32 path_addr, vm::ptr<be_t<u32>> fd)
|
||||
s32 cellFsOpendir(vm::ptr<const char> path, vm::ptr<be_t<u32>> fd)
|
||||
{
|
||||
const std::string& path = Memory.ReadString(path_addr);
|
||||
sys_fs->Warning("cellFsOpendir(path=\"%s\", fd_addr=0x%x)", path.c_str(), fd.addr());
|
||||
sys_fs->Warning("cellFsOpendir(path=\"%s\", fd_addr=0x%x)", path.get_ptr(), fd.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsDirBase* dir = Emu.GetVFS().OpenDir(path);
|
||||
vfsDirBase* dir = Emu.GetVFS().OpenDir(path.get_ptr());
|
||||
if(!dir || !dir->IsOpened())
|
||||
{
|
||||
delete dir;
|
||||
|
@ -180,7 +189,9 @@ s32 cellFsOpendir(u32 path_addr, vm::ptr<be_t<u32>> fd)
|
|||
|
||||
s32 cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<be_t<u64>> nread)
|
||||
{
|
||||
sys_fs->Log("cellFsReaddir(fd=%d, dir_addr=0x%x, nread_addr=0x%x)", fd, dir.addr(), nread.addr());
|
||||
sys_fs->Warning("cellFsReaddir(fd=%d, dir_addr=0x%x, nread_addr=0x%x)", fd, dir.addr(), nread.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsDirBase* directory;
|
||||
if(!sys_fs->CheckId(fd, directory))
|
||||
|
@ -189,10 +200,10 @@ s32 cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<be_t<u64>> nread)
|
|||
const DirEntryInfo* info = directory->Read();
|
||||
if(info)
|
||||
{
|
||||
*nread = 1;
|
||||
Memory.WriteString(dir.addr() + 2, info->name);
|
||||
dir->d_namlen = info->name.length();
|
||||
dir->d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
|
||||
dir->d_namlen = u8(std::min((u32)info->name.length(), (u32)CELL_MAX_FS_FILE_NAME_LENGTH));
|
||||
strcpy_trunc(dir->d_name, info->name);
|
||||
*nread = sizeof(CellFsDirent);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -204,7 +215,9 @@ s32 cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<be_t<u64>> nread)
|
|||
|
||||
s32 cellFsClosedir(u32 fd)
|
||||
{
|
||||
sys_fs->Log("cellFsClosedir(fd=%d)", fd);
|
||||
sys_fs->Warning("cellFsClosedir(fd=%d)", fd);
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
if(!Emu.GetIdManager().RemoveID(fd))
|
||||
return CELL_ESRCH;
|
||||
|
@ -212,10 +225,13 @@ s32 cellFsClosedir(u32 fd)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellFsStat(const u32 path_addr, vm::ptr<CellFsStat> sb)
|
||||
s32 cellFsStat(vm::ptr<const char> path, vm::ptr<CellFsStat> sb)
|
||||
{
|
||||
const std::string& path = Memory.ReadString(path_addr);
|
||||
sys_fs->Warning("cellFsStat(path=\"%s\", sb_addr: 0x%x)", path.c_str(), sb.addr());
|
||||
sys_fs->Warning("cellFsStat(path=\"%s\", sb_addr: 0x%x)", path.get_ptr(), sb.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
const std::string _path = path.get_ptr();
|
||||
|
||||
sb->st_mode =
|
||||
CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR |
|
||||
|
@ -230,7 +246,7 @@ s32 cellFsStat(const u32 path_addr, vm::ptr<CellFsStat> sb)
|
|||
sb->st_blksize = 4096;
|
||||
|
||||
{
|
||||
vfsDir dir(path);
|
||||
vfsDir dir(_path);
|
||||
if(dir.IsOpened())
|
||||
{
|
||||
sb->st_mode |= CELL_FS_S_IFDIR;
|
||||
|
@ -239,7 +255,7 @@ s32 cellFsStat(const u32 path_addr, vm::ptr<CellFsStat> sb)
|
|||
}
|
||||
|
||||
{
|
||||
vfsFile f(path);
|
||||
vfsFile f(_path);
|
||||
if(f.IsOpened())
|
||||
{
|
||||
sb->st_mode |= CELL_FS_S_IFREG;
|
||||
|
@ -248,13 +264,15 @@ s32 cellFsStat(const u32 path_addr, vm::ptr<CellFsStat> sb)
|
|||
}
|
||||
}
|
||||
|
||||
sys_fs->Warning("cellFsStat: \"%s\" not found.", path.c_str());
|
||||
sys_fs->Warning("cellFsStat: \"%s\" not found.", path.get_ptr());
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
s32 cellFsFstat(u32 fd, vm::ptr<CellFsStat> sb)
|
||||
{
|
||||
sys_fs->Log("cellFsFstat(fd=%d, sb_addr: 0x%x)", fd, sb.addr());
|
||||
sys_fs->Warning("cellFsFstat(fd=%d, sb_addr: 0x%x)", fd, sb.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
IDType type;
|
||||
vfsStream* file;
|
||||
|
@ -279,36 +297,36 @@ s32 cellFsFstat(u32 fd, vm::ptr<CellFsStat> sb)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellFsMkdir(u32 path_addr, u32 mode)
|
||||
s32 cellFsMkdir(vm::ptr<const char> path, u32 mode)
|
||||
{
|
||||
const std::string& ps3_path = Memory.ReadString(path_addr);
|
||||
sys_fs->Log("cellFsMkdir(path=\"%s\", mode=0x%x)", ps3_path.c_str(), mode);
|
||||
|
||||
/*vfsDir dir;
|
||||
if(dir.IsExists(ps3_path))
|
||||
return CELL_EEXIST;
|
||||
if(!dir.Create(ps3_path))
|
||||
return CELL_EBUSY;*/
|
||||
sys_fs->Warning("cellFsMkdir(path=\"%s\", mode=0x%x)", path.get_ptr(), mode);
|
||||
|
||||
if(Emu.GetVFS().ExistsDir(ps3_path))
|
||||
LV2_LOCK(0);
|
||||
|
||||
const std::string _path = path.get_ptr();
|
||||
|
||||
if(Emu.GetVFS().ExistsDir(_path))
|
||||
return CELL_EEXIST;
|
||||
if(!Emu.GetVFS().CreateDir(ps3_path))
|
||||
if(!Emu.GetVFS().CreateDir(_path))
|
||||
return CELL_EBUSY;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellFsRename(u32 from_addr, u32 to_addr)
|
||||
s32 cellFsRename(vm::ptr<const char> from, vm::ptr<const char> to)
|
||||
{
|
||||
const std::string& ps3_from = Memory.ReadString(from_addr);
|
||||
const std::string& ps3_to = Memory.ReadString(to_addr);
|
||||
sys_fs->Log("cellFsRename(from='%s' (from_addr=0x%x), to='%s' (to_addr=0x%x))", ps3_from.c_str(), from_addr, ps3_to.c_str(), to_addr);
|
||||
sys_fs->Warning("cellFsRename(from='%s', to='%s')", from.get_ptr(), to.get_ptr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
std::string _from = from.get_ptr();
|
||||
std::string _to = to.get_ptr();
|
||||
|
||||
{
|
||||
vfsDir dir;
|
||||
if(dir.IsExists(ps3_from))
|
||||
if(dir.IsExists(_from))
|
||||
{
|
||||
if(!dir.Rename(ps3_from, ps3_to))
|
||||
if(!dir.Rename(_from, _to))
|
||||
return CELL_EBUSY;
|
||||
|
||||
return CELL_OK;
|
||||
|
@ -317,9 +335,10 @@ s32 cellFsRename(u32 from_addr, u32 to_addr)
|
|||
|
||||
{
|
||||
vfsFile f;
|
||||
if(f.Exists(ps3_from))
|
||||
|
||||
if(f.Exists(_from))
|
||||
{
|
||||
if(!f.Rename(ps3_from, ps3_to))
|
||||
if(!f.Rename(_from, _to))
|
||||
return CELL_EBUSY;
|
||||
|
||||
return CELL_OK;
|
||||
|
@ -328,10 +347,11 @@ s32 cellFsRename(u32 from_addr, u32 to_addr)
|
|||
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
s32 cellFsChmod(u32 path_addr, u32 mode)
|
||||
s32 cellFsChmod(vm::ptr<const char> path, u32 mode)
|
||||
{
|
||||
const std::string& ps3_path = Memory.ReadString(path_addr);
|
||||
sys_fs->Todo("cellFsChmod(path=\"%s\", mode=0x%x)", ps3_path.c_str(), mode);
|
||||
sys_fs->Todo("cellFsChmod(path=\"%s\", mode=0x%x)", path.get_ptr(), mode);
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
// TODO:
|
||||
|
||||
|
@ -342,38 +362,46 @@ s32 cellFsFsync(u32 fd)
|
|||
{
|
||||
sys_fs->Todo("cellFsFsync(fd=0x%x)", fd);
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
// TODO:
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellFsRmdir(u32 path_addr)
|
||||
s32 cellFsRmdir(vm::ptr<const char> path)
|
||||
{
|
||||
const std::string& ps3_path = Memory.ReadString(path_addr);
|
||||
sys_fs->Log("cellFsRmdir(path=\"%s\")", ps3_path.c_str());
|
||||
sys_fs->Warning("cellFsRmdir(path=\"%s\")", path.get_ptr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
std::string _path = path.get_ptr();
|
||||
|
||||
vfsDir d;
|
||||
if(!d.IsExists(ps3_path))
|
||||
if(!d.IsExists(_path))
|
||||
return CELL_ENOENT;
|
||||
|
||||
if(!d.Remove(ps3_path))
|
||||
if(!d.Remove(_path))
|
||||
return CELL_EBUSY;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellFsUnlink(u32 path_addr)
|
||||
s32 cellFsUnlink(vm::ptr<const char> path)
|
||||
{
|
||||
const std::string& ps3_path = Memory.ReadString(path_addr);
|
||||
sys_fs->Warning("cellFsUnlink(path=\"%s\")", ps3_path.c_str());
|
||||
sys_fs->Warning("cellFsUnlink(path=\"%s\")", path.get_ptr());
|
||||
|
||||
if (Emu.GetVFS().ExistsDir(ps3_path))
|
||||
LV2_LOCK(0);
|
||||
|
||||
std::string _path = path.get_ptr();
|
||||
|
||||
if (Emu.GetVFS().ExistsDir(_path))
|
||||
return CELL_EISDIR;
|
||||
|
||||
if (!Emu.GetVFS().ExistsFile(ps3_path))
|
||||
if (!Emu.GetVFS().ExistsFile(_path))
|
||||
return CELL_ENOENT;
|
||||
|
||||
if (!Emu.GetVFS().RemoveFile(ps3_path))
|
||||
if (!Emu.GetVFS().RemoveFile(_path))
|
||||
return CELL_EACCES;
|
||||
|
||||
return CELL_OK;
|
||||
|
@ -381,8 +409,11 @@ s32 cellFsUnlink(u32 path_addr)
|
|||
|
||||
s32 cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr<be_t<u64>> pos)
|
||||
{
|
||||
vfsSeekMode seek_mode;
|
||||
sys_fs->Log("cellFsLseek(fd=%d, offset=0x%llx, whence=0x%x, pos_addr=0x%x)", fd, offset, whence, pos.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsSeekMode seek_mode;
|
||||
switch(whence)
|
||||
{
|
||||
case CELL_SEEK_SET: seek_mode = vfsSeekSet; break;
|
||||
|
@ -404,7 +435,9 @@ s32 cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr<be_t<u64>> pos)
|
|||
|
||||
s32 cellFsFtruncate(u32 fd, u64 size)
|
||||
{
|
||||
sys_fs->Log("cellFsFtruncate(fd=%d, size=%lld)", fd, size);
|
||||
sys_fs->Warning("cellFsFtruncate(fd=%d, size=%lld)", fd, size);
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
IDType type;
|
||||
vfsStream* file;
|
||||
|
@ -431,15 +464,16 @@ s32 cellFsFtruncate(u32 fd, u64 size)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellFsTruncate(u32 path_addr, u64 size)
|
||||
s32 cellFsTruncate(vm::ptr<const char> path, u64 size)
|
||||
{
|
||||
const std::string& path = Memory.ReadString(path_addr);
|
||||
sys_fs->Log("cellFsTruncate(path=\"%s\", size=%lld)", path.c_str(), size);
|
||||
sys_fs->Warning("cellFsTruncate(path=\"%s\", size=%lld)", path.get_ptr(), size);
|
||||
|
||||
vfsFile f(path, vfsReadWrite);
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsFile f(path.get_ptr(), vfsReadWrite);
|
||||
if(!f.IsOpened())
|
||||
{
|
||||
sys_fs->Warning("cellFsTruncate: \"%s\" not found.", path.c_str());
|
||||
sys_fs->Warning("cellFsTruncate: \"%s\" not found.", path.get_ptr());
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
u64 initialSize = f.GetSize();
|
||||
|
@ -464,9 +498,11 @@ s32 cellFsTruncate(u32 path_addr, u64 size)
|
|||
|
||||
s32 cellFsFGetBlockSize(u32 fd, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64>> block_size)
|
||||
{
|
||||
sys_fs->Log("cellFsFGetBlockSize(fd=%d, sector_size_addr: 0x%x, block_size_addr: 0x%x)",
|
||||
sys_fs->Warning("cellFsFGetBlockSize(fd=%d, sector_size_addr=0x%x, block_size_addr=0x%x)",
|
||||
fd, sector_size.addr(), block_size.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
@ -476,10 +512,12 @@ s32 cellFsFGetBlockSize(u32 fd, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellFsGetBlockSize(u32 path_addr, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64>> block_size)
|
||||
s32 cellFsGetBlockSize(vm::ptr<const char> path, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64>> block_size)
|
||||
{
|
||||
sys_fs->Log("cellFsGetBlockSize(file: %s, sector_size_addr: 0x%x, block_size_addr: 0x%x)",
|
||||
Memory.ReadString(path_addr).c_str(), sector_size.addr(), block_size.addr());
|
||||
sys_fs->Warning("cellFsGetBlockSize(file='%s', sector_size_addr=0x%x, block_size_addr=0x%x)",
|
||||
path.get_ptr(), sector_size.addr(), block_size.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
*sector_size = 4096; // ?
|
||||
*block_size = 4096; // ?
|
||||
|
@ -487,14 +525,12 @@ s32 cellFsGetBlockSize(u32 path_addr, vm::ptr<be_t<u64>> sector_size, vm::ptr<be
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellFsGetFreeSize(u32 path_addr, vm::ptr<be_t<u32>> block_size, vm::ptr<be_t<u64>> block_count)
|
||||
s32 cellFsGetFreeSize(vm::ptr<const char> path, vm::ptr<be_t<u32>> block_size, vm::ptr<be_t<u64>> block_count)
|
||||
{
|
||||
const std::string& ps3_path = Memory.ReadString(path_addr);
|
||||
sys_fs->Warning("cellFsGetFreeSize(path=\"%s\", block_size_addr=0x%x, block_count_addr=0x%x)",
|
||||
ps3_path.c_str(), block_size.addr(), block_count.addr());
|
||||
path.get_ptr(), block_size.addr(), block_count.addr());
|
||||
|
||||
if (ps3_path.empty())
|
||||
return CELL_EINVAL;
|
||||
LV2_LOCK(0);
|
||||
|
||||
// TODO: Get real values. Currently, it always returns 40 GB of free space divided in 4 KB blocks
|
||||
*block_size = 4096; // ?
|
||||
|
@ -505,9 +541,11 @@ s32 cellFsGetFreeSize(u32 path_addr, vm::ptr<be_t<u32>> block_size, vm::ptr<be_t
|
|||
|
||||
s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32 entries_size, vm::ptr<be_t<u32>> data_count)
|
||||
{
|
||||
sys_fs->Log("cellFsGetDirectoryEntries(fd=%d, entries_addr=0x%x, entries_size = 0x%x, data_count_addr=0x%x)",
|
||||
sys_fs->Warning("cellFsGetDirectoryEntries(fd=%d, entries_addr=0x%x, entries_size=0x%x, data_count_addr=0x%x)",
|
||||
fd, entries.addr(), entries_size, data_count.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsDirBase* directory;
|
||||
if(!sys_fs->CheckId(fd, directory))
|
||||
return CELL_ESRCH;
|
||||
|
@ -515,11 +553,6 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32
|
|||
const DirEntryInfo* info = directory->Read();
|
||||
if(info)
|
||||
{
|
||||
*data_count = 1;
|
||||
Memory.WriteString(entries.addr()+2, info->name);
|
||||
entries->entry_name.d_namlen = info->name.length();
|
||||
entries->entry_name.d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
|
||||
|
||||
entries->attribute.st_mode =
|
||||
CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR |
|
||||
CELL_FS_S_IRGRP | CELL_FS_S_IWGRP | CELL_FS_S_IXGRP |
|
||||
|
@ -531,6 +564,11 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32
|
|||
entries->attribute.st_mtime_ = 0; //TODO
|
||||
entries->attribute.st_ctime_ = 0; //TODO
|
||||
entries->attribute.st_blksize = 4096;
|
||||
|
||||
entries->entry_name.d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
|
||||
entries->entry_name.d_namlen = u8(std::min((u32)info->name.length(), (u32)CELL_MAX_FS_FILE_NAME_LENGTH));
|
||||
strcpy_trunc(entries->entry_name.d_name, info->name);
|
||||
*data_count = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -544,6 +582,8 @@ s32 cellFsStReadInit(u32 fd, vm::ptr<CellFsRingBuffer> ringbuf)
|
|||
{
|
||||
sys_fs->Warning("cellFsStReadInit(fd=%d, ringbuf_addr=0x%x)", fd, ringbuf.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
@ -555,7 +595,7 @@ s32 cellFsStReadInit(u32 fd, vm::ptr<CellFsRingBuffer> ringbuf)
|
|||
|
||||
// alloc memory
|
||||
fs_config.m_buffer = (u32)Memory.Alloc(fs_config.m_alloc_mem_size, 1024);
|
||||
memset(Memory + fs_config.m_buffer, 0, fs_config.m_alloc_mem_size);
|
||||
memset(vm::get_ptr<void>(fs_config.m_buffer), 0, fs_config.m_alloc_mem_size);
|
||||
|
||||
fs_config.m_fs_status = CELL_FS_ST_INITIALIZED;
|
||||
|
||||
|
@ -566,6 +606,8 @@ s32 cellFsStReadFinish(u32 fd)
|
|||
{
|
||||
sys_fs->Warning("cellFsStReadFinish(fd=%d)", fd);
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
@ -579,6 +621,8 @@ s32 cellFsStReadGetRingBuf(u32 fd, vm::ptr<CellFsRingBuffer> ringbuf)
|
|||
{
|
||||
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, ringbuf_addr=0x%x)", fd, ringbuf.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
@ -593,6 +637,8 @@ s32 cellFsStReadGetStatus(u32 fd, vm::ptr<be_t<u64>> status)
|
|||
{
|
||||
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, status_addr=0x%x)", fd, status.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
@ -605,6 +651,8 @@ s32 cellFsStReadGetRegid(u32 fd, vm::ptr<be_t<u64>> regid)
|
|||
{
|
||||
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, regid_addr=0x%x)", fd, regid.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
@ -617,6 +665,8 @@ s32 cellFsStReadStart(u32 fd, u64 offset, u64 size)
|
|||
{
|
||||
sys_fs->Todo("cellFsStReadStart(fd=%d, offset=0x%llx, size=0x%llx)", fd, offset, size);
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
@ -630,6 +680,8 @@ s32 cellFsStReadStop(u32 fd)
|
|||
{
|
||||
sys_fs->Warning("cellFsStReadStop(fd=%d)", fd);
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
@ -641,6 +693,8 @@ s32 cellFsStReadStop(u32 fd)
|
|||
s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, vm::ptr<be_t<u64>> rsize)
|
||||
{
|
||||
sys_fs->Todo("cellFsStRead(fd=%d, buf_addr=0x%x, size=0x%llx, rsize_addr = 0x%x)", fd, buf_addr, size, rsize.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
@ -655,6 +709,8 @@ s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr<be_t<u32>> addr, vm::ptr<be_t<u64
|
|||
{
|
||||
sys_fs->Todo("cellFsStReadGetCurrentAddr(fd=%d, addr_addr=0x%x, size_addr = 0x%x)", fd, addr.addr(), size.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
@ -664,6 +720,8 @@ s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr<be_t<u32>> addr, vm::ptr<be_t<u64
|
|||
s32 cellFsStReadPutCurrentAddr(u32 fd, u32 addr_addr, u64 size)
|
||||
{
|
||||
sys_fs->Todo("cellFsStReadPutCurrentAddr(fd=%d, addr_addr=0x%x, size = 0x%llx)", fd, addr_addr, size);
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
@ -674,6 +732,8 @@ s32 cellFsStReadPutCurrentAddr(u32 fd, u32 addr_addr, u64 size)
|
|||
s32 cellFsStReadWait(u32 fd, u64 size)
|
||||
{
|
||||
sys_fs->Todo("cellFsStReadWait(fd=%d, size = 0x%llx)", fd, size);
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
@ -685,6 +745,8 @@ s32 cellFsStReadWaitCallback(u32 fd, u64 size, vm::ptr<void (*)(int xfd, u64 xsi
|
|||
{
|
||||
sys_fs->Todo("cellFsStReadWaitCallback(fd=%d, size = 0x%llx, func_addr = 0x%x)", fd, size, func.addr());
|
||||
|
||||
LV2_LOCK(0);
|
||||
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ struct CellFsAio
|
|||
{
|
||||
be_t<u32> fd;
|
||||
be_t<u64> offset;
|
||||
be_t<u32> buf_addr;
|
||||
vm::bptr<void> buf;
|
||||
be_t<u64> size;
|
||||
be_t<u64> user_data;
|
||||
};
|
||||
|
@ -124,27 +124,27 @@ struct CellFsRingBuffer
|
|||
};
|
||||
|
||||
// SysCalls
|
||||
s32 cellFsOpen(u32 path_addr, s32 flags, vm::ptr<be_t<u32>> fd, vm::ptr<be_t<u32>> arg, u64 size);
|
||||
s32 cellFsRead(u32 fd, u32 buf_addr, u64 nbytes, vm::ptr<be_t<u64>> nread);
|
||||
s32 cellFsWrite(u32 fd, u32 buf_addr, u64 nbytes, vm::ptr<be_t<u64>> nwrite);
|
||||
s32 cellFsOpen(vm::ptr<const char> path, s32 flags, vm::ptr<be_t<u32>> fd, vm::ptr<be_t<u32>> arg, u64 size);
|
||||
s32 cellFsRead(u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<be_t<u64>> nread);
|
||||
s32 cellFsWrite(u32 fd, vm::ptr<const void> buf, u64 nbytes, vm::ptr<be_t<u64>> nwrite);
|
||||
s32 cellFsClose(u32 fd);
|
||||
s32 cellFsOpendir(u32 path_addr, vm::ptr<be_t<u32>> fd);
|
||||
s32 cellFsOpendir(vm::ptr<const char> path, vm::ptr<be_t<u32>> fd);
|
||||
s32 cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<be_t<u64>> nread);
|
||||
s32 cellFsClosedir(u32 fd);
|
||||
s32 cellFsStat(u32 path_addr, vm::ptr<CellFsStat> sb);
|
||||
s32 cellFsStat(vm::ptr<const char> path, vm::ptr<CellFsStat> sb);
|
||||
s32 cellFsFstat(u32 fd, vm::ptr<CellFsStat> sb);
|
||||
s32 cellFsMkdir(u32 path_addr, u32 mode);
|
||||
s32 cellFsRename(u32 from_addr, u32 to_addr);
|
||||
s32 cellFsChmod(u32 path_addr, u32 mode);
|
||||
s32 cellFsMkdir(vm::ptr<const char> path, u32 mode);
|
||||
s32 cellFsRename(vm::ptr<const char> from, vm::ptr<const char> to);
|
||||
s32 cellFsChmod(vm::ptr<const char> path, u32 mode);
|
||||
s32 cellFsFsync(u32 fd);
|
||||
s32 cellFsRmdir(u32 path_addr);
|
||||
s32 cellFsUnlink(u32 path_addr);
|
||||
s32 cellFsRmdir(vm::ptr<const char> path);
|
||||
s32 cellFsUnlink(vm::ptr<const char> path);
|
||||
s32 cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr<be_t<u64>> pos);
|
||||
s32 cellFsFtruncate(u32 fd, u64 size);
|
||||
s32 cellFsTruncate(u32 path_addr, u64 size);
|
||||
s32 cellFsTruncate(vm::ptr<const char> path, u64 size);
|
||||
s32 cellFsFGetBlockSize(u32 fd, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64>> block_size);
|
||||
s32 cellFsGetBlockSize(u32 path_addr, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64>> block_size);
|
||||
s32 cellFsGetFreeSize(u32 path_addr, vm::ptr<be_t<u32>> block_size, vm::ptr<be_t<u64>> block_count);
|
||||
s32 cellFsGetBlockSize(vm::ptr<const char> path, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64>> block_size);
|
||||
s32 cellFsGetFreeSize(vm::ptr<const char> path, vm::ptr<be_t<u32>> block_size, vm::ptr<be_t<u64>> block_count);
|
||||
s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32 entries_size, vm::ptr<be_t<u32>> data_count);
|
||||
s32 cellFsStReadInit(u32 fd, vm::ptr<CellFsRingBuffer> ringbuf);
|
||||
s32 cellFsStReadFinish(u32 fd);
|
||||
|
|
|
@ -135,7 +135,7 @@ s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr<sys_event_data> event_arra
|
|||
eq->sq.m_mutex.unlock();
|
||||
return CELL_OK;
|
||||
}
|
||||
*number = eq->events.pop_all((sys_event_data*)(Memory + event_array.addr()), size);
|
||||
*number = eq->events.pop_all(event_array.get_ptr(), size);
|
||||
eq->owner.unlock(tid);
|
||||
eq->sq.m_mutex.unlock();
|
||||
return CELL_OK;
|
||||
|
|
|
@ -58,30 +58,24 @@ s32 sys_mmapper_allocate_memory(u32 size, u64 flags, vm::ptr<be_t<u32>> mem_id)
|
|||
sys_mmapper.Warning("sys_mmapper_allocate_memory(size=0x%x, flags=0x%llx, mem_id_addr=0x%x)", size, flags, mem_id.addr());
|
||||
|
||||
// Check page granularity.
|
||||
u32 addr;
|
||||
switch(flags & (SYS_MEMORY_PAGE_SIZE_1M | SYS_MEMORY_PAGE_SIZE_64K))
|
||||
{
|
||||
case SYS_MEMORY_PAGE_SIZE_1M:
|
||||
if(size & 0xfffff)
|
||||
return CELL_EALIGN;
|
||||
addr = (u32)Memory.Alloc(size, 0x100000);
|
||||
break;
|
||||
|
||||
case SYS_MEMORY_PAGE_SIZE_64K:
|
||||
if(size & 0xffff)
|
||||
return CELL_EALIGN;
|
||||
addr = (u32)Memory.Alloc(size, 0x10000);
|
||||
break;
|
||||
|
||||
default:
|
||||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
if(!addr)
|
||||
return CELL_ENOMEM;
|
||||
|
||||
// Generate a new mem ID.
|
||||
*mem_id = sys_mmapper.GetNewId(new mmapper_info(addr, size, flags));
|
||||
*mem_id = sys_mmapper.GetNewId(new mmapper_info(size, flags));
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -102,25 +96,21 @@ s32 sys_mmapper_allocate_memory_from_container(u32 size, u32 cid, u64 flags, vm:
|
|||
case SYS_MEMORY_PAGE_SIZE_1M:
|
||||
if(size & 0xfffff)
|
||||
return CELL_EALIGN;
|
||||
ct->addr = (u32)Memory.Alloc(size, 0x100000);
|
||||
break;
|
||||
|
||||
case SYS_MEMORY_PAGE_SIZE_64K:
|
||||
if(size & 0xffff)
|
||||
return CELL_EALIGN;
|
||||
ct->addr = (u32)Memory.Alloc(size, 0x10000);
|
||||
break;
|
||||
|
||||
default:
|
||||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
if(!ct->addr)
|
||||
return CELL_ENOMEM;
|
||||
ct->size = size;
|
||||
|
||||
// Generate a new mem ID.
|
||||
*mem_id = sys_mmapper.GetNewId(new mmapper_info(ct->addr, ct->size, flags), TYPE_MEM);
|
||||
*mem_id = sys_mmapper.GetNewId(new mmapper_info(ct->size, flags), TYPE_MEM);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -153,7 +143,6 @@ s32 sys_mmapper_free_memory(u32 mem_id)
|
|||
return CELL_ESRCH;
|
||||
|
||||
// Release the allocated memory and remove the ID.
|
||||
Memory.Free(info->addr);
|
||||
sys_mmapper.RemoveId(mem_id);
|
||||
|
||||
return CELL_OK;
|
||||
|
@ -169,7 +158,7 @@ s32 sys_mmapper_map_memory(u32 start_addr, u32 mem_id, u64 flags)
|
|||
return CELL_ESRCH;
|
||||
|
||||
// Map the memory into the process address.
|
||||
if(!Memory.Map(start_addr, info->addr, info->size))
|
||||
if(!Memory.Map(start_addr, info->size))
|
||||
sys_mmapper.Error("sys_mmapper_map_memory failed!");
|
||||
|
||||
// Keep track of mapped addresses.
|
||||
|
@ -194,7 +183,7 @@ s32 sys_mmapper_search_and_map(u32 start_addr, u32 mem_id, u64 flags, u32 alloc_
|
|||
for (int i = 0; i < SYS_MMAPPER_FIXED_SIZE; i += 0x100000)
|
||||
{
|
||||
addr = start_addr + i;
|
||||
found = Memory.Map(addr, info->addr, info->size);
|
||||
found = Memory.Map(addr, info->size);
|
||||
if(found)
|
||||
{
|
||||
sys_mmapper.Warning("Found and mapped address 0x%x", addr);
|
||||
|
|
|
@ -5,13 +5,11 @@
|
|||
|
||||
struct mmapper_info
|
||||
{
|
||||
u32 addr;
|
||||
u32 size;
|
||||
u64 flags;
|
||||
|
||||
mmapper_info(u32 _addr, u32 _size, u64 _flags)
|
||||
: addr(_addr)
|
||||
, size(_size)
|
||||
mmapper_info(u32 _size, u64 _flags)
|
||||
: size(_size)
|
||||
, flags(_flags)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -150,13 +150,10 @@ s32 sys_ppu_thread_restart(u64 thread_id)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 sys_ppu_thread_create(vm::ptr<be_t<u64>> thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, u32 threadname_addr)
|
||||
s32 sys_ppu_thread_create(vm::ptr<be_t<u64>> thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, vm::ptr<const char> threadname)
|
||||
{
|
||||
std::string threadname = "";
|
||||
if (threadname_addr) threadname = Memory.ReadString(threadname_addr);
|
||||
|
||||
sys_ppu_thread.Log("sys_ppu_thread_create(thread_id_addr=0x%x, entry=0x%x, arg=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname_addr=0x%x('%s'))",
|
||||
thread_id.addr(), entry, arg, prio, stacksize, flags, threadname_addr, threadname.c_str());
|
||||
thread_id.addr(), entry, arg, prio, stacksize, flags, threadname.addr(), threadname ? threadname.get_ptr() : "");
|
||||
|
||||
bool is_joinable = false;
|
||||
bool is_interrupt = false;
|
||||
|
@ -187,7 +184,7 @@ s32 sys_ppu_thread_create(vm::ptr<be_t<u64>> thread_id, u32 entry, u64 arg, s32
|
|||
//new_thread.flags = flags;
|
||||
new_thread.m_has_interrupt = false;
|
||||
new_thread.m_is_interrupt = is_interrupt;
|
||||
new_thread.SetName(threadname);
|
||||
new_thread.SetName(threadname ? threadname.get_ptr() : "");
|
||||
|
||||
sys_ppu_thread.Notice("*** New PPU Thread [%s] (flags=0x%llx, entry=0x%x): id = %d", new_thread.GetName().c_str(), flags, entry, new_thread.GetId());
|
||||
|
||||
|
@ -219,15 +216,15 @@ s32 sys_ppu_thread_get_id(vm::ptr<be_t<u64>> thread_id)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 sys_ppu_thread_rename(u64 thread_id, u32 name_addr)
|
||||
s32 sys_ppu_thread_rename(u64 thread_id, vm::ptr<const char> name)
|
||||
{
|
||||
sys_ppu_thread.Log("sys_ppu_thread_rename(thread_id=%d, name_addr=0x%x)", thread_id, name_addr);
|
||||
sys_ppu_thread.Log("sys_ppu_thread_rename(thread_id=%d, name_addr=0x%x('%s'))", thread_id, name.addr(), name.get_ptr());
|
||||
|
||||
CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
|
||||
if (!thr) {
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
thr->SetThreadName(Memory.ReadString(name_addr));
|
||||
thr->SetThreadName(name.get_ptr());
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ s32 sys_ppu_thread_get_priority(u64 thread_id, u32 prio_addr);
|
|||
s32 sys_ppu_thread_get_stack_information(u32 info_addr);
|
||||
s32 sys_ppu_thread_stop(u64 thread_id);
|
||||
s32 sys_ppu_thread_restart(u64 thread_id);
|
||||
s32 sys_ppu_thread_create(vm::ptr<be_t<u64>> thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, u32 threadname_addr);
|
||||
s32 sys_ppu_thread_create(vm::ptr<be_t<u64>> thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, vm::ptr<const char> threadname);
|
||||
void sys_ppu_thread_once(vm::ptr<std::atomic<be_t<u32>>> once_ctrl, u32 entry);
|
||||
s32 sys_ppu_thread_get_id(vm::ptr<be_t<u64>> thread_id);
|
||||
s32 sys_ppu_thread_rename(u64 thread_id, u32 name_addr);
|
||||
s32 sys_ppu_thread_rename(u64 thread_id, vm::ptr<const char> name);
|
||||
|
|
|
@ -38,7 +38,7 @@ s32 sys_process_exit(s32 errorcode)
|
|||
}
|
||||
|
||||
void sys_game_process_exitspawn(
|
||||
u32 path_addr,
|
||||
vm::ptr<const char> path,
|
||||
u32 argv_addr,
|
||||
u32 envp_addr,
|
||||
u32 data_addr,
|
||||
|
@ -47,7 +47,7 @@ void sys_game_process_exitspawn(
|
|||
u64 flags )
|
||||
{
|
||||
sys_process.Todo("sys_game_process_exitspawn()");
|
||||
sys_process.Warning("path: %s", Memory.ReadString(path_addr).c_str());
|
||||
sys_process.Warning("path: %s", path.get_ptr());
|
||||
sys_process.Warning("argv: 0x%x", argv_addr);
|
||||
sys_process.Warning("envp: 0x%x", envp_addr);
|
||||
sys_process.Warning("data: 0x%x", data_addr);
|
||||
|
@ -55,20 +55,20 @@ void sys_game_process_exitspawn(
|
|||
sys_process.Warning("prio: %d", prio);
|
||||
sys_process.Warning("flags: %d", flags);
|
||||
|
||||
std::string path = Memory.ReadString(path_addr);
|
||||
std::string _path = path.get_ptr();
|
||||
std::vector<std::string> argv;
|
||||
std::vector<std::string> env;
|
||||
|
||||
auto argvp = vm::ptr<u32>::make(argv_addr);
|
||||
auto argvp = vm::ptr<vm::bptr<const char>>::make(argv_addr);
|
||||
while (argvp && *argvp)
|
||||
{
|
||||
argv.push_back(Memory.ReadString(Memory.Read32(argvp.addr())));
|
||||
argv.push_back(argvp[0].get_ptr());
|
||||
argvp++;
|
||||
}
|
||||
auto envp = vm::ptr<u32>::make(envp_addr);
|
||||
auto envp = vm::ptr<vm::bptr<const char>>::make(envp_addr);
|
||||
while (envp && *envp)
|
||||
{
|
||||
env.push_back(Memory.ReadString(Memory.Read32(envp.addr())));
|
||||
env.push_back(envp[0].get_ptr());
|
||||
envp++;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ void sys_game_process_exitspawn(
|
|||
}
|
||||
|
||||
void sys_game_process_exitspawn2(
|
||||
u32 path_addr,
|
||||
vm::ptr<const char> path,
|
||||
u32 argv_addr,
|
||||
u32 envp_addr,
|
||||
u32 data_addr,
|
||||
|
@ -95,7 +95,7 @@ void sys_game_process_exitspawn2(
|
|||
u64 flags)
|
||||
{
|
||||
sys_process.Todo("sys_game_process_exitspawn2");
|
||||
sys_process.Warning("path: %s", Memory.ReadString(path_addr).c_str());
|
||||
sys_process.Warning("path: %s", path.get_ptr());
|
||||
sys_process.Warning("argv: 0x%x", argv_addr);
|
||||
sys_process.Warning("envp: 0x%x", envp_addr);
|
||||
sys_process.Warning("data: 0x%x", data_addr);
|
||||
|
@ -103,20 +103,20 @@ void sys_game_process_exitspawn2(
|
|||
sys_process.Warning("prio: %d", prio);
|
||||
sys_process.Warning("flags: %d", flags);
|
||||
|
||||
std::string path = Memory.ReadString(path_addr);
|
||||
std::string _path = path.get_ptr();
|
||||
std::vector<std::string> argv;
|
||||
std::vector<std::string> env;
|
||||
|
||||
auto argvp = vm::ptr<u32>::make(argv_addr);
|
||||
auto argvp = vm::ptr<vm::bptr<const char>>::make(argv_addr);
|
||||
while (argvp && *argvp)
|
||||
{
|
||||
argv.push_back(Memory.ReadString(Memory.Read32(argvp.addr())));
|
||||
argv.push_back(argvp[0].get_ptr());
|
||||
argvp++;
|
||||
}
|
||||
auto envp = vm::ptr<u32>::make(envp_addr);
|
||||
auto envp = vm::ptr<vm::bptr<const char>>::make(envp_addr);
|
||||
while (envp && *envp)
|
||||
{
|
||||
env.push_back(Memory.ReadString(Memory.Read32(envp.addr())));
|
||||
env.push_back(envp[0].get_ptr());
|
||||
envp++;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ s32 sys_process_kill(u32 pid);
|
|||
s32 sys_process_wait_for_child(u32 pid, vm::ptr<be_t<u32>> status, u64 unk);
|
||||
s32 sys_process_wait_for_child2(u64 unk1, u64 unk2, u64 unk3, u64 unk4, u64 unk5, u64 unk6);
|
||||
s32 sys_process_detach_child(u64 unk);
|
||||
void sys_game_process_exitspawn(u32 path_addr, u32 argv_addr, u32 envp_addr,
|
||||
void sys_game_process_exitspawn(vm::ptr<const char> path, u32 argv_addr, u32 envp_addr,
|
||||
u32 data_addr, u32 data_size, u32 prio, u64 flags);
|
||||
void sys_game_process_exitspawn2(u32 path_addr, u32 argv_addr, u32 envp_addr,
|
||||
void sys_game_process_exitspawn2(vm::ptr<const char> path, u32 argv_addr, u32 envp_addr,
|
||||
u32 data_addr, u32 data_size, u32 prio, u64 flags);
|
||||
|
|
|
@ -10,22 +10,22 @@
|
|||
|
||||
SysCallBase sys_prx("sys_prx");
|
||||
|
||||
s32 sys_prx_load_module(u32 path_addr, u64 flags, vm::ptr<sys_prx_load_module_option_t> pOpt)
|
||||
s32 sys_prx_load_module(vm::ptr<const char> path, u64 flags, vm::ptr<sys_prx_load_module_option_t> pOpt)
|
||||
{
|
||||
std::string path = Memory.ReadString(path_addr);
|
||||
sys_prx.Todo("sys_prx_load_module(path=\"%s\", flags=0x%llx, pOpt=0x%x)", path.c_str(), flags, pOpt.addr());
|
||||
sys_prx.Todo("sys_prx_load_module(path=\"%s\", flags=0x%llx, pOpt=0x%x)", path.get_ptr(), flags, pOpt.addr());
|
||||
|
||||
std::string _path = path.get_ptr();
|
||||
// Check if the file is SPRX
|
||||
std::string local_path;
|
||||
Emu.GetVFS().GetDevice(path, local_path);
|
||||
Emu.GetVFS().GetDevice(_path, local_path);
|
||||
if (IsSelf(local_path)) {
|
||||
if (!DecryptSelf(local_path+".prx", local_path)) {
|
||||
return CELL_PRX_ERROR_ILLEGAL_LIBRARY;
|
||||
}
|
||||
path += ".prx";
|
||||
_path += ".prx";
|
||||
}
|
||||
|
||||
vfsFile f(path);
|
||||
vfsFile f(_path);
|
||||
if (!f.IsOpened()) {
|
||||
return CELL_PRX_ERROR_UNKNOWN_MODULE;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ s32 sys_prx_load_module(u32 path_addr, u64 flags, vm::ptr<sys_prx_load_module_op
|
|||
prx->path = path;
|
||||
|
||||
// Load the PRX into memory
|
||||
f.Read(Memory.VirtualToRealAddr(prx->address), prx->size);
|
||||
f.Read(vm::get_ptr<void>(prx->address), prx->size);
|
||||
|
||||
u32 id = sys_prx.GetNewId(prx, TYPE_PRX);
|
||||
return id;
|
||||
|
|
|
@ -65,7 +65,7 @@ struct sys_prx_t
|
|||
};
|
||||
|
||||
// SysCalls
|
||||
s32 sys_prx_load_module(u32 path_addr, u64 flags, vm::ptr<sys_prx_load_module_option_t> pOpt);
|
||||
s32 sys_prx_load_module(vm::ptr<const char> path, u64 flags, vm::ptr<sys_prx_load_module_option_t> pOpt);
|
||||
s32 sys_prx_load_module_on_memcontainer();
|
||||
s32 sys_prx_load_module_by_fd();
|
||||
s32 sys_prx_load_module_on_memcontainer_by_fd();
|
||||
|
|
|
@ -18,10 +18,10 @@ s32 sys_rwlock_create(vm::ptr<be_t<u32>> rw_lock_id, vm::ptr<sys_rwlock_attribut
|
|||
|
||||
switch (attr->attr_protocol.ToBE())
|
||||
{
|
||||
case se(attr->attr_protocol, SYS_SYNC_PRIORITY): sys_rwlock.Todo("SYS_SYNC_PRIORITY"); break;
|
||||
case se(attr->attr_protocol, SYS_SYNC_RETRY): sys_rwlock.Error("SYS_SYNC_RETRY"); return CELL_EINVAL;
|
||||
case se(attr->attr_protocol, SYS_SYNC_PRIORITY_INHERIT): sys_rwlock.Todo("SYS_SYNC_PRIORITY_INHERIT"); break;
|
||||
case se(attr->attr_protocol, SYS_SYNC_FIFO): break;
|
||||
case se32(SYS_SYNC_PRIORITY): sys_rwlock.Todo("SYS_SYNC_PRIORITY"); break;
|
||||
case se32(SYS_SYNC_RETRY): sys_rwlock.Error("SYS_SYNC_RETRY"); return CELL_EINVAL;
|
||||
case se32(SYS_SYNC_PRIORITY_INHERIT): sys_rwlock.Todo("SYS_SYNC_PRIORITY_INHERIT"); break;
|
||||
case se32(SYS_SYNC_FIFO): break;
|
||||
default: return CELL_EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,15 +23,14 @@ u32 LoadSpuImage(vfsStream& stream, u32& spu_ep)
|
|||
}
|
||||
|
||||
//156
|
||||
s32 sys_spu_image_open(vm::ptr<sys_spu_image> img, u32 path_addr)
|
||||
s32 sys_spu_image_open(vm::ptr<sys_spu_image> img, vm::ptr<const char> path)
|
||||
{
|
||||
const std::string path = Memory.ReadString(path_addr);
|
||||
sys_spu.Warning("sys_spu_image_open(img_addr=0x%x, path_addr=0x%x [%s])", img.addr(), path_addr, path.c_str());
|
||||
sys_spu.Warning("sys_spu_image_open(img_addr=0x%x, path_addr=0x%x [%s])", img.addr(), path.addr(), path.get_ptr());
|
||||
|
||||
vfsFile f(path);
|
||||
vfsFile f(path.get_ptr());
|
||||
if(!f.IsOpened())
|
||||
{
|
||||
sys_spu.Error("sys_spu_image_open error: '%s' not found!", path.c_str());
|
||||
sys_spu.Error("sys_spu_image_open error: '%s' not found!", path.get_ptr());
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
|
@ -71,9 +70,9 @@ s32 sys_spu_thread_initialize(vm::ptr<be_t<u32>> thread, u32 group, u32 spu_num,
|
|||
u32 spu_ep = (u32)img->entry_point;
|
||||
|
||||
std::string name = "SPUThread";
|
||||
if (attr->name_addr)
|
||||
if (attr->name)
|
||||
{
|
||||
name = Memory.ReadString(attr->name_addr, attr->name_len);
|
||||
name = std::string(attr->name.get_ptr(), attr->name_len);
|
||||
}
|
||||
|
||||
u64 a1 = arg->arg1;
|
||||
|
@ -81,9 +80,10 @@ s32 sys_spu_thread_initialize(vm::ptr<be_t<u32>> thread, u32 group, u32 spu_num,
|
|||
u64 a3 = arg->arg3;
|
||||
u64 a4 = arg->arg4;
|
||||
|
||||
//copy SPU image:
|
||||
auto spu_offset = Memory.MainMem.AllocAlign(256 * 1024);
|
||||
memcpy(Memory + spu_offset, Memory + (u32)img->segs_addr, 256 * 1024);
|
||||
// Copy SPU image:
|
||||
// TODO: use correct segment info
|
||||
auto spu_offset = Memory.Alloc(256 * 1024, 4096);
|
||||
memcpy(vm::get_ptr<void>(spu_offset), vm::get_ptr<void>(img->segs_addr), 256 * 1024);
|
||||
|
||||
CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_SPU);
|
||||
//initialize from new place:
|
||||
|
@ -101,7 +101,7 @@ s32 sys_spu_thread_initialize(vm::ptr<be_t<u32>> thread, u32 group, u32 spu_num,
|
|||
(*(SPUThread*)&new_thread).group = group_info;
|
||||
|
||||
sys_spu.Warning("*** New SPU Thread [%s] (img_offset=0x%x, ls_offset=0x%x, ep=0x%x, a1=0x%llx, a2=0x%llx, a3=0x%llx, a4=0x%llx): id=%d",
|
||||
(attr->name_addr ? name.c_str() : ""), (u32) img->segs_addr, ((SPUThread&) new_thread).dmac.ls_offset, spu_ep, a1, a2, a3, a4, id);
|
||||
(attr->name ? attr->name.get_ptr() : ""), (u32)img->segs_addr, ((SPUThread&)new_thread).dmac.ls_offset, spu_ep, a1, a2, a3, a4, id);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -175,8 +175,12 @@ s32 sys_spu_thread_group_destroy(u32 id)
|
|||
for (u32 i = 0; i < group_info->list.size(); i++)
|
||||
{
|
||||
// TODO: disconnect all event ports
|
||||
|
||||
Emu.GetCPU().RemoveThread(group_info->list[i]);
|
||||
CPUThread* t = Emu.GetCPU().GetThread(group_info->list[i]);
|
||||
if (t)
|
||||
{
|
||||
Memory.Free(((SPUThread*)t)->GetOffset());
|
||||
Emu.GetCPU().RemoveThread(group_info->list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
group_info->m_state = SPU_THREAD_GROUP_STATUS_UNKNOWN;
|
||||
|
@ -410,7 +414,7 @@ s32 sys_spu_thread_group_create(vm::ptr<be_t<u32>> id, u32 num, int prio, vm::pt
|
|||
|
||||
if (prio < 16 || prio > 255) return CELL_EINVAL;
|
||||
|
||||
const std::string name = Memory.ReadString(attr->name_addr, attr->name_len);
|
||||
const std::string name(attr->name.get_ptr(), attr->nsize);
|
||||
|
||||
*id = sys_spu.GetNewId(new SpuGroupInfo(name, num, prio, attr->type, attr->ct));
|
||||
|
||||
|
|
|
@ -39,16 +39,15 @@ enum
|
|||
|
||||
struct sys_spu_thread_group_attribute
|
||||
{
|
||||
be_t<u32> name_len;
|
||||
be_t<u32> name_addr;
|
||||
be_t<int> type;
|
||||
/* struct {} option; */
|
||||
be_t<u32> nsize;
|
||||
vm::bptr<const char> name;
|
||||
be_t<s32> type;
|
||||
be_t<u32> ct; // memory container id
|
||||
};
|
||||
|
||||
struct sys_spu_thread_attribute
|
||||
{
|
||||
be_t<u32> name_addr;
|
||||
vm::bptr<const char> name;
|
||||
be_t<u32> name_len;
|
||||
be_t<u32> option;
|
||||
};
|
||||
|
@ -110,7 +109,7 @@ struct SpuGroupInfo
|
|||
|
||||
// SysCalls
|
||||
s32 sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu);
|
||||
s32 sys_spu_image_open(vm::ptr<sys_spu_image> img, u32 path_addr);
|
||||
s32 sys_spu_image_open(vm::ptr<sys_spu_image> img, vm::ptr<const char> path);
|
||||
s32 sys_spu_thread_initialize(vm::ptr<be_t<u32>> thread, u32 group, u32 spu_num, vm::ptr<sys_spu_image> img, vm::ptr<sys_spu_thread_attribute> attr, vm::ptr<sys_spu_thread_argument> arg);
|
||||
s32 sys_spu_thread_set_argument(u32 id, vm::ptr<sys_spu_thread_argument> arg);
|
||||
s32 sys_spu_thread_group_destroy(u32 id);
|
||||
|
|
|
@ -8,31 +8,31 @@
|
|||
|
||||
SysCallBase sys_tty("sys_tty");
|
||||
|
||||
s32 sys_tty_read(u32 ch, u64 buf_addr, u32 len, u64 preadlen_addr)
|
||||
s32 sys_tty_read(s32 ch, vm::ptr<void> buf, u32 len, vm::ptr<u32> preadlen)
|
||||
{
|
||||
sys_tty.Error("sys_tty_read(ch=%d, buf_addr=%llx, len=%d, preadlen_addr=0x%llx)", ch, buf_addr, len, preadlen_addr);
|
||||
sys_tty.Error("sys_tty_read(ch=%d, buf_addr=0x%x, len=%d, preadlen_addr=0x%x)", ch, buf.addr(), len, preadlen.addr());
|
||||
|
||||
// We currently do not support reading from the Console
|
||||
Memory.Write32(preadlen_addr, len);
|
||||
*preadlen = 0;
|
||||
Emu.Pause();
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 sys_tty_write(u32 ch, u64 buf_addr, u32 len, u64 pwritelen_addr)
|
||||
s32 sys_tty_write(s32 ch, vm::ptr<const void> buf, u32 len, vm::ptr<u32> pwritelen)
|
||||
{
|
||||
sys_tty.Log("sys_tty_write(ch=%d, buf_addr=%llx, len=%d, preadlen_addr=0x%llx)", ch, buf_addr, len, pwritelen_addr);
|
||||
sys_tty.Log("sys_tty_write(ch=%d, buf_addr=0x%x, len=%d, preadlen_addr=0x%x)", ch, buf.addr(), len, pwritelen.addr());
|
||||
|
||||
if(ch > 15 || (s32)len <= 0) return CELL_EINVAL;
|
||||
|
||||
const std::string data((const char*)buf.get_ptr(), len);
|
||||
|
||||
if (ch == SYS_TTYP_PPU_STDOUT || ch == SYS_TTYP_SPU_STDOUT || (ch >= SYS_TTYP_USER1 && ch <= SYS_TTYP_USER13)) {
|
||||
LOG_NOTICE(TTY, "%s", Memory.ReadString(buf_addr, len).c_str());
|
||||
LOG_NOTICE(TTY, "%s", data.c_str());
|
||||
}
|
||||
if (ch == SYS_TTYP_PPU_STDERR) {
|
||||
LOG_ERROR(TTY, "%s", Memory.ReadString(buf_addr, len).c_str());
|
||||
LOG_ERROR(TTY, "%s", data.c_str());
|
||||
}
|
||||
|
||||
Memory.Write32(pwritelen_addr, len);
|
||||
|
||||
*pwritelen = data.size();
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -23,5 +23,5 @@ enum
|
|||
};
|
||||
|
||||
// SysCalls
|
||||
s32 sys_tty_read(u32 ch, u64 buf_addr, u32 len, u64 preadlen_addr);
|
||||
s32 sys_tty_write(u32 ch, u64 buf_addr, u32 len, u64 pwritelen_addr);
|
||||
s32 sys_tty_read(s32 ch, vm::ptr<void> buf, u32 len, vm::ptr<u32> preadlen);
|
||||
s32 sys_tty_write(s32 ch, vm::ptr<const void> buf, u32 len, vm::ptr<u32> pwritelen);
|
||||
|
|
|
@ -11,7 +11,7 @@ MemoryContainerInfo* current_ct;
|
|||
|
||||
s32 sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, u32 addr)
|
||||
{
|
||||
sys_vm.Warning("sys_vm_memory_map(vsize=0x%x,psize=0x%x,cidr=0x%x,flags=0x%llx,policy=0x%llx,addr=0x%x)",
|
||||
sys_vm.Todo("sys_vm_memory_map(vsize=0x%x,psize=0x%x,cidr=0x%x,flags=0x%llx,policy=0x%llx,addr=0x%x)",
|
||||
vsize, psize, cid, flag, policy, addr);
|
||||
|
||||
// Check virtual size.
|
||||
|
@ -65,7 +65,7 @@ s32 sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, u32 a
|
|||
|
||||
s32 sys_vm_unmap(u32 addr)
|
||||
{
|
||||
sys_vm.Warning("sys_vm_unmap(addr=0x%x)", addr);
|
||||
sys_vm.Todo("sys_vm_unmap(addr=0x%x)", addr);
|
||||
|
||||
// Simply free the memory to unmap.
|
||||
if(!Memory.Free(addr)) return CELL_EINVAL;
|
||||
|
@ -75,7 +75,7 @@ s32 sys_vm_unmap(u32 addr)
|
|||
|
||||
s32 sys_vm_append_memory(u32 addr, u32 size)
|
||||
{
|
||||
sys_vm.Warning("sys_vm_append_memory(addr=0x%x,size=0x%x)", addr, size);
|
||||
sys_vm.Todo("sys_vm_append_memory(addr=0x%x,size=0x%x)", addr, size);
|
||||
|
||||
// Check address and size.
|
||||
if((current_ct->addr != addr) || (size <= 0))
|
||||
|
@ -97,7 +97,7 @@ s32 sys_vm_append_memory(u32 addr, u32 size)
|
|||
|
||||
s32 sys_vm_return_memory(u32 addr, u32 size)
|
||||
{
|
||||
sys_vm.Warning("sys_vm_return_memory(addr=0x%x,size=0x%x)", addr, size);
|
||||
sys_vm.Todo("sys_vm_return_memory(addr=0x%x,size=0x%x)", addr, size);
|
||||
|
||||
// Check address and size.
|
||||
if((current_ct->addr != addr) || (size <= 0))
|
||||
|
@ -119,7 +119,7 @@ s32 sys_vm_return_memory(u32 addr, u32 size)
|
|||
|
||||
s32 sys_vm_lock(u32 addr, u32 size)
|
||||
{
|
||||
sys_vm.Warning("sys_vm_lock(addr=0x%x,size=0x%x)", addr, size);
|
||||
sys_vm.Todo("sys_vm_lock(addr=0x%x,size=0x%x)", addr, size);
|
||||
|
||||
// Check address and size.
|
||||
if((current_ct->addr != addr) || (current_ct->size < size) || (size <= 0))
|
||||
|
@ -133,15 +133,13 @@ s32 sys_vm_lock(u32 addr, u32 size)
|
|||
return CELL_EBUSY;
|
||||
}
|
||||
|
||||
// The locked memory area keeps allocated and unchanged until sys_vm_unlocked is called.
|
||||
Memory.Lock(addr, size);
|
||||
|
||||
// TODO: The locked memory area keeps allocated and unchanged until sys_vm_unlocked is called.
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 sys_vm_unlock(u32 addr, u32 size)
|
||||
{
|
||||
sys_vm.Warning("sys_vm_unlock(addr=0x%x,size=0x%x)", addr, size);
|
||||
sys_vm.Todo("sys_vm_unlock(addr=0x%x,size=0x%x)", addr, size);
|
||||
|
||||
// Check address and size.
|
||||
if((current_ct->addr != addr) || (current_ct->size < size) || (size <= 0))
|
||||
|
@ -149,8 +147,7 @@ s32 sys_vm_unlock(u32 addr, u32 size)
|
|||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
Memory.Unlock(addr, size);
|
||||
|
||||
// TODO: Unlock
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -238,9 +235,9 @@ s32 sys_vm_sync(u32 addr, u32 size)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 sys_vm_test(u32 addr, u32 size, u32 result_addr)
|
||||
s32 sys_vm_test(u32 addr, u32 size, vm::ptr<u64> result)
|
||||
{
|
||||
sys_vm.Todo("sys_vm_test(addr=0x%x,size=0x%x,result_addr=0x%x)", addr, size, result_addr);
|
||||
sys_vm.Todo("sys_vm_test(addr=0x%x, size=0x%x, result_addr=0x%x)", addr, size, result.addr());
|
||||
|
||||
// Check address and size.
|
||||
if((current_ct->addr != addr) || (current_ct->size < size) || (size <= 0))
|
||||
|
@ -252,14 +249,14 @@ s32 sys_vm_test(u32 addr, u32 size, u32 result_addr)
|
|||
// sys_vm_test checks the state of a portion of the virtual memory area.
|
||||
|
||||
// Faking.
|
||||
Memory.Write64(result_addr, SYS_VM_TEST_ALLOCATED);
|
||||
*result = SYS_VM_TEST_ALLOCATED;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 sys_vm_get_statistics(u32 addr, u32 stat_addr)
|
||||
s32 sys_vm_get_statistics(u32 addr, vm::ptr<sys_vm_statistics> stat)
|
||||
{
|
||||
sys_vm.Todo("sys_vm_get_statistics(addr=0x%x,stat_addr=0x%x)", addr, stat_addr);
|
||||
sys_vm.Todo("sys_vm_get_statistics(addr=0x%x, stat_addr=0x%x)", addr, stat.addr());
|
||||
|
||||
// Check address.
|
||||
if(current_ct->addr != addr)
|
||||
|
@ -268,17 +265,12 @@ s32 sys_vm_get_statistics(u32 addr, u32 stat_addr)
|
|||
}
|
||||
|
||||
// TODO
|
||||
// sys_vm_get_statistics collects virtual memory management stats.
|
||||
|
||||
sys_vm_statistics stats;
|
||||
stats.physical_mem_size = current_ct->size; // Total physical memory allocated for the virtual memory area.
|
||||
stats.physical_mem_used = 0; // Physical memory in use by the virtual memory area.
|
||||
stats.timestamp = 0; // Current time.
|
||||
stats.vm_crash_ppu = 0; // Number of bad virtual memory accesses from a PPU thread.
|
||||
stats.vm_crash_spu = 0; // Number of bad virtual memory accesses from a SPU thread.
|
||||
stats.vm_read = 0; // Number of virtual memory backup reading operations.
|
||||
stats.vm_write = 0; // Number of virtual memory backup writing operations.
|
||||
Memory.WriteData(stat_addr, stats); // Faking.
|
||||
|
||||
stat->page_fault_ppu = 0;
|
||||
stat->page_fault_spu = 0;
|
||||
stat->page_in = 0;
|
||||
stat->page_out = 0;
|
||||
stat->pmem_total = current_ct->size;
|
||||
stat->pmem_used = 0;
|
||||
stat->timestamp = 0;
|
||||
return CELL_OK;
|
||||
}
|
|
@ -1,18 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#define SYS_VM_TEST_INVALID 0x0000ULL
|
||||
#define SYS_VM_TEST_UNUSED 0x0001ULL
|
||||
#define SYS_VM_TEST_ALLOCATED 0x0002ULL
|
||||
#define SYS_VM_TEST_STORED 0x0004ULL
|
||||
enum : u64
|
||||
{
|
||||
SYS_VM_TEST_INVALID = 0,
|
||||
SYS_VM_TEST_UNUSED = 1,
|
||||
SYS_VM_TEST_ALLOCATED = 2,
|
||||
SYS_VM_TEST_STORED = 4,
|
||||
};
|
||||
|
||||
struct sys_vm_statistics {
|
||||
u64 vm_crash_ppu;
|
||||
u64 vm_crash_spu;
|
||||
u64 vm_read;
|
||||
u64 vm_write;
|
||||
u32 physical_mem_size;
|
||||
u32 physical_mem_used;
|
||||
u64 timestamp;
|
||||
struct sys_vm_statistics
|
||||
{
|
||||
be_t<u64> page_fault_ppu; // Number of bad virtual memory accesses from a PPU thread.
|
||||
be_t<u64> page_fault_spu; // Number of bad virtual memory accesses from a SPU thread.
|
||||
be_t<u64> page_in; // Number of virtual memory backup reading operations.
|
||||
be_t<u64> page_out; // Number of virtual memory backup writing operations.
|
||||
be_t<u32> pmem_total; // Total physical memory allocated for the virtual memory area.
|
||||
be_t<u32> pmem_used; // Physical memory in use by the virtual memory area.
|
||||
be_t<u64> timestamp;
|
||||
};
|
||||
|
||||
// SysCalls
|
||||
|
@ -27,5 +31,5 @@ s32 sys_vm_flush(u32 addr, u32 size);
|
|||
s32 sys_vm_invalidate(u32 addr, u32 size);
|
||||
s32 sys_vm_store(u32 addr, u32 size);
|
||||
s32 sys_vm_sync(u32 addr, u32 size);
|
||||
s32 sys_vm_test(u32 addr, u32 size, u32 result_addr);
|
||||
s32 sys_vm_get_statistics(u32 addr, u32 stat_addr);
|
||||
s32 sys_vm_test(u32 addr, u32 size, vm::ptr<u64> result);
|
||||
s32 sys_vm_get_statistics(u32 addr, vm::ptr<sys_vm_statistics> stat);
|
||||
|
|
|
@ -175,7 +175,7 @@ public:
|
|||
__forceinline bool IsReady() const { return m_status == Ready; }
|
||||
};
|
||||
|
||||
#define LV2_LOCK(x) std::lock_guard<std::recursive_mutex> x(Emu.GetCoreMutex())
|
||||
#define LV2_LOCK(x) std::lock_guard<std::recursive_mutex> core_lock##x(Emu.GetCoreMutex())
|
||||
|
||||
extern Emulator Emu;
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr)
|
|||
}
|
||||
else
|
||||
{
|
||||
disasm->offset = Memory.GetMemFromAddr(CPU->GetOffset());
|
||||
disasm->offset = vm::get_ptr<u8>(CPU->GetOffset());
|
||||
for(uint i=0, count = 4; i<m_item_count; ++i, PC += count)
|
||||
{
|
||||
if(!Memory.IsGoodAddr(CPU->GetOffset() + PC, 4))
|
||||
|
|
|
@ -233,7 +233,7 @@ void MemoryViewerPanel::ShowImage(wxWindow* parent, u32 addr, int mode, u32 widt
|
|||
f_image_viewer->Show();
|
||||
wxClientDC dc_canvas(f_image_viewer);
|
||||
|
||||
unsigned char* originalBuffer = (unsigned char*)Memory.VirtualToRealAddr(addr);
|
||||
unsigned char* originalBuffer = vm::get_ptr<unsigned char>(addr);
|
||||
unsigned char* convertedBuffer = (unsigned char*)malloc(width * height * 3);
|
||||
switch(mode)
|
||||
{
|
||||
|
|
|
@ -330,7 +330,7 @@ void RSXDebugger::OnClickBuffer(wxMouseEvent& event)
|
|||
void RSXDebugger::GoToGet(wxCommandEvent& event)
|
||||
{
|
||||
if (!RSXReady()) return;
|
||||
CellGcmControl* ctrl = (CellGcmControl*)&Memory[Emu.GetGSManager().GetRender().m_ctrlAddress];
|
||||
auto ctrl = vm::get_ptr<CellGcmControl>(Emu.GetGSManager().GetRender().m_ctrlAddress);
|
||||
u64 realAddr;
|
||||
if (Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + ctrl->get, realAddr)) {
|
||||
m_addr = realAddr; // WARNING: Potential Truncation? Cast from u64 to u32
|
||||
|
@ -344,7 +344,7 @@ void RSXDebugger::GoToGet(wxCommandEvent& event)
|
|||
void RSXDebugger::GoToPut(wxCommandEvent& event)
|
||||
{
|
||||
if (!RSXReady()) return;
|
||||
CellGcmControl* ctrl = (CellGcmControl*)&Memory[Emu.GetGSManager().GetRender().m_ctrlAddress];
|
||||
auto ctrl = vm::get_ptr<CellGcmControl>(Emu.GetGSManager().GetRender().m_ctrlAddress);
|
||||
u64 realAddr;
|
||||
if (Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + ctrl->put, realAddr)) {
|
||||
m_addr = realAddr; // WARNING: Potential Truncation? Cast from u64 to u32
|
||||
|
@ -412,13 +412,13 @@ void RSXDebugger::GetBuffers()
|
|||
if(!Memory.IsGoodAddr(render.m_gcm_buffers_addr))
|
||||
continue;
|
||||
|
||||
CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(render.m_gcm_buffers_addr);
|
||||
auto buffers = vm::get_ptr<CellGcmDisplayInfo>(render.m_gcm_buffers_addr);
|
||||
u32 RSXbuffer_addr = render.m_local_mem_addr + buffers[bufferId].offset;
|
||||
|
||||
if(!Memory.IsGoodAddr(RSXbuffer_addr))
|
||||
continue;
|
||||
|
||||
unsigned char* RSXbuffer = (unsigned char*)Memory.VirtualToRealAddr(RSXbuffer_addr);
|
||||
auto RSXbuffer = vm::get_ptr<unsigned char>(RSXbuffer_addr);
|
||||
|
||||
u32 width = buffers[bufferId].width;
|
||||
u32 height = buffers[bufferId].height;
|
||||
|
@ -470,7 +470,7 @@ void RSXDebugger::GetBuffers()
|
|||
if(!Memory.IsGoodAddr(TexBuffer_addr))
|
||||
return;
|
||||
|
||||
unsigned char* TexBuffer = (unsigned char*)Memory.VirtualToRealAddr(TexBuffer_addr);
|
||||
unsigned char* TexBuffer = vm::get_ptr<unsigned char>(TexBuffer_addr);
|
||||
|
||||
u32 width = render.m_textures[m_cur_texture].GetWidth();
|
||||
u32 height = render.m_textures[m_cur_texture].GetHeight();
|
||||
|
|
|
@ -448,7 +448,7 @@ bool ELF32Loader::LoadPhdrData(u64 _offset)
|
|||
}
|
||||
|
||||
elf32_f.Seek(phdr_arr[i].p_offset);
|
||||
elf32_f.Read(&Memory[phdr_arr[i].p_vaddr + offset], phdr_arr[i].p_filesz);
|
||||
elf32_f.Read(vm::get_ptr<void>(phdr_arr[i].p_vaddr + offset), phdr_arr[i].p_filesz);
|
||||
}
|
||||
else if(phdr_arr[i].p_type == 0x00000004)
|
||||
{
|
||||
|
|
|
@ -355,8 +355,8 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
|
|||
else if (phdr.p_filesz)
|
||||
{
|
||||
elf64_f.Seek(phdr.p_offset);
|
||||
elf64_f.Read(&Memory[offset + phdr.p_vaddr], phdr.p_filesz);
|
||||
Emu.GetSFuncManager().StaticAnalyse(&Memory[offset + phdr.p_vaddr], (u32)phdr.p_filesz, (u32)phdr.p_vaddr);
|
||||
elf64_f.Read(vm::get_ptr<void>(offset + phdr.p_vaddr), phdr.p_filesz);
|
||||
Emu.GetSFuncManager().StaticAnalyse(vm::get_ptr<void>(offset + phdr.p_vaddr), (u32)phdr.p_filesz, (u32)phdr.p_vaddr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -370,7 +370,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
|
|||
if(!phdr.p_filesz)
|
||||
break;
|
||||
|
||||
const sys_process_param& proc_param = *(sys_process_param*)&Memory[offset + phdr.p_vaddr];
|
||||
auto& proc_param = vm::get_ref<sys_process_param>(offset + phdr.p_vaddr);
|
||||
|
||||
if (proc_param.size < sizeof(sys_process_param)) {
|
||||
LOG_WARNING(LOADER, "Bad proc param size! [0x%x : 0x%x]", proc_param.size, sizeof(sys_process_param));
|
||||
|
@ -397,7 +397,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
|
|||
if(!phdr.p_filesz)
|
||||
break;
|
||||
|
||||
sys_proc_prx_param proc_prx_param = *(sys_proc_prx_param*)&Memory[offset + phdr.p_vaddr];
|
||||
sys_proc_prx_param proc_prx_param = vm::get_ref<sys_proc_prx_param>(offset + phdr.p_vaddr);
|
||||
|
||||
|
||||
#ifdef LOADER_DEBUG
|
||||
|
@ -418,9 +418,9 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
|
|||
|
||||
for(u32 s=proc_prx_param.libstubstart; s<proc_prx_param.libstubend; s+=sizeof(Elf64_StubHeader))
|
||||
{
|
||||
Elf64_StubHeader stub = *(Elf64_StubHeader*)Memory.GetMemFromAddr(offset + s);
|
||||
Elf64_StubHeader stub = vm::get_ref<Elf64_StubHeader>(offset + s);
|
||||
|
||||
const std::string& module_name = Memory.ReadString(stub.s_modulename);
|
||||
const std::string module_name = vm::get_ptr<const char>(stub.s_modulename);
|
||||
Module* module = Emu.GetModuleManager().GetModuleByName(module_name);
|
||||
if (module) {
|
||||
//module->SetLoaded();
|
||||
|
|
|
@ -177,7 +177,7 @@
|
|||
<ClCompile Include="Emu\SysCalls\Modules\cellSysmodule.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellSysutil.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellSysutilAp.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellSysutil_SaveData.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellSaveData.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellUsbd.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellUsbpspcm.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellUserInfo.cpp" />
|
||||
|
@ -193,9 +193,9 @@
|
|||
<ClCompile Include="Emu\SysCalls\Modules\sceNpSns.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\sceNpTrophy.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\sceNpTus.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\SC_Keyboard.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\SC_Mouse.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\SC_Pad.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellKb.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellMouse.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellPad.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\sysPrxForUser.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\sys_fs.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Modules\sys_http.cpp" />
|
||||
|
@ -308,7 +308,6 @@
|
|||
<ClInclude Include="Emu\Io\Null\NullPadHandler.h" />
|
||||
<ClInclude Include="Emu\Io\Pad.h" />
|
||||
<ClInclude Include="Emu\Io\PadHandler.h" />
|
||||
<ClInclude Include="Emu\Memory\DynamicMemoryBlockBase.h" />
|
||||
<ClInclude Include="Emu\Memory\Memory.h" />
|
||||
<ClInclude Include="Emu\Memory\MemoryBlock.h" />
|
||||
<ClInclude Include="Emu\RSX\GCM.h" />
|
||||
|
@ -375,6 +374,7 @@
|
|||
<ClInclude Include="Emu\SysCalls\Modules\cellL10n.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellNetCtl.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellMsgDialog.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellPad.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellPamf.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellPngDec.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellSail.h" />
|
||||
|
@ -385,7 +385,7 @@
|
|||
<ClInclude Include="Emu\SysCalls\Modules\cellSync.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellSync2.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellSysutil.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellSysutil_SaveData.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellSaveData.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellUserInfo.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellVdec.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellVpost.h" />
|
||||
|
@ -398,8 +398,8 @@
|
|||
<ClInclude Include="Emu\SysCalls\Modules\sceNpSns.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\sceNpTrophy.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\sceNpTus.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\SC_Keyboard.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\SC_Mouse.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellKb.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellMouse.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\sysPrxForUser.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Modules\sys_net.h" />
|
||||
<ClInclude Include="Emu\SysCalls\SC_FUNC.h" />
|
||||
|
|
|
@ -188,9 +188,6 @@
|
|||
<ClCompile Include="Emu\SysCalls\Modules\cellSysutilAp.cpp">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellSysutil_SaveData.cpp">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellUserInfo.cpp">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClCompile>
|
||||
|
@ -530,15 +527,6 @@
|
|||
<ClCompile Include="Emu\SysCalls\lv2\sys_mmapper.cpp">
|
||||
<Filter>Emu\SysCalls\lv2</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\SysCalls\Modules\SC_Mouse.cpp">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\SysCalls\Modules\SC_Pad.cpp">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\SysCalls\Modules\SC_Keyboard.cpp">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\SysCalls\lv2\lv2Fs.cpp">
|
||||
<Filter>Emu\SysCalls\lv2</Filter>
|
||||
</ClCompile>
|
||||
|
@ -623,6 +611,18 @@
|
|||
<ClCompile Include="Emu\Memory\vm.cpp">
|
||||
<Filter>Emu\Memory</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellMouse.cpp">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellKb.cpp">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellPad.cpp">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\SysCalls\Modules\cellSaveData.cpp">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Crypto\aes.h">
|
||||
|
@ -715,9 +715,6 @@
|
|||
<ClInclude Include="Emu\SysCalls\Modules\cellSysutil.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellSysutil_SaveData.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellUserInfo.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
|
@ -1057,9 +1054,6 @@
|
|||
<ClInclude Include="Emu\SysCalls\Modules\cellMsgDialog.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\Memory\DynamicMemoryBlockBase.h">
|
||||
<Filter>Emu\Memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellSync.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
|
@ -1162,12 +1156,6 @@
|
|||
<ClInclude Include="Emu\SysCalls\Modules\cellFiber.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\SysCalls\Modules\SC_Keyboard.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\SysCalls\Modules\SC_Mouse.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Utilities\MTRingbuffer.h">
|
||||
<Filter>Utilities</Filter>
|
||||
</ClInclude>
|
||||
|
@ -1204,5 +1192,17 @@
|
|||
<ClInclude Include="Emu\Memory\vm_var.h">
|
||||
<Filter>Emu\Memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellPad.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellKb.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellMouse.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\SysCalls\Modules\cellSaveData.h">
|
||||
<Filter>Emu\SysCalls\Modules</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Add table
Reference in a new issue