diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp index ef4d1f2d6..4f97cf448 100644 --- a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp +++ b/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp @@ -69,7 +69,7 @@ namespace ams::sf::cmif { class ServerMessageProcessor { public: /* Used to enabled templated message processors. */ - virtual void SetImplementationProcessor(ServerMessageProcessor *impl) { /* ... */ } + virtual void SetImplementationProcessor(ServerMessageProcessor *impl) = 0; virtual const ServerMessageRuntimeMetadata GetRuntimeMetadata() const = 0; virtual Result PrepareForProcess(const ServiceDispatchContext &ctx, const ServerMessageRuntimeMetadata runtime_metadata) const = 0; diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp index 0dfdd763f..794aae6df 100644 --- a/stratosphere/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp +++ b/stratosphere/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp @@ -720,8 +720,27 @@ namespace ams::sf::impl { } }; + class HipcCommandProcessorCommon : public sf::cmif::ServerMessageProcessor { + public: + virtual void SetImplementationProcessor(sf::cmif::ServerMessageProcessor *) override final { /* ... */ } + + virtual void PrepareForErrorReply(const cmif::ServiceDispatchContext &ctx, cmif::PointerAndSize &out_raw_data, const cmif::ServerMessageRuntimeMetadata runtime_metadata) override final { + const size_t raw_size = runtime_metadata.GetOutHeadersSize(); + const auto response = hipcMakeRequestInline(ctx.out_message_buffer.GetPointer(), + .type = CmifCommandType_Invalid, /* Really response */ + .num_data_words = static_cast((util::AlignUp(raw_size, 0x4) + 0x10 /* padding */) / sizeof(u32)), + ); + out_raw_data = cmif::PointerAndSize(util::AlignUp(reinterpret_cast(response.data_words), 0x10), raw_size); + } + + virtual Result GetInObjects(cmif::ServiceObjectHolder *in_objects) const override final { + /* By default, InObjects aren't supported. */ + return sf::ResultNotSupported(); + } + }; + template - struct HipcCommandProcessor : public sf::cmif::ServerMessageProcessor { + struct HipcCommandProcessor : public HipcCommandProcessorCommon { public: virtual const cmif::ServerMessageRuntimeMetadata GetRuntimeMetadata() const override final { return CommandMeta::RuntimeMetadata; @@ -760,20 +779,6 @@ namespace ams::sf::impl { return response; } - virtual void PrepareForErrorReply(const cmif::ServiceDispatchContext &ctx, cmif::PointerAndSize &out_raw_data, const cmif::ServerMessageRuntimeMetadata runtime_metadata) override final { - const size_t raw_size = runtime_metadata.GetOutHeadersSize(); - const auto response = hipcMakeRequestInline(ctx.out_message_buffer.GetPointer(), - .type = CmifCommandType_Invalid, /* Really response */ - .num_data_words = static_cast((util::AlignUp(raw_size, 0x4) + 0x10 /* padding */) / sizeof(u32)), - ); - out_raw_data = cmif::PointerAndSize(util::AlignUp(reinterpret_cast(response.data_words), 0x10), raw_size); - } - - virtual Result GetInObjects(cmif::ServiceObjectHolder *in_objects) const override final { - /* By default, InObjects aren't supported. */ - return sf::ResultNotSupported(); - } - virtual void SetOutObjects(const cmif::ServiceDispatchContext &ctx, const HipcRequest &response, cmif::ServiceObjectHolder *out_objects, cmif::DomainObjectId *ids) override final { #define _SF_IMPL_PROCESSOR_SET_OUT_OBJECT_IMPL(n) do { if constexpr (CommandMeta::NumOutObjects > n) { SetOutObjectImpl(response, ctx.manager, std::move(out_objects[n])); } } while (0) _SF_IMPL_PROCESSOR_SET_OUT_OBJECT_IMPL(0);