summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar MerryMage2016-04-16 11:18:49 +0100
committerGravatar Subv2016-05-21 11:14:12 -0500
commitfddd243b17edb0fe03ef1a85c2abdf95353a534d (patch)
treec3e6a15cc40b4516fcf0f0a485261777f7d01f8e /src
parentKernel/Thread: Remove use of Memory::GetPointer (diff)
downloadyuzu-fddd243b17edb0fe03ef1a85c2abdf95353a534d.tar.gz
yuzu-fddd243b17edb0fe03ef1a85c2abdf95353a534d.tar.xz
yuzu-fddd243b17edb0fe03ef1a85c2abdf95353a534d.zip
APT: Remove use of Memory::GetPointer
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/applets/mii_selector.cpp21
-rw-r--r--src/core/hle/applets/mii_selector.h4
-rw-r--r--src/core/hle/applets/swkbd.cpp15
-rw-r--r--src/core/hle/service/apt/apt.cpp25
-rw-r--r--src/core/hle/service/apt/apt.h6
5 files changed, 36 insertions, 35 deletions
diff --git a/src/core/hle/applets/mii_selector.cpp b/src/core/hle/applets/mii_selector.cpp
index bf39eca22..77f01d208 100644
--- a/src/core/hle/applets/mii_selector.cpp
+++ b/src/core/hle/applets/mii_selector.cpp
@@ -32,9 +32,9 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
32 // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory. 32 // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
33 // Create the SharedMemory that will hold the framebuffer data 33 // Create the SharedMemory that will hold the framebuffer data
34 Service::APT::CaptureBufferInfo capture_info; 34 Service::APT::CaptureBufferInfo capture_info;
35 ASSERT(sizeof(capture_info) == parameter.buffer_size); 35 ASSERT(sizeof(capture_info) == parameter.buffer.size());
36 36
37 memcpy(&capture_info, parameter.data, sizeof(capture_info)); 37 memcpy(&capture_info, parameter.buffer.data(), sizeof(capture_info));
38 38
39 using Kernel::MemoryPermission; 39 using Kernel::MemoryPermission;
40 // Allocate a heap block of the required size for this applet. 40 // Allocate a heap block of the required size for this applet.
@@ -47,8 +47,7 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
47 // Send the response message with the newly created SharedMemory 47 // Send the response message with the newly created SharedMemory
48 Service::APT::MessageParameter result; 48 Service::APT::MessageParameter result;
49 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished); 49 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
50 result.data = nullptr; 50 result.buffer.clear();
51 result.buffer_size = 0;
52 result.destination_id = static_cast<u32>(Service::APT::AppletId::Application); 51 result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
53 result.sender_id = static_cast<u32>(id); 52 result.sender_id = static_cast<u32>(id);
54 result.object = framebuffer_memory; 53 result.object = framebuffer_memory;
@@ -63,15 +62,17 @@ ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& pa
63 // TODO(Subv): Set the expected fields in the response buffer before resending it to the application. 62 // TODO(Subv): Set the expected fields in the response buffer before resending it to the application.
64 // TODO(Subv): Reverse the parameter format for the Mii Selector 63 // TODO(Subv): Reverse the parameter format for the Mii Selector
65 64
66 if(parameter.buffer_size >= sizeof(u32)) { 65 memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
67 // TODO: defaults return no error, but garbage in other unknown fields 66
68 memset(parameter.data, 0, sizeof(u32)); 67 // TODO(Subv): Find more about this structure, result code 0 is enough to let most games continue.
69 } 68 MiiResult result;
69 memset(&result, 0, sizeof(result));
70 result.result_code = 0;
70 71
71 // Let the application know that we're closing 72 // Let the application know that we're closing
72 Service::APT::MessageParameter message; 73 Service::APT::MessageParameter message;
73 message.buffer_size = parameter.buffer_size; 74 message.buffer.resize(sizeof(MiiResult));
74 message.data = parameter.data; 75 std::memcpy(message.buffer.data(), &result, message.buffer.size());
75 message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed); 76 message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed);
76 message.destination_id = static_cast<u32>(Service::APT::AppletId::Application); 77 message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
77 message.sender_id = static_cast<u32>(id); 78 message.sender_id = static_cast<u32>(id);
diff --git a/src/core/hle/applets/mii_selector.h b/src/core/hle/applets/mii_selector.h
index be6b04642..24e8e721d 100644
--- a/src/core/hle/applets/mii_selector.h
+++ b/src/core/hle/applets/mii_selector.h
@@ -24,7 +24,7 @@ struct MiiConfig {
24 u8 unk_004; 24 u8 unk_004;
25 INSERT_PADDING_BYTES(3); 25 INSERT_PADDING_BYTES(3);
26 u16 unk_008; 26 u16 unk_008;
27 INSERT_PADDING_BYTES(0x8C - 0xA); 27 INSERT_PADDING_BYTES(0x82);
28 u8 unk_08C; 28 u8 unk_08C;
29 INSERT_PADDING_BYTES(3); 29 INSERT_PADDING_BYTES(3);
30 u16 unk_090; 30 u16 unk_090;
@@ -75,6 +75,8 @@ public:
75 75
76 /// Whether this applet is currently running instead of the host application or not. 76 /// Whether this applet is currently running instead of the host application or not.
77 bool started; 77 bool started;
78
79 MiiConfig config;
78}; 80};
79 81
80} 82}
diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp
index 3ad950692..d87bf3d57 100644
--- a/src/core/hle/applets/swkbd.cpp
+++ b/src/core/hle/applets/swkbd.cpp
@@ -35,9 +35,9 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
35 // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory. 35 // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
36 // Create the SharedMemory that will hold the framebuffer data 36 // Create the SharedMemory that will hold the framebuffer data
37 Service::APT::CaptureBufferInfo capture_info; 37 Service::APT::CaptureBufferInfo capture_info;
38 ASSERT(sizeof(capture_info) == parameter.buffer_size); 38 ASSERT(sizeof(capture_info) == parameter.buffer.size());
39 39
40 memcpy(&capture_info, parameter.data, sizeof(capture_info)); 40 memcpy(&capture_info, parameter.buffer.data(), sizeof(capture_info));
41 41
42 using Kernel::MemoryPermission; 42 using Kernel::MemoryPermission;
43 // Allocate a heap block of the required size for this applet. 43 // Allocate a heap block of the required size for this applet.
@@ -50,8 +50,7 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
50 // Send the response message with the newly created SharedMemory 50 // Send the response message with the newly created SharedMemory
51 Service::APT::MessageParameter result; 51 Service::APT::MessageParameter result;
52 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished); 52 result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
53 result.data = nullptr; 53 result.buffer.clear();
54 result.buffer_size = 0;
55 result.destination_id = static_cast<u32>(Service::APT::AppletId::Application); 54 result.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
56 result.sender_id = static_cast<u32>(id); 55 result.sender_id = static_cast<u32>(id);
57 result.object = framebuffer_memory; 56 result.object = framebuffer_memory;
@@ -61,9 +60,9 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
61} 60}
62 61
63ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter const& parameter) { 62ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter const& parameter) {
64 ASSERT_MSG(parameter.buffer_size == sizeof(config), "The size of the parameter (SoftwareKeyboardConfig) is wrong"); 63 ASSERT_MSG(parameter.buffer.size() == sizeof(config), "The size of the parameter (SoftwareKeyboardConfig) is wrong");
65 64
66 memcpy(&config, parameter.data, parameter.buffer_size); 65 memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
67 text_memory = boost::static_pointer_cast<Kernel::SharedMemory, Kernel::Object>(parameter.object); 66 text_memory = boost::static_pointer_cast<Kernel::SharedMemory, Kernel::Object>(parameter.object);
68 67
69 // TODO(Subv): Verify if this is the correct behavior 68 // TODO(Subv): Verify if this is the correct behavior
@@ -107,8 +106,8 @@ void SoftwareKeyboard::DrawScreenKeyboard() {
107void SoftwareKeyboard::Finalize() { 106void SoftwareKeyboard::Finalize() {
108 // Let the application know that we're closing 107 // Let the application know that we're closing
109 Service::APT::MessageParameter message; 108 Service::APT::MessageParameter message;
110 message.buffer_size = sizeof(SoftwareKeyboardConfig); 109 message.buffer.resize(sizeof(SoftwareKeyboardConfig));
111 message.data = reinterpret_cast<u8*>(&config); 110 std::memcpy(message.buffer.data(), &config, message.buffer.size());
112 message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed); 111 message.signal = static_cast<u32>(Service::APT::SignalType::LibAppClosed);
113 message.destination_id = static_cast<u32>(Service::APT::AppletId::Application); 112 message.destination_id = static_cast<u32>(Service::APT::AppletId::Application);
114 message.sender_id = static_cast<u32>(id); 113 message.sender_id = static_cast<u32>(id);
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
index 73fce6079..e2304fa54 100644
--- a/src/core/hle/service/apt/apt.cpp
+++ b/src/core/hle/service/apt/apt.cpp
@@ -176,12 +176,12 @@ void SendParameter(Service::Interface* self) {
176 } 176 }
177 177
178 MessageParameter param; 178 MessageParameter param;
179 param.buffer_size = buffer_size;
180 param.destination_id = dst_app_id; 179 param.destination_id = dst_app_id;
181 param.sender_id = src_app_id; 180 param.sender_id = src_app_id;
182 param.object = Kernel::g_handle_table.GetGeneric(handle); 181 param.object = Kernel::g_handle_table.GetGeneric(handle);
183 param.signal = signal_type; 182 param.signal = signal_type;
184 param.data = Memory::GetPointer(buffer); 183 param.buffer.resize(buffer_size);
184 Memory::ReadBlock(buffer, param.buffer.data(), param.buffer.size());
185 185
186 cmd_buff[1] = dest_applet->ReceiveParameter(param).raw; 186 cmd_buff[1] = dest_applet->ReceiveParameter(param).raw;
187 187
@@ -199,16 +199,15 @@ void ReceiveParameter(Service::Interface* self) {
199 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 199 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
200 cmd_buff[2] = next_parameter.sender_id; 200 cmd_buff[2] = next_parameter.sender_id;
201 cmd_buff[3] = next_parameter.signal; // Signal type 201 cmd_buff[3] = next_parameter.signal; // Signal type
202 cmd_buff[4] = next_parameter.buffer_size; // Parameter buffer size 202 cmd_buff[4] = next_parameter.buffer.size(); // Parameter buffer size
203 cmd_buff[5] = 0x10; 203 cmd_buff[5] = 0x10;
204 cmd_buff[6] = 0; 204 cmd_buff[6] = 0;
205 if (next_parameter.object != nullptr) 205 if (next_parameter.object != nullptr)
206 cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom(); 206 cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom();
207 cmd_buff[7] = (next_parameter.buffer_size << 14) | 2; 207 cmd_buff[7] = (next_parameter.buffer.size() << 14) | 2;
208 cmd_buff[8] = buffer; 208 cmd_buff[8] = buffer;
209 209
210 if (next_parameter.data) 210 Memory::WriteBlock(buffer, next_parameter.buffer.data(), next_parameter.buffer.size());
211 memcpy(Memory::GetPointer(buffer), next_parameter.data, std::min(buffer_size, next_parameter.buffer_size));
212 211
213 LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); 212 LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size);
214} 213}
@@ -222,16 +221,15 @@ void GlanceParameter(Service::Interface* self) {
222 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 221 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
223 cmd_buff[2] = next_parameter.sender_id; 222 cmd_buff[2] = next_parameter.sender_id;
224 cmd_buff[3] = next_parameter.signal; // Signal type 223 cmd_buff[3] = next_parameter.signal; // Signal type
225 cmd_buff[4] = next_parameter.buffer_size; // Parameter buffer size 224 cmd_buff[4] = next_parameter.buffer.size(); // Parameter buffer size
226 cmd_buff[5] = 0x10; 225 cmd_buff[5] = 0x10;
227 cmd_buff[6] = 0; 226 cmd_buff[6] = 0;
228 if (next_parameter.object != nullptr) 227 if (next_parameter.object != nullptr)
229 cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom(); 228 cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom();
230 cmd_buff[7] = (next_parameter.buffer_size << 14) | 2; 229 cmd_buff[7] = (next_parameter.buffer.size() << 14) | 2;
231 cmd_buff[8] = buffer; 230 cmd_buff[8] = buffer;
232 231
233 if (next_parameter.data) 232 Memory::WriteBlock(buffer, next_parameter.buffer.data(), std::min(static_cast<size_t>(buffer_size), next_parameter.buffer.size()));
234 memcpy(Memory::GetPointer(buffer), next_parameter.data, std::min(buffer_size, next_parameter.buffer_size));
235 233
236 LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); 234 LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size);
237} 235}
@@ -365,10 +363,13 @@ void StartLibraryApplet(Service::Interface* self) {
365 return; 363 return;
366 } 364 }
367 365
366 size_t buffer_size = cmd_buff[2];
367 VAddr buffer_addr = cmd_buff[6];
368
368 AppletStartupParameter parameter; 369 AppletStartupParameter parameter;
369 parameter.buffer_size = cmd_buff[2];
370 parameter.object = Kernel::g_handle_table.GetGeneric(cmd_buff[4]); 370 parameter.object = Kernel::g_handle_table.GetGeneric(cmd_buff[4]);
371 parameter.data = Memory::GetPointer(cmd_buff[6]); 371 parameter.buffer.resize(buffer_size);
372 Memory::ReadBlock(buffer_addr, parameter.buffer.data(), parameter.buffer.size());
372 373
373 cmd_buff[1] = applet->Start(parameter).raw; 374 cmd_buff[1] = applet->Start(parameter).raw;
374} 375}
diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h
index 1a1034fcc..66cda1d4c 100644
--- a/src/core/hle/service/apt/apt.h
+++ b/src/core/hle/service/apt/apt.h
@@ -20,16 +20,14 @@ struct MessageParameter {
20 u32 sender_id = 0; 20 u32 sender_id = 0;
21 u32 destination_id = 0; 21 u32 destination_id = 0;
22 u32 signal = 0; 22 u32 signal = 0;
23 u32 buffer_size = 0;
24 Kernel::SharedPtr<Kernel::Object> object = nullptr; 23 Kernel::SharedPtr<Kernel::Object> object = nullptr;
25 u8* data = nullptr; 24 std::vector<u8> buffer;
26}; 25};
27 26
28/// Holds information about the parameters used in StartLibraryApplet 27/// Holds information about the parameters used in StartLibraryApplet
29struct AppletStartupParameter { 28struct AppletStartupParameter {
30 u32 buffer_size = 0;
31 Kernel::SharedPtr<Kernel::Object> object = nullptr; 29 Kernel::SharedPtr<Kernel::Object> object = nullptr;
32 u8* data = nullptr; 30 std::vector<u8> buffer;
33}; 31};
34 32
35/// Used by the application to pass information about the current framebuffer to applets. 33/// Used by the application to pass information about the current framebuffer to applets.