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