From b7be8b19efb325307dbbe0ddaf84625fcc997c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandro=20S=C3=A1nchez=20Bach?= Date: Sat, 16 Aug 2014 23:45:56 +0200 Subject: [PATCH] Updates in sys_rsx and CellGcmDisplayInfo Thanks a lot to @3141card for all the relevant information about RSX related lv2 syscalls. --- rpcs3/Emu/RSX/GCM.h | 24 ++++-- rpcs3/Emu/RSX/GL/GLGSRender.cpp | 10 +-- rpcs3/Emu/RSX/GSManager.h | 8 -- rpcs3/Emu/RSX/RSXThread.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp | 113 +++++++++++++++++++++++++---- 5 files changed, 121 insertions(+), 36 deletions(-) diff --git a/rpcs3/Emu/RSX/GCM.h b/rpcs3/Emu/RSX/GCM.h index af6d412e96..ac37e04a83 100644 --- a/rpcs3/Emu/RSX/GCM.h +++ b/rpcs3/Emu/RSX/GCM.h @@ -238,17 +238,17 @@ struct CellGcmSurface u8 colorFormat; u8 colorTarget; u8 colorLocation[4]; - u32 colorOffset[4]; - u32 colorPitch[4]; + be_t colorOffset[4]; + be_t colorPitch[4]; u8 depthFormat; u8 depthLocation; u8 _padding[2]; - u32 depthOffset; - u32 depthPitch; - u16 width; - u16 height; - u16 x; - u16 y; + be_t depthOffset; + be_t depthPitch; + be_t width; + be_t height; + be_t x; + be_t y; }; struct CellGcmReportData @@ -268,6 +268,14 @@ struct CellGcmZcullInfo u32 status1; }; +struct CellGcmDisplayInfo +{ + be_t offset; + be_t pitch; + be_t width; + be_t height; +}; + struct CellGcmTileInfo { be_t tile; diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 24e7fb790c..d19aa005cc 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -14,7 +14,7 @@ #define CMD_LOG(...) #endif -gcmBuffer gcmBuffers[8]; +CellGcmDisplayInfo gcmBuffers[8]; GLuint g_flip_tex, g_depth_tex, g_pbo[6]; int last_width = 0, last_height = 0, last_depth_format = 0; @@ -1272,13 +1272,13 @@ void GLGSRender::Flip() if (m_read_buffer) { format = GL_BGRA; - gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(m_gcm_buffers_addr); - u32 addr = GetAddress(re(buffers[m_gcm_current_buffer].offset), CELL_GCM_LOCATION_LOCAL); + CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(m_gcm_buffers_addr); + u32 addr = GetAddress(buffers[m_gcm_current_buffer].offset, CELL_GCM_LOCATION_LOCAL); if (Memory.IsGoodAddr(addr)) { - width = re(buffers[m_gcm_current_buffer].width); - height = re(buffers[m_gcm_current_buffer].height); + width = buffers[m_gcm_current_buffer].width; + height = buffers[m_gcm_current_buffer].height; src_buffer = (u8*)Memory.VirtualToRealAddr(addr); } else diff --git a/rpcs3/Emu/RSX/GSManager.h b/rpcs3/Emu/RSX/GSManager.h index 08f424a9a9..11f7b3917f 100644 --- a/rpcs3/Emu/RSX/GSManager.h +++ b/rpcs3/Emu/RSX/GSManager.h @@ -33,14 +33,6 @@ struct GSInfo } }; -struct gcmBuffer -{ - u32 offset; - u32 pitch; - u32 width; - u32 height; -}; - class GSManager { GSInfo m_info; diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 295768b92a..81b37330e2 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -1320,7 +1320,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t args, const u32 case 2: m_surface_pitch_a = ARGS(1); } - gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(m_gcm_buffers_addr); + CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(m_gcm_buffers_addr); m_width = re(buffers[m_gcm_current_buffer].width); m_height = re(buffers[m_gcm_current_buffer].height); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp b/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp index 5d92f4205c..2e12f9e4b7 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp @@ -19,27 +19,57 @@ s32 sys_rsx_device_close() return CELL_OK; } -s32 sys_rsx_memory_allocate() +/* + * lv2 SysCall 668 (0x29C): sys_rsx_memory_allocate + * @param mem_handle (OUT): Context / ID, which is used by sys_rsx_memory_free to free allocated memory. + * @param mem_addr (OUT): Returns the local memory base address, usually 0xC0000000. + * @param size (IN): Local memory size. E.g. 0x0F900000 (249 MB). + * @param flags (IN): E.g. Immediate value passed in cellGcmSys is 8. + * @param a5 (IN): E.g. Immediate value passed in cellGcmSys is 0x00300000 (3 MB?). + * @param a6 (IN): E.g. Immediate value passed in cellGcmSys is 16. + * @param a7 (IN): E.g. Immediate value passed in cellGcmSys is 8. + */ +s32 sys_rsx_memory_allocate(mem32_t mem_handle, mem32_t mem_addr, u32 size, u64 flags, u64 a5, u64 a6, u64 a7) { - sys_rsx.Todo("sys_rsx_memory_allocate()"); + sys_rsx.Todo("sys_rsx_memory_allocate(mem_handle_addr=0x%x, local_mem_addr=0x%x, size=0x%x, flags=0x%x, a5=%d, a6=%d, a7=%d)", + mem_handle.GetAddr(), mem_addr.GetAddr(), size, flags, a5, a6, a7); return CELL_OK; } -s32 sys_rsx_memory_free() +/* + * lv2 SysCall 669 (0x29D): sys_rsx_memory_free + * @param mem_handle (OUT): Context / ID, for allocated local memory generated by sys_rsx_memory_allocate + */ +s32 sys_rsx_memory_free(u32 mem_handle) { - sys_rsx.Todo("sys_rsx_memory_free()"); + sys_rsx.Todo("sys_rsx_memory_free(mem_handle=%d)", mem_handle); return CELL_OK; } -s32 sys_rsx_context_allocate() +/* + * lv2 SysCall 670 (0x29E): sys_rsx_context_allocate + * @param context_id (OUT): RSX_context, E.g. 0x55555555 (in vsh.self) + * @param lpar_dma_control (OUT): Control register area. E.g. 0x60100000 (in vsh.self) + * @param lpar_driver_info (OUT): RSX data like frequencies, sizes, version... E.g. 0x60200000 (in vsh.self) + * @param lpar_reports (OUT): Report data area. E.g. 0x60300000 (in vsh.self) + * @param mem_ctx (IN): mem_ctx given by sys_rsx_memory_allocate + * @param system_mode (IN): + */ +s32 sys_rsx_context_allocate(mem32_t context_id, mem32_t lpar_dma_control, mem32_t lpar_driver_info, mem32_t lpar_reports, u64 mem_ctx, u64 system_mode) { - sys_rsx.Todo("sys_rsx_context_allocate()"); + sys_rsx.Todo("sys_rsx_context_allocate(context_id_addr=0x%x, lpar_dma_control_addr=0x%x, lpar_driver_info_addr=0x%x, lpar_reports_addr=0x%x, mem_ctx=0x%x, system_mode=0x%x)", + context_id.GetAddr(), lpar_dma_control.GetAddr(), lpar_driver_info.GetAddr(), lpar_reports.GetAddr(), mem_ctx, system_mode); + return CELL_OK; } -s32 sys_rsx_context_free() +/* + * lv2 SysCall 671 (0x29F): sys_rsx_context_free + * @param a1 (IN): RSX_context generated by sys_rsx_context_allocate to free the context. + */ +s32 sys_rsx_context_free(u32 context_id) { - sys_rsx.Todo("sys_rsx_context_free()"); + sys_rsx.Todo("sys_rsx_context_free(context_id=%d)", context_id); return CELL_OK; } @@ -55,21 +85,76 @@ s32 sys_rsx_context_iounmap() return CELL_OK; } -s32 sys_rsx_context_attribute(s32 context_id, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6) +/* + * lv2 SysCall 674 (0x2A2): sys_rsx_context_attribute + * @param context_id (IN): RSX context, e.g. 0x55555555 + * @param package_id (IN): + * @param a3 (IN): + * @param a4 (IN): + * @param a5 (IN): + * @param a6 (IN): + */ +s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u64 a5, u64 a6) { - sys_rsx.Todo("sys_rsx_context_attribute(context_id=%d, a2=%llu, a3=%llu, a4=%llu, a5=%llu, a6=%llu)", context_id, a2, a3, a4, a5, a6); + sys_rsx.Todo("sys_rsx_context_attribute(context_id=0x%x, package_id=0x%x, a3=%llu, a4=%llu, a5=%llu, a6=%llu)", + context_id, package_id, a3, a4, a5, a6); + + switch(package_id) + { + case 0x001: // ? + break; + + case 0x101: // ? + break; + + case 0x104: // Display buffer + break; + + case 0x10a: // ? + break; + + case 0x300: // Tiles + break; + + case 0x301: // Depth-buffer (Z-cull) + break; + + default: + + } return CELL_OK; } -s32 sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 a3) +/* + * lv2 SysCall 675 (0x2A3): sys_rsx_device_map + * @param a1 (OUT): For example: In vsh.self it is 0x60000000, global semaphore. For a game it is 0x40000000. + * @param a2 (OUT): Unused? + * @param dev_id (IN): An immediate value and always 8. + */ +s32 sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 dev_id) { - sys_rsx.Todo("sys_rsx_device_map(a1_addr=0x%x, a2_addr=0x%x, a3=%d)", a1.GetAddr(), a2.GetAddr(), a3); + sys_rsx.Todo("sys_rsx_device_map(a1_addr=0x%x, a2_addr=0x%x, a3=%d)", a1.GetAddr(), a2.GetAddr(), dev_id); + + if (dev_id > 15) { + // TODO: Throw RSX error + return CELL_EINVAL; + } + + if (dev_id == 0 || dev_id > 8) { + // TODO: lv1 related so we may ignore it. + // if (something) { return CELL_EPERM; } + } + return CELL_OK; } -s32 sys_rsx_device_unmap() +/* + * lv2 SysCall 676 (0x2A4): sys_rsx_device_unmap + * @param dev_id (IN): An immediate value and always 8. + */ +s32 sys_rsx_device_unmap(u32 dev_id) { - sys_rsx.Todo("sys_rsx_device_unmap()"); + sys_rsx.Todo("sys_rsx_device_unmap(a1=%d)", dev_id); return CELL_OK; }