From cd0664eb77e14a801fe1f15be50c3a90b98ee5ef Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 24 Apr 2014 22:16:54 -0400 Subject: - refactored how service functions are called - added option to create/delete service handles --- src/core/hle/service/apt.cpp | 6 +++--- src/core/hle/service/apt.h | 4 ---- src/core/hle/service/hid.cpp | 2 +- src/core/hle/service/service.h | 40 ++++++++++++++++++++++++++++++++-------- src/core/hle/service/srv.cpp | 6 +++--- 5 files changed, 39 insertions(+), 19 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/apt.cpp b/src/core/hle/service/apt.cpp index 4f8d7248d..4a1e8c992 100644 --- a/src/core/hle/service/apt.cpp +++ b/src/core/hle/service/apt.cpp @@ -13,16 +13,16 @@ namespace APT_U { -void Initialize() { +void Initialize(Service::Interface* self) { NOTICE_LOG(OSHLE, "APT_U::Sync - Initialize"); } -void GetLockHandle() { +void GetLockHandle(Service::Interface* self) { u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); cmd_buff[5] = 0x00000000; // TODO: This should be an actual mutex handle } -const HLE::FunctionDef FunctionTable[] = { +const Interface::FunctionInfo FunctionTable[] = { {0x00010040, GetLockHandle, "GetLockHandle"}, {0x00020080, Initialize, "Initialize"}, {0x00030040, NULL, "Enable"}, diff --git a/src/core/hle/service/apt.h b/src/core/hle/service/apt.h index e74baac0c..4c7dd07e7 100644 --- a/src/core/hle/service/apt.h +++ b/src/core/hle/service/apt.h @@ -32,10 +32,6 @@ public: std::string GetPortName() const { return "APT:U"; } - -private: - - DISALLOW_COPY_AND_ASSIGN(Interface); }; } // namespace diff --git a/src/core/hle/service/hid.cpp b/src/core/hle/service/hid.cpp index 2d823dd16..5542e5bf2 100644 --- a/src/core/hle/service/hid.cpp +++ b/src/core/hle/service/hid.cpp @@ -12,7 +12,7 @@ namespace HID_User { -const HLE::FunctionDef FunctionTable[] = { +const Interface::FunctionInfo FunctionTable[] = { {0x000A0000, NULL, "GetIPCHandles"}, {0x00110000, NULL, "EnableAccelerometer"}, {0x00130000, NULL, "EnableGyroscopeLow"}, diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 9cbf8b6fa..9de17beab 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -25,7 +25,7 @@ static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer class Manager; /// Interface to a CTROS service -class Interface { +class Interface : NonCopyable { friend class Manager; public: @@ -35,6 +35,14 @@ public: virtual ~Interface() { } + typedef void (*Function)(Interface*); + + struct FunctionInfo { + u32 id; + Function func; + std::string name; + }; + /** * Gets the UID for the serice * @return UID of service in native format @@ -51,6 +59,23 @@ public: return "[UNKNOWN SERVICE PORT]"; } + /// Allocates a new handle for the service + Syscall::Handle NewHandle() { + Syscall::Handle handle = (m_handles.size() << 16) | m_uid; + m_handles.push_back(handle); + return handle; + } + + /// Frees a handle from the service + void DeleteHandle(Syscall::Handle handle) { + for(auto iter = m_handles.begin(); iter != m_handles.end(); ++iter) { + if(*iter == handle) { + m_handles.erase(iter); + break; + } + } + } + /** * Called when svcSendSyncRequest is called, loads command buffer and executes comand * @return Return result of svcSendSyncRequest passed back to user app @@ -70,16 +95,17 @@ public: return -1; } - itr->second.func(); + itr->second.func(this); return 0; // TODO: Implement return from actual function } protected: + /** * Registers the functions in the service */ - void Register(const HLE::FunctionDef* functions, int len) { + void Register(const FunctionInfo* functions, int len) { for (int i = 0; i < len; i++) { m_functions[functions[i].id] = functions[i]; } @@ -87,9 +113,9 @@ protected: private: u32 m_uid; - std::map m_functions; - - DISALLOW_COPY_AND_ASSIGN(Interface); + + std::vector m_handles; + std::map m_functions; }; /// Simple class to manage accessing services from ports and UID handles @@ -126,8 +152,6 @@ private: std::vector m_services; std::map m_port_map; - - DISALLOW_COPY_AND_ASSIGN(Manager); }; /// Initialize ServiceManager diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp index 579ea4a34..9437868c5 100644 --- a/src/core/hle/service/srv.cpp +++ b/src/core/hle/service/srv.cpp @@ -12,11 +12,11 @@ namespace SRV { -void Initialize() { +void Initialize(Service::Interface* self) { NOTICE_LOG(OSHLE, "SRV::Sync - Initialize"); } -void GetServiceHandle() { +void GetServiceHandle(Service::Interface* self) { Syscall::Result res = 0; u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); @@ -37,7 +37,7 @@ void GetServiceHandle() { //return res; } -const HLE::FunctionDef FunctionTable[] = { +const Interface::FunctionInfo FunctionTable[] = { {0x00010002, Initialize, "Initialize"}, {0x00020000, NULL, "GetProcSemaphore"}, {0x00030100, NULL, "RegisterService"}, -- cgit v1.2.3 From 66e1f8ab330aca275db686290d9ece5100821c6c Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 24 Apr 2014 22:20:13 -0400 Subject: added GSP::RegisterInterruptRelayQueue function --- src/core/hle/service/gsp.cpp | 71 +++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 31 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp index 7c80ab8b5..df23ac542 100644 --- a/src/core/hle/service/gsp.cpp +++ b/src/core/hle/service/gsp.cpp @@ -13,37 +13,46 @@ namespace GSP_GPU { -const HLE::FunctionDef FunctionTable[] = { - {0x00010082, NULL, "WriteHWRegs"}, - {0x00020084, NULL, "WriteHWRegsWithMask"}, - {0x00030082, NULL, "WriteHWRegRepeat"}, - {0x00040080, NULL, "ReadHWRegs"}, - {0x00050200, NULL, "SetBufferSwap"}, - {0x00060082, NULL, "SetCommandList"}, - {0x000700C2, NULL, "RequestDma"}, - {0x00080082, NULL, "FlushDataCache"}, - {0x00090082, NULL, "InvalidateDataCache"}, - {0x000A0044, NULL, "RegisterInterruptEvents"}, - {0x000B0040, NULL, "SetLcdForceBlack"}, - {0x000C0000, NULL, "TriggerCmdReqQueue"}, - {0x000D0140, NULL, "SetDisplayTransfer"}, - {0x000E0180, NULL, "SetTextureCopy"}, - {0x000F0200, NULL, "SetMemoryFill"}, - {0x00100040, NULL, "SetAxiConfigQoSMode"}, - {0x00110040, NULL, "SetPerfLogMode"}, - {0x00120000, NULL, "GetPerfLog"}, - {0x00130042, NULL, "RegisterInterruptRelayQueue"}, - {0x00140000, NULL, "UnregisterInterruptRelayQueue"}, - {0x00150002, NULL, "TryAcquireRight"}, - {0x00160042, NULL, "AcquireRight"}, - {0x00170000, NULL, "ReleaseRight"}, - {0x00180000, NULL, "ImportDisplayCaptureInfo"}, - {0x00190000, NULL, "SaveVramSysArea"}, - {0x001A0000, NULL, "RestoreVramSysArea"}, - {0x001B0000, NULL, "ResetGpuCore"}, - {0x001C0040, NULL, "SetLedForceOff"}, - {0x001D0040, NULL, "SetTestCommand"}, - {0x001E0080, NULL, "SetInternalPriorities"}, +void RegisterInterruptRelayQueue(Service::Interface* self) { + u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); + u32 flags = cmd_buff[1]; + u32 event_handle = cmd_buff[3]; // TODO(bunnei): Implement event handling + cmd_buff[4] = self->NewHandle(); + + return; +} + +const Interface::FunctionInfo FunctionTable[] = { + {0x00010082, NULL, "WriteHWRegs"}, + {0x00020084, NULL, "WriteHWRegsWithMask"}, + {0x00030082, NULL, "WriteHWRegRepeat"}, + {0x00040080, NULL, "ReadHWRegs"}, + {0x00050200, NULL, "SetBufferSwap"}, + {0x00060082, NULL, "SetCommandList"}, + {0x000700C2, NULL, "RequestDma"}, + {0x00080082, NULL, "FlushDataCache"}, + {0x00090082, NULL, "InvalidateDataCache"}, + {0x000A0044, NULL, "RegisterInterruptEvents"}, + {0x000B0040, NULL, "SetLcdForceBlack"}, + {0x000C0000, NULL, "TriggerCmdReqQueue"}, + {0x000D0140, NULL, "SetDisplayTransfer"}, + {0x000E0180, NULL, "SetTextureCopy"}, + {0x000F0200, NULL, "SetMemoryFill"}, + {0x00100040, NULL, "SetAxiConfigQoSMode"}, + {0x00110040, NULL, "SetPerfLogMode"}, + {0x00120000, NULL, "GetPerfLog"}, + {0x00130042, RegisterInterruptRelayQueue, "RegisterInterruptRelayQueue"}, + {0x00140000, NULL, "UnregisterInterruptRelayQueue"}, + {0x00150002, NULL, "TryAcquireRight"}, + {0x00160042, NULL, "AcquireRight"}, + {0x00170000, NULL, "ReleaseRight"}, + {0x00180000, NULL, "ImportDisplayCaptureInfo"}, + {0x00190000, NULL, "SaveVramSysArea"}, + {0x001A0000, NULL, "RestoreVramSysArea"}, + {0x001B0000, NULL, "ResetGpuCore"}, + {0x001C0040, NULL, "SetLedForceOff"}, + {0x001D0040, NULL, "SetTestCommand"}, + {0x001E0080, NULL, "SetInternalPriorities"}, }; //////////////////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 9e047e32d4973cb01f96116027e80639aa9f4280 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 26 Apr 2014 01:48:24 -0400 Subject: added simple GSP GPU ReadHWRegs function to support returning the framebuffer address --- src/core/hle/service/gsp.cpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp index df23ac542..24e9f18dc 100644 --- a/src/core/hle/service/gsp.cpp +++ b/src/core/hle/service/gsp.cpp @@ -5,14 +5,50 @@ #include "common/log.h" +#include "core/mem_map.h" #include "core/hle/hle.h" #include "core/hle/service/gsp.h" +#include "core/hw/lcd.h" + //////////////////////////////////////////////////////////////////////////////////////////////////// // Namespace GSP_GPU namespace GSP_GPU { +enum { + REG_FRAMEBUFFER_1 = 0x00400468, + REG_FRAMEBUFFER_2 = 0x00400494, +}; + +/// Read a GSP GPU hardware register +void ReadHWRegs(Service::Interface* self) { + static const u32 framebuffer_1[] = {LCD::VRAM_TOP_LEFT_FRAME1, LCD::VRAM_TOP_RIGHT_FRAME1}; + static const u32 framebuffer_2[] = {LCD::VRAM_TOP_LEFT_FRAME2, LCD::VRAM_TOP_RIGHT_FRAME2}; + + u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); + u32 reg_addr = cmd_buff[1]; + u32 size = cmd_buff[2]; + u32* dst = (u32*)Memory::GetPointer(cmd_buff[0x41]); + + switch (reg_addr) { + + // Top framebuffer 1 addresses + case REG_FRAMEBUFFER_1: + memcpy(dst, framebuffer_1, size); + break; + + // Top framebuffer 2 addresses + case REG_FRAMEBUFFER_2: + memcpy(dst, framebuffer_1, size); + break; + + default: + ERROR_LOG(OSHLE, "GSP_GPU::ReadHWRegs unknown register read at address %08X", reg_addr); + } + +} + void RegisterInterruptRelayQueue(Service::Interface* self) { u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); u32 flags = cmd_buff[1]; @@ -26,7 +62,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00010082, NULL, "WriteHWRegs"}, {0x00020084, NULL, "WriteHWRegsWithMask"}, {0x00030082, NULL, "WriteHWRegRepeat"}, - {0x00040080, NULL, "ReadHWRegs"}, + {0x00040080, ReadHWRegs, "ReadHWRegs"}, {0x00050200, NULL, "SetBufferSwap"}, {0x00060082, NULL, "SetCommandList"}, {0x000700C2, NULL, "RequestDma"}, -- cgit v1.2.3 From a6c925112a4e97feb21a8ae577f2993d0617cb1f Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 27 Apr 2014 12:41:25 -0400 Subject: hackish but working way to set the framebuffer location to VRAM (used in ARM11 demos tested thus far, e.g. yeti3DS) --- src/core/hle/service/gsp.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp index 24e9f18dc..88c1f1a0f 100644 --- a/src/core/hle/service/gsp.cpp +++ b/src/core/hle/service/gsp.cpp @@ -23,8 +23,8 @@ enum { /// Read a GSP GPU hardware register void ReadHWRegs(Service::Interface* self) { - static const u32 framebuffer_1[] = {LCD::VRAM_TOP_LEFT_FRAME1, LCD::VRAM_TOP_RIGHT_FRAME1}; - static const u32 framebuffer_2[] = {LCD::VRAM_TOP_LEFT_FRAME2, LCD::VRAM_TOP_RIGHT_FRAME2}; + static const u32 framebuffer_1[] = {LCD::PADDR_VRAM_TOP_LEFT_FRAME1, LCD::PADDR_VRAM_TOP_RIGHT_FRAME1}; + static const u32 framebuffer_2[] = {LCD::PADDR_VRAM_TOP_LEFT_FRAME2, LCD::PADDR_VRAM_TOP_RIGHT_FRAME2}; u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); u32 reg_addr = cmd_buff[1]; @@ -33,14 +33,20 @@ void ReadHWRegs(Service::Interface* self) { switch (reg_addr) { + // NOTE: Calling SetFramebufferLocation here is a hack... Not sure the correct way yet to set + // whether the framebuffers should be in VRAM or GSP heap, but from what I understand, if the + // user application is reading from either of these registers, then its going to be in VRAM. + // Top framebuffer 1 addresses case REG_FRAMEBUFFER_1: + LCD::SetFramebufferLocation(LCD::FRAMEBUFFER_LOCATION_VRAM); memcpy(dst, framebuffer_1, size); break; // Top framebuffer 2 addresses case REG_FRAMEBUFFER_2: - memcpy(dst, framebuffer_1, size); + LCD::SetFramebufferLocation(LCD::FRAMEBUFFER_LOCATION_VRAM); + memcpy(dst, framebuffer_2, size); break; default: -- cgit v1.2.3 From 451a14f98c4d881208c786a6a5aa621e2647aed5 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 27 Apr 2014 18:24:54 -0400 Subject: fixed weird spacing --- src/core/hle/service/service.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 9de17beab..b79dc9458 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -115,7 +115,7 @@ private: u32 m_uid; std::vector m_handles; - std::map m_functions; + std::map m_functions; }; /// Simple class to manage accessing services from ports and UID handles -- cgit v1.2.3 From a48c6b947d5314ab804f375cca22af159cc3b77b Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 27 Apr 2014 18:29:51 -0400 Subject: removed DISALLOW_COPY_AND_ASSIGN in favor of NonCopyable class --- src/common/common.h | 5 ----- src/core/arm/arm_interface.h | 3 +-- src/core/arm/interpreter/arm_interpreter.h | 1 - src/core/hle/service/gsp.h | 3 --- src/core/hle/service/hid.h | 3 --- src/core/hle/service/srv.h | 3 --- src/video_core/renderer_base.h | 4 +--- src/video_core/renderer_opengl/renderer_opengl.h | 1 - 8 files changed, 2 insertions(+), 21 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/common/common.h b/src/common/common.h index a281b21cc..418757855 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -159,9 +159,4 @@ enum EMUSTATE_CHANGE EMUSTATE_CHANGE_STOP }; -// This should be used in the private: declarations for a class -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&); \ - void operator=(const TypeName&) - #endif // _COMMON_H_ diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index eee4726db..4dfe0570b 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h @@ -8,7 +8,7 @@ #include "common/common_types.h" /// Generic ARM11 CPU interface -class ARM_Interface { +class ARM_Interface : NonCopyable { public: ARM_Interface() { m_num_instructions = 0; @@ -75,5 +75,4 @@ private: u64 m_num_instructions; ///< Number of instructions executed - DISALLOW_COPY_AND_ASSIGN(ARM_Interface); }; diff --git a/src/core/arm/interpreter/arm_interpreter.h b/src/core/arm/interpreter/arm_interpreter.h index f3c86f8dd..625c0c652 100644 --- a/src/core/arm/interpreter/arm_interpreter.h +++ b/src/core/arm/interpreter/arm_interpreter.h @@ -63,5 +63,4 @@ private: ARMul_State* m_state; - DISALLOW_COPY_AND_ASSIGN(ARM_Interpreter); }; diff --git a/src/core/hle/service/gsp.h b/src/core/hle/service/gsp.h index 3b1846082..5ba09ab70 100644 --- a/src/core/hle/service/gsp.h +++ b/src/core/hle/service/gsp.h @@ -27,9 +27,6 @@ public: return "gsp::Gpu"; } -private: - - DISALLOW_COPY_AND_ASSIGN(Interface); }; } // namespace diff --git a/src/core/hle/service/hid.h b/src/core/hle/service/hid.h index 746c1b1fc..b17fcfa86 100644 --- a/src/core/hle/service/hid.h +++ b/src/core/hle/service/hid.h @@ -29,9 +29,6 @@ public: return "hid:USER"; } -private: - - DISALLOW_COPY_AND_ASSIGN(Interface); }; } // namespace diff --git a/src/core/hle/service/srv.h b/src/core/hle/service/srv.h index d9ac8fc88..760c976b4 100644 --- a/src/core/hle/service/srv.h +++ b/src/core/hle/service/srv.h @@ -32,9 +32,6 @@ public: */ Syscall::Result Sync(); -private: - - DISALLOW_COPY_AND_ASSIGN(Interface); }; } // namespace diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h index bc65bf0ce..2650620b4 100644 --- a/src/video_core/renderer_base.h +++ b/src/video_core/renderer_base.h @@ -6,7 +6,7 @@ #include "common/common.h" -class RendererBase { +class RendererBase : NonCopyable { public: /// Used to reference a framebuffer @@ -52,6 +52,4 @@ protected: f32 m_current_fps; ///< Current framerate, should be set by the renderer int m_current_frame; ///< Current frame, should be set by the renderer -private: - DISALLOW_COPY_AND_ASSIGN(RendererBase); }; diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index 676a0ea02..4c0b6e59d 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h @@ -87,5 +87,4 @@ private: u8 m_xfb_top_flipped[VideoCore::kScreenTopWidth * VideoCore::kScreenTopWidth * 4]; u8 m_xfb_bottom_flipped[VideoCore::kScreenTopWidth * VideoCore::kScreenTopWidth * 4]; - DISALLOW_COPY_AND_ASSIGN(RendererOpenGL); }; \ No newline at end of file -- cgit v1.2.3