srv.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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(false);
  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 == NULL, 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. DEBUG_LOG(OSHLE, "called port=%s, handle=0x%08X", port_name.c_str(),
  31. service->GetHandle());
  32. if (NULL != service) {
  33. cmd_buff[3] = service->GetHandle();
  34. } else {
  35. ERROR_LOG(OSHLE, "Service %s does not exist", port_name.c_str());
  36. res = -1;
  37. }
  38. cmd_buff[1] = res;
  39. //return res;
  40. }
  41. const Interface::FunctionInfo FunctionTable[] = {
  42. {0x00010002, Initialize, "Initialize"},
  43. {0x00020000, GetProcSemaphore, "GetProcSemaphore"},
  44. {0x00030100, NULL, "RegisterService"},
  45. {0x000400C0, NULL, "UnregisterService"},
  46. {0x00050100, GetServiceHandle, "GetServiceHandle"},
  47. };
  48. ////////////////////////////////////////////////////////////////////////////////////////////////////
  49. // Interface class
  50. Interface::Interface() {
  51. Register(FunctionTable, ARRAY_SIZE(FunctionTable));
  52. }
  53. Interface::~Interface() {
  54. }
  55. } // namespace