yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

nvhost_ctrl: Corrections to event handling

This commit is contained in:
Fernando Sahmkow 2019-06-08 15:13:26 -04:00 committed by FernandoS27
parent eef55f493b
commit 78add28aab
2 changed files with 12 additions and 8 deletions

View File

@ -102,6 +102,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000; params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000;
} }
params.value |= event_id; params.value |= event_id;
events_interface.events[event_id].writable->Clear();
gpu.RegisterEvent(event_id, params.syncpt_id, params.threshold); gpu.RegisterEvent(event_id, params.syncpt_id, params.threshold);
std::memcpy(output.data(), &params, sizeof(params)); std::memcpy(output.data(), &params, sizeof(params));
gpu.Guard(false); gpu.Guard(false);
@ -115,26 +116,29 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
u32 nvhost_ctrl::IocCtrlEventRegister(const std::vector<u8>& input, std::vector<u8>& output) { u32 nvhost_ctrl::IocCtrlEventRegister(const std::vector<u8>& input, std::vector<u8>& output) {
IocCtrlEventRegisterParams params{}; IocCtrlEventRegisterParams params{};
std::memcpy(&params, input.data(), sizeof(params)); std::memcpy(&params, input.data(), sizeof(params));
if (params.user_event_id >= MaxNvEvents) { const u32 event_id = params.user_event_id & 0x00FF;
if (event_id >= MaxNvEvents) {
return NvResult::BadParameter; return NvResult::BadParameter;
} }
if (events_interface.registered[params.user_event_id]) { if (events_interface.registered[event_id]) {
return NvResult::BadParameter; return NvResult::BadParameter;
} }
events_interface.RegisterEvent(params.user_event_id); events_interface.RegisterEvent(event_id);
events_interface.events[event_id].writable->Signal();
return NvResult::Success; return NvResult::Success;
} }
u32 nvhost_ctrl::IocCtrlEventUnregister(const std::vector<u8>& input, std::vector<u8>& output) { u32 nvhost_ctrl::IocCtrlEventUnregister(const std::vector<u8>& input, std::vector<u8>& output) {
IocCtrlEventUnregisterParams params{}; IocCtrlEventUnregisterParams params{};
std::memcpy(&params, input.data(), sizeof(params)); std::memcpy(&params, input.data(), sizeof(params));
if (params.user_event_id >= MaxNvEvents) { const u32 event_id = params.user_event_id & 0x00FF;
if (event_id >= MaxNvEvents) {
return NvResult::BadParameter; return NvResult::BadParameter;
} }
if (!events_interface.registered[params.user_event_id]) { if (!events_interface.registered[event_id]) {
return NvResult::BadParameter; return NvResult::BadParameter;
} }
events_interface.UnregisterEvent(params.user_event_id); events_interface.UnregisterEvent(event_id);
return NvResult::Success; return NvResult::Success;
} }
@ -142,7 +146,7 @@ u32 nvhost_ctrl::IocCtrlEventSignal(const std::vector<u8>& input, std::vector<u8
IocCtrlEventSignalParams params{}; IocCtrlEventSignalParams params{};
std::memcpy(&params, input.data(), sizeof(params)); std::memcpy(&params, input.data(), sizeof(params));
// TODO(Blinkhawk): This is normally called when an NvEvents timeout on WaitSynchronization // TODO(Blinkhawk): This is normally called when an NvEvents timeout on WaitSynchronization
// It is believed to cancel the GPU Event. However, better research is required // It is believed from RE to cancel the GPU Event. However, better research is required
u32 event_id = params.user_event_id & 0x00FF; u32 event_id = params.user_event_id & 0x00FF;
LOG_WARNING(Service_NVDRV, "(STUBBED) called, user_event_id: {:X}", event_id); LOG_WARNING(Service_NVDRV, "(STUBBED) called, user_event_id: {:X}", event_id);
if (event_id >= MaxNvEvents) { if (event_id >= MaxNvEvents) {

View File

@ -40,7 +40,7 @@ Module::Module() {
for (u32 i = 0; i < MaxNvEvents; i++) { for (u32 i = 0; i < MaxNvEvents; i++) {
std::string event_label = fmt::format("NVDRV::NvEvent_{}", i); std::string event_label = fmt::format("NVDRV::NvEvent_{}", i);
events_interface.events[i] = Kernel::WritableEvent::CreateEventPair( events_interface.events[i] = Kernel::WritableEvent::CreateEventPair(
kernel, Kernel::ResetType::Automatic, event_label); kernel, Kernel::ResetType::Manual, event_label);
events_interface.status[i] = EventState::Free; events_interface.status[i] = EventState::Free;
events_interface.registered[i] = false; events_interface.registered[i] = false;
} }