diff options
| author | 2016-07-04 08:52:42 -0700 | |
|---|---|---|
| committer | 2016-07-04 08:52:42 -0700 | |
| commit | 51f4a9fd3285d746542a13006c3bc960ffec9b8d (patch) | |
| tree | fd62863b09208c511da9891cc419d31db5578c3d /src | |
| parent | Merge pull request #1935 from wwylele/fix-result-module (diff) | |
| parent | HLE/Applets: Implement ErrEula applet (diff) | |
| download | yuzu-51f4a9fd3285d746542a13006c3bc960ffec9b8d.tar.gz yuzu-51f4a9fd3285d746542a13006c3bc960ffec9b8d.tar.xz yuzu-51f4a9fd3285d746542a13006c3bc960ffec9b8d.zip | |
Merge pull request #1850 from mailwl/erreula
HLE/Applets: Implement ErrEula applet
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/applets/applet.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/applets/erreula.cpp | 72 | ||||
| -rw-r--r-- | src/core/hle/applets/erreula.h | 31 | ||||
| -rw-r--r-- | src/core/hle/service/apt/apt.h | 8 |
5 files changed, 118 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 02d902bb5..0773339a9 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -27,6 +27,7 @@ set(SRCS | |||
| 27 | hle/config_mem.cpp | 27 | hle/config_mem.cpp |
| 28 | hle/hle.cpp | 28 | hle/hle.cpp |
| 29 | hle/applets/applet.cpp | 29 | hle/applets/applet.cpp |
| 30 | hle/applets/erreula.cpp | ||
| 30 | hle/applets/mii_selector.cpp | 31 | hle/applets/mii_selector.cpp |
| 31 | hle/applets/swkbd.cpp | 32 | hle/applets/swkbd.cpp |
| 32 | hle/kernel/address_arbiter.cpp | 33 | hle/kernel/address_arbiter.cpp |
| @@ -168,6 +169,7 @@ set(HEADERS | |||
| 168 | hle/function_wrappers.h | 169 | hle/function_wrappers.h |
| 169 | hle/hle.h | 170 | hle/hle.h |
| 170 | hle/applets/applet.h | 171 | hle/applets/applet.h |
| 172 | hle/applets/erreula.h | ||
| 171 | hle/applets/mii_selector.h | 173 | hle/applets/mii_selector.h |
| 172 | hle/applets/swkbd.h | 174 | hle/applets/swkbd.h |
| 173 | hle/kernel/address_arbiter.h | 175 | hle/kernel/address_arbiter.h |
diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp index 90e134437..ccf35fa07 100644 --- a/src/core/hle/applets/applet.cpp +++ b/src/core/hle/applets/applet.cpp | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | #include "core/core_timing.h" | 13 | #include "core/core_timing.h" |
| 14 | #include "core/hle/applets/applet.h" | 14 | #include "core/hle/applets/applet.h" |
| 15 | #include "core/hle/applets/erreula.h" | ||
| 15 | #include "core/hle/applets/mii_selector.h" | 16 | #include "core/hle/applets/mii_selector.h" |
| 16 | #include "core/hle/applets/swkbd.h" | 17 | #include "core/hle/applets/swkbd.h" |
| 17 | #include "core/hle/result.h" | 18 | #include "core/hle/result.h" |
| @@ -52,6 +53,10 @@ ResultCode Applet::Create(Service::APT::AppletId id) { | |||
| 52 | case Service::APT::AppletId::Ed2: | 53 | case Service::APT::AppletId::Ed2: |
| 53 | applets[id] = std::make_shared<MiiSelector>(id); | 54 | applets[id] = std::make_shared<MiiSelector>(id); |
| 54 | break; | 55 | break; |
| 56 | case Service::APT::AppletId::Error: | ||
| 57 | case Service::APT::AppletId::Error2: | ||
| 58 | applets[id] = std::make_shared<ErrEula>(id); | ||
| 59 | break; | ||
| 55 | default: | 60 | default: |
| 56 | LOG_ERROR(Service_APT, "Could not create applet %u", id); | 61 | LOG_ERROR(Service_APT, "Could not create applet %u", id); |
| 57 | // TODO(Subv): Find the right error code | 62 | // TODO(Subv): Find the right error code |
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 | |||
| 10 | namespace HLE { | ||
| 11 | namespace Applets { | ||
| 12 | |||
| 13 | ResultCode 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 | |||
| 49 | ResultCode 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 | |||
| 68 | void ErrEula::Update() { | ||
| 69 | } | ||
| 70 | |||
| 71 | } // namespace Applets | ||
| 72 | } // namespace HLE | ||
diff --git a/src/core/hle/applets/erreula.h b/src/core/hle/applets/erreula.h new file mode 100644 index 000000000..9fe72ae07 --- /dev/null +++ b/src/core/hle/applets/erreula.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/applets/applet.h" | ||
| 8 | #include "core/hle/kernel/shared_memory.h" | ||
| 9 | |||
| 10 | namespace HLE { | ||
| 11 | namespace Applets { | ||
| 12 | |||
| 13 | class ErrEula final : public Applet { | ||
| 14 | public: | ||
| 15 | explicit ErrEula(Service::APT::AppletId id): Applet(id) { } | ||
| 16 | |||
| 17 | ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override; | ||
| 18 | ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override; | ||
| 19 | void Update() override; | ||
| 20 | bool IsRunning() const override { return started; } | ||
| 21 | |||
| 22 | /// This SharedMemory will be created when we receive the LibAppJustStarted message. | ||
| 23 | /// It holds the framebuffer info retrieved by the application with GSPGPU::ImportDisplayCaptureInfo | ||
| 24 | Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory; | ||
| 25 | private: | ||
| 26 | /// Whether this applet is currently running instead of the host application or not. | ||
| 27 | bool started = false; | ||
| 28 | }; | ||
| 29 | |||
| 30 | } // namespace Applets | ||
| 31 | } // namespace HLE | ||
diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h index 76b3a3807..53cee4867 100644 --- a/src/core/hle/service/apt/apt.h +++ b/src/core/hle/service/apt/apt.h | |||
| @@ -66,6 +66,8 @@ enum class AppletId : u32 { | |||
| 66 | InstructionManual = 0x115, | 66 | InstructionManual = 0x115, |
| 67 | Notifications = 0x116, | 67 | Notifications = 0x116, |
| 68 | Miiverse = 0x117, | 68 | Miiverse = 0x117, |
| 69 | MiiversePost = 0x118, | ||
| 70 | AmiiboSettings = 0x119, | ||
| 69 | SoftwareKeyboard1 = 0x201, | 71 | SoftwareKeyboard1 = 0x201, |
| 70 | Ed1 = 0x202, | 72 | Ed1 = 0x202, |
| 71 | PnoteApp = 0x204, | 73 | PnoteApp = 0x204, |
| @@ -78,6 +80,12 @@ enum class AppletId : u32 { | |||
| 78 | AnyLibraryApplet = 0x400, | 80 | AnyLibraryApplet = 0x400, |
| 79 | SoftwareKeyboard2 = 0x401, | 81 | SoftwareKeyboard2 = 0x401, |
| 80 | Ed2 = 0x402, | 82 | Ed2 = 0x402, |
| 83 | PnoteApp2 = 0x404, | ||
| 84 | SnoteApp2 = 0x405, | ||
| 85 | Error2 = 0x406, | ||
| 86 | Mint2 = 0x407, | ||
| 87 | Extrapad2 = 0x408, | ||
| 88 | Memolib2 = 0x409, | ||
| 81 | }; | 89 | }; |
| 82 | 90 | ||
| 83 | enum class StartupArgumentType : u32 { | 91 | enum class StartupArgumentType : u32 { |