erreula.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/string_util.h"
  5. #include "core/hle/applets/erreula.h"
  6. #include "core/hle/service/apt/apt.h"
  7. namespace HLE {
  8. namespace Applets {
  9. ResultCode ErrEula::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
  10. if (parameter.signal != static_cast<u32>(Service::APT::SignalType::Request)) {
  11. LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal);
  12. UNIMPLEMENTED();
  13. // TODO(Subv): Find the right error code
  14. return ResultCode(-1);
  15. }
  16. // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
  17. // memory.
  18. // Create the SharedMemory that will hold the framebuffer data
  19. Service::APT::CaptureBufferInfo capture_info;
  20. ASSERT(sizeof(capture_info) == parameter.buffer.size());
  21. memcpy(&capture_info, parameter.buffer.data(), sizeof(capture_info));
  22. // TODO: allocated memory never released
  23. using Kernel::MemoryPermission;
  24. // Allocate a heap block of the required size for this applet.
  25. heap_memory = std::make_shared<std::vector<u8>>(capture_info.size);
  26. // Create a SharedMemory that directly points to this heap block.
  27. framebuffer_memory = Kernel::SharedMemory::CreateForApplet(
  28. heap_memory, 0, heap_memory->size(), MemoryPermission::ReadWrite,
  29. MemoryPermission::ReadWrite, "ErrEula Memory");
  30. // Send the response message with the newly created SharedMemory
  31. Service::APT::MessageParameter result;
  32. result.signal = static_cast<u32>(Service::APT::SignalType::Response);
  33. result.buffer.clear();
  34. result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
  35. result.sender_id = static_cast<u32>(id);
  36. result.object = framebuffer_memory;
  37. Service::APT::SendParameter(result);
  38. return RESULT_SUCCESS;
  39. }
  40. ResultCode ErrEula::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
  41. is_running = true;
  42. // TODO(Subv): Set the expected fields in the response buffer before resending it to the
  43. // application.
  44. // TODO(Subv): Reverse the parameter format for the ErrEula applet
  45. // Let the application know that we're closing
  46. Service::APT::MessageParameter message;
  47. message.buffer.resize(parameter.buffer.size());
  48. std::fill(message.buffer.begin(), message.buffer.end(), 0);
  49. message.signal = static_cast<u32>(Service::APT::SignalType::WakeupByExit);
  50. message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
  51. message.sender_id = static_cast<u32>(id);
  52. Service::APT::SendParameter(message);
  53. is_running = false;
  54. return RESULT_SUCCESS;
  55. }
  56. void ErrEula::Update() {}
  57. } // namespace Applets
  58. } // namespace HLE