yuzu-emu
/
yuzu
Archived
1
0
Fork 0

nv_services: Fixes to event liberation.

This commit is contained in:
Fernando Sahmkow 2019-06-11 17:04:24 -04:00 committed by FernandoS27
parent ea97589624
commit efdeab3a1d
1 changed files with 14 additions and 6 deletions

View File

@ -27,16 +27,17 @@ class nvdevice;
} }
struct EventsInterface { struct EventsInterface {
u64 events_mask; u64 events_mask{};
std::array<Kernel::EventPair, MaxNvEvents> events; std::array<Kernel::EventPair, MaxNvEvents> events;
std::array<EventState, MaxNvEvents> status; std::array<EventState, MaxNvEvents> status{};
std::array<bool, MaxNvEvents> registered; std::array<bool, MaxNvEvents> registered{};
std::array<u32, MaxNvEvents> assigned_syncpt; std::array<u32, MaxNvEvents> assigned_syncpt{};
std::array<u32, MaxNvEvents> assigned_value; std::array<u32, MaxNvEvents> assigned_value{};
u32 GetFreeEvent() { u32 GetFreeEvent() {
u64 mask = events_mask; u64 mask = events_mask;
for (u32 i = 0; i < MaxNvEvents; i++) { for (u32 i = 0; i < MaxNvEvents; i++) {
if (mask & 0x1) { const bool is_free = (mask & 0x1) == 0;
if (is_free) {
if (status[i] == EventState::Registered || status[i] == EventState::Free) { if (status[i] == EventState::Registered || status[i] == EventState::Free) {
return i; return i;
} }
@ -46,10 +47,16 @@ struct EventsInterface {
return 0xFFFFFFFF; return 0xFFFFFFFF;
} }
void SetEventStatus(const u32 event_id, EventState new_status) { void SetEventStatus(const u32 event_id, EventState new_status) {
EventState old_status = status[event_id];
if (old_status == new_status)
return;
status[event_id] = new_status; status[event_id] = new_status;
if (new_status == EventState::Registered) { if (new_status == EventState::Registered) {
registered[event_id] = true; registered[event_id] = true;
} }
if (new_status == EventState::Waiting || new_status == EventState::Busy) {
events_mask |= (1 << event_id);
}
} }
void RegisterEvent(const u32 event_id) { void RegisterEvent(const u32 event_id) {
registered[event_id] = true; registered[event_id] = true;
@ -65,6 +72,7 @@ struct EventsInterface {
} }
void LiberateEvent(const u32 event_id) { void LiberateEvent(const u32 event_id) {
status[event_id] = registered[event_id] ? EventState::Registered : EventState::Free; status[event_id] = registered[event_id] ? EventState::Registered : EventState::Free;
events_mask &= ~(1 << event_id);
} }
}; };