hle: kernel: Migrate KReadableEvent and KWritableEvent to KAutoObject.
This commit is contained in:
parent
eba3bb9d21
commit
2e8d6fe9a0
@ -54,7 +54,9 @@ ResultVal<Handle> HandleTable::Create(Object* obj) {
|
|||||||
case HandleType::SharedMemory:
|
case HandleType::SharedMemory:
|
||||||
case HandleType::Thread:
|
case HandleType::Thread:
|
||||||
case HandleType::Event:
|
case HandleType::Event:
|
||||||
case HandleType::Process: {
|
case HandleType::Process:
|
||||||
|
case HandleType::ReadableEvent:
|
||||||
|
case HandleType::WritableEvent: {
|
||||||
Handle handle{};
|
Handle handle{};
|
||||||
Add(&handle, reinterpret_cast<KAutoObject*>(obj), {});
|
Add(&handle, reinterpret_cast<KAutoObject*>(obj), {});
|
||||||
return MakeResult<Handle>(handle);
|
return MakeResult<Handle>(handle);
|
||||||
|
@ -3,14 +3,13 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "core/hle/kernel/k_event.h"
|
#include "core/hle/kernel/k_event.h"
|
||||||
#include "core/hle/kernel/k_readable_event.h"
|
|
||||||
#include "core/hle/kernel/k_resource_limit.h"
|
#include "core/hle/kernel/k_resource_limit.h"
|
||||||
#include "core/hle/kernel/k_writable_event.h"
|
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
KEvent::KEvent(KernelCore& kernel) : KAutoObjectWithSlabHeapAndContainer{kernel} {}
|
KEvent::KEvent(KernelCore& kernel)
|
||||||
|
: KAutoObjectWithSlabHeapAndContainer{kernel}, readable_event{kernel}, writable_event{kernel} {}
|
||||||
|
|
||||||
KEvent::~KEvent() = default;
|
KEvent::~KEvent() = default;
|
||||||
|
|
||||||
@ -21,17 +20,13 @@ void KEvent::Initialize(std::string&& name_) {
|
|||||||
// writable events are closed this object will be destroyed.
|
// writable events are closed this object will be destroyed.
|
||||||
Open();
|
Open();
|
||||||
|
|
||||||
//// Create our sub events.
|
|
||||||
//KAutoObject::Create(readable_event.get());
|
|
||||||
//KAutoObject::Create(writable_event.get());
|
|
||||||
|
|
||||||
// Create our sub events.
|
// Create our sub events.
|
||||||
readable_event = std::make_shared<KReadableEvent>(kernel, name_ + ":Readable");
|
KAutoObject::Create(std::addressof(readable_event));
|
||||||
writable_event = std::make_shared<KWritableEvent>(kernel, name_ + ":Writable");
|
KAutoObject::Create(std::addressof(writable_event));
|
||||||
|
|
||||||
// Initialize our sub sessions.
|
// Initialize our sub sessions.
|
||||||
readable_event->Initialize(this);
|
readable_event.Initialize(this, name_ + ":Readable");
|
||||||
writable_event->Initialize(this);
|
writable_event.Initialize(this, name_ + ":Writable");
|
||||||
|
|
||||||
// Set our owner process.
|
// Set our owner process.
|
||||||
owner = kernel.CurrentProcess();
|
owner = kernel.CurrentProcess();
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/kernel/k_readable_event.h"
|
||||||
|
#include "core/hle/kernel/k_writable_event.h"
|
||||||
#include "core/hle/kernel/slab_helpers.h"
|
#include "core/hle/kernel/slab_helpers.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
@ -27,12 +29,27 @@ public:
|
|||||||
virtual bool IsInitialized() const override {
|
virtual bool IsInitialized() const override {
|
||||||
return initialized;
|
return initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual uintptr_t GetPostDestroyArgument() const override {
|
virtual uintptr_t GetPostDestroyArgument() const override {
|
||||||
return reinterpret_cast<uintptr_t>(owner);
|
return reinterpret_cast<uintptr_t>(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PostDestroy(uintptr_t arg);
|
static void PostDestroy(uintptr_t arg);
|
||||||
|
|
||||||
|
virtual Process* GetOwner() const override {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
KReadableEvent& GetReadableEvent() {
|
||||||
|
return readable_event;
|
||||||
|
}
|
||||||
|
|
||||||
|
KWritableEvent& GetWritableEvent() {
|
||||||
|
return writable_event;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEPRECATED
|
||||||
|
|
||||||
std::string GetTypeName() const override {
|
std::string GetTypeName() const override {
|
||||||
return "KEvent";
|
return "KEvent";
|
||||||
}
|
}
|
||||||
@ -42,25 +59,9 @@ public:
|
|||||||
return HANDLE_TYPE;
|
return HANDLE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
KReadableEvent* GetReadableEvent() {
|
|
||||||
return readable_event.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<KWritableEvent>& GetWritableEvent() {
|
|
||||||
return writable_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::shared_ptr<KReadableEvent>& GetReadableEvent() const {
|
|
||||||
return readable_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::shared_ptr<KWritableEvent>& GetWritableEvent() const {
|
|
||||||
return writable_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<KReadableEvent> readable_event;
|
KReadableEvent readable_event;
|
||||||
std::shared_ptr<KWritableEvent> writable_event;
|
KWritableEvent writable_event;
|
||||||
Process* owner{};
|
Process* owner{};
|
||||||
bool initialized{};
|
bool initialized{};
|
||||||
};
|
};
|
||||||
|
@ -2,21 +2,18 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/common_funcs.h"
|
#include "core/hle/kernel/k_event.h"
|
||||||
#include "common/logging/log.h"
|
|
||||||
#include "core/hle/kernel/k_readable_event.h"
|
#include "core/hle/kernel/k_readable_event.h"
|
||||||
#include "core/hle/kernel/k_scheduler.h"
|
#include "core/hle/kernel/k_scheduler.h"
|
||||||
#include "core/hle/kernel/k_thread.h"
|
#include "core/hle/kernel/k_thread.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/object.h"
|
|
||||||
#include "core/hle/kernel/svc_results.h"
|
#include "core/hle/kernel/svc_results.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
KReadableEvent::KReadableEvent(KernelCore& kernel, std::string&& name)
|
KReadableEvent::KReadableEvent(KernelCore& kernel) : KSynchronizationObject{kernel} {}
|
||||||
: KSynchronizationObject{kernel, std::move(name)} {}
|
|
||||||
KReadableEvent::~KReadableEvent() = default;
|
KReadableEvent::~KReadableEvent() = default;
|
||||||
|
|
||||||
bool KReadableEvent::IsSignaled() const {
|
bool KReadableEvent::IsSignaled() const {
|
||||||
@ -25,6 +22,12 @@ bool KReadableEvent::IsSignaled() const {
|
|||||||
return is_signaled;
|
return is_signaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KReadableEvent::Destroy() {
|
||||||
|
if (parent) {
|
||||||
|
parent->Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ResultCode KReadableEvent::Signal() {
|
ResultCode KReadableEvent::Signal() {
|
||||||
KScopedSchedulerLock lk{kernel};
|
KScopedSchedulerLock lk{kernel};
|
||||||
|
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/kernel/k_auto_object.h"
|
||||||
#include "core/hle/kernel/k_synchronization_object.h"
|
#include "core/hle/kernel/k_synchronization_object.h"
|
||||||
#include "core/hle/kernel/object.h"
|
#include "core/hle/kernel/object.h"
|
||||||
|
#include "core/hle/kernel/slab_helpers.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
@ -13,11 +15,32 @@ namespace Kernel {
|
|||||||
class KernelCore;
|
class KernelCore;
|
||||||
class KEvent;
|
class KEvent;
|
||||||
|
|
||||||
class KReadableEvent final : public KSynchronizationObject {
|
class KReadableEvent : public KSynchronizationObject {
|
||||||
|
KERNEL_AUTOOBJECT_TRAITS(KReadableEvent, KSynchronizationObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit KReadableEvent(KernelCore& kernel, std::string&& name);
|
explicit KReadableEvent(KernelCore& kernel);
|
||||||
~KReadableEvent() override;
|
~KReadableEvent() override;
|
||||||
|
|
||||||
|
void Initialize(KEvent* parent_, std::string&& name_) {
|
||||||
|
is_signaled = false;
|
||||||
|
parent = parent_;
|
||||||
|
name = std::move(name_);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr KEvent* GetParent() const {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool IsSignaled() const override;
|
||||||
|
virtual void Destroy() override;
|
||||||
|
|
||||||
|
ResultCode Signal();
|
||||||
|
ResultCode Clear();
|
||||||
|
ResultCode Reset();
|
||||||
|
|
||||||
|
// DEPRECATED
|
||||||
|
|
||||||
std::string GetTypeName() const override {
|
std::string GetTypeName() const override {
|
||||||
return "KReadableEvent";
|
return "KReadableEvent";
|
||||||
}
|
}
|
||||||
@ -27,22 +50,6 @@ public:
|
|||||||
return HANDLE_TYPE;
|
return HANDLE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
KEvent* GetParent() const {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Initialize(KEvent* parent_) {
|
|
||||||
is_signaled = false;
|
|
||||||
parent = parent_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsSignaled() const override;
|
|
||||||
void Finalize() override {}
|
|
||||||
|
|
||||||
ResultCode Signal();
|
|
||||||
ResultCode Clear();
|
|
||||||
ResultCode Reset();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool is_signaled{};
|
bool is_signaled{};
|
||||||
KEvent* parent{};
|
KEvent* parent{};
|
||||||
|
@ -8,20 +8,28 @@
|
|||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
KWritableEvent::KWritableEvent(KernelCore& kernel, std::string&& name)
|
KWritableEvent::KWritableEvent(KernelCore& kernel) : KAutoObjectWithSlabHeapAndContainer{kernel} {}
|
||||||
: Object{kernel, std::move(name)} {}
|
|
||||||
KWritableEvent::~KWritableEvent() = default;
|
KWritableEvent::~KWritableEvent() = default;
|
||||||
|
|
||||||
void KWritableEvent::Initialize(KEvent* parent_) {
|
void KWritableEvent::Initialize(KEvent* parent_, std::string&& name_) {
|
||||||
parent = parent_;
|
parent = parent_;
|
||||||
|
name = std::move(name_);
|
||||||
|
parent->GetReadableEvent().Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode KWritableEvent::Signal() {
|
ResultCode KWritableEvent::Signal() {
|
||||||
return parent->GetReadableEvent()->Signal();
|
return parent->GetReadableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode KWritableEvent::Clear() {
|
ResultCode KWritableEvent::Clear() {
|
||||||
return parent->GetReadableEvent()->Clear();
|
return parent->GetReadableEvent().Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KWritableEvent::Destroy() {
|
||||||
|
// Close our references.
|
||||||
|
parent->GetReadableEvent().Close();
|
||||||
|
parent->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/kernel/k_auto_object.h"
|
||||||
#include "core/hle/kernel/object.h"
|
#include "core/hle/kernel/object.h"
|
||||||
|
#include "core/hle/kernel/slab_helpers.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
@ -12,11 +14,28 @@ namespace Kernel {
|
|||||||
class KernelCore;
|
class KernelCore;
|
||||||
class KEvent;
|
class KEvent;
|
||||||
|
|
||||||
class KWritableEvent final : public Object {
|
class KWritableEvent final
|
||||||
|
: public KAutoObjectWithSlabHeapAndContainer<KWritableEvent, KAutoObjectWithList> {
|
||||||
|
KERNEL_AUTOOBJECT_TRAITS(KWritableEvent, KAutoObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit KWritableEvent(KernelCore& kernel, std::string&& name);
|
explicit KWritableEvent(KernelCore& kernel);
|
||||||
~KWritableEvent() override;
|
~KWritableEvent() override;
|
||||||
|
|
||||||
|
virtual void Destroy() override;
|
||||||
|
|
||||||
|
static void PostDestroy([[maybe_unused]] uintptr_t arg) {}
|
||||||
|
|
||||||
|
void Initialize(KEvent* parent_, std::string&& name_);
|
||||||
|
ResultCode Signal();
|
||||||
|
ResultCode Clear();
|
||||||
|
|
||||||
|
constexpr KEvent* GetParent() const {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEPRECATED
|
||||||
|
|
||||||
std::string GetTypeName() const override {
|
std::string GetTypeName() const override {
|
||||||
return "KWritableEvent";
|
return "KWritableEvent";
|
||||||
}
|
}
|
||||||
@ -26,17 +45,6 @@ public:
|
|||||||
return HANDLE_TYPE;
|
return HANDLE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(KEvent* parent_);
|
|
||||||
|
|
||||||
void Finalize() override {}
|
|
||||||
|
|
||||||
ResultCode Signal();
|
|
||||||
ResultCode Clear();
|
|
||||||
|
|
||||||
KEvent* GetParent() const {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KEvent* parent{};
|
KEvent* parent{};
|
||||||
};
|
};
|
||||||
|
@ -40,6 +40,7 @@ class KResourceLimit;
|
|||||||
class KScheduler;
|
class KScheduler;
|
||||||
class KSharedMemory;
|
class KSharedMemory;
|
||||||
class KThread;
|
class KThread;
|
||||||
|
class KWritableEvent;
|
||||||
class PhysicalCore;
|
class PhysicalCore;
|
||||||
class Process;
|
class Process;
|
||||||
class ServiceThread;
|
class ServiceThread;
|
||||||
@ -269,6 +270,8 @@ public:
|
|||||||
return slab_heap_container->shared_memory;
|
return slab_heap_container->shared_memory;
|
||||||
} else if constexpr (std::is_same_v<T, KLinkedListNode>) {
|
} else if constexpr (std::is_same_v<T, KLinkedListNode>) {
|
||||||
return slab_heap_container->linked_list_node;
|
return slab_heap_container->linked_list_node;
|
||||||
|
} else if constexpr (std::is_same_v<T, KWritableEvent>) {
|
||||||
|
return slab_heap_container->writeable_event;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,6 +311,7 @@ private:
|
|||||||
KSlabHeap<KEvent> event;
|
KSlabHeap<KEvent> event;
|
||||||
KSlabHeap<KSharedMemory> shared_memory;
|
KSlabHeap<KSharedMemory> shared_memory;
|
||||||
KSlabHeap<KLinkedListNode> linked_list_node;
|
KSlabHeap<KLinkedListNode> linked_list_node;
|
||||||
|
KSlabHeap<KWritableEvent> writeable_event;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<SlabHeapContainer> slab_heap_container;
|
std::unique_ptr<SlabHeapContainer> slab_heap_container;
|
||||||
|
@ -1745,16 +1745,16 @@ static ResultCode ResetSignal(Core::System& system, Handle handle) {
|
|||||||
|
|
||||||
// Try to reset as readable event.
|
// Try to reset as readable event.
|
||||||
{
|
{
|
||||||
auto readable_event = handle_table.Get<KReadableEvent>(handle);
|
KScopedAutoObject readable_event = handle_table.GetObject<KReadableEvent>(handle);
|
||||||
if (readable_event) {
|
if (readable_event.IsNotNull()) {
|
||||||
return readable_event->Reset();
|
return readable_event->Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to reset as process.
|
// Try to reset as process.
|
||||||
{
|
{
|
||||||
auto process = handle_table.Get<Process>(handle);
|
KScopedAutoObject process = handle_table.GetObject<Process>(handle);
|
||||||
if (process) {
|
if (process.IsNotNull()) {
|
||||||
return process->Reset();
|
return process->Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1885,27 +1885,12 @@ static ResultCode SetThreadCoreMask32(Core::System& system, Handle thread_handle
|
|||||||
static ResultCode SignalEvent(Core::System& system, Handle event_handle) {
|
static ResultCode SignalEvent(Core::System& system, Handle event_handle) {
|
||||||
LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
|
LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
|
||||||
|
|
||||||
auto& kernel = system.Kernel();
|
|
||||||
// Get the current handle table.
|
// Get the current handle table.
|
||||||
const HandleTable& handle_table = kernel.CurrentProcess()->GetHandleTable();
|
const HandleTable& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
|
||||||
|
|
||||||
// Reserve a new event from the process resource limit.
|
|
||||||
KScopedResourceReservation event_reservation(kernel.CurrentProcess(),
|
|
||||||
LimitableResource::Events);
|
|
||||||
if (!event_reservation.Succeeded()) {
|
|
||||||
LOG_ERROR(Kernel, "Could not reserve a new event");
|
|
||||||
return ResultResourceLimitedExceeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the writable event.
|
// Get the writable event.
|
||||||
auto writable_event = handle_table.Get<KWritableEvent>(event_handle);
|
KScopedAutoObject writable_event = handle_table.GetObject<KWritableEvent>(event_handle);
|
||||||
if (!writable_event) {
|
R_UNLESS(writable_event.IsNotNull(), ResultInvalidHandle);
|
||||||
LOG_ERROR(Kernel_SVC, "Invalid event handle provided (handle={:08X})", event_handle);
|
|
||||||
return ResultInvalidHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commit the successfuly reservation.
|
|
||||||
event_reservation.Commit();
|
|
||||||
|
|
||||||
return writable_event->Signal();
|
return writable_event->Signal();
|
||||||
}
|
}
|
||||||
@ -1922,16 +1907,16 @@ static ResultCode ClearEvent(Core::System& system, Handle event_handle) {
|
|||||||
|
|
||||||
// Try to clear the writable event.
|
// Try to clear the writable event.
|
||||||
{
|
{
|
||||||
auto writable_event = handle_table.Get<KWritableEvent>(event_handle);
|
KScopedAutoObject writable_event = handle_table.GetObject<KWritableEvent>(event_handle);
|
||||||
if (writable_event) {
|
if (writable_event.IsNotNull()) {
|
||||||
return writable_event->Clear();
|
return writable_event->Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to clear the readable event.
|
// Try to clear the readable event.
|
||||||
{
|
{
|
||||||
auto readable_event = handle_table.Get<KReadableEvent>(event_handle);
|
KScopedAutoObject readable_event = handle_table.GetObject<KReadableEvent>(event_handle);
|
||||||
if (readable_event) {
|
if (readable_event.IsNotNull()) {
|
||||||
return readable_event->Clear();
|
return readable_event->Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1950,7 +1935,12 @@ static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* o
|
|||||||
|
|
||||||
// Get the kernel reference and handle table.
|
// Get the kernel reference and handle table.
|
||||||
auto& kernel = system.Kernel();
|
auto& kernel = system.Kernel();
|
||||||
HandleTable& handle_table = kernel.CurrentProcess()->GetHandleTable();
|
auto& handle_table = kernel.CurrentProcess()->GetHandleTable();
|
||||||
|
|
||||||
|
// Reserve a new event from the process resource limit
|
||||||
|
KScopedResourceReservation event_reservation(kernel.CurrentProcess(),
|
||||||
|
LimitableResource::Events);
|
||||||
|
R_UNLESS(event_reservation.Succeeded(), ResultResourceLimitedExceeded);
|
||||||
|
|
||||||
// Create a new event.
|
// Create a new event.
|
||||||
KEvent* event = KEvent::Create(kernel);
|
KEvent* event = KEvent::Create(kernel);
|
||||||
@ -1959,22 +1949,26 @@ static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* o
|
|||||||
// Initialize the event.
|
// Initialize the event.
|
||||||
event->Initialize("CreateEvent");
|
event->Initialize("CreateEvent");
|
||||||
|
|
||||||
// Add the writable event to the handle table.
|
// Commit the thread reservation.
|
||||||
const auto write_create_result = handle_table.Create(event->GetWritableEvent().get());
|
event_reservation.Commit();
|
||||||
if (write_create_result.Failed()) {
|
|
||||||
return write_create_result.Code();
|
// Ensure that we clean up the event (and its only references are handle table) on function end.
|
||||||
}
|
SCOPE_EXIT({
|
||||||
*out_write = *write_create_result;
|
event->GetWritableEvent().Close();
|
||||||
|
event->GetReadableEvent().Close();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Register the event.
|
||||||
|
KEvent::Register(kernel, event);
|
||||||
|
|
||||||
// Add the writable event to the handle table.
|
// Add the writable event to the handle table.
|
||||||
auto handle_guard = SCOPE_GUARD({ handle_table.Remove(*write_create_result); });
|
R_TRY(handle_table.Add(out_write, std::addressof(event->GetWritableEvent())));
|
||||||
|
|
||||||
|
// Add the writable event to the handle table.
|
||||||
|
auto handle_guard = SCOPE_GUARD({ handle_table.Remove(*out_write); });
|
||||||
|
|
||||||
// Add the readable event to the handle table.
|
// Add the readable event to the handle table.
|
||||||
const auto read_create_result = handle_table.Create(event->GetReadableEvent());
|
R_TRY(handle_table.Add(out_read, std::addressof(event->GetReadableEvent())));
|
||||||
if (read_create_result.Failed()) {
|
|
||||||
return read_create_result.Code();
|
|
||||||
}
|
|
||||||
*out_read = *read_create_result;
|
|
||||||
|
|
||||||
// We succeeded.
|
// We succeeded.
|
||||||
handle_guard.Cancel();
|
handle_guard.Cancel();
|
||||||
|
@ -320,7 +320,7 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv
|
|||||||
Kernel::KAutoObject::Create(std::addressof(accumulated_suspended_tick_changed_event));
|
Kernel::KAutoObject::Create(std::addressof(accumulated_suspended_tick_changed_event));
|
||||||
accumulated_suspended_tick_changed_event.Initialize(
|
accumulated_suspended_tick_changed_event.Initialize(
|
||||||
"ISelfController:AccumulatedSuspendedTickChangedEvent");
|
"ISelfController:AccumulatedSuspendedTickChangedEvent");
|
||||||
accumulated_suspended_tick_changed_event.GetWritableEvent()->Signal();
|
accumulated_suspended_tick_changed_event.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
ISelfController::~ISelfController() = default;
|
ISelfController::~ISelfController() = default;
|
||||||
@ -379,7 +379,7 @@ void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) {
|
|||||||
void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
|
void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||||
|
|
||||||
launchable_event.GetWritableEvent()->Signal();
|
launchable_event.GetWritableEvent().Signal();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
@ -592,28 +592,28 @@ AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel)
|
|||||||
|
|
||||||
AppletMessageQueue::~AppletMessageQueue() = default;
|
AppletMessageQueue::~AppletMessageQueue() = default;
|
||||||
|
|
||||||
Kernel::KReadableEvent* AppletMessageQueue::GetMessageReceiveEvent() const {
|
Kernel::KReadableEvent& AppletMessageQueue::GetMessageReceiveEvent() {
|
||||||
return on_new_message.GetReadableEvent().get();
|
return on_new_message.GetReadableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel::KReadableEvent* AppletMessageQueue::GetOperationModeChangedEvent() const {
|
Kernel::KReadableEvent& AppletMessageQueue::GetOperationModeChangedEvent() {
|
||||||
return on_operation_mode_changed.GetReadableEvent().get();
|
return on_operation_mode_changed.GetReadableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletMessageQueue::PushMessage(AppletMessage msg) {
|
void AppletMessageQueue::PushMessage(AppletMessage msg) {
|
||||||
messages.push(msg);
|
messages.push(msg);
|
||||||
on_new_message.GetWritableEvent()->Signal();
|
on_new_message.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() {
|
AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() {
|
||||||
if (messages.empty()) {
|
if (messages.empty()) {
|
||||||
on_new_message.GetWritableEvent()->Clear();
|
on_new_message.GetWritableEvent().Clear();
|
||||||
return AppletMessage::NoMessage;
|
return AppletMessage::NoMessage;
|
||||||
}
|
}
|
||||||
auto msg = messages.front();
|
auto msg = messages.front();
|
||||||
messages.pop();
|
messages.pop();
|
||||||
if (messages.empty()) {
|
if (messages.empty()) {
|
||||||
on_new_message.GetWritableEvent()->Clear();
|
on_new_message.GetWritableEvent().Clear();
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
@ -633,7 +633,7 @@ void AppletMessageQueue::FocusStateChanged() {
|
|||||||
void AppletMessageQueue::OperationModeChanged() {
|
void AppletMessageQueue::OperationModeChanged() {
|
||||||
PushMessage(AppletMessage::OperationModeChanged);
|
PushMessage(AppletMessage::OperationModeChanged);
|
||||||
PushMessage(AppletMessage::PerformanceModeChanged);
|
PushMessage(AppletMessage::PerformanceModeChanged);
|
||||||
on_operation_mode_changed.GetWritableEvent()->Signal();
|
on_operation_mode_changed.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
ICommonStateGetter::ICommonStateGetter(Core::System& system_,
|
ICommonStateGetter::ICommonStateGetter(Core::System& system_,
|
||||||
@ -930,11 +930,9 @@ private:
|
|||||||
void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) {
|
void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_AM, "called");
|
LOG_DEBUG(Service_AM, "called");
|
||||||
|
|
||||||
const auto event = applet->GetBroker().GetStateChangedEvent();
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushCopyObjects(event);
|
rb.PushCopyObjects(applet->GetBroker().GetStateChangedEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IsCompleted(Kernel::HLERequestContext& ctx) {
|
void IsCompleted(Kernel::HLERequestContext& ctx) {
|
||||||
|
@ -56,8 +56,8 @@ public:
|
|||||||
explicit AppletMessageQueue(Kernel::KernelCore& kernel);
|
explicit AppletMessageQueue(Kernel::KernelCore& kernel);
|
||||||
~AppletMessageQueue();
|
~AppletMessageQueue();
|
||||||
|
|
||||||
Kernel::KReadableEvent* GetMessageReceiveEvent() const;
|
Kernel::KReadableEvent& GetMessageReceiveEvent();
|
||||||
Kernel::KReadableEvent* GetOperationModeChangedEvent() const;
|
Kernel::KReadableEvent& GetOperationModeChangedEvent();
|
||||||
void PushMessage(AppletMessage msg);
|
void PushMessage(AppletMessage msg);
|
||||||
AppletMessage PopMessage();
|
AppletMessage PopMessage();
|
||||||
std::size_t GetMessageCount() const;
|
std::size_t GetMessageCount() const;
|
||||||
|
@ -66,7 +66,7 @@ std::shared_ptr<IStorage> AppletDataBroker::PopNormalDataToGame() {
|
|||||||
|
|
||||||
auto out = std::move(out_channel.front());
|
auto out = std::move(out_channel.front());
|
||||||
out_channel.pop_front();
|
out_channel.pop_front();
|
||||||
pop_out_data_event.GetWritableEvent()->Clear();
|
pop_out_data_event.GetWritableEvent().Clear();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ std::shared_ptr<IStorage> AppletDataBroker::PopInteractiveDataToGame() {
|
|||||||
|
|
||||||
auto out = std::move(out_interactive_channel.front());
|
auto out = std::move(out_interactive_channel.front());
|
||||||
out_interactive_channel.pop_front();
|
out_interactive_channel.pop_front();
|
||||||
pop_interactive_out_data_event.GetWritableEvent()->Clear();
|
pop_interactive_out_data_event.GetWritableEvent().Clear();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ void AppletDataBroker::PushNormalDataFromGame(std::shared_ptr<IStorage>&& storag
|
|||||||
|
|
||||||
void AppletDataBroker::PushNormalDataFromApplet(std::shared_ptr<IStorage>&& storage) {
|
void AppletDataBroker::PushNormalDataFromApplet(std::shared_ptr<IStorage>&& storage) {
|
||||||
out_channel.emplace_back(std::move(storage));
|
out_channel.emplace_back(std::move(storage));
|
||||||
pop_out_data_event.GetWritableEvent()->Signal();
|
pop_out_data_event.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage) {
|
void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage) {
|
||||||
@ -113,11 +113,11 @@ void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& s
|
|||||||
|
|
||||||
void AppletDataBroker::PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage) {
|
void AppletDataBroker::PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage) {
|
||||||
out_interactive_channel.emplace_back(std::move(storage));
|
out_interactive_channel.emplace_back(std::move(storage));
|
||||||
pop_interactive_out_data_event.GetWritableEvent()->Signal();
|
pop_interactive_out_data_event.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletDataBroker::SignalStateChanged() {
|
void AppletDataBroker::SignalStateChanged() {
|
||||||
state_changed_event.GetWritableEvent()->Signal();
|
state_changed_event.GetWritableEvent().Signal();
|
||||||
|
|
||||||
switch (applet_mode) {
|
switch (applet_mode) {
|
||||||
case LibraryAppletMode::AllForeground:
|
case LibraryAppletMode::AllForeground:
|
||||||
@ -141,16 +141,16 @@ void AppletDataBroker::SignalStateChanged() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel::KReadableEvent* AppletDataBroker::GetNormalDataEvent() const {
|
Kernel::KReadableEvent& AppletDataBroker::GetNormalDataEvent() {
|
||||||
return pop_out_data_event.GetReadableEvent().get();
|
return pop_out_data_event.GetReadableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel::KReadableEvent* AppletDataBroker::GetInteractiveDataEvent() const {
|
Kernel::KReadableEvent& AppletDataBroker::GetInteractiveDataEvent() {
|
||||||
return pop_interactive_out_data_event.GetReadableEvent().get();
|
return pop_interactive_out_data_event.GetReadableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel::KReadableEvent* AppletDataBroker::GetStateChangedEvent() const {
|
Kernel::KReadableEvent& AppletDataBroker::GetStateChangedEvent() {
|
||||||
return state_changed_event.GetReadableEvent().get();
|
return state_changed_event.GetReadableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
Applet::Applet(Core::System& system_, LibraryAppletMode applet_mode_)
|
Applet::Applet(Core::System& system_, LibraryAppletMode applet_mode_)
|
||||||
|
@ -96,11 +96,11 @@ public:
|
|||||||
void PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage);
|
void PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage);
|
||||||
void PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage);
|
void PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage);
|
||||||
|
|
||||||
void SignalStateChanged() const;
|
void SignalStateChanged();
|
||||||
|
|
||||||
Kernel::KReadableEvent* GetNormalDataEvent() const;
|
Kernel::KReadableEvent& GetNormalDataEvent();
|
||||||
Kernel::KReadableEvent* GetInteractiveDataEvent() const;
|
Kernel::KReadableEvent& GetInteractiveDataEvent();
|
||||||
Kernel::KReadableEvent* GetStateChangedEvent() const;
|
Kernel::KReadableEvent& GetStateChangedEvent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate,
|
stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate,
|
||||||
audio_params.channel_count, std::move(unique_name), [this] {
|
audio_params.channel_count, std::move(unique_name), [this] {
|
||||||
const auto guard = LockService();
|
const auto guard = LockService();
|
||||||
buffer_event.GetWritableEvent()->Signal();
|
buffer_event.GetWritableEvent().Signal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
system.CoreTiming(), system.Memory(), audren_params,
|
system.CoreTiming(), system.Memory(), audren_params,
|
||||||
[this]() {
|
[this]() {
|
||||||
const auto guard = LockService();
|
const auto guard = LockService();
|
||||||
system_event.GetWritableEvent()->Signal();
|
system_event.GetWritableEvent().Signal();
|
||||||
},
|
},
|
||||||
instance_number);
|
instance_number);
|
||||||
}
|
}
|
||||||
@ -289,7 +289,7 @@ private:
|
|||||||
void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) {
|
void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
||||||
|
|
||||||
buffer_event.GetWritableEvent()->Signal();
|
buffer_event.GetWritableEvent().Signal();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
@ -19,7 +19,7 @@ ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel,
|
|||||||
update_event.Initialize("ProgressServiceBackend:UpdateEvent:" + std::string(event_name));
|
update_event.Initialize("ProgressServiceBackend:UpdateEvent:" + std::string(event_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KReadableEvent> ProgressServiceBackend::GetEvent() const {
|
Kernel::KReadableEvent& ProgressServiceBackend::GetEvent() {
|
||||||
return update_event.GetReadableEvent();
|
return update_event.GetReadableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,12 +85,12 @@ void ProgressServiceBackend::FinishDownload(ResultCode result) {
|
|||||||
SignalUpdate();
|
SignalUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgressServiceBackend::SignalUpdate() const {
|
void ProgressServiceBackend::SignalUpdate() {
|
||||||
if (need_hle_lock) {
|
if (need_hle_lock) {
|
||||||
std::lock_guard lock(HLE::g_hle_lock);
|
std::lock_guard lock(HLE::g_hle_lock);
|
||||||
update_event.GetWritableEvent()->Signal();
|
update_event.GetWritableEvent().Signal();
|
||||||
} else {
|
} else {
|
||||||
update_event.GetWritableEvent()->Signal();
|
update_event.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,10 +99,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
explicit ProgressServiceBackend(Kernel::KernelCore& kernel, std::string_view event_name);
|
explicit ProgressServiceBackend(Kernel::KernelCore& kernel, std::string_view event_name);
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KReadableEvent> GetEvent() const;
|
Kernel::KReadableEvent& GetEvent();
|
||||||
DeliveryCacheProgressImpl& GetImpl();
|
DeliveryCacheProgressImpl& GetImpl();
|
||||||
|
|
||||||
void SignalUpdate() const;
|
void SignalUpdate();
|
||||||
|
|
||||||
DeliveryCacheProgressImpl impl{};
|
DeliveryCacheProgressImpl impl{};
|
||||||
Kernel::KEvent update_event;
|
Kernel::KEvent update_event;
|
||||||
|
@ -88,11 +88,9 @@ struct DeliveryCacheDirectoryEntry {
|
|||||||
|
|
||||||
class IDeliveryCacheProgressService final : public ServiceFramework<IDeliveryCacheProgressService> {
|
class IDeliveryCacheProgressService final : public ServiceFramework<IDeliveryCacheProgressService> {
|
||||||
public:
|
public:
|
||||||
explicit IDeliveryCacheProgressService(Core::System& system_,
|
explicit IDeliveryCacheProgressService(Core::System& system_, Kernel::KReadableEvent& event_,
|
||||||
std::shared_ptr<Kernel::KReadableEvent> event_,
|
|
||||||
const DeliveryCacheProgressImpl& impl_)
|
const DeliveryCacheProgressImpl& impl_)
|
||||||
: ServiceFramework{system_, "IDeliveryCacheProgressService"}, event{std::move(event_)},
|
: ServiceFramework{system_, "IDeliveryCacheProgressService"}, event{event_}, impl{impl_} {
|
||||||
impl{impl_} {
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IDeliveryCacheProgressService::GetEvent, "GetEvent"},
|
{0, &IDeliveryCacheProgressService::GetEvent, "GetEvent"},
|
||||||
@ -109,7 +107,7 @@ private:
|
|||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushCopyObjects(event.get());
|
rb.PushCopyObjects(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetImpl(Kernel::HLERequestContext& ctx) {
|
void GetImpl(Kernel::HLERequestContext& ctx) {
|
||||||
@ -121,7 +119,7 @@ private:
|
|||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KReadableEvent> event;
|
Kernel::KReadableEvent& event;
|
||||||
const DeliveryCacheProgressImpl& impl;
|
const DeliveryCacheProgressImpl& impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
|
|||||||
const auto controller_type = connected_controllers[controller_idx].type;
|
const auto controller_type = connected_controllers[controller_idx].type;
|
||||||
auto& controller = shared_memory_entries[controller_idx];
|
auto& controller = shared_memory_entries[controller_idx];
|
||||||
if (controller_type == NPadControllerType::None) {
|
if (controller_type == NPadControllerType::None) {
|
||||||
styleset_changed_events[controller_idx]->GetWritableEvent()->Signal();
|
styleset_changed_events[controller_idx]->GetWritableEvent().Signal();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
controller.style_set.raw = 0; // Zero out
|
controller.style_set.raw = 0; // Zero out
|
||||||
@ -959,13 +959,12 @@ bool Controller_NPad::IsVibrationDeviceMounted(const DeviceHandle& vibration_dev
|
|||||||
return vibration_devices_mounted[npad_index][device_index];
|
return vibration_devices_mounted[npad_index][device_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel::KReadableEvent* Controller_NPad::GetStyleSetChangedEvent(u32 npad_id) const {
|
Kernel::KReadableEvent& Controller_NPad::GetStyleSetChangedEvent(u32 npad_id) {
|
||||||
const auto& styleset_event = styleset_changed_events[NPadIdToIndex(npad_id)];
|
return styleset_changed_events[NPadIdToIndex(npad_id)]->GetReadableEvent();
|
||||||
return styleset_event->GetReadableEvent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::SignalStyleSetChangedEvent(u32 npad_id) const {
|
void Controller_NPad::SignalStyleSetChangedEvent(u32 npad_id) const {
|
||||||
styleset_changed_events[NPadIdToIndex(npad_id)]->GetWritableEvent()->Signal();
|
styleset_changed_events[NPadIdToIndex(npad_id)]->GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::AddNewControllerAt(NPadControllerType controller, std::size_t npad_index) {
|
void Controller_NPad::AddNewControllerAt(NPadControllerType controller, std::size_t npad_index) {
|
||||||
|
@ -199,7 +199,7 @@ public:
|
|||||||
|
|
||||||
bool IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const;
|
bool IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const;
|
||||||
|
|
||||||
Kernel::KReadableEvent* GetStyleSetChangedEvent(u32 npad_id) const;
|
Kernel::KReadableEvent& GetStyleSetChangedEvent(u32 npad_id);
|
||||||
void SignalStyleSetChangedEvent(u32 npad_id) const;
|
void SignalStyleSetChangedEvent(u32 npad_id) const;
|
||||||
|
|
||||||
// Adds a new controller at an index.
|
// Adds a new controller at an index.
|
||||||
|
@ -175,7 +175,7 @@ private:
|
|||||||
switch (device_state) {
|
switch (device_state) {
|
||||||
case DeviceState::TagFound:
|
case DeviceState::TagFound:
|
||||||
case DeviceState::TagNearby:
|
case DeviceState::TagNearby:
|
||||||
deactivate_event.GetWritableEvent()->Signal();
|
deactivate_event.GetWritableEvent().Signal();
|
||||||
device_state = DeviceState::Initialized;
|
device_state = DeviceState::Initialized;
|
||||||
break;
|
break;
|
||||||
case DeviceState::SearchingForTag:
|
case DeviceState::SearchingForTag:
|
||||||
@ -318,7 +318,7 @@ private:
|
|||||||
const u32 npad_id{0}; // Player 1 controller
|
const u32 npad_id{0}; // Player 1 controller
|
||||||
State state{State::NonInitialized};
|
State state{State::NonInitialized};
|
||||||
DeviceState device_state{DeviceState::Initialized};
|
DeviceState device_state{DeviceState::Initialized};
|
||||||
const Module::Interface& nfp_interface;
|
Module::Interface& nfp_interface;
|
||||||
Kernel::KEvent deactivate_event;
|
Kernel::KEvent deactivate_event;
|
||||||
Kernel::KEvent availability_change_event;
|
Kernel::KEvent availability_change_event;
|
||||||
};
|
};
|
||||||
@ -338,12 +338,12 @@ bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::memcpy(&amiibo, buffer.data(), sizeof(amiibo));
|
std::memcpy(&amiibo, buffer.data(), sizeof(amiibo));
|
||||||
nfc_tag_load.GetWritableEvent()->Signal();
|
nfc_tag_load.GetWritableEvent().Signal();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel::KReadableEvent* Module::Interface::GetNFCEvent() const {
|
Kernel::KReadableEvent& Module::Interface::GetNFCEvent() {
|
||||||
return nfc_tag_load.GetReadableEvent().get();
|
return nfc_tag_load.GetReadableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() const {
|
const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() const {
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
|
|
||||||
void CreateUserInterface(Kernel::HLERequestContext& ctx);
|
void CreateUserInterface(Kernel::HLERequestContext& ctx);
|
||||||
bool LoadAmiibo(const std::vector<u8>& buffer);
|
bool LoadAmiibo(const std::vector<u8>& buffer);
|
||||||
Kernel::KReadableEvent* GetNFCEvent() const;
|
Kernel::KReadableEvent& GetNFCEvent();
|
||||||
const AmiiboFile& GetAmiiboBuffer() const;
|
const AmiiboFile& GetAmiiboBuffer() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -323,7 +323,7 @@ private:
|
|||||||
void StartTask(Kernel::HLERequestContext& ctx) {
|
void StartTask(Kernel::HLERequestContext& ctx) {
|
||||||
// No need to connect to the internet, just finish the task straight away.
|
// No need to connect to the internet, just finish the task straight away.
|
||||||
LOG_DEBUG(Service_NIM, "called");
|
LOG_DEBUG(Service_NIM, "called");
|
||||||
finished_event.GetWritableEvent()->Signal();
|
finished_event.GetWritableEvent().Signal();
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ private:
|
|||||||
|
|
||||||
void Cancel(Kernel::HLERequestContext& ctx) {
|
void Cancel(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_NIM, "called");
|
LOG_DEBUG(Service_NIM, "called");
|
||||||
finished_event.GetWritableEvent()->Clear();
|
finished_event.GetWritableEvent().Clear();
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -108,14 +108,14 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
|
|||||||
// This is mostly to take into account unimplemented features. As synced
|
// This is mostly to take into account unimplemented features. As synced
|
||||||
// gpu is always synced.
|
// gpu is always synced.
|
||||||
if (!gpu.IsAsync()) {
|
if (!gpu.IsAsync()) {
|
||||||
event.event->GetWritableEvent()->Signal();
|
event.event->GetWritableEvent().Signal();
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
auto lock = gpu.LockSync();
|
auto lock = gpu.LockSync();
|
||||||
const u32 current_syncpoint_value = event.fence.value;
|
const u32 current_syncpoint_value = event.fence.value;
|
||||||
const s32 diff = current_syncpoint_value - params.threshold;
|
const s32 diff = current_syncpoint_value - params.threshold;
|
||||||
if (diff >= 0) {
|
if (diff >= 0) {
|
||||||
event.event->GetWritableEvent()->Signal();
|
event.event->GetWritableEvent().Signal();
|
||||||
params.value = current_syncpoint_value;
|
params.value = current_syncpoint_value;
|
||||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
@ -142,7 +142,7 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
|
|||||||
params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000;
|
params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000;
|
||||||
}
|
}
|
||||||
params.value |= event_id;
|
params.value |= event_id;
|
||||||
event.event->GetWritableEvent()->Clear();
|
event.event->GetWritableEvent().Clear();
|
||||||
gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value);
|
gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value);
|
||||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||||
return NvResult::Timeout;
|
return NvResult::Timeout;
|
||||||
|
@ -187,9 +187,9 @@ void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) {
|
|||||||
if (event_id < MaxNvEvents) {
|
if (event_id < MaxNvEvents) {
|
||||||
IPC::ResponseBuilder rb{ctx, 3, 1};
|
IPC::ResponseBuilder rb{ctx, 3, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
auto event = nvdrv->GetEvent(event_id);
|
auto& event = nvdrv->GetEvent(event_id);
|
||||||
event->Clear();
|
event.Clear();
|
||||||
rb.PushCopyObjects(event.get());
|
rb.PushCopyObjects(event);
|
||||||
rb.PushEnum(NvResult::Success);
|
rb.PushEnum(NvResult::Success);
|
||||||
} else {
|
} else {
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
@ -176,16 +176,16 @@ void Module::SignalSyncpt(const u32 syncpoint_id, const u32 value) {
|
|||||||
if (events_interface.assigned_syncpt[i] == syncpoint_id &&
|
if (events_interface.assigned_syncpt[i] == syncpoint_id &&
|
||||||
events_interface.assigned_value[i] == value) {
|
events_interface.assigned_value[i] == value) {
|
||||||
events_interface.LiberateEvent(i);
|
events_interface.LiberateEvent(i);
|
||||||
events_interface.events[i].event->GetWritableEvent()->Signal();
|
events_interface.events[i].event->GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KReadableEvent> Module::GetEvent(const u32 event_id) const {
|
Kernel::KReadableEvent& Module::GetEvent(const u32 event_id) {
|
||||||
return SharedFrom(events_interface.events[event_id].event->GetReadableEvent());
|
return events_interface.events[event_id].event->GetReadableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KWritableEvent> Module::GetEventWriteable(const u32 event_id) const {
|
Kernel::KWritableEvent& Module::GetEventWriteable(const u32 event_id) {
|
||||||
return events_interface.events[event_id].event->GetWritableEvent();
|
return events_interface.events[event_id].event->GetWritableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,9 +136,9 @@ public:
|
|||||||
|
|
||||||
void SignalSyncpt(const u32 syncpoint_id, const u32 value);
|
void SignalSyncpt(const u32 syncpoint_id, const u32 value);
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KReadableEvent> GetEvent(u32 event_id) const;
|
Kernel::KReadableEvent& GetEvent(u32 event_id);
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KWritableEvent> GetEventWriteable(u32 event_id) const;
|
Kernel::KWritableEvent& GetEventWriteable(u32 event_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Manages syncpoints on the host
|
/// Manages syncpoints on the host
|
||||||
|
@ -41,7 +41,7 @@ void BufferQueue::SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer)
|
|||||||
.multi_fence = {},
|
.multi_fence = {},
|
||||||
};
|
};
|
||||||
|
|
||||||
buffer_wait_event.GetWritableEvent()->Signal();
|
buffer_wait_event.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::pair<u32, Service::Nvidia::MultiFence*>> BufferQueue::DequeueBuffer(u32 width,
|
std::optional<std::pair<u32, Service::Nvidia::MultiFence*>> BufferQueue::DequeueBuffer(u32 width,
|
||||||
@ -119,7 +119,7 @@ void BufferQueue::CancelBuffer(u32 slot, const Service::Nvidia::MultiFence& mult
|
|||||||
}
|
}
|
||||||
free_buffers_condition.notify_one();
|
free_buffers_condition.notify_one();
|
||||||
|
|
||||||
buffer_wait_event.GetWritableEvent()->Signal();
|
buffer_wait_event.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::AcquireBuffer() {
|
std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::AcquireBuffer() {
|
||||||
@ -154,7 +154,7 @@ void BufferQueue::ReleaseBuffer(u32 slot) {
|
|||||||
}
|
}
|
||||||
free_buffers_condition.notify_one();
|
free_buffers_condition.notify_one();
|
||||||
|
|
||||||
buffer_wait_event.GetWritableEvent()->Signal();
|
buffer_wait_event.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferQueue::Connect() {
|
void BufferQueue::Connect() {
|
||||||
@ -169,7 +169,7 @@ void BufferQueue::Disconnect() {
|
|||||||
std::unique_lock lock{queue_sequence_mutex};
|
std::unique_lock lock{queue_sequence_mutex};
|
||||||
queue_sequence.clear();
|
queue_sequence.clear();
|
||||||
}
|
}
|
||||||
buffer_wait_event.GetWritableEvent()->Signal();
|
buffer_wait_event.GetWritableEvent().Signal();
|
||||||
is_connect = false;
|
is_connect = false;
|
||||||
free_buffers_condition.notify_one();
|
free_buffers_condition.notify_one();
|
||||||
}
|
}
|
||||||
@ -188,11 +188,11 @@ u32 BufferQueue::Query(QueryType type) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KWritableEvent> BufferQueue::GetWritableBufferWaitEvent() const {
|
Kernel::KWritableEvent& BufferQueue::GetWritableBufferWaitEvent() {
|
||||||
return buffer_wait_event.GetWritableEvent();
|
return buffer_wait_event.GetWritableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KReadableEvent> BufferQueue::GetBufferWaitEvent() const {
|
Kernel::KReadableEvent& BufferQueue::GetBufferWaitEvent() {
|
||||||
return buffer_wait_event.GetReadableEvent();
|
return buffer_wait_event.GetReadableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,9 +117,9 @@ public:
|
|||||||
return is_connect;
|
return is_connect;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KWritableEvent> GetWritableBufferWaitEvent() const;
|
Kernel::KWritableEvent& GetWritableBufferWaitEvent();
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KReadableEvent> GetBufferWaitEvent() const;
|
Kernel::KReadableEvent& GetBufferWaitEvent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BufferQueue(const BufferQueue&) = delete;
|
BufferQueue(const BufferQueue&) = delete;
|
||||||
|
@ -165,7 +165,7 @@ std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) co
|
|||||||
return layer->GetBufferQueue().GetId();
|
return layer->GetBufferQueue().GetId();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id) {
|
Kernel::KReadableEvent* NVFlinger::FindVsyncEvent(u64 display_id) {
|
||||||
const auto lock_guard = Lock();
|
const auto lock_guard = Lock();
|
||||||
auto* const display = FindDisplay(display_id);
|
auto* const display = FindDisplay(display_id);
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return display->GetVSyncEvent();
|
return &display->GetVSyncEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferQueue* NVFlinger::FindBufferQueue(u32 id) {
|
BufferQueue* NVFlinger::FindBufferQueue(u32 id) {
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
/// Gets the vsync event for the specified display.
|
/// Gets the vsync event for the specified display.
|
||||||
///
|
///
|
||||||
/// If an invalid display ID is provided, then nullptr is returned.
|
/// If an invalid display ID is provided, then nullptr is returned.
|
||||||
[[nodiscard]] std::shared_ptr<Kernel::KReadableEvent> FindVsyncEvent(u64 display_id);
|
[[nodiscard]] Kernel::KReadableEvent* FindVsyncEvent(u64 display_id);
|
||||||
|
|
||||||
/// Obtains a buffer queue identified by the ID.
|
/// Obtains a buffer queue identified by the ID.
|
||||||
[[nodiscard]] BufferQueue* FindBufferQueue(u32 id);
|
[[nodiscard]] BufferQueue* FindBufferQueue(u32 id);
|
||||||
|
@ -41,19 +41,19 @@ public:
|
|||||||
|
|
||||||
void SignalChargerTypeChanged() {
|
void SignalChargerTypeChanged() {
|
||||||
if (should_signal && should_signal_charger_type) {
|
if (should_signal && should_signal_charger_type) {
|
||||||
state_change_event.GetWritableEvent()->Signal();
|
state_change_event.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SignalPowerSupplyChanged() {
|
void SignalPowerSupplyChanged() {
|
||||||
if (should_signal && should_signal_power_supply) {
|
if (should_signal && should_signal_power_supply) {
|
||||||
state_change_event.GetWritableEvent()->Signal();
|
state_change_event.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SignalBatteryVoltageStateChanged() {
|
void SignalBatteryVoltageStateChanged() {
|
||||||
if (should_signal && should_signal_battery_voltage) {
|
if (should_signal && should_signal_battery_voltage) {
|
||||||
state_change_event.GetWritableEvent()->Signal();
|
state_change_event.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,12 +33,12 @@ const Layer& Display::GetLayer(std::size_t index) const {
|
|||||||
return *layers.at(index);
|
return *layers.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Kernel::KReadableEvent> Display::GetVSyncEvent() const {
|
Kernel::KReadableEvent& Display::GetVSyncEvent() {
|
||||||
return vsync_event.GetReadableEvent();
|
return vsync_event.GetReadableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::SignalVSyncEvent() {
|
void Display::SignalVSyncEvent() {
|
||||||
vsync_event.GetWritableEvent()->Signal();
|
vsync_event.GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue) {
|
void Display::CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue) {
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
const Layer& GetLayer(std::size_t index) const;
|
const Layer& GetLayer(std::size_t index) const;
|
||||||
|
|
||||||
/// Gets the readable vsync event.
|
/// Gets the readable vsync event.
|
||||||
std::shared_ptr<Kernel::KReadableEvent> GetVSyncEvent() const;
|
Kernel::KReadableEvent& GetVSyncEvent();
|
||||||
|
|
||||||
/// Signals the internal vsync event.
|
/// Signals the internal vsync event.
|
||||||
void SignalVSyncEvent();
|
void SignalVSyncEvent();
|
||||||
|
@ -669,12 +669,10 @@ private:
|
|||||||
|
|
||||||
LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown);
|
LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown);
|
||||||
|
|
||||||
const auto& buffer_queue = *nv_flinger.FindBufferQueue(id);
|
|
||||||
|
|
||||||
// TODO(Subv): Find out what this actually is.
|
// TODO(Subv): Find out what this actually is.
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushCopyObjects(buffer_queue.GetBufferWaitEvent().get());
|
rb.PushCopyObjects(nv_flinger.FindBufferQueue(id)->GetBufferWaitEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
NVFlinger::NVFlinger& nv_flinger;
|
NVFlinger::NVFlinger& nv_flinger;
|
||||||
@ -1209,7 +1207,7 @@ private:
|
|||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushCopyObjects(vsync_event.get());
|
rb.PushCopyObjects(vsync_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertScalingMode(Kernel::HLERequestContext& ctx) {
|
void ConvertScalingMode(Kernel::HLERequestContext& ctx) {
|
||||||
|
Loading…
Reference in New Issue
Block a user