diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2019-06-08 00:41:55 +0200 |
---|---|---|
committer | FernandoS27 <fsahmkow27@gmail.com> | 2019-07-05 21:49:13 +0200 |
commit | e0027eba854b9cf097360e898457e164e6ae0b4d (patch) | |
tree | 3dfffe7615e1371aae0d31c98982608a62171701 /src/core/hle/service/nvdrv/nvdrv.h | |
parent | nv_services: Create GPU channels correctly (diff) | |
download | yuzu-e0027eba854b9cf097360e898457e164e6ae0b4d.tar yuzu-e0027eba854b9cf097360e898457e164e6ae0b4d.tar.gz yuzu-e0027eba854b9cf097360e898457e164e6ae0b4d.tar.bz2 yuzu-e0027eba854b9cf097360e898457e164e6ae0b4d.tar.lz yuzu-e0027eba854b9cf097360e898457e164e6ae0b4d.tar.xz yuzu-e0027eba854b9cf097360e898457e164e6ae0b4d.tar.zst yuzu-e0027eba854b9cf097360e898457e164e6ae0b4d.zip |
Diffstat (limited to 'src/core/hle/service/nvdrv/nvdrv.h')
-rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index bacd7cdb7..9a4cdc60f 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -15,12 +15,58 @@ namespace Service::NVFlinger { class NVFlinger; } +namespace Kernel { +class WritableEvent; +} + namespace Service::Nvidia { namespace Devices { class nvdevice; } +struct EventsInterface { + u64 events_mask; + std::array<Kernel::EventPair, MaxNvEvents> events; + std::array<EventState, MaxNvEvents> status; + std::array<bool, MaxNvEvents> registered; + std::array<u32, MaxNvEvents> assigned_syncpt; + std::array<u32, MaxNvEvents> assigned_value; + u32 GetFreeEvent() { + u64 mask = events_mask; + for (u32 i = 0; i < MaxNvEvents; i++) { + if (mask & 0x1) { + if (status[i] == EventState::Registered || status[i] == EventState::Free) { + return i; + } + } + mask = mask >> 1; + } + return 0xFFFFFFFF; + } + void SetEventStatus(const u32 event_id, EventState new_status) { + status[event_id] = new_status; + if (new_status == EventState::Registered) { + registered[event_id] = true; + } + } + void RegisterEvent(const u32 event_id) { + registered[event_id] = true; + if (status[event_id] == EventState::Free) { + status[event_id] = EventState::Registered; + } + } + void UnregisterEvent(const u32 event_id) { + registered[event_id] = false; + if (status[event_id] == EventState::Registered) { + status[event_id] = EventState::Free; + } + } + void LiberateEvent(const u32 event_id) { + status[event_id] = registered[event_id] ? EventState::Registered : EventState::Free; + } +}; + class Module final { public: Module(); @@ -42,6 +88,10 @@ public: /// Closes a device file descriptor and returns operation success. ResultCode Close(u32 fd); + void SignalEvent(const u32 event_id); + + Kernel::SharedPtr<Kernel::ReadableEvent> GetEvent(const u32 event_id); + private: /// Id to use for the next open file descriptor. u32 next_fd = 1; @@ -51,6 +101,8 @@ private: /// Mapping of device node names to their implementation. std::unordered_map<std::string, std::shared_ptr<Devices::nvdevice>> devices; + + EventsInterface events_interface; }; /// Registers all NVDRV services with the specified service manager. |