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();
}
if (hle_notifier)
hle_notifier();
}
const std::vector<SharedPtr<Thread>>& WaitObject::GetWaitingThreads() const {
return waiting_threads;
}
void WaitObject::SetHLENotifier(std::function<void()> callback) {
hle_notifier = callback;
}
} // namespace Kernel

View File

@ -4,6 +4,7 @@
#pragma once
#include <functional>
#include <vector>
#include <boost/smart_ptr/intrusive_ptr.hpp>
#include "common/common_types.h"
@ -52,9 +53,15 @@ public:
/// Get a const reference to the waiting threads list for debug use
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:
/// Threads waiting for this object to become available
std::vector<SharedPtr<Thread>> waiting_threads;
/// Function to call when this object becomes available
std::function<void()> hle_notifier;
};
// 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) {
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);
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) {
@ -380,6 +380,9 @@ DSP_DSP::DSP_DSP(Core::System& system)
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() {

View File

@ -257,6 +257,7 @@ private:
Core::System& system;
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_one = nullptr; /// Currently unknown purpose