controller.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/logging/log.h"
  5. #include "core/hle/ipc_helpers.h"
  6. #include "core/hle/kernel/session.h"
  7. #include "core/hle/service/sm/controller.h"
  8. namespace Service::SM {
  9. void Controller::ConvertSessionToDomain(Kernel::HLERequestContext& ctx) {
  10. ASSERT_MSG(!ctx.Session()->IsDomain(), "session is alread a domain");
  11. ctx.Session()->ConvertToDomain();
  12. IPC::ResponseBuilder rb{ctx, 3};
  13. rb.Push(RESULT_SUCCESS);
  14. rb.Push<u32>(1); // Converted sessions start with 1 request handler
  15. NGLOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetObjectId());
  16. }
  17. void Controller::DuplicateSession(Kernel::HLERequestContext& ctx) {
  18. // TODO(bunnei): This is just creating a new handle to the same Session. I assume this is wrong
  19. // and that we probably want to actually make an entirely new Session, but we still need to
  20. // verify this on hardware.
  21. IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
  22. rb.Push(RESULT_SUCCESS);
  23. Kernel::SharedPtr<Kernel::ClientSession> session{ctx.Session()->parent->client};
  24. rb.PushMoveObjects(session);
  25. NGLOG_DEBUG(Service, "called, session={}", session->GetObjectId());
  26. }
  27. void Controller::DuplicateSessionEx(Kernel::HLERequestContext& ctx) {
  28. NGLOG_WARNING(Service, "(STUBBED) called, using DuplicateSession");
  29. DuplicateSession(ctx);
  30. }
  31. void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) {
  32. IPC::ResponseBuilder rb{ctx, 3};
  33. rb.Push(RESULT_SUCCESS);
  34. rb.Push<u32>(0x500);
  35. NGLOG_WARNING(Service, "(STUBBED) called");
  36. }
  37. Controller::Controller() : ServiceFramework("IpcController") {
  38. static const FunctionInfo functions[] = {
  39. {0x00000000, &Controller::ConvertSessionToDomain, "ConvertSessionToDomain"},
  40. {0x00000001, nullptr, "ConvertDomainToSession"},
  41. {0x00000002, &Controller::DuplicateSession, "DuplicateSession"},
  42. {0x00000003, &Controller::QueryPointerBufferSize, "QueryPointerBufferSize"},
  43. {0x00000004, &Controller::DuplicateSessionEx, "DuplicateSessionEx"},
  44. };
  45. RegisterHandlers(functions);
  46. }
  47. } // namespace Service::SM