summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2014-12-12 23:20:01 -0500
committerGravatar bunnei2014-12-12 23:20:01 -0500
commitaf1cd769e7b407af71496e788e218add31f8b2b0 (patch)
tree1e3fd71256c04a15970b09abd3f7280f8b1ff678
parentMerge pull request #267 from bunnei/apt-shared-font (diff)
parentRemove old logging system (diff)
downloadyuzu-af1cd769e7b407af71496e788e218add31f8b2b0.tar.gz
yuzu-af1cd769e7b407af71496e788e218add31f8b2b0.tar.xz
yuzu-af1cd769e7b407af71496e788e218add31f8b2b0.zip
Merge pull request #258 from yuriks/log-ng
New logging system
-rw-r--r--Doxyfile2
-rw-r--r--src/citra/citra.cpp23
-rw-r--r--src/citra/config.cpp8
-rw-r--r--src/citra/default_ini.h2
-rw-r--r--src/citra/emu_window/emu_window_glfw.cpp16
-rw-r--r--src/citra_qt/bootmanager.cpp8
-rw-r--r--src/citra_qt/config.cpp4
-rw-r--r--src/citra_qt/debugger/graphics_breakpoints.cpp2
-rw-r--r--src/citra_qt/main.cpp33
-rw-r--r--src/citra_qt/util/spinbox.cpp2
-rw-r--r--src/common/CMakeLists.txt13
-rw-r--r--src/common/break_points.cpp2
-rw-r--r--src/common/chunk_file.h35
-rw-r--r--src/common/common_funcs.h3
-rw-r--r--src/common/common_types.h2
-rw-r--r--src/common/concurrent_ring_buffer.h164
-rw-r--r--src/common/console_listener.cpp319
-rw-r--r--src/common/console_listener.h38
-rw-r--r--src/common/file_util.cpp84
-rw-r--r--src/common/log.h125
-rw-r--r--src/common/log_manager.cpp198
-rw-r--r--src/common/log_manager.h166
-rw-r--r--src/common/logging/backend.cpp151
-rw-r--r--src/common/logging/backend.h134
-rw-r--r--src/common/logging/filter.cpp132
-rw-r--r--src/common/logging/filter.h63
-rw-r--r--src/common/logging/log.h115
-rw-r--r--src/common/logging/text_formatter.cpp126
-rw-r--r--src/common/logging/text_formatter.h39
-rw-r--r--src/common/mem_arena.cpp14
-rw-r--r--src/common/memory_util.cpp2
-rw-r--r--src/common/msg_handler.cpp2
-rw-r--r--src/common/scope_exit.h37
-rw-r--r--src/common/string_util.cpp10
-rw-r--r--src/common/string_util.h15
-rw-r--r--src/common/thread.h1
-rw-r--r--src/core/arm/dyncom/arm_dyncom_interpreter.cpp200
-rw-r--r--src/core/arm/interpreter/armemu.cpp4
-rw-r--r--src/core/arm/interpreter/armsupp.cpp8
-rw-r--r--src/core/arm/interpreter/thumbemu.cpp2
-rw-r--r--src/core/arm/skyeye_common/armemu.h4
-rw-r--r--src/core/core.cpp4
-rw-r--r--src/core/core_timing.cpp8
-rw-r--r--src/core/file_sys/archive.h12
-rw-r--r--src/core/file_sys/archive_romfs.cpp18
-rw-r--r--src/core/file_sys/archive_sdmc.cpp18
-rw-r--r--src/core/file_sys/directory_sdmc.cpp2
-rw-r--r--src/core/file_sys/file_sdmc.cpp2
-rw-r--r--src/core/hle/config_mem.cpp3
-rw-r--r--src/core/hle/hle.cpp12
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp8
-rw-r--r--src/core/hle/kernel/archive.cpp50
-rw-r--r--src/core/hle/kernel/kernel.cpp8
-rw-r--r--src/core/hle/kernel/kernel.h17
-rw-r--r--src/core/hle/kernel/shared_memory.cpp10
-rw-r--r--src/core/hle/kernel/thread.cpp24
-rw-r--r--src/core/hle/service/ac_u.cpp2
-rw-r--r--src/core/hle/service/apt_u.cpp20
-rw-r--r--src/core/hle/service/cfg_u.cpp6
-rw-r--r--src/core/hle/service/dsp_dsp.cpp14
-rw-r--r--src/core/hle/service/fs_user.cpp54
-rw-r--r--src/core/hle/service/gsp_gpu.cpp18
-rw-r--r--src/core/hle/service/hid_user.cpp2
-rw-r--r--src/core/hle/service/ptm_u.cpp8
-rw-r--r--src/core/hle/service/service.cpp4
-rw-r--r--src/core/hle/service/service.h8
-rw-r--r--src/core/hle/service/srv.cpp8
-rw-r--r--src/core/hle/svc.cpp54
-rw-r--r--src/core/hw/gpu.cpp16
-rw-r--r--src/core/hw/hw.cpp8
-rw-r--r--src/core/loader/3dsx.cpp14
-rw-r--r--src/core/loader/elf.cpp16
-rw-r--r--src/core/loader/loader.cpp6
-rw-r--r--src/core/loader/ncch.cpp34
-rw-r--r--src/core/mem_map.cpp4
-rw-r--r--src/core/mem_map_funcs.cpp12
-rw-r--r--src/core/settings.h4
-rw-r--r--src/video_core/clipper.cpp2
-rw-r--r--src/video_core/command_processor.cpp6
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp18
-rw-r--r--src/video_core/gpu_debugger.h2
-rw-r--r--src/video_core/primitive_assembly.cpp2
-rw-r--r--src/video_core/rasterizer.cpp12
-rw-r--r--src/video_core/renderer_opengl/gl_shader_util.cpp24
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp12
-rw-r--r--src/video_core/vertex_shader.cpp6
-rw-r--r--src/video_core/video_core.cpp4
87 files changed, 1529 insertions, 1375 deletions
diff --git a/Doxyfile b/Doxyfile
index 981121d92..5c2e09246 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -419,7 +419,7 @@ LOOKUP_CACHE_SIZE = 0
419# normally produced when WARNINGS is set to YES. 419# normally produced when WARNINGS is set to YES.
420# The default value is: NO. 420# The default value is: NO.
421 421
422EXTRACT_ALL = NO 422EXTRACT_ALL = YES
423 423
424# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will 424# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will
425# be included in the documentation. 425# be included in the documentation.
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp
index f2aeb510e..d6e8a4ec7 100644
--- a/src/citra/citra.cpp
+++ b/src/citra/citra.cpp
@@ -2,8 +2,13 @@
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <thread>
6
5#include "common/common.h" 7#include "common/common.h"
6#include "common/log_manager.h" 8#include "common/logging/text_formatter.h"
9#include "common/logging/backend.h"
10#include "common/logging/filter.h"
11#include "common/scope_exit.h"
7 12
8#include "core/settings.h" 13#include "core/settings.h"
9#include "core/system.h" 14#include "core/system.h"
@@ -15,17 +20,21 @@
15 20
16/// Application entry point 21/// Application entry point
17int __cdecl main(int argc, char **argv) { 22int __cdecl main(int argc, char **argv) {
18 LogManager::Init(); 23 std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger();
24 Log::Filter log_filter(Log::Level::Debug);
25 std::thread logging_thread(Log::TextLoggingLoop, logger, &log_filter);
26 SCOPE_EXIT({
27 logger->Close();
28 logging_thread.join();
29 });
19 30
20 if (argc < 2) { 31 if (argc < 2) {
21 ERROR_LOG(BOOT, "Failed to load ROM: No ROM specified"); 32 LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
22 return -1; 33 return -1;
23 } 34 }
24 35
25 Config config; 36 Config config;
26 37 log_filter.ParseFilterString(Settings::values.log_filter);
27 if (!Settings::values.enable_log)
28 LogManager::Shutdown();
29 38
30 std::string boot_filename = argv[1]; 39 std::string boot_filename = argv[1];
31 EmuWindow_GLFW* emu_window = new EmuWindow_GLFW; 40 EmuWindow_GLFW* emu_window = new EmuWindow_GLFW;
@@ -34,7 +43,7 @@ int __cdecl main(int argc, char **argv) {
34 43
35 Loader::ResultStatus load_result = Loader::LoadFile(boot_filename); 44 Loader::ResultStatus load_result = Loader::LoadFile(boot_filename);
36 if (Loader::ResultStatus::Success != load_result) { 45 if (Loader::ResultStatus::Success != load_result) {
37 ERROR_LOG(BOOT, "Failed to load ROM (Error %i)!", load_result); 46 LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result);
38 return -1; 47 return -1;
39 } 48 }
40 49
diff --git a/src/citra/config.cpp b/src/citra/config.cpp
index 1f8f5922b..92764809e 100644
--- a/src/citra/config.cpp
+++ b/src/citra/config.cpp
@@ -22,17 +22,17 @@ Config::Config() {
22bool Config::LoadINI(INIReader* config, const char* location, const std::string& default_contents, bool retry) { 22bool Config::LoadINI(INIReader* config, const char* location, const std::string& default_contents, bool retry) {
23 if (config->ParseError() < 0) { 23 if (config->ParseError() < 0) {
24 if (retry) { 24 if (retry) {
25 ERROR_LOG(CONFIG, "Failed to load %s. Creating file from defaults...", location); 25 LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location);
26 FileUtil::CreateFullPath(location); 26 FileUtil::CreateFullPath(location);
27 FileUtil::WriteStringToFile(true, default_contents, location); 27 FileUtil::WriteStringToFile(true, default_contents, location);
28 *config = INIReader(location); // Reopen file 28 *config = INIReader(location); // Reopen file
29 29
30 return LoadINI(config, location, default_contents, false); 30 return LoadINI(config, location, default_contents, false);
31 } 31 }
32 ERROR_LOG(CONFIG, "Failed."); 32 LOG_ERROR(Config, "Failed.");
33 return false; 33 return false;
34 } 34 }
35 INFO_LOG(CONFIG, "Successfully loaded %s", location); 35 LOG_INFO(Config, "Successfully loaded %s", location);
36 return true; 36 return true;
37} 37}
38 38
@@ -64,7 +64,7 @@ void Config::ReadValues() {
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 // Miscellaneous 66 // Miscellaneous
67 Settings::values.enable_log = glfw_config->GetBoolean("Miscellaneous", "enable_log", true); 67 Settings::values.log_filter = glfw_config->Get("Miscellaneous", "log_filter", "*:Info");
68} 68}
69 69
70void Config::Reload() { 70void Config::Reload() {
diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h
index f1f626eed..7cf543e07 100644
--- a/src/citra/default_ini.h
+++ b/src/citra/default_ini.h
@@ -34,7 +34,7 @@ gpu_refresh_rate = ## 60 (default)
34use_virtual_sd = 34use_virtual_sd =
35 35
36[Miscellaneous] 36[Miscellaneous]
37enable_log = 37log_filter = *:Info ## Examples: *:Debug Kernel.SVC:Trace Service.*:Critical
38)"; 38)";
39 39
40} 40}
diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp
index 982619126..929e09f43 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_(GUI, width > 0); 39 _dbg_assert_(Frontend, width > 0);
40 _dbg_assert_(GUI, height > 0); 40 _dbg_assert_(Frontend, 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_(GUI, width > 0); 46 _dbg_assert_(Frontend, width > 0);
47 _dbg_assert_(GUI, height > 0); 47 _dbg_assert_(Frontend, 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.
@@ -59,12 +59,12 @@ EmuWindow_GLFW::EmuWindow_GLFW() {
59 ReloadSetKeymaps(); 59 ReloadSetKeymaps();
60 60
61 glfwSetErrorCallback([](int error, const char *desc){ 61 glfwSetErrorCallback([](int error, const char *desc){
62 ERROR_LOG(GUI, "GLFW 0x%08x: %s", error, desc); 62 LOG_ERROR(Frontend, "GLFW 0x%08x: %s", error, desc);
63 }); 63 });
64 64
65 // Initialize the window 65 // Initialize the window
66 if(glfwInit() != GL_TRUE) { 66 if(glfwInit() != GL_TRUE) {
67 ERROR_LOG(GUI, "Failed to initialize GLFW! Exiting..."); 67 LOG_CRITICAL(Frontend, "Failed to initialize GLFW! Exiting...");
68 exit(1); 68 exit(1);
69 } 69 }
70 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); 70 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
@@ -79,7 +79,7 @@ EmuWindow_GLFW::EmuWindow_GLFW() {
79 window_title.c_str(), nullptr, nullptr); 79 window_title.c_str(), nullptr, nullptr);
80 80
81 if (m_render_window == nullptr) { 81 if (m_render_window == nullptr) {
82 ERROR_LOG(GUI, "Failed to create GLFW window! Exiting..."); 82 LOG_CRITICAL(Frontend, "Failed to create GLFW window! Exiting...");
83 exit(1); 83 exit(1);
84 } 84 }
85 85
@@ -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_(GUI, (int)minimal_size.first > 0 && (int)minimal_size.second > 0); 152 _dbg_assert_(Frontend, (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/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index b53206be6..6d08d6afc 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -62,7 +62,7 @@ void EmuThread::Stop()
62{ 62{
63 if (!isRunning()) 63 if (!isRunning())
64 { 64 {
65 INFO_LOG(MASTER_LOG, "EmuThread::Stop called while emu thread wasn't running, returning..."); 65 LOG_WARNING(Frontend, "EmuThread::Stop called while emu thread wasn't running, returning...");
66 return; 66 return;
67 } 67 }
68 stop_run = true; 68 stop_run = true;
@@ -76,7 +76,7 @@ void EmuThread::Stop()
76 wait(1000); 76 wait(1000);
77 if (isRunning()) 77 if (isRunning())
78 { 78 {
79 WARN_LOG(MASTER_LOG, "EmuThread still running, terminating..."); 79 LOG_WARNING(Frontend, "EmuThread still running, terminating...");
80 quit(); 80 quit();
81 81
82 // TODO: Waiting 50 seconds can be necessary if the logging subsystem has a lot of spam 82 // TODO: Waiting 50 seconds can be necessary if the logging subsystem has a lot of spam
@@ -84,11 +84,11 @@ void EmuThread::Stop()
84 wait(50000); 84 wait(50000);
85 if (isRunning()) 85 if (isRunning())
86 { 86 {
87 WARN_LOG(MASTER_LOG, "EmuThread STILL running, something is wrong here..."); 87 LOG_CRITICAL(Frontend, "EmuThread STILL running, something is wrong here...");
88 terminate(); 88 terminate();
89 } 89 }
90 } 90 }
91 INFO_LOG(MASTER_LOG, "EmuThread stopped"); 91 LOG_INFO(Frontend, "EmuThread stopped");
92} 92}
93 93
94 94
diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp
index 3209e5900..0ae6b8b2d 100644
--- a/src/citra_qt/config.cpp
+++ b/src/citra_qt/config.cpp
@@ -52,7 +52,7 @@ void Config::ReadValues() {
52 qt_config->endGroup(); 52 qt_config->endGroup();
53 53
54 qt_config->beginGroup("Miscellaneous"); 54 qt_config->beginGroup("Miscellaneous");
55 Settings::values.enable_log = qt_config->value("enable_log", true).toBool(); 55 Settings::values.log_filter = qt_config->value("log_filter", "*:Info").toString().toStdString();
56 qt_config->endGroup(); 56 qt_config->endGroup();
57} 57}
58 58
@@ -87,7 +87,7 @@ void Config::SaveValues() {
87 qt_config->endGroup(); 87 qt_config->endGroup();
88 88
89 qt_config->beginGroup("Miscellaneous"); 89 qt_config->beginGroup("Miscellaneous");
90 qt_config->setValue("enable_log", Settings::values.enable_log); 90 qt_config->setValue("log_filter", QString::fromStdString(Settings::values.log_filter));
91 qt_config->endGroup(); 91 qt_config->endGroup();
92} 92}
93 93
diff --git a/src/citra_qt/debugger/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics_breakpoints.cpp
index df5579e15..53394b6e6 100644
--- a/src/citra_qt/debugger/graphics_breakpoints.cpp
+++ b/src/citra_qt/debugger/graphics_breakpoints.cpp
@@ -45,7 +45,7 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const
45 map.insert({Pica::DebugContext::Event::IncomingPrimitiveBatch, tr("Incoming primitive batch")}); 45 map.insert({Pica::DebugContext::Event::IncomingPrimitiveBatch, tr("Incoming primitive batch")});
46 map.insert({Pica::DebugContext::Event::FinishedPrimitiveBatch, tr("Finished primitive batch")}); 46 map.insert({Pica::DebugContext::Event::FinishedPrimitiveBatch, tr("Finished primitive batch")});
47 47
48 _dbg_assert_(GUI, map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents)); 48 _dbg_assert_(Debug_GPU, map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents));
49 49
50 return map[event]; 50 return map[event];
51 } 51 }
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index b4e3ad964..1299338ac 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -1,3 +1,5 @@
1#include <thread>
2
1#include <QtGui> 3#include <QtGui>
2#include <QDesktopWidget> 4#include <QDesktopWidget>
3#include <QFileDialog> 5#include <QFileDialog>
@@ -5,8 +7,13 @@
5#include "main.hxx" 7#include "main.hxx"
6 8
7#include "common/common.h" 9#include "common/common.h"
10#include "common/logging/text_formatter.h"
11#include "common/logging/log.h"
12#include "common/logging/backend.h"
13#include "common/logging/filter.h"
8#include "common/platform.h" 14#include "common/platform.h"
9#include "common/log_manager.h" 15#include "common/scope_exit.h"
16
10#if EMU_PLATFORM == PLATFORM_LINUX 17#if EMU_PLATFORM == PLATFORM_LINUX
11#include <unistd.h> 18#include <unistd.h>
12#endif 19#endif
@@ -33,18 +40,12 @@
33 40
34#include "version.h" 41#include "version.h"
35 42
36
37GMainWindow::GMainWindow() 43GMainWindow::GMainWindow()
38{ 44{
39 LogManager::Init();
40
41 Pica::g_debug_context = Pica::DebugContext::Construct(); 45 Pica::g_debug_context = Pica::DebugContext::Construct();
42 46
43 Config config; 47 Config config;
44 48
45 if (!Settings::values.enable_log)
46 LogManager::Shutdown();
47
48 ui.setupUi(this); 49 ui.setupUi(this);
49 statusBar()->hide(); 50 statusBar()->hide();
50 51
@@ -153,18 +154,18 @@ GMainWindow::~GMainWindow()
153 154
154void GMainWindow::BootGame(std::string filename) 155void GMainWindow::BootGame(std::string filename)
155{ 156{
156 NOTICE_LOG(MASTER_LOG, "Citra starting...\n"); 157 LOG_INFO(Frontend, "Citra starting...\n");
157 System::Init(render_window); 158 System::Init(render_window);
158 159
159 if (Core::Init()) { 160 if (Core::Init()) {
160 ERROR_LOG(MASTER_LOG, "Core initialization failed, exiting..."); 161 LOG_CRITICAL(Frontend, "Core initialization failed, exiting...");
161 Core::Stop(); 162 Core::Stop();
162 exit(1); 163 exit(1);
163 } 164 }
164 165
165 // Load a game or die... 166 // Load a game or die...
166 if (Loader::ResultStatus::Success != Loader::LoadFile(filename)) { 167 if (Loader::ResultStatus::Success != Loader::LoadFile(filename)) {
167 ERROR_LOG(BOOT, "Failed to load ROM!"); 168 LOG_CRITICAL(Frontend, "Failed to load ROM!");
168 } 169 }
169 170
170 disasmWidget->Init(); 171 disasmWidget->Init();
@@ -271,9 +272,21 @@ void GMainWindow::closeEvent(QCloseEvent* event)
271 272
272int __cdecl main(int argc, char* argv[]) 273int __cdecl main(int argc, char* argv[])
273{ 274{
275 std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger();
276 Log::Filter log_filter(Log::Level::Info);
277 std::thread logging_thread(Log::TextLoggingLoop, logger, &log_filter);
278 SCOPE_EXIT({
279 logger->Close();
280 logging_thread.join();
281 });
282
274 QApplication::setAttribute(Qt::AA_X11InitThreads); 283 QApplication::setAttribute(Qt::AA_X11InitThreads);
275 QApplication app(argc, argv); 284 QApplication app(argc, argv);
285
276 GMainWindow main_window; 286 GMainWindow main_window;
287 // After settings have been loaded by GMainWindow, apply the filter
288 log_filter.ParseFilterString(Settings::values.log_filter);
289
277 main_window.show(); 290 main_window.show();
278 return app.exec(); 291 return app.exec();
279} 292}
diff --git a/src/citra_qt/util/spinbox.cpp b/src/citra_qt/util/spinbox.cpp
index 80dc67d7d..9672168f5 100644
--- a/src/citra_qt/util/spinbox.cpp
+++ b/src/citra_qt/util/spinbox.cpp
@@ -244,7 +244,7 @@ QValidator::State CSpinBox::validate(QString& input, int& pos) const
244 if (strpos >= input.length() - HasSign() - suffix.length()) 244 if (strpos >= input.length() - HasSign() - suffix.length())
245 return QValidator::Intermediate; 245 return QValidator::Intermediate;
246 246
247 _dbg_assert_(GUI, base <= 10 || base == 16); 247 _dbg_assert_(Frontend, base <= 10 || base == 16);
248 QString regexp; 248 QString regexp;
249 249
250 // Demand sign character for negative ranges 250 // Demand sign character for negative ranges
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 9d5a90762..15989708d 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -3,14 +3,15 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOU
3 3
4set(SRCS 4set(SRCS
5 break_points.cpp 5 break_points.cpp
6 console_listener.cpp
7 emu_window.cpp 6 emu_window.cpp
8 extended_trace.cpp 7 extended_trace.cpp
9 file_search.cpp 8 file_search.cpp
10 file_util.cpp 9 file_util.cpp
11 hash.cpp 10 hash.cpp
12 key_map.cpp 11 key_map.cpp
13 log_manager.cpp 12 logging/filter.cpp
13 logging/text_formatter.cpp
14 logging/backend.cpp
14 math_util.cpp 15 math_util.cpp
15 mem_arena.cpp 16 mem_arena.cpp
16 memory_util.cpp 17 memory_util.cpp
@@ -32,7 +33,7 @@ set(HEADERS
32 common_funcs.h 33 common_funcs.h
33 common_paths.h 34 common_paths.h
34 common_types.h 35 common_types.h
35 console_listener.h 36 concurrent_ring_buffer.h
36 cpu_detect.h 37 cpu_detect.h
37 debug_interface.h 38 debug_interface.h
38 emu_window.h 39 emu_window.h
@@ -44,13 +45,17 @@ set(HEADERS
44 key_map.h 45 key_map.h
45 linear_disk_cache.h 46 linear_disk_cache.h
46 log.h 47 log.h
47 log_manager.h 48 logging/text_formatter.h
49 logging/filter.h
50 logging/log.h
51 logging/backend.h
48 math_util.h 52 math_util.h
49 mem_arena.h 53 mem_arena.h
50 memory_util.h 54 memory_util.h
51 msg_handler.h 55 msg_handler.h
52 platform.h 56 platform.h
53 scm_rev.h 57 scm_rev.h
58 scope_exit.h
54 string_util.h 59 string_util.h
55 swap.h 60 swap.h
56 symbols.h 61 symbols.h
diff --git a/src/common/break_points.cpp b/src/common/break_points.cpp
index 25528b864..587dbf40a 100644
--- a/src/common/break_points.cpp
+++ b/src/common/break_points.cpp
@@ -180,7 +180,7 @@ void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr,
180 { 180 {
181 if (Log) 181 if (Log)
182 { 182 {
183 INFO_LOG(MEMMAP, "CHK %08x (%s) %s%i %0*x at %08x (%s)", 183 LOG_DEBUG(Debug_Breakpoint, "CHK %08x (%s) %s%i %0*x at %08x (%s)",
184 pc, debug_interface->getDescription(pc).c_str(), 184 pc, debug_interface->getDescription(pc).c_str(),
185 write ? "Write" : "Read", size*8, size*2, iValue, addr, 185 write ? "Write" : "Read", size*8, size*2, iValue, addr,
186 debug_interface->getDescription(addr).c_str() 186 debug_interface->getDescription(addr).c_str()
diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h
index 32af74594..39a14dc81 100644
--- a/src/common/chunk_file.h
+++ b/src/common/chunk_file.h
@@ -154,7 +154,7 @@ public:
154 Do(foundVersion); 154 Do(foundVersion);
155 155
156 if (error == ERROR_FAILURE || foundVersion < minVer || foundVersion > ver) { 156 if (error == ERROR_FAILURE || foundVersion < minVer || foundVersion > ver) {
157 WARN_LOG(COMMON, "Savestate failure: wrong version %d found for %s", foundVersion, title); 157 LOG_ERROR(Common, "Savestate failure: wrong version %d found for %s", foundVersion, title);
158 SetError(ERROR_FAILURE); 158 SetError(ERROR_FAILURE);
159 return PointerWrapSection(*this, -1, title); 159 return PointerWrapSection(*this, -1, title);
160 } 160 }
@@ -178,7 +178,14 @@ public:
178 case MODE_READ: if (memcmp(data, *ptr, size) != 0) return false; break; 178 case MODE_READ: if (memcmp(data, *ptr, size) != 0) return false; break;
179 case MODE_WRITE: memcpy(*ptr, data, size); break; 179 case MODE_WRITE: memcpy(*ptr, data, size); break;
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: for(int i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; 181 case MODE_VERIFY:
182 for (int i = 0; i < size; i++) {
183 _dbg_assert_msg_(Common, ((u8*)data)[i] == (*ptr)[i],
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],
186 (*ptr)[i], (*ptr)[i], &(*ptr)[i]);
187 }
188 break;
182 default: break; // throw an error? 189 default: break; // throw an error?
183 } 190 }
184 (*ptr) += size; 191 (*ptr) += size;
@@ -191,7 +198,14 @@ public:
191 case MODE_READ: memcpy(data, *ptr, size); break; 198 case MODE_READ: memcpy(data, *ptr, size); break;
192 case MODE_WRITE: memcpy(*ptr, data, size); break; 199 case MODE_WRITE: memcpy(*ptr, data, size); break;
193 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
194 case MODE_VERIFY: for(int i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; 201 case MODE_VERIFY:
202 for (int i = 0; i < size; i++) {
203 _dbg_assert_msg_(Common, ((u8*)data)[i] == (*ptr)[i],
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],
206 (*ptr)[i], (*ptr)[i], &(*ptr)[i]);
207 }
208 break;
195 default: break; // throw an error? 209 default: break; // throw an error?
196 } 210 }
197 (*ptr) += size; 211 (*ptr) += size;
@@ -476,7 +490,7 @@ public:
476 break; 490 break;
477 491
478 default: 492 default:
479 ERROR_LOG(COMMON, "Savestate error: invalid mode %d.", mode); 493 LOG_ERROR(Common, "Savestate error: invalid mode %d.", mode);
480 } 494 }
481 } 495 }
482 496
@@ -490,7 +504,12 @@ public:
490 case MODE_READ: x = (char*)*ptr; break; 504 case MODE_READ: x = (char*)*ptr; break;
491 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; 505 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
492 case MODE_MEASURE: break; 506 case MODE_MEASURE: break;
493 case MODE_VERIFY: _dbg_assert_msg_(COMMON, !strcmp(x.c_str(), (char*)*ptr), "Savestate verification failure: \"%s\" != \"%s\" (at %p).\n", x.c_str(), (char*)*ptr, ptr); break; 507 case MODE_VERIFY:
508 _dbg_assert_msg_(Common,
509 !strcmp(x.c_str(), (char*)*ptr),
510 "Savestate verification failure: \"%s\" != \"%s\" (at %p).\n",
511 x.c_str(), (char*)*ptr, ptr);
512 break;
494 } 513 }
495 (*ptr) += stringLen; 514 (*ptr) += stringLen;
496 } 515 }
@@ -504,7 +523,11 @@ public:
504 case MODE_READ: x = (wchar_t*)*ptr; break; 523 case MODE_READ: x = (wchar_t*)*ptr; break;
505 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; 524 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
506 case MODE_MEASURE: break; 525 case MODE_MEASURE: break;
507 case MODE_VERIFY: _dbg_assert_msg_(COMMON, x == (wchar_t*)*ptr, "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", x.c_str(), (wchar_t*)*ptr, ptr); break; 526 case MODE_VERIFY:
527 _dbg_assert_msg_(Common, x == (wchar_t*)*ptr,
528 "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n",
529 x.c_str(), (wchar_t*)*ptr, ptr);
530 break;
508 } 531 }
509 (*ptr) += stringLen; 532 (*ptr) += stringLen;
510 } 533 }
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index db041780a..67b3679b0 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -5,6 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include "common_types.h" 7#include "common_types.h"
8#include <cstdlib>
8 9
9#ifdef _WIN32 10#ifdef _WIN32
10#define SLEEP(x) Sleep(x) 11#define SLEEP(x) Sleep(x)
@@ -39,8 +40,6 @@ template<> struct CompileTimeAssert<true> {};
39#include <sys/endian.h> 40#include <sys/endian.h>
40#endif 41#endif
41 42
42#include "common_types.h"
43
44// go to debugger mode 43// go to debugger mode
45 #ifdef GEKKO 44 #ifdef GEKKO
46 #define Crash() 45 #define Crash()
diff --git a/src/common/common_types.h b/src/common/common_types.h
index fcc8b9a4e..c74c74f0f 100644
--- a/src/common/common_types.h
+++ b/src/common/common_types.h
@@ -41,8 +41,6 @@ typedef std::int64_t s64; ///< 64-bit signed int
41typedef float f32; ///< 32-bit floating point 41typedef float f32; ///< 32-bit floating point
42typedef double f64; ///< 64-bit floating point 42typedef double f64; ///< 64-bit floating point
43 43
44#include "common/common.h"
45
46/// Union for fast 16-bit type casting 44/// Union for fast 16-bit type casting
47union t16 { 45union t16 {
48 u8 _u8[2]; ///< 8-bit unsigned char(s) 46 u8 _u8[2]; ///< 8-bit unsigned char(s)
diff --git a/src/common/concurrent_ring_buffer.h b/src/common/concurrent_ring_buffer.h
new file mode 100644
index 000000000..2951d93db
--- /dev/null
+++ b/src/common/concurrent_ring_buffer.h
@@ -0,0 +1,164 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <array>
8#include <condition_variable>
9#include <cstdint>
10#include <mutex>
11#include <thread>
12
13#include "common/common.h" // for NonCopyable
14#include "common/log.h" // for _dbg_assert_
15
16namespace Common {
17
18/**
19 * A MPMC (Multiple-Producer Multiple-Consumer) concurrent ring buffer. This data structure permits
20 * multiple threads to push and pop from a queue of bounded size.
21 */
22template <typename T, size_t ArraySize>
23class ConcurrentRingBuffer : private NonCopyable {
24public:
25 /// Value returned by the popping functions when the queue has been closed.
26 static const size_t QUEUE_CLOSED = -1;
27
28 ConcurrentRingBuffer() {}
29
30 ~ConcurrentRingBuffer() {
31 // If for whatever reason the queue wasn't completely drained, destroy the left over items.
32 for (size_t i = reader_index, end = writer_index; i != end; i = (i + 1) % ArraySize) {
33 Data()[i].~T();
34 }
35 }
36
37 /**
38 * Pushes a value to the queue. If the queue is full, this method will block. Does nothing if
39 * the queue is closed.
40 */
41 void Push(T val) {
42 std::unique_lock<std::mutex> lock(mutex);
43 if (closed) {
44 return;
45 }
46
47 // If the buffer is full, wait
48 writer.wait(lock, [&]{
49 return (writer_index + 1) % ArraySize != reader_index;
50 });
51
52 T* item = &Data()[writer_index];
53 new (item) T(std::move(val));
54
55 writer_index = (writer_index + 1) % ArraySize;
56
57 // Wake up waiting readers
58 lock.unlock();
59 reader.notify_one();
60 }
61
62 /**
63 * Pops up to `dest_len` items from the queue, storing them in `dest`. This function will not
64 * block, and might return 0 values if there are no elements in the queue when it is called.
65 *
66 * @return The number of elements stored in `dest`. If the queue has been closed, returns
67 * `QUEUE_CLOSED`.
68 */
69 size_t Pop(T* dest, size_t dest_len) {
70 std::unique_lock<std::mutex> lock(mutex);
71 if (closed && !CanRead()) {
72 return QUEUE_CLOSED;
73 }
74 return PopInternal(dest, dest_len);
75 }
76
77 /**
78 * Pops up to `dest_len` items from the queue, storing them in `dest`. This function will block
79 * if there are no elements in the queue when it is called.
80 *
81 * @return The number of elements stored in `dest`. If the queue has been closed, returns
82 * `QUEUE_CLOSED`.
83 */
84 size_t BlockingPop(T* dest, size_t dest_len) {
85 std::unique_lock<std::mutex> lock(mutex);
86 if (closed && !CanRead()) {
87 return QUEUE_CLOSED;
88 }
89
90 while (!CanRead()) {
91 reader.wait(lock);
92 if (closed && !CanRead()) {
93 return QUEUE_CLOSED;
94 }
95 }
96 _dbg_assert_(Common, CanRead());
97 return PopInternal(dest, dest_len);
98 }
99
100 /**
101 * Closes the queue. After calling this method, `Push` operations won't have any effect, and
102 * `PopMany` and `PopManyBlock` will start returning `QUEUE_CLOSED`. This is intended to allow
103 * a graceful shutdown of all consumers.
104 */
105 void Close() {
106 std::unique_lock<std::mutex> lock(mutex);
107 closed = true;
108 // We need to wake up any reader that are waiting for an item that will never come.
109 lock.unlock();
110 reader.notify_all();
111 }
112
113 /// Returns true if `Close()` has been called.
114 bool IsClosed() const {
115 return closed;
116 }
117
118private:
119 size_t PopInternal(T* dest, size_t dest_len) {
120 size_t output_count = 0;
121 while (output_count < dest_len && CanRead()) {
122 _dbg_assert_(Common, CanRead());
123
124 T* item = &Data()[reader_index];
125 T out_val = std::move(*item);
126 item->~T();
127
128 size_t prev_index = (reader_index + ArraySize - 1) % ArraySize;
129 reader_index = (reader_index + 1) % ArraySize;
130 if (writer_index == prev_index) {
131 writer.notify_one();
132 }
133 dest[output_count++] = std::move(out_val);
134 }
135 return output_count;
136 }
137
138 bool CanRead() const {
139 return reader_index != writer_index;
140 }
141
142 T* Data() {
143 return static_cast<T*>(static_cast<void*>(&storage));
144 }
145
146 /// Storage for entries
147 typename std::aligned_storage<ArraySize * sizeof(T),
148 std::alignment_of<T>::value>::type storage;
149
150 /// Data is valid in the half-open interval [reader, writer). If they are `QUEUE_CLOSED` then the
151 /// queue has been closed.
152 size_t writer_index = 0, reader_index = 0;
153 // True if the queue has been closed.
154 bool closed = false;
155
156 /// Mutex that protects the entire data structure.
157 std::mutex mutex;
158 /// Signaling wakes up reader which is waiting for storage to be non-empty.
159 std::condition_variable reader;
160 /// Signaling wakes up writer which is waiting for storage to be non-full.
161 std::condition_variable writer;
162};
163
164} // namespace
diff --git a/src/common/console_listener.cpp b/src/common/console_listener.cpp
deleted file mode 100644
index b6042796d..000000000
--- a/src/common/console_listener.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
1// Copyright 2013 Dolphin Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include <algorithm>
6
7#ifdef _WIN32
8#include <windows.h>
9#include <array>
10#endif
11
12#include "common/common.h"
13#include "common/log_manager.h" // Common
14#include "common/console_listener.h" // Common
15
16ConsoleListener::ConsoleListener()
17{
18#ifdef _WIN32
19 hConsole = nullptr;
20 bUseColor = true;
21#else
22 bUseColor = isatty(fileno(stdout));
23#endif
24}
25
26ConsoleListener::~ConsoleListener()
27{
28 Close();
29}
30
31// 100, 100, "Dolphin Log Console"
32// Open console window - width and height is the size of console window
33// Name is the window title
34void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title)
35{
36#ifdef _WIN32
37 if (!GetConsoleWindow())
38 {
39 // Open the console window and create the window handle for GetStdHandle()
40 AllocConsole();
41 // Hide
42 if (Hidden) ShowWindow(GetConsoleWindow(), SW_HIDE);
43 // Save the window handle that AllocConsole() created
44 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
45 // Set the console window title
46 SetConsoleTitle(Common::UTF8ToTStr(Title).c_str());
47 // Set letter space
48 LetterSpace(80, 4000);
49 //MoveWindow(GetConsoleWindow(), 200,200, 800,800, true);
50 }
51 else
52 {
53 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
54 }
55#endif
56}
57
58void ConsoleListener::UpdateHandle()
59{
60#ifdef _WIN32
61 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
62#endif
63}
64
65// Close the console window and close the eventual file handle
66void ConsoleListener::Close()
67{
68#ifdef _WIN32
69 if (hConsole == nullptr)
70 return;
71 FreeConsole();
72 hConsole = nullptr;
73#else
74 fflush(nullptr);
75#endif
76}
77
78bool ConsoleListener::IsOpen()
79{
80#ifdef _WIN32
81 return (hConsole != nullptr);
82#else
83 return true;
84#endif
85}
86
87/*
88 LetterSpace: SetConsoleScreenBufferSize and SetConsoleWindowInfo are
89 dependent on each other, that's the reason for the additional checks.
90*/
91void ConsoleListener::BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst)
92{
93#ifdef _WIN32
94 BOOL SB, SW;
95 if (BufferFirst)
96 {
97 // Change screen buffer size
98 COORD Co = {BufferWidth, BufferHeight};
99 SB = SetConsoleScreenBufferSize(hConsole, Co);
100 // Change the screen buffer window size
101 SMALL_RECT coo = {0,0,ScreenWidth, ScreenHeight}; // top, left, right, bottom
102 SW = SetConsoleWindowInfo(hConsole, TRUE, &coo);
103 }
104 else
105 {
106 // Change the screen buffer window size
107 SMALL_RECT coo = {0,0, ScreenWidth, ScreenHeight}; // top, left, right, bottom
108 SW = SetConsoleWindowInfo(hConsole, TRUE, &coo);
109 // Change screen buffer size
110 COORD Co = {BufferWidth, BufferHeight};
111 SB = SetConsoleScreenBufferSize(hConsole, Co);
112 }
113#endif
114}
115void ConsoleListener::LetterSpace(int Width, int Height)
116{
117#ifdef _WIN32
118 // Get console info
119 CONSOLE_SCREEN_BUFFER_INFO ConInfo;
120 GetConsoleScreenBufferInfo(hConsole, &ConInfo);
121
122 //
123 int OldBufferWidth = ConInfo.dwSize.X;
124 int OldBufferHeight = ConInfo.dwSize.Y;
125 int OldScreenWidth = (ConInfo.srWindow.Right - ConInfo.srWindow.Left);
126 int OldScreenHeight = (ConInfo.srWindow.Bottom - ConInfo.srWindow.Top);
127 //
128 int NewBufferWidth = Width;
129 int NewBufferHeight = Height;
130 int NewScreenWidth = NewBufferWidth - 1;
131 int NewScreenHeight = OldScreenHeight;
132
133 // Width
134 BufferWidthHeight(NewBufferWidth, OldBufferHeight, NewScreenWidth, OldScreenHeight, (NewBufferWidth > OldScreenWidth-1));
135 // Height
136 BufferWidthHeight(NewBufferWidth, NewBufferHeight, NewScreenWidth, NewScreenHeight, (NewBufferHeight > OldScreenHeight-1));
137
138 // Resize the window too
139 //MoveWindow(GetConsoleWindow(), 200,200, (Width*8 + 50),(NewScreenHeight*12 + 200), true);
140#endif
141}
142#ifdef _WIN32
143COORD ConsoleListener::GetCoordinates(int BytesRead, int BufferWidth)
144{
145 COORD Ret = {0, 0};
146 // Full rows
147 int Step = (int)floor((float)BytesRead / (float)BufferWidth);
148 Ret.Y += Step;
149 // Partial row
150 Ret.X = BytesRead - (BufferWidth * Step);
151 return Ret;
152}
153#endif
154void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool Resize)
155{
156#ifdef _WIN32
157 // Check size
158 if (Width < 8 || Height < 12) return;
159
160 bool DBef = true;
161 bool DAft = true;
162 std::string SLog = "";
163
164 const HWND hWnd = GetConsoleWindow();
165 const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
166
167 // Get console info
168 CONSOLE_SCREEN_BUFFER_INFO ConInfo;
169 GetConsoleScreenBufferInfo(hConsole, &ConInfo);
170 DWORD BufferSize = ConInfo.dwSize.X * ConInfo.dwSize.Y;
171
172 // ---------------------------------------------------------------------
173 // Save the current text
174 // ------------------------
175 DWORD cCharsRead = 0;
176 COORD coordScreen = { 0, 0 };
177
178 static const int MAX_BYTES = 1024 * 16;
179
180 std::vector<std::array<TCHAR, MAX_BYTES>> Str;
181 std::vector<std::array<WORD, MAX_BYTES>> Attr;
182
183 // ReadConsoleOutputAttribute seems to have a limit at this level
184 static const int ReadBufferSize = MAX_BYTES - 32;
185
186 DWORD cAttrRead = ReadBufferSize;
187 DWORD BytesRead = 0;
188 while (BytesRead < BufferSize)
189 {
190 Str.resize(Str.size() + 1);
191 if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead))
192 SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error");
193
194 Attr.resize(Attr.size() + 1);
195 if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead))
196 SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error");
197
198 // Break on error
199 if (cAttrRead == 0) break;
200 BytesRead += cAttrRead;
201 coordScreen = GetCoordinates(BytesRead, ConInfo.dwSize.X);
202 }
203 // Letter space
204 int LWidth = (int)(floor((float)Width / 8.0f) - 1.0f);
205 int LHeight = (int)(floor((float)Height / 12.0f) - 1.0f);
206 int LBufWidth = LWidth + 1;
207 int LBufHeight = (int)floor((float)BufferSize / (float)LBufWidth);
208 // Change screen buffer size
209 LetterSpace(LBufWidth, LBufHeight);
210
211
212 ClearScreen(true);
213 coordScreen.Y = 0;
214 coordScreen.X = 0;
215 DWORD cCharsWritten = 0;
216
217 int BytesWritten = 0;
218 DWORD cAttrWritten = 0;
219 for (size_t i = 0; i < Attr.size(); i++)
220 {
221 if (!WriteConsoleOutputCharacter(hConsole, Str[i].data(), ReadBufferSize, coordScreen, &cCharsWritten))
222 SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error");
223 if (!WriteConsoleOutputAttribute(hConsole, Attr[i].data(), ReadBufferSize, coordScreen, &cAttrWritten))
224 SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error");
225
226 BytesWritten += cAttrWritten;
227 coordScreen = GetCoordinates(BytesWritten, LBufWidth);
228 }
229
230 const int OldCursor = ConInfo.dwCursorPosition.Y * ConInfo.dwSize.X + ConInfo.dwCursorPosition.X;
231 COORD Coo = GetCoordinates(OldCursor, LBufWidth);
232 SetConsoleCursorPosition(hConsole, Coo);
233
234 if (SLog.length() > 0) Log(LogTypes::LNOTICE, SLog.c_str());
235
236 // Resize the window too
237 if (Resize) MoveWindow(GetConsoleWindow(), Left,Top, (Width + 100),Height, true);
238#endif
239}
240
241void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
242{
243#if defined(_WIN32)
244 WORD Color;
245
246 switch (Level)
247 {
248 case OS_LEVEL: // light yellow
249 Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
250 break;
251 case NOTICE_LEVEL: // light green
252 Color = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
253 break;
254 case ERROR_LEVEL: // light red
255 Color = FOREGROUND_RED | FOREGROUND_INTENSITY;
256 break;
257 case WARNING_LEVEL: // light purple
258 Color = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
259 break;
260 case INFO_LEVEL: // cyan
261 Color = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
262 break;
263 case DEBUG_LEVEL: // gray
264 Color = FOREGROUND_INTENSITY;
265 break;
266 default: // off-white
267 Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
268 break;
269 }
270 SetConsoleTextAttribute(hConsole, Color);
271 printf(Text);
272#else
273 char ColorAttr[16] = "";
274 char ResetAttr[16] = "";
275
276 if (bUseColor)
277 {
278 strcpy(ResetAttr, "\033[0m");
279 switch (Level)
280 {
281 case NOTICE_LEVEL: // light green
282 strcpy(ColorAttr, "\033[92m");
283 break;
284 case ERROR_LEVEL: // light red
285 strcpy(ColorAttr, "\033[91m");
286 break;
287 case WARNING_LEVEL: // light yellow
288 strcpy(ColorAttr, "\033[93m");
289 break;
290 default:
291 break;
292 }
293 }
294 fprintf(stderr, "%s%s%s", ColorAttr, Text, ResetAttr);
295#endif
296}
297// Clear console screen
298void ConsoleListener::ClearScreen(bool Cursor)
299{
300#if defined(_WIN32)
301 COORD coordScreen = { 0, 0 };
302 DWORD cCharsWritten;
303 CONSOLE_SCREEN_BUFFER_INFO csbi;
304 DWORD dwConSize;
305
306 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
307
308 GetConsoleScreenBufferInfo(hConsole, &csbi);
309 dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
310 // Write space to the entire console
311 FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
312 GetConsoleScreenBufferInfo(hConsole, &csbi);
313 FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
314 // Reset cursor
315 if (Cursor) SetConsoleCursorPosition(hConsole, coordScreen);
316#endif
317}
318
319
diff --git a/src/common/console_listener.h b/src/common/console_listener.h
deleted file mode 100644
index ebd90a105..000000000
--- a/src/common/console_listener.h
+++ /dev/null
@@ -1,38 +0,0 @@
1// Copyright 2013 Dolphin Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/log_manager.h"
8
9#ifdef _WIN32
10#include <windows.h>
11#endif
12
13class ConsoleListener : public LogListener
14{
15public:
16 ConsoleListener();
17 ~ConsoleListener();
18
19 void Open(bool Hidden = false, int Width = 100, int Height = 100, const char * Name = "Console");
20 void UpdateHandle();
21 void Close();
22 bool IsOpen();
23 void LetterSpace(int Width, int Height);
24 void BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst);
25 void PixelSpace(int Left, int Top, int Width, int Height, bool);
26#ifdef _WIN32
27 COORD GetCoordinates(int BytesRead, int BufferWidth);
28#endif
29 void Log(LogTypes::LOG_LEVELS, const char *Text) override;
30 void ClearScreen(bool Cursor = true);
31
32private:
33#ifdef _WIN32
34 HWND GetHwnd(void);
35 HANDLE hConsole;
36#endif
37 bool bUseColor;
38};
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 7579d8c0f..88c46c117 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -88,7 +88,7 @@ bool IsDirectory(const std::string &filename)
88#endif 88#endif
89 89
90 if (result < 0) { 90 if (result < 0) {
91 WARN_LOG(COMMON, "IsDirectory: stat failed on %s: %s", 91 LOG_WARNING(Common_Filesystem, "stat failed on %s: %s",
92 filename.c_str(), GetLastErrorMsg()); 92 filename.c_str(), GetLastErrorMsg());
93 return false; 93 return false;
94 } 94 }
@@ -100,33 +100,33 @@ bool IsDirectory(const std::string &filename)
100// Doesn't supports deleting a directory 100// Doesn't supports deleting a directory
101bool Delete(const std::string &filename) 101bool Delete(const std::string &filename)
102{ 102{
103 INFO_LOG(COMMON, "Delete: file %s", filename.c_str()); 103 LOG_INFO(Common_Filesystem, "file %s", filename.c_str());
104 104
105 // Return true because we care about the file no 105 // Return true because we care about the file no
106 // being there, not the actual delete. 106 // being there, not the actual delete.
107 if (!Exists(filename)) 107 if (!Exists(filename))
108 { 108 {
109 WARN_LOG(COMMON, "Delete: %s does not exist", filename.c_str()); 109 LOG_WARNING(Common_Filesystem, "%s does not exist", filename.c_str());
110 return true; 110 return true;
111 } 111 }
112 112
113 // We can't delete a directory 113 // We can't delete a directory
114 if (IsDirectory(filename)) 114 if (IsDirectory(filename))
115 { 115 {
116 WARN_LOG(COMMON, "Delete failed: %s is a directory", filename.c_str()); 116 LOG_ERROR(Common_Filesystem, "Failed: %s is a directory", filename.c_str());
117 return false; 117 return false;
118 } 118 }
119 119
120#ifdef _WIN32 120#ifdef _WIN32
121 if (!DeleteFile(Common::UTF8ToTStr(filename).c_str())) 121 if (!DeleteFile(Common::UTF8ToTStr(filename).c_str()))
122 { 122 {
123 WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", 123 LOG_ERROR(Common_Filesystem, "DeleteFile failed on %s: %s",
124 filename.c_str(), GetLastErrorMsg()); 124 filename.c_str(), GetLastErrorMsg());
125 return false; 125 return false;
126 } 126 }
127#else 127#else
128 if (unlink(filename.c_str()) == -1) { 128 if (unlink(filename.c_str()) == -1) {
129 WARN_LOG(COMMON, "Delete: unlink failed on %s: %s", 129 LOG_ERROR(Common_Filesystem, "unlink failed on %s: %s",
130 filename.c_str(), GetLastErrorMsg()); 130 filename.c_str(), GetLastErrorMsg());
131 return false; 131 return false;
132 } 132 }
@@ -138,17 +138,17 @@ bool Delete(const std::string &filename)
138// Returns true if successful, or path already exists. 138// Returns true if successful, or path already exists.
139bool CreateDir(const std::string &path) 139bool CreateDir(const std::string &path)
140{ 140{
141 INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); 141 LOG_TRACE(Common_Filesystem, "directory %s", path.c_str());
142#ifdef _WIN32 142#ifdef _WIN32
143 if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), nullptr)) 143 if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), nullptr))
144 return true; 144 return true;
145 DWORD error = GetLastError(); 145 DWORD error = GetLastError();
146 if (error == ERROR_ALREADY_EXISTS) 146 if (error == ERROR_ALREADY_EXISTS)
147 { 147 {
148 WARN_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: already exists", path.c_str()); 148 LOG_WARNING(Common_Filesystem, "CreateDirectory failed on %s: already exists", path.c_str());
149 return true; 149 return true;
150 } 150 }
151 ERROR_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: %i", path.c_str(), error); 151 LOG_ERROR(Common_Filesystem, "CreateDirectory failed on %s: %i", path.c_str(), error);
152 return false; 152 return false;
153#else 153#else
154 if (mkdir(path.c_str(), 0755) == 0) 154 if (mkdir(path.c_str(), 0755) == 0)
@@ -158,11 +158,11 @@ bool CreateDir(const std::string &path)
158 158
159 if (err == EEXIST) 159 if (err == EEXIST)
160 { 160 {
161 WARN_LOG(COMMON, "CreateDir: mkdir failed on %s: already exists", path.c_str()); 161 LOG_WARNING(Common_Filesystem, "mkdir failed on %s: already exists", path.c_str());
162 return true; 162 return true;
163 } 163 }
164 164
165 ERROR_LOG(COMMON, "CreateDir: mkdir failed on %s: %s", path.c_str(), strerror(err)); 165 LOG_ERROR(Common_Filesystem, "mkdir failed on %s: %s", path.c_str(), strerror(err));
166 return false; 166 return false;
167#endif 167#endif
168} 168}
@@ -171,11 +171,11 @@ bool CreateDir(const std::string &path)
171bool CreateFullPath(const std::string &fullPath) 171bool CreateFullPath(const std::string &fullPath)
172{ 172{
173 int panicCounter = 100; 173 int panicCounter = 100;
174 INFO_LOG(COMMON, "CreateFullPath: path %s", fullPath.c_str()); 174 LOG_TRACE(Common_Filesystem, "path %s", fullPath.c_str());
175 175
176 if (FileUtil::Exists(fullPath)) 176 if (FileUtil::Exists(fullPath))
177 { 177 {
178 INFO_LOG(COMMON, "CreateFullPath: path exists %s", fullPath.c_str()); 178 LOG_WARNING(Common_Filesystem, "path exists %s", fullPath.c_str());
179 return true; 179 return true;
180 } 180 }
181 181
@@ -192,7 +192,7 @@ bool CreateFullPath(const std::string &fullPath)
192 // Include the '/' so the first call is CreateDir("/") rather than CreateDir("") 192 // Include the '/' so the first call is CreateDir("/") rather than CreateDir("")
193 std::string const subPath(fullPath.substr(0, position + 1)); 193 std::string const subPath(fullPath.substr(0, position + 1));
194 if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) { 194 if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) {
195 ERROR_LOG(COMMON, "CreateFullPath: directory creation failed"); 195 LOG_ERROR(Common, "CreateFullPath: directory creation failed");
196 return false; 196 return false;
197 } 197 }
198 198
@@ -200,7 +200,7 @@ bool CreateFullPath(const std::string &fullPath)
200 panicCounter--; 200 panicCounter--;
201 if (panicCounter <= 0) 201 if (panicCounter <= 0)
202 { 202 {
203 ERROR_LOG(COMMON, "CreateFullPath: directory structure is too deep"); 203 LOG_ERROR(Common, "CreateFullPath: directory structure is too deep");
204 return false; 204 return false;
205 } 205 }
206 position++; 206 position++;
@@ -211,12 +211,12 @@ bool CreateFullPath(const std::string &fullPath)
211// Deletes a directory filename, returns true on success 211// Deletes a directory filename, returns true on success
212bool DeleteDir(const std::string &filename) 212bool DeleteDir(const std::string &filename)
213{ 213{
214 INFO_LOG(COMMON, "DeleteDir: directory %s", filename.c_str()); 214 LOG_INFO(Common_Filesystem, "directory %s", filename.c_str());
215 215
216 // check if a directory 216 // check if a directory
217 if (!FileUtil::IsDirectory(filename)) 217 if (!FileUtil::IsDirectory(filename))
218 { 218 {
219 ERROR_LOG(COMMON, "DeleteDir: Not a directory %s", filename.c_str()); 219 LOG_ERROR(Common_Filesystem, "Not a directory %s", filename.c_str());
220 return false; 220 return false;
221 } 221 }
222 222
@@ -227,7 +227,7 @@ bool DeleteDir(const std::string &filename)
227 if (rmdir(filename.c_str()) == 0) 227 if (rmdir(filename.c_str()) == 0)
228 return true; 228 return true;
229#endif 229#endif
230 ERROR_LOG(COMMON, "DeleteDir: %s: %s", filename.c_str(), GetLastErrorMsg()); 230 LOG_ERROR(Common_Filesystem, "failed %s: %s", filename.c_str(), GetLastErrorMsg());
231 231
232 return false; 232 return false;
233} 233}
@@ -235,11 +235,11 @@ bool DeleteDir(const std::string &filename)
235// renames file srcFilename to destFilename, returns true on success 235// renames file srcFilename to destFilename, returns true on success
236bool Rename(const std::string &srcFilename, const std::string &destFilename) 236bool Rename(const std::string &srcFilename, const std::string &destFilename)
237{ 237{
238 INFO_LOG(COMMON, "Rename: %s --> %s", 238 LOG_TRACE(Common_Filesystem, "%s --> %s",
239 srcFilename.c_str(), destFilename.c_str()); 239 srcFilename.c_str(), destFilename.c_str());
240 if (rename(srcFilename.c_str(), destFilename.c_str()) == 0) 240 if (rename(srcFilename.c_str(), destFilename.c_str()) == 0)
241 return true; 241 return true;
242 ERROR_LOG(COMMON, "Rename: failed %s --> %s: %s", 242 LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s",
243 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 243 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
244 return false; 244 return false;
245} 245}
@@ -247,13 +247,13 @@ bool Rename(const std::string &srcFilename, const std::string &destFilename)
247// copies file srcFilename to destFilename, returns true on success 247// copies file srcFilename to destFilename, returns true on success
248bool Copy(const std::string &srcFilename, const std::string &destFilename) 248bool Copy(const std::string &srcFilename, const std::string &destFilename)
249{ 249{
250 INFO_LOG(COMMON, "Copy: %s --> %s", 250 LOG_TRACE(Common_Filesystem, "%s --> %s",
251 srcFilename.c_str(), destFilename.c_str()); 251 srcFilename.c_str(), destFilename.c_str());
252#ifdef _WIN32 252#ifdef _WIN32
253 if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE)) 253 if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE))
254 return true; 254 return true;
255 255
256 ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", 256 LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s",
257 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 257 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
258 return false; 258 return false;
259#else 259#else
@@ -267,7 +267,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
267 FILE *input = fopen(srcFilename.c_str(), "rb"); 267 FILE *input = fopen(srcFilename.c_str(), "rb");
268 if (!input) 268 if (!input)
269 { 269 {
270 ERROR_LOG(COMMON, "Copy: input failed %s --> %s: %s", 270 LOG_ERROR(Common_Filesystem, "opening input failed %s --> %s: %s",
271 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 271 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
272 return false; 272 return false;
273 } 273 }
@@ -277,7 +277,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
277 if (!output) 277 if (!output)
278 { 278 {
279 fclose(input); 279 fclose(input);
280 ERROR_LOG(COMMON, "Copy: output failed %s --> %s: %s", 280 LOG_ERROR(Common_Filesystem, "opening output failed %s --> %s: %s",
281 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 281 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
282 return false; 282 return false;
283 } 283 }
@@ -291,8 +291,8 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
291 { 291 {
292 if (ferror(input) != 0) 292 if (ferror(input) != 0)
293 { 293 {
294 ERROR_LOG(COMMON, 294 LOG_ERROR(Common_Filesystem,
295 "Copy: failed reading from source, %s --> %s: %s", 295 "failed reading from source, %s --> %s: %s",
296 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 296 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
297 goto bail; 297 goto bail;
298 } 298 }
@@ -302,8 +302,8 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
302 int wnum = fwrite(buffer, sizeof(char), rnum, output); 302 int wnum = fwrite(buffer, sizeof(char), rnum, output);
303 if (wnum != rnum) 303 if (wnum != rnum)
304 { 304 {
305 ERROR_LOG(COMMON, 305 LOG_ERROR(Common_Filesystem,
306 "Copy: failed writing to output, %s --> %s: %s", 306 "failed writing to output, %s --> %s: %s",
307 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 307 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
308 goto bail; 308 goto bail;
309 } 309 }
@@ -326,13 +326,13 @@ u64 GetSize(const std::string &filename)
326{ 326{
327 if (!Exists(filename)) 327 if (!Exists(filename))
328 { 328 {
329 WARN_LOG(COMMON, "GetSize: failed %s: No such file", filename.c_str()); 329 LOG_ERROR(Common_Filesystem, "failed %s: No such file", filename.c_str());
330 return 0; 330 return 0;
331 } 331 }
332 332
333 if (IsDirectory(filename)) 333 if (IsDirectory(filename))
334 { 334 {
335 WARN_LOG(COMMON, "GetSize: failed %s: is a directory", filename.c_str()); 335 LOG_ERROR(Common_Filesystem, "failed %s: is a directory", filename.c_str());
336 return 0; 336 return 0;
337 } 337 }
338 338
@@ -343,12 +343,12 @@ u64 GetSize(const std::string &filename)
343 if (stat64(filename.c_str(), &buf) == 0) 343 if (stat64(filename.c_str(), &buf) == 0)
344#endif 344#endif
345 { 345 {
346 DEBUG_LOG(COMMON, "GetSize: %s: %lld", 346 LOG_TRACE(Common_Filesystem, "%s: %lld",
347 filename.c_str(), (long long)buf.st_size); 347 filename.c_str(), (long long)buf.st_size);
348 return buf.st_size; 348 return buf.st_size;
349 } 349 }
350 350
351 ERROR_LOG(COMMON, "GetSize: Stat failed %s: %s", 351 LOG_ERROR(Common_Filesystem, "Stat failed %s: %s",
352 filename.c_str(), GetLastErrorMsg()); 352 filename.c_str(), GetLastErrorMsg());
353 return 0; 353 return 0;
354} 354}
@@ -358,7 +358,7 @@ u64 GetSize(const int fd)
358{ 358{
359 struct stat64 buf; 359 struct stat64 buf;
360 if (fstat64(fd, &buf) != 0) { 360 if (fstat64(fd, &buf) != 0) {
361 ERROR_LOG(COMMON, "GetSize: stat failed %i: %s", 361 LOG_ERROR(Common_Filesystem, "GetSize: stat failed %i: %s",
362 fd, GetLastErrorMsg()); 362 fd, GetLastErrorMsg());
363 return 0; 363 return 0;
364 } 364 }
@@ -371,13 +371,13 @@ u64 GetSize(FILE *f)
371 // can't use off_t here because it can be 32-bit 371 // can't use off_t here because it can be 32-bit
372 u64 pos = ftello(f); 372 u64 pos = ftello(f);
373 if (fseeko(f, 0, SEEK_END) != 0) { 373 if (fseeko(f, 0, SEEK_END) != 0) {
374 ERROR_LOG(COMMON, "GetSize: seek failed %p: %s", 374 LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s",
375 f, GetLastErrorMsg()); 375 f, GetLastErrorMsg());
376 return 0; 376 return 0;
377 } 377 }
378 u64 size = ftello(f); 378 u64 size = ftello(f);
379 if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) { 379 if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) {
380 ERROR_LOG(COMMON, "GetSize: seek failed %p: %s", 380 LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s",
381 f, GetLastErrorMsg()); 381 f, GetLastErrorMsg());
382 return 0; 382 return 0;
383 } 383 }
@@ -387,11 +387,11 @@ u64 GetSize(FILE *f)
387// creates an empty file filename, returns true on success 387// creates an empty file filename, returns true on success
388bool CreateEmptyFile(const std::string &filename) 388bool CreateEmptyFile(const std::string &filename)
389{ 389{
390 INFO_LOG(COMMON, "CreateEmptyFile: %s", filename.c_str()); 390 LOG_TRACE(Common_Filesystem, "%s", filename.c_str());
391 391
392 if (!FileUtil::IOFile(filename, "wb")) 392 if (!FileUtil::IOFile(filename, "wb"))
393 { 393 {
394 ERROR_LOG(COMMON, "CreateEmptyFile: failed %s: %s", 394 LOG_ERROR(Common_Filesystem, "failed %s: %s",
395 filename.c_str(), GetLastErrorMsg()); 395 filename.c_str(), GetLastErrorMsg());
396 return false; 396 return false;
397 } 397 }
@@ -404,7 +404,7 @@ bool CreateEmptyFile(const std::string &filename)
404// results into parentEntry. Returns the number of files+directories found 404// results into parentEntry. Returns the number of files+directories found
405u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) 405u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry)
406{ 406{
407 INFO_LOG(COMMON, "ScanDirectoryTree: directory %s", directory.c_str()); 407 LOG_TRACE(Common_Filesystem, "directory %s", directory.c_str());
408 // How many files + directories we found 408 // How many files + directories we found
409 u32 foundEntries = 0; 409 u32 foundEntries = 0;
410#ifdef _WIN32 410#ifdef _WIN32
@@ -474,7 +474,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry)
474// Deletes the given directory and anything under it. Returns true on success. 474// Deletes the given directory and anything under it. Returns true on success.
475bool DeleteDirRecursively(const std::string &directory) 475bool DeleteDirRecursively(const std::string &directory)
476{ 476{
477 INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory.c_str()); 477 LOG_TRACE(Common_Filesystem, "%s", directory.c_str());
478#ifdef _WIN32 478#ifdef _WIN32
479 // Find the first file in the directory. 479 // Find the first file in the directory.
480 WIN32_FIND_DATA ffd; 480 WIN32_FIND_DATA ffd;
@@ -588,7 +588,7 @@ std::string GetCurrentDir()
588 // Get the current working directory (getcwd uses malloc) 588 // Get the current working directory (getcwd uses malloc)
589 if (!(dir = __getcwd(nullptr, 0))) { 589 if (!(dir = __getcwd(nullptr, 0))) {
590 590
591 ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s", 591 LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: %s",
592 GetLastErrorMsg()); 592 GetLastErrorMsg());
593 return nullptr; 593 return nullptr;
594 } 594 }
@@ -647,7 +647,7 @@ std::string GetSysDirectory()
647#endif 647#endif
648 sysDir += DIR_SEP; 648 sysDir += DIR_SEP;
649 649
650 INFO_LOG(COMMON, "GetSysDirectory: Setting to %s:", sysDir.c_str()); 650 LOG_DEBUG(Common_Filesystem, "Setting to %s:", sysDir.c_str());
651 return sysDir; 651 return sysDir;
652} 652}
653 653
@@ -695,7 +695,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
695 { 695 {
696 if (!FileUtil::IsDirectory(newPath)) 696 if (!FileUtil::IsDirectory(newPath))
697 { 697 {
698 WARN_LOG(COMMON, "Invalid path specified %s", newPath.c_str()); 698 LOG_ERROR(Common_Filesystem, "Invalid path specified %s", newPath.c_str());
699 return paths[DirIDX]; 699 return paths[DirIDX];
700 } 700 }
701 else 701 else
diff --git a/src/common/log.h b/src/common/log.h
index 78f0dae4d..663eda9ad 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -6,105 +6,7 @@
6 6
7#include "common/common_funcs.h" 7#include "common/common_funcs.h"
8#include "common/msg_handler.h" 8#include "common/msg_handler.h"
9 9#include "common/logging/log.h"
10#ifndef LOGGING
11#define LOGGING
12#endif
13
14enum {
15 OS_LEVEL, // Printed by the emulated operating system
16 NOTICE_LEVEL, // VERY important information that is NOT errors. Like startup and OSReports.
17 ERROR_LEVEL, // Critical errors
18 WARNING_LEVEL, // Something is suspicious.
19 INFO_LEVEL, // General information.
20 DEBUG_LEVEL, // Detailed debugging - might make things slow.
21};
22
23namespace LogTypes
24{
25
26enum LOG_TYPE {
27 ACTIONREPLAY,
28 AUDIO,
29 AUDIO_INTERFACE,
30 BOOT,
31 COMMANDPROCESSOR,
32 COMMON,
33 CONSOLE,
34 CONFIG,
35 DISCIO,
36 FILEMON,
37 DSPHLE,
38 DSPLLE,
39 DSP_MAIL,
40 DSPINTERFACE,
41 DVDINTERFACE,
42 DYNA_REC,
43 EXPANSIONINTERFACE,
44 GDB_STUB,
45 ARM11,
46 GSP,
47 OSHLE,
48 MASTER_LOG,
49 MEMMAP,
50 MEMCARD_MANAGER,
51 OSREPORT,
52 PAD,
53 PROCESSORINTERFACE,
54 PIXELENGINE,
55 SERIALINTERFACE,
56 SP1,
57 STREAMINGINTERFACE,
58 VIDEO,
59 VIDEOINTERFACE,
60 LOADER,
61 FILESYS,
62 WII_IPC_DVD,
63 WII_IPC_ES,
64 WII_IPC_FILEIO,
65 WII_IPC_HID,
66 KERNEL,
67 SVC,
68 HLE,
69 RENDER,
70 GPU,
71 HW,
72 TIME,
73 NETPLAY,
74 GUI,
75
76 NUMBER_OF_LOGS // Must be last
77};
78
79// FIXME: should this be removed?
80enum LOG_LEVELS {
81 LOS = OS_LEVEL,
82 LNOTICE = NOTICE_LEVEL,
83 LERROR = ERROR_LEVEL,
84 LWARNING = WARNING_LEVEL,
85 LINFO = INFO_LEVEL,
86 LDEBUG = DEBUG_LEVEL,
87};
88
89#define LOGTYPES_LEVELS LogTypes::LOG_LEVELS
90#define LOGTYPES_TYPE LogTypes::LOG_TYPE
91
92} // namespace
93
94void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int line,
95 const char* function, const char* fmt, ...)
96#ifdef __GNUC__
97 __attribute__((format(printf, 6, 7)))
98#endif
99 ;
100
101#if defined LOGGING || defined _DEBUG || defined DEBUGFAST
102#define MAX_LOGLEVEL LDEBUG
103#else
104#ifndef MAX_LOGLEVEL
105#define MAX_LOGLEVEL LWARNING
106#endif // loglevel
107#endif // logging
108 10
109#ifdef _WIN32 11#ifdef _WIN32
110#ifndef __func__ 12#ifndef __func__
@@ -112,29 +14,16 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int
112#endif 14#endif
113#endif 15#endif
114 16
115// Let the compiler optimize this out 17#if _DEBUG
116#define GENERIC_LOG(t, v, ...) { \
117 if (v <= LogTypes::MAX_LOGLEVEL) \
118 GenericLog(v, t, __FILE__, __LINE__, __func__, __VA_ARGS__); \
119 }
120
121#define OS_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LOS, __VA_ARGS__) } while (0)
122#define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (0)
123#define WARN_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } while (0)
124#define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (0)
125#define INFO_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } while (0)
126#define DEBUG_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } while (0)
127
128#if MAX_LOGLEVEL >= DEBUG_LEVEL
129#define _dbg_assert_(_t_, _a_) \ 18#define _dbg_assert_(_t_, _a_) \
130 if (!(_a_)) {\ 19 if (!(_a_)) {\
131 ERROR_LOG(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \ 20 LOG_CRITICAL(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \
132 __LINE__, __FILE__, __TIME__); \ 21 __LINE__, __FILE__, __TIME__); \
133 if (!PanicYesNo("*** Assertion (see log)***\n")) {Crash();} \ 22 if (!PanicYesNo("*** Assertion (see log)***\n")) {Crash();} \
134 } 23 }
135#define _dbg_assert_msg_(_t_, _a_, ...)\ 24#define _dbg_assert_msg_(_t_, _a_, ...)\
136 if (!(_a_)) {\ 25 if (!(_a_)) {\
137 ERROR_LOG(_t_, __VA_ARGS__); \ 26 LOG_CRITICAL(_t_, __VA_ARGS__); \
138 if (!PanicYesNo(__VA_ARGS__)) {Crash();} \ 27 if (!PanicYesNo(__VA_ARGS__)) {Crash();} \
139 } 28 }
140#define _dbg_update_() Host_UpdateLogDisplay(); 29#define _dbg_update_() Host_UpdateLogDisplay();
@@ -146,11 +35,10 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int
146#define _dbg_assert_(_t_, _a_) {} 35#define _dbg_assert_(_t_, _a_) {}
147#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) {} 36#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) {}
148#endif // dbg_assert 37#endif // dbg_assert
149#endif // MAX_LOGLEVEL DEBUG 38#endif
150 39
151#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_) 40#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
152 41
153#ifndef GEKKO
154#ifdef _WIN32 42#ifdef _WIN32
155#define _assert_msg_(_t_, _a_, _fmt_, ...) \ 43#define _assert_msg_(_t_, _a_, _fmt_, ...) \
156 if (!(_a_)) {\ 44 if (!(_a_)) {\
@@ -162,6 +50,3 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int
162 if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \ 50 if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \
163 } 51 }
164#endif // WIN32 52#endif // WIN32
165#else // GEKKO
166#define _assert_msg_(_t_, _a_, _fmt_, ...)
167#endif
diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp
deleted file mode 100644
index 128c15388..000000000
--- a/src/common/log_manager.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
1// Copyright 2013 Dolphin Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include <algorithm>
6
7#include "common/log_manager.h"
8#include "common/console_listener.h"
9#include "common/timer.h"
10
11void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
12 const char* function, const char* fmt, ...)
13{
14 va_list args;
15 va_start(args, fmt);
16
17 if (LogManager::GetInstance()) {
18 LogManager::GetInstance()->Log(level, type,
19 file, line, function, fmt, args);
20 }
21 va_end(args);
22}
23
24LogManager *LogManager::m_logManager = nullptr;
25
26LogManager::LogManager()
27{
28 // create log files
29 m_Log[LogTypes::MASTER_LOG] = new LogContainer("*", "Master Log");
30 m_Log[LogTypes::BOOT] = new LogContainer("BOOT", "Boot");
31 m_Log[LogTypes::COMMON] = new LogContainer("COMMON", "Common");
32 m_Log[LogTypes::CONFIG] = new LogContainer("CONFIG", "Configuration");
33 m_Log[LogTypes::DISCIO] = new LogContainer("DIO", "Disc IO");
34 m_Log[LogTypes::FILEMON] = new LogContainer("FileMon", "File Monitor");
35 m_Log[LogTypes::PAD] = new LogContainer("PAD", "Pad");
36 m_Log[LogTypes::PIXELENGINE] = new LogContainer("PE", "PixelEngine");
37 m_Log[LogTypes::COMMANDPROCESSOR] = new LogContainer("CP", "CommandProc");
38 m_Log[LogTypes::VIDEOINTERFACE] = new LogContainer("VI", "VideoInt");
39 m_Log[LogTypes::SERIALINTERFACE] = new LogContainer("SI", "SerialInt");
40 m_Log[LogTypes::PROCESSORINTERFACE] = new LogContainer("PI", "ProcessorInt");
41 m_Log[LogTypes::MEMMAP] = new LogContainer("MI", "MI & memmap");
42 m_Log[LogTypes::SP1] = new LogContainer("SP1", "Serial Port 1");
43 m_Log[LogTypes::STREAMINGINTERFACE] = new LogContainer("Stream", "StreamingInt");
44 m_Log[LogTypes::DSPINTERFACE] = new LogContainer("DSP", "DSPInterface");
45 m_Log[LogTypes::DVDINTERFACE] = new LogContainer("DVD", "DVDInterface");
46 m_Log[LogTypes::GSP] = new LogContainer("GSP", "GSP");
47 m_Log[LogTypes::EXPANSIONINTERFACE] = new LogContainer("EXI", "ExpansionInt");
48 m_Log[LogTypes::GDB_STUB] = new LogContainer("GDB_STUB", "GDB Stub");
49 m_Log[LogTypes::AUDIO_INTERFACE] = new LogContainer("AI", "AudioInt");
50 m_Log[LogTypes::ARM11] = new LogContainer("ARM11", "ARM11");
51 m_Log[LogTypes::OSHLE] = new LogContainer("HLE", "HLE");
52 m_Log[LogTypes::DSPHLE] = new LogContainer("DSPHLE", "DSP HLE");
53 m_Log[LogTypes::DSPLLE] = new LogContainer("DSPLLE", "DSP LLE");
54 m_Log[LogTypes::DSP_MAIL] = new LogContainer("DSPMails", "DSP Mails");
55 m_Log[LogTypes::VIDEO] = new LogContainer("Video", "Video Backend");
56 m_Log[LogTypes::AUDIO] = new LogContainer("Audio", "Audio Emulator");
57 m_Log[LogTypes::DYNA_REC] = new LogContainer("JIT", "JIT");
58 m_Log[LogTypes::CONSOLE] = new LogContainer("CONSOLE", "Dolphin Console");
59 m_Log[LogTypes::OSREPORT] = new LogContainer("OSREPORT", "OSReport");
60 m_Log[LogTypes::TIME] = new LogContainer("Time", "Core Timing");
61 m_Log[LogTypes::LOADER] = new LogContainer("Loader", "Loader");
62 m_Log[LogTypes::FILESYS] = new LogContainer("FileSys", "File System");
63 m_Log[LogTypes::WII_IPC_HID] = new LogContainer("WII_IPC_HID", "WII IPC HID");
64 m_Log[LogTypes::KERNEL] = new LogContainer("KERNEL", "KERNEL HLE");
65 m_Log[LogTypes::WII_IPC_DVD] = new LogContainer("WII_IPC_DVD", "WII IPC DVD");
66 m_Log[LogTypes::WII_IPC_ES] = new LogContainer("WII_IPC_ES", "WII IPC ES");
67 m_Log[LogTypes::WII_IPC_FILEIO] = new LogContainer("WII_IPC_FILEIO", "WII IPC FILEIO");
68 m_Log[LogTypes::RENDER] = new LogContainer("RENDER", "RENDER");
69 m_Log[LogTypes::GPU] = new LogContainer("GPU", "GPU");
70 m_Log[LogTypes::SVC] = new LogContainer("SVC", "Supervisor Call HLE");
71 m_Log[LogTypes::HLE] = new LogContainer("HLE", "High Level Emulation");
72 m_Log[LogTypes::HW] = new LogContainer("HW", "Hardware");
73 m_Log[LogTypes::ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay");
74 m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager");
75 m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay");
76 m_Log[LogTypes::GUI] = new LogContainer("GUI", "GUI");
77
78 m_fileLog = new FileLogListener(FileUtil::GetUserPath(F_MAINLOG_IDX).c_str());
79 m_consoleLog = new ConsoleListener();
80 m_debuggerLog = new DebuggerLogListener();
81
82 for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
83 {
84 m_Log[i]->SetEnable(true);
85 m_Log[i]->AddListener(m_fileLog);
86 m_Log[i]->AddListener(m_consoleLog);
87#ifdef _MSC_VER
88 if (IsDebuggerPresent())
89 m_Log[i]->AddListener(m_debuggerLog);
90#endif
91 }
92
93 m_consoleLog->Open();
94}
95
96LogManager::~LogManager()
97{
98 for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
99 {
100 m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog);
101 m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_consoleLog);
102 m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog);
103 }
104
105 for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
106 delete m_Log[i];
107
108 delete m_fileLog;
109 delete m_consoleLog;
110 delete m_debuggerLog;
111}
112
113void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file,
114 int line, const char* function, const char *fmt, va_list args)
115{
116 char temp[MAX_MSGLEN];
117 char msg[MAX_MSGLEN * 2];
118 LogContainer *log = m_Log[type];
119
120 if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners())
121 return;
122
123 Common::CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args);
124
125 static const char level_to_char[7] = "ONEWID";
126 sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line,
127 level_to_char[(int)level], log->GetShortName(), function, temp);
128
129#ifdef ANDROID
130 Host_SysMessage(msg);
131#endif
132 log->Trigger(level, msg);
133}
134
135void LogManager::Init()
136{
137 m_logManager = new LogManager();
138}
139
140void LogManager::Shutdown()
141{
142 delete m_logManager;
143 m_logManager = nullptr;
144}
145
146LogContainer::LogContainer(const char* shortName, const char* fullName, bool enable)
147 : m_enable(enable)
148{
149 strncpy(m_fullName, fullName, 128);
150 strncpy(m_shortName, shortName, 32);
151 m_level = LogTypes::MAX_LOGLEVEL;
152}
153
154// LogContainer
155void LogContainer::AddListener(LogListener *listener)
156{
157 std::lock_guard<std::mutex> lk(m_listeners_lock);
158 m_listeners.insert(listener);
159}
160
161void LogContainer::RemoveListener(LogListener *listener)
162{
163 std::lock_guard<std::mutex> lk(m_listeners_lock);
164 m_listeners.erase(listener);
165}
166
167void LogContainer::Trigger(LogTypes::LOG_LEVELS level, const char *msg)
168{
169 std::lock_guard<std::mutex> lk(m_listeners_lock);
170
171 std::set<LogListener*>::const_iterator i;
172 for (i = m_listeners.begin(); i != m_listeners.end(); ++i)
173 {
174 (*i)->Log(level, msg);
175 }
176}
177
178FileLogListener::FileLogListener(const char *filename)
179{
180 OpenFStream(m_logfile, filename, std::ios::app);
181 SetEnable(true);
182}
183
184void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg)
185{
186 if (!IsEnabled() || !IsValid())
187 return;
188
189 std::lock_guard<std::mutex> lk(m_log_lock);
190 m_logfile << msg << std::flush;
191}
192
193void DebuggerLogListener::Log(LogTypes::LOG_LEVELS, const char *msg)
194{
195#if _MSC_VER
196 ::OutputDebugStringA(msg);
197#endif
198}
diff --git a/src/common/log_manager.h b/src/common/log_manager.h
deleted file mode 100644
index baefc4ba8..000000000
--- a/src/common/log_manager.h
+++ /dev/null
@@ -1,166 +0,0 @@
1// Copyright 2013 Dolphin Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/log.h"
8#include "common/string_util.h"
9#include "common/file_util.h"
10
11#include <cstring>
12#include <set>
13#include <mutex>
14
15#define MAX_MESSAGES 8000
16#define MAX_MSGLEN 1024
17
18
19// pure virtual interface
20class LogListener
21{
22public:
23 virtual ~LogListener() {}
24
25 virtual void Log(LogTypes::LOG_LEVELS, const char *msg) = 0;
26};
27
28class FileLogListener : public LogListener
29{
30public:
31 FileLogListener(const char *filename);
32
33 void Log(LogTypes::LOG_LEVELS, const char *msg) override;
34
35 bool IsValid() { return !m_logfile.fail(); }
36 bool IsEnabled() const { return m_enable; }
37 void SetEnable(bool enable) { m_enable = enable; }
38
39 const char* GetName() const { return "file"; }
40
41private:
42 std::mutex m_log_lock;
43 std::ofstream m_logfile;
44 bool m_enable;
45};
46
47class DebuggerLogListener : public LogListener
48{
49public:
50 void Log(LogTypes::LOG_LEVELS, const char *msg) override;
51};
52
53class LogContainer
54{
55public:
56 LogContainer(const char* shortName, const char* fullName, bool enable = false);
57
58 const char* GetShortName() const { return m_shortName; }
59 const char* GetFullName() const { return m_fullName; }
60
61 void AddListener(LogListener* listener);
62 void RemoveListener(LogListener* listener);
63
64 void Trigger(LogTypes::LOG_LEVELS, const char *msg);
65
66 bool IsEnabled() const { return m_enable; }
67 void SetEnable(bool enable) { m_enable = enable; }
68
69 LogTypes::LOG_LEVELS GetLevel() const { return m_level; }
70
71 void SetLevel(LogTypes::LOG_LEVELS level) { m_level = level; }
72
73 bool HasListeners() const { return !m_listeners.empty(); }
74
75private:
76 char m_fullName[128];
77 char m_shortName[32];
78 bool m_enable;
79 LogTypes::LOG_LEVELS m_level;
80 std::mutex m_listeners_lock;
81 std::set<LogListener*> m_listeners;
82};
83
84class ConsoleListener;
85
86class LogManager : NonCopyable
87{
88private:
89 LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS];
90 FileLogListener *m_fileLog;
91 ConsoleListener *m_consoleLog;
92 DebuggerLogListener *m_debuggerLog;
93 static LogManager *m_logManager; // Singleton. Ugh.
94
95 LogManager();
96 ~LogManager();
97public:
98
99 static u32 GetMaxLevel() { return LogTypes::MAX_LOGLEVEL; }
100
101 void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
102 const char* function, const char *fmt, va_list args);
103
104 void SetLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level)
105 {
106 m_Log[type]->SetLevel(level);
107 }
108
109 void SetEnable(LogTypes::LOG_TYPE type, bool enable)
110 {
111 m_Log[type]->SetEnable(enable);
112 }
113
114 bool IsEnabled(LogTypes::LOG_TYPE type) const
115 {
116 return m_Log[type]->IsEnabled();
117 }
118
119 const char* GetShortName(LogTypes::LOG_TYPE type) const
120 {
121 return m_Log[type]->GetShortName();
122 }
123
124 const char* GetFullName(LogTypes::LOG_TYPE type) const
125 {
126 return m_Log[type]->GetFullName();
127 }
128
129 void AddListener(LogTypes::LOG_TYPE type, LogListener *listener)
130 {
131 m_Log[type]->AddListener(listener);
132 }
133
134 void RemoveListener(LogTypes::LOG_TYPE type, LogListener *listener)
135 {
136 m_Log[type]->RemoveListener(listener);
137 }
138
139 FileLogListener *GetFileListener() const
140 {
141 return m_fileLog;
142 }
143
144 ConsoleListener *GetConsoleListener() const
145 {
146 return m_consoleLog;
147 }
148
149 DebuggerLogListener *GetDebuggerListener() const
150 {
151 return m_debuggerLog;
152 }
153
154 static LogManager* GetInstance()
155 {
156 return m_logManager;
157 }
158
159 static void SetInstance(LogManager *logManager)
160 {
161 m_logManager = logManager;
162 }
163
164 static void Init();
165 static void Shutdown();
166};
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
new file mode 100644
index 000000000..e79b84604
--- /dev/null
+++ b/src/common/logging/backend.cpp
@@ -0,0 +1,151 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#include <algorithm>
6
7#include "common/log.h" // For _dbg_assert_
8
9#include "common/logging/backend.h"
10#include "common/logging/log.h"
11#include "common/logging/text_formatter.h"
12
13namespace Log {
14
15static std::shared_ptr<Logger> global_logger;
16
17/// Macro listing all log classes. Code should define CLS and SUB as desired before invoking this.
18#define ALL_LOG_CLASSES() \
19 CLS(Log) \
20 CLS(Common) \
21 SUB(Common, Filesystem) \
22 SUB(Common, Memory) \
23 CLS(Core) \
24 SUB(Core, ARM11) \
25 CLS(Config) \
26 CLS(Debug) \
27 SUB(Debug, Emulated) \
28 SUB(Debug, GPU) \
29 SUB(Debug, Breakpoint) \
30 CLS(Kernel) \
31 SUB(Kernel, SVC) \
32 CLS(Service) \
33 SUB(Service, SRV) \
34 SUB(Service, FS) \
35 SUB(Service, APT) \
36 SUB(Service, GSP) \
37 SUB(Service, AC) \
38 SUB(Service, PTM) \
39 SUB(Service, CFG) \
40 SUB(Service, DSP) \
41 SUB(Service, HID) \
42 CLS(HW) \
43 SUB(HW, Memory) \
44 SUB(HW, GPU) \
45 CLS(Frontend) \
46 CLS(Render) \
47 SUB(Render, Software) \
48 SUB(Render, OpenGL) \
49 CLS(Loader)
50
51Logger::Logger() {
52 // Register logging classes so that they can be queried at runtime
53 size_t parent_class;
54 all_classes.reserve((size_t)Class::Count);
55
56#define CLS(x) \
57 all_classes.push_back(Class::x); \
58 parent_class = all_classes.size() - 1;
59#define SUB(x, y) \
60 all_classes.push_back(Class::x##_##y); \
61 all_classes[parent_class].num_children += 1;
62
63 ALL_LOG_CLASSES()
64#undef CLS
65#undef SUB
66
67 // Ensures that ALL_LOG_CLASSES isn't missing any entries.
68 _dbg_assert_(Log, all_classes.size() == (size_t)Class::Count);
69}
70
71// GetClassName is a macro defined by Windows.h, grrr...
72const char* Logger::GetLogClassName(Class log_class) {
73 switch (log_class) {
74#define CLS(x) case Class::x: return #x;
75#define SUB(x, y) case Class::x##_##y: return #x "." #y;
76 ALL_LOG_CLASSES()
77#undef CLS
78#undef SUB
79 }
80 return "Unknown";
81}
82
83const char* Logger::GetLevelName(Level log_level) {
84#define LVL(x) case Level::x: return #x
85 switch (log_level) {
86 LVL(Trace);
87 LVL(Debug);
88 LVL(Info);
89 LVL(Warning);
90 LVL(Error);
91 LVL(Critical);
92 }
93 return "Unknown";
94#undef LVL
95}
96
97void Logger::LogMessage(Entry entry) {
98 ring_buffer.Push(std::move(entry));
99}
100
101size_t Logger::GetEntries(Entry* out_buffer, size_t buffer_len) {
102 return ring_buffer.BlockingPop(out_buffer, buffer_len);
103}
104
105std::shared_ptr<Logger> InitGlobalLogger() {
106 global_logger = std::make_shared<Logger>();
107 return global_logger;
108}
109
110Entry CreateEntry(Class log_class, Level log_level,
111 const char* filename, unsigned int line_nr, const char* function,
112 const char* format, va_list args) {
113 using std::chrono::steady_clock;
114 using std::chrono::duration_cast;
115
116 static steady_clock::time_point time_origin = steady_clock::now();
117
118 std::array<char, 4 * 1024> formatting_buffer;
119
120 Entry entry;
121 entry.timestamp = duration_cast<std::chrono::microseconds>(steady_clock::now() - time_origin);
122 entry.log_class = log_class;
123 entry.log_level = log_level;
124
125 snprintf(formatting_buffer.data(), formatting_buffer.size(), "%s:%s:%u", filename, function, line_nr);
126 entry.location = std::string(formatting_buffer.data());
127
128 vsnprintf(formatting_buffer.data(), formatting_buffer.size(), format, args);
129 entry.message = std::string(formatting_buffer.data());
130
131 return std::move(entry);
132}
133
134void LogMessage(Class log_class, Level log_level,
135 const char* filename, unsigned int line_nr, const char* function,
136 const char* format, ...) {
137 va_list args;
138 va_start(args, format);
139 Entry entry = CreateEntry(log_class, log_level,
140 filename, line_nr, function, format, args);
141 va_end(args);
142
143 if (global_logger != nullptr && !global_logger->IsClosed()) {
144 global_logger->LogMessage(std::move(entry));
145 } else {
146 // Fall back to directly printing to stderr
147 PrintMessage(entry);
148 }
149}
150
151}
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h
new file mode 100644
index 000000000..ae270efe8
--- /dev/null
+++ b/src/common/logging/backend.h
@@ -0,0 +1,134 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <cstdarg>
8#include <memory>
9#include <vector>
10
11#include "common/concurrent_ring_buffer.h"
12
13#include "common/logging/log.h"
14
15namespace Log {
16
17/**
18 * A log entry. Log entries are store in a structured format to permit more varied output
19 * formatting on different frontends, as well as facilitating filtering and aggregation.
20 */
21struct Entry {
22 std::chrono::microseconds timestamp;
23 Class log_class;
24 Level log_level;
25 std::string location;
26 std::string message;
27
28 Entry() = default;
29
30 // TODO(yuriks) Use defaulted move constructors once MSVC supports them
31#define MOVE(member) member(std::move(o.member))
32 Entry(Entry&& o)
33 : MOVE(timestamp), MOVE(log_class), MOVE(log_level),
34 MOVE(location), MOVE(message)
35 {}
36#undef MOVE
37
38 Entry& operator=(const Entry&& o) {
39#define MOVE(member) member = std::move(o.member)
40 MOVE(timestamp);
41 MOVE(log_class);
42 MOVE(log_level);
43 MOVE(location);
44 MOVE(message);
45#undef MOVE
46 return *this;
47 }
48};
49
50struct ClassInfo {
51 Class log_class;
52
53 /**
54 * Total number of (direct or indirect) sub classes this class has. If any, they follow in
55 * sequence after this class in the class list.
56 */
57 unsigned int num_children = 0;
58
59 ClassInfo(Class log_class) : log_class(log_class) {}
60};
61
62/**
63 * Logging management class. This class has the dual purpose of acting as an exchange point between
64 * the logging clients and the log outputter, as well as containing reflection info about available
65 * log classes.
66 */
67class Logger {
68private:
69 using Buffer = Common::ConcurrentRingBuffer<Entry, 16 * 1024 / sizeof(Entry)>;
70
71public:
72 static const size_t QUEUE_CLOSED = Buffer::QUEUE_CLOSED;
73
74 Logger();
75
76 /**
77 * Returns a list of all vector classes and subclasses. The sequence returned is a pre-order of
78 * classes and subclasses, which together with the `num_children` field in ClassInfo, allows
79 * you to recover the hierarchy.
80 */
81 const std::vector<ClassInfo>& GetClasses() const { return all_classes; }
82
83 /**
84 * Returns the name of the passed log class as a C-string. Subclasses are separated by periods
85 * instead of underscores as in the enumeration.
86 */
87 static const char* GetLogClassName(Class log_class);
88
89 /**
90 * Returns the name of the passed log level as a C-string.
91 */
92 static const char* GetLevelName(Level log_level);
93
94 /**
95 * Appends a messages to the log buffer.
96 * @note This function is thread safe.
97 */
98 void LogMessage(Entry entry);
99
100 /**
101 * Retrieves a batch of messages from the log buffer, blocking until they are available.
102 * @note This function is thread safe.
103 *
104 * @param out_buffer Destination buffer that will receive the log entries.
105 * @param buffer_len The maximum size of `out_buffer`.
106 * @return The number of entries stored. In case the logger is shutting down, `QUEUE_CLOSED` is
107 * returned, no entries are stored and the logger should shutdown.
108 */
109 size_t GetEntries(Entry* out_buffer, size_t buffer_len);
110
111 /**
112 * Initiates a shutdown of the logger. This will indicate to log output clients that they
113 * should shutdown.
114 */
115 void Close() { ring_buffer.Close(); }
116
117 /**
118 * Returns true if Close() has already been called on the Logger.
119 */
120 bool IsClosed() const { return ring_buffer.IsClosed(); }
121
122private:
123 Buffer ring_buffer;
124 std::vector<ClassInfo> all_classes;
125};
126
127/// Creates a log entry by formatting the given source location, and message.
128Entry CreateEntry(Class log_class, Level log_level,
129 const char* filename, unsigned int line_nr, const char* function,
130 const char* format, va_list args);
131/// Initializes the default Logger.
132std::shared_ptr<Logger> InitGlobalLogger();
133
134}
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
new file mode 100644
index 000000000..0cf9b05e7
--- /dev/null
+++ b/src/common/logging/filter.cpp
@@ -0,0 +1,132 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#include <algorithm>
6
7#include "common/logging/filter.h"
8#include "common/logging/backend.h"
9#include "common/string_util.h"
10
11namespace Log {
12
13Filter::Filter(Level default_level) {
14 ResetAll(default_level);
15}
16
17void Filter::ResetAll(Level level) {
18 class_levels.fill(level);
19}
20
21void Filter::SetClassLevel(Class log_class, Level level) {
22 class_levels[static_cast<size_t>(log_class)] = level;
23}
24
25void Filter::SetSubclassesLevel(const ClassInfo& log_class, Level level) {
26 const size_t log_class_i = static_cast<size_t>(log_class.log_class);
27
28 const size_t begin = log_class_i + 1;
29 const size_t end = begin + log_class.num_children;
30 for (size_t i = begin; begin < end; ++i) {
31 class_levels[i] = level;
32 }
33}
34
35void Filter::ParseFilterString(const std::string& filter_str) {
36 auto clause_begin = filter_str.cbegin();
37 while (clause_begin != filter_str.cend()) {
38 auto clause_end = std::find(clause_begin, filter_str.cend(), ' ');
39
40 // If clause isn't empty
41 if (clause_end != clause_begin) {
42 ParseFilterRule(clause_begin, clause_end);
43 }
44
45 if (clause_end != filter_str.cend()) {
46 // Skip over the whitespace
47 ++clause_end;
48 }
49 clause_begin = clause_end;
50 }
51}
52
53template <typename It>
54static Level GetLevelByName(const It begin, const It end) {
55 for (u8 i = 0; i < static_cast<u8>(Level::Count); ++i) {
56 const char* level_name = Logger::GetLevelName(static_cast<Level>(i));
57 if (Common::ComparePartialString(begin, end, level_name)) {
58 return static_cast<Level>(i);
59 }
60 }
61 return Level::Count;
62}
63
64template <typename It>
65static Class GetClassByName(const It begin, const It end) {
66 for (ClassType i = 0; i < static_cast<ClassType>(Class::Count); ++i) {
67 const char* level_name = Logger::GetLogClassName(static_cast<Class>(i));
68 if (Common::ComparePartialString(begin, end, level_name)) {
69 return static_cast<Class>(i);
70 }
71 }
72 return Class::Count;
73}
74
75template <typename InputIt, typename T>
76static InputIt find_last(InputIt begin, const InputIt end, const T& value) {
77 auto match = end;
78 while (begin != end) {
79 auto new_match = std::find(begin, end, value);
80 if (new_match != end) {
81 match = new_match;
82 ++new_match;
83 }
84 begin = new_match;
85 }
86 return match;
87}
88
89bool Filter::ParseFilterRule(const std::string::const_iterator begin,
90 const std::string::const_iterator end) {
91 auto level_separator = std::find(begin, end, ':');
92 if (level_separator == end) {
93 LOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: %s",
94 std::string(begin, end).c_str());
95 return false;
96 }
97
98 const Level level = GetLevelByName(level_separator + 1, end);
99 if (level == Level::Count) {
100 LOG_ERROR(Log, "Unknown log level in filter: %s", std::string(begin, end).c_str());
101 return false;
102 }
103
104 if (Common::ComparePartialString(begin, level_separator, "*")) {
105 ResetAll(level);
106 return true;
107 }
108
109 auto class_name_end = find_last(begin, level_separator, '.');
110 if (class_name_end != level_separator &&
111 !Common::ComparePartialString(class_name_end + 1, level_separator, "*")) {
112 class_name_end = level_separator;
113 }
114
115 const Class log_class = GetClassByName(begin, class_name_end);
116 if (log_class == Class::Count) {
117 LOG_ERROR(Log, "Unknown log class in filter: %s", std::string(begin, end).c_str());
118 return false;
119 }
120
121 if (class_name_end == level_separator) {
122 SetClassLevel(log_class, level);
123 }
124 SetSubclassesLevel(log_class, level);
125 return true;
126}
127
128bool Filter::CheckMessage(Class log_class, Level level) const {
129 return static_cast<u8>(level) >= static_cast<u8>(class_levels[static_cast<size_t>(log_class)]);
130}
131
132}
diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h
new file mode 100644
index 000000000..32b14b159
--- /dev/null
+++ b/src/common/logging/filter.h
@@ -0,0 +1,63 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#include <array>
6#include <string>
7
8#include "common/logging/log.h"
9
10namespace Log {
11
12struct ClassInfo;
13
14/**
15 * Implements a log message filter which allows different log classes to have different minimum
16 * severity levels. The filter can be changed at runtime and can be parsed from a string to allow
17 * editing via the interface or loading from a configuration file.
18 */
19class Filter {
20public:
21 /// Initializes the filter with all classes having `default_level` as the minimum level.
22 Filter(Level default_level);
23
24 /// Resets the filter so that all classes have `level` as the minimum displayed level.
25 void ResetAll(Level level);
26 /// Sets the minimum level of `log_class` (and not of its subclasses) to `level`.
27 void SetClassLevel(Class log_class, Level level);
28 /**
29 * Sets the minimum level of all of `log_class` subclasses to `level`. The level of `log_class`
30 * itself is not changed.
31 */
32 void SetSubclassesLevel(const ClassInfo& log_class, Level level);
33
34 /**
35 * Parses a filter string and applies it to this filter.
36 *
37 * A filter string consists of a space-separated list of filter rules, each of the format
38 * `<class>:<level>`. `<class>` is a log class name, with subclasses separated using periods.
39 * A rule for a given class also affects all of its subclasses. `*` wildcards are allowed and
40 * can be used to apply a rule to all classes or to all subclasses of a class without affecting
41 * the parent class. `<level>` a severity level name which will be set as the minimum logging
42 * level of the matched classes. Rules are applied left to right, with each rule overriding
43 * previous ones in the sequence.
44 *
45 * A few examples of filter rules:
46 * - `*:Info` -- Resets the level of all classes to Info.
47 * - `Service:Info` -- Sets the level of Service and all subclasses (Service.FS, Service.APT,
48 * etc.) to Info.
49 * - `Service.*:Debug` -- Sets the level of all Service subclasses to Debug, while leaving the
50 * level of Service unchanged.
51 * - `Service.FS:Trace` -- Sets the level of the Service.FS class to Trace.
52 */
53 void ParseFilterString(const std::string& filter_str);
54 bool ParseFilterRule(const std::string::const_iterator start, const std::string::const_iterator end);
55
56 /// Matches class/level combination against the filter, returning true if it passed.
57 bool CheckMessage(Class log_class, Level level) const;
58
59private:
60 std::array<Level, (size_t)Class::Count> class_levels;
61};
62
63}
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
new file mode 100644
index 000000000..1eec34fbb
--- /dev/null
+++ b/src/common/logging/log.h
@@ -0,0 +1,115 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <cassert>
8#include <chrono>
9#include <string>
10
11#include "common/common_types.h"
12
13namespace Log {
14
15/// Specifies the severity or level of detail of the log message.
16enum class Level : u8 {
17 Trace, ///< Extremely detailed and repetitive debugging information that is likely to
18 /// pollute logs.
19 Debug, ///< Less detailed debugging information.
20 Info, ///< Status information from important points during execution.
21 Warning, ///< Minor or potential problems found during execution of a task.
22 Error, ///< Major problems found during execution of a task that prevent it from being
23 /// completed.
24 Critical, ///< Major problems during execution that threathen the stability of the entire
25 /// application.
26
27 Count ///< Total number of logging levels
28};
29
30typedef u8 ClassType;
31
32/**
33 * Specifies the sub-system that generated the log message.
34 *
35 * @note If you add a new entry here, also add a corresponding one to `ALL_LOG_CLASSES` in log.cpp.
36 */
37enum class Class : ClassType {
38 Log, ///< Messages about the log system itself
39 Common, ///< Library routines
40 Common_Filesystem, ///< Filesystem interface library
41 Common_Memory, ///< Memory mapping and management functions
42 Core, ///< LLE emulation core
43 Core_ARM11, ///< ARM11 CPU core
44 Config, ///< Emulator configuration (including commandline)
45 Debug, ///< Debugging tools
46 Debug_Emulated, ///< Debug messages from the emulated programs
47 Debug_GPU, ///< GPU debugging tools
48 Debug_Breakpoint, ///< Logging breakpoints and watchpoints
49 Kernel, ///< The HLE implementation of the CTR kernel
50 Kernel_SVC, ///< Kernel system calls
51 Service, ///< HLE implementation of system services. Each major service
52 /// should have its own subclass.
53 Service_SRV, ///< The SRV (Service Directory) implementation
54 Service_FS, ///< The FS (Filesystem) service implementation
55 Service_APT, ///< The APT (Applets) service
56 Service_GSP, ///< The GSP (GPU control) service
57 Service_AC, ///< The AC (WiFi status) service
58 Service_PTM, ///< The PTM (Power status & misc.) service
59 Service_CFG, ///< The CFG (Configuration) service
60 Service_DSP, ///< The DSP (DSP control) service
61 Service_HID, ///< The HID (User input) service
62 HW, ///< Low-level hardware emulation
63 HW_Memory, ///< Memory-map and address translation
64 HW_GPU, ///< GPU control emulation
65 Frontend, ///< Emulator UI
66 Render, ///< Emulator video output and hardware acceleration
67 Render_Software, ///< Software renderer backend
68 Render_OpenGL, ///< OpenGL backend
69 Loader, ///< ROM loader
70
71 Count ///< Total number of logging classes
72};
73
74/**
75 * Level below which messages are simply discarded without buffering regardless of the display
76 * settings.
77 */
78const Level MINIMUM_LEVEL =
79#ifdef _DEBUG
80 Level::Trace;
81#else
82 Level::Debug;
83#endif
84
85/**
86 * Logs a message to the global logger. This proxy exists to avoid exposing the details of the
87 * Logger class, including the ConcurrentRingBuffer template, to all files that desire to log
88 * messages, reducing unecessary recompilations.
89 */
90void LogMessage(Class log_class, Level log_level,
91 const char* filename, unsigned int line_nr, const char* function,
92#ifdef _MSC_VER
93 _Printf_format_string_
94#endif
95 const char* format, ...)
96#ifdef __GNUC__
97 __attribute__((format(printf, 6, 7)))
98#endif
99 ;
100
101} // namespace Log
102
103#define LOG_GENERIC(log_class, log_level, ...) \
104 do { \
105 if (::Log::Level::log_level >= ::Log::MINIMUM_LEVEL) \
106 ::Log::LogMessage(::Log::Class::log_class, ::Log::Level::log_level, \
107 __FILE__, __LINE__, __func__, __VA_ARGS__); \
108 } while (0)
109
110#define LOG_TRACE( log_class, ...) LOG_GENERIC(log_class, Trace, __VA_ARGS__)
111#define LOG_DEBUG( log_class, ...) LOG_GENERIC(log_class, Debug, __VA_ARGS__)
112#define LOG_INFO( log_class, ...) LOG_GENERIC(log_class, Info, __VA_ARGS__)
113#define LOG_WARNING( log_class, ...) LOG_GENERIC(log_class, Warning, __VA_ARGS__)
114#define LOG_ERROR( log_class, ...) LOG_GENERIC(log_class, Error, __VA_ARGS__)
115#define LOG_CRITICAL(log_class, ...) LOG_GENERIC(log_class, Critical, __VA_ARGS__)
diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp
new file mode 100644
index 000000000..3fe435346
--- /dev/null
+++ b/src/common/logging/text_formatter.cpp
@@ -0,0 +1,126 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#include <array>
6#include <cstdio>
7
8#ifdef _WIN32
9# define WIN32_LEAN_AND_MEAN
10# include <Windows.h>
11#endif
12
13#include "common/logging/backend.h"
14#include "common/logging/filter.h"
15#include "common/logging/log.h"
16#include "common/logging/text_formatter.h"
17
18#include "common/string_util.h"
19
20namespace Log {
21
22// TODO(bunnei): This should be moved to a generic path manipulation library
23const char* TrimSourcePath(const char* path, const char* root) {
24 const char* p = path;
25
26 while (*p != '\0') {
27 const char* next_slash = p;
28 while (*next_slash != '\0' && *next_slash != '/' && *next_slash != '\\') {
29 ++next_slash;
30 }
31
32 bool is_src = Common::ComparePartialString(p, next_slash, root);
33 p = next_slash;
34
35 if (*p != '\0') {
36 ++p;
37 }
38 if (is_src) {
39 path = p;
40 }
41 }
42 return path;
43}
44
45void FormatLogMessage(const Entry& entry, char* out_text, size_t text_len) {
46 unsigned int time_seconds = static_cast<unsigned int>(entry.timestamp.count() / 1000000);
47 unsigned int time_fractional = static_cast<unsigned int>(entry.timestamp.count() % 1000000);
48
49 const char* class_name = Logger::GetLogClassName(entry.log_class);
50 const char* level_name = Logger::GetLevelName(entry.log_level);
51
52 snprintf(out_text, text_len, "[%4u.%06u] %s <%s> %s: %s",
53 time_seconds, time_fractional, class_name, level_name,
54 TrimSourcePath(entry.location.c_str()), entry.message.c_str());
55}
56
57static void ChangeConsoleColor(Level level) {
58#ifdef _WIN32
59 static HANDLE console_handle = GetStdHandle(STD_ERROR_HANDLE);
60
61 WORD color = 0;
62 switch (level) {
63 case Level::Trace: // Grey
64 color = FOREGROUND_INTENSITY; break;
65 case Level::Debug: // Cyan
66 color = FOREGROUND_GREEN | FOREGROUND_BLUE; break;
67 case Level::Info: // Bright gray
68 color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
69 case Level::Warning: // Bright yellow
70 color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; break;
71 case Level::Error: // Bright red
72 color = FOREGROUND_RED | FOREGROUND_INTENSITY; break;
73 case Level::Critical: // Bright magenta
74 color = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break;
75 }
76
77 SetConsoleTextAttribute(console_handle, color);
78#else
79#define ESC "\x1b"
80 const char* color = "";
81 switch (level) {
82 case Level::Trace: // Grey
83 color = ESC "[1;30m"; break;
84 case Level::Debug: // Cyan
85 color = ESC "[0;36m"; break;
86 case Level::Info: // Bright gray
87 color = ESC "[0;37m"; break;
88 case Level::Warning: // Bright yellow
89 color = ESC "[1;33m"; break;
90 case Level::Error: // Bright red
91 color = ESC "[1;31m"; break;
92 case Level::Critical: // Bright magenta
93 color = ESC "[1;35m"; break;
94 }
95#undef ESC
96
97 fputs(color, stderr);
98#endif
99}
100
101void PrintMessage(const Entry& entry) {
102 ChangeConsoleColor(entry.log_level);
103 std::array<char, 4 * 1024> format_buffer;
104 FormatLogMessage(entry, format_buffer.data(), format_buffer.size());
105 fputs(format_buffer.data(), stderr);
106 fputc('\n', stderr);
107}
108
109void TextLoggingLoop(std::shared_ptr<Logger> logger, const Filter* filter) {
110 std::array<Entry, 256> entry_buffer;
111
112 while (true) {
113 size_t num_entries = logger->GetEntries(entry_buffer.data(), entry_buffer.size());
114 if (num_entries == Logger::QUEUE_CLOSED) {
115 break;
116 }
117 for (size_t i = 0; i < num_entries; ++i) {
118 const Entry& entry = entry_buffer[i];
119 if (filter->CheckMessage(entry.log_class, entry.log_level)) {
120 PrintMessage(entry);
121 }
122 }
123 }
124}
125
126}
diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h
new file mode 100644
index 000000000..d7e298e28
--- /dev/null
+++ b/src/common/logging/text_formatter.h
@@ -0,0 +1,39 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <cstddef>
8#include <memory>
9
10namespace Log {
11
12class Logger;
13struct Entry;
14class Filter;
15
16/**
17 * Attempts to trim an arbitrary prefix from `path`, leaving only the part starting at `root`. It's
18 * intended to be used to strip a system-specific build directory from the `__FILE__` macro,
19 * leaving only the path relative to the sources root.
20 *
21 * @param path The input file path as a null-terminated string
22 * @param root The name of the root source directory as a null-terminated string. Path up to and
23 * including the last occurence of this name will be stripped
24 * @return A pointer to the same string passed as `path`, but starting at the trimmed portion
25 */
26const char* TrimSourcePath(const char* path, const char* root = "src");
27
28/// Formats a log entry into the provided text buffer.
29void FormatLogMessage(const Entry& entry, char* out_text, size_t text_len);
30/// Formats and prints a log entry to stderr.
31void PrintMessage(const Entry& entry);
32
33/**
34 * Logging loop that repeatedly reads messages from the provided logger and prints them to the
35 * console. It is the baseline barebones log outputter.
36 */
37void TextLoggingLoop(std::shared_ptr<Logger> logger, const Filter* filter);
38
39}
diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp
index 7d4fda0e2..9904d2472 100644
--- a/src/common/mem_arena.cpp
+++ b/src/common/mem_arena.cpp
@@ -71,7 +71,7 @@ int ashmem_create_region(const char *name, size_t size)
71 return fd; 71 return fd;
72 72
73error: 73error:
74 ERROR_LOG(MEMMAP, "NASTY ASHMEM ERROR: ret = %08x", ret); 74 LOG_ERROR(Common_Memory, "NASTY ASHMEM ERROR: ret = %08x", ret);
75 close(fd); 75 close(fd);
76 return ret; 76 return ret;
77} 77}
@@ -130,7 +130,7 @@ void MemArena::GrabLowMemSpace(size_t size)
130 // Note that it appears that ashmem is pinned by default, so no need to pin. 130 // Note that it appears that ashmem is pinned by default, so no need to pin.
131 if (fd < 0) 131 if (fd < 0)
132 { 132 {
133 ERROR_LOG(MEMMAP, "Failed to grab ashmem space of size: %08x errno: %d", (int)size, (int)(errno)); 133 LOG_ERROR(Common_Memory, "Failed to grab ashmem space of size: %08x errno: %d", (int)size, (int)(errno));
134 return; 134 return;
135 } 135 }
136#else 136#else
@@ -148,12 +148,12 @@ void MemArena::GrabLowMemSpace(size_t size)
148 } 148 }
149 else if (errno != EEXIST) 149 else if (errno != EEXIST)
150 { 150 {
151 ERROR_LOG(MEMMAP, "shm_open failed: %s", strerror(errno)); 151 LOG_ERROR(Common_Memory, "shm_open failed: %s", strerror(errno));
152 return; 152 return;
153 } 153 }
154 } 154 }
155 if (ftruncate(fd, size) < 0) 155 if (ftruncate(fd, size) < 0)
156 ERROR_LOG(MEMMAP, "Failed to allocate low memory space"); 156 LOG_ERROR(Common_Memory, "Failed to allocate low memory space");
157#endif 157#endif
158} 158}
159 159
@@ -197,7 +197,7 @@ void *MemArena::CreateView(s64 offset, size_t size, void *base)
197 197
198 if (retval == MAP_FAILED) 198 if (retval == MAP_FAILED)
199 { 199 {
200 NOTICE_LOG(MEMMAP, "mmap failed"); 200 LOG_ERROR(Common_Memory, "mmap failed");
201 return nullptr; 201 return nullptr;
202 } 202 }
203 return retval; 203 return retval;
@@ -423,7 +423,7 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
423 base = (u8 *)base_addr; 423 base = (u8 *)base_addr;
424 if (Memory_TryBase(base, views, num_views, flags, arena)) 424 if (Memory_TryBase(base, views, num_views, flags, arena))
425 { 425 {
426 INFO_LOG(MEMMAP, "Found valid memory base at %p after %i tries.", base, base_attempts); 426 LOG_DEBUG(Common_Memory, "Found valid memory base at %p after %i tries.", base, base_attempts);
427 base_attempts = 0; 427 base_attempts = 0;
428 break; 428 break;
429 } 429 }
@@ -442,7 +442,7 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
442 u8 *base = MemArena::Find4GBBase(); 442 u8 *base = MemArena::Find4GBBase();
443 if (!Memory_TryBase(base, views, num_views, flags, arena)) 443 if (!Memory_TryBase(base, views, num_views, flags, arena))
444 { 444 {
445 ERROR_LOG(MEMMAP, "MemoryMap_Setup: Failed finding a memory base."); 445 LOG_ERROR(Common_Memory, "MemoryMap_Setup: Failed finding a memory base.");
446 PanicAlert("MemoryMap_Setup: Failed finding a memory base."); 446 PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
447 return 0; 447 return 0;
448 } 448 }
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp
index 93da5500b..ca8a2a9e4 100644
--- a/src/common/memory_util.cpp
+++ b/src/common/memory_util.cpp
@@ -109,7 +109,7 @@ void* AllocateAlignedMemory(size_t size,size_t alignment)
109 ptr = memalign(alignment, size); 109 ptr = memalign(alignment, size);
110#else 110#else
111 if (posix_memalign(&ptr, alignment, size) != 0) 111 if (posix_memalign(&ptr, alignment, size) != 0)
112 ERROR_LOG(MEMMAP, "Failed to allocate aligned memory"); 112 LOG_ERROR(Common_Memory, "Failed to allocate aligned memory");
113#endif 113#endif
114#endif 114#endif
115 115
diff --git a/src/common/msg_handler.cpp b/src/common/msg_handler.cpp
index b3556aaa8..7ffedc45a 100644
--- a/src/common/msg_handler.cpp
+++ b/src/common/msg_handler.cpp
@@ -75,7 +75,7 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...)
75 Common::CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); 75 Common::CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args);
76 va_end(args); 76 va_end(args);
77 77
78 ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer); 78 LOG_INFO(Common, "%s: %s", caption.c_str(), buffer);
79 79
80 // Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored 80 // Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored
81 if (msg_handler && (AlertEnabled || Style == QUESTION || Style == CRITICAL)) 81 if (msg_handler && (AlertEnabled || Style == QUESTION || Style == CRITICAL))
diff --git a/src/common/scope_exit.h b/src/common/scope_exit.h
new file mode 100644
index 000000000..1d3e59319
--- /dev/null
+++ b/src/common/scope_exit.h
@@ -0,0 +1,37 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#pragma once
6
7namespace detail {
8 template <typename Func>
9 struct ScopeExitHelper {
10 explicit ScopeExitHelper(Func&& func) : func(std::move(func)) {}
11 ~ScopeExitHelper() { func(); }
12
13 Func func;
14 };
15
16 template <typename Func>
17 ScopeExitHelper<Func> ScopeExit(Func&& func) { return ScopeExitHelper<Func>(std::move(func)); }
18}
19
20/**
21 * This macro allows you to conveniently specify a block of code that will run on scope exit. Handy
22 * for doing ad-hoc clean-up tasks in a function with multiple returns.
23 *
24 * Example usage:
25 * \code
26 * const int saved_val = g_foo;
27 * g_foo = 55;
28 * SCOPE_EXIT({ g_foo = saved_val; });
29 *
30 * if (Bar()) {
31 * return 0;
32 * } else {
33 * return 20;
34 * }
35 * \endcode
36 */
37#define SCOPE_EXIT(body) auto scope_exit_helper_##__LINE__ = detail::ScopeExit([&]() body)
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 7a8274a91..6d9612fb5 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -107,7 +107,7 @@ std::string StringFromFormat(const char* format, ...)
107#else 107#else
108 va_start(args, format); 108 va_start(args, format);
109 if (vasprintf(&buf, format, args) < 0) 109 if (vasprintf(&buf, format, args) < 0)
110 ERROR_LOG(COMMON, "Unable to allocate memory for string"); 110 LOG_ERROR(Common, "Unable to allocate memory for string");
111 va_end(args); 111 va_end(args);
112 112
113 std::string temp = buf; 113 std::string temp = buf;
@@ -475,7 +475,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>&
475 iconv_t const conv_desc = iconv_open("UTF-8", fromcode); 475 iconv_t const conv_desc = iconv_open("UTF-8", fromcode);
476 if ((iconv_t)(-1) == conv_desc) 476 if ((iconv_t)(-1) == conv_desc)
477 { 477 {
478 ERROR_LOG(COMMON, "Iconv initialization failure [%s]: %s", fromcode, strerror(errno)); 478 LOG_ERROR(Common, "Iconv initialization failure [%s]: %s", fromcode, strerror(errno));
479 iconv_close(conv_desc); 479 iconv_close(conv_desc);
480 return {}; 480 return {};
481 } 481 }
@@ -510,7 +510,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>&
510 } 510 }
511 else 511 else
512 { 512 {
513 ERROR_LOG(COMMON, "iconv failure [%s]: %s", fromcode, strerror(errno)); 513 LOG_ERROR(Common, "iconv failure [%s]: %s", fromcode, strerror(errno));
514 break; 514 break;
515 } 515 }
516 } 516 }
@@ -531,7 +531,7 @@ std::u16string UTF8ToUTF16(const std::string& input)
531 iconv_t const conv_desc = iconv_open("UTF-16LE", "UTF-8"); 531 iconv_t const conv_desc = iconv_open("UTF-16LE", "UTF-8");
532 if ((iconv_t)(-1) == conv_desc) 532 if ((iconv_t)(-1) == conv_desc)
533 { 533 {
534 ERROR_LOG(COMMON, "Iconv initialization failure [UTF-8]: %s", strerror(errno)); 534 LOG_ERROR(Common, "Iconv initialization failure [UTF-8]: %s", strerror(errno));
535 iconv_close(conv_desc); 535 iconv_close(conv_desc);
536 return {}; 536 return {};
537 } 537 }
@@ -566,7 +566,7 @@ std::u16string UTF8ToUTF16(const std::string& input)
566 } 566 }
567 else 567 else
568 { 568 {
569 ERROR_LOG(COMMON, "iconv failure [UTF-8]: %s", strerror(errno)); 569 LOG_ERROR(Common, "iconv failure [UTF-8]: %s", strerror(errno));
570 break; 570 break;
571 } 571 }
572 } 572 }
diff --git a/src/common/string_util.h b/src/common/string_util.h
index ae5bbadad..7d75691b1 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -115,4 +115,19 @@ inline std::string UTF8ToTStr(const std::string& str)
115 115
116#endif 116#endif
117 117
118/**
119 * Compares the string defined by the range [`begin`, `end`) to the null-terminated C-string
120 * `other` for equality.
121 */
122template <typename InIt>
123bool ComparePartialString(InIt begin, InIt end, const char* other) {
124 for (; begin != end && *other != '\0'; ++begin, ++other) {
125 if (*begin != *other) {
126 return false;
127 }
128 }
129 // Only return true if both strings finished at the same point
130 return (begin == end) == (*other == '\0');
131}
132
118} 133}
diff --git a/src/common/thread.h b/src/common/thread.h
index be9b5cbe2..8c36d3f07 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -21,6 +21,7 @@
21//for gettimeofday and struct time(spec|val) 21//for gettimeofday and struct time(spec|val)
22#include <time.h> 22#include <time.h>
23#include <sys/time.h> 23#include <sys/time.h>
24#include <unistd.h>
24#endif 25#endif
25 26
26namespace Common 27namespace Common
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
index 233cd3e3a..68012bffd 100644
--- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
+++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
@@ -433,9 +433,7 @@ typedef struct _ldst_inst {
433 unsigned int inst; 433 unsigned int inst;
434 get_addr_fp_t get_addr; 434 get_addr_fp_t get_addr;
435} ldst_inst; 435} ldst_inst;
436#define DEBUG_MSG DEBUG_LOG(ARM11, "in %s %d\n", __FUNCTION__, __LINE__); \ 436#define DEBUG_MSG LOG_DEBUG(Core_ARM11, "inst is %x", inst); CITRA_IGNORE_EXIT(0)
437 DEBUG_LOG(ARM11, "inst is %x\n", inst); \
438 CITRA_IGNORE_EXIT(0)
439 437
440int CondPassed(arm_processor *cpu, unsigned int cond); 438int CondPassed(arm_processor *cpu, unsigned int cond);
441#define LnSWoUB(s) glue(LnSWoUB, s) 439#define LnSWoUB(s) glue(LnSWoUB, s)
@@ -1423,7 +1421,7 @@ inline void *AllocBuffer(unsigned int size)
1423 int start = top; 1421 int start = top;
1424 top += size; 1422 top += size;
1425 if (top > CACHE_BUFFER_SIZE) { 1423 if (top > CACHE_BUFFER_SIZE) {
1426 DEBUG_LOG(ARM11, "inst_buf is full\n"); 1424 LOG_ERROR(Core_ARM11, "inst_buf is full");
1427 CITRA_IGNORE_EXIT(-1); 1425 CITRA_IGNORE_EXIT(-1);
1428 } 1426 }
1429 return (void *)&inst_buf[start]; 1427 return (void *)&inst_buf[start];
@@ -1609,6 +1607,10 @@ get_addr_fp_t get_calc_addr_op(unsigned int inst)
1609#define CHECK_RM (inst_cream->Rm == 15) 1607#define CHECK_RM (inst_cream->Rm == 15)
1610#define CHECK_RS (inst_cream->Rs == 15) 1608#define CHECK_RS (inst_cream->Rs == 15)
1611 1609
1610#define UNIMPLEMENTED_INSTRUCTION(mnemonic) \
1611 LOG_ERROR(Core_ARM11, "unimplemented instruction: %s", mnemonic); \
1612 CITRA_IGNORE_EXIT(-1); \
1613 return nullptr;
1612 1614
1613ARM_INST_PTR INTERPRETER_TRANSLATE(adc)(unsigned int inst, int index) 1615ARM_INST_PTR INTERPRETER_TRANSLATE(adc)(unsigned int inst, int index)
1614{ 1616{
@@ -1723,7 +1725,7 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(bic)(unsigned int inst, int index)
1723 inst_base->br = INDIRECT_BRANCH; 1725 inst_base->br = INDIRECT_BRANCH;
1724 return inst_base; 1726 return inst_base;
1725} 1727}
1726ARM_INST_PTR INTERPRETER_TRANSLATE(bkpt)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 1728ARM_INST_PTR INTERPRETER_TRANSLATE(bkpt)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("BKPT"); }
1727ARM_INST_PTR INTERPRETER_TRANSLATE(blx)(unsigned int inst, int index) 1729ARM_INST_PTR INTERPRETER_TRANSLATE(blx)(unsigned int inst, int index)
1728{ 1730{
1729 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(blx_inst)); 1731 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(blx_inst));
@@ -1758,7 +1760,7 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(bx)(unsigned int inst, int index)
1758 1760
1759 return inst_base; 1761 return inst_base;
1760} 1762}
1761ARM_INST_PTR INTERPRETER_TRANSLATE(bxj)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 1763ARM_INST_PTR INTERPRETER_TRANSLATE(bxj)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("BXJ"); }
1762ARM_INST_PTR INTERPRETER_TRANSLATE(cdp)(unsigned int inst, int index){ 1764ARM_INST_PTR INTERPRETER_TRANSLATE(cdp)(unsigned int inst, int index){
1763 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(cdp_inst)); 1765 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(cdp_inst));
1764 cdp_inst *inst_cream = (cdp_inst *)inst_base->component; 1766 cdp_inst *inst_cream = (cdp_inst *)inst_base->component;
@@ -1775,7 +1777,7 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(cdp)(unsigned int inst, int index){
1775 inst_cream->opcode_1 = BITS(inst, 20, 23); 1777 inst_cream->opcode_1 = BITS(inst, 20, 23);
1776 inst_cream->inst = inst; 1778 inst_cream->inst = inst;
1777 1779
1778 DEBUG_LOG(ARM11, "in func %s inst %x index %x\n", __FUNCTION__, inst, index); 1780 LOG_TRACE(Core_ARM11, "inst %x index %x", inst, index);
1779 return inst_base; 1781 return inst_base;
1780} 1782}
1781ARM_INST_PTR INTERPRETER_TRANSLATE(clrex)(unsigned int inst, int index) 1783ARM_INST_PTR INTERPRETER_TRANSLATE(clrex)(unsigned int inst, int index)
@@ -2205,7 +2207,7 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(mcr)(unsigned int inst, int index)
2205 inst_cream->inst = inst; 2207 inst_cream->inst = inst;
2206 return inst_base; 2208 return inst_base;
2207} 2209}
2208ARM_INST_PTR INTERPRETER_TRANSLATE(mcrr)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2210ARM_INST_PTR INTERPRETER_TRANSLATE(mcrr)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("MCRR"); }
2209ARM_INST_PTR INTERPRETER_TRANSLATE(mla)(unsigned int inst, int index) 2211ARM_INST_PTR INTERPRETER_TRANSLATE(mla)(unsigned int inst, int index)
2210{ 2212{
2211 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(mla_inst)); 2213 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(mla_inst));
@@ -2264,7 +2266,7 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(mrc)(unsigned int inst, int index)
2264 inst_cream->inst = inst; 2266 inst_cream->inst = inst;
2265 return inst_base; 2267 return inst_base;
2266} 2268}
2267ARM_INST_PTR INTERPRETER_TRANSLATE(mrrc)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2269ARM_INST_PTR INTERPRETER_TRANSLATE(mrrc)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("MRRC"); }
2268ARM_INST_PTR INTERPRETER_TRANSLATE(mrs)(unsigned int inst, int index) 2270ARM_INST_PTR INTERPRETER_TRANSLATE(mrs)(unsigned int inst, int index)
2269{ 2271{
2270 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(mrs_inst)); 2272 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(mrs_inst));
@@ -2358,8 +2360,8 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(orr)(unsigned int inst, int index)
2358 } 2360 }
2359 return inst_base; 2361 return inst_base;
2360} 2362}
2361ARM_INST_PTR INTERPRETER_TRANSLATE(pkhbt)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2363ARM_INST_PTR INTERPRETER_TRANSLATE(pkhbt)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("PKHBT"); }
2362ARM_INST_PTR INTERPRETER_TRANSLATE(pkhtb)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2364ARM_INST_PTR INTERPRETER_TRANSLATE(pkhtb)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("PKHTB"); }
2363ARM_INST_PTR INTERPRETER_TRANSLATE(pld)(unsigned int inst, int index) 2365ARM_INST_PTR INTERPRETER_TRANSLATE(pld)(unsigned int inst, int index)
2364{ 2366{
2365 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(pld_inst)); 2367 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(pld_inst));
@@ -2371,16 +2373,16 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(pld)(unsigned int inst, int index)
2371 2373
2372 return inst_base; 2374 return inst_base;
2373} 2375}
2374ARM_INST_PTR INTERPRETER_TRANSLATE(qadd)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2376ARM_INST_PTR INTERPRETER_TRANSLATE(qadd)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("QADD"); }
2375ARM_INST_PTR INTERPRETER_TRANSLATE(qadd16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2377ARM_INST_PTR INTERPRETER_TRANSLATE(qadd16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("QADD16"); }
2376ARM_INST_PTR INTERPRETER_TRANSLATE(qadd8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2378ARM_INST_PTR INTERPRETER_TRANSLATE(qadd8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("QADD8"); }
2377ARM_INST_PTR INTERPRETER_TRANSLATE(qaddsubx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2379ARM_INST_PTR INTERPRETER_TRANSLATE(qaddsubx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("QADDSUBX"); }
2378ARM_INST_PTR INTERPRETER_TRANSLATE(qdadd)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2380ARM_INST_PTR INTERPRETER_TRANSLATE(qdadd)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("QDADD"); }
2379ARM_INST_PTR INTERPRETER_TRANSLATE(qdsub)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2381ARM_INST_PTR INTERPRETER_TRANSLATE(qdsub)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("QDSUB"); }
2380ARM_INST_PTR INTERPRETER_TRANSLATE(qsub)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2382ARM_INST_PTR INTERPRETER_TRANSLATE(qsub)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("QSUB"); }
2381ARM_INST_PTR INTERPRETER_TRANSLATE(qsub16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2383ARM_INST_PTR INTERPRETER_TRANSLATE(qsub16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("QSUB16"); }
2382ARM_INST_PTR INTERPRETER_TRANSLATE(qsub8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2384ARM_INST_PTR INTERPRETER_TRANSLATE(qsub8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("QSUB8"); }
2383ARM_INST_PTR INTERPRETER_TRANSLATE(qsubaddx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2385ARM_INST_PTR INTERPRETER_TRANSLATE(qsubaddx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("QSUBADDX"); }
2384ARM_INST_PTR INTERPRETER_TRANSLATE(rev)(unsigned int inst, int index) 2386ARM_INST_PTR INTERPRETER_TRANSLATE(rev)(unsigned int inst, int index)
2385{ 2387{
2386 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(rev_inst)); 2388 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(rev_inst));
@@ -2410,8 +2412,8 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(rev16)(unsigned int inst, int index){
2410 2412
2411 return inst_base; 2413 return inst_base;
2412} 2414}
2413ARM_INST_PTR INTERPRETER_TRANSLATE(revsh)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2415ARM_INST_PTR INTERPRETER_TRANSLATE(revsh)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("REVSH"); }
2414ARM_INST_PTR INTERPRETER_TRANSLATE(rfe)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2416ARM_INST_PTR INTERPRETER_TRANSLATE(rfe)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("RFE"); }
2415ARM_INST_PTR INTERPRETER_TRANSLATE(rsb)(unsigned int inst, int index) 2417ARM_INST_PTR INTERPRETER_TRANSLATE(rsb)(unsigned int inst, int index)
2416{ 2418{
2417 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(rsb_inst)); 2419 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(rsb_inst));
@@ -2460,9 +2462,9 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(rsc)(unsigned int inst, int index)
2460 } 2462 }
2461 return inst_base; 2463 return inst_base;
2462} 2464}
2463ARM_INST_PTR INTERPRETER_TRANSLATE(sadd16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2465ARM_INST_PTR INTERPRETER_TRANSLATE(sadd16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SADD16"); }
2464ARM_INST_PTR INTERPRETER_TRANSLATE(sadd8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2466ARM_INST_PTR INTERPRETER_TRANSLATE(sadd8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SADD8"); }
2465ARM_INST_PTR INTERPRETER_TRANSLATE(saddsubx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2467ARM_INST_PTR INTERPRETER_TRANSLATE(saddsubx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SADDSUBX"); }
2466ARM_INST_PTR INTERPRETER_TRANSLATE(sbc)(unsigned int inst, int index) 2468ARM_INST_PTR INTERPRETER_TRANSLATE(sbc)(unsigned int inst, int index)
2467{ 2469{
2468 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(sbc_inst)); 2470 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(sbc_inst));
@@ -2487,14 +2489,14 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(sbc)(unsigned int inst, int index)
2487 } 2489 }
2488 return inst_base; 2490 return inst_base;
2489} 2491}
2490ARM_INST_PTR INTERPRETER_TRANSLATE(sel)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2492ARM_INST_PTR INTERPRETER_TRANSLATE(sel)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SEL"); }
2491ARM_INST_PTR INTERPRETER_TRANSLATE(setend)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2493ARM_INST_PTR INTERPRETER_TRANSLATE(setend)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SETEND"); }
2492ARM_INST_PTR INTERPRETER_TRANSLATE(shadd16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2494ARM_INST_PTR INTERPRETER_TRANSLATE(shadd16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SHADD16"); }
2493ARM_INST_PTR INTERPRETER_TRANSLATE(shadd8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2495ARM_INST_PTR INTERPRETER_TRANSLATE(shadd8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SHADD8"); }
2494ARM_INST_PTR INTERPRETER_TRANSLATE(shaddsubx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2496ARM_INST_PTR INTERPRETER_TRANSLATE(shaddsubx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SHADDSUBX"); }
2495ARM_INST_PTR INTERPRETER_TRANSLATE(shsub16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2497ARM_INST_PTR INTERPRETER_TRANSLATE(shsub16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SHSUB16"); }
2496ARM_INST_PTR INTERPRETER_TRANSLATE(shsub8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2498ARM_INST_PTR INTERPRETER_TRANSLATE(shsub8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SHSUB8"); }
2497ARM_INST_PTR INTERPRETER_TRANSLATE(shsubaddx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2499ARM_INST_PTR INTERPRETER_TRANSLATE(shsubaddx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SHSUBADDX"); }
2498ARM_INST_PTR INTERPRETER_TRANSLATE(smla)(unsigned int inst, int index) 2500ARM_INST_PTR INTERPRETER_TRANSLATE(smla)(unsigned int inst, int index)
2499{ 2501{
2500 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(smla_inst)); 2502 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(smla_inst));
@@ -2553,15 +2555,15 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(smlal)(unsigned int inst, int index)
2553 inst_base->load_r15 = 1; 2555 inst_base->load_r15 = 1;
2554 return inst_base; 2556 return inst_base;
2555} 2557}
2556ARM_INST_PTR INTERPRETER_TRANSLATE(smlalxy)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2558ARM_INST_PTR INTERPRETER_TRANSLATE(smlalxy)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SMLALXY"); }
2557ARM_INST_PTR INTERPRETER_TRANSLATE(smlald)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2559ARM_INST_PTR INTERPRETER_TRANSLATE(smlald)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SMLALD"); }
2558ARM_INST_PTR INTERPRETER_TRANSLATE(smlaw)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2560ARM_INST_PTR INTERPRETER_TRANSLATE(smlaw)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SMLAW"); }
2559ARM_INST_PTR INTERPRETER_TRANSLATE(smlsd)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2561ARM_INST_PTR INTERPRETER_TRANSLATE(smlsd)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SMLSD"); }
2560ARM_INST_PTR INTERPRETER_TRANSLATE(smlsld)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2562ARM_INST_PTR INTERPRETER_TRANSLATE(smlsld)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SMLSLD"); }
2561ARM_INST_PTR INTERPRETER_TRANSLATE(smmla)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2563ARM_INST_PTR INTERPRETER_TRANSLATE(smmla)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SMMLA"); }
2562ARM_INST_PTR INTERPRETER_TRANSLATE(smmls)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2564ARM_INST_PTR INTERPRETER_TRANSLATE(smmls)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SMMLS"); }
2563ARM_INST_PTR INTERPRETER_TRANSLATE(smmul)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2565ARM_INST_PTR INTERPRETER_TRANSLATE(smmul)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SMMUL"); }
2564ARM_INST_PTR INTERPRETER_TRANSLATE(smuad)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2566ARM_INST_PTR INTERPRETER_TRANSLATE(smuad)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SMUAD"); }
2565ARM_INST_PTR INTERPRETER_TRANSLATE(smul)(unsigned int inst, int index) 2567ARM_INST_PTR INTERPRETER_TRANSLATE(smul)(unsigned int inst, int index)
2566{ 2568{
2567 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(smul_inst)); 2569 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(smul_inst));
@@ -2624,13 +2626,13 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(smulw)(unsigned int inst, int index)
2624 inst_base->load_r15 = 1; 2626 inst_base->load_r15 = 1;
2625 return inst_base; 2627 return inst_base;
2626} 2628}
2627ARM_INST_PTR INTERPRETER_TRANSLATE(smusd)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2629ARM_INST_PTR INTERPRETER_TRANSLATE(smusd)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SMUSD"); }
2628ARM_INST_PTR INTERPRETER_TRANSLATE(srs)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2630ARM_INST_PTR INTERPRETER_TRANSLATE(srs)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SRS"); }
2629ARM_INST_PTR INTERPRETER_TRANSLATE(ssat)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2631ARM_INST_PTR INTERPRETER_TRANSLATE(ssat)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSAT"); }
2630ARM_INST_PTR INTERPRETER_TRANSLATE(ssat16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2632ARM_INST_PTR INTERPRETER_TRANSLATE(ssat16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSAT16"); }
2631ARM_INST_PTR INTERPRETER_TRANSLATE(ssub16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2633ARM_INST_PTR INTERPRETER_TRANSLATE(ssub16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSUB16"); }
2632ARM_INST_PTR INTERPRETER_TRANSLATE(ssub8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2634ARM_INST_PTR INTERPRETER_TRANSLATE(ssub8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSUB8"); }
2633ARM_INST_PTR INTERPRETER_TRANSLATE(ssubaddx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2635ARM_INST_PTR INTERPRETER_TRANSLATE(ssubaddx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSUBADDX"); }
2634ARM_INST_PTR INTERPRETER_TRANSLATE(stc)(unsigned int inst, int index) 2636ARM_INST_PTR INTERPRETER_TRANSLATE(stc)(unsigned int inst, int index)
2635{ 2637{
2636 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(stc_inst)); 2638 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(stc_inst));
@@ -2937,9 +2939,9 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(sxtab)(unsigned int inst, int index){
2937 2939
2938 return inst_base; 2940 return inst_base;
2939} 2941}
2940ARM_INST_PTR INTERPRETER_TRANSLATE(sxtab16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2942ARM_INST_PTR INTERPRETER_TRANSLATE(sxtab16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SXTAB16"); }
2941ARM_INST_PTR INTERPRETER_TRANSLATE(sxtah)(unsigned int inst, int index){ 2943ARM_INST_PTR INTERPRETER_TRANSLATE(sxtah)(unsigned int inst, int index){
2942 DEBUG_LOG(ARM11, "in func %s, SXTAH untested\n", __func__); 2944 LOG_WARNING(Core_ARM11, "SXTAH untested");
2943 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(sxtah_inst)); 2945 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(sxtah_inst));
2944 sxtah_inst *inst_cream = (sxtah_inst *)inst_base->component; 2946 sxtah_inst *inst_cream = (sxtah_inst *)inst_base->component;
2945 2947
@@ -2955,7 +2957,7 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(sxtah)(unsigned int inst, int index){
2955 2957
2956 return inst_base; 2958 return inst_base;
2957} 2959}
2958ARM_INST_PTR INTERPRETER_TRANSLATE(sxtb16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 2960ARM_INST_PTR INTERPRETER_TRANSLATE(sxtb16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SXTB16"); }
2959ARM_INST_PTR INTERPRETER_TRANSLATE(teq)(unsigned int inst, int index) 2961ARM_INST_PTR INTERPRETER_TRANSLATE(teq)(unsigned int inst, int index)
2960{ 2962{
2961 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(teq_inst)); 2963 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(teq_inst));
@@ -2999,16 +3001,16 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(tst)(unsigned int inst, int index)
2999 inst_base->load_r15 = 1; 3001 inst_base->load_r15 = 1;
3000 return inst_base; 3002 return inst_base;
3001} 3003}
3002ARM_INST_PTR INTERPRETER_TRANSLATE(uadd16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3004ARM_INST_PTR INTERPRETER_TRANSLATE(uadd16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UADD16"); }
3003ARM_INST_PTR INTERPRETER_TRANSLATE(uadd8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3005ARM_INST_PTR INTERPRETER_TRANSLATE(uadd8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UADD8"); }
3004ARM_INST_PTR INTERPRETER_TRANSLATE(uaddsubx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3006ARM_INST_PTR INTERPRETER_TRANSLATE(uaddsubx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UADDSUBX"); }
3005ARM_INST_PTR INTERPRETER_TRANSLATE(uhadd16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3007ARM_INST_PTR INTERPRETER_TRANSLATE(uhadd16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UHADD16"); }
3006ARM_INST_PTR INTERPRETER_TRANSLATE(uhadd8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3008ARM_INST_PTR INTERPRETER_TRANSLATE(uhadd8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UHADD8"); }
3007ARM_INST_PTR INTERPRETER_TRANSLATE(uhaddsubx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3009ARM_INST_PTR INTERPRETER_TRANSLATE(uhaddsubx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UHADDSUBX"); }
3008ARM_INST_PTR INTERPRETER_TRANSLATE(uhsub16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3010ARM_INST_PTR INTERPRETER_TRANSLATE(uhsub16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UHSUB16"); }
3009ARM_INST_PTR INTERPRETER_TRANSLATE(uhsub8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3011ARM_INST_PTR INTERPRETER_TRANSLATE(uhsub8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UHSUB8"); }
3010ARM_INST_PTR INTERPRETER_TRANSLATE(uhsubaddx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3012ARM_INST_PTR INTERPRETER_TRANSLATE(uhsubaddx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UHSUBADDX"); }
3011ARM_INST_PTR INTERPRETER_TRANSLATE(umaal)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3013ARM_INST_PTR INTERPRETER_TRANSLATE(umaal)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UMAAL"); }
3012ARM_INST_PTR INTERPRETER_TRANSLATE(umlal)(unsigned int inst, int index) 3014ARM_INST_PTR INTERPRETER_TRANSLATE(umlal)(unsigned int inst, int index)
3013{ 3015{
3014 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(umlal_inst)); 3016 arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(umlal_inst));
@@ -3111,21 +3113,21 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(blx_1_thumb)(unsigned int tinst, int index)
3111 return inst_base; 3113 return inst_base;
3112} 3114}
3113 3115
3114ARM_INST_PTR INTERPRETER_TRANSLATE(uqadd16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3116ARM_INST_PTR INTERPRETER_TRANSLATE(uqadd16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UQADD16"); }
3115ARM_INST_PTR INTERPRETER_TRANSLATE(uqadd8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3117ARM_INST_PTR INTERPRETER_TRANSLATE(uqadd8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UQADD8"); }
3116ARM_INST_PTR INTERPRETER_TRANSLATE(uqaddsubx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3118ARM_INST_PTR INTERPRETER_TRANSLATE(uqaddsubx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UQADDSUBX"); }
3117ARM_INST_PTR INTERPRETER_TRANSLATE(uqsub16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3119ARM_INST_PTR INTERPRETER_TRANSLATE(uqsub16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UQSUB16"); }
3118ARM_INST_PTR INTERPRETER_TRANSLATE(uqsub8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3120ARM_INST_PTR INTERPRETER_TRANSLATE(uqsub8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UQSUB8"); }
3119ARM_INST_PTR INTERPRETER_TRANSLATE(uqsubaddx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3121ARM_INST_PTR INTERPRETER_TRANSLATE(uqsubaddx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UQSUBADDX"); }
3120ARM_INST_PTR INTERPRETER_TRANSLATE(usad8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3122ARM_INST_PTR INTERPRETER_TRANSLATE(usad8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("USAD8"); }
3121ARM_INST_PTR INTERPRETER_TRANSLATE(usada8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3123ARM_INST_PTR INTERPRETER_TRANSLATE(usada8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("USADA8"); }
3122ARM_INST_PTR INTERPRETER_TRANSLATE(usat)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3124ARM_INST_PTR INTERPRETER_TRANSLATE(usat)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("USAT"); }
3123ARM_INST_PTR INTERPRETER_TRANSLATE(usat16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3125ARM_INST_PTR INTERPRETER_TRANSLATE(usat16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("USAT16"); }
3124ARM_INST_PTR INTERPRETER_TRANSLATE(usub16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3126ARM_INST_PTR INTERPRETER_TRANSLATE(usub16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("USUB16"); }
3125ARM_INST_PTR INTERPRETER_TRANSLATE(usub8)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3127ARM_INST_PTR INTERPRETER_TRANSLATE(usub8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("USUB8"); }
3126ARM_INST_PTR INTERPRETER_TRANSLATE(usubaddx)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3128ARM_INST_PTR INTERPRETER_TRANSLATE(usubaddx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("USUBADDX"); }
3127ARM_INST_PTR INTERPRETER_TRANSLATE(uxtab16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3129ARM_INST_PTR INTERPRETER_TRANSLATE(uxtab16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UXTAB16"); }
3128ARM_INST_PTR INTERPRETER_TRANSLATE(uxtb16)(unsigned int inst, int index){DEBUG_LOG(ARM11, "in func %s\n", __FUNCTION__);CITRA_IGNORE_EXIT(-1); return nullptr;} 3130ARM_INST_PTR INTERPRETER_TRANSLATE(uxtb16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("UXTB16"); }
3129 3131
3130 3132
3131 3133
@@ -3391,7 +3393,7 @@ static tdstate decode_thumb_instr(arm_processor *cpu, uint32_t inst, addr_t addr
3391 } 3393 }
3392 else{ 3394 else{
3393 /* something wrong */ 3395 /* something wrong */
3394 DEBUG_LOG(ARM11, "In %s, thumb decoder error\n", __FUNCTION__); 3396 LOG_ERROR(Core_ARM11, "thumb decoder error");
3395 } 3397 }
3396 break; 3398 break;
3397 case 28: 3399 case 28:
@@ -3599,7 +3601,7 @@ int InterpreterTranslate(arm_processor *cpu, int &bb_start, addr_t addr)
3599 bank->bank_read(32, phys_addr, &inst); 3601 bank->bank_read(32, phys_addr, &inst);
3600 } 3602 }
3601 else { 3603 else {
3602 DEBUG_LOG(ARM11, "SKYEYE: Read physical addr 0x%x error!!\n", phys_addr); 3604 LOG_ERROR(Core_ARM11, "SKYEYE: Read physical addr 0x%x error!!\n", phys_addr);
3603 return FETCH_FAILURE; 3605 return FETCH_FAILURE;
3604 } 3606 }
3605#else 3607#else
@@ -3629,8 +3631,8 @@ int InterpreterTranslate(arm_processor *cpu, int &bb_start, addr_t addr)
3629 3631
3630 ret = decode_arm_instr(inst, &idx); 3632 ret = decode_arm_instr(inst, &idx);
3631 if (ret == DECODE_FAILURE) { 3633 if (ret == DECODE_FAILURE) {
3632 DEBUG_LOG(ARM11, "[info] : Decode failure.\tPC : [0x%x]\tInstruction : [%x]\n", phys_addr, inst); 3634 LOG_ERROR(Core_ARM11, "Decode failure.\tPC : [0x%x]\tInstruction : [%x]", phys_addr, inst);
3633 DEBUG_LOG(ARM11, "cpsr=0x%x, cpu->TFlag=%d, r15=0x%x\n", cpu->Cpsr, cpu->TFlag, cpu->Reg[15]); 3635 LOG_ERROR(Core_ARM11, "cpsr=0x%x, cpu->TFlag=%d, r15=0x%x", cpu->Cpsr, cpu->TFlag, cpu->Reg[15]);
3634 CITRA_IGNORE_EXIT(-1); 3636 CITRA_IGNORE_EXIT(-1);
3635 } 3637 }
3636// DEBUG_LOG(ARM11, "PC : [0x%x] INST : %s\n", cpu->translate_pc, arm_instruction[idx].name); 3638// DEBUG_LOG(ARM11, "PC : [0x%x] INST : %s\n", cpu->translate_pc, arm_instruction[idx].name);
@@ -3674,7 +3676,7 @@ void InterpreterInitInstLength(unsigned long long int *ptr, size_t size)
3674 } 3676 }
3675 } 3677 }
3676 for (int i = 0; i < array_size - 4; i ++) 3678 for (int i = 0; i < array_size - 4; i ++)
3677 DEBUG_LOG(ARM11, "[%d]:%d\n", i, InstLength[i]); 3679 LOG_DEBUG(Core_ARM11, "[%d]:%d", i, InstLength[i]);
3678} 3680}
3679 3681
3680int clz(unsigned int x) 3682int clz(unsigned int x)
@@ -3721,7 +3723,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
3721 //if (debug_function(core)) \ 3723 //if (debug_function(core)) \
3722 if (core->check_int_flag) \ 3724 if (core->check_int_flag) \
3723 goto END 3725 goto END
3724 //DEBUG_LOG(ARM11, "icounter is %llx line is %d pc is %x\n", cpu->icounter, __LINE__, cpu->Reg[15]) 3726 //LOG_TRACE(Core_ARM11, "icounter is %llx pc is %x\n", cpu->icounter, cpu->Reg[15])
3725 #else 3727 #else
3726 #define INC_ICOUNTER ; 3728 #define INC_ICOUNTER ;
3727 #endif 3729 #endif
@@ -4348,7 +4350,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
4348 bx_inst *inst_cream = (bx_inst *)inst_base->component; 4350 bx_inst *inst_cream = (bx_inst *)inst_base->component;
4349 if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) { 4351 if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
4350 if (inst_cream->Rm == 15) 4352 if (inst_cream->Rm == 15)
4351 DEBUG_LOG(ARM11, "In %s, BX at pc %x: use of Rm = R15 is discouraged\n", __FUNCTION__, cpu->Reg[15]); 4353 LOG_WARNING(Core_ARM11, "BX at pc %x: use of Rm = R15 is discouraged", cpu->Reg[15]);
4352 cpu->TFlag = cpu->Reg[inst_cream->Rm] & 0x1; 4354 cpu->TFlag = cpu->Reg[inst_cream->Rm] & 0x1;
4353 cpu->Reg[15] = cpu->Reg[inst_cream->Rm] & 0xfffffffe; 4355 cpu->Reg[15] = cpu->Reg[inst_cream->Rm] & 0xfffffffe;
4354// cpu->TFlag = cpu->Reg[inst_cream->Rm] & 0x1; 4356// cpu->TFlag = cpu->Reg[inst_cream->Rm] & 0x1;
@@ -4373,10 +4375,10 @@ unsigned InterpreterMainLoop(ARMul_State* state)
4373 cpu->NumInstrsToExecute = 0; 4375 cpu->NumInstrsToExecute = 0;
4374 return num_instrs; 4376 return num_instrs;
4375 } 4377 }
4376 ERROR_LOG(ARM11, "CDP insn inst=0x%x, pc=0x%x\n", inst_cream->inst, cpu->Reg[15]); 4378 LOG_ERROR(Core_ARM11, "CDP insn inst=0x%x, pc=0x%x\n", inst_cream->inst, cpu->Reg[15]);
4377 unsigned cpab = (cpu->CDP[inst_cream->cp_num]) (cpu, ARMul_FIRST, inst_cream->inst); 4379 unsigned cpab = (cpu->CDP[inst_cream->cp_num]) (cpu, ARMul_FIRST, inst_cream->inst);
4378 if(cpab != ARMul_DONE){ 4380 if(cpab != ARMul_DONE){
4379 ERROR_LOG(ARM11, "CDP insn wrong, inst=0x%x, cp_num=0x%x\n", inst_cream->inst, inst_cream->cp_num); 4381 LOG_ERROR(Core_ARM11, "CDP insn wrong, inst=0x%x, cp_num=0x%x\n", inst_cream->inst, inst_cream->cp_num);
4380 //CITRA_IGNORE_EXIT(-1); 4382 //CITRA_IGNORE_EXIT(-1);
4381 } 4383 }
4382 } 4384 }
@@ -4803,7 +4805,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
4803 & 0xffff; 4805 & 0xffff;
4804 RD = RN + operand2; 4806 RD = RN + operand2;
4805 if (inst_cream->Rn == 15 || inst_cream->Rm == 15) { 4807 if (inst_cream->Rn == 15 || inst_cream->Rm == 15) {
4806 DEBUG_LOG(ARM11, "in line %d\n", __LINE__); 4808 LOG_ERROR(Core_ARM11, "invalid operands for UXTAH");
4807 CITRA_IGNORE_EXIT(-1); 4809 CITRA_IGNORE_EXIT(-1);
4808 } 4810 }
4809 } 4811 }
@@ -4866,7 +4868,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
4866 uint32_t rear_phys_addr; 4868 uint32_t rear_phys_addr;
4867 fault = check_address_validity(cpu, addr + 4, &rear_phys_addr, 1); 4869 fault = check_address_validity(cpu, addr + 4, &rear_phys_addr, 1);
4868 if(fault){ 4870 if(fault){
4869 ERROR_LOG(ARM11, "mmu fault , should rollback the above get_addr\n"); 4871 LOG_ERROR(Core_ARM11, "mmu fault , should rollback the above get_addr\n");
4870 CITRA_IGNORE_EXIT(-1); 4872 CITRA_IGNORE_EXIT(-1);
4871 goto MMU_EXCEPTION; 4873 goto MMU_EXCEPTION;
4872 } 4874 }
@@ -5089,7 +5091,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
5089 switch(OPCODE_2){ 5091 switch(OPCODE_2){
5090 case 0: /* invalidate all */ 5092 case 0: /* invalidate all */
5091 //invalidate_all_tlb(state); 5093 //invalidate_all_tlb(state);
5092 DEBUG_LOG(ARM11, "{TLB} [INSN] invalidate all\n"); 5094 LOG_DEBUG(Core_ARM11, "{TLB} [INSN] invalidate all");
5093 //remove_tlb(INSN_TLB); 5095 //remove_tlb(INSN_TLB);
5094 //erase_all(core, INSN_TLB); 5096 //erase_all(core, INSN_TLB);
5095 break; 5097 break;
@@ -5115,7 +5117,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
5115 //invalidate_all_tlb(state); 5117 //invalidate_all_tlb(state);
5116 //remove_tlb(DATA_TLB); 5118 //remove_tlb(DATA_TLB);
5117 //erase_all(core, DATA_TLB); 5119 //erase_all(core, DATA_TLB);
5118 DEBUG_LOG(ARM11, "{TLB} [DATA] invalidate all\n"); 5120 LOG_DEBUG(Core_ARM11, "{TLB} [DATA] invalidate all");
5119 break; 5121 break;
5120 case 1: /* invalidate by MVA */ 5122 case 1: /* invalidate by MVA */
5121 //invalidate_by_mva(state, value); 5123 //invalidate_by_mva(state, value);
@@ -5147,13 +5149,13 @@ unsigned InterpreterMainLoop(ARMul_State* state)
5147 //invalidate_by_mva(state, value); 5149 //invalidate_by_mva(state, value);
5148 //erase_by_mva(core, RD, DATA_TLB); 5150 //erase_by_mva(core, RD, DATA_TLB);
5149 //erase_by_mva(core, RD, INSN_TLB); 5151 //erase_by_mva(core, RD, INSN_TLB);
5150 DEBUG_LOG(ARM11, "{TLB} [UNIFILED] invalidate by mva\n"); 5152 LOG_DEBUG(Core_ARM11, "{TLB} [UNIFILED] invalidate by mva");
5151 break; 5153 break;
5152 case 2: /* invalidate by asid */ 5154 case 2: /* invalidate by asid */
5153 //invalidate_by_asid(state, value); 5155 //invalidate_by_asid(state, value);
5154 //erase_by_asid(core, RD, DATA_TLB); 5156 //erase_by_asid(core, RD, DATA_TLB);
5155 //erase_by_asid(core, RD, INSN_TLB); 5157 //erase_by_asid(core, RD, INSN_TLB);
5156 DEBUG_LOG(ARM11, "{TLB} [UNIFILED] invalidate by asid\n"); 5158 LOG_DEBUG(Core_ARM11, "{TLB} [UNIFILED] invalidate by asid");
5157 break; 5159 break;
5158 default: 5160 default:
5159 break; 5161 break;
@@ -5175,7 +5177,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
5175 } 5177 }
5176 5178
5177 } else { 5179 } else {
5178 DEBUG_LOG(ARM11, "mcr is not implementated. CRn is %d, CRm is %d, OPCODE_2 is %d\n", CRn, CRm, OPCODE_2); 5180 LOG_ERROR(Core_ARM11, "mcr CRn=%d, CRm=%d OP2=%d is not implemented", CRn, CRm, OPCODE_2);
5179 } 5181 }
5180 } 5182 }
5181 } 5183 }
@@ -5195,7 +5197,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
5195 uint64_t rs = RS; 5197 uint64_t rs = RS;
5196 uint64_t rn = RN; 5198 uint64_t rn = RN;
5197 if (inst_cream->Rm == 15 || inst_cream->Rs == 15 || inst_cream->Rn == 15) { 5199 if (inst_cream->Rm == 15 || inst_cream->Rs == 15 || inst_cream->Rn == 15) {
5198 DEBUG_LOG(ARM11, "in __line__\n", __LINE__); 5200 LOG_ERROR(Core_ARM11, "invalid operands for MLA");
5199 CITRA_IGNORE_EXIT(-1); 5201 CITRA_IGNORE_EXIT(-1);
5200 } 5202 }
5201// RD = dst = RM * RS + RN; 5203// RD = dst = RM * RS + RN;
@@ -5309,7 +5311,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
5309 } 5311 }
5310 } 5312 }
5311 else { 5313 else {
5312 DEBUG_LOG(ARM11, "mrc is not implementated. CRn is %d, CRm is %d, OPCODE_2 is %d\n", CRn, CRm, OPCODE_2); 5314 LOG_ERROR(Core_ARM11, "mrc CRn=%d, CRm=%d, OP2=%d is not implemented", CRn, CRm, OPCODE_2);
5313 } 5315 }
5314 } 5316 }
5315 //DEBUG_LOG(ARM11, "mrc is not implementated. CRn is %d, CRm is %d, OPCODE_2 is %d\n", CRn, CRm, OPCODE_2); 5317 //DEBUG_LOG(ARM11, "mrc is not implementated. CRn is %d, CRm is %d, OPCODE_2 is %d\n", CRn, CRm, OPCODE_2);
@@ -5500,7 +5502,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
5500 (((RM >> 16) & 0xff) << 8) | 5502 (((RM >> 16) & 0xff) << 8) |
5501 ((RM >> 24) & 0xff); 5503 ((RM >> 24) & 0xff);
5502 if (inst_cream->Rm == 15) { 5504 if (inst_cream->Rm == 15) {
5503 DEBUG_LOG(ARM11, "in line %d\n", __LINE__); 5505 LOG_ERROR(Core_ARM11, "invalid operand for REV");
5504 CITRA_IGNORE_EXIT(-1); 5506 CITRA_IGNORE_EXIT(-1);
5505 } 5507 }
5506 } 5508 }
@@ -5953,7 +5955,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
5953 sxtb_inst *inst_cream = (sxtb_inst *)inst_base->component; 5955 sxtb_inst *inst_cream = (sxtb_inst *)inst_base->component;
5954 if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) { 5956 if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
5955 if (inst_cream->Rm == 15) { 5957 if (inst_cream->Rm == 15) {
5956 DEBUG_LOG(ARM11, "line is %d\n", __LINE__); 5958 LOG_ERROR(Core_ARM11, "invalid operand for SXTB");
5957 CITRA_IGNORE_EXIT(-1); 5959 CITRA_IGNORE_EXIT(-1);
5958 } 5960 }
5959 unsigned int operand2 = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate); 5961 unsigned int operand2 = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate);
@@ -6059,7 +6061,7 @@ unsigned InterpreterMainLoop(ARMul_State* state)
6059 uint32_t rear_phys_addr; 6061 uint32_t rear_phys_addr;
6060 fault = check_address_validity(cpu, addr + 4, &rear_phys_addr, 0); 6062 fault = check_address_validity(cpu, addr + 4, &rear_phys_addr, 0);
6061 if (fault){ 6063 if (fault){
6062 ERROR_LOG(ARM11, "mmu fault , should rollback the above get_addr\n"); 6064 LOG_ERROR(Core_ARM11, "mmu fault , should rollback the above get_addr\n");
6063 CITRA_IGNORE_EXIT(-1); 6065 CITRA_IGNORE_EXIT(-1);
6064 goto MMU_EXCEPTION; 6066 goto MMU_EXCEPTION;
6065 } 6067 }
diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp
index d717bd2c8..825955ade 100644
--- a/src/core/arm/interpreter/armemu.cpp
+++ b/src/core/arm/interpreter/armemu.cpp
@@ -949,7 +949,7 @@ ARMul_Emulate26 (ARMul_State * state)
949 //printf("t decode %04lx -> %08lx\n", instr & 0xffff, armOp); 949 //printf("t decode %04lx -> %08lx\n", instr & 0xffff, armOp);
950 950
951 if (armOp == 0xDEADC0DE) { 951 if (armOp == 0xDEADC0DE) {
952 DEBUG("Failed to decode thumb opcode %04X at %08X\n", instr, pc); 952 LOG_ERROR(Core_ARM11, "Failed to decode thumb opcode %04X at %08X", instr, pc);
953 } 953 }
954 954
955 instr = armOp; 955 instr = armOp;
@@ -3437,7 +3437,7 @@ mainswitch:
3437 3437
3438 case 0x7f: /* Load Byte, WriteBack, Pre Inc, Reg. */ 3438 case 0x7f: /* Load Byte, WriteBack, Pre Inc, Reg. */
3439 if (BIT (4)) { 3439 if (BIT (4)) {
3440 DEBUG("got unhandled special breakpoint\n"); 3440 LOG_DEBUG(Core_ARM11, "got unhandled special breakpoint");
3441 return 1; 3441 return 1;
3442 } 3442 }
3443 UNDEF_LSRBaseEQOffWb; 3443 UNDEF_LSRBaseEQOffWb;
diff --git a/src/core/arm/interpreter/armsupp.cpp b/src/core/arm/interpreter/armsupp.cpp
index 2568b93ef..30519f216 100644
--- a/src/core/arm/interpreter/armsupp.cpp
+++ b/src/core/arm/interpreter/armsupp.cpp
@@ -665,7 +665,7 @@ ARMul_MCR (ARMul_State * state, ARMword instr, ARMword source)
665 //if (!CP_ACCESS_ALLOWED (state, CPNum)) { 665 //if (!CP_ACCESS_ALLOWED (state, CPNum)) {
666 if (!state->MCR[CPNum]) { 666 if (!state->MCR[CPNum]) {
667 //chy 2004-07-19 should fix in the future ????!!!! 667 //chy 2004-07-19 should fix in the future ????!!!!
668 DEBUG("SKYEYE ARMul_MCR, ACCESS_not ALLOWed, UndefinedInstr CPnum is %x, source %x\n",CPNum, source); 668 LOG_ERROR(Core_ARM11, "SKYEYE ARMul_MCR, ACCESS_not ALLOWed, UndefinedInstr CPnum is %x, source %x",CPNum, source);
669 ARMul_UndefInstr (state, instr); 669 ARMul_UndefInstr (state, instr);
670 return; 670 return;
671 } 671 }
@@ -690,7 +690,7 @@ ARMul_MCR (ARMul_State * state, ARMword instr, ARMword source)
690 } 690 }
691 691
692 if (cpab == ARMul_CANT) { 692 if (cpab == ARMul_CANT) {
693 DEBUG("SKYEYE ARMul_MCR, CANT, UndefinedInstr %x CPnum is %x, source %x\n", instr, CPNum, source); //ichfly todo 693 LOG_ERROR(Core_ARM11, "SKYEYE ARMul_MCR, CANT, UndefinedInstr %x CPnum is %x, source %x", instr, CPNum, source); //ichfly todo
694 //ARMul_Abort (state, ARMul_UndefinedInstrV); 694 //ARMul_Abort (state, ARMul_UndefinedInstrV);
695 } else { 695 } else {
696 BUSUSEDINCPCN; 696 BUSUSEDINCPCN;
@@ -762,7 +762,7 @@ ARMword ARMul_MRC (ARMul_State * state, ARMword instr)
762 //if (!CP_ACCESS_ALLOWED (state, CPNum)) { 762 //if (!CP_ACCESS_ALLOWED (state, CPNum)) {
763 if (!state->MRC[CPNum]) { 763 if (!state->MRC[CPNum]) {
764 //chy 2004-07-19 should fix in the future????!!!! 764 //chy 2004-07-19 should fix in the future????!!!!
765 DEBUG("SKYEYE ARMul_MRC,NOT ALLOWed UndefInstr CPnum is %x, instr %x\n", CPNum, instr); 765 LOG_ERROR(Core_ARM11, "SKYEYE ARMul_MRC,NOT ALLOWed UndefInstr CPnum is %x, instr %x", CPNum, instr);
766 ARMul_UndefInstr (state, instr); 766 ARMul_UndefInstr (state, instr);
767 return -1; 767 return -1;
768 } 768 }
@@ -865,7 +865,7 @@ void
865ARMul_UndefInstr (ARMul_State * state, ARMword instr) 865ARMul_UndefInstr (ARMul_State * state, ARMword instr)
866{ 866{
867 std::string disasm = ARM_Disasm::Disassemble(state->pc, instr); 867 std::string disasm = ARM_Disasm::Disassemble(state->pc, instr);
868 ERROR_LOG(ARM11, "Undefined instruction!! Disasm: %s Opcode: 0x%x", disasm.c_str(), instr); 868 LOG_ERROR(Core_ARM11, "Undefined instruction!! Disasm: %s Opcode: 0x%x", disasm.c_str(), instr);
869 ARMul_Abort (state, ARMul_UndefinedInstrV); 869 ARMul_Abort (state, ARMul_UndefinedInstrV);
870} 870}
871 871
diff --git a/src/core/arm/interpreter/thumbemu.cpp b/src/core/arm/interpreter/thumbemu.cpp
index f7f11f714..9cf80672d 100644
--- a/src/core/arm/interpreter/thumbemu.cpp
+++ b/src/core/arm/interpreter/thumbemu.cpp
@@ -467,7 +467,7 @@ ARMul_ThumbDecode (
467 (state->Reg[14] + ((tinstr & 0x07FF) << 1)) & 0xFFFFFFFC; 467 (state->Reg[14] + ((tinstr & 0x07FF) << 1)) & 0xFFFFFFFC;
468 state->Reg[14] = (tmp | 1); 468 state->Reg[14] = (tmp | 1);
469 CLEART; 469 CLEART;
470 DEBUG_LOG(ARM11, "In %s, After BLX(1),LR=0x%x,PC=0x%x, offset=0x%x\n", __FUNCTION__, state->Reg[14], state->Reg[15], (tinstr &0x7FF) << 1); 470 LOG_DEBUG(Core_ARM11, "After BLX(1),LR=0x%x,PC=0x%x, offset=0x%x", state->Reg[14], state->Reg[15], (tinstr &0x7FF) << 1);
471 valid = t_branch; 471 valid = t_branch;
472 FLUSHPIPE; 472 FLUSHPIPE;
473 } 473 }
diff --git a/src/core/arm/skyeye_common/armemu.h b/src/core/arm/skyeye_common/armemu.h
index 075fc7e9e..7f7c0e682 100644
--- a/src/core/arm/skyeye_common/armemu.h
+++ b/src/core/arm/skyeye_common/armemu.h
@@ -23,8 +23,6 @@
23 23
24//extern ARMword isize; 24//extern ARMword isize;
25 25
26#define DEBUG(...) DEBUG_LOG(ARM11, __VA_ARGS__)
27
28/* Shift Opcodes. */ 26/* Shift Opcodes. */
29#define LSL 0 27#define LSL 0
30#define LSR 1 28#define LSR 1
@@ -485,7 +483,7 @@ tdstate;
485 * out-of-updated with the newer ISA. 483 * out-of-updated with the newer ISA.
486 * -- Michael.Kang 484 * -- Michael.Kang
487 ********************************************************************************/ 485 ********************************************************************************/
488#define UNDEF_WARNING WARN_LOG(ARM11, "undefined or unpredicted behavior for arm instruction.\n"); 486#define UNDEF_WARNING LOG_WARNING(Core_ARM11, "undefined or unpredicted behavior for arm instruction.");
489 487
490/* Macros to scrutinize instructions. */ 488/* Macros to scrutinize instructions. */
491#define UNDEF_Test UNDEF_WARNING 489#define UNDEF_Test UNDEF_WARNING
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 865898b24..64de0cbba 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -47,7 +47,7 @@ void Stop() {
47 47
48/// Initialize the core 48/// Initialize the core
49int Init() { 49int Init() {
50 NOTICE_LOG(MASTER_LOG, "initialized OK"); 50 LOG_DEBUG(Core, "initialized OK");
51 51
52 disasm = new ARM_Disasm(); 52 disasm = new ARM_Disasm();
53 g_sys_core = new ARM_Interpreter(); 53 g_sys_core = new ARM_Interpreter();
@@ -72,7 +72,7 @@ void Shutdown() {
72 delete g_app_core; 72 delete g_app_core;
73 delete g_sys_core; 73 delete g_sys_core;
74 74
75 NOTICE_LOG(MASTER_LOG, "shutdown OK"); 75 LOG_DEBUG(Core, "shutdown OK");
76} 76}
77 77
78} // namespace 78} // namespace
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index bf8acf41f..1a0b2724a 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -124,7 +124,7 @@ int RegisterEvent(const char *name, TimedCallback callback)
124 124
125void AntiCrashCallback(u64 userdata, int cyclesLate) 125void AntiCrashCallback(u64 userdata, int cyclesLate)
126{ 126{
127 ERROR_LOG(TIME, "Savestate broken: an unregistered event was called."); 127 LOG_CRITICAL(Core, "Savestate broken: an unregistered event was called.");
128 Core::Halt("invalid timing events"); 128 Core::Halt("invalid timing events");
129} 129}
130 130
@@ -176,7 +176,7 @@ void Shutdown()
176 176
177u64 GetTicks() 177u64 GetTicks()
178{ 178{
179 ERROR_LOG(TIME, "Unimplemented function!"); 179 LOG_ERROR(Core, "Unimplemented function!");
180 return 0; 180 return 0;
181 //return (u64)globalTimer + slicelength - currentMIPS->downcount; 181 //return (u64)globalTimer + slicelength - currentMIPS->downcount;
182} 182}
@@ -510,7 +510,7 @@ void MoveEvents()
510 510
511void Advance() 511void Advance()
512{ 512{
513 ERROR_LOG(TIME, "Unimplemented function!"); 513 LOG_ERROR(Core, "Unimplemented function!");
514 //int cyclesExecuted = slicelength - currentMIPS->downcount; 514 //int cyclesExecuted = slicelength - currentMIPS->downcount;
515 //globalTimer += cyclesExecuted; 515 //globalTimer += cyclesExecuted;
516 //currentMIPS->downcount = slicelength; 516 //currentMIPS->downcount = slicelength;
@@ -547,7 +547,7 @@ void LogPendingEvents()
547 547
548void Idle(int maxIdle) 548void Idle(int maxIdle)
549{ 549{
550 ERROR_LOG(TIME, "Unimplemented function!"); 550 LOG_ERROR(Core, "Unimplemented function!");
551 //int cyclesDown = currentMIPS->downcount; 551 //int cyclesDown = currentMIPS->downcount;
552 //if (maxIdle != 0 && cyclesDown > maxIdle) 552 //if (maxIdle != 0 && cyclesDown > maxIdle)
553 // cyclesDown = maxIdle; 553 // cyclesDown = maxIdle;
diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h
index f3cb11133..27ed23cd0 100644
--- a/src/core/file_sys/archive.h
+++ b/src/core/file_sys/archive.h
@@ -100,7 +100,8 @@ public:
100 case Wchar: 100 case Wchar:
101 return "[Wchar: " + AsString() + ']'; 101 return "[Wchar: " + AsString() + ']';
102 default: 102 default:
103 ERROR_LOG(KERNEL, "LowPathType cannot be converted to string!"); 103 // TODO(yuriks): Add assert
104 LOG_ERROR(Service_FS, "LowPathType cannot be converted to string!");
104 return {}; 105 return {};
105 } 106 }
106 } 107 }
@@ -114,7 +115,8 @@ public:
114 case Empty: 115 case Empty:
115 return {}; 116 return {};
116 default: 117 default:
117 ERROR_LOG(KERNEL, "LowPathType cannot be converted to string!"); 118 // TODO(yuriks): Add assert
119 LOG_ERROR(Service_FS, "LowPathType cannot be converted to string!");
118 return {}; 120 return {};
119 } 121 }
120 } 122 }
@@ -128,7 +130,8 @@ public:
128 case Empty: 130 case Empty:
129 return {}; 131 return {};
130 default: 132 default:
131 ERROR_LOG(KERNEL, "LowPathType cannot be converted to u16string!"); 133 // TODO(yuriks): Add assert
134 LOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!");
132 return {}; 135 return {};
133 } 136 }
134 } 137 }
@@ -144,7 +147,8 @@ public:
144 case Empty: 147 case Empty:
145 return {}; 148 return {};
146 default: 149 default:
147 ERROR_LOG(KERNEL, "LowPathType cannot be converted to binary!"); 150 // TODO(yuriks): Add assert
151 LOG_ERROR(Service_FS, "LowPathType cannot be converted to binary!");
148 return {}; 152 return {};
149 } 153 }
150 } 154 }
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp
index 8c2dbeda5..74974c2df 100644
--- a/src/core/file_sys/archive_romfs.cpp
+++ b/src/core/file_sys/archive_romfs.cpp
@@ -16,7 +16,7 @@ namespace FileSys {
16Archive_RomFS::Archive_RomFS(const Loader::AppLoader& app_loader) { 16Archive_RomFS::Archive_RomFS(const Loader::AppLoader& app_loader) {
17 // Load the RomFS from the app 17 // Load the RomFS from the app
18 if (Loader::ResultStatus::Success != app_loader.ReadRomFS(raw_data)) { 18 if (Loader::ResultStatus::Success != app_loader.ReadRomFS(raw_data)) {
19 WARN_LOG(FILESYS, "Unable to read RomFS!"); 19 LOG_ERROR(Service_FS, "Unable to read RomFS!");
20 } 20 }
21} 21}
22 22
@@ -39,12 +39,12 @@ std::unique_ptr<File> Archive_RomFS::OpenFile(const Path& path, const Mode mode)
39 * @return Whether the file could be deleted 39 * @return Whether the file could be deleted
40 */ 40 */
41bool Archive_RomFS::DeleteFile(const FileSys::Path& path) const { 41bool Archive_RomFS::DeleteFile(const FileSys::Path& path) const {
42 ERROR_LOG(FILESYS, "Attempted to delete a file from ROMFS."); 42 LOG_WARNING(Service_FS, "Attempted to delete a file from ROMFS.");
43 return false; 43 return false;
44} 44}
45 45
46bool Archive_RomFS::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { 46bool Archive_RomFS::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const {
47 ERROR_LOG(FILESYS, "Attempted to rename a file within ROMFS."); 47 LOG_WARNING(Service_FS, "Attempted to rename a file within ROMFS.");
48 return false; 48 return false;
49} 49}
50 50
@@ -54,7 +54,7 @@ bool Archive_RomFS::RenameFile(const FileSys::Path& src_path, const FileSys::Pat
54 * @return Whether the directory could be deleted 54 * @return Whether the directory could be deleted
55 */ 55 */
56bool Archive_RomFS::DeleteDirectory(const FileSys::Path& path) const { 56bool Archive_RomFS::DeleteDirectory(const FileSys::Path& path) const {
57 ERROR_LOG(FILESYS, "Attempted to delete a directory from ROMFS."); 57 LOG_WARNING(Service_FS, "Attempted to delete a directory from ROMFS.");
58 return false; 58 return false;
59} 59}
60 60
@@ -64,12 +64,12 @@ bool Archive_RomFS::DeleteDirectory(const FileSys::Path& path) const {
64 * @return Whether the directory could be created 64 * @return Whether the directory could be created
65 */ 65 */
66bool Archive_RomFS::CreateDirectory(const Path& path) const { 66bool Archive_RomFS::CreateDirectory(const Path& path) const {
67 ERROR_LOG(FILESYS, "Attempted to create a directory in ROMFS."); 67 LOG_WARNING(Service_FS, "Attempted to create a directory in ROMFS.");
68 return false; 68 return false;
69} 69}
70 70
71bool Archive_RomFS::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { 71bool Archive_RomFS::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const {
72 ERROR_LOG(FILESYS, "Attempted to rename a file within ROMFS."); 72 LOG_WARNING(Service_FS, "Attempted to rename a file within ROMFS.");
73 return false; 73 return false;
74} 74}
75 75
@@ -90,7 +90,7 @@ std::unique_ptr<Directory> Archive_RomFS::OpenDirectory(const Path& path) const
90 * @return Number of bytes read 90 * @return Number of bytes read
91 */ 91 */
92size_t Archive_RomFS::Read(const u64 offset, const u32 length, u8* buffer) const { 92size_t Archive_RomFS::Read(const u64 offset, const u32 length, u8* buffer) const {
93 DEBUG_LOG(FILESYS, "called offset=%llu, length=%d", offset, length); 93 LOG_TRACE(Service_FS, "called offset=%llu, length=%d", offset, length);
94 memcpy(buffer, &raw_data[(u32)offset], length); 94 memcpy(buffer, &raw_data[(u32)offset], length);
95 return length; 95 return length;
96} 96}
@@ -104,7 +104,7 @@ size_t Archive_RomFS::Read(const u64 offset, const u32 length, u8* buffer) const
104 * @return Number of bytes written 104 * @return Number of bytes written
105 */ 105 */
106size_t Archive_RomFS::Write(const u64 offset, const u32 length, const u32 flush, u8* buffer) { 106size_t Archive_RomFS::Write(const u64 offset, const u32 length, const u32 flush, u8* buffer) {
107 ERROR_LOG(FILESYS, "Attempted to write to ROMFS."); 107 LOG_WARNING(Service_FS, "Attempted to write to ROMFS.");
108 return 0; 108 return 0;
109} 109}
110 110
@@ -120,7 +120,7 @@ size_t Archive_RomFS::GetSize() const {
120 * Set the size of the archive in bytes 120 * Set the size of the archive in bytes
121 */ 121 */
122void Archive_RomFS::SetSize(const u64 size) { 122void Archive_RomFS::SetSize(const u64 size) {
123 ERROR_LOG(FILESYS, "Attempted to set the size of ROMFS"); 123 LOG_WARNING(Service_FS, "Attempted to set the size of ROMFS");
124} 124}
125 125
126} // namespace FileSys 126} // namespace FileSys
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp
index fc0b9b72d..9e524b60e 100644
--- a/src/core/file_sys/archive_sdmc.cpp
+++ b/src/core/file_sys/archive_sdmc.cpp
@@ -19,7 +19,7 @@ namespace FileSys {
19 19
20Archive_SDMC::Archive_SDMC(const std::string& mount_point) { 20Archive_SDMC::Archive_SDMC(const std::string& mount_point) {
21 this->mount_point = mount_point; 21 this->mount_point = mount_point;
22 DEBUG_LOG(FILESYS, "Directory %s set as SDMC.", mount_point.c_str()); 22 LOG_INFO(Service_FS, "Directory %s set as SDMC.", mount_point.c_str());
23} 23}
24 24
25Archive_SDMC::~Archive_SDMC() { 25Archive_SDMC::~Archive_SDMC() {
@@ -31,12 +31,12 @@ Archive_SDMC::~Archive_SDMC() {
31 */ 31 */
32bool Archive_SDMC::Initialize() { 32bool Archive_SDMC::Initialize() {
33 if (!Settings::values.use_virtual_sd) { 33 if (!Settings::values.use_virtual_sd) {
34 WARN_LOG(FILESYS, "SDMC disabled by config."); 34 LOG_WARNING(Service_FS, "SDMC disabled by config.");
35 return false; 35 return false;
36 } 36 }
37 37
38 if (!FileUtil::CreateFullPath(mount_point)) { 38 if (!FileUtil::CreateFullPath(mount_point)) {
39 WARN_LOG(FILESYS, "Unable to create SDMC path."); 39 LOG_ERROR(Service_FS, "Unable to create SDMC path.");
40 return false; 40 return false;
41 } 41 }
42 42
@@ -50,7 +50,7 @@ bool Archive_SDMC::Initialize() {
50 * @return Opened file, or nullptr 50 * @return Opened file, or nullptr
51 */ 51 */
52std::unique_ptr<File> Archive_SDMC::OpenFile(const Path& path, const Mode mode) const { 52std::unique_ptr<File> Archive_SDMC::OpenFile(const Path& path, const Mode mode) const {
53 DEBUG_LOG(FILESYS, "called path=%s mode=%u", path.DebugStr().c_str(), mode.hex); 53 LOG_DEBUG(Service_FS, "called path=%s mode=%u", path.DebugStr().c_str(), mode.hex);
54 File_SDMC* file = new File_SDMC(this, path, mode); 54 File_SDMC* file = new File_SDMC(this, path, mode);
55 if (!file->Open()) 55 if (!file->Open())
56 return nullptr; 56 return nullptr;
@@ -98,7 +98,7 @@ bool Archive_SDMC::RenameDirectory(const FileSys::Path& src_path, const FileSys:
98 * @return Opened directory, or nullptr 98 * @return Opened directory, or nullptr
99 */ 99 */
100std::unique_ptr<Directory> Archive_SDMC::OpenDirectory(const Path& path) const { 100std::unique_ptr<Directory> Archive_SDMC::OpenDirectory(const Path& path) const {
101 DEBUG_LOG(FILESYS, "called path=%s", path.DebugStr().c_str()); 101 LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str());
102 Directory_SDMC* directory = new Directory_SDMC(this, path); 102 Directory_SDMC* directory = new Directory_SDMC(this, path);
103 if (!directory->Open()) 103 if (!directory->Open())
104 return nullptr; 104 return nullptr;
@@ -113,7 +113,7 @@ std::unique_ptr<Directory> Archive_SDMC::OpenDirectory(const Path& path) const {
113 * @return Number of bytes read 113 * @return Number of bytes read
114 */ 114 */
115size_t Archive_SDMC::Read(const u64 offset, const u32 length, u8* buffer) const { 115size_t Archive_SDMC::Read(const u64 offset, const u32 length, u8* buffer) const {
116 ERROR_LOG(FILESYS, "(UNIMPLEMENTED)"); 116 LOG_ERROR(Service_FS, "(UNIMPLEMENTED)");
117 return -1; 117 return -1;
118} 118}
119 119
@@ -126,7 +126,7 @@ size_t Archive_SDMC::Read(const u64 offset, const u32 length, u8* buffer) const
126 * @return Number of bytes written 126 * @return Number of bytes written
127 */ 127 */
128size_t Archive_SDMC::Write(const u64 offset, const u32 length, const u32 flush, u8* buffer) { 128size_t Archive_SDMC::Write(const u64 offset, const u32 length, const u32 flush, u8* buffer) {
129 ERROR_LOG(FILESYS, "(UNIMPLEMENTED)"); 129 LOG_ERROR(Service_FS, "(UNIMPLEMENTED)");
130 return -1; 130 return -1;
131} 131}
132 132
@@ -135,7 +135,7 @@ size_t Archive_SDMC::Write(const u64 offset, const u32 length, const u32 flush,
135 * @return Size of the archive in bytes 135 * @return Size of the archive in bytes
136 */ 136 */
137size_t Archive_SDMC::GetSize() const { 137size_t Archive_SDMC::GetSize() const {
138 ERROR_LOG(FILESYS, "(UNIMPLEMENTED)"); 138 LOG_ERROR(Service_FS, "(UNIMPLEMENTED)");
139 return 0; 139 return 0;
140} 140}
141 141
@@ -143,7 +143,7 @@ size_t Archive_SDMC::GetSize() const {
143 * Set the size of the archive in bytes 143 * Set the size of the archive in bytes
144 */ 144 */
145void Archive_SDMC::SetSize(const u64 size) { 145void Archive_SDMC::SetSize(const u64 size) {
146 ERROR_LOG(FILESYS, "(UNIMPLEMENTED)"); 146 LOG_ERROR(Service_FS, "(UNIMPLEMENTED)");
147} 147}
148 148
149/** 149/**
diff --git a/src/core/file_sys/directory_sdmc.cpp b/src/core/file_sys/directory_sdmc.cpp
index 0f156a127..519787641 100644
--- a/src/core/file_sys/directory_sdmc.cpp
+++ b/src/core/file_sys/directory_sdmc.cpp
@@ -49,7 +49,7 @@ u32 Directory_SDMC::Read(const u32 count, Entry* entries) {
49 const std::string& filename = file.virtualName; 49 const std::string& filename = file.virtualName;
50 Entry& entry = entries[entries_read]; 50 Entry& entry = entries[entries_read];
51 51
52 WARN_LOG(FILESYS, "File %s: size=%llu dir=%d", filename.c_str(), file.size, file.isDirectory); 52 LOG_TRACE(Service_FS, "File %s: size=%llu dir=%d", filename.c_str(), file.size, file.isDirectory);
53 53
54 // TODO(Link Mauve): use a proper conversion to UTF-16. 54 // TODO(Link Mauve): use a proper conversion to UTF-16.
55 for (size_t j = 0; j < FILENAME_LENGTH; ++j) { 55 for (size_t j = 0; j < FILENAME_LENGTH; ++j) {
diff --git a/src/core/file_sys/file_sdmc.cpp b/src/core/file_sys/file_sdmc.cpp
index b01d96e3d..46c29900b 100644
--- a/src/core/file_sys/file_sdmc.cpp
+++ b/src/core/file_sys/file_sdmc.cpp
@@ -33,7 +33,7 @@ File_SDMC::~File_SDMC() {
33 */ 33 */
34bool File_SDMC::Open() { 34bool File_SDMC::Open() {
35 if (!mode.create_flag && !FileUtil::Exists(path)) { 35 if (!mode.create_flag && !FileUtil::Exists(path)) {
36 ERROR_LOG(FILESYS, "Non-existing file %s can’t be open without mode create.", path.c_str()); 36 LOG_ERROR(Service_FS, "Non-existing file %s can’t be open without mode create.", path.c_str());
37 return false; 37 return false;
38 } 38 }
39 39
diff --git a/src/core/hle/config_mem.cpp b/src/core/hle/config_mem.cpp
index c7cf5b1d3..d8ba9e6cf 100644
--- a/src/core/hle/config_mem.cpp
+++ b/src/core/hle/config_mem.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/common_types.h" 5#include "common/common_types.h"
6#include "common/log.h"
6 7
7#include "core/hle/config_mem.h" 8#include "core/hle/config_mem.h"
8 9
@@ -54,7 +55,7 @@ inline void Read(T &var, const u32 addr) {
54 break; 55 break;
55 56
56 default: 57 default:
57 ERROR_LOG(HLE, "unknown addr=0x%08X", addr); 58 LOG_ERROR(Kernel, "unknown addr=0x%08X", addr);
58 } 59 }
59} 60}
60 61
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp
index b8ac186f6..3f73b5538 100644
--- a/src/core/hle/hle.cpp
+++ b/src/core/hle/hle.cpp
@@ -20,7 +20,7 @@ bool g_reschedule = false; ///< If true, immediately reschedules the CPU to a n
20const FunctionDef* GetSVCInfo(u32 opcode) { 20const FunctionDef* GetSVCInfo(u32 opcode) {
21 u32 func_num = opcode & 0xFFFFFF; // 8 bits 21 u32 func_num = opcode & 0xFFFFFF; // 8 bits
22 if (func_num > 0xFF) { 22 if (func_num > 0xFF) {
23 ERROR_LOG(HLE,"unknown svc=0x%02X", func_num); 23 LOG_ERROR(Kernel_SVC,"unknown svc=0x%02X", func_num);
24 return nullptr; 24 return nullptr;
25 } 25 }
26 return &g_module_db[0].func_table[func_num]; 26 return &g_module_db[0].func_table[func_num];
@@ -35,14 +35,12 @@ void CallSVC(u32 opcode) {
35 if (info->func) { 35 if (info->func) {
36 info->func(); 36 info->func();
37 } else { 37 } else {
38 ERROR_LOG(HLE, "unimplemented SVC function %s(..)", info->name.c_str()); 38 LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name.c_str());
39 } 39 }
40} 40}
41 41
42void Reschedule(const char *reason) { 42void Reschedule(const char *reason) {
43#ifdef _DEBUG 43 _dbg_assert_msg_(Kernel, reason != 0 && strlen(reason) < 256, "Reschedule: Invalid or too long reason.");
44 _dbg_assert_msg_(HLE, reason != 0 && strlen(reason) < 256, "Reschedule: Invalid or too long reason.");
45#endif
46 Core::g_app_core->PrepareReschedule(); 44 Core::g_app_core->PrepareReschedule();
47 g_reschedule = true; 45 g_reschedule = true;
48} 46}
@@ -61,7 +59,7 @@ void Init() {
61 59
62 RegisterAllModules(); 60 RegisterAllModules();
63 61
64 NOTICE_LOG(HLE, "initialized OK"); 62 LOG_DEBUG(Kernel, "initialized OK");
65} 63}
66 64
67void Shutdown() { 65void Shutdown() {
@@ -69,7 +67,7 @@ void Shutdown() {
69 67
70 g_module_db.clear(); 68 g_module_db.clear();
71 69
72 NOTICE_LOG(HLE, "shutdown OK"); 70 LOG_DEBUG(Kernel, "shutdown OK");
73} 71}
74 72
75} // namespace 73} // namespace
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index ce4f3c854..9a921108d 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -24,12 +24,6 @@ public:
24 Kernel::HandleType GetHandleType() const override { return HandleType::AddressArbiter; } 24 Kernel::HandleType GetHandleType() const override { return HandleType::AddressArbiter; }
25 25
26 std::string name; ///< Name of address arbiter object (optional) 26 std::string name; ///< Name of address arbiter object (optional)
27
28 ResultVal<bool> WaitSynchronization() override {
29 // TODO(bunnei): ImplementMe
30 ERROR_LOG(OSHLE, "(UNIMPLEMENTED)");
31 return UnimplementedFunction(ErrorModule::OS);
32 }
33}; 27};
34 28
35//////////////////////////////////////////////////////////////////////////////////////////////////// 29////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -59,7 +53,7 @@ ResultCode ArbitrateAddress(Handle handle, ArbitrationType type, u32 address, s3
59 break; 53 break;
60 54
61 default: 55 default:
62 ERROR_LOG(KERNEL, "unknown type=%d", type); 56 LOG_ERROR(Kernel, "unknown type=%d", type);
63 return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel, ErrorSummary::WrongArgument, ErrorLevel::Usage); 57 return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel, ErrorSummary::WrongArgument, ErrorLevel::Usage);
64 } 58 }
65 return RESULT_SUCCESS; 59 return RESULT_SUCCESS;
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp
index a875fa7ff..ddc09e13b 100644
--- a/src/core/hle/kernel/archive.cpp
+++ b/src/core/hle/kernel/archive.cpp
@@ -94,26 +94,20 @@ public:
94 } 94 }
95 case FileCommand::Close: 95 case FileCommand::Close:
96 { 96 {
97 DEBUG_LOG(KERNEL, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); 97 LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
98 CloseArchive(backend->GetIdCode()); 98 CloseArchive(backend->GetIdCode());
99 break; 99 break;
100 } 100 }
101 // Unknown command... 101 // Unknown command...
102 default: 102 default:
103 { 103 {
104 ERROR_LOG(KERNEL, "Unknown command=0x%08X!", cmd); 104 LOG_ERROR(Service_FS, "Unknown command=0x%08X", cmd);
105 return UnimplementedFunction(ErrorModule::FS); 105 return UnimplementedFunction(ErrorModule::FS);
106 } 106 }
107 } 107 }
108 cmd_buff[1] = 0; // No error 108 cmd_buff[1] = 0; // No error
109 return MakeResult<bool>(false); 109 return MakeResult<bool>(false);
110 } 110 }
111
112 ResultVal<bool> WaitSynchronization() override {
113 // TODO(bunnei): ImplementMe
114 ERROR_LOG(OSHLE, "(UNIMPLEMENTED)");
115 return UnimplementedFunction(ErrorModule::FS);
116 }
117}; 111};
118 112
119class File : public Object { 113class File : public Object {
@@ -138,7 +132,7 @@ public:
138 u64 offset = cmd_buff[1] | ((u64) cmd_buff[2]) << 32; 132 u64 offset = cmd_buff[1] | ((u64) cmd_buff[2]) << 32;
139 u32 length = cmd_buff[3]; 133 u32 length = cmd_buff[3];
140 u32 address = cmd_buff[5]; 134 u32 address = cmd_buff[5];
141 DEBUG_LOG(KERNEL, "Read %s %s: offset=0x%llx length=%d address=0x%x", 135 LOG_TRACE(Service_FS, "Read %s %s: offset=0x%llx length=%d address=0x%x",
142 GetTypeName().c_str(), GetName().c_str(), offset, length, address); 136 GetTypeName().c_str(), GetName().c_str(), offset, length, address);
143 cmd_buff[2] = backend->Read(offset, length, Memory::GetPointer(address)); 137 cmd_buff[2] = backend->Read(offset, length, Memory::GetPointer(address));
144 break; 138 break;
@@ -151,7 +145,7 @@ public:
151 u32 length = cmd_buff[3]; 145 u32 length = cmd_buff[3];
152 u32 flush = cmd_buff[4]; 146 u32 flush = cmd_buff[4];
153 u32 address = cmd_buff[6]; 147 u32 address = cmd_buff[6];
154 DEBUG_LOG(KERNEL, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x", 148 LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x",
155 GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush); 149 GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush);
156 cmd_buff[2] = backend->Write(offset, length, flush, Memory::GetPointer(address)); 150 cmd_buff[2] = backend->Write(offset, length, flush, Memory::GetPointer(address));
157 break; 151 break;
@@ -159,7 +153,7 @@ public:
159 153
160 case FileCommand::GetSize: 154 case FileCommand::GetSize:
161 { 155 {
162 DEBUG_LOG(KERNEL, "GetSize %s %s", GetTypeName().c_str(), GetName().c_str()); 156 LOG_TRACE(Service_FS, "GetSize %s %s", GetTypeName().c_str(), GetName().c_str());
163 u64 size = backend->GetSize(); 157 u64 size = backend->GetSize();
164 cmd_buff[2] = (u32)size; 158 cmd_buff[2] = (u32)size;
165 cmd_buff[3] = size >> 32; 159 cmd_buff[3] = size >> 32;
@@ -169,7 +163,7 @@ public:
169 case FileCommand::SetSize: 163 case FileCommand::SetSize:
170 { 164 {
171 u64 size = cmd_buff[1] | ((u64)cmd_buff[2] << 32); 165 u64 size = cmd_buff[1] | ((u64)cmd_buff[2] << 32);
172 DEBUG_LOG(KERNEL, "SetSize %s %s size=%llu", 166 LOG_TRACE(Service_FS, "SetSize %s %s size=%llu",
173 GetTypeName().c_str(), GetName().c_str(), size); 167 GetTypeName().c_str(), GetName().c_str(), size);
174 backend->SetSize(size); 168 backend->SetSize(size);
175 break; 169 break;
@@ -177,14 +171,14 @@ public:
177 171
178 case FileCommand::Close: 172 case FileCommand::Close:
179 { 173 {
180 DEBUG_LOG(KERNEL, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); 174 LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
181 Kernel::g_object_pool.Destroy<File>(GetHandle()); 175 Kernel::g_object_pool.Destroy<File>(GetHandle());
182 break; 176 break;
183 } 177 }
184 178
185 // Unknown command... 179 // Unknown command...
186 default: 180 default:
187 ERROR_LOG(KERNEL, "Unknown command=0x%08X!", cmd); 181 LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd);
188 ResultCode error = UnimplementedFunction(ErrorModule::FS); 182 ResultCode error = UnimplementedFunction(ErrorModule::FS);
189 cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that. 183 cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
190 return error; 184 return error;
@@ -192,12 +186,6 @@ public:
192 cmd_buff[1] = 0; // No error 186 cmd_buff[1] = 0; // No error
193 return MakeResult<bool>(false); 187 return MakeResult<bool>(false);
194 } 188 }
195
196 ResultVal<bool> WaitSynchronization() override {
197 // TODO(bunnei): ImplementMe
198 ERROR_LOG(OSHLE, "(UNIMPLEMENTED)");
199 return UnimplementedFunction(ErrorModule::FS);
200 }
201}; 189};
202 190
203class Directory : public Object { 191class Directory : public Object {
@@ -222,7 +210,7 @@ public:
222 u32 count = cmd_buff[1]; 210 u32 count = cmd_buff[1];
223 u32 address = cmd_buff[3]; 211 u32 address = cmd_buff[3];
224 auto entries = reinterpret_cast<FileSys::Entry*>(Memory::GetPointer(address)); 212 auto entries = reinterpret_cast<FileSys::Entry*>(Memory::GetPointer(address));
225 DEBUG_LOG(KERNEL, "Read %s %s: count=%d", 213 LOG_TRACE(Service_FS, "Read %s %s: count=%d",
226 GetTypeName().c_str(), GetName().c_str(), count); 214 GetTypeName().c_str(), GetName().c_str(), count);
227 215
228 // Number of entries actually read 216 // Number of entries actually read
@@ -232,14 +220,14 @@ public:
232 220
233 case DirectoryCommand::Close: 221 case DirectoryCommand::Close:
234 { 222 {
235 DEBUG_LOG(KERNEL, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); 223 LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
236 Kernel::g_object_pool.Destroy<Directory>(GetHandle()); 224 Kernel::g_object_pool.Destroy<Directory>(GetHandle());
237 break; 225 break;
238 } 226 }
239 227
240 // Unknown command... 228 // Unknown command...
241 default: 229 default:
242 ERROR_LOG(KERNEL, "Unknown command=0x%08X!", cmd); 230 LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd);
243 ResultCode error = UnimplementedFunction(ErrorModule::FS); 231 ResultCode error = UnimplementedFunction(ErrorModule::FS);
244 cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that. 232 cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that.
245 return error; 233 return error;
@@ -247,12 +235,6 @@ public:
247 cmd_buff[1] = 0; // No error 235 cmd_buff[1] = 0; // No error
248 return MakeResult<bool>(false); 236 return MakeResult<bool>(false);
249 } 237 }
250
251 ResultVal<bool> WaitSynchronization() override {
252 // TODO(bunnei): ImplementMe
253 ERROR_LOG(OSHLE, "(UNIMPLEMENTED)");
254 return UnimplementedFunction(ErrorModule::FS);
255 }
256}; 238};
257 239
258//////////////////////////////////////////////////////////////////////////////////////////////////// 240////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -272,11 +254,11 @@ ResultVal<Handle> OpenArchive(FileSys::Archive::IdCode id_code) {
272ResultCode CloseArchive(FileSys::Archive::IdCode id_code) { 254ResultCode CloseArchive(FileSys::Archive::IdCode id_code) {
273 auto itr = g_archive_map.find(id_code); 255 auto itr = g_archive_map.find(id_code);
274 if (itr == g_archive_map.end()) { 256 if (itr == g_archive_map.end()) {
275 ERROR_LOG(KERNEL, "Cannot close archive %d, does not exist!", (int)id_code); 257 LOG_ERROR(Service_FS, "Cannot close archive %d, does not exist!", (int)id_code);
276 return InvalidHandle(ErrorModule::FS); 258 return InvalidHandle(ErrorModule::FS);
277 } 259 }
278 260
279 INFO_LOG(KERNEL, "Closed archive %d", (int) id_code); 261 LOG_TRACE(Service_FS, "Closed archive %d", (int) id_code);
280 return RESULT_SUCCESS; 262 return RESULT_SUCCESS;
281} 263}
282 264
@@ -288,11 +270,11 @@ ResultCode MountArchive(Archive* archive) {
288 FileSys::Archive::IdCode id_code = archive->backend->GetIdCode(); 270 FileSys::Archive::IdCode id_code = archive->backend->GetIdCode();
289 ResultVal<Handle> archive_handle = OpenArchive(id_code); 271 ResultVal<Handle> archive_handle = OpenArchive(id_code);
290 if (archive_handle.Succeeded()) { 272 if (archive_handle.Succeeded()) {
291 ERROR_LOG(KERNEL, "Cannot mount two archives with the same ID code! (%d)", (int) id_code); 273 LOG_ERROR(Service_FS, "Cannot mount two archives with the same ID code! (%d)", (int) id_code);
292 return archive_handle.Code(); 274 return archive_handle.Code();
293 } 275 }
294 g_archive_map[id_code] = archive->GetHandle(); 276 g_archive_map[id_code] = archive->GetHandle();
295 INFO_LOG(KERNEL, "Mounted archive %s", archive->GetName().c_str()); 277 LOG_TRACE(Service_FS, "Mounted archive %s", archive->GetName().c_str());
296 return RESULT_SUCCESS; 278 return RESULT_SUCCESS;
297} 279}
298 280
@@ -442,7 +424,7 @@ void ArchiveInit() {
442 if (archive->Initialize()) 424 if (archive->Initialize())
443 CreateArchive(archive, "SDMC"); 425 CreateArchive(archive, "SDMC");
444 else 426 else
445 ERROR_LOG(KERNEL, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str()); 427 LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str());
446} 428}
447 429
448/// Shutdown archives 430/// Shutdown archives
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 80a34c2d5..b38be0a49 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -35,7 +35,7 @@ Handle ObjectPool::Create(Object* obj, int range_bottom, int range_top) {
35 return i + HANDLE_OFFSET; 35 return i + HANDLE_OFFSET;
36 } 36 }
37 } 37 }
38 ERROR_LOG(HLE, "Unable to allocate kernel object, too many objects slots in use."); 38 LOG_ERROR(Kernel, "Unable to allocate kernel object, too many objects slots in use.");
39 return 0; 39 return 0;
40} 40}
41 41
@@ -62,7 +62,7 @@ void ObjectPool::Clear() {
62 62
63Object* &ObjectPool::operator [](Handle handle) 63Object* &ObjectPool::operator [](Handle handle)
64{ 64{
65 _dbg_assert_msg_(KERNEL, IsValid(handle), "GRABBING UNALLOCED KERNEL OBJ"); 65 _dbg_assert_msg_(Kernel, IsValid(handle), "GRABBING UNALLOCED KERNEL OBJ");
66 return pool[handle - HANDLE_OFFSET]; 66 return pool[handle - HANDLE_OFFSET];
67} 67}
68 68
@@ -70,7 +70,7 @@ void ObjectPool::List() {
70 for (int i = 0; i < MAX_COUNT; i++) { 70 for (int i = 0; i < MAX_COUNT; i++) {
71 if (occupied[i]) { 71 if (occupied[i]) {
72 if (pool[i]) { 72 if (pool[i]) {
73 INFO_LOG(KERNEL, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName().c_str(), 73 LOG_DEBUG(Kernel, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName().c_str(),
74 pool[i]->GetName().c_str()); 74 pool[i]->GetName().c_str());
75 } 75 }
76 } 76 }
@@ -82,7 +82,7 @@ int ObjectPool::GetCount() const {
82} 82}
83 83
84Object* ObjectPool::CreateByIDType(int type) { 84Object* ObjectPool::CreateByIDType(int type) {
85 ERROR_LOG(COMMON, "Unimplemented: %d.", type); 85 LOG_ERROR(Kernel, "Unimplemented: %d.", type);
86 return nullptr; 86 return nullptr;
87} 87}
88 88
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 00a2228bf..00f9b57fc 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -57,7 +57,7 @@ public:
57 * @return True if the current thread should wait as a result of the sync 57 * @return True if the current thread should wait as a result of the sync
58 */ 58 */
59 virtual ResultVal<bool> SyncRequest() { 59 virtual ResultVal<bool> SyncRequest() {
60 ERROR_LOG(KERNEL, "(UNIMPLEMENTED)"); 60 LOG_ERROR(Kernel, "(UNIMPLEMENTED)");
61 return UnimplementedFunction(ErrorModule::Kernel); 61 return UnimplementedFunction(ErrorModule::Kernel);
62 } 62 }
63 63
@@ -65,7 +65,10 @@ public:
65 * Wait for kernel object to synchronize. 65 * Wait for kernel object to synchronize.
66 * @return True if the current thread should wait as a result of the wait 66 * @return True if the current thread should wait as a result of the wait
67 */ 67 */
68 virtual ResultVal<bool> WaitSynchronization() = 0; 68 virtual ResultVal<bool> WaitSynchronization() {
69 LOG_ERROR(Kernel, "(UNIMPLEMENTED)");
70 return UnimplementedFunction(ErrorModule::Kernel);
71 }
69}; 72};
70 73
71class ObjectPool : NonCopyable { 74class ObjectPool : NonCopyable {
@@ -92,13 +95,13 @@ public:
92 T* Get(Handle handle) { 95 T* Get(Handle handle) {
93 if (handle < HANDLE_OFFSET || handle >= HANDLE_OFFSET + MAX_COUNT || !occupied[handle - HANDLE_OFFSET]) { 96 if (handle < HANDLE_OFFSET || handle >= HANDLE_OFFSET + MAX_COUNT || !occupied[handle - HANDLE_OFFSET]) {
94 if (handle != 0) { 97 if (handle != 0) {
95 WARN_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle); 98 LOG_ERROR(Kernel, "Bad object handle %08x", handle, handle);
96 } 99 }
97 return nullptr; 100 return nullptr;
98 } else { 101 } else {
99 Object* t = pool[handle - HANDLE_OFFSET]; 102 Object* t = pool[handle - HANDLE_OFFSET];
100 if (t->GetHandleType() != T::GetStaticHandleType()) { 103 if (t->GetHandleType() != T::GetStaticHandleType()) {
101 WARN_LOG(KERNEL, "Kernel: Wrong object type for %i (%08x)", handle, handle); 104 LOG_ERROR(Kernel, "Wrong object type for %08x", handle, handle);
102 return nullptr; 105 return nullptr;
103 } 106 }
104 return static_cast<T*>(t); 107 return static_cast<T*>(t);
@@ -109,7 +112,7 @@ public:
109 template <class T> 112 template <class T>
110 T *GetFast(Handle handle) { 113 T *GetFast(Handle handle) {
111 const Handle realHandle = handle - HANDLE_OFFSET; 114 const Handle realHandle = handle - HANDLE_OFFSET;
112 _dbg_assert_(KERNEL, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]); 115 _dbg_assert_(Kernel, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]);
113 return static_cast<T*>(pool[realHandle]); 116 return static_cast<T*>(pool[realHandle]);
114 } 117 }
115 118
@@ -130,8 +133,8 @@ public:
130 133
131 bool GetIDType(Handle handle, HandleType* type) const { 134 bool GetIDType(Handle handle, HandleType* type) const {
132 if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) || 135 if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) ||
133 !occupied[handle - HANDLE_OFFSET]) { 136 !occupied[handle - HANDLE_OFFSET]) {
134 ERROR_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle); 137 LOG_ERROR(Kernel, "Bad object handle %08X", handle, handle);
135 return false; 138 return false;
136 } 139 }
137 Object* t = pool[handle - HANDLE_OFFSET]; 140 Object* t = pool[handle - HANDLE_OFFSET];
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index cfcc0e0b7..3c8c502c6 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -16,12 +16,6 @@ public:
16 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::SharedMemory; } 16 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::SharedMemory; }
17 Kernel::HandleType GetHandleType() const override { return Kernel::HandleType::SharedMemory; } 17 Kernel::HandleType GetHandleType() const override { return Kernel::HandleType::SharedMemory; }
18 18
19 ResultVal<bool> WaitSynchronization() override {
20 // TODO(bunnei): ImplementMe
21 ERROR_LOG(OSHLE, "(UNIMPLEMENTED)");
22 return UnimplementedFunction(ErrorModule::OS);
23 }
24
25 u32 base_address; ///< Address of shared memory block in RAM 19 u32 base_address; ///< Address of shared memory block in RAM
26 MemoryPermission permissions; ///< Permissions of shared memory block (SVC field) 20 MemoryPermission permissions; ///< Permissions of shared memory block (SVC field)
27 MemoryPermission other_permissions; ///< Other permissions of shared memory block (SVC field) 21 MemoryPermission other_permissions; ///< Other permissions of shared memory block (SVC field)
@@ -61,7 +55,7 @@ ResultCode MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions
61 MemoryPermission other_permissions) { 55 MemoryPermission other_permissions) {
62 56
63 if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) { 57 if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) {
64 ERROR_LOG(KERNEL, "cannot map handle=0x%08X, address=0x%08X outside of shared mem bounds!", 58 LOG_ERROR(Kernel_SVC, "cannot map handle=0x%08X, address=0x%08X outside of shared mem bounds!",
65 handle, address); 59 handle, address);
66 return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, 60 return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
67 ErrorSummary::InvalidArgument, ErrorLevel::Permanent); 61 ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
@@ -83,7 +77,7 @@ ResultVal<u8*> GetSharedMemoryPointer(Handle handle, u32 offset) {
83 if (0 != shared_memory->base_address) 77 if (0 != shared_memory->base_address)
84 return MakeResult<u8*>(Memory::GetPointer(shared_memory->base_address + offset)); 78 return MakeResult<u8*>(Memory::GetPointer(shared_memory->base_address + offset));
85 79
86 ERROR_LOG(KERNEL, "memory block handle=0x%08X not mapped!", handle); 80 LOG_ERROR(Kernel_SVC, "memory block handle=0x%08X not mapped!", handle);
87 // TODO(yuriks): Verify error code. 81 // TODO(yuriks): Verify error code.
88 return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, 82 return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
89 ErrorSummary::InvalidState, ErrorLevel::Permanent); 83 ErrorSummary::InvalidState, ErrorLevel::Permanent);
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 492b917e1..1c04701de 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -150,13 +150,13 @@ void ChangeReadyState(Thread* t, bool ready) {
150 150
151/// Verify that a thread has not been released from waiting 151/// Verify that a thread has not been released from waiting
152static bool VerifyWait(const Thread* thread, WaitType type, Handle wait_handle) { 152static bool VerifyWait(const Thread* thread, WaitType type, Handle wait_handle) {
153 _dbg_assert_(KERNEL, thread != nullptr); 153 _dbg_assert_(Kernel, thread != nullptr);
154 return (type == thread->wait_type) && (wait_handle == thread->wait_handle) && (thread->IsWaiting()); 154 return (type == thread->wait_type) && (wait_handle == thread->wait_handle) && (thread->IsWaiting());
155} 155}
156 156
157/// Verify that a thread has not been released from waiting (with wait address) 157/// Verify that a thread has not been released from waiting (with wait address)
158static bool VerifyWait(const Thread* thread, WaitType type, Handle wait_handle, VAddr wait_address) { 158static bool VerifyWait(const Thread* thread, WaitType type, Handle wait_handle, VAddr wait_address) {
159 _dbg_assert_(KERNEL, thread != nullptr); 159 _dbg_assert_(Kernel, thread != nullptr);
160 return VerifyWait(thread, type, wait_handle) && (wait_address == thread->wait_address); 160 return VerifyWait(thread, type, wait_handle) && (wait_address == thread->wait_address);
161} 161}
162 162
@@ -196,7 +196,7 @@ void ChangeThreadState(Thread* t, ThreadStatus new_status) {
196 196
197 if (new_status == THREADSTATUS_WAIT) { 197 if (new_status == THREADSTATUS_WAIT) {
198 if (t->wait_type == WAITTYPE_NONE) { 198 if (t->wait_type == WAITTYPE_NONE) {
199 ERROR_LOG(KERNEL, "Waittype none not allowed"); 199 LOG_ERROR(Kernel, "Waittype none not allowed");
200 } 200 }
201 } 201 }
202} 202}
@@ -318,12 +318,12 @@ void DebugThreadQueue() {
318 if (!thread) { 318 if (!thread) {
319 return; 319 return;
320 } 320 }
321 INFO_LOG(KERNEL, "0x%02X 0x%08X (current)", thread->current_priority, GetCurrentThreadHandle()); 321 LOG_DEBUG(Kernel, "0x%02X 0x%08X (current)", thread->current_priority, GetCurrentThreadHandle());
322 for (u32 i = 0; i < thread_queue.size(); i++) { 322 for (u32 i = 0; i < thread_queue.size(); i++) {
323 Handle handle = thread_queue[i]; 323 Handle handle = thread_queue[i];
324 s32 priority = thread_ready_queue.contains(handle); 324 s32 priority = thread_ready_queue.contains(handle);
325 if (priority != -1) { 325 if (priority != -1) {
326 INFO_LOG(KERNEL, "0x%02X 0x%08X", priority, handle); 326 LOG_DEBUG(Kernel, "0x%02X 0x%08X", priority, handle);
327 } 327 }
328 } 328 }
329} 329}
@@ -333,7 +333,7 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio
333 s32 processor_id, u32 stack_top, int stack_size) { 333 s32 processor_id, u32 stack_top, int stack_size) {
334 334
335 _assert_msg_(KERNEL, (priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST), 335 _assert_msg_(KERNEL, (priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST),
336 "CreateThread priority=%d, outside of allowable range!", priority) 336 "priority=%d, outside of allowable range!", priority)
337 337
338 Thread* thread = new Thread; 338 Thread* thread = new Thread;
339 339
@@ -362,24 +362,24 @@ Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s3
362 u32 stack_top, int stack_size) { 362 u32 stack_top, int stack_size) {
363 363
364 if (name == nullptr) { 364 if (name == nullptr) {
365 ERROR_LOG(KERNEL, "CreateThread(): nullptr name"); 365 LOG_ERROR(Kernel_SVC, "nullptr name");
366 return -1; 366 return -1;
367 } 367 }
368 if ((u32)stack_size < 0x200) { 368 if ((u32)stack_size < 0x200) {
369 ERROR_LOG(KERNEL, "CreateThread(name=%s): invalid stack_size=0x%08X", name, 369 LOG_ERROR(Kernel_SVC, "(name=%s): invalid stack_size=0x%08X", name,
370 stack_size); 370 stack_size);
371 return -1; 371 return -1;
372 } 372 }
373 if (priority < THREADPRIO_HIGHEST || priority > THREADPRIO_LOWEST) { 373 if (priority < THREADPRIO_HIGHEST || priority > THREADPRIO_LOWEST) {
374 s32 new_priority = CLAMP(priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST); 374 s32 new_priority = CLAMP(priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST);
375 WARN_LOG(KERNEL, "CreateThread(name=%s): invalid priority=0x%08X, clamping to %08X", 375 LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d",
376 name, priority, new_priority); 376 name, priority, new_priority);
377 // TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm 377 // TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm
378 // validity of this 378 // validity of this
379 priority = new_priority; 379 priority = new_priority;
380 } 380 }
381 if (!Memory::GetPointer(entry_point)) { 381 if (!Memory::GetPointer(entry_point)) {
382 ERROR_LOG(KERNEL, "CreateThread(name=%s): invalid entry %08x", name, entry_point); 382 LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %08x", name, entry_point);
383 return -1; 383 return -1;
384 } 384 }
385 Handle handle; 385 Handle handle;
@@ -416,7 +416,7 @@ ResultCode SetThreadPriority(Handle handle, s32 priority) {
416 // If priority is invalid, clamp to valid range 416 // If priority is invalid, clamp to valid range
417 if (priority < THREADPRIO_HIGHEST || priority > THREADPRIO_LOWEST) { 417 if (priority < THREADPRIO_HIGHEST || priority > THREADPRIO_LOWEST) {
418 s32 new_priority = CLAMP(priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST); 418 s32 new_priority = CLAMP(priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST);
419 WARN_LOG(KERNEL, "invalid priority=0x%08X, clamping to %08X", priority, new_priority); 419 LOG_WARNING(Kernel_SVC, "invalid priority=%d, clamping to %d", priority, new_priority);
420 // TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm 420 // TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm
421 // validity of this 421 // validity of this
422 priority = new_priority; 422 priority = new_priority;
@@ -470,7 +470,7 @@ void Reschedule() {
470 Thread* next = NextThread(); 470 Thread* next = NextThread();
471 HLE::g_reschedule = false; 471 HLE::g_reschedule = false;
472 if (next > 0) { 472 if (next > 0) {
473 INFO_LOG(KERNEL, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle()); 473 LOG_TRACE(Kernel, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle());
474 474
475 SwitchContext(next); 475 SwitchContext(next);
476 476
diff --git a/src/core/hle/service/ac_u.cpp b/src/core/hle/service/ac_u.cpp
index 46aee40d6..4130feb9d 100644
--- a/src/core/hle/service/ac_u.cpp
+++ b/src/core/hle/service/ac_u.cpp
@@ -26,7 +26,7 @@ void GetWifiStatus(Service::Interface* self) {
26 cmd_buff[1] = 0; // No error 26 cmd_buff[1] = 0; // No error
27 cmd_buff[2] = 0; // Connection type set to none 27 cmd_buff[2] = 0; // Connection type set to none
28 28
29 WARN_LOG(KERNEL, "(STUBBED) called"); 29 LOG_WARNING(Service_AC, "(STUBBED) called");
30} 30}
31 31
32const Interface::FunctionInfo FunctionTable[] = { 32const Interface::FunctionInfo FunctionTable[] = {
diff --git a/src/core/hle/service/apt_u.cpp b/src/core/hle/service/apt_u.cpp
index 181763724..b6d5d101f 100644
--- a/src/core/hle/service/apt_u.cpp
+++ b/src/core/hle/service/apt_u.cpp
@@ -53,7 +53,7 @@ void Initialize(Service::Interface* self) {
53 53
54 cmd_buff[1] = 0; // No error 54 cmd_buff[1] = 0; // No error
55 55
56 DEBUG_LOG(KERNEL, "called"); 56 LOG_DEBUG(Service_APT, "called");
57} 57}
58 58
59void GetLockHandle(Service::Interface* self) { 59void GetLockHandle(Service::Interface* self) {
@@ -74,14 +74,14 @@ void GetLockHandle(Service::Interface* self) {
74 cmd_buff[4] = 0; 74 cmd_buff[4] = 0;
75 75
76 cmd_buff[5] = lock_handle; 76 cmd_buff[5] = lock_handle;
77 DEBUG_LOG(KERNEL, "called handle=0x%08X", cmd_buff[5]); 77 LOG_TRACE(Service_APT, "called handle=0x%08X", cmd_buff[5]);
78} 78}
79 79
80void Enable(Service::Interface* self) { 80void Enable(Service::Interface* self) {
81 u32* cmd_buff = Service::GetCommandBuffer(); 81 u32* cmd_buff = Service::GetCommandBuffer();
82 u32 unk = cmd_buff[1]; // TODO(bunnei): What is this field used for? 82 u32 unk = cmd_buff[1]; // TODO(bunnei): What is this field used for?
83 cmd_buff[1] = 0; // No error 83 cmd_buff[1] = 0; // No error
84 WARN_LOG(KERNEL, "(STUBBED) called unk=0x%08X", unk); 84 LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X", unk);
85} 85}
86 86
87void InquireNotification(Service::Interface* self) { 87void InquireNotification(Service::Interface* self) {
@@ -89,7 +89,7 @@ void InquireNotification(Service::Interface* self) {
89 u32 app_id = cmd_buff[2]; 89 u32 app_id = cmd_buff[2];
90 cmd_buff[1] = 0; // No error 90 cmd_buff[1] = 0; // No error
91 cmd_buff[2] = static_cast<u32>(SignalType::None); // Signal type 91 cmd_buff[2] = static_cast<u32>(SignalType::None); // Signal type
92 WARN_LOG(KERNEL, "(STUBBED) called app_id=0x%08X", app_id); 92 LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id);
93} 93}
94 94
95/** 95/**
@@ -122,7 +122,7 @@ void ReceiveParameter(Service::Interface* self) {
122 cmd_buff[5] = 0; 122 cmd_buff[5] = 0;
123 cmd_buff[6] = 0; 123 cmd_buff[6] = 0;
124 cmd_buff[7] = 0; 124 cmd_buff[7] = 0;
125 WARN_LOG(KERNEL, "(STUBBED) called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); 125 LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size);
126} 126}
127 127
128/** 128/**
@@ -155,7 +155,7 @@ void GlanceParameter(Service::Interface* self) {
155 cmd_buff[6] = 0; 155 cmd_buff[6] = 0;
156 cmd_buff[7] = 0; 156 cmd_buff[7] = 0;
157 157
158 WARN_LOG(KERNEL, "(STUBBED) called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); 158 LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size);
159} 159}
160 160
161/** 161/**
@@ -181,7 +181,7 @@ void AppletUtility(Service::Interface* self) {
181 181
182 cmd_buff[1] = 0; // No error 182 cmd_buff[1] = 0; // No error
183 183
184 WARN_LOG(KERNEL, "(STUBBED) called unk=0x%08X, buffer1_size=0x%08x, buffer2_size=0x%08x, " 184 LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X, buffer1_size=0x%08x, buffer2_size=0x%08x, "
185 "buffer1_addr=0x%08x, buffer2_addr=0x%08x", unk, buffer1_size, buffer2_size, 185 "buffer1_addr=0x%08x, buffer2_addr=0x%08x", unk, buffer1_size, buffer2_size,
186 buffer1_addr, buffer2_addr); 186 buffer1_addr, buffer2_addr);
187} 187}
@@ -194,7 +194,7 @@ void AppletUtility(Service::Interface* self) {
194 * 4 : Handle to shared font memory 194 * 4 : Handle to shared font memory
195 */ 195 */
196void GetSharedFont(Service::Interface* self) { 196void GetSharedFont(Service::Interface* self) {
197 DEBUG_LOG(KERNEL, "called"); 197 LOG_TRACE(Kernel_SVC, "called");
198 198
199 u32* cmd_buff = Service::GetCommandBuffer(); 199 u32* cmd_buff = Service::GetCommandBuffer();
200 200
@@ -210,7 +210,7 @@ void GetSharedFont(Service::Interface* self) {
210 cmd_buff[4] = shared_font_mem; 210 cmd_buff[4] = shared_font_mem;
211 } else { 211 } else {
212 cmd_buff[1] = -1; // Generic error (not really possible to verify this on hardware) 212 cmd_buff[1] = -1; // Generic error (not really possible to verify this on hardware)
213 ERROR_LOG(KERNEL, "called, but %s has not been loaded!", SHARED_FONT); 213 LOG_ERROR(Kernel_SVC, "called, but %s has not been loaded!", SHARED_FONT);
214 } 214 }
215} 215}
216 216
@@ -321,7 +321,7 @@ Interface::Interface() {
321 // Create shared font memory object 321 // Create shared font memory object
322 shared_font_mem = Kernel::CreateSharedMemory("APT_U:shared_font_mem"); 322 shared_font_mem = Kernel::CreateSharedMemory("APT_U:shared_font_mem");
323 } else { 323 } else {
324 WARN_LOG(KERNEL, "Unable to load shared font: %s", filepath.c_str()); 324 LOG_WARNING(Service_APT, "Unable to load shared font: %s", filepath.c_str());
325 shared_font_mem = 0; 325 shared_font_mem = 0;
326 } 326 }
327 327
diff --git a/src/core/hle/service/cfg_u.cpp b/src/core/hle/service/cfg_u.cpp
index 82bab5797..972cc0534 100644
--- a/src/core/hle/service/cfg_u.cpp
+++ b/src/core/hle/service/cfg_u.cpp
@@ -56,7 +56,7 @@ static void GetCountryCodeString(Service::Interface* self) {
56 u32 country_code_id = cmd_buffer[1]; 56 u32 country_code_id = cmd_buffer[1];
57 57
58 if (country_code_id >= country_codes.size() || 0 == country_codes[country_code_id]) { 58 if (country_code_id >= country_codes.size() || 0 == country_codes[country_code_id]) {
59 ERROR_LOG(KERNEL, "requested country code id=%d is invalid", country_code_id); 59 LOG_ERROR(Service_CFG, "requested country code id=%d is invalid", country_code_id);
60 cmd_buffer[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw; 60 cmd_buffer[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw;
61 return; 61 return;
62 } 62 }
@@ -79,7 +79,7 @@ static void GetCountryCodeID(Service::Interface* self) {
79 u16 country_code_id = 0; 79 u16 country_code_id = 0;
80 80
81 // The following algorithm will fail if the first country code isn't 0. 81 // The following algorithm will fail if the first country code isn't 0.
82 _dbg_assert_(HLE, country_codes[0] == 0); 82 _dbg_assert_(Service_CFG, country_codes[0] == 0);
83 83
84 for (size_t id = 0; id < country_codes.size(); ++id) { 84 for (size_t id = 0; id < country_codes.size(); ++id) {
85 if (country_codes[id] == country_code) { 85 if (country_codes[id] == country_code) {
@@ -89,7 +89,7 @@ static void GetCountryCodeID(Service::Interface* self) {
89 } 89 }
90 90
91 if (0 == country_code_id) { 91 if (0 == country_code_id) {
92 ERROR_LOG(KERNEL, "requested country code name=%c%c is invalid", country_code & 0xff, country_code >> 8); 92 LOG_ERROR(Service_CFG, "requested country code name=%c%c is invalid", country_code & 0xff, country_code >> 8);
93 cmd_buffer[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw; 93 cmd_buffer[1] = ResultCode(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw;
94 cmd_buffer[2] = 0xFFFF; 94 cmd_buffer[2] = 0xFFFF;
95 return; 95 return;
diff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cpp
index e89c8aae3..ce1c9938d 100644
--- a/src/core/hle/service/dsp_dsp.cpp
+++ b/src/core/hle/service/dsp_dsp.cpp
@@ -32,7 +32,7 @@ void ConvertProcessAddressFromDspDram(Service::Interface* self) {
32 cmd_buff[1] = 0; // No error 32 cmd_buff[1] = 0; // No error
33 cmd_buff[2] = (addr << 1) + (Memory::DSP_MEMORY_VADDR + 0x40000); 33 cmd_buff[2] = (addr << 1) + (Memory::DSP_MEMORY_VADDR + 0x40000);
34 34
35 DEBUG_LOG(KERNEL, "(STUBBED) called with address %u", addr); 35 LOG_WARNING(Service_DSP, "(STUBBED) called with address %u", addr);
36} 36}
37 37
38/** 38/**
@@ -55,7 +55,7 @@ void LoadComponent(Service::Interface* self) {
55 55
56 // TODO(bunnei): Implement real DSP firmware loading 56 // TODO(bunnei): Implement real DSP firmware loading
57 57
58 DEBUG_LOG(KERNEL, "(STUBBED) called"); 58 LOG_WARNING(Service_DSP, "(STUBBED) called");
59} 59}
60 60
61/** 61/**
@@ -70,7 +70,7 @@ void GetSemaphoreEventHandle(Service::Interface* self) {
70 cmd_buff[1] = 0; // No error 70 cmd_buff[1] = 0; // No error
71 cmd_buff[3] = semaphore_event; // Event handle 71 cmd_buff[3] = semaphore_event; // Event handle
72 72
73 DEBUG_LOG(KERNEL, "(STUBBED) called"); 73 LOG_WARNING(Service_DSP, "(STUBBED) called");
74} 74}
75 75
76/** 76/**
@@ -89,7 +89,7 @@ void RegisterInterruptEvents(Service::Interface* self) {
89 89
90 cmd_buff[1] = 0; // No error 90 cmd_buff[1] = 0; // No error
91 91
92 DEBUG_LOG(KERNEL, "(STUBBED) called"); 92 LOG_WARNING(Service_DSP, "(STUBBED) called");
93} 93}
94 94
95/** 95/**
@@ -106,7 +106,7 @@ void WriteReg0x10(Service::Interface* self) {
106 106
107 cmd_buff[1] = 0; // No error 107 cmd_buff[1] = 0; // No error
108 108
109 DEBUG_LOG(KERNEL, "(STUBBED) called"); 109 LOG_WARNING(Service_DSP, "(STUBBED) called");
110} 110}
111 111
112/** 112/**
@@ -140,7 +140,7 @@ void ReadPipeIfPossible(Service::Interface* self) {
140 Memory::Write16(addr + offset, canned_read_pipe[read_pipe_count]); 140 Memory::Write16(addr + offset, canned_read_pipe[read_pipe_count]);
141 read_pipe_count++; 141 read_pipe_count++;
142 } else { 142 } else {
143 ERROR_LOG(KERNEL, "canned read pipe log exceeded!"); 143 LOG_ERROR(Service_DSP, "canned read pipe log exceeded!");
144 break; 144 break;
145 } 145 }
146 } 146 }
@@ -148,7 +148,7 @@ void ReadPipeIfPossible(Service::Interface* self) {
148 cmd_buff[1] = 0; // No error 148 cmd_buff[1] = 0; // No error
149 cmd_buff[2] = (read_pipe_count - initial_size) * sizeof(u16); 149 cmd_buff[2] = (read_pipe_count - initial_size) * sizeof(u16);
150 150
151 DEBUG_LOG(KERNEL, "(STUBBED) called size=0x%08X, buffer=0x%08X", size, addr); 151 LOG_WARNING(Service_DSP, "(STUBBED) called size=0x%08X, buffer=0x%08X", size, addr);
152} 152}
153 153
154const Interface::FunctionInfo FunctionTable[] = { 154const Interface::FunctionInfo FunctionTable[] = {
diff --git a/src/core/hle/service/fs_user.cpp b/src/core/hle/service/fs_user.cpp
index 51e8b579e..9bda4fe8a 100644
--- a/src/core/hle/service/fs_user.cpp
+++ b/src/core/hle/service/fs_user.cpp
@@ -23,7 +23,7 @@ static void Initialize(Service::Interface* self) {
23 // http://3dbrew.org/wiki/FS:Initialize#Request 23 // http://3dbrew.org/wiki/FS:Initialize#Request
24 cmd_buff[1] = RESULT_SUCCESS.raw; 24 cmd_buff[1] = RESULT_SUCCESS.raw;
25 25
26 DEBUG_LOG(KERNEL, "called"); 26 LOG_DEBUG(Service_FS, "called");
27} 27}
28 28
29/** 29/**
@@ -55,17 +55,15 @@ static void OpenFile(Service::Interface* self) {
55 u32 filename_ptr = cmd_buff[9]; 55 u32 filename_ptr = cmd_buff[9];
56 FileSys::Path file_path(filename_type, filename_size, filename_ptr); 56 FileSys::Path file_path(filename_type, filename_size, filename_ptr);
57 57
58 DEBUG_LOG(KERNEL, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex, attributes); 58 LOG_DEBUG(Service_FS, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex, attributes);
59 59
60 ResultVal<Handle> handle = Kernel::OpenFileFromArchive(archive_handle, file_path, mode); 60 ResultVal<Handle> handle = Kernel::OpenFileFromArchive(archive_handle, file_path, mode);
61 cmd_buff[1] = handle.Code().raw; 61 cmd_buff[1] = handle.Code().raw;
62 if (handle.Succeeded()) { 62 if (handle.Succeeded()) {
63 cmd_buff[3] = *handle; 63 cmd_buff[3] = *handle;
64 } else { 64 } else {
65 ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_path.DebugStr().c_str()); 65 LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str());
66 } 66 }
67
68 DEBUG_LOG(KERNEL, "called");
69} 67}
70 68
71/** 69/**
@@ -102,11 +100,11 @@ static void OpenFileDirectly(Service::Interface* self) {
102 FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr); 100 FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
103 FileSys::Path file_path(filename_type, filename_size, filename_ptr); 101 FileSys::Path file_path(filename_type, filename_size, filename_ptr);
104 102
105 DEBUG_LOG(KERNEL, "archive_path=%s file_path=%s, mode=%u attributes=%d", 103 LOG_DEBUG(Service_FS, "archive_path=%s file_path=%s, mode=%u attributes=%d",
106 archive_path.DebugStr().c_str(), file_path.DebugStr().c_str(), mode.hex, attributes); 104 archive_path.DebugStr().c_str(), file_path.DebugStr().c_str(), mode.hex, attributes);
107 105
108 if (archive_path.GetType() != FileSys::Empty) { 106 if (archive_path.GetType() != FileSys::Empty) {
109 ERROR_LOG(KERNEL, "archive LowPath type other than empty is currently unsupported"); 107 LOG_ERROR(Service_FS, "archive LowPath type other than empty is currently unsupported");
110 cmd_buff[1] = UnimplementedFunction(ErrorModule::FS).raw; 108 cmd_buff[1] = UnimplementedFunction(ErrorModule::FS).raw;
111 return; 109 return;
112 } 110 }
@@ -116,7 +114,7 @@ static void OpenFileDirectly(Service::Interface* self) {
116 ResultVal<Handle> archive_handle = Kernel::OpenArchive(archive_id); 114 ResultVal<Handle> archive_handle = Kernel::OpenArchive(archive_id);
117 cmd_buff[1] = archive_handle.Code().raw; 115 cmd_buff[1] = archive_handle.Code().raw;
118 if (archive_handle.Failed()) { 116 if (archive_handle.Failed()) {
119 ERROR_LOG(KERNEL, "failed to get a handle for archive"); 117 LOG_ERROR(Service_FS, "failed to get a handle for archive");
120 return; 118 return;
121 } 119 }
122 // cmd_buff[2] isn't used according to 3dmoo's implementation. 120 // cmd_buff[2] isn't used according to 3dmoo's implementation.
@@ -127,10 +125,8 @@ static void OpenFileDirectly(Service::Interface* self) {
127 if (handle.Succeeded()) { 125 if (handle.Succeeded()) {
128 cmd_buff[3] = *handle; 126 cmd_buff[3] = *handle;
129 } else { 127 } else {
130 ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_path.DebugStr().c_str()); 128 LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str());
131 } 129 }
132
133 DEBUG_LOG(KERNEL, "called");
134} 130}
135 131
136/* 132/*
@@ -156,12 +152,10 @@ void DeleteFile(Service::Interface* self) {
156 152
157 FileSys::Path file_path(filename_type, filename_size, filename_ptr); 153 FileSys::Path file_path(filename_type, filename_size, filename_ptr);
158 154
159 DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", 155 LOG_DEBUG(Service_FS, "type=%d size=%d data=%s",
160 filename_type, filename_size, file_path.DebugStr().c_str()); 156 filename_type, filename_size, file_path.DebugStr().c_str());
161 157
162 cmd_buff[1] = Kernel::DeleteFileFromArchive(archive_handle, file_path).raw; 158 cmd_buff[1] = Kernel::DeleteFileFromArchive(archive_handle, file_path).raw;
163
164 DEBUG_LOG(KERNEL, "called");
165} 159}
166 160
167/* 161/*
@@ -197,13 +191,11 @@ void RenameFile(Service::Interface* self) {
197 FileSys::Path src_file_path(src_filename_type, src_filename_size, src_filename_ptr); 191 FileSys::Path src_file_path(src_filename_type, src_filename_size, src_filename_ptr);
198 FileSys::Path dest_file_path(dest_filename_type, dest_filename_size, dest_filename_ptr); 192 FileSys::Path dest_file_path(dest_filename_type, dest_filename_size, dest_filename_ptr);
199 193
200 DEBUG_LOG(KERNEL, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s", 194 LOG_DEBUG(Service_FS, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
201 src_filename_type, src_filename_size, src_file_path.DebugStr().c_str(), 195 src_filename_type, src_filename_size, src_file_path.DebugStr().c_str(),
202 dest_filename_type, dest_filename_size, dest_file_path.DebugStr().c_str()); 196 dest_filename_type, dest_filename_size, dest_file_path.DebugStr().c_str());
203 197
204 cmd_buff[1] = Kernel::RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle, dest_file_path).raw; 198 cmd_buff[1] = Kernel::RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle, dest_file_path).raw;
205
206 DEBUG_LOG(KERNEL, "called");
207} 199}
208 200
209/* 201/*
@@ -229,12 +221,10 @@ void DeleteDirectory(Service::Interface* self) {
229 221
230 FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr); 222 FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
231 223
232 DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", 224 LOG_DEBUG(Service_FS, "type=%d size=%d data=%s",
233 dirname_type, dirname_size, dir_path.DebugStr().c_str()); 225 dirname_type, dirname_size, dir_path.DebugStr().c_str());
234 226
235 cmd_buff[1] = Kernel::DeleteDirectoryFromArchive(archive_handle, dir_path).raw; 227 cmd_buff[1] = Kernel::DeleteDirectoryFromArchive(archive_handle, dir_path).raw;
236
237 DEBUG_LOG(KERNEL, "called");
238} 228}
239 229
240/* 230/*
@@ -260,11 +250,9 @@ static void CreateDirectory(Service::Interface* self) {
260 250
261 FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr); 251 FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
262 252
263 DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str()); 253 LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str());
264 254
265 cmd_buff[1] = Kernel::CreateDirectoryFromArchive(archive_handle, dir_path).raw; 255 cmd_buff[1] = Kernel::CreateDirectoryFromArchive(archive_handle, dir_path).raw;
266
267 DEBUG_LOG(KERNEL, "called");
268} 256}
269 257
270/* 258/*
@@ -300,13 +288,11 @@ void RenameDirectory(Service::Interface* self) {
300 FileSys::Path src_dir_path(src_dirname_type, src_dirname_size, src_dirname_ptr); 288 FileSys::Path src_dir_path(src_dirname_type, src_dirname_size, src_dirname_ptr);
301 FileSys::Path dest_dir_path(dest_dirname_type, dest_dirname_size, dest_dirname_ptr); 289 FileSys::Path dest_dir_path(dest_dirname_type, dest_dirname_size, dest_dirname_ptr);
302 290
303 DEBUG_LOG(KERNEL, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s", 291 LOG_DEBUG(Service_FS, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
304 src_dirname_type, src_dirname_size, src_dir_path.DebugStr().c_str(), 292 src_dirname_type, src_dirname_size, src_dir_path.DebugStr().c_str(),
305 dest_dirname_type, dest_dirname_size, dest_dir_path.DebugStr().c_str()); 293 dest_dirname_type, dest_dirname_size, dest_dir_path.DebugStr().c_str());
306 294
307 cmd_buff[1] = Kernel::RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path, dest_archive_handle, dest_dir_path).raw; 295 cmd_buff[1] = Kernel::RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path, dest_archive_handle, dest_dir_path).raw;
308
309 DEBUG_LOG(KERNEL, "called");
310} 296}
311 297
312static void OpenDirectory(Service::Interface* self) { 298static void OpenDirectory(Service::Interface* self) {
@@ -321,17 +307,15 @@ static void OpenDirectory(Service::Interface* self) {
321 307
322 FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr); 308 FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
323 309
324 DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str()); 310 LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str());
325 311
326 ResultVal<Handle> handle = Kernel::OpenDirectoryFromArchive(archive_handle, dir_path); 312 ResultVal<Handle> handle = Kernel::OpenDirectoryFromArchive(archive_handle, dir_path);
327 cmd_buff[1] = handle.Code().raw; 313 cmd_buff[1] = handle.Code().raw;
328 if (handle.Succeeded()) { 314 if (handle.Succeeded()) {
329 cmd_buff[3] = *handle; 315 cmd_buff[3] = *handle;
330 } else { 316 } else {
331 ERROR_LOG(KERNEL, "failed to get a handle for directory"); 317 LOG_ERROR(Service_FS, "failed to get a handle for directory");
332 } 318 }
333
334 DEBUG_LOG(KERNEL, "called");
335} 319}
336 320
337/** 321/**
@@ -356,10 +340,10 @@ static void OpenArchive(Service::Interface* self) {
356 u32 archivename_ptr = cmd_buff[5]; 340 u32 archivename_ptr = cmd_buff[5];
357 FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr); 341 FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
358 342
359 DEBUG_LOG(KERNEL, "archive_path=%s", archive_path.DebugStr().c_str()); 343 LOG_DEBUG(Service_FS, "archive_path=%s", archive_path.DebugStr().c_str());
360 344
361 if (archive_path.GetType() != FileSys::Empty) { 345 if (archive_path.GetType() != FileSys::Empty) {
362 ERROR_LOG(KERNEL, "archive LowPath type other than empty is currently unsupported"); 346 LOG_ERROR(Service_FS, "archive LowPath type other than empty is currently unsupported");
363 cmd_buff[1] = UnimplementedFunction(ErrorModule::FS).raw; 347 cmd_buff[1] = UnimplementedFunction(ErrorModule::FS).raw;
364 return; 348 return;
365 } 349 }
@@ -370,10 +354,8 @@ static void OpenArchive(Service::Interface* self) {
370 // cmd_buff[2] isn't used according to 3dmoo's implementation. 354 // cmd_buff[2] isn't used according to 3dmoo's implementation.
371 cmd_buff[3] = *handle; 355 cmd_buff[3] = *handle;
372 } else { 356 } else {
373 ERROR_LOG(KERNEL, "failed to get a handle for archive"); 357 LOG_ERROR(Service_FS, "failed to get a handle for archive");
374 } 358 }
375
376 DEBUG_LOG(KERNEL, "called");
377} 359}
378 360
379/* 361/*
@@ -388,7 +370,7 @@ static void IsSdmcDetected(Service::Interface* self) {
388 cmd_buff[1] = 0; 370 cmd_buff[1] = 0;
389 cmd_buff[2] = Settings::values.use_virtual_sd ? 1 : 0; 371 cmd_buff[2] = Settings::values.use_virtual_sd ? 1 : 0;
390 372
391 DEBUG_LOG(KERNEL, "called"); 373 LOG_DEBUG(Service_FS, "called");
392} 374}
393 375
394const Interface::FunctionInfo FunctionTable[] = { 376const Interface::FunctionInfo FunctionTable[] = {
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp
index 34eabac45..223800560 100644
--- a/src/core/hle/service/gsp_gpu.cpp
+++ b/src/core/hle/service/gsp_gpu.cpp
@@ -33,7 +33,7 @@ static inline u8* GetCommandBuffer(u32 thread_id) {
33} 33}
34 34
35static inline FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { 35static inline FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) {
36 _dbg_assert_msg_(GSP, screen_index < 2, "Invalid screen index"); 36 _dbg_assert_msg_(Service_GSP, screen_index < 2, "Invalid screen index");
37 37
38 // For each thread there are two FrameBufferUpdate fields 38 // For each thread there are two FrameBufferUpdate fields
39 u32 offset = 0x200 + (2 * thread_id + screen_index) * sizeof(FrameBufferUpdate); 39 u32 offset = 0x200 + (2 * thread_id + screen_index) * sizeof(FrameBufferUpdate);
@@ -50,14 +50,14 @@ static inline InterruptRelayQueue* GetInterruptRelayQueue(u32 thread_id) {
50static void WriteHWRegs(u32 base_address, u32 size_in_bytes, const u32* data) { 50static void WriteHWRegs(u32 base_address, u32 size_in_bytes, const u32* data) {
51 // TODO: Return proper error codes 51 // TODO: Return proper error codes
52 if (base_address + size_in_bytes >= 0x420000) { 52 if (base_address + size_in_bytes >= 0x420000) {
53 ERROR_LOG(GPU, "Write address out of range! (address=0x%08x, size=0x%08x)", 53 LOG_ERROR(Service_GSP, "Write address out of range! (address=0x%08x, size=0x%08x)",
54 base_address, size_in_bytes); 54 base_address, size_in_bytes);
55 return; 55 return;
56 } 56 }
57 57
58 // size should be word-aligned 58 // size should be word-aligned
59 if ((size_in_bytes % 4) != 0) { 59 if ((size_in_bytes % 4) != 0) {
60 ERROR_LOG(GPU, "Invalid size 0x%08x", size_in_bytes); 60 LOG_ERROR(Service_GSP, "Invalid size 0x%08x", size_in_bytes);
61 return; 61 return;
62 } 62 }
63 63
@@ -89,13 +89,13 @@ static void ReadHWRegs(Service::Interface* self) {
89 89
90 // TODO: Return proper error codes 90 // TODO: Return proper error codes
91 if (reg_addr + size >= 0x420000) { 91 if (reg_addr + size >= 0x420000) {
92 ERROR_LOG(GPU, "Read address out of range! (address=0x%08x, size=0x%08x)", reg_addr, size); 92 LOG_ERROR(Service_GSP, "Read address out of range! (address=0x%08x, size=0x%08x)", reg_addr, size);
93 return; 93 return;
94 } 94 }
95 95
96 // size should be word-aligned 96 // size should be word-aligned
97 if ((size % 4) != 0) { 97 if ((size % 4) != 0) {
98 ERROR_LOG(GPU, "Invalid size 0x%08x", size); 98 LOG_ERROR(Service_GSP, "Invalid size 0x%08x", size);
99 return; 99 return;
100 } 100 }
101 101
@@ -177,11 +177,11 @@ static void RegisterInterruptRelayQueue(Service::Interface* self) {
177 */ 177 */
178void SignalInterrupt(InterruptId interrupt_id) { 178void SignalInterrupt(InterruptId interrupt_id) {
179 if (0 == g_interrupt_event) { 179 if (0 == g_interrupt_event) {
180 WARN_LOG(GSP, "cannot synchronize until GSP event has been created!"); 180 LOG_WARNING(Service_GSP, "cannot synchronize until GSP event has been created!");
181 return; 181 return;
182 } 182 }
183 if (0 == g_shared_memory) { 183 if (0 == g_shared_memory) {
184 WARN_LOG(GSP, "cannot synchronize until GSP shared memory has been created!"); 184 LOG_WARNING(Service_GSP, "cannot synchronize until GSP shared memory has been created!");
185 return; 185 return;
186 } 186 }
187 for (int thread_id = 0; thread_id < 0x4; ++thread_id) { 187 for (int thread_id = 0; thread_id < 0x4; ++thread_id) {
@@ -298,14 +298,14 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
298 } 298 }
299 299
300 default: 300 default:
301 ERROR_LOG(GSP, "unknown command 0x%08X", (int)command.id.Value()); 301 LOG_ERROR(Service_GSP, "unknown command 0x%08X", (int)command.id.Value());
302 } 302 }
303} 303}
304 304
305/// This triggers handling of the GX command written to the command buffer in shared memory. 305/// This triggers handling of the GX command written to the command buffer in shared memory.
306static void TriggerCmdReqQueue(Service::Interface* self) { 306static void TriggerCmdReqQueue(Service::Interface* self) {
307 307
308 DEBUG_LOG(GSP, "called"); 308 LOG_TRACE(Service_GSP, "called");
309 309
310 // Iterate through each thread's command queue... 310 // Iterate through each thread's command queue...
311 for (unsigned thread_id = 0; thread_id < 0x4; ++thread_id) { 311 for (unsigned thread_id = 0; thread_id < 0x4; ++thread_id) {
diff --git a/src/core/hle/service/hid_user.cpp b/src/core/hle/service/hid_user.cpp
index 2abaf0f2f..5772199d4 100644
--- a/src/core/hle/service/hid_user.cpp
+++ b/src/core/hle/service/hid_user.cpp
@@ -163,7 +163,7 @@ static void GetIPCHandles(Service::Interface* self) {
163 cmd_buff[7] = event_gyroscope; 163 cmd_buff[7] = event_gyroscope;
164 cmd_buff[8] = event_debug_pad; 164 cmd_buff[8] = event_debug_pad;
165 165
166 DEBUG_LOG(KERNEL, "called"); 166 LOG_TRACE(Service_HID, "called");
167} 167}
168 168
169const Interface::FunctionInfo FunctionTable[] = { 169const Interface::FunctionInfo FunctionTable[] = {
diff --git a/src/core/hle/service/ptm_u.cpp b/src/core/hle/service/ptm_u.cpp
index 941df467b..559f148dd 100644
--- a/src/core/hle/service/ptm_u.cpp
+++ b/src/core/hle/service/ptm_u.cpp
@@ -42,7 +42,7 @@ static void GetAdapterState(Service::Interface* self) {
42 cmd_buff[1] = 0; // No error 42 cmd_buff[1] = 0; // No error
43 cmd_buff[2] = battery_is_charging ? 1 : 0; 43 cmd_buff[2] = battery_is_charging ? 1 : 0;
44 44
45 WARN_LOG(KERNEL, "(STUBBED) called"); 45 LOG_WARNING(Service_PTM, "(STUBBED) called");
46} 46}
47 47
48/* 48/*
@@ -57,7 +57,7 @@ static void GetShellState(Service::Interface* self) {
57 cmd_buff[1] = 0; 57 cmd_buff[1] = 0;
58 cmd_buff[2] = shell_open ? 1 : 0; 58 cmd_buff[2] = shell_open ? 1 : 0;
59 59
60 DEBUG_LOG(KERNEL, "PTM_U::GetShellState called"); 60 LOG_TRACE(Service_PTM, "PTM_U::GetShellState called");
61} 61}
62 62
63/** 63/**
@@ -76,7 +76,7 @@ static void GetBatteryLevel(Service::Interface* self) {
76 cmd_buff[1] = 0; // No error 76 cmd_buff[1] = 0; // No error
77 cmd_buff[2] = static_cast<u32>(ChargeLevels::CompletelyFull); // Set to a completely full battery 77 cmd_buff[2] = static_cast<u32>(ChargeLevels::CompletelyFull); // Set to a completely full battery
78 78
79 WARN_LOG(KERNEL, "(STUBBED) called"); 79 LOG_WARNING(Service_PTM, "(STUBBED) called");
80} 80}
81 81
82/** 82/**
@@ -94,7 +94,7 @@ static void GetBatteryChargeState(Service::Interface* self) {
94 cmd_buff[1] = 0; // No error 94 cmd_buff[1] = 0; // No error
95 cmd_buff[2] = battery_is_charging ? 1 : 0; 95 cmd_buff[2] = battery_is_charging ? 1 : 0;
96 96
97 WARN_LOG(KERNEL, "(STUBBED) called"); 97 LOG_WARNING(Service_PTM, "(STUBBED) called");
98} 98}
99 99
100const Interface::FunctionInfo FunctionTable[] = { 100const Interface::FunctionInfo FunctionTable[] = {
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index fed2268a0..e6973572b 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -106,13 +106,13 @@ void Init() {
106 g_manager->AddService(new SOC_U::Interface); 106 g_manager->AddService(new SOC_U::Interface);
107 g_manager->AddService(new SSL_C::Interface); 107 g_manager->AddService(new SSL_C::Interface);
108 108
109 NOTICE_LOG(HLE, "initialized OK"); 109 LOG_DEBUG(Service, "initialized OK");
110} 110}
111 111
112/// Shutdown ServiceManager 112/// Shutdown ServiceManager
113void Shutdown() { 113void Shutdown() {
114 delete g_manager; 114 delete g_manager;
115 NOTICE_LOG(HLE, "shutdown OK"); 115 LOG_DEBUG(Service, "shutdown OK");
116} 116}
117 117
118 118
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 3a7d6c469..baae910a1 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -91,7 +91,7 @@ public:
91 91
92 std::string name = (itr == m_functions.end()) ? Common::StringFromFormat("0x%08X", cmd_buff[0]) : itr->second.name; 92 std::string name = (itr == m_functions.end()) ? Common::StringFromFormat("0x%08X", cmd_buff[0]) : itr->second.name;
93 93
94 ERROR_LOG(OSHLE, error.c_str(), name.c_str(), GetPortName().c_str()); 94 LOG_ERROR(Service, error.c_str(), name.c_str(), GetPortName().c_str());
95 95
96 // TODO(bunnei): Hack - ignore error 96 // TODO(bunnei): Hack - ignore error
97 cmd_buff[1] = 0; 97 cmd_buff[1] = 0;
@@ -103,12 +103,6 @@ public:
103 return MakeResult<bool>(false); // TODO: Implement return from actual function 103 return MakeResult<bool>(false); // TODO: Implement return from actual function
104 } 104 }
105 105
106 ResultVal<bool> WaitSynchronization() override {
107 // TODO(bunnei): ImplementMe
108 ERROR_LOG(OSHLE, "unimplemented function");
109 return UnimplementedFunction(ErrorModule::OS);
110 }
111
112protected: 106protected:
113 107
114 /** 108 /**
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp
index 0e7fa9e3b..24a846533 100644
--- a/src/core/hle/service/srv.cpp
+++ b/src/core/hle/service/srv.cpp
@@ -14,7 +14,7 @@ namespace SRV {
14static Handle g_event_handle = 0; 14static Handle g_event_handle = 0;
15 15
16static void Initialize(Service::Interface* self) { 16static void Initialize(Service::Interface* self) {
17 DEBUG_LOG(OSHLE, "called"); 17 LOG_DEBUG(Service_SRV, "called");
18 18
19 u32* cmd_buff = Service::GetCommandBuffer(); 19 u32* cmd_buff = Service::GetCommandBuffer();
20 20
@@ -22,7 +22,7 @@ static void Initialize(Service::Interface* self) {
22} 22}
23 23
24static void GetProcSemaphore(Service::Interface* self) { 24static void GetProcSemaphore(Service::Interface* self) {
25 DEBUG_LOG(OSHLE, "called"); 25 LOG_TRACE(Service_SRV, "called");
26 26
27 u32* cmd_buff = Service::GetCommandBuffer(); 27 u32* cmd_buff = Service::GetCommandBuffer();
28 28
@@ -43,9 +43,9 @@ static void GetServiceHandle(Service::Interface* self) {
43 43
44 if (nullptr != service) { 44 if (nullptr != service) {
45 cmd_buff[3] = service->GetHandle(); 45 cmd_buff[3] = service->GetHandle();
46 DEBUG_LOG(OSHLE, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]); 46 LOG_TRACE(Service_SRV, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]);
47 } else { 47 } else {
48 ERROR_LOG(OSHLE, "(UNIMPLEMENTED) called port=%s", port_name.c_str()); 48 LOG_ERROR(Service_SRV, "(UNIMPLEMENTED) called port=%s", port_name.c_str());
49 res = UnimplementedFunction(ErrorModule::SRV); 49 res = UnimplementedFunction(ErrorModule::SRV);
50 } 50 }
51 cmd_buff[1] = res.raw; 51 cmd_buff[1] = res.raw;
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index b99c301d4..db0c42e74 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -31,7 +31,7 @@ enum ControlMemoryOperation {
31 31
32/// Map application or GSP heap memory 32/// Map application or GSP heap memory
33static Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { 33static Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) {
34 DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", 34 LOG_TRACE(Kernel_SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X",
35 operation, addr0, addr1, size, permissions); 35 operation, addr0, addr1, size, permissions);
36 36
37 switch (operation) { 37 switch (operation) {
@@ -48,14 +48,14 @@ static Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1,
48 48
49 // Unknown ControlMemory operation 49 // Unknown ControlMemory operation
50 default: 50 default:
51 ERROR_LOG(SVC, "unknown operation=0x%08X", operation); 51 LOG_ERROR(Kernel_SVC, "unknown operation=0x%08X", operation);
52 } 52 }
53 return 0; 53 return 0;
54} 54}
55 55
56/// Maps a memory block to specified address 56/// Maps a memory block to specified address
57static Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { 57static Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) {
58 DEBUG_LOG(SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", 58 LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d",
59 handle, addr, permissions, other_permissions); 59 handle, addr, permissions, other_permissions);
60 60
61 Kernel::MemoryPermission permissions_type = static_cast<Kernel::MemoryPermission>(permissions); 61 Kernel::MemoryPermission permissions_type = static_cast<Kernel::MemoryPermission>(permissions);
@@ -68,7 +68,7 @@ static Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other
68 static_cast<Kernel::MemoryPermission>(other_permissions)); 68 static_cast<Kernel::MemoryPermission>(other_permissions));
69 break; 69 break;
70 default: 70 default:
71 ERROR_LOG(OSHLE, "unknown permissions=0x%08X", permissions); 71 LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions);
72 } 72 }
73 return 0; 73 return 0;
74} 74}
@@ -77,7 +77,7 @@ static Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other
77static Result ConnectToPort(Handle* out, const char* port_name) { 77static Result ConnectToPort(Handle* out, const char* port_name) {
78 Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); 78 Service::Interface* service = Service::g_manager->FetchFromPortName(port_name);
79 79
80 DEBUG_LOG(SVC, "called port_name=%s", port_name); 80 LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name);
81 _assert_msg_(KERNEL, (service != nullptr), "called, but service is not implemented!"); 81 _assert_msg_(KERNEL, (service != nullptr), "called, but service is not implemented!");
82 82
83 *out = service->GetHandle(); 83 *out = service->GetHandle();
@@ -95,7 +95,7 @@ static Result SendSyncRequest(Handle handle) {
95 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle); 95 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
96 96
97 _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!"); 97 _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!");
98 DEBUG_LOG(SVC, "called handle=0x%08X(%s)", handle, object->GetTypeName().c_str()); 98 LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s)", handle, object->GetTypeName().c_str());
99 99
100 ResultVal<bool> wait = object->SyncRequest(); 100 ResultVal<bool> wait = object->SyncRequest();
101 if (wait.Succeeded() && *wait) { 101 if (wait.Succeeded() && *wait) {
@@ -108,7 +108,7 @@ static Result SendSyncRequest(Handle handle) {
108/// Close a handle 108/// Close a handle
109static Result CloseHandle(Handle handle) { 109static Result CloseHandle(Handle handle) {
110 // ImplementMe 110 // ImplementMe
111 ERROR_LOG(SVC, "(UNIMPLEMENTED) called handle=0x%08X", handle); 111 LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called handle=0x%08X", handle);
112 return 0; 112 return 0;
113} 113}
114 114
@@ -121,9 +121,9 @@ static Result WaitSynchronization1(Handle handle, s64 nano_seconds) {
121 return InvalidHandle(ErrorModule::Kernel).raw; 121 return InvalidHandle(ErrorModule::Kernel).raw;
122 } 122 }
123 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle); 123 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
124 _dbg_assert_(KERNEL, object != nullptr); 124 _dbg_assert_(Kernel, object != nullptr);
125 125
126 DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, object->GetTypeName().c_str(), 126 LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, object->GetTypeName().c_str(),
127 object->GetName().c_str(), nano_seconds); 127 object->GetName().c_str(), nano_seconds);
128 128
129 ResultVal<bool> wait = object->WaitSynchronization(); 129 ResultVal<bool> wait = object->WaitSynchronization();
@@ -143,7 +143,7 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count,
143 bool unlock_all = true; 143 bool unlock_all = true;
144 bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated 144 bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated
145 145
146 DEBUG_LOG(SVC, "called handle_count=%d, wait_all=%s, nanoseconds=%lld", 146 LOG_TRACE(Kernel_SVC, "called handle_count=%d, wait_all=%s, nanoseconds=%lld",
147 handle_count, (wait_all ? "true" : "false"), nano_seconds); 147 handle_count, (wait_all ? "true" : "false"), nano_seconds);
148 148
149 // Iterate through each handle, synchronize kernel object 149 // Iterate through each handle, synchronize kernel object
@@ -153,7 +153,7 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count,
153 } 153 }
154 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handles[i]); 154 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handles[i]);
155 155
156 DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName().c_str(), 156 LOG_TRACE(Kernel_SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName().c_str(),
157 object->GetName().c_str()); 157 object->GetName().c_str());
158 158
159 // TODO(yuriks): Verify how the real function behaves when an error happens here 159 // TODO(yuriks): Verify how the real function behaves when an error happens here
@@ -181,7 +181,7 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count,
181 181
182/// Create an address arbiter (to allocate access to shared resources) 182/// Create an address arbiter (to allocate access to shared resources)
183static Result CreateAddressArbiter(u32* arbiter) { 183static Result CreateAddressArbiter(u32* arbiter) {
184 DEBUG_LOG(SVC, "called"); 184 LOG_TRACE(Kernel_SVC, "called");
185 Handle handle = Kernel::CreateAddressArbiter(); 185 Handle handle = Kernel::CreateAddressArbiter();
186 *arbiter = handle; 186 *arbiter = handle;
187 return 0; 187 return 0;
@@ -189,7 +189,7 @@ static Result CreateAddressArbiter(u32* arbiter) {
189 189
190/// Arbitrate address 190/// Arbitrate address
191static Result ArbitrateAddress(Handle arbiter, u32 address, u32 type, u32 value, s64 nanoseconds) { 191static Result ArbitrateAddress(Handle arbiter, u32 address, u32 type, u32 value, s64 nanoseconds) {
192 DEBUG_LOG(SVC, "called handle=0x%08X, address=0x%08X, type=0x%08X, value=0x%08X", arbiter, 192 LOG_TRACE(Kernel_SVC, "called handle=0x%08X, address=0x%08X, type=0x%08X, value=0x%08X", arbiter,
193 address, type, value); 193 address, type, value);
194 return Kernel::ArbitrateAddress(arbiter, static_cast<Kernel::ArbitrationType>(type), 194 return Kernel::ArbitrateAddress(arbiter, static_cast<Kernel::ArbitrationType>(type),
195 address, value).raw; 195 address, value).raw;
@@ -197,7 +197,7 @@ static Result ArbitrateAddress(Handle arbiter, u32 address, u32 type, u32 value,
197 197
198/// Used to output a message on a debug hardware unit - does nothing on a retail unit 198/// Used to output a message on a debug hardware unit - does nothing on a retail unit
199static void OutputDebugString(const char* string) { 199static void OutputDebugString(const char* string) {
200 OS_LOG(SVC, "%s", string); 200 LOG_DEBUG(Debug_Emulated, "%s", string);
201} 201}
202 202
203/// Get resource limit 203/// Get resource limit
@@ -206,14 +206,14 @@ static Result GetResourceLimit(Handle* resource_limit, Handle process) {
206 // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for 206 // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for
207 // the current KThread. 207 // the current KThread.
208 *resource_limit = 0xDEADBEEF; 208 *resource_limit = 0xDEADBEEF;
209 ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process); 209 LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called process=0x%08X", process);
210 return 0; 210 return 0;
211} 211}
212 212
213/// Get resource limit current values 213/// Get resource limit current values
214static Result GetResourceLimitCurrentValues(s64* values, Handle resource_limit, void* names, 214static Result GetResourceLimitCurrentValues(s64* values, Handle resource_limit, void* names,
215 s32 name_count) { 215 s32 name_count) {
216 ERROR_LOG(SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%s, name_count=%d", 216 LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%s, name_count=%d",
217 resource_limit, names, name_count); 217 resource_limit, names, name_count);
218 Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now 218 Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now
219 return 0; 219 return 0;
@@ -234,7 +234,7 @@ static Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top
234 234
235 Core::g_app_core->SetReg(1, thread); 235 Core::g_app_core->SetReg(1, thread);
236 236
237 DEBUG_LOG(SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " 237 LOG_TRACE(Kernel_SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, "
238 "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point, 238 "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point,
239 name.c_str(), arg, stack_top, priority, processor_id, thread); 239 name.c_str(), arg, stack_top, priority, processor_id, thread);
240 240
@@ -245,7 +245,7 @@ static Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top
245static u32 ExitThread() { 245static u32 ExitThread() {
246 Handle thread = Kernel::GetCurrentThreadHandle(); 246 Handle thread = Kernel::GetCurrentThreadHandle();
247 247
248 DEBUG_LOG(SVC, "called, pc=0x%08X", Core::g_app_core->GetPC()); // PC = 0x0010545C 248 LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::g_app_core->GetPC()); // PC = 0x0010545C
249 249
250 Kernel::StopThread(thread, __func__); 250 Kernel::StopThread(thread, __func__);
251 HLE::Reschedule(__func__); 251 HLE::Reschedule(__func__);
@@ -269,42 +269,42 @@ static Result SetThreadPriority(Handle handle, s32 priority) {
269/// Create a mutex 269/// Create a mutex
270static Result CreateMutex(Handle* mutex, u32 initial_locked) { 270static Result CreateMutex(Handle* mutex, u32 initial_locked) {
271 *mutex = Kernel::CreateMutex((initial_locked != 0)); 271 *mutex = Kernel::CreateMutex((initial_locked != 0));
272 DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X", 272 LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X",
273 initial_locked ? "true" : "false", *mutex); 273 initial_locked ? "true" : "false", *mutex);
274 return 0; 274 return 0;
275} 275}
276 276
277/// Release a mutex 277/// Release a mutex
278static Result ReleaseMutex(Handle handle) { 278static Result ReleaseMutex(Handle handle) {
279 DEBUG_LOG(SVC, "called handle=0x%08X", handle); 279 LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle);
280 ResultCode res = Kernel::ReleaseMutex(handle); 280 ResultCode res = Kernel::ReleaseMutex(handle);
281 return res.raw; 281 return res.raw;
282} 282}
283 283
284/// Get the ID for the specified thread. 284/// Get the ID for the specified thread.
285static Result GetThreadId(u32* thread_id, Handle handle) { 285static Result GetThreadId(u32* thread_id, Handle handle) {
286 DEBUG_LOG(SVC, "called thread=0x%08X", handle); 286 LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle);
287 ResultCode result = Kernel::GetThreadId(thread_id, handle); 287 ResultCode result = Kernel::GetThreadId(thread_id, handle);
288 return result.raw; 288 return result.raw;
289} 289}
290 290
291/// Query memory 291/// Query memory
292static Result QueryMemory(void* info, void* out, u32 addr) { 292static Result QueryMemory(void* info, void* out, u32 addr) {
293 ERROR_LOG(SVC, "(UNIMPLEMENTED) called addr=0x%08X", addr); 293 LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called addr=0x%08X", addr);
294 return 0; 294 return 0;
295} 295}
296 296
297/// Create an event 297/// Create an event
298static Result CreateEvent(Handle* evt, u32 reset_type) { 298static Result CreateEvent(Handle* evt, u32 reset_type) {
299 *evt = Kernel::CreateEvent((ResetType)reset_type); 299 *evt = Kernel::CreateEvent((ResetType)reset_type);
300 DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X", 300 LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X",
301 reset_type, *evt); 301 reset_type, *evt);
302 return 0; 302 return 0;
303} 303}
304 304
305/// Duplicates a kernel handle 305/// Duplicates a kernel handle
306static Result DuplicateHandle(Handle* out, Handle handle) { 306static Result DuplicateHandle(Handle* out, Handle handle) {
307 DEBUG_LOG(SVC, "called handle=0x%08X", handle); 307 LOG_WARNING(Kernel_SVC, "(STUBBED) called handle=0x%08X", handle);
308 308
309 // Translate kernel handles -> real handles 309 // Translate kernel handles -> real handles
310 if (handle == Kernel::CurrentThread) { 310 if (handle == Kernel::CurrentThread) {
@@ -321,19 +321,19 @@ static Result DuplicateHandle(Handle* out, Handle handle) {
321 321
322/// Signals an event 322/// Signals an event
323static Result SignalEvent(Handle evt) { 323static Result SignalEvent(Handle evt) {
324 DEBUG_LOG(SVC, "called event=0x%08X", evt); 324 LOG_TRACE(Kernel_SVC, "called event=0x%08X", evt);
325 return Kernel::SignalEvent(evt).raw; 325 return Kernel::SignalEvent(evt).raw;
326} 326}
327 327
328/// Clears an event 328/// Clears an event
329static Result ClearEvent(Handle evt) { 329static Result ClearEvent(Handle evt) {
330 DEBUG_LOG(SVC, "called event=0x%08X", evt); 330 LOG_TRACE(Kernel_SVC, "called event=0x%08X", evt);
331 return Kernel::ClearEvent(evt).raw; 331 return Kernel::ClearEvent(evt).raw;
332} 332}
333 333
334/// Sleep the current thread 334/// Sleep the current thread
335static void SleepThread(s64 nanoseconds) { 335static void SleepThread(s64 nanoseconds) {
336 DEBUG_LOG(SVC, "called nanoseconds=%lld", nanoseconds); 336 LOG_TRACE(Kernel_SVC, "called nanoseconds=%lld", nanoseconds);
337 337
338 // Check for next thread to schedule 338 // Check for next thread to schedule
339 HLE::Reschedule(__func__); 339 HLE::Reschedule(__func__);
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp
index 77557e582..da78b85e5 100644
--- a/src/core/hw/gpu.cpp
+++ b/src/core/hw/gpu.cpp
@@ -35,7 +35,7 @@ inline void Read(T &var, const u32 raw_addr) {
35 35
36 // Reads other than u32 are untested, so I'd rather have them abort than silently fail 36 // Reads other than u32 are untested, so I'd rather have them abort than silently fail
37 if (index >= Regs::NumIds() || !std::is_same<T,u32>::value) { 37 if (index >= Regs::NumIds() || !std::is_same<T,u32>::value) {
38 ERROR_LOG(GPU, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, addr); 38 LOG_ERROR(HW_GPU, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, addr);
39 return; 39 return;
40 } 40 }
41 41
@@ -49,7 +49,7 @@ inline void Write(u32 addr, const T data) {
49 49
50 // Writes other than u32 are untested, so I'd rather have them abort than silently fail 50 // Writes other than u32 are untested, so I'd rather have them abort than silently fail
51 if (index >= Regs::NumIds() || !std::is_same<T,u32>::value) { 51 if (index >= Regs::NumIds() || !std::is_same<T,u32>::value) {
52 ERROR_LOG(GPU, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, addr); 52 LOG_ERROR(HW_GPU, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, addr);
53 return; 53 return;
54 } 54 }
55 55
@@ -73,7 +73,7 @@ inline void Write(u32 addr, const T data) {
73 for (u32* ptr = start; ptr < end; ++ptr) 73 for (u32* ptr = start; ptr < end; ++ptr)
74 *ptr = bswap32(config.value); // TODO: This is just a workaround to missing framebuffer format emulation 74 *ptr = bswap32(config.value); // TODO: This is just a workaround to missing framebuffer format emulation
75 75
76 DEBUG_LOG(GPU, "MemoryFill from 0x%08x to 0x%08x", config.GetStartAddress(), config.GetEndAddress()); 76 LOG_TRACE(HW_GPU, "MemoryFill from 0x%08x to 0x%08x", config.GetStartAddress(), config.GetEndAddress());
77 } 77 }
78 break; 78 break;
79 } 79 }
@@ -105,7 +105,7 @@ inline void Write(u32 addr, const T data) {
105 } 105 }
106 106
107 default: 107 default:
108 ERROR_LOG(GPU, "Unknown source framebuffer format %x", config.input_format.Value()); 108 LOG_ERROR(HW_GPU, "Unknown source framebuffer format %x", config.input_format.Value());
109 break; 109 break;
110 } 110 }
111 111
@@ -132,13 +132,13 @@ inline void Write(u32 addr, const T data) {
132 } 132 }
133 133
134 default: 134 default:
135 ERROR_LOG(GPU, "Unknown destination framebuffer format %x", config.output_format.Value()); 135 LOG_ERROR(HW_GPU, "Unknown destination framebuffer format %x", config.output_format.Value());
136 break; 136 break;
137 } 137 }
138 } 138 }
139 } 139 }
140 140
141 DEBUG_LOG(GPU, "DisplayTriggerTransfer: 0x%08x bytes from 0x%08x(%ux%u)-> 0x%08x(%ux%u), dst format %x", 141 LOG_TRACE(HW_GPU, "DisplayTriggerTransfer: 0x%08x bytes from 0x%08x(%ux%u)-> 0x%08x(%ux%u), dst format %x",
142 config.output_height * config.output_width * 4, 142 config.output_height * config.output_width * 4,
143 config.GetPhysicalInputAddress(), (u32)config.input_width, (u32)config.input_height, 143 config.GetPhysicalInputAddress(), (u32)config.input_width, (u32)config.input_height,
144 config.GetPhysicalOutputAddress(), (u32)config.output_width, (u32)config.output_height, 144 config.GetPhysicalOutputAddress(), (u32)config.output_width, (u32)config.output_height,
@@ -251,12 +251,12 @@ void Init() {
251 framebuffer_sub.color_format = Regs::PixelFormat::RGB8; 251 framebuffer_sub.color_format = Regs::PixelFormat::RGB8;
252 framebuffer_sub.active_fb = 0; 252 framebuffer_sub.active_fb = 0;
253 253
254 NOTICE_LOG(GPU, "initialized OK"); 254 LOG_DEBUG(HW_GPU, "initialized OK");
255} 255}
256 256
257/// Shutdown hardware 257/// Shutdown hardware
258void Shutdown() { 258void Shutdown() {
259 NOTICE_LOG(GPU, "shutdown OK"); 259 LOG_DEBUG(HW_GPU, "shutdown OK");
260} 260}
261 261
262} // namespace 262} // namespace
diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp
index 73a4f1e53..af42b41fb 100644
--- a/src/core/hw/hw.cpp
+++ b/src/core/hw/hw.cpp
@@ -44,7 +44,7 @@ inline void Read(T &var, const u32 addr) {
44 break; 44 break;
45 45
46 default: 46 default:
47 ERROR_LOG(HW, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, addr); 47 LOG_ERROR(HW_Memory, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, addr);
48 } 48 }
49} 49}
50 50
@@ -57,7 +57,7 @@ inline void Write(u32 addr, const T data) {
57 break; 57 break;
58 58
59 default: 59 default:
60 ERROR_LOG(HW, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, addr); 60 LOG_ERROR(HW_Memory, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, addr);
61 } 61 }
62} 62}
63 63
@@ -81,12 +81,12 @@ void Update() {
81/// Initialize hardware 81/// Initialize hardware
82void Init() { 82void Init() {
83 GPU::Init(); 83 GPU::Init();
84 NOTICE_LOG(HW, "initialized OK"); 84 LOG_DEBUG(HW, "initialized OK");
85} 85}
86 86
87/// Shutdown hardware 87/// Shutdown hardware
88void Shutdown() { 88void Shutdown() {
89 NOTICE_LOG(HW, "shutdown OK"); 89 LOG_DEBUG(HW, "shutdown OK");
90} 90}
91 91
92} \ No newline at end of file 92} \ No newline at end of file
diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp
index 7ef146359..f48d13530 100644
--- a/src/core/loader/3dsx.cpp
+++ b/src/core/loader/3dsx.cpp
@@ -174,14 +174,14 @@ int THREEDSXReader::Load3DSXFile(const std::string& filename, u32 base_addr)
174 return ERROR_READ; 174 return ERROR_READ;
175 175
176 for (u32 current_inprogress = 0; current_inprogress < remaining && pos < end_pos; current_inprogress++) { 176 for (u32 current_inprogress = 0; current_inprogress < remaining && pos < end_pos; current_inprogress++) {
177 DEBUG_LOG(LOADER, "(t=%d,skip=%u,patch=%u)\n", 177 LOG_TRACE(Loader, "(t=%d,skip=%u,patch=%u)\n",
178 current_segment_reloc_table, (u32)reloc_table[current_inprogress].skip, (u32)reloc_table[current_inprogress].patch); 178 current_segment_reloc_table, (u32)reloc_table[current_inprogress].skip, (u32)reloc_table[current_inprogress].patch);
179 pos += reloc_table[current_inprogress].skip; 179 pos += reloc_table[current_inprogress].skip;
180 s32 num_patches = reloc_table[current_inprogress].patch; 180 s32 num_patches = reloc_table[current_inprogress].patch;
181 while (0 < num_patches && pos < end_pos) { 181 while (0 < num_patches && pos < end_pos) {
182 u32 in_addr = (char*)pos - (char*)&all_mem[0]; 182 u32 in_addr = (char*)pos - (char*)&all_mem[0];
183 u32 addr = TranslateAddr(*pos, &loadinfo, offsets); 183 u32 addr = TranslateAddr(*pos, &loadinfo, offsets);
184 DEBUG_LOG(LOADER, "Patching %08X <-- rel(%08X,%d) (%08X)\n", 184 LOG_TRACE(Loader, "Patching %08X <-- rel(%08X,%d) (%08X)\n",
185 base_addr + in_addr, addr, current_segment_reloc_table, *pos); 185 base_addr + in_addr, addr, current_segment_reloc_table, *pos);
186 switch (current_segment_reloc_table) { 186 switch (current_segment_reloc_table) {
187 case 0: *pos = (addr); break; 187 case 0: *pos = (addr); break;
@@ -199,10 +199,10 @@ int THREEDSXReader::Load3DSXFile(const std::string& filename, u32 base_addr)
199 // Write the data 199 // Write the data
200 memcpy(Memory::GetPointer(base_addr), &all_mem[0], loadinfo.seg_sizes[0] + loadinfo.seg_sizes[1] + loadinfo.seg_sizes[2]); 200 memcpy(Memory::GetPointer(base_addr), &all_mem[0], loadinfo.seg_sizes[0] + loadinfo.seg_sizes[1] + loadinfo.seg_sizes[2]);
201 201
202 DEBUG_LOG(LOADER, "CODE: %u pages\n", loadinfo.seg_sizes[0] / 0x1000); 202 LOG_DEBUG(Loader, "CODE: %u pages\n", loadinfo.seg_sizes[0] / 0x1000);
203 DEBUG_LOG(LOADER, "RODATA: %u pages\n", loadinfo.seg_sizes[1] / 0x1000); 203 LOG_DEBUG(Loader, "RODATA: %u pages\n", loadinfo.seg_sizes[1] / 0x1000);
204 DEBUG_LOG(LOADER, "DATA: %u pages\n", data_load_size / 0x1000); 204 LOG_DEBUG(Loader, "DATA: %u pages\n", data_load_size / 0x1000);
205 DEBUG_LOG(LOADER, "BSS: %u pages\n", bss_load_size / 0x1000); 205 LOG_DEBUG(Loader, "BSS: %u pages\n", bss_load_size / 0x1000);
206 206
207 return ERROR_NONE; 207 return ERROR_NONE;
208} 208}
@@ -220,7 +220,7 @@ int THREEDSXReader::Load3DSXFile(const std::string& filename, u32 base_addr)
220 * @return Success on success, otherwise Error 220 * @return Success on success, otherwise Error
221 */ 221 */
222 ResultStatus AppLoader_THREEDSX::Load() { 222 ResultStatus AppLoader_THREEDSX::Load() {
223 INFO_LOG(LOADER, "Loading 3DSX file %s...", filename.c_str()); 223 LOG_INFO(Loader, "Loading 3DSX file %s...", filename.c_str());
224 FileUtil::IOFile file(filename, "rb"); 224 FileUtil::IOFile file(filename, "rb");
225 if (file.IsOpen()) { 225 if (file.IsOpen()) {
226 226
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 63d2496ed..c95882f4a 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -254,18 +254,18 @@ const char *ElfReader::GetSectionName(int section) const {
254} 254}
255 255
256bool ElfReader::LoadInto(u32 vaddr) { 256bool ElfReader::LoadInto(u32 vaddr) {
257 DEBUG_LOG(MASTER_LOG, "String section: %i", header->e_shstrndx); 257 LOG_DEBUG(Loader, "String section: %i", header->e_shstrndx);
258 258
259 // Should we relocate? 259 // Should we relocate?
260 relocate = (header->e_type != ET_EXEC); 260 relocate = (header->e_type != ET_EXEC);
261 261
262 if (relocate) { 262 if (relocate) {
263 DEBUG_LOG(MASTER_LOG, "Relocatable module"); 263 LOG_DEBUG(Loader, "Relocatable module");
264 entryPoint += vaddr; 264 entryPoint += vaddr;
265 } else { 265 } else {
266 DEBUG_LOG(MASTER_LOG, "Prerelocated executable"); 266 LOG_DEBUG(Loader, "Prerelocated executable");
267 } 267 }
268 INFO_LOG(MASTER_LOG, "%i segments:", header->e_phnum); 268 LOG_DEBUG(Loader, "%i segments:", header->e_phnum);
269 269
270 // First pass : Get the bits into RAM 270 // First pass : Get the bits into RAM
271 u32 segment_addr[32]; 271 u32 segment_addr[32];
@@ -273,17 +273,17 @@ bool ElfReader::LoadInto(u32 vaddr) {
273 273
274 for (int i = 0; i < header->e_phnum; i++) { 274 for (int i = 0; i < header->e_phnum; i++) {
275 Elf32_Phdr *p = segments + i; 275 Elf32_Phdr *p = segments + i;
276 INFO_LOG(MASTER_LOG, "Type: %i Vaddr: %08x Filesz: %i Memsz: %i ", p->p_type, p->p_vaddr, 276 LOG_DEBUG(Loader, "Type: %i Vaddr: %08x Filesz: %i Memsz: %i ", p->p_type, p->p_vaddr,
277 p->p_filesz, p->p_memsz); 277 p->p_filesz, p->p_memsz);
278 278
279 if (p->p_type == PT_LOAD) { 279 if (p->p_type == PT_LOAD) {
280 segment_addr[i] = base_addr + p->p_vaddr; 280 segment_addr[i] = base_addr + p->p_vaddr;
281 memcpy(Memory::GetPointer(segment_addr[i]), GetSegmentPtr(i), p->p_filesz); 281 memcpy(Memory::GetPointer(segment_addr[i]), GetSegmentPtr(i), p->p_filesz);
282 INFO_LOG(MASTER_LOG, "Loadable Segment Copied to %08x, size %08x", segment_addr[i], 282 LOG_DEBUG(Loader, "Loadable Segment Copied to %08x, size %08x", segment_addr[i],
283 p->p_memsz); 283 p->p_memsz);
284 } 284 }
285 } 285 }
286 INFO_LOG(MASTER_LOG, "Done loading."); 286 LOG_DEBUG(Loader, "Done loading.");
287 return true; 287 return true;
288} 288}
289 289
@@ -346,7 +346,7 @@ AppLoader_ELF::~AppLoader_ELF() {
346 * @return True on success, otherwise false 346 * @return True on success, otherwise false
347 */ 347 */
348ResultStatus AppLoader_ELF::Load() { 348ResultStatus AppLoader_ELF::Load() {
349 INFO_LOG(LOADER, "Loading ELF file %s...", filename.c_str()); 349 LOG_INFO(Loader, "Loading ELF file %s...", filename.c_str());
350 350
351 if (is_loaded) 351 if (is_loaded)
352 return ResultStatus::ErrorAlreadyLoaded; 352 return ResultStatus::ErrorAlreadyLoaded;
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index 174397b05..3883e1307 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -23,7 +23,7 @@ namespace Loader {
23 */ 23 */
24FileType IdentifyFile(const std::string &filename) { 24FileType IdentifyFile(const std::string &filename) {
25 if (filename.size() == 0) { 25 if (filename.size() == 0) {
26 ERROR_LOG(LOADER, "invalid filename %s", filename.c_str()); 26 LOG_ERROR(Loader, "invalid filename %s", filename.c_str());
27 return FileType::Error; 27 return FileType::Error;
28 } 28 }
29 29
@@ -55,7 +55,7 @@ FileType IdentifyFile(const std::string &filename) {
55 * @return ResultStatus result of function 55 * @return ResultStatus result of function
56 */ 56 */
57ResultStatus LoadFile(const std::string& filename) { 57ResultStatus LoadFile(const std::string& filename) {
58 INFO_LOG(LOADER, "Loading file %s...", filename.c_str()); 58 LOG_INFO(Loader, "Loading file %s...", filename.c_str());
59 59
60 switch (IdentifyFile(filename)) { 60 switch (IdentifyFile(filename)) {
61 61
@@ -83,7 +83,7 @@ ResultStatus LoadFile(const std::string& filename) {
83 // Raw BIN file format... 83 // Raw BIN file format...
84 case FileType::BIN: 84 case FileType::BIN:
85 { 85 {
86 INFO_LOG(LOADER, "Loading BIN file %s...", filename.c_str()); 86 LOG_INFO(Loader, "Loading BIN file %s...", filename.c_str());
87 87
88 FileUtil::IOFile file(filename, "rb"); 88 FileUtil::IOFile file(filename, "rb");
89 89
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 343bb7523..ba9ba00c0 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -140,13 +140,13 @@ ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>&
140 // Iterate through the ExeFs archive until we find the .code file... 140 // Iterate through the ExeFs archive until we find the .code file...
141 FileUtil::IOFile file(filename, "rb"); 141 FileUtil::IOFile file(filename, "rb");
142 if (file.IsOpen()) { 142 if (file.IsOpen()) {
143 LOG_DEBUG(Loader, "%d sections:", kMaxSections);
143 for (int i = 0; i < kMaxSections; i++) { 144 for (int i = 0; i < kMaxSections; i++) {
144 // Load the specified section... 145 // Load the specified section...
145 if (strcmp((const char*)exefs_header.section[i].name, name) == 0) { 146 if (strcmp((const char*)exefs_header.section[i].name, name) == 0) {
146 INFO_LOG(LOADER, "ExeFS section %d:", i); 147 LOG_DEBUG(Loader, "%d - offset: 0x%08X, size: 0x%08X, name: %s", i,
147 INFO_LOG(LOADER, " name: %s", exefs_header.section[i].name); 148 exefs_header.section[i].offset, exefs_header.section[i].size,
148 INFO_LOG(LOADER, " offset: 0x%08X", exefs_header.section[i].offset); 149 exefs_header.section[i].name);
149 INFO_LOG(LOADER, " size: 0x%08X", exefs_header.section[i].size);
150 150
151 s64 section_offset = (exefs_header.section[i].offset + exefs_offset + 151 s64 section_offset = (exefs_header.section[i].offset + exefs_offset +
152 sizeof(ExeFs_Header)+ncch_offset); 152 sizeof(ExeFs_Header)+ncch_offset);
@@ -181,7 +181,7 @@ ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>&
181 } 181 }
182 } 182 }
183 } else { 183 } else {
184 ERROR_LOG(LOADER, "Unable to read file %s!", filename.c_str()); 184 LOG_ERROR(Loader, "Unable to read file %s!", filename.c_str());
185 return ResultStatus::Error; 185 return ResultStatus::Error;
186 } 186 }
187 return ResultStatus::ErrorNotUsed; 187 return ResultStatus::ErrorNotUsed;
@@ -194,7 +194,7 @@ ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>&
194 * @return True on success, otherwise false 194 * @return True on success, otherwise false
195 */ 195 */
196ResultStatus AppLoader_NCCH::Load() { 196ResultStatus AppLoader_NCCH::Load() {
197 INFO_LOG(LOADER, "Loading NCCH file %s...", filename.c_str()); 197 LOG_INFO(Loader, "Loading NCCH file %s...", filename.c_str());
198 198
199 if (is_loaded) 199 if (is_loaded)
200 return ResultStatus::ErrorAlreadyLoaded; 200 return ResultStatus::ErrorAlreadyLoaded;
@@ -205,7 +205,7 @@ ResultStatus AppLoader_NCCH::Load() {
205 205
206 // Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)... 206 // Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)...
207 if (0 == memcmp(&ncch_header.magic, "NCSD", 4)) { 207 if (0 == memcmp(&ncch_header.magic, "NCSD", 4)) {
208 WARN_LOG(LOADER, "Only loading the first (bootable) NCCH within the NCSD file!"); 208 LOG_WARNING(Loader, "Only loading the first (bootable) NCCH within the NCSD file!");
209 ncch_offset = 0x4000; 209 ncch_offset = 0x4000;
210 file.Seek(ncch_offset, 0); 210 file.Seek(ncch_offset, 0);
211 file.ReadBytes(&ncch_header, sizeof(NCCH_Header)); 211 file.ReadBytes(&ncch_header, sizeof(NCCH_Header));
@@ -222,17 +222,17 @@ ResultStatus AppLoader_NCCH::Load() {
222 is_compressed = (exheader_header.codeset_info.flags.flag & 1) == 1; 222 is_compressed = (exheader_header.codeset_info.flags.flag & 1) == 1;
223 entry_point = exheader_header.codeset_info.text.address; 223 entry_point = exheader_header.codeset_info.text.address;
224 224
225 INFO_LOG(LOADER, "Name: %s", exheader_header.codeset_info.name); 225 LOG_INFO(Loader, "Name: %s", exheader_header.codeset_info.name);
226 INFO_LOG(LOADER, "Code compressed: %s", is_compressed ? "yes" : "no"); 226 LOG_DEBUG(Loader, "Code compressed: %s", is_compressed ? "yes" : "no");
227 INFO_LOG(LOADER, "Entry point: 0x%08X", entry_point); 227 LOG_DEBUG(Loader, "Entry point: 0x%08X", entry_point);
228 228
229 // Read ExeFS... 229 // Read ExeFS...
230 230
231 exefs_offset = ncch_header.exefs_offset * kBlockSize; 231 exefs_offset = ncch_header.exefs_offset * kBlockSize;
232 u32 exefs_size = ncch_header.exefs_size * kBlockSize; 232 u32 exefs_size = ncch_header.exefs_size * kBlockSize;
233 233
234 INFO_LOG(LOADER, "ExeFS offset: 0x%08X", exefs_offset); 234 LOG_DEBUG(Loader, "ExeFS offset: 0x%08X", exefs_offset);
235 INFO_LOG(LOADER, "ExeFS size: 0x%08X", exefs_size); 235 LOG_DEBUG(Loader, "ExeFS size: 0x%08X", exefs_size);
236 236
237 file.Seek(exefs_offset + ncch_offset, 0); 237 file.Seek(exefs_offset + ncch_offset, 0);
238 file.ReadBytes(&exefs_header, sizeof(ExeFs_Header)); 238 file.ReadBytes(&exefs_header, sizeof(ExeFs_Header));
@@ -243,7 +243,7 @@ ResultStatus AppLoader_NCCH::Load() {
243 243
244 return ResultStatus::Success; 244 return ResultStatus::Success;
245 } else { 245 } else {
246 ERROR_LOG(LOADER, "Unable to read file %s!", filename.c_str()); 246 LOG_ERROR(Loader, "Unable to read file %s!", filename.c_str());
247 } 247 }
248 return ResultStatus::Error; 248 return ResultStatus::Error;
249} 249}
@@ -297,8 +297,8 @@ ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) const {
297 u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000; 297 u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000;
298 u32 romfs_size = (ncch_header.romfs_size * kBlockSize) - 0x1000; 298 u32 romfs_size = (ncch_header.romfs_size * kBlockSize) - 0x1000;
299 299
300 INFO_LOG(LOADER, "RomFS offset: 0x%08X", romfs_offset); 300 LOG_DEBUG(Loader, "RomFS offset: 0x%08X", romfs_offset);
301 INFO_LOG(LOADER, "RomFS size: 0x%08X", romfs_size); 301 LOG_DEBUG(Loader, "RomFS size: 0x%08X", romfs_size);
302 302
303 buffer.resize(romfs_size); 303 buffer.resize(romfs_size);
304 304
@@ -307,10 +307,10 @@ ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) const {
307 307
308 return ResultStatus::Success; 308 return ResultStatus::Success;
309 } 309 }
310 NOTICE_LOG(LOADER, "RomFS unused"); 310 LOG_DEBUG(Loader, "NCCH has no RomFS");
311 return ResultStatus::ErrorNotUsed; 311 return ResultStatus::ErrorNotUsed;
312 } else { 312 } else {
313 ERROR_LOG(LOADER, "Unable to read file %s!", filename.c_str()); 313 LOG_ERROR(Loader, "Unable to read file %s!", filename.c_str());
314 } 314 }
315 return ResultStatus::Error; 315 return ResultStatus::Error;
316} 316}
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp
index e1c2580ff..d1c44ed24 100644
--- a/src/core/mem_map.cpp
+++ b/src/core/mem_map.cpp
@@ -71,7 +71,7 @@ void Init() {
71 71
72 g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &arena); 72 g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &arena);
73 73
74 NOTICE_LOG(MEMMAP, "initialized OK, RAM at %p (mirror at 0 @ %p)", g_heap, 74 LOG_DEBUG(HW_Memory, "initialized OK, RAM at %p (mirror at 0 @ %p)", g_heap,
75 physical_fcram); 75 physical_fcram);
76} 76}
77 77
@@ -82,7 +82,7 @@ void Shutdown() {
82 arena.ReleaseSpace(); 82 arena.ReleaseSpace();
83 g_base = nullptr; 83 g_base = nullptr;
84 84
85 NOTICE_LOG(MEMMAP, "shutdown OK"); 85 LOG_DEBUG(HW_Memory, "shutdown OK");
86} 86}
87 87
88} // namespace 88} // namespace
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp
index b78821a3b..7f7e77233 100644
--- a/src/core/mem_map_funcs.cpp
+++ b/src/core/mem_map_funcs.cpp
@@ -28,7 +28,7 @@ VAddr PhysicalToVirtualAddress(const PAddr addr) {
28 return addr - FCRAM_PADDR + FCRAM_VADDR; 28 return addr - FCRAM_PADDR + FCRAM_VADDR;
29 } 29 }
30 30
31 ERROR_LOG(MEMMAP, "Unknown physical address @ 0x%08x", addr); 31 LOG_ERROR(HW_Memory, "Unknown physical address @ 0x%08x", addr);
32 return addr; 32 return addr;
33} 33}
34 34
@@ -44,7 +44,7 @@ PAddr VirtualToPhysicalAddress(const VAddr addr) {
44 return addr - FCRAM_VADDR + FCRAM_PADDR; 44 return addr - FCRAM_VADDR + FCRAM_PADDR;
45 } 45 }
46 46
47 ERROR_LOG(MEMMAP, "Unknown virtual address @ 0x%08x", addr); 47 LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%08x", addr);
48 return addr; 48 return addr;
49} 49}
50 50
@@ -92,7 +92,7 @@ inline void Read(T &var, const VAddr vaddr) {
92 var = *((const T*)&g_vram[vaddr - VRAM_VADDR]); 92 var = *((const T*)&g_vram[vaddr - VRAM_VADDR]);
93 93
94 } else { 94 } else {
95 ERROR_LOG(MEMMAP, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, vaddr); 95 LOG_ERROR(HW_Memory, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, vaddr);
96 } 96 }
97} 97}
98 98
@@ -141,7 +141,7 @@ inline void Write(const VAddr vaddr, const T data) {
141 141
142 // Error out... 142 // Error out...
143 } else { 143 } else {
144 ERROR_LOG(MEMMAP, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, vaddr); 144 LOG_ERROR(HW_Memory, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, vaddr);
145 } 145 }
146} 146}
147 147
@@ -175,7 +175,7 @@ u8 *GetPointer(const VAddr vaddr) {
175 return g_vram + (vaddr - VRAM_VADDR); 175 return g_vram + (vaddr - VRAM_VADDR);
176 176
177 } else { 177 } else {
178 ERROR_LOG(MEMMAP, "unknown GetPointer @ 0x%08x", vaddr); 178 LOG_ERROR(HW_Memory, "unknown GetPointer @ 0x%08x", vaddr);
179 return 0; 179 return 0;
180 } 180 }
181} 181}
@@ -239,7 +239,7 @@ u16 Read16(const VAddr addr) {
239 // Check for 16-bit unaligned memory reads... 239 // Check for 16-bit unaligned memory reads...
240 if (addr & 1) { 240 if (addr & 1) {
241 // TODO(bunnei): Implement 16-bit unaligned memory reads 241 // TODO(bunnei): Implement 16-bit unaligned memory reads
242 ERROR_LOG(MEMMAP, "16-bit unaligned memory reads are not implemented!"); 242 LOG_ERROR(HW_Memory, "16-bit unaligned memory reads are not implemented!");
243 } 243 }
244 244
245 return (u16)data; 245 return (u16)data;
diff --git a/src/core/settings.h b/src/core/settings.h
index 7e7a66b89..138ffc615 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -4,6 +4,8 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <string>
8
7namespace Settings { 9namespace Settings {
8 10
9struct Values { 11struct Values {
@@ -33,7 +35,7 @@ struct Values {
33 // Data Storage 35 // Data Storage
34 bool use_virtual_sd; 36 bool use_virtual_sd;
35 37
36 bool enable_log; 38 std::string log_filter;
37} extern values; 39} extern values;
38 40
39} 41}
diff --git a/src/video_core/clipper.cpp b/src/video_core/clipper.cpp
index fbe4047ce..632fb959a 100644
--- a/src/video_core/clipper.cpp
+++ b/src/video_core/clipper.cpp
@@ -157,7 +157,7 @@ void ProcessTriangle(OutputVertex &v0, OutputVertex &v1, OutputVertex &v2) {
157 157
158 InitScreenCoordinates(vtx2); 158 InitScreenCoordinates(vtx2);
159 159
160 DEBUG_LOG(GPU, 160 LOG_TRACE(Render_Software,
161 "Triangle %lu/%lu (%lu buffer vertices) at position (%.3f, %.3f, %.3f, %.3f), " 161 "Triangle %lu/%lu (%lu buffer vertices) at position (%.3f, %.3f, %.3f, %.3f), "
162 "(%.3f, %.3f, %.3f, %.3f), (%.3f, %.3f, %.3f, %.3f) and " 162 "(%.3f, %.3f, %.3f, %.3f), (%.3f, %.3f, %.3f, %.3f) and "
163 "screen position (%.2f, %.2f, %.2f), (%.2f, %.2f, %.2f), (%.2f, %.2f, %.2f)", 163 "screen position (%.2f, %.2f, %.2f), (%.2f, %.2f, %.2f), (%.2f, %.2f, %.2f)",
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
index 431139cc2..b74cd3261 100644
--- a/src/video_core/command_processor.cpp
+++ b/src/video_core/command_processor.cpp
@@ -114,7 +114,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
114 (vertex_attribute_formats[i] == 2) ? *(s16*)srcdata : 114 (vertex_attribute_formats[i] == 2) ? *(s16*)srcdata :
115 *(float*)srcdata; 115 *(float*)srcdata;
116 input.attr[i][comp] = float24::FromFloat32(srcval); 116 input.attr[i][comp] = float24::FromFloat32(srcval);
117 DEBUG_LOG(GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f", 117 LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f",
118 comp, i, vertex, index, 118 comp, i, vertex, index,
119 attribute_config.GetBaseAddress(), 119 attribute_config.GetBaseAddress(),
120 vertex_attribute_sources[i] - base_address, 120 vertex_attribute_sources[i] - base_address,
@@ -176,7 +176,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
176 auto& uniform = VertexShader::GetFloatUniform(uniform_setup.index); 176 auto& uniform = VertexShader::GetFloatUniform(uniform_setup.index);
177 177
178 if (uniform_setup.index > 95) { 178 if (uniform_setup.index > 95) {
179 ERROR_LOG(GPU, "Invalid VS uniform index %d", (int)uniform_setup.index); 179 LOG_ERROR(HW_GPU, "Invalid VS uniform index %d", (int)uniform_setup.index);
180 break; 180 break;
181 } 181 }
182 182
@@ -192,7 +192,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
192 uniform.x = float24::FromRawFloat24(uniform_write_buffer[2] & 0xFFFFFF); 192 uniform.x = float24::FromRawFloat24(uniform_write_buffer[2] & 0xFFFFFF);
193 } 193 }
194 194
195 DEBUG_LOG(GPU, "Set uniform %x to (%f %f %f %f)", (int)uniform_setup.index, 195 LOG_TRACE(HW_GPU, "Set uniform %x to (%f %f %f %f)", (int)uniform_setup.index,
196 uniform.x.ToFloat32(), uniform.y.ToFloat32(), uniform.z.ToFloat32(), 196 uniform.x.ToFloat32(), uniform.y.ToFloat32(), uniform.z.ToFloat32(),
197 uniform.w.ToFloat32()); 197 uniform.w.ToFloat32());
198 198
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index 71b03f31c..1a20f19ec 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -248,8 +248,8 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data
248 it->component_mask = it->component_mask | component_mask; 248 it->component_mask = it->component_mask | component_mask;
249 } 249 }
250 } catch (const std::out_of_range& ) { 250 } catch (const std::out_of_range& ) {
251 _dbg_assert_msg_(GPU, 0, "Unknown output attribute mapping"); 251 _dbg_assert_msg_(HW_GPU, 0, "Unknown output attribute mapping");
252 ERROR_LOG(GPU, "Unknown output attribute mapping: %03x, %03x, %03x, %03x", 252 LOG_ERROR(HW_GPU, "Unknown output attribute mapping: %03x, %03x, %03x, %03x",
253 (int)output_attributes[i].map_x.Value(), 253 (int)output_attributes[i].map_x.Value(),
254 (int)output_attributes[i].map_y.Value(), 254 (int)output_attributes[i].map_y.Value(),
255 (int)output_attributes[i].map_z.Value(), 255 (int)output_attributes[i].map_z.Value(),
@@ -309,7 +309,7 @@ static int is_pica_tracing = false;
309void StartPicaTracing() 309void StartPicaTracing()
310{ 310{
311 if (is_pica_tracing) { 311 if (is_pica_tracing) {
312 ERROR_LOG(GPU, "StartPicaTracing called even though tracing already running!"); 312 LOG_WARNING(HW_GPU, "StartPicaTracing called even though tracing already running!");
313 return; 313 return;
314 } 314 }
315 315
@@ -342,7 +342,7 @@ void OnPicaRegWrite(u32 id, u32 value)
342std::unique_ptr<PicaTrace> FinishPicaTracing() 342std::unique_ptr<PicaTrace> FinishPicaTracing()
343{ 343{
344 if (!is_pica_tracing) { 344 if (!is_pica_tracing) {
345 ERROR_LOG(GPU, "FinishPicaTracing called even though tracing already running!"); 345 LOG_WARNING(HW_GPU, "FinishPicaTracing called even though tracing isn't running!");
346 return {}; 346 return {};
347 } 347 }
348 348
@@ -357,7 +357,7 @@ std::unique_ptr<PicaTrace> FinishPicaTracing()
357} 357}
358 358
359const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const TextureInfo& info) { 359const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const TextureInfo& info) {
360 _dbg_assert_(GPU, info.format == Pica::Regs::TextureFormat::RGB8); 360 _dbg_assert_(Debug_GPU, info.format == Pica::Regs::TextureFormat::RGB8);
361 361
362 // Cf. rasterizer code for an explanation of this algorithm. 362 // Cf. rasterizer code for an explanation of this algorithm.
363 int texel_index_within_tile = 0; 363 int texel_index_within_tile = 0;
@@ -421,7 +421,7 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) {
421 // Initialize write structure 421 // Initialize write structure
422 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); 422 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
423 if (png_ptr == nullptr) { 423 if (png_ptr == nullptr) {
424 ERROR_LOG(GPU, "Could not allocate write struct\n"); 424 LOG_ERROR(Debug_GPU, "Could not allocate write struct\n");
425 goto finalise; 425 goto finalise;
426 426
427 } 427 }
@@ -429,13 +429,13 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) {
429 // Initialize info structure 429 // Initialize info structure
430 info_ptr = png_create_info_struct(png_ptr); 430 info_ptr = png_create_info_struct(png_ptr);
431 if (info_ptr == nullptr) { 431 if (info_ptr == nullptr) {
432 ERROR_LOG(GPU, "Could not allocate info struct\n"); 432 LOG_ERROR(Debug_GPU, "Could not allocate info struct\n");
433 goto finalise; 433 goto finalise;
434 } 434 }
435 435
436 // Setup Exception handling 436 // Setup Exception handling
437 if (setjmp(png_jmpbuf(png_ptr))) { 437 if (setjmp(png_jmpbuf(png_ptr))) {
438 ERROR_LOG(GPU, "Error during png creation\n"); 438 LOG_ERROR(Debug_GPU, "Error during png creation\n");
439 goto finalise; 439 goto finalise;
440 } 440 }
441 441
@@ -582,7 +582,7 @@ void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages)
582 stage_info += "Stage " + std::to_string(index) + ": " + GetColorCombinerStr(tev_stage) + " " + GetAlphaCombinerStr(tev_stage) + "\n"; 582 stage_info += "Stage " + std::to_string(index) + ": " + GetColorCombinerStr(tev_stage) + " " + GetAlphaCombinerStr(tev_stage) + "\n";
583 } 583 }
584 584
585 DEBUG_LOG(GPU, "%s", stage_info.c_str()); 585 LOG_TRACE(HW_GPU, "%s", stage_info.c_str());
586} 586}
587 587
588} // namespace 588} // namespace
diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h
index 1242eb58f..16b1656bb 100644
--- a/src/video_core/gpu_debugger.h
+++ b/src/video_core/gpu_debugger.h
@@ -39,7 +39,7 @@ public:
39 virtual void GXCommandProcessed(int total_command_count) 39 virtual void GXCommandProcessed(int total_command_count)
40 { 40 {
41 const GSP_GPU::Command& cmd = observed->ReadGXCommandHistory(total_command_count-1); 41 const GSP_GPU::Command& cmd = observed->ReadGXCommandHistory(total_command_count-1);
42 ERROR_LOG(GSP, "Received command: id=%x", (int)cmd.id.Value()); 42 LOG_TRACE(Debug_GPU, "Received command: id=%x", (int)cmd.id.Value());
43 } 43 }
44 44
45 protected: 45 protected:
diff --git a/src/video_core/primitive_assembly.cpp b/src/video_core/primitive_assembly.cpp
index dabf2d1a3..102693ed9 100644
--- a/src/video_core/primitive_assembly.cpp
+++ b/src/video_core/primitive_assembly.cpp
@@ -43,7 +43,7 @@ void PrimitiveAssembler<VertexType>::SubmitVertex(VertexType& vtx, TriangleHandl
43 break; 43 break;
44 44
45 default: 45 default:
46 ERROR_LOG(GPU, "Unknown triangle topology %x:", (int)topology); 46 LOG_ERROR(Render_Software, "Unknown triangle topology %x:", (int)topology);
47 break; 47 break;
48 } 48 }
49} 49}
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index a35f0c0d8..b7e04a560 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -252,7 +252,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
252 return combiner_output.rgb(); 252 return combiner_output.rgb();
253 253
254 default: 254 default:
255 ERROR_LOG(GPU, "Unknown color combiner source %d\n", (int)source); 255 LOG_ERROR(HW_GPU, "Unknown color combiner source %d\n", (int)source);
256 return {}; 256 return {};
257 } 257 }
258 }; 258 };
@@ -272,7 +272,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
272 return combiner_output.a(); 272 return combiner_output.a();
273 273
274 default: 274 default:
275 ERROR_LOG(GPU, "Unknown alpha combiner source %d\n", (int)source); 275 LOG_ERROR(HW_GPU, "Unknown alpha combiner source %d\n", (int)source);
276 return 0; 276 return 0;
277 } 277 }
278 }; 278 };
@@ -283,7 +283,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
283 case ColorModifier::SourceColor: 283 case ColorModifier::SourceColor:
284 return values; 284 return values;
285 default: 285 default:
286 ERROR_LOG(GPU, "Unknown color factor %d\n", (int)factor); 286 LOG_ERROR(HW_GPU, "Unknown color factor %d\n", (int)factor);
287 return {}; 287 return {};
288 } 288 }
289 }; 289 };
@@ -293,7 +293,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
293 case AlphaModifier::SourceAlpha: 293 case AlphaModifier::SourceAlpha:
294 return value; 294 return value;
295 default: 295 default:
296 ERROR_LOG(GPU, "Unknown color factor %d\n", (int)factor); 296 LOG_ERROR(HW_GPU, "Unknown color factor %d\n", (int)factor);
297 return 0; 297 return 0;
298 } 298 }
299 }; 299 };
@@ -307,7 +307,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
307 return ((input[0] * input[1]) / 255).Cast<u8>(); 307 return ((input[0] * input[1]) / 255).Cast<u8>();
308 308
309 default: 309 default:
310 ERROR_LOG(GPU, "Unknown color combiner operation %d\n", (int)op); 310 LOG_ERROR(HW_GPU, "Unknown color combiner operation %d\n", (int)op);
311 return {}; 311 return {};
312 } 312 }
313 }; 313 };
@@ -321,7 +321,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
321 return input[0] * input[1] / 255; 321 return input[0] * input[1] / 255;
322 322
323 default: 323 default:
324 ERROR_LOG(GPU, "Unknown alpha combiner operation %d\n", (int)op); 324 LOG_ERROR(HW_GPU, "Unknown alpha combiner operation %d\n", (int)op);
325 return 0; 325 return 0;
326 } 326 }
327 }; 327 };
diff --git a/src/video_core/renderer_opengl/gl_shader_util.cpp b/src/video_core/renderer_opengl/gl_shader_util.cpp
index fdac9ae1a..d0f82e6cd 100644
--- a/src/video_core/renderer_opengl/gl_shader_util.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_util.cpp
@@ -20,7 +20,7 @@ GLuint LoadShaders(const char* vertex_shader, const char* fragment_shader) {
20 int info_log_length; 20 int info_log_length;
21 21
22 // Compile Vertex Shader 22 // Compile Vertex Shader
23 DEBUG_LOG(GPU, "Compiling vertex shader."); 23 LOG_DEBUG(Render_OpenGL, "Compiling vertex shader...");
24 24
25 glShaderSource(vertex_shader_id, 1, &vertex_shader, nullptr); 25 glShaderSource(vertex_shader_id, 1, &vertex_shader, nullptr);
26 glCompileShader(vertex_shader_id); 26 glCompileShader(vertex_shader_id);
@@ -32,11 +32,15 @@ GLuint LoadShaders(const char* vertex_shader, const char* fragment_shader) {
32 if (info_log_length > 1) { 32 if (info_log_length > 1) {
33 std::vector<char> vertex_shader_error(info_log_length); 33 std::vector<char> vertex_shader_error(info_log_length);
34 glGetShaderInfoLog(vertex_shader_id, info_log_length, nullptr, &vertex_shader_error[0]); 34 glGetShaderInfoLog(vertex_shader_id, info_log_length, nullptr, &vertex_shader_error[0]);
35 DEBUG_LOG(GPU, "%s", &vertex_shader_error[0]); 35 if (result) {
36 LOG_DEBUG(Render_OpenGL, "%s", &vertex_shader_error[0]);
37 } else {
38 LOG_ERROR(Render_OpenGL, "Error compiling vertex shader:\n%s", &vertex_shader_error[0]);
39 }
36 } 40 }
37 41
38 // Compile Fragment Shader 42 // Compile Fragment Shader
39 DEBUG_LOG(GPU, "Compiling fragment shader."); 43 LOG_DEBUG(Render_OpenGL, "Compiling fragment shader...");
40 44
41 glShaderSource(fragment_shader_id, 1, &fragment_shader, nullptr); 45 glShaderSource(fragment_shader_id, 1, &fragment_shader, nullptr);
42 glCompileShader(fragment_shader_id); 46 glCompileShader(fragment_shader_id);
@@ -48,11 +52,15 @@ GLuint LoadShaders(const char* vertex_shader, const char* fragment_shader) {
48 if (info_log_length > 1) { 52 if (info_log_length > 1) {
49 std::vector<char> fragment_shader_error(info_log_length); 53 std::vector<char> fragment_shader_error(info_log_length);
50 glGetShaderInfoLog(fragment_shader_id, info_log_length, nullptr, &fragment_shader_error[0]); 54 glGetShaderInfoLog(fragment_shader_id, info_log_length, nullptr, &fragment_shader_error[0]);
51 DEBUG_LOG(GPU, "%s", &fragment_shader_error[0]); 55 if (result) {
56 LOG_DEBUG(Render_OpenGL, "%s", &fragment_shader_error[0]);
57 } else {
58 LOG_ERROR(Render_OpenGL, "Error compiling fragment shader:\n%s", &fragment_shader_error[0]);
59 }
52 } 60 }
53 61
54 // Link the program 62 // Link the program
55 DEBUG_LOG(GPU, "Linking program."); 63 LOG_DEBUG(Render_OpenGL, "Linking program...");
56 64
57 GLuint program_id = glCreateProgram(); 65 GLuint program_id = glCreateProgram();
58 glAttachShader(program_id, vertex_shader_id); 66 glAttachShader(program_id, vertex_shader_id);
@@ -66,7 +74,11 @@ GLuint LoadShaders(const char* vertex_shader, const char* fragment_shader) {
66 if (info_log_length > 1) { 74 if (info_log_length > 1) {
67 std::vector<char> program_error(info_log_length); 75 std::vector<char> program_error(info_log_length);
68 glGetProgramInfoLog(program_id, info_log_length, nullptr, &program_error[0]); 76 glGetProgramInfoLog(program_id, info_log_length, nullptr, &program_error[0]);
69 DEBUG_LOG(GPU, "%s", &program_error[0]); 77 if (result) {
78 LOG_DEBUG(Render_OpenGL, "%s", &program_error[0]);
79 } else {
80 LOG_ERROR(Render_OpenGL, "Error linking shader:\n%s", &program_error[0]);
81 }
70 } 82 }
71 83
72 glDeleteShader(vertex_shader_id); 84 glDeleteShader(vertex_shader_id);
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 06de6afbd..e2caeeb8f 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -90,7 +90,7 @@ void RendererOpenGL::LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig&
90 const VAddr framebuffer_vaddr = Memory::PhysicalToVirtualAddress( 90 const VAddr framebuffer_vaddr = Memory::PhysicalToVirtualAddress(
91 framebuffer.active_fb == 1 ? framebuffer.address_left2 : framebuffer.address_left1); 91 framebuffer.active_fb == 1 ? framebuffer.address_left2 : framebuffer.address_left1);
92 92
93 DEBUG_LOG(GPU, "0x%08x bytes from 0x%08x(%dx%d), fmt %x", 93 LOG_TRACE(Render_OpenGL, "0x%08x bytes from 0x%08x(%dx%d), fmt %x",
94 framebuffer.stride * framebuffer.height, 94 framebuffer.stride * framebuffer.height,
95 framebuffer_vaddr, (int)framebuffer.width, 95 framebuffer_vaddr, (int)framebuffer.width,
96 (int)framebuffer.height, (int)framebuffer.format); 96 (int)framebuffer.height, (int)framebuffer.format);
@@ -98,15 +98,15 @@ void RendererOpenGL::LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig&
98 const u8* framebuffer_data = Memory::GetPointer(framebuffer_vaddr); 98 const u8* framebuffer_data = Memory::GetPointer(framebuffer_vaddr);
99 99
100 // TODO: Handle other pixel formats 100 // TODO: Handle other pixel formats
101 _dbg_assert_msg_(RENDER, framebuffer.color_format == GPU::Regs::PixelFormat::RGB8, 101 _dbg_assert_msg_(Render_OpenGL, framebuffer.color_format == GPU::Regs::PixelFormat::RGB8,
102 "Unsupported 3DS pixel format."); 102 "Unsupported 3DS pixel format.");
103 103
104 size_t pixel_stride = framebuffer.stride / 3; 104 size_t pixel_stride = framebuffer.stride / 3;
105 // OpenGL only supports specifying a stride in units of pixels, not bytes, unfortunately 105 // OpenGL only supports specifying a stride in units of pixels, not bytes, unfortunately
106 _dbg_assert_(RENDER, pixel_stride * 3 == framebuffer.stride); 106 _dbg_assert_(Render_OpenGL, pixel_stride * 3 == framebuffer.stride);
107 // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default 107 // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default
108 // only allows rows to have a memory alignement of 4. 108 // only allows rows to have a memory alignement of 4.
109 _dbg_assert_(RENDER, pixel_stride % 4 == 0); 109 _dbg_assert_(Render_OpenGL, pixel_stride % 4 == 0);
110 110
111 glBindTexture(GL_TEXTURE_2D, texture.handle); 111 glBindTexture(GL_TEXTURE_2D, texture.handle);
112 glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint)pixel_stride); 112 glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint)pixel_stride);
@@ -263,11 +263,11 @@ void RendererOpenGL::Init() {
263 263
264 int err = ogl_LoadFunctions(); 264 int err = ogl_LoadFunctions();
265 if (ogl_LOAD_SUCCEEDED != err) { 265 if (ogl_LOAD_SUCCEEDED != err) {
266 ERROR_LOG(RENDER, "Failed to initialize GL functions! Exiting..."); 266 LOG_CRITICAL(Render_OpenGL, "Failed to initialize GL functions! Exiting...");
267 exit(-1); 267 exit(-1);
268 } 268 }
269 269
270 NOTICE_LOG(RENDER, "GL_VERSION: %s\n", glGetString(GL_VERSION)); 270 LOG_INFO(Render_OpenGL, "GL_VERSION: %s", glGetString(GL_VERSION));
271 InitOpenGLObjects(); 271 InitOpenGLObjects();
272} 272}
273 273
diff --git a/src/video_core/vertex_shader.cpp b/src/video_core/vertex_shader.cpp
index 0dff11a0f..477e78cfe 100644
--- a/src/video_core/vertex_shader.cpp
+++ b/src/video_core/vertex_shader.cpp
@@ -206,7 +206,7 @@ static void ProcessShaderCode(VertexShaderState& state) {
206 case Instruction::OpCode::CALL: 206 case Instruction::OpCode::CALL:
207 increment_pc = false; 207 increment_pc = false;
208 208
209 _dbg_assert_(GPU, state.call_stack_pointer - state.call_stack < sizeof(state.call_stack)); 209 _dbg_assert_(HW_GPU, state.call_stack_pointer - state.call_stack < sizeof(state.call_stack));
210 210
211 *++state.call_stack_pointer = state.program_counter - shader_memory; 211 *++state.call_stack_pointer = state.program_counter - shader_memory;
212 // TODO: Does this offset refer to the beginning of shader memory? 212 // TODO: Does this offset refer to the beginning of shader memory?
@@ -218,7 +218,7 @@ static void ProcessShaderCode(VertexShaderState& state) {
218 break; 218 break;
219 219
220 default: 220 default:
221 ERROR_LOG(GPU, "Unhandled instruction: 0x%02x (%s): 0x%08x", 221 LOG_ERROR(HW_GPU, "Unhandled instruction: 0x%02x (%s): 0x%08x",
222 (int)instr.opcode.Value(), instr.GetOpCodeName().c_str(), instr.hex); 222 (int)instr.opcode.Value(), instr.GetOpCodeName().c_str(), instr.hex);
223 break; 223 break;
224 } 224 }
@@ -285,7 +285,7 @@ OutputVertex RunShader(const InputVertex& input, int num_attributes)
285 state.debug.max_opdesc_id, registers.vs_main_offset, 285 state.debug.max_opdesc_id, registers.vs_main_offset,
286 registers.vs_output_attributes); 286 registers.vs_output_attributes);
287 287
288 DEBUG_LOG(GPU, "Output vertex: pos (%.2f, %.2f, %.2f, %.2f), col(%.2f, %.2f, %.2f, %.2f), tc0(%.2f, %.2f)", 288 LOG_TRACE(Render_Software, "Output vertex: pos (%.2f, %.2f, %.2f, %.2f), col(%.2f, %.2f, %.2f, %.2f), tc0(%.2f, %.2f)",
289 ret.pos.x.ToFloat32(), ret.pos.y.ToFloat32(), ret.pos.z.ToFloat32(), ret.pos.w.ToFloat32(), 289 ret.pos.x.ToFloat32(), ret.pos.y.ToFloat32(), ret.pos.z.ToFloat32(), ret.pos.w.ToFloat32(),
290 ret.color.x.ToFloat32(), ret.color.y.ToFloat32(), ret.color.z.ToFloat32(), ret.color.w.ToFloat32(), 290 ret.color.x.ToFloat32(), ret.color.y.ToFloat32(), ret.color.z.ToFloat32(), ret.color.w.ToFloat32(),
291 ret.tc0.u().ToFloat32(), ret.tc0.v().ToFloat32()); 291 ret.tc0.u().ToFloat32(), ret.tc0.v().ToFloat32());
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp
index b581ff4da..6791e4007 100644
--- a/src/video_core/video_core.cpp
+++ b/src/video_core/video_core.cpp
@@ -30,13 +30,13 @@ void Init(EmuWindow* emu_window) {
30 30
31 g_current_frame = 0; 31 g_current_frame = 0;
32 32
33 NOTICE_LOG(VIDEO, "initialized OK"); 33 LOG_DEBUG(Render, "initialized OK");
34} 34}
35 35
36/// Shutdown the video core 36/// Shutdown the video core
37void Shutdown() { 37void Shutdown() {
38 delete g_renderer; 38 delete g_renderer;
39 NOTICE_LOG(VIDEO, "shutdown OK"); 39 LOG_DEBUG(Render, "shutdown OK");
40} 40}
41 41
42} // namespace 42} // namespace