yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

Services/APT: Use boost::optional for the APT parameter structure.

This commit is contained in:
Subv 2017-07-21 13:01:21 -05:00
parent 5621a65037
commit 5682608df7
1 changed files with 26 additions and 20 deletions

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <boost/optional.hpp>
#include "common/common_paths.h" #include "common/common_paths.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
@ -44,7 +45,7 @@ static u8 unknown_ns_state_field;
static ScreencapPostPermission screen_capture_post_permission; static ScreencapPostPermission screen_capture_post_permission;
/// Parameter data to be returned in the next call to Glance/ReceiveParameter /// Parameter data to be returned in the next call to Glance/ReceiveParameter
static MessageParameter next_parameter; static boost::optional<MessageParameter> next_parameter;
void SendParameter(const MessageParameter& parameter) { void SendParameter(const MessageParameter& parameter) {
next_parameter = parameter; next_parameter = parameter;
@ -227,18 +228,20 @@ void ReceiveParameter(Service::Interface* self) {
buffer_size, static_buff_size); buffer_size, static_buff_size);
IPC::RequestBuilder rb = rp.MakeBuilder(4, 4); IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
rb.Push(RESULT_SUCCESS); // No error rb.Push(RESULT_SUCCESS); // No error
rb.Push(next_parameter.sender_id); rb.Push(next_parameter->sender_id);
rb.Push(next_parameter.signal); // Signal type rb.Push(next_parameter->signal); // Signal type
ASSERT_MSG(next_parameter.buffer.size() <= buffer_size, "Input static buffer is too small !"); ASSERT_MSG(next_parameter->buffer.size() <= buffer_size, "Input static buffer is too small !");
rb.Push(static_cast<u32>(next_parameter.buffer.size())); // Parameter buffer size rb.Push(static_cast<u32>(next_parameter->buffer.size())); // Parameter buffer size
rb.PushMoveHandles((next_parameter.object != nullptr) rb.PushMoveHandles((next_parameter->object != nullptr)
? Kernel::g_handle_table.Create(next_parameter.object).Unwrap() ? Kernel::g_handle_table.Create(next_parameter->object).Unwrap()
: 0); : 0);
rb.PushStaticBuffer(buffer, static_cast<u32>(next_parameter.buffer.size()), 0);
Memory::WriteBlock(buffer, next_parameter.buffer.data(), next_parameter.buffer.size()); rb.PushStaticBuffer(buffer, static_cast<u32>(next_parameter->buffer.size()), 0);
Memory::WriteBlock(buffer, next_parameter->buffer.data(), next_parameter->buffer.size());
LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08zX", app_id, buffer_size); LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08zX", app_id, buffer_size);
} }
@ -258,17 +261,18 @@ void GlanceParameter(Service::Interface* self) {
IPC::RequestBuilder rb = rp.MakeBuilder(4, 4); IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
rb.Push(RESULT_SUCCESS); // No error rb.Push(RESULT_SUCCESS); // No error
rb.Push(next_parameter.sender_id); rb.Push(next_parameter->sender_id);
rb.Push(next_parameter.signal); // Signal type rb.Push(next_parameter->signal); // Signal type
ASSERT_MSG(next_parameter.buffer.size() <= buffer_size, "Input static buffer is too small !"); ASSERT_MSG(next_parameter->buffer.size() <= buffer_size, "Input static buffer is too small !");
rb.Push(static_cast<u32>(next_parameter.buffer.size())); // Parameter buffer size rb.Push(static_cast<u32>(next_parameter->buffer.size())); // Parameter buffer size
rb.PushCopyHandles((next_parameter.object != nullptr) rb.PushMoveHandles((next_parameter->object != nullptr)
? Kernel::g_handle_table.Create(next_parameter.object).Unwrap() ? Kernel::g_handle_table.Create(next_parameter->object).Unwrap()
: 0); : 0);
rb.PushStaticBuffer(buffer, static_cast<u32>(next_parameter.buffer.size()), 0);
Memory::WriteBlock(buffer, next_parameter.buffer.data(), next_parameter.buffer.size()); rb.PushStaticBuffer(buffer, static_cast<u32>(next_parameter->buffer.size()), 0);
Memory::WriteBlock(buffer, next_parameter->buffer.data(), next_parameter->buffer.size());
LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08zX", app_id, buffer_size); LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08zX", app_id, buffer_size);
} }
@ -800,8 +804,10 @@ void Init() {
notification_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "APT_U:Notification"); notification_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "APT_U:Notification");
parameter_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "APT_U:Start"); parameter_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "APT_U:Start");
next_parameter.signal = static_cast<u32>(SignalType::Wakeup); // Initialize the parameter to wake up the application.
next_parameter.destination_id = 0x300; next_parameter.emplace();
next_parameter->signal = static_cast<u32>(SignalType::Wakeup);
next_parameter->destination_id = static_cast<u32>(AppletId::Application);
} }
void Shutdown() { void Shutdown() {
@ -812,7 +818,7 @@ void Shutdown() {
notification_event = nullptr; notification_event = nullptr;
parameter_event = nullptr; parameter_event = nullptr;
next_parameter.object = nullptr; next_parameter = boost::none;
HLE::Applets::Shutdown(); HLE::Applets::Shutdown();
} }