2022-04-23 01:59:50 -07:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2019-06-07 17:41:06 -07:00
|
|
|
|
|
|
|
#include "core/core.h"
|
2019-06-18 17:53:21 -07:00
|
|
|
#include "core/core_timing.h"
|
2019-06-07 17:41:06 -07:00
|
|
|
#include "core/hardware_interrupt_manager.h"
|
2021-07-13 21:52:17 -07:00
|
|
|
#include "core/hle/service/nvdrv/nvdrv_interface.h"
|
2019-06-07 17:41:06 -07:00
|
|
|
#include "core/hle/service/sm/sm.h"
|
|
|
|
|
|
|
|
namespace Core::Hardware {
|
|
|
|
|
|
|
|
InterruptManager::InterruptManager(Core::System& system_in) : system(system_in) {
|
2020-07-27 16:00:41 -07:00
|
|
|
gpu_interrupt_event = Core::Timing::CreateEvent(
|
2022-07-09 22:59:40 -07:00
|
|
|
"GPUInterrupt",
|
|
|
|
[this](std::uintptr_t message, u64 time,
|
|
|
|
std::chrono::nanoseconds) -> std::optional<std::chrono::nanoseconds> {
|
2020-07-15 16:14:21 -07:00
|
|
|
auto nvdrv = system.ServiceManager().GetService<Service::Nvidia::NVDRV>("nvdrv");
|
|
|
|
const u32 syncpt = static_cast<u32>(message >> 32);
|
|
|
|
const u32 value = static_cast<u32>(message);
|
|
|
|
nvdrv->SignalGPUInterruptSyncpt(syncpt, value);
|
2022-07-09 22:59:40 -07:00
|
|
|
return std::nullopt;
|
2020-07-15 16:14:21 -07:00
|
|
|
});
|
2019-06-07 17:41:06 -07:00
|
|
|
}
|
|
|
|
|
2019-06-18 17:53:21 -07:00
|
|
|
InterruptManager::~InterruptManager() = default;
|
|
|
|
|
2019-06-12 04:52:49 -07:00
|
|
|
void InterruptManager::GPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) {
|
|
|
|
const u64 msg = (static_cast<u64>(syncpoint_id) << 32ULL) | value;
|
2020-07-15 15:30:06 -07:00
|
|
|
system.CoreTiming().ScheduleEvent(std::chrono::nanoseconds{10}, gpu_interrupt_event, msg);
|
2019-06-07 17:41:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Core::Hardware
|