address_arbiter.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_types.h"
  6. #include "core/hle/kernel/kernel.h"
  7. // Address arbiters are an underlying kernel synchronization object that can be created/used via
  8. // supervisor calls (SVCs). They function as sort of a global lock. Typically, games/other CTR
  9. // applications use them as an underlying mechanism to implement thread-safe barriers, events, and
  10. // semphores.
  11. ////////////////////////////////////////////////////////////////////////////////////////////////////
  12. // Kernel namespace
  13. namespace Kernel {
  14. enum class ArbitrationType : u32 {
  15. Signal,
  16. WaitIfLessThan,
  17. DecrementAndWaitIfLessThan,
  18. WaitIfLessThanWithTimeout,
  19. DecrementAndWaitIfLessThanWithTimeout,
  20. };
  21. class AddressArbiter final : public Object {
  22. public:
  23. /**
  24. * Creates an address arbiter.
  25. *
  26. * @param name Optional name used for debugging.
  27. * @returns The created AddressArbiter.
  28. */
  29. static SharedPtr<AddressArbiter> Create(std::string name = "Unknown");
  30. std::string GetTypeName() const override { return "Arbiter"; }
  31. std::string GetName() const override { return name; }
  32. static const HandleType HANDLE_TYPE = HandleType::AddressArbiter;
  33. HandleType GetHandleType() const override { return HANDLE_TYPE; }
  34. std::string name; ///< Name of address arbiter object (optional)
  35. ResultCode ArbitrateAddress(ArbitrationType type, VAddr address, s32 value, u64 nanoseconds);
  36. private:
  37. AddressArbiter();
  38. ~AddressArbiter() override;
  39. };
  40. } // namespace FileSys