summaryrefslogtreecommitdiff
path: root/src/core/core.h
diff options
context:
space:
mode:
authorGravatar bunnei2018-08-31 11:31:20 -0400
committerGravatar GitHub2018-08-31 11:31:20 -0400
commitf08d24e9c0a8dd7920ca5db5a5765b867eb1d714 (patch)
treef2b144f08f5881d4e1174d9eb0184cf6548f20ce /src/core/core.h
parentMerge pull request #1207 from degasus/hotfix (diff)
parentcore: Make the main System class use the PImpl idiom (diff)
downloadyuzu-f08d24e9c0a8dd7920ca5db5a5765b867eb1d714.tar.gz
yuzu-f08d24e9c0a8dd7920ca5db5a5765b867eb1d714.tar.xz
yuzu-f08d24e9c0a8dd7920ca5db5a5765b867eb1d714.zip
Merge pull request #1204 from lioncash/pimpl
core: Make the main System class use the PImpl idiom
Diffstat (limited to 'src/core/core.h')
-rw-r--r--src/core/core.h138
1 files changed, 38 insertions, 100 deletions
diff --git a/src/core/core.h b/src/core/core.h
index 2c18f7193..984e8f94c 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -94,11 +94,7 @@ public:
94 * This function should only be used by GDB Stub to support breakpoints, memory updates and 94 * This function should only be used by GDB Stub to support breakpoints, memory updates and
95 * step/continue commands. 95 * step/continue commands.
96 */ 96 */
97 void InvalidateCpuInstructionCaches() { 97 void InvalidateCpuInstructionCaches();
98 for (auto& cpu : cpu_cores) {
99 cpu->ArmInterface().ClearInstructionCache();
100 }
101 }
102 98
103 /// Shutdown the emulated system. 99 /// Shutdown the emulated system.
104 void Shutdown(); 100 void Shutdown();
@@ -117,17 +113,13 @@ public:
117 * application). 113 * application).
118 * @returns True if the emulated system is powered on, otherwise false. 114 * @returns True if the emulated system is powered on, otherwise false.
119 */ 115 */
120 bool IsPoweredOn() const { 116 bool IsPoweredOn() const;
121 return cpu_barrier && cpu_barrier->IsAlive();
122 }
123 117
124 /** 118 /**
125 * Returns a reference to the telemetry session for this emulation session. 119 * Returns a reference to the telemetry session for this emulation session.
126 * @returns Reference to the telemetry session. 120 * @returns Reference to the telemetry session.
127 */ 121 */
128 Core::TelemetrySession& TelemetrySession() const { 122 Core::TelemetrySession& TelemetrySession() const;
129 return *telemetry_session;
130 }
131 123
132 /// Prepare the core emulation for a reschedule 124 /// Prepare the core emulation for a reschedule
133 void PrepareReschedule(); 125 void PrepareReschedule();
@@ -136,14 +128,13 @@ public:
136 PerfStats::Results GetAndResetPerfStats(); 128 PerfStats::Results GetAndResetPerfStats();
137 129
138 /// Gets an ARM interface to the CPU core that is currently running 130 /// Gets an ARM interface to the CPU core that is currently running
139 ARM_Interface& CurrentArmInterface() { 131 ARM_Interface& CurrentArmInterface();
140 return CurrentCpuCore().ArmInterface();
141 }
142 132
143 /// Gets the index of the currently running CPU core 133 /// Gets the index of the currently running CPU core
144 size_t CurrentCoreIndex() { 134 size_t CurrentCoreIndex();
145 return CurrentCpuCore().CoreIndex(); 135
146 } 136 /// Gets the scheduler for the CPU core that is currently running
137 Kernel::Scheduler& CurrentScheduler();
147 138
148 /// Gets an ARM interface to the CPU core with the specified index 139 /// Gets an ARM interface to the CPU core with the specified index
149 ARM_Interface& ArmInterface(size_t core_index); 140 ARM_Interface& ArmInterface(size_t core_index);
@@ -151,43 +142,26 @@ public:
151 /// Gets a CPU interface to the CPU core with the specified index 142 /// Gets a CPU interface to the CPU core with the specified index
152 Cpu& CpuCore(size_t core_index); 143 Cpu& CpuCore(size_t core_index);
153 144
145 /// Gets the exclusive monitor
146 ExclusiveMonitor& Monitor();
147
154 /// Gets a mutable reference to the GPU interface 148 /// Gets a mutable reference to the GPU interface
155 Tegra::GPU& GPU() { 149 Tegra::GPU& GPU();
156 return *gpu_core;
157 }
158 150
159 /// Gets an immutable reference to the GPU interface. 151 /// Gets an immutable reference to the GPU interface.
160 const Tegra::GPU& GPU() const { 152 const Tegra::GPU& GPU() const;
161 return *gpu_core;
162 }
163 153
164 /// Gets a mutable reference to the renderer. 154 /// Gets a mutable reference to the renderer.
165 VideoCore::RendererBase& Renderer() { 155 VideoCore::RendererBase& Renderer();
166 return *renderer;
167 }
168 156
169 /// Gets an immutable reference to the renderer. 157 /// Gets an immutable reference to the renderer.
170 const VideoCore::RendererBase& Renderer() const { 158 const VideoCore::RendererBase& Renderer() const;
171 return *renderer;
172 }
173
174 /// Gets the scheduler for the CPU core that is currently running
175 Kernel::Scheduler& CurrentScheduler() {
176 return *CurrentCpuCore().Scheduler();
177 }
178
179 /// Gets the exclusive monitor
180 ExclusiveMonitor& Monitor() {
181 return *cpu_exclusive_monitor;
182 }
183 159
184 /// Gets the scheduler for the CPU core with the specified index 160 /// Gets the scheduler for the CPU core with the specified index
185 const std::shared_ptr<Kernel::Scheduler>& Scheduler(size_t core_index); 161 const std::shared_ptr<Kernel::Scheduler>& Scheduler(size_t core_index);
186 162
187 /// Gets the current process 163 /// Gets the current process
188 Kernel::SharedPtr<Kernel::Process>& CurrentProcess() { 164 Kernel::SharedPtr<Kernel::Process>& CurrentProcess();
189 return current_process;
190 }
191 165
192 /// Provides a reference to the kernel instance. 166 /// Provides a reference to the kernel instance.
193 Kernel::KernelCore& Kernel(); 167 Kernel::KernelCore& Kernel();
@@ -195,49 +169,37 @@ public:
195 /// Provides a constant reference to the kernel instance. 169 /// Provides a constant reference to the kernel instance.
196 const Kernel::KernelCore& Kernel() const; 170 const Kernel::KernelCore& Kernel() const;
197 171
198 /// Gets the name of the current game 172 /// Provides a reference to the internal PerfStats instance.
199 Loader::ResultStatus GetGameName(std::string& out) const { 173 Core::PerfStats& GetPerfStats();
200 if (app_loader == nullptr)
201 return Loader::ResultStatus::ErrorNotInitialized;
202 return app_loader->ReadTitle(out);
203 }
204 174
205 PerfStats perf_stats; 175 /// Provides a constant reference to the internal PerfStats instance.
206 FrameLimiter frame_limiter; 176 const Core::PerfStats& GetPerfStats() const;
207 177
208 void SetStatus(ResultStatus new_status, const char* details = nullptr) { 178 /// Provides a reference to the frame limiter;
209 status = new_status; 179 Core::FrameLimiter& FrameLimiter();
210 if (details) {
211 status_details = details;
212 }
213 }
214 180
215 const std::string& GetStatusDetails() const { 181 /// Provides a constant referent to the frame limiter
216 return status_details; 182 const Core::FrameLimiter& FrameLimiter() const;
217 }
218 183
219 Loader::AppLoader& GetAppLoader() const { 184 /// Gets the name of the current game
220 return *app_loader; 185 Loader::ResultStatus GetGameName(std::string& out) const;
221 } 186
187 void SetStatus(ResultStatus new_status, const char* details);
188
189 const std::string& GetStatusDetails() const;
190
191 Loader::AppLoader& GetAppLoader() const;
222 192
223 Service::SM::ServiceManager& ServiceManager(); 193 Service::SM::ServiceManager& ServiceManager();
224 const Service::SM::ServiceManager& ServiceManager() const; 194 const Service::SM::ServiceManager& ServiceManager() const;
225 195
226 void SetGPUDebugContext(std::shared_ptr<Tegra::DebugContext> context) { 196 void SetGPUDebugContext(std::shared_ptr<Tegra::DebugContext> context);
227 debug_context = std::move(context);
228 }
229 197
230 std::shared_ptr<Tegra::DebugContext> GetGPUDebugContext() const { 198 std::shared_ptr<Tegra::DebugContext> GetGPUDebugContext() const;
231 return debug_context;
232 }
233 199
234 void SetFilesystem(FileSys::VirtualFilesystem vfs) { 200 void SetFilesystem(FileSys::VirtualFilesystem vfs);
235 virtual_filesystem = std::move(vfs);
236 }
237 201
238 FileSys::VirtualFilesystem GetFilesystem() const { 202 FileSys::VirtualFilesystem GetFilesystem() const;
239 return virtual_filesystem;
240 }
241 203
242private: 204private:
243 System(); 205 System();
@@ -253,34 +215,10 @@ private:
253 */ 215 */
254 ResultStatus Init(Frontend::EmuWindow& emu_window); 216 ResultStatus Init(Frontend::EmuWindow& emu_window);
255 217
256 Kernel::KernelCore kernel; 218 struct Impl;
257 /// RealVfsFilesystem instance 219 std::unique_ptr<Impl> impl;
258 FileSys::VirtualFilesystem virtual_filesystem;
259 /// AppLoader used to load the current executing application
260 std::unique_ptr<Loader::AppLoader> app_loader;
261 std::unique_ptr<VideoCore::RendererBase> renderer;
262 std::unique_ptr<Tegra::GPU> gpu_core;
263 std::shared_ptr<Tegra::DebugContext> debug_context;
264 Kernel::SharedPtr<Kernel::Process> current_process;
265 std::shared_ptr<ExclusiveMonitor> cpu_exclusive_monitor;
266 std::shared_ptr<CpuBarrier> cpu_barrier;
267 std::array<std::shared_ptr<Cpu>, NUM_CPU_CORES> cpu_cores;
268 std::array<std::unique_ptr<std::thread>, NUM_CPU_CORES - 1> cpu_core_threads;
269 size_t active_core{}; ///< Active core, only used in single thread mode
270
271 /// Service manager
272 std::shared_ptr<Service::SM::ServiceManager> service_manager;
273
274 /// Telemetry session for this emulation session
275 std::unique_ptr<Core::TelemetrySession> telemetry_session;
276 220
277 static System s_instance; 221 static System s_instance;
278
279 ResultStatus status = ResultStatus::Success;
280 std::string status_details = "";
281
282 /// Map of guest threads to CPU cores
283 std::map<std::thread::id, std::shared_ptr<Cpu>> thread_to_cpu;
284}; 222};
285 223
286inline ARM_Interface& CurrentArmInterface() { 224inline ARM_Interface& CurrentArmInterface() {