From 6674e8e0480b49c36a963eb8028ff5796773fd2a Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 16:32:01 -0500
Subject: [PATCH 01/17] acc_u0: Stub out GetLastOpenedUser.

---
 src/core/hle/service/acc/acc_u0.cpp | 9 +++++++++
 src/core/hle/service/acc/acc_u0.h   | 1 +
 2 files changed, 10 insertions(+)

diff --git a/src/core/hle/service/acc/acc_u0.cpp b/src/core/hle/service/acc/acc_u0.cpp
index 63b60c9271..8110606aaa 100644
--- a/src/core/hle/service/acc/acc_u0.cpp
+++ b/src/core/hle/service/acc/acc_u0.cpp
@@ -81,9 +81,18 @@ void ACC_U0::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx)
     LOG_DEBUG(Service, "called");
 }
 
+void ACC_U0::GetLastOpenedUser(Kernel::HLERequestContext& ctx) {
+    LOG_WARNING(Service, "(STUBBED) called");
+    IPC::ResponseBuilder rb{ctx, 6};
+    rb.Push(RESULT_SUCCESS);
+    rb.Push<u64>(0x0);
+    rb.Push<u64>(0x0);
+}
+
 ACC_U0::ACC_U0() : ServiceFramework("acc:u0") {
     static const FunctionInfo functions[] = {
         {1, &ACC_U0::GetUserExistence, "GetUserExistence"},
+        {4, &ACC_U0::GetLastOpenedUser, "GetLastOpenedUser"},
         {5, &ACC_U0::GetProfile, "GetProfile"},
         {100, &ACC_U0::InitializeApplicationInfo, "InitializeApplicationInfo"},
         {101, &ACC_U0::GetBaasAccountManagerForApplication, "GetBaasAccountManagerForApplication"},
diff --git a/src/core/hle/service/acc/acc_u0.h b/src/core/hle/service/acc/acc_u0.h
index 51676e8594..b38c2f95ec 100644
--- a/src/core/hle/service/acc/acc_u0.h
+++ b/src/core/hle/service/acc/acc_u0.h
@@ -28,6 +28,7 @@ public:
 
 private:
     void GetUserExistence(Kernel::HLERequestContext& ctx);
+    void GetLastOpenedUser(Kernel::HLERequestContext& ctx);
     void GetProfile(Kernel::HLERequestContext& ctx);
     void InitializeApplicationInfo(Kernel::HLERequestContext& ctx);
     void GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx);

From a947f16b639c6fa866d690792fff01c711daa2bb Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 16:40:12 -0500
Subject: [PATCH 02/17] logger: Add "account" service logging category.

---
 src/common/logging/backend.cpp      |  1 +
 src/common/logging/log.h            |  1 +
 src/core/hle/service/acc/acc_u0.cpp | 16 ++++++++--------
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index be53be407b..3b0a0c62b1 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -32,6 +32,7 @@ namespace Log {
     CLS(Kernel)                                                                                    \
     SUB(Kernel, SVC)                                                                               \
     CLS(Service)                                                                                   \
+    SUB(Service, ACC)                                                                              \
     SUB(Service, SM)                                                                               \
     SUB(Service, FS)                                                                               \
     SUB(Service, GSP)                                                                              \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 09ea7a2c79..46a522ed99 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -49,6 +49,7 @@ enum class Class : ClassType {
     Kernel_SVC,        ///< Kernel system calls
     Service,           ///< HLE implementation of system services. Each major service
                        ///  should have its own subclass.
+    Service_ACC,       ///< The ACC (Account service) implementation
     Service_SM,        ///< The SRV (Service Directory) implementation
     Service_FS,        ///< The FS (Filesystem) service implementation
     Service_GSP,       ///< The GSP (GPU control) service
diff --git a/src/core/hle/service/acc/acc_u0.cpp b/src/core/hle/service/acc/acc_u0.cpp
index 8110606aaa..ff9f6cca80 100644
--- a/src/core/hle/service/acc/acc_u0.cpp
+++ b/src/core/hle/service/acc/acc_u0.cpp
@@ -20,7 +20,7 @@ public:
 
 private:
     void GetBase(Kernel::HLERequestContext& ctx) {
-        LOG_WARNING(Service, "(STUBBED) called");
+        LOG_WARNING(Service_ACC, "(STUBBED) called");
         ProfileBase profile_base{};
         IPC::ResponseBuilder rb{ctx, 16};
         rb.Push(RESULT_SUCCESS);
@@ -40,14 +40,14 @@ public:
 
 private:
     void CheckAvailability(Kernel::HLERequestContext& ctx) {
-        LOG_WARNING(Service, "(STUBBED) called");
+        LOG_WARNING(Service_ACC, "(STUBBED) called");
         IPC::ResponseBuilder rb{ctx, 3};
         rb.Push(RESULT_SUCCESS);
         rb.Push(true); // TODO: Check when this is supposed to return true and when not
     }
 
     void GetAccountId(Kernel::HLERequestContext& ctx) {
-        LOG_WARNING(Service, "(STUBBED) called");
+        LOG_WARNING(Service_ACC, "(STUBBED) called");
         IPC::ResponseBuilder rb{ctx, 4};
         rb.Push(RESULT_SUCCESS);
         rb.Push<u64>(0x12345678ABCDEF);
@@ -55,7 +55,7 @@ private:
 };
 
 void ACC_U0::GetUserExistence(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_ACC, "(STUBBED) called");
     IPC::ResponseBuilder rb{ctx, 3};
     rb.Push(RESULT_SUCCESS);
     rb.Push(true); // TODO: Check when this is supposed to return true and when not
@@ -65,11 +65,11 @@ void ACC_U0::GetProfile(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IProfile>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_ACC, "called");
 }
 
 void ACC_U0::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_ACC, "(STUBBED) called");
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 }
@@ -78,11 +78,11 @@ void ACC_U0::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx)
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IManagerForApplication>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_ACC, "called");
 }
 
 void ACC_U0::GetLastOpenedUser(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_ACC, "(STUBBED) called");
     IPC::ResponseBuilder rb{ctx, 6};
     rb.Push(RESULT_SUCCESS);
     rb.Push<u64>(0x0);

From 65cfe09b62d992eee0f7ddafd4151fb17e628e4f Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 16:58:12 -0500
Subject: [PATCH 03/17] logger: Add AM service logging category.

---
 src/common/logging/backend.cpp        |  1 +
 src/common/logging/log.h              |  1 +
 src/core/hle/service/am/am.cpp        | 48 +++++++++++++--------------
 src/core/hle/service/am/applet_ae.cpp | 18 +++++-----
 src/core/hle/service/am/applet_oe.cpp | 18 +++++-----
 5 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 3b0a0c62b1..4a1397b7bf 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -33,6 +33,7 @@ namespace Log {
     SUB(Kernel, SVC)                                                                               \
     CLS(Service)                                                                                   \
     SUB(Service, ACC)                                                                              \
+    SUB(Service, AM)                                                                               \
     SUB(Service, SM)                                                                               \
     SUB(Service, FS)                                                                               \
     SUB(Service, GSP)                                                                              \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 46a522ed99..72e4f2ef72 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -50,6 +50,7 @@ enum class Class : ClassType {
     Service,           ///< HLE implementation of system services. Each major service
                        ///  should have its own subclass.
     Service_ACC,       ///< The ACC (Account service) implementation
+    Service_AM,        ///< The AM (Applet manager service) implementation
     Service_SM,        ///< The SRV (Service Directory) implementation
     Service_FS,        ///< The FS (Filesystem) service implementation
     Service_GSP,       ///< The GSP (GPU control) service
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 2825abd1a5..eb4a04c53b 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -22,14 +22,14 @@ IWindowController::IWindowController() : ServiceFramework("IWindowController") {
 }
 
 void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
     IPC::ResponseBuilder rb{ctx, 4};
     rb.Push(RESULT_SUCCESS);
     rb.Push<u64>(0);
 }
 
 void IWindowController::AcquireForegroundRights(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 }
@@ -73,14 +73,14 @@ void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) {
@@ -91,7 +91,7 @@ void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestCo
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 
-    LOG_WARNING(Service, "(STUBBED) called flag=%u", static_cast<u32>(flag));
+    LOG_WARNING(Service_AM, "(STUBBED) called flag=%u", static_cast<u32>(flag));
 }
 
 void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) {
@@ -102,7 +102,7 @@ void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestCont
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 
-    LOG_WARNING(Service, "(STUBBED) called flag=%u", static_cast<u32>(flag));
+    LOG_WARNING(Service_AM, "(STUBBED) called flag=%u", static_cast<u32>(flag));
 }
 
 void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) {
@@ -115,21 +115,21 @@ void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext&
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 
-    LOG_WARNING(Service, "(STUBBED) called enabled=%u", static_cast<u32>(enabled));
+    LOG_WARNING(Service_AM, "(STUBBED) called enabled=%u", static_cast<u32>(enabled));
 }
 
 void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) {
@@ -142,7 +142,7 @@ void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx)
     rb.Push(RESULT_SUCCESS);
     rb.Push(layer_id);
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 ICommonStateGetter::ICommonStateGetter() : ServiceFramework("ICommonStateGetter") {
@@ -165,7 +165,7 @@ void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
     rb.PushCopyObjects(event);
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) {
@@ -173,7 +173,7 @@ void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
     rb.Push<u32>(15);
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) {
@@ -181,7 +181,7 @@ void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
     rb.Push(static_cast<u8>(FocusState::InFocus));
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) {
@@ -189,7 +189,7 @@ void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
     rb.Push(static_cast<u8>(OperationMode::Handheld));
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
@@ -197,7 +197,7 @@ void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
     rb.Push(static_cast<u32>(APM::PerformanceMode::Handheld));
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 ILibraryAppletCreator::ILibraryAppletCreator() : ServiceFramework("ILibraryAppletCreator") {}
@@ -222,7 +222,7 @@ private:
         rb.Push(RESULT_SUCCESS);
         rb.Push(static_cast<u64>(buffer.size()));
 
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void Read(Kernel::HLERequestContext& ctx) {
@@ -240,7 +240,7 @@ private:
 
         rb.Push(RESULT_SUCCESS);
 
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 };
 
@@ -263,7 +263,7 @@ private:
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<AM::IStorageAccessor>(buffer);
 
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 };
 
@@ -296,7 +296,7 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<AM::IStorage>(buffer);
 
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_AM, "called");
 }
 
 void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) {
@@ -309,27 +309,27 @@ void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 
-    LOG_WARNING(Service, "(STUBBED) called, result=0x%08X", result);
+    LOG_WARNING(Service_AM, "(STUBBED) called, result=0x%08X", result);
 }
 
 void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 4};
     rb.Push(RESULT_SUCCESS);
     rb.Push<u64>(SystemLanguage::English);
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void IApplicationFunctions::InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void IApplicationFunctions::SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void IApplicationFunctions::NotifyRunning(Kernel::HLERequestContext& ctx) {
@@ -337,7 +337,7 @@ void IApplicationFunctions::NotifyRunning(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
     rb.Push<u8>(0); // Unknown, seems to be ignored by official processes
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_AM, "(STUBBED) called");
 }
 
 void InstallInterfaces(SM::ServiceManager& service_manager,
diff --git a/src/core/hle/service/am/applet_ae.cpp b/src/core/hle/service/am/applet_ae.cpp
index a63fb62103..0e51caa70d 100644
--- a/src/core/hle/service/am/applet_ae.cpp
+++ b/src/core/hle/service/am/applet_ae.cpp
@@ -33,56 +33,56 @@ private:
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<ICommonStateGetter>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetSelfController(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<ISelfController>(nvflinger);
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetWindowController(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IWindowController>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetAudioController(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IAudioController>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetDisplayController(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IDisplayController>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetDebugFunctions(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IDebugFunctions>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<ILibraryAppletCreator>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetApplicationFunctions(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IApplicationFunctions>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
@@ -92,7 +92,7 @@ void AppletAE::OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger);
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_AM, "called");
 }
 
 AppletAE::AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp
index 5aa7657701..bdcebe689e 100644
--- a/src/core/hle/service/am/applet_oe.cpp
+++ b/src/core/hle/service/am/applet_oe.cpp
@@ -33,56 +33,56 @@ private:
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IAudioController>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetDisplayController(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IDisplayController>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetDebugFunctions(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IDebugFunctions>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetWindowController(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IWindowController>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetSelfController(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<ISelfController>(nvflinger);
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetCommonStateGetter(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<ICommonStateGetter>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<ILibraryAppletCreator>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     void GetApplicationFunctions(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IApplicationFunctions>();
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_AM, "called");
     }
 
     std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
@@ -92,7 +92,7 @@ void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IApplicationProxy>(nvflinger);
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_AM, "called");
 }
 
 AppletOE::AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)

From 764bbaa19c9bd0ddb597a51a373debc24627b500 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 17:00:33 -0500
Subject: [PATCH 04/17] logger: Use Service_NVDRV category where applicable.

---
 src/core/hle/service/nvdrv/devices/nvmap.cpp | 10 +++++-----
 src/core/hle/service/nvdrv/interface.cpp     | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp
index 74ee7e154c..f6196da1bb 100644
--- a/src/core/hle/service/nvdrv/devices/nvmap.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp
@@ -52,7 +52,7 @@ u32 nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) {
     u32 handle = next_handle++;
     handles[handle] = std::move(object);
 
-    LOG_WARNING(Service, "(STUBBED) size 0x%08X", params.size);
+    LOG_WARNING(Service_NVDRV, "(STUBBED) size 0x%08X", params.size);
 
     params.handle = handle;
 
@@ -74,7 +74,7 @@ u32 nvmap::IocAlloc(const std::vector<u8>& input, std::vector<u8>& output) {
     object->addr = params.addr;
     object->status = Object::Status::Allocated;
 
-    LOG_WARNING(Service, "(STUBBED) Allocated address 0x%llx", params.addr);
+    LOG_WARNING(Service_NVDRV, "(STUBBED) Allocated address 0x%llx", params.addr);
 
     std::memcpy(output.data(), &params, sizeof(params));
     return 0;
@@ -84,7 +84,7 @@ u32 nvmap::IocGetId(const std::vector<u8>& input, std::vector<u8>& output) {
     IocGetIdParams params;
     std::memcpy(&params, input.data(), sizeof(params));
 
-    LOG_WARNING(Service, "called");
+    LOG_WARNING(Service_NVDRV, "called");
 
     auto itr = handles.find(params.handle);
     ASSERT(itr != handles.end());
@@ -99,7 +99,7 @@ u32 nvmap::IocFromId(const std::vector<u8>& input, std::vector<u8>& output) {
     IocFromIdParams params;
     std::memcpy(&params, input.data(), sizeof(params));
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_NVDRV, "(STUBBED) called");
 
     auto itr = std::find_if(handles.begin(), handles.end(),
                             [&](const auto& entry) { return entry.second->id == params.id; });
@@ -121,7 +121,7 @@ u32 nvmap::IocParam(const std::vector<u8>& input, std::vector<u8>& output) {
     IocParamParams params;
     std::memcpy(&params, input.data(), sizeof(params));
 
-    LOG_WARNING(Service, "(STUBBED) called type=%u", params.type);
+    LOG_WARNING(Service_NVDRV, "(STUBBED) called type=%u", params.type);
 
     auto itr = handles.find(params.handle);
     ASSERT(itr != handles.end());
diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp
index 85ecde6d20..af8fa44c90 100644
--- a/src/core/hle/service/nvdrv/interface.cpp
+++ b/src/core/hle/service/nvdrv/interface.cpp
@@ -11,7 +11,7 @@ namespace Service {
 namespace Nvidia {
 
 void NVDRV::Open(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_NVDRV, "(STUBBED) called");
 
     auto buffer = ctx.BufferDescriptorA()[0];
 
@@ -25,7 +25,7 @@ void NVDRV::Open(Kernel::HLERequestContext& ctx) {
 }
 
 void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_NVDRV, "(STUBBED) called");
 
     IPC::RequestParser rp{ctx};
     u32 fd = rp.Pop<u32>();
@@ -49,7 +49,7 @@ void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) {
 }
 
 void NVDRV::Close(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_NVDRV, "(STUBBED) called");
 
     IPC::RequestParser rp{ctx};
     u32 fd = rp.Pop<u32>();
@@ -61,7 +61,7 @@ void NVDRV::Close(Kernel::HLERequestContext& ctx) {
 }
 
 void NVDRV::Initialize(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_NVDRV, "(STUBBED) called");
     IPC::ResponseBuilder rb{ctx, 3};
     rb.Push(RESULT_SUCCESS);
     rb.Push<u32>(0);
@@ -71,7 +71,7 @@ void NVDRV::SetClientPID(Kernel::HLERequestContext& ctx) {
     IPC::RequestParser rp{ctx};
     pid = rp.Pop<u64>();
 
-    LOG_INFO(Service, "called, pid=0x%lx", pid);
+    LOG_INFO(Service_NVDRV, "called, pid=0x%lx", pid);
     IPC::ResponseBuilder rb{ctx, 3};
     rb.Push(RESULT_SUCCESS);
     rb.Push<u32>(0);

From ea615ef5a40f80da8a0f05792a1bcdd1f286a1f9 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 17:02:39 -0500
Subject: [PATCH 05/17] logger: Use Service_HID category where applicable.

---
 src/core/hle/service/hid/hid.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 326e0a4ab6..e920560ee4 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -49,7 +49,7 @@ private:
         IPC::ResponseBuilder rb{ctx, 2, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushCopyObjects(shared_mem);
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_HID, "called");
     }
 
     void LoadInputDevices() {
@@ -172,7 +172,7 @@ private:
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IAppletResource>(applet_resource);
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_HID, "called");
     }
 };
 

From ad97414057f31b0711b030adf4cf9de4f01c1f6b Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 17:06:14 -0500
Subject: [PATCH 06/17] hid: Implement CreateActiveVibrationDeviceList.

---
 src/core/hle/service/hid/hid.cpp | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index e920560ee4..e7b559d45c 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -151,11 +151,29 @@ private:
         buttons;
 };
 
+class IActiveVibrationDeviceList final : public ServiceFramework<IActiveVibrationDeviceList> {
+public:
+    IActiveVibrationDeviceList() : ServiceFramework("IActiveVibrationDeviceList") {
+        static const FunctionInfo functions[] = {
+            {0, &IActiveVibrationDeviceList::ActivateVibrationDevice, "ActivateVibrationDevice"},
+        };
+        RegisterHandlers(functions);
+    }
+
+private:
+    void ActivateVibrationDevice(Kernel::HLERequestContext& ctx) {
+        IPC::ResponseBuilder rb{ctx, 2};
+        rb.Push(RESULT_SUCCESS);
+        LOG_WARNING(Service_HID, "(STUBBED) called");
+    }
+};
+
 class Hid final : public ServiceFramework<Hid> {
 public:
     Hid() : ServiceFramework("hid") {
         static const FunctionInfo functions[] = {
             {0x00000000, &Hid::CreateAppletResource, "CreateAppletResource"},
+            {203, &Hid::CreateActiveVibrationDeviceList, "CreateActiveVibrationDeviceList"},
         };
         RegisterHandlers(functions);
     }
@@ -174,6 +192,13 @@ private:
         rb.PushIpcInterface<IAppletResource>(applet_resource);
         LOG_DEBUG(Service_HID, "called");
     }
+
+    void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) {
+        IPC::ResponseBuilder rb{ctx, 2, 0, 1};
+        rb.Push(RESULT_SUCCESS);
+        rb.PushIpcInterface<IActiveVibrationDeviceList>();
+        LOG_DEBUG(Service_HID, "called");
+    }
 };
 
 void ReloadInputDevices() {}

From 119f02a439b0e5b20f9176ba0df4d12857b50ffa Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 22:24:20 -0500
Subject: [PATCH 07/17] hid: Stub out several functions.

---
 src/core/hle/service/hid/hid.cpp | 40 +++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index e7b559d45c..be058a64e7 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -172,7 +172,15 @@ class Hid final : public ServiceFramework<Hid> {
 public:
     Hid() : ServiceFramework("hid") {
         static const FunctionInfo functions[] = {
-            {0x00000000, &Hid::CreateAppletResource, "CreateAppletResource"},
+            {0, &Hid::CreateAppletResource, "CreateAppletResource"},
+            {1, &Hid::ActivateDebugPad, "ActivateDebugPad"},
+            {11, nullptr, "ActivateTouchScreen"},
+            {66, &Hid::StartSixAxisSensor, "StartSixAxisSensor"},
+            {100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"},
+            {102, &Hid::SetSupportedNpadIdType, "SetSupportedNpadIdType"},
+            {103, &Hid::ActivateNpad, "ActivateNpad"},
+            {120, nullptr, "SetNpadJoyHoldType"},
+            {124, nullptr, "SetNpadJoyAssignmentModeDual"},
             {203, &Hid::CreateActiveVibrationDeviceList, "CreateActiveVibrationDeviceList"},
         };
         RegisterHandlers(functions);
@@ -193,6 +201,36 @@ private:
         LOG_DEBUG(Service_HID, "called");
     }
 
+    void ActivateDebugPad(Kernel::HLERequestContext& ctx) {
+        IPC::ResponseBuilder rb{ctx, 2};
+        rb.Push(RESULT_SUCCESS);
+        LOG_WARNING(Service_HID, "(STUBBED) called");
+    }
+
+    void StartSixAxisSensor(Kernel::HLERequestContext& ctx) {
+        IPC::ResponseBuilder rb{ctx, 2};
+        rb.Push(RESULT_SUCCESS);
+        LOG_WARNING(Service_HID, "(STUBBED) called");
+    }
+
+    void SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) {
+        IPC::ResponseBuilder rb{ctx, 2};
+        rb.Push(RESULT_SUCCESS);
+        LOG_WARNING(Service_HID, "(STUBBED) called");
+    }
+
+    void SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) {
+        IPC::ResponseBuilder rb{ctx, 2};
+        rb.Push(RESULT_SUCCESS);
+        LOG_WARNING(Service_HID, "(STUBBED) called");
+    }
+
+    void ActivateNpad(Kernel::HLERequestContext& ctx) {
+        IPC::ResponseBuilder rb{ctx, 2};
+        rb.Push(RESULT_SUCCESS);
+        LOG_WARNING(Service_HID, "(STUBBED) called");
+    }
+
     void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) {
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);

From 8a5833f7ad757f3c9c9051632aa05c99ca4543fa Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 22:26:44 -0500
Subject: [PATCH 08/17] logger: Add VI service logging category.

---
 src/common/logging/backend.cpp   |  1 +
 src/common/logging/log.h         |  1 +
 src/core/hle/service/vi/vi.cpp   | 35 ++++++++++++++++----------------
 src/core/hle/service/vi/vi_m.cpp |  2 +-
 src/core/hle/service/vi/vi_s.cpp |  2 +-
 src/core/hle/service/vi/vi_u.cpp |  2 +-
 6 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 4a1397b7bf..7d72916122 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -42,6 +42,7 @@ namespace Log {
     SUB(Service, HID)                                                                              \
     SUB(Service, NVDRV)                                                                            \
     SUB(Service, Audio)                                                                            \
+    SUB(Service, VI)                                                                               \
     CLS(HW)                                                                                        \
     SUB(HW, Memory)                                                                                \
     SUB(HW, LCD)                                                                                   \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 72e4f2ef72..76cee71cbe 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -59,6 +59,7 @@ enum class Class : ClassType {
     Service_HID,       ///< The HID (Human interface device) service
     Service_NVDRV,     ///< The NVDRV (Nvidia driver) service
     Service_Audio,     ///< The Audio (Audio control) service
+    Service_VI,        ///< The VI (Video interface) service
     HW,                ///< Low-level hardware emulation
     HW_Memory,         ///< Memory-map and address translation
     HW_LCD,            ///< LCD register emulation
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 2c7737fd90..adefba2b7a 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -429,7 +429,7 @@ private:
         auto& output_buffer = ctx.BufferDescriptorB()[0];
 
         auto buffer_queue = nv_flinger->GetBufferQueue(id);
-
+        LOG_WARNING(Service_VI, "(STUBBED) called, transaction=%x", transaction);
         if (transaction == TransactionId::Connect) {
             IGBPConnectRequestParcel request{input_data};
             IGBPConnectResponseParcel response{1280, 720};
@@ -487,7 +487,6 @@ private:
             ASSERT_MSG(false, "Unimplemented");
         }
 
-        LOG_WARNING(Service, "(STUBBED) called");
         IPC::ResponseBuilder rb{ctx, 2};
         rb.Push(RESULT_SUCCESS);
     }
@@ -498,7 +497,7 @@ private:
         s32 addval = rp.PopRaw<s32>();
         u32 type = rp.Pop<u32>();
 
-        LOG_WARNING(Service, "(STUBBED) called id=%u, addval=%08X, type=%08X", id, addval, type);
+        LOG_WARNING(Service_VI, "(STUBBED) called id=%u, addval=%08X, type=%08X", id, addval, type);
         IPC::ResponseBuilder rb{ctx, 2};
         rb.Push(RESULT_SUCCESS);
     }
@@ -512,7 +511,7 @@ private:
 
         // TODO(Subv): Find out what this actually is.
 
-        LOG_WARNING(Service, "(STUBBED) called id=%u, unknown=%08X", id, unknown);
+        LOG_WARNING(Service_VI, "(STUBBED) called id=%u, unknown=%08X", id, unknown);
         IPC::ResponseBuilder rb{ctx, 2, 1};
         rb.Push(RESULT_SUCCESS);
         rb.PushCopyObjects(buffer_queue->GetNativeHandle());
@@ -534,7 +533,7 @@ public:
 
 private:
     void SetLayerZ(Kernel::HLERequestContext& ctx) {
-        LOG_WARNING(Service, "(STUBBED) called");
+        LOG_WARNING(Service_VI, "(STUBBED) called");
         IPC::RequestParser rp{ctx};
         u64 layer_id = rp.Pop<u64>();
         u64 z_value = rp.Pop<u64>();
@@ -560,7 +559,7 @@ public:
 
 private:
     void CloseDisplay(Kernel::HLERequestContext& ctx) {
-        LOG_WARNING(Service, "(STUBBED) called");
+        LOG_WARNING(Service_VI, "(STUBBED) called");
         IPC::RequestParser rp{ctx};
         u64 display = rp.Pop<u64>();
 
@@ -569,7 +568,7 @@ private:
     }
 
     void CreateManagedLayer(Kernel::HLERequestContext& ctx) {
-        LOG_WARNING(Service, "(STUBBED) called");
+        LOG_WARNING(Service_VI, "(STUBBED) called");
         IPC::RequestParser rp{ctx};
         u32 unknown = rp.Pop<u32>();
         rp.Skip(1, false);
@@ -584,7 +583,7 @@ private:
     }
 
     void AddToLayerStack(Kernel::HLERequestContext& ctx) {
-        LOG_WARNING(Service, "(STUBBED) called");
+        LOG_WARNING(Service_VI, "(STUBBED) called");
         IPC::RequestParser rp{ctx};
         u32 stack = rp.Pop<u32>();
         u64 layer_id = rp.Pop<u64>();
@@ -597,7 +596,7 @@ private:
 };
 
 void IApplicationDisplayService::GetRelayService(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
@@ -605,7 +604,7 @@ void IApplicationDisplayService::GetRelayService(Kernel::HLERequestContext& ctx)
 }
 
 void IApplicationDisplayService::GetSystemDisplayService(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
@@ -613,7 +612,7 @@ void IApplicationDisplayService::GetSystemDisplayService(Kernel::HLERequestConte
 }
 
 void IApplicationDisplayService::GetManagerDisplayService(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
@@ -622,7 +621,7 @@ void IApplicationDisplayService::GetManagerDisplayService(Kernel::HLERequestCont
 
 void IApplicationDisplayService::GetIndirectDisplayTransactionService(
     Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
@@ -630,7 +629,7 @@ void IApplicationDisplayService::GetIndirectDisplayTransactionService(
 }
 
 void IApplicationDisplayService::OpenDisplay(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
     IPC::RequestParser rp{ctx};
     auto name_buf = rp.PopRaw<std::array<u8, 0x40>>();
     auto end = std::find(name_buf.begin(), name_buf.end(), '\0');
@@ -645,7 +644,7 @@ void IApplicationDisplayService::OpenDisplay(Kernel::HLERequestContext& ctx) {
 }
 
 void IApplicationDisplayService::CloseDisplay(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
     IPC::RequestParser rp{ctx};
     u64 display_id = rp.Pop<u64>();
 
@@ -654,7 +653,7 @@ void IApplicationDisplayService::CloseDisplay(Kernel::HLERequestContext& ctx) {
 }
 
 void IApplicationDisplayService::OpenLayer(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
     IPC::RequestParser rp{ctx};
     auto name_buf = rp.PopRaw<std::array<u8, 0x40>>();
     auto end = std::find(name_buf.begin(), name_buf.end(), '\0');
@@ -704,7 +703,7 @@ void IApplicationDisplayService::CreateStrayLayer(Kernel::HLERequestContext& ctx
 }
 
 void IApplicationDisplayService::DestroyStrayLayer(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
 
     IPC::RequestParser rp{ctx};
     u64 layer_id = rp.Pop<u64>();
@@ -714,7 +713,7 @@ void IApplicationDisplayService::DestroyStrayLayer(Kernel::HLERequestContext& ct
 }
 
 void IApplicationDisplayService::SetLayerScalingMode(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
     IPC::RequestParser rp{ctx};
     u32 scaling_mode = rp.Pop<u32>();
     u64 unknown = rp.Pop<u64>();
@@ -724,7 +723,7 @@ void IApplicationDisplayService::SetLayerScalingMode(Kernel::HLERequestContext&
 }
 
 void IApplicationDisplayService::GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
     IPC::RequestParser rp{ctx};
     u64 display_id = rp.Pop<u64>();
 
diff --git a/src/core/hle/service/vi/vi_m.cpp b/src/core/hle/service/vi/vi_m.cpp
index bb440cadb1..5d99647dca 100644
--- a/src/core/hle/service/vi/vi_m.cpp
+++ b/src/core/hle/service/vi/vi_m.cpp
@@ -11,7 +11,7 @@ namespace Service {
 namespace VI {
 
 void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
diff --git a/src/core/hle/service/vi/vi_s.cpp b/src/core/hle/service/vi/vi_s.cpp
index dc2848a9c8..4117579817 100644
--- a/src/core/hle/service/vi/vi_s.cpp
+++ b/src/core/hle/service/vi/vi_s.cpp
@@ -11,7 +11,7 @@ namespace Service {
 namespace VI {
 
 void VI_S::GetDisplayService(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
diff --git a/src/core/hle/service/vi/vi_u.cpp b/src/core/hle/service/vi/vi_u.cpp
index 95c4d9fd7c..f5568383be 100644
--- a/src/core/hle/service/vi/vi_u.cpp
+++ b/src/core/hle/service/vi/vi_u.cpp
@@ -11,7 +11,7 @@ namespace Service {
 namespace VI {
 
 void VI_U::GetDisplayService(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_VI, "(STUBBED) called");
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);

From 485c6541cfec7f5c1405a6cfa82712e0485e4464 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 22:35:42 -0500
Subject: [PATCH 09/17] logger: Add NIFM service logging category.

---
 src/common/logging/backend.cpp       |  1 +
 src/common/logging/log.h             |  1 +
 src/core/hle/service/nifm/nifm.cpp   | 10 +++++-----
 src/core/hle/service/nifm/nifm_a.cpp |  4 ++--
 src/core/hle/service/nifm/nifm_s.cpp |  4 ++--
 src/core/hle/service/nifm/nifm_u.cpp |  4 ++--
 6 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 7d72916122..c1f0311ce4 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -40,6 +40,7 @@ namespace Log {
     SUB(Service, CFG)                                                                              \
     SUB(Service, DSP)                                                                              \
     SUB(Service, HID)                                                                              \
+    SUB(Service, NIFM)                                                                             \
     SUB(Service, NVDRV)                                                                            \
     SUB(Service, Audio)                                                                            \
     SUB(Service, VI)                                                                               \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 76cee71cbe..bf1fe9bbc7 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -57,6 +57,7 @@ enum class Class : ClassType {
     Service_CFG,       ///< The CFG (Configuration) service
     Service_DSP,       ///< The DSP (DSP control) service
     Service_HID,       ///< The HID (Human interface device) service
+    Service_NIFM,      ///< The NIFM (Network interface) service
     Service_NVDRV,     ///< The NVDRV (Nvidia driver) service
     Service_Audio,     ///< The Audio (Audio control) service
     Service_VI,        ///< The VI (Video interface) service
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp
index f91571eb4d..290a2ee74c 100644
--- a/src/core/hle/service/nifm/nifm.cpp
+++ b/src/core/hle/service/nifm/nifm.cpp
@@ -112,7 +112,7 @@ IGeneralService::IGeneralService() : ServiceFramework("IGeneralService") {
 }
 
 void IGeneralService::GetClientId(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_NIFM, "(STUBBED) called");
     IPC::ResponseBuilder rb{ctx, 4};
     rb.Push(RESULT_SUCCESS);
     rb.Push<u64>(0);
@@ -124,7 +124,7 @@ void IGeneralService::CreateScanRequest(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IScanRequest>();
 
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_NIFM, "called");
 }
 
 void IGeneralService::CreateRequest(Kernel::HLERequestContext& ctx) {
@@ -133,11 +133,11 @@ void IGeneralService::CreateRequest(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IRequest>();
 
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_NIFM, "called");
 }
 
 void IGeneralService::RemoveNetworkProfile(Kernel::HLERequestContext& ctx) {
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_NIFM, "(STUBBED) called");
     IPC::ResponseBuilder rb{ctx, 2};
     rb.Push(RESULT_SUCCESS);
 }
@@ -148,7 +148,7 @@ void IGeneralService::CreateTemporaryNetworkProfile(Kernel::HLERequestContext& c
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<INetworkProfile>();
 
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_NIFM, "called");
 }
 
 void InstallInterfaces(SM::ServiceManager& service_manager) {
diff --git a/src/core/hle/service/nifm/nifm_a.cpp b/src/core/hle/service/nifm/nifm_a.cpp
index 3835a87bfd..ee61d8ff44 100644
--- a/src/core/hle/service/nifm/nifm_a.cpp
+++ b/src/core/hle/service/nifm/nifm_a.cpp
@@ -14,14 +14,14 @@ void NIFM_A::CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IGeneralService>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_NIFM, "called");
 }
 
 void NIFM_A::CreateGeneralService(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IGeneralService>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_NIFM, "called");
 }
 
 NIFM_A::NIFM_A() : ServiceFramework("nifm:a") {
diff --git a/src/core/hle/service/nifm/nifm_s.cpp b/src/core/hle/service/nifm/nifm_s.cpp
index cbb42891c9..c38b2a4c7d 100644
--- a/src/core/hle/service/nifm/nifm_s.cpp
+++ b/src/core/hle/service/nifm/nifm_s.cpp
@@ -14,14 +14,14 @@ void NIFM_S::CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IGeneralService>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_NIFM, "called");
 }
 
 void NIFM_S::CreateGeneralService(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IGeneralService>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_NIFM, "called");
 }
 
 NIFM_S::NIFM_S() : ServiceFramework("nifm:s") {
diff --git a/src/core/hle/service/nifm/nifm_u.cpp b/src/core/hle/service/nifm/nifm_u.cpp
index c6de147448..a5895c13c6 100644
--- a/src/core/hle/service/nifm/nifm_u.cpp
+++ b/src/core/hle/service/nifm/nifm_u.cpp
@@ -14,14 +14,14 @@ void NIFM_U::CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IGeneralService>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_NIFM, "called");
 }
 
 void NIFM_U::CreateGeneralService(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IGeneralService>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_NIFM, "called");
 }
 
 NIFM_U::NIFM_U() : ServiceFramework("nifm:u") {

From 69697535bfca47419333064758bc61a00eca0d79 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 22:36:57 -0500
Subject: [PATCH 10/17] lm: Ensure log string is non-empty before checking
 back().

---
 src/core/hle/service/lm/lm.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index 2843e0e408..7ff9c37f31 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -125,7 +125,7 @@ private:
         if (line) {
             output += std::to_string(line) + ':';
         }
-        if (output.back() == ':') {
+        if (output.length() > 0 && output.back() == ':') {
             output += ' ';
         }
         output += message;

From 8d2e4c3d39dca1abcb1e48c5cdbe02bdb1a21570 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 22:39:47 -0500
Subject: [PATCH 11/17] logger: Add APM service logging category.

---
 src/common/logging/backend.cpp   | 1 +
 src/common/logging/log.h         | 1 +
 src/core/hle/service/apm/apm.cpp | 5 +++--
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index c1f0311ce4..27a18a6c23 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -34,6 +34,7 @@ namespace Log {
     CLS(Service)                                                                                   \
     SUB(Service, ACC)                                                                              \
     SUB(Service, AM)                                                                               \
+    SUB(Service, APM)                                                                              \
     SUB(Service, SM)                                                                               \
     SUB(Service, FS)                                                                               \
     SUB(Service, GSP)                                                                              \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index bf1fe9bbc7..83fd012f15 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -51,6 +51,7 @@ enum class Class : ClassType {
                        ///  should have its own subclass.
     Service_ACC,       ///< The ACC (Account service) implementation
     Service_AM,        ///< The AM (Applet manager service) implementation
+    Service_APM,       ///< The APM service implementation
     Service_SM,        ///< The SRV (Service Directory) implementation
     Service_FS,        ///< The FS (Filesystem) service implementation
     Service_GSP,       ///< The GSP (GPU control) service
diff --git a/src/core/hle/service/apm/apm.cpp b/src/core/hle/service/apm/apm.cpp
index c4b1723c58..a7495d0a0b 100644
--- a/src/core/hle/service/apm/apm.cpp
+++ b/src/core/hle/service/apm/apm.cpp
@@ -33,7 +33,8 @@ private:
         IPC::ResponseBuilder rb{ctx, 2};
         rb.Push(RESULT_SUCCESS);
 
-        LOG_WARNING(Service, "(STUBBED) called mode=%u config=%u", static_cast<u32>(mode), config);
+        LOG_WARNING(Service_APM, "(STUBBED) called mode=%u config=%u", static_cast<u32>(mode),
+                    config);
     }
 
     void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
@@ -45,7 +46,7 @@ private:
         rb.Push(RESULT_SUCCESS);
         rb.Push<u32>(0); // Performance configuration
 
-        LOG_WARNING(Service, "(STUBBED) called mode=%u", static_cast<u32>(mode));
+        LOG_WARNING(Service_APM, "(STUBBED) called mode=%u", static_cast<u32>(mode));
     }
 };
 

From 649960b4eb40d453ad55688b0fe0dc9677ca1605 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 22:41:55 -0500
Subject: [PATCH 12/17] logger: Add LM service logging category.

---
 src/common/logging/backend.cpp | 1 +
 src/common/logging/log.h       | 1 +
 src/core/hle/service/lm/lm.cpp | 4 ++--
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 27a18a6c23..9af9f531bc 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -41,6 +41,7 @@ namespace Log {
     SUB(Service, CFG)                                                                              \
     SUB(Service, DSP)                                                                              \
     SUB(Service, HID)                                                                              \
+    SUB(Service, LM)                                                                               \
     SUB(Service, NIFM)                                                                             \
     SUB(Service, NVDRV)                                                                            \
     SUB(Service, Audio)                                                                            \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 83fd012f15..6897a10362 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -58,6 +58,7 @@ enum class Class : ClassType {
     Service_CFG,       ///< The CFG (Configuration) service
     Service_DSP,       ///< The DSP (DSP control) service
     Service_HID,       ///< The HID (Human interface device) service
+    Service_LM,        ///< The LM (Logger) service implementation
     Service_NIFM,      ///< The NIFM (Network interface) service
     Service_NVDRV,     ///< The NVDRV (Nvidia driver) service
     Service_Audio,     ///< The Audio (Audio control) service
diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index 7ff9c37f31..c480f6b97c 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -76,7 +76,7 @@ private:
         addr += sizeof(MessageHeader);
 
         if (!header.IsSingleMessage()) {
-            LOG_WARNING(Service, "Multi message logs are unimplemeneted");
+            LOG_WARNING(Service_LM, "Multi message logs are unimplemeneted");
             return;
         }
 
@@ -150,7 +150,7 @@ void LM::Initialize(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<Logger>();
 
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_LM, "called");
 }
 
 LM::LM() : ServiceFramework("lm") {

From fc1359dc03cac8df8c4dcddf48b67de6622b97a4 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 22:44:00 -0500
Subject: [PATCH 13/17] logger: Add PCTL service logging category.

---
 src/common/logging/backend.cpp       | 1 +
 src/common/logging/log.h             | 1 +
 src/core/hle/service/pctl/pctl_a.cpp | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 9af9f531bc..6dcfaed691 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -44,6 +44,7 @@ namespace Log {
     SUB(Service, LM)                                                                               \
     SUB(Service, NIFM)                                                                             \
     SUB(Service, NVDRV)                                                                            \
+    SUB(Service, PCTL)                                                                             \
     SUB(Service, Audio)                                                                            \
     SUB(Service, VI)                                                                               \
     CLS(HW)                                                                                        \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 6897a10362..b7d3e1c4f7 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -61,6 +61,7 @@ enum class Class : ClassType {
     Service_LM,        ///< The LM (Logger) service implementation
     Service_NIFM,      ///< The NIFM (Network interface) service
     Service_NVDRV,     ///< The NVDRV (Nvidia driver) service
+    Service_PCTL,      ///< The PCTL (Parental control) service
     Service_Audio,     ///< The Audio (Audio control) service
     Service_VI,        ///< The VI (Video interface) service
     HW,                ///< Low-level hardware emulation
diff --git a/src/core/hle/service/pctl/pctl_a.cpp b/src/core/hle/service/pctl/pctl_a.cpp
index c808b764bb..c65fffa070 100644
--- a/src/core/hle/service/pctl/pctl_a.cpp
+++ b/src/core/hle/service/pctl/pctl_a.cpp
@@ -18,7 +18,7 @@ void PCTL_A::GetService(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IParentalControlService>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_PCTL, "called");
 }
 
 PCTL_A::PCTL_A() : ServiceFramework("pctl:a") {

From c689fe84244868542bf557b2ca3fe1da63f2a6da Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 22:55:45 -0500
Subject: [PATCH 14/17] logger: Add SET service logging category.

---
 src/common/logging/backend.cpp   |  8 +++-----
 src/common/logging/log.h         | 18 ++++++++----------
 src/core/hle/service/set/set.cpp |  2 +-
 3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 6dcfaed691..2848fe1166 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -33,19 +33,17 @@ namespace Log {
     SUB(Kernel, SVC)                                                                               \
     CLS(Service)                                                                                   \
     SUB(Service, ACC)                                                                              \
+    SUB(Service, Audio)                                                                            \
     SUB(Service, AM)                                                                               \
     SUB(Service, APM)                                                                              \
-    SUB(Service, SM)                                                                               \
     SUB(Service, FS)                                                                               \
-    SUB(Service, GSP)                                                                              \
-    SUB(Service, CFG)                                                                              \
-    SUB(Service, DSP)                                                                              \
     SUB(Service, HID)                                                                              \
     SUB(Service, LM)                                                                               \
     SUB(Service, NIFM)                                                                             \
     SUB(Service, NVDRV)                                                                            \
     SUB(Service, PCTL)                                                                             \
-    SUB(Service, Audio)                                                                            \
+    SUB(Service, SET)                                                                              \
+    SUB(Service, SM)                                                                               \
     SUB(Service, VI)                                                                               \
     CLS(HW)                                                                                        \
     SUB(HW, Memory)                                                                                \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index b7d3e1c4f7..f7336cea8d 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -49,20 +49,18 @@ enum class Class : ClassType {
     Kernel_SVC,        ///< Kernel system calls
     Service,           ///< HLE implementation of system services. Each major service
                        ///  should have its own subclass.
-    Service_ACC,       ///< The ACC (Account service) implementation
-    Service_AM,        ///< The AM (Applet manager service) implementation
-    Service_APM,       ///< The APM service implementation
-    Service_SM,        ///< The SRV (Service Directory) implementation
-    Service_FS,        ///< The FS (Filesystem) service implementation
-    Service_GSP,       ///< The GSP (GPU control) service
-    Service_CFG,       ///< The CFG (Configuration) service
-    Service_DSP,       ///< The DSP (DSP control) service
+    Service_ACC,       ///< The ACC (Accounts) service
+    Service_AM,        ///< The AM (Applet manager) service
+    Service_APM,       ///< The APM (Performance) service
+    Service_Audio,     ///< The Audio (Audio control) service
+    Service_FS,        ///< The FS (Filesystem) service
     Service_HID,       ///< The HID (Human interface device) service
-    Service_LM,        ///< The LM (Logger) service implementation
+    Service_LM,        ///< The LM (Logger) service
     Service_NIFM,      ///< The NIFM (Network interface) service
     Service_NVDRV,     ///< The NVDRV (Nvidia driver) service
     Service_PCTL,      ///< The PCTL (Parental control) service
-    Service_Audio,     ///< The Audio (Audio control) service
+    Service_SET,       ///< The SET (Settings) service
+    Service_SM,        ///< The SM (Service manager) service
     Service_VI,        ///< The VI (Video interface) service
     HW,                ///< Low-level hardware emulation
     HW_Memory,         ///< Memory-map and address translation
diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp
index e0e157fe1f..d139304bba 100644
--- a/src/core/hle/service/set/set.cpp
+++ b/src/core/hle/service/set/set.cpp
@@ -24,7 +24,7 @@ void SET::GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
     rb.Push(static_cast<u64>(lang_codes.size()));
 
-    LOG_WARNING(Service, "(STUBBED) called");
+    LOG_WARNING(Service_SET, "(STUBBED) called");
 }
 
 SET::SET(const char* name) : ServiceFramework(name) {

From 8e1dbb26bd50ad5c2d6b17f89d53198d42a7d800 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 22:59:52 -0500
Subject: [PATCH 15/17] logger: Add Time service logging category.

---
 src/common/logging/backend.cpp     |  1 +
 src/common/logging/log.h           |  1 +
 src/core/hle/service/time/time.cpp | 20 ++++++++++----------
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 2848fe1166..2bbc5bb164 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -44,6 +44,7 @@ namespace Log {
     SUB(Service, PCTL)                                                                             \
     SUB(Service, SET)                                                                              \
     SUB(Service, SM)                                                                               \
+    SUB(Service, Time)                                                                             \
     SUB(Service, VI)                                                                               \
     CLS(HW)                                                                                        \
     SUB(HW, Memory)                                                                                \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index f7336cea8d..0d79b84988 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -61,6 +61,7 @@ enum class Class : ClassType {
     Service_PCTL,      ///< The PCTL (Parental control) service
     Service_SET,       ///< The SET (Settings) service
     Service_SM,        ///< The SM (Service manager) service
+    Service_Time,      ///< The time service
     Service_VI,        ///< The VI (Video interface) service
     HW,                ///< Low-level hardware emulation
     HW_Memory,         ///< Memory-map and address translation
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index 5802f6f6c7..532b9c1c57 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -29,14 +29,14 @@ private:
         const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>(
                                        std::chrono::system_clock::now().time_since_epoch())
                                        .count()};
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_Time, "called");
         IPC::ResponseBuilder rb{ctx, 4};
         rb.Push(RESULT_SUCCESS);
         rb.Push<u64>(time_since_epoch);
     }
 
     void GetSystemClockContext(Kernel::HLERequestContext& ctx) {
-        LOG_WARNING(Service, "(STUBBED) called");
+        LOG_WARNING(Service_Time, "(STUBBED) called");
         SystemClockContext system_clock_ontext{};
         IPC::ResponseBuilder rb{ctx, (sizeof(SystemClockContext) / 4) + 2};
         rb.Push(RESULT_SUCCESS);
@@ -55,7 +55,7 @@ public:
 
 private:
     void GetCurrentTimePoint(Kernel::HLERequestContext& ctx) {
-        LOG_DEBUG(Service, "called");
+        LOG_DEBUG(Service_Time, "called");
         SteadyClockTimePoint steady_clock_time_point{cyclesToMs(CoreTiming::GetTicks()) / 1000};
         IPC::ResponseBuilder rb{ctx, (sizeof(SteadyClockTimePoint) / 4) + 2};
         rb.Push(RESULT_SUCCESS);
@@ -76,7 +76,7 @@ public:
 
 private:
     void GetDeviceLocationName(Kernel::HLERequestContext& ctx) {
-        LOG_WARNING(Service, "(STUBBED) called");
+        LOG_WARNING(Service_Time, "(STUBBED) called");
         LocationName location_name{};
         IPC::ResponseBuilder rb{ctx, (sizeof(LocationName) / 4) + 2};
         rb.Push(RESULT_SUCCESS);
@@ -84,7 +84,7 @@ private:
     }
 
     void GetTotalLocationNameCount(Kernel::HLERequestContext& ctx) {
-        LOG_WARNING(Service, "(STUBBED) called");
+        LOG_WARNING(Service_Time, "(STUBBED) called");
         IPC::ResponseBuilder rb{ctx, 3};
         rb.Push(RESULT_SUCCESS);
         rb.Push<u32>(0);
@@ -94,7 +94,7 @@ private:
         IPC::RequestParser rp{ctx};
         u64 posix_time = rp.Pop<u64>();
 
-        LOG_WARNING(Service, "(STUBBED) called, posix_time=0x%016llX", posix_time);
+        LOG_WARNING(Service_Time, "(STUBBED) called, posix_time=0x%016llX", posix_time);
 
         CalendarTime calendar_time{2018, 1, 1, 0, 0, 0};
         CalendarAdditionalInfo additional_info{};
@@ -109,28 +109,28 @@ void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ct
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<ISystemClock>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_Time, "called");
 }
 
 void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<ISystemClock>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_Time, "called");
 }
 
 void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<ISteadyClock>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_Time, "called");
 }
 
 void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<ITimeZoneService>();
-    LOG_DEBUG(Service, "called");
+    LOG_DEBUG(Service_Time, "called");
 }
 
 Module::Interface::Interface(std::shared_ptr<Module> time, const char* name)

From fe9905259984f1fd5a1cf771a2d90248601e5baf Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 23:00:35 -0500
Subject: [PATCH 16/17] nvflinger: Signal BufferQueue native handle event.

- This gets BOTW booting.
---
 src/core/hle/service/nvflinger/buffer_queue.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp
index 705bdbe5d4..c7206a6831 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue.cpp
@@ -14,6 +14,7 @@ namespace NVFlinger {
 
 BufferQueue::BufferQueue(u32 id, u64 layer_id) : id(id), layer_id(layer_id) {
     native_handle = Kernel::Event::Create(Kernel::ResetType::OneShot, "BufferQueue NativeHandle");
+    native_handle->Signal();
 }
 
 void BufferQueue::SetPreallocatedBuffer(u32 slot, IGBPBuffer& igbp_buffer) {

From 1d51b25ed154ec6e2bdbbcdfc11068defb1ecad1 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 4 Feb 2018 23:42:43 -0500
Subject: [PATCH 17/17] set: GetAvailableLanguageCodes should not return
 lang_codes size.

---
 src/core/hle/service/set/set.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp
index d139304bba..1062ba8b38 100644
--- a/src/core/hle/service/set/set.cpp
+++ b/src/core/hle/service/set/set.cpp
@@ -13,16 +13,17 @@ namespace Service {
 namespace Set {
 
 void SET::GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx) {
+    IPC::RequestParser rp{ctx};
+    u32 id = rp.Pop<u32>();
     constexpr std::array<u8, 13> lang_codes{};
 
     const auto& output_buffer = ctx.BufferDescriptorC()[0];
 
     Memory::WriteBlock(output_buffer.Address(), lang_codes.data(), lang_codes.size());
 
-    IPC::ResponseBuilder rb{ctx, 4};
+    IPC::ResponseBuilder rb{ctx, 2};
 
     rb.Push(RESULT_SUCCESS);
-    rb.Push(static_cast<u64>(lang_codes.size()));
 
     LOG_WARNING(Service_SET, "(STUBBED) called");
 }