interface.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/service/apm/apm.h"
  7. #include "core/hle/service/apm/interface.h"
  8. namespace Service::APM {
  9. class ISession final : public ServiceFramework<ISession> {
  10. public:
  11. ISession() : ServiceFramework("ISession") {
  12. static const FunctionInfo functions[] = {
  13. {0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"},
  14. {1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"},
  15. };
  16. RegisterHandlers(functions);
  17. }
  18. private:
  19. void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
  20. IPC::RequestParser rp{ctx};
  21. auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
  22. u32 config = rp.Pop<u32>();
  23. IPC::ResponseBuilder rb{ctx, 2};
  24. rb.Push(RESULT_SUCCESS);
  25. LOG_WARNING(Service_APM, "(STUBBED) called mode=%u config=%u", static_cast<u32>(mode),
  26. config);
  27. }
  28. void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
  29. IPC::RequestParser rp{ctx};
  30. auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
  31. IPC::ResponseBuilder rb{ctx, 3};
  32. rb.Push(RESULT_SUCCESS);
  33. rb.Push<u32>(0); // Performance configuration
  34. LOG_WARNING(Service_APM, "(STUBBED) called mode=%u", static_cast<u32>(mode));
  35. }
  36. };
  37. APM::APM(std::shared_ptr<Module> apm, const char* name)
  38. : ServiceFramework(name), apm(std::move(apm)) {
  39. static const FunctionInfo functions[] = {
  40. {0, &APM::OpenSession, "OpenSession"},
  41. {1, nullptr, "GetPerformanceMode"},
  42. };
  43. RegisterHandlers(functions);
  44. }
  45. void APM::OpenSession(Kernel::HLERequestContext& ctx) {
  46. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  47. rb.Push(RESULT_SUCCESS);
  48. rb.PushIpcInterface<ISession>();
  49. }
  50. } // namespace Service::APM