Service/DSP: implement semaphore event

This commit is contained in:
Weiyi Wang 2018-12-06 10:18:39 -05:00
parent 6f6ffceec4
commit 92e5c51adb
4 changed files with 20 additions and 2 deletions

View file

@ -86,10 +86,17 @@ void WaitObject::WakeupAllWaitingThreads() {
thread->ResumeFromWait(); thread->ResumeFromWait();
} }
if (hle_notifier)
hle_notifier();
} }
const std::vector<SharedPtr<Thread>>& WaitObject::GetWaitingThreads() const { const std::vector<SharedPtr<Thread>>& WaitObject::GetWaitingThreads() const {
return waiting_threads; return waiting_threads;
} }
void WaitObject::SetHLENotifier(std::function<void()> callback) {
hle_notifier = callback;
}
} // namespace Kernel } // namespace Kernel

View file

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <functional>
#include <vector> #include <vector>
#include <boost/smart_ptr/intrusive_ptr.hpp> #include <boost/smart_ptr/intrusive_ptr.hpp>
#include "common/common_types.h" #include "common/common_types.h"
@ -52,9 +53,15 @@ public:
/// Get a const reference to the waiting threads list for debug use /// Get a const reference to the waiting threads list for debug use
const std::vector<SharedPtr<Thread>>& GetWaitingThreads() const; const std::vector<SharedPtr<Thread>>& GetWaitingThreads() const;
/// Sets a callback which is called when the object becomes available
void SetHLENotifier(std::function<void()> callback);
private: private:
/// Threads waiting for this object to become available /// Threads waiting for this object to become available
std::vector<SharedPtr<Thread>> waiting_threads; std::vector<SharedPtr<Thread>> waiting_threads;
/// Function to call when this object becomes available
std::function<void()> hle_notifier;
}; };
// Specialization of DynamicObjectCast for WaitObjects // Specialization of DynamicObjectCast for WaitObjects

View file

@ -268,12 +268,12 @@ void DSP_DSP::GetSemaphoreEventHandle(Kernel::HLERequestContext& ctx) {
void DSP_DSP::SetSemaphoreMask(Kernel::HLERequestContext& ctx) { void DSP_DSP::SetSemaphoreMask(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x17, 1, 0); IPC::RequestParser rp(ctx, 0x17, 1, 0);
const u32 mask = rp.Pop<u32>(); preset_semaphore = rp.Pop<u16>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
LOG_WARNING(Service_DSP, "(STUBBED) called mask=0x{:08X}", mask); LOG_WARNING(Service_DSP, "(STUBBED) called mask=0x{:04X}", preset_semaphore);
} }
void DSP_DSP::GetHeadphoneStatus(Kernel::HLERequestContext& ctx) { void DSP_DSP::GetHeadphoneStatus(Kernel::HLERequestContext& ctx) {
@ -380,6 +380,9 @@ DSP_DSP::DSP_DSP(Core::System& system)
semaphore_event = semaphore_event =
system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "DSP_DSP::semaphore_event"); system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "DSP_DSP::semaphore_event");
semaphore_event->SetHLENotifier(
[this]() { this->system.DSP().SetSemaphore(preset_semaphore); });
} }
DSP_DSP::~DSP_DSP() { DSP_DSP::~DSP_DSP() {

View file

@ -257,6 +257,7 @@ private:
Core::System& system; Core::System& system;
Kernel::SharedPtr<Kernel::Event> semaphore_event; Kernel::SharedPtr<Kernel::Event> semaphore_event;
u16 preset_semaphore = 0;
Kernel::SharedPtr<Kernel::Event> interrupt_zero = nullptr; /// Currently unknown purpose Kernel::SharedPtr<Kernel::Event> interrupt_zero = nullptr; /// Currently unknown purpose
Kernel::SharedPtr<Kernel::Event> interrupt_one = nullptr; /// Currently unknown purpose Kernel::SharedPtr<Kernel::Event> interrupt_one = nullptr; /// Currently unknown purpose