diff options
| author | 2019-11-26 14:10:49 -0500 | |
|---|---|---|
| committer | 2019-11-26 21:55:37 -0500 | |
| commit | 536fc7f0ea77e08d68c760f387c307d258804e3b (patch) | |
| tree | e979df531bf1222788cc26144531c6e6f5cca1d1 /src/core/hle | |
| parent | core/memory: Move memory read/write implementation functions into an anonymou... (diff) | |
| download | yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar.gz yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar.xz yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.zip | |
core: Prepare various classes for memory read/write migration
Amends a few interfaces to be able to handle the migration over to the
new Memory class by passing the class by reference as a function
parameter where necessary.
Notably, within the filesystem services, this eliminates two ReadBlock()
calls by using the helper functions of HLERequestContext to do that for
us.
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/kernel/client_session.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/client_session.h | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/server_session.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/kernel/server_session.h | 9 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audren_u.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/lm/lm.cpp | 13 |
8 files changed, 32 insertions, 17 deletions
diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp index 5995a6556..9849dbe91 100644 --- a/src/core/hle/kernel/client_session.cpp +++ b/src/core/hle/kernel/client_session.cpp | |||
| @@ -21,10 +21,10 @@ ClientSession::~ClientSession() { | |||
| 21 | } | 21 | } |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | ResultCode ClientSession::SendSyncRequest(Thread* thread) { | 24 | ResultCode ClientSession::SendSyncRequest(Thread* thread, Memory::Memory& memory) { |
| 25 | // Signal the server session that new data is available | 25 | // Signal the server session that new data is available |
| 26 | if (auto server = parent->server.lock()) { | 26 | if (auto server = parent->server.lock()) { |
| 27 | return server->HandleSyncRequest(SharedFrom(thread)); | 27 | return server->HandleSyncRequest(SharedFrom(thread), memory); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | return ERR_SESSION_CLOSED_BY_REMOTE; | 30 | return ERR_SESSION_CLOSED_BY_REMOTE; |
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index 5ae41db29..484dd7bc9 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h | |||
| @@ -10,6 +10,10 @@ | |||
| 10 | 10 | ||
| 11 | union ResultCode; | 11 | union ResultCode; |
| 12 | 12 | ||
| 13 | namespace Memory { | ||
| 14 | class Memory; | ||
| 15 | } | ||
| 16 | |||
| 13 | namespace Kernel { | 17 | namespace Kernel { |
| 14 | 18 | ||
| 15 | class KernelCore; | 19 | class KernelCore; |
| @@ -37,7 +41,7 @@ public: | |||
| 37 | return HANDLE_TYPE; | 41 | return HANDLE_TYPE; |
| 38 | } | 42 | } |
| 39 | 43 | ||
| 40 | ResultCode SendSyncRequest(Thread* thread); | 44 | ResultCode SendSyncRequest(Thread* thread, Memory::Memory& memory); |
| 41 | 45 | ||
| 42 | private: | 46 | private: |
| 43 | /// The parent session, which links to the server endpoint. | 47 | /// The parent session, which links to the server endpoint. |
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index c7db21eb2..57878514d 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp | |||
| @@ -127,7 +127,8 @@ ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& con | |||
| 127 | return RESULT_SUCCESS; | 127 | return RESULT_SUCCESS; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread) { | 130 | ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread, |
| 131 | Memory::Memory& memory) { | ||
| 131 | // The ServerSession received a sync request, this means that there's new data available | 132 | // The ServerSession received a sync request, this means that there's new data available |
| 132 | // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or | 133 | // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or |
| 133 | // similar. | 134 | // similar. |
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index 8a65647b6..641709a45 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h | |||
| @@ -13,6 +13,10 @@ | |||
| 13 | #include "core/hle/kernel/wait_object.h" | 13 | #include "core/hle/kernel/wait_object.h" |
| 14 | #include "core/hle/result.h" | 14 | #include "core/hle/result.h" |
| 15 | 15 | ||
| 16 | namespace Memory { | ||
| 17 | class Memory; | ||
| 18 | } | ||
| 19 | |||
| 16 | namespace Kernel { | 20 | namespace Kernel { |
| 17 | 21 | ||
| 18 | class ClientPort; | 22 | class ClientPort; |
| @@ -85,10 +89,13 @@ public: | |||
| 85 | 89 | ||
| 86 | /** | 90 | /** |
| 87 | * Handle a sync request from the emulated application. | 91 | * Handle a sync request from the emulated application. |
| 92 | * | ||
| 88 | * @param thread Thread that initiated the request. | 93 | * @param thread Thread that initiated the request. |
| 94 | * @param memory Memory context to handle the sync request under. | ||
| 95 | * | ||
| 89 | * @returns ResultCode from the operation. | 96 | * @returns ResultCode from the operation. |
| 90 | */ | 97 | */ |
| 91 | ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread); | 98 | ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread, Memory::Memory& memory); |
| 92 | 99 | ||
| 93 | bool ShouldWait(const Thread* thread) const override; | 100 | bool ShouldWait(const Thread* thread) const override; |
| 94 | 101 | ||
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index eddafaf60..68bff11ec 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -383,7 +383,7 @@ static ResultCode SendSyncRequest(Core::System& system, Handle handle) { | |||
| 383 | 383 | ||
| 384 | // TODO(Subv): svcSendSyncRequest should put the caller thread to sleep while the server | 384 | // TODO(Subv): svcSendSyncRequest should put the caller thread to sleep while the server |
| 385 | // responds and cause a reschedule. | 385 | // responds and cause a reschedule. |
| 386 | return session->SendSyncRequest(system.CurrentScheduler().GetCurrentThread()); | 386 | return session->SendSyncRequest(system.CurrentScheduler().GetCurrentThread(), system.Memory()); |
| 387 | } | 387 | } |
| 388 | 388 | ||
| 389 | /// Get the ID for the specified thread. | 389 | /// Get the ID for the specified thread. |
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 4ea7ade6e..82a5dbf14 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp | |||
| @@ -49,8 +49,9 @@ public: | |||
| 49 | 49 | ||
| 50 | system_event = | 50 | system_event = |
| 51 | Kernel::WritableEvent::CreateEventPair(system.Kernel(), "IAudioRenderer:SystemEvent"); | 51 | Kernel::WritableEvent::CreateEventPair(system.Kernel(), "IAudioRenderer:SystemEvent"); |
| 52 | renderer = std::make_unique<AudioCore::AudioRenderer>( | 52 | renderer = std::make_unique<AudioCore::AudioRenderer>(system.CoreTiming(), system.Memory(), |
| 53 | system.CoreTiming(), audren_params, system_event.writable, instance_number); | 53 | audren_params, system_event.writable, |
| 54 | instance_number); | ||
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | private: | 57 | private: |
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 5874ed6bd..89e1957f9 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp | |||
| @@ -391,13 +391,10 @@ public: | |||
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | void RenameFile(Kernel::HLERequestContext& ctx) { | 393 | void RenameFile(Kernel::HLERequestContext& ctx) { |
| 394 | std::vector<u8> buffer; | 394 | std::vector<u8> buffer = ctx.ReadBuffer(0); |
| 395 | buffer.resize(ctx.BufferDescriptorX()[0].Size()); | ||
| 396 | Memory::ReadBlock(ctx.BufferDescriptorX()[0].Address(), buffer.data(), buffer.size()); | ||
| 397 | const std::string src_name = Common::StringFromBuffer(buffer); | 395 | const std::string src_name = Common::StringFromBuffer(buffer); |
| 398 | 396 | ||
| 399 | buffer.resize(ctx.BufferDescriptorX()[1].Size()); | 397 | buffer = ctx.ReadBuffer(1); |
| 400 | Memory::ReadBlock(ctx.BufferDescriptorX()[1].Address(), buffer.data(), buffer.size()); | ||
| 401 | const std::string dst_name = Common::StringFromBuffer(buffer); | 398 | const std::string dst_name = Common::StringFromBuffer(buffer); |
| 402 | 399 | ||
| 403 | LOG_DEBUG(Service_FS, "called. file '{}' to file '{}'", src_name, dst_name); | 400 | LOG_DEBUG(Service_FS, "called. file '{}' to file '{}'", src_name, dst_name); |
diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index 435f2d286..74ecaef1b 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp | |||
| @@ -17,7 +17,8 @@ namespace Service::LM { | |||
| 17 | 17 | ||
| 18 | class ILogger final : public ServiceFramework<ILogger> { | 18 | class ILogger final : public ServiceFramework<ILogger> { |
| 19 | public: | 19 | public: |
| 20 | ILogger(Manager& manager) : ServiceFramework("ILogger"), manager(manager) { | 20 | explicit ILogger(Manager& manager_, Memory::Memory& memory_) |
| 21 | : ServiceFramework("ILogger"), manager{manager_}, memory{memory_} { | ||
| 21 | static const FunctionInfo functions[] = { | 22 | static const FunctionInfo functions[] = { |
| 22 | {0, &ILogger::Log, "Log"}, | 23 | {0, &ILogger::Log, "Log"}, |
| 23 | {1, &ILogger::SetDestination, "SetDestination"}, | 24 | {1, &ILogger::SetDestination, "SetDestination"}, |
| @@ -74,11 +75,13 @@ private: | |||
| 74 | } | 75 | } |
| 75 | 76 | ||
| 76 | Manager& manager; | 77 | Manager& manager; |
| 78 | Memory::Memory& memory; | ||
| 77 | }; | 79 | }; |
| 78 | 80 | ||
| 79 | class LM final : public ServiceFramework<LM> { | 81 | class LM final : public ServiceFramework<LM> { |
| 80 | public: | 82 | public: |
| 81 | explicit LM(Manager& manager) : ServiceFramework{"lm"}, manager(manager) { | 83 | explicit LM(Manager& manager_, Memory::Memory& memory_) |
| 84 | : ServiceFramework{"lm"}, manager{manager_}, memory{memory_} { | ||
| 82 | // clang-format off | 85 | // clang-format off |
| 83 | static const FunctionInfo functions[] = { | 86 | static const FunctionInfo functions[] = { |
| 84 | {0, &LM::OpenLogger, "OpenLogger"}, | 87 | {0, &LM::OpenLogger, "OpenLogger"}, |
| @@ -94,14 +97,16 @@ private: | |||
| 94 | 97 | ||
| 95 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 98 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 96 | rb.Push(RESULT_SUCCESS); | 99 | rb.Push(RESULT_SUCCESS); |
| 97 | rb.PushIpcInterface<ILogger>(manager); | 100 | rb.PushIpcInterface<ILogger>(manager, memory); |
| 98 | } | 101 | } |
| 99 | 102 | ||
| 100 | Manager& manager; | 103 | Manager& manager; |
| 104 | Memory::Memory& memory; | ||
| 101 | }; | 105 | }; |
| 102 | 106 | ||
| 103 | void InstallInterfaces(Core::System& system) { | 107 | void InstallInterfaces(Core::System& system) { |
| 104 | std::make_shared<LM>(system.GetLogManager())->InstallAsService(system.ServiceManager()); | 108 | std::make_shared<LM>(system.GetLogManager(), system.Memory()) |
| 109 | ->InstallAsService(system.ServiceManager()); | ||
| 105 | } | 110 | } |
| 106 | 111 | ||
| 107 | } // namespace Service::LM | 112 | } // namespace Service::LM |