srv.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #include "core/hle/hle.h"
  5. #include "core/hle/service/srv.h"
  6. #include "core/hle/service/service.h"
  7. #include "core/hle/kernel/mutex.h"
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////
  9. // Namespace SRV
  10. namespace SRV {
  11. Handle g_mutex = 0;
  12. void Initialize(Service::Interface* self) {
  13. DEBUG_LOG(OSHLE, "called");
  14. if (!g_mutex) {
  15. g_mutex = Kernel::CreateMutex(true, "SRV:Lock");
  16. }
  17. }
  18. void GetProcSemaphore(Service::Interface* self) {
  19. DEBUG_LOG(OSHLE, "called");
  20. // Get process semaphore?
  21. u32* cmd_buff = Service::GetCommandBuffer();
  22. cmd_buff[1] = 0; // No error
  23. cmd_buff[3] = g_mutex; // Return something... 0 == nullptr, raises an exception
  24. }
  25. void GetServiceHandle(Service::Interface* self) {
  26. Result res = 0;
  27. u32* cmd_buff = Service::GetCommandBuffer();
  28. std::string port_name = std::string((const char*)&cmd_buff[1], 0, Service::kMaxPortSize);
  29. Service::Interface* service = Service::g_manager->FetchFromPortName(port_name);
  30. if (nullptr != service) {
  31. cmd_buff[3] = service->GetHandle();
  32. DEBUG_LOG(OSHLE, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]);
  33. } else {
  34. ERROR_LOG(OSHLE, "(UNIMPLEMENTED) called port=%s", port_name.c_str());
  35. res = -1;
  36. }
  37. cmd_buff[1] = res;
  38. }
  39. const Interface::FunctionInfo FunctionTable[] = {
  40. {0x00010002, Initialize, "Initialize"},
  41. {0x00020000, GetProcSemaphore, "GetProcSemaphore"},
  42. {0x00030100, nullptr, "RegisterService"},
  43. {0x000400C0, nullptr, "UnregisterService"},
  44. {0x00050100, GetServiceHandle, "GetServiceHandle"},
  45. };
  46. ////////////////////////////////////////////////////////////////////////////////////////////////////
  47. // Interface class
  48. Interface::Interface() {
  49. Register(FunctionTable, ARRAY_SIZE(FunctionTable));
  50. }
  51. Interface::~Interface() {
  52. }
  53. } // namespace