1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 04:02:42 +01:00

sys_process_get_paramsfo implemented

This commit is contained in:
Nekotekina 2015-02-28 17:41:15 +03:00
parent 316bd8d155
commit 942d984dc5
14 changed files with 58 additions and 86 deletions

View File

@ -832,7 +832,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
return false;
}
memcpy(vm::get_priv_ptr(addr), XMMREG(context, reg - X64R_XMM0), 16);
memcpy(vm::priv_ptr(addr), XMMREG(context, reg - X64R_XMM0), 16);
break;
}
@ -842,7 +842,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
return false;
}
memcpy(vm::get_priv_ptr(addr), &reg_value, d_size);
memcpy(vm::priv_ptr(addr), &reg_value, d_size);
break;
}
case X64OP_MOVS:
@ -867,7 +867,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
// copy data
memcpy(&value, (void*)RSI(context), d_size);
memcpy(vm::get_priv_ptr(a_addr), &value, d_size);
memcpy(vm::priv_ptr(a_addr), &value, d_size);
// shift pointers
if (EFLAGS(context) & 0x400 /* direction flag */)
@ -925,7 +925,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
while (a_addr >> 12 == addr >> 12)
{
// fill data with value
memcpy(vm::get_priv_ptr(a_addr), &value, d_size);
memcpy(vm::priv_ptr(a_addr), &value, d_size);
// shift pointers
if (EFLAGS(context) & 0x400 /* direction flag */)
@ -966,10 +966,10 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
switch (d_size)
{
case 1: reg_value = vm::get_priv_ref<atomic_le_t<u8>>(addr).exchange((u8)reg_value); break;
case 2: reg_value = vm::get_priv_ref<atomic_le_t<u16>>(addr).exchange((u16)reg_value); break;
case 4: reg_value = vm::get_priv_ref<atomic_le_t<u32>>(addr).exchange((u32)reg_value); break;
case 8: reg_value = vm::get_priv_ref<atomic_le_t<u64>>(addr).exchange((u64)reg_value); break;
case 1: reg_value = vm::priv_ref<atomic_le_t<u8>>(addr).exchange((u8)reg_value); break;
case 2: reg_value = vm::priv_ref<atomic_le_t<u16>>(addr).exchange((u16)reg_value); break;
case 4: reg_value = vm::priv_ref<atomic_le_t<u32>>(addr).exchange((u32)reg_value); break;
case 8: reg_value = vm::priv_ref<atomic_le_t<u64>>(addr).exchange((u64)reg_value); break;
default: return false;
}
@ -989,10 +989,10 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
switch (d_size)
{
case 1: old_value = vm::get_priv_ref<atomic_le_t<u8>>(addr).compare_and_swap((u8)cmp_value, (u8)reg_value); break;
case 2: old_value = vm::get_priv_ref<atomic_le_t<u16>>(addr).compare_and_swap((u16)cmp_value, (u16)reg_value); break;
case 4: old_value = vm::get_priv_ref<atomic_le_t<u32>>(addr).compare_and_swap((u32)cmp_value, (u32)reg_value); break;
case 8: old_value = vm::get_priv_ref<atomic_le_t<u64>>(addr).compare_and_swap((u64)cmp_value, (u64)reg_value); break;
case 1: old_value = vm::priv_ref<atomic_le_t<u8>>(addr).compare_and_swap((u8)cmp_value, (u8)reg_value); break;
case 2: old_value = vm::priv_ref<atomic_le_t<u16>>(addr).compare_and_swap((u16)cmp_value, (u16)reg_value); break;
case 4: old_value = vm::priv_ref<atomic_le_t<u32>>(addr).compare_and_swap((u32)cmp_value, (u32)reg_value); break;
case 8: old_value = vm::priv_ref<atomic_le_t<u64>>(addr).compare_and_swap((u64)cmp_value, (u64)reg_value); break;
default: return false;
}

View File

@ -410,7 +410,7 @@ void SPUThread::EnqMfcCmd(MFCReg& MFCArgs)
{
vm::reservation_op(vm::cast(ea), 128, [this, tag, lsa, ea]()
{
memcpy(vm::get_priv_ptr(vm::cast(ea)), vm::get_ptr(ls_offset + lsa), 128);
memcpy(vm::priv_ptr(vm::cast(ea)), vm::get_ptr(ls_offset + lsa), 128);
});
if (op == MFC_PUTLLUC_CMD)

View File

@ -264,7 +264,7 @@ namespace vm
_reservation_set(addr, true);
// update memory using privileged access
memcpy(vm::get_priv_ptr(addr), data, size);
memcpy(vm::priv_ptr(addr), data, size);
// remove callback to not call it on successful update
g_reservation_cb = nullptr;
@ -362,7 +362,7 @@ namespace vm
}
void* real_addr = vm::get_ptr(addr);
void* priv_addr = vm::get_priv_ptr(addr);
void* priv_addr = vm::priv_ptr(addr);
#ifdef _WIN32
auto protection = flags & page_writable ? PAGE_READWRITE : (flags & page_readable ? PAGE_READONLY : PAGE_NOACCESS);
@ -464,7 +464,7 @@ namespace vm
}
void* real_addr = vm::get_ptr(addr);
void* priv_addr = vm::get_priv_ptr(addr);
void* priv_addr = vm::priv_ptr(addr);
#ifdef _WIN32
DWORD old;

View File

@ -77,15 +77,15 @@ namespace vm
}
template<typename T = void>
T* const get_priv_ptr(u32 addr)
T* const priv_ptr(u32 addr)
{
return reinterpret_cast<T*>(static_cast<u8*>(g_priv_addr) + addr);
}
template<typename T>
T& get_priv_ref(u32 addr)
T& priv_ref(u32 addr)
{
return *get_priv_ptr<T>(addr);
return *priv_ptr<T>(addr);
}
u32 get_addr(const void* real_pointer);

View File

@ -214,9 +214,9 @@ namespace vm
return vm::get_ptr<T>(vm::cast(m_addr));
}
T* get_priv_ptr() const
T* priv_ptr() const
{
return vm::get_priv_ptr<T>(vm::cast(m_addr));
return vm::priv_ptr<T>(vm::cast(m_addr));
}
static const _ptr_base make(const AT& addr)
@ -248,9 +248,9 @@ namespace vm
return vm::get_ptr<void>(vm::cast(m_addr));
}
void* get_priv_ptr() const
void* priv_ptr() const
{
return vm::get_priv_ptr<void>(vm::cast(m_addr));
return vm::priv_ptr<void>(vm::cast(m_addr));
}
explicit operator void*() const
@ -311,9 +311,9 @@ namespace vm
return vm::get_ptr<const void>(vm::cast(m_addr));
}
const void* get_priv_ptr() const
const void* priv_ptr() const
{
return vm::get_priv_ptr<const void>(vm::cast(m_addr));
return vm::priv_ptr<const void>(vm::cast(m_addr));
}
explicit operator const void*() const

View File

@ -168,7 +168,7 @@ bool spursKernel1SelectWorkload(SPUThread & spu) {
vm::reservation_op(vm::cast(ctxt->spurs.addr()), 128, [&]() {
// lock the first 0x80 bytes of spurs
auto spurs = ctxt->spurs.get_priv_ptr();
auto spurs = ctxt->spurs.priv_ptr();
// Calculate the contention (number of SPUs used) for each workload
u8 contention[CELL_SPURS_MAX_WORKLOAD];
@ -325,7 +325,7 @@ bool spursKernel2SelectWorkload(SPUThread & spu) {
vm::reservation_op(vm::cast(ctxt->spurs.addr()), 128, [&]() {
// lock the first 0x80 bytes of spurs
auto spurs = ctxt->spurs.get_priv_ptr();
auto spurs = ctxt->spurs.priv_ptr();
// Calculate the contention (number of SPUs used) for each workload
u8 contention[CELL_SPURS_MAX_WORKLOAD2];
@ -696,7 +696,7 @@ void spursSysServiceMain(SPUThread & spu, u32 pollStatus) {
vm::reservation_acquire(vm::get_ptr(spu.ls_offset + 0x100), vm::cast(ctxt->spurs.addr()), 128);
vm::reservation_op(vm::cast(ctxt->spurs.addr() + offsetof(CellSpurs, m.wklState1)), 128, [&]() {
auto spurs = ctxt->spurs.get_priv_ptr();
auto spurs = ctxt->spurs.priv_ptr();
// Halt if already initialised
if (spurs->m.sysSrvOnSpu & (1 << ctxt->spuNum)) {
@ -786,7 +786,7 @@ void spursSysServiceProcessRequests(SPUThread & spu, SpursKernelContext * ctxt)
bool terminate = false;
vm::reservation_op(vm::cast(ctxt->spurs.addr() + offsetof(CellSpurs, m.wklState1)), 128, [&]() {
auto spurs = ctxt->spurs.get_priv_ptr();
auto spurs = ctxt->spurs.priv_ptr();
// Terminate request
if (spurs->m.sysSrvMsgTerminate & (1 << ctxt->spuNum)) {
@ -853,7 +853,7 @@ void spursSysServiceActivateWorkload(SPUThread & spu, SpursKernelContext * ctxt)
}
vm::reservation_op(vm::cast(ctxt->spurs.addr() + offsetof(CellSpurs, m.wklState1)), 128, [&]() {
auto spurs = ctxt->spurs.get_priv_ptr();
auto spurs = ctxt->spurs.priv_ptr();
for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++) {
// Update workload status and runnable flag based on the workload state
@ -910,7 +910,7 @@ void spursSysServiceUpdateShutdownCompletionEvents(SPUThread & spu, SpursKernelC
u32 wklNotifyBitSet;
u8 spuPort;
vm::reservation_op(vm::cast(ctxt->spurs.addr() + offsetof(CellSpurs, m.wklState1)), 128, [&]() {
auto spurs = ctxt->spurs.get_priv_ptr();
auto spurs = ctxt->spurs.priv_ptr();
wklNotifyBitSet = 0;
spuPort = spurs->m.spuPort;;
@ -952,7 +952,7 @@ void spursSysServiceTraceUpdate(SPUThread & spu, SpursKernelContext * ctxt, u32
u8 sysSrvMsgUpdateTrace;
vm::reservation_op(vm::cast(ctxt->spurs.addr() + offsetof(CellSpurs, m.wklState1)), 128, [&]() {
auto spurs = ctxt->spurs.get_priv_ptr();
auto spurs = ctxt->spurs.priv_ptr();
sysSrvMsgUpdateTrace = spurs->m.sysSrvMsgUpdateTrace;
spurs->m.sysSrvMsgUpdateTrace &= ~(1 << ctxt->spuNum);
@ -1006,7 +1006,7 @@ void spursSysServiceCleanupAfterSystemWorkload(SPUThread & spu, SpursKernelConte
bool do_return = false;
vm::reservation_op(vm::cast(ctxt->spurs.addr() + offsetof(CellSpurs, m.wklState1)), 128, [&]() {
auto spurs = ctxt->spurs.get_priv_ptr();
auto spurs = ctxt->spurs.priv_ptr();
if (spurs->m.sysSrvWorkload[ctxt->spuNum] == 0xFF) {
do_return = true;
@ -1024,7 +1024,7 @@ void spursSysServiceCleanupAfterSystemWorkload(SPUThread & spu, SpursKernelConte
spursSysServiceActivateWorkload(spu, ctxt);
vm::reservation_op(vm::cast(ctxt->spurs.addr()), 128, [&]() {
auto spurs = ctxt->spurs.get_priv_ptr();
auto spurs = ctxt->spurs.priv_ptr();
if (wklId >= CELL_SPURS_MAX_WORKLOAD) {
spurs->m.wklCurrentContention[wklId & 0x0F] -= 0x10;
@ -1158,7 +1158,7 @@ s32 spursTasksetProcessRequest(SPUThread & spu, s32 request, u32 * taskId, u32 *
s32 rc = CELL_OK;
s32 numNewlyReadyTasks;
vm::reservation_op(vm::cast(ctxt->taskset.addr()), 128, [&]() {
auto taskset = ctxt->taskset.get_priv_ptr();
auto taskset = ctxt->taskset.priv_ptr();
// Verify taskset state is valid
auto _0 = be_t<u128>::make(u128::from32(0));
@ -1299,7 +1299,7 @@ s32 spursTasksetProcessRequest(SPUThread & spu, s32 request, u32 * taskId, u32 *
// Increment the ready count of the workload by the number of tasks that have become ready
vm::reservation_op(vm::cast(kernelCtxt->spurs.addr()), 128, [&]() {
auto spurs = kernelCtxt->spurs.get_priv_ptr();
auto spurs = kernelCtxt->spurs.priv_ptr();
s32 readyCount = kernelCtxt->wklCurrentId < CELL_SPURS_MAX_WORKLOAD ? spurs->m.wklReadyCount1[kernelCtxt->wklCurrentId].read_relaxed() : spurs->m.wklIdleSpuCountOrReadyCount2[kernelCtxt->wklCurrentId & 0x0F].read_relaxed();
readyCount += numNewlyReadyTasks;

View File

@ -559,13 +559,12 @@ s32 _sys_printf(vm::ptr<const char> fmt) // va_args...
return CELL_OK;
}
s32 _nid_E75C40F2(u32 dest)
s32 sys_process_get_paramsfo(vm::ptr<u8[0x40]> buffer)
{
sysPrxForUser.Todo("Unnamed function 0xE75C40F2 (dest=0x%x) -> CELL_ENOENT", dest);
sysPrxForUser.Warning("sys_process_get_paramsfo(buffer=0x%x)", buffer);
// prx: load some data (0x40 bytes) previously set by sys_process_get_paramsfo
//memset(Memory + dest, 0, 0x40);
return CELL_ENOENT;
// prx: load some data (0x40 bytes) previously set by _sys_process_get_paramsfo syscall
return _sys_process_get_paramsfo(buffer);
}
Module sysPrxForUser("sysPrxForUser", []()
@ -674,5 +673,5 @@ Module sysPrxForUser("sysPrxForUser", []()
REG_FUNC(sysPrxForUser, _sys_printf);
REG_UNNAMED(sysPrxForUser, E75C40F2);
REG_FUNC(sysPrxForUser, sys_process_get_paramsfo);
});

View File

@ -80,7 +80,7 @@ const ppu_func_caller sc_table[1024] =
null_func,//bind_func(), //27 (0x01B) DBG
null_func,//bind_func(_sys_process_get_number_of_object)//28 (0x01C) ROOT
bind_func(sys_process_get_id), //29 (0x01D) ROOT
bind_func(sys_process_get_paramsfo), //30 (0x01E)
bind_func(_sys_process_get_paramsfo), //30 (0x01E)
null_func,//bind_func(sys_process_get_ppu_guid), //31 (0x01F)
null_func, null_func, null_func, null_func, null_func, null_func, null_func, null_func, null_func, //32-40 UNS

View File

@ -4,6 +4,8 @@
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/FS/vfsFile.h"
#include "Loader/PSF.h"
#include "sys_memory.h"
#include "sys_process.h"
@ -286,29 +288,20 @@ s32 sys_process_is_spu_lock_line_reservation_address(u32 addr, u64 flags)
return process_is_spu_lock_line_reservation_address(addr, flags);
}
s32 sys_process_get_paramsfo(vm::ptr<u8> buffer)
s32 _sys_process_get_paramsfo(vm::ptr<u8[0x40]> buffer)
{
sys_process.Todo("sys_process_get_paramsfo(buffer_addr=0x%x) -> CELL_ENOENT", buffer.addr());
sys_process.Warning("_sys_process_get_paramsfo(buffer=0x%x)", buffer);
memset(buffer.get_ptr(), 0, 0x40);
memcpy(buffer.get_ptr(), Emu.GetTitleID().c_str(), Emu.GetTitleID().length());
return CELL_ENOENT;
/*//Before uncommenting this code, we should check if it is actually working.
MemoryAllocator<be_t<u32>> fd;
char filePath [] = "/app_home/../PARAM.SFO";
if (!cellFsOpen(Memory.RealToVirtualAddr(filePath), 0, fd, NULL, 0))
return CELL_ENOENT;
MemoryAllocator<be_t<u64>> pos, nread;
cellFsLseek(fd, 0, CELL_SEEK_SET, pos); //TODO: Move to the appropriate offset (probably 0x3F7)
cellFsRead(fd, buffer.addr(), 40, nread); //WARNING: If offset==0x3F7: The file will end before the buffer (40 bytes) is filled!
cellFsClose(fd);
return CELL_OK;*/
}
s32 process_get_sdk_version(u32 pid, s32& ver)
{
// TODO: get correct SDK version for selected pid
ver = Emu.m_sdk_version;
// get correct SDK version for selected pid
ver = Emu.GetSDKVersion();
return CELL_OK;
}

View File

@ -33,7 +33,7 @@ s32 sys_process_getpid();
s32 sys_process_getppid();
s32 sys_process_get_number_of_object(u32 object, vm::ptr<u32> nump);
s32 sys_process_get_id(u32 object, vm::ptr<u32> buffer, u32 size, vm::ptr<u32> set_size);
s32 sys_process_get_paramsfo(vm::ptr<u8> buffer);
s32 _sys_process_get_paramsfo(vm::ptr<u8[0x40]> buffer);
s32 sys_process_get_sdk_version(u32 pid, vm::ptr<s32> version);
s32 sys_process_get_status(u64 unk);
s32 sys_process_is_spu_lock_line_reservation_address(u32 addr, u64 flags);

View File

@ -255,24 +255,7 @@ void Emulator::Load()
vm::close();
return;
}
// trying to load some info from PARAM.SFO
vfsFile f2("/app_home/../PARAM.SFO");
if (f2.IsOpened())
{
PSFLoader psf(f2);
if (psf.Load(false))
{
std::string version = psf.GetString("PS3_SYSTEM_VER");
const size_t dot = version.find('.');
if (dot != std::string::npos)
{
Emu.m_sdk_version = (std::stoi(version, nullptr, 16) << 20) | ((std::stoi(version.substr(dot + 1), nullptr, 16) & 0xffff) << 4) | 1;
}
}
}
LoadPoints(BreakPointsDBName);
m_status = Ready;

View File

@ -103,7 +103,6 @@ public:
std::string m_emu_path;
std::string m_title_id;
std::string m_title;
s32 m_sdk_version;
Emulator();
~Emulator();
@ -123,12 +122,12 @@ public:
return m_emu_path;
}
std::string GetTitleID() const
const std::string& GetTitleID() const
{
return m_title_id;
}
std::string GetTitle() const
const std::string& GetTitle() const
{
return m_title;
}
@ -177,6 +176,7 @@ public:
u32 GetTLSMemsz() const { return m_info.GetTLSMemsz(); }
u32 GetMallocPageSize() { return m_info.GetProcParam().malloc_pagesize; }
u32 GetSDKVersion() { return m_info.GetProcParam().sdk_version; }
u32 GetRSXCallback() const { return m_rsx_callback; }
u32 GetCPUThreadStop() const { return m_cpu_thr_stop; }

View File

@ -62,7 +62,7 @@ void GLGSFrame::Flip(void* context)
canvas->SwapBuffers();
m_frames++;
const std::string sub_title = Emu.GetTitle() += Emu.GetTitleID().length() ? " [" + Emu.GetTitleID() + "] | " : " | ";
const std::string sub_title = Emu.GetTitle() + (Emu.GetTitleID().length() ? " [" + Emu.GetTitleID() + "] | " : " | ");
if (fps_t.GetElapsedTimeInSec() >= 0.5)
{

View File

@ -307,8 +307,6 @@ namespace loader
return load_sprx(info);
}
Emu.m_sdk_version = -1;
//store elf to memory
vm::ps3::init();
@ -618,7 +616,6 @@ namespace loader
*/
info = proc_param.info;
Emu.m_sdk_version = info.sdk_version;
}
}
break;