controller.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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/assert.h"
  5. #include "common/logging/log.h"
  6. #include "core/hle/ipc_helpers.h"
  7. #include "core/hle/kernel/client_session.h"
  8. #include "core/hle/kernel/server_session.h"
  9. #include "core/hle/kernel/session.h"
  10. #include "core/hle/service/sm/controller.h"
  11. namespace Service::SM {
  12. void Controller::ConvertSessionToDomain(Kernel::HLERequestContext& ctx) {
  13. ASSERT_MSG(ctx.Session()->IsSession(), "Session is already a domain");
  14. LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetObjectId());
  15. ctx.Session()->ConvertToDomain();
  16. IPC::ResponseBuilder rb{ctx, 3};
  17. rb.Push(RESULT_SUCCESS);
  18. rb.Push<u32>(1); // Converted sessions start with 1 request handler
  19. }
  20. void Controller::DuplicateSession(Kernel::HLERequestContext& ctx) {
  21. // TODO(bunnei): This is just creating a new handle to the same Session. I assume this is wrong
  22. // and that we probably want to actually make an entirely new Session, but we still need to
  23. // verify this on hardware.
  24. LOG_DEBUG(Service, "called");
  25. IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
  26. rb.Push(RESULT_SUCCESS);
  27. rb.PushMoveObjects(ctx.Session()->GetParent()->Client());
  28. }
  29. void Controller::DuplicateSessionEx(Kernel::HLERequestContext& ctx) {
  30. LOG_WARNING(Service, "(STUBBED) called, using DuplicateSession");
  31. DuplicateSession(ctx);
  32. }
  33. void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) {
  34. LOG_WARNING(Service, "(STUBBED) called");
  35. IPC::ResponseBuilder rb{ctx, 3};
  36. rb.Push(RESULT_SUCCESS);
  37. rb.Push<u16>(0x1000);
  38. }
  39. Controller::Controller() : ServiceFramework("IpcController") {
  40. static const FunctionInfo functions[] = {
  41. {0x00000000, &Controller::ConvertSessionToDomain, "ConvertSessionToDomain"},
  42. {0x00000001, nullptr, "ConvertDomainToSession"},
  43. {0x00000002, &Controller::DuplicateSession, "DuplicateSession"},
  44. {0x00000003, &Controller::QueryPointerBufferSize, "QueryPointerBufferSize"},
  45. {0x00000004, &Controller::DuplicateSessionEx, "DuplicateSessionEx"},
  46. };
  47. RegisterHandlers(functions);
  48. }
  49. Controller::~Controller() = default;
  50. } // namespace Service::SM