summaryrefslogtreecommitdiff
path: root/src/core/core.h
diff options
context:
space:
mode:
authorGravatar bunnei2016-12-15 19:01:48 -0500
committerGravatar bunnei2016-12-21 23:29:13 -0500
commit232ef55c1a13552e5ba8b72d61d1d072f5851598 (patch)
tree729ee82ded58202888a2c27bdc3beec6ab926768 /src/core/core.h
parentfile_util: Remove unused paths. (diff)
downloadyuzu-232ef55c1a13552e5ba8b72d61d1d072f5851598.tar.gz
yuzu-232ef55c1a13552e5ba8b72d61d1d072f5851598.tar.xz
yuzu-232ef55c1a13552e5ba8b72d61d1d072f5851598.zip
core: Consolidate core and system state, remove system module & cleanups.
Diffstat (limited to 'src/core/core.h')
-rw-r--r--src/core/core.h132
1 files changed, 99 insertions, 33 deletions
diff --git a/src/core/core.h b/src/core/core.h
index ffbfa91c3..f4326161d 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -5,11 +5,17 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8#include <string>
9
8#include "common/common_types.h" 10#include "common/common_types.h"
11#include "core/memory.h"
9 12
13class EmuWindow;
10class ARM_Interface; 14class ARM_Interface;
11 15
12//////////////////////////////////////////////////////////////////////////////////////////////////// 16namespace Loader {
17class AppLoader;
18}
13 19
14namespace Core { 20namespace Core {
15 21
@@ -24,37 +30,97 @@ struct ThreadContext {
24 u32 fpexc; 30 u32 fpexc;
25}; 31};
26 32
27extern std::unique_ptr<ARM_Interface> g_app_core; ///< ARM11 application core 33class System {
28extern std::unique_ptr<ARM_Interface> g_sys_core; ///< ARM11 system (OS) core 34public:
29 35 /**
30//////////////////////////////////////////////////////////////////////////////////////////////////// 36 * Gets the instance of the System singleton class.
31 37 * @returns Reference to the instance of the System singleton class.
32/// Start the core 38 */
33void Start(); 39 static System& GetInstance() {
34 40 return s_instance;
35/** 41 }
36 * Run the core CPU loop 42
37 * This function runs the core for the specified number of CPU instructions before trying to update 43 /// Enumeration representing the return values of the System Initialize and Load process.
38 * hardware. This is much faster than SingleStep (and should be equivalent), as the CPU is not 44 enum class ResultStatus : u32 {
39 * required to do a full dispatch with each instruction. NOTE: the number of instructions requested 45 Success, ///< Succeeded
40 * is not guaranteed to run, as this will be interrupted preemptively if a hardware update is 46 ErrorNotInitialized, ///< Error trying to use core prior to initialization
41 * requested (e.g. on a thread switch). 47 ErrorGetLoader, ///< Error finding the correct application loader
42 */ 48 ErrorSystemMode, ///< Error determining the system mode
43void RunLoop(int tight_loop = 1000); 49 ErrorLoader, ///< Error loading the specified application
44 50 ErrorLoader_ErrorEncrypted, ///< Error loading the specified application due to encryption
45/// Step the CPU one instruction 51 ErrorLoader_ErrorInvalidFormat, ///< Error loading the specified application due to an invalid format
46void SingleStep(); 52 ErrorVideoCore, ///< Error in the video core
47 53 };
48/// Halt the core 54
49void Halt(const char* msg); 55 /**
50 56 * Initialize the emulated system.
51/// Kill the core 57 * @param emu_window Pointer to the host-system window used for video output and keyboard input.
52void Stop(); 58 * @param system_mode The system mode.
53 59 * @return ResultStatus code, indicating if the operation succeeded.
54/// Initialize the core 60 */
55void Init(); 61 ResultStatus Init(EmuWindow* emu_window, u32 system_mode);
62
63 /// Start the core
64 void Start();
65
66 /**
67 * Run the core CPU loop
68 * This function runs the core for the specified number of CPU instructions before trying to update
69 * hardware. This is much faster than SingleStep (and should be equivalent), as the CPU is not
70 * required to do a full dispatch with each instruction. NOTE: the number of instructions requested
71 * is not guaranteed to run, as this will be interrupted preemptively if a hardware update is
72 * requested (e.g. on a thread switch).
73 * @param tight_loop Number of instructions to execute.
74 * @return Result status, indicating whethor or not the operation succeeded.
75 */
76 ResultStatus RunLoop(int tight_loop = 1000);
77
78 /**
79 * Step the CPU one instruction
80 * @return Result status, indicating whethor or not the operation succeeded.
81 */
82 ResultStatus SingleStep();
83
84 /// Shutdown the emulated system.
85 void Shutdown();
86
87 /**
88 * Load an executable application.
89 * @param emu_window Pointer to the host-system window used for video output and keyboard input.
90 * @param filepath String path to the executable application to load on the host file system.
91 * @returns ResultStatus code, indicating if the operation succeeded.
92 */
93 ResultStatus Load(EmuWindow* emu_window, const std::string& filepath);
94
95 /**
96 * Indicates if the emulated system is powered on (all subsystems initialized and able to run an
97 * application).
98 * @returns True if the emulated system is powered on, otherwise false.
99 */
100 bool IsPoweredOn() const {
101 return app_core != nullptr;
102 }
103
104 /**
105 * Gets a reference to the emulated AppCore CPU.
106 * @returns A reference to the emulated AppCore CPU.
107 */
108 ARM_Interface& AppCore() {
109 return *app_core;
110 }
111
112private:
113 /// AppLoader used to load the current executing application
114 std::unique_ptr<Loader::AppLoader> app_loader;
115
116 ///< ARM11 application core
117 std::unique_ptr<ARM_Interface> app_core;
118
119 static System s_instance;
120};
56 121
57/// Shutdown the core 122static ARM_Interface& AppCore() {
58void Shutdown(); 123 return System::GetInstance().AppCore();
124}
59 125
60} // namespace 126} // namespace Core