APT: Remove use of Memory::GetPointer
This commit is contained in:
parent
1ebaaf9bb1
commit
fddd243b17
|
@ -32,9 +32,9 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
|
||||||
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
|
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
|
||||||
// Create the SharedMemory that will hold the framebuffer data
|
// Create the SharedMemory that will hold the framebuffer data
|
||||||
Service::APT::CaptureBufferInfo capture_info;
|
Service::APT::CaptureBufferInfo capture_info;
|
||||||
ASSERT(sizeof(capture_info) == parameter.buffer_size);
|
ASSERT(sizeof(capture_info) == parameter.buffer.size());
|
||||||
|
|
||||||
memcpy(&capture_info, parameter.data, sizeof(capture_info));
|
memcpy(&capture_info, parameter.buffer.data(), sizeof(capture_info));
|
||||||
|
|
||||||
using Kernel::MemoryPermission;
|
using Kernel::MemoryPermission;
|
||||||
// Allocate a heap block of the required size for this applet.
|
// Allocate a heap block of the required size for this applet.
|
||||||
|
@ -47,8 +47,7 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
|
||||||
// Send the response message with the newly created SharedMemory
|
// Send the response message with the newly created SharedMemory
|
||||||
Service::APT::MessageParameter result;
|
Service::APT::MessageParameter result;
|
||||||
result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
|
result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
|
||||||
result.data = nullptr;
|
result.buffer.clear();
|
||||||
result.buffer_size = 0;
|
|
||||||
result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
|
result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
|
||||||
result.sender_id = static_cast<u32>(id);
|
result.sender_id = static_cast<u32>(id);
|
||||||
result.object = framebuffer_memory;
|
result.object = framebuffer_memory;
|
||||||
|
@ -63,15 +62,17 @@ ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& pa
|
||||||
// TODO(Subv): Set the expected fields in the response buffer before resending it to the application.
|
// TODO(Subv): Set the expected fields in the response buffer before resending it to the application.
|
||||||
// TODO(Subv): Reverse the parameter format for the Mii Selector
|
// TODO(Subv): Reverse the parameter format for the Mii Selector
|
||||||
|
|
||||||
if(parameter.buffer_size >= sizeof(u32)) {
|
memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
|
||||||
// TODO: defaults return no error, but garbage in other unknown fields
|
|
||||||
memset(parameter.data, 0, sizeof(u32));
|
// TODO(Subv): Find more about this structure, result code 0 is enough to let most games continue.
|
||||||
}
|
MiiResult result;
|
||||||
|
memset(&result, 0, sizeof(result));
|
||||||
|
result.result_code = 0;
|
||||||
|
|
||||||
// Let the application know that we're closing
|
// Let the application know that we're closing
|
||||||
Service::APT::MessageParameter message;
|
Service::APT::MessageParameter message;
|
||||||
message.buffer_size = parameter.buffer_size;
|
message.buffer.resize(sizeof(MiiResult));
|
||||||
message.data = parameter.data;
|
std::memcpy(message.buffer.data(), &result, message.buffer.size());
|
||||||
message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed);
|
message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed);
|
||||||
message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
|
message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
|
||||||
message.sender_id = static_cast<u32>(id);
|
message.sender_id = static_cast<u32>(id);
|
||||||
|
|
|
@ -24,7 +24,7 @@ struct MiiConfig {
|
||||||
u8 unk_004;
|
u8 unk_004;
|
||||||
INSERT_PADDING_BYTES(3);
|
INSERT_PADDING_BYTES(3);
|
||||||
u16 unk_008;
|
u16 unk_008;
|
||||||
INSERT_PADDING_BYTES(0x8C - 0xA);
|
INSERT_PADDING_BYTES(0x82);
|
||||||
u8 unk_08C;
|
u8 unk_08C;
|
||||||
INSERT_PADDING_BYTES(3);
|
INSERT_PADDING_BYTES(3);
|
||||||
u16 unk_090;
|
u16 unk_090;
|
||||||
|
@ -75,6 +75,8 @@ public:
|
||||||
|
|
||||||
/// Whether this applet is currently running instead of the host application or not.
|
/// Whether this applet is currently running instead of the host application or not.
|
||||||
bool started;
|
bool started;
|
||||||
|
|
||||||
|
MiiConfig config;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
|
||||||
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
|
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
|
||||||
// Create the SharedMemory that will hold the framebuffer data
|
// Create the SharedMemory that will hold the framebuffer data
|
||||||
Service::APT::CaptureBufferInfo capture_info;
|
Service::APT::CaptureBufferInfo capture_info;
|
||||||
ASSERT(sizeof(capture_info) == parameter.buffer_size);
|
ASSERT(sizeof(capture_info) == parameter.buffer.size());
|
||||||
|
|
||||||
memcpy(&capture_info, parameter.data, sizeof(capture_info));
|
memcpy(&capture_info, parameter.buffer.data(), sizeof(capture_info));
|
||||||
|
|
||||||
using Kernel::MemoryPermission;
|
using Kernel::MemoryPermission;
|
||||||
// Allocate a heap block of the required size for this applet.
|
// Allocate a heap block of the required size for this applet.
|
||||||
|
@ -50,8 +50,7 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
|
||||||
// Send the response message with the newly created SharedMemory
|
// Send the response message with the newly created SharedMemory
|
||||||
Service::APT::MessageParameter result;
|
Service::APT::MessageParameter result;
|
||||||
result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
|
result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
|
||||||
result.data = nullptr;
|
result.buffer.clear();
|
||||||
result.buffer_size = 0;
|
|
||||||
result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
|
result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
|
||||||
result.sender_id = static_cast<u32>(id);
|
result.sender_id = static_cast<u32>(id);
|
||||||
result.object = framebuffer_memory;
|
result.object = framebuffer_memory;
|
||||||
|
@ -61,9 +60,9 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter const& parameter) {
|
ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter const& parameter) {
|
||||||
ASSERT_MSG(parameter.buffer_size == sizeof(config), "The size of the parameter (SoftwareKeyboardConfig) is wrong");
|
ASSERT_MSG(parameter.buffer.size() == sizeof(config), "The size of the parameter (SoftwareKeyboardConfig) is wrong");
|
||||||
|
|
||||||
memcpy(&config, parameter.data, parameter.buffer_size);
|
memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
|
||||||
text_memory = boost::static_pointer_cast<Kernel::SharedMemory, Kernel::Object>(parameter.object);
|
text_memory = boost::static_pointer_cast<Kernel::SharedMemory, Kernel::Object>(parameter.object);
|
||||||
|
|
||||||
// TODO(Subv): Verify if this is the correct behavior
|
// TODO(Subv): Verify if this is the correct behavior
|
||||||
|
@ -107,8 +106,8 @@ void SoftwareKeyboard::DrawScreenKeyboard() {
|
||||||
void SoftwareKeyboard::Finalize() {
|
void SoftwareKeyboard::Finalize() {
|
||||||
// Let the application know that we're closing
|
// Let the application know that we're closing
|
||||||
Service::APT::MessageParameter message;
|
Service::APT::MessageParameter message;
|
||||||
message.buffer_size = sizeof(SoftwareKeyboardConfig);
|
message.buffer.resize(sizeof(SoftwareKeyboardConfig));
|
||||||
message.data = reinterpret_cast<u8*>(&config);
|
std::memcpy(message.buffer.data(), &config, message.buffer.size());
|
||||||
message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed);
|
message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed);
|
||||||
message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
|
message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
|
||||||
message.sender_id = static_cast<u32>(id);
|
message.sender_id = static_cast<u32>(id);
|
||||||
|
|
|
@ -176,12 +176,12 @@ void SendParameter(Service::Interface* self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageParameter param;
|
MessageParameter param;
|
||||||
param.buffer_size = buffer_size;
|
|
||||||
param.destination_id = dst_app_id;
|
param.destination_id = dst_app_id;
|
||||||
param.sender_id = src_app_id;
|
param.sender_id = src_app_id;
|
||||||
param.object = Kernel::g_handle_table.GetGeneric(handle);
|
param.object = Kernel::g_handle_table.GetGeneric(handle);
|
||||||
param.signal = signal_type;
|
param.signal = signal_type;
|
||||||
param.data = Memory::GetPointer(buffer);
|
param.buffer.resize(buffer_size);
|
||||||
|
Memory::ReadBlock(buffer, param.buffer.data(), param.buffer.size());
|
||||||
|
|
||||||
cmd_buff[1] = dest_applet->ReceiveParameter(param).raw;
|
cmd_buff[1] = dest_applet->ReceiveParameter(param).raw;
|
||||||
|
|
||||||
|
@ -199,16 +199,15 @@ void ReceiveParameter(Service::Interface* self) {
|
||||||
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
||||||
cmd_buff[2] = next_parameter.sender_id;
|
cmd_buff[2] = next_parameter.sender_id;
|
||||||
cmd_buff[3] = next_parameter.signal; // Signal type
|
cmd_buff[3] = next_parameter.signal; // Signal type
|
||||||
cmd_buff[4] = next_parameter.buffer_size; // Parameter buffer size
|
cmd_buff[4] = next_parameter.buffer.size(); // Parameter buffer size
|
||||||
cmd_buff[5] = 0x10;
|
cmd_buff[5] = 0x10;
|
||||||
cmd_buff[6] = 0;
|
cmd_buff[6] = 0;
|
||||||
if (next_parameter.object != nullptr)
|
if (next_parameter.object != nullptr)
|
||||||
cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom();
|
cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom();
|
||||||
cmd_buff[7] = (next_parameter.buffer_size << 14) | 2;
|
cmd_buff[7] = (next_parameter.buffer.size() << 14) | 2;
|
||||||
cmd_buff[8] = buffer;
|
cmd_buff[8] = buffer;
|
||||||
|
|
||||||
if (next_parameter.data)
|
Memory::WriteBlock(buffer, next_parameter.buffer.data(), next_parameter.buffer.size());
|
||||||
memcpy(Memory::GetPointer(buffer), next_parameter.data, std::min(buffer_size, next_parameter.buffer_size));
|
|
||||||
|
|
||||||
LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size);
|
LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size);
|
||||||
}
|
}
|
||||||
|
@ -222,16 +221,15 @@ void GlanceParameter(Service::Interface* self) {
|
||||||
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
|
||||||
cmd_buff[2] = next_parameter.sender_id;
|
cmd_buff[2] = next_parameter.sender_id;
|
||||||
cmd_buff[3] = next_parameter.signal; // Signal type
|
cmd_buff[3] = next_parameter.signal; // Signal type
|
||||||
cmd_buff[4] = next_parameter.buffer_size; // Parameter buffer size
|
cmd_buff[4] = next_parameter.buffer.size(); // Parameter buffer size
|
||||||
cmd_buff[5] = 0x10;
|
cmd_buff[5] = 0x10;
|
||||||
cmd_buff[6] = 0;
|
cmd_buff[6] = 0;
|
||||||
if (next_parameter.object != nullptr)
|
if (next_parameter.object != nullptr)
|
||||||
cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom();
|
cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom();
|
||||||
cmd_buff[7] = (next_parameter.buffer_size << 14) | 2;
|
cmd_buff[7] = (next_parameter.buffer.size() << 14) | 2;
|
||||||
cmd_buff[8] = buffer;
|
cmd_buff[8] = buffer;
|
||||||
|
|
||||||
if (next_parameter.data)
|
Memory::WriteBlock(buffer, next_parameter.buffer.data(), std::min(static_cast<size_t>(buffer_size), next_parameter.buffer.size()));
|
||||||
memcpy(Memory::GetPointer(buffer), next_parameter.data, std::min(buffer_size, next_parameter.buffer_size));
|
|
||||||
|
|
||||||
LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size);
|
LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size);
|
||||||
}
|
}
|
||||||
|
@ -365,10 +363,13 @@ void StartLibraryApplet(Service::Interface* self) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t buffer_size = cmd_buff[2];
|
||||||
|
VAddr buffer_addr = cmd_buff[6];
|
||||||
|
|
||||||
AppletStartupParameter parameter;
|
AppletStartupParameter parameter;
|
||||||
parameter.buffer_size = cmd_buff[2];
|
|
||||||
parameter.object = Kernel::g_handle_table.GetGeneric(cmd_buff[4]);
|
parameter.object = Kernel::g_handle_table.GetGeneric(cmd_buff[4]);
|
||||||
parameter.data = Memory::GetPointer(cmd_buff[6]);
|
parameter.buffer.resize(buffer_size);
|
||||||
|
Memory::ReadBlock(buffer_addr, parameter.buffer.data(), parameter.buffer.size());
|
||||||
|
|
||||||
cmd_buff[1] = applet->Start(parameter).raw;
|
cmd_buff[1] = applet->Start(parameter).raw;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,16 +20,14 @@ struct MessageParameter {
|
||||||
u32 sender_id = 0;
|
u32 sender_id = 0;
|
||||||
u32 destination_id = 0;
|
u32 destination_id = 0;
|
||||||
u32 signal = 0;
|
u32 signal = 0;
|
||||||
u32 buffer_size = 0;
|
|
||||||
Kernel::SharedPtr<Kernel::Object> object = nullptr;
|
Kernel::SharedPtr<Kernel::Object> object = nullptr;
|
||||||
u8* data = nullptr;
|
std::vector<u8> buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Holds information about the parameters used in StartLibraryApplet
|
/// Holds information about the parameters used in StartLibraryApplet
|
||||||
struct AppletStartupParameter {
|
struct AppletStartupParameter {
|
||||||
u32 buffer_size = 0;
|
|
||||||
Kernel::SharedPtr<Kernel::Object> object = nullptr;
|
Kernel::SharedPtr<Kernel::Object> object = nullptr;
|
||||||
u8* data = nullptr;
|
std::vector<u8> buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Used by the application to pass information about the current framebuffer to applets.
|
/// Used by the application to pass information about the current framebuffer to applets.
|
||||||
|
|
Loading…
Reference in New Issue