srv.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. };
  46. ////////////////////////////////////////////////////////////////////////////////////////////////////
  47. // Interface class
  48. Interface::Interface() {
  49. Register(FunctionTable, ARRAY_SIZE(FunctionTable));
  50. }
  51. Interface::~Interface() {
  52. }
  53. } // namespace