summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------externals/boost0
-rw-r--r--src/citra/config.cpp3
-rw-r--r--src/citra/default_ini.h3
-rw-r--r--src/citra/emu_window/emu_window_glfw.cpp10
-rw-r--r--src/citra_qt/config.cpp8
-rw-r--r--src/citra_qt/config/controller_config.cpp2
-rw-r--r--src/citra_qt/debugger/graphics_breakpoints.cpp2
-rw-r--r--src/citra_qt/debugger/ramview.cpp2
-rw-r--r--src/citra_qt/util/spinbox.cpp5
-rw-r--r--src/common/CMakeLists.txt2
-rw-r--r--src/common/assert.h36
-rw-r--r--src/common/break_points.cpp1
-rw-r--r--src/common/chunk_file.h9
-rw-r--r--src/common/common.h3
-rw-r--r--src/common/common_funcs.h35
-rw-r--r--src/common/common_types.h6
-rw-r--r--src/common/concurrent_ring_buffer.h5
-rw-r--r--src/common/log.h56
-rw-r--r--src/common/logging/backend.cpp4
-rw-r--r--src/common/logging/log.h1
-rw-r--r--src/common/msg_handler.h14
-rw-r--r--src/common/scope_exit.h1
-rw-r--r--src/common/symbols.cpp2
-rw-r--r--src/common/utf8.cpp2
-rw-r--r--src/common/utf8.h2
-rw-r--r--src/core/arm/disassembler/arm_disasm.cpp2
-rw-r--r--src/core/arm/dyncom/arm_dyncom_run.cpp1
-rw-r--r--src/core/arm/dyncom/arm_dyncom_thumb.cpp14
-rw-r--r--src/core/core_timing.cpp2
-rw-r--r--src/core/file_sys/archive_backend.h39
-rw-r--r--src/core/file_sys/archive_extsavedata.cpp15
-rw-r--r--src/core/file_sys/archive_extsavedata.h21
-rw-r--r--src/core/file_sys/archive_romfs.cpp17
-rw-r--r--src/core/file_sys/archive_romfs.h11
-rw-r--r--src/core/file_sys/archive_savedata.cpp23
-rw-r--r--src/core/file_sys/archive_savedata.h17
-rw-r--r--src/core/file_sys/archive_savedatacheck.cpp28
-rw-r--r--src/core/file_sys/archive_savedatacheck.h8
-rw-r--r--src/core/file_sys/archive_sdmc.cpp17
-rw-r--r--src/core/file_sys/archive_sdmc.h10
-rw-r--r--src/core/file_sys/disk_archive.cpp26
-rw-r--r--src/core/file_sys/disk_archive.h25
-rw-r--r--src/core/file_sys/ivfc_archive.cpp22
-rw-r--r--src/core/file_sys/ivfc_archive.h13
-rw-r--r--src/core/hle/config_mem.cpp2
-rw-r--r--src/core/hle/hle.cpp2
-rw-r--r--src/core/hle/kernel/event.cpp2
-rw-r--r--src/core/hle/kernel/kernel.cpp4
-rw-r--r--src/core/hle/kernel/mutex.cpp2
-rw-r--r--src/core/hle/kernel/semaphore.cpp2
-rw-r--r--src/core/hle/kernel/session.h2
-rw-r--r--src/core/hle/kernel/thread.cpp14
-rw-r--r--src/core/hle/kernel/timer.cpp2
-rw-r--r--src/core/hle/result.h8
-rw-r--r--src/core/hle/service/ac_u.cpp2
-rw-r--r--src/core/hle/service/act_u.cpp1
-rw-r--r--src/core/hle/service/am_app.cpp1
-rw-r--r--src/core/hle/service/am_net.cpp1
-rw-r--r--src/core/hle/service/am_sys.cpp1
-rw-r--r--src/core/hle/service/apt_a.cpp1
-rw-r--r--src/core/hle/service/apt_u.cpp2
-rw-r--r--src/core/hle/service/boss_p.cpp1
-rw-r--r--src/core/hle/service/boss_u.cpp1
-rw-r--r--src/core/hle/service/cam_u.cpp1
-rw-r--r--src/core/hle/service/cecd_s.cpp1
-rw-r--r--src/core/hle/service/cecd_u.cpp1
-rw-r--r--src/core/hle/service/cfg/cfg.cpp3
-rw-r--r--src/core/hle/service/cfg/cfg_i.cpp1
-rw-r--r--src/core/hle/service/cfg/cfg_s.cpp1
-rw-r--r--src/core/hle/service/cfg/cfg_u.cpp69
-rw-r--r--src/core/hle/service/csnd_snd.cpp1
-rw-r--r--src/core/hle/service/dsp_dsp.cpp67
-rw-r--r--src/core/hle/service/err_f.cpp1
-rw-r--r--src/core/hle/service/frd_a.cpp1
-rw-r--r--src/core/hle/service/frd_u.cpp1
-rw-r--r--src/core/hle/service/fs/archive.cpp191
-rw-r--r--src/core/hle/service/fs/archive.h45
-rw-r--r--src/core/hle/service/fs/fs_user.cpp10
-rw-r--r--src/core/hle/service/gsp_gpu.cpp13
-rw-r--r--src/core/hle/service/gsp_lcd.cpp2
-rw-r--r--src/core/hle/service/hid/hid_spvr.cpp1
-rw-r--r--src/core/hle/service/hid/hid_user.cpp2
-rw-r--r--src/core/hle/service/http_c.cpp1
-rw-r--r--src/core/hle/service/ir_rst.cpp1
-rw-r--r--src/core/hle/service/ir_u.cpp1
-rw-r--r--src/core/hle/service/ldr_ro.cpp65
-rw-r--r--src/core/hle/service/mic_u.cpp1
-rw-r--r--src/core/hle/service/news_s.cpp1
-rw-r--r--src/core/hle/service/news_u.cpp1
-rw-r--r--src/core/hle/service/nim_aoc.cpp1
-rw-r--r--src/core/hle/service/nwm_uds.cpp1
-rw-r--r--src/core/hle/service/pm_app.cpp1
-rw-r--r--src/core/hle/service/ptm_play.cpp1
-rw-r--r--src/core/hle/service/ptm_sysm.cpp1
-rw-r--r--src/core/hle/service/ptm_u.cpp36
-rw-r--r--src/core/hle/service/soc_u.cpp5
-rw-r--r--src/core/hle/service/ssl_c.cpp1
-rw-r--r--src/core/hle/service/y2r_u.cpp1
-rw-r--r--src/core/hle/shared_page.cpp1
-rw-r--r--src/core/hle/svc.cpp2
-rw-r--r--src/core/hw/hw.cpp2
-rw-r--r--src/core/loader/loader.cpp2
-rw-r--r--src/core/mem_map_funcs.cpp4
-rw-r--r--src/core/settings.h3
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp6
-rw-r--r--src/video_core/gpu_debugger.h2
-rw-r--r--src/video_core/primitive_assembly.cpp1
-rw-r--r--src/video_core/rasterizer.cpp10
-rw-r--r--src/video_core/renderer_opengl/gl_shader_util.cpp2
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp6
-rw-r--r--src/video_core/vertex_shader.cpp13
-rw-r--r--src/video_core/video_core.cpp1
112 files changed, 652 insertions, 510 deletions
diff --git a/externals/boost b/externals/boost
Subproject 728a4d7d1c8b28355544ae829df9c4b5f28373c Subproject a1afc91d3aaa3da06bdbc13c78613e146665340
diff --git a/src/citra/config.cpp b/src/citra/config.cpp
index 1ebe74941..f5b4069c7 100644
--- a/src/citra/config.cpp
+++ b/src/citra/config.cpp
@@ -63,6 +63,9 @@ void Config::ReadValues() {
63 // Data Storage 63 // Data Storage
64 Settings::values.use_virtual_sd = glfw_config->GetBoolean("Data Storage", "use_virtual_sd", true); 64 Settings::values.use_virtual_sd = glfw_config->GetBoolean("Data Storage", "use_virtual_sd", true);
65 65
66 // System Region
67 Settings::values.region_value = glfw_config->GetInteger("System Region", "region_value", 1);
68
66 // Miscellaneous 69 // Miscellaneous
67 Settings::values.log_filter = glfw_config->Get("Miscellaneous", "log_filter", "*:Info"); 70 Settings::values.log_filter = glfw_config->Get("Miscellaneous", "log_filter", "*:Info");
68} 71}
diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h
index 3f523857f..be4b289bd 100644
--- a/src/citra/default_ini.h
+++ b/src/citra/default_ini.h
@@ -33,6 +33,9 @@ frame_skip = ## 0: No frameskip (default), 1 : 2x frameskip, 2 : 4x frameskip, e
33[Data Storage] 33[Data Storage]
34use_virtual_sd = 34use_virtual_sd =
35 35
36[System Region]
37region_value = ## 0 : Japan, 1 : Usa (default), 2 : Europe, 3 : Australia, 4 : China, 5 : Korea, 6 : Taiwan.
38
36[Miscellaneous] 39[Miscellaneous]
37log_filter = *:Info ## Examples: *:Debug Kernel.SVC:Trace Service.*:Critical 40log_filter = *:Info ## Examples: *:Debug Kernel.SVC:Trace Service.*:Critical
38)"; 41)";
diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp
index 9d1adc2fa..8a3ee64a8 100644
--- a/src/citra/emu_window/emu_window_glfw.cpp
+++ b/src/citra/emu_window/emu_window_glfw.cpp
@@ -36,15 +36,15 @@ const bool EmuWindow_GLFW::IsOpen() {
36} 36}
37 37
38void EmuWindow_GLFW::OnFramebufferResizeEvent(GLFWwindow* win, int width, int height) { 38void EmuWindow_GLFW::OnFramebufferResizeEvent(GLFWwindow* win, int width, int height) {
39 _dbg_assert_(Frontend, width > 0); 39 ASSERT(width > 0);
40 _dbg_assert_(Frontend, height > 0); 40 ASSERT(height > 0);
41 41
42 GetEmuWindow(win)->NotifyFramebufferSizeChanged(std::pair<unsigned,unsigned>(width, height)); 42 GetEmuWindow(win)->NotifyFramebufferSizeChanged(std::pair<unsigned,unsigned>(width, height));
43} 43}
44 44
45void EmuWindow_GLFW::OnClientAreaResizeEvent(GLFWwindow* win, int width, int height) { 45void EmuWindow_GLFW::OnClientAreaResizeEvent(GLFWwindow* win, int width, int height) {
46 _dbg_assert_(Frontend, width > 0); 46 ASSERT(width > 0);
47 _dbg_assert_(Frontend, height > 0); 47 ASSERT(height > 0);
48 48
49 // NOTE: GLFW provides no proper way to set a minimal window size. 49 // NOTE: GLFW provides no proper way to set a minimal window size.
50 // Hence, we just ignore the corresponding EmuWindow hint. 50 // Hence, we just ignore the corresponding EmuWindow hint.
@@ -149,7 +149,7 @@ void EmuWindow_GLFW::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,u
149 std::pair<int,int> current_size; 149 std::pair<int,int> current_size;
150 glfwGetWindowSize(m_render_window, &current_size.first, &current_size.second); 150 glfwGetWindowSize(m_render_window, &current_size.first, &current_size.second);
151 151
152 _dbg_assert_(Frontend, (int)minimal_size.first > 0 && (int)minimal_size.second > 0); 152 DEBUG_ASSERT((int)minimal_size.first > 0 && (int)minimal_size.second > 0);
153 int new_width = std::max(current_size.first, (int)minimal_size.first); 153 int new_width = std::max(current_size.first, (int)minimal_size.first);
154 int new_height = std::max(current_size.second, (int)minimal_size.second); 154 int new_height = std::max(current_size.second, (int)minimal_size.second);
155 155
diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp
index 955c8a4e0..76aeaedd0 100644
--- a/src/citra_qt/config.cpp
+++ b/src/citra_qt/config.cpp
@@ -51,6 +51,10 @@ void Config::ReadValues() {
51 Settings::values.use_virtual_sd = qt_config->value("use_virtual_sd", true).toBool(); 51 Settings::values.use_virtual_sd = qt_config->value("use_virtual_sd", true).toBool();
52 qt_config->endGroup(); 52 qt_config->endGroup();
53 53
54 qt_config->beginGroup("System Region");
55 Settings::values.region_value = qt_config->value("region_value", 1).toInt();
56 qt_config->endGroup();
57
54 qt_config->beginGroup("Miscellaneous"); 58 qt_config->beginGroup("Miscellaneous");
55 Settings::values.log_filter = qt_config->value("log_filter", "*:Info").toString().toStdString(); 59 Settings::values.log_filter = qt_config->value("log_filter", "*:Info").toString().toStdString();
56 qt_config->endGroup(); 60 qt_config->endGroup();
@@ -86,6 +90,10 @@ void Config::SaveValues() {
86 qt_config->setValue("use_virtual_sd", Settings::values.use_virtual_sd); 90 qt_config->setValue("use_virtual_sd", Settings::values.use_virtual_sd);
87 qt_config->endGroup(); 91 qt_config->endGroup();
88 92
93 qt_config->beginGroup("System Region");
94 qt_config->setValue("region_value", Settings::values.region_value);
95 qt_config->endGroup();
96
89 qt_config->beginGroup("Miscellaneous"); 97 qt_config->beginGroup("Miscellaneous");
90 qt_config->setValue("log_filter", QString::fromStdString(Settings::values.log_filter)); 98 qt_config->setValue("log_filter", QString::fromStdString(Settings::values.log_filter));
91 qt_config->endGroup(); 99 qt_config->endGroup();
diff --git a/src/citra_qt/config/controller_config.cpp b/src/citra_qt/config/controller_config.cpp
index 892995bb2..512879f1b 100644
--- a/src/citra_qt/config/controller_config.cpp
+++ b/src/citra_qt/config/controller_config.cpp
@@ -92,4 +92,4 @@ void GControllerConfigDialog::EnableChanges()
92 } 92 }
93} 93}
94 94
95*/ \ No newline at end of file 95*/
diff --git a/src/citra_qt/debugger/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics_breakpoints.cpp
index 262e2e770..92348be34 100644
--- a/src/citra_qt/debugger/graphics_breakpoints.cpp
+++ b/src/citra_qt/debugger/graphics_breakpoints.cpp
@@ -47,7 +47,7 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const
47 { Pica::DebugContext::Event::VertexLoaded, tr("Vertex loaded") } 47 { Pica::DebugContext::Event::VertexLoaded, tr("Vertex loaded") }
48 }; 48 };
49 49
50 _dbg_assert_(Debug_GPU, map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents)); 50 DEBUG_ASSERT(map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents));
51 51
52 return (map.find(event) != map.end()) ? map.at(event) : QString(); 52 return (map.find(event) != map.end()) ? map.at(event) : QString();
53 } 53 }
diff --git a/src/citra_qt/debugger/ramview.cpp b/src/citra_qt/debugger/ramview.cpp
index 2b199bad1..88570f2cd 100644
--- a/src/citra_qt/debugger/ramview.cpp
+++ b/src/citra_qt/debugger/ramview.cpp
@@ -14,4 +14,4 @@ void GRamView::OnCPUStepped()
14{ 14{
15 // TODO: QHexEdit doesn't show vertical scroll bars for > 10MB data streams... 15 // TODO: QHexEdit doesn't show vertical scroll bars for > 10MB data streams...
16 //setData(QByteArray((const char*)Mem_RAM,sizeof(Mem_RAM)/8)); 16 //setData(QByteArray((const char*)Mem_RAM,sizeof(Mem_RAM)/8));
17} \ No newline at end of file 17}
diff --git a/src/citra_qt/util/spinbox.cpp b/src/citra_qt/util/spinbox.cpp
index 1e3767c18..2e2076a27 100644
--- a/src/citra_qt/util/spinbox.cpp
+++ b/src/citra_qt/util/spinbox.cpp
@@ -32,8 +32,7 @@
32#include <QLineEdit> 32#include <QLineEdit>
33#include <QRegExpValidator> 33#include <QRegExpValidator>
34 34
35#include "common/log.h" 35#include "common/assert.h"
36
37#include "spinbox.h" 36#include "spinbox.h"
38 37
39CSpinBox::CSpinBox(QWidget* parent) : QAbstractSpinBox(parent), min_value(-100), max_value(100), value(0), base(10), num_digits(0) 38CSpinBox::CSpinBox(QWidget* parent) : QAbstractSpinBox(parent), min_value(-100), max_value(100), value(0), base(10), num_digits(0)
@@ -244,7 +243,7 @@ QValidator::State CSpinBox::validate(QString& input, int& pos) const
244 if (strpos >= input.length() - HasSign() - suffix.length()) 243 if (strpos >= input.length() - HasSign() - suffix.length())
245 return QValidator::Intermediate; 244 return QValidator::Intermediate;
246 245
247 _dbg_assert_(Frontend, base <= 10 || base == 16); 246 DEBUG_ASSERT(base <= 10 || base == 16);
248 QString regexp; 247 QString regexp;
249 248
250 // Demand sign character for negative ranges 249 // Demand sign character for negative ranges
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 3c3419bbc..8c87deaa4 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -26,6 +26,7 @@ set(SRCS
26 ) 26 )
27 27
28set(HEADERS 28set(HEADERS
29 assert.h
29 bit_field.h 30 bit_field.h
30 break_points.h 31 break_points.h
31 chunk_file.h 32 chunk_file.h
@@ -44,7 +45,6 @@ set(HEADERS
44 hash.h 45 hash.h
45 key_map.h 46 key_map.h
46 linear_disk_cache.h 47 linear_disk_cache.h
47 log.h
48 logging/text_formatter.h 48 logging/text_formatter.h
49 logging/filter.h 49 logging/filter.h
50 logging/log.h 50 logging/log.h
diff --git a/src/common/assert.h b/src/common/assert.h
new file mode 100644
index 000000000..3b2232a7e
--- /dev/null
+++ b/src/common/assert.h
@@ -0,0 +1,36 @@
1// Copyright 2013 Dolphin Emulator Project / 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_funcs.h"
8
9// TODO (yuriks) allow synchronous logging so we don't need printf
10#define ASSERT(_a_) \
11 do if (!(_a_)) {\
12 fprintf(stderr, "Assertion Failed!\n\n Line: %d\n File: %s\n Time: %s\n", \
13 __LINE__, __FILE__, __TIME__); \
14 Crash(); \
15 } while (0)
16
17#define ASSERT_MSG(_a_, ...) \
18 do if (!(_a_)) {\
19 fprintf(stderr, "Assertion Failed!\n\n Line: %d\n File: %s\n Time: %s\n", \
20 __LINE__, __FILE__, __TIME__); \
21 fprintf(stderr, __VA_ARGS__); \
22 fprintf(stderr, "\n"); \
23 Crash(); \
24 } while (0)
25
26#define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!")
27
28#ifdef _DEBUG
29#define DEBUG_ASSERT(_a_) ASSERT(_a_)
30#define DEBUG_ASSERT_MSG(_a_, ...) ASSERT_MSG(_a_, __VA_ARGS__)
31#else // not debug
32#define DEBUG_ASSERT(_a_)
33#define DEBUG_ASSERT_MSG(_a_, _desc_, ...)
34#endif
35
36#define UNIMPLEMENTED() DEBUG_ASSERT_MSG(false, "Unimplemented code!")
diff --git a/src/common/break_points.cpp b/src/common/break_points.cpp
index 6696935fa..2655d3ce9 100644
--- a/src/common/break_points.cpp
+++ b/src/common/break_points.cpp
@@ -5,6 +5,7 @@
5#include "common/common.h" 5#include "common/common.h"
6#include "common/debug_interface.h" 6#include "common/debug_interface.h"
7#include "common/break_points.h" 7#include "common/break_points.h"
8#include "common/logging/log.h"
8 9
9#include <sstream> 10#include <sstream>
10#include <algorithm> 11#include <algorithm>
diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h
index 39a14dc81..dc27da088 100644
--- a/src/common/chunk_file.h
+++ b/src/common/chunk_file.h
@@ -180,7 +180,7 @@ public:
180 case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything 180 case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything
181 case MODE_VERIFY: 181 case MODE_VERIFY:
182 for (int i = 0; i < size; i++) { 182 for (int i = 0; i < size; i++) {
183 _dbg_assert_msg_(Common, ((u8*)data)[i] == (*ptr)[i], 183 DEBUG_ASSERT_MSG(((u8*)data)[i] == (*ptr)[i],
184 "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", 184 "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n",
185 ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], 185 ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i],
186 (*ptr)[i], (*ptr)[i], &(*ptr)[i]); 186 (*ptr)[i], (*ptr)[i], &(*ptr)[i]);
@@ -200,7 +200,7 @@ public:
200 case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything 200 case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything
201 case MODE_VERIFY: 201 case MODE_VERIFY:
202 for (int i = 0; i < size; i++) { 202 for (int i = 0; i < size; i++) {
203 _dbg_assert_msg_(Common, ((u8*)data)[i] == (*ptr)[i], 203 DEBUG_ASSERT_MSG(((u8*)data)[i] == (*ptr)[i],
204 "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", 204 "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n",
205 ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], 205 ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i],
206 (*ptr)[i], (*ptr)[i], &(*ptr)[i]); 206 (*ptr)[i], (*ptr)[i], &(*ptr)[i]);
@@ -505,8 +505,7 @@ public:
505 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; 505 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
506 case MODE_MEASURE: break; 506 case MODE_MEASURE: break;
507 case MODE_VERIFY: 507 case MODE_VERIFY:
508 _dbg_assert_msg_(Common, 508 DEBUG_ASSERT_MSG((x == (char*)*ptr),
509 !strcmp(x.c_str(), (char*)*ptr),
510 "Savestate verification failure: \"%s\" != \"%s\" (at %p).\n", 509 "Savestate verification failure: \"%s\" != \"%s\" (at %p).\n",
511 x.c_str(), (char*)*ptr, ptr); 510 x.c_str(), (char*)*ptr, ptr);
512 break; 511 break;
@@ -524,7 +523,7 @@ public:
524 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; 523 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
525 case MODE_MEASURE: break; 524 case MODE_MEASURE: break;
526 case MODE_VERIFY: 525 case MODE_VERIFY:
527 _dbg_assert_msg_(Common, x == (wchar_t*)*ptr, 526 DEBUG_ASSERT_MSG((x == (wchar_t*)*ptr),
528 "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", 527 "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n",
529 x.c_str(), (wchar_t*)*ptr, ptr); 528 x.c_str(), (wchar_t*)*ptr, ptr);
530 break; 529 break;
diff --git a/src/common/common.h b/src/common/common.h
index 3246c7797..ad2de6f2e 100644
--- a/src/common/common.h
+++ b/src/common/common.h
@@ -25,7 +25,8 @@ private:
25 NonCopyable& operator=(NonCopyable& other); 25 NonCopyable& operator=(NonCopyable& other);
26}; 26};
27 27
28#include "common/log.h" 28#include "common/assert.h"
29#include "common/logging/log.h"
29#include "common/common_types.h" 30#include "common/common_types.h"
30#include "common/msg_handler.h" 31#include "common/msg_handler.h"
31#include "common/common_funcs.h" 32#include "common/common_funcs.h"
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 229eb74c9..44d8ae11f 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -44,15 +44,14 @@ template<> struct CompileTimeAssert<true> {};
44#include <sys/endian.h> 44#include <sys/endian.h>
45#endif 45#endif
46 46
47// go to debugger mode 47#if defined(__x86_64__) || defined(_M_X64)
48 #ifdef GEKKO 48#define Crash() __asm__ __volatile__("int $3")
49 #define Crash() 49#elif defined(_M_ARM)
50 #elif defined _M_GENERIC 50#define Crash() __asm__ __volatile__("trap")
51 #define Crash() { exit(1); } 51#else
52 #else 52#define Crash() exit(1)
53 #define Crash() {asm ("int $3");} 53#endif
54 #endif 54
55 #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
56// GCC 4.8 defines all the rotate functions now 55// GCC 4.8 defines all the rotate functions now
57// Small issue with GCC's lrotl/lrotr intrinsics is they are still 32bit while we require 64bit 56// Small issue with GCC's lrotl/lrotr intrinsics is they are still 32bit while we require 64bit
58#ifndef _rotl 57#ifndef _rotl
@@ -97,10 +96,10 @@ inline u64 _rotr64(u64 x, unsigned int shift){
97 #define LC_GLOBAL_LOCALE ((locale_t)-1) 96 #define LC_GLOBAL_LOCALE ((locale_t)-1)
98 #define LC_ALL_MASK LC_ALL 97 #define LC_ALL_MASK LC_ALL
99 #define LC_COLLATE_MASK LC_COLLATE 98 #define LC_COLLATE_MASK LC_COLLATE
100 #define LC_CTYPE_MASK LC_CTYPE 99 #define LC_CTYPE_MASK LC_CTYPE
101 #define LC_MONETARY_MASK LC_MONETARY 100 #define LC_MONETARY_MASK LC_MONETARY
102 #define LC_NUMERIC_MASK LC_NUMERIC 101 #define LC_NUMERIC_MASK LC_NUMERIC
103 #define LC_TIME_MASK LC_TIME 102 #define LC_TIME_MASK LC_TIME
104 103
105 inline locale_t uselocale(locale_t new_locale) 104 inline locale_t uselocale(locale_t new_locale)
106 { 105 {
@@ -136,14 +135,10 @@ inline u64 _rotr64(u64 x, unsigned int shift){
136 #define fstat64 _fstat64 135 #define fstat64 _fstat64
137 #define fileno _fileno 136 #define fileno _fileno
138 137
139 #if _M_IX86 138 extern "C" {
140 #define Crash() {__asm int 3} 139 __declspec(dllimport) void __stdcall DebugBreak(void);
141 #else 140 }
142extern "C" { 141 #define Crash() {DebugBreak();}
143 __declspec(dllimport) void __stdcall DebugBreak(void);
144}
145 #define Crash() {DebugBreak();}
146 #endif // M_IX86
147#endif // _MSC_VER ndef 142#endif // _MSC_VER ndef
148 143
149// Dolphin's min and max functions 144// Dolphin's min and max functions
diff --git a/src/common/common_types.h b/src/common/common_types.h
index 94e1406b1..1b453e7f5 100644
--- a/src/common/common_types.h
+++ b/src/common/common_types.h
@@ -28,6 +28,12 @@
28#include <cstdint> 28#include <cstdint>
29#include <cstdlib> 29#include <cstdlib>
30 30
31#ifdef _MSC_VER
32#ifndef __func__
33#define __func__ __FUNCTION__
34#endif
35#endif
36
31typedef std::uint8_t u8; ///< 8-bit unsigned byte 37typedef std::uint8_t u8; ///< 8-bit unsigned byte
32typedef std::uint16_t u16; ///< 16-bit unsigned short 38typedef std::uint16_t u16; ///< 16-bit unsigned short
33typedef std::uint32_t u32; ///< 32-bit unsigned word 39typedef std::uint32_t u32; ///< 32-bit unsigned word
diff --git a/src/common/concurrent_ring_buffer.h b/src/common/concurrent_ring_buffer.h
index 311bb01f4..fc18e6c86 100644
--- a/src/common/concurrent_ring_buffer.h
+++ b/src/common/concurrent_ring_buffer.h
@@ -11,7 +11,6 @@
11#include <thread> 11#include <thread>
12 12
13#include "common/common.h" // for NonCopyable 13#include "common/common.h" // for NonCopyable
14#include "common/log.h" // for _dbg_assert_
15 14
16namespace Common { 15namespace Common {
17 16
@@ -93,7 +92,7 @@ public:
93 return QUEUE_CLOSED; 92 return QUEUE_CLOSED;
94 } 93 }
95 } 94 }
96 _dbg_assert_(Common, CanRead()); 95 DEBUG_ASSERT(CanRead());
97 return PopInternal(dest, dest_len); 96 return PopInternal(dest, dest_len);
98 } 97 }
99 98
@@ -119,7 +118,7 @@ private:
119 size_t PopInternal(T* dest, size_t dest_len) { 118 size_t PopInternal(T* dest, size_t dest_len) {
120 size_t output_count = 0; 119 size_t output_count = 0;
121 while (output_count < dest_len && CanRead()) { 120 while (output_count < dest_len && CanRead()) {
122 _dbg_assert_(Common, CanRead()); 121 DEBUG_ASSERT(CanRead());
123 122
124 T* item = &Data()[reader_index]; 123 T* item = &Data()[reader_index];
125 T out_val = std::move(*item); 124 T out_val = std::move(*item);
diff --git a/src/common/log.h b/src/common/log.h
deleted file mode 100644
index b397cf14d..000000000
--- a/src/common/log.h
+++ /dev/null
@@ -1,56 +0,0 @@
1// Copyright 2013 Dolphin Emulator Project / 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_funcs.h"
8#include "common/msg_handler.h"
9#include "common/logging/log.h"
10
11#ifdef _MSC_VER
12#ifndef __func__
13#define __func__ __FUNCTION__
14#endif
15#endif
16
17#ifdef _DEBUG
18#define _dbg_assert_(_t_, _a_) \
19 if (!(_a_)) {\
20 LOG_CRITICAL(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \
21 __LINE__, __FILE__, __TIME__); \
22 if (!PanicYesNo("*** Assertion (see log)***\n")) {Crash();} \
23 }
24#define _dbg_assert_msg_(_t_, _a_, ...)\
25 if (!(_a_)) {\
26 LOG_CRITICAL(_t_, __VA_ARGS__); \
27 if (!PanicYesNo(__VA_ARGS__)) {Crash();} \
28 }
29#define _dbg_update_() Host_UpdateLogDisplay();
30
31#else // not debug
32#define _dbg_update_() ;
33
34#ifndef _dbg_assert_
35#define _dbg_assert_(_t_, _a_) {}
36#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) {}
37#endif // dbg_assert
38#endif
39
40#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
41
42#ifndef GEKKO
43#ifdef _MSC_VER
44#define _assert_msg_(_t_, _a_, _fmt_, ...) \
45 if (!(_a_)) {\
46 if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \
47 }
48#else // not msvc
49#define _assert_msg_(_t_, _a_, _fmt_, ...) \
50 if (!(_a_)) {\
51 if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \
52 }
53#endif // _WIN32
54#else // GEKKO
55#define _assert_msg_(_t_, _a_, _fmt_, ...)
56#endif \ No newline at end of file
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 83ebb42d9..459b44135 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -4,7 +4,7 @@
4 4
5#include <algorithm> 5#include <algorithm>
6 6
7#include "common/log.h" // For _dbg_assert_ 7#include "common/assert.h"
8 8
9#include "common/logging/backend.h" 9#include "common/logging/backend.h"
10#include "common/logging/log.h" 10#include "common/logging/log.h"
@@ -67,7 +67,7 @@ Logger::Logger() {
67#undef SUB 67#undef SUB
68 68
69 // Ensures that ALL_LOG_CLASSES isn't missing any entries. 69 // Ensures that ALL_LOG_CLASSES isn't missing any entries.
70 _dbg_assert_(Log, all_classes.size() == (size_t)Class::Count); 70 DEBUG_ASSERT(all_classes.size() == (size_t)Class::Count);
71} 71}
72 72
73// GetClassName is a macro defined by Windows.h, grrr... 73// GetClassName is a macro defined by Windows.h, grrr...
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 897ef36b8..6c5ca3968 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -57,6 +57,7 @@ enum class Class : ClassType {
57 Service_GSP, ///< The GSP (GPU control) service 57 Service_GSP, ///< The GSP (GPU control) service
58 Service_AC, ///< The AC (WiFi status) service 58 Service_AC, ///< The AC (WiFi status) service
59 Service_PTM, ///< The PTM (Power status & misc.) service 59 Service_PTM, ///< The PTM (Power status & misc.) service
60 Service_LDR, ///< The LDR (3ds dll loader) service
60 Service_CFG, ///< The CFG (Configuration) service 61 Service_CFG, ///< The CFG (Configuration) service
61 Service_DSP, ///< The DSP (DSP control) service 62 Service_DSP, ///< The DSP (DSP control) service
62 Service_HID, ///< The HID (User input) service 63 Service_HID, ///< The HID (User input) service
diff --git a/src/common/msg_handler.h b/src/common/msg_handler.h
index 5a483ddb4..421f93e23 100644
--- a/src/common/msg_handler.h
+++ b/src/common/msg_handler.h
@@ -29,7 +29,6 @@ extern bool MsgAlert(bool yes_no, int Style, const char* format, ...)
29 ; 29 ;
30void SetEnableAlert(bool enable); 30void SetEnableAlert(bool enable);
31 31
32#ifndef GEKKO
33#ifdef _MSC_VER 32#ifdef _MSC_VER
34 #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__) 33 #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__)
35 #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__) 34 #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__)
@@ -55,16 +54,3 @@ void SetEnableAlert(bool enable);
55 #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__) 54 #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__)
56 #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__) 55 #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__)
57#endif 56#endif
58#else
59// GEKKO
60 #define SuccessAlert(format, ...) ;
61 #define PanicAlert(format, ...) ;
62 #define PanicYesNo(format, ...) ;
63 #define AskYesNo(format, ...) ;
64 #define CriticalAlert(format, ...) ;
65 #define SuccessAlertT(format, ...) ;
66 #define PanicAlertT(format, ...) ;
67 #define PanicYesNoT(format, ...) ;
68 #define AskYesNoT(format, ...) ;
69 #define CriticalAlertT(format, ...) ;
70#endif
diff --git a/src/common/scope_exit.h b/src/common/scope_exit.h
index 77dcbaa22..08f09a8c8 100644
--- a/src/common/scope_exit.h
+++ b/src/common/scope_exit.h
@@ -5,6 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include "common/common_funcs.h" 7#include "common/common_funcs.h"
8#include <utility>
8 9
9namespace detail { 10namespace detail {
10 template <typename Func> 11 template <typename Func>
diff --git a/src/common/symbols.cpp b/src/common/symbols.cpp
index 9e4dccfb3..f23e51c9d 100644
--- a/src/common/symbols.cpp
+++ b/src/common/symbols.cpp
@@ -54,4 +54,4 @@ namespace Symbols
54 { 54 {
55 g_symbols.clear(); 55 g_symbols.clear();
56 } 56 }
57} \ No newline at end of file 57}
diff --git a/src/common/utf8.cpp b/src/common/utf8.cpp
index 66a2f6339..56609634c 100644
--- a/src/common/utf8.cpp
+++ b/src/common/utf8.cpp
@@ -456,4 +456,4 @@ std::wstring ConvertUTF8ToWString(const std::string &source) {
456 return str; 456 return str;
457} 457}
458 458
459#endif \ No newline at end of file 459#endif
diff --git a/src/common/utf8.h b/src/common/utf8.h
index 6479ec5ad..a6e84913b 100644
--- a/src/common/utf8.h
+++ b/src/common/utf8.h
@@ -64,4 +64,4 @@ std::string ConvertWStringToUTF8(const wchar_t *wstr);
64void ConvertUTF8ToWString(wchar_t *dest, size_t destSize, const std::string &source); 64void ConvertUTF8ToWString(wchar_t *dest, size_t destSize, const std::string &source);
65std::wstring ConvertUTF8ToWString(const std::string &source); 65std::wstring ConvertUTF8ToWString(const std::string &source);
66 66
67#endif \ No newline at end of file 67#endif
diff --git a/src/core/arm/disassembler/arm_disasm.cpp b/src/core/arm/disassembler/arm_disasm.cpp
index 45c720e16..f7c7451e9 100644
--- a/src/core/arm/disassembler/arm_disasm.cpp
+++ b/src/core/arm/disassembler/arm_disasm.cpp
@@ -963,4 +963,4 @@ Opcode ARM_Disasm::DecodeALU(uint32_t insn) {
963 } 963 }
964 // Unreachable 964 // Unreachable
965 return OP_INVALID; 965 return OP_INVALID;
966} \ No newline at end of file 966}
diff --git a/src/core/arm/dyncom/arm_dyncom_run.cpp b/src/core/arm/dyncom/arm_dyncom_run.cpp
index d457d0ac5..15677da27 100644
--- a/src/core/arm/dyncom/arm_dyncom_run.cpp
+++ b/src/core/arm/dyncom/arm_dyncom_run.cpp
@@ -4,6 +4,7 @@
4 4
5#include <assert.h> 5#include <assert.h>
6 6
7#include "common/logging/log.h"
7#include "core/arm/skyeye_common/armdefs.h" 8#include "core/arm/skyeye_common/armdefs.h"
8 9
9void switch_mode(arm_core_t *core, uint32_t mode) { 10void switch_mode(arm_core_t *core, uint32_t mode) {
diff --git a/src/core/arm/dyncom/arm_dyncom_thumb.cpp b/src/core/arm/dyncom/arm_dyncom_thumb.cpp
index de70ca8ae..d5a698365 100644
--- a/src/core/arm/dyncom/arm_dyncom_thumb.cpp
+++ b/src/core/arm/dyncom/arm_dyncom_thumb.cpp
@@ -48,7 +48,7 @@ tdstate thumb_translate (addr_t addr, uint32_t instr, uint32_t* ainstr, uint32_t
48 48
49 case 3: // ADD/SUB 49 case 3: // ADD/SUB
50 { 50 {
51 ARMword subset[4] = { 51 static const ARMword subset[4] = {
52 0xE0900000, // ADDS Rd,Rs,Rn 52 0xE0900000, // ADDS Rd,Rs,Rn
53 0xE0500000, // SUBS Rd,Rs,Rn 53 0xE0500000, // SUBS Rd,Rs,Rn
54 0xE2900000, // ADDS Rd,Rs,#imm3 54 0xE2900000, // ADDS Rd,Rs,#imm3
@@ -67,7 +67,7 @@ tdstate thumb_translate (addr_t addr, uint32_t instr, uint32_t* ainstr, uint32_t
67 case 6: // ADD 67 case 6: // ADD
68 case 7: // SUB 68 case 7: // SUB
69 { 69 {
70 ARMword subset[4] = { 70 static const ARMword subset[4] = {
71 0xE3B00000, // MOVS Rd,#imm8 71 0xE3B00000, // MOVS Rd,#imm8
72 0xE3500000, // CMP Rd,#imm8 72 0xE3500000, // CMP Rd,#imm8
73 0xE2900000, // ADDS Rd,Rd,#imm8 73 0xE2900000, // ADDS Rd,Rd,#imm8
@@ -95,7 +95,7 @@ tdstate thumb_translate (addr_t addr, uint32_t instr, uint32_t* ainstr, uint32_t
95 t_mul 95 t_mul
96 }; 96 };
97 97
98 struct { 98 static const struct {
99 ARMword opcode; 99 ARMword opcode;
100 otype type; 100 otype type;
101 } subset[16] = { 101 } subset[16] = {
@@ -205,7 +205,7 @@ tdstate thumb_translate (addr_t addr, uint32_t instr, uint32_t* ainstr, uint32_t
205 // merged into a single subset, saving on the following boolean: 205 // merged into a single subset, saving on the following boolean:
206 206
207 if ((tinstr & (1 << 9)) == 0) { 207 if ((tinstr & (1 << 9)) == 0) {
208 ARMword subset[4] = { 208 static const ARMword subset[4] = {
209 0xE7800000, // STR Rd,[Rb,Ro] 209 0xE7800000, // STR Rd,[Rb,Ro]
210 0xE7C00000, // STRB Rd,[Rb,Ro] 210 0xE7C00000, // STRB Rd,[Rb,Ro]
211 0xE7900000, // LDR Rd,[Rb,Ro] 211 0xE7900000, // LDR Rd,[Rb,Ro]
@@ -218,7 +218,7 @@ tdstate thumb_translate (addr_t addr, uint32_t instr, uint32_t* ainstr, uint32_t
218 |((tinstr & 0x01C0) >> 6); // Ro 218 |((tinstr & 0x01C0) >> 6); // Ro
219 219
220 } else { 220 } else {
221 ARMword subset[4] = { 221 static const ARMword subset[4] = {
222 0xE18000B0, // STRH Rd,[Rb,Ro] 222 0xE18000B0, // STRH Rd,[Rb,Ro]
223 0xE19000D0, // LDRSB Rd,[Rb,Ro] 223 0xE19000D0, // LDRSB Rd,[Rb,Ro]
224 0xE19000B0, // LDRH Rd,[Rb,Ro] 224 0xE19000B0, // LDRH Rd,[Rb,Ro]
@@ -236,7 +236,7 @@ tdstate thumb_translate (addr_t addr, uint32_t instr, uint32_t* ainstr, uint32_t
236 case 14: // STRB Rd,[Rb,#imm5] 236 case 14: // STRB Rd,[Rb,#imm5]
237 case 15: // LDRB Rd,[Rb,#imm5] 237 case 15: // LDRB Rd,[Rb,#imm5]
238 { 238 {
239 ARMword subset[4] = { 239 static const ARMword subset[4] = {
240 0xE5800000, // STR Rd,[Rb,#imm5] 240 0xE5800000, // STR Rd,[Rb,#imm5]
241 0xE5900000, // LDR Rd,[Rb,#imm5] 241 0xE5900000, // LDR Rd,[Rb,#imm5]
242 0xE5C00000, // STRB Rd,[Rb,#imm5] 242 0xE5C00000, // STRB Rd,[Rb,#imm5]
@@ -300,7 +300,7 @@ tdstate thumb_translate (addr_t addr, uint32_t instr, uint32_t* ainstr, uint32_t
300 } else if ((tinstr & 0x0F00) == 0x0e00) 300 } else if ((tinstr & 0x0F00) == 0x0e00)
301 *ainstr = 0xEF000000 | SWI_Breakpoint; 301 *ainstr = 0xEF000000 | SWI_Breakpoint;
302 else { 302 else {
303 ARMword subset[4] = { 303 static const ARMword subset[4] = {
304 0xE92D0000, // STMDB sp!,{rlist} 304 0xE92D0000, // STMDB sp!,{rlist}
305 0xE92D4000, // STMDB sp!,{rlist,lr} 305 0xE92D4000, // STMDB sp!,{rlist,lr}
306 0xE8BD0000, // LDMIA sp!,{rlist} 306 0xE8BD0000, // LDMIA sp!,{rlist}
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 3aebd7e9d..d96d3fe16 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -7,8 +7,8 @@
7#include <mutex> 7#include <mutex>
8#include <vector> 8#include <vector>
9 9
10#include "common/assert.h"
10#include "common/chunk_file.h" 11#include "common/chunk_file.h"
11#include "common/log.h"
12 12
13#include "core/arm/arm_interface.h" 13#include "core/arm/arm_interface.h"
14#include "core/core.h" 14#include "core/core.h"
diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.h
index 390178f67..43a106549 100644
--- a/src/core/file_sys/archive_backend.h
+++ b/src/core/file_sys/archive_backend.h
@@ -181,20 +181,6 @@ public:
181 } 181 }
182 182
183 /** 183 /**
184 * Tries to open the archive of this type with the specified path
185 * @param path Path to the archive
186 * @return ResultCode of the operation
187 */
188 virtual ResultCode Open(const Path& path) = 0;
189
190 /**
191 * Deletes the archive contents and then re-creates the base folder
192 * @param path Path to the archive
193 * @return ResultCode of the operation, 0 on success
194 */
195 virtual ResultCode Format(const Path& path) const = 0;
196
197 /**
198 * Get a descriptive name for the archive (e.g. "RomFS", "SaveData", etc.) 184 * Get a descriptive name for the archive (e.g. "RomFS", "SaveData", etc.)
199 */ 185 */
200 virtual std::string GetName() const = 0; 186 virtual std::string GetName() const = 0;
@@ -260,4 +246,29 @@ public:
260 virtual std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const = 0; 246 virtual std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const = 0;
261}; 247};
262 248
249class ArchiveFactory : NonCopyable {
250public:
251 virtual ~ArchiveFactory() {
252 }
253
254 /**
255 * Get a descriptive name for the archive (e.g. "RomFS", "SaveData", etc.)
256 */
257 virtual std::string GetName() const = 0;
258
259 /**
260 * Tries to open the archive of this type with the specified path
261 * @param path Path to the archive
262 * @return An ArchiveBackend corresponding operating specified archive path.
263 */
264 virtual ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path) = 0;
265
266 /**
267 * Deletes the archive contents and then re-creates the base folder
268 * @param path Path to the archive
269 * @return ResultCode of the operation, 0 on success
270 */
271 virtual ResultCode Format(const Path& path) = 0;
272};
273
263} // namespace FileSys 274} // namespace FileSys
diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp
index 33e4e76f8..0363c9771 100644
--- a/src/core/file_sys/archive_extsavedata.cpp
+++ b/src/core/file_sys/archive_extsavedata.cpp
@@ -6,6 +6,7 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/file_util.h" 8#include "common/file_util.h"
9#include "common/make_unique.h"
9 10
10#include "core/file_sys/archive_extsavedata.h" 11#include "core/file_sys/archive_extsavedata.h"
11#include "core/file_sys/disk_archive.h" 12#include "core/file_sys/disk_archive.h"
@@ -33,12 +34,12 @@ std::string GetExtDataContainerPath(const std::string& mount_point, bool shared)
33 SYSTEM_ID.c_str(), SDCARD_ID.c_str()); 34 SYSTEM_ID.c_str(), SDCARD_ID.c_str());
34} 35}
35 36
36Archive_ExtSaveData::Archive_ExtSaveData(const std::string& mount_location, bool shared) 37ArchiveFactory_ExtSaveData::ArchiveFactory_ExtSaveData(const std::string& mount_location, bool shared)
37 : DiskArchive(GetExtDataContainerPath(mount_location, shared)) { 38 : mount_point(GetExtDataContainerPath(mount_location, shared)) {
38 LOG_INFO(Service_FS, "Directory %s set as base for ExtSaveData.", mount_point.c_str()); 39 LOG_INFO(Service_FS, "Directory %s set as base for ExtSaveData.", mount_point.c_str());
39} 40}
40 41
41bool Archive_ExtSaveData::Initialize() { 42bool ArchiveFactory_ExtSaveData::Initialize() {
42 if (!FileUtil::CreateFullPath(mount_point)) { 43 if (!FileUtil::CreateFullPath(mount_point)) {
43 LOG_ERROR(Service_FS, "Unable to create ExtSaveData base path."); 44 LOG_ERROR(Service_FS, "Unable to create ExtSaveData base path.");
44 return false; 45 return false;
@@ -47,18 +48,18 @@ bool Archive_ExtSaveData::Initialize() {
47 return true; 48 return true;
48} 49}
49 50
50ResultCode Archive_ExtSaveData::Open(const Path& path) { 51ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(const Path& path) {
51 std::string fullpath = GetExtSaveDataPath(mount_point, path); 52 std::string fullpath = GetExtSaveDataPath(mount_point, path);
52 if (!FileUtil::Exists(fullpath)) { 53 if (!FileUtil::Exists(fullpath)) {
53 // TODO(Subv): Check error code, this one is probably wrong 54 // TODO(Subv): Check error code, this one is probably wrong
54 return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, 55 return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
55 ErrorSummary::InvalidState, ErrorLevel::Status); 56 ErrorSummary::InvalidState, ErrorLevel::Status);
56 } 57 }
57 concrete_mount_point = fullpath; 58 auto archive = Common::make_unique<DiskArchive>(fullpath);
58 return RESULT_SUCCESS; 59 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
59} 60}
60 61
61ResultCode Archive_ExtSaveData::Format(const Path& path) const { 62ResultCode ArchiveFactory_ExtSaveData::Format(const Path& path) {
62 std::string fullpath = GetExtSaveDataPath(mount_point, path); 63 std::string fullpath = GetExtSaveDataPath(mount_point, path);
63 FileUtil::CreateFullPath(fullpath); 64 FileUtil::CreateFullPath(fullpath);
64 return RESULT_SUCCESS; 65 return RESULT_SUCCESS;
diff --git a/src/core/file_sys/archive_extsavedata.h b/src/core/file_sys/archive_extsavedata.h
index 802a11b5f..83c6b0291 100644
--- a/src/core/file_sys/archive_extsavedata.h
+++ b/src/core/file_sys/archive_extsavedata.h
@@ -15,9 +15,9 @@
15namespace FileSys { 15namespace FileSys {
16 16
17/// File system interface to the ExtSaveData archive 17/// File system interface to the ExtSaveData archive
18class Archive_ExtSaveData final : public DiskArchive { 18class ArchiveFactory_ExtSaveData final : public ArchiveFactory {
19public: 19public:
20 Archive_ExtSaveData(const std::string& mount_point, bool shared); 20 ArchiveFactory_ExtSaveData(const std::string& mount_point, bool shared);
21 21
22 /** 22 /**
23 * Initialize the archive. 23 * Initialize the archive.
@@ -25,21 +25,20 @@ public:
25 */ 25 */
26 bool Initialize(); 26 bool Initialize();
27 27
28 ResultCode Open(const Path& path) override;
29 ResultCode Format(const Path& path) const override;
30 std::string GetName() const override { return "ExtSaveData"; } 28 std::string GetName() const override { return "ExtSaveData"; }
31 29
32 const std::string& GetMountPoint() const override { 30 ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path) override;
33 return concrete_mount_point; 31 ResultCode Format(const Path& path) override;
34 }
35 32
36protected: 33 const std::string& GetMountPoint() const { return mount_point; }
34
35private:
37 /** 36 /**
38 * This holds the full directory path for this archive, it is only set after a successful call to Open, 37 * This holds the full directory path for this archive, it is only set after a successful call
39 * this is formed as <base extsavedatapath>/<type>/<high>/<low>. 38 * to Open, this is formed as <base extsavedatapath>/<type>/<high>/<low>.
40 * See GetExtSaveDataPath for the code that extracts this data from an archive path. 39 * See GetExtSaveDataPath for the code that extracts this data from an archive path.
41 */ 40 */
42 std::string concrete_mount_point; 41 std::string mount_point;
43}; 42};
44 43
45/** 44/**
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp
index a30f73d0e..bf54a3866 100644
--- a/src/core/file_sys/archive_romfs.cpp
+++ b/src/core/file_sys/archive_romfs.cpp
@@ -15,11 +15,24 @@
15 15
16namespace FileSys { 16namespace FileSys {
17 17
18Archive_RomFS::Archive_RomFS(const Loader::AppLoader& app_loader) { 18ArchiveFactory_RomFS::ArchiveFactory_RomFS(const Loader::AppLoader& app_loader)
19 : romfs_data(std::make_shared<std::vector<u8>>()) {
19 // Load the RomFS from the app 20 // Load the RomFS from the app
20 if (Loader::ResultStatus::Success != app_loader.ReadRomFS(raw_data)) { 21 if (Loader::ResultStatus::Success != app_loader.ReadRomFS(*romfs_data)) {
21 LOG_ERROR(Service_FS, "Unable to read RomFS!"); 22 LOG_ERROR(Service_FS, "Unable to read RomFS!");
22 } 23 }
23} 24}
24 25
26ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_RomFS::Open(const Path& path) {
27 auto archive = Common::make_unique<IVFCArchive>(romfs_data);
28 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
29}
30
31ResultCode ArchiveFactory_RomFS::Format(const Path& path) {
32 LOG_ERROR(Service_FS, "Attempted to format a RomFS archive.");
33 // TODO: Verify error code
34 return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS,
35 ErrorSummary::NotSupported, ErrorLevel::Permanent);
36}
37
25} // namespace FileSys 38} // namespace FileSys
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h
index 5cb75e04d..409bc670a 100644
--- a/src/core/file_sys/archive_romfs.h
+++ b/src/core/file_sys/archive_romfs.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
7#include <vector> 8#include <vector>
8 9
9#include "common/common_types.h" 10#include "common/common_types.h"
@@ -17,12 +18,16 @@
17namespace FileSys { 18namespace FileSys {
18 19
19/// File system interface to the RomFS archive 20/// File system interface to the RomFS archive
20class Archive_RomFS final : public IVFCArchive { 21class ArchiveFactory_RomFS final : public ArchiveFactory {
21public: 22public:
22 Archive_RomFS(const Loader::AppLoader& app_loader); 23 ArchiveFactory_RomFS(const Loader::AppLoader& app_loader);
23 24
24 std::string GetName() const override { return "RomFS"; } 25 std::string GetName() const override { return "RomFS"; }
25 ResultCode Open(const Path& path) override { return RESULT_SUCCESS; } 26 ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path) override;
27 ResultCode Format(const Path& path) override;
28
29private:
30 std::shared_ptr<std::vector<u8>> romfs_data;
26}; 31};
27 32
28} // namespace FileSys 33} // namespace FileSys
diff --git a/src/core/file_sys/archive_savedata.cpp b/src/core/file_sys/archive_savedata.cpp
index 3baee5294..8496e06f3 100644
--- a/src/core/file_sys/archive_savedata.cpp
+++ b/src/core/file_sys/archive_savedata.cpp
@@ -6,6 +6,7 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/file_util.h" 8#include "common/file_util.h"
9#include "common/make_unique.h"
9 10
10#include "core/file_sys/archive_savedata.h" 11#include "core/file_sys/archive_savedata.h"
11#include "core/file_sys/disk_archive.h" 12#include "core/file_sys/disk_archive.h"
@@ -28,26 +29,28 @@ static std::string GetSaveDataPath(const std::string& mount_location, u64 progra
28 return Common::StringFromFormat("%s%08x/%08x/data/00000001/", mount_location.c_str(), high, low); 29 return Common::StringFromFormat("%s%08x/%08x/data/00000001/", mount_location.c_str(), high, low);
29} 30}
30 31
31Archive_SaveData::Archive_SaveData(const std::string& sdmc_directory) 32ArchiveFactory_SaveData::ArchiveFactory_SaveData(const std::string& sdmc_directory)
32 : DiskArchive(GetSaveDataContainerPath(sdmc_directory)) { 33 : mount_point(GetSaveDataContainerPath(sdmc_directory)) {
33 LOG_INFO(Service_FS, "Directory %s set as SaveData.", this->mount_point.c_str()); 34 LOG_INFO(Service_FS, "Directory %s set as SaveData.", this->mount_point.c_str());
34} 35}
35 36
36ResultCode Archive_SaveData::Open(const Path& path) { 37ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SaveData::Open(const Path& path) {
37 if (concrete_mount_point.empty()) 38 std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_program_id);
38 concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_program_id);
39 if (!FileUtil::Exists(concrete_mount_point)) { 39 if (!FileUtil::Exists(concrete_mount_point)) {
40 // When a SaveData archive is created for the first time, it is not yet formatted 40 // When a SaveData archive is created for the first time, it is not yet formatted
41 // and the save file/directory structure expected by the game has not yet been initialized. 41 // and the save file/directory structure expected by the game has not yet been initialized.
42 // Returning the NotFormatted error code will signal the game to provision the SaveData archive 42 // Returning the NotFormatted error code will signal the game to provision the SaveData archive
43 // with the files and folders that it expects. 43 // with the files and folders that it expects.
44 return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, 44 return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
45 ErrorSummary::InvalidState, ErrorLevel::Status); 45 ErrorSummary::InvalidState, ErrorLevel::Status);
46 } 46 }
47 return RESULT_SUCCESS; 47
48 auto archive = Common::make_unique<DiskArchive>(std::move(concrete_mount_point));
49 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
48} 50}
49 51
50ResultCode Archive_SaveData::Format(const Path& path) const { 52ResultCode ArchiveFactory_SaveData::Format(const Path& path) {
53 std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_program_id);
51 FileUtil::DeleteDirRecursively(concrete_mount_point); 54 FileUtil::DeleteDirRecursively(concrete_mount_point);
52 FileUtil::CreateFullPath(concrete_mount_point); 55 FileUtil::CreateFullPath(concrete_mount_point);
53 return RESULT_SUCCESS; 56 return RESULT_SUCCESS;
diff --git a/src/core/file_sys/archive_savedata.h b/src/core/file_sys/archive_savedata.h
index 07c7f7eff..db17afc92 100644
--- a/src/core/file_sys/archive_savedata.h
+++ b/src/core/file_sys/archive_savedata.h
@@ -15,22 +15,17 @@
15namespace FileSys { 15namespace FileSys {
16 16
17/// File system interface to the SaveData archive 17/// File system interface to the SaveData archive
18class Archive_SaveData final : public DiskArchive { 18class ArchiveFactory_SaveData final : public ArchiveFactory {
19public: 19public:
20 Archive_SaveData(const std::string& mount_point); 20 ArchiveFactory_SaveData(const std::string& mount_point);
21 21
22 std::string GetName() const override { return "SaveData"; } 22 std::string GetName() const override { return "SaveData"; }
23 23
24 ResultCode Open(const Path& path) override; 24 ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path) override;
25 ResultCode Format(const Path& path) override;
25 26
26 ResultCode Format(const Path& path) const override; 27private:
27 28 std::string mount_point;
28 const std::string& GetMountPoint() const override {
29 return concrete_mount_point;
30 }
31
32protected:
33 std::string concrete_mount_point;
34}; 29};
35 30
36} // namespace FileSys 31} // namespace FileSys
diff --git a/src/core/file_sys/archive_savedatacheck.cpp b/src/core/file_sys/archive_savedatacheck.cpp
index a7a507536..47d8a9d25 100644
--- a/src/core/file_sys/archive_savedatacheck.cpp
+++ b/src/core/file_sys/archive_savedatacheck.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 "common/file_util.h" 5#include "common/file_util.h"
6#include "common/make_unique.h"
6 7
7#include "core/file_sys/archive_savedatacheck.h" 8#include "core/file_sys/archive_savedatacheck.h"
8#include "core/hle/service/fs/archive.h" 9#include "core/hle/service/fs/archive.h"
@@ -21,32 +22,33 @@ static std::string GetSaveDataCheckPath(const std::string& mount_point, u32 high
21 mount_point.c_str(), high, low); 22 mount_point.c_str(), high, low);
22} 23}
23 24
24Archive_SaveDataCheck::Archive_SaveDataCheck(const std::string& nand_directory) : 25ArchiveFactory_SaveDataCheck::ArchiveFactory_SaveDataCheck(const std::string& nand_directory) :
25 mount_point(GetSaveDataCheckContainerPath(nand_directory)) { 26 mount_point(GetSaveDataCheckContainerPath(nand_directory)) {
26} 27}
27 28
28ResultCode Archive_SaveDataCheck::Open(const Path& path) { 29ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SaveDataCheck::Open(const Path& path) {
29 // TODO(Subv): We should not be overwriting raw_data everytime this function is called,
30 // but until we use factory classes to create the archives at runtime instead of creating them beforehand
31 // and allow multiple archives of the same type to be open at the same time without clobbering each other,
32 // we won't be able to maintain the state of each archive, hence we overwrite it every time it's needed.
33 // There are a number of problems with this, for example opening a file in this archive, then opening
34 // this archive again with a different path, will corrupt the previously open file.
35 auto vec = path.AsBinary(); 30 auto vec = path.AsBinary();
36 const u32* data = reinterpret_cast<u32*>(vec.data()); 31 const u32* data = reinterpret_cast<u32*>(vec.data());
37 std::string file_path = GetSaveDataCheckPath(mount_point, data[1], data[0]); 32 std::string file_path = GetSaveDataCheckPath(mount_point, data[1], data[0]);
38 FileUtil::IOFile file(file_path, "rb"); 33 FileUtil::IOFile file(file_path, "rb");
39 34
40 std::fill(raw_data.begin(), raw_data.end(), 0);
41
42 if (!file.IsOpen()) { 35 if (!file.IsOpen()) {
43 return ResultCode(-1); // TODO(Subv): Find the right error code 36 return ResultCode(-1); // TODO(Subv): Find the right error code
44 } 37 }
45 auto size = file.GetSize(); 38 auto size = file.GetSize();
46 raw_data.resize(size); 39 auto raw_data = std::make_shared<std::vector<u8>>(size);
47 file.ReadBytes(raw_data.data(), size); 40 file.ReadBytes(raw_data->data(), size);
48 file.Close(); 41 file.Close();
49 return RESULT_SUCCESS; 42
43 auto archive = Common::make_unique<IVFCArchive>(std::move(raw_data));
44 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
45}
46
47ResultCode ArchiveFactory_SaveDataCheck::Format(const Path& path) {
48 LOG_ERROR(Service_FS, "Attempted to format a SaveDataCheck archive.");
49 // TODO: Verify error code
50 return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS,
51 ErrorSummary::NotSupported, ErrorLevel::Permanent);
50} 52}
51 53
52} // namespace FileSys 54} // namespace FileSys
diff --git a/src/core/file_sys/archive_savedatacheck.h b/src/core/file_sys/archive_savedatacheck.h
index f6e73e803..f78a6f02e 100644
--- a/src/core/file_sys/archive_savedatacheck.h
+++ b/src/core/file_sys/archive_savedatacheck.h
@@ -17,12 +17,14 @@
17namespace FileSys { 17namespace FileSys {
18 18
19/// File system interface to the SaveDataCheck archive 19/// File system interface to the SaveDataCheck archive
20class Archive_SaveDataCheck final : public IVFCArchive { 20class ArchiveFactory_SaveDataCheck final : public ArchiveFactory {
21public: 21public:
22 Archive_SaveDataCheck(const std::string& mount_point); 22 ArchiveFactory_SaveDataCheck(const std::string& mount_point);
23 23
24 std::string GetName() const override { return "SaveDataCheck"; } 24 std::string GetName() const override { return "SaveDataCheck"; }
25 ResultCode Open(const Path& path) override; 25
26 ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path) override;
27 ResultCode Format(const Path& path) override;
26 28
27private: 29private:
28 std::string mount_point; 30 std::string mount_point;
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp
index 26b03e82f..92b20c7f6 100644
--- a/src/core/file_sys/archive_sdmc.cpp
+++ b/src/core/file_sys/archive_sdmc.cpp
@@ -6,6 +6,7 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/file_util.h" 8#include "common/file_util.h"
9#include "common/make_unique.h"
9 10
10#include "core/file_sys/archive_sdmc.h" 11#include "core/file_sys/archive_sdmc.h"
11#include "core/file_sys/disk_archive.h" 12#include "core/file_sys/disk_archive.h"
@@ -16,17 +17,17 @@
16 17
17namespace FileSys { 18namespace FileSys {
18 19
19Archive_SDMC::Archive_SDMC(const std::string& sdmc_directory) : DiskArchive(sdmc_directory) { 20ArchiveFactory_SDMC::ArchiveFactory_SDMC(const std::string& sdmc_directory) : sdmc_directory(sdmc_directory) {
20 LOG_INFO(Service_FS, "Directory %s set as SDMC.", sdmc_directory.c_str()); 21 LOG_INFO(Service_FS, "Directory %s set as SDMC.", sdmc_directory.c_str());
21} 22}
22 23
23bool Archive_SDMC::Initialize() { 24bool ArchiveFactory_SDMC::Initialize() {
24 if (!Settings::values.use_virtual_sd) { 25 if (!Settings::values.use_virtual_sd) {
25 LOG_WARNING(Service_FS, "SDMC disabled by config."); 26 LOG_WARNING(Service_FS, "SDMC disabled by config.");
26 return false; 27 return false;
27 } 28 }
28 29
29 if (!FileUtil::CreateFullPath(mount_point)) { 30 if (!FileUtil::CreateFullPath(sdmc_directory)) {
30 LOG_ERROR(Service_FS, "Unable to create SDMC path."); 31 LOG_ERROR(Service_FS, "Unable to create SDMC path.");
31 return false; 32 return false;
32 } 33 }
@@ -34,4 +35,14 @@ bool Archive_SDMC::Initialize() {
34 return true; 35 return true;
35} 36}
36 37
38ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SDMC::Open(const Path& path) {
39 auto archive = Common::make_unique<DiskArchive>(sdmc_directory);
40 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
41}
42
43ResultCode ArchiveFactory_SDMC::Format(const Path& path) {
44 // This is kind of an undesirable operation, so let's just ignore it. :)
45 return RESULT_SUCCESS;
46}
47
37} // namespace FileSys 48} // namespace FileSys
diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h
index 1b801f217..1becf6c0f 100644
--- a/src/core/file_sys/archive_sdmc.h
+++ b/src/core/file_sys/archive_sdmc.h
@@ -15,9 +15,9 @@
15namespace FileSys { 15namespace FileSys {
16 16
17/// File system interface to the SDMC archive 17/// File system interface to the SDMC archive
18class Archive_SDMC final : public DiskArchive { 18class ArchiveFactory_SDMC final : public ArchiveFactory {
19public: 19public:
20 Archive_SDMC(const std::string& mount_point); 20 ArchiveFactory_SDMC(const std::string& mount_point);
21 21
22 /** 22 /**
23 * Initialize the archive. 23 * Initialize the archive.
@@ -26,6 +26,12 @@ public:
26 bool Initialize(); 26 bool Initialize();
27 27
28 std::string GetName() const override { return "SDMC"; } 28 std::string GetName() const override { return "SDMC"; }
29
30 ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path) override;
31 ResultCode Format(const Path& path) override;
32
33private:
34 std::string sdmc_directory;
29}; 35};
30 36
31} // namespace FileSys 37} // namespace FileSys
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp
index c6e033fcd..f53fd57db 100644
--- a/src/core/file_sys/disk_archive.cpp
+++ b/src/core/file_sys/disk_archive.cpp
@@ -18,26 +18,26 @@ namespace FileSys {
18 18
19std::unique_ptr<FileBackend> DiskArchive::OpenFile(const Path& path, const Mode mode) const { 19std::unique_ptr<FileBackend> DiskArchive::OpenFile(const Path& path, const Mode mode) const {
20 LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex); 20 LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex);
21 auto file = Common::make_unique<DiskFile>(this, path, mode); 21 auto file = Common::make_unique<DiskFile>(*this, path, mode);
22 if (!file->Open()) 22 if (!file->Open())
23 return nullptr; 23 return nullptr;
24 return std::move(file); 24 return std::move(file);
25} 25}
26 26
27bool DiskArchive::DeleteFile(const Path& path) const { 27bool DiskArchive::DeleteFile(const Path& path) const {
28 return FileUtil::Delete(GetMountPoint() + path.AsString()); 28 return FileUtil::Delete(mount_point + path.AsString());
29} 29}
30 30
31bool DiskArchive::RenameFile(const Path& src_path, const Path& dest_path) const { 31bool DiskArchive::RenameFile(const Path& src_path, const Path& dest_path) const {
32 return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString()); 32 return FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString());
33} 33}
34 34
35bool DiskArchive::DeleteDirectory(const Path& path) const { 35bool DiskArchive::DeleteDirectory(const Path& path) const {
36 return FileUtil::DeleteDir(GetMountPoint() + path.AsString()); 36 return FileUtil::DeleteDir(mount_point + path.AsString());
37} 37}
38 38
39ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u32 size) const { 39ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u32 size) const {
40 std::string full_path = GetMountPoint() + path.AsString(); 40 std::string full_path = mount_point + path.AsString();
41 41
42 if (FileUtil::Exists(full_path)) 42 if (FileUtil::Exists(full_path))
43 return ResultCode(ErrorDescription::AlreadyExists, ErrorModule::FS, ErrorSummary::NothingHappened, ErrorLevel::Info); 43 return ResultCode(ErrorDescription::AlreadyExists, ErrorModule::FS, ErrorSummary::NothingHappened, ErrorLevel::Info);
@@ -58,16 +58,16 @@ ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u32 size) const {
58 58
59 59
60bool DiskArchive::CreateDirectory(const Path& path) const { 60bool DiskArchive::CreateDirectory(const Path& path) const {
61 return FileUtil::CreateDir(GetMountPoint() + path.AsString()); 61 return FileUtil::CreateDir(mount_point + path.AsString());
62} 62}
63 63
64bool DiskArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { 64bool DiskArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const {
65 return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString()); 65 return FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString());
66} 66}
67 67
68std::unique_ptr<DirectoryBackend> DiskArchive::OpenDirectory(const Path& path) const { 68std::unique_ptr<DirectoryBackend> DiskArchive::OpenDirectory(const Path& path) const {
69 LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str()); 69 LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str());
70 auto directory = Common::make_unique<DiskDirectory>(this, path); 70 auto directory = Common::make_unique<DiskDirectory>(*this, path);
71 if (!directory->Open()) 71 if (!directory->Open())
72 return nullptr; 72 return nullptr;
73 return std::move(directory); 73 return std::move(directory);
@@ -75,13 +75,12 @@ std::unique_ptr<DirectoryBackend> DiskArchive::OpenDirectory(const Path& path) c
75 75
76//////////////////////////////////////////////////////////////////////////////////////////////////// 76////////////////////////////////////////////////////////////////////////////////////////////////////
77 77
78DiskFile::DiskFile(const DiskArchive* archive, const Path& path, const Mode mode) { 78DiskFile::DiskFile(const DiskArchive& archive, const Path& path, const Mode mode) {
79 // TODO(Link Mauve): normalize path into an absolute path without "..", it can currently bypass 79 // TODO(Link Mauve): normalize path into an absolute path without "..", it can currently bypass
80 // the root directory we set while opening the archive. 80 // the root directory we set while opening the archive.
81 // For example, opening /../../etc/passwd can give the emulated program your users list. 81 // For example, opening /../../etc/passwd can give the emulated program your users list.
82 this->path = archive->GetMountPoint() + path.AsString(); 82 this->path = archive.mount_point + path.AsString();
83 this->mode.hex = mode.hex; 83 this->mode.hex = mode.hex;
84 this->archive = archive;
85} 84}
86 85
87bool DiskFile::Open() { 86bool DiskFile::Open() {
@@ -134,12 +133,11 @@ bool DiskFile::Close() const {
134 133
135//////////////////////////////////////////////////////////////////////////////////////////////////// 134////////////////////////////////////////////////////////////////////////////////////////////////////
136 135
137DiskDirectory::DiskDirectory(const DiskArchive* archive, const Path& path) { 136DiskDirectory::DiskDirectory(const DiskArchive& archive, const Path& path) {
138 // TODO(Link Mauve): normalize path into an absolute path without "..", it can currently bypass 137 // TODO(Link Mauve): normalize path into an absolute path without "..", it can currently bypass
139 // the root directory we set while opening the archive. 138 // the root directory we set while opening the archive.
140 // For example, opening /../../usr/bin can give the emulated program your installed programs. 139 // For example, opening /../../usr/bin can give the emulated program your installed programs.
141 this->path = archive->GetMountPoint() + path.AsString(); 140 this->path = archive.mount_point + path.AsString();
142 this->archive = archive;
143} 141}
144 142
145bool DiskDirectory::Open() { 143bool DiskDirectory::Open() {
diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h
index 3472f6874..dbbdced74 100644
--- a/src/core/file_sys/disk_archive.h
+++ b/src/core/file_sys/disk_archive.h
@@ -24,8 +24,8 @@ class DiskArchive : public ArchiveBackend {
24public: 24public:
25 DiskArchive(const std::string& mount_point_) : mount_point(mount_point_) {} 25 DiskArchive(const std::string& mount_point_) : mount_point(mount_point_) {}
26 26
27 virtual std::string GetName() const = 0; 27 virtual std::string GetName() const { return "DiskArchive: " + mount_point; }
28 virtual ResultCode Format(const Path& path) const { return RESULT_SUCCESS; } 28
29 std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override; 29 std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override;
30 bool DeleteFile(const Path& path) const override; 30 bool DeleteFile(const Path& path) const override;
31 bool RenameFile(const Path& src_path, const Path& dest_path) const override; 31 bool RenameFile(const Path& src_path, const Path& dest_path) const override;
@@ -35,26 +35,17 @@ public:
35 bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; 35 bool RenameDirectory(const Path& src_path, const Path& dest_path) const override;
36 std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; 36 std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override;
37 37
38 virtual ResultCode Open(const Path& path) override {
39 return RESULT_SUCCESS;
40 }
41
42 /**
43 * Getter for the path used for this Archive
44 * @return Mount point of that passthrough archive
45 */
46 virtual const std::string& GetMountPoint() const {
47 return mount_point;
48 }
49
50protected: 38protected:
39 friend class DiskFile;
40 friend class DiskDirectory;
41
51 std::string mount_point; 42 std::string mount_point;
52}; 43};
53 44
54class DiskFile : public FileBackend { 45class DiskFile : public FileBackend {
55public: 46public:
56 DiskFile(); 47 DiskFile();
57 DiskFile(const DiskArchive* archive, const Path& path, const Mode mode); 48 DiskFile(const DiskArchive& archive, const Path& path, const Mode mode);
58 49
59 bool Open() override; 50 bool Open() override;
60 size_t Read(const u64 offset, const u32 length, u8* buffer) const override; 51 size_t Read(const u64 offset, const u32 length, u8* buffer) const override;
@@ -68,7 +59,6 @@ public:
68 } 59 }
69 60
70protected: 61protected:
71 const DiskArchive* archive;
72 std::string path; 62 std::string path;
73 Mode mode; 63 Mode mode;
74 std::unique_ptr<FileUtil::IOFile> file; 64 std::unique_ptr<FileUtil::IOFile> file;
@@ -77,7 +67,7 @@ protected:
77class DiskDirectory : public DirectoryBackend { 67class DiskDirectory : public DirectoryBackend {
78public: 68public:
79 DiskDirectory(); 69 DiskDirectory();
80 DiskDirectory(const DiskArchive* archive, const Path& path); 70 DiskDirectory(const DiskArchive& archive, const Path& path);
81 71
82 ~DiskDirectory() override { 72 ~DiskDirectory() override {
83 Close(); 73 Close();
@@ -91,7 +81,6 @@ public:
91 } 81 }
92 82
93protected: 83protected:
94 const DiskArchive* archive;
95 std::string path; 84 std::string path;
96 u32 total_entries_in_directory; 85 u32 total_entries_in_directory;
97 FileUtil::FSTEntry directory; 86 FileUtil::FSTEntry directory;
diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/ivfc_archive.cpp
index 68c3c8b81..35aca54fa 100644
--- a/src/core/file_sys/ivfc_archive.cpp
+++ b/src/core/file_sys/ivfc_archive.cpp
@@ -15,11 +15,15 @@
15 15
16namespace FileSys { 16namespace FileSys {
17 17
18IVFCArchive::IVFCArchive() { 18IVFCArchive::IVFCArchive(std::shared_ptr<const std::vector<u8>> data) : data(data) {
19}
20
21std::string IVFCArchive::GetName() const {
22 return "IVFC";
19} 23}
20 24
21std::unique_ptr<FileBackend> IVFCArchive::OpenFile(const Path& path, const Mode mode) const { 25std::unique_ptr<FileBackend> IVFCArchive::OpenFile(const Path& path, const Mode mode) const {
22 return Common::make_unique<IVFCFile>(this); 26 return Common::make_unique<IVFCFile>(data);
23} 27}
24 28
25bool IVFCArchive::DeleteFile(const Path& path) const { 29bool IVFCArchive::DeleteFile(const Path& path) const {
@@ -57,31 +61,25 @@ std::unique_ptr<DirectoryBackend> IVFCArchive::OpenDirectory(const Path& path) c
57 return Common::make_unique<IVFCDirectory>(); 61 return Common::make_unique<IVFCDirectory>();
58} 62}
59 63
60ResultCode IVFCArchive::Format(const Path& path) const {
61 LOG_CRITICAL(Service_FS, "Attempted to format an IVFC archive (%s).", GetName().c_str());
62 // TODO: Verify error code
63 return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, ErrorLevel::Permanent);
64}
65
66//////////////////////////////////////////////////////////////////////////////////////////////////// 64////////////////////////////////////////////////////////////////////////////////////////////////////
67 65
68size_t IVFCFile::Read(const u64 offset, const u32 length, u8* buffer) const { 66size_t IVFCFile::Read(const u64 offset, const u32 length, u8* buffer) const {
69 LOG_TRACE(Service_FS, "called offset=%llu, length=%d", offset, length); 67 LOG_TRACE(Service_FS, "called offset=%llu, length=%d", offset, length);
70 memcpy(buffer, &archive->raw_data[(u32)offset], length); 68 memcpy(buffer, data->data() + offset, length);
71 return length; 69 return length;
72} 70}
73 71
74size_t IVFCFile::Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const { 72size_t IVFCFile::Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const {
75 LOG_CRITICAL(Service_FS, "Attempted to write to IVFC file in archive %s.", archive->GetName().c_str()); 73 LOG_ERROR(Service_FS, "Attempted to write to IVFC file");
76 return 0; 74 return 0;
77} 75}
78 76
79size_t IVFCFile::GetSize() const { 77size_t IVFCFile::GetSize() const {
80 return sizeof(u8) * archive->raw_data.size(); 78 return sizeof(u8) * data->size();
81} 79}
82 80
83bool IVFCFile::SetSize(const u64 size) const { 81bool IVFCFile::SetSize(const u64 size) const {
84 LOG_CRITICAL(Service_FS, "Attempted to set the size of an IVFC file in archive %s", archive->GetName().c_str()); 82 LOG_ERROR(Service_FS, "Attempted to set the size of an IVFC file");
85 return false; 83 return false;
86} 84}
87 85
diff --git a/src/core/file_sys/ivfc_archive.h b/src/core/file_sys/ivfc_archive.h
index 6f4cc86df..1aff9e0a4 100644
--- a/src/core/file_sys/ivfc_archive.h
+++ b/src/core/file_sys/ivfc_archive.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
7#include <vector> 8#include <vector>
8 9
9#include "common/common_types.h" 10#include "common/common_types.h"
@@ -23,7 +24,9 @@ namespace FileSys {
23 */ 24 */
24class IVFCArchive : public ArchiveBackend { 25class IVFCArchive : public ArchiveBackend {
25public: 26public:
26 IVFCArchive(); 27 IVFCArchive(std::shared_ptr<const std::vector<u8>> data);
28
29 std::string GetName() const override;
27 30
28 std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override; 31 std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override;
29 bool DeleteFile(const Path& path) const override; 32 bool DeleteFile(const Path& path) const override;
@@ -33,16 +36,14 @@ public:
33 bool CreateDirectory(const Path& path) const override; 36 bool CreateDirectory(const Path& path) const override;
34 bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; 37 bool RenameDirectory(const Path& src_path, const Path& dest_path) const override;
35 std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; 38 std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override;
36 ResultCode Format(const Path& path) const override;
37 39
38protected: 40protected:
39 friend class IVFCFile; 41 std::shared_ptr<const std::vector<u8>> data;
40 std::vector<u8> raw_data;
41}; 42};
42 43
43class IVFCFile : public FileBackend { 44class IVFCFile : public FileBackend {
44public: 45public:
45 IVFCFile(const IVFCArchive* archive) : archive(archive) {} 46 IVFCFile(std::shared_ptr<const std::vector<u8>> data) : data(data) {}
46 47
47 bool Open() override { return true; } 48 bool Open() override { return true; }
48 size_t Read(const u64 offset, const u32 length, u8* buffer) const override; 49 size_t Read(const u64 offset, const u32 length, u8* buffer) const override;
@@ -53,7 +54,7 @@ public:
53 void Flush() const override { } 54 void Flush() const override { }
54 55
55private: 56private:
56 const IVFCArchive* archive; 57 std::shared_ptr<const std::vector<u8>> data;
57}; 58};
58 59
59class IVFCDirectory : public DirectoryBackend { 60class IVFCDirectory : public DirectoryBackend {
diff --git a/src/core/hle/config_mem.cpp b/src/core/hle/config_mem.cpp
index 721a600b5..68d3071f5 100644
--- a/src/core/hle/config_mem.cpp
+++ b/src/core/hle/config_mem.cpp
@@ -3,7 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common_types.h" 5#include "common/common_types.h"
6#include "common/log.h" 6#include "common/logging/log.h"
7 7
8#include "core/hle/config_mem.h" 8#include "core/hle/config_mem.h"
9 9
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp
index 5a2edeb4a..97d73781f 100644
--- a/src/core/hle/hle.cpp
+++ b/src/core/hle/hle.cpp
@@ -45,7 +45,7 @@ void CallSVC(u32 opcode) {
45} 45}
46 46
47void Reschedule(const char *reason) { 47void Reschedule(const char *reason) {
48 _dbg_assert_msg_(Kernel, reason != 0 && strlen(reason) < 256, "Reschedule: Invalid or too long reason."); 48 DEBUG_ASSERT_MSG(reason != nullptr && strlen(reason) < 256, "Reschedule: Invalid or too long reason.");
49 49
50 // TODO(bunnei): It seems that games depend on some CPU execution time elapsing during HLE 50 // TODO(bunnei): It seems that games depend on some CPU execution time elapsing during HLE
51 // routines. This simulates that time by artificially advancing the number of CPU "ticks". 51 // routines. This simulates that time by artificially advancing the number of CPU "ticks".
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp
index 898e1c98f..420906ec0 100644
--- a/src/core/hle/kernel/event.cpp
+++ b/src/core/hle/kernel/event.cpp
@@ -32,7 +32,7 @@ bool Event::ShouldWait() {
32} 32}
33 33
34void Event::Acquire() { 34void Event::Acquire() {
35 _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); 35 ASSERT_MSG(!ShouldWait(), "object unavailable!");
36 36
37 // Release the event if it's not sticky... 37 // Release the event if it's not sticky...
38 if (reset_type != RESETTYPE_STICKY) 38 if (reset_type != RESETTYPE_STICKY)
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index a2ffbcdb7..eb61d8ef3 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -52,7 +52,7 @@ void WaitObject::WakeupAllWaitingThreads() {
52 for (auto thread : waiting_threads_copy) 52 for (auto thread : waiting_threads_copy)
53 thread->ReleaseWaitObject(this); 53 thread->ReleaseWaitObject(this);
54 54
55 _assert_msg_(Kernel, waiting_threads.empty(), "failed to awaken all waiting threads!"); 55 ASSERT_MSG(waiting_threads.empty(), "failed to awaken all waiting threads!");
56} 56}
57 57
58HandleTable::HandleTable() { 58HandleTable::HandleTable() {
@@ -61,7 +61,7 @@ HandleTable::HandleTable() {
61} 61}
62 62
63ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) { 63ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) {
64 _dbg_assert_(Kernel, obj != nullptr); 64 DEBUG_ASSERT(obj != nullptr);
65 65
66 u16 slot = next_free_slot; 66 u16 slot = next_free_slot;
67 if (slot >= generations.size()) { 67 if (slot >= generations.size()) {
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index a811db392..be2c49706 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -64,7 +64,7 @@ void Mutex::Acquire() {
64} 64}
65 65
66void Mutex::Acquire(SharedPtr<Thread> thread) { 66void Mutex::Acquire(SharedPtr<Thread> thread) {
67 _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); 67 ASSERT_MSG(!ShouldWait(), "object unavailable!");
68 68
69 // Actually "acquire" the mutex only if we don't already have it... 69 // Actually "acquire" the mutex only if we don't already have it...
70 if (lock_count == 0) { 70 if (lock_count == 0) {
diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp
index c8cf8b9a2..6aecc24aa 100644
--- a/src/core/hle/kernel/semaphore.cpp
+++ b/src/core/hle/kernel/semaphore.cpp
@@ -36,7 +36,7 @@ bool Semaphore::ShouldWait() {
36} 36}
37 37
38void Semaphore::Acquire() { 38void Semaphore::Acquire() {
39 _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); 39 ASSERT_MSG(!ShouldWait(), "object unavailable!");
40 --available_count; 40 --available_count;
41} 41}
42 42
diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h
index 7cc9332c9..9e9288e0f 100644
--- a/src/core/hle/kernel/session.h
+++ b/src/core/hle/kernel/session.h
@@ -66,7 +66,7 @@ public:
66 } 66 }
67 67
68 void Acquire() override { 68 void Acquire() override {
69 _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); 69 ASSERT_MSG(!ShouldWait(), "object unavailable!");
70 } 70 }
71}; 71};
72 72
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 7f629c20e..f8c834a8d 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -29,7 +29,7 @@ bool Thread::ShouldWait() {
29} 29}
30 30
31void Thread::Acquire() { 31void Thread::Acquire() {
32 _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); 32 ASSERT_MSG(!ShouldWait(), "object unavailable!");
33} 33}
34 34
35// Lists all thread ids that aren't deleted/etc. 35// Lists all thread ids that aren't deleted/etc.
@@ -144,7 +144,7 @@ void ArbitrateAllThreads(u32 address) {
144 * @param new_thread The thread to switch to 144 * @param new_thread The thread to switch to
145 */ 145 */
146static void SwitchContext(Thread* new_thread) { 146static void SwitchContext(Thread* new_thread) {
147 _dbg_assert_msg_(Kernel, new_thread->status == THREADSTATUS_READY, "Thread must be ready to become running."); 147 DEBUG_ASSERT_MSG(new_thread->status == THREADSTATUS_READY, "Thread must be ready to become running.");
148 148
149 Thread* previous_thread = GetCurrentThread(); 149 Thread* previous_thread = GetCurrentThread();
150 150
@@ -304,14 +304,12 @@ void Thread::ResumeFromWait() {
304 break; 304 break;
305 case THREADSTATUS_RUNNING: 305 case THREADSTATUS_RUNNING:
306 case THREADSTATUS_READY: 306 case THREADSTATUS_READY:
307 LOG_ERROR(Kernel, "Thread with object id %u has already resumed.", GetObjectId()); 307 DEBUG_ASSERT_MSG(false, "Thread with object id %u has already resumed.", GetObjectId());
308 _dbg_assert_(Kernel, false);
309 return; 308 return;
310 case THREADSTATUS_DEAD: 309 case THREADSTATUS_DEAD:
311 // This should never happen, as threads must complete before being stopped. 310 // This should never happen, as threads must complete before being stopped.
312 LOG_CRITICAL(Kernel, "Thread with object id %u cannot be resumed because it's DEAD.", 311 DEBUG_ASSERT_MSG(false, "Thread with object id %u cannot be resumed because it's DEAD.",
313 GetObjectId()); 312 GetObjectId());
314 _dbg_assert_(Kernel, false);
315 return; 313 return;
316 } 314 }
317 315
@@ -387,7 +385,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
387// TODO(peachum): Remove this. Range checking should be done, and an appropriate error should be returned. 385// TODO(peachum): Remove this. Range checking should be done, and an appropriate error should be returned.
388static void ClampPriority(const Thread* thread, s32* priority) { 386static void ClampPriority(const Thread* thread, s32* priority) {
389 if (*priority < THREADPRIO_HIGHEST || *priority > THREADPRIO_LOWEST) { 387 if (*priority < THREADPRIO_HIGHEST || *priority > THREADPRIO_LOWEST) {
390 _dbg_assert_msg_(Kernel, false, "Application passed an out of range priority. An error should be returned."); 388 DEBUG_ASSERT_MSG(false, "Application passed an out of range priority. An error should be returned.");
391 389
392 s32 new_priority = CLAMP(*priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST); 390 s32 new_priority = CLAMP(*priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST);
393 LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d", 391 LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d",
@@ -425,7 +423,7 @@ SharedPtr<Thread> SetupIdleThread() {
425} 423}
426 424
427SharedPtr<Thread> SetupMainThread(u32 stack_size, u32 entry_point, s32 priority) { 425SharedPtr<Thread> SetupMainThread(u32 stack_size, u32 entry_point, s32 priority) {
428 _dbg_assert_(Kernel, !GetCurrentThread()); 426 DEBUG_ASSERT(!GetCurrentThread());
429 427
430 // Initialize new "main" thread 428 // Initialize new "main" thread
431 auto thread_res = Thread::Create("main", entry_point, priority, 0, 429 auto thread_res = Thread::Create("main", entry_point, priority, 0,
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp
index 4352fc99c..aa0afb796 100644
--- a/src/core/hle/kernel/timer.cpp
+++ b/src/core/hle/kernel/timer.cpp
@@ -38,7 +38,7 @@ bool Timer::ShouldWait() {
38} 38}
39 39
40void Timer::Acquire() { 40void Timer::Acquire() {
41 _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); 41 ASSERT_MSG( !ShouldWait(), "object unavailable!");
42} 42}
43 43
44void Timer::Set(s64 initial, s64 interval) { 44void Timer::Set(s64 initial, s64 interval) {
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index 948b9e38e..9dbd5a914 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -307,14 +307,14 @@ public:
307 } 307 }
308 308
309 ResultVal& operator=(const ResultVal& o) { 309 ResultVal& operator=(const ResultVal& o) {
310 if (*this) { 310 if (!empty()) {
311 if (o) { 311 if (!o.empty()) {
312 *GetPointer() = *o.GetPointer(); 312 *GetPointer() = *o.GetPointer();
313 } else { 313 } else {
314 GetPointer()->~T(); 314 GetPointer()->~T();
315 } 315 }
316 } else { 316 } else {
317 if (o) { 317 if (!o.empty()) {
318 new (&storage) T(*o.GetPointer()); 318 new (&storage) T(*o.GetPointer());
319 } 319 }
320 } 320 }
@@ -363,7 +363,7 @@ public:
363 /// Asserts that the result succeeded and returns a reference to it. 363 /// Asserts that the result succeeded and returns a reference to it.
364 T& Unwrap() { 364 T& Unwrap() {
365 // TODO(yuriks): Should be a release assert 365 // TODO(yuriks): Should be a release assert
366 _assert_msg_(Common, Succeeded(), "Tried to Unwrap empty ResultVal"); 366 ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal");
367 return **this; 367 return **this;
368 } 368 }
369 369
diff --git a/src/core/hle/service/ac_u.cpp b/src/core/hle/service/ac_u.cpp
index 53d920de1..50644816b 100644
--- a/src/core/hle/service/ac_u.cpp
+++ b/src/core/hle/service/ac_u.cpp
@@ -2,7 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h" 5#include "common/logging/log.h"
6#include "core/hle/hle.h" 6#include "core/hle/hle.h"
7#include "core/hle/service/ac_u.h" 7#include "core/hle/service/ac_u.h"
8 8
diff --git a/src/core/hle/service/act_u.cpp b/src/core/hle/service/act_u.cpp
index 4ea7a9fb2..57f49c91f 100644
--- a/src/core/hle/service/act_u.cpp
+++ b/src/core/hle/service/act_u.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/act_u.h" 6#include "core/hle/service/act_u.h"
8 7
diff --git a/src/core/hle/service/am_app.cpp b/src/core/hle/service/am_app.cpp
index df10db87f..684b753f0 100644
--- a/src/core/hle/service/am_app.cpp
+++ b/src/core/hle/service/am_app.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/am_app.h" 6#include "core/hle/service/am_app.h"
8 7
diff --git a/src/core/hle/service/am_net.cpp b/src/core/hle/service/am_net.cpp
index c74012d9d..ba2a499f1 100644
--- a/src/core/hle/service/am_net.cpp
+++ b/src/core/hle/service/am_net.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/am_net.h" 6#include "core/hle/service/am_net.h"
8 7
diff --git a/src/core/hle/service/am_sys.cpp b/src/core/hle/service/am_sys.cpp
index c5df8abda..7ab89569f 100644
--- a/src/core/hle/service/am_sys.cpp
+++ b/src/core/hle/service/am_sys.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/am_sys.h" 6#include "core/hle/service/am_sys.h"
8 7
diff --git a/src/core/hle/service/apt_a.cpp b/src/core/hle/service/apt_a.cpp
index e1dd2a5fb..1c1d92572 100644
--- a/src/core/hle/service/apt_a.cpp
+++ b/src/core/hle/service/apt_a.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/apt_a.h" 6#include "core/hle/service/apt_a.h"
8 7
diff --git a/src/core/hle/service/apt_u.cpp b/src/core/hle/service/apt_u.cpp
index ccfd04591..12af5e9f7 100644
--- a/src/core/hle/service/apt_u.cpp
+++ b/src/core/hle/service/apt_u.cpp
@@ -79,7 +79,7 @@ void Initialize(Service::Interface* self) {
79 notification_event->Clear(); 79 notification_event->Clear();
80 pause_event->Signal(); // Fire start event 80 pause_event->Signal(); // Fire start event
81 81
82 _assert_msg_(KERNEL, (nullptr != lock), "Cannot initialize without lock"); 82 ASSERT_MSG((nullptr != lock), "Cannot initialize without lock");
83 lock->Release(); 83 lock->Release();
84 84
85 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 85 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
diff --git a/src/core/hle/service/boss_p.cpp b/src/core/hle/service/boss_p.cpp
index b3aa6acee..8280830e5 100644
--- a/src/core/hle/service/boss_p.cpp
+++ b/src/core/hle/service/boss_p.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/boss_p.h" 6#include "core/hle/service/boss_p.h"
8 7
diff --git a/src/core/hle/service/boss_u.cpp b/src/core/hle/service/boss_u.cpp
index 50bb5d426..2c322bdfd 100644
--- a/src/core/hle/service/boss_u.cpp
+++ b/src/core/hle/service/boss_u.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/boss_u.h" 6#include "core/hle/service/boss_u.h"
8 7
diff --git a/src/core/hle/service/cam_u.cpp b/src/core/hle/service/cam_u.cpp
index cf3b27664..fcfd87715 100644
--- a/src/core/hle/service/cam_u.cpp
+++ b/src/core/hle/service/cam_u.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/cam_u.h" 6#include "core/hle/service/cam_u.h"
8 7
diff --git a/src/core/hle/service/cecd_s.cpp b/src/core/hle/service/cecd_s.cpp
index 2c707baff..b298f151d 100644
--- a/src/core/hle/service/cecd_s.cpp
+++ b/src/core/hle/service/cecd_s.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/cecd_s.h" 6#include "core/hle/service/cecd_s.h"
8 7
diff --git a/src/core/hle/service/cecd_u.cpp b/src/core/hle/service/cecd_u.cpp
index b7ea3a186..9125364bc 100644
--- a/src/core/hle/service/cecd_u.cpp
+++ b/src/core/hle/service/cecd_u.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/cecd_u.h" 6#include "core/hle/service/cecd_u.h"
8 7
diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp
index 8812c49ef..1a2104b48 100644
--- a/src/core/hle/service/cfg/cfg.cpp
+++ b/src/core/hle/service/cfg/cfg.cpp
@@ -3,7 +3,6 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include "common/log.h"
7#include "common/make_unique.h" 6#include "common/make_unique.h"
8#include "core/file_sys/archive_systemsavedata.h" 7#include "core/file_sys/archive_systemsavedata.h"
9#include "core/hle/service/cfg/cfg.h" 8#include "core/hle/service/cfg/cfg.h"
@@ -109,7 +108,7 @@ ResultCode UpdateConfigNANDSavegame() {
109 mode.create_flag = 1; 108 mode.create_flag = 1;
110 FileSys::Path path("config"); 109 FileSys::Path path("config");
111 auto file = cfg_system_save_data->OpenFile(path, mode); 110 auto file = cfg_system_save_data->OpenFile(path, mode);
112 _assert_msg_(Service_CFG, file != nullptr, "could not open file"); 111 ASSERT_MSG(file != nullptr, "could not open file");
113 file->Write(0, CONFIG_SAVEFILE_SIZE, 1, cfg_config_file_buffer.data()); 112 file->Write(0, CONFIG_SAVEFILE_SIZE, 1, cfg_config_file_buffer.data());
114 return RESULT_SUCCESS; 113 return RESULT_SUCCESS;
115} 114}
diff --git a/src/core/hle/service/cfg/cfg_i.cpp b/src/core/hle/service/cfg/cfg_i.cpp
index 555b7884a..20b09a8cb 100644
--- a/src/core/hle/service/cfg/cfg_i.cpp
+++ b/src/core/hle/service/cfg/cfg_i.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/cfg/cfg.h" 6#include "core/hle/service/cfg/cfg.h"
8#include "core/hle/service/cfg/cfg_i.h" 7#include "core/hle/service/cfg/cfg_i.h"
diff --git a/src/core/hle/service/cfg/cfg_s.cpp b/src/core/hle/service/cfg/cfg_s.cpp
index 2170894d6..d80aeae8d 100644
--- a/src/core/hle/service/cfg/cfg_s.cpp
+++ b/src/core/hle/service/cfg/cfg_s.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/cfg/cfg.h" 6#include "core/hle/service/cfg/cfg.h"
8#include "core/hle/service/cfg/cfg_s.h" 7#include "core/hle/service/cfg/cfg_s.h"
diff --git a/src/core/hle/service/cfg/cfg_u.cpp b/src/core/hle/service/cfg/cfg_u.cpp
index 1da9f59f6..4c5eac382 100644
--- a/src/core/hle/service/cfg/cfg_u.cpp
+++ b/src/core/hle/service/cfg/cfg_u.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 "common/file_util.h" 5#include "common/file_util.h"
6#include "common/log.h"
7#include "common/string_util.h" 6#include "common/string_util.h"
7#include "core/settings.h"
8#include "core/file_sys/archive_systemsavedata.h" 8#include "core/file_sys/archive_systemsavedata.h"
9#include "core/hle/hle.h" 9#include "core/hle/hle.h"
10#include "core/hle/service/cfg/cfg.h" 10#include "core/hle/service/cfg/cfg.h"
@@ -83,7 +83,7 @@ static void GetCountryCodeID(Service::Interface* self) {
83 u16 country_code_id = 0; 83 u16 country_code_id = 0;
84 84
85 // The following algorithm will fail if the first country code isn't 0. 85 // The following algorithm will fail if the first country code isn't 0.
86 _dbg_assert_(Service_CFG, country_codes[0] == 0); 86 DEBUG_ASSERT(country_codes[0] == 0);
87 87
88 for (size_t id = 0; id < country_codes.size(); ++id) { 88 for (size_t id = 0; id < country_codes.size(); ++id) {
89 if (country_codes[id] == country_code) { 89 if (country_codes[id] == country_code) {
@@ -129,6 +129,65 @@ static void GetConfigInfoBlk2(Service::Interface* self) {
129} 129}
130 130
131/** 131/**
132 * CFG_User::SecureInfoGetRegion service function
133 * Inputs:
134 * 1 : None
135 * Outputs:
136 * 0 : Result Header code
137 * 1 : Result of function, 0 on success, otherwise error code
138 * 2 : Region value loaded from SecureInfo offset 0x100
139 */
140static void SecureInfoGetRegion(Service::Interface* self) {
141 u32* cmd_buffer = Kernel::GetCommandBuffer();
142
143 cmd_buffer[1] = RESULT_SUCCESS.raw; // No Error
144 cmd_buffer[2] = Settings::values.region_value;
145}
146
147/**
148 * CFG_User::GenHashConsoleUnique service function
149 * Inputs:
150 * 1 : 20 bit application ID salt
151 * Outputs:
152 * 0 : Result Header code
153 * 1 : Result of function, 0 on success, otherwise error code
154 * 2 : Hash/"ID" lower word
155 * 3 : Hash/"ID" upper word
156 */
157static void GenHashConsoleUnique(Service::Interface* self) {
158 u32* cmd_buffer = Kernel::GetCommandBuffer();
159 u32 app_id_salt = cmd_buffer[1];
160
161 cmd_buffer[1] = RESULT_SUCCESS.raw; // No Error
162 cmd_buffer[2] = 0x33646D6F ^ (app_id_salt & 0xFFFFF); // 3dmoo hash
163 cmd_buffer[3] = 0x6F534841 ^ (app_id_salt & 0xFFFFF);
164
165 LOG_WARNING(Service_CFG, "(STUBBED) called app_id_salt=0x%08X", app_id_salt);
166}
167
168/**
169 * CFG_User::GetRegionCanadaUSA service function
170 * Inputs:
171 * 1 : None
172 * Outputs:
173 * 0 : Result Header code
174 * 1 : Result of function, 0 on success, otherwise error code
175 * 2 : Output value
176 */
177static void GetRegionCanadaUSA(Service::Interface* self) {
178 u32* cmd_buffer = Kernel::GetCommandBuffer();
179
180 cmd_buffer[1] = RESULT_SUCCESS.raw; // No Error
181
182 u8 canada_or_usa = 1;
183 if (canada_or_usa == Settings::values.region_value) {
184 cmd_buffer[2] = 1;
185 } else {
186 cmd_buffer[2] = 0;
187 }
188}
189
190/**
132 * CFG_User::GetSystemModel service function 191 * CFG_User::GetSystemModel service function
133 * Inputs: 192 * Inputs:
134 * 0 : 0x00050000 193 * 0 : 0x00050000
@@ -171,9 +230,9 @@ static void GetModelNintendo2DS(Service::Interface* self) {
171 230
172const Interface::FunctionInfo FunctionTable[] = { 231const Interface::FunctionInfo FunctionTable[] = {
173 {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"}, 232 {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
174 {0x00020000, nullptr, "SecureInfoGetRegion"}, 233 {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"},
175 {0x00030040, nullptr, "GenHashConsoleUnique"}, 234 {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"},
176 {0x00040000, nullptr, "GetRegionCanadaUSA"}, 235 {0x00040000, GetRegionCanadaUSA, "GetRegionCanadaUSA"},
177 {0x00050000, GetSystemModel, "GetSystemModel"}, 236 {0x00050000, GetSystemModel, "GetSystemModel"},
178 {0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"}, 237 {0x00060000, GetModelNintendo2DS, "GetModelNintendo2DS"},
179 {0x00070040, nullptr, "WriteToFirstByteCfgSavegame"}, 238 {0x00070040, nullptr, "WriteToFirstByteCfgSavegame"},
diff --git a/src/core/hle/service/csnd_snd.cpp b/src/core/hle/service/csnd_snd.cpp
index 39b00982c..6a1d961ac 100644
--- a/src/core/hle/service/csnd_snd.cpp
+++ b/src/core/hle/service/csnd_snd.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/csnd_snd.h" 6#include "core/hle/service/csnd_snd.h"
8 7
diff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cpp
index 0f86894a6..db1e3b5fd 100644
--- a/src/core/hle/service/dsp_dsp.cpp
+++ b/src/core/hle/service/dsp_dsp.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/kernel/event.h" 6#include "core/hle/kernel/event.h"
8#include "core/hle/service/dsp_dsp.h" 7#include "core/hle/service/dsp_dsp.h"
@@ -128,6 +127,31 @@ void WriteReg0x10(Service::Interface* self) {
128} 127}
129 128
130/** 129/**
130 * DSP_DSP::WriteProcessPipe service function
131 * Inputs:
132 * 1 : Number
133 * 2 : Size
134 * 3 : (size <<14) | 0x402
135 * 4 : Buffer
136 * Outputs:
137 * 0 : Return header
138 * 1 : Result of function, 0 on success, otherwise error code
139 */
140void WriteProcessPipe(Service::Interface* self) {
141 u32* cmd_buff = Kernel::GetCommandBuffer();
142
143 u32 number = cmd_buff[1];
144 u32 size = cmd_buff[2];
145 u32 new_size = cmd_buff[3];
146 u32 buffer = cmd_buff[4];
147
148 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
149
150 LOG_WARNING(Service_DSP, "(STUBBED) called number=%u, size=0x%08X, new_size=0x%08X, buffer=0x%08X",
151 number, size, new_size, buffer);
152}
153
154/**
131 * DSP_DSP::ReadPipeIfPossible service function 155 * DSP_DSP::ReadPipeIfPossible service function
132 * Inputs: 156 * Inputs:
133 * 1 : Unknown 157 * 1 : Unknown
@@ -169,6 +193,41 @@ void ReadPipeIfPossible(Service::Interface* self) {
169 LOG_WARNING(Service_DSP, "(STUBBED) called size=0x%08X, buffer=0x%08X", size, addr); 193 LOG_WARNING(Service_DSP, "(STUBBED) called size=0x%08X, buffer=0x%08X", size, addr);
170} 194}
171 195
196/**
197 * DSP_DSP::SetSemaphoreMask service function
198 * Inputs:
199 * 1 : Mask
200 * Outputs:
201 * 1 : Result of function, 0 on success, otherwise error code
202 */
203void SetSemaphoreMask(Service::Interface* self) {
204 u32* cmd_buff = Kernel::GetCommandBuffer();
205
206 u32 mask = cmd_buff[1];
207
208 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
209
210 LOG_WARNING(Service_DSP, "(STUBBED) called mask=0x%08X", mask);
211}
212
213/**
214 * DSP_DSP::GetHeadphoneStatus service function
215 * Inputs:
216 * 1 : None
217 * Outputs:
218 * 1 : Result of function, 0 on success, otherwise error code
219 * 2 : The headphone status response, 0 = Not using headphones?,
220 * 1 = using headphones?
221 */
222void GetHeadphoneStatus(Service::Interface* self) {
223 u32* cmd_buff = Kernel::GetCommandBuffer();
224
225 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
226 cmd_buff[2] = 0; // Not using headphones?
227
228 LOG_WARNING(Service_DSP, "(STUBBED) called");
229}
230
172const Interface::FunctionInfo FunctionTable[] = { 231const Interface::FunctionInfo FunctionTable[] = {
173 {0x00010040, nullptr, "RecvData"}, 232 {0x00010040, nullptr, "RecvData"},
174 {0x00020040, nullptr, "RecvDataIsReady"}, 233 {0x00020040, nullptr, "RecvDataIsReady"},
@@ -179,7 +238,7 @@ const Interface::FunctionInfo FunctionTable[] = {
179 {0x00090040, nullptr, "ClearSemaphore"}, 238 {0x00090040, nullptr, "ClearSemaphore"},
180 {0x000B0000, nullptr, "CheckSemaphoreRequest"}, 239 {0x000B0000, nullptr, "CheckSemaphoreRequest"},
181 {0x000C0040, ConvertProcessAddressFromDspDram, "ConvertProcessAddressFromDspDram"}, 240 {0x000C0040, ConvertProcessAddressFromDspDram, "ConvertProcessAddressFromDspDram"},
182 {0x000D0082, nullptr, "WriteProcessPipe"}, 241 {0x000D0082, WriteProcessPipe, "WriteProcessPipe"},
183 {0x001000C0, ReadPipeIfPossible, "ReadPipeIfPossible"}, 242 {0x001000C0, ReadPipeIfPossible, "ReadPipeIfPossible"},
184 {0x001100C2, LoadComponent, "LoadComponent"}, 243 {0x001100C2, LoadComponent, "LoadComponent"},
185 {0x00120000, nullptr, "UnloadComponent"}, 244 {0x00120000, nullptr, "UnloadComponent"},
@@ -187,13 +246,13 @@ const Interface::FunctionInfo FunctionTable[] = {
187 {0x00140082, nullptr, "InvalidateDCache"}, 246 {0x00140082, nullptr, "InvalidateDCache"},
188 {0x00150082, RegisterInterruptEvents, "RegisterInterruptEvents"}, 247 {0x00150082, RegisterInterruptEvents, "RegisterInterruptEvents"},
189 {0x00160000, GetSemaphoreEventHandle, "GetSemaphoreEventHandle"}, 248 {0x00160000, GetSemaphoreEventHandle, "GetSemaphoreEventHandle"},
190 {0x00170040, nullptr, "SetSemaphoreMask"}, 249 {0x00170040, SetSemaphoreMask, "SetSemaphoreMask"},
191 {0x00180040, nullptr, "GetPhysicalAddress"}, 250 {0x00180040, nullptr, "GetPhysicalAddress"},
192 {0x00190040, nullptr, "GetVirtualAddress"}, 251 {0x00190040, nullptr, "GetVirtualAddress"},
193 {0x001A0042, nullptr, "SetIirFilterI2S1_cmd1"}, 252 {0x001A0042, nullptr, "SetIirFilterI2S1_cmd1"},
194 {0x001B0042, nullptr, "SetIirFilterI2S1_cmd2"}, 253 {0x001B0042, nullptr, "SetIirFilterI2S1_cmd2"},
195 {0x001C0082, nullptr, "SetIirFilterEQ"}, 254 {0x001C0082, nullptr, "SetIirFilterEQ"},
196 {0x001F0000, nullptr, "GetHeadphoneStatus"}, 255 {0x001F0000, GetHeadphoneStatus, "GetHeadphoneStatus"},
197 {0x00210000, nullptr, "GetIsDspOccupied"}, 256 {0x00210000, nullptr, "GetIsDspOccupied"},
198}; 257};
199 258
diff --git a/src/core/hle/service/err_f.cpp b/src/core/hle/service/err_f.cpp
index 962de2170..8d765acb5 100644
--- a/src/core/hle/service/err_f.cpp
+++ b/src/core/hle/service/err_f.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/err_f.h" 6#include "core/hle/service/err_f.h"
8 7
diff --git a/src/core/hle/service/frd_a.cpp b/src/core/hle/service/frd_a.cpp
index 79140a756..569979319 100644
--- a/src/core/hle/service/frd_a.cpp
+++ b/src/core/hle/service/frd_a.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/frd_a.h" 6#include "core/hle/service/frd_a.h"
8 7
diff --git a/src/core/hle/service/frd_u.cpp b/src/core/hle/service/frd_u.cpp
index 59faca77a..6d2ff1e21 100644
--- a/src/core/hle/service/frd_u.cpp
+++ b/src/core/hle/service/frd_u.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/frd_u.h" 6#include "core/hle/service/frd_u.h"
8 7
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index ccf132f31..37bcec219 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -5,6 +5,8 @@
5#include <memory> 5#include <memory>
6#include <unordered_map> 6#include <unordered_map>
7 7
8#include <boost/container/flat_map.hpp>
9
8#include "common/common_types.h" 10#include "common/common_types.h"
9#include "common/file_util.h" 11#include "common/file_util.h"
10#include "common/make_unique.h" 12#include "common/make_unique.h"
@@ -18,7 +20,6 @@
18#include "core/file_sys/archive_sdmc.h" 20#include "core/file_sys/archive_sdmc.h"
19#include "core/file_sys/directory_backend.h" 21#include "core/file_sys/directory_backend.h"
20#include "core/hle/service/fs/archive.h" 22#include "core/hle/service/fs/archive.h"
21#include "core/hle/kernel/session.h"
22#include "core/hle/result.h" 23#include "core/hle/result.h"
23 24
24// Specializes std::hash for ArchiveIdCode, so that we can use it in std::unordered_map. 25// Specializes std::hash for ArchiveIdCode, so that we can use it in std::unordered_map.
@@ -74,43 +75,19 @@ enum class DirectoryCommand : u32 {
74 Close = 0x08020000, 75 Close = 0x08020000,
75}; 76};
76 77
77class Archive { 78ResultVal<bool> File::SyncRequest() {
78public: 79 u32* cmd_buff = Kernel::GetCommandBuffer();
79 Archive(std::unique_ptr<FileSys::ArchiveBackend>&& backend, ArchiveIdCode id_code) 80 FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
80 : id_code(id_code), backend(std::move(backend)) { 81 switch (cmd) {
81 }
82
83 std::string GetName() const { return "Archive: " + backend->GetName(); }
84
85 ArchiveIdCode id_code; ///< Id code of the archive
86 std::unique_ptr<FileSys::ArchiveBackend> backend; ///< Archive backend interface
87};
88
89class File : public Kernel::Session {
90public:
91 File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path)
92 : path(path), priority(0), backend(std::move(backend)) {
93 }
94
95 std::string GetName() const override { return "Path: " + path.DebugStr(); }
96
97 FileSys::Path path; ///< Path of the file
98 u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means
99 std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface
100
101 ResultVal<bool> SyncRequest() override {
102 u32* cmd_buff = Kernel::GetCommandBuffer();
103 FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
104 switch (cmd) {
105 82
106 // Read from file... 83 // Read from file...
107 case FileCommand::Read: 84 case FileCommand::Read:
108 { 85 {
109 u64 offset = cmd_buff[1] | ((u64) cmd_buff[2]) << 32; 86 u64 offset = cmd_buff[1] | ((u64)cmd_buff[2]) << 32;
110 u32 length = cmd_buff[3]; 87 u32 length = cmd_buff[3];
111 u32 address = cmd_buff[5]; 88 u32 address = cmd_buff[5];
112 LOG_TRACE(Service_FS, "Read %s %s: offset=0x%llx length=%d address=0x%x", 89 LOG_TRACE(Service_FS, "Read %s %s: offset=0x%llx length=%d address=0x%x",
113 GetTypeName().c_str(), GetName().c_str(), offset, length, address); 90 GetTypeName().c_str(), GetName().c_str(), offset, length, address);
114 cmd_buff[2] = backend->Read(offset, length, Memory::GetPointer(address)); 91 cmd_buff[2] = backend->Read(offset, length, Memory::GetPointer(address));
115 break; 92 break;
116 } 93 }
@@ -118,12 +95,12 @@ public:
118 // Write to file... 95 // Write to file...
119 case FileCommand::Write: 96 case FileCommand::Write:
120 { 97 {
121 u64 offset = cmd_buff[1] | ((u64) cmd_buff[2]) << 32; 98 u64 offset = cmd_buff[1] | ((u64)cmd_buff[2]) << 32;
122 u32 length = cmd_buff[3]; 99 u32 length = cmd_buff[3];
123 u32 flush = cmd_buff[4]; 100 u32 flush = cmd_buff[4];
124 u32 address = cmd_buff[6]; 101 u32 address = cmd_buff[6];
125 LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x", 102 LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x",
126 GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush); 103 GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush);
127 cmd_buff[2] = backend->Write(offset, length, flush, Memory::GetPointer(address)); 104 cmd_buff[2] = backend->Write(offset, length, flush, Memory::GetPointer(address));
128 break; 105 break;
129 } 106 }
@@ -141,7 +118,7 @@ public:
141 { 118 {
142 u64 size = cmd_buff[1] | ((u64)cmd_buff[2] << 32); 119 u64 size = cmd_buff[1] | ((u64)cmd_buff[2] << 32);
143 LOG_TRACE(Service_FS, "SetSize %s %s size=%llu", 120 LOG_TRACE(Service_FS, "SetSize %s %s size=%llu",
144 GetTypeName().c_str(), GetName().c_str(), size); 121 GetTypeName().c_str(), GetName().c_str(), size);
145 backend->SetSize(size); 122 backend->SetSize(size);
146 break; 123 break;
147 } 124 }
@@ -187,27 +164,15 @@ public:
187 ResultCode error = UnimplementedFunction(ErrorModule::FS); 164 ResultCode error = UnimplementedFunction(ErrorModule::FS);
188 cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that. 165 cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
189 return error; 166 return error;
190 }
191 cmd_buff[1] = 0; // No error
192 return MakeResult<bool>(false);
193 } 167 }
194}; 168 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
195 169 return MakeResult<bool>(false);
196class Directory : public Kernel::Session { 170}
197public:
198 Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path& path)
199 : path(path), backend(std::move(backend)) {
200 }
201
202 std::string GetName() const override { return "Directory: " + path.DebugStr(); }
203
204 FileSys::Path path; ///< Path of the directory
205 std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface
206 171
207 ResultVal<bool> SyncRequest() override { 172ResultVal<bool> Directory::SyncRequest() {
208 u32* cmd_buff = Kernel::GetCommandBuffer(); 173 u32* cmd_buff = Kernel::GetCommandBuffer();
209 DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]); 174 DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]);
210 switch (cmd) { 175 switch (cmd) {
211 176
212 // Read from directory... 177 // Read from directory...
213 case DirectoryCommand::Read: 178 case DirectoryCommand::Read:
@@ -216,7 +181,7 @@ public:
216 u32 address = cmd_buff[3]; 181 u32 address = cmd_buff[3];
217 auto entries = reinterpret_cast<FileSys::Entry*>(Memory::GetPointer(address)); 182 auto entries = reinterpret_cast<FileSys::Entry*>(Memory::GetPointer(address));
218 LOG_TRACE(Service_FS, "Read %s %s: count=%d", 183 LOG_TRACE(Service_FS, "Read %s %s: count=%d",
219 GetTypeName().c_str(), GetName().c_str(), count); 184 GetTypeName().c_str(), GetName().c_str(), count);
220 185
221 // Number of entries actually read 186 // Number of entries actually read
222 cmd_buff[2] = backend->Read(count, entries); 187 cmd_buff[2] = backend->Read(count, entries);
@@ -236,29 +201,31 @@ public:
236 ResultCode error = UnimplementedFunction(ErrorModule::FS); 201 ResultCode error = UnimplementedFunction(ErrorModule::FS);
237 cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that. 202 cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
238 return MakeResult<bool>(false); 203 return MakeResult<bool>(false);
239 }
240 cmd_buff[1] = 0; // No error
241 return MakeResult<bool>(false);
242 } 204 }
243}; 205 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
206 return MakeResult<bool>(false);
207}
244 208
245//////////////////////////////////////////////////////////////////////////////////////////////////// 209////////////////////////////////////////////////////////////////////////////////////////////////////
246 210
211using FileSys::ArchiveBackend;
212using FileSys::ArchiveFactory;
213
247/** 214/**
248 * Map of registered archives, identified by id code. Once an archive is registered here, it is 215 * Map of registered archives, identified by id code. Once an archive is registered here, it is
249 * never removed until the FS service is shut down. 216 * never removed until the FS service is shut down.
250 */ 217 */
251static std::unordered_map<ArchiveIdCode, std::unique_ptr<Archive>> id_code_map; 218static boost::container::flat_map<ArchiveIdCode, std::unique_ptr<ArchiveFactory>> id_code_map;
252 219
253/** 220/**
254 * Map of active archive handles. Values are pointers to the archives in `idcode_map`. 221 * Map of active archive handles. Values are pointers to the archives in `idcode_map`.
255 */ 222 */
256static std::unordered_map<ArchiveHandle, Archive*> handle_map; 223static std::unordered_map<ArchiveHandle, std::unique_ptr<ArchiveBackend>> handle_map;
257static ArchiveHandle next_handle; 224static ArchiveHandle next_handle;
258 225
259static Archive* GetArchive(ArchiveHandle handle) { 226static ArchiveBackend* GetArchive(ArchiveHandle handle) {
260 auto itr = handle_map.find(handle); 227 auto itr = handle_map.find(handle);
261 return (itr == handle_map.end()) ? nullptr : itr->second; 228 return (itr == handle_map.end()) ? nullptr : itr->second.get();
262} 229}
263 230
264ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archive_path) { 231ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archive_path) {
@@ -271,15 +238,13 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi
271 ErrorSummary::NotFound, ErrorLevel::Permanent); 238 ErrorSummary::NotFound, ErrorLevel::Permanent);
272 } 239 }
273 240
274 ResultCode res = itr->second->backend->Open(archive_path); 241 CASCADE_RESULT(std::unique_ptr<ArchiveBackend> res, itr->second->Open(archive_path));
275 if (!res.IsSuccess())
276 return res;
277 242
278 // This should never even happen in the first place with 64-bit handles, 243 // This should never even happen in the first place with 64-bit handles,
279 while (handle_map.count(next_handle) != 0) { 244 while (handle_map.count(next_handle) != 0) {
280 ++next_handle; 245 ++next_handle;
281 } 246 }
282 handle_map.emplace(next_handle, itr->second.get()); 247 handle_map.emplace(next_handle, std::move(res));
283 return MakeResult<ArchiveHandle>(next_handle++); 248 return MakeResult<ArchiveHandle>(next_handle++);
284} 249}
285 250
@@ -292,39 +257,39 @@ ResultCode CloseArchive(ArchiveHandle handle) {
292 257
293// TODO(yuriks): This might be what the fs:REG service is for. See the Register/Unregister calls in 258// TODO(yuriks): This might be what the fs:REG service is for. See the Register/Unregister calls in
294// http://3dbrew.org/wiki/Filesystem_services#ProgramRegistry_service_.22fs:REG.22 259// http://3dbrew.org/wiki/Filesystem_services#ProgramRegistry_service_.22fs:REG.22
295ResultCode CreateArchive(std::unique_ptr<FileSys::ArchiveBackend>&& backend, ArchiveIdCode id_code) { 260ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory, ArchiveIdCode id_code) {
296 auto result = id_code_map.emplace(id_code, Common::make_unique<Archive>(std::move(backend), id_code)); 261 auto result = id_code_map.emplace(id_code, std::move(factory));
297 262
298 bool inserted = result.second; 263 bool inserted = result.second;
299 _dbg_assert_msg_(Service_FS, inserted, "Tried to register more than one archive with same id code"); 264 ASSERT_MSG(inserted, "Tried to register more than one archive with same id code");
300 265
301 auto& archive = result.first->second; 266 auto& archive = result.first->second;
302 LOG_DEBUG(Service_FS, "Registered archive %s with id code 0x%08X", archive->GetName().c_str(), id_code); 267 LOG_DEBUG(Service_FS, "Registered archive %s with id code 0x%08X", archive->GetName().c_str(), id_code);
303 return RESULT_SUCCESS; 268 return RESULT_SUCCESS;
304} 269}
305 270
306ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenFileFromArchive(ArchiveHandle archive_handle, 271ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_handle,
307 const FileSys::Path& path, const FileSys::Mode mode) { 272 const FileSys::Path& path, const FileSys::Mode mode) {
308 Archive* archive = GetArchive(archive_handle); 273 ArchiveBackend* archive = GetArchive(archive_handle);
309 if (archive == nullptr) 274 if (archive == nullptr)
310 return ERR_INVALID_HANDLE; 275 return ERR_INVALID_HANDLE;
311 276
312 std::unique_ptr<FileSys::FileBackend> backend = archive->backend->OpenFile(path, mode); 277 std::unique_ptr<FileSys::FileBackend> backend = archive->OpenFile(path, mode);
313 if (backend == nullptr) { 278 if (backend == nullptr) {
314 return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, 279 return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS,
315 ErrorSummary::NotFound, ErrorLevel::Status); 280 ErrorSummary::NotFound, ErrorLevel::Status);
316 } 281 }
317 282
318 auto file = Kernel::SharedPtr<File>(new File(std::move(backend), path)); 283 auto file = Kernel::SharedPtr<File>(new File(std::move(backend), path));
319 return MakeResult<Kernel::SharedPtr<Kernel::Session>>(std::move(file)); 284 return MakeResult<Kernel::SharedPtr<File>>(std::move(file));
320} 285}
321 286
322ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { 287ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
323 Archive* archive = GetArchive(archive_handle); 288 ArchiveBackend* archive = GetArchive(archive_handle);
324 if (archive == nullptr) 289 if (archive == nullptr)
325 return ERR_INVALID_HANDLE; 290 return ERR_INVALID_HANDLE;
326 291
327 if (archive->backend->DeleteFile(path)) 292 if (archive->DeleteFile(path))
328 return RESULT_SUCCESS; 293 return RESULT_SUCCESS;
329 return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description 294 return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
330 ErrorSummary::Canceled, ErrorLevel::Status); 295 ErrorSummary::Canceled, ErrorLevel::Status);
@@ -332,13 +297,13 @@ ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Pa
332 297
333ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path, 298ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,
334 ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path) { 299 ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path) {
335 Archive* src_archive = GetArchive(src_archive_handle); 300 ArchiveBackend* src_archive = GetArchive(src_archive_handle);
336 Archive* dest_archive = GetArchive(dest_archive_handle); 301 ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
337 if (src_archive == nullptr || dest_archive == nullptr) 302 if (src_archive == nullptr || dest_archive == nullptr)
338 return ERR_INVALID_HANDLE; 303 return ERR_INVALID_HANDLE;
339 304
340 if (src_archive == dest_archive) { 305 if (src_archive == dest_archive) {
341 if (src_archive->backend->RenameFile(src_path, dest_path)) 306 if (src_archive->RenameFile(src_path, dest_path))
342 return RESULT_SUCCESS; 307 return RESULT_SUCCESS;
343 } else { 308 } else {
344 // TODO: Implement renaming across archives 309 // TODO: Implement renaming across archives
@@ -352,30 +317,30 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const Fil
352} 317}
353 318
354ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { 319ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
355 Archive* archive = GetArchive(archive_handle); 320 ArchiveBackend* archive = GetArchive(archive_handle);
356 if (archive == nullptr) 321 if (archive == nullptr)
357 return ERR_INVALID_HANDLE; 322 return ERR_INVALID_HANDLE;
358 323
359 if (archive->backend->DeleteDirectory(path)) 324 if (archive->DeleteDirectory(path))
360 return RESULT_SUCCESS; 325 return RESULT_SUCCESS;
361 return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description 326 return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
362 ErrorSummary::Canceled, ErrorLevel::Status); 327 ErrorSummary::Canceled, ErrorLevel::Status);
363} 328}
364 329
365ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u32 file_size) { 330ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u32 file_size) {
366 Archive* archive = GetArchive(archive_handle); 331 ArchiveBackend* archive = GetArchive(archive_handle);
367 if (archive == nullptr) 332 if (archive == nullptr)
368 return ERR_INVALID_HANDLE; 333 return ERR_INVALID_HANDLE;
369 334
370 return archive->backend->CreateFile(path, file_size); 335 return archive->CreateFile(path, file_size);
371} 336}
372 337
373ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { 338ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
374 Archive* archive = GetArchive(archive_handle); 339 ArchiveBackend* archive = GetArchive(archive_handle);
375 if (archive == nullptr) 340 if (archive == nullptr)
376 return ERR_INVALID_HANDLE; 341 return ERR_INVALID_HANDLE;
377 342
378 if (archive->backend->CreateDirectory(path)) 343 if (archive->CreateDirectory(path))
379 return RESULT_SUCCESS; 344 return RESULT_SUCCESS;
380 return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description 345 return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
381 ErrorSummary::Canceled, ErrorLevel::Status); 346 ErrorSummary::Canceled, ErrorLevel::Status);
@@ -383,13 +348,13 @@ ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
383 348
384ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path, 349ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,
385 ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path) { 350 ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path) {
386 Archive* src_archive = GetArchive(src_archive_handle); 351 ArchiveBackend* src_archive = GetArchive(src_archive_handle);
387 Archive* dest_archive = GetArchive(dest_archive_handle); 352 ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
388 if (src_archive == nullptr || dest_archive == nullptr) 353 if (src_archive == nullptr || dest_archive == nullptr)
389 return ERR_INVALID_HANDLE; 354 return ERR_INVALID_HANDLE;
390 355
391 if (src_archive == dest_archive) { 356 if (src_archive == dest_archive) {
392 if (src_archive->backend->RenameDirectory(src_path, dest_path)) 357 if (src_archive->RenameDirectory(src_path, dest_path))
393 return RESULT_SUCCESS; 358 return RESULT_SUCCESS;
394 } else { 359 } else {
395 // TODO: Implement renaming across archives 360 // TODO: Implement renaming across archives
@@ -402,31 +367,29 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons
402 ErrorSummary::NothingHappened, ErrorLevel::Status); 367 ErrorSummary::NothingHappened, ErrorLevel::Status);
403} 368}
404 369
405ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenDirectoryFromArchive(ArchiveHandle archive_handle, 370ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
406 const FileSys::Path& path) { 371 const FileSys::Path& path) {
407 Archive* archive = GetArchive(archive_handle); 372 ArchiveBackend* archive = GetArchive(archive_handle);
408 if (archive == nullptr) 373 if (archive == nullptr)
409 return ERR_INVALID_HANDLE; 374 return ERR_INVALID_HANDLE;
410 375
411 std::unique_ptr<FileSys::DirectoryBackend> backend = archive->backend->OpenDirectory(path); 376 std::unique_ptr<FileSys::DirectoryBackend> backend = archive->OpenDirectory(path);
412 if (backend == nullptr) { 377 if (backend == nullptr) {
413 return ResultCode(ErrorDescription::NotFound, ErrorModule::FS, 378 return ResultCode(ErrorDescription::NotFound, ErrorModule::FS,
414 ErrorSummary::NotFound, ErrorLevel::Permanent); 379 ErrorSummary::NotFound, ErrorLevel::Permanent);
415 } 380 }
416 381
417 auto directory = Kernel::SharedPtr<Directory>(new Directory(std::move(backend), path)); 382 auto directory = Kernel::SharedPtr<Directory>(new Directory(std::move(backend), path));
418 return MakeResult<Kernel::SharedPtr<Kernel::Session>>(std::move(directory)); 383 return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory));
419} 384}
420 385
421ResultCode FormatSaveData() { 386ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path) {
422 // Do not create the archive again if it already exists 387 auto archive_itr = id_code_map.find(id_code);
423 auto archive_itr = id_code_map.find(ArchiveIdCode::SaveData);
424 if (archive_itr == id_code_map.end()) { 388 if (archive_itr == id_code_map.end()) {
425 return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error 389 return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
426 } 390 }
427 391
428 // Use an empty path, we do not use it when formatting the savedata 392 return archive_itr->second->Format(path);
429 return archive_itr->second->backend->Format(FileSys::Path());
430} 393}
431 394
432ResultCode CreateExtSaveData(u32 high, u32 low) { 395ResultCode CreateExtSaveData(u32 high, u32 low) {
@@ -460,32 +423,32 @@ void ArchiveInit() {
460 423
461 std::string sdmc_directory = FileUtil::GetUserPath(D_SDMC_IDX); 424 std::string sdmc_directory = FileUtil::GetUserPath(D_SDMC_IDX);
462 std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX); 425 std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
463 auto sdmc_archive = Common::make_unique<FileSys::Archive_SDMC>(sdmc_directory); 426 auto sdmc_factory = Common::make_unique<FileSys::ArchiveFactory_SDMC>(sdmc_directory);
464 if (sdmc_archive->Initialize()) 427 if (sdmc_factory->Initialize())
465 CreateArchive(std::move(sdmc_archive), ArchiveIdCode::SDMC); 428 RegisterArchiveType(std::move(sdmc_factory), ArchiveIdCode::SDMC);
466 else 429 else
467 LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str()); 430 LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str());
468 431
469 // Create the SaveData archive 432 // Create the SaveData archive
470 auto savedata_archive = Common::make_unique<FileSys::Archive_SaveData>(sdmc_directory); 433 auto savedata_factory = Common::make_unique<FileSys::ArchiveFactory_SaveData>(sdmc_directory);
471 CreateArchive(std::move(savedata_archive), ArchiveIdCode::SaveData); 434 RegisterArchiveType(std::move(savedata_factory), ArchiveIdCode::SaveData);
472 435
473 auto extsavedata_archive = Common::make_unique<FileSys::Archive_ExtSaveData>(sdmc_directory, false); 436 auto extsavedata_factory = Common::make_unique<FileSys::ArchiveFactory_ExtSaveData>(sdmc_directory, false);
474 if (extsavedata_archive->Initialize()) 437 if (extsavedata_factory->Initialize())
475 CreateArchive(std::move(extsavedata_archive), ArchiveIdCode::ExtSaveData); 438 RegisterArchiveType(std::move(extsavedata_factory), ArchiveIdCode::ExtSaveData);
476 else 439 else
477 LOG_ERROR(Service_FS, "Can't instantiate ExtSaveData archive with path %s", extsavedata_archive->GetMountPoint().c_str()); 440 LOG_ERROR(Service_FS, "Can't instantiate ExtSaveData archive with path %s", extsavedata_factory->GetMountPoint().c_str());
478 441
479 auto sharedextsavedata_archive = Common::make_unique<FileSys::Archive_ExtSaveData>(nand_directory, true); 442 auto sharedextsavedata_factory = Common::make_unique<FileSys::ArchiveFactory_ExtSaveData>(nand_directory, true);
480 if (sharedextsavedata_archive->Initialize()) 443 if (sharedextsavedata_factory->Initialize())
481 CreateArchive(std::move(sharedextsavedata_archive), ArchiveIdCode::SharedExtSaveData); 444 RegisterArchiveType(std::move(sharedextsavedata_factory), ArchiveIdCode::SharedExtSaveData);
482 else 445 else
483 LOG_ERROR(Service_FS, "Can't instantiate SharedExtSaveData archive with path %s", 446 LOG_ERROR(Service_FS, "Can't instantiate SharedExtSaveData archive with path %s",
484 sharedextsavedata_archive->GetMountPoint().c_str()); 447 sharedextsavedata_factory->GetMountPoint().c_str());
485 448
486 // Create the SaveDataCheck archive, basically a small variation of the RomFS archive 449 // Create the SaveDataCheck archive, basically a small variation of the RomFS archive
487 auto savedatacheck_archive = Common::make_unique<FileSys::Archive_SaveDataCheck>(nand_directory); 450 auto savedatacheck_factory = Common::make_unique<FileSys::ArchiveFactory_SaveDataCheck>(nand_directory);
488 CreateArchive(std::move(savedatacheck_archive), ArchiveIdCode::SaveDataCheck); 451 RegisterArchiveType(std::move(savedatacheck_factory), ArchiveIdCode::SaveDataCheck);
489} 452}
490 453
491/// Shutdown archives 454/// Shutdown archives
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h
index ab5ea4da8..c490327d0 100644
--- a/src/core/hle/service/fs/archive.h
+++ b/src/core/hle/service/fs/archive.h
@@ -8,6 +8,7 @@
8 8
9#include "core/file_sys/archive_backend.h" 9#include "core/file_sys/archive_backend.h"
10#include "core/hle/kernel/kernel.h" 10#include "core/hle/kernel/kernel.h"
11#include "core/hle/kernel/session.h"
11#include "core/hle/result.h" 12#include "core/hle/result.h"
12 13
13/// The unique system identifier hash, also known as ID0 14/// The unique system identifier hash, also known as ID0
@@ -36,6 +37,35 @@ enum class ArchiveIdCode : u32 {
36 37
37typedef u64 ArchiveHandle; 38typedef u64 ArchiveHandle;
38 39
40class File : public Kernel::Session {
41public:
42 File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path)
43 : path(path), priority(0), backend(std::move(backend)) {
44 }
45
46 std::string GetName() const override { return "Path: " + path.DebugStr(); }
47
48 FileSys::Path path; ///< Path of the file
49 u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means
50 std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface
51
52 ResultVal<bool> SyncRequest() override;
53};
54
55class Directory : public Kernel::Session {
56public:
57 Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path& path)
58 : path(path), backend(std::move(backend)) {
59 }
60
61 std::string GetName() const override { return "Directory: " + path.DebugStr(); }
62
63 FileSys::Path path; ///< Path of the directory
64 std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface
65
66 ResultVal<bool> SyncRequest() override;
67};
68
39/** 69/**
40 * Opens an archive 70 * Opens an archive
41 * @param id_code IdCode of the archive to open 71 * @param id_code IdCode of the archive to open
@@ -51,11 +81,11 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi
51ResultCode CloseArchive(ArchiveHandle handle); 81ResultCode CloseArchive(ArchiveHandle handle);
52 82
53/** 83/**
54 * Creates an Archive 84 * Registers an Archive type, instances of which can later be opened using its IdCode.
55 * @param backend File system backend interface to the archive 85 * @param backend File system backend interface to the archive
56 * @param id_code Id code used to access this type of archive 86 * @param id_code Id code used to access this type of archive
57 */ 87 */
58ResultCode CreateArchive(std::unique_ptr<FileSys::ArchiveBackend>&& backend, ArchiveIdCode id_code); 88ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory, ArchiveIdCode id_code);
59 89
60/** 90/**
61 * Open a File from an Archive 91 * Open a File from an Archive
@@ -64,7 +94,7 @@ ResultCode CreateArchive(std::unique_ptr<FileSys::ArchiveBackend>&& backend, Arc
64 * @param mode Mode under which to open the File 94 * @param mode Mode under which to open the File
65 * @return The opened File object as a Session 95 * @return The opened File object as a Session
66 */ 96 */
67ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenFileFromArchive(ArchiveHandle archive_handle, 97ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_handle,
68 const FileSys::Path& path, const FileSys::Mode mode); 98 const FileSys::Path& path, const FileSys::Mode mode);
69 99
70/** 100/**
@@ -128,14 +158,17 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons
128 * @param path Path to the Directory inside of the Archive 158 * @param path Path to the Directory inside of the Archive
129 * @return The opened Directory object as a Session 159 * @return The opened Directory object as a Session
130 */ 160 */
131ResultVal<Kernel::SharedPtr<Kernel::Session>> OpenDirectoryFromArchive(ArchiveHandle archive_handle, 161ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
132 const FileSys::Path& path); 162 const FileSys::Path& path);
133 163
134/** 164/**
135 * Creates a blank SaveData archive. 165 * Erases the contents of the physical folder that contains the archive
166 * identified by the specified id code and path
167 * @param id_code The id of the archive to format
168 * @param path The path to the archive, if relevant.
136 * @return ResultCode 0 on success or the corresponding code on error 169 * @return ResultCode 0 on success or the corresponding code on error
137 */ 170 */
138ResultCode FormatSaveData(); 171ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path = FileSys::Path());
139 172
140/** 173/**
141 * Creates a blank SharedExtSaveData archive for the specified extdata ID 174 * Creates a blank SharedExtSaveData archive for the specified extdata ID
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp
index 94a3a31c8..71ee4ff55 100644
--- a/src/core/hle/service/fs/fs_user.cpp
+++ b/src/core/hle/service/fs/fs_user.cpp
@@ -61,7 +61,7 @@ static void OpenFile(Service::Interface* self) {
61 61
62 LOG_DEBUG(Service_FS, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex, attributes); 62 LOG_DEBUG(Service_FS, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex, attributes);
63 63
64 ResultVal<SharedPtr<Session>> file_res = OpenFileFromArchive(archive_handle, file_path, mode); 64 ResultVal<SharedPtr<File>> file_res = OpenFileFromArchive(archive_handle, file_path, mode);
65 cmd_buff[1] = file_res.Code().raw; 65 cmd_buff[1] = file_res.Code().raw;
66 if (file_res.Succeeded()) { 66 if (file_res.Succeeded()) {
67 cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom(); 67 cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom();
@@ -117,7 +117,7 @@ static void OpenFileDirectly(Service::Interface* self) {
117 } 117 }
118 SCOPE_EXIT({ CloseArchive(*archive_handle); }); 118 SCOPE_EXIT({ CloseArchive(*archive_handle); });
119 119
120 ResultVal<SharedPtr<Session>> file_res = OpenFileFromArchive(*archive_handle, file_path, mode); 120 ResultVal<SharedPtr<File>> file_res = OpenFileFromArchive(*archive_handle, file_path, mode);
121 cmd_buff[1] = file_res.Code().raw; 121 cmd_buff[1] = file_res.Code().raw;
122 if (file_res.Succeeded()) { 122 if (file_res.Succeeded()) {
123 cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom(); 123 cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom();
@@ -337,7 +337,7 @@ static void OpenDirectory(Service::Interface* self) {
337 337
338 LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str()); 338 LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str());
339 339
340 ResultVal<SharedPtr<Session>> dir_res = OpenDirectoryFromArchive(archive_handle, dir_path); 340 ResultVal<SharedPtr<Directory>> dir_res = OpenDirectoryFromArchive(archive_handle, dir_path);
341 cmd_buff[1] = dir_res.Code().raw; 341 cmd_buff[1] = dir_res.Code().raw;
342 if (dir_res.Succeeded()) { 342 if (dir_res.Succeeded()) {
343 cmd_buff[3] = Kernel::g_handle_table.Create(*dir_res).MoveFrom(); 343 cmd_buff[3] = Kernel::g_handle_table.Create(*dir_res).MoveFrom();
@@ -468,7 +468,7 @@ static void FormatSaveData(Service::Interface* self) {
468 return; 468 return;
469 } 469 }
470 470
471 cmd_buff[1] = FormatSaveData().raw; 471 cmd_buff[1] = FormatArchive(ArchiveIdCode::SaveData).raw;
472} 472}
473 473
474/** 474/**
@@ -484,7 +484,7 @@ static void FormatThisUserSaveData(Service::Interface* self) {
484 484
485 // TODO(Subv): Find out what the inputs and outputs of this function are 485 // TODO(Subv): Find out what the inputs and outputs of this function are
486 486
487 cmd_buff[1] = FormatSaveData().raw; 487 cmd_buff[1] = FormatArchive(ArchiveIdCode::SaveData).raw;
488} 488}
489 489
490static void CreateExtSaveData(Service::Interface* self) { 490static void CreateExtSaveData(Service::Interface* self) {
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp
index 495c117ee..4c3ac845b 100644
--- a/src/core/hle/service/gsp_gpu.cpp
+++ b/src/core/hle/service/gsp_gpu.cpp
@@ -2,8 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5
6#include "common/log.h"
7#include "common/bit_field.h" 5#include "common/bit_field.h"
8 6
9#include "core/mem_map.h" 7#include "core/mem_map.h"
@@ -36,7 +34,7 @@ static inline u8* GetCommandBuffer(u32 thread_id) {
36} 34}
37 35
38static inline FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { 36static inline FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) {
39 _dbg_assert_msg_(Service_GSP, screen_index < 2, "Invalid screen index"); 37 DEBUG_ASSERT_MSG(screen_index < 2, "Invalid screen index");
40 38
41 // For each thread there are two FrameBufferUpdate fields 39 // For each thread there are two FrameBufferUpdate fields
42 u32 offset = 0x200 + (2 * thread_id + screen_index) * sizeof(FrameBufferUpdate); 40 u32 offset = 0x200 + (2 * thread_id + screen_index) * sizeof(FrameBufferUpdate);
@@ -186,7 +184,7 @@ static void RegisterInterruptRelayQueue(Service::Interface* self) {
186 u32 flags = cmd_buff[1]; 184 u32 flags = cmd_buff[1];
187 185
188 g_interrupt_event = Kernel::g_handle_table.Get<Kernel::Event>(cmd_buff[3]); 186 g_interrupt_event = Kernel::g_handle_table.Get<Kernel::Event>(cmd_buff[3]);
189 _assert_msg_(GSP, (g_interrupt_event != nullptr), "handle is not valid!"); 187 ASSERT_MSG((g_interrupt_event != nullptr), "handle is not valid!");
190 g_shared_memory = Kernel::SharedMemory::Create("GSPSharedMem"); 188 g_shared_memory = Kernel::SharedMemory::Create("GSPSharedMem");
191 189
192 Handle shmem_handle = Kernel::g_handle_table.Create(g_shared_memory).MoveFrom(); 190 Handle shmem_handle = Kernel::g_handle_table.Create(g_shared_memory).MoveFrom();
@@ -227,14 +225,13 @@ void SignalInterrupt(InterruptId interrupt_id) {
227 // Update framebuffer information if requested 225 // Update framebuffer information if requested
228 // TODO(yuriks): Confirm where this code should be called. It is definitely updated without 226 // TODO(yuriks): Confirm where this code should be called. It is definitely updated without
229 // executing any GSP commands, only waiting on the event. 227 // executing any GSP commands, only waiting on the event.
230 for (int screen_id = 0; screen_id < 2; ++screen_id) { 228 int screen_id = (interrupt_id == InterruptId::PDC0) ? 0 : (interrupt_id == InterruptId::PDC1) ? 1 : -1;
229 if (screen_id != -1) {
231 FrameBufferUpdate* info = GetFrameBufferInfo(thread_id, screen_id); 230 FrameBufferUpdate* info = GetFrameBufferInfo(thread_id, screen_id);
232
233 if (info->is_dirty) { 231 if (info->is_dirty) {
234 SetBufferSwap(screen_id, info->framebuffer_info[info->index]); 232 SetBufferSwap(screen_id, info->framebuffer_info[info->index]);
233 info->is_dirty = false;
235 } 234 }
236
237 info->is_dirty = false;
238 } 235 }
239 } 236 }
240 g_interrupt_event->Signal(); 237 g_interrupt_event->Signal();
diff --git a/src/core/hle/service/gsp_lcd.cpp b/src/core/hle/service/gsp_lcd.cpp
index d63fa1ee2..9e36732b4 100644
--- a/src/core/hle/service/gsp_lcd.cpp
+++ b/src/core/hle/service/gsp_lcd.cpp
@@ -2,8 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5
6#include "common/log.h"
7#include "common/bit_field.h" 5#include "common/bit_field.h"
8 6
9#include "core/hle/service/gsp_lcd.h" 7#include "core/hle/service/gsp_lcd.h"
diff --git a/src/core/hle/service/hid/hid_spvr.cpp b/src/core/hle/service/hid/hid_spvr.cpp
index 054aa8b59..8f06b224d 100644
--- a/src/core/hle/service/hid/hid_spvr.cpp
+++ b/src/core/hle/service/hid/hid_spvr.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/hid/hid_spvr.h" 6#include "core/hle/service/hid/hid_spvr.h"
8 7
diff --git a/src/core/hle/service/hid/hid_user.cpp b/src/core/hle/service/hid/hid_user.cpp
index 68edafebb..7f464705f 100644
--- a/src/core/hle/service/hid/hid_user.cpp
+++ b/src/core/hle/service/hid/hid_user.cpp
@@ -2,8 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6
7#include "core/hle/hle.h" 5#include "core/hle/hle.h"
8#include "core/hle/kernel/event.h" 6#include "core/hle/kernel/event.h"
9#include "core/hle/kernel/shared_memory.h" 7#include "core/hle/kernel/shared_memory.h"
diff --git a/src/core/hle/service/http_c.cpp b/src/core/hle/service/http_c.cpp
index 6595ca572..0a3aba0a0 100644
--- a/src/core/hle/service/http_c.cpp
+++ b/src/core/hle/service/http_c.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/http_c.h" 6#include "core/hle/service/http_c.h"
8 7
diff --git a/src/core/hle/service/ir_rst.cpp b/src/core/hle/service/ir_rst.cpp
index 31da8e160..4c26c2f03 100644
--- a/src/core/hle/service/ir_rst.cpp
+++ b/src/core/hle/service/ir_rst.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/ir_rst.h" 6#include "core/hle/service/ir_rst.h"
8 7
diff --git a/src/core/hle/service/ir_u.cpp b/src/core/hle/service/ir_u.cpp
index 7fa233048..608ed3c06 100644
--- a/src/core/hle/service/ir_u.cpp
+++ b/src/core/hle/service/ir_u.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/ir_u.h" 6#include "core/hle/service/ir_u.h"
8 7
diff --git a/src/core/hle/service/ldr_ro.cpp b/src/core/hle/service/ldr_ro.cpp
index 459717fff..c0c4a2344 100644
--- a/src/core/hle/service/ldr_ro.cpp
+++ b/src/core/hle/service/ldr_ro.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/ldr_ro.h" 6#include "core/hle/service/ldr_ro.h"
8 7
@@ -11,9 +10,69 @@
11 10
12namespace LDR_RO { 11namespace LDR_RO {
13 12
13/**
14 * LDR_RO::Initialize service function
15 * Inputs:
16 * 1 : CRS buffer pointer
17 * 2 : CRS Size
18 * 3 : Process memory address where the CRS will be mapped
19 * 4 : Value, must be zero
20 * 5 : KProcess handle
21 * Outputs:
22 * 0 : Return header
23 * 1 : Result of function, 0 on success, otherwise error code
24 */
25static void Initialize(Service::Interface* self) {
26 u32* cmd_buff = Kernel::GetCommandBuffer();
27 u32 crs_buffer_ptr = cmd_buff[1];
28 u32 crs_size = cmd_buff[2];
29 u32 address = cmd_buff[3];
30 u32 value = cmd_buff[4];
31 u32 process = cmd_buff[5];
32
33 if (value != 0) {
34 LOG_ERROR(Service_LDR, "This value should be zero, but is actually %u!", value);
35 }
36
37 // TODO(purpasmart96): Verify return header on HW
38
39 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
40
41 LOG_WARNING(Service_LDR, "(STUBBED) called");
42}
43
44/**
45 * LDR_RO::LoadCRR service function
46 * Inputs:
47 * 1 : CRS buffer pointer
48 * 2 : CRS Size
49 * 3 : Value, must be zero
50 * 4 : KProcess handle
51 * Outputs:
52 * 0 : Return header
53 * 1 : Result of function, 0 on success, otherwise error code
54 */
55static void LoadCRR(Service::Interface* self) {
56 u32* cmd_buff = Kernel::GetCommandBuffer();
57 u32 crs_buffer_ptr = cmd_buff[1];
58 u32 crs_size = cmd_buff[2];
59 u32 value = cmd_buff[3];
60 u32 process = cmd_buff[4];
61
62 if (value != 0) {
63 LOG_ERROR(Service_LDR, "This value should be zero, but is actually %u!", value);
64 }
65
66 // TODO(purpasmart96): Verify return header on HW
67
68 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
69
70 LOG_WARNING(Service_LDR, "(STUBBED) called");
71}
72
14const Interface::FunctionInfo FunctionTable[] = { 73const Interface::FunctionInfo FunctionTable[] = {
15 {0x000100C2, nullptr, "Initialize"}, 74 {0x000100C2, Initialize, "Initialize"},
16 {0x00020082, nullptr, "LoadCRR"}, 75 {0x00020082, LoadCRR, "LoadCRR"},
17 {0x00030042, nullptr, "UnloadCCR"}, 76 {0x00030042, nullptr, "UnloadCCR"},
18 {0x000402C2, nullptr, "LoadExeCRO"}, 77 {0x000402C2, nullptr, "LoadExeCRO"},
19 {0x000500C2, nullptr, "LoadCROSymbols"}, 78 {0x000500C2, nullptr, "LoadCROSymbols"},
diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp
index af967b5b6..25e70d321 100644
--- a/src/core/hle/service/mic_u.cpp
+++ b/src/core/hle/service/mic_u.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/mic_u.h" 6#include "core/hle/service/mic_u.h"
8 7
diff --git a/src/core/hle/service/news_s.cpp b/src/core/hle/service/news_s.cpp
index d7537875b..302d588c7 100644
--- a/src/core/hle/service/news_s.cpp
+++ b/src/core/hle/service/news_s.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/news_s.h" 6#include "core/hle/service/news_s.h"
8 7
diff --git a/src/core/hle/service/news_u.cpp b/src/core/hle/service/news_u.cpp
index a9e161c23..7d835aa30 100644
--- a/src/core/hle/service/news_u.cpp
+++ b/src/core/hle/service/news_u.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/news_u.h" 6#include "core/hle/service/news_u.h"
8 7
diff --git a/src/core/hle/service/nim_aoc.cpp b/src/core/hle/service/nim_aoc.cpp
index ab2ef4429..7a6aea91a 100644
--- a/src/core/hle/service/nim_aoc.cpp
+++ b/src/core/hle/service/nim_aoc.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/nim_aoc.h" 6#include "core/hle/service/nim_aoc.h"
8 7
diff --git a/src/core/hle/service/nwm_uds.cpp b/src/core/hle/service/nwm_uds.cpp
index 61fcb54ce..88be6c8d9 100644
--- a/src/core/hle/service/nwm_uds.cpp
+++ b/src/core/hle/service/nwm_uds.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/nwm_uds.h" 6#include "core/hle/service/nwm_uds.h"
8 7
diff --git a/src/core/hle/service/pm_app.cpp b/src/core/hle/service/pm_app.cpp
index d61eaf80f..7420a62f4 100644
--- a/src/core/hle/service/pm_app.cpp
+++ b/src/core/hle/service/pm_app.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/pm_app.h" 6#include "core/hle/service/pm_app.h"
8 7
diff --git a/src/core/hle/service/ptm_play.cpp b/src/core/hle/service/ptm_play.cpp
index b357057fd..f21d9088e 100644
--- a/src/core/hle/service/ptm_play.cpp
+++ b/src/core/hle/service/ptm_play.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/ptm_play.h" 6#include "core/hle/service/ptm_play.h"
8 7
diff --git a/src/core/hle/service/ptm_sysm.cpp b/src/core/hle/service/ptm_sysm.cpp
index b6f688de3..96ef2dce0 100644
--- a/src/core/hle/service/ptm_sysm.cpp
+++ b/src/core/hle/service/ptm_sysm.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "common/make_unique.h" 5#include "common/make_unique.h"
7#include "core/file_sys/archive_extsavedata.h" 6#include "core/file_sys/archive_extsavedata.h"
8#include "core/hle/hle.h" 7#include "core/hle/hle.h"
diff --git a/src/core/hle/service/ptm_u.cpp b/src/core/hle/service/ptm_u.cpp
index 7b465a348..7121d837c 100644
--- a/src/core/hle/service/ptm_u.cpp
+++ b/src/core/hle/service/ptm_u.cpp
@@ -2,10 +2,10 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "common/make_unique.h" 5#include "common/make_unique.h"
7#include "core/file_sys/archive_extsavedata.h" 6
8#include "core/hle/hle.h" 7#include "core/hle/hle.h"
8#include "core/hle/service/fs/archive.h"
9#include "core/hle/service/ptm_u.h" 9#include "core/hle/service/ptm_u.h"
10 10
11//////////////////////////////////////////////////////////////////////////////////////////////////// 11////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -28,7 +28,6 @@ struct GameCoin {
28 u8 day; 28 u8 day;
29}; 29};
30static const GameCoin default_game_coin = { 0x4F00, 42, 0, 0, 0, 2014, 12, 29 }; 30static const GameCoin default_game_coin = { 0x4F00, 42, 0, 0, 0, 2014, 12, 29 };
31static std::unique_ptr<FileSys::Archive_ExtSaveData> ptm_shared_extsavedata;
32static const std::vector<u8> ptm_shared_extdata_id = {0, 0, 0, 0, 0x0B, 0, 0, 0xF0, 0, 0, 0, 0}; 31static const std::vector<u8> ptm_shared_extdata_id = {0, 0, 0, 0, 0x0B, 0, 0, 0xF0, 0, 0, 0, 0};
33 32
34/// Charge levels used by PTM functions 33/// Charge levels used by PTM functions
@@ -138,31 +137,28 @@ const Interface::FunctionInfo FunctionTable[] = {
138 137
139Interface::Interface() { 138Interface::Interface() {
140 Register(FunctionTable); 139 Register(FunctionTable);
141 // Create the SharedExtSaveData archive 0xF000000B and the gamecoin.dat file 140
142 // TODO(Subv): In the future we should use the FS service to query this archive 141 // Open the SharedExtSaveData archive 0xF000000B and the gamecoin.dat file
143 std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
144 ptm_shared_extsavedata = Common::make_unique<FileSys::Archive_ExtSaveData>(nand_directory, true);
145 if (!ptm_shared_extsavedata->Initialize()) {
146 LOG_CRITICAL(Service_PTM, "Could not initialize SharedExtSaveData archive for the PTM:U service");
147 return;
148 }
149 FileSys::Path archive_path(ptm_shared_extdata_id); 142 FileSys::Path archive_path(ptm_shared_extdata_id);
150 ResultCode result = ptm_shared_extsavedata->Open(archive_path); 143 auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
151 // If the archive didn't exist, create the files inside 144 // If the archive didn't exist, create the files inside
152 if (result.description == ErrorDescription::FS_NotFormatted) { 145 if (archive_result.Code().description == ErrorDescription::FS_NotFormatted) {
153 // Format the archive to clear the directories 146 // Format the archive to create the directories
154 ptm_shared_extsavedata->Format(archive_path); 147 Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
155 // Open it again to get a valid archive now that the folder exists 148 // Open it again to get a valid archive now that the folder exists
156 ptm_shared_extsavedata->Open(archive_path); 149 archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
150 ASSERT_MSG(archive_result.Succeeded(), "Could not open the PTM SharedExtSaveData archive!");
151
157 FileSys::Path gamecoin_path("gamecoin.dat"); 152 FileSys::Path gamecoin_path("gamecoin.dat");
158 FileSys::Mode open_mode = {}; 153 FileSys::Mode open_mode = {};
159 open_mode.write_flag = 1; 154 open_mode.write_flag = 1;
160 open_mode.create_flag = 1; 155 open_mode.create_flag = 1;
161 // Open the file and write the default gamecoin information 156 // Open the file and write the default gamecoin information
162 auto gamecoin = ptm_shared_extsavedata->OpenFile(gamecoin_path, open_mode); 157 auto gamecoin_result = Service::FS::OpenFileFromArchive(*archive_result, gamecoin_path, open_mode);
163 if (gamecoin != nullptr) { 158 if (gamecoin_result.Succeeded()) {
164 gamecoin->Write(0, sizeof(GameCoin), 1, reinterpret_cast<const u8*>(&default_game_coin)); 159 auto gamecoin = gamecoin_result.MoveFrom();
165 gamecoin->Close(); 160 gamecoin->backend->Write(0, sizeof(GameCoin), 1, reinterpret_cast<const u8*>(&default_game_coin));
161 gamecoin->backend->Close();
166 } 162 }
167 } 163 }
168} 164}
diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp
index 414c53c54..231ead185 100644
--- a/src/core/hle/service/soc_u.cpp
+++ b/src/core/hle/service/soc_u.cpp
@@ -29,7 +29,6 @@
29#include <poll.h> 29#include <poll.h>
30#endif 30#endif
31 31
32#include "common/log.h"
33#include "common/scope_exit.h" 32#include "common/scope_exit.h"
34#include "core/hle/hle.h" 33#include "core/hle/hle.h"
35#include "core/hle/service/soc_u.h" 34#include "core/hle/service/soc_u.h"
@@ -259,7 +258,7 @@ union CTRSockAddr {
259 break; 258 break;
260 } 259 }
261 default: 260 default:
262 _dbg_assert_msg_(Service_SOC, false, "Unhandled address family (sa_family) in CTRSockAddr::ToPlatform"); 261 ASSERT_MSG(false, "Unhandled address family (sa_family) in CTRSockAddr::ToPlatform");
263 break; 262 break;
264 } 263 }
265 return result; 264 return result;
@@ -280,7 +279,7 @@ union CTRSockAddr {
280 break; 279 break;
281 } 280 }
282 default: 281 default:
283 _dbg_assert_msg_(Service_SOC, false, "Unhandled address family (sa_family) in CTRSockAddr::ToPlatform"); 282 ASSERT_MSG(false, "Unhandled address family (sa_family) in CTRSockAddr::ToPlatform");
284 break; 283 break;
285 } 284 }
286 return result; 285 return result;
diff --git a/src/core/hle/service/ssl_c.cpp b/src/core/hle/service/ssl_c.cpp
index 3f49c1c97..e634276fc 100644
--- a/src/core/hle/service/ssl_c.cpp
+++ b/src/core/hle/service/ssl_c.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/service/ssl_c.h" 6#include "core/hle/service/ssl_c.h"
8 7
diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cpp
index fc76d2721..a58e04d6d 100644
--- a/src/core/hle/service/y2r_u.cpp
+++ b/src/core/hle/service/y2r_u.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/log.h"
6#include "core/hle/hle.h" 5#include "core/hle/hle.h"
7#include "core/hle/kernel/event.h" 6#include "core/hle/kernel/event.h"
8#include "core/hle/service/y2r_u.h" 7#include "core/hle/service/y2r_u.h"
diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp
index 6033a53b4..f5f2a6858 100644
--- a/src/core/hle/shared_page.cpp
+++ b/src/core/hle/shared_page.cpp
@@ -3,7 +3,6 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common_types.h" 5#include "common/common_types.h"
6#include "common/log.h"
7 6
8#include "core/core.h" 7#include "core/core.h"
9#include "core/mem_map.h" 8#include "core/mem_map.h"
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 96da29923..17385f9b2 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -175,7 +175,7 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
175 175
176 // NOTE: on real hardware, there is no nullptr check for 'out' (tested with firmware 4.4). If 176 // NOTE: on real hardware, there is no nullptr check for 'out' (tested with firmware 4.4). If
177 // this happens, the running application will crash. 177 // this happens, the running application will crash.
178 _assert_msg_(Kernel, out != nullptr, "invalid output pointer specified!"); 178 ASSERT_MSG(out != nullptr, "invalid output pointer specified!");
179 179
180 // Check if 'handle_count' is invalid 180 // Check if 'handle_count' is invalid
181 if (handle_count < 0) 181 if (handle_count < 0)
diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp
index 503200629..a63ba6eeb 100644
--- a/src/core/hw/hw.cpp
+++ b/src/core/hw/hw.cpp
@@ -88,4 +88,4 @@ void Shutdown() {
88 LOG_DEBUG(HW, "shutdown OK"); 88 LOG_DEBUG(HW, "shutdown OK");
89} 89}
90 90
91} \ No newline at end of file 91}
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index 52730a7b4..94dcc50f9 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -127,7 +127,7 @@ ResultStatus LoadFile(const std::string& filename) {
127 // Load application and RomFS 127 // Load application and RomFS
128 if (ResultStatus::Success == app_loader.Load()) { 128 if (ResultStatus::Success == app_loader.Load()) {
129 Kernel::g_program_id = app_loader.GetProgramId(); 129 Kernel::g_program_id = app_loader.GetProgramId();
130 Service::FS::CreateArchive(Common::make_unique<FileSys::Archive_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS); 130 Service::FS::RegisterArchiveType(Common::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS);
131 return ResultStatus::Success; 131 return ResultStatus::Success;
132 } 132 }
133 break; 133 break;
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp
index 0e3b81b28..4f93c0e64 100644
--- a/src/core/mem_map_funcs.cpp
+++ b/src/core/mem_map_funcs.cpp
@@ -136,9 +136,9 @@ inline void Write(const VAddr vaddr, const T data) {
136 *(T*)&g_dsp_mem[vaddr - DSP_MEMORY_VADDR] = data; 136 *(T*)&g_dsp_mem[vaddr - DSP_MEMORY_VADDR] = data;
137 137
138 //} else if ((vaddr & 0xFFFF0000) == 0x1FF80000) { 138 //} else if ((vaddr & 0xFFFF0000) == 0x1FF80000) {
139 // _assert_msg_(MEMMAP, false, "umimplemented write to Configuration Memory"); 139 // ASSERT_MSG(MEMMAP, false, "umimplemented write to Configuration Memory");
140 //} else if ((vaddr & 0xFFFFF000) == 0x1FF81000) { 140 //} else if ((vaddr & 0xFFFFF000) == 0x1FF81000) {
141 // _assert_msg_(MEMMAP, false, "umimplemented write to shared page"); 141 // ASSERT_MSG(MEMMAP, false, "umimplemented write to shared page");
142 142
143 // Error out... 143 // Error out...
144 } else { 144 } else {
diff --git a/src/core/settings.h b/src/core/settings.h
index cedba3a98..e62dd4358 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -35,6 +35,9 @@ struct Values {
35 // Data Storage 35 // Data Storage
36 bool use_virtual_sd; 36 bool use_virtual_sd;
37 37
38 // System Region
39 int region_value;
40
38 std::string log_filter; 41 std::string log_filter;
39} extern values; 42} extern values;
40 43
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index 12f0009bd..8c4ec1044 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -16,7 +16,7 @@
16 16
17#include <nihstro/shader_binary.h> 17#include <nihstro/shader_binary.h>
18 18
19#include "common/log.h" 19#include "common/assert.h"
20#include "common/file_util.h" 20#include "common/file_util.h"
21#include "common/math_util.h" 21#include "common/math_util.h"
22 22
@@ -197,7 +197,7 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data
197 it->component_mask = it->component_mask | component_mask; 197 it->component_mask = it->component_mask | component_mask;
198 } 198 }
199 } catch (const std::out_of_range& ) { 199 } catch (const std::out_of_range& ) {
200 _dbg_assert_msg_(HW_GPU, 0, "Unknown output attribute mapping"); 200 DEBUG_ASSERT_MSG(false, "Unknown output attribute mapping");
201 LOG_ERROR(HW_GPU, "Unknown output attribute mapping: %03x, %03x, %03x, %03x", 201 LOG_ERROR(HW_GPU, "Unknown output attribute mapping: %03x, %03x, %03x, %03x",
202 (int)output_attributes[i].map_x.Value(), 202 (int)output_attributes[i].map_x.Value(),
203 (int)output_attributes[i].map_y.Value(), 203 (int)output_attributes[i].map_y.Value(),
@@ -571,7 +571,7 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture
571 571
572 default: 572 default:
573 LOG_ERROR(HW_GPU, "Unknown texture format: %x", (u32)info.format); 573 LOG_ERROR(HW_GPU, "Unknown texture format: %x", (u32)info.format);
574 _dbg_assert_(HW_GPU, 0); 574 DEBUG_ASSERT(false);
575 return {}; 575 return {};
576 } 576 }
577} 577}
diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h
index a51d49c92..c2c898992 100644
--- a/src/video_core/gpu_debugger.h
+++ b/src/video_core/gpu_debugger.h
@@ -8,8 +8,6 @@
8#include <functional> 8#include <functional>
9#include <vector> 9#include <vector>
10 10
11#include "common/log.h"
12
13#include "core/hle/service/gsp_gpu.h" 11#include "core/hle/service/gsp_gpu.h"
14 12
15#include "command_processor.h" 13#include "command_processor.h"
diff --git a/src/video_core/primitive_assembly.cpp b/src/video_core/primitive_assembly.cpp
index 242a07e26..1776a1925 100644
--- a/src/video_core/primitive_assembly.cpp
+++ b/src/video_core/primitive_assembly.cpp
@@ -6,6 +6,7 @@
6#include "primitive_assembly.h" 6#include "primitive_assembly.h"
7#include "vertex_shader.h" 7#include "vertex_shader.h"
8 8
9#include "common/logging/log.h"
9#include "video_core/debug_utils/debug_utils.h" 10#include "video_core/debug_utils/debug_utils.h"
10 11
11namespace Pica { 12namespace Pica {
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index 06fd8d140..617c767e7 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -216,7 +216,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
216 if (!texture.enabled) 216 if (!texture.enabled)
217 continue; 217 continue;
218 218
219 _dbg_assert_(HW_GPU, 0 != texture.config.address); 219 DEBUG_ASSERT(0 != texture.config.address);
220 220
221 int s = (int)(uv[i].u() * float24::FromFloat32(static_cast<float>(texture.config.width))).ToFloat32(); 221 int s = (int)(uv[i].u() * float24::FromFloat32(static_cast<float>(texture.config.width))).ToFloat32();
222 int t = (int)(uv[i].v() * float24::FromFloat32(static_cast<float>(texture.config.height))).ToFloat32(); 222 int t = (int)(uv[i].v() * float24::FromFloat32(static_cast<float>(texture.config.height))).ToFloat32();
@@ -232,7 +232,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
232 232
233 default: 233 default:
234 LOG_ERROR(HW_GPU, "Unknown texture coordinate wrapping mode %x\n", (int)mode); 234 LOG_ERROR(HW_GPU, "Unknown texture coordinate wrapping mode %x\n", (int)mode);
235 _dbg_assert_(HW_GPU, 0); 235 UNIMPLEMENTED();
236 return 0; 236 return 0;
237 } 237 }
238 }; 238 };
@@ -282,7 +282,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
282 282
283 default: 283 default:
284 LOG_ERROR(HW_GPU, "Unknown color combiner source %d\n", (int)source); 284 LOG_ERROR(HW_GPU, "Unknown color combiner source %d\n", (int)source);
285 _dbg_assert_(HW_GPU, 0); 285 UNIMPLEMENTED();
286 return {}; 286 return {};
287 } 287 }
288 }; 288 };
@@ -380,7 +380,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
380 380
381 default: 381 default:
382 LOG_ERROR(HW_GPU, "Unknown color combiner operation %d\n", (int)op); 382 LOG_ERROR(HW_GPU, "Unknown color combiner operation %d\n", (int)op);
383 _dbg_assert_(HW_GPU, 0); 383 UNIMPLEMENTED();
384 return {}; 384 return {};
385 } 385 }
386 }; 386 };
@@ -404,7 +404,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
404 404
405 default: 405 default:
406 LOG_ERROR(HW_GPU, "Unknown alpha combiner operation %d\n", (int)op); 406 LOG_ERROR(HW_GPU, "Unknown alpha combiner operation %d\n", (int)op);
407 _dbg_assert_(HW_GPU, 0); 407 UNIMPLEMENTED();
408 return 0; 408 return 0;
409 } 409 }
410 }; 410 };
diff --git a/src/video_core/renderer_opengl/gl_shader_util.cpp b/src/video_core/renderer_opengl/gl_shader_util.cpp
index e982e3746..42d0e597c 100644
--- a/src/video_core/renderer_opengl/gl_shader_util.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_util.cpp
@@ -3,7 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "gl_shader_util.h" 5#include "gl_shader_util.h"
6#include "common/log.h" 6#include "common/logging/log.h"
7 7
8#include <vector> 8#include <vector>
9#include <algorithm> 9#include <algorithm>
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index aa47bd616..735c0cf45 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -99,15 +99,15 @@ void RendererOpenGL::LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig&
99 const u8* framebuffer_data = Memory::GetPointer(framebuffer_vaddr); 99 const u8* framebuffer_data = Memory::GetPointer(framebuffer_vaddr);
100 100
101 // TODO: Handle other pixel formats 101 // TODO: Handle other pixel formats
102 _dbg_assert_msg_(Render_OpenGL, framebuffer.color_format == GPU::Regs::PixelFormat::RGB8, 102 ASSERT_MSG(framebuffer.color_format == GPU::Regs::PixelFormat::RGB8,
103 "Unsupported 3DS pixel format."); 103 "Unsupported 3DS pixel format.");
104 104
105 size_t pixel_stride = framebuffer.stride / 3; 105 size_t pixel_stride = framebuffer.stride / 3;
106 // OpenGL only supports specifying a stride in units of pixels, not bytes, unfortunately 106 // OpenGL only supports specifying a stride in units of pixels, not bytes, unfortunately
107 _dbg_assert_(Render_OpenGL, pixel_stride * 3 == framebuffer.stride); 107 ASSERT(pixel_stride * 3 == framebuffer.stride);
108 // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default 108 // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default
109 // only allows rows to have a memory alignement of 4. 109 // only allows rows to have a memory alignement of 4.
110 _dbg_assert_(Render_OpenGL, pixel_stride % 4 == 0); 110 ASSERT(pixel_stride % 4 == 0);
111 111
112 glBindTexture(GL_TEXTURE_2D, texture.handle); 112 glBindTexture(GL_TEXTURE_2D, texture.handle);
113 glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint)pixel_stride); 113 glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint)pixel_stride);
diff --git a/src/video_core/vertex_shader.cpp b/src/video_core/vertex_shader.cpp
index 48977380e..0bd52231b 100644
--- a/src/video_core/vertex_shader.cpp
+++ b/src/video_core/vertex_shader.cpp
@@ -146,13 +146,10 @@ static void ProcessShaderCode(VertexShaderState& state) {
146 case Instruction::OpCodeType::Arithmetic: 146 case Instruction::OpCodeType::Arithmetic:
147 { 147 {
148 bool is_inverted = 0 != (instr.opcode.GetInfo().subtype & Instruction::OpCodeInfo::SrcInversed); 148 bool is_inverted = 0 != (instr.opcode.GetInfo().subtype & Instruction::OpCodeInfo::SrcInversed);
149 if (is_inverted) { 149 // TODO: We don't really support this properly: For instance, the address register
150 // TODO: We don't really support this properly: For instance, the address register 150 // offset needs to be applied to SRC2 instead, etc.
151 // offset needs to be applied to SRC2 instead, etc. 151 // For now, we just abort in this situation.
152 // For now, we just abort in this situation. 152 ASSERT_MSG(!is_inverted, "Bad condition...");
153 LOG_CRITICAL(HW_GPU, "Bad condition...");
154 exit(0);
155 }
156 153
157 const int address_offset = (instr.common.address_register_index == 0) 154 const int address_offset = (instr.common.address_register_index == 0)
158 ? 0 : state.address_registers[instr.common.address_register_index - 1]; 155 ? 0 : state.address_registers[instr.common.address_register_index - 1];
@@ -342,7 +339,7 @@ static void ProcessShaderCode(VertexShaderState& state) {
342 default: 339 default:
343 LOG_ERROR(HW_GPU, "Unhandled arithmetic instruction: 0x%02x (%s): 0x%08x", 340 LOG_ERROR(HW_GPU, "Unhandled arithmetic instruction: 0x%02x (%s): 0x%08x",
344 (int)instr.opcode.Value(), instr.opcode.GetInfo().name, instr.hex); 341 (int)instr.opcode.Value(), instr.opcode.GetInfo().name, instr.hex);
345 _dbg_assert_(HW_GPU, 0); 342 DEBUG_ASSERT(false);
346 break; 343 break;
347 } 344 }
348 345
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp
index c9707e5f1..0a236595c 100644
--- a/src/video_core/video_core.cpp
+++ b/src/video_core/video_core.cpp
@@ -4,7 +4,6 @@
4 4
5#include "common/common.h" 5#include "common/common.h"
6#include "common/emu_window.h" 6#include "common/emu_window.h"
7#include "common/log.h"
8 7
9#include "core/core.h" 8#include "core/core.h"
10 9