diff options
| author | 2017-10-15 01:24:22 -0400 | |
|---|---|---|
| committer | 2017-10-15 01:24:22 -0400 | |
| commit | 4fb1b24d68e140230da612d464a5edc226860946 (patch) | |
| tree | ed6cc24d62caf4476737508de317908a6cb23e90 /src/core/hle/kernel | |
| parent | core: Refactor MakeMagic usage and remove dead code. (diff) | |
| download | yuzu-4fb1b24d68e140230da612d464a5edc226860946.tar.gz yuzu-4fb1b24d68e140230da612d464a5edc226860946.tar.xz yuzu-4fb1b24d68e140230da612d464a5edc226860946.zip | |
hle: Implement ConvertSessionToDomain, various cleanups.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 23 | ||||
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.h | 3 | ||||
| -rw-r--r-- | src/core/hle/kernel/server_session.h | 10 |
3 files changed, 31 insertions, 5 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index b7070af03..35cac68f1 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include <boost/range/algorithm_ext/erase.hpp> | 5 | #include <boost/range/algorithm_ext/erase.hpp> |
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/common_funcs.h" | ||
| 7 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 8 | #include "core/hle/ipc_helpers.h" | 9 | #include "core/hle/ipc_helpers.h" |
| 9 | #include "core/hle/kernel/handle_table.h" | 10 | #include "core/hle/kernel/handle_table.h" |
| @@ -45,10 +46,15 @@ void HLERequestContext::ClearIncomingObjects() { | |||
| 45 | request_handles.clear(); | 46 | request_handles.clear(); |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf) { | 49 | void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) { |
| 49 | IPC::RequestParser rp(src_cmdbuf); | 50 | IPC::RequestParser rp(src_cmdbuf); |
| 50 | command_header = std::make_unique<IPC::CommandHeader>(rp.PopRaw<IPC::CommandHeader>()); | 51 | command_header = std::make_unique<IPC::CommandHeader>(rp.PopRaw<IPC::CommandHeader>()); |
| 51 | 52 | ||
| 53 | if (command_header->type == IPC::CommandType::Close) { | ||
| 54 | // Close does not populate the rest of the IPC header | ||
| 55 | return; | ||
| 56 | } | ||
| 57 | |||
| 52 | // If handle descriptor is present, add size of it | 58 | // If handle descriptor is present, add size of it |
| 53 | if (command_header->enable_handle_descriptor) { | 59 | if (command_header->enable_handle_descriptor) { |
| 54 | handle_descriptor_header = | 60 | handle_descriptor_header = |
| @@ -80,9 +86,18 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf) { | |||
| 80 | UNIMPLEMENTED(); | 86 | UNIMPLEMENTED(); |
| 81 | } | 87 | } |
| 82 | 88 | ||
| 89 | if (incoming && Session()->IsDomain()) { | ||
| 90 | domain_message_header = std::make_unique<IPC::DomainMessageHeader>(rp.PopRaw<IPC::DomainMessageHeader>()); | ||
| 91 | } | ||
| 92 | |||
| 83 | data_payload_header = | 93 | data_payload_header = |
| 84 | std::make_unique<IPC::DataPayloadHeader>(rp.PopRaw<IPC::DataPayloadHeader>()); | 94 | std::make_unique<IPC::DataPayloadHeader>(rp.PopRaw<IPC::DataPayloadHeader>()); |
| 85 | ASSERT(data_payload_header->magic == 0x49434653 || data_payload_header->magic == 0x4F434653); | 95 | |
| 96 | if (incoming) { | ||
| 97 | ASSERT(data_payload_header->magic == Common::MakeMagic('S', 'F', 'C', 'I')); | ||
| 98 | } else { | ||
| 99 | ASSERT(data_payload_header->magic == Common::MakeMagic('S', 'F', 'C', 'O')); | ||
| 100 | } | ||
| 86 | 101 | ||
| 87 | data_payload_offset = rp.GetCurrentOffset(); | 102 | data_payload_offset = rp.GetCurrentOffset(); |
| 88 | command = rp.Pop<u32_le>(); | 103 | command = rp.Pop<u32_le>(); |
| @@ -91,7 +106,7 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf) { | |||
| 91 | ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(u32_le* src_cmdbuf, | 106 | ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(u32_le* src_cmdbuf, |
| 92 | Process& src_process, | 107 | Process& src_process, |
| 93 | HandleTable& src_table) { | 108 | HandleTable& src_table) { |
| 94 | ParseCommandBuffer(src_cmdbuf); | 109 | ParseCommandBuffer(src_cmdbuf, true); |
| 95 | size_t untranslated_size = data_payload_offset + command_header->data_size; | 110 | size_t untranslated_size = data_payload_offset + command_header->data_size; |
| 96 | std::copy_n(src_cmdbuf, untranslated_size, cmd_buf.begin()); | 111 | std::copy_n(src_cmdbuf, untranslated_size, cmd_buf.begin()); |
| 97 | 112 | ||
| @@ -106,7 +121,7 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(u32_le* src_cmdb | |||
| 106 | 121 | ||
| 107 | ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, Process& dst_process, | 122 | ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, Process& dst_process, |
| 108 | HandleTable& dst_table) { | 123 | HandleTable& dst_table) { |
| 109 | ParseCommandBuffer(&cmd_buf[0]); | 124 | ParseCommandBuffer(&cmd_buf[0], false); |
| 110 | size_t untranslated_size = data_payload_offset + command_header->data_size; | 125 | size_t untranslated_size = data_payload_offset + command_header->data_size; |
| 111 | std::copy_n(cmd_buf.begin(), untranslated_size, dst_cmdbuf); | 126 | std::copy_n(cmd_buf.begin(), untranslated_size, dst_cmdbuf); |
| 112 | 127 | ||
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 32a528968..17baffc06 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h | |||
| @@ -119,7 +119,7 @@ public: | |||
| 119 | */ | 119 | */ |
| 120 | void ClearIncomingObjects(); | 120 | void ClearIncomingObjects(); |
| 121 | 121 | ||
| 122 | void ParseCommandBuffer(u32_le* src_cmdbuf); | 122 | void ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming); |
| 123 | 123 | ||
| 124 | /// Populates this context with data from the requesting process/thread. | 124 | /// Populates this context with data from the requesting process/thread. |
| 125 | ResultCode PopulateFromIncomingCommandBuffer(u32_le* src_cmdbuf, Process& src_process, | 125 | ResultCode PopulateFromIncomingCommandBuffer(u32_le* src_cmdbuf, Process& src_process, |
| @@ -149,6 +149,7 @@ private: | |||
| 149 | std::unique_ptr<IPC::CommandHeader> command_header; | 149 | std::unique_ptr<IPC::CommandHeader> command_header; |
| 150 | std::unique_ptr<IPC::HandleDescriptorHeader> handle_descriptor_header; | 150 | std::unique_ptr<IPC::HandleDescriptorHeader> handle_descriptor_header; |
| 151 | std::unique_ptr<IPC::DataPayloadHeader> data_payload_header; | 151 | std::unique_ptr<IPC::DataPayloadHeader> data_payload_header; |
| 152 | std::unique_ptr<IPC::DomainMessageHeader> domain_message_header; | ||
| 152 | 153 | ||
| 153 | unsigned data_payload_offset{}; | 154 | unsigned data_payload_offset{}; |
| 154 | u32_le command{}; | 155 | u32_le command{}; |
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index f4360ddf3..78db5510d 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h | |||
| @@ -91,6 +91,14 @@ public: | |||
| 91 | /// TODO(Subv): Find a better name for this. | 91 | /// TODO(Subv): Find a better name for this. |
| 92 | SharedPtr<Thread> currently_handling; | 92 | SharedPtr<Thread> currently_handling; |
| 93 | 93 | ||
| 94 | void ConvertToDomain() { | ||
| 95 | is_domain = true; | ||
| 96 | } | ||
| 97 | |||
| 98 | bool IsDomain() const { | ||
| 99 | return is_domain; | ||
| 100 | } | ||
| 101 | |||
| 94 | private: | 102 | private: |
| 95 | ServerSession(); | 103 | ServerSession(); |
| 96 | ~ServerSession() override; | 104 | ~ServerSession() override; |
| @@ -102,6 +110,8 @@ private: | |||
| 102 | * @return The created server session | 110 | * @return The created server session |
| 103 | */ | 111 | */ |
| 104 | static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown"); | 112 | static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown"); |
| 113 | |||
| 114 | bool is_domain{}; | ||
| 105 | }; | 115 | }; |
| 106 | 116 | ||
| 107 | /** | 117 | /** |