diff options
| author | 2016-12-22 11:47:44 -0500 | |
|---|---|---|
| committer | 2016-12-22 11:47:44 -0500 | |
| commit | aa47af7fb6efd0bda54cca2373ed978e538f6d61 (patch) | |
| tree | 93d96872603f64925cd632f27bb5c7046cadeedf | |
| parent | Merge pull request #2285 from mailwl/csnd-format (diff) | |
| parent | ThreadContext: Move from "core" to "arm_interface". (diff) | |
| download | yuzu-aa47af7fb6efd0bda54cca2373ed978e538f6d61.tar.gz yuzu-aa47af7fb6efd0bda54cca2373ed978e538f6d61.tar.xz yuzu-aa47af7fb6efd0bda54cca2373ed978e538f6d61.zip | |
Merge pull request #2343 from bunnei/core-cleanup
Core: Top-level consolidate & misc cleanup
45 files changed, 435 insertions, 591 deletions
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 3114a71db..99c096ac7 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp | |||
| @@ -33,7 +33,6 @@ | |||
| 33 | #include "core/gdbstub/gdbstub.h" | 33 | #include "core/gdbstub/gdbstub.h" |
| 34 | #include "core/loader/loader.h" | 34 | #include "core/loader/loader.h" |
| 35 | #include "core/settings.h" | 35 | #include "core/settings.h" |
| 36 | #include "core/system.h" | ||
| 37 | #include "video_core/video_core.h" | 36 | #include "video_core/video_core.h" |
| 38 | 37 | ||
| 39 | static void PrintHelp(const char* argv0) { | 38 | static void PrintHelp(const char* argv0) { |
| @@ -64,7 +63,7 @@ int main(int argc, char** argv) { | |||
| 64 | return -1; | 63 | return -1; |
| 65 | } | 64 | } |
| 66 | #endif | 65 | #endif |
| 67 | std::string boot_filename; | 66 | std::string filepath; |
| 68 | 67 | ||
| 69 | static struct option long_options[] = { | 68 | static struct option long_options[] = { |
| 70 | {"gdbport", required_argument, 0, 'g'}, | 69 | {"gdbport", required_argument, 0, 'g'}, |
| @@ -97,9 +96,9 @@ int main(int argc, char** argv) { | |||
| 97 | } | 96 | } |
| 98 | } else { | 97 | } else { |
| 99 | #ifdef _WIN32 | 98 | #ifdef _WIN32 |
| 100 | boot_filename = Common::UTF16ToUTF8(argv_w[optind]); | 99 | filepath = Common::UTF16ToUTF8(argv_w[optind]); |
| 101 | #else | 100 | #else |
| 102 | boot_filename = argv[optind]; | 101 | filepath = argv[optind]; |
| 103 | #endif | 102 | #endif |
| 104 | optind++; | 103 | optind++; |
| 105 | } | 104 | } |
| @@ -115,7 +114,7 @@ int main(int argc, char** argv) { | |||
| 115 | MicroProfileOnThreadCreate("EmuThread"); | 114 | MicroProfileOnThreadCreate("EmuThread"); |
| 116 | SCOPE_EXIT({ MicroProfileShutdown(); }); | 115 | SCOPE_EXIT({ MicroProfileShutdown(); }); |
| 117 | 116 | ||
| 118 | if (boot_filename.empty()) { | 117 | if (filepath.empty()) { |
| 119 | LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); | 118 | LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); |
| 120 | return -1; | 119 | return -1; |
| 121 | } | 120 | } |
| @@ -127,32 +126,25 @@ int main(int argc, char** argv) { | |||
| 127 | Settings::values.use_gdbstub = use_gdbstub; | 126 | Settings::values.use_gdbstub = use_gdbstub; |
| 128 | Settings::Apply(); | 127 | Settings::Apply(); |
| 129 | 128 | ||
| 130 | std::unique_ptr<EmuWindow_SDL2> emu_window = std::make_unique<EmuWindow_SDL2>(); | 129 | std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>()}; |
| 131 | 130 | ||
| 132 | std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(boot_filename); | 131 | Core::System& system{Core::System::GetInstance()}; |
| 133 | if (!loader) { | ||
| 134 | LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", boot_filename.c_str()); | ||
| 135 | return -1; | ||
| 136 | } | ||
| 137 | |||
| 138 | boost::optional<u32> system_mode = loader->LoadKernelSystemMode(); | ||
| 139 | 132 | ||
| 140 | if (!system_mode) { | 133 | SCOPE_EXIT({ system.Shutdown(); }); |
| 141 | LOG_CRITICAL(Frontend, "Failed to load ROM (Could not determine system mode)!"); | ||
| 142 | return -1; | ||
| 143 | } | ||
| 144 | 134 | ||
| 145 | System::Init(emu_window.get(), system_mode.get()); | 135 | const Core::System::ResultStatus load_result{system.Load(emu_window.get(), filepath)}; |
| 146 | SCOPE_EXIT({ System::Shutdown(); }); | ||
| 147 | 136 | ||
| 148 | Loader::ResultStatus load_result = loader->Load(); | 137 | switch (load_result) { |
| 149 | if (Loader::ResultStatus::Success != load_result) { | 138 | case Core::System::ResultStatus::ErrorGetLoader: |
| 150 | LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result); | 139 | LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filepath.c_str()); |
| 140 | return -1; | ||
| 141 | case Core::System::ResultStatus::ErrorLoader: | ||
| 142 | LOG_CRITICAL(Frontend, "Failed to load ROM!"); | ||
| 151 | return -1; | 143 | return -1; |
| 152 | } | 144 | } |
| 153 | 145 | ||
| 154 | while (emu_window->IsOpen()) { | 146 | while (emu_window->IsOpen()) { |
| 155 | Core::RunLoop(); | 147 | system.RunLoop(); |
| 156 | } | 148 | } |
| 157 | 149 | ||
| 158 | return 0; | 150 | return 0; |
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index c7eb2aafc..bb75633b6 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp | |||
| @@ -14,8 +14,6 @@ | |||
| 14 | #include "common/scm_rev.h" | 14 | #include "common/scm_rev.h" |
| 15 | #include "common/string_util.h" | 15 | #include "common/string_util.h" |
| 16 | #include "core/core.h" | 16 | #include "core/core.h" |
| 17 | #include "core/settings.h" | ||
| 18 | #include "core/system.h" | ||
| 19 | #include "video_core/debug_utils/debug_utils.h" | 17 | #include "video_core/debug_utils/debug_utils.h" |
| 20 | #include "video_core/video_core.h" | 18 | #include "video_core/video_core.h" |
| 21 | 19 | ||
| @@ -38,7 +36,7 @@ void EmuThread::run() { | |||
| 38 | if (!was_active) | 36 | if (!was_active) |
| 39 | emit DebugModeLeft(); | 37 | emit DebugModeLeft(); |
| 40 | 38 | ||
| 41 | Core::RunLoop(); | 39 | Core::System::GetInstance().RunLoop(); |
| 42 | 40 | ||
| 43 | was_active = running || exec_step; | 41 | was_active = running || exec_step; |
| 44 | if (!was_active && !stop_run) | 42 | if (!was_active && !stop_run) |
| @@ -48,7 +46,7 @@ void EmuThread::run() { | |||
| 48 | emit DebugModeLeft(); | 46 | emit DebugModeLeft(); |
| 49 | 47 | ||
| 50 | exec_step = false; | 48 | exec_step = false; |
| 51 | Core::SingleStep(); | 49 | Core::System::GetInstance().SingleStep(); |
| 52 | emit DebugModeEntered(); | 50 | emit DebugModeEntered(); |
| 53 | yieldCurrentThread(); | 51 | yieldCurrentThread(); |
| 54 | 52 | ||
| @@ -60,7 +58,7 @@ void EmuThread::run() { | |||
| 60 | } | 58 | } |
| 61 | 59 | ||
| 62 | // Shutdown the core emulation | 60 | // Shutdown the core emulation |
| 63 | System::Shutdown(); | 61 | Core::System::GetInstance().Shutdown(); |
| 64 | 62 | ||
| 65 | #if MICROPROFILE_ENABLED | 63 | #if MICROPROFILE_ENABLED |
| 66 | MicroProfileOnThreadExit(); | 64 | MicroProfileOnThreadExit(); |
diff --git a/src/citra_qt/configure_general.cpp b/src/citra_qt/configure_general.cpp index 27139fb30..03cd8835b 100644 --- a/src/citra_qt/configure_general.cpp +++ b/src/citra_qt/configure_general.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #include "citra_qt/configure_general.h" | 5 | #include "citra_qt/configure_general.h" |
| 6 | #include "citra_qt/ui_settings.h" | 6 | #include "citra_qt/ui_settings.h" |
| 7 | #include "core/core.h" | ||
| 7 | #include "core/settings.h" | 8 | #include "core/settings.h" |
| 8 | #include "core/system.h" | ||
| 9 | #include "ui_configure_general.h" | 9 | #include "ui_configure_general.h" |
| 10 | 10 | ||
| 11 | ConfigureGeneral::ConfigureGeneral(QWidget* parent) | 11 | ConfigureGeneral::ConfigureGeneral(QWidget* parent) |
| @@ -14,7 +14,7 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent) | |||
| 14 | ui->setupUi(this); | 14 | ui->setupUi(this); |
| 15 | this->setConfiguration(); | 15 | this->setConfiguration(); |
| 16 | 16 | ||
| 17 | ui->toggle_cpu_jit->setEnabled(!System::IsPoweredOn()); | 17 | ui->toggle_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | ConfigureGeneral::~ConfigureGeneral() {} | 20 | ConfigureGeneral::~ConfigureGeneral() {} |
diff --git a/src/citra_qt/configure_graphics.cpp b/src/citra_qt/configure_graphics.cpp index 36f10c8d7..cea7db388 100644 --- a/src/citra_qt/configure_graphics.cpp +++ b/src/citra_qt/configure_graphics.cpp | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "citra_qt/configure_graphics.h" | 5 | #include "citra_qt/configure_graphics.h" |
| 6 | #include "core/core.h" | ||
| 6 | #include "core/settings.h" | 7 | #include "core/settings.h" |
| 7 | #include "core/system.h" | ||
| 8 | #include "ui_configure_graphics.h" | 8 | #include "ui_configure_graphics.h" |
| 9 | 9 | ||
| 10 | ConfigureGraphics::ConfigureGraphics(QWidget* parent) | 10 | ConfigureGraphics::ConfigureGraphics(QWidget* parent) |
| @@ -13,7 +13,7 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent) | |||
| 13 | ui->setupUi(this); | 13 | ui->setupUi(this); |
| 14 | this->setConfiguration(); | 14 | this->setConfiguration(); |
| 15 | 15 | ||
| 16 | ui->toggle_vsync->setEnabled(!System::IsPoweredOn()); | 16 | ui->toggle_vsync->setEnabled(!Core::System::GetInstance().IsPoweredOn()); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | ConfigureGraphics::~ConfigureGraphics() {} | 19 | ConfigureGraphics::~ConfigureGraphics() {} |
diff --git a/src/citra_qt/configure_system.cpp b/src/citra_qt/configure_system.cpp index 873d314ec..eb1276ef3 100644 --- a/src/citra_qt/configure_system.cpp +++ b/src/citra_qt/configure_system.cpp | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | #include "citra_qt/ui_settings.h" | 6 | #include "citra_qt/ui_settings.h" |
| 7 | #include "core/hle/service/cfg/cfg.h" | 7 | #include "core/hle/service/cfg/cfg.h" |
| 8 | #include "core/hle/service/fs/archive.h" | 8 | #include "core/hle/service/fs/archive.h" |
| 9 | #include "core/system.h" | ||
| 10 | #include "ui_configure_system.h" | 9 | #include "ui_configure_system.h" |
| 11 | 10 | ||
| 12 | static const std::array<int, 12> days_in_month = {{ | 11 | static const std::array<int, 12> days_in_month = {{ |
| @@ -24,7 +23,7 @@ ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui:: | |||
| 24 | ConfigureSystem::~ConfigureSystem() {} | 23 | ConfigureSystem::~ConfigureSystem() {} |
| 25 | 24 | ||
| 26 | void ConfigureSystem::setConfiguration() { | 25 | void ConfigureSystem::setConfiguration() { |
| 27 | enabled = !System::IsPoweredOn(); | 26 | enabled = !Core::System::GetInstance().IsPoweredOn(); |
| 28 | 27 | ||
| 29 | if (!enabled) { | 28 | if (!enabled) { |
| 30 | ReadSystemSettings(); | 29 | ReadSystemSettings(); |
diff --git a/src/citra_qt/debugger/callstack.cpp b/src/citra_qt/debugger/callstack.cpp index c66f2b96a..c1db93583 100644 --- a/src/citra_qt/debugger/callstack.cpp +++ b/src/citra_qt/debugger/callstack.cpp | |||
| @@ -25,7 +25,7 @@ CallstackWidget::CallstackWidget(QWidget* parent) : QDockWidget(parent) { | |||
| 25 | 25 | ||
| 26 | void CallstackWidget::OnDebugModeEntered() { | 26 | void CallstackWidget::OnDebugModeEntered() { |
| 27 | // Stack pointer | 27 | // Stack pointer |
| 28 | const u32 sp = Core::g_app_core->GetReg(13); | 28 | const u32 sp = Core::CPU().GetReg(13); |
| 29 | 29 | ||
| 30 | Clear(); | 30 | Clear(); |
| 31 | 31 | ||
diff --git a/src/citra_qt/debugger/disassembler.cpp b/src/citra_qt/debugger/disassembler.cpp index 1ee6bbd6a..e9c8ad858 100644 --- a/src/citra_qt/debugger/disassembler.cpp +++ b/src/citra_qt/debugger/disassembler.cpp | |||
| @@ -185,13 +185,13 @@ DisassemblerWidget::DisassemblerWidget(QWidget* parent, EmuThread* emu_thread) | |||
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | void DisassemblerWidget::Init() { | 187 | void DisassemblerWidget::Init() { |
| 188 | model->ParseFromAddress(Core::g_app_core->GetPC()); | 188 | model->ParseFromAddress(Core::CPU().GetPC()); |
| 189 | 189 | ||
| 190 | disasm_ui.treeView->resizeColumnToContents(0); | 190 | disasm_ui.treeView->resizeColumnToContents(0); |
| 191 | disasm_ui.treeView->resizeColumnToContents(1); | 191 | disasm_ui.treeView->resizeColumnToContents(1); |
| 192 | disasm_ui.treeView->resizeColumnToContents(2); | 192 | disasm_ui.treeView->resizeColumnToContents(2); |
| 193 | 193 | ||
| 194 | QModelIndex model_index = model->IndexFromAbsoluteAddress(Core::g_app_core->GetPC()); | 194 | QModelIndex model_index = model->IndexFromAbsoluteAddress(Core::CPU().GetPC()); |
| 195 | disasm_ui.treeView->scrollTo(model_index); | 195 | disasm_ui.treeView->scrollTo(model_index); |
| 196 | disasm_ui.treeView->selectionModel()->setCurrentIndex( | 196 | disasm_ui.treeView->selectionModel()->setCurrentIndex( |
| 197 | model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); | 197 | model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); |
| @@ -214,8 +214,8 @@ void DisassemblerWidget::OnPause() { | |||
| 214 | emu_thread->SetRunning(false); | 214 | emu_thread->SetRunning(false); |
| 215 | 215 | ||
| 216 | // TODO: By now, the CPU might not have actually stopped... | 216 | // TODO: By now, the CPU might not have actually stopped... |
| 217 | if (Core::g_app_core) { | 217 | if (Core::System::GetInstance().IsPoweredOn()) { |
| 218 | model->SetNextInstruction(Core::g_app_core->GetPC()); | 218 | model->SetNextInstruction(Core::CPU().GetPC()); |
| 219 | } | 219 | } |
| 220 | } | 220 | } |
| 221 | 221 | ||
| @@ -224,7 +224,7 @@ void DisassemblerWidget::OnToggleStartStop() { | |||
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | void DisassemblerWidget::OnDebugModeEntered() { | 226 | void DisassemblerWidget::OnDebugModeEntered() { |
| 227 | u32 next_instr = Core::g_app_core->GetPC(); | 227 | u32 next_instr = Core::CPU().GetPC(); |
| 228 | 228 | ||
| 229 | if (model->GetBreakPoints().IsAddressBreakPoint(next_instr)) | 229 | if (model->GetBreakPoints().IsAddressBreakPoint(next_instr)) |
| 230 | emu_thread->SetRunning(false); | 230 | emu_thread->SetRunning(false); |
diff --git a/src/citra_qt/debugger/registers.cpp b/src/citra_qt/debugger/registers.cpp index 4c529d3c3..b982bc58b 100644 --- a/src/citra_qt/debugger/registers.cpp +++ b/src/citra_qt/debugger/registers.cpp | |||
| @@ -58,16 +58,16 @@ RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent) { | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | void RegistersWidget::OnDebugModeEntered() { | 60 | void RegistersWidget::OnDebugModeEntered() { |
| 61 | if (!Core::g_app_core) | 61 | if (!Core::System::GetInstance().IsPoweredOn()) |
| 62 | return; | 62 | return; |
| 63 | 63 | ||
| 64 | for (int i = 0; i < core_registers->childCount(); ++i) | 64 | for (int i = 0; i < core_registers->childCount(); ++i) |
| 65 | core_registers->child(i)->setText( | 65 | core_registers->child(i)->setText( |
| 66 | 1, QString("0x%1").arg(Core::g_app_core->GetReg(i), 8, 16, QLatin1Char('0'))); | 66 | 1, QString("0x%1").arg(Core::CPU().GetReg(i), 8, 16, QLatin1Char('0'))); |
| 67 | 67 | ||
| 68 | for (int i = 0; i < vfp_registers->childCount(); ++i) | 68 | for (int i = 0; i < vfp_registers->childCount(); ++i) |
| 69 | vfp_registers->child(i)->setText( | 69 | vfp_registers->child(i)->setText( |
| 70 | 1, QString("0x%1").arg(Core::g_app_core->GetVFPReg(i), 8, 16, QLatin1Char('0'))); | 70 | 1, QString("0x%1").arg(Core::CPU().GetVFPReg(i), 8, 16, QLatin1Char('0'))); |
| 71 | 71 | ||
| 72 | UpdateCPSRValues(); | 72 | UpdateCPSRValues(); |
| 73 | UpdateVFPSystemRegisterValues(); | 73 | UpdateVFPSystemRegisterValues(); |
| @@ -127,7 +127,7 @@ void RegistersWidget::CreateCPSRChildren() { | |||
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | void RegistersWidget::UpdateCPSRValues() { | 129 | void RegistersWidget::UpdateCPSRValues() { |
| 130 | const u32 cpsr_val = Core::g_app_core->GetCPSR(); | 130 | const u32 cpsr_val = Core::CPU().GetCPSR(); |
| 131 | 131 | ||
| 132 | cpsr->setText(1, QString("0x%1").arg(cpsr_val, 8, 16, QLatin1Char('0'))); | 132 | cpsr->setText(1, QString("0x%1").arg(cpsr_val, 8, 16, QLatin1Char('0'))); |
| 133 | cpsr->child(0)->setText( | 133 | cpsr->child(0)->setText( |
| @@ -191,10 +191,10 @@ void RegistersWidget::CreateVFPSystemRegisterChildren() { | |||
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | void RegistersWidget::UpdateVFPSystemRegisterValues() { | 193 | void RegistersWidget::UpdateVFPSystemRegisterValues() { |
| 194 | const u32 fpscr_val = Core::g_app_core->GetVFPSystemReg(VFP_FPSCR); | 194 | const u32 fpscr_val = Core::CPU().GetVFPSystemReg(VFP_FPSCR); |
| 195 | const u32 fpexc_val = Core::g_app_core->GetVFPSystemReg(VFP_FPEXC); | 195 | const u32 fpexc_val = Core::CPU().GetVFPSystemReg(VFP_FPEXC); |
| 196 | const u32 fpinst_val = Core::g_app_core->GetVFPSystemReg(VFP_FPINST); | 196 | const u32 fpinst_val = Core::CPU().GetVFPSystemReg(VFP_FPINST); |
| 197 | const u32 fpinst2_val = Core::g_app_core->GetVFPSystemReg(VFP_FPINST2); | 197 | const u32 fpinst2_val = Core::CPU().GetVFPSystemReg(VFP_FPINST2); |
| 198 | 198 | ||
| 199 | QTreeWidgetItem* const fpscr = vfp_system_registers->child(0); | 199 | QTreeWidgetItem* const fpscr = vfp_system_registers->child(0); |
| 200 | fpscr->setText(1, QString("0x%1").arg(fpscr_val, 8, 16, QLatin1Char('0'))); | 200 | fpscr->setText(1, QString("0x%1").arg(fpscr_val, 8, 16, QLatin1Char('0'))); |
diff --git a/src/citra_qt/debugger/wait_tree.cpp b/src/citra_qt/debugger/wait_tree.cpp index 5a308bf7f..1d2de5185 100644 --- a/src/citra_qt/debugger/wait_tree.cpp +++ b/src/citra_qt/debugger/wait_tree.cpp | |||
| @@ -391,7 +391,7 @@ WaitTreeWidget::WaitTreeWidget(QWidget* parent) : QDockWidget(tr("Wait Tree"), p | |||
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | void WaitTreeWidget::OnDebugModeEntered() { | 393 | void WaitTreeWidget::OnDebugModeEntered() { |
| 394 | if (!Core::g_app_core) | 394 | if (!Core::System::GetInstance().IsPoweredOn()) |
| 395 | return; | 395 | return; |
| 396 | model->InitItems(); | 396 | model->InitItems(); |
| 397 | view->setModel(model); | 397 | view->setModel(model); |
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index e16d3196c..6d59cf640 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp | |||
| @@ -46,7 +46,6 @@ | |||
| 46 | #include "core/gdbstub/gdbstub.h" | 46 | #include "core/gdbstub/gdbstub.h" |
| 47 | #include "core/loader/loader.h" | 47 | #include "core/loader/loader.h" |
| 48 | #include "core/settings.h" | 48 | #include "core/settings.h" |
| 49 | #include "core/system.h" | ||
| 50 | #include "qhexedit.h" | 49 | #include "qhexedit.h" |
| 51 | #include "video_core/video_core.h" | 50 | #include "video_core/video_core.h" |
| 52 | 51 | ||
| @@ -274,7 +273,7 @@ void GMainWindow::OnDisplayTitleBars(bool show) { | |||
| 274 | } | 273 | } |
| 275 | } | 274 | } |
| 276 | 275 | ||
| 277 | bool GMainWindow::InitializeSystem(u32 system_mode) { | 276 | bool GMainWindow::LoadROM(const std::string& filename) { |
| 278 | // Shutdown previous session if the emu thread is still active... | 277 | // Shutdown previous session if the emu thread is still active... |
| 279 | if (emu_thread != nullptr) | 278 | if (emu_thread != nullptr) |
| 280 | ShutdownGame(); | 279 | ShutdownGame(); |
| @@ -290,54 +289,25 @@ bool GMainWindow::InitializeSystem(u32 system_mode) { | |||
| 290 | return false; | 289 | return false; |
| 291 | } | 290 | } |
| 292 | 291 | ||
| 293 | // Initialize the core emulation | 292 | Core::System& system{Core::System::GetInstance()}; |
| 294 | System::Result system_result = System::Init(render_window, system_mode); | ||
| 295 | if (System::Result::Success != system_result) { | ||
| 296 | switch (system_result) { | ||
| 297 | case System::Result::ErrorInitVideoCore: | ||
| 298 | QMessageBox::critical(this, tr("Error while starting Citra!"), | ||
| 299 | tr("Failed to initialize the video core!\n\n" | ||
| 300 | "Please ensure that your GPU supports OpenGL 3.3 and that you " | ||
| 301 | "have the latest graphics driver.")); | ||
| 302 | break; | ||
| 303 | |||
| 304 | default: | ||
| 305 | QMessageBox::critical(this, tr("Error while starting Citra!"), | ||
| 306 | tr("Unknown error (please check the log)!")); | ||
| 307 | break; | ||
| 308 | } | ||
| 309 | return false; | ||
| 310 | } | ||
| 311 | return true; | ||
| 312 | } | ||
| 313 | |||
| 314 | bool GMainWindow::LoadROM(const std::string& filename) { | ||
| 315 | std::unique_ptr<Loader::AppLoader> app_loader = Loader::GetLoader(filename); | ||
| 316 | if (!app_loader) { | ||
| 317 | LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filename.c_str()); | ||
| 318 | QMessageBox::critical(this, tr("Error while loading ROM!"), | ||
| 319 | tr("The ROM format is not supported.")); | ||
| 320 | return false; | ||
| 321 | } | ||
| 322 | 293 | ||
| 323 | boost::optional<u32> system_mode = app_loader->LoadKernelSystemMode(); | 294 | const Core::System::ResultStatus result{system.Load(render_window, filename)}; |
| 324 | if (!system_mode) { | ||
| 325 | LOG_CRITICAL(Frontend, "Failed to load ROM!"); | ||
| 326 | QMessageBox::critical(this, tr("Error while loading ROM!"), | ||
| 327 | tr("Could not determine the system mode.")); | ||
| 328 | return false; | ||
| 329 | } | ||
| 330 | 295 | ||
| 331 | if (!InitializeSystem(system_mode.get())) | 296 | if (result != Core::System::ResultStatus::Success) { |
| 332 | return false; | 297 | switch (result) { |
| 298 | case Core::System::ResultStatus::ErrorGetLoader: | ||
| 299 | LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filename.c_str()); | ||
| 300 | QMessageBox::critical(this, tr("Error while loading ROM!"), | ||
| 301 | tr("The ROM format is not supported.")); | ||
| 302 | break; | ||
| 333 | 303 | ||
| 334 | Loader::ResultStatus result = app_loader->Load(); | 304 | case Core::System::ResultStatus::ErrorSystemMode: |
| 335 | if (Loader::ResultStatus::Success != result) { | 305 | LOG_CRITICAL(Frontend, "Failed to load ROM!"); |
| 336 | System::Shutdown(); | 306 | QMessageBox::critical(this, tr("Error while loading ROM!"), |
| 337 | LOG_CRITICAL(Frontend, "Failed to load ROM!"); | 307 | tr("Could not determine the system mode.")); |
| 308 | break; | ||
| 338 | 309 | ||
| 339 | switch (result) { | 310 | case Core::System::ResultStatus::ErrorLoader_ErrorEncrypted: { |
| 340 | case Loader::ResultStatus::ErrorEncrypted: { | ||
| 341 | // Build the MessageBox ourselves to have clickable link | 311 | // Build the MessageBox ourselves to have clickable link |
| 342 | QMessageBox popup_error; | 312 | QMessageBox popup_error; |
| 343 | popup_error.setTextFormat(Qt::RichText); | 313 | popup_error.setTextFormat(Qt::RichText); |
| @@ -352,11 +322,10 @@ bool GMainWindow::LoadROM(const std::string& filename) { | |||
| 352 | popup_error.exec(); | 322 | popup_error.exec(); |
| 353 | break; | 323 | break; |
| 354 | } | 324 | } |
| 355 | case Loader::ResultStatus::ErrorInvalidFormat: | 325 | case Core::System::ResultStatus::ErrorLoader_ErrorInvalidFormat: |
| 356 | QMessageBox::critical(this, tr("Error while loading ROM!"), | 326 | QMessageBox::critical(this, tr("Error while loading ROM!"), |
| 357 | tr("The ROM format is not supported.")); | 327 | tr("The ROM format is not supported.")); |
| 358 | break; | 328 | break; |
| 359 | case Loader::ResultStatus::Error: | ||
| 360 | 329 | ||
| 361 | default: | 330 | default: |
| 362 | QMessageBox::critical(this, tr("Error while loading ROM!"), tr("Unknown error!")); | 331 | QMessageBox::critical(this, tr("Error while loading ROM!"), tr("Unknown error!")); |
diff --git a/src/common/common_paths.h b/src/common/common_paths.h index 37304d236..b56105306 100644 --- a/src/common/common_paths.h +++ b/src/common/common_paths.h | |||
| @@ -32,22 +32,10 @@ | |||
| 32 | 32 | ||
| 33 | // Subdirs in the User dir returned by GetUserPath(D_USER_IDX) | 33 | // Subdirs in the User dir returned by GetUserPath(D_USER_IDX) |
| 34 | #define CONFIG_DIR "config" | 34 | #define CONFIG_DIR "config" |
| 35 | #define GAMECONFIG_DIR "game_config" | ||
| 36 | #define MAPS_DIR "maps" | ||
| 37 | #define CACHE_DIR "cache" | 35 | #define CACHE_DIR "cache" |
| 38 | #define SDMC_DIR "sdmc" | 36 | #define SDMC_DIR "sdmc" |
| 39 | #define NAND_DIR "nand" | 37 | #define NAND_DIR "nand" |
| 40 | #define SYSDATA_DIR "sysdata" | 38 | #define SYSDATA_DIR "sysdata" |
| 41 | #define SHADERCACHE_DIR "shader_cache" | ||
| 42 | #define STATESAVES_DIR "state_saves" | ||
| 43 | #define SCREENSHOTS_DIR "screenShots" | ||
| 44 | #define DUMP_DIR "dump" | ||
| 45 | #define DUMP_TEXTURES_DIR "textures" | ||
| 46 | #define DUMP_FRAMES_DIR "frames" | ||
| 47 | #define DUMP_AUDIO_DIR "audio" | ||
| 48 | #define LOGS_DIR "logs" | ||
| 49 | #define SHADERS_DIR "shaders" | ||
| 50 | #define SYSCONF_DIR "sysconf" | ||
| 51 | 39 | ||
| 52 | // Filenames | 40 | // Filenames |
| 53 | // Files in the directory returned by GetUserPath(D_CONFIG_IDX) | 41 | // Files in the directory returned by GetUserPath(D_CONFIG_IDX) |
| @@ -57,9 +45,3 @@ | |||
| 57 | 45 | ||
| 58 | // Sys files | 46 | // Sys files |
| 59 | #define SHARED_FONT "shared_font.bin" | 47 | #define SHARED_FONT "shared_font.bin" |
| 60 | |||
| 61 | // Files in the directory returned by GetUserPath(D_LOGS_IDX) | ||
| 62 | #define MAIN_LOG "emu.log" | ||
| 63 | |||
| 64 | // Files in the directory returned by GetUserPath(D_SYSCONF_IDX) | ||
| 65 | #define SYSCONF "SYSCONF" | ||
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index c618495f7..5ab938a24 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -697,6 +697,9 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new | |||
| 697 | 697 | ||
| 698 | paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; | 698 | paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; |
| 699 | paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; | 699 | paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; |
| 700 | paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; | ||
| 701 | paths[D_NAND_IDX] = paths[D_USER_IDX] + NAND_DIR DIR_SEP; | ||
| 702 | paths[D_SYSDATA_IDX] = paths[D_USER_IDX] + SYSDATA_DIR DIR_SEP; | ||
| 700 | #else | 703 | #else |
| 701 | if (FileUtil::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) { | 704 | if (FileUtil::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) { |
| 702 | paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP; | 705 | paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP; |
| @@ -712,24 +715,8 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new | |||
| 712 | paths[D_CACHE_IDX] = cache_dir + DIR_SEP EMU_DATA_DIR DIR_SEP; | 715 | paths[D_CACHE_IDX] = cache_dir + DIR_SEP EMU_DATA_DIR DIR_SEP; |
| 713 | } | 716 | } |
| 714 | #endif | 717 | #endif |
| 715 | |||
| 716 | paths[D_GAMECONFIG_IDX] = paths[D_USER_IDX] + GAMECONFIG_DIR DIR_SEP; | ||
| 717 | paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; | ||
| 718 | paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; | 718 | paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; |
| 719 | paths[D_NAND_IDX] = paths[D_USER_IDX] + NAND_DIR DIR_SEP; | 719 | paths[D_NAND_IDX] = paths[D_USER_IDX] + NAND_DIR DIR_SEP; |
| 720 | paths[D_SYSDATA_IDX] = paths[D_USER_IDX] + SYSDATA_DIR DIR_SEP; | ||
| 721 | paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; | ||
| 722 | paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; | ||
| 723 | paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; | ||
| 724 | paths[D_SCREENSHOTS_IDX] = paths[D_USER_IDX] + SCREENSHOTS_DIR DIR_SEP; | ||
| 725 | paths[D_DUMP_IDX] = paths[D_USER_IDX] + DUMP_DIR DIR_SEP; | ||
| 726 | paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; | ||
| 727 | paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; | ||
| 728 | paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; | ||
| 729 | paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP; | ||
| 730 | paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; | ||
| 731 | paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; | ||
| 732 | paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; | ||
| 733 | } | 720 | } |
| 734 | 721 | ||
| 735 | if (!newPath.empty()) { | 722 | if (!newPath.empty()) { |
| @@ -743,48 +730,15 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new | |||
| 743 | switch (DirIDX) { | 730 | switch (DirIDX) { |
| 744 | case D_ROOT_IDX: | 731 | case D_ROOT_IDX: |
| 745 | paths[D_USER_IDX] = paths[D_ROOT_IDX] + DIR_SEP; | 732 | paths[D_USER_IDX] = paths[D_ROOT_IDX] + DIR_SEP; |
| 746 | paths[D_SYSCONF_IDX] = paths[D_USER_IDX] + SYSCONF_DIR + DIR_SEP; | ||
| 747 | paths[F_SYSCONF_IDX] = paths[D_SYSCONF_IDX] + SYSCONF; | ||
| 748 | break; | 733 | break; |
| 749 | 734 | ||
| 750 | case D_USER_IDX: | 735 | case D_USER_IDX: |
| 751 | paths[D_USER_IDX] = paths[D_ROOT_IDX] + DIR_SEP; | 736 | paths[D_USER_IDX] = paths[D_ROOT_IDX] + DIR_SEP; |
| 752 | paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; | 737 | paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; |
| 753 | paths[D_GAMECONFIG_IDX] = paths[D_USER_IDX] + GAMECONFIG_DIR DIR_SEP; | ||
| 754 | paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; | ||
| 755 | paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; | 738 | paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; |
| 756 | paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; | 739 | paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; |
| 757 | paths[D_NAND_IDX] = paths[D_USER_IDX] + NAND_DIR DIR_SEP; | 740 | paths[D_NAND_IDX] = paths[D_USER_IDX] + NAND_DIR DIR_SEP; |
| 758 | paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; | ||
| 759 | paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; | ||
| 760 | paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; | ||
| 761 | paths[D_SCREENSHOTS_IDX] = paths[D_USER_IDX] + SCREENSHOTS_DIR DIR_SEP; | ||
| 762 | paths[D_DUMP_IDX] = paths[D_USER_IDX] + DUMP_DIR DIR_SEP; | ||
| 763 | paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; | ||
| 764 | paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; | ||
| 765 | paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; | ||
| 766 | paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP; | ||
| 767 | paths[D_SYSCONF_IDX] = paths[D_USER_IDX] + SYSCONF_DIR DIR_SEP; | ||
| 768 | paths[F_EMUCONFIG_IDX] = paths[D_CONFIG_IDX] + EMU_CONFIG; | ||
| 769 | paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; | ||
| 770 | paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; | ||
| 771 | paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; | ||
| 772 | break; | 741 | break; |
| 773 | |||
| 774 | case D_CONFIG_IDX: | ||
| 775 | paths[F_EMUCONFIG_IDX] = paths[D_CONFIG_IDX] + EMU_CONFIG; | ||
| 776 | paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; | ||
| 777 | paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; | ||
| 778 | break; | ||
| 779 | |||
| 780 | case D_DUMP_IDX: | ||
| 781 | paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; | ||
| 782 | paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; | ||
| 783 | paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; | ||
| 784 | break; | ||
| 785 | |||
| 786 | case D_LOGS_IDX: | ||
| 787 | paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; | ||
| 788 | } | 742 | } |
| 789 | } | 743 | } |
| 790 | 744 | ||
diff --git a/src/common/file_util.h b/src/common/file_util.h index ac58607c5..94adfcd7e 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h | |||
| @@ -21,31 +21,11 @@ enum { | |||
| 21 | D_USER_IDX, | 21 | D_USER_IDX, |
| 22 | D_ROOT_IDX, | 22 | D_ROOT_IDX, |
| 23 | D_CONFIG_IDX, | 23 | D_CONFIG_IDX, |
| 24 | D_GAMECONFIG_IDX, | ||
| 25 | D_MAPS_IDX, | ||
| 26 | D_CACHE_IDX, | 24 | D_CACHE_IDX, |
| 27 | D_SHADERCACHE_IDX, | ||
| 28 | D_SHADERS_IDX, | ||
| 29 | D_STATESAVES_IDX, | ||
| 30 | D_SCREENSHOTS_IDX, | ||
| 31 | D_SDMC_IDX, | 25 | D_SDMC_IDX, |
| 32 | D_NAND_IDX, | 26 | D_NAND_IDX, |
| 33 | D_SYSDATA_IDX, | 27 | D_SYSDATA_IDX, |
| 34 | D_HIRESTEXTURES_IDX, | ||
| 35 | D_DUMP_IDX, | ||
| 36 | D_DUMPFRAMES_IDX, | ||
| 37 | D_DUMPAUDIO_IDX, | ||
| 38 | D_DUMPTEXTURES_IDX, | ||
| 39 | D_DUMPDSP_IDX, | ||
| 40 | D_LOGS_IDX, | 28 | D_LOGS_IDX, |
| 41 | D_SYSCONF_IDX, | ||
| 42 | F_EMUCONFIG_IDX, | ||
| 43 | F_DEBUGGERCONFIG_IDX, | ||
| 44 | F_LOGGERCONFIG_IDX, | ||
| 45 | F_MAINLOG_IDX, | ||
| 46 | F_RAMDUMP_IDX, | ||
| 47 | F_ARAMDUMP_IDX, | ||
| 48 | F_SYSCONF_IDX, | ||
| 49 | NUM_PATH_INDICES | 29 | NUM_PATH_INDICES |
| 50 | }; | 30 | }; |
| 51 | 31 | ||
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index af224166a..5d74e4546 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -31,7 +31,6 @@ set(SRCS | |||
| 31 | file_sys/savedata_archive.cpp | 31 | file_sys/savedata_archive.cpp |
| 32 | gdbstub/gdbstub.cpp | 32 | gdbstub/gdbstub.cpp |
| 33 | hle/config_mem.cpp | 33 | hle/config_mem.cpp |
| 34 | hle/hle.cpp | ||
| 35 | hle/applets/applet.cpp | 34 | hle/applets/applet.cpp |
| 36 | hle/applets/erreula.cpp | 35 | hle/applets/erreula.cpp |
| 37 | hle/applets/mii_selector.cpp | 36 | hle/applets/mii_selector.cpp |
| @@ -155,7 +154,6 @@ set(SRCS | |||
| 155 | tracer/recorder.cpp | 154 | tracer/recorder.cpp |
| 156 | memory.cpp | 155 | memory.cpp |
| 157 | settings.cpp | 156 | settings.cpp |
| 158 | system.cpp | ||
| 159 | ) | 157 | ) |
| 160 | 158 | ||
| 161 | set(HEADERS | 159 | set(HEADERS |
| @@ -196,7 +194,6 @@ set(HEADERS | |||
| 196 | gdbstub/gdbstub.h | 194 | gdbstub/gdbstub.h |
| 197 | hle/config_mem.h | 195 | hle/config_mem.h |
| 198 | hle/function_wrappers.h | 196 | hle/function_wrappers.h |
| 199 | hle/hle.h | ||
| 200 | hle/ipc.h | 197 | hle/ipc.h |
| 201 | hle/applets/applet.h | 198 | hle/applets/applet.h |
| 202 | hle/applets/erreula.h | 199 | hle/applets/erreula.h |
| @@ -325,7 +322,6 @@ set(HEADERS | |||
| 325 | memory_setup.h | 322 | memory_setup.h |
| 326 | mmio.h | 323 | mmio.h |
| 327 | settings.h | 324 | settings.h |
| 328 | system.h | ||
| 329 | ) | 325 | ) |
| 330 | 326 | ||
| 331 | include_directories(../../externals/dynarmic/include) | 327 | include_directories(../../externals/dynarmic/include) |
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index e466b21b2..ccd43f431 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h | |||
| @@ -8,15 +8,22 @@ | |||
| 8 | #include "core/arm/skyeye_common/arm_regformat.h" | 8 | #include "core/arm/skyeye_common/arm_regformat.h" |
| 9 | #include "core/arm/skyeye_common/vfp/asm_vfp.h" | 9 | #include "core/arm/skyeye_common/vfp/asm_vfp.h" |
| 10 | 10 | ||
| 11 | namespace Core { | ||
| 12 | struct ThreadContext; | ||
| 13 | } | ||
| 14 | |||
| 15 | /// Generic ARM11 CPU interface | 11 | /// Generic ARM11 CPU interface |
| 16 | class ARM_Interface : NonCopyable { | 12 | class ARM_Interface : NonCopyable { |
| 17 | public: | 13 | public: |
| 18 | virtual ~ARM_Interface() {} | 14 | virtual ~ARM_Interface() {} |
| 19 | 15 | ||
| 16 | struct ThreadContext { | ||
| 17 | u32 cpu_registers[13]; | ||
| 18 | u32 sp; | ||
| 19 | u32 lr; | ||
| 20 | u32 pc; | ||
| 21 | u32 cpsr; | ||
| 22 | u32 fpu_registers[64]; | ||
| 23 | u32 fpscr; | ||
| 24 | u32 fpexc; | ||
| 25 | }; | ||
| 26 | |||
| 20 | /** | 27 | /** |
| 21 | * Runs the CPU for the given number of instructions | 28 | * Runs the CPU for the given number of instructions |
| 22 | * @param num_instructions Number of instructions to run | 29 | * @param num_instructions Number of instructions to run |
| @@ -124,13 +131,13 @@ public: | |||
| 124 | * Saves the current CPU context | 131 | * Saves the current CPU context |
| 125 | * @param ctx Thread context to save | 132 | * @param ctx Thread context to save |
| 126 | */ | 133 | */ |
| 127 | virtual void SaveContext(Core::ThreadContext& ctx) = 0; | 134 | virtual void SaveContext(ThreadContext& ctx) = 0; |
| 128 | 135 | ||
| 129 | /** | 136 | /** |
| 130 | * Loads a CPU context | 137 | * Loads a CPU context |
| 131 | * @param ctx Thread context to load | 138 | * @param ctx Thread context to load |
| 132 | */ | 139 | */ |
| 133 | virtual void LoadContext(const Core::ThreadContext& ctx) = 0; | 140 | virtual void LoadContext(const ThreadContext& ctx) = 0; |
| 134 | 141 | ||
| 135 | /// Prepare core for thread reschedule (if needed to correctly handle state) | 142 | /// Prepare core for thread reschedule (if needed to correctly handle state) |
| 136 | virtual void PrepareReschedule() = 0; | 143 | virtual void PrepareReschedule() = 0; |
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index fc4254670..5290382ff 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp | |||
| @@ -137,7 +137,7 @@ void ARM_Dynarmic::ExecuteInstructions(int num_instructions) { | |||
| 137 | AddTicks(ticks_executed); | 137 | AddTicks(ticks_executed); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | void ARM_Dynarmic::SaveContext(Core::ThreadContext& ctx) { | 140 | void ARM_Dynarmic::SaveContext(ARM_Interface::ThreadContext& ctx) { |
| 141 | memcpy(ctx.cpu_registers, jit->Regs().data(), sizeof(ctx.cpu_registers)); | 141 | memcpy(ctx.cpu_registers, jit->Regs().data(), sizeof(ctx.cpu_registers)); |
| 142 | memcpy(ctx.fpu_registers, jit->ExtRegs().data(), sizeof(ctx.fpu_registers)); | 142 | memcpy(ctx.fpu_registers, jit->ExtRegs().data(), sizeof(ctx.fpu_registers)); |
| 143 | 143 | ||
| @@ -150,7 +150,7 @@ void ARM_Dynarmic::SaveContext(Core::ThreadContext& ctx) { | |||
| 150 | ctx.fpexc = interpreter_state->VFP[VFP_FPEXC]; | 150 | ctx.fpexc = interpreter_state->VFP[VFP_FPEXC]; |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | void ARM_Dynarmic::LoadContext(const Core::ThreadContext& ctx) { | 153 | void ARM_Dynarmic::LoadContext(const ARM_Interface::ThreadContext& ctx) { |
| 154 | memcpy(jit->Regs().data(), ctx.cpu_registers, sizeof(ctx.cpu_registers)); | 154 | memcpy(jit->Regs().data(), ctx.cpu_registers, sizeof(ctx.cpu_registers)); |
| 155 | memcpy(jit->ExtRegs().data(), ctx.fpu_registers, sizeof(ctx.fpu_registers)); | 155 | memcpy(jit->ExtRegs().data(), ctx.fpu_registers, sizeof(ctx.fpu_registers)); |
| 156 | 156 | ||
diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index ced86d29b..87ab53d81 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h | |||
| @@ -10,10 +10,6 @@ | |||
| 10 | #include "core/arm/arm_interface.h" | 10 | #include "core/arm/arm_interface.h" |
| 11 | #include "core/arm/skyeye_common/armstate.h" | 11 | #include "core/arm/skyeye_common/armstate.h" |
| 12 | 12 | ||
| 13 | namespace Core { | ||
| 14 | struct ThreadContext; | ||
| 15 | } | ||
| 16 | |||
| 17 | class ARM_Dynarmic final : public ARM_Interface { | 13 | class ARM_Dynarmic final : public ARM_Interface { |
| 18 | public: | 14 | public: |
| 19 | ARM_Dynarmic(PrivilegeMode initial_mode); | 15 | ARM_Dynarmic(PrivilegeMode initial_mode); |
| @@ -33,8 +29,8 @@ public: | |||
| 33 | 29 | ||
| 34 | void AddTicks(u64 ticks) override; | 30 | void AddTicks(u64 ticks) override; |
| 35 | 31 | ||
| 36 | void SaveContext(Core::ThreadContext& ctx) override; | 32 | void SaveContext(ThreadContext& ctx) override; |
| 37 | void LoadContext(const Core::ThreadContext& ctx) override; | 33 | void LoadContext(const ThreadContext& ctx) override; |
| 38 | 34 | ||
| 39 | void PrepareReschedule() override; | 35 | void PrepareReschedule() override; |
| 40 | void ExecuteInstructions(int num_instructions) override; | 36 | void ExecuteInstructions(int num_instructions) override; |
diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp index 34c7f945e..81f9bf99e 100644 --- a/src/core/arm/dyncom/arm_dyncom.cpp +++ b/src/core/arm/dyncom/arm_dyncom.cpp | |||
| @@ -89,7 +89,7 @@ void ARM_DynCom::ExecuteInstructions(int num_instructions) { | |||
| 89 | AddTicks(ticks_executed); | 89 | AddTicks(ticks_executed); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | void ARM_DynCom::SaveContext(Core::ThreadContext& ctx) { | 92 | void ARM_DynCom::SaveContext(ThreadContext& ctx) { |
| 93 | memcpy(ctx.cpu_registers, state->Reg.data(), sizeof(ctx.cpu_registers)); | 93 | memcpy(ctx.cpu_registers, state->Reg.data(), sizeof(ctx.cpu_registers)); |
| 94 | memcpy(ctx.fpu_registers, state->ExtReg.data(), sizeof(ctx.fpu_registers)); | 94 | memcpy(ctx.fpu_registers, state->ExtReg.data(), sizeof(ctx.fpu_registers)); |
| 95 | 95 | ||
| @@ -102,7 +102,7 @@ void ARM_DynCom::SaveContext(Core::ThreadContext& ctx) { | |||
| 102 | ctx.fpexc = state->VFP[VFP_FPEXC]; | 102 | ctx.fpexc = state->VFP[VFP_FPEXC]; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | void ARM_DynCom::LoadContext(const Core::ThreadContext& ctx) { | 105 | void ARM_DynCom::LoadContext(const ThreadContext& ctx) { |
| 106 | memcpy(state->Reg.data(), ctx.cpu_registers, sizeof(ctx.cpu_registers)); | 106 | memcpy(state->Reg.data(), ctx.cpu_registers, sizeof(ctx.cpu_registers)); |
| 107 | memcpy(state->ExtReg.data(), ctx.fpu_registers, sizeof(ctx.fpu_registers)); | 107 | memcpy(state->ExtReg.data(), ctx.fpu_registers, sizeof(ctx.fpu_registers)); |
| 108 | 108 | ||
diff --git a/src/core/arm/dyncom/arm_dyncom.h b/src/core/arm/dyncom/arm_dyncom.h index 65db1f0f9..62c174f3c 100644 --- a/src/core/arm/dyncom/arm_dyncom.h +++ b/src/core/arm/dyncom/arm_dyncom.h | |||
| @@ -10,10 +10,6 @@ | |||
| 10 | #include "core/arm/skyeye_common/arm_regformat.h" | 10 | #include "core/arm/skyeye_common/arm_regformat.h" |
| 11 | #include "core/arm/skyeye_common/armstate.h" | 11 | #include "core/arm/skyeye_common/armstate.h" |
| 12 | 12 | ||
| 13 | namespace Core { | ||
| 14 | struct ThreadContext; | ||
| 15 | } | ||
| 16 | |||
| 17 | class ARM_DynCom final : public ARM_Interface { | 13 | class ARM_DynCom final : public ARM_Interface { |
| 18 | public: | 14 | public: |
| 19 | ARM_DynCom(PrivilegeMode initial_mode); | 15 | ARM_DynCom(PrivilegeMode initial_mode); |
| @@ -36,8 +32,8 @@ public: | |||
| 36 | 32 | ||
| 37 | void AddTicks(u64 ticks) override; | 33 | void AddTicks(u64 ticks) override; |
| 38 | 34 | ||
| 39 | void SaveContext(Core::ThreadContext& ctx) override; | 35 | void SaveContext(ThreadContext& ctx) override; |
| 40 | void LoadContext(const Core::ThreadContext& ctx) override; | 36 | void LoadContext(const ThreadContext& ctx) override; |
| 41 | 37 | ||
| 42 | void PrepareReschedule() override; | 38 | void PrepareReschedule() override; |
| 43 | void ExecuteInstructions(int num_instructions) override; | 39 | void ExecuteInstructions(int num_instructions) override; |
diff --git a/src/core/core.cpp b/src/core/core.cpp index 6efa18159..ee5237096 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <memory> | 5 | #include <memory> |
| 6 | |||
| 7 | #include "audio_core/audio_core.h" | ||
| 6 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 7 | #include "core/arm/arm_interface.h" | 9 | #include "core/arm/arm_interface.h" |
| 8 | #include "core/arm/dynarmic/arm_dynarmic.h" | 10 | #include "core/arm/dynarmic/arm_dynarmic.h" |
| @@ -10,18 +12,24 @@ | |||
| 10 | #include "core/core.h" | 12 | #include "core/core.h" |
| 11 | #include "core/core_timing.h" | 13 | #include "core/core_timing.h" |
| 12 | #include "core/gdbstub/gdbstub.h" | 14 | #include "core/gdbstub/gdbstub.h" |
| 13 | #include "core/hle/hle.h" | 15 | #include "core/hle/kernel/kernel.h" |
| 16 | #include "core/hle/kernel/memory.h" | ||
| 14 | #include "core/hle/kernel/thread.h" | 17 | #include "core/hle/kernel/thread.h" |
| 18 | #include "core/hle/service/service.h" | ||
| 15 | #include "core/hw/hw.h" | 19 | #include "core/hw/hw.h" |
| 20 | #include "core/loader/loader.h" | ||
| 16 | #include "core/settings.h" | 21 | #include "core/settings.h" |
| 22 | #include "video_core/video_core.h" | ||
| 17 | 23 | ||
| 18 | namespace Core { | 24 | namespace Core { |
| 19 | 25 | ||
| 20 | std::unique_ptr<ARM_Interface> g_app_core; ///< ARM11 application core | 26 | /*static*/ System System::s_instance; |
| 21 | std::unique_ptr<ARM_Interface> g_sys_core; ///< ARM11 system (OS) core | 27 | |
| 28 | System::ResultStatus System::RunLoop(int tight_loop) { | ||
| 29 | if (!cpu_core) { | ||
| 30 | return ResultStatus::ErrorNotInitialized; | ||
| 31 | } | ||
| 22 | 32 | ||
| 23 | /// Run the core CPU loop | ||
| 24 | void RunLoop(int tight_loop) { | ||
| 25 | if (GDBStub::IsServerEnabled()) { | 33 | if (GDBStub::IsServerEnabled()) { |
| 26 | GDBStub::HandlePacket(); | 34 | GDBStub::HandlePacket(); |
| 27 | 35 | ||
| @@ -32,7 +40,7 @@ void RunLoop(int tight_loop) { | |||
| 32 | GDBStub::SetCpuStepFlag(false); | 40 | GDBStub::SetCpuStepFlag(false); |
| 33 | tight_loop = 1; | 41 | tight_loop = 1; |
| 34 | } else { | 42 | } else { |
| 35 | return; | 43 | return ResultStatus::Success; |
| 36 | } | 44 | } |
| 37 | } | 45 | } |
| 38 | } | 46 | } |
| @@ -43,48 +51,114 @@ void RunLoop(int tight_loop) { | |||
| 43 | LOG_TRACE(Core_ARM11, "Idling"); | 51 | LOG_TRACE(Core_ARM11, "Idling"); |
| 44 | CoreTiming::Idle(); | 52 | CoreTiming::Idle(); |
| 45 | CoreTiming::Advance(); | 53 | CoreTiming::Advance(); |
| 46 | HLE::Reschedule(__func__); | 54 | PrepareReschedule(); |
| 47 | } else { | 55 | } else { |
| 48 | g_app_core->Run(tight_loop); | 56 | cpu_core->Run(tight_loop); |
| 49 | } | 57 | } |
| 50 | 58 | ||
| 51 | HW::Update(); | 59 | HW::Update(); |
| 52 | if (HLE::IsReschedulePending()) { | 60 | Reschedule(); |
| 53 | Kernel::Reschedule(); | 61 | |
| 54 | } | 62 | return ResultStatus::Success; |
| 63 | } | ||
| 64 | |||
| 65 | System::ResultStatus System::SingleStep() { | ||
| 66 | return RunLoop(1); | ||
| 55 | } | 67 | } |
| 56 | 68 | ||
| 57 | /// Step the CPU one instruction | 69 | System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& filepath) { |
| 58 | void SingleStep() { | 70 | if (app_loader) { |
| 59 | RunLoop(1); | 71 | app_loader.reset(); |
| 72 | } | ||
| 73 | |||
| 74 | app_loader = Loader::GetLoader(filepath); | ||
| 75 | |||
| 76 | if (!app_loader) { | ||
| 77 | LOG_CRITICAL(Core, "Failed to obtain loader for %s!", filepath.c_str()); | ||
| 78 | return ResultStatus::ErrorGetLoader; | ||
| 79 | } | ||
| 80 | |||
| 81 | boost::optional<u32> system_mode{app_loader->LoadKernelSystemMode()}; | ||
| 82 | if (!system_mode) { | ||
| 83 | LOG_CRITICAL(Core, "Failed to determine system mode!"); | ||
| 84 | return ResultStatus::ErrorSystemMode; | ||
| 85 | } | ||
| 86 | |||
| 87 | ResultStatus init_result{Init(emu_window, system_mode.get())}; | ||
| 88 | if (init_result != ResultStatus::Success) { | ||
| 89 | LOG_CRITICAL(Core, "Failed to initialize system (Error %i)!", init_result); | ||
| 90 | System::Shutdown(); | ||
| 91 | return init_result; | ||
| 92 | } | ||
| 93 | |||
| 94 | const Loader::ResultStatus load_result{app_loader->Load()}; | ||
| 95 | if (Loader::ResultStatus::Success != load_result) { | ||
| 96 | LOG_CRITICAL(Core, "Failed to load ROM (Error %i)!", load_result); | ||
| 97 | System::Shutdown(); | ||
| 98 | |||
| 99 | switch (load_result) { | ||
| 100 | case Loader::ResultStatus::ErrorEncrypted: | ||
| 101 | return ResultStatus::ErrorLoader_ErrorEncrypted; | ||
| 102 | case Loader::ResultStatus::ErrorInvalidFormat: | ||
| 103 | return ResultStatus::ErrorLoader_ErrorInvalidFormat; | ||
| 104 | default: | ||
| 105 | return ResultStatus::ErrorLoader; | ||
| 106 | } | ||
| 107 | } | ||
| 108 | return ResultStatus::Success; | ||
| 60 | } | 109 | } |
| 61 | 110 | ||
| 62 | /// Halt the core | 111 | void System::PrepareReschedule() { |
| 63 | void Halt(const char* msg) { | 112 | cpu_core->PrepareReschedule(); |
| 64 | // TODO(ShizZy): ImplementMe | 113 | reschedule_pending = true; |
| 65 | } | 114 | } |
| 66 | 115 | ||
| 67 | /// Kill the core | 116 | void System::Reschedule() { |
| 68 | void Stop() { | 117 | if (!reschedule_pending) { |
| 69 | // TODO(ShizZy): ImplementMe | 118 | return; |
| 119 | } | ||
| 120 | |||
| 121 | reschedule_pending = false; | ||
| 122 | Kernel::Reschedule(); | ||
| 70 | } | 123 | } |
| 71 | 124 | ||
| 72 | /// Initialize the core | 125 | System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { |
| 73 | void Init() { | 126 | if (cpu_core) { |
| 127 | cpu_core.reset(); | ||
| 128 | } | ||
| 129 | |||
| 130 | Memory::Init(); | ||
| 131 | |||
| 74 | if (Settings::values.use_cpu_jit) { | 132 | if (Settings::values.use_cpu_jit) { |
| 75 | g_sys_core = std::make_unique<ARM_Dynarmic>(USER32MODE); | 133 | cpu_core = std::make_unique<ARM_Dynarmic>(USER32MODE); |
| 76 | g_app_core = std::make_unique<ARM_Dynarmic>(USER32MODE); | ||
| 77 | } else { | 134 | } else { |
| 78 | g_sys_core = std::make_unique<ARM_DynCom>(USER32MODE); | 135 | cpu_core = std::make_unique<ARM_DynCom>(USER32MODE); |
| 79 | g_app_core = std::make_unique<ARM_DynCom>(USER32MODE); | 136 | } |
| 137 | |||
| 138 | CoreTiming::Init(); | ||
| 139 | HW::Init(); | ||
| 140 | Kernel::Init(system_mode); | ||
| 141 | Service::Init(); | ||
| 142 | AudioCore::Init(); | ||
| 143 | GDBStub::Init(); | ||
| 144 | |||
| 145 | if (!VideoCore::Init(emu_window)) { | ||
| 146 | return ResultStatus::ErrorVideoCore; | ||
| 80 | } | 147 | } |
| 81 | 148 | ||
| 82 | LOG_DEBUG(Core, "Initialized OK"); | 149 | LOG_DEBUG(Core, "Initialized OK"); |
| 150 | |||
| 151 | return ResultStatus::Success; | ||
| 83 | } | 152 | } |
| 84 | 153 | ||
| 85 | void Shutdown() { | 154 | void System::Shutdown() { |
| 86 | g_app_core.reset(); | 155 | GDBStub::Shutdown(); |
| 87 | g_sys_core.reset(); | 156 | AudioCore::Shutdown(); |
| 157 | VideoCore::Shutdown(); | ||
| 158 | Service::Shutdown(); | ||
| 159 | Kernel::Shutdown(); | ||
| 160 | HW::Shutdown(); | ||
| 161 | CoreTiming::Shutdown(); | ||
| 88 | 162 | ||
| 89 | LOG_DEBUG(Core, "Shutdown OK"); | 163 | LOG_DEBUG(Core, "Shutdown OK"); |
| 90 | } | 164 | } |
diff --git a/src/core/core.h b/src/core/core.h index ffbfa91c3..1015e8847 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -5,56 +5,118 @@ | |||
| 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 | ||
| 13 | class EmuWindow; | ||
| 10 | class ARM_Interface; | 14 | class ARM_Interface; |
| 11 | 15 | ||
| 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 16 | namespace Loader { |
| 17 | class AppLoader; | ||
| 18 | } | ||
| 13 | 19 | ||
| 14 | namespace Core { | 20 | namespace Core { |
| 15 | 21 | ||
| 16 | struct ThreadContext { | 22 | class System { |
| 17 | u32 cpu_registers[13]; | 23 | public: |
| 18 | u32 sp; | 24 | /** |
| 19 | u32 lr; | 25 | * Gets the instance of the System singleton class. |
| 20 | u32 pc; | 26 | * @returns Reference to the instance of the System singleton class. |
| 21 | u32 cpsr; | 27 | */ |
| 22 | u32 fpu_registers[64]; | 28 | static System& GetInstance() { |
| 23 | u32 fpscr; | 29 | return s_instance; |
| 24 | u32 fpexc; | 30 | } |
| 31 | |||
| 32 | /// Enumeration representing the return values of the System Initialize and Load process. | ||
| 33 | enum class ResultStatus : u32 { | ||
| 34 | Success, ///< Succeeded | ||
| 35 | ErrorNotInitialized, ///< Error trying to use core prior to initialization | ||
| 36 | ErrorGetLoader, ///< Error finding the correct application loader | ||
| 37 | ErrorSystemMode, ///< Error determining the system mode | ||
| 38 | ErrorLoader, ///< Error loading the specified application | ||
| 39 | ErrorLoader_ErrorEncrypted, ///< Error loading the specified application due to encryption | ||
| 40 | ErrorLoader_ErrorInvalidFormat, ///< Error loading the specified application due to an | ||
| 41 | /// invalid format | ||
| 42 | ErrorVideoCore, ///< Error in the video core | ||
| 43 | }; | ||
| 44 | |||
| 45 | /** | ||
| 46 | * Run the core CPU loop | ||
| 47 | * This function runs the core for the specified number of CPU instructions before trying to | ||
| 48 | * update hardware. This is much faster than SingleStep (and should be equivalent), as the CPU | ||
| 49 | * is not required to do a full dispatch with each instruction. NOTE: the number of instructions | ||
| 50 | * requested is not guaranteed to run, as this will be interrupted preemptively if a hardware | ||
| 51 | * update is requested (e.g. on a thread switch). | ||
| 52 | * @param tight_loop Number of instructions to execute. | ||
| 53 | * @return Result status, indicating whethor or not the operation succeeded. | ||
| 54 | */ | ||
| 55 | ResultStatus RunLoop(int tight_loop = 1000); | ||
| 56 | |||
| 57 | /** | ||
| 58 | * Step the CPU one instruction | ||
| 59 | * @return Result status, indicating whethor or not the operation succeeded. | ||
| 60 | */ | ||
| 61 | ResultStatus SingleStep(); | ||
| 62 | |||
| 63 | /// Shutdown the emulated system. | ||
| 64 | void Shutdown(); | ||
| 65 | |||
| 66 | /** | ||
| 67 | * Load an executable application. | ||
| 68 | * @param emu_window Pointer to the host-system window used for video output and keyboard input. | ||
| 69 | * @param filepath String path to the executable application to load on the host file system. | ||
| 70 | * @returns ResultStatus code, indicating if the operation succeeded. | ||
| 71 | */ | ||
| 72 | ResultStatus Load(EmuWindow* emu_window, const std::string& filepath); | ||
| 73 | |||
| 74 | /** | ||
| 75 | * Indicates if the emulated system is powered on (all subsystems initialized and able to run an | ||
| 76 | * application). | ||
| 77 | * @returns True if the emulated system is powered on, otherwise false. | ||
| 78 | */ | ||
| 79 | bool IsPoweredOn() const { | ||
| 80 | return cpu_core != nullptr; | ||
| 81 | } | ||
| 82 | |||
| 83 | /// Prepare the core emulation for a reschedule | ||
| 84 | void PrepareReschedule(); | ||
| 85 | |||
| 86 | /** | ||
| 87 | * Gets a reference to the emulated CPU. | ||
| 88 | * @returns A reference to the emulated CPU. | ||
| 89 | */ | ||
| 90 | ARM_Interface& CPU() { | ||
| 91 | return *cpu_core; | ||
| 92 | } | ||
| 93 | |||
| 94 | private: | ||
| 95 | /** | ||
| 96 | * Initialize the emulated system. | ||
| 97 | * @param emu_window Pointer to the host-system window used for video output and keyboard input. | ||
| 98 | * @param system_mode The system mode. | ||
| 99 | * @return ResultStatus code, indicating if the operation succeeded. | ||
| 100 | */ | ||
| 101 | ResultStatus Init(EmuWindow* emu_window, u32 system_mode); | ||
| 102 | |||
| 103 | /// Reschedule the core emulation | ||
| 104 | void Reschedule(); | ||
| 105 | |||
| 106 | /// AppLoader used to load the current executing application | ||
| 107 | std::unique_ptr<Loader::AppLoader> app_loader; | ||
| 108 | |||
| 109 | ///< ARM11 CPU core | ||
| 110 | std::unique_ptr<ARM_Interface> cpu_core; | ||
| 111 | |||
| 112 | /// When true, signals that a reschedule should happen | ||
| 113 | bool reschedule_pending{}; | ||
| 114 | |||
| 115 | static System s_instance; | ||
| 25 | }; | 116 | }; |
| 26 | 117 | ||
| 27 | extern std::unique_ptr<ARM_Interface> g_app_core; ///< ARM11 application core | 118 | static ARM_Interface& CPU() { |
| 28 | extern std::unique_ptr<ARM_Interface> g_sys_core; ///< ARM11 system (OS) core | 119 | return System::GetInstance().CPU(); |
| 29 | 120 | } | |
| 30 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 31 | |||
| 32 | /// Start the core | ||
| 33 | void Start(); | ||
| 34 | |||
| 35 | /** | ||
| 36 | * Run the core CPU loop | ||
| 37 | * This function runs the core for the specified number of CPU instructions before trying to update | ||
| 38 | * hardware. This is much faster than SingleStep (and should be equivalent), as the CPU is not | ||
| 39 | * required to do a full dispatch with each instruction. NOTE: the number of instructions requested | ||
| 40 | * is not guaranteed to run, as this will be interrupted preemptively if a hardware update is | ||
| 41 | * requested (e.g. on a thread switch). | ||
| 42 | */ | ||
| 43 | void RunLoop(int tight_loop = 1000); | ||
| 44 | |||
| 45 | /// Step the CPU one instruction | ||
| 46 | void SingleStep(); | ||
| 47 | |||
| 48 | /// Halt the core | ||
| 49 | void Halt(const char* msg); | ||
| 50 | |||
| 51 | /// Kill the core | ||
| 52 | void Stop(); | ||
| 53 | |||
| 54 | /// Initialize the core | ||
| 55 | void Init(); | ||
| 56 | |||
| 57 | /// Shutdown the core | ||
| 58 | void Shutdown(); | ||
| 59 | 121 | ||
| 60 | } // namespace | 122 | } // namespace Core |
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 5220b55ea..a437d0823 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp | |||
| @@ -130,7 +130,6 @@ int RegisterEvent(const char* name, TimedCallback callback) { | |||
| 130 | 130 | ||
| 131 | static void AntiCrashCallback(u64 userdata, int cycles_late) { | 131 | static void AntiCrashCallback(u64 userdata, int cycles_late) { |
| 132 | LOG_CRITICAL(Core_Timing, "Savestate broken: an unregistered event was called."); | 132 | LOG_CRITICAL(Core_Timing, "Savestate broken: an unregistered event was called."); |
| 133 | Core::Halt("invalid timing events"); | ||
| 134 | } | 133 | } |
| 135 | 134 | ||
| 136 | void RestoreRegisterEvent(int event_type, const char* name, TimedCallback callback) { | 135 | void RestoreRegisterEvent(int event_type, const char* name, TimedCallback callback) { |
| @@ -147,7 +146,7 @@ void UnregisterAllEvents() { | |||
| 147 | } | 146 | } |
| 148 | 147 | ||
| 149 | void Init() { | 148 | void Init() { |
| 150 | Core::g_app_core->down_count = INITIAL_SLICE_LENGTH; | 149 | Core::CPU().down_count = INITIAL_SLICE_LENGTH; |
| 151 | g_slice_length = INITIAL_SLICE_LENGTH; | 150 | g_slice_length = INITIAL_SLICE_LENGTH; |
| 152 | global_timer = 0; | 151 | global_timer = 0; |
| 153 | idled_cycles = 0; | 152 | idled_cycles = 0; |
| @@ -187,7 +186,7 @@ void Shutdown() { | |||
| 187 | } | 186 | } |
| 188 | 187 | ||
| 189 | u64 GetTicks() { | 188 | u64 GetTicks() { |
| 190 | return (u64)global_timer + g_slice_length - Core::g_app_core->down_count; | 189 | return (u64)global_timer + g_slice_length - Core::CPU().down_count; |
| 191 | } | 190 | } |
| 192 | 191 | ||
| 193 | u64 GetIdleTicks() { | 192 | u64 GetIdleTicks() { |
| @@ -461,18 +460,18 @@ void MoveEvents() { | |||
| 461 | } | 460 | } |
| 462 | 461 | ||
| 463 | void ForceCheck() { | 462 | void ForceCheck() { |
| 464 | s64 cycles_executed = g_slice_length - Core::g_app_core->down_count; | 463 | s64 cycles_executed = g_slice_length - Core::CPU().down_count; |
| 465 | global_timer += cycles_executed; | 464 | global_timer += cycles_executed; |
| 466 | // This will cause us to check for new events immediately. | 465 | // This will cause us to check for new events immediately. |
| 467 | Core::g_app_core->down_count = 0; | 466 | Core::CPU().down_count = 0; |
| 468 | // But let's not eat a bunch more time in Advance() because of this. | 467 | // But let's not eat a bunch more time in Advance() because of this. |
| 469 | g_slice_length = 0; | 468 | g_slice_length = 0; |
| 470 | } | 469 | } |
| 471 | 470 | ||
| 472 | void Advance() { | 471 | void Advance() { |
| 473 | s64 cycles_executed = g_slice_length - Core::g_app_core->down_count; | 472 | s64 cycles_executed = g_slice_length - Core::CPU().down_count; |
| 474 | global_timer += cycles_executed; | 473 | global_timer += cycles_executed; |
| 475 | Core::g_app_core->down_count = g_slice_length; | 474 | Core::CPU().down_count = g_slice_length; |
| 476 | 475 | ||
| 477 | if (has_ts_events) | 476 | if (has_ts_events) |
| 478 | MoveEvents(); | 477 | MoveEvents(); |
| @@ -481,7 +480,7 @@ void Advance() { | |||
| 481 | if (!first) { | 480 | if (!first) { |
| 482 | if (g_slice_length < 10000) { | 481 | if (g_slice_length < 10000) { |
| 483 | g_slice_length += 10000; | 482 | g_slice_length += 10000; |
| 484 | Core::g_app_core->down_count += g_slice_length; | 483 | Core::CPU().down_count += g_slice_length; |
| 485 | } | 484 | } |
| 486 | } else { | 485 | } else { |
| 487 | // Note that events can eat cycles as well. | 486 | // Note that events can eat cycles as well. |
| @@ -491,7 +490,7 @@ void Advance() { | |||
| 491 | 490 | ||
| 492 | const int diff = target - g_slice_length; | 491 | const int diff = target - g_slice_length; |
| 493 | g_slice_length += diff; | 492 | g_slice_length += diff; |
| 494 | Core::g_app_core->down_count += diff; | 493 | Core::CPU().down_count += diff; |
| 495 | } | 494 | } |
| 496 | if (advance_callback) | 495 | if (advance_callback) |
| 497 | advance_callback(static_cast<int>(cycles_executed)); | 496 | advance_callback(static_cast<int>(cycles_executed)); |
| @@ -507,12 +506,12 @@ void LogPendingEvents() { | |||
| 507 | } | 506 | } |
| 508 | 507 | ||
| 509 | void Idle(int max_idle) { | 508 | void Idle(int max_idle) { |
| 510 | s64 cycles_down = Core::g_app_core->down_count; | 509 | s64 cycles_down = Core::CPU().down_count; |
| 511 | if (max_idle != 0 && cycles_down > max_idle) | 510 | if (max_idle != 0 && cycles_down > max_idle) |
| 512 | cycles_down = max_idle; | 511 | cycles_down = max_idle; |
| 513 | 512 | ||
| 514 | if (first && cycles_down > 0) { | 513 | if (first && cycles_down > 0) { |
| 515 | s64 cycles_executed = g_slice_length - Core::g_app_core->down_count; | 514 | s64 cycles_executed = g_slice_length - Core::CPU().down_count; |
| 516 | s64 cycles_next_event = first->time - global_timer; | 515 | s64 cycles_next_event = first->time - global_timer; |
| 517 | 516 | ||
| 518 | if (cycles_next_event < cycles_executed + cycles_down) { | 517 | if (cycles_next_event < cycles_executed + cycles_down) { |
| @@ -527,9 +526,9 @@ void Idle(int max_idle) { | |||
| 527 | cycles_down / (float)(g_clock_rate_arm11 * 0.001f)); | 526 | cycles_down / (float)(g_clock_rate_arm11 * 0.001f)); |
| 528 | 527 | ||
| 529 | idled_cycles += cycles_down; | 528 | idled_cycles += cycles_down; |
| 530 | Core::g_app_core->down_count -= cycles_down; | 529 | Core::CPU().down_count -= cycles_down; |
| 531 | if (Core::g_app_core->down_count == 0) | 530 | if (Core::CPU().down_count == 0) |
| 532 | Core::g_app_core->down_count = -1; | 531 | Core::CPU().down_count = -1; |
| 533 | } | 532 | } |
| 534 | 533 | ||
| 535 | std::string GetScheduledEventsSummary() { | 534 | std::string GetScheduledEventsSummary() { |
diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp index 5b172df4a..51ce78435 100644 --- a/src/core/file_sys/archive_extsavedata.cpp +++ b/src/core/file_sys/archive_extsavedata.cpp | |||
| @@ -141,11 +141,10 @@ std::string GetExtSaveDataPath(const std::string& mount_point, const Path& path) | |||
| 141 | 141 | ||
| 142 | std::string GetExtDataContainerPath(const std::string& mount_point, bool shared) { | 142 | std::string GetExtDataContainerPath(const std::string& mount_point, bool shared) { |
| 143 | if (shared) | 143 | if (shared) |
| 144 | return Common::StringFromFormat("%sdata/%s/extdata/", mount_point.c_str(), | 144 | return Common::StringFromFormat("%sdata/%s/extdata/", mount_point.c_str(), SYSTEM_ID); |
| 145 | SYSTEM_ID.c_str()); | ||
| 146 | 145 | ||
| 147 | return Common::StringFromFormat("%sNintendo 3DS/%s/%s/extdata/", mount_point.c_str(), | 146 | return Common::StringFromFormat("%sNintendo 3DS/%s/%s/extdata/", mount_point.c_str(), SYSTEM_ID, |
| 148 | SYSTEM_ID.c_str(), SDCARD_ID.c_str()); | 147 | SDCARD_ID); |
| 149 | } | 148 | } |
| 150 | 149 | ||
| 151 | Path ConstructExtDataBinaryPath(u32 media_type, u32 high, u32 low) { | 150 | Path ConstructExtDataBinaryPath(u32 media_type, u32 high, u32 low) { |
diff --git a/src/core/file_sys/archive_ncch.cpp b/src/core/file_sys/archive_ncch.cpp index 6f1aadfc3..89455e39c 100644 --- a/src/core/file_sys/archive_ncch.cpp +++ b/src/core/file_sys/archive_ncch.cpp | |||
| @@ -19,7 +19,7 @@ | |||
| 19 | namespace FileSys { | 19 | namespace FileSys { |
| 20 | 20 | ||
| 21 | static std::string GetNCCHContainerPath(const std::string& nand_directory) { | 21 | static std::string GetNCCHContainerPath(const std::string& nand_directory) { |
| 22 | return Common::StringFromFormat("%s%s/title/", nand_directory.c_str(), SYSTEM_ID.c_str()); | 22 | return Common::StringFromFormat("%s%s/title/", nand_directory.c_str(), SYSTEM_ID); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | static std::string GetNCCHPath(const std::string& mount_point, u32 high, u32 low) { | 25 | static std::string GetNCCHPath(const std::string& mount_point, u32 high, u32 low) { |
diff --git a/src/core/file_sys/archive_source_sd_savedata.cpp b/src/core/file_sys/archive_source_sd_savedata.cpp index 287322d3e..e01357891 100644 --- a/src/core/file_sys/archive_source_sd_savedata.cpp +++ b/src/core/file_sys/archive_source_sd_savedata.cpp | |||
| @@ -18,7 +18,7 @@ namespace { | |||
| 18 | 18 | ||
| 19 | std::string GetSaveDataContainerPath(const std::string& sdmc_directory) { | 19 | std::string GetSaveDataContainerPath(const std::string& sdmc_directory) { |
| 20 | return Common::StringFromFormat("%sNintendo 3DS/%s/%s/title/", sdmc_directory.c_str(), | 20 | return Common::StringFromFormat("%sNintendo 3DS/%s/%s/title/", sdmc_directory.c_str(), |
| 21 | SYSTEM_ID.c_str(), SDCARD_ID.c_str()); | 21 | SYSTEM_ID, SDCARD_ID); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | std::string GetSaveDataPath(const std::string& mount_location, u64 program_id) { | 24 | std::string GetSaveDataPath(const std::string& mount_location, u64 program_id) { |
diff --git a/src/core/file_sys/archive_systemsavedata.cpp b/src/core/file_sys/archive_systemsavedata.cpp index 54e7793e0..8986b5c0e 100644 --- a/src/core/file_sys/archive_systemsavedata.cpp +++ b/src/core/file_sys/archive_systemsavedata.cpp | |||
| @@ -26,7 +26,7 @@ std::string GetSystemSaveDataPath(const std::string& mount_point, const Path& pa | |||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | std::string GetSystemSaveDataContainerPath(const std::string& mount_point) { | 28 | std::string GetSystemSaveDataContainerPath(const std::string& mount_point) { |
| 29 | return Common::StringFromFormat("%sdata/%s/sysdata/", mount_point.c_str(), SYSTEM_ID.c_str()); | 29 | return Common::StringFromFormat("%sdata/%s/sysdata/", mount_point.c_str(), SYSTEM_ID); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | Path ConstructSystemSaveDataBinaryPath(u32 high, u32 low) { | 32 | Path ConstructSystemSaveDataBinaryPath(u32 high, u32 low) { |
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index f96cbde64..d88e25073 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | #include "core/arm/arm_interface.h" | 35 | #include "core/arm/arm_interface.h" |
| 36 | #include "core/core.h" | 36 | #include "core/core.h" |
| 37 | #include "core/gdbstub/gdbstub.h" | 37 | #include "core/gdbstub/gdbstub.h" |
| 38 | #include "core/loader/loader.h" | ||
| 38 | #include "core/memory.h" | 39 | #include "core/memory.h" |
| 39 | 40 | ||
| 40 | const int GDB_BUFFER_SIZE = 10000; | 41 | const int GDB_BUFFER_SIZE = 10000; |
| @@ -449,9 +450,9 @@ static void SendSignal(u32 signal) { | |||
| 449 | 450 | ||
| 450 | latest_signal = signal; | 451 | latest_signal = signal; |
| 451 | 452 | ||
| 452 | std::string buffer = Common::StringFromFormat("T%02x%02x:%08x;%02x:%08x;", latest_signal, 15, | 453 | std::string buffer = |
| 453 | htonl(Core::g_app_core->GetPC()), 13, | 454 | Common::StringFromFormat("T%02x%02x:%08x;%02x:%08x;", latest_signal, 15, |
| 454 | htonl(Core::g_app_core->GetReg(13))); | 455 | htonl(Core::CPU().GetPC()), 13, htonl(Core::CPU().GetReg(13))); |
| 455 | LOG_DEBUG(Debug_GDBStub, "Response: %s", buffer.c_str()); | 456 | LOG_DEBUG(Debug_GDBStub, "Response: %s", buffer.c_str()); |
| 456 | SendReply(buffer.c_str()); | 457 | SendReply(buffer.c_str()); |
| 457 | } | 458 | } |
| @@ -538,15 +539,15 @@ static void ReadRegister() { | |||
| 538 | } | 539 | } |
| 539 | 540 | ||
| 540 | if (id <= R15_REGISTER) { | 541 | if (id <= R15_REGISTER) { |
| 541 | IntToGdbHex(reply, Core::g_app_core->GetReg(id)); | 542 | IntToGdbHex(reply, Core::CPU().GetReg(id)); |
| 542 | } else if (id == CPSR_REGISTER) { | 543 | } else if (id == CPSR_REGISTER) { |
| 543 | IntToGdbHex(reply, Core::g_app_core->GetCPSR()); | 544 | IntToGdbHex(reply, Core::CPU().GetCPSR()); |
| 544 | } else if (id > CPSR_REGISTER && id < FPSCR_REGISTER) { | 545 | } else if (id > CPSR_REGISTER && id < FPSCR_REGISTER) { |
| 545 | IntToGdbHex(reply, Core::g_app_core->GetVFPReg( | 546 | IntToGdbHex(reply, Core::CPU().GetVFPReg( |
| 546 | id - CPSR_REGISTER - | 547 | id - CPSR_REGISTER - |
| 547 | 1)); // VFP registers should start at 26, so one after CSPR_REGISTER | 548 | 1)); // VFP registers should start at 26, so one after CSPR_REGISTER |
| 548 | } else if (id == FPSCR_REGISTER) { | 549 | } else if (id == FPSCR_REGISTER) { |
| 549 | IntToGdbHex(reply, Core::g_app_core->GetVFPSystemReg(VFP_FPSCR)); // Get FPSCR | 550 | IntToGdbHex(reply, Core::CPU().GetVFPSystemReg(VFP_FPSCR)); // Get FPSCR |
| 550 | IntToGdbHex(reply + 8, 0); | 551 | IntToGdbHex(reply + 8, 0); |
| 551 | } else { | 552 | } else { |
| 552 | return SendReply("E01"); | 553 | return SendReply("E01"); |
| @@ -563,22 +564,22 @@ static void ReadRegisters() { | |||
| 563 | u8* bufptr = buffer; | 564 | u8* bufptr = buffer; |
| 564 | 565 | ||
| 565 | for (int reg = 0; reg <= R15_REGISTER; reg++) { | 566 | for (int reg = 0; reg <= R15_REGISTER; reg++) { |
| 566 | IntToGdbHex(bufptr + reg * CHAR_BIT, Core::g_app_core->GetReg(reg)); | 567 | IntToGdbHex(bufptr + reg * CHAR_BIT, Core::CPU().GetReg(reg)); |
| 567 | } | 568 | } |
| 568 | 569 | ||
| 569 | bufptr += (16 * CHAR_BIT); | 570 | bufptr += (16 * CHAR_BIT); |
| 570 | 571 | ||
| 571 | IntToGdbHex(bufptr, Core::g_app_core->GetCPSR()); | 572 | IntToGdbHex(bufptr, Core::CPU().GetCPSR()); |
| 572 | 573 | ||
| 573 | bufptr += CHAR_BIT; | 574 | bufptr += CHAR_BIT; |
| 574 | 575 | ||
| 575 | for (int reg = 0; reg <= 31; reg++) { | 576 | for (int reg = 0; reg <= 31; reg++) { |
| 576 | IntToGdbHex(bufptr + reg * CHAR_BIT, Core::g_app_core->GetVFPReg(reg)); | 577 | IntToGdbHex(bufptr + reg * CHAR_BIT, Core::CPU().GetVFPReg(reg)); |
| 577 | } | 578 | } |
| 578 | 579 | ||
| 579 | bufptr += (32 * CHAR_BIT); | 580 | bufptr += (32 * CHAR_BIT); |
| 580 | 581 | ||
| 581 | IntToGdbHex(bufptr, Core::g_app_core->GetVFPSystemReg(VFP_FPSCR)); | 582 | IntToGdbHex(bufptr, Core::CPU().GetVFPSystemReg(VFP_FPSCR)); |
| 582 | 583 | ||
| 583 | SendReply(reinterpret_cast<char*>(buffer)); | 584 | SendReply(reinterpret_cast<char*>(buffer)); |
| 584 | } | 585 | } |
| @@ -595,13 +596,13 @@ static void WriteRegister() { | |||
| 595 | } | 596 | } |
| 596 | 597 | ||
| 597 | if (id <= R15_REGISTER) { | 598 | if (id <= R15_REGISTER) { |
| 598 | Core::g_app_core->SetReg(id, GdbHexToInt(buffer_ptr)); | 599 | Core::CPU().SetReg(id, GdbHexToInt(buffer_ptr)); |
| 599 | } else if (id == CPSR_REGISTER) { | 600 | } else if (id == CPSR_REGISTER) { |
| 600 | Core::g_app_core->SetCPSR(GdbHexToInt(buffer_ptr)); | 601 | Core::CPU().SetCPSR(GdbHexToInt(buffer_ptr)); |
| 601 | } else if (id > CPSR_REGISTER && id < FPSCR_REGISTER) { | 602 | } else if (id > CPSR_REGISTER && id < FPSCR_REGISTER) { |
| 602 | Core::g_app_core->SetVFPReg(id - CPSR_REGISTER - 1, GdbHexToInt(buffer_ptr)); | 603 | Core::CPU().SetVFPReg(id - CPSR_REGISTER - 1, GdbHexToInt(buffer_ptr)); |
| 603 | } else if (id == FPSCR_REGISTER) { | 604 | } else if (id == FPSCR_REGISTER) { |
| 604 | Core::g_app_core->SetVFPSystemReg(VFP_FPSCR, GdbHexToInt(buffer_ptr)); | 605 | Core::CPU().SetVFPSystemReg(VFP_FPSCR, GdbHexToInt(buffer_ptr)); |
| 605 | } else { | 606 | } else { |
| 606 | return SendReply("E01"); | 607 | return SendReply("E01"); |
| 607 | } | 608 | } |
| @@ -618,20 +619,19 @@ static void WriteRegisters() { | |||
| 618 | 619 | ||
| 619 | for (int i = 0, reg = 0; reg <= FPSCR_REGISTER; i++, reg++) { | 620 | for (int i = 0, reg = 0; reg <= FPSCR_REGISTER; i++, reg++) { |
| 620 | if (reg <= R15_REGISTER) { | 621 | if (reg <= R15_REGISTER) { |
| 621 | Core::g_app_core->SetReg(reg, GdbHexToInt(buffer_ptr + i * CHAR_BIT)); | 622 | Core::CPU().SetReg(reg, GdbHexToInt(buffer_ptr + i * CHAR_BIT)); |
| 622 | } else if (reg == CPSR_REGISTER) { | 623 | } else if (reg == CPSR_REGISTER) { |
| 623 | Core::g_app_core->SetCPSR(GdbHexToInt(buffer_ptr + i * CHAR_BIT)); | 624 | Core::CPU().SetCPSR(GdbHexToInt(buffer_ptr + i * CHAR_BIT)); |
| 624 | } else if (reg == CPSR_REGISTER - 1) { | 625 | } else if (reg == CPSR_REGISTER - 1) { |
| 625 | // Dummy FPA register, ignore | 626 | // Dummy FPA register, ignore |
| 626 | } else if (reg < CPSR_REGISTER) { | 627 | } else if (reg < CPSR_REGISTER) { |
| 627 | // Dummy FPA registers, ignore | 628 | // Dummy FPA registers, ignore |
| 628 | i += 2; | 629 | i += 2; |
| 629 | } else if (reg > CPSR_REGISTER && reg < FPSCR_REGISTER) { | 630 | } else if (reg > CPSR_REGISTER && reg < FPSCR_REGISTER) { |
| 630 | Core::g_app_core->SetVFPReg(reg - CPSR_REGISTER - 1, | 631 | Core::CPU().SetVFPReg(reg - CPSR_REGISTER - 1, GdbHexToInt(buffer_ptr + i * CHAR_BIT)); |
| 631 | GdbHexToInt(buffer_ptr + i * CHAR_BIT)); | ||
| 632 | i++; // Skip padding | 632 | i++; // Skip padding |
| 633 | } else if (reg == FPSCR_REGISTER) { | 633 | } else if (reg == FPSCR_REGISTER) { |
| 634 | Core::g_app_core->SetVFPSystemReg(VFP_FPSCR, GdbHexToInt(buffer_ptr + i * CHAR_BIT)); | 634 | Core::CPU().SetVFPSystemReg(VFP_FPSCR, GdbHexToInt(buffer_ptr + i * CHAR_BIT)); |
| 635 | } | 635 | } |
| 636 | } | 636 | } |
| 637 | 637 | ||
| @@ -908,7 +908,7 @@ void ToggleServer(bool status) { | |||
| 908 | server_enabled = status; | 908 | server_enabled = status; |
| 909 | 909 | ||
| 910 | // Start server | 910 | // Start server |
| 911 | if (!IsConnected() && Core::g_sys_core != nullptr) { | 911 | if (!IsConnected() && Core::System().GetInstance().IsPoweredOn()) { |
| 912 | Init(); | 912 | Init(); |
| 913 | } | 913 | } |
| 914 | } else { | 914 | } else { |
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index 8ce0f6d2b..7875971ce 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h | |||
| @@ -7,14 +7,14 @@ | |||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "core/arm/arm_interface.h" | 8 | #include "core/arm/arm_interface.h" |
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/hle/hle.h" | 10 | #include "core/hle/kernel/kernel.h" |
| 11 | #include "core/hle/result.h" | 11 | #include "core/hle/result.h" |
| 12 | #include "core/hle/svc.h" | 12 | #include "core/hle/svc.h" |
| 13 | #include "core/memory.h" | 13 | #include "core/memory.h" |
| 14 | 14 | ||
| 15 | namespace HLE { | 15 | namespace HLE { |
| 16 | 16 | ||
| 17 | #define PARAM(n) Core::g_app_core->GetReg(n) | 17 | #define PARAM(n) Core::CPU().GetReg(n) |
| 18 | 18 | ||
| 19 | /// An invalid result code that is meant to be overwritten when a thread resumes from waiting | 19 | /// An invalid result code that is meant to be overwritten when a thread resumes from waiting |
| 20 | static const ResultCode RESULT_INVALID(0xDEADC0DE); | 20 | static const ResultCode RESULT_INVALID(0xDEADC0DE); |
| @@ -24,7 +24,7 @@ static const ResultCode RESULT_INVALID(0xDEADC0DE); | |||
| 24 | * @param res Result to return | 24 | * @param res Result to return |
| 25 | */ | 25 | */ |
| 26 | static inline void FuncReturn(u32 res) { | 26 | static inline void FuncReturn(u32 res) { |
| 27 | Core::g_app_core->SetReg(0, res); | 27 | Core::CPU().SetReg(0, res); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| @@ -33,8 +33,8 @@ static inline void FuncReturn(u32 res) { | |||
| 33 | * @todo Verify that this function is correct | 33 | * @todo Verify that this function is correct |
| 34 | */ | 34 | */ |
| 35 | static inline void FuncReturn64(u64 res) { | 35 | static inline void FuncReturn64(u64 res) { |
| 36 | Core::g_app_core->SetReg(0, (u32)(res & 0xFFFFFFFF)); | 36 | Core::CPU().SetReg(0, (u32)(res & 0xFFFFFFFF)); |
| 37 | Core::g_app_core->SetReg(1, (u32)((res >> 32) & 0xFFFFFFFF)); | 37 | Core::CPU().SetReg(1, (u32)((res >> 32) & 0xFFFFFFFF)); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 40 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -49,7 +49,7 @@ template <ResultCode func(u32*, u32, u32, u32, u32, u32)> | |||
| 49 | void Wrap() { | 49 | void Wrap() { |
| 50 | u32 param_1 = 0; | 50 | u32 param_1 = 0; |
| 51 | u32 retval = func(¶m_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw; | 51 | u32 retval = func(¶m_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw; |
| 52 | Core::g_app_core->SetReg(1, param_1); | 52 | Core::CPU().SetReg(1, param_1); |
| 53 | FuncReturn(retval); | 53 | FuncReturn(retval); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| @@ -57,19 +57,19 @@ template <ResultCode func(u32*, s32, u32, u32, u32, s32)> | |||
| 57 | void Wrap() { | 57 | void Wrap() { |
| 58 | u32 param_1 = 0; | 58 | u32 param_1 = 0; |
| 59 | u32 retval = func(¶m_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw; | 59 | u32 retval = func(¶m_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw; |
| 60 | Core::g_app_core->SetReg(1, param_1); | 60 | Core::CPU().SetReg(1, param_1); |
| 61 | FuncReturn(retval); | 61 | FuncReturn(retval); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | template <ResultCode func(s32*, u32*, s32, bool, s64)> | 64 | template <ResultCode func(s32*, u32*, s32, bool, s64)> |
| 65 | void Wrap() { | 65 | void Wrap() { |
| 66 | s32 param_1 = 0; | 66 | s32 param_1 = 0; |
| 67 | s32 retval = func(¶m_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2), | 67 | s32 retval = func(¶m_1, (Kernel::Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2), |
| 68 | (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))) | 68 | (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))) |
| 69 | .raw; | 69 | .raw; |
| 70 | 70 | ||
| 71 | if (retval != RESULT_INVALID.raw) { | 71 | if (retval != RESULT_INVALID.raw) { |
| 72 | Core::g_app_core->SetReg(1, (u32)param_1); | 72 | Core::CPU().SetReg(1, (u32)param_1); |
| 73 | FuncReturn(retval); | 73 | FuncReturn(retval); |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| @@ -84,7 +84,7 @@ template <ResultCode func(u32*)> | |||
| 84 | void Wrap() { | 84 | void Wrap() { |
| 85 | u32 param_1 = 0; | 85 | u32 param_1 = 0; |
| 86 | u32 retval = func(¶m_1).raw; | 86 | u32 retval = func(¶m_1).raw; |
| 87 | Core::g_app_core->SetReg(1, param_1); | 87 | Core::CPU().SetReg(1, param_1); |
| 88 | FuncReturn(retval); | 88 | FuncReturn(retval); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| @@ -102,24 +102,24 @@ void Wrap() { | |||
| 102 | MemoryInfo memory_info = {}; | 102 | MemoryInfo memory_info = {}; |
| 103 | PageInfo page_info = {}; | 103 | PageInfo page_info = {}; |
| 104 | u32 retval = func(&memory_info, &page_info, PARAM(2)).raw; | 104 | u32 retval = func(&memory_info, &page_info, PARAM(2)).raw; |
| 105 | Core::g_app_core->SetReg(1, memory_info.base_address); | 105 | Core::CPU().SetReg(1, memory_info.base_address); |
| 106 | Core::g_app_core->SetReg(2, memory_info.size); | 106 | Core::CPU().SetReg(2, memory_info.size); |
| 107 | Core::g_app_core->SetReg(3, memory_info.permission); | 107 | Core::CPU().SetReg(3, memory_info.permission); |
| 108 | Core::g_app_core->SetReg(4, memory_info.state); | 108 | Core::CPU().SetReg(4, memory_info.state); |
| 109 | Core::g_app_core->SetReg(5, page_info.flags); | 109 | Core::CPU().SetReg(5, page_info.flags); |
| 110 | FuncReturn(retval); | 110 | FuncReturn(retval); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | template <ResultCode func(MemoryInfo*, PageInfo*, Handle, u32)> | 113 | template <ResultCode func(MemoryInfo*, PageInfo*, Kernel::Handle, u32)> |
| 114 | void Wrap() { | 114 | void Wrap() { |
| 115 | MemoryInfo memory_info = {}; | 115 | MemoryInfo memory_info = {}; |
| 116 | PageInfo page_info = {}; | 116 | PageInfo page_info = {}; |
| 117 | u32 retval = func(&memory_info, &page_info, PARAM(2), PARAM(3)).raw; | 117 | u32 retval = func(&memory_info, &page_info, PARAM(2), PARAM(3)).raw; |
| 118 | Core::g_app_core->SetReg(1, memory_info.base_address); | 118 | Core::CPU().SetReg(1, memory_info.base_address); |
| 119 | Core::g_app_core->SetReg(2, memory_info.size); | 119 | Core::CPU().SetReg(2, memory_info.size); |
| 120 | Core::g_app_core->SetReg(3, memory_info.permission); | 120 | Core::CPU().SetReg(3, memory_info.permission); |
| 121 | Core::g_app_core->SetReg(4, memory_info.state); | 121 | Core::CPU().SetReg(4, memory_info.state); |
| 122 | Core::g_app_core->SetReg(5, page_info.flags); | 122 | Core::CPU().SetReg(5, page_info.flags); |
| 123 | FuncReturn(retval); | 123 | FuncReturn(retval); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| @@ -127,7 +127,7 @@ template <ResultCode func(s32*, u32)> | |||
| 127 | void Wrap() { | 127 | void Wrap() { |
| 128 | s32 param_1 = 0; | 128 | s32 param_1 = 0; |
| 129 | u32 retval = func(¶m_1, PARAM(1)).raw; | 129 | u32 retval = func(¶m_1, PARAM(1)).raw; |
| 130 | Core::g_app_core->SetReg(1, param_1); | 130 | Core::CPU().SetReg(1, param_1); |
| 131 | FuncReturn(retval); | 131 | FuncReturn(retval); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| @@ -140,7 +140,7 @@ template <ResultCode func(u32*, u32)> | |||
| 140 | void Wrap() { | 140 | void Wrap() { |
| 141 | u32 param_1 = 0; | 141 | u32 param_1 = 0; |
| 142 | u32 retval = func(¶m_1, PARAM(1)).raw; | 142 | u32 retval = func(¶m_1, PARAM(1)).raw; |
| 143 | Core::g_app_core->SetReg(1, param_1); | 143 | Core::CPU().SetReg(1, param_1); |
| 144 | FuncReturn(retval); | 144 | FuncReturn(retval); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| @@ -160,7 +160,7 @@ template <ResultCode func(u32*, const char*)> | |||
| 160 | void Wrap() { | 160 | void Wrap() { |
| 161 | u32 param_1 = 0; | 161 | u32 param_1 = 0; |
| 162 | u32 retval = func(¶m_1, (char*)Memory::GetPointer(PARAM(1))).raw; | 162 | u32 retval = func(¶m_1, (char*)Memory::GetPointer(PARAM(1))).raw; |
| 163 | Core::g_app_core->SetReg(1, param_1); | 163 | Core::CPU().SetReg(1, param_1); |
| 164 | FuncReturn(retval); | 164 | FuncReturn(retval); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| @@ -168,7 +168,7 @@ template <ResultCode func(u32*, s32, s32)> | |||
| 168 | void Wrap() { | 168 | void Wrap() { |
| 169 | u32 param_1 = 0; | 169 | u32 param_1 = 0; |
| 170 | u32 retval = func(¶m_1, PARAM(1), PARAM(2)).raw; | 170 | u32 retval = func(¶m_1, PARAM(1), PARAM(2)).raw; |
| 171 | Core::g_app_core->SetReg(1, param_1); | 171 | Core::CPU().SetReg(1, param_1); |
| 172 | FuncReturn(retval); | 172 | FuncReturn(retval); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| @@ -176,7 +176,7 @@ template <ResultCode func(s32*, u32, s32)> | |||
| 176 | void Wrap() { | 176 | void Wrap() { |
| 177 | s32 param_1 = 0; | 177 | s32 param_1 = 0; |
| 178 | u32 retval = func(¶m_1, PARAM(1), PARAM(2)).raw; | 178 | u32 retval = func(¶m_1, PARAM(1), PARAM(2)).raw; |
| 179 | Core::g_app_core->SetReg(1, param_1); | 179 | Core::CPU().SetReg(1, param_1); |
| 180 | FuncReturn(retval); | 180 | FuncReturn(retval); |
| 181 | } | 181 | } |
| 182 | 182 | ||
| @@ -184,8 +184,8 @@ template <ResultCode func(s64*, u32, s32)> | |||
| 184 | void Wrap() { | 184 | void Wrap() { |
| 185 | s64 param_1 = 0; | 185 | s64 param_1 = 0; |
| 186 | u32 retval = func(¶m_1, PARAM(1), PARAM(2)).raw; | 186 | u32 retval = func(¶m_1, PARAM(1), PARAM(2)).raw; |
| 187 | Core::g_app_core->SetReg(1, (u32)param_1); | 187 | Core::CPU().SetReg(1, (u32)param_1); |
| 188 | Core::g_app_core->SetReg(2, (u32)(param_1 >> 32)); | 188 | Core::CPU().SetReg(2, (u32)(param_1 >> 32)); |
| 189 | FuncReturn(retval); | 189 | FuncReturn(retval); |
| 190 | } | 190 | } |
| 191 | 191 | ||
| @@ -194,7 +194,7 @@ void Wrap() { | |||
| 194 | u32 param_1 = 0; | 194 | u32 param_1 = 0; |
| 195 | // The last parameter is passed in R0 instead of R4 | 195 | // The last parameter is passed in R0 instead of R4 |
| 196 | u32 retval = func(¶m_1, PARAM(1), PARAM(2), PARAM(3), PARAM(0)).raw; | 196 | u32 retval = func(¶m_1, PARAM(1), PARAM(2), PARAM(3), PARAM(0)).raw; |
| 197 | Core::g_app_core->SetReg(1, param_1); | 197 | Core::CPU().SetReg(1, param_1); |
| 198 | FuncReturn(retval); | 198 | FuncReturn(retval); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| @@ -205,30 +205,30 @@ void Wrap() { | |||
| 205 | FuncReturn(func(PARAM(0), param1, param2).raw); | 205 | FuncReturn(func(PARAM(0), param1, param2).raw); |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | template <ResultCode func(s64*, Handle, u32)> | 208 | template <ResultCode func(s64*, Kernel::Handle, u32)> |
| 209 | void Wrap() { | 209 | void Wrap() { |
| 210 | s64 param_1 = 0; | 210 | s64 param_1 = 0; |
| 211 | u32 retval = func(¶m_1, PARAM(1), PARAM(2)).raw; | 211 | u32 retval = func(¶m_1, PARAM(1), PARAM(2)).raw; |
| 212 | Core::g_app_core->SetReg(1, (u32)param_1); | 212 | Core::CPU().SetReg(1, (u32)param_1); |
| 213 | Core::g_app_core->SetReg(2, (u32)(param_1 >> 32)); | 213 | Core::CPU().SetReg(2, (u32)(param_1 >> 32)); |
| 214 | FuncReturn(retval); | 214 | FuncReturn(retval); |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | template <ResultCode func(Handle, u32)> | 217 | template <ResultCode func(Kernel::Handle, u32)> |
| 218 | void Wrap() { | 218 | void Wrap() { |
| 219 | FuncReturn(func(PARAM(0), PARAM(1)).raw); | 219 | FuncReturn(func(PARAM(0), PARAM(1)).raw); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | template <ResultCode func(Handle*, Handle*, const char*, u32)> | 222 | template <ResultCode func(Kernel::Handle*, Kernel::Handle*, const char*, u32)> |
| 223 | void Wrap() { | 223 | void Wrap() { |
| 224 | Handle param_1 = 0; | 224 | Kernel::Handle param_1 = 0; |
| 225 | Handle param_2 = 0; | 225 | Kernel::Handle param_2 = 0; |
| 226 | u32 retval = func(¶m_1, ¶m_2, | 226 | u32 retval = func(¶m_1, ¶m_2, |
| 227 | reinterpret_cast<const char*>(Memory::GetPointer(PARAM(2))), PARAM(3)) | 227 | reinterpret_cast<const char*>(Memory::GetPointer(PARAM(2))), PARAM(3)) |
| 228 | .raw; | 228 | .raw; |
| 229 | // The first out parameter is moved into R2 and the second is moved into R1. | 229 | // The first out parameter is moved into R2 and the second is moved into R1. |
| 230 | Core::g_app_core->SetReg(1, param_2); | 230 | Core::CPU().SetReg(1, param_2); |
| 231 | Core::g_app_core->SetReg(2, param_1); | 231 | Core::CPU().SetReg(2, param_1); |
| 232 | FuncReturn(retval); | 232 | FuncReturn(retval); |
| 233 | } | 233 | } |
| 234 | 234 | ||
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index 41b772163..d73d98a70 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp | |||
| @@ -26,9 +26,9 @@ void Reschedule(const char* reason) { | |||
| 26 | // routines. This simulates that time by artificially advancing the number of CPU "ticks". | 26 | // routines. This simulates that time by artificially advancing the number of CPU "ticks". |
| 27 | // The value was chosen empirically, it seems to work well enough for everything tested, but | 27 | // The value was chosen empirically, it seems to work well enough for everything tested, but |
| 28 | // is likely not ideal. We should find a more accurate way to simulate timing with HLE. | 28 | // is likely not ideal. We should find a more accurate way to simulate timing with HLE. |
| 29 | Core::g_app_core->AddTicks(4000); | 29 | Core::AppCore().AddTicks(4000); |
| 30 | 30 | ||
| 31 | Core::g_app_core->PrepareReschedule(); | 31 | Core::AppCore().PrepareReschedule(); |
| 32 | 32 | ||
| 33 | reschedule = true; | 33 | reschedule = true; |
| 34 | } | 34 | } |
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h deleted file mode 100644 index 23859e129..000000000 --- a/src/core/hle/hle.h +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | typedef u32 Handle; | ||
| 10 | typedef s32 Result; | ||
| 11 | |||
| 12 | const Handle INVALID_HANDLE = 0; | ||
| 13 | |||
| 14 | namespace HLE { | ||
| 15 | |||
| 16 | void Reschedule(const char* reason); | ||
| 17 | bool IsReschedulePending(); | ||
| 18 | void DoneRescheduling(); | ||
| 19 | |||
| 20 | void Init(); | ||
| 21 | void Shutdown(); | ||
| 22 | |||
| 23 | } // namespace | ||
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index b5a0cc3a3..01fab123e 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/common_types.h" | 5 | #include "common/common_types.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/hle/hle.h" | ||
| 8 | #include "core/hle/kernel/address_arbiter.h" | 7 | #include "core/hle/kernel/address_arbiter.h" |
| 9 | #include "core/hle/kernel/thread.h" | 8 | #include "core/hle/kernel/thread.h" |
| 10 | #include "core/memory.h" | 9 | #include "core/memory.h" |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 1adcf6c71..9503e7d04 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -11,11 +11,12 @@ | |||
| 11 | #include <vector> | 11 | #include <vector> |
| 12 | #include <boost/smart_ptr/intrusive_ptr.hpp> | 12 | #include <boost/smart_ptr/intrusive_ptr.hpp> |
| 13 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 14 | #include "core/hle/hle.h" | ||
| 15 | #include "core/hle/result.h" | 14 | #include "core/hle/result.h" |
| 16 | 15 | ||
| 17 | namespace Kernel { | 16 | namespace Kernel { |
| 18 | 17 | ||
| 18 | using Handle = u32; | ||
| 19 | |||
| 19 | class Thread; | 20 | class Thread; |
| 20 | 21 | ||
| 21 | // TODO: Verify code | 22 | // TODO: Verify code |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 18b696f72..5fb95dada 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -14,7 +14,6 @@ | |||
| 14 | #include "core/arm/skyeye_common/armstate.h" | 14 | #include "core/arm/skyeye_common/armstate.h" |
| 15 | #include "core/core.h" | 15 | #include "core/core.h" |
| 16 | #include "core/core_timing.h" | 16 | #include "core/core_timing.h" |
| 17 | #include "core/hle/hle.h" | ||
| 18 | #include "core/hle/kernel/kernel.h" | 17 | #include "core/hle/kernel/kernel.h" |
| 19 | #include "core/hle/kernel/memory.h" | 18 | #include "core/hle/kernel/memory.h" |
| 20 | #include "core/hle/kernel/mutex.h" | 19 | #include "core/hle/kernel/mutex.h" |
| @@ -188,7 +187,7 @@ static void SwitchContext(Thread* new_thread) { | |||
| 188 | // Save context for previous thread | 187 | // Save context for previous thread |
| 189 | if (previous_thread) { | 188 | if (previous_thread) { |
| 190 | previous_thread->last_running_ticks = CoreTiming::GetTicks(); | 189 | previous_thread->last_running_ticks = CoreTiming::GetTicks(); |
| 191 | Core::g_app_core->SaveContext(previous_thread->context); | 190 | Core::CPU().SaveContext(previous_thread->context); |
| 192 | 191 | ||
| 193 | if (previous_thread->status == THREADSTATUS_RUNNING) { | 192 | if (previous_thread->status == THREADSTATUS_RUNNING) { |
| 194 | // This is only the case when a reschedule is triggered without the current thread | 193 | // This is only the case when a reschedule is triggered without the current thread |
| @@ -214,8 +213,8 @@ static void SwitchContext(Thread* new_thread) { | |||
| 214 | // Restores thread to its nominal priority if it has been temporarily changed | 213 | // Restores thread to its nominal priority if it has been temporarily changed |
| 215 | new_thread->current_priority = new_thread->nominal_priority; | 214 | new_thread->current_priority = new_thread->nominal_priority; |
| 216 | 215 | ||
| 217 | Core::g_app_core->LoadContext(new_thread->context); | 216 | Core::CPU().LoadContext(new_thread->context); |
| 218 | Core::g_app_core->SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress()); | 217 | Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress()); |
| 219 | } else { | 218 | } else { |
| 220 | current_thread = nullptr; | 219 | current_thread = nullptr; |
| 221 | } | 220 | } |
| @@ -330,7 +329,7 @@ void Thread::ResumeFromWait() { | |||
| 330 | 329 | ||
| 331 | ready_queue.push_back(current_priority, this); | 330 | ready_queue.push_back(current_priority, this); |
| 332 | status = THREADSTATUS_READY; | 331 | status = THREADSTATUS_READY; |
| 333 | HLE::Reschedule(__func__); | 332 | Core::System::GetInstance().PrepareReschedule(); |
| 334 | } | 333 | } |
| 335 | 334 | ||
| 336 | /** | 335 | /** |
| @@ -385,9 +384,9 @@ std::tuple<u32, u32, bool> GetFreeThreadLocalSlot(std::vector<std::bitset<8>>& t | |||
| 385 | * @param entry_point Address of entry point for execution | 384 | * @param entry_point Address of entry point for execution |
| 386 | * @param arg User argument for thread | 385 | * @param arg User argument for thread |
| 387 | */ | 386 | */ |
| 388 | static void ResetThreadContext(Core::ThreadContext& context, u32 stack_top, u32 entry_point, | 387 | static void ResetThreadContext(ARM_Interface::ThreadContext& context, u32 stack_top, |
| 389 | u32 arg) { | 388 | u32 entry_point, u32 arg) { |
| 390 | memset(&context, 0, sizeof(Core::ThreadContext)); | 389 | memset(&context, 0, sizeof(ARM_Interface::ThreadContext)); |
| 391 | 390 | ||
| 392 | context.cpu_registers[0] = arg; | 391 | context.cpu_registers[0] = arg; |
| 393 | context.pc = entry_point; | 392 | context.pc = entry_point; |
| @@ -545,8 +544,6 @@ void Reschedule() { | |||
| 545 | Thread* cur = GetCurrentThread(); | 544 | Thread* cur = GetCurrentThread(); |
| 546 | Thread* next = PopNextReadyThread(); | 545 | Thread* next = PopNextReadyThread(); |
| 547 | 546 | ||
| 548 | HLE::DoneRescheduling(); | ||
| 549 | |||
| 550 | if (cur && next) { | 547 | if (cur && next) { |
| 551 | LOG_TRACE(Kernel, "context switch %u -> %u", cur->GetObjectId(), next->GetObjectId()); | 548 | LOG_TRACE(Kernel, "context switch %u -> %u", cur->GetObjectId(), next->GetObjectId()); |
| 552 | } else if (cur) { | 549 | } else if (cur) { |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index d4fefc573..c77ac644d 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -10,8 +10,8 @@ | |||
| 10 | #include <boost/container/flat_map.hpp> | 10 | #include <boost/container/flat_map.hpp> |
| 11 | #include <boost/container/flat_set.hpp> | 11 | #include <boost/container/flat_set.hpp> |
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "core/arm/arm_interface.h" | ||
| 13 | #include "core/core.h" | 14 | #include "core/core.h" |
| 14 | #include "core/hle/hle.h" | ||
| 15 | #include "core/hle/kernel/kernel.h" | 15 | #include "core/hle/kernel/kernel.h" |
| 16 | #include "core/hle/result.h" | 16 | #include "core/hle/result.h" |
| 17 | 17 | ||
| @@ -158,7 +158,7 @@ public: | |||
| 158 | return !wait_objects.empty(); | 158 | return !wait_objects.empty(); |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | Core::ThreadContext context; | 161 | ARM_Interface::ThreadContext context; |
| 162 | 162 | ||
| 163 | u32 thread_id; | 163 | u32 thread_id; |
| 164 | 164 | ||
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 09205e4b2..6cddc1fdb 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -23,7 +23,6 @@ | |||
| 23 | #include "core/file_sys/archive_systemsavedata.h" | 23 | #include "core/file_sys/archive_systemsavedata.h" |
| 24 | #include "core/file_sys/directory_backend.h" | 24 | #include "core/file_sys/directory_backend.h" |
| 25 | #include "core/file_sys/file_backend.h" | 25 | #include "core/file_sys/file_backend.h" |
| 26 | #include "core/hle/hle.h" | ||
| 27 | #include "core/hle/kernel/client_session.h" | 26 | #include "core/hle/kernel/client_session.h" |
| 28 | #include "core/hle/result.h" | 27 | #include "core/hle/result.h" |
| 29 | #include "core/hle/service/fs/archive.h" | 28 | #include "core/hle/service/fs/archive.h" |
| @@ -46,9 +45,7 @@ struct hash<Service::FS::ArchiveIdCode> { | |||
| 46 | }; | 45 | }; |
| 47 | } | 46 | } |
| 48 | 47 | ||
| 49 | /// TODO(Subv): Confirm length of these strings | 48 | static constexpr Kernel::Handle INVALID_HANDLE{}; |
| 50 | const std::string SYSTEM_ID = "00000000000000000000000000000000"; | ||
| 51 | const std::string SDCARD_ID = "00000000000000000000000000000000"; | ||
| 52 | 49 | ||
| 53 | namespace Service { | 50 | namespace Service { |
| 54 | namespace FS { | 51 | namespace FS { |
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index 7ba62ede0..519c1f3a9 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h | |||
| @@ -17,9 +17,9 @@ class FileBackend; | |||
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | /// The unique system identifier hash, also known as ID0 | 19 | /// The unique system identifier hash, also known as ID0 |
| 20 | extern const std::string SYSTEM_ID; | 20 | static constexpr char SYSTEM_ID[]{"00000000000000000000000000000000"}; |
| 21 | /// The scrambled SD card CID, also known as ID1 | 21 | /// The scrambled SD card CID, also known as ID1 |
| 22 | extern const std::string SDCARD_ID; | 22 | static constexpr char SDCARD_ID[]{"00000000000000000000000000000000"}; |
| 23 | 23 | ||
| 24 | namespace Service { | 24 | namespace Service { |
| 25 | namespace FS { | 25 | namespace FS { |
diff --git a/src/core/hle/service/ir/ir.cpp b/src/core/hle/service/ir/ir.cpp index 4d6639ded..7f1731a50 100644 --- a/src/core/hle/service/ir/ir.cpp +++ b/src/core/hle/service/ir/ir.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/hle/kernel/event.h" | 5 | #include "core/hle/kernel/event.h" |
| 6 | #include "core/hle/kernel/kernel.h" | ||
| 6 | #include "core/hle/kernel/shared_memory.h" | 7 | #include "core/hle/kernel/shared_memory.h" |
| 7 | #include "core/hle/service/ir/ir.h" | 8 | #include "core/hle/service/ir/ir.h" |
| 8 | #include "core/hle/service/ir/ir_rst.h" | 9 | #include "core/hle/service/ir/ir_rst.h" |
| @@ -36,7 +37,7 @@ void InitializeIrNopShared(Interface* self) { | |||
| 36 | u32 send_buff_size = cmd_buff[4]; | 37 | u32 send_buff_size = cmd_buff[4]; |
| 37 | u32 unk2 = cmd_buff[5]; | 38 | u32 unk2 = cmd_buff[5]; |
| 38 | u8 baud_rate = cmd_buff[6] & 0xFF; | 39 | u8 baud_rate = cmd_buff[6] & 0xFF; |
| 39 | Handle handle = cmd_buff[8]; | 40 | Kernel::Handle handle = cmd_buff[8]; |
| 40 | 41 | ||
| 41 | if (Kernel::g_handle_table.IsValid(handle)) { | 42 | if (Kernel::g_handle_table.IsValid(handle)) { |
| 42 | transfer_shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle); | 43 | transfer_shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle); |
diff --git a/src/core/hle/service/ldr_ro/ldr_ro.cpp b/src/core/hle/service/ldr_ro/ldr_ro.cpp index 9e5d6a318..8d00a7577 100644 --- a/src/core/hle/service/ldr_ro/ldr_ro.cpp +++ b/src/core/hle/service/ldr_ro/ldr_ro.cpp | |||
| @@ -457,7 +457,7 @@ static void LoadCRO(Interface* self, bool link_on_load_bug_fix) { | |||
| 457 | } | 457 | } |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | Core::g_app_core->ClearInstructionCache(); | 460 | Core::CPU().ClearInstructionCache(); |
| 461 | 461 | ||
| 462 | LOG_INFO(Service_LDR, "CRO \"%s\" loaded at 0x%08X, fixed_end=0x%08X", cro.ModuleName().data(), | 462 | LOG_INFO(Service_LDR, "CRO \"%s\" loaded at 0x%08X, fixed_end=0x%08X", cro.ModuleName().data(), |
| 463 | cro_address, cro_address + fix_size); | 463 | cro_address, cro_address + fix_size); |
| @@ -562,7 +562,7 @@ static void UnloadCRO(Interface* self) { | |||
| 562 | memory_synchronizer.RemoveMemoryBlock(cro_address, cro_buffer_ptr); | 562 | memory_synchronizer.RemoveMemoryBlock(cro_address, cro_buffer_ptr); |
| 563 | } | 563 | } |
| 564 | 564 | ||
| 565 | Core::g_app_core->ClearInstructionCache(); | 565 | Core::CPU().ClearInstructionCache(); |
| 566 | 566 | ||
| 567 | cmd_buff[1] = result.raw; | 567 | cmd_buff[1] = result.raw; |
| 568 | } | 568 | } |
| @@ -624,7 +624,7 @@ static void LinkCRO(Interface* self) { | |||
| 624 | } | 624 | } |
| 625 | 625 | ||
| 626 | memory_synchronizer.SynchronizeOriginalMemory(); | 626 | memory_synchronizer.SynchronizeOriginalMemory(); |
| 627 | Core::g_app_core->ClearInstructionCache(); | 627 | Core::CPU().ClearInstructionCache(); |
| 628 | 628 | ||
| 629 | cmd_buff[1] = result.raw; | 629 | cmd_buff[1] = result.raw; |
| 630 | } | 630 | } |
| @@ -686,7 +686,7 @@ static void UnlinkCRO(Interface* self) { | |||
| 686 | } | 686 | } |
| 687 | 687 | ||
| 688 | memory_synchronizer.SynchronizeOriginalMemory(); | 688 | memory_synchronizer.SynchronizeOriginalMemory(); |
| 689 | Core::g_app_core->ClearInstructionCache(); | 689 | Core::CPU().ClearInstructionCache(); |
| 690 | 690 | ||
| 691 | cmd_buff[1] = result.raw; | 691 | cmd_buff[1] = result.raw; |
| 692 | } | 692 | } |
diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp index 7ced36439..4f1dd2fce 100644 --- a/src/core/hle/service/mic_u.cpp +++ b/src/core/hle/service/mic_u.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 6 | #include "core/hle/kernel/event.h" | 6 | #include "core/hle/kernel/event.h" |
| 7 | #include "core/hle/kernel/kernel.h" | ||
| 7 | #include "core/hle/kernel/shared_memory.h" | 8 | #include "core/hle/kernel/shared_memory.h" |
| 8 | #include "core/hle/service/mic_u.h" | 9 | #include "core/hle/service/mic_u.h" |
| 9 | 10 | ||
| @@ -50,7 +51,7 @@ static bool audio_buffer_loop; | |||
| 50 | static void MapSharedMem(Interface* self) { | 51 | static void MapSharedMem(Interface* self) { |
| 51 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 52 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 52 | u32 size = cmd_buff[1]; | 53 | u32 size = cmd_buff[1]; |
| 53 | Handle mem_handle = cmd_buff[3]; | 54 | Kernel::Handle mem_handle = cmd_buff[3]; |
| 54 | shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(mem_handle); | 55 | shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(mem_handle); |
| 55 | if (shared_memory) { | 56 | if (shared_memory) { |
| 56 | shared_memory->name = "MIC_U:shared_memory"; | 57 | shared_memory->name = "MIC_U:shared_memory"; |
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 5839d7230..2ca270de3 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -166,7 +166,8 @@ static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 add | |||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | /// Maps a memory block to specified address | 168 | /// Maps a memory block to specified address |
| 169 | static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { | 169 | static ResultCode MapMemoryBlock(Kernel::Handle handle, u32 addr, u32 permissions, |
| 170 | u32 other_permissions) { | ||
| 170 | using Kernel::SharedMemory; | 171 | using Kernel::SharedMemory; |
| 171 | using Kernel::MemoryPermission; | 172 | using Kernel::MemoryPermission; |
| 172 | 173 | ||
| @@ -198,7 +199,7 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o | |||
| 198 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | 199 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); |
| 199 | } | 200 | } |
| 200 | 201 | ||
| 201 | static ResultCode UnmapMemoryBlock(Handle handle, u32 addr) { | 202 | static ResultCode UnmapMemoryBlock(Kernel::Handle handle, u32 addr) { |
| 202 | using Kernel::SharedMemory; | 203 | using Kernel::SharedMemory; |
| 203 | 204 | ||
| 204 | LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X", handle, addr); | 205 | LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X", handle, addr); |
| @@ -213,7 +214,7 @@ static ResultCode UnmapMemoryBlock(Handle handle, u32 addr) { | |||
| 213 | } | 214 | } |
| 214 | 215 | ||
| 215 | /// Connect to an OS service given the port name, returns the handle to the port to out | 216 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| 216 | static ResultCode ConnectToPort(Handle* out_handle, const char* port_name) { | 217 | static ResultCode ConnectToPort(Kernel::Handle* out_handle, const char* port_name) { |
| 217 | if (port_name == nullptr) | 218 | if (port_name == nullptr) |
| 218 | return ERR_NOT_FOUND; | 219 | return ERR_NOT_FOUND; |
| 219 | if (std::strlen(port_name) > 11) | 220 | if (std::strlen(port_name) > 11) |
| @@ -238,7 +239,7 @@ static ResultCode ConnectToPort(Handle* out_handle, const char* port_name) { | |||
| 238 | } | 239 | } |
| 239 | 240 | ||
| 240 | /// Makes a blocking IPC call to an OS service. | 241 | /// Makes a blocking IPC call to an OS service. |
| 241 | static ResultCode SendSyncRequest(Handle handle) { | 242 | static ResultCode SendSyncRequest(Kernel::Handle handle) { |
| 242 | SharedPtr<Kernel::ClientSession> session = | 243 | SharedPtr<Kernel::ClientSession> session = |
| 243 | Kernel::g_handle_table.Get<Kernel::ClientSession>(handle); | 244 | Kernel::g_handle_table.Get<Kernel::ClientSession>(handle); |
| 244 | if (session == nullptr) { | 245 | if (session == nullptr) { |
| @@ -253,13 +254,13 @@ static ResultCode SendSyncRequest(Handle handle) { | |||
| 253 | } | 254 | } |
| 254 | 255 | ||
| 255 | /// Close a handle | 256 | /// Close a handle |
| 256 | static ResultCode CloseHandle(Handle handle) { | 257 | static ResultCode CloseHandle(Kernel::Handle handle) { |
| 257 | LOG_TRACE(Kernel_SVC, "Closing handle 0x%08X", handle); | 258 | LOG_TRACE(Kernel_SVC, "Closing handle 0x%08X", handle); |
| 258 | return Kernel::g_handle_table.Close(handle); | 259 | return Kernel::g_handle_table.Close(handle); |
| 259 | } | 260 | } |
| 260 | 261 | ||
| 261 | /// Wait for a handle to synchronize, timeout after the specified nanoseconds | 262 | /// Wait for a handle to synchronize, timeout after the specified nanoseconds |
| 262 | static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) { | 263 | static ResultCode WaitSynchronization1(Kernel::Handle handle, s64 nano_seconds) { |
| 263 | auto object = Kernel::g_handle_table.GetWaitObject(handle); | 264 | auto object = Kernel::g_handle_table.GetWaitObject(handle); |
| 264 | Kernel::Thread* thread = Kernel::GetCurrentThread(); | 265 | Kernel::Thread* thread = Kernel::GetCurrentThread(); |
| 265 | 266 | ||
| @@ -295,8 +296,8 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) { | |||
| 295 | } | 296 | } |
| 296 | 297 | ||
| 297 | /// Wait for the given handles to synchronize, timeout after the specified nanoseconds | 298 | /// Wait for the given handles to synchronize, timeout after the specified nanoseconds |
| 298 | static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wait_all, | 299 | static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 handle_count, |
| 299 | s64 nano_seconds) { | 300 | bool wait_all, s64 nano_seconds) { |
| 300 | Kernel::Thread* thread = Kernel::GetCurrentThread(); | 301 | Kernel::Thread* thread = Kernel::GetCurrentThread(); |
| 301 | 302 | ||
| 302 | // Check if 'handles' is invalid | 303 | // Check if 'handles' is invalid |
| @@ -423,7 +424,7 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou | |||
| 423 | } | 424 | } |
| 424 | 425 | ||
| 425 | /// Create an address arbiter (to allocate access to shared resources) | 426 | /// Create an address arbiter (to allocate access to shared resources) |
| 426 | static ResultCode CreateAddressArbiter(Handle* out_handle) { | 427 | static ResultCode CreateAddressArbiter(Kernel::Handle* out_handle) { |
| 427 | using Kernel::AddressArbiter; | 428 | using Kernel::AddressArbiter; |
| 428 | 429 | ||
| 429 | SharedPtr<AddressArbiter> arbiter = AddressArbiter::Create(); | 430 | SharedPtr<AddressArbiter> arbiter = AddressArbiter::Create(); |
| @@ -433,7 +434,7 @@ static ResultCode CreateAddressArbiter(Handle* out_handle) { | |||
| 433 | } | 434 | } |
| 434 | 435 | ||
| 435 | /// Arbitrate address | 436 | /// Arbitrate address |
| 436 | static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value, | 437 | static ResultCode ArbitrateAddress(Kernel::Handle handle, u32 address, u32 type, u32 value, |
| 437 | s64 nanoseconds) { | 438 | s64 nanoseconds) { |
| 438 | using Kernel::AddressArbiter; | 439 | using Kernel::AddressArbiter; |
| 439 | 440 | ||
| @@ -476,7 +477,7 @@ static void OutputDebugString(const char* string) { | |||
| 476 | } | 477 | } |
| 477 | 478 | ||
| 478 | /// Get resource limit | 479 | /// Get resource limit |
| 479 | static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle) { | 480 | static ResultCode GetResourceLimit(Kernel::Handle* resource_limit, Kernel::Handle process_handle) { |
| 480 | LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); | 481 | LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); |
| 481 | 482 | ||
| 482 | SharedPtr<Kernel::Process> process = | 483 | SharedPtr<Kernel::Process> process = |
| @@ -490,7 +491,7 @@ static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle | |||
| 490 | } | 491 | } |
| 491 | 492 | ||
| 492 | /// Get resource limit current values | 493 | /// Get resource limit current values |
| 493 | static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_limit_handle, | 494 | static ResultCode GetResourceLimitCurrentValues(s64* values, Kernel::Handle resource_limit_handle, |
| 494 | u32* names, u32 name_count) { | 495 | u32* names, u32 name_count) { |
| 495 | LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d", | 496 | LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d", |
| 496 | resource_limit_handle, names, name_count); | 497 | resource_limit_handle, names, name_count); |
| @@ -507,8 +508,8 @@ static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_lim | |||
| 507 | } | 508 | } |
| 508 | 509 | ||
| 509 | /// Get resource limit max values | 510 | /// Get resource limit max values |
| 510 | static ResultCode GetResourceLimitLimitValues(s64* values, Handle resource_limit_handle, u32* names, | 511 | static ResultCode GetResourceLimitLimitValues(s64* values, Kernel::Handle resource_limit_handle, |
| 511 | u32 name_count) { | 512 | u32* names, u32 name_count) { |
| 512 | LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d", | 513 | LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d", |
| 513 | resource_limit_handle, names, name_count); | 514 | resource_limit_handle, names, name_count); |
| 514 | 515 | ||
| @@ -524,7 +525,7 @@ static ResultCode GetResourceLimitLimitValues(s64* values, Handle resource_limit | |||
| 524 | } | 525 | } |
| 525 | 526 | ||
| 526 | /// Creates a new thread | 527 | /// Creates a new thread |
| 527 | static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point, u32 arg, | 528 | static ResultCode CreateThread(Kernel::Handle* out_handle, s32 priority, u32 entry_point, u32 arg, |
| 528 | u32 stack_top, s32 processor_id) { | 529 | u32 stack_top, s32 processor_id) { |
| 529 | using Kernel::Thread; | 530 | using Kernel::Thread; |
| 530 | 531 | ||
| @@ -582,13 +583,13 @@ static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point | |||
| 582 | 583 | ||
| 583 | /// Called when a thread exits | 584 | /// Called when a thread exits |
| 584 | static void ExitThread() { | 585 | static void ExitThread() { |
| 585 | LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::g_app_core->GetPC()); | 586 | LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::CPU().GetPC()); |
| 586 | 587 | ||
| 587 | Kernel::ExitCurrentThread(); | 588 | Kernel::ExitCurrentThread(); |
| 588 | } | 589 | } |
| 589 | 590 | ||
| 590 | /// Gets the priority for the specified thread | 591 | /// Gets the priority for the specified thread |
| 591 | static ResultCode GetThreadPriority(s32* priority, Handle handle) { | 592 | static ResultCode GetThreadPriority(s32* priority, Kernel::Handle handle) { |
| 592 | const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); | 593 | const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); |
| 593 | if (thread == nullptr) | 594 | if (thread == nullptr) |
| 594 | return ERR_INVALID_HANDLE; | 595 | return ERR_INVALID_HANDLE; |
| @@ -598,7 +599,7 @@ static ResultCode GetThreadPriority(s32* priority, Handle handle) { | |||
| 598 | } | 599 | } |
| 599 | 600 | ||
| 600 | /// Sets the priority for the specified thread | 601 | /// Sets the priority for the specified thread |
| 601 | static ResultCode SetThreadPriority(Handle handle, s32 priority) { | 602 | static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) { |
| 602 | SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); | 603 | SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); |
| 603 | if (thread == nullptr) | 604 | if (thread == nullptr) |
| 604 | return ERR_INVALID_HANDLE; | 605 | return ERR_INVALID_HANDLE; |
| @@ -608,11 +609,11 @@ static ResultCode SetThreadPriority(Handle handle, s32 priority) { | |||
| 608 | } | 609 | } |
| 609 | 610 | ||
| 610 | /// Create a mutex | 611 | /// Create a mutex |
| 611 | static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) { | 612 | static ResultCode CreateMutex(Kernel::Handle* out_handle, u32 initial_locked) { |
| 612 | using Kernel::Mutex; | 613 | using Kernel::Mutex; |
| 613 | 614 | ||
| 614 | SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0); | 615 | SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0); |
| 615 | mutex->name = Common::StringFromFormat("mutex-%08x", Core::g_app_core->GetReg(14)); | 616 | mutex->name = Common::StringFromFormat("mutex-%08x", Core::CPU().GetReg(14)); |
| 616 | CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(mutex))); | 617 | CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(mutex))); |
| 617 | 618 | ||
| 618 | LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X", | 619 | LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X", |
| @@ -622,7 +623,7 @@ static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) { | |||
| 622 | } | 623 | } |
| 623 | 624 | ||
| 624 | /// Release a mutex | 625 | /// Release a mutex |
| 625 | static ResultCode ReleaseMutex(Handle handle) { | 626 | static ResultCode ReleaseMutex(Kernel::Handle handle) { |
| 626 | using Kernel::Mutex; | 627 | using Kernel::Mutex; |
| 627 | 628 | ||
| 628 | LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle); | 629 | LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle); |
| @@ -637,7 +638,7 @@ static ResultCode ReleaseMutex(Handle handle) { | |||
| 637 | } | 638 | } |
| 638 | 639 | ||
| 639 | /// Get the ID of the specified process | 640 | /// Get the ID of the specified process |
| 640 | static ResultCode GetProcessId(u32* process_id, Handle process_handle) { | 641 | static ResultCode GetProcessId(u32* process_id, Kernel::Handle process_handle) { |
| 641 | LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); | 642 | LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); |
| 642 | 643 | ||
| 643 | const SharedPtr<Kernel::Process> process = | 644 | const SharedPtr<Kernel::Process> process = |
| @@ -650,7 +651,7 @@ static ResultCode GetProcessId(u32* process_id, Handle process_handle) { | |||
| 650 | } | 651 | } |
| 651 | 652 | ||
| 652 | /// Get the ID of the process that owns the specified thread | 653 | /// Get the ID of the process that owns the specified thread |
| 653 | static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) { | 654 | static ResultCode GetProcessIdOfThread(u32* process_id, Kernel::Handle thread_handle) { |
| 654 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); | 655 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); |
| 655 | 656 | ||
| 656 | const SharedPtr<Kernel::Thread> thread = | 657 | const SharedPtr<Kernel::Thread> thread = |
| @@ -667,7 +668,7 @@ static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) { | |||
| 667 | } | 668 | } |
| 668 | 669 | ||
| 669 | /// Get the ID for the specified thread. | 670 | /// Get the ID for the specified thread. |
| 670 | static ResultCode GetThreadId(u32* thread_id, Handle handle) { | 671 | static ResultCode GetThreadId(u32* thread_id, Kernel::Handle handle) { |
| 671 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); | 672 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); |
| 672 | 673 | ||
| 673 | const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); | 674 | const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); |
| @@ -679,11 +680,11 @@ static ResultCode GetThreadId(u32* thread_id, Handle handle) { | |||
| 679 | } | 680 | } |
| 680 | 681 | ||
| 681 | /// Creates a semaphore | 682 | /// Creates a semaphore |
| 682 | static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max_count) { | 683 | static ResultCode CreateSemaphore(Kernel::Handle* out_handle, s32 initial_count, s32 max_count) { |
| 683 | using Kernel::Semaphore; | 684 | using Kernel::Semaphore; |
| 684 | 685 | ||
| 685 | CASCADE_RESULT(SharedPtr<Semaphore> semaphore, Semaphore::Create(initial_count, max_count)); | 686 | CASCADE_RESULT(SharedPtr<Semaphore> semaphore, Semaphore::Create(initial_count, max_count)); |
| 686 | semaphore->name = Common::StringFromFormat("semaphore-%08x", Core::g_app_core->GetReg(14)); | 687 | semaphore->name = Common::StringFromFormat("semaphore-%08x", Core::CPU().GetReg(14)); |
| 687 | CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(semaphore))); | 688 | CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(semaphore))); |
| 688 | 689 | ||
| 689 | LOG_TRACE(Kernel_SVC, "called initial_count=%d, max_count=%d, created handle=0x%08X", | 690 | LOG_TRACE(Kernel_SVC, "called initial_count=%d, max_count=%d, created handle=0x%08X", |
| @@ -692,7 +693,7 @@ static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max | |||
| 692 | } | 693 | } |
| 693 | 694 | ||
| 694 | /// Releases a certain number of slots in a semaphore | 695 | /// Releases a certain number of slots in a semaphore |
| 695 | static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) { | 696 | static ResultCode ReleaseSemaphore(s32* count, Kernel::Handle handle, s32 release_count) { |
| 696 | using Kernel::Semaphore; | 697 | using Kernel::Semaphore; |
| 697 | 698 | ||
| 698 | LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, handle); | 699 | LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, handle); |
| @@ -708,7 +709,7 @@ static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) | |||
| 708 | 709 | ||
| 709 | /// Query process memory | 710 | /// Query process memory |
| 710 | static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, | 711 | static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, |
| 711 | Handle process_handle, u32 addr) { | 712 | Kernel::Handle process_handle, u32 addr) { |
| 712 | using Kernel::Process; | 713 | using Kernel::Process; |
| 713 | Kernel::SharedPtr<Process> process = Kernel::g_handle_table.Get<Process>(process_handle); | 714 | Kernel::SharedPtr<Process> process = Kernel::g_handle_table.Get<Process>(process_handle); |
| 714 | if (process == nullptr) | 715 | if (process == nullptr) |
| @@ -736,11 +737,11 @@ static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32 | |||
| 736 | } | 737 | } |
| 737 | 738 | ||
| 738 | /// Create an event | 739 | /// Create an event |
| 739 | static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) { | 740 | static ResultCode CreateEvent(Kernel::Handle* out_handle, u32 reset_type) { |
| 740 | using Kernel::Event; | 741 | using Kernel::Event; |
| 741 | 742 | ||
| 742 | SharedPtr<Event> evt = Event::Create(static_cast<Kernel::ResetType>(reset_type)); | 743 | SharedPtr<Event> evt = Event::Create(static_cast<Kernel::ResetType>(reset_type)); |
| 743 | evt->name = Common::StringFromFormat("event-%08x", Core::g_app_core->GetReg(14)); | 744 | evt->name = Common::StringFromFormat("event-%08x", Core::CPU().GetReg(14)); |
| 744 | CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(evt))); | 745 | CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(evt))); |
| 745 | 746 | ||
| 746 | LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, | 747 | LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, |
| @@ -749,14 +750,14 @@ static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) { | |||
| 749 | } | 750 | } |
| 750 | 751 | ||
| 751 | /// Duplicates a kernel handle | 752 | /// Duplicates a kernel handle |
| 752 | static ResultCode DuplicateHandle(Handle* out, Handle handle) { | 753 | static ResultCode DuplicateHandle(Kernel::Handle* out, Kernel::Handle handle) { |
| 753 | CASCADE_RESULT(*out, Kernel::g_handle_table.Duplicate(handle)); | 754 | CASCADE_RESULT(*out, Kernel::g_handle_table.Duplicate(handle)); |
| 754 | LOG_TRACE(Kernel_SVC, "duplicated 0x%08X to 0x%08X", handle, *out); | 755 | LOG_TRACE(Kernel_SVC, "duplicated 0x%08X to 0x%08X", handle, *out); |
| 755 | return RESULT_SUCCESS; | 756 | return RESULT_SUCCESS; |
| 756 | } | 757 | } |
| 757 | 758 | ||
| 758 | /// Signals an event | 759 | /// Signals an event |
| 759 | static ResultCode SignalEvent(Handle handle) { | 760 | static ResultCode SignalEvent(Kernel::Handle handle) { |
| 760 | using Kernel::Event; | 761 | using Kernel::Event; |
| 761 | LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle); | 762 | LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle); |
| 762 | 763 | ||
| @@ -770,7 +771,7 @@ static ResultCode SignalEvent(Handle handle) { | |||
| 770 | } | 771 | } |
| 771 | 772 | ||
| 772 | /// Clears an event | 773 | /// Clears an event |
| 773 | static ResultCode ClearEvent(Handle handle) { | 774 | static ResultCode ClearEvent(Kernel::Handle handle) { |
| 774 | using Kernel::Event; | 775 | using Kernel::Event; |
| 775 | LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle); | 776 | LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle); |
| 776 | 777 | ||
| @@ -783,11 +784,11 @@ static ResultCode ClearEvent(Handle handle) { | |||
| 783 | } | 784 | } |
| 784 | 785 | ||
| 785 | /// Creates a timer | 786 | /// Creates a timer |
| 786 | static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) { | 787 | static ResultCode CreateTimer(Kernel::Handle* out_handle, u32 reset_type) { |
| 787 | using Kernel::Timer; | 788 | using Kernel::Timer; |
| 788 | 789 | ||
| 789 | SharedPtr<Timer> timer = Timer::Create(static_cast<Kernel::ResetType>(reset_type)); | 790 | SharedPtr<Timer> timer = Timer::Create(static_cast<Kernel::ResetType>(reset_type)); |
| 790 | timer->name = Common::StringFromFormat("timer-%08x", Core::g_app_core->GetReg(14)); | 791 | timer->name = Common::StringFromFormat("timer-%08x", Core::CPU().GetReg(14)); |
| 791 | CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(timer))); | 792 | CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(timer))); |
| 792 | 793 | ||
| 793 | LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, | 794 | LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, |
| @@ -796,7 +797,7 @@ static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) { | |||
| 796 | } | 797 | } |
| 797 | 798 | ||
| 798 | /// Clears a timer | 799 | /// Clears a timer |
| 799 | static ResultCode ClearTimer(Handle handle) { | 800 | static ResultCode ClearTimer(Kernel::Handle handle) { |
| 800 | using Kernel::Timer; | 801 | using Kernel::Timer; |
| 801 | 802 | ||
| 802 | LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); | 803 | LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); |
| @@ -810,7 +811,7 @@ static ResultCode ClearTimer(Handle handle) { | |||
| 810 | } | 811 | } |
| 811 | 812 | ||
| 812 | /// Starts a timer | 813 | /// Starts a timer |
| 813 | static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) { | 814 | static ResultCode SetTimer(Kernel::Handle handle, s64 initial, s64 interval) { |
| 814 | using Kernel::Timer; | 815 | using Kernel::Timer; |
| 815 | 816 | ||
| 816 | LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); | 817 | LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); |
| @@ -825,7 +826,7 @@ static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) { | |||
| 825 | } | 826 | } |
| 826 | 827 | ||
| 827 | /// Cancels a timer | 828 | /// Cancels a timer |
| 828 | static ResultCode CancelTimer(Handle handle) { | 829 | static ResultCode CancelTimer(Kernel::Handle handle) { |
| 829 | using Kernel::Timer; | 830 | using Kernel::Timer; |
| 830 | 831 | ||
| 831 | LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); | 832 | LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); |
| @@ -854,14 +855,13 @@ static void SleepThread(s64 nanoseconds) { | |||
| 854 | static s64 GetSystemTick() { | 855 | static s64 GetSystemTick() { |
| 855 | s64 result = CoreTiming::GetTicks(); | 856 | s64 result = CoreTiming::GetTicks(); |
| 856 | // Advance time to defeat dumb games (like Cubic Ninja) that busy-wait for the frame to end. | 857 | // Advance time to defeat dumb games (like Cubic Ninja) that busy-wait for the frame to end. |
| 857 | Core::g_app_core->AddTicks( | 858 | Core::CPU().AddTicks(150); // Measured time between two calls on a 9.2 o3DS with Ninjhax 1.1b |
| 858 | 150); // Measured time between two calls on a 9.2 o3DS with Ninjhax 1.1b | ||
| 859 | return result; | 859 | return result; |
| 860 | } | 860 | } |
| 861 | 861 | ||
| 862 | /// Creates a memory block at the specified address with the specified permissions and size | 862 | /// Creates a memory block at the specified address with the specified permissions and size |
| 863 | static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my_permission, | 863 | static ResultCode CreateMemoryBlock(Kernel::Handle* out_handle, u32 addr, u32 size, |
| 864 | u32 other_permission) { | 864 | u32 my_permission, u32 other_permission) { |
| 865 | using Kernel::SharedMemory; | 865 | using Kernel::SharedMemory; |
| 866 | 866 | ||
| 867 | if (size % Memory::PAGE_SIZE != 0) | 867 | if (size % Memory::PAGE_SIZE != 0) |
| @@ -912,8 +912,8 @@ static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 | |||
| 912 | return RESULT_SUCCESS; | 912 | return RESULT_SUCCESS; |
| 913 | } | 913 | } |
| 914 | 914 | ||
| 915 | static ResultCode CreatePort(Handle* server_port, Handle* client_port, const char* name, | 915 | static ResultCode CreatePort(Kernel::Handle* server_port, Kernel::Handle* client_port, |
| 916 | u32 max_sessions) { | 916 | const char* name, u32 max_sessions) { |
| 917 | // TODO(Subv): Implement named ports. | 917 | // TODO(Subv): Implement named ports. |
| 918 | ASSERT_MSG(name == nullptr, "Named ports are currently unimplemented"); | 918 | ASSERT_MSG(name == nullptr, "Named ports are currently unimplemented"); |
| 919 | 919 | ||
| @@ -978,7 +978,7 @@ static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) { | |||
| 978 | return RESULT_SUCCESS; | 978 | return RESULT_SUCCESS; |
| 979 | } | 979 | } |
| 980 | 980 | ||
| 981 | static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) { | 981 | static ResultCode GetProcessInfo(s64* out, Kernel::Handle process_handle, u32 type) { |
| 982 | LOG_TRACE(Kernel_SVC, "called process=0x%08X type=%u", process_handle, type); | 982 | LOG_TRACE(Kernel_SVC, "called process=0x%08X type=%u", process_handle, type); |
| 983 | 983 | ||
| 984 | using Kernel::Process; | 984 | using Kernel::Process; |
| @@ -1185,7 +1185,7 @@ void CallSVC(u32 immediate) { | |||
| 1185 | if (info->func) { | 1185 | if (info->func) { |
| 1186 | info->func(); | 1186 | info->func(); |
| 1187 | // TODO(Subv): Not all service functions should cause a reschedule in all cases. | 1187 | // TODO(Subv): Not all service functions should cause a reschedule in all cases. |
| 1188 | HLE::Reschedule(__func__); | 1188 | Core::System::GetInstance().PrepareReschedule(); |
| 1189 | } else { | 1189 | } else { |
| 1190 | LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name); | 1190 | LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name); |
| 1191 | } | 1191 | } |
diff --git a/src/core/loader/3dsx.h b/src/core/loader/3dsx.h index cfcc21cc4..3f376778a 100644 --- a/src/core/loader/3dsx.h +++ b/src/core/loader/3dsx.h | |||
| @@ -27,34 +27,14 @@ public: | |||
| 27 | */ | 27 | */ |
| 28 | static FileType IdentifyType(FileUtil::IOFile& file); | 28 | static FileType IdentifyType(FileUtil::IOFile& file); |
| 29 | 29 | ||
| 30 | /** | ||
| 31 | * Returns the type of this file | ||
| 32 | * @return FileType corresponding to the loaded file | ||
| 33 | */ | ||
| 34 | FileType GetFileType() override { | 30 | FileType GetFileType() override { |
| 35 | return IdentifyType(file); | 31 | return IdentifyType(file); |
| 36 | } | 32 | } |
| 37 | 33 | ||
| 38 | /** | ||
| 39 | * Load the bootable file | ||
| 40 | * @return ResultStatus result of function | ||
| 41 | */ | ||
| 42 | ResultStatus Load() override; | 34 | ResultStatus Load() override; |
| 43 | 35 | ||
| 44 | /** | ||
| 45 | * Get the icon (typically icon section) of the application | ||
| 46 | * @param buffer Reference to buffer to store data | ||
| 47 | * @return ResultStatus result of function | ||
| 48 | */ | ||
| 49 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; | 36 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; |
| 50 | 37 | ||
| 51 | /** | ||
| 52 | * Get the RomFS of the application | ||
| 53 | * @param romfs_file Reference to buffer to store data | ||
| 54 | * @param offset Offset in the file to the RomFS | ||
| 55 | * @param size Size of the RomFS in bytes | ||
| 56 | * @return ResultStatus result of function | ||
| 57 | */ | ||
| 58 | ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, | 38 | ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, |
| 59 | u64& size) override; | 39 | u64& size) override; |
| 60 | 40 | ||
diff --git a/src/core/loader/elf.h b/src/core/loader/elf.h index 584bf6e27..862aa90d8 100644 --- a/src/core/loader/elf.h +++ b/src/core/loader/elf.h | |||
| @@ -26,18 +26,10 @@ public: | |||
| 26 | */ | 26 | */ |
| 27 | static FileType IdentifyType(FileUtil::IOFile& file); | 27 | static FileType IdentifyType(FileUtil::IOFile& file); |
| 28 | 28 | ||
| 29 | /** | ||
| 30 | * Returns the type of this file | ||
| 31 | * @return FileType corresponding to the loaded file | ||
| 32 | */ | ||
| 33 | FileType GetFileType() override { | 29 | FileType GetFileType() override { |
| 34 | return IdentifyType(file); | 30 | return IdentifyType(file); |
| 35 | } | 31 | } |
| 36 | 32 | ||
| 37 | /** | ||
| 38 | * Load the bootable file | ||
| 39 | * @return ResultStatus result of function | ||
| 40 | */ | ||
| 41 | ResultStatus Load() override; | 33 | ResultStatus Load() override; |
| 42 | 34 | ||
| 43 | private: | 35 | private: |
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index 6c93d46d8..6afc171a5 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h | |||
| @@ -171,18 +171,10 @@ public: | |||
| 171 | */ | 171 | */ |
| 172 | static FileType IdentifyType(FileUtil::IOFile& file); | 172 | static FileType IdentifyType(FileUtil::IOFile& file); |
| 173 | 173 | ||
| 174 | /** | ||
| 175 | * Returns the type of this file | ||
| 176 | * @return FileType corresponding to the loaded file | ||
| 177 | */ | ||
| 178 | FileType GetFileType() override { | 174 | FileType GetFileType() override { |
| 179 | return IdentifyType(file); | 175 | return IdentifyType(file); |
| 180 | } | 176 | } |
| 181 | 177 | ||
| 182 | /** | ||
| 183 | * Load the application | ||
| 184 | * @return ResultStatus result of function | ||
| 185 | */ | ||
| 186 | ResultStatus Load() override; | 178 | ResultStatus Load() override; |
| 187 | 179 | ||
| 188 | /** | 180 | /** |
| @@ -191,32 +183,12 @@ public: | |||
| 191 | */ | 183 | */ |
| 192 | boost::optional<u32> LoadKernelSystemMode(); | 184 | boost::optional<u32> LoadKernelSystemMode(); |
| 193 | 185 | ||
| 194 | /** | ||
| 195 | * Get the code (typically .code section) of the application | ||
| 196 | * @param buffer Reference to buffer to store data | ||
| 197 | * @return ResultStatus result of function | ||
| 198 | */ | ||
| 199 | ResultStatus ReadCode(std::vector<u8>& buffer) override; | 186 | ResultStatus ReadCode(std::vector<u8>& buffer) override; |
| 200 | 187 | ||
| 201 | /** | ||
| 202 | * Get the icon (typically icon section) of the application | ||
| 203 | * @param buffer Reference to buffer to store data | ||
| 204 | * @return ResultStatus result of function | ||
| 205 | */ | ||
| 206 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; | 188 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; |
| 207 | 189 | ||
| 208 | /** | ||
| 209 | * Get the banner (typically banner section) of the application | ||
| 210 | * @param buffer Reference to buffer to store data | ||
| 211 | * @return ResultStatus result of function | ||
| 212 | */ | ||
| 213 | ResultStatus ReadBanner(std::vector<u8>& buffer) override; | 190 | ResultStatus ReadBanner(std::vector<u8>& buffer) override; |
| 214 | 191 | ||
| 215 | /** | ||
| 216 | * Get the logo (typically logo section) of the application | ||
| 217 | * @param buffer Reference to buffer to store data | ||
| 218 | * @return ResultStatus result of function | ||
| 219 | */ | ||
| 220 | ResultStatus ReadLogo(std::vector<u8>& buffer) override; | 192 | ResultStatus ReadLogo(std::vector<u8>& buffer) override; |
| 221 | 193 | ||
| 222 | /** | 194 | /** |
diff --git a/src/core/system.cpp b/src/core/system.cpp deleted file mode 100644 index a5f763805..000000000 --- a/src/core/system.cpp +++ /dev/null | |||
| @@ -1,55 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "audio_core/audio_core.h" | ||
| 6 | #include "core/core.h" | ||
| 7 | #include "core/core_timing.h" | ||
| 8 | #include "core/gdbstub/gdbstub.h" | ||
| 9 | #include "core/hle/hle.h" | ||
| 10 | #include "core/hle/kernel/kernel.h" | ||
| 11 | #include "core/hle/kernel/memory.h" | ||
| 12 | #include "core/hw/hw.h" | ||
| 13 | #include "core/system.h" | ||
| 14 | #include "video_core/video_core.h" | ||
| 15 | |||
| 16 | namespace System { | ||
| 17 | |||
| 18 | static bool is_powered_on{false}; | ||
| 19 | |||
| 20 | Result Init(EmuWindow* emu_window, u32 system_mode) { | ||
| 21 | Core::Init(); | ||
| 22 | CoreTiming::Init(); | ||
| 23 | Memory::Init(); | ||
| 24 | HW::Init(); | ||
| 25 | Kernel::Init(system_mode); | ||
| 26 | HLE::Init(); | ||
| 27 | if (!VideoCore::Init(emu_window)) { | ||
| 28 | return Result::ErrorInitVideoCore; | ||
| 29 | } | ||
| 30 | AudioCore::Init(); | ||
| 31 | GDBStub::Init(); | ||
| 32 | |||
| 33 | is_powered_on = true; | ||
| 34 | |||
| 35 | return Result::Success; | ||
| 36 | } | ||
| 37 | |||
| 38 | bool IsPoweredOn() { | ||
| 39 | return is_powered_on; | ||
| 40 | } | ||
| 41 | |||
| 42 | void Shutdown() { | ||
| 43 | GDBStub::Shutdown(); | ||
| 44 | AudioCore::Shutdown(); | ||
| 45 | VideoCore::Shutdown(); | ||
| 46 | HLE::Shutdown(); | ||
| 47 | Kernel::Shutdown(); | ||
| 48 | HW::Shutdown(); | ||
| 49 | CoreTiming::Shutdown(); | ||
| 50 | Core::Shutdown(); | ||
| 51 | |||
| 52 | is_powered_on = false; | ||
| 53 | } | ||
| 54 | |||
| 55 | } // namespace | ||
diff --git a/src/core/system.h b/src/core/system.h deleted file mode 100644 index b41fc088a..000000000 --- a/src/core/system.h +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | class EmuWindow; | ||
| 8 | |||
| 9 | namespace System { | ||
| 10 | |||
| 11 | enum class Result { | ||
| 12 | Success, ///< Everything is fine | ||
| 13 | Error, ///< Something went wrong (no module specified) | ||
| 14 | ErrorInitCore, ///< Something went wrong during core init | ||
| 15 | ErrorInitVideoCore, ///< Something went wrong during video core init | ||
| 16 | }; | ||
| 17 | |||
| 18 | Result Init(EmuWindow* emu_window, u32 system_mode); | ||
| 19 | bool IsPoweredOn(); | ||
| 20 | void Shutdown(); | ||
| 21 | } | ||