srv.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/kernel/event.h"
  7. ////////////////////////////////////////////////////////////////////////////////////////////////////
  8. // Namespace SRV
  9. namespace SRV {
  10. Handle g_event_handle = 0;
  11. void Initialize(Service::Interface* self) {
  12. DEBUG_LOG(OSHLE, "called");
  13. u32* cmd_buff = Service::GetCommandBuffer();
  14. cmd_buff[1] = 0; // No error
  15. }
  16. void GetProcSemaphore(Service::Interface* self) {
  17. DEBUG_LOG(OSHLE, "called");
  18. u32* cmd_buff = Service::GetCommandBuffer();
  19. // TODO(bunnei): Change to a semaphore once these have been implemented
  20. g_event_handle = Kernel::CreateEvent(RESETTYPE_ONESHOT, "SRV:Event");
  21. Kernel::SetEventLocked(g_event_handle, false);
  22. cmd_buff[1] = 0; // No error
  23. cmd_buff[3] = g_event_handle;
  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. {0x000B0000, nullptr, "ReceiveNotification"},
  46. {0x000C0080, nullptr, "PublishToSubscriber"}
  47. };
  48. ////////////////////////////////////////////////////////////////////////////////////////////////////
  49. // Interface class
  50. Interface::Interface() {
  51. Register(FunctionTable, ARRAY_SIZE(FunctionTable));
  52. }
  53. Interface::~Interface() {
  54. }
  55. } // namespace