From 32c3462047d814eada8f3b80ee5ea2cd03936ae0 Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 16 Apr 2014 00:03:41 -0400 Subject: [PATCH] - added stubbed out GSP::Gpu service interface - various cleanups/refactors to HLE services --- src/core/core.vcxproj | 2 ++ src/core/core.vcxproj.filters | 6 ++++ src/core/hle/service/apt.h | 2 +- src/core/hle/service/gsp.cpp | 56 ++++++++++++++++++++++++++++++++ src/core/hle/service/gsp.h | 34 +++++++++++++++++++ src/core/hle/service/service.cpp | 4 +++ src/core/hle/service/service.h | 10 +++--- src/core/hle/service/srv.cpp | 2 +- src/core/hle/service/srv.h | 2 +- 9 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 src/core/hle/service/gsp.cpp create mode 100644 src/core/hle/service/gsp.h diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index da3cc7a266..931345441f 100644 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj @@ -154,6 +154,7 @@ + @@ -190,6 +191,7 @@ + diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index fa20ab6867..e022785ad0 100644 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters @@ -96,6 +96,9 @@ hle\service + + hle\service + @@ -187,6 +190,9 @@ hle\service + + hle\service + diff --git a/src/core/hle/service/apt.h b/src/core/hle/service/apt.h index 889b127119..9345eabc3e 100644 --- a/src/core/hle/service/apt.h +++ b/src/core/hle/service/apt.h @@ -25,7 +25,7 @@ public: ~Interface(); /** - * Gets the string port name used by CTROS for the APT service + * Gets the string port name used by CTROS for the service * @return Port name of service */ std::string GetPortName() const { diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp new file mode 100644 index 0000000000..6dfd76de3e --- /dev/null +++ b/src/core/hle/service/gsp.cpp @@ -0,0 +1,56 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + + +#include "common/log.h" + +#include "core/hle/hle.h" +#include "core/hle/service/gsp.h" + +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"}, +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Interface class + +Interface::Interface() { + Register(FunctionTable, ARRAY_SIZE(FunctionTable)); +} + +Interface::~Interface() { +} + +} // namespace diff --git a/src/core/hle/service/gsp.h b/src/core/hle/service/gsp.h new file mode 100644 index 0000000000..0a9d452f62 --- /dev/null +++ b/src/core/hle/service/gsp.h @@ -0,0 +1,34 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#pragma once + +#include "core/hle/service/service.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Namespace Service + +namespace GSP_GPU { + +class Interface : public Service::Interface { +public: + + Interface(); + + ~Interface(); + + /** + * Gets the string port name used by CTROS for the service + * @return Port name of service + */ + std::string GetPortName() const { + return "gsp::Gpu"; + } + +private: + + DISALLOW_COPY_AND_ASSIGN(Interface); +}; + +} // namespace diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 81a34ed061..f612ff8300 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -9,6 +9,7 @@ #include "core/hle/hle.h" #include "core/hle/service/service.h" #include "core/hle/service/apt.h" +#include "core/hle/service/gsp.h" #include "core/hle/service/srv.h" namespace Service { @@ -73,8 +74,11 @@ Interface* Manager::FetchFromPortName(std::string port_name) { /// Initialize ServiceManager void Init() { g_manager = new Manager; + g_manager->AddService(new SRV::Interface); g_manager->AddService(new APT_U::Interface); + g_manager->AddService(new GSP_GPU::Interface); + NOTICE_LOG(HLE, "Services initialized OK"); } diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 3b256aa3e8..9cbf8b6fa9 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -19,7 +19,8 @@ namespace Service { typedef s32 NativeUID; ///< Native handle for a service -static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer of header +static const int kMaxPortSize = 0x08; ///< Maximum size of a port name (8 characters) +static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer of header class Manager; @@ -59,14 +60,15 @@ public: auto itr = m_functions.find(cmd_buff[0]); if (itr == m_functions.end()) { - ERROR_LOG(OSHLE, "Unknown/unimplemented function: port=%s, command=0x%08X!", + ERROR_LOG(OSHLE, "Unknown/unimplemented function: port = %s, command = 0x%08X!", GetPortName().c_str(), cmd_buff[0]); return -1; } if (itr->second.func == NULL) { - ERROR_LOG(OSHLE, "Unimplemented function: port=%s, name=%s!", + ERROR_LOG(OSHLE, "Unimplemented function: port = %s, name = %s!", GetPortName().c_str(), itr->second.name.c_str()); - } + return -1; + } itr->second.func(); diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp index bb6c08b78f..ad74484617 100644 --- a/src/core/hle/service/srv.cpp +++ b/src/core/hle/service/srv.cpp @@ -17,7 +17,7 @@ void GetServiceHandle() { Syscall::Result res = 0; u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); - const char* port_name = (const char*)&cmd_buff[1]; + std::string port_name = std::string((const char*)&cmd_buff[1], 0, Service::kMaxPortSize); Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); NOTICE_LOG(OSHLE, "SRV::Sync - GetHandle - port: %s, handle: 0x%08X", port_name, diff --git a/src/core/hle/service/srv.h b/src/core/hle/service/srv.h index b4c5a0c171..a1d26a34d8 100644 --- a/src/core/hle/service/srv.h +++ b/src/core/hle/service/srv.h @@ -18,7 +18,7 @@ public: ~Interface(); /** - * Gets the string name used by CTROS for a service + * Gets the string name used by CTROS for the service * @return Port name of service */ std::string GetPortName() const {