From efdff9ad3ed8856fa492fd08810322030a5e97ee Mon Sep 17 00:00:00 2001 From: mailwl Date: Fri, 22 Apr 2016 21:13:01 +0300 Subject: gsp::Gpu: implement AcquireRight, ReleaseRight functions --- src/core/hle/service/gsp_gpu.cpp | 45 +++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index 211fcf599..9fb4962d8 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp @@ -44,6 +44,8 @@ Kernel::SharedPtr g_shared_memory; /// Thread index into interrupt relay queue u32 g_thread_id = 0; +static bool gpu_right_acquired = false; + /// Gets a pointer to a thread command buffer in GSP shared memory static inline u8* GetCommandBuffer(u32 thread_id) { return g_shared_memory->GetPointer(0x800 + (thread_id * sizeof(CommandBuffer))); @@ -371,14 +373,10 @@ static void UnregisterInterruptRelayQueue(Service::Interface* self) { * @todo This probably does not belong in the GSP module, instead move to video_core */ void SignalInterrupt(InterruptId interrupt_id) { - if (nullptr == g_interrupt_event) { - LOG_WARNING(Service_GSP, "cannot synchronize until GSP event has been created!"); - return; - } - if (nullptr == g_shared_memory) { - LOG_WARNING(Service_GSP, "cannot synchronize until GSP shared memory has been created!"); + if (!gpu_right_acquired) { return; } + for (int thread_id = 0; thread_id < 0x4; ++thread_id) { InterruptRelayQueue* interrupt_relay_queue = GetInterruptRelayQueue(thread_id); u8 next = interrupt_relay_queue->index; @@ -625,6 +623,35 @@ static void ImportDisplayCaptureInfo(Service::Interface* self) { LOG_WARNING(Service_GSP, "called"); } +/** + * GSP_GPU::AcquireRight service function + * Outputs: + * 1: Result code + */ +static void AcquireRight(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + gpu_right_acquired = true; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_GSP, "called"); +} + +/** + * GSP_GPU::ReleaseRight service function + * Outputs: + * 1: Result code + */ +static void ReleaseRight(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + gpu_right_acquired = false; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_GSP, "called"); +} const Interface::FunctionInfo FunctionTable[] = { {0x00010082, WriteHWRegs, "WriteHWRegs"}, @@ -648,8 +675,8 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00130042, RegisterInterruptRelayQueue, "RegisterInterruptRelayQueue"}, {0x00140000, UnregisterInterruptRelayQueue, "UnregisterInterruptRelayQueue"}, {0x00150002, nullptr, "TryAcquireRight"}, - {0x00160042, nullptr, "AcquireRight"}, - {0x00170000, nullptr, "ReleaseRight"}, + {0x00160042, AcquireRight, "AcquireRight"}, + {0x00170000, ReleaseRight, "ReleaseRight"}, {0x00180000, ImportDisplayCaptureInfo, "ImportDisplayCaptureInfo"}, {0x00190000, nullptr, "SaveVramSysArea"}, {0x001A0000, nullptr, "RestoreVramSysArea"}, @@ -670,11 +697,13 @@ Interface::Interface() { g_shared_memory = nullptr; g_thread_id = 0; + gpu_right_acquired = false; } Interface::~Interface() { g_interrupt_event = nullptr; g_shared_memory = nullptr; + gpu_right_acquired = false; } } // namespace -- cgit v1.2.3 From 67c657bf80513c02f4e60e0953c58103e9f80405 Mon Sep 17 00:00:00 2001 From: mailwl Date: Sat, 23 Apr 2016 16:17:03 +0300 Subject: return checks if event and memory created --- src/core/hle/service/gsp_gpu.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index 9fb4962d8..d254fdd2e 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp @@ -376,7 +376,14 @@ void SignalInterrupt(InterruptId interrupt_id) { if (!gpu_right_acquired) { return; } - + if (nullptr == g_interrupt_event) { + LOG_WARNING(Service_GSP, "cannot synchronize until GSP event has been created!"); + return; + } + if (nullptr == g_shared_memory) { + LOG_WARNING(Service_GSP, "cannot synchronize until GSP shared memory has been created!"); + return; + } for (int thread_id = 0; thread_id < 0x4; ++thread_id) { InterruptRelayQueue* interrupt_relay_queue = GetInterruptRelayQueue(thread_id); u8 next = interrupt_relay_queue->index; -- cgit v1.2.3