From 1568930da6476354c4f5df24c4dacf29d623de8d Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 30 Nov 2014 22:23:51 +0300 Subject: [PATCH] /dev_bdvd/ and /app_home/ fixed --- rpcs3/Emu/FS/VFS.cpp | 4 ++-- rpcs3/Emu/RSX/GCM.h | 8 ++++--- rpcs3/Emu/RSX/RSXThread.cpp | 28 +++++++++++------------ rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp | 21 +++++++++++++---- rpcs3/Gui/RSXDebugger.cpp | 4 ++-- 5 files changed, 40 insertions(+), 25 deletions(-) diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index f36c39c045..d963d9c91f 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -422,7 +422,7 @@ void VFS::Init(const std::string& path) Mount(entry.mount, mpath, dev); } - Link("/app_home/", cwd); + Link("/app_home/", "/host_root/" + cwd); } void VFS::SaveLoadDevices(std::vector& res, bool is_load) @@ -442,7 +442,7 @@ void VFS::SaveLoadDevices(std::vector& res, bool is_load) res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_flash/", "/dev_flash/"); res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_usb000/", "/dev_usb000/"); res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_usb000/", "/dev_usb/"); - res.emplace_back(vfsDevice_LocalFile, "$(GameDir)/../", "/dev_bdvd/"); + res.emplace_back(vfsDevice_LocalFile, "$(GameDir)/../../", "/dev_bdvd/"); res.emplace_back(vfsDevice_LocalFile, "", "/host_root/"); return; diff --git a/rpcs3/Emu/RSX/GCM.h b/rpcs3/Emu/RSX/GCM.h index e19e792652..7b216aa87f 100644 --- a/rpcs3/Emu/RSX/GCM.h +++ b/rpcs3/Emu/RSX/GCM.h @@ -1,5 +1,7 @@ #pragma once +#include "Emu/Memory/atomic_type.h" + enum { CELL_GCM_DISPLAY_HSYNC = 1, @@ -201,9 +203,9 @@ enum struct CellGcmControl { - be_t put; - be_t get; - be_t ref; + atomic_t put; + atomic_t get; + atomic_t ref; }; struct CellGcmConfig diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index ca9b35cca0..de0ff1aa8f 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -259,7 +259,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const // NV406E case NV406E_SET_REFERENCE: { - m_ctrl->ref = ARGS(0); + m_ctrl->ref.exchange(be_t::make(ARGS(0))); } break; @@ -2204,14 +2204,8 @@ void RSXThread::Task() inc=1; - u32 put, get; - // this code produces only mov + bswap: - put = se_t::func(std::atomic_load((volatile std::atomic*)((u8*)m_ctrl + offsetof(CellGcmControl, put)))); - get = se_t::func(std::atomic_load((volatile std::atomic*)((u8*)m_ctrl + offsetof(CellGcmControl, get)))); - /* - se_t::func(put, InterlockedCompareExchange((volatile unsigned long*)((u8*)m_ctrl + offsetof(CellGcmControl, put)), 0, 0)); - se_t::func(get, InterlockedCompareExchange((volatile unsigned long*)((u8*)m_ctrl + offsetof(CellGcmControl, get)), 0, 0)); - */ + u32 get = m_ctrl->get.read_sync(); + u32 put = m_ctrl->put.read_sync(); if(put == get || !Emu.IsRunning()) { @@ -2241,7 +2235,7 @@ void RSXThread::Task() { u32 addr = cmd & ~(CELL_GCM_METHOD_FLAG_JUMP | CELL_GCM_METHOD_FLAG_NON_INCREMENT); //LOG_WARNING(RSX, "rsx jump(0x%x) #addr=0x%x, cmd=0x%x, get=0x%x, put=0x%x", addr, m_ioAddress + get, cmd, get, put); - m_ctrl->get = addr; + m_ctrl->get.exchange(be_t::make(addr)); continue; } if(cmd & CELL_GCM_METHOD_FLAG_CALL) @@ -2250,7 +2244,7 @@ void RSXThread::Task() u32 offs = cmd & ~CELL_GCM_METHOD_FLAG_CALL; //u32 addr = offs; //LOG_WARNING(RSX, "rsx call(0x%x) #0x%x - 0x%x - 0x%x", offs, addr, cmd, get); - m_ctrl->get = offs; + m_ctrl->get.exchange(be_t::make(offs)); continue; } if(cmd == CELL_GCM_METHOD_FLAG_RETURN) @@ -2259,7 +2253,7 @@ void RSXThread::Task() u32 get = m_call_stack.top(); m_call_stack.pop(); //LOG_WARNING(RSX, "rsx return(0x%x)", get); - m_ctrl->get = get; + m_ctrl->get.exchange(be_t::make(get)); continue; } if(cmd & CELL_GCM_METHOD_FLAG_NON_INCREMENT) @@ -2273,7 +2267,10 @@ void RSXThread::Task() LOG_ERROR(Log::RSX, "null cmd: cmd=0x%x, put=0x%x, get=0x%x (addr=0x%x)", cmd, put, get, (u32)Memory.RSXIOMem.RealAddr(get)); //Emu.Pause(); //HACK! We shouldn't be here - m_ctrl->get = get + (count + 1) * 4; + m_ctrl->get.atomic_op([](be_t& value) + { + value += 4; + }); continue; } @@ -2286,7 +2283,10 @@ void RSXThread::Task() DoCmd(cmd, cmd & 0x3ffff, args.addr(), count); - m_ctrl->get = get + (count + 1) * 4; + m_ctrl->get.atomic_op([count](be_t& value) + { + value += (count + 1) * 4; + }); //memset(Memory.GetMemFromAddr(p.m_ioAddress + get), 0, (count + 1) * 4); } catch (const std::string& e) diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index bb4146f8b4..5f53b45414 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -380,9 +380,9 @@ s32 _cellGcmInitBody(vm::ptr context, u32 cmdSize, u32 ioSiz vm::write32(context.addr(), gcm_info.context_addr); auto& ctrl = vm::get_ref(gcm_info.control_addr); - ctrl.put = 0; - ctrl.get = 0; - ctrl.ref = -1; + ctrl.put.write_relaxed(be_t::make(0)); + ctrl.get.write_relaxed(be_t::make(0)); + ctrl.ref.write_relaxed(be_t::make(-1)); auto& render = Emu.GetGSManager().GetRender(); render.m_ctxt_addr = context.addr(); @@ -526,7 +526,10 @@ s32 cellGcmSetPrepareFlip(vm::ptr ctxt, u32 id) if(ctxt.addr() == gcm_info.context_addr) { auto& ctrl = vm::get_ref(gcm_info.control_addr); - ctrl.put += 8; + ctrl.put.atomic_op([](be_t& value) + { + value += 8; + }); } return id; @@ -1166,6 +1169,16 @@ int cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 co s32 cellGcmCallback(vm::ptr context, u32 count) { cellGcmSys->Log("cellGcmCallback(context_addr=0x%x, count=0x%x)", context.addr(), count); + + auto& ctrl = vm::get_ref(gcm_info.control_addr); + + { + const u32 address = context->current; + const u32 upper = offsetTable.ioAddress[address >> 20]; // 12 bits + assert(upper != 0xFFFF); + u32 offset = (upper << 20) | (address & 0xFFFFF); + //ctrl.put.exchange(be_t::make(offset)); // update put pointer + } // TODO: this may be wrong diff --git a/rpcs3/Gui/RSXDebugger.cpp b/rpcs3/Gui/RSXDebugger.cpp index 85ab9a5672..69a09bc2cb 100644 --- a/rpcs3/Gui/RSXDebugger.cpp +++ b/rpcs3/Gui/RSXDebugger.cpp @@ -332,7 +332,7 @@ void RSXDebugger::GoToGet(wxCommandEvent& event) if (!RSXReady()) return; auto ctrl = vm::get_ptr(Emu.GetGSManager().GetRender().m_ctrlAddress); u64 realAddr; - if (Memory.RSXIOMem.getRealAddr(ctrl->get, realAddr)) { + if (Memory.RSXIOMem.getRealAddr(ctrl->get.read_relaxed(), realAddr)) { m_addr = realAddr; // WARNING: Potential Truncation? Cast from u64 to u32 t_addr->SetValue(wxString::Format("%08x", m_addr)); UpdateInformation(); @@ -346,7 +346,7 @@ void RSXDebugger::GoToPut(wxCommandEvent& event) if (!RSXReady()) return; auto ctrl = vm::get_ptr(Emu.GetGSManager().GetRender().m_ctrlAddress); u64 realAddr; - if (Memory.RSXIOMem.getRealAddr(ctrl->put, realAddr)) { + if (Memory.RSXIOMem.getRealAddr(ctrl->put.read_relaxed(), realAddr)) { m_addr = realAddr; // WARNING: Potential Truncation? Cast from u64 to u32 t_addr->SetValue(wxString::Format("%08x", m_addr)); UpdateInformation();