mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-12-26 01:31:56 +01:00
Kernel: pass Kernel reference into AddressArbiter
This commit is contained in:
parent
f446fd1fe5
commit
734be98966
@ -7,6 +7,7 @@
|
|||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/hle/kernel/address_arbiter.h"
|
#include "core/hle/kernel/address_arbiter.h"
|
||||||
#include "core/hle/kernel/errors.h"
|
#include "core/hle/kernel/errors.h"
|
||||||
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/thread.h"
|
#include "core/hle/kernel/thread.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
|
|
||||||
@ -64,11 +65,11 @@ SharedPtr<Thread> AddressArbiter::ResumeHighestPriorityThread(VAddr address) {
|
|||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressArbiter::AddressArbiter() {}
|
AddressArbiter::AddressArbiter(KernelSystem& kernel) {}
|
||||||
AddressArbiter::~AddressArbiter() {}
|
AddressArbiter::~AddressArbiter() {}
|
||||||
|
|
||||||
SharedPtr<AddressArbiter> AddressArbiter::Create(std::string name) {
|
SharedPtr<AddressArbiter> KernelSystem::CreateAddressArbiter(std::string name) {
|
||||||
SharedPtr<AddressArbiter> address_arbiter(new AddressArbiter);
|
SharedPtr<AddressArbiter> address_arbiter(new AddressArbiter(*this));
|
||||||
|
|
||||||
address_arbiter->name = std::move(name);
|
address_arbiter->name = std::move(name);
|
||||||
|
|
||||||
|
@ -31,14 +31,6 @@ enum class ArbitrationType : u32 {
|
|||||||
|
|
||||||
class AddressArbiter final : public Object {
|
class AddressArbiter final : public Object {
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* Creates an address arbiter.
|
|
||||||
*
|
|
||||||
* @param name Optional name used for debugging.
|
|
||||||
* @returns The created AddressArbiter.
|
|
||||||
*/
|
|
||||||
static SharedPtr<AddressArbiter> Create(std::string name = "Unknown");
|
|
||||||
|
|
||||||
std::string GetTypeName() const override {
|
std::string GetTypeName() const override {
|
||||||
return "Arbiter";
|
return "Arbiter";
|
||||||
}
|
}
|
||||||
@ -57,7 +49,7 @@ public:
|
|||||||
s32 value, u64 nanoseconds);
|
s32 value, u64 nanoseconds);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AddressArbiter();
|
explicit AddressArbiter(KernelSystem& kernel);
|
||||||
~AddressArbiter() override;
|
~AddressArbiter() override;
|
||||||
|
|
||||||
/// Puts the thread to wait on the specified arbitration address under this address arbiter.
|
/// Puts the thread to wait on the specified arbitration address under this address arbiter.
|
||||||
@ -72,6 +64,8 @@ private:
|
|||||||
|
|
||||||
/// Threads waiting for the address arbiter to be signaled.
|
/// Threads waiting for the address arbiter to be signaled.
|
||||||
std::vector<SharedPtr<Thread>> waiting_threads;
|
std::vector<SharedPtr<Thread>> waiting_threads;
|
||||||
|
|
||||||
|
friend class KernelSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
@ -4,14 +4,29 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <boost/smart_ptr/intrusive_ptr.hpp>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
class AddressArbiter;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using SharedPtr = boost::intrusive_ptr<T>;
|
||||||
|
|
||||||
class KernelSystem {
|
class KernelSystem {
|
||||||
public:
|
public:
|
||||||
explicit KernelSystem(u32 system_mode);
|
explicit KernelSystem(u32 system_mode);
|
||||||
~KernelSystem();
|
~KernelSystem();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an address arbiter.
|
||||||
|
*
|
||||||
|
* @param name Optional name used for debugging.
|
||||||
|
* @returns The created AddressArbiter.
|
||||||
|
*/
|
||||||
|
SharedPtr<AddressArbiter> CreateAddressArbiter(std::string name = "Unknown");
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
@ -6,10 +6,8 @@
|
|||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <boost/smart_ptr/intrusive_ptr.hpp>
|
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "core/hle/kernel/kernel.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
@ -88,9 +86,6 @@ inline void intrusive_ptr_release(Object* object) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using SharedPtr = boost::intrusive_ptr<T>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to downcast the given Object pointer to a pointer to T.
|
* Attempts to downcast the given Object pointer to a pointer to T.
|
||||||
* @return Derived pointer to the object, or `nullptr` if `object` isn't of type T.
|
* @return Derived pointer to the object, or `nullptr` if `object` isn't of type T.
|
||||||
|
@ -615,7 +615,7 @@ static ResultCode ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_
|
|||||||
|
|
||||||
/// Create an address arbiter (to allocate access to shared resources)
|
/// Create an address arbiter (to allocate access to shared resources)
|
||||||
static ResultCode CreateAddressArbiter(Handle* out_handle) {
|
static ResultCode CreateAddressArbiter(Handle* out_handle) {
|
||||||
SharedPtr<AddressArbiter> arbiter = AddressArbiter::Create();
|
SharedPtr<AddressArbiter> arbiter = Core::System::GetInstance().Kernel().CreateAddressArbiter();
|
||||||
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(arbiter)));
|
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(arbiter)));
|
||||||
LOG_TRACE(Kernel_SVC, "returned handle=0x{:08X}", *out_handle);
|
LOG_TRACE(Kernel_SVC, "returned handle=0x{:08X}", *out_handle);
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user