summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/core.cpp12
-rw-r--r--src/core/core.h10
-rw-r--r--src/core/hardware_interrupt_manager.cpp21
-rw-r--r--src/core/hardware_interrupt_manager.h24
-rw-r--r--src/core/hle/service/nvdrv/interface.cpp2
-rw-r--r--src/core/hle/service/nvdrv/interface.h2
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.h5
8 files changed, 69 insertions, 9 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index c22585bfb..12f06a189 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -111,6 +111,8 @@ add_library(core STATIC
111 frontend/scope_acquire_window_context.h 111 frontend/scope_acquire_window_context.h
112 gdbstub/gdbstub.cpp 112 gdbstub/gdbstub.cpp
113 gdbstub/gdbstub.h 113 gdbstub/gdbstub.h
114 hardware_interrupt_manager.cpp
115 hardware_interrupt_manager.h
114 hle/ipc.h 116 hle/ipc.h
115 hle/ipc_helpers.h 117 hle/ipc_helpers.h
116 hle/kernel/address_arbiter.cpp 118 hle/kernel/address_arbiter.cpp
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 262411db8..d7f43f5ec 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -19,6 +19,7 @@
19#include "core/file_sys/vfs_concat.h" 19#include "core/file_sys/vfs_concat.h"
20#include "core/file_sys/vfs_real.h" 20#include "core/file_sys/vfs_real.h"
21#include "core/gdbstub/gdbstub.h" 21#include "core/gdbstub/gdbstub.h"
22#include "core/hardware_interrupt_manager.h"
22#include "core/hle/kernel/client_port.h" 23#include "core/hle/kernel/client_port.h"
23#include "core/hle/kernel/kernel.h" 24#include "core/hle/kernel/kernel.h"
24#include "core/hle/kernel/process.h" 25#include "core/hle/kernel/process.h"
@@ -150,7 +151,7 @@ struct System::Impl {
150 if (!renderer->Init()) { 151 if (!renderer->Init()) {
151 return ResultStatus::ErrorVideoCore; 152 return ResultStatus::ErrorVideoCore;
152 } 153 }
153 154 interrupt_manager = std::make_unique<Core::Hardware::InterruptManager>(system);
154 gpu_core = VideoCore::CreateGPU(system); 155 gpu_core = VideoCore::CreateGPU(system);
155 156
156 is_powered_on = true; 157 is_powered_on = true;
@@ -297,6 +298,7 @@ struct System::Impl {
297 std::unique_ptr<VideoCore::RendererBase> renderer; 298 std::unique_ptr<VideoCore::RendererBase> renderer;
298 std::unique_ptr<Tegra::GPU> gpu_core; 299 std::unique_ptr<Tegra::GPU> gpu_core;
299 std::shared_ptr<Tegra::DebugContext> debug_context; 300 std::shared_ptr<Tegra::DebugContext> debug_context;
301 std::unique_ptr<Core::Hardware::InterruptManager> interrupt_manager;
300 CpuCoreManager cpu_core_manager; 302 CpuCoreManager cpu_core_manager;
301 bool is_powered_on = false; 303 bool is_powered_on = false;
302 304
@@ -440,6 +442,14 @@ const Tegra::GPU& System::GPU() const {
440 return *impl->gpu_core; 442 return *impl->gpu_core;
441} 443}
442 444
445Core::Hardware::InterruptManager& System::InterruptManager() {
446 return *impl->interrupt_manager;
447}
448
449const Core::Hardware::InterruptManager& System::InterruptManager() const {
450 return *impl->interrupt_manager;
451}
452
443VideoCore::RendererBase& System::Renderer() { 453VideoCore::RendererBase& System::Renderer() {
444 return *impl->renderer; 454 return *impl->renderer;
445} 455}
diff --git a/src/core/core.h b/src/core/core.h
index 70adb7af9..53e6fdb7b 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -66,6 +66,10 @@ namespace Core::Timing {
66class CoreTiming; 66class CoreTiming;
67} 67}
68 68
69namespace Core::Hardware {
70class InterruptManager;
71}
72
69namespace Core { 73namespace Core {
70 74
71class ARM_Interface; 75class ARM_Interface;
@@ -230,6 +234,12 @@ public:
230 /// Provides a constant reference to the core timing instance. 234 /// Provides a constant reference to the core timing instance.
231 const Timing::CoreTiming& CoreTiming() const; 235 const Timing::CoreTiming& CoreTiming() const;
232 236
237 /// Provides a reference to the interrupt manager instance.
238 Core::Hardware::InterruptManager& InterruptManager();
239
240 /// Provides a constant reference to the interrupt manager instance.
241 const Core::Hardware::InterruptManager& InterruptManager() const;
242
233 /// Provides a reference to the kernel instance. 243 /// Provides a reference to the kernel instance.
234 Kernel::KernelCore& Kernel(); 244 Kernel::KernelCore& Kernel();
235 245
diff --git a/src/core/hardware_interrupt_manager.cpp b/src/core/hardware_interrupt_manager.cpp
new file mode 100644
index 000000000..463d2916c
--- /dev/null
+++ b/src/core/hardware_interrupt_manager.cpp
@@ -0,0 +1,21 @@
1
2#include "core/core.h"
3#include "core/hardware_interrupt_manager.h"
4#include "core/hle/service/nvdrv/interface.h"
5#include "core/hle/service/sm/sm.h"
6
7namespace Core::Hardware {
8
9InterruptManager::InterruptManager(Core::System& system_in) : system(system_in) {
10 gpu_interrupt_event =
11 system.CoreTiming().RegisterEvent("GPUInterrupt", [this](u64 event_index, s64) {
12 auto nvdrv = system.ServiceManager().GetService<Service::Nvidia::NVDRV>("nvdrv");
13 nvdrv->SignalGPUInterrupt(static_cast<u32>(event_index));
14 });
15}
16
17void InterruptManager::InterruptGPU(const u32 event_index) {
18 system.CoreTiming().ScheduleEvent(10, gpu_interrupt_event, static_cast<u64>(event_index));
19}
20
21} // namespace Core::Hardware
diff --git a/src/core/hardware_interrupt_manager.h b/src/core/hardware_interrupt_manager.h
new file mode 100644
index 000000000..fc565c88b
--- /dev/null
+++ b/src/core/hardware_interrupt_manager.h
@@ -0,0 +1,24 @@
1#pragma once
2
3#include "common/common_types.h"
4#include "core/core_timing.h"
5
6namespace Core {
7class System;
8}
9
10namespace Core::Hardware {
11
12class InterruptManager {
13public:
14 InterruptManager(Core::System& system);
15 ~InterruptManager() = default;
16
17 void InterruptGPU(const u32 event_index);
18
19private:
20 Core::System& system;
21 Core::Timing::EventType* gpu_interrupt_event{};
22};
23
24} // namespace Core::Hardware
diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp
index 76482d16e..d95ba18cb 100644
--- a/src/core/hle/service/nvdrv/interface.cpp
+++ b/src/core/hle/service/nvdrv/interface.cpp
@@ -140,8 +140,6 @@ NVDRV::NVDRV(std::shared_ptr<Module> nvdrv, const char* name)
140 RegisterHandlers(functions); 140 RegisterHandlers(functions);
141 141
142 auto& kernel = Core::System::GetInstance().Kernel(); 142 auto& kernel = Core::System::GetInstance().Kernel();
143 query_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic,
144 "NVDRV::query_event");
145} 143}
146 144
147NVDRV::~NVDRV() = default; 145NVDRV::~NVDRV() = default;
diff --git a/src/core/hle/service/nvdrv/interface.h b/src/core/hle/service/nvdrv/interface.h
index 421b01017..09cf4bb12 100644
--- a/src/core/hle/service/nvdrv/interface.h
+++ b/src/core/hle/service/nvdrv/interface.h
@@ -35,8 +35,6 @@ private:
35 std::shared_ptr<Module> nvdrv; 35 std::shared_ptr<Module> nvdrv;
36 36
37 u64 pid{}; 37 u64 pid{};
38
39 Kernel::EventPair query_event;
40}; 38};
41 39
42} // namespace Service::Nvidia 40} // namespace Service::Nvidia
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h
index 9a4cdc60f..d299f2877 100644
--- a/src/core/hle/service/nvdrv/nvdrv.h
+++ b/src/core/hle/service/nvdrv/nvdrv.h
@@ -8,6 +8,7 @@
8#include <unordered_map> 8#include <unordered_map>
9#include <vector> 9#include <vector>
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "core/hle/kernel/writable_event.h"
11#include "core/hle/service/nvdrv/nvdata.h" 12#include "core/hle/service/nvdrv/nvdata.h"
12#include "core/hle/service/service.h" 13#include "core/hle/service/service.h"
13 14
@@ -15,10 +16,6 @@ namespace Service::NVFlinger {
15class NVFlinger; 16class NVFlinger;
16} 17}
17 18
18namespace Kernel {
19class WritableEvent;
20}
21
22namespace Service::Nvidia { 19namespace Service::Nvidia {
23 20
24namespace Devices { 21namespace Devices {