mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
sf: PrepareForErrorReply is common to all objects
This commit is contained in:
parent
93a218abeb
commit
c6b9a0c4bf
2 changed files with 21 additions and 16 deletions
|
@ -69,7 +69,7 @@ namespace ams::sf::cmif {
|
||||||
class ServerMessageProcessor {
|
class ServerMessageProcessor {
|
||||||
public:
|
public:
|
||||||
/* Used to enabled templated message processors. */
|
/* Used to enabled templated message processors. */
|
||||||
virtual void SetImplementationProcessor(ServerMessageProcessor *impl) { /* ... */ }
|
virtual void SetImplementationProcessor(ServerMessageProcessor *impl) = 0;
|
||||||
virtual const ServerMessageRuntimeMetadata GetRuntimeMetadata() const = 0;
|
virtual const ServerMessageRuntimeMetadata GetRuntimeMetadata() const = 0;
|
||||||
|
|
||||||
virtual Result PrepareForProcess(const ServiceDispatchContext &ctx, const ServerMessageRuntimeMetadata runtime_metadata) const = 0;
|
virtual Result PrepareForProcess(const ServiceDispatchContext &ctx, const ServerMessageRuntimeMetadata runtime_metadata) const = 0;
|
||||||
|
|
|
@ -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<u32>((util::AlignUp(raw_size, 0x4) + 0x10 /* padding */) / sizeof(u32)),
|
||||||
|
);
|
||||||
|
out_raw_data = cmif::PointerAndSize(util::AlignUp(reinterpret_cast<uintptr_t>(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<typename CommandMeta>
|
template<typename CommandMeta>
|
||||||
struct HipcCommandProcessor : public sf::cmif::ServerMessageProcessor {
|
struct HipcCommandProcessor : public HipcCommandProcessorCommon {
|
||||||
public:
|
public:
|
||||||
virtual const cmif::ServerMessageRuntimeMetadata GetRuntimeMetadata() const override final {
|
virtual const cmif::ServerMessageRuntimeMetadata GetRuntimeMetadata() const override final {
|
||||||
return CommandMeta::RuntimeMetadata;
|
return CommandMeta::RuntimeMetadata;
|
||||||
|
@ -760,20 +779,6 @@ namespace ams::sf::impl {
|
||||||
return response;
|
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<u32>((util::AlignUp(raw_size, 0x4) + 0x10 /* padding */) / sizeof(u32)),
|
|
||||||
);
|
|
||||||
out_raw_data = cmif::PointerAndSize(util::AlignUp(reinterpret_cast<uintptr_t>(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 {
|
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<n>(response, ctx.manager, std::move(out_objects[n])); } } while (0)
|
#define _SF_IMPL_PROCESSOR_SET_OUT_OBJECT_IMPL(n) do { if constexpr (CommandMeta::NumOutObjects > n) { SetOutObjectImpl<n>(response, ctx.manager, std::move(out_objects[n])); } } while (0)
|
||||||
_SF_IMPL_PROCESSOR_SET_OUT_OBJECT_IMPL(0);
|
_SF_IMPL_PROCESSOR_SET_OUT_OBJECT_IMPL(0);
|
||||||
|
|
Loading…
Reference in a new issue