From 699900eed0fd25d0a60521e443d0d20e818c86d2 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Wed, 21 Nov 2018 21:20:02 -0500 Subject: applets: Add StubApplet This will log all data it receives, log all calls to its methods and push dummy data into both channels on execution. --- src/core/hle/service/am/applets/stub_applet.cpp | 65 +++++++++++++++++++++++++ src/core/hle/service/am/applets/stub_applet.h | 31 ++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 src/core/hle/service/am/applets/stub_applet.cpp create mode 100644 src/core/hle/service/am/applets/stub_applet.h (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/am/applets/stub_applet.cpp b/src/core/hle/service/am/applets/stub_applet.cpp new file mode 100644 index 000000000..c9bd3d973 --- /dev/null +++ b/src/core/hle/service/am/applets/stub_applet.cpp @@ -0,0 +1,65 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "common/hex_util.h" +#include "core/hle/service/am/applets/stub_applet.h" + +namespace Service::AM::Applets { + +static void LogCurrentStorage(AppletDataBroker& broker, std::string prefix) { + std::unique_ptr storage = broker.PopNormalDataToApplet(); + for (; storage != nullptr; storage = broker.PopNormalDataToApplet()) { + const auto data = storage->GetData(); + LOG_INFO(Service_AM, + "called (STUBBED), during {} recieved normal data with size={:08X}, data={}", + prefix, data.size(), Common::HexVectorToString(data)); + } + + storage = broker.PopInteractiveDataToApplet(); + for (; storage != nullptr; storage = broker.PopInteractiveDataToApplet()) { + const auto data = storage->GetData(); + LOG_INFO(Service_AM, + "called (STUBBED), during {} recieved interactive data with size={:08X}, data={}", + prefix, data.size(), Common::HexVectorToString(data)); + } +} + +StubApplet::StubApplet() = default; + +StubApplet::~StubApplet() = default; + +void StubApplet::Initialize() { + LOG_WARNING(Service_AM, "called (STUBBED)"); + Applet::Initialize(); + LogCurrentStorage(broker, "Initialize"); +} + +bool StubApplet::TransactionComplete() const { + LOG_WARNING(Service_AM, "called (STUBBED)"); + return true; +} + +ResultCode StubApplet::GetStatus() const { + LOG_WARNING(Service_AM, "called (STUBBED)"); + return RESULT_SUCCESS; +} + +void StubApplet::ExecuteInteractive() { + LOG_WARNING(Service_AM, "called (STUBBED)"); + LogCurrentStorage(broker, "ExecuteInteractive"); + + broker.PushNormalDataFromApplet(IStorage{std::vector(0x1000)}); + broker.PushInteractiveDataFromApplet(IStorage{std::vector(0x1000)}); + broker.SignalStateChanged(); +} + +void StubApplet::Execute() { + LOG_WARNING(Service_AM, "called (STUBBED)"); + LogCurrentStorage(broker, "Execute"); + + broker.PushNormalDataFromApplet(IStorage{std::vector(0x1000)}); + broker.PushInteractiveDataFromApplet(IStorage{std::vector(0x1000)}); + broker.SignalStateChanged(); +} +} // namespace Service::AM::Applets diff --git a/src/core/hle/service/am/applets/stub_applet.h b/src/core/hle/service/am/applets/stub_applet.h new file mode 100644 index 000000000..41add5fe6 --- /dev/null +++ b/src/core/hle/service/am/applets/stub_applet.h @@ -0,0 +1,31 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include + +#include "common/common_funcs.h" +#include "common/swap.h" +#include "core/hle/service/am/am.h" +#include "core/hle/service/am/applets/applets.h" + +namespace Service::AM::Applets { + +class StubApplet final : public Applet { +public: + StubApplet(); + ~StubApplet() override; + + void Initialize() override; + + bool TransactionComplete() const override; + ResultCode GetStatus() const override; + void ExecuteInteractive() override; + void Execute() override; +}; + +} // namespace Service::AM::Applets -- cgit v1.2.3 From f820e58be4532d7c845c828ba6ec609a5b277723 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Thu, 22 Nov 2018 15:58:00 -0500 Subject: am: Return StubApplet instead of nullptr when AppletId not found --- src/core/hle/service/am/am.cpp | 10 ++++++---- src/core/hle/service/am/applets/stub_applet.cpp | 5 +++++ src/core/hle/service/am/applets/stub_applet.h | 7 ------- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 11181a0af..f4127701f 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -6,8 +6,6 @@ #include #include #include -#include "applets/applets.h" -#include "applets/software_keyboard.h" #include "audio_core/audio_renderer.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" @@ -18,6 +16,9 @@ #include "core/hle/service/am/am.h" #include "core/hle/service/am/applet_ae.h" #include "core/hle/service/am/applet_oe.h" +#include "core/hle/service/am/applets/applets.h" +#include "core/hle/service/am/applets/software_keyboard.h" +#include "core/hle/service/am/applets/stub_applet.h" #include "core/hle/service/am/idle.h" #include "core/hle/service/am/omm.h" #include "core/hle/service/am/spsm.h" @@ -761,8 +762,9 @@ static std::shared_ptr GetAppletFromId(AppletId id) { case AppletId::SoftwareKeyboard: return std::make_shared(); default: - UNREACHABLE_MSG("Unimplemented AppletId [{:08X}]!", static_cast(id)); - return nullptr; + LOG_ERROR(Service_AM, "Unimplemented AppletId [{:08X}]! -- Falling back to stub!", + static_cast(id)); + return std::make_shared(); } } diff --git a/src/core/hle/service/am/applets/stub_applet.cpp b/src/core/hle/service/am/applets/stub_applet.cpp index c9bd3d973..ed166b87d 100644 --- a/src/core/hle/service/am/applets/stub_applet.cpp +++ b/src/core/hle/service/am/applets/stub_applet.cpp @@ -2,7 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include + #include "common/hex_util.h" +#include "common/logging/log.h" +#include "core/hle/result.h" +#include "core/hle/service/am/am.h" #include "core/hle/service/am/applets/stub_applet.h" namespace Service::AM::Applets { diff --git a/src/core/hle/service/am/applets/stub_applet.h b/src/core/hle/service/am/applets/stub_applet.h index 41add5fe6..7d8dc968d 100644 --- a/src/core/hle/service/am/applets/stub_applet.h +++ b/src/core/hle/service/am/applets/stub_applet.h @@ -4,13 +4,6 @@ #pragma once -#include -#include -#include - -#include "common/common_funcs.h" -#include "common/swap.h" -#include "core/hle/service/am/am.h" #include "core/hle/service/am/applets/applets.h" namespace Service::AM::Applets { -- cgit v1.2.3