diff options
| author | 2016-12-26 13:58:50 +0100 | |
|---|---|---|
| committer | 2016-12-26 14:07:29 +0100 | |
| commit | 8baae9d9828eff9bcaf24c5767ed03d05f7e617b (patch) | |
| tree | 7d9c45ca77af31c1df2189f105b2a0187dfae72e /src | |
| parent | IPC helpers (diff) | |
| download | yuzu-8baae9d9828eff9bcaf24c5767ed03d05f7e617b.tar.gz yuzu-8baae9d9828eff9bcaf24c5767ed03d05f7e617b.tar.xz yuzu-8baae9d9828eff9bcaf24c5767ed03d05f7e617b.zip | |
IPC helpers example
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 27 | ||||
| -rw-r--r-- | src/core/hle/service/service.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/y2r_u.cpp | 47 |
3 files changed, 40 insertions, 35 deletions
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 337da1387..33b290699 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp | |||
| @@ -54,15 +54,17 @@ static void Initialize(Service::Interface* self) { | |||
| 54 | * 3 : File handle | 54 | * 3 : File handle |
| 55 | */ | 55 | */ |
| 56 | static void OpenFile(Service::Interface* self) { | 56 | static void OpenFile(Service::Interface* self) { |
| 57 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 57 | // The helper should be passed by argument to the function |
| 58 | IPC::RequestParser rp(Kernel::GetCommandBuffer(), {0x080201C2}); | ||
| 59 | rp.Pop<u32>(); // Always 0 ? | ||
| 58 | 60 | ||
| 59 | ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]); | 61 | ArchiveHandle archive_handle = rp.Pop<u64>(); |
| 60 | auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]); | 62 | auto filename_type = static_cast<FileSys::LowPathType>(rp.Pop<u32>()); |
| 61 | u32 filename_size = cmd_buff[5]; | 63 | u32 filename_size = rp.Pop<u32>(); |
| 62 | FileSys::Mode mode; | 64 | FileSys::Mode mode; |
| 63 | mode.hex = cmd_buff[6]; | 65 | mode.hex = rp.Pop<u32>(); |
| 64 | u32 attributes = cmd_buff[7]; // TODO(Link Mauve): do something with those attributes. | 66 | u32 attributes = rp.Pop<u32>(); // TODO(Link Mauve): do something with those attributes. |
| 65 | u32 filename_ptr = cmd_buff[9]; | 67 | VAddr filename_ptr = rp.PopStaticBuffer(); |
| 66 | FileSys::Path file_path(filename_type, filename_size, filename_ptr); | 68 | FileSys::Path file_path(filename_type, filename_size, filename_ptr); |
| 67 | 69 | ||
| 68 | LOG_DEBUG(Service_FS, "path=%s, mode=%u attrs=%u", file_path.DebugStr().c_str(), mode.hex, | 70 | LOG_DEBUG(Service_FS, "path=%s, mode=%u attrs=%u", file_path.DebugStr().c_str(), mode.hex, |
| @@ -70,16 +72,17 @@ static void OpenFile(Service::Interface* self) { | |||
| 70 | 72 | ||
| 71 | ResultVal<std::shared_ptr<File>> file_res = | 73 | ResultVal<std::shared_ptr<File>> file_res = |
| 72 | OpenFileFromArchive(archive_handle, file_path, mode); | 74 | OpenFileFromArchive(archive_handle, file_path, mode); |
| 73 | cmd_buff[1] = file_res.Code().raw; | 75 | IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); |
| 76 | rb.Push(file_res.Code()); | ||
| 74 | if (file_res.Succeeded()) { | 77 | if (file_res.Succeeded()) { |
| 75 | std::shared_ptr<File> file = *file_res; | 78 | std::shared_ptr<File> file = *file_res; |
| 76 | auto sessions = ServerSession::CreateSessionPair(file->GetName(), file); | 79 | auto sessions = ServerSession::CreateSessionPair(file->GetName(), file); |
| 77 | file->ClientConnected(std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions)); | 80 | file->ClientConnected(std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions)); |
| 78 | cmd_buff[3] = Kernel::g_handle_table | 81 | rb.PushMoveHandles(Kernel::g_handle_table |
| 79 | .Create(std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions)) | 82 | .Create(std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions)) |
| 80 | .MoveFrom(); | 83 | .MoveFrom()); |
| 81 | } else { | 84 | } else { |
| 82 | cmd_buff[3] = 0; | 85 | rb.PushMoveHandles(0); |
| 83 | LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str()); | 86 | LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str()); |
| 84 | } | 87 | } |
| 85 | } | 88 | } |
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index a7ba7688f..e6a5f1417 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <boost/container/flat_map.hpp> | 10 | #include <boost/container/flat_map.hpp> |
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "core/hle/ipc.h" | 12 | #include "core/hle/ipc.h" |
| 13 | #include "core/hle/ipc_helpers.h" | ||
| 13 | #include "core/hle/kernel/client_port.h" | 14 | #include "core/hle/kernel/client_port.h" |
| 14 | #include "core/hle/kernel/thread.h" | 15 | #include "core/hle/kernel/thread.h" |
| 15 | #include "core/hle/result.h" | 16 | #include "core/hle/result.h" |
diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cpp index a20194107..35eb2b597 100644 --- a/src/core/hle/service/y2r_u.cpp +++ b/src/core/hle/service/y2r_u.cpp | |||
| @@ -281,37 +281,39 @@ static void GetTransferEndEvent(Interface* self) { | |||
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | static void SetSendingY(Interface* self) { | 283 | static void SetSendingY(Interface* self) { |
| 284 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 284 | // The helper should be passed by argument to the function |
| 285 | 285 | IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x00100102); | |
| 286 | conversion.src_Y.address = cmd_buff[1]; | 286 | conversion.src_Y.address = rp.Pop<u32>(); |
| 287 | conversion.src_Y.image_size = cmd_buff[2]; | 287 | conversion.src_Y.image_size = rp.Pop<u32>(); |
| 288 | conversion.src_Y.transfer_unit = cmd_buff[3]; | 288 | conversion.src_Y.transfer_unit = rp.Pop<u32>(); |
| 289 | conversion.src_Y.gap = cmd_buff[4]; | 289 | conversion.src_Y.gap = rp.Pop<u32>(); |
| 290 | Kernel::Handle src_process_handle = rp.PopHandle(); | ||
| 290 | 291 | ||
| 291 | cmd_buff[0] = IPC::MakeHeader(0x10, 1, 0); | 292 | IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); |
| 292 | cmd_buff[1] = RESULT_SUCCESS.raw; | 293 | rb.Push(RESULT_SUCCESS); |
| 293 | 294 | ||
| 294 | LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, " | 295 | LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, " |
| 295 | "src_process_handle=0x%08X", | 296 | "src_process_handle=0x%08X", |
| 296 | conversion.src_Y.image_size, conversion.src_Y.transfer_unit, conversion.src_Y.gap, | 297 | conversion.src_Y.image_size, conversion.src_Y.transfer_unit, conversion.src_Y.gap, |
| 297 | cmd_buff[6]); | 298 | src_process_handle); |
| 298 | } | 299 | } |
| 299 | 300 | ||
| 300 | static void SetSendingU(Interface* self) { | 301 | static void SetSendingU(Interface* self) { |
| 301 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 302 | // The helper should be passed by argument to the function |
| 303 | IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x00110102); | ||
| 304 | conversion.src_U.address = rp.Pop<u32>(); | ||
| 305 | conversion.src_U.image_size = rp.Pop<u32>(); | ||
| 306 | conversion.src_U.transfer_unit = rp.Pop<u32>(); | ||
| 307 | conversion.src_U.gap = rp.Pop<u32>(); | ||
| 308 | Kernel::Handle src_process_handle = rp.PopHandle(); | ||
| 302 | 309 | ||
| 303 | conversion.src_U.address = cmd_buff[1]; | 310 | IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); |
| 304 | conversion.src_U.image_size = cmd_buff[2]; | 311 | rb.Push(RESULT_SUCCESS); |
| 305 | conversion.src_U.transfer_unit = cmd_buff[3]; | ||
| 306 | conversion.src_U.gap = cmd_buff[4]; | ||
| 307 | |||
| 308 | cmd_buff[0] = IPC::MakeHeader(0x11, 1, 0); | ||
| 309 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 310 | 312 | ||
| 311 | LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, " | 313 | LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, " |
| 312 | "src_process_handle=0x%08X", | 314 | "src_process_handle=0x%08X", |
| 313 | conversion.src_U.image_size, conversion.src_U.transfer_unit, conversion.src_U.gap, | 315 | conversion.src_U.image_size, conversion.src_U.transfer_unit, conversion.src_U.gap, |
| 314 | cmd_buff[6]); | 316 | src_process_handle); |
| 315 | } | 317 | } |
| 316 | 318 | ||
| 317 | static void SetSendingV(Interface* self) { | 319 | static void SetSendingV(Interface* self) { |
| @@ -559,11 +561,10 @@ static void GetAlpha(Interface* self) { | |||
| 559 | } | 561 | } |
| 560 | 562 | ||
| 561 | static void SetDitheringWeightParams(Interface* self) { | 563 | static void SetDitheringWeightParams(Interface* self) { |
| 562 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 564 | IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x24, 8, 0); // 0x240200 |
| 563 | std::memcpy(&dithering_weight_params, &cmd_buff[1], sizeof(DitheringWeightParams)); | 565 | rp.PopRaw(dithering_weight_params); |
| 564 | 566 | IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); | |
| 565 | cmd_buff[0] = IPC::MakeHeader(0x24, 1, 0); | 567 | rb.Push(RESULT_SUCCESS); |
| 566 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 567 | 568 | ||
| 568 | LOG_DEBUG(Service_Y2R, "called"); | 569 | LOG_DEBUG(Service_Y2R, "called"); |
| 569 | } | 570 | } |