summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2015-01-11 17:46:49 +0100
committerYuri Kunde Schlesner <yuriks@yuriks.net>2015-01-30 14:47:06 +0100
commit38e7122f23424d40e0555fa40daeff55e23e4da4 (patch)
tree37c52c6f20c49fc1093f9228b5c78406b5cdc6ff /src/core/hle/kernel
parentKernel: Convert Semaphore to not use Handles (diff)
downloadyuzu-38e7122f23424d40e0555fa40daeff55e23e4da4.tar
yuzu-38e7122f23424d40e0555fa40daeff55e23e4da4.tar.gz
yuzu-38e7122f23424d40e0555fa40daeff55e23e4da4.tar.bz2
yuzu-38e7122f23424d40e0555fa40daeff55e23e4da4.tar.lz
yuzu-38e7122f23424d40e0555fa40daeff55e23e4da4.tar.xz
yuzu-38e7122f23424d40e0555fa40daeff55e23e4da4.tar.zst
yuzu-38e7122f23424d40e0555fa40daeff55e23e4da4.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp39
-rw-r--r--src/core/hle/kernel/address_arbiter.h24
2 files changed, 31 insertions, 32 deletions
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index 2a66f8dd5..2d01e2ef5 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -15,25 +15,18 @@
namespace Kernel {
-class AddressArbiter : public Object {
-public:
- std::string GetTypeName() const override { return "Arbiter"; }
- std::string GetName() const override { return name; }
+ResultVal<SharedPtr<AddressArbiter>> AddressArbiter::Create(std::string name) {
+ SharedPtr<AddressArbiter> address_arbiter(new AddressArbiter);
+ // TOOD(yuriks): Don't create Handle (see Thread::Create())
+ CASCADE_RESULT(auto unused, Kernel::g_handle_table.Create(address_arbiter));
- static const HandleType HANDLE_TYPE = HandleType::AddressArbiter;
- HandleType GetHandleType() const override { return HANDLE_TYPE; }
+ address_arbiter->name = std::move(name);
- std::string name; ///< Name of address arbiter object (optional)
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-ResultCode ArbitrateAddress(Handle handle, ArbitrationType type, u32 address, s32 value, u64 nanoseconds) {
- AddressArbiter* object = Kernel::g_handle_table.Get<AddressArbiter>(handle).get();
-
- if (object == nullptr)
- return InvalidHandle(ErrorModule::Kernel);
+ return MakeResult<SharedPtr<AddressArbiter>>(std::move(address_arbiter));
+}
+ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address, s32 value,
+ u64 nanoseconds) {
switch (type) {
// Signal thread(s) waiting for arbitrate address...
@@ -91,18 +84,4 @@ ResultCode ArbitrateAddress(Handle handle, ArbitrationType type, u32 address, s3
return RESULT_SUCCESS;
}
-static AddressArbiter* CreateAddressArbiter(Handle& handle, const std::string& name) {
- AddressArbiter* address_arbiter = new AddressArbiter;
- // TOOD(yuriks): Fix error reporting
- handle = Kernel::g_handle_table.Create(address_arbiter).ValueOr(INVALID_HANDLE);
- address_arbiter->name = name;
- return address_arbiter;
-}
-
-Handle CreateAddressArbiter(const std::string& name) {
- Handle handle;
- CreateAddressArbiter(handle, name);
- return handle;
-}
-
} // namespace Kernel
diff --git a/src/core/hle/kernel/address_arbiter.h b/src/core/hle/kernel/address_arbiter.h
index 81084bdc8..536f0f017 100644
--- a/src/core/hle/kernel/address_arbiter.h
+++ b/src/core/hle/kernel/address_arbiter.h
@@ -26,8 +26,28 @@ enum class ArbitrationType : u32 {
DecrementAndWaitIfLessThanWithTimeout,
};
-ResultCode ArbitrateAddress(Handle handle, ArbitrationType type, u32 address, s32 value, u64 nanoseconds);
+class AddressArbiter : public Object {
+public:
+ /**
+ * Creates an address arbiter.
+ *
+ * @param name Optional name used for debugging.
+ * @returns The created AddressArbiter.
+ */
+ static ResultVal<SharedPtr<AddressArbiter>> Create(std::string name = "Unknown");
-Handle CreateAddressArbiter(const std::string& name = "Unknown");
+ std::string GetTypeName() const override { return "Arbiter"; }
+ std::string GetName() const override { return name; }
+
+ static const HandleType HANDLE_TYPE = HandleType::AddressArbiter;
+ HandleType GetHandleType() const override { return HANDLE_TYPE; }
+
+ std::string name; ///< Name of address arbiter object (optional)
+
+ ResultCode ArbitrateAddress(ArbitrationType type, VAddr address, s32 value, u64 nanoseconds);
+
+private:
+ AddressArbiter() = default;
+};
} // namespace FileSys