summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/file_sys/disk_filesystem.cpp12
-rw-r--r--src/core/file_sys/disk_filesystem.h2
-rw-r--r--src/core/file_sys/filesystem.h3
-rw-r--r--src/core/file_sys/romfs_filesystem.cpp3
-rw-r--r--src/core/file_sys/romfs_filesystem.h2
-rw-r--r--src/core/hle/kernel/condition_variable.cpp64
-rw-r--r--src/core/hle/kernel/condition_variable.h63
-rw-r--r--src/core/hle/kernel/errors.h1
-rw-r--r--src/core/hle/kernel/kernel.h4
-rw-r--r--src/core/hle/kernel/mutex.cpp179
-rw-r--r--src/core/hle/kernel/mutex.h88
-rw-r--r--src/core/hle/kernel/svc.cpp162
-rw-r--r--src/core/hle/kernel/thread.cpp66
-rw-r--r--src/core/hle/kernel/thread.h36
-rw-r--r--src/core/hle/service/acc/acc.cpp20
-rw-r--r--src/core/hle/service/am/am.cpp64
-rw-r--r--src/core/hle/service/am/applet_ae.cpp18
-rw-r--r--src/core/hle/service/am/applet_oe.cpp18
-rw-r--r--src/core/hle/service/aoc/aoc_u.cpp4
-rw-r--r--src/core/hle/service/apm/interface.cpp6
-rw-r--r--src/core/hle/service/audio/audout_u.cpp16
-rw-r--r--src/core/hle/service/audio/audren_u.cpp26
-rw-r--r--src/core/hle/service/fatal/fatal.cpp4
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp8
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp71
-rw-r--r--src/core/hle/service/friend/friend.cpp2
-rw-r--r--src/core/hle/service/hid/hid.cpp50
-rw-r--r--src/core/hle/service/lm/lm.cpp12
-rw-r--r--src/core/hle/service/nfp/nfp.cpp2
-rw-r--r--src/core/hle/service/nifm/nifm.cpp22
-rw-r--r--src/core/hle/service/ns/pl_u.cpp12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp8
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp71
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp14
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp18
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp39
-rw-r--r--src/core/hle/service/nvdrv/devices/nvmap.cpp12
-rw-r--r--src/core/hle/service/nvdrv/interface.cpp14
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.cpp10
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.h6
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp2
-rw-r--r--src/core/hle/service/pctl/pctl_a.cpp2
-rw-r--r--src/core/hle/service/service.cpp10
-rw-r--r--src/core/hle/service/set/set.cpp2
-rw-r--r--src/core/hle/service/set/set_sys.cpp2
-rw-r--r--src/core/hle/service/sm/controller.cpp8
-rw-r--r--src/core/hle/service/sm/sm.cpp9
-rw-r--r--src/core/hle/service/sockets/bsd.cpp13
-rw-r--r--src/core/hle/service/sockets/sfdnsres.cpp2
-rw-r--r--src/core/hle/service/spl/module.cpp2
-rw-r--r--src/core/hle/service/ssl/ssl.cpp6
-rw-r--r--src/core/hle/service/time/time.cpp24
-rw-r--r--src/core/hle/service/vi/vi.cpp53
-rw-r--r--src/core/loader/nro.cpp2
-rw-r--r--src/core/loader/nso.cpp2
-rw-r--r--src/video_core/engines/maxwell_3d.h5
-rw-r--r--src/video_core/memory_manager.cpp53
-rw-r--r--src/video_core/memory_manager.h6
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp121
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h6
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp8
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h14
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp3
-rw-r--r--src/video_core/textures/decoders.cpp3
-rw-r--r--src/video_core/textures/texture.h1
-rw-r--r--src/yuzu/debugger/graphics/graphics_surface.cpp2
-rw-r--r--src/yuzu/debugger/wait_tree.cpp86
-rw-r--r--src/yuzu/debugger/wait_tree.h43
70 files changed, 818 insertions, 918 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index c1a645460..b3807c204 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -42,8 +42,6 @@ add_library(core STATIC
42 hle/kernel/client_port.h 42 hle/kernel/client_port.h
43 hle/kernel/client_session.cpp 43 hle/kernel/client_session.cpp
44 hle/kernel/client_session.h 44 hle/kernel/client_session.h
45 hle/kernel/condition_variable.cpp
46 hle/kernel/condition_variable.h
47 hle/kernel/errors.h 45 hle/kernel/errors.h
48 hle/kernel/event.cpp 46 hle/kernel/event.cpp
49 hle/kernel/event.h 47 hle/kernel/event.h
diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp
index ca1323873..4d00249fa 100644
--- a/src/core/file_sys/disk_filesystem.cpp
+++ b/src/core/file_sys/disk_filesystem.cpp
@@ -67,10 +67,16 @@ ResultCode Disk_FileSystem::DeleteFile(const std::string& path) const {
67 return RESULT_SUCCESS; 67 return RESULT_SUCCESS;
68} 68}
69 69
70ResultCode Disk_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const { 70ResultCode Disk_FileSystem::RenameFile(const std::string& src_path,
71 LOG_WARNING(Service_FS, "(STUBBED) called"); 71 const std::string& dest_path) const {
72 const std::string full_src_path = base_directory + src_path;
73 const std::string full_dest_path = base_directory + dest_path;
74
75 if (!FileUtil::Exists(full_src_path)) {
76 return ERROR_PATH_NOT_FOUND;
77 }
72 // TODO(wwylele): Use correct error code 78 // TODO(wwylele): Use correct error code
73 return ResultCode(-1); 79 return FileUtil::Rename(full_src_path, full_dest_path) ? RESULT_SUCCESS : ResultCode(-1);
74} 80}
75 81
76ResultCode Disk_FileSystem::DeleteDirectory(const Path& path) const { 82ResultCode Disk_FileSystem::DeleteDirectory(const Path& path) const {
diff --git a/src/core/file_sys/disk_filesystem.h b/src/core/file_sys/disk_filesystem.h
index 8f9e1145a..591e39fda 100644
--- a/src/core/file_sys/disk_filesystem.h
+++ b/src/core/file_sys/disk_filesystem.h
@@ -26,7 +26,7 @@ public:
26 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, 26 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
27 Mode mode) const override; 27 Mode mode) const override;
28 ResultCode DeleteFile(const std::string& path) const override; 28 ResultCode DeleteFile(const std::string& path) const override;
29 ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; 29 ResultCode RenameFile(const std::string& src_path, const std::string& dest_path) const override;
30 ResultCode DeleteDirectory(const Path& path) const override; 30 ResultCode DeleteDirectory(const Path& path) const override;
31 ResultCode DeleteDirectoryRecursively(const Path& path) const override; 31 ResultCode DeleteDirectoryRecursively(const Path& path) const override;
32 ResultCode CreateFile(const std::string& path, u64 size) const override; 32 ResultCode CreateFile(const std::string& path, u64 size) const override;
diff --git a/src/core/file_sys/filesystem.h b/src/core/file_sys/filesystem.h
index beefcfdb2..295a3133e 100644
--- a/src/core/file_sys/filesystem.h
+++ b/src/core/file_sys/filesystem.h
@@ -126,7 +126,8 @@ public:
126 * @param dest_path Destination path relative to the archive 126 * @param dest_path Destination path relative to the archive
127 * @return Result of the operation 127 * @return Result of the operation
128 */ 128 */
129 virtual ResultCode RenameFile(const Path& src_path, const Path& dest_path) const = 0; 129 virtual ResultCode RenameFile(const std::string& src_path,
130 const std::string& dest_path) const = 0;
130 131
131 /** 132 /**
132 * Rename a Directory specified by its path 133 * Rename a Directory specified by its path
diff --git a/src/core/file_sys/romfs_filesystem.cpp b/src/core/file_sys/romfs_filesystem.cpp
index 3d77e2d5f..b9982e6fa 100644
--- a/src/core/file_sys/romfs_filesystem.cpp
+++ b/src/core/file_sys/romfs_filesystem.cpp
@@ -27,7 +27,8 @@ ResultCode RomFS_FileSystem::DeleteFile(const std::string& path) const {
27 return ResultCode(-1); 27 return ResultCode(-1);
28} 28}
29 29
30ResultCode RomFS_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const { 30ResultCode RomFS_FileSystem::RenameFile(const std::string& src_path,
31 const std::string& dest_path) const {
31 LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive (%s).", 32 LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive (%s).",
32 GetName().c_str()); 33 GetName().c_str());
33 // TODO(wwylele): Use correct error code 34 // TODO(wwylele): Use correct error code
diff --git a/src/core/file_sys/romfs_filesystem.h b/src/core/file_sys/romfs_filesystem.h
index 1b5cac409..ba9d85823 100644
--- a/src/core/file_sys/romfs_filesystem.h
+++ b/src/core/file_sys/romfs_filesystem.h
@@ -32,7 +32,7 @@ public:
32 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, 32 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
33 Mode mode) const override; 33 Mode mode) const override;
34 ResultCode DeleteFile(const std::string& path) const override; 34 ResultCode DeleteFile(const std::string& path) const override;
35 ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; 35 ResultCode RenameFile(const std::string& src_path, const std::string& dest_path) const override;
36 ResultCode DeleteDirectory(const Path& path) const override; 36 ResultCode DeleteDirectory(const Path& path) const override;
37 ResultCode DeleteDirectoryRecursively(const Path& path) const override; 37 ResultCode DeleteDirectoryRecursively(const Path& path) const override;
38 ResultCode CreateFile(const std::string& path, u64 size) const override; 38 ResultCode CreateFile(const std::string& path, u64 size) const override;
diff --git a/src/core/hle/kernel/condition_variable.cpp b/src/core/hle/kernel/condition_variable.cpp
deleted file mode 100644
index a786d7f74..000000000
--- a/src/core/hle/kernel/condition_variable.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/assert.h"
6#include "core/hle/kernel/condition_variable.h"
7#include "core/hle/kernel/errors.h"
8#include "core/hle/kernel/kernel.h"
9#include "core/hle/kernel/object_address_table.h"
10#include "core/hle/kernel/thread.h"
11
12namespace Kernel {
13
14ConditionVariable::ConditionVariable() {}
15ConditionVariable::~ConditionVariable() {}
16
17ResultVal<SharedPtr<ConditionVariable>> ConditionVariable::Create(VAddr guest_addr,
18 std::string name) {
19 SharedPtr<ConditionVariable> condition_variable(new ConditionVariable);
20
21 condition_variable->name = std::move(name);
22 condition_variable->guest_addr = guest_addr;
23 condition_variable->mutex_addr = 0;
24
25 // Condition variables are referenced by guest address, so track this in the kernel
26 g_object_address_table.Insert(guest_addr, condition_variable);
27
28 return MakeResult<SharedPtr<ConditionVariable>>(std::move(condition_variable));
29}
30
31bool ConditionVariable::ShouldWait(Thread* thread) const {
32 return GetAvailableCount() <= 0;
33}
34
35void ConditionVariable::Acquire(Thread* thread) {
36 if (GetAvailableCount() <= 0)
37 return;
38
39 SetAvailableCount(GetAvailableCount() - 1);
40}
41
42ResultCode ConditionVariable::Release(s32 target) {
43 if (target == -1) {
44 // When -1, wake up all waiting threads
45 SetAvailableCount(static_cast<s32>(GetWaitingThreads().size()));
46 WakeupAllWaitingThreads();
47 } else {
48 // Otherwise, wake up just a single thread
49 SetAvailableCount(target);
50 WakeupWaitingThread(GetHighestPriorityReadyThread());
51 }
52
53 return RESULT_SUCCESS;
54}
55
56s32 ConditionVariable::GetAvailableCount() const {
57 return Memory::Read32(guest_addr);
58}
59
60void ConditionVariable::SetAvailableCount(s32 value) const {
61 Memory::Write32(guest_addr, value);
62}
63
64} // namespace Kernel
diff --git a/src/core/hle/kernel/condition_variable.h b/src/core/hle/kernel/condition_variable.h
deleted file mode 100644
index 1c9f06769..000000000
--- a/src/core/hle/kernel/condition_variable.h
+++ /dev/null
@@ -1,63 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <string>
8#include <queue>
9#include "common/common_types.h"
10#include "core/hle/kernel/kernel.h"
11#include "core/hle/kernel/wait_object.h"
12#include "core/hle/result.h"
13
14namespace Kernel {
15
16class ConditionVariable final : public WaitObject {
17public:
18 /**
19 * Creates a condition variable.
20 * @param guest_addr Address of the object tracking the condition variable in guest memory. If
21 * specified, this condition variable will update the guest object when its state changes.
22 * @param name Optional name of condition variable.
23 * @return The created condition variable.
24 */
25 static ResultVal<SharedPtr<ConditionVariable>> Create(VAddr guest_addr,
26 std::string name = "Unknown");
27
28 std::string GetTypeName() const override {
29 return "ConditionVariable";
30 }
31 std::string GetName() const override {
32 return name;
33 }
34
35 static const HandleType HANDLE_TYPE = HandleType::ConditionVariable;
36 HandleType GetHandleType() const override {
37 return HANDLE_TYPE;
38 }
39
40 s32 GetAvailableCount() const;
41 void SetAvailableCount(s32 value) const;
42
43 std::string name; ///< Name of condition variable (optional)
44 VAddr guest_addr; ///< Address of the guest condition variable value
45 VAddr mutex_addr; ///< (optional) Address of guest mutex value associated with this condition
46 ///< variable, used for implementing events
47
48 bool ShouldWait(Thread* thread) const override;
49 void Acquire(Thread* thread) override;
50
51 /**
52 * Releases a slot from a condition variable.
53 * @param target The number of threads to wakeup, -1 is all.
54 * @return ResultCode indicating if the operation succeeded.
55 */
56 ResultCode Release(s32 target);
57
58private:
59 ConditionVariable();
60 ~ConditionVariable() override;
61};
62
63} // namespace Kernel
diff --git a/src/core/hle/kernel/errors.h b/src/core/hle/kernel/errors.h
index 29d8dfdaa..5be20c878 100644
--- a/src/core/hle/kernel/errors.h
+++ b/src/core/hle/kernel/errors.h
@@ -20,6 +20,7 @@ enum {
20 MaxConnectionsReached = 52, 20 MaxConnectionsReached = 52,
21 21
22 // Confirmed Switch OS error codes 22 // Confirmed Switch OS error codes
23 MisalignedAddress = 102,
23 InvalidHandle = 114, 24 InvalidHandle = 114,
24 Timeout = 117, 25 Timeout = 117,
25 SynchronizationCanceled = 118, 26 SynchronizationCanceled = 118,
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 053bf4e17..402ae900f 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -18,12 +18,10 @@ using Handle = u32;
18enum class HandleType : u32 { 18enum class HandleType : u32 {
19 Unknown, 19 Unknown,
20 Event, 20 Event,
21 Mutex,
22 SharedMemory, 21 SharedMemory,
23 Thread, 22 Thread,
24 Process, 23 Process,
25 AddressArbiter, 24 AddressArbiter,
26 ConditionVariable,
27 Timer, 25 Timer,
28 ResourceLimit, 26 ResourceLimit,
29 CodeSet, 27 CodeSet,
@@ -63,9 +61,7 @@ public:
63 bool IsWaitable() const { 61 bool IsWaitable() const {
64 switch (GetHandleType()) { 62 switch (GetHandleType()) {
65 case HandleType::Event: 63 case HandleType::Event:
66 case HandleType::Mutex:
67 case HandleType::Thread: 64 case HandleType::Thread:
68 case HandleType::ConditionVariable:
69 case HandleType::Timer: 65 case HandleType::Timer:
70 case HandleType::ServerPort: 66 case HandleType::ServerPort:
71 case HandleType::ServerSession: 67 case HandleType::ServerSession:
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 0b9dc700c..63733ad79 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -7,6 +7,7 @@
7#include <boost/range/algorithm_ext/erase.hpp> 7#include <boost/range/algorithm_ext/erase.hpp>
8#include "common/assert.h" 8#include "common/assert.h"
9#include "core/core.h" 9#include "core/core.h"
10#include "core/hle/kernel/errors.h"
10#include "core/hle/kernel/handle_table.h" 11#include "core/hle/kernel/handle_table.h"
11#include "core/hle/kernel/kernel.h" 12#include "core/hle/kernel/kernel.h"
12#include "core/hle/kernel/mutex.h" 13#include "core/hle/kernel/mutex.h"
@@ -15,124 +16,120 @@
15 16
16namespace Kernel { 17namespace Kernel {
17 18
18void ReleaseThreadMutexes(Thread* thread) { 19/// Returns the number of threads that are waiting for a mutex, and the highest priority one among
19 for (auto& mtx : thread->held_mutexes) { 20/// those.
20 mtx->SetHasWaiters(false); 21static std::pair<SharedPtr<Thread>, u32> GetHighestPriorityMutexWaitingThread(
21 mtx->SetHoldingThread(nullptr); 22 SharedPtr<Thread> current_thread, VAddr mutex_addr) {
22 mtx->WakeupAllWaitingThreads();
23 }
24 thread->held_mutexes.clear();
25}
26 23
27Mutex::Mutex() {} 24 SharedPtr<Thread> highest_priority_thread;
28Mutex::~Mutex() {} 25 u32 num_waiters = 0;
29 26
30SharedPtr<Mutex> Mutex::Create(SharedPtr<Kernel::Thread> holding_thread, VAddr guest_addr, 27 for (auto& thread : current_thread->wait_mutex_threads) {
31 std::string name) { 28 if (thread->mutex_wait_address != mutex_addr)
32 SharedPtr<Mutex> mutex(new Mutex); 29 continue;
33 30
34 mutex->guest_addr = guest_addr; 31 ASSERT(thread->status == THREADSTATUS_WAIT_MUTEX);
35 mutex->name = std::move(name);
36 32
37 // If mutex was initialized with a holding thread, acquire it by the holding thread 33 ++num_waiters;
38 if (holding_thread) { 34 if (highest_priority_thread == nullptr ||
39 mutex->Acquire(holding_thread.get()); 35 thread->GetPriority() < highest_priority_thread->GetPriority()) {
36 highest_priority_thread = thread;
37 }
40 } 38 }
41 39
42 // Mutexes are referenced by guest address, so track this in the kernel 40 return {highest_priority_thread, num_waiters};
43 g_object_address_table.Insert(guest_addr, mutex);
44
45 return mutex;
46} 41}
47 42
48bool Mutex::ShouldWait(Thread* thread) const { 43/// Update the mutex owner field of all threads waiting on the mutex to point to the new owner.
49 auto holding_thread = GetHoldingThread(); 44static void TransferMutexOwnership(VAddr mutex_addr, SharedPtr<Thread> current_thread,
50 return holding_thread != nullptr && thread != holding_thread; 45 SharedPtr<Thread> new_owner) {
46 auto threads = current_thread->wait_mutex_threads;
47 for (auto& thread : threads) {
48 if (thread->mutex_wait_address != mutex_addr)
49 continue;
50
51 ASSERT(thread->lock_owner == current_thread);
52 current_thread->RemoveMutexWaiter(thread);
53 if (new_owner != thread)
54 new_owner->AddMutexWaiter(thread);
55 }
51} 56}
52 57
53void Mutex::Acquire(Thread* thread) { 58ResultCode Mutex::TryAcquire(VAddr address, Handle holding_thread_handle,
54 ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); 59 Handle requesting_thread_handle) {
60 // The mutex address must be 4-byte aligned
61 if ((address % sizeof(u32)) != 0) {
62 return ResultCode(ErrorModule::Kernel, ErrCodes::MisalignedAddress);
63 }
55 64
56 priority = thread->current_priority; 65 SharedPtr<Thread> holding_thread = g_handle_table.Get<Thread>(holding_thread_handle);
57 thread->held_mutexes.insert(this); 66 SharedPtr<Thread> requesting_thread = g_handle_table.Get<Thread>(requesting_thread_handle);
58 SetHoldingThread(thread);
59 thread->UpdatePriority();
60 Core::System::GetInstance().PrepareReschedule();
61}
62 67
63ResultCode Mutex::Release(Thread* thread) { 68 // TODO(Subv): It is currently unknown if it is possible to lock a mutex in behalf of another
64 auto holding_thread = GetHoldingThread(); 69 // thread.
65 ASSERT(holding_thread); 70 ASSERT(requesting_thread == GetCurrentThread());
66 71
67 // We can only release the mutex if it's held by the calling thread. 72 u32 addr_value = Memory::Read32(address);
68 ASSERT(thread == holding_thread); 73
74 // If the mutex isn't being held, just return success.
75 if (addr_value != (holding_thread_handle | Mutex::MutexHasWaitersFlag)) {
76 return RESULT_SUCCESS;
77 }
78
79 if (holding_thread == nullptr)
80 return ERR_INVALID_HANDLE;
81
82 // Wait until the mutex is released
83 GetCurrentThread()->mutex_wait_address = address;
84 GetCurrentThread()->wait_handle = requesting_thread_handle;
85
86 GetCurrentThread()->status = THREADSTATUS_WAIT_MUTEX;
87 GetCurrentThread()->wakeup_callback = nullptr;
88
89 // Update the lock holder thread's priority to prevent priority inversion.
90 holding_thread->AddMutexWaiter(GetCurrentThread());
69 91
70 holding_thread->held_mutexes.erase(this);
71 holding_thread->UpdatePriority();
72 SetHoldingThread(nullptr);
73 SetHasWaiters(!GetWaitingThreads().empty());
74 WakeupAllWaitingThreads();
75 Core::System::GetInstance().PrepareReschedule(); 92 Core::System::GetInstance().PrepareReschedule();
76 93
77 return RESULT_SUCCESS; 94 return RESULT_SUCCESS;
78} 95}
79 96
80void Mutex::AddWaitingThread(SharedPtr<Thread> thread) { 97ResultCode Mutex::Release(VAddr address) {
81 WaitObject::AddWaitingThread(thread); 98 // The mutex address must be 4-byte aligned
82 thread->pending_mutexes.insert(this); 99 if ((address % sizeof(u32)) != 0) {
83 SetHasWaiters(true); 100 return ResultCode(ErrorModule::Kernel, ErrCodes::MisalignedAddress);
84 UpdatePriority(); 101 }
85}
86
87void Mutex::RemoveWaitingThread(Thread* thread) {
88 WaitObject::RemoveWaitingThread(thread);
89 thread->pending_mutexes.erase(this);
90 if (!GetHasWaiters())
91 SetHasWaiters(!GetWaitingThreads().empty());
92 UpdatePriority();
93}
94 102
95void Mutex::UpdatePriority() { 103 auto [thread, num_waiters] = GetHighestPriorityMutexWaitingThread(GetCurrentThread(), address);
96 if (!GetHoldingThread())
97 return;
98 104
99 u32 best_priority = THREADPRIO_LOWEST; 105 // There are no more threads waiting for the mutex, release it completely.
100 for (auto& waiter : GetWaitingThreads()) { 106 if (thread == nullptr) {
101 if (waiter->current_priority < best_priority) 107 ASSERT(GetCurrentThread()->wait_mutex_threads.empty());
102 best_priority = waiter->current_priority; 108 Memory::Write32(address, 0);
109 return RESULT_SUCCESS;
103 } 110 }
104 111
105 if (best_priority != priority) { 112 // Transfer the ownership of the mutex from the previous owner to the new one.
106 priority = best_priority; 113 TransferMutexOwnership(address, GetCurrentThread(), thread);
107 GetHoldingThread()->UpdatePriority();
108 }
109}
110 114
111Handle Mutex::GetOwnerHandle() const { 115 u32 mutex_value = thread->wait_handle;
112 GuestState guest_state{Memory::Read32(guest_addr)};
113 return guest_state.holding_thread_handle;
114}
115 116
116SharedPtr<Thread> Mutex::GetHoldingThread() const { 117 if (num_waiters >= 2) {
117 GuestState guest_state{Memory::Read32(guest_addr)}; 118 // Notify the guest that there are still some threads waiting for the mutex
118 return g_handle_table.Get<Thread>(guest_state.holding_thread_handle); 119 mutex_value |= Mutex::MutexHasWaitersFlag;
119} 120 }
120 121
121void Mutex::SetHoldingThread(SharedPtr<Thread> thread) { 122 // Grant the mutex to the next waiting thread and resume it.
122 GuestState guest_state{Memory::Read32(guest_addr)}; 123 Memory::Write32(address, mutex_value);
123 guest_state.holding_thread_handle.Assign(thread ? thread->guest_handle : 0);
124 Memory::Write32(guest_addr, guest_state.raw);
125}
126 124
127bool Mutex::GetHasWaiters() const { 125 ASSERT(thread->status == THREADSTATUS_WAIT_MUTEX);
128 GuestState guest_state{Memory::Read32(guest_addr)}; 126 thread->ResumeFromWait();
129 return guest_state.has_waiters != 0;
130}
131 127
132void Mutex::SetHasWaiters(bool has_waiters) { 128 thread->lock_owner = nullptr;
133 GuestState guest_state{Memory::Read32(guest_addr)}; 129 thread->condvar_wait_address = 0;
134 guest_state.has_waiters.Assign(has_waiters ? 1 : 0); 130 thread->mutex_wait_address = 0;
135 Memory::Write32(guest_addr, guest_state.raw); 131 thread->wait_handle = 0;
136}
137 132
133 return RESULT_SUCCESS;
134}
138} // namespace Kernel 135} // namespace Kernel
diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h
index 38db21005..3117e7c70 100644
--- a/src/core/hle/kernel/mutex.h
+++ b/src/core/hle/kernel/mutex.h
@@ -15,87 +15,23 @@ namespace Kernel {
15 15
16class Thread; 16class Thread;
17 17
18class Mutex final : public WaitObject { 18class Mutex final {
19public: 19public:
20 /** 20 /// Flag that indicates that a mutex still has threads waiting for it.
21 * Creates a mutex. 21 static constexpr u32 MutexHasWaitersFlag = 0x40000000;
22 * @param holding_thread Specifies a thread already holding the mutex. If not nullptr, this 22 /// Mask of the bits in a mutex address value that contain the mutex owner.
23 * thread will acquire the mutex. 23 static constexpr u32 MutexOwnerMask = 0xBFFFFFFF;
24 * @param guest_addr Address of the object tracking the mutex in guest memory. If specified,
25 * this mutex will update the guest object when its state changes.
26 * @param name Optional name of mutex
27 * @return Pointer to new Mutex object
28 */
29 static SharedPtr<Mutex> Create(SharedPtr<Kernel::Thread> holding_thread, VAddr guest_addr = 0,
30 std::string name = "Unknown");
31 24
32 std::string GetTypeName() const override { 25 /// Attempts to acquire a mutex at the specified address.
33 return "Mutex"; 26 static ResultCode TryAcquire(VAddr address, Handle holding_thread_handle,
34 } 27 Handle requesting_thread_handle);
35 std::string GetName() const override {
36 return name;
37 }
38 28
39 static const HandleType HANDLE_TYPE = HandleType::Mutex; 29 /// Releases the mutex at the specified address.
40 HandleType GetHandleType() const override { 30 static ResultCode Release(VAddr address);
41 return HANDLE_TYPE;
42 }
43
44 u32 priority; ///< The priority of the mutex, used for priority inheritance.
45 std::string name; ///< Name of mutex (optional)
46 VAddr guest_addr; ///< Address of the guest mutex value
47
48 /**
49 * Elevate the mutex priority to the best priority
50 * among the priorities of all its waiting threads.
51 */
52 void UpdatePriority();
53
54 bool ShouldWait(Thread* thread) const override;
55 void Acquire(Thread* thread) override;
56
57 void AddWaitingThread(SharedPtr<Thread> thread) override;
58 void RemoveWaitingThread(Thread* thread) override;
59
60 /**
61 * Attempts to release the mutex from the specified thread.
62 * @param thread Thread that wants to release the mutex.
63 * @returns The result code of the operation.
64 */
65 ResultCode Release(Thread* thread);
66
67 /// Gets the handle to the holding process stored in the guest state.
68 Handle GetOwnerHandle() const;
69
70 /// Gets the Thread pointed to by the owner handle
71 SharedPtr<Thread> GetHoldingThread() const;
72 /// Sets the holding process handle in the guest state.
73 void SetHoldingThread(SharedPtr<Thread> thread);
74
75 /// Returns the has_waiters bit in the guest state.
76 bool GetHasWaiters() const;
77 /// Sets the has_waiters bit in the guest state.
78 void SetHasWaiters(bool has_waiters);
79 31
80private: 32private:
81 Mutex(); 33 Mutex() = default;
82 ~Mutex() override; 34 ~Mutex() = default;
83
84 /// Object in guest memory used to track the mutex state
85 union GuestState {
86 u32_le raw;
87 /// Handle of the thread that currently holds the mutex, 0 if available
88 BitField<0, 30, u32_le> holding_thread_handle;
89 /// 1 when there are threads waiting for this mutex, otherwise 0
90 BitField<30, 1, u32_le> has_waiters;
91 };
92 static_assert(sizeof(GuestState) == 4, "GuestState size is incorrect");
93}; 35};
94 36
95/**
96 * Releases all the mutexes held by the specified thread
97 * @param thread Thread that is holding the mutexes
98 */
99void ReleaseThreadMutexes(Thread* thread);
100
101} // namespace Kernel 37} // namespace Kernel
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 633740992..c22da6e47 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -13,7 +13,6 @@
13#include "core/core_timing.h" 13#include "core/core_timing.h"
14#include "core/hle/kernel/client_port.h" 14#include "core/hle/kernel/client_port.h"
15#include "core/hle/kernel/client_session.h" 15#include "core/hle/kernel/client_session.h"
16#include "core/hle/kernel/condition_variable.h"
17#include "core/hle/kernel/event.h" 16#include "core/hle/kernel/event.h"
18#include "core/hle/kernel/handle_table.h" 17#include "core/hle/kernel/handle_table.h"
19#include "core/hle/kernel/mutex.h" 18#include "core/hle/kernel/mutex.h"
@@ -262,32 +261,14 @@ static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr,
262 "requesting_current_thread_handle=0x%08X", 261 "requesting_current_thread_handle=0x%08X",
263 holding_thread_handle, mutex_addr, requesting_thread_handle); 262 holding_thread_handle, mutex_addr, requesting_thread_handle);
264 263
265 SharedPtr<Thread> holding_thread = g_handle_table.Get<Thread>(holding_thread_handle); 264 return Mutex::TryAcquire(mutex_addr, holding_thread_handle, requesting_thread_handle);
266 SharedPtr<Thread> requesting_thread = g_handle_table.Get<Thread>(requesting_thread_handle);
267
268 ASSERT(requesting_thread);
269 ASSERT(requesting_thread == GetCurrentThread());
270
271 SharedPtr<Mutex> mutex = g_object_address_table.Get<Mutex>(mutex_addr);
272 if (!mutex) {
273 // Create a new mutex for the specified address if one does not already exist
274 mutex = Mutex::Create(holding_thread, mutex_addr);
275 mutex->name = Common::StringFromFormat("mutex-%llx", mutex_addr);
276 }
277
278 ASSERT(holding_thread == mutex->GetHoldingThread());
279
280 return WaitSynchronization1(mutex, requesting_thread.get());
281} 265}
282 266
283/// Unlock a mutex 267/// Unlock a mutex
284static ResultCode ArbitrateUnlock(VAddr mutex_addr) { 268static ResultCode ArbitrateUnlock(VAddr mutex_addr) {
285 LOG_TRACE(Kernel_SVC, "called mutex_addr=0x%llx", mutex_addr); 269 LOG_TRACE(Kernel_SVC, "called mutex_addr=0x%llx", mutex_addr);
286 270
287 SharedPtr<Mutex> mutex = g_object_address_table.Get<Mutex>(mutex_addr); 271 return Mutex::Release(mutex_addr);
288 ASSERT(mutex);
289
290 return mutex->Release(GetCurrentThread());
291} 272}
292 273
293/// Break program execution 274/// Break program execution
@@ -412,11 +393,6 @@ static ResultCode SetThreadPriority(Handle handle, u32 priority) {
412 } 393 }
413 394
414 thread->SetPriority(priority); 395 thread->SetPriority(priority);
415 thread->UpdatePriority();
416
417 // Update the mutexes that this thread is waiting for
418 for (auto& mutex : thread->pending_mutexes)
419 mutex->UpdatePriority();
420 396
421 Core::System::GetInstance().PrepareReschedule(); 397 Core::System::GetInstance().PrepareReschedule();
422 return RESULT_SUCCESS; 398 return RESULT_SUCCESS;
@@ -634,103 +610,75 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var
634 SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); 610 SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle);
635 ASSERT(thread); 611 ASSERT(thread);
636 612
637 SharedPtr<Mutex> mutex = g_object_address_table.Get<Mutex>(mutex_addr); 613 CASCADE_CODE(Mutex::Release(mutex_addr));
638 if (!mutex) {
639 // Create a new mutex for the specified address if one does not already exist
640 mutex = Mutex::Create(thread, mutex_addr);
641 mutex->name = Common::StringFromFormat("mutex-%llx", mutex_addr);
642 }
643
644 SharedPtr<ConditionVariable> condition_variable =
645 g_object_address_table.Get<ConditionVariable>(condition_variable_addr);
646 if (!condition_variable) {
647 // Create a new condition_variable for the specified address if one does not already exist
648 condition_variable = ConditionVariable::Create(condition_variable_addr).Unwrap();
649 condition_variable->name =
650 Common::StringFromFormat("condition-variable-%llx", condition_variable_addr);
651 }
652
653 if (condition_variable->mutex_addr) {
654 // Previously created the ConditionVariable using WaitProcessWideKeyAtomic, verify
655 // everything is correct
656 ASSERT(condition_variable->mutex_addr == mutex_addr);
657 } else {
658 // Previously created the ConditionVariable using SignalProcessWideKey, set the mutex
659 // associated with it
660 condition_variable->mutex_addr = mutex_addr;
661 }
662 614
663 if (mutex->GetOwnerHandle()) { 615 SharedPtr<Thread> current_thread = GetCurrentThread();
664 // Release the mutex if the current thread is holding it 616 current_thread->condvar_wait_address = condition_variable_addr;
665 mutex->Release(thread.get()); 617 current_thread->mutex_wait_address = mutex_addr;
666 } 618 current_thread->wait_handle = thread_handle;
619 current_thread->status = THREADSTATUS_WAIT_MUTEX;
620 current_thread->wakeup_callback = nullptr;
667 621
668 auto wakeup_callback = [mutex, nano_seconds](ThreadWakeupReason reason, 622 current_thread->WakeAfterDelay(nano_seconds);
669 SharedPtr<Thread> thread,
670 SharedPtr<WaitObject> object, size_t index) {
671 ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY);
672 623
673 if (reason == ThreadWakeupReason::Timeout) { 624 // Note: Deliberately don't attempt to inherit the lock owner's priority.
674 thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
675 return true;
676 }
677 625
678 ASSERT(reason == ThreadWakeupReason::Signal); 626 Core::System::GetInstance().PrepareReschedule();
627 return RESULT_SUCCESS;
628}
679 629
680 // Now try to acquire the mutex and don't resume if it's not available. 630/// Signal process wide key
681 if (!mutex->ShouldWait(thread.get())) { 631static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target) {
682 mutex->Acquire(thread.get()); 632 LOG_TRACE(Kernel_SVC, "called, condition_variable_addr=0x%llx, target=0x%08x",
683 thread->SetWaitSynchronizationResult(RESULT_SUCCESS); 633 condition_variable_addr, target);
684 return true;
685 }
686 634
687 if (nano_seconds == 0) { 635 u32 processed = 0;
688 thread->SetWaitSynchronizationResult(RESULT_TIMEOUT); 636 auto& thread_list = Core::System::GetInstance().Scheduler().GetThreadList();
689 return true;
690 }
691 637
692 thread->wait_objects = {mutex}; 638 for (auto& thread : thread_list) {
693 mutex->AddWaitingThread(thread); 639 if (thread->condvar_wait_address != condition_variable_addr)
694 thread->status = THREADSTATUS_WAIT_SYNCH_ANY; 640 continue;
695 641
696 // Create an event to wake the thread up after the 642 // Only process up to 'target' threads, unless 'target' is -1, in which case process
697 // specified nanosecond delay has passed 643 // them all.
698 thread->WakeAfterDelay(nano_seconds); 644 if (target != -1 && processed >= target)
699 thread->wakeup_callback = DefaultThreadWakeupCallback; 645 break;
700 646
701 Core::System::GetInstance().PrepareReschedule(); 647 // If the mutex is not yet acquired, acquire it.
648 u32 mutex_val = Memory::Read32(thread->mutex_wait_address);
702 649
703 return false; 650 if (mutex_val == 0) {
704 }; 651 // We were able to acquire the mutex, resume this thread.
705 CASCADE_CODE( 652 Memory::Write32(thread->mutex_wait_address, thread->wait_handle);
706 WaitSynchronization1(condition_variable, thread.get(), nano_seconds, wakeup_callback)); 653 ASSERT(thread->status == THREADSTATUS_WAIT_MUTEX);
654 thread->ResumeFromWait();
707 655
708 return RESULT_SUCCESS; 656 auto lock_owner = thread->lock_owner;
709} 657 if (lock_owner)
658 lock_owner->RemoveMutexWaiter(thread);
710 659
711/// Signal process wide key 660 thread->lock_owner = nullptr;
712static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target) { 661 thread->mutex_wait_address = 0;
713 LOG_TRACE(Kernel_SVC, "called, condition_variable_addr=0x%llx, target=0x%08x", 662 thread->condvar_wait_address = 0;
714 condition_variable_addr, target); 663 thread->wait_handle = 0;
664 } else {
665 // Couldn't acquire the mutex, block the thread.
666 Handle owner_handle = static_cast<Handle>(mutex_val & Mutex::MutexOwnerMask);
667 auto owner = g_handle_table.Get<Thread>(owner_handle);
668 ASSERT(owner);
669 ASSERT(thread->status != THREADSTATUS_RUNNING);
670 thread->status = THREADSTATUS_WAIT_MUTEX;
671 thread->wakeup_callback = nullptr;
715 672
716 // Wakeup all or one thread - Any other value is unimplemented 673 // Signal that the mutex now has a waiting thread.
717 ASSERT(target == -1 || target == 1); 674 Memory::Write32(thread->mutex_wait_address, mutex_val | Mutex::MutexHasWaitersFlag);
718 675
719 SharedPtr<ConditionVariable> condition_variable = 676 owner->AddMutexWaiter(thread);
720 g_object_address_table.Get<ConditionVariable>(condition_variable_addr);
721 if (!condition_variable) {
722 // Create a new condition_variable for the specified address if one does not already exist
723 condition_variable = ConditionVariable::Create(condition_variable_addr).Unwrap();
724 condition_variable->name =
725 Common::StringFromFormat("condition-variable-%llx", condition_variable_addr);
726 }
727 677
728 CASCADE_CODE(condition_variable->Release(target)); 678 Core::System::GetInstance().PrepareReschedule();
679 }
729 680
730 if (condition_variable->mutex_addr) { 681 ++processed;
731 // If a mutex was created for this condition_variable, wait the current thread on it
732 SharedPtr<Mutex> mutex = g_object_address_table.Get<Mutex>(condition_variable->mutex_addr);
733 return WaitSynchronization1(mutex, GetCurrentThread());
734 } 682 }
735 683
736 return RESULT_SUCCESS; 684 return RESULT_SUCCESS;
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index f3a8aa4aa..36222d45f 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -77,9 +77,6 @@ void Thread::Stop() {
77 } 77 }
78 wait_objects.clear(); 78 wait_objects.clear();
79 79
80 // Release all the mutexes that this thread holds
81 ReleaseThreadMutexes(this);
82
83 // Mark the TLS slot in the thread's page as free. 80 // Mark the TLS slot in the thread's page as free.
84 u64 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE; 81 u64 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE;
85 u64 tls_slot = 82 u64 tls_slot =
@@ -126,6 +123,19 @@ static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) {
126 resume = thread->wakeup_callback(ThreadWakeupReason::Timeout, thread, nullptr, 0); 123 resume = thread->wakeup_callback(ThreadWakeupReason::Timeout, thread, nullptr, 0);
127 } 124 }
128 125
126 if (thread->mutex_wait_address != 0 || thread->condvar_wait_address != 0 ||
127 thread->wait_handle) {
128 ASSERT(thread->status == THREADSTATUS_WAIT_MUTEX);
129 thread->mutex_wait_address = 0;
130 thread->condvar_wait_address = 0;
131 thread->wait_handle = 0;
132
133 auto lock_owner = thread->lock_owner;
134 // Threads waking up by timeout from WaitProcessWideKey do not perform priority inheritance
135 // and don't have a lock owner.
136 ASSERT(lock_owner == nullptr);
137 }
138
129 if (resume) 139 if (resume)
130 thread->ResumeFromWait(); 140 thread->ResumeFromWait();
131} 141}
@@ -151,6 +161,7 @@ void Thread::ResumeFromWait() {
151 case THREADSTATUS_WAIT_HLE_EVENT: 161 case THREADSTATUS_WAIT_HLE_EVENT:
152 case THREADSTATUS_WAIT_SLEEP: 162 case THREADSTATUS_WAIT_SLEEP:
153 case THREADSTATUS_WAIT_IPC: 163 case THREADSTATUS_WAIT_IPC:
164 case THREADSTATUS_WAIT_MUTEX:
154 break; 165 break;
155 166
156 case THREADSTATUS_READY: 167 case THREADSTATUS_READY:
@@ -256,7 +267,9 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
256 thread->last_running_ticks = CoreTiming::GetTicks(); 267 thread->last_running_ticks = CoreTiming::GetTicks();
257 thread->processor_id = processor_id; 268 thread->processor_id = processor_id;
258 thread->wait_objects.clear(); 269 thread->wait_objects.clear();
259 thread->wait_address = 0; 270 thread->mutex_wait_address = 0;
271 thread->condvar_wait_address = 0;
272 thread->wait_handle = 0;
260 thread->name = std::move(name); 273 thread->name = std::move(name);
261 thread->callback_handle = wakeup_callback_handle_table.Create(thread).Unwrap(); 274 thread->callback_handle = wakeup_callback_handle_table.Create(thread).Unwrap();
262 thread->owner_process = owner_process; 275 thread->owner_process = owner_process;
@@ -317,17 +330,8 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
317void Thread::SetPriority(u32 priority) { 330void Thread::SetPriority(u32 priority) {
318 ASSERT_MSG(priority <= THREADPRIO_LOWEST && priority >= THREADPRIO_HIGHEST, 331 ASSERT_MSG(priority <= THREADPRIO_LOWEST && priority >= THREADPRIO_HIGHEST,
319 "Invalid priority value."); 332 "Invalid priority value.");
320 Core::System::GetInstance().Scheduler().SetThreadPriority(this, priority); 333 nominal_priority = priority;
321 nominal_priority = current_priority = priority; 334 UpdatePriority();
322}
323
324void Thread::UpdatePriority() {
325 u32 best_priority = nominal_priority;
326 for (auto& mutex : held_mutexes) {
327 if (mutex->priority < best_priority)
328 best_priority = mutex->priority;
329 }
330 BoostPriority(best_priority);
331} 335}
332 336
333void Thread::BoostPriority(u32 priority) { 337void Thread::BoostPriority(u32 priority) {
@@ -377,6 +381,38 @@ VAddr Thread::GetCommandBufferAddress() const {
377 return GetTLSAddress() + CommandHeaderOffset; 381 return GetTLSAddress() + CommandHeaderOffset;
378} 382}
379 383
384void Thread::AddMutexWaiter(SharedPtr<Thread> thread) {
385 thread->lock_owner = this;
386 wait_mutex_threads.emplace_back(std::move(thread));
387 UpdatePriority();
388}
389
390void Thread::RemoveMutexWaiter(SharedPtr<Thread> thread) {
391 boost::remove_erase(wait_mutex_threads, thread);
392 thread->lock_owner = nullptr;
393 UpdatePriority();
394}
395
396void Thread::UpdatePriority() {
397 // Find the highest priority among all the threads that are waiting for this thread's lock
398 u32 new_priority = nominal_priority;
399 for (const auto& thread : wait_mutex_threads) {
400 if (thread->nominal_priority < new_priority)
401 new_priority = thread->nominal_priority;
402 }
403
404 if (new_priority == current_priority)
405 return;
406
407 Core::System::GetInstance().Scheduler().SetThreadPriority(this, new_priority);
408
409 current_priority = new_priority;
410
411 // Recursively update the priority of the thread that depends on the priority of this one.
412 if (lock_owner)
413 lock_owner->UpdatePriority();
414}
415
380//////////////////////////////////////////////////////////////////////////////////////////////////// 416////////////////////////////////////////////////////////////////////////////////////////////////////
381 417
382/** 418/**
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index dbf47e269..e0a3c0934 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -18,7 +18,7 @@
18enum ThreadPriority : u32 { 18enum ThreadPriority : u32 {
19 THREADPRIO_HIGHEST = 0, ///< Highest thread priority 19 THREADPRIO_HIGHEST = 0, ///< Highest thread priority
20 THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps 20 THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps
21 THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps 21 THREADPRIO_DEFAULT = 44, ///< Default thread priority for userland apps
22 THREADPRIO_LOWEST = 63, ///< Lowest thread priority 22 THREADPRIO_LOWEST = 63, ///< Lowest thread priority
23}; 23};
24 24
@@ -43,6 +43,7 @@ enum ThreadStatus {
43 THREADSTATUS_WAIT_IPC, ///< Waiting for the reply from an IPC request 43 THREADSTATUS_WAIT_IPC, ///< Waiting for the reply from an IPC request
44 THREADSTATUS_WAIT_SYNCH_ANY, ///< Waiting due to WaitSynch1 or WaitSynchN with wait_all = false 44 THREADSTATUS_WAIT_SYNCH_ANY, ///< Waiting due to WaitSynch1 or WaitSynchN with wait_all = false
45 THREADSTATUS_WAIT_SYNCH_ALL, ///< Waiting due to WaitSynchronizationN with wait_all = true 45 THREADSTATUS_WAIT_SYNCH_ALL, ///< Waiting due to WaitSynchronizationN with wait_all = true
46 THREADSTATUS_WAIT_MUTEX, ///< Waiting due to an ArbitrateLock/WaitProcessWideKey svc
46 THREADSTATUS_DORMANT, ///< Created but not yet made ready 47 THREADSTATUS_DORMANT, ///< Created but not yet made ready
47 THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated 48 THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated
48}; 49};
@@ -54,7 +55,6 @@ enum class ThreadWakeupReason {
54 55
55namespace Kernel { 56namespace Kernel {
56 57
57class Mutex;
58class Process; 58class Process;
59 59
60class Thread final : public WaitObject { 60class Thread final : public WaitObject {
@@ -104,17 +104,20 @@ public:
104 void SetPriority(u32 priority); 104 void SetPriority(u32 priority);
105 105
106 /** 106 /**
107 * Boost's a thread's priority to the best priority among the thread's held mutexes.
108 * This prevents priority inversion via priority inheritance.
109 */
110 void UpdatePriority();
111
112 /**
113 * Temporarily boosts the thread's priority until the next time it is scheduled 107 * Temporarily boosts the thread's priority until the next time it is scheduled
114 * @param priority The new priority 108 * @param priority The new priority
115 */ 109 */
116 void BoostPriority(u32 priority); 110 void BoostPriority(u32 priority);
117 111
112 /// Adds a thread to the list of threads that are waiting for a lock held by this thread.
113 void AddMutexWaiter(SharedPtr<Thread> thread);
114
115 /// Removes a thread from the list of threads that are waiting for a lock held by this thread.
116 void RemoveMutexWaiter(SharedPtr<Thread> thread);
117
118 /// Recalculates the current priority taking into account priority inheritance.
119 void UpdatePriority();
120
118 /** 121 /**
119 * Gets the thread's thread ID 122 * Gets the thread's thread ID
120 * @return The thread's ID 123 * @return The thread's ID
@@ -205,19 +208,22 @@ public:
205 208
206 VAddr tls_address; ///< Virtual address of the Thread Local Storage of the thread 209 VAddr tls_address; ///< Virtual address of the Thread Local Storage of the thread
207 210
208 /// Mutexes currently held by this thread, which will be released when it exits.
209 boost::container::flat_set<SharedPtr<Mutex>> held_mutexes;
210
211 /// Mutexes that this thread is currently waiting for.
212 boost::container::flat_set<SharedPtr<Mutex>> pending_mutexes;
213
214 SharedPtr<Process> owner_process; ///< Process that owns this thread 211 SharedPtr<Process> owner_process; ///< Process that owns this thread
215 212
216 /// Objects that the thread is waiting on, in the same order as they were 213 /// Objects that the thread is waiting on, in the same order as they were
217 // passed to WaitSynchronization1/N. 214 // passed to WaitSynchronization1/N.
218 std::vector<SharedPtr<WaitObject>> wait_objects; 215 std::vector<SharedPtr<WaitObject>> wait_objects;
219 216
220 VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address 217 /// List of threads that are waiting for a mutex that is held by this thread.
218 std::vector<SharedPtr<Thread>> wait_mutex_threads;
219
220 /// Thread that owns the lock that this thread is waiting for.
221 SharedPtr<Thread> lock_owner;
222
223 // If waiting on a ConditionVariable, this is the ConditionVariable address
224 VAddr condvar_wait_address;
225 VAddr mutex_wait_address; ///< If waiting on a Mutex, this is the mutex address
226 Handle wait_handle; ///< The handle used to wait for the mutex.
221 227
222 std::string name; 228 std::string name;
223 229
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 6bafb2dce..f2fffa760 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -47,7 +47,7 @@ public:
47 47
48private: 48private:
49 void GetBase(Kernel::HLERequestContext& ctx) { 49 void GetBase(Kernel::HLERequestContext& ctx) {
50 LOG_WARNING(Service_ACC, "(STUBBED) called"); 50 NGLOG_WARNING(Service_ACC, "(STUBBED) called");
51 ProfileBase profile_base{}; 51 ProfileBase profile_base{};
52 IPC::ResponseBuilder rb{ctx, 16}; 52 IPC::ResponseBuilder rb{ctx, 16};
53 rb.Push(RESULT_SUCCESS); 53 rb.Push(RESULT_SUCCESS);
@@ -72,14 +72,14 @@ public:
72 72
73private: 73private:
74 void CheckAvailability(Kernel::HLERequestContext& ctx) { 74 void CheckAvailability(Kernel::HLERequestContext& ctx) {
75 LOG_WARNING(Service_ACC, "(STUBBED) called"); 75 NGLOG_WARNING(Service_ACC, "(STUBBED) called");
76 IPC::ResponseBuilder rb{ctx, 3}; 76 IPC::ResponseBuilder rb{ctx, 3};
77 rb.Push(RESULT_SUCCESS); 77 rb.Push(RESULT_SUCCESS);
78 rb.Push(true); // TODO: Check when this is supposed to return true and when not 78 rb.Push(true); // TODO: Check when this is supposed to return true and when not
79 } 79 }
80 80
81 void GetAccountId(Kernel::HLERequestContext& ctx) { 81 void GetAccountId(Kernel::HLERequestContext& ctx) {
82 LOG_WARNING(Service_ACC, "(STUBBED) called"); 82 NGLOG_WARNING(Service_ACC, "(STUBBED) called");
83 IPC::ResponseBuilder rb{ctx, 4}; 83 IPC::ResponseBuilder rb{ctx, 4};
84 rb.Push(RESULT_SUCCESS); 84 rb.Push(RESULT_SUCCESS);
85 rb.Push<u64>(0x12345678ABCDEF); 85 rb.Push<u64>(0x12345678ABCDEF);
@@ -87,14 +87,14 @@ private:
87}; 87};
88 88
89void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) { 89void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) {
90 LOG_WARNING(Service_ACC, "(STUBBED) called"); 90 NGLOG_WARNING(Service_ACC, "(STUBBED) called");
91 IPC::ResponseBuilder rb{ctx, 3}; 91 IPC::ResponseBuilder rb{ctx, 3};
92 rb.Push(RESULT_SUCCESS); 92 rb.Push(RESULT_SUCCESS);
93 rb.Push(true); // TODO: Check when this is supposed to return true and when not 93 rb.Push(true); // TODO: Check when this is supposed to return true and when not
94} 94}
95 95
96void Module::Interface::ListAllUsers(Kernel::HLERequestContext& ctx) { 96void Module::Interface::ListAllUsers(Kernel::HLERequestContext& ctx) {
97 LOG_WARNING(Service_ACC, "(STUBBED) called"); 97 NGLOG_WARNING(Service_ACC, "(STUBBED) called");
98 constexpr std::array<u128, 10> user_ids{DEFAULT_USER_ID}; 98 constexpr std::array<u128, 10> user_ids{DEFAULT_USER_ID};
99 ctx.WriteBuffer(user_ids.data(), user_ids.size()); 99 ctx.WriteBuffer(user_ids.data(), user_ids.size());
100 IPC::ResponseBuilder rb{ctx, 2}; 100 IPC::ResponseBuilder rb{ctx, 2};
@@ -102,7 +102,7 @@ void Module::Interface::ListAllUsers(Kernel::HLERequestContext& ctx) {
102} 102}
103 103
104void Module::Interface::ListOpenUsers(Kernel::HLERequestContext& ctx) { 104void Module::Interface::ListOpenUsers(Kernel::HLERequestContext& ctx) {
105 LOG_WARNING(Service_ACC, "(STUBBED) called"); 105 NGLOG_WARNING(Service_ACC, "(STUBBED) called");
106 constexpr std::array<u128, 10> user_ids{DEFAULT_USER_ID}; 106 constexpr std::array<u128, 10> user_ids{DEFAULT_USER_ID};
107 ctx.WriteBuffer(user_ids.data(), user_ids.size()); 107 ctx.WriteBuffer(user_ids.data(), user_ids.size());
108 IPC::ResponseBuilder rb{ctx, 2}; 108 IPC::ResponseBuilder rb{ctx, 2};
@@ -113,11 +113,11 @@ void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) {
113 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 113 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
114 rb.Push(RESULT_SUCCESS); 114 rb.Push(RESULT_SUCCESS);
115 rb.PushIpcInterface<IProfile>(); 115 rb.PushIpcInterface<IProfile>();
116 LOG_DEBUG(Service_ACC, "called"); 116 NGLOG_DEBUG(Service_ACC, "called");
117} 117}
118 118
119void Module::Interface::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) { 119void Module::Interface::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) {
120 LOG_WARNING(Service_ACC, "(STUBBED) called"); 120 NGLOG_WARNING(Service_ACC, "(STUBBED) called");
121 IPC::ResponseBuilder rb{ctx, 2}; 121 IPC::ResponseBuilder rb{ctx, 2};
122 rb.Push(RESULT_SUCCESS); 122 rb.Push(RESULT_SUCCESS);
123} 123}
@@ -126,11 +126,11 @@ void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestCo
126 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 126 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
127 rb.Push(RESULT_SUCCESS); 127 rb.Push(RESULT_SUCCESS);
128 rb.PushIpcInterface<IManagerForApplication>(); 128 rb.PushIpcInterface<IManagerForApplication>();
129 LOG_DEBUG(Service_ACC, "called"); 129 NGLOG_DEBUG(Service_ACC, "called");
130} 130}
131 131
132void Module::Interface::GetLastOpenedUser(Kernel::HLERequestContext& ctx) { 132void Module::Interface::GetLastOpenedUser(Kernel::HLERequestContext& ctx) {
133 LOG_WARNING(Service_ACC, "(STUBBED) called"); 133 NGLOG_WARNING(Service_ACC, "(STUBBED) called");
134 IPC::ResponseBuilder rb{ctx, 6}; 134 IPC::ResponseBuilder rb{ctx, 6};
135 rb.Push(RESULT_SUCCESS); 135 rb.Push(RESULT_SUCCESS);
136 rb.PushRaw(DEFAULT_USER_ID); 136 rb.PushRaw(DEFAULT_USER_ID);
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index f41a59afe..19fadcb8e 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -28,14 +28,14 @@ IWindowController::IWindowController() : ServiceFramework("IWindowController") {
28} 28}
29 29
30void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) { 30void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) {
31 LOG_WARNING(Service_AM, "(STUBBED) called"); 31 NGLOG_WARNING(Service_AM, "(STUBBED) called");
32 IPC::ResponseBuilder rb{ctx, 4}; 32 IPC::ResponseBuilder rb{ctx, 4};
33 rb.Push(RESULT_SUCCESS); 33 rb.Push(RESULT_SUCCESS);
34 rb.Push<u64>(0); 34 rb.Push<u64>(0);
35} 35}
36 36
37void IWindowController::AcquireForegroundRights(Kernel::HLERequestContext& ctx) { 37void IWindowController::AcquireForegroundRights(Kernel::HLERequestContext& ctx) {
38 LOG_WARNING(Service_AM, "(STUBBED) called"); 38 NGLOG_WARNING(Service_AM, "(STUBBED) called");
39 IPC::ResponseBuilder rb{ctx, 2}; 39 IPC::ResponseBuilder rb{ctx, 2};
40 rb.Push(RESULT_SUCCESS); 40 rb.Push(RESULT_SUCCESS);
41} 41}
@@ -54,20 +54,20 @@ IAudioController::IAudioController() : ServiceFramework("IAudioController") {
54} 54}
55 55
56void IAudioController::SetExpectedMasterVolume(Kernel::HLERequestContext& ctx) { 56void IAudioController::SetExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
57 LOG_WARNING(Service_AM, "(STUBBED) called"); 57 NGLOG_WARNING(Service_AM, "(STUBBED) called");
58 IPC::ResponseBuilder rb{ctx, 2}; 58 IPC::ResponseBuilder rb{ctx, 2};
59 rb.Push(RESULT_SUCCESS); 59 rb.Push(RESULT_SUCCESS);
60} 60}
61 61
62void IAudioController::GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) { 62void IAudioController::GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
63 LOG_WARNING(Service_AM, "(STUBBED) called"); 63 NGLOG_WARNING(Service_AM, "(STUBBED) called");
64 IPC::ResponseBuilder rb{ctx, 3}; 64 IPC::ResponseBuilder rb{ctx, 3};
65 rb.Push(RESULT_SUCCESS); 65 rb.Push(RESULT_SUCCESS);
66 rb.Push(volume); 66 rb.Push(volume);
67} 67}
68 68
69void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) { 69void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
70 LOG_WARNING(Service_AM, "(STUBBED) called"); 70 NGLOG_WARNING(Service_AM, "(STUBBED) called");
71 IPC::ResponseBuilder rb{ctx, 3}; 71 IPC::ResponseBuilder rb{ctx, 3};
72 rb.Push(RESULT_SUCCESS); 72 rb.Push(RESULT_SUCCESS);
73 rb.Push(volume); 73 rb.Push(volume);
@@ -139,14 +139,14 @@ void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) {
139 IPC::ResponseBuilder rb{ctx, 2}; 139 IPC::ResponseBuilder rb{ctx, 2};
140 rb.Push(RESULT_SUCCESS); 140 rb.Push(RESULT_SUCCESS);
141 141
142 LOG_WARNING(Service_AM, "(STUBBED) called"); 142 NGLOG_WARNING(Service_AM, "(STUBBED) called");
143} 143}
144 144
145void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) { 145void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) {
146 IPC::ResponseBuilder rb{ctx, 2}; 146 IPC::ResponseBuilder rb{ctx, 2};
147 rb.Push(RESULT_SUCCESS); 147 rb.Push(RESULT_SUCCESS);
148 148
149 LOG_WARNING(Service_AM, "(STUBBED) called"); 149 NGLOG_WARNING(Service_AM, "(STUBBED) called");
150} 150}
151 151
152void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) { 152void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) {
@@ -157,14 +157,14 @@ void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestCo
157 IPC::ResponseBuilder rb{ctx, 2}; 157 IPC::ResponseBuilder rb{ctx, 2};
158 rb.Push(RESULT_SUCCESS); 158 rb.Push(RESULT_SUCCESS);
159 159
160 LOG_WARNING(Service_AM, "(STUBBED) called flag=%u", static_cast<u32>(flag)); 160 NGLOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
161} 161}
162 162
163void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) { 163void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
164 IPC::ResponseBuilder rb{ctx, 2}; 164 IPC::ResponseBuilder rb{ctx, 2};
165 rb.Push(RESULT_SUCCESS); 165 rb.Push(RESULT_SUCCESS);
166 166
167 LOG_WARNING(Service_AM, "(STUBBED) called"); 167 NGLOG_WARNING(Service_AM, "(STUBBED) called");
168} 168}
169 169
170void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) { 170void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) {
@@ -175,7 +175,7 @@ void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestCont
175 IPC::ResponseBuilder rb{ctx, 2}; 175 IPC::ResponseBuilder rb{ctx, 2};
176 rb.Push(RESULT_SUCCESS); 176 rb.Push(RESULT_SUCCESS);
177 177
178 LOG_WARNING(Service_AM, "(STUBBED) called flag=%u", static_cast<u32>(flag)); 178 NGLOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
179} 179}
180 180
181void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) { 181void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) {
@@ -188,21 +188,21 @@ void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext&
188 IPC::ResponseBuilder rb{ctx, 2}; 188 IPC::ResponseBuilder rb{ctx, 2};
189 rb.Push(RESULT_SUCCESS); 189 rb.Push(RESULT_SUCCESS);
190 190
191 LOG_WARNING(Service_AM, "(STUBBED) called enabled=%u", static_cast<u32>(enabled)); 191 NGLOG_WARNING(Service_AM, "(STUBBED) called enabled={}", enabled);
192} 192}
193 193
194void ISelfController::LockExit(Kernel::HLERequestContext& ctx) { 194void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
195 IPC::ResponseBuilder rb{ctx, 2}; 195 IPC::ResponseBuilder rb{ctx, 2};
196 rb.Push(RESULT_SUCCESS); 196 rb.Push(RESULT_SUCCESS);
197 197
198 LOG_WARNING(Service_AM, "(STUBBED) called"); 198 NGLOG_WARNING(Service_AM, "(STUBBED) called");
199} 199}
200 200
201void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) { 201void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) {
202 IPC::ResponseBuilder rb{ctx, 2}; 202 IPC::ResponseBuilder rb{ctx, 2};
203 rb.Push(RESULT_SUCCESS); 203 rb.Push(RESULT_SUCCESS);
204 204
205 LOG_WARNING(Service_AM, "(STUBBED) called"); 205 NGLOG_WARNING(Service_AM, "(STUBBED) called");
206} 206}
207 207
208void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) { 208void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
@@ -212,7 +212,7 @@ void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext&
212 rb.Push(RESULT_SUCCESS); 212 rb.Push(RESULT_SUCCESS);
213 rb.PushCopyObjects(launchable_event); 213 rb.PushCopyObjects(launchable_event);
214 214
215 LOG_WARNING(Service_AM, "(STUBBED) called"); 215 NGLOG_WARNING(Service_AM, "(STUBBED) called");
216} 216}
217 217
218void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) { 218void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) {
@@ -225,7 +225,7 @@ void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx)
225 rb.Push(RESULT_SUCCESS); 225 rb.Push(RESULT_SUCCESS);
226 rb.Push(layer_id); 226 rb.Push(layer_id);
227 227
228 LOG_WARNING(Service_AM, "(STUBBED) called"); 228 NGLOG_WARNING(Service_AM, "(STUBBED) called");
229} 229}
230 230
231ICommonStateGetter::ICommonStateGetter() : ServiceFramework("ICommonStateGetter") { 231ICommonStateGetter::ICommonStateGetter() : ServiceFramework("ICommonStateGetter") {
@@ -269,7 +269,7 @@ void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) {
269 rb.Push(RESULT_SUCCESS); 269 rb.Push(RESULT_SUCCESS);
270 rb.PushCopyObjects(event); 270 rb.PushCopyObjects(event);
271 271
272 LOG_WARNING(Service_AM, "(STUBBED) called"); 272 NGLOG_WARNING(Service_AM, "(STUBBED) called");
273} 273}
274 274
275void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) { 275void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) {
@@ -277,7 +277,7 @@ void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) {
277 rb.Push(RESULT_SUCCESS); 277 rb.Push(RESULT_SUCCESS);
278 rb.Push<u32>(15); 278 rb.Push<u32>(15);
279 279
280 LOG_WARNING(Service_AM, "(STUBBED) called"); 280 NGLOG_WARNING(Service_AM, "(STUBBED) called");
281} 281}
282 282
283void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) { 283void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) {
@@ -285,7 +285,7 @@ void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) {
285 rb.Push(RESULT_SUCCESS); 285 rb.Push(RESULT_SUCCESS);
286 rb.Push(static_cast<u8>(FocusState::InFocus)); 286 rb.Push(static_cast<u8>(FocusState::InFocus));
287 287
288 LOG_WARNING(Service_AM, "(STUBBED) called"); 288 NGLOG_WARNING(Service_AM, "(STUBBED) called");
289} 289}
290 290
291void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) { 291void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) {
@@ -294,7 +294,7 @@ void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) {
294 rb.Push(RESULT_SUCCESS); 294 rb.Push(RESULT_SUCCESS);
295 rb.Push(static_cast<u8>(use_docked_mode ? OperationMode::Docked : OperationMode::Handheld)); 295 rb.Push(static_cast<u8>(use_docked_mode ? OperationMode::Docked : OperationMode::Handheld));
296 296
297 LOG_WARNING(Service_AM, "(STUBBED) called"); 297 NGLOG_WARNING(Service_AM, "(STUBBED) called");
298} 298}
299 299
300void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) { 300void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
@@ -304,7 +304,7 @@ void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
304 rb.Push(static_cast<u32>(use_docked_mode ? APM::PerformanceMode::Docked 304 rb.Push(static_cast<u32>(use_docked_mode ? APM::PerformanceMode::Docked
305 : APM::PerformanceMode::Handheld)); 305 : APM::PerformanceMode::Handheld));
306 306
307 LOG_WARNING(Service_AM, "(STUBBED) called"); 307 NGLOG_WARNING(Service_AM, "(STUBBED) called");
308} 308}
309 309
310class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> { 310class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> {
@@ -344,7 +344,7 @@ private:
344 rb.Push(RESULT_SUCCESS); 344 rb.Push(RESULT_SUCCESS);
345 rb.PushCopyObjects(state_changed_event); 345 rb.PushCopyObjects(state_changed_event);
346 346
347 LOG_WARNING(Service_AM, "(STUBBED) called"); 347 NGLOG_WARNING(Service_AM, "(STUBBED) called");
348 } 348 }
349 349
350 Kernel::SharedPtr<Kernel::Event> state_changed_event; 350 Kernel::SharedPtr<Kernel::Event> state_changed_event;
@@ -368,7 +368,7 @@ void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx)
368 rb.Push(RESULT_SUCCESS); 368 rb.Push(RESULT_SUCCESS);
369 rb.PushIpcInterface<AM::ILibraryAppletAccessor>(); 369 rb.PushIpcInterface<AM::ILibraryAppletAccessor>();
370 370
371 LOG_DEBUG(Service_AM, "called"); 371 NGLOG_DEBUG(Service_AM, "called");
372} 372}
373 373
374class IStorageAccessor final : public ServiceFramework<IStorageAccessor> { 374class IStorageAccessor final : public ServiceFramework<IStorageAccessor> {
@@ -392,7 +392,7 @@ private:
392 rb.Push(RESULT_SUCCESS); 392 rb.Push(RESULT_SUCCESS);
393 rb.Push(static_cast<u64>(buffer.size())); 393 rb.Push(static_cast<u64>(buffer.size()));
394 394
395 LOG_DEBUG(Service_AM, "called"); 395 NGLOG_DEBUG(Service_AM, "called");
396 } 396 }
397 397
398 void Read(Kernel::HLERequestContext& ctx) { 398 void Read(Kernel::HLERequestContext& ctx) {
@@ -410,7 +410,7 @@ private:
410 410
411 rb.Push(RESULT_SUCCESS); 411 rb.Push(RESULT_SUCCESS);
412 412
413 LOG_DEBUG(Service_AM, "called"); 413 NGLOG_DEBUG(Service_AM, "called");
414 } 414 }
415}; 415};
416 416
@@ -434,7 +434,7 @@ private:
434 rb.Push(RESULT_SUCCESS); 434 rb.Push(RESULT_SUCCESS);
435 rb.PushIpcInterface<AM::IStorageAccessor>(buffer); 435 rb.PushIpcInterface<AM::IStorageAccessor>(buffer);
436 436
437 LOG_DEBUG(Service_AM, "called"); 437 NGLOG_DEBUG(Service_AM, "called");
438 } 438 }
439}; 439};
440 440
@@ -498,14 +498,14 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
498 rb.Push(RESULT_SUCCESS); 498 rb.Push(RESULT_SUCCESS);
499 rb.PushIpcInterface<AM::IStorage>(buffer); 499 rb.PushIpcInterface<AM::IStorage>(buffer);
500 500
501 LOG_DEBUG(Service_AM, "called"); 501 NGLOG_DEBUG(Service_AM, "called");
502} 502}
503 503
504void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) { 504void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
505 IPC::RequestParser rp{ctx}; 505 IPC::RequestParser rp{ctx};
506 u128 uid = rp.PopRaw<u128>(); 506 u128 uid = rp.PopRaw<u128>();
507 507
508 LOG_WARNING(Service, "(STUBBED) called uid = %016" PRIX64 "%016" PRIX64, uid[1], uid[0]); 508 NGLOG_WARNING(Service, "(STUBBED) called uid = {:016X}{:016X}", uid[1], uid[0]);
509 509
510 IPC::ResponseBuilder rb{ctx, 4}; 510 IPC::ResponseBuilder rb{ctx, 4};
511 511
@@ -533,27 +533,27 @@ void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) {
533 IPC::ResponseBuilder rb{ctx, 2}; 533 IPC::ResponseBuilder rb{ctx, 2};
534 rb.Push(RESULT_SUCCESS); 534 rb.Push(RESULT_SUCCESS);
535 535
536 LOG_WARNING(Service_AM, "(STUBBED) called, result=0x%08X", result); 536 NGLOG_WARNING(Service_AM, "(STUBBED) called, result={:#010}", result);
537} 537}
538 538
539void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) { 539void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
540 IPC::ResponseBuilder rb{ctx, 4}; 540 IPC::ResponseBuilder rb{ctx, 4};
541 rb.Push(RESULT_SUCCESS); 541 rb.Push(RESULT_SUCCESS);
542 rb.Push<u64>(SystemLanguage::English); 542 rb.Push<u64>(SystemLanguage::English);
543 LOG_WARNING(Service_AM, "(STUBBED) called"); 543 NGLOG_WARNING(Service_AM, "(STUBBED) called");
544} 544}
545 545
546void IApplicationFunctions::InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) { 546void IApplicationFunctions::InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) {
547 IPC::ResponseBuilder rb{ctx, 2}; 547 IPC::ResponseBuilder rb{ctx, 2};
548 rb.Push(RESULT_SUCCESS); 548 rb.Push(RESULT_SUCCESS);
549 LOG_WARNING(Service_AM, "(STUBBED) called"); 549 NGLOG_WARNING(Service_AM, "(STUBBED) called");
550} 550}
551 551
552void IApplicationFunctions::SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) { 552void IApplicationFunctions::SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) {
553 IPC::ResponseBuilder rb{ctx, 2}; 553 IPC::ResponseBuilder rb{ctx, 2};
554 rb.Push(RESULT_SUCCESS); 554 rb.Push(RESULT_SUCCESS);
555 555
556 LOG_WARNING(Service_AM, "(STUBBED) called"); 556 NGLOG_WARNING(Service_AM, "(STUBBED) called");
557} 557}
558 558
559void IApplicationFunctions::NotifyRunning(Kernel::HLERequestContext& ctx) { 559void IApplicationFunctions::NotifyRunning(Kernel::HLERequestContext& ctx) {
@@ -561,7 +561,7 @@ void IApplicationFunctions::NotifyRunning(Kernel::HLERequestContext& ctx) {
561 rb.Push(RESULT_SUCCESS); 561 rb.Push(RESULT_SUCCESS);
562 rb.Push<u8>(0); // Unknown, seems to be ignored by official processes 562 rb.Push<u8>(0); // Unknown, seems to be ignored by official processes
563 563
564 LOG_WARNING(Service_AM, "(STUBBED) called"); 564 NGLOG_WARNING(Service_AM, "(STUBBED) called");
565} 565}
566 566
567void InstallInterfaces(SM::ServiceManager& service_manager, 567void 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 4f0698a8a..8951980cf 100644
--- a/src/core/hle/service/am/applet_ae.cpp
+++ b/src/core/hle/service/am/applet_ae.cpp
@@ -33,56 +33,56 @@ private:
33 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 33 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
34 rb.Push(RESULT_SUCCESS); 34 rb.Push(RESULT_SUCCESS);
35 rb.PushIpcInterface<ICommonStateGetter>(); 35 rb.PushIpcInterface<ICommonStateGetter>();
36 LOG_DEBUG(Service_AM, "called"); 36 NGLOG_DEBUG(Service_AM, "called");
37 } 37 }
38 38
39 void GetSelfController(Kernel::HLERequestContext& ctx) { 39 void GetSelfController(Kernel::HLERequestContext& ctx) {
40 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 40 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
41 rb.Push(RESULT_SUCCESS); 41 rb.Push(RESULT_SUCCESS);
42 rb.PushIpcInterface<ISelfController>(nvflinger); 42 rb.PushIpcInterface<ISelfController>(nvflinger);
43 LOG_DEBUG(Service_AM, "called"); 43 NGLOG_DEBUG(Service_AM, "called");
44 } 44 }
45 45
46 void GetWindowController(Kernel::HLERequestContext& ctx) { 46 void GetWindowController(Kernel::HLERequestContext& ctx) {
47 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 47 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
48 rb.Push(RESULT_SUCCESS); 48 rb.Push(RESULT_SUCCESS);
49 rb.PushIpcInterface<IWindowController>(); 49 rb.PushIpcInterface<IWindowController>();
50 LOG_DEBUG(Service_AM, "called"); 50 NGLOG_DEBUG(Service_AM, "called");
51 } 51 }
52 52
53 void GetAudioController(Kernel::HLERequestContext& ctx) { 53 void GetAudioController(Kernel::HLERequestContext& ctx) {
54 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 54 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
55 rb.Push(RESULT_SUCCESS); 55 rb.Push(RESULT_SUCCESS);
56 rb.PushIpcInterface<IAudioController>(); 56 rb.PushIpcInterface<IAudioController>();
57 LOG_DEBUG(Service_AM, "called"); 57 NGLOG_DEBUG(Service_AM, "called");
58 } 58 }
59 59
60 void GetDisplayController(Kernel::HLERequestContext& ctx) { 60 void GetDisplayController(Kernel::HLERequestContext& ctx) {
61 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 61 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
62 rb.Push(RESULT_SUCCESS); 62 rb.Push(RESULT_SUCCESS);
63 rb.PushIpcInterface<IDisplayController>(); 63 rb.PushIpcInterface<IDisplayController>();
64 LOG_DEBUG(Service_AM, "called"); 64 NGLOG_DEBUG(Service_AM, "called");
65 } 65 }
66 66
67 void GetDebugFunctions(Kernel::HLERequestContext& ctx) { 67 void GetDebugFunctions(Kernel::HLERequestContext& ctx) {
68 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 68 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
69 rb.Push(RESULT_SUCCESS); 69 rb.Push(RESULT_SUCCESS);
70 rb.PushIpcInterface<IDebugFunctions>(); 70 rb.PushIpcInterface<IDebugFunctions>();
71 LOG_DEBUG(Service_AM, "called"); 71 NGLOG_DEBUG(Service_AM, "called");
72 } 72 }
73 73
74 void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) { 74 void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) {
75 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 75 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
76 rb.Push(RESULT_SUCCESS); 76 rb.Push(RESULT_SUCCESS);
77 rb.PushIpcInterface<ILibraryAppletCreator>(); 77 rb.PushIpcInterface<ILibraryAppletCreator>();
78 LOG_DEBUG(Service_AM, "called"); 78 NGLOG_DEBUG(Service_AM, "called");
79 } 79 }
80 80
81 void GetApplicationFunctions(Kernel::HLERequestContext& ctx) { 81 void GetApplicationFunctions(Kernel::HLERequestContext& ctx) {
82 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 82 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
83 rb.Push(RESULT_SUCCESS); 83 rb.Push(RESULT_SUCCESS);
84 rb.PushIpcInterface<IApplicationFunctions>(); 84 rb.PushIpcInterface<IApplicationFunctions>();
85 LOG_DEBUG(Service_AM, "called"); 85 NGLOG_DEBUG(Service_AM, "called");
86 } 86 }
87 87
88 std::shared_ptr<NVFlinger::NVFlinger> nvflinger; 88 std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
@@ -92,7 +92,7 @@ void AppletAE::OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx) {
92 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 92 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
93 rb.Push(RESULT_SUCCESS); 93 rb.Push(RESULT_SUCCESS);
94 rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger); 94 rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger);
95 LOG_DEBUG(Service_AM, "called"); 95 NGLOG_DEBUG(Service_AM, "called");
96} 96}
97 97
98AppletAE::AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger) 98AppletAE::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 674b4d753..68388bf5e 100644
--- a/src/core/hle/service/am/applet_oe.cpp
+++ b/src/core/hle/service/am/applet_oe.cpp
@@ -33,56 +33,56 @@ private:
33 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 33 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
34 rb.Push(RESULT_SUCCESS); 34 rb.Push(RESULT_SUCCESS);
35 rb.PushIpcInterface<IAudioController>(); 35 rb.PushIpcInterface<IAudioController>();
36 LOG_DEBUG(Service_AM, "called"); 36 NGLOG_DEBUG(Service_AM, "called");
37 } 37 }
38 38
39 void GetDisplayController(Kernel::HLERequestContext& ctx) { 39 void GetDisplayController(Kernel::HLERequestContext& ctx) {
40 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 40 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
41 rb.Push(RESULT_SUCCESS); 41 rb.Push(RESULT_SUCCESS);
42 rb.PushIpcInterface<IDisplayController>(); 42 rb.PushIpcInterface<IDisplayController>();
43 LOG_DEBUG(Service_AM, "called"); 43 NGLOG_DEBUG(Service_AM, "called");
44 } 44 }
45 45
46 void GetDebugFunctions(Kernel::HLERequestContext& ctx) { 46 void GetDebugFunctions(Kernel::HLERequestContext& ctx) {
47 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 47 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
48 rb.Push(RESULT_SUCCESS); 48 rb.Push(RESULT_SUCCESS);
49 rb.PushIpcInterface<IDebugFunctions>(); 49 rb.PushIpcInterface<IDebugFunctions>();
50 LOG_DEBUG(Service_AM, "called"); 50 NGLOG_DEBUG(Service_AM, "called");
51 } 51 }
52 52
53 void GetWindowController(Kernel::HLERequestContext& ctx) { 53 void GetWindowController(Kernel::HLERequestContext& ctx) {
54 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 54 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
55 rb.Push(RESULT_SUCCESS); 55 rb.Push(RESULT_SUCCESS);
56 rb.PushIpcInterface<IWindowController>(); 56 rb.PushIpcInterface<IWindowController>();
57 LOG_DEBUG(Service_AM, "called"); 57 NGLOG_DEBUG(Service_AM, "called");
58 } 58 }
59 59
60 void GetSelfController(Kernel::HLERequestContext& ctx) { 60 void GetSelfController(Kernel::HLERequestContext& ctx) {
61 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 61 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
62 rb.Push(RESULT_SUCCESS); 62 rb.Push(RESULT_SUCCESS);
63 rb.PushIpcInterface<ISelfController>(nvflinger); 63 rb.PushIpcInterface<ISelfController>(nvflinger);
64 LOG_DEBUG(Service_AM, "called"); 64 NGLOG_DEBUG(Service_AM, "called");
65 } 65 }
66 66
67 void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { 67 void GetCommonStateGetter(Kernel::HLERequestContext& ctx) {
68 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 68 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
69 rb.Push(RESULT_SUCCESS); 69 rb.Push(RESULT_SUCCESS);
70 rb.PushIpcInterface<ICommonStateGetter>(); 70 rb.PushIpcInterface<ICommonStateGetter>();
71 LOG_DEBUG(Service_AM, "called"); 71 NGLOG_DEBUG(Service_AM, "called");
72 } 72 }
73 73
74 void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) { 74 void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) {
75 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 75 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
76 rb.Push(RESULT_SUCCESS); 76 rb.Push(RESULT_SUCCESS);
77 rb.PushIpcInterface<ILibraryAppletCreator>(); 77 rb.PushIpcInterface<ILibraryAppletCreator>();
78 LOG_DEBUG(Service_AM, "called"); 78 NGLOG_DEBUG(Service_AM, "called");
79 } 79 }
80 80
81 void GetApplicationFunctions(Kernel::HLERequestContext& ctx) { 81 void GetApplicationFunctions(Kernel::HLERequestContext& ctx) {
82 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 82 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
83 rb.Push(RESULT_SUCCESS); 83 rb.Push(RESULT_SUCCESS);
84 rb.PushIpcInterface<IApplicationFunctions>(); 84 rb.PushIpcInterface<IApplicationFunctions>();
85 LOG_DEBUG(Service_AM, "called"); 85 NGLOG_DEBUG(Service_AM, "called");
86 } 86 }
87 87
88 std::shared_ptr<NVFlinger::NVFlinger> nvflinger; 88 std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
@@ -92,7 +92,7 @@ void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) {
92 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 92 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
93 rb.Push(RESULT_SUCCESS); 93 rb.Push(RESULT_SUCCESS);
94 rb.PushIpcInterface<IApplicationProxy>(nvflinger); 94 rb.PushIpcInterface<IApplicationProxy>(nvflinger);
95 LOG_DEBUG(Service_AM, "called"); 95 NGLOG_DEBUG(Service_AM, "called");
96} 96}
97 97
98AppletOE::AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger) 98AppletOE::AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp
index 6e7438580..5b6dfb48f 100644
--- a/src/core/hle/service/aoc/aoc_u.cpp
+++ b/src/core/hle/service/aoc/aoc_u.cpp
@@ -27,14 +27,14 @@ void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) {
27 IPC::ResponseBuilder rb{ctx, 4}; 27 IPC::ResponseBuilder rb{ctx, 4};
28 rb.Push(RESULT_SUCCESS); 28 rb.Push(RESULT_SUCCESS);
29 rb.Push<u64>(0); 29 rb.Push<u64>(0);
30 LOG_WARNING(Service_AOC, "(STUBBED) called"); 30 NGLOG_WARNING(Service_AOC, "(STUBBED) called");
31} 31}
32 32
33void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) { 33void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) {
34 IPC::ResponseBuilder rb{ctx, 4}; 34 IPC::ResponseBuilder rb{ctx, 4};
35 rb.Push(RESULT_SUCCESS); 35 rb.Push(RESULT_SUCCESS);
36 rb.Push<u64>(0); 36 rb.Push<u64>(0);
37 LOG_WARNING(Service_AOC, "(STUBBED) called"); 37 NGLOG_WARNING(Service_AOC, "(STUBBED) called");
38} 38}
39 39
40void InstallInterfaces(SM::ServiceManager& service_manager) { 40void InstallInterfaces(SM::ServiceManager& service_manager) {
diff --git a/src/core/hle/service/apm/interface.cpp b/src/core/hle/service/apm/interface.cpp
index 4e11f3f14..3a03188ce 100644
--- a/src/core/hle/service/apm/interface.cpp
+++ b/src/core/hle/service/apm/interface.cpp
@@ -29,8 +29,8 @@ private:
29 IPC::ResponseBuilder rb{ctx, 2}; 29 IPC::ResponseBuilder rb{ctx, 2};
30 rb.Push(RESULT_SUCCESS); 30 rb.Push(RESULT_SUCCESS);
31 31
32 LOG_WARNING(Service_APM, "(STUBBED) called mode=%u config=%u", static_cast<u32>(mode), 32 NGLOG_WARNING(Service_APM, "(STUBBED) called mode={} config={}", static_cast<u32>(mode),
33 config); 33 config);
34 } 34 }
35 35
36 void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) { 36 void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
@@ -42,7 +42,7 @@ private:
42 rb.Push(RESULT_SUCCESS); 42 rb.Push(RESULT_SUCCESS);
43 rb.Push<u32>(0); // Performance configuration 43 rb.Push<u32>(0); // Performance configuration
44 44
45 LOG_WARNING(Service_APM, "(STUBBED) called mode=%u", static_cast<u32>(mode)); 45 NGLOG_WARNING(Service_APM, "(STUBBED) called mode={}", static_cast<u32>(mode));
46 } 46 }
47}; 47};
48 48
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp
index 2d7f8cb04..6297dc450 100644
--- a/src/core/hle/service/audio/audout_u.cpp
+++ b/src/core/hle/service/audio/audout_u.cpp
@@ -60,14 +60,14 @@ public:
60 60
61private: 61private:
62 void GetAudioOutState(Kernel::HLERequestContext& ctx) { 62 void GetAudioOutState(Kernel::HLERequestContext& ctx) {
63 LOG_DEBUG(Service_Audio, "called"); 63 NGLOG_DEBUG(Service_Audio, "called");
64 IPC::ResponseBuilder rb{ctx, 3}; 64 IPC::ResponseBuilder rb{ctx, 3};
65 rb.Push(RESULT_SUCCESS); 65 rb.Push(RESULT_SUCCESS);
66 rb.Push(static_cast<u32>(audio_out_state)); 66 rb.Push(static_cast<u32>(audio_out_state));
67 } 67 }
68 68
69 void StartAudioOut(Kernel::HLERequestContext& ctx) { 69 void StartAudioOut(Kernel::HLERequestContext& ctx) {
70 LOG_WARNING(Service_Audio, "(STUBBED) called"); 70 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
71 71
72 // Start audio 72 // Start audio
73 audio_out_state = AudioState::Started; 73 audio_out_state = AudioState::Started;
@@ -77,7 +77,7 @@ private:
77 } 77 }
78 78
79 void StopAudioOut(Kernel::HLERequestContext& ctx) { 79 void StopAudioOut(Kernel::HLERequestContext& ctx) {
80 LOG_WARNING(Service_Audio, "(STUBBED) called"); 80 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
81 81
82 // Stop audio 82 // Stop audio
83 audio_out_state = AudioState::Stopped; 83 audio_out_state = AudioState::Stopped;
@@ -89,7 +89,7 @@ private:
89 } 89 }
90 90
91 void RegisterBufferEvent(Kernel::HLERequestContext& ctx) { 91 void RegisterBufferEvent(Kernel::HLERequestContext& ctx) {
92 LOG_WARNING(Service_Audio, "(STUBBED) called"); 92 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
93 93
94 IPC::ResponseBuilder rb{ctx, 2, 1}; 94 IPC::ResponseBuilder rb{ctx, 2, 1};
95 rb.Push(RESULT_SUCCESS); 95 rb.Push(RESULT_SUCCESS);
@@ -97,7 +97,7 @@ private:
97 } 97 }
98 98
99 void AppendAudioOutBuffer(Kernel::HLERequestContext& ctx) { 99 void AppendAudioOutBuffer(Kernel::HLERequestContext& ctx) {
100 LOG_WARNING(Service_Audio, "(STUBBED) called"); 100 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
101 IPC::RequestParser rp{ctx}; 101 IPC::RequestParser rp{ctx};
102 102
103 const u64 key{rp.Pop<u64>()}; 103 const u64 key{rp.Pop<u64>()};
@@ -108,7 +108,7 @@ private:
108 } 108 }
109 109
110 void GetReleasedAudioOutBuffer(Kernel::HLERequestContext& ctx) { 110 void GetReleasedAudioOutBuffer(Kernel::HLERequestContext& ctx) {
111 LOG_WARNING(Service_Audio, "(STUBBED) called"); 111 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
112 112
113 // TODO(st4rk): This is how libtransistor currently implements the 113 // TODO(st4rk): This is how libtransistor currently implements the
114 // GetReleasedAudioOutBuffer, it should return the key (a VAddr) to the app and this address 114 // GetReleasedAudioOutBuffer, it should return the key (a VAddr) to the app and this address
@@ -164,7 +164,7 @@ private:
164}; 164};
165 165
166void AudOutU::ListAudioOuts(Kernel::HLERequestContext& ctx) { 166void AudOutU::ListAudioOuts(Kernel::HLERequestContext& ctx) {
167 LOG_WARNING(Service_Audio, "(STUBBED) called"); 167 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
168 IPC::RequestParser rp{ctx}; 168 IPC::RequestParser rp{ctx};
169 169
170 const std::string audio_interface = "AudioInterface"; 170 const std::string audio_interface = "AudioInterface";
@@ -180,7 +180,7 @@ void AudOutU::ListAudioOuts(Kernel::HLERequestContext& ctx) {
180} 180}
181 181
182void AudOutU::OpenAudioOut(Kernel::HLERequestContext& ctx) { 182void AudOutU::OpenAudioOut(Kernel::HLERequestContext& ctx) {
183 LOG_WARNING(Service_Audio, "(STUBBED) called"); 183 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
184 184
185 if (!audio_out_interface) { 185 if (!audio_out_interface) {
186 audio_out_interface = std::make_shared<IAudioOut>(); 186 audio_out_interface = std::make_shared<IAudioOut>();
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index d9245cb19..72810b436 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -56,7 +56,7 @@ private:
56 } 56 }
57 57
58 void RequestUpdateAudioRenderer(Kernel::HLERequestContext& ctx) { 58 void RequestUpdateAudioRenderer(Kernel::HLERequestContext& ctx) {
59 LOG_DEBUG(Service_Audio, "%s", ctx.Description().c_str()); 59 NGLOG_DEBUG(Service_Audio, "{}", ctx.Description());
60 AudioRendererResponseData response_data{}; 60 AudioRendererResponseData response_data{};
61 61
62 response_data.section_0_size = 62 response_data.section_0_size =
@@ -79,7 +79,7 @@ private:
79 79
80 rb.Push(RESULT_SUCCESS); 80 rb.Push(RESULT_SUCCESS);
81 81
82 LOG_WARNING(Service_Audio, "(STUBBED) called"); 82 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
83 } 83 }
84 84
85 void StartAudioRenderer(Kernel::HLERequestContext& ctx) { 85 void StartAudioRenderer(Kernel::HLERequestContext& ctx) {
@@ -87,7 +87,7 @@ private:
87 87
88 rb.Push(RESULT_SUCCESS); 88 rb.Push(RESULT_SUCCESS);
89 89
90 LOG_WARNING(Service_Audio, "(STUBBED) called"); 90 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
91 } 91 }
92 92
93 void StopAudioRenderer(Kernel::HLERequestContext& ctx) { 93 void StopAudioRenderer(Kernel::HLERequestContext& ctx) {
@@ -95,7 +95,7 @@ private:
95 95
96 rb.Push(RESULT_SUCCESS); 96 rb.Push(RESULT_SUCCESS);
97 97
98 LOG_WARNING(Service_Audio, "(STUBBED) called"); 98 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
99 } 99 }
100 100
101 void QuerySystemEvent(Kernel::HLERequestContext& ctx) { 101 void QuerySystemEvent(Kernel::HLERequestContext& ctx) {
@@ -105,7 +105,7 @@ private:
105 rb.Push(RESULT_SUCCESS); 105 rb.Push(RESULT_SUCCESS);
106 rb.PushCopyObjects(system_event); 106 rb.PushCopyObjects(system_event);
107 107
108 LOG_WARNING(Service_Audio, "(STUBBED) called"); 108 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
109 } 109 }
110 110
111 struct AudioRendererStateEntry { 111 struct AudioRendererStateEntry {
@@ -176,7 +176,7 @@ public:
176 176
177private: 177private:
178 void ListAudioDeviceName(Kernel::HLERequestContext& ctx) { 178 void ListAudioDeviceName(Kernel::HLERequestContext& ctx) {
179 LOG_WARNING(Service_Audio, "(STUBBED) called"); 179 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
180 IPC::RequestParser rp{ctx}; 180 IPC::RequestParser rp{ctx};
181 181
182 const std::string audio_interface = "AudioInterface"; 182 const std::string audio_interface = "AudioInterface";
@@ -188,7 +188,7 @@ private:
188 } 188 }
189 189
190 void SetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) { 190 void SetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) {
191 LOG_WARNING(Service_Audio, "(STUBBED) called"); 191 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
192 192
193 IPC::RequestParser rp{ctx}; 193 IPC::RequestParser rp{ctx};
194 f32 volume = static_cast<f32>(rp.Pop<u32>()); 194 f32 volume = static_cast<f32>(rp.Pop<u32>());
@@ -201,7 +201,7 @@ private:
201 } 201 }
202 202
203 void GetActiveAudioDeviceName(Kernel::HLERequestContext& ctx) { 203 void GetActiveAudioDeviceName(Kernel::HLERequestContext& ctx) {
204 LOG_WARNING(Service_Audio, "(STUBBED) called"); 204 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
205 IPC::RequestParser rp{ctx}; 205 IPC::RequestParser rp{ctx};
206 206
207 const std::string audio_interface = "AudioDevice"; 207 const std::string audio_interface = "AudioDevice";
@@ -213,7 +213,7 @@ private:
213 } 213 }
214 214
215 void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) { 215 void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) {
216 LOG_WARNING(Service_Audio, "(STUBBED) called"); 216 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
217 217
218 buffer_event->Signal(); 218 buffer_event->Signal();
219 219
@@ -223,7 +223,7 @@ private:
223 } 223 }
224 224
225 void GetActiveChannelCount(Kernel::HLERequestContext& ctx) { 225 void GetActiveChannelCount(Kernel::HLERequestContext& ctx) {
226 LOG_WARNING(Service_Audio, "(STUBBED) called"); 226 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
227 IPC::ResponseBuilder rb{ctx, 3}; 227 IPC::ResponseBuilder rb{ctx, 3};
228 rb.Push(RESULT_SUCCESS); 228 rb.Push(RESULT_SUCCESS);
229 rb.Push<u32>(1); 229 rb.Push<u32>(1);
@@ -250,7 +250,7 @@ void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) {
250 rb.Push(RESULT_SUCCESS); 250 rb.Push(RESULT_SUCCESS);
251 rb.PushIpcInterface<Audio::IAudioRenderer>(); 251 rb.PushIpcInterface<Audio::IAudioRenderer>();
252 252
253 LOG_DEBUG(Service_Audio, "called"); 253 NGLOG_DEBUG(Service_Audio, "called");
254} 254}
255 255
256void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) { 256void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) {
@@ -259,7 +259,7 @@ void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) {
259 rb.Push(RESULT_SUCCESS); 259 rb.Push(RESULT_SUCCESS);
260 rb.Push<u64>(0x400); 260 rb.Push<u64>(0x400);
261 261
262 LOG_WARNING(Service_Audio, "(STUBBED) called"); 262 NGLOG_WARNING(Service_Audio, "(STUBBED) called");
263} 263}
264 264
265void AudRenU::GetAudioDevice(Kernel::HLERequestContext& ctx) { 265void AudRenU::GetAudioDevice(Kernel::HLERequestContext& ctx) {
@@ -268,7 +268,7 @@ void AudRenU::GetAudioDevice(Kernel::HLERequestContext& ctx) {
268 rb.Push(RESULT_SUCCESS); 268 rb.Push(RESULT_SUCCESS);
269 rb.PushIpcInterface<Audio::IAudioDevice>(); 269 rb.PushIpcInterface<Audio::IAudioDevice>();
270 270
271 LOG_DEBUG(Service_Audio, "called"); 271 NGLOG_DEBUG(Service_Audio, "called");
272} 272}
273 273
274} // namespace Service::Audio 274} // namespace Service::Audio
diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp
index 41d58f999..d7ad0600a 100644
--- a/src/core/hle/service/fatal/fatal.cpp
+++ b/src/core/hle/service/fatal/fatal.cpp
@@ -16,13 +16,13 @@ Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
16void Module::Interface::FatalSimple(Kernel::HLERequestContext& ctx) { 16void Module::Interface::FatalSimple(Kernel::HLERequestContext& ctx) {
17 IPC::RequestParser rp(ctx); 17 IPC::RequestParser rp(ctx);
18 u32 error_code = rp.Pop<u32>(); 18 u32 error_code = rp.Pop<u32>();
19 LOG_WARNING(Service_Fatal, "(STUBBED) called, error_code=0x%X", error_code); 19 NGLOG_WARNING(Service_Fatal, "(STUBBED) called, error_code={:#X}", error_code);
20 IPC::ResponseBuilder rb{ctx, 2}; 20 IPC::ResponseBuilder rb{ctx, 2};
21 rb.Push(RESULT_SUCCESS); 21 rb.Push(RESULT_SUCCESS);
22} 22}
23 23
24void Module::Interface::TransitionToFatalError(Kernel::HLERequestContext& ctx) { 24void Module::Interface::TransitionToFatalError(Kernel::HLERequestContext& ctx) {
25 LOG_WARNING(Service_Fatal, "(STUBBED) called"); 25 NGLOG_WARNING(Service_Fatal, "(STUBBED) called");
26 IPC::ResponseBuilder rb{ctx, 2}; 26 IPC::ResponseBuilder rb{ctx, 2};
27 rb.Push(RESULT_SUCCESS); 27 rb.Push(RESULT_SUCCESS);
28} 28}
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index 9e504992f..c2951c560 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -25,14 +25,14 @@ ResultCode RegisterFileSystem(std::unique_ptr<FileSys::FileSystemFactory>&& fact
25 ASSERT_MSG(inserted, "Tried to register more than one system with same id code"); 25 ASSERT_MSG(inserted, "Tried to register more than one system with same id code");
26 26
27 auto& filesystem = result.first->second; 27 auto& filesystem = result.first->second;
28 LOG_DEBUG(Service_FS, "Registered file system %s with id code 0x%08X", 28 NGLOG_DEBUG(Service_FS, "Registered file system {} with id code {:#010X}",
29 filesystem->GetName().c_str(), static_cast<u32>(type)); 29 filesystem->GetName(), static_cast<u32>(type));
30 return RESULT_SUCCESS; 30 return RESULT_SUCCESS;
31} 31}
32 32
33ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenFileSystem(Type type, 33ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenFileSystem(Type type,
34 FileSys::Path& path) { 34 FileSys::Path& path) {
35 LOG_TRACE(Service_FS, "Opening FileSystem with type=%d", type); 35 NGLOG_TRACE(Service_FS, "Opening FileSystem with type={}", static_cast<u32>(type));
36 36
37 auto itr = filesystem_map.find(type); 37 auto itr = filesystem_map.find(type);
38 if (itr == filesystem_map.end()) { 38 if (itr == filesystem_map.end()) {
@@ -44,7 +44,7 @@ ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenFileSystem(Type type,
44} 44}
45 45
46ResultCode FormatFileSystem(Type type) { 46ResultCode FormatFileSystem(Type type) {
47 LOG_TRACE(Service_FS, "Formatting FileSystem with type=%d", type); 47 NGLOG_TRACE(Service_FS, "Formatting FileSystem with type={}", static_cast<u32>(type));
48 48
49 auto itr = filesystem_map.find(type); 49 auto itr = filesystem_map.find(type);
50 if (itr == filesystem_map.end()) { 50 if (itr == filesystem_map.end()) {
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index 2f476c869..ed9f2ef72 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -35,7 +35,7 @@ private:
35 const s64 offset = rp.Pop<s64>(); 35 const s64 offset = rp.Pop<s64>();
36 const s64 length = rp.Pop<s64>(); 36 const s64 length = rp.Pop<s64>();
37 37
38 LOG_DEBUG(Service_FS, "called, offset=0x%ld, length=0x%ld", offset, length); 38 NGLOG_DEBUG(Service_FS, "called, offset={:#X}, length={}", offset, length);
39 39
40 // Error checking 40 // Error checking
41 if (length < 0) { 41 if (length < 0) {
@@ -87,7 +87,7 @@ private:
87 const s64 offset = rp.Pop<s64>(); 87 const s64 offset = rp.Pop<s64>();
88 const s64 length = rp.Pop<s64>(); 88 const s64 length = rp.Pop<s64>();
89 89
90 LOG_DEBUG(Service_FS, "called, offset=0x%ld, length=0x%ld", offset, length); 90 NGLOG_DEBUG(Service_FS, "called, offset={:#X}, length={}", offset, length);
91 91
92 // Error checking 92 // Error checking
93 if (length < 0) { 93 if (length < 0) {
@@ -124,7 +124,7 @@ private:
124 const s64 offset = rp.Pop<s64>(); 124 const s64 offset = rp.Pop<s64>();
125 const s64 length = rp.Pop<s64>(); 125 const s64 length = rp.Pop<s64>();
126 126
127 LOG_DEBUG(Service_FS, "called, offset=0x%ld, length=0x%ld", offset, length); 127 NGLOG_DEBUG(Service_FS, "called, offset={:#X}, length={}", offset, length);
128 128
129 // Error checking 129 // Error checking
130 if (length < 0) { 130 if (length < 0) {
@@ -152,7 +152,7 @@ private:
152 } 152 }
153 153
154 void Flush(Kernel::HLERequestContext& ctx) { 154 void Flush(Kernel::HLERequestContext& ctx) {
155 LOG_DEBUG(Service_FS, "called"); 155 NGLOG_DEBUG(Service_FS, "called");
156 backend->Flush(); 156 backend->Flush();
157 157
158 IPC::ResponseBuilder rb{ctx, 2}; 158 IPC::ResponseBuilder rb{ctx, 2};
@@ -163,7 +163,7 @@ private:
163 IPC::RequestParser rp{ctx}; 163 IPC::RequestParser rp{ctx};
164 const u64 size = rp.Pop<u64>(); 164 const u64 size = rp.Pop<u64>();
165 backend->SetSize(size); 165 backend->SetSize(size);
166 LOG_DEBUG(Service_FS, "called, size=%" PRIu64, size); 166 NGLOG_DEBUG(Service_FS, "called, size={}", size);
167 167
168 IPC::ResponseBuilder rb{ctx, 2}; 168 IPC::ResponseBuilder rb{ctx, 2};
169 rb.Push(RESULT_SUCCESS); 169 rb.Push(RESULT_SUCCESS);
@@ -171,7 +171,7 @@ private:
171 171
172 void GetSize(Kernel::HLERequestContext& ctx) { 172 void GetSize(Kernel::HLERequestContext& ctx) {
173 const u64 size = backend->GetSize(); 173 const u64 size = backend->GetSize();
174 LOG_DEBUG(Service_FS, "called, size=%" PRIu64, size); 174 NGLOG_DEBUG(Service_FS, "called, size={}", size);
175 175
176 IPC::ResponseBuilder rb{ctx, 4}; 176 IPC::ResponseBuilder rb{ctx, 4};
177 rb.Push(RESULT_SUCCESS); 177 rb.Push(RESULT_SUCCESS);
@@ -197,7 +197,7 @@ private:
197 IPC::RequestParser rp{ctx}; 197 IPC::RequestParser rp{ctx};
198 const u64 unk = rp.Pop<u64>(); 198 const u64 unk = rp.Pop<u64>();
199 199
200 LOG_DEBUG(Service_FS, "called, unk=0x%llx", unk); 200 NGLOG_DEBUG(Service_FS, "called, unk={:#X}", unk);
201 201
202 // Calculate how many entries we can fit in the output buffer 202 // Calculate how many entries we can fit in the output buffer
203 u64 count_entries = ctx.GetWriteBufferSize() / sizeof(FileSys::Entry); 203 u64 count_entries = ctx.GetWriteBufferSize() / sizeof(FileSys::Entry);
@@ -219,7 +219,7 @@ private:
219 } 219 }
220 220
221 void GetEntryCount(Kernel::HLERequestContext& ctx) { 221 void GetEntryCount(Kernel::HLERequestContext& ctx) {
222 LOG_DEBUG(Service_FS, "called"); 222 NGLOG_DEBUG(Service_FS, "called");
223 223
224 u64 count = backend->GetEntryCount(); 224 u64 count = backend->GetEntryCount();
225 225
@@ -239,7 +239,7 @@ public:
239 {2, &IFileSystem::CreateDirectory, "CreateDirectory"}, 239 {2, &IFileSystem::CreateDirectory, "CreateDirectory"},
240 {3, nullptr, "DeleteDirectory"}, 240 {3, nullptr, "DeleteDirectory"},
241 {4, nullptr, "DeleteDirectoryRecursively"}, 241 {4, nullptr, "DeleteDirectoryRecursively"},
242 {5, nullptr, "RenameFile"}, 242 {5, &IFileSystem::RenameFile, "RenameFile"},
243 {6, nullptr, "RenameDirectory"}, 243 {6, nullptr, "RenameDirectory"},
244 {7, &IFileSystem::GetEntryType, "GetEntryType"}, 244 {7, &IFileSystem::GetEntryType, "GetEntryType"},
245 {8, &IFileSystem::OpenFile, "OpenFile"}, 245 {8, &IFileSystem::OpenFile, "OpenFile"},
@@ -265,8 +265,7 @@ public:
265 u64 mode = rp.Pop<u64>(); 265 u64 mode = rp.Pop<u64>();
266 u32 size = rp.Pop<u32>(); 266 u32 size = rp.Pop<u32>();
267 267
268 LOG_DEBUG(Service_FS, "called file %s mode 0x%" PRIX64 " size 0x%08X", name.c_str(), mode, 268 NGLOG_DEBUG(Service_FS, "called file {} mode {:#X} size {:#010X}", name, mode, size);
269 size);
270 269
271 IPC::ResponseBuilder rb{ctx, 2}; 270 IPC::ResponseBuilder rb{ctx, 2};
272 rb.Push(backend->CreateFile(name, size)); 271 rb.Push(backend->CreateFile(name, size));
@@ -280,7 +279,7 @@ public:
280 279
281 std::string name(file_buffer.begin(), end); 280 std::string name(file_buffer.begin(), end);
282 281
283 LOG_DEBUG(Service_FS, "called file %s", name.c_str()); 282 NGLOG_DEBUG(Service_FS, "called file {}", name);
284 283
285 IPC::ResponseBuilder rb{ctx, 2}; 284 IPC::ResponseBuilder rb{ctx, 2};
286 rb.Push(backend->DeleteFile(name)); 285 rb.Push(backend->DeleteFile(name));
@@ -294,12 +293,32 @@ public:
294 293
295 std::string name(file_buffer.begin(), end); 294 std::string name(file_buffer.begin(), end);
296 295
297 LOG_DEBUG(Service_FS, "called directory %s", name.c_str()); 296 NGLOG_DEBUG(Service_FS, "called directory {}", name);
298 297
299 IPC::ResponseBuilder rb{ctx, 2}; 298 IPC::ResponseBuilder rb{ctx, 2};
300 rb.Push(backend->CreateDirectory(name)); 299 rb.Push(backend->CreateDirectory(name));
301 } 300 }
302 301
302 void RenameFile(Kernel::HLERequestContext& ctx) {
303 IPC::RequestParser rp{ctx};
304
305 std::vector<u8> buffer;
306 buffer.resize(ctx.BufferDescriptorX()[0].Size());
307 Memory::ReadBlock(ctx.BufferDescriptorX()[0].Address(), buffer.data(), buffer.size());
308 auto end = std::find(buffer.begin(), buffer.end(), '\0');
309 std::string src_name(buffer.begin(), end);
310
311 buffer.resize(ctx.BufferDescriptorX()[1].Size());
312 Memory::ReadBlock(ctx.BufferDescriptorX()[1].Address(), buffer.data(), buffer.size());
313 end = std::find(buffer.begin(), buffer.end(), '\0');
314 std::string dst_name(buffer.begin(), end);
315
316 NGLOG_DEBUG(Service_FS, "called file '{}' to file '{}'", src_name, dst_name);
317
318 IPC::ResponseBuilder rb{ctx, 2};
319 rb.Push(backend->RenameFile(src_name, dst_name));
320 }
321
303 void OpenFile(Kernel::HLERequestContext& ctx) { 322 void OpenFile(Kernel::HLERequestContext& ctx) {
304 IPC::RequestParser rp{ctx}; 323 IPC::RequestParser rp{ctx};
305 324
@@ -310,7 +329,7 @@ public:
310 329
311 auto mode = static_cast<FileSys::Mode>(rp.Pop<u32>()); 330 auto mode = static_cast<FileSys::Mode>(rp.Pop<u32>());
312 331
313 LOG_DEBUG(Service_FS, "called file %s mode %u", name.c_str(), static_cast<u32>(mode)); 332 NGLOG_DEBUG(Service_FS, "called file {} mode {}", name, static_cast<u32>(mode));
314 333
315 auto result = backend->OpenFile(name, mode); 334 auto result = backend->OpenFile(name, mode);
316 if (result.Failed()) { 335 if (result.Failed()) {
@@ -337,7 +356,7 @@ public:
337 // TODO(Subv): Implement this filter. 356 // TODO(Subv): Implement this filter.
338 u32 filter_flags = rp.Pop<u32>(); 357 u32 filter_flags = rp.Pop<u32>();
339 358
340 LOG_DEBUG(Service_FS, "called directory %s filter %u", name.c_str(), filter_flags); 359 NGLOG_DEBUG(Service_FS, "called directory {} filter {}", name, filter_flags);
341 360
342 auto result = backend->OpenDirectory(name); 361 auto result = backend->OpenDirectory(name);
343 if (result.Failed()) { 362 if (result.Failed()) {
@@ -361,7 +380,7 @@ public:
361 380
362 std::string name(file_buffer.begin(), end); 381 std::string name(file_buffer.begin(), end);
363 382
364 LOG_DEBUG(Service_FS, "called file %s", name.c_str()); 383 NGLOG_DEBUG(Service_FS, "called file {}", name);
365 384
366 auto result = backend->GetEntryType(name); 385 auto result = backend->GetEntryType(name);
367 if (result.Failed()) { 386 if (result.Failed()) {
@@ -376,7 +395,7 @@ public:
376 } 395 }
377 396
378 void Commit(Kernel::HLERequestContext& ctx) { 397 void Commit(Kernel::HLERequestContext& ctx) {
379 LOG_WARNING(Service_FS, "(STUBBED) called"); 398 NGLOG_WARNING(Service_FS, "(STUBBED) called");
380 399
381 IPC::ResponseBuilder rb{ctx, 2}; 400 IPC::ResponseBuilder rb{ctx, 2};
382 rb.Push(RESULT_SUCCESS); 401 rb.Push(RESULT_SUCCESS);
@@ -492,14 +511,14 @@ void FSP_SRV::TryLoadRomFS() {
492} 511}
493 512
494void FSP_SRV::Initialize(Kernel::HLERequestContext& ctx) { 513void FSP_SRV::Initialize(Kernel::HLERequestContext& ctx) {
495 LOG_WARNING(Service_FS, "(STUBBED) called"); 514 NGLOG_WARNING(Service_FS, "(STUBBED) called");
496 515
497 IPC::ResponseBuilder rb{ctx, 2}; 516 IPC::ResponseBuilder rb{ctx, 2};
498 rb.Push(RESULT_SUCCESS); 517 rb.Push(RESULT_SUCCESS);
499} 518}
500 519
501void FSP_SRV::MountSdCard(Kernel::HLERequestContext& ctx) { 520void FSP_SRV::MountSdCard(Kernel::HLERequestContext& ctx) {
502 LOG_DEBUG(Service_FS, "called"); 521 NGLOG_DEBUG(Service_FS, "called");
503 522
504 FileSys::Path unused; 523 FileSys::Path unused;
505 auto filesystem = OpenFileSystem(Type::SDMC, unused).Unwrap(); 524 auto filesystem = OpenFileSystem(Type::SDMC, unused).Unwrap();
@@ -516,14 +535,14 @@ void FSP_SRV::CreateSaveData(Kernel::HLERequestContext& ctx) {
516 auto save_create_struct = rp.PopRaw<std::array<u8, 0x40>>(); 535 auto save_create_struct = rp.PopRaw<std::array<u8, 0x40>>();
517 u128 uid = rp.PopRaw<u128>(); 536 u128 uid = rp.PopRaw<u128>();
518 537
519 LOG_WARNING(Service_FS, "(STUBBED) called uid = %016" PRIX64 "%016" PRIX64, uid[1], uid[0]); 538 NGLOG_WARNING(Service_FS, "(STUBBED) called uid = {:016X}{:016X}", uid[1], uid[0]);
520 539
521 IPC::ResponseBuilder rb{ctx, 2}; 540 IPC::ResponseBuilder rb{ctx, 2};
522 rb.Push(RESULT_SUCCESS); 541 rb.Push(RESULT_SUCCESS);
523} 542}
524 543
525void FSP_SRV::MountSaveData(Kernel::HLERequestContext& ctx) { 544void FSP_SRV::MountSaveData(Kernel::HLERequestContext& ctx) {
526 LOG_WARNING(Service_FS, "(STUBBED) called"); 545 NGLOG_WARNING(Service_FS, "(STUBBED) called");
527 546
528 FileSys::Path unused; 547 FileSys::Path unused;
529 auto filesystem = OpenFileSystem(Type::SaveData, unused).Unwrap(); 548 auto filesystem = OpenFileSystem(Type::SaveData, unused).Unwrap();
@@ -534,7 +553,7 @@ void FSP_SRV::MountSaveData(Kernel::HLERequestContext& ctx) {
534} 553}
535 554
536void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { 555void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) {
537 LOG_WARNING(Service_FS, "(STUBBED) called"); 556 NGLOG_WARNING(Service_FS, "(STUBBED) called");
538 557
539 IPC::ResponseBuilder rb{ctx, 3}; 558 IPC::ResponseBuilder rb{ctx, 3};
540 rb.Push(RESULT_SUCCESS); 559 rb.Push(RESULT_SUCCESS);
@@ -542,12 +561,12 @@ void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) {
542} 561}
543 562
544void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { 563void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) {
545 LOG_DEBUG(Service_FS, "called"); 564 NGLOG_DEBUG(Service_FS, "called");
546 565
547 TryLoadRomFS(); 566 TryLoadRomFS();
548 if (!romfs) { 567 if (!romfs) {
549 // TODO (bunnei): Find the right error code to use here 568 // TODO (bunnei): Find the right error code to use here
550 LOG_CRITICAL(Service_FS, "no file system interface available!"); 569 NGLOG_CRITICAL(Service_FS, "no file system interface available!");
551 IPC::ResponseBuilder rb{ctx, 2}; 570 IPC::ResponseBuilder rb{ctx, 2};
552 rb.Push(ResultCode(-1)); 571 rb.Push(ResultCode(-1));
553 return; 572 return;
@@ -556,7 +575,7 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) {
556 // Attempt to open a StorageBackend interface to the RomFS 575 // Attempt to open a StorageBackend interface to the RomFS
557 auto storage = romfs->OpenFile({}, {}); 576 auto storage = romfs->OpenFile({}, {});
558 if (storage.Failed()) { 577 if (storage.Failed()) {
559 LOG_CRITICAL(Service_FS, "no storage interface available!"); 578 NGLOG_CRITICAL(Service_FS, "no storage interface available!");
560 IPC::ResponseBuilder rb{ctx, 2}; 579 IPC::ResponseBuilder rb{ctx, 2};
561 rb.Push(storage.Code()); 580 rb.Push(storage.Code());
562 return; 581 return;
@@ -568,7 +587,7 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) {
568} 587}
569 588
570void FSP_SRV::OpenRomStorage(Kernel::HLERequestContext& ctx) { 589void FSP_SRV::OpenRomStorage(Kernel::HLERequestContext& ctx) {
571 LOG_WARNING(Service_FS, "(STUBBED) called, using OpenDataStorageByCurrentProcess"); 590 NGLOG_WARNING(Service_FS, "(STUBBED) called, using OpenDataStorageByCurrentProcess");
572 OpenDataStorageByCurrentProcess(ctx); 591 OpenDataStorageByCurrentProcess(ctx);
573} 592}
574 593
diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp
index c98a46e05..94d9fbf25 100644
--- a/src/core/hle/service/friend/friend.cpp
+++ b/src/core/hle/service/friend/friend.cpp
@@ -13,7 +13,7 @@ namespace Service::Friend {
13void Module::Interface::CreateFriendService(Kernel::HLERequestContext& ctx) { 13void Module::Interface::CreateFriendService(Kernel::HLERequestContext& ctx) {
14 IPC::ResponseBuilder rb{ctx, 2}; 14 IPC::ResponseBuilder rb{ctx, 2};
15 rb.Push(RESULT_SUCCESS); 15 rb.Push(RESULT_SUCCESS);
16 LOG_WARNING(Service_Friend, "(STUBBED) called"); 16 NGLOG_WARNING(Service_Friend, "(STUBBED) called");
17} 17}
18 18
19Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) 19Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index aad5e688b..736180b63 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -53,7 +53,7 @@ private:
53 IPC::ResponseBuilder rb{ctx, 2, 1}; 53 IPC::ResponseBuilder rb{ctx, 2, 1};
54 rb.Push(RESULT_SUCCESS); 54 rb.Push(RESULT_SUCCESS);
55 rb.PushCopyObjects(shared_mem); 55 rb.PushCopyObjects(shared_mem);
56 LOG_DEBUG(Service_HID, "called"); 56 NGLOG_DEBUG(Service_HID, "called");
57 } 57 }
58 58
59 void LoadInputDevices() { 59 void LoadInputDevices() {
@@ -184,7 +184,7 @@ private:
184 void ActivateVibrationDevice(Kernel::HLERequestContext& ctx) { 184 void ActivateVibrationDevice(Kernel::HLERequestContext& ctx) {
185 IPC::ResponseBuilder rb{ctx, 2}; 185 IPC::ResponseBuilder rb{ctx, 2};
186 rb.Push(RESULT_SUCCESS); 186 rb.Push(RESULT_SUCCESS);
187 LOG_WARNING(Service_HID, "(STUBBED) called"); 187 NGLOG_WARNING(Service_HID, "(STUBBED) called");
188 } 188 }
189}; 189};
190 190
@@ -286,144 +286,144 @@ private:
286 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 286 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
287 rb.Push(RESULT_SUCCESS); 287 rb.Push(RESULT_SUCCESS);
288 rb.PushIpcInterface<IAppletResource>(applet_resource); 288 rb.PushIpcInterface<IAppletResource>(applet_resource);
289 LOG_DEBUG(Service_HID, "called"); 289 NGLOG_DEBUG(Service_HID, "called");
290 } 290 }
291 291
292 void ActivateDebugPad(Kernel::HLERequestContext& ctx) { 292 void ActivateDebugPad(Kernel::HLERequestContext& ctx) {
293 IPC::ResponseBuilder rb{ctx, 2}; 293 IPC::ResponseBuilder rb{ctx, 2};
294 rb.Push(RESULT_SUCCESS); 294 rb.Push(RESULT_SUCCESS);
295 LOG_WARNING(Service_HID, "(STUBBED) called"); 295 NGLOG_WARNING(Service_HID, "(STUBBED) called");
296 } 296 }
297 297
298 void ActivateTouchScreen(Kernel::HLERequestContext& ctx) { 298 void ActivateTouchScreen(Kernel::HLERequestContext& ctx) {
299 IPC::ResponseBuilder rb{ctx, 2}; 299 IPC::ResponseBuilder rb{ctx, 2};
300 rb.Push(RESULT_SUCCESS); 300 rb.Push(RESULT_SUCCESS);
301 LOG_WARNING(Service_HID, "(STUBBED) called"); 301 NGLOG_WARNING(Service_HID, "(STUBBED) called");
302 } 302 }
303 303
304 void ActivateMouse(Kernel::HLERequestContext& ctx) { 304 void ActivateMouse(Kernel::HLERequestContext& ctx) {
305 IPC::ResponseBuilder rb{ctx, 2}; 305 IPC::ResponseBuilder rb{ctx, 2};
306 rb.Push(RESULT_SUCCESS); 306 rb.Push(RESULT_SUCCESS);
307 LOG_WARNING(Service_HID, "(STUBBED) called"); 307 NGLOG_WARNING(Service_HID, "(STUBBED) called");
308 } 308 }
309 309
310 void ActivateKeyboard(Kernel::HLERequestContext& ctx) { 310 void ActivateKeyboard(Kernel::HLERequestContext& ctx) {
311 IPC::ResponseBuilder rb{ctx, 2}; 311 IPC::ResponseBuilder rb{ctx, 2};
312 rb.Push(RESULT_SUCCESS); 312 rb.Push(RESULT_SUCCESS);
313 LOG_WARNING(Service_HID, "(STUBBED) called"); 313 NGLOG_WARNING(Service_HID, "(STUBBED) called");
314 } 314 }
315 315
316 void StartSixAxisSensor(Kernel::HLERequestContext& ctx) { 316 void StartSixAxisSensor(Kernel::HLERequestContext& ctx) {
317 IPC::ResponseBuilder rb{ctx, 2}; 317 IPC::ResponseBuilder rb{ctx, 2};
318 rb.Push(RESULT_SUCCESS); 318 rb.Push(RESULT_SUCCESS);
319 LOG_WARNING(Service_HID, "(STUBBED) called"); 319 NGLOG_WARNING(Service_HID, "(STUBBED) called");
320 } 320 }
321 321
322 void SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { 322 void SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) {
323 IPC::ResponseBuilder rb{ctx, 2}; 323 IPC::ResponseBuilder rb{ctx, 2};
324 rb.Push(RESULT_SUCCESS); 324 rb.Push(RESULT_SUCCESS);
325 LOG_WARNING(Service_HID, "(STUBBED) called"); 325 NGLOG_WARNING(Service_HID, "(STUBBED) called");
326 } 326 }
327 327
328 void SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) { 328 void SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) {
329 IPC::ResponseBuilder rb{ctx, 2}; 329 IPC::ResponseBuilder rb{ctx, 2};
330 rb.Push(RESULT_SUCCESS); 330 rb.Push(RESULT_SUCCESS);
331 LOG_WARNING(Service_HID, "(STUBBED) called"); 331 NGLOG_WARNING(Service_HID, "(STUBBED) called");
332 } 332 }
333 333
334 void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) { 334 void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) {
335 IPC::ResponseBuilder rb{ctx, 3}; 335 IPC::ResponseBuilder rb{ctx, 3};
336 rb.Push(RESULT_SUCCESS); 336 rb.Push(RESULT_SUCCESS);
337 rb.Push<u32>(0); 337 rb.Push<u32>(0);
338 LOG_WARNING(Service_HID, "(STUBBED) called"); 338 NGLOG_WARNING(Service_HID, "(STUBBED) called");
339 } 339 }
340 340
341 void SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) { 341 void SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) {
342 IPC::ResponseBuilder rb{ctx, 2}; 342 IPC::ResponseBuilder rb{ctx, 2};
343 rb.Push(RESULT_SUCCESS); 343 rb.Push(RESULT_SUCCESS);
344 LOG_WARNING(Service_HID, "(STUBBED) called"); 344 NGLOG_WARNING(Service_HID, "(STUBBED) called");
345 } 345 }
346 346
347 void ActivateNpad(Kernel::HLERequestContext& ctx) { 347 void ActivateNpad(Kernel::HLERequestContext& ctx) {
348 IPC::ResponseBuilder rb{ctx, 2}; 348 IPC::ResponseBuilder rb{ctx, 2};
349 rb.Push(RESULT_SUCCESS); 349 rb.Push(RESULT_SUCCESS);
350 LOG_WARNING(Service_HID, "(STUBBED) called"); 350 NGLOG_WARNING(Service_HID, "(STUBBED) called");
351 } 351 }
352 352
353 void AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx) { 353 void AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx) {
354 IPC::ResponseBuilder rb{ctx, 2, 1}; 354 IPC::ResponseBuilder rb{ctx, 2, 1};
355 rb.Push(RESULT_SUCCESS); 355 rb.Push(RESULT_SUCCESS);
356 rb.PushCopyObjects(event); 356 rb.PushCopyObjects(event);
357 LOG_WARNING(Service_HID, "(STUBBED) called"); 357 NGLOG_WARNING(Service_HID, "(STUBBED) called");
358 } 358 }
359 359
360 void GetPlayerLedPattern(Kernel::HLERequestContext& ctx) { 360 void GetPlayerLedPattern(Kernel::HLERequestContext& ctx) {
361 IPC::ResponseBuilder rb{ctx, 2}; 361 IPC::ResponseBuilder rb{ctx, 2};
362 rb.Push(RESULT_SUCCESS); 362 rb.Push(RESULT_SUCCESS);
363 LOG_WARNING(Service_HID, "(STUBBED) called"); 363 NGLOG_WARNING(Service_HID, "(STUBBED) called");
364 } 364 }
365 365
366 void SetNpadJoyHoldType(Kernel::HLERequestContext& ctx) { 366 void SetNpadJoyHoldType(Kernel::HLERequestContext& ctx) {
367 IPC::ResponseBuilder rb{ctx, 2}; 367 IPC::ResponseBuilder rb{ctx, 2};
368 rb.Push(RESULT_SUCCESS); 368 rb.Push(RESULT_SUCCESS);
369 LOG_WARNING(Service_HID, "(STUBBED) called"); 369 NGLOG_WARNING(Service_HID, "(STUBBED) called");
370 } 370 }
371 371
372 void GetNpadJoyHoldType(Kernel::HLERequestContext& ctx) { 372 void GetNpadJoyHoldType(Kernel::HLERequestContext& ctx) {
373 IPC::ResponseBuilder rb{ctx, 3}; 373 IPC::ResponseBuilder rb{ctx, 3};
374 rb.Push(RESULT_SUCCESS); 374 rb.Push(RESULT_SUCCESS);
375 rb.Push(joy_hold_type); 375 rb.Push(joy_hold_type);
376 LOG_WARNING(Service_HID, "(STUBBED) called"); 376 NGLOG_WARNING(Service_HID, "(STUBBED) called");
377 } 377 }
378 378
379 void SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx) { 379 void SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx) {
380 IPC::ResponseBuilder rb{ctx, 2}; 380 IPC::ResponseBuilder rb{ctx, 2};
381 rb.Push(RESULT_SUCCESS); 381 rb.Push(RESULT_SUCCESS);
382 LOG_WARNING(Service_HID, "(STUBBED) called"); 382 NGLOG_WARNING(Service_HID, "(STUBBED) called");
383 } 383 }
384 384
385 void SendVibrationValue(Kernel::HLERequestContext& ctx) { 385 void SendVibrationValue(Kernel::HLERequestContext& ctx) {
386 IPC::ResponseBuilder rb{ctx, 2}; 386 IPC::ResponseBuilder rb{ctx, 2};
387 rb.Push(RESULT_SUCCESS); 387 rb.Push(RESULT_SUCCESS);
388 LOG_WARNING(Service_HID, "(STUBBED) called"); 388 NGLOG_WARNING(Service_HID, "(STUBBED) called");
389 } 389 }
390 390
391 void GetActualVibrationValue(Kernel::HLERequestContext& ctx) { 391 void GetActualVibrationValue(Kernel::HLERequestContext& ctx) {
392 IPC::ResponseBuilder rb{ctx, 2}; 392 IPC::ResponseBuilder rb{ctx, 2};
393 rb.Push(RESULT_SUCCESS); 393 rb.Push(RESULT_SUCCESS);
394 LOG_WARNING(Service_HID, "(STUBBED) called"); 394 NGLOG_WARNING(Service_HID, "(STUBBED) called");
395 } 395 }
396 396
397 void SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) { 397 void SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) {
398 IPC::ResponseBuilder rb{ctx, 2}; 398 IPC::ResponseBuilder rb{ctx, 2};
399 rb.Push(RESULT_SUCCESS); 399 rb.Push(RESULT_SUCCESS);
400 LOG_WARNING(Service_HID, "(STUBBED) called"); 400 NGLOG_WARNING(Service_HID, "(STUBBED) called");
401 } 401 }
402 402
403 void SetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx) { 403 void SetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx) {
404 IPC::ResponseBuilder rb{ctx, 2}; 404 IPC::ResponseBuilder rb{ctx, 2};
405 rb.Push(RESULT_SUCCESS); 405 rb.Push(RESULT_SUCCESS);
406 LOG_WARNING(Service_HID, "(STUBBED) called"); 406 NGLOG_WARNING(Service_HID, "(STUBBED) called");
407 } 407 }
408 408
409 void GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) { 409 void GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) {
410 IPC::ResponseBuilder rb{ctx, 4}; 410 IPC::ResponseBuilder rb{ctx, 4};
411 rb.Push(RESULT_SUCCESS); 411 rb.Push(RESULT_SUCCESS);
412 rb.Push<u64>(0); 412 rb.Push<u64>(0);
413 LOG_WARNING(Service_HID, "(STUBBED) called"); 413 NGLOG_WARNING(Service_HID, "(STUBBED) called");
414 } 414 }
415 415
416 void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) { 416 void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) {
417 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 417 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
418 rb.Push(RESULT_SUCCESS); 418 rb.Push(RESULT_SUCCESS);
419 rb.PushIpcInterface<IActiveVibrationDeviceList>(); 419 rb.PushIpcInterface<IActiveVibrationDeviceList>();
420 LOG_DEBUG(Service_HID, "called"); 420 NGLOG_DEBUG(Service_HID, "called");
421 } 421 }
422 422
423 void SendVibrationValues(Kernel::HLERequestContext& ctx) { 423 void SendVibrationValues(Kernel::HLERequestContext& ctx) {
424 IPC::ResponseBuilder rb{ctx, 2}; 424 IPC::ResponseBuilder rb{ctx, 2};
425 rb.Push(RESULT_SUCCESS); 425 rb.Push(RESULT_SUCCESS);
426 LOG_WARNING(Service_HID, "(STUBBED) called"); 426 NGLOG_WARNING(Service_HID, "(STUBBED) called");
427 } 427 }
428}; 428};
429 429
diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index b87172dff..46194643e 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -141,19 +141,19 @@ private:
141 if (header.IsTailLog()) { 141 if (header.IsTailLog()) {
142 switch (header.severity) { 142 switch (header.severity) {
143 case MessageHeader::Severity::Trace: 143 case MessageHeader::Severity::Trace:
144 LOG_TRACE(Debug_Emulated, "%s", log_stream.str().c_str()); 144 NGLOG_TRACE(Debug_Emulated, "{}", log_stream.str());
145 break; 145 break;
146 case MessageHeader::Severity::Info: 146 case MessageHeader::Severity::Info:
147 LOG_INFO(Debug_Emulated, "%s", log_stream.str().c_str()); 147 NGLOG_INFO(Debug_Emulated, "{}", log_stream.str());
148 break; 148 break;
149 case MessageHeader::Severity::Warning: 149 case MessageHeader::Severity::Warning:
150 LOG_WARNING(Debug_Emulated, "%s", log_stream.str().c_str()); 150 NGLOG_WARNING(Debug_Emulated, "{}", log_stream.str());
151 break; 151 break;
152 case MessageHeader::Severity::Error: 152 case MessageHeader::Severity::Error:
153 LOG_ERROR(Debug_Emulated, "%s", log_stream.str().c_str()); 153 NGLOG_ERROR(Debug_Emulated, "{}", log_stream.str());
154 break; 154 break;
155 case MessageHeader::Severity::Critical: 155 case MessageHeader::Severity::Critical:
156 LOG_CRITICAL(Debug_Emulated, "%s", log_stream.str().c_str()); 156 NGLOG_CRITICAL(Debug_Emulated, "{}", log_stream.str());
157 break; 157 break;
158 } 158 }
159 } 159 }
@@ -178,7 +178,7 @@ void LM::Initialize(Kernel::HLERequestContext& ctx) {
178 rb.Push(RESULT_SUCCESS); 178 rb.Push(RESULT_SUCCESS);
179 rb.PushIpcInterface<Logger>(); 179 rb.PushIpcInterface<Logger>();
180 180
181 LOG_DEBUG(Service_LM, "called"); 181 NGLOG_DEBUG(Service_LM, "called");
182} 182}
183 183
184LM::LM() : ServiceFramework("lm") { 184LM::LM() : ServiceFramework("lm") {
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp
index 91e5f527a..6627aaddc 100644
--- a/src/core/hle/service/nfp/nfp.cpp
+++ b/src/core/hle/service/nfp/nfp.cpp
@@ -13,7 +13,7 @@ Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
13 : ServiceFramework(name), module(std::move(module)) {} 13 : ServiceFramework(name), module(std::move(module)) {}
14 14
15void Module::Interface::Unknown(Kernel::HLERequestContext& ctx) { 15void Module::Interface::Unknown(Kernel::HLERequestContext& ctx) {
16 LOG_WARNING(Service_NFP, "(STUBBED) called"); 16 NGLOG_WARNING(Service_NFP, "(STUBBED) called");
17 IPC::ResponseBuilder rb{ctx, 2}; 17 IPC::ResponseBuilder rb{ctx, 2};
18 rb.Push(RESULT_SUCCESS); 18 rb.Push(RESULT_SUCCESS);
19} 19}
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp
index df1e7f8fe..eee92cfcd 100644
--- a/src/core/hle/service/nifm/nifm.cpp
+++ b/src/core/hle/service/nifm/nifm.cpp
@@ -62,24 +62,24 @@ public:
62 62
63private: 63private:
64 void GetRequestState(Kernel::HLERequestContext& ctx) { 64 void GetRequestState(Kernel::HLERequestContext& ctx) {
65 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 65 NGLOG_WARNING(Service_NIFM, "(STUBBED) called");
66 IPC::ResponseBuilder rb{ctx, 3}; 66 IPC::ResponseBuilder rb{ctx, 3};
67 rb.Push(RESULT_SUCCESS); 67 rb.Push(RESULT_SUCCESS);
68 rb.Push<u32>(0); 68 rb.Push<u32>(0);
69 } 69 }
70 void GetResult(Kernel::HLERequestContext& ctx) { 70 void GetResult(Kernel::HLERequestContext& ctx) {
71 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 71 NGLOG_WARNING(Service_NIFM, "(STUBBED) called");
72 IPC::ResponseBuilder rb{ctx, 2}; 72 IPC::ResponseBuilder rb{ctx, 2};
73 rb.Push(RESULT_SUCCESS); 73 rb.Push(RESULT_SUCCESS);
74 } 74 }
75 void GetSystemEventReadableHandles(Kernel::HLERequestContext& ctx) { 75 void GetSystemEventReadableHandles(Kernel::HLERequestContext& ctx) {
76 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 76 NGLOG_WARNING(Service_NIFM, "(STUBBED) called");
77 IPC::ResponseBuilder rb{ctx, 2, 2}; 77 IPC::ResponseBuilder rb{ctx, 2, 2};
78 rb.Push(RESULT_SUCCESS); 78 rb.Push(RESULT_SUCCESS);
79 rb.PushCopyObjects(event1, event2); 79 rb.PushCopyObjects(event1, event2);
80 } 80 }
81 void Cancel(Kernel::HLERequestContext& ctx) { 81 void Cancel(Kernel::HLERequestContext& ctx) {
82 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 82 NGLOG_WARNING(Service_NIFM, "(STUBBED) called");
83 IPC::ResponseBuilder rb{ctx, 2}; 83 IPC::ResponseBuilder rb{ctx, 2};
84 rb.Push(RESULT_SUCCESS); 84 rb.Push(RESULT_SUCCESS);
85 } 85 }
@@ -105,7 +105,7 @@ public:
105 105
106private: 106private:
107 void GetClientId(Kernel::HLERequestContext& ctx) { 107 void GetClientId(Kernel::HLERequestContext& ctx) {
108 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 108 NGLOG_WARNING(Service_NIFM, "(STUBBED) called");
109 IPC::ResponseBuilder rb{ctx, 4}; 109 IPC::ResponseBuilder rb{ctx, 4};
110 rb.Push(RESULT_SUCCESS); 110 rb.Push(RESULT_SUCCESS);
111 rb.Push<u64>(0); 111 rb.Push<u64>(0);
@@ -116,7 +116,7 @@ private:
116 rb.Push(RESULT_SUCCESS); 116 rb.Push(RESULT_SUCCESS);
117 rb.PushIpcInterface<IScanRequest>(); 117 rb.PushIpcInterface<IScanRequest>();
118 118
119 LOG_DEBUG(Service_NIFM, "called"); 119 NGLOG_DEBUG(Service_NIFM, "called");
120 } 120 }
121 void CreateRequest(Kernel::HLERequestContext& ctx) { 121 void CreateRequest(Kernel::HLERequestContext& ctx) {
122 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 122 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@@ -124,10 +124,10 @@ private:
124 rb.Push(RESULT_SUCCESS); 124 rb.Push(RESULT_SUCCESS);
125 rb.PushIpcInterface<IRequest>(); 125 rb.PushIpcInterface<IRequest>();
126 126
127 LOG_DEBUG(Service_NIFM, "called"); 127 NGLOG_DEBUG(Service_NIFM, "called");
128 } 128 }
129 void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) { 129 void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) {
130 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 130 NGLOG_WARNING(Service_NIFM, "(STUBBED) called");
131 IPC::ResponseBuilder rb{ctx, 2}; 131 IPC::ResponseBuilder rb{ctx, 2};
132 rb.Push(RESULT_SUCCESS); 132 rb.Push(RESULT_SUCCESS);
133 } 133 }
@@ -137,7 +137,7 @@ private:
137 rb.Push(RESULT_SUCCESS); 137 rb.Push(RESULT_SUCCESS);
138 rb.PushIpcInterface<INetworkProfile>(); 138 rb.PushIpcInterface<INetworkProfile>();
139 139
140 LOG_DEBUG(Service_NIFM, "called"); 140 NGLOG_DEBUG(Service_NIFM, "called");
141 } 141 }
142}; 142};
143 143
@@ -187,14 +187,14 @@ void Module::Interface::CreateGeneralServiceOld(Kernel::HLERequestContext& ctx)
187 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 187 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
188 rb.Push(RESULT_SUCCESS); 188 rb.Push(RESULT_SUCCESS);
189 rb.PushIpcInterface<IGeneralService>(); 189 rb.PushIpcInterface<IGeneralService>();
190 LOG_DEBUG(Service_NIFM, "called"); 190 NGLOG_DEBUG(Service_NIFM, "called");
191} 191}
192 192
193void Module::Interface::CreateGeneralService(Kernel::HLERequestContext& ctx) { 193void Module::Interface::CreateGeneralService(Kernel::HLERequestContext& ctx) {
194 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 194 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
195 rb.Push(RESULT_SUCCESS); 195 rb.Push(RESULT_SUCCESS);
196 rb.PushIpcInterface<IGeneralService>(); 196 rb.PushIpcInterface<IGeneralService>();
197 LOG_DEBUG(Service_NIFM, "called"); 197 NGLOG_DEBUG(Service_NIFM, "called");
198} 198}
199 199
200Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) 200Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp
index c416ad720..c2a647e89 100644
--- a/src/core/hle/service/ns/pl_u.cpp
+++ b/src/core/hle/service/ns/pl_u.cpp
@@ -52,7 +52,7 @@ PL_U::PL_U() : ServiceFramework("pl:u") {
52 ASSERT(file.GetSize() == SHARED_FONT_MEM_SIZE); 52 ASSERT(file.GetSize() == SHARED_FONT_MEM_SIZE);
53 file.ReadBytes(shared_font->data(), shared_font->size()); 53 file.ReadBytes(shared_font->data(), shared_font->size());
54 } else { 54 } else {
55 LOG_WARNING(Service_NS, "Unable to load shared font: %s", filepath.c_str()); 55 NGLOG_WARNING(Service_NS, "Unable to load shared font: {}", filepath);
56 } 56 }
57} 57}
58 58
@@ -60,7 +60,7 @@ void PL_U::RequestLoad(Kernel::HLERequestContext& ctx) {
60 IPC::RequestParser rp{ctx}; 60 IPC::RequestParser rp{ctx};
61 const u32 shared_font_type{rp.Pop<u32>()}; 61 const u32 shared_font_type{rp.Pop<u32>()};
62 62
63 LOG_DEBUG(Service_NS, "called, shared_font_type=%d", shared_font_type); 63 NGLOG_DEBUG(Service_NS, "called, shared_font_type={}", shared_font_type);
64 IPC::ResponseBuilder rb{ctx, 2}; 64 IPC::ResponseBuilder rb{ctx, 2};
65 rb.Push(RESULT_SUCCESS); 65 rb.Push(RESULT_SUCCESS);
66} 66}
@@ -69,7 +69,7 @@ void PL_U::GetLoadState(Kernel::HLERequestContext& ctx) {
69 IPC::RequestParser rp{ctx}; 69 IPC::RequestParser rp{ctx};
70 const u32 font_id{rp.Pop<u32>()}; 70 const u32 font_id{rp.Pop<u32>()};
71 71
72 LOG_DEBUG(Service_NS, "called, font_id=%d", font_id); 72 NGLOG_DEBUG(Service_NS, "called, font_id={}", font_id);
73 IPC::ResponseBuilder rb{ctx, 3}; 73 IPC::ResponseBuilder rb{ctx, 3};
74 rb.Push(RESULT_SUCCESS); 74 rb.Push(RESULT_SUCCESS);
75 rb.Push<u32>(static_cast<u32>(LoadState::Done)); 75 rb.Push<u32>(static_cast<u32>(LoadState::Done));
@@ -79,7 +79,7 @@ void PL_U::GetSize(Kernel::HLERequestContext& ctx) {
79 IPC::RequestParser rp{ctx}; 79 IPC::RequestParser rp{ctx};
80 const u32 font_id{rp.Pop<u32>()}; 80 const u32 font_id{rp.Pop<u32>()};
81 81
82 LOG_DEBUG(Service_NS, "called, font_id=%d", font_id); 82 NGLOG_DEBUG(Service_NS, "called, font_id={}", font_id);
83 IPC::ResponseBuilder rb{ctx, 3}; 83 IPC::ResponseBuilder rb{ctx, 3};
84 rb.Push(RESULT_SUCCESS); 84 rb.Push(RESULT_SUCCESS);
85 rb.Push<u32>(SHARED_FONT_REGIONS[font_id].size); 85 rb.Push<u32>(SHARED_FONT_REGIONS[font_id].size);
@@ -89,7 +89,7 @@ void PL_U::GetSharedMemoryAddressOffset(Kernel::HLERequestContext& ctx) {
89 IPC::RequestParser rp{ctx}; 89 IPC::RequestParser rp{ctx};
90 const u32 font_id{rp.Pop<u32>()}; 90 const u32 font_id{rp.Pop<u32>()};
91 91
92 LOG_DEBUG(Service_NS, "called, font_id=%d", font_id); 92 NGLOG_DEBUG(Service_NS, "called, font_id={}", font_id);
93 IPC::ResponseBuilder rb{ctx, 3}; 93 IPC::ResponseBuilder rb{ctx, 3};
94 rb.Push(RESULT_SUCCESS); 94 rb.Push(RESULT_SUCCESS);
95 rb.Push<u32>(SHARED_FONT_REGIONS[font_id].offset); 95 rb.Push<u32>(SHARED_FONT_REGIONS[font_id].offset);
@@ -110,7 +110,7 @@ void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) {
110 Kernel::MemoryPermission::Read, SHARED_FONT_MEM_VADDR, Kernel::MemoryRegion::BASE, 110 Kernel::MemoryPermission::Read, SHARED_FONT_MEM_VADDR, Kernel::MemoryRegion::BASE,
111 "PL_U:shared_font_mem"); 111 "PL_U:shared_font_mem");
112 112
113 LOG_DEBUG(Service_NS, "called"); 113 NGLOG_DEBUG(Service_NS, "called");
114 IPC::ResponseBuilder rb{ctx, 2, 1}; 114 IPC::ResponseBuilder rb{ctx, 2, 1};
115 rb.Push(RESULT_SUCCESS); 115 rb.Push(RESULT_SUCCESS);
116 rb.PushCopyObjects(shared_font_mem); 116 rb.PushCopyObjects(shared_font_mem);
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
index 61f22b1a5..103e66d0c 100644
--- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
@@ -13,16 +13,16 @@
13namespace Service::Nvidia::Devices { 13namespace Service::Nvidia::Devices {
14 14
15u32 nvdisp_disp0::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { 15u32 nvdisp_disp0::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
16 UNIMPLEMENTED(); 16 UNIMPLEMENTED_MSG("Unimplemented ioctl");
17 return 0; 17 return 0;
18} 18}
19 19
20void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height, 20void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height,
21 u32 stride, NVFlinger::BufferQueue::BufferTransformFlags transform) { 21 u32 stride, NVFlinger::BufferQueue::BufferTransformFlags transform) {
22 VAddr addr = nvmap_dev->GetObjectAddress(buffer_handle); 22 VAddr addr = nvmap_dev->GetObjectAddress(buffer_handle);
23 LOG_WARNING(Service, 23 NGLOG_WARNING(Service,
24 "Drawing from address %lx offset %08X Width %u Height %u Stride %u Format %u", addr, 24 "Drawing from address {:X} offset {:08X} Width {} Height {} Stride {} Format {}",
25 offset, width, height, stride, format); 25 addr, offset, width, height, stride, format);
26 26
27 using PixelFormat = Tegra::FramebufferConfig::PixelFormat; 27 using PixelFormat = Tegra::FramebufferConfig::PixelFormat;
28 const Tegra::FramebufferConfig framebuffer{ 28 const Tegra::FramebufferConfig framebuffer{
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
index 71e844959..36d7f837b 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
@@ -12,8 +12,8 @@
12namespace Service::Nvidia::Devices { 12namespace Service::Nvidia::Devices {
13 13
14u32 nvhost_as_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { 14u32 nvhost_as_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
15 LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%zx, output_size=0x%zx", 15 NGLOG_DEBUG(Service_NVDRV, "called, command={:#010X}, input_size={:#X}, output_size={:#X}",
16 command.raw, input.size(), output.size()); 16 command.raw, input.size(), output.size());
17 17
18 switch (static_cast<IoctlCommand>(command.raw)) { 18 switch (static_cast<IoctlCommand>(command.raw)) {
19 case IoctlCommand::IocInitalizeExCommand: 19 case IoctlCommand::IocInitalizeExCommand:
@@ -27,13 +27,18 @@ u32 nvhost_as_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vecto
27 case IoctlCommand::IocGetVaRegionsCommand: 27 case IoctlCommand::IocGetVaRegionsCommand:
28 return GetVARegions(input, output); 28 return GetVARegions(input, output);
29 } 29 }
30
31 if (static_cast<IoctlCommand>(command.cmd.Value()) == IoctlCommand::IocRemapCommand)
32 return Remap(input, output);
33
34 UNIMPLEMENTED_MSG("Unimplemented ioctl command");
30 return 0; 35 return 0;
31} 36}
32 37
33u32 nvhost_as_gpu::InitalizeEx(const std::vector<u8>& input, std::vector<u8>& output) { 38u32 nvhost_as_gpu::InitalizeEx(const std::vector<u8>& input, std::vector<u8>& output) {
34 IoctlInitalizeEx params{}; 39 IoctlInitalizeEx params{};
35 std::memcpy(&params, input.data(), input.size()); 40 std::memcpy(&params, input.data(), input.size());
36 LOG_WARNING(Service_NVDRV, "(STUBBED) called, big_page_size=0x%x", params.big_page_size); 41 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, big_page_size={:#X}", params.big_page_size);
37 std::memcpy(output.data(), &params, output.size()); 42 std::memcpy(output.data(), &params, output.size());
38 return 0; 43 return 0;
39} 44}
@@ -41,8 +46,8 @@ u32 nvhost_as_gpu::InitalizeEx(const std::vector<u8>& input, std::vector<u8>& ou
41u32 nvhost_as_gpu::AllocateSpace(const std::vector<u8>& input, std::vector<u8>& output) { 46u32 nvhost_as_gpu::AllocateSpace(const std::vector<u8>& input, std::vector<u8>& output) {
42 IoctlAllocSpace params{}; 47 IoctlAllocSpace params{};
43 std::memcpy(&params, input.data(), input.size()); 48 std::memcpy(&params, input.data(), input.size());
44 LOG_DEBUG(Service_NVDRV, "called, pages=%x, page_size=%x, flags=%x", params.pages, 49 NGLOG_DEBUG(Service_NVDRV, "called, pages={:X}, page_size={:X}, flags={:X}", params.pages,
45 params.page_size, params.flags); 50 params.page_size, params.flags);
46 51
47 auto& gpu = Core::System::GetInstance().GPU(); 52 auto& gpu = Core::System::GetInstance().GPU();
48 const u64 size{static_cast<u64>(params.pages) * static_cast<u64>(params.page_size)}; 53 const u64 size{static_cast<u64>(params.pages) * static_cast<u64>(params.page_size)};
@@ -56,15 +61,45 @@ u32 nvhost_as_gpu::AllocateSpace(const std::vector<u8>& input, std::vector<u8>&
56 return 0; 61 return 0;
57} 62}
58 63
64u32 nvhost_as_gpu::Remap(const std::vector<u8>& input, std::vector<u8>& output) {
65 size_t num_entries = input.size() / sizeof(IoctlRemapEntry);
66
67 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, num_entries=0x{:X}", num_entries);
68
69 std::vector<IoctlRemapEntry> entries(num_entries);
70 std::memcpy(entries.data(), input.data(), input.size());
71
72 auto& gpu = Core::System::GetInstance().GPU();
73
74 for (const auto& entry : entries) {
75 NGLOG_WARNING(Service_NVDRV, "remap entry, offset=0x{:X} handle=0x{:X} pages=0x{:X}",
76 entry.offset, entry.nvmap_handle, entry.pages);
77 Tegra::GPUVAddr offset = static_cast<Tegra::GPUVAddr>(entry.offset) << 0x10;
78
79 auto object = nvmap_dev->GetObject(entry.nvmap_handle);
80 ASSERT(object);
81
82 ASSERT(object->status == nvmap::Object::Status::Allocated);
83
84 u64 size = static_cast<u64>(entry.pages) << 0x10;
85 ASSERT(size <= object->size);
86
87 Tegra::GPUVAddr returned = gpu.memory_manager->MapBufferEx(object->addr, offset, size);
88 ASSERT(returned == offset);
89 }
90 std::memcpy(output.data(), entries.data(), output.size());
91 return 0;
92}
93
59u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output) { 94u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output) {
60 IoctlMapBufferEx params{}; 95 IoctlMapBufferEx params{};
61 std::memcpy(&params, input.data(), input.size()); 96 std::memcpy(&params, input.data(), input.size());
62 97
63 LOG_DEBUG(Service_NVDRV, 98 NGLOG_DEBUG(Service_NVDRV,
64 "called, flags=%x, nvmap_handle=%x, buffer_offset=%" PRIu64 ", mapping_size=%" PRIu64 99 "called, flags={:X}, nvmap_handle={:X}, buffer_offset={}, mapping_size={}"
65 ", offset=%" PRIu64, 100 ", offset={}",
66 params.flags, params.nvmap_handle, params.buffer_offset, params.mapping_size, 101 params.flags, params.nvmap_handle, params.buffer_offset, params.mapping_size,
67 params.offset); 102 params.offset);
68 103
69 if (!params.nvmap_handle) { 104 if (!params.nvmap_handle) {
70 return 0; 105 return 0;
@@ -73,6 +108,16 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou
73 auto object = nvmap_dev->GetObject(params.nvmap_handle); 108 auto object = nvmap_dev->GetObject(params.nvmap_handle);
74 ASSERT(object); 109 ASSERT(object);
75 110
111 // We can only map objects that have already been assigned a CPU address.
112 ASSERT(object->status == nvmap::Object::Status::Allocated);
113
114 ASSERT(params.buffer_offset == 0);
115
116 // The real nvservices doesn't make a distinction between handles and ids, and
117 // object can only have one handle and it will be the same as its id. Assert that this is the
118 // case to prevent unexpected behavior.
119 ASSERT(object->id == params.nvmap_handle);
120
76 auto& gpu = Core::System::GetInstance().GPU(); 121 auto& gpu = Core::System::GetInstance().GPU();
77 122
78 if (params.flags & 1) { 123 if (params.flags & 1) {
@@ -88,7 +133,7 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou
88u32 nvhost_as_gpu::BindChannel(const std::vector<u8>& input, std::vector<u8>& output) { 133u32 nvhost_as_gpu::BindChannel(const std::vector<u8>& input, std::vector<u8>& output) {
89 IoctlBindChannel params{}; 134 IoctlBindChannel params{};
90 std::memcpy(&params, input.data(), input.size()); 135 std::memcpy(&params, input.data(), input.size());
91 LOG_DEBUG(Service_NVDRV, "called, fd=%x", params.fd); 136 NGLOG_DEBUG(Service_NVDRV, "called, fd={:X}", params.fd);
92 channel = params.fd; 137 channel = params.fd;
93 std::memcpy(output.data(), &params, output.size()); 138 std::memcpy(output.data(), &params, output.size());
94 return 0; 139 return 0;
@@ -97,8 +142,8 @@ u32 nvhost_as_gpu::BindChannel(const std::vector<u8>& input, std::vector<u8>& ou
97u32 nvhost_as_gpu::GetVARegions(const std::vector<u8>& input, std::vector<u8>& output) { 142u32 nvhost_as_gpu::GetVARegions(const std::vector<u8>& input, std::vector<u8>& output) {
98 IoctlGetVaRegions params{}; 143 IoctlGetVaRegions params{};
99 std::memcpy(&params, input.data(), input.size()); 144 std::memcpy(&params, input.data(), input.size());
100 LOG_WARNING(Service_NVDRV, "(STUBBED) called, buf_addr=%" PRIu64 ", buf_size=%x", 145 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, buf_addr={:X}, buf_size={:X}", params.buf_addr,
101 params.buf_addr, params.buf_size); 146 params.buf_size);
102 147
103 params.buf_size = 0x30; 148 params.buf_size = 0x30;
104 params.regions[0].offset = 0x04000000; 149 params.regions[0].offset = 0x04000000;
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
index d86c3ebd9..f2dd0c3b3 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
@@ -26,6 +26,7 @@ private:
26 enum class IoctlCommand : u32_le { 26 enum class IoctlCommand : u32_le {
27 IocInitalizeExCommand = 0x40284109, 27 IocInitalizeExCommand = 0x40284109,
28 IocAllocateSpaceCommand = 0xC0184102, 28 IocAllocateSpaceCommand = 0xC0184102,
29 IocRemapCommand = 0x00000014,
29 IocMapBufferExCommand = 0xC0284106, 30 IocMapBufferExCommand = 0xC0284106,
30 IocBindChannelCommand = 0x40044101, 31 IocBindChannelCommand = 0x40044101,
31 IocGetVaRegionsCommand = 0xC0404108, 32 IocGetVaRegionsCommand = 0xC0404108,
@@ -54,6 +55,16 @@ private:
54 }; 55 };
55 static_assert(sizeof(IoctlAllocSpace) == 24, "IoctlInitalizeEx is incorrect size"); 56 static_assert(sizeof(IoctlAllocSpace) == 24, "IoctlInitalizeEx is incorrect size");
56 57
58 struct IoctlRemapEntry {
59 u16_le flags;
60 u16_le kind;
61 u32_le nvmap_handle;
62 INSERT_PADDING_WORDS(1);
63 u32_le offset;
64 u32_le pages;
65 };
66 static_assert(sizeof(IoctlRemapEntry) == 20, "IoctlRemapEntry is incorrect size");
67
57 struct IoctlMapBufferEx { 68 struct IoctlMapBufferEx {
58 u32_le flags; // bit0: fixed_offset, bit2: cacheable 69 u32_le flags; // bit0: fixed_offset, bit2: cacheable
59 u32_le kind; // -1 is default 70 u32_le kind; // -1 is default
@@ -91,6 +102,7 @@ private:
91 102
92 u32 InitalizeEx(const std::vector<u8>& input, std::vector<u8>& output); 103 u32 InitalizeEx(const std::vector<u8>& input, std::vector<u8>& output);
93 u32 AllocateSpace(const std::vector<u8>& input, std::vector<u8>& output); 104 u32 AllocateSpace(const std::vector<u8>& input, std::vector<u8>& output);
105 u32 Remap(const std::vector<u8>& input, std::vector<u8>& output);
94 u32 MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output); 106 u32 MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output);
95 u32 BindChannel(const std::vector<u8>& input, std::vector<u8>& output); 107 u32 BindChannel(const std::vector<u8>& input, std::vector<u8>& output);
96 u32 GetVARegions(const std::vector<u8>& input, std::vector<u8>& output); 108 u32 GetVARegions(const std::vector<u8>& input, std::vector<u8>& output);
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
index 660a0f665..46f0b6862 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
@@ -9,8 +9,8 @@
9namespace Service::Nvidia::Devices { 9namespace Service::Nvidia::Devices {
10 10
11u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { 11u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
12 LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%zx, output_size=0x%zx", 12 NGLOG_DEBUG(Service_NVDRV, "called, command={:#010X}, input_size={:#X}, output_size={:#X}",
13 command.raw, input.size(), output.size()); 13 command.raw, input.size(), output.size());
14 14
15 switch (static_cast<IoctlCommand>(command.raw)) { 15 switch (static_cast<IoctlCommand>(command.raw)) {
16 case IoctlCommand::IocGetConfigCommand: 16 case IoctlCommand::IocGetConfigCommand:
@@ -18,15 +18,15 @@ u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<
18 case IoctlCommand::IocCtrlEventWaitCommand: 18 case IoctlCommand::IocCtrlEventWaitCommand:
19 return IocCtrlEventWait(input, output); 19 return IocCtrlEventWait(input, output);
20 } 20 }
21 UNIMPLEMENTED(); 21 UNIMPLEMENTED_MSG("Unimplemented ioctl");
22 return 0; 22 return 0;
23} 23}
24 24
25u32 nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) { 25u32 nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) {
26 IocGetConfigParams params{}; 26 IocGetConfigParams params{};
27 std::memcpy(&params, input.data(), sizeof(params)); 27 std::memcpy(&params, input.data(), sizeof(params));
28 LOG_DEBUG(Service_NVDRV, "called, setting=%s!%s", params.domain_str.data(), 28 NGLOG_DEBUG(Service_NVDRV, "called, setting={}!{}", params.domain_str.data(),
29 params.param_str.data()); 29 params.param_str.data());
30 30
31 if (!strcmp(params.domain_str.data(), "nv")) { 31 if (!strcmp(params.domain_str.data(), "nv")) {
32 if (!strcmp(params.param_str.data(), "NV_MEMORY_PROFILER")) { 32 if (!strcmp(params.param_str.data(), "NV_MEMORY_PROFILER")) {
@@ -48,8 +48,8 @@ u32 nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>&
48u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& output) { 48u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& output) {
49 IocCtrlEventWaitParams params{}; 49 IocCtrlEventWaitParams params{};
50 std::memcpy(&params, input.data(), sizeof(params)); 50 std::memcpy(&params, input.data(), sizeof(params));
51 LOG_WARNING(Service_NVDRV, "(STUBBED) called, syncpt_id=%u threshold=%u timeout=%d", 51 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, syncpt_id={} threshold={} timeout={}",
52 params.syncpt_id, params.threshold, params.timeout); 52 params.syncpt_id, params.threshold, params.timeout);
53 53
54 // TODO(Subv): Implement actual syncpt waiting. 54 // TODO(Subv): Implement actual syncpt waiting.
55 params.value = 0; 55 params.value = 0;
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
index 18ea12ef5..1e457ae6e 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
@@ -10,8 +10,8 @@
10namespace Service::Nvidia::Devices { 10namespace Service::Nvidia::Devices {
11 11
12u32 nvhost_ctrl_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { 12u32 nvhost_ctrl_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
13 LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%zx, output_size=0x%zx", 13 NGLOG_DEBUG(Service_NVDRV, "called, command={:#010X}, input_size={:#X}, output_size={:#X}",
14 command.raw, input.size(), output.size()); 14 command.raw, input.size(), output.size());
15 15
16 switch (static_cast<IoctlCommand>(command.raw)) { 16 switch (static_cast<IoctlCommand>(command.raw)) {
17 case IoctlCommand::IocGetCharacteristicsCommand: 17 case IoctlCommand::IocGetCharacteristicsCommand:
@@ -25,12 +25,12 @@ u32 nvhost_ctrl_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vec
25 case IoctlCommand::IocZcullGetInfo: 25 case IoctlCommand::IocZcullGetInfo:
26 return ZCullGetInfo(input, output); 26 return ZCullGetInfo(input, output);
27 } 27 }
28 UNIMPLEMENTED(); 28 UNIMPLEMENTED_MSG("Unimplemented ioctl");
29 return 0; 29 return 0;
30} 30}
31 31
32u32 nvhost_ctrl_gpu::GetCharacteristics(const std::vector<u8>& input, std::vector<u8>& output) { 32u32 nvhost_ctrl_gpu::GetCharacteristics(const std::vector<u8>& input, std::vector<u8>& output) {
33 LOG_DEBUG(Service_NVDRV, "called"); 33 NGLOG_DEBUG(Service_NVDRV, "called");
34 IoctlCharacteristics params{}; 34 IoctlCharacteristics params{};
35 std::memcpy(&params, input.data(), input.size()); 35 std::memcpy(&params, input.data(), input.size());
36 params.gc.arch = 0x120; 36 params.gc.arch = 0x120;
@@ -77,14 +77,14 @@ u32 nvhost_ctrl_gpu::GetCharacteristics(const std::vector<u8>& input, std::vecto
77u32 nvhost_ctrl_gpu::GetTPCMasks(const std::vector<u8>& input, std::vector<u8>& output) { 77u32 nvhost_ctrl_gpu::GetTPCMasks(const std::vector<u8>& input, std::vector<u8>& output) {
78 IoctlGpuGetTpcMasksArgs params{}; 78 IoctlGpuGetTpcMasksArgs params{};
79 std::memcpy(&params, input.data(), input.size()); 79 std::memcpy(&params, input.data(), input.size());
80 LOG_WARNING(Service_NVDRV, "(STUBBED) called, mask=0x%x, mask_buf_addr=0x%" PRIx64, 80 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, mask={:#X}, mask_buf_addr={:#X}",
81 params.mask_buf_size, params.mask_buf_addr); 81 params.mask_buf_size, params.mask_buf_addr);
82 std::memcpy(output.data(), &params, sizeof(params)); 82 std::memcpy(output.data(), &params, sizeof(params));
83 return 0; 83 return 0;
84} 84}
85 85
86u32 nvhost_ctrl_gpu::GetActiveSlotMask(const std::vector<u8>& input, std::vector<u8>& output) { 86u32 nvhost_ctrl_gpu::GetActiveSlotMask(const std::vector<u8>& input, std::vector<u8>& output) {
87 LOG_DEBUG(Service_NVDRV, "called"); 87 NGLOG_DEBUG(Service_NVDRV, "called");
88 IoctlActiveSlotMask params{}; 88 IoctlActiveSlotMask params{};
89 std::memcpy(&params, input.data(), input.size()); 89 std::memcpy(&params, input.data(), input.size());
90 params.slot = 0x07; 90 params.slot = 0x07;
@@ -94,7 +94,7 @@ u32 nvhost_ctrl_gpu::GetActiveSlotMask(const std::vector<u8>& input, std::vector
94} 94}
95 95
96u32 nvhost_ctrl_gpu::ZCullGetCtxSize(const std::vector<u8>& input, std::vector<u8>& output) { 96u32 nvhost_ctrl_gpu::ZCullGetCtxSize(const std::vector<u8>& input, std::vector<u8>& output) {
97 LOG_DEBUG(Service_NVDRV, "called"); 97 NGLOG_DEBUG(Service_NVDRV, "called");
98 IoctlZcullGetCtxSize params{}; 98 IoctlZcullGetCtxSize params{};
99 std::memcpy(&params, input.data(), input.size()); 99 std::memcpy(&params, input.data(), input.size());
100 params.size = 0x1; 100 params.size = 0x1;
@@ -103,7 +103,7 @@ u32 nvhost_ctrl_gpu::ZCullGetCtxSize(const std::vector<u8>& input, std::vector<u
103} 103}
104 104
105u32 nvhost_ctrl_gpu::ZCullGetInfo(const std::vector<u8>& input, std::vector<u8>& output) { 105u32 nvhost_ctrl_gpu::ZCullGetInfo(const std::vector<u8>& input, std::vector<u8>& output) {
106 LOG_DEBUG(Service_NVDRV, "called"); 106 NGLOG_DEBUG(Service_NVDRV, "called");
107 IoctlNvgpuGpuZcullGetInfoArgs params{}; 107 IoctlNvgpuGpuZcullGetInfoArgs params{};
108 std::memcpy(&params, input.data(), input.size()); 108 std::memcpy(&params, input.data(), input.size());
109 params.width_align_pixels = 0x20; 109 params.width_align_pixels = 0x20;
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
index a16e90457..70625211e 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
@@ -12,8 +12,8 @@
12namespace Service::Nvidia::Devices { 12namespace Service::Nvidia::Devices {
13 13
14u32 nvhost_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { 14u32 nvhost_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
15 LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%zx, output_size=0x%zx", 15 NGLOG_DEBUG(Service_NVDRV, "called, command={:#010X}, input_size={:#X}, output_size={:#X}",
16 command.raw, input.size(), output.size()); 16 command.raw, input.size(), output.size());
17 17
18 switch (static_cast<IoctlCommand>(command.raw)) { 18 switch (static_cast<IoctlCommand>(command.raw)) {
19 case IoctlCommand::IocSetNVMAPfdCommand: 19 case IoctlCommand::IocSetNVMAPfdCommand:
@@ -40,21 +40,21 @@ u32 nvhost_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u
40 } 40 }
41 } 41 }
42 42
43 UNIMPLEMENTED(); 43 UNIMPLEMENTED_MSG("Unimplemented ioctl");
44 return 0; 44 return 0;
45}; 45};
46 46
47u32 nvhost_gpu::SetNVMAPfd(const std::vector<u8>& input, std::vector<u8>& output) { 47u32 nvhost_gpu::SetNVMAPfd(const std::vector<u8>& input, std::vector<u8>& output) {
48 IoctlSetNvmapFD params{}; 48 IoctlSetNvmapFD params{};
49 std::memcpy(&params, input.data(), input.size()); 49 std::memcpy(&params, input.data(), input.size());
50 LOG_DEBUG(Service_NVDRV, "called, fd=%x", params.nvmap_fd); 50 NGLOG_DEBUG(Service_NVDRV, "called, fd={}", params.nvmap_fd);
51 nvmap_fd = params.nvmap_fd; 51 nvmap_fd = params.nvmap_fd;
52 std::memcpy(output.data(), &params, output.size()); 52 std::memcpy(output.data(), &params, output.size());
53 return 0; 53 return 0;
54} 54}
55 55
56u32 nvhost_gpu::SetClientData(const std::vector<u8>& input, std::vector<u8>& output) { 56u32 nvhost_gpu::SetClientData(const std::vector<u8>& input, std::vector<u8>& output) {
57 LOG_DEBUG(Service_NVDRV, "called"); 57 NGLOG_DEBUG(Service_NVDRV, "called");
58 IoctlClientData params{}; 58 IoctlClientData params{};
59 std::memcpy(&params, input.data(), input.size()); 59 std::memcpy(&params, input.data(), input.size());
60 user_data = params.data; 60 user_data = params.data;
@@ -63,7 +63,7 @@ u32 nvhost_gpu::SetClientData(const std::vector<u8>& input, std::vector<u8>& out
63} 63}
64 64
65u32 nvhost_gpu::GetClientData(const std::vector<u8>& input, std::vector<u8>& output) { 65u32 nvhost_gpu::GetClientData(const std::vector<u8>& input, std::vector<u8>& output) {
66 LOG_DEBUG(Service_NVDRV, "called"); 66 NGLOG_DEBUG(Service_NVDRV, "called");
67 IoctlClientData params{}; 67 IoctlClientData params{};
68 std::memcpy(&params, input.data(), input.size()); 68 std::memcpy(&params, input.data(), input.size());
69 params.data = user_data; 69 params.data = user_data;
@@ -73,8 +73,8 @@ u32 nvhost_gpu::GetClientData(const std::vector<u8>& input, std::vector<u8>& out
73 73
74u32 nvhost_gpu::ZCullBind(const std::vector<u8>& input, std::vector<u8>& output) { 74u32 nvhost_gpu::ZCullBind(const std::vector<u8>& input, std::vector<u8>& output) {
75 std::memcpy(&zcull_params, input.data(), input.size()); 75 std::memcpy(&zcull_params, input.data(), input.size());
76 LOG_DEBUG(Service_NVDRV, "called, gpu_va=%" PRIx64 ", mode=%x", zcull_params.gpu_va, 76 NGLOG_DEBUG(Service_NVDRV, "called, gpu_va={:X}, mode={:X}", zcull_params.gpu_va,
77 zcull_params.mode); 77 zcull_params.mode);
78 std::memcpy(output.data(), &zcull_params, output.size()); 78 std::memcpy(output.data(), &zcull_params, output.size());
79 return 0; 79 return 0;
80} 80}
@@ -82,15 +82,15 @@ u32 nvhost_gpu::ZCullBind(const std::vector<u8>& input, std::vector<u8>& output)
82u32 nvhost_gpu::SetErrorNotifier(const std::vector<u8>& input, std::vector<u8>& output) { 82u32 nvhost_gpu::SetErrorNotifier(const std::vector<u8>& input, std::vector<u8>& output) {
83 IoctlSetErrorNotifier params{}; 83 IoctlSetErrorNotifier params{};
84 std::memcpy(&params, input.data(), input.size()); 84 std::memcpy(&params, input.data(), input.size());
85 LOG_WARNING(Service_NVDRV, "(STUBBED) called, offset=%" PRIx64 ", size=%" PRIx64 ", mem=%x", 85 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, offset={:X}, size={:X}, mem={:X}",
86 params.offset, params.size, params.mem); 86 params.offset, params.size, params.mem);
87 std::memcpy(output.data(), &params, output.size()); 87 std::memcpy(output.data(), &params, output.size());
88 return 0; 88 return 0;
89} 89}
90 90
91u32 nvhost_gpu::SetChannelPriority(const std::vector<u8>& input, std::vector<u8>& output) { 91u32 nvhost_gpu::SetChannelPriority(const std::vector<u8>& input, std::vector<u8>& output) {
92 std::memcpy(&channel_priority, input.data(), input.size()); 92 std::memcpy(&channel_priority, input.data(), input.size());
93 LOG_DEBUG(Service_NVDRV, "(STUBBED) called, priority=%x", channel_priority); 93 NGLOG_DEBUG(Service_NVDRV, "(STUBBED) called, priority={:X}", channel_priority);
94 std::memcpy(output.data(), &channel_priority, output.size()); 94 std::memcpy(output.data(), &channel_priority, output.size());
95 return 0; 95 return 0;
96} 96}
@@ -98,10 +98,11 @@ u32 nvhost_gpu::SetChannelPriority(const std::vector<u8>& input, std::vector<u8>
98u32 nvhost_gpu::AllocGPFIFOEx2(const std::vector<u8>& input, std::vector<u8>& output) { 98u32 nvhost_gpu::AllocGPFIFOEx2(const std::vector<u8>& input, std::vector<u8>& output) {
99 IoctlAllocGpfifoEx2 params{}; 99 IoctlAllocGpfifoEx2 params{};
100 std::memcpy(&params, input.data(), input.size()); 100 std::memcpy(&params, input.data(), input.size());
101 LOG_WARNING(Service_NVDRV, 101 NGLOG_WARNING(Service_NVDRV,
102 "(STUBBED) called, num_entries=%x, flags=%x, unk0=%x, unk1=%x, unk2=%x, unk3=%x", 102 "(STUBBED) called, num_entries={:X}, flags={:X}, unk0={:X}, "
103 params.num_entries, params.flags, params.unk0, params.unk1, params.unk2, 103 "unk1={:X}, unk2={:X}, unk3={:X}",
104 params.unk3); 104 params.num_entries, params.flags, params.unk0, params.unk1, params.unk2,
105 params.unk3);
105 params.fence_out.id = 0; 106 params.fence_out.id = 0;
106 params.fence_out.value = 0; 107 params.fence_out.value = 0;
107 std::memcpy(output.data(), &params, output.size()); 108 std::memcpy(output.data(), &params, output.size());
@@ -111,8 +112,8 @@ u32 nvhost_gpu::AllocGPFIFOEx2(const std::vector<u8>& input, std::vector<u8>& ou
111u32 nvhost_gpu::AllocateObjectContext(const std::vector<u8>& input, std::vector<u8>& output) { 112u32 nvhost_gpu::AllocateObjectContext(const std::vector<u8>& input, std::vector<u8>& output) {
112 IoctlAllocObjCtx params{}; 113 IoctlAllocObjCtx params{};
113 std::memcpy(&params, input.data(), input.size()); 114 std::memcpy(&params, input.data(), input.size());
114 LOG_WARNING(Service_NVDRV, "(STUBBED) called, class_num=%x, flags=%x", params.class_num, 115 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, class_num={:X}, flags={:X}", params.class_num,
115 params.flags); 116 params.flags);
116 params.obj_id = 0x0; 117 params.obj_id = 0x0;
117 std::memcpy(output.data(), &params, output.size()); 118 std::memcpy(output.data(), &params, output.size());
118 return 0; 119 return 0;
@@ -123,8 +124,8 @@ u32 nvhost_gpu::SubmitGPFIFO(const std::vector<u8>& input, std::vector<u8>& outp
123 UNIMPLEMENTED(); 124 UNIMPLEMENTED();
124 IoctlSubmitGpfifo params{}; 125 IoctlSubmitGpfifo params{};
125 std::memcpy(&params, input.data(), sizeof(IoctlSubmitGpfifo)); 126 std::memcpy(&params, input.data(), sizeof(IoctlSubmitGpfifo));
126 LOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo=%" PRIx64 ", num_entries=%x, flags=%x", 127 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo={:X}, num_entries={:X}, flags={:X}",
127 params.gpfifo, params.num_entries, params.flags); 128 params.gpfifo, params.num_entries, params.flags);
128 129
129 auto entries = std::vector<IoctlGpfifoEntry>(); 130 auto entries = std::vector<IoctlGpfifoEntry>();
130 entries.resize(params.num_entries); 131 entries.resize(params.num_entries);
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp
index 4bb1f57f6..11df8849d 100644
--- a/src/core/hle/service/nvdrv/devices/nvmap.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp
@@ -32,7 +32,7 @@ u32 nvmap::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& o
32 return IocParam(input, output); 32 return IocParam(input, output);
33 } 33 }
34 34
35 UNIMPLEMENTED(); 35 UNIMPLEMENTED_MSG("Unimplemented ioctl");
36 return 0; 36 return 0;
37} 37}
38 38
@@ -49,7 +49,7 @@ u32 nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) {
49 u32 handle = next_handle++; 49 u32 handle = next_handle++;
50 handles[handle] = std::move(object); 50 handles[handle] = std::move(object);
51 51
52 LOG_DEBUG(Service_NVDRV, "size=0x%08X", params.size); 52 NGLOG_DEBUG(Service_NVDRV, "size={:#010X}", params.size);
53 53
54 params.handle = handle; 54 params.handle = handle;
55 55
@@ -70,7 +70,7 @@ u32 nvmap::IocAlloc(const std::vector<u8>& input, std::vector<u8>& output) {
70 object->addr = params.addr; 70 object->addr = params.addr;
71 object->status = Object::Status::Allocated; 71 object->status = Object::Status::Allocated;
72 72
73 LOG_DEBUG(Service_NVDRV, "called, addr=0x%" PRIx64, params.addr); 73 NGLOG_DEBUG(Service_NVDRV, "called, addr={:X}", params.addr);
74 74
75 std::memcpy(output.data(), &params, sizeof(params)); 75 std::memcpy(output.data(), &params, sizeof(params));
76 return 0; 76 return 0;
@@ -80,7 +80,7 @@ u32 nvmap::IocGetId(const std::vector<u8>& input, std::vector<u8>& output) {
80 IocGetIdParams params; 80 IocGetIdParams params;
81 std::memcpy(&params, input.data(), sizeof(params)); 81 std::memcpy(&params, input.data(), sizeof(params));
82 82
83 LOG_WARNING(Service_NVDRV, "called"); 83 NGLOG_WARNING(Service_NVDRV, "called");
84 84
85 auto object = GetObject(params.handle); 85 auto object = GetObject(params.handle);
86 ASSERT(object); 86 ASSERT(object);
@@ -95,7 +95,7 @@ u32 nvmap::IocFromId(const std::vector<u8>& input, std::vector<u8>& output) {
95 IocFromIdParams params; 95 IocFromIdParams params;
96 std::memcpy(&params, input.data(), sizeof(params)); 96 std::memcpy(&params, input.data(), sizeof(params));
97 97
98 LOG_WARNING(Service_NVDRV, "(STUBBED) called"); 98 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called");
99 99
100 auto itr = std::find_if(handles.begin(), handles.end(), 100 auto itr = std::find_if(handles.begin(), handles.end(),
101 [&](const auto& entry) { return entry.second->id == params.id; }); 101 [&](const auto& entry) { return entry.second->id == params.id; });
@@ -114,7 +114,7 @@ u32 nvmap::IocParam(const std::vector<u8>& input, std::vector<u8>& output) {
114 IocParamParams params; 114 IocParamParams params;
115 std::memcpy(&params, input.data(), sizeof(params)); 115 std::memcpy(&params, input.data(), sizeof(params));
116 116
117 LOG_WARNING(Service_NVDRV, "(STUBBED) called type=%u", params.type); 117 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called type={}", params.type);
118 118
119 auto object = GetObject(params.handle); 119 auto object = GetObject(params.handle);
120 ASSERT(object); 120 ASSERT(object);
diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp
index d0d64a840..38b3a9a84 100644
--- a/src/core/hle/service/nvdrv/interface.cpp
+++ b/src/core/hle/service/nvdrv/interface.cpp
@@ -12,7 +12,7 @@
12namespace Service::Nvidia { 12namespace Service::Nvidia {
13 13
14void NVDRV::Open(Kernel::HLERequestContext& ctx) { 14void NVDRV::Open(Kernel::HLERequestContext& ctx) {
15 LOG_DEBUG(Service_NVDRV, "called"); 15 NGLOG_DEBUG(Service_NVDRV, "called");
16 16
17 const auto& buffer = ctx.ReadBuffer(); 17 const auto& buffer = ctx.ReadBuffer();
18 std::string device_name(buffer.begin(), buffer.end()); 18 std::string device_name(buffer.begin(), buffer.end());
@@ -25,7 +25,7 @@ void NVDRV::Open(Kernel::HLERequestContext& ctx) {
25} 25}
26 26
27void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) { 27void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) {
28 LOG_DEBUG(Service_NVDRV, "called"); 28 NGLOG_DEBUG(Service_NVDRV, "called");
29 29
30 IPC::RequestParser rp{ctx}; 30 IPC::RequestParser rp{ctx};
31 u32 fd = rp.Pop<u32>(); 31 u32 fd = rp.Pop<u32>();
@@ -41,7 +41,7 @@ void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) {
41} 41}
42 42
43void NVDRV::Close(Kernel::HLERequestContext& ctx) { 43void NVDRV::Close(Kernel::HLERequestContext& ctx) {
44 LOG_DEBUG(Service_NVDRV, "called"); 44 NGLOG_DEBUG(Service_NVDRV, "called");
45 45
46 IPC::RequestParser rp{ctx}; 46 IPC::RequestParser rp{ctx};
47 u32 fd = rp.Pop<u32>(); 47 u32 fd = rp.Pop<u32>();
@@ -53,7 +53,7 @@ void NVDRV::Close(Kernel::HLERequestContext& ctx) {
53} 53}
54 54
55void NVDRV::Initialize(Kernel::HLERequestContext& ctx) { 55void NVDRV::Initialize(Kernel::HLERequestContext& ctx) {
56 LOG_WARNING(Service_NVDRV, "(STUBBED) called"); 56 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called");
57 IPC::ResponseBuilder rb{ctx, 3}; 57 IPC::ResponseBuilder rb{ctx, 3};
58 rb.Push(RESULT_SUCCESS); 58 rb.Push(RESULT_SUCCESS);
59 rb.Push<u32>(0); 59 rb.Push<u32>(0);
@@ -63,7 +63,7 @@ void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) {
63 IPC::RequestParser rp{ctx}; 63 IPC::RequestParser rp{ctx};
64 u32 fd = rp.Pop<u32>(); 64 u32 fd = rp.Pop<u32>();
65 u32 event_id = rp.Pop<u32>(); 65 u32 event_id = rp.Pop<u32>();
66 LOG_WARNING(Service_NVDRV, "(STUBBED) called, fd=%x, event_id=%x", fd, event_id); 66 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, fd={:X}, event_id={:X}", fd, event_id);
67 67
68 IPC::ResponseBuilder rb{ctx, 3, 1}; 68 IPC::ResponseBuilder rb{ctx, 3, 1};
69 rb.Push(RESULT_SUCCESS); 69 rb.Push(RESULT_SUCCESS);
@@ -75,14 +75,14 @@ void NVDRV::SetClientPID(Kernel::HLERequestContext& ctx) {
75 IPC::RequestParser rp{ctx}; 75 IPC::RequestParser rp{ctx};
76 pid = rp.Pop<u64>(); 76 pid = rp.Pop<u64>();
77 77
78 LOG_WARNING(Service_NVDRV, "(STUBBED) called, pid=0x%" PRIx64, pid); 78 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, pid={:#X}", pid);
79 IPC::ResponseBuilder rb{ctx, 3}; 79 IPC::ResponseBuilder rb{ctx, 3};
80 rb.Push(RESULT_SUCCESS); 80 rb.Push(RESULT_SUCCESS);
81 rb.Push<u32>(0); 81 rb.Push<u32>(0);
82} 82}
83 83
84void NVDRV::FinishInitialize(Kernel::HLERequestContext& ctx) { 84void NVDRV::FinishInitialize(Kernel::HLERequestContext& ctx) {
85 LOG_WARNING(Service_NVDRV, "(STUBBED) called"); 85 NGLOG_WARNING(Service_NVDRV, "(STUBBED) called");
86 IPC::ResponseBuilder rb{ctx, 2}; 86 IPC::ResponseBuilder rb{ctx, 2};
87 rb.Push(RESULT_SUCCESS); 87 rb.Push(RESULT_SUCCESS);
88} 88}
diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp
index 03a4fed59..49e88b394 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue.cpp
@@ -9,7 +9,8 @@
9#include "core/core_timing.h" 9#include "core/core_timing.h"
10#include "core/hle/service/nvflinger/buffer_queue.h" 10#include "core/hle/service/nvflinger/buffer_queue.h"
11 11
12namespace Service::NVFlinger { 12namespace Service {
13namespace NVFlinger {
13 14
14BufferQueue::BufferQueue(u32 id, u64 layer_id) : id(id), layer_id(layer_id) { 15BufferQueue::BufferQueue(u32 id, u64 layer_id) : id(id), layer_id(layer_id) {
15 native_handle = Kernel::Event::Create(Kernel::ResetType::OneShot, "BufferQueue NativeHandle"); 16 native_handle = Kernel::Event::Create(Kernel::ResetType::OneShot, "BufferQueue NativeHandle");
@@ -22,7 +23,7 @@ void BufferQueue::SetPreallocatedBuffer(u32 slot, IGBPBuffer& igbp_buffer) {
22 buffer.igbp_buffer = igbp_buffer; 23 buffer.igbp_buffer = igbp_buffer;
23 buffer.status = Buffer::Status::Free; 24 buffer.status = Buffer::Status::Free;
24 25
25 LOG_WARNING(Service, "Adding graphics buffer %u", slot); 26 NGLOG_WARNING(Service, "Adding graphics buffer {}", slot);
26 27
27 queue.emplace_back(buffer); 28 queue.emplace_back(buffer);
28 29
@@ -93,7 +94,7 @@ void BufferQueue::ReleaseBuffer(u32 slot) {
93} 94}
94 95
95u32 BufferQueue::Query(QueryType type) { 96u32 BufferQueue::Query(QueryType type) {
96 LOG_WARNING(Service, "(STUBBED) called type=%u", static_cast<u32>(type)); 97 NGLOG_WARNING(Service, "(STUBBED) called type={}", static_cast<u32>(type));
97 switch (type) { 98 switch (type) {
98 case QueryType::NativeWindowFormat: 99 case QueryType::NativeWindowFormat:
99 // TODO(Subv): Use an enum for this 100 // TODO(Subv): Use an enum for this
@@ -110,4 +111,5 @@ void BufferQueue::SetBufferWaitEvent(Kernel::SharedPtr<Kernel::Event>&& wait_eve
110 buffer_wait_event = std::move(wait_event); 111 buffer_wait_event = std::move(wait_event);
111} 112}
112 113
113} // namespace Service::NVFlinger 114} // namespace NVFlinger
115} // namespace Service
diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h
index 95adc4706..1de5767cb 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.h
+++ b/src/core/hle/service/nvflinger/buffer_queue.h
@@ -13,7 +13,8 @@ namespace CoreTiming {
13struct EventType; 13struct EventType;
14} 14}
15 15
16namespace Service::NVFlinger { 16namespace Service {
17namespace NVFlinger {
17 18
18struct IGBPBuffer { 19struct IGBPBuffer {
19 u32_le magic; 20 u32_le magic;
@@ -97,4 +98,5 @@ private:
97 Kernel::SharedPtr<Kernel::Event> buffer_wait_event; 98 Kernel::SharedPtr<Kernel::Event> buffer_wait_event;
98}; 99};
99 100
100} // namespace Service::NVFlinger 101} // namespace NVFlinger
102} // namespace Service
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index a99ebc8e6..3481e48d0 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -48,7 +48,7 @@ NVFlinger::~NVFlinger() {
48} 48}
49 49
50u64 NVFlinger::OpenDisplay(const std::string& name) { 50u64 NVFlinger::OpenDisplay(const std::string& name) {
51 LOG_WARNING(Service, "Opening display %s", name.c_str()); 51 NGLOG_WARNING(Service, "Opening display {}", name);
52 52
53 // TODO(Subv): Currently we only support the Default display. 53 // TODO(Subv): Currently we only support the Default display.
54 ASSERT(name == "Default"); 54 ASSERT(name == "Default");
diff --git a/src/core/hle/service/pctl/pctl_a.cpp b/src/core/hle/service/pctl/pctl_a.cpp
index 9fb4628ad..24a6cf310 100644
--- a/src/core/hle/service/pctl/pctl_a.cpp
+++ b/src/core/hle/service/pctl/pctl_a.cpp
@@ -113,7 +113,7 @@ void PCTL_A::CreateService(Kernel::HLERequestContext& ctx) {
113 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 113 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
114 rb.Push(RESULT_SUCCESS); 114 rb.Push(RESULT_SUCCESS);
115 rb.PushIpcInterface<IParentalControlService>(); 115 rb.PushIpcInterface<IParentalControlService>();
116 LOG_DEBUG(Service_PCTL, "called"); 116 NGLOG_DEBUG(Service_PCTL, "called");
117} 117}
118 118
119PCTL_A::PCTL_A() : ServiceFramework("pctl:a") { 119PCTL_A::PCTL_A() : ServiceFramework("pctl:a") {
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 08ce29677..5817819fe 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -120,7 +120,7 @@ void ServiceFrameworkBase::ReportUnimplementedFunction(Kernel::HLERequestContext
120 } 120 }
121 buf.push_back('}'); 121 buf.push_back('}');
122 122
123 LOG_ERROR(Service, "unknown / unimplemented %s", fmt::to_string(buf).c_str()); 123 NGLOG_ERROR(Service, "unknown / unimplemented {}", fmt::to_string(buf));
124 UNIMPLEMENTED(); 124 UNIMPLEMENTED();
125} 125}
126 126
@@ -131,8 +131,8 @@ void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) {
131 return ReportUnimplementedFunction(ctx, info); 131 return ReportUnimplementedFunction(ctx, info);
132 } 132 }
133 133
134 LOG_TRACE( 134 NGLOG_TRACE(
135 Service, "%s", 135 Service, "{}",
136 MakeFunctionString(info->name, GetServiceName().c_str(), ctx.CommandBuffer()).c_str()); 136 MakeFunctionString(info->name, GetServiceName().c_str(), ctx.CommandBuffer()).c_str());
137 handler_invoker(this, info->handler_callback, ctx); 137 handler_invoker(this, info->handler_callback, ctx);
138} 138}
@@ -199,12 +199,12 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) {
199 VI::InstallInterfaces(*sm, nv_flinger); 199 VI::InstallInterfaces(*sm, nv_flinger);
200 Set::InstallInterfaces(*sm); 200 Set::InstallInterfaces(*sm);
201 201
202 LOG_DEBUG(Service, "initialized OK"); 202 NGLOG_DEBUG(Service, "initialized OK");
203} 203}
204 204
205/// Shutdown ServiceManager 205/// Shutdown ServiceManager
206void Shutdown() { 206void Shutdown() {
207 g_kernel_named_ports.clear(); 207 g_kernel_named_ports.clear();
208 LOG_DEBUG(Service, "shutdown OK"); 208 NGLOG_DEBUG(Service, "shutdown OK");
209} 209}
210} // namespace Service 210} // namespace Service
diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp
index fc3e424d0..ece29aa70 100644
--- a/src/core/hle/service/set/set.cpp
+++ b/src/core/hle/service/set/set.cpp
@@ -22,7 +22,7 @@ void SET::GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx) {
22 22
23 rb.Push(RESULT_SUCCESS); 23 rb.Push(RESULT_SUCCESS);
24 24
25 LOG_WARNING(Service_SET, "(STUBBED) called"); 25 NGLOG_WARNING(Service_SET, "(STUBBED) called");
26} 26}
27 27
28SET::SET() : ServiceFramework("set") { 28SET::SET() : ServiceFramework("set") {
diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp
index fa85277fe..762a664c5 100644
--- a/src/core/hle/service/set/set_sys.cpp
+++ b/src/core/hle/service/set/set_sys.cpp
@@ -16,7 +16,7 @@ void SET_SYS::GetColorSetId(Kernel::HLERequestContext& ctx) {
16 rb.Push(RESULT_SUCCESS); 16 rb.Push(RESULT_SUCCESS);
17 rb.Push<u32>(0); 17 rb.Push<u32>(0);
18 18
19 LOG_WARNING(Service_SET, "(STUBBED) called"); 19 NGLOG_WARNING(Service_SET, "(STUBBED) called");
20} 20}
21 21
22SET_SYS::SET_SYS() : ServiceFramework("set:sys") { 22SET_SYS::SET_SYS() : ServiceFramework("set:sys") {
diff --git a/src/core/hle/service/sm/controller.cpp b/src/core/hle/service/sm/controller.cpp
index 13e31620d..fe5097cdc 100644
--- a/src/core/hle/service/sm/controller.cpp
+++ b/src/core/hle/service/sm/controller.cpp
@@ -17,7 +17,7 @@ void Controller::ConvertSessionToDomain(Kernel::HLERequestContext& ctx) {
17 rb.Push(RESULT_SUCCESS); 17 rb.Push(RESULT_SUCCESS);
18 rb.Push<u32>(1); // Converted sessions start with 1 request handler 18 rb.Push<u32>(1); // Converted sessions start with 1 request handler
19 19
20 LOG_DEBUG(Service, "called, server_session=%d", ctx.Session()->GetObjectId()); 20 NGLOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetObjectId());
21} 21}
22 22
23void Controller::DuplicateSession(Kernel::HLERequestContext& ctx) { 23void Controller::DuplicateSession(Kernel::HLERequestContext& ctx) {
@@ -29,11 +29,11 @@ void Controller::DuplicateSession(Kernel::HLERequestContext& ctx) {
29 Kernel::SharedPtr<Kernel::ClientSession> session{ctx.Session()->parent->client}; 29 Kernel::SharedPtr<Kernel::ClientSession> session{ctx.Session()->parent->client};
30 rb.PushMoveObjects(session); 30 rb.PushMoveObjects(session);
31 31
32 LOG_DEBUG(Service, "called, session=%u", session->GetObjectId()); 32 NGLOG_DEBUG(Service, "called, session={}", session->GetObjectId());
33} 33}
34 34
35void Controller::DuplicateSessionEx(Kernel::HLERequestContext& ctx) { 35void Controller::DuplicateSessionEx(Kernel::HLERequestContext& ctx) {
36 LOG_WARNING(Service, "(STUBBED) called, using DuplicateSession"); 36 NGLOG_WARNING(Service, "(STUBBED) called, using DuplicateSession");
37 37
38 DuplicateSession(ctx); 38 DuplicateSession(ctx);
39} 39}
@@ -43,7 +43,7 @@ void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) {
43 rb.Push(RESULT_SUCCESS); 43 rb.Push(RESULT_SUCCESS);
44 rb.Push<u32>(0x500); 44 rb.Push<u32>(0x500);
45 45
46 LOG_WARNING(Service, "(STUBBED) called"); 46 NGLOG_WARNING(Service, "(STUBBED) called");
47} 47}
48 48
49Controller::Controller() : ServiceFramework("IpcController") { 49Controller::Controller() : ServiceFramework("IpcController") {
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index 4578fc05f..073277ade 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -86,7 +86,7 @@ SM::~SM() = default;
86void SM::Initialize(Kernel::HLERequestContext& ctx) { 86void SM::Initialize(Kernel::HLERequestContext& ctx) {
87 IPC::ResponseBuilder rb{ctx, 2}; 87 IPC::ResponseBuilder rb{ctx, 2};
88 rb.Push(RESULT_SUCCESS); 88 rb.Push(RESULT_SUCCESS);
89 LOG_DEBUG(Service_SM, "called"); 89 NGLOG_DEBUG(Service_SM, "called");
90} 90}
91 91
92void SM::GetService(Kernel::HLERequestContext& ctx) { 92void SM::GetService(Kernel::HLERequestContext& ctx) {
@@ -102,8 +102,8 @@ void SM::GetService(Kernel::HLERequestContext& ctx) {
102 if (client_port.Failed()) { 102 if (client_port.Failed()) {
103 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0); 103 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
104 rb.Push(client_port.Code()); 104 rb.Push(client_port.Code());
105 LOG_ERROR(Service_SM, "called service=%s -> error 0x%08X", name.c_str(), 105 NGLOG_ERROR(Service_SM, "called service={} -> error {:#010X}", name,
106 client_port.Code().raw); 106 client_port.Code().raw);
107 if (name.length() == 0) 107 if (name.length() == 0)
108 return; // LibNX Fix 108 return; // LibNX Fix
109 UNIMPLEMENTED(); 109 UNIMPLEMENTED();
@@ -113,8 +113,7 @@ void SM::GetService(Kernel::HLERequestContext& ctx) {
113 auto session = client_port.Unwrap()->Connect(); 113 auto session = client_port.Unwrap()->Connect();
114 ASSERT(session.Succeeded()); 114 ASSERT(session.Succeeded());
115 if (session.Succeeded()) { 115 if (session.Succeeded()) {
116 LOG_DEBUG(Service_SM, "called service=%s -> session=%u", name.c_str(), 116 NGLOG_DEBUG(Service_SM, "called service={} -> session={}", name, (*session)->GetObjectId());
117 (*session)->GetObjectId());
118 IPC::ResponseBuilder rb = 117 IPC::ResponseBuilder rb =
119 rp.MakeBuilder(2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles); 118 rp.MakeBuilder(2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles);
120 rb.Push(session.Code()); 119 rb.Push(session.Code());
diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp
index f99809bed..ab909fdaa 100644
--- a/src/core/hle/service/sockets/bsd.cpp
+++ b/src/core/hle/service/sockets/bsd.cpp
@@ -8,7 +8,7 @@
8namespace Service::Sockets { 8namespace Service::Sockets {
9 9
10void BSD::RegisterClient(Kernel::HLERequestContext& ctx) { 10void BSD::RegisterClient(Kernel::HLERequestContext& ctx) {
11 LOG_WARNING(Service, "(STUBBED) called"); 11 NGLOG_WARNING(Service, "(STUBBED) called");
12 12
13 IPC::ResponseBuilder rb{ctx, 3}; 13 IPC::ResponseBuilder rb{ctx, 3};
14 14
@@ -17,7 +17,7 @@ void BSD::RegisterClient(Kernel::HLERequestContext& ctx) {
17} 17}
18 18
19void BSD::StartMonitoring(Kernel::HLERequestContext& ctx) { 19void BSD::StartMonitoring(Kernel::HLERequestContext& ctx) {
20 LOG_WARNING(Service, "(STUBBED) called"); 20 NGLOG_WARNING(Service, "(STUBBED) called");
21 21
22 IPC::ResponseBuilder rb{ctx, 3}; 22 IPC::ResponseBuilder rb{ctx, 3};
23 23
@@ -32,7 +32,8 @@ void BSD::Socket(Kernel::HLERequestContext& ctx) {
32 u32 type = rp.Pop<u32>(); 32 u32 type = rp.Pop<u32>();
33 u32 protocol = rp.Pop<u32>(); 33 u32 protocol = rp.Pop<u32>();
34 34
35 LOG_WARNING(Service, "(STUBBED) called domain=%u type=%u protocol=%u", domain, type, protocol); 35 NGLOG_WARNING(Service, "(STUBBED) called domain={} type={} protocol={}", domain, type,
36 protocol);
36 37
37 u32 fd = next_fd++; 38 u32 fd = next_fd++;
38 39
@@ -44,7 +45,7 @@ void BSD::Socket(Kernel::HLERequestContext& ctx) {
44} 45}
45 46
46void BSD::Connect(Kernel::HLERequestContext& ctx) { 47void BSD::Connect(Kernel::HLERequestContext& ctx) {
47 LOG_WARNING(Service, "(STUBBED) called"); 48 NGLOG_WARNING(Service, "(STUBBED) called");
48 49
49 IPC::ResponseBuilder rb{ctx, 4}; 50 IPC::ResponseBuilder rb{ctx, 4};
50 51
@@ -54,7 +55,7 @@ void BSD::Connect(Kernel::HLERequestContext& ctx) {
54} 55}
55 56
56void BSD::SendTo(Kernel::HLERequestContext& ctx) { 57void BSD::SendTo(Kernel::HLERequestContext& ctx) {
57 LOG_WARNING(Service, "(STUBBED) called"); 58 NGLOG_WARNING(Service, "(STUBBED) called");
58 59
59 IPC::ResponseBuilder rb{ctx, 4}; 60 IPC::ResponseBuilder rb{ctx, 4};
60 61
@@ -64,7 +65,7 @@ void BSD::SendTo(Kernel::HLERequestContext& ctx) {
64} 65}
65 66
66void BSD::Close(Kernel::HLERequestContext& ctx) { 67void BSD::Close(Kernel::HLERequestContext& ctx) {
67 LOG_WARNING(Service, "(STUBBED) called"); 68 NGLOG_WARNING(Service, "(STUBBED) called");
68 69
69 IPC::ResponseBuilder rb{ctx, 4}; 70 IPC::ResponseBuilder rb{ctx, 4};
70 71
diff --git a/src/core/hle/service/sockets/sfdnsres.cpp b/src/core/hle/service/sockets/sfdnsres.cpp
index d235c4cfd..f377e59f2 100644
--- a/src/core/hle/service/sockets/sfdnsres.cpp
+++ b/src/core/hle/service/sockets/sfdnsres.cpp
@@ -10,7 +10,7 @@ namespace Service::Sockets {
10void SFDNSRES::GetAddrInfo(Kernel::HLERequestContext& ctx) { 10void SFDNSRES::GetAddrInfo(Kernel::HLERequestContext& ctx) {
11 IPC::RequestParser rp{ctx}; 11 IPC::RequestParser rp{ctx};
12 12
13 LOG_WARNING(Service, "(STUBBED) called"); 13 NGLOG_WARNING(Service, "(STUBBED) called");
14 14
15 IPC::ResponseBuilder rb{ctx, 2}; 15 IPC::ResponseBuilder rb{ctx, 2};
16 16
diff --git a/src/core/hle/service/spl/module.cpp b/src/core/hle/service/spl/module.cpp
index 3f5a342a7..76ba97156 100644
--- a/src/core/hle/service/spl/module.cpp
+++ b/src/core/hle/service/spl/module.cpp
@@ -28,7 +28,7 @@ void Module::Interface::GetRandomBytes(Kernel::HLERequestContext& ctx) {
28 28
29 IPC::ResponseBuilder rb{ctx, 2}; 29 IPC::ResponseBuilder rb{ctx, 2};
30 rb.Push(RESULT_SUCCESS); 30 rb.Push(RESULT_SUCCESS);
31 LOG_DEBUG(Service_SPL, "called"); 31 NGLOG_DEBUG(Service_SPL, "called");
32} 32}
33 33
34void InstallInterfaces(SM::ServiceManager& service_manager) { 34void InstallInterfaces(SM::ServiceManager& service_manager) {
diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp
index 11d438728..c7788da5c 100644
--- a/src/core/hle/service/ssl/ssl.cpp
+++ b/src/core/hle/service/ssl/ssl.cpp
@@ -65,7 +65,7 @@ public:
65 65
66private: 66private:
67 void SetOption(Kernel::HLERequestContext& ctx) { 67 void SetOption(Kernel::HLERequestContext& ctx) {
68 LOG_WARNING(Service_SSL, "(STUBBED) called"); 68 NGLOG_WARNING(Service_SSL, "(STUBBED) called");
69 IPC::RequestParser rp{ctx}; 69 IPC::RequestParser rp{ctx};
70 70
71 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0); 71 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
@@ -73,7 +73,7 @@ private:
73 } 73 }
74 74
75 void CreateConnection(Kernel::HLERequestContext& ctx) { 75 void CreateConnection(Kernel::HLERequestContext& ctx) {
76 LOG_WARNING(Service_SSL, "(STUBBED) called"); 76 NGLOG_WARNING(Service_SSL, "(STUBBED) called");
77 77
78 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 78 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
79 rb.Push(RESULT_SUCCESS); 79 rb.Push(RESULT_SUCCESS);
@@ -82,7 +82,7 @@ private:
82}; 82};
83 83
84void SSL::CreateContext(Kernel::HLERequestContext& ctx) { 84void SSL::CreateContext(Kernel::HLERequestContext& ctx) {
85 LOG_WARNING(Service_SSL, "(STUBBED) called"); 85 NGLOG_WARNING(Service_SSL, "(STUBBED) called");
86 86
87 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 87 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
88 rb.Push(RESULT_SUCCESS); 88 rb.Push(RESULT_SUCCESS);
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index 2604ecc1c..278465358 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -32,14 +32,14 @@ private:
32 const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>( 32 const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>(
33 std::chrono::system_clock::now().time_since_epoch()) 33 std::chrono::system_clock::now().time_since_epoch())
34 .count()}; 34 .count()};
35 LOG_DEBUG(Service_Time, "called"); 35 NGLOG_DEBUG(Service_Time, "called");
36 IPC::ResponseBuilder rb{ctx, 4}; 36 IPC::ResponseBuilder rb{ctx, 4};
37 rb.Push(RESULT_SUCCESS); 37 rb.Push(RESULT_SUCCESS);
38 rb.Push<u64>(time_since_epoch); 38 rb.Push<u64>(time_since_epoch);
39 } 39 }
40 40
41 void GetSystemClockContext(Kernel::HLERequestContext& ctx) { 41 void GetSystemClockContext(Kernel::HLERequestContext& ctx) {
42 LOG_WARNING(Service_Time, "(STUBBED) called"); 42 NGLOG_WARNING(Service_Time, "(STUBBED) called");
43 SystemClockContext system_clock_ontext{}; 43 SystemClockContext system_clock_ontext{};
44 IPC::ResponseBuilder rb{ctx, (sizeof(SystemClockContext) / 4) + 2}; 44 IPC::ResponseBuilder rb{ctx, (sizeof(SystemClockContext) / 4) + 2};
45 rb.Push(RESULT_SUCCESS); 45 rb.Push(RESULT_SUCCESS);
@@ -58,7 +58,7 @@ public:
58 58
59private: 59private:
60 void GetCurrentTimePoint(Kernel::HLERequestContext& ctx) { 60 void GetCurrentTimePoint(Kernel::HLERequestContext& ctx) {
61 LOG_DEBUG(Service_Time, "called"); 61 NGLOG_DEBUG(Service_Time, "called");
62 SteadyClockTimePoint steady_clock_time_point{cyclesToMs(CoreTiming::GetTicks()) / 1000}; 62 SteadyClockTimePoint steady_clock_time_point{cyclesToMs(CoreTiming::GetTicks()) / 1000};
63 IPC::ResponseBuilder rb{ctx, (sizeof(SteadyClockTimePoint) / 4) + 2}; 63 IPC::ResponseBuilder rb{ctx, (sizeof(SteadyClockTimePoint) / 4) + 2};
64 rb.Push(RESULT_SUCCESS); 64 rb.Push(RESULT_SUCCESS);
@@ -86,7 +86,7 @@ public:
86 86
87private: 87private:
88 void GetDeviceLocationName(Kernel::HLERequestContext& ctx) { 88 void GetDeviceLocationName(Kernel::HLERequestContext& ctx) {
89 LOG_WARNING(Service_Time, "(STUBBED) called"); 89 NGLOG_WARNING(Service_Time, "(STUBBED) called");
90 LocationName location_name{}; 90 LocationName location_name{};
91 IPC::ResponseBuilder rb{ctx, (sizeof(LocationName) / 4) + 2}; 91 IPC::ResponseBuilder rb{ctx, (sizeof(LocationName) / 4) + 2};
92 rb.Push(RESULT_SUCCESS); 92 rb.Push(RESULT_SUCCESS);
@@ -94,14 +94,14 @@ private:
94 } 94 }
95 95
96 void GetTotalLocationNameCount(Kernel::HLERequestContext& ctx) { 96 void GetTotalLocationNameCount(Kernel::HLERequestContext& ctx) {
97 LOG_WARNING(Service_Time, "(STUBBED) called"); 97 NGLOG_WARNING(Service_Time, "(STUBBED) called");
98 IPC::ResponseBuilder rb{ctx, 3}; 98 IPC::ResponseBuilder rb{ctx, 3};
99 rb.Push(RESULT_SUCCESS); 99 rb.Push(RESULT_SUCCESS);
100 rb.Push<u32>(0); 100 rb.Push<u32>(0);
101 } 101 }
102 102
103 void LoadTimeZoneRule(Kernel::HLERequestContext& ctx) { 103 void LoadTimeZoneRule(Kernel::HLERequestContext& ctx) {
104 LOG_WARNING(Service_Time, "(STUBBED) called"); 104 NGLOG_WARNING(Service_Time, "(STUBBED) called");
105 IPC::ResponseBuilder rb{ctx, 2}; 105 IPC::ResponseBuilder rb{ctx, 2};
106 rb.Push(RESULT_SUCCESS); 106 rb.Push(RESULT_SUCCESS);
107 } 107 }
@@ -110,7 +110,7 @@ private:
110 IPC::RequestParser rp{ctx}; 110 IPC::RequestParser rp{ctx};
111 u64 posix_time = rp.Pop<u64>(); 111 u64 posix_time = rp.Pop<u64>();
112 112
113 LOG_WARNING(Service_Time, "(STUBBED) called, posix_time=0x%016lX", posix_time); 113 NGLOG_WARNING(Service_Time, "(STUBBED) called, posix_time={:#018X}", posix_time);
114 114
115 CalendarTime calendar_time{2018, 1, 1, 0, 0, 0}; 115 CalendarTime calendar_time{2018, 1, 1, 0, 0, 0};
116 CalendarAdditionalInfo additional_info{}; 116 CalendarAdditionalInfo additional_info{};
@@ -125,35 +125,35 @@ void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ct
125 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 125 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
126 rb.Push(RESULT_SUCCESS); 126 rb.Push(RESULT_SUCCESS);
127 rb.PushIpcInterface<ISystemClock>(); 127 rb.PushIpcInterface<ISystemClock>();
128 LOG_DEBUG(Service_Time, "called"); 128 NGLOG_DEBUG(Service_Time, "called");
129} 129}
130 130
131void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) { 131void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
132 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 132 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
133 rb.Push(RESULT_SUCCESS); 133 rb.Push(RESULT_SUCCESS);
134 rb.PushIpcInterface<ISystemClock>(); 134 rb.PushIpcInterface<ISystemClock>();
135 LOG_DEBUG(Service_Time, "called"); 135 NGLOG_DEBUG(Service_Time, "called");
136} 136}
137 137
138void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) { 138void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
139 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 139 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
140 rb.Push(RESULT_SUCCESS); 140 rb.Push(RESULT_SUCCESS);
141 rb.PushIpcInterface<ISteadyClock>(); 141 rb.PushIpcInterface<ISteadyClock>();
142 LOG_DEBUG(Service_Time, "called"); 142 NGLOG_DEBUG(Service_Time, "called");
143} 143}
144 144
145void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) { 145void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {
146 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 146 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
147 rb.Push(RESULT_SUCCESS); 147 rb.Push(RESULT_SUCCESS);
148 rb.PushIpcInterface<ITimeZoneService>(); 148 rb.PushIpcInterface<ITimeZoneService>();
149 LOG_DEBUG(Service_Time, "called"); 149 NGLOG_DEBUG(Service_Time, "called");
150} 150}
151 151
152void Module::Interface::GetStandardLocalSystemClock(Kernel::HLERequestContext& ctx) { 152void Module::Interface::GetStandardLocalSystemClock(Kernel::HLERequestContext& ctx) {
153 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 153 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
154 rb.Push(RESULT_SUCCESS); 154 rb.Push(RESULT_SUCCESS);
155 rb.PushIpcInterface<ISystemClock>(); 155 rb.PushIpcInterface<ISystemClock>();
156 LOG_DEBUG(Service_Time, "called"); 156 NGLOG_DEBUG(Service_Time, "called");
157} 157}
158 158
159Module::Interface::Interface(std::shared_ptr<Module> time, const char* name) 159Module::Interface::Interface(std::shared_ptr<Module> time, const char* name)
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 36ae2215f..45f3568d2 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -470,7 +470,7 @@ private:
470 u32 flags = rp.Pop<u32>(); 470 u32 flags = rp.Pop<u32>();
471 auto buffer_queue = nv_flinger->GetBufferQueue(id); 471 auto buffer_queue = nv_flinger->GetBufferQueue(id);
472 472
473 LOG_DEBUG(Service_VI, "called, transaction=%x", static_cast<u32>(transaction)); 473 NGLOG_DEBUG(Service_VI, "called, transaction={:X}", static_cast<u32>(transaction));
474 474
475 if (transaction == TransactionId::Connect) { 475 if (transaction == TransactionId::Connect) {
476 IGBPConnectRequestParcel request{ctx.ReadBuffer()}; 476 IGBPConnectRequestParcel request{ctx.ReadBuffer()};
@@ -532,7 +532,7 @@ private:
532 IGBPQueryResponseParcel response{value}; 532 IGBPQueryResponseParcel response{value};
533 ctx.WriteBuffer(response.Serialize()); 533 ctx.WriteBuffer(response.Serialize());
534 } else if (transaction == TransactionId::CancelBuffer) { 534 } else if (transaction == TransactionId::CancelBuffer) {
535 LOG_WARNING(Service_VI, "(STUBBED) called, transaction=CancelBuffer"); 535 NGLOG_WARNING(Service_VI, "(STUBBED) called, transaction=CancelBuffer");
536 } else { 536 } else {
537 ASSERT_MSG(false, "Unimplemented"); 537 ASSERT_MSG(false, "Unimplemented");
538 } 538 }
@@ -547,7 +547,8 @@ private:
547 s32 addval = rp.PopRaw<s32>(); 547 s32 addval = rp.PopRaw<s32>();
548 u32 type = rp.Pop<u32>(); 548 u32 type = rp.Pop<u32>();
549 549
550 LOG_WARNING(Service_VI, "(STUBBED) called id=%u, addval=%08X, type=%08X", id, addval, type); 550 NGLOG_WARNING(Service_VI, "(STUBBED) called id={}, addval={:08X}, type={:08X}", id, addval,
551 type);
551 IPC::ResponseBuilder rb{ctx, 2}; 552 IPC::ResponseBuilder rb{ctx, 2};
552 rb.Push(RESULT_SUCCESS); 553 rb.Push(RESULT_SUCCESS);
553 } 554 }
@@ -561,7 +562,7 @@ private:
561 562
562 // TODO(Subv): Find out what this actually is. 563 // TODO(Subv): Find out what this actually is.
563 564
564 LOG_WARNING(Service_VI, "(STUBBED) called id=%u, unknown=%08X", id, unknown); 565 NGLOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown);
565 IPC::ResponseBuilder rb{ctx, 2, 1}; 566 IPC::ResponseBuilder rb{ctx, 2, 1};
566 rb.Push(RESULT_SUCCESS); 567 rb.Push(RESULT_SUCCESS);
567 rb.PushCopyObjects(buffer_queue->GetNativeHandle()); 568 rb.PushCopyObjects(buffer_queue->GetNativeHandle());
@@ -624,7 +625,7 @@ public:
624 625
625private: 626private:
626 void SetLayerZ(Kernel::HLERequestContext& ctx) { 627 void SetLayerZ(Kernel::HLERequestContext& ctx) {
627 LOG_WARNING(Service_VI, "(STUBBED) called"); 628 NGLOG_WARNING(Service_VI, "(STUBBED) called");
628 IPC::RequestParser rp{ctx}; 629 IPC::RequestParser rp{ctx};
629 u64 layer_id = rp.Pop<u64>(); 630 u64 layer_id = rp.Pop<u64>();
630 u64 z_value = rp.Pop<u64>(); 631 u64 z_value = rp.Pop<u64>();
@@ -639,8 +640,8 @@ private:
639 bool visibility = rp.Pop<bool>(); 640 bool visibility = rp.Pop<bool>();
640 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0); 641 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
641 rb.Push(RESULT_SUCCESS); 642 rb.Push(RESULT_SUCCESS);
642 LOG_WARNING(Service_VI, "(STUBBED) called, layer_id=0x%x, visibility=%u", layer_id, 643 NGLOG_WARNING(Service_VI, "(STUBBED) called, layer_id={:#010X}, visibility={}", layer_id,
643 visibility); 644 visibility);
644 } 645 }
645}; 646};
646 647
@@ -722,7 +723,7 @@ public:
722 723
723private: 724private:
724 void CloseDisplay(Kernel::HLERequestContext& ctx) { 725 void CloseDisplay(Kernel::HLERequestContext& ctx) {
725 LOG_WARNING(Service_VI, "(STUBBED) called"); 726 NGLOG_WARNING(Service_VI, "(STUBBED) called");
726 IPC::RequestParser rp{ctx}; 727 IPC::RequestParser rp{ctx};
727 u64 display = rp.Pop<u64>(); 728 u64 display = rp.Pop<u64>();
728 729
@@ -731,7 +732,7 @@ private:
731 } 732 }
732 733
733 void CreateManagedLayer(Kernel::HLERequestContext& ctx) { 734 void CreateManagedLayer(Kernel::HLERequestContext& ctx) {
734 LOG_WARNING(Service_VI, "(STUBBED) called"); 735 NGLOG_WARNING(Service_VI, "(STUBBED) called");
735 IPC::RequestParser rp{ctx}; 736 IPC::RequestParser rp{ctx};
736 u32 unknown = rp.Pop<u32>(); 737 u32 unknown = rp.Pop<u32>();
737 rp.Skip(1, false); 738 rp.Skip(1, false);
@@ -746,7 +747,7 @@ private:
746 } 747 }
747 748
748 void AddToLayerStack(Kernel::HLERequestContext& ctx) { 749 void AddToLayerStack(Kernel::HLERequestContext& ctx) {
749 LOG_WARNING(Service_VI, "(STUBBED) called"); 750 NGLOG_WARNING(Service_VI, "(STUBBED) called");
750 IPC::RequestParser rp{ctx}; 751 IPC::RequestParser rp{ctx};
751 u32 stack = rp.Pop<u32>(); 752 u32 stack = rp.Pop<u32>();
752 u64 layer_id = rp.Pop<u64>(); 753 u64 layer_id = rp.Pop<u64>();
@@ -761,8 +762,8 @@ private:
761 bool visibility = rp.Pop<bool>(); 762 bool visibility = rp.Pop<bool>();
762 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0); 763 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
763 rb.Push(RESULT_SUCCESS); 764 rb.Push(RESULT_SUCCESS);
764 LOG_WARNING(Service_VI, "(STUBBED) called, layer_id=0x%x, visibility=%u", layer_id, 765 NGLOG_WARNING(Service_VI, "(STUBBED) called, layer_id={:#X}, visibility={}", layer_id,
765 visibility); 766 visibility);
766 } 767 }
767 768
768 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger; 769 std::shared_ptr<NVFlinger::NVFlinger> nv_flinger;
@@ -775,7 +776,7 @@ public:
775 776
776private: 777private:
777 void GetRelayService(Kernel::HLERequestContext& ctx) { 778 void GetRelayService(Kernel::HLERequestContext& ctx) {
778 LOG_WARNING(Service_VI, "(STUBBED) called"); 779 NGLOG_WARNING(Service_VI, "(STUBBED) called");
779 780
780 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 781 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
781 rb.Push(RESULT_SUCCESS); 782 rb.Push(RESULT_SUCCESS);
@@ -783,7 +784,7 @@ private:
783 } 784 }
784 785
785 void GetSystemDisplayService(Kernel::HLERequestContext& ctx) { 786 void GetSystemDisplayService(Kernel::HLERequestContext& ctx) {
786 LOG_WARNING(Service_VI, "(STUBBED) called"); 787 NGLOG_WARNING(Service_VI, "(STUBBED) called");
787 788
788 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 789 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
789 rb.Push(RESULT_SUCCESS); 790 rb.Push(RESULT_SUCCESS);
@@ -791,7 +792,7 @@ private:
791 } 792 }
792 793
793 void GetManagerDisplayService(Kernel::HLERequestContext& ctx) { 794 void GetManagerDisplayService(Kernel::HLERequestContext& ctx) {
794 LOG_WARNING(Service_VI, "(STUBBED) called"); 795 NGLOG_WARNING(Service_VI, "(STUBBED) called");
795 796
796 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 797 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
797 rb.Push(RESULT_SUCCESS); 798 rb.Push(RESULT_SUCCESS);
@@ -799,7 +800,7 @@ private:
799 } 800 }
800 801
801 void GetIndirectDisplayTransactionService(Kernel::HLERequestContext& ctx) { 802 void GetIndirectDisplayTransactionService(Kernel::HLERequestContext& ctx) {
802 LOG_WARNING(Service_VI, "(STUBBED) called"); 803 NGLOG_WARNING(Service_VI, "(STUBBED) called");
803 804
804 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 805 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
805 rb.Push(RESULT_SUCCESS); 806 rb.Push(RESULT_SUCCESS);
@@ -807,7 +808,7 @@ private:
807 } 808 }
808 809
809 void OpenDisplay(Kernel::HLERequestContext& ctx) { 810 void OpenDisplay(Kernel::HLERequestContext& ctx) {
810 LOG_WARNING(Service_VI, "(STUBBED) called"); 811 NGLOG_WARNING(Service_VI, "(STUBBED) called");
811 IPC::RequestParser rp{ctx}; 812 IPC::RequestParser rp{ctx};
812 auto name_buf = rp.PopRaw<std::array<u8, 0x40>>(); 813 auto name_buf = rp.PopRaw<std::array<u8, 0x40>>();
813 auto end = std::find(name_buf.begin(), name_buf.end(), '\0'); 814 auto end = std::find(name_buf.begin(), name_buf.end(), '\0');
@@ -822,7 +823,7 @@ private:
822 } 823 }
823 824
824 void CloseDisplay(Kernel::HLERequestContext& ctx) { 825 void CloseDisplay(Kernel::HLERequestContext& ctx) {
825 LOG_WARNING(Service_VI, "(STUBBED) called"); 826 NGLOG_WARNING(Service_VI, "(STUBBED) called");
826 IPC::RequestParser rp{ctx}; 827 IPC::RequestParser rp{ctx};
827 u64 display_id = rp.Pop<u64>(); 828 u64 display_id = rp.Pop<u64>();
828 829
@@ -831,7 +832,7 @@ private:
831 } 832 }
832 833
833 void GetDisplayResolution(Kernel::HLERequestContext& ctx) { 834 void GetDisplayResolution(Kernel::HLERequestContext& ctx) {
834 LOG_WARNING(Service_VI, "(STUBBED) called"); 835 NGLOG_WARNING(Service_VI, "(STUBBED) called");
835 IPC::RequestParser rp{ctx}; 836 IPC::RequestParser rp{ctx};
836 u64 display_id = rp.Pop<u64>(); 837 u64 display_id = rp.Pop<u64>();
837 838
@@ -848,7 +849,7 @@ private:
848 } 849 }
849 850
850 void SetLayerScalingMode(Kernel::HLERequestContext& ctx) { 851 void SetLayerScalingMode(Kernel::HLERequestContext& ctx) {
851 LOG_WARNING(Service_VI, "(STUBBED) called"); 852 NGLOG_WARNING(Service_VI, "(STUBBED) called");
852 IPC::RequestParser rp{ctx}; 853 IPC::RequestParser rp{ctx};
853 u32 scaling_mode = rp.Pop<u32>(); 854 u32 scaling_mode = rp.Pop<u32>();
854 u64 unknown = rp.Pop<u64>(); 855 u64 unknown = rp.Pop<u64>();
@@ -864,11 +865,11 @@ private:
864 IPC::ResponseBuilder rb = rp.MakeBuilder(4, 0, 0); 865 IPC::ResponseBuilder rb = rp.MakeBuilder(4, 0, 0);
865 rb.Push(RESULT_SUCCESS); 866 rb.Push(RESULT_SUCCESS);
866 rb.Push<u64>(1); 867 rb.Push<u64>(1);
867 LOG_WARNING(Service_VI, "(STUBBED) called"); 868 NGLOG_WARNING(Service_VI, "(STUBBED) called");
868 } 869 }
869 870
870 void OpenLayer(Kernel::HLERequestContext& ctx) { 871 void OpenLayer(Kernel::HLERequestContext& ctx) {
871 LOG_DEBUG(Service_VI, "called"); 872 NGLOG_DEBUG(Service_VI, "called");
872 IPC::RequestParser rp{ctx}; 873 IPC::RequestParser rp{ctx};
873 auto name_buf = rp.PopRaw<std::array<u8, 0x40>>(); 874 auto name_buf = rp.PopRaw<std::array<u8, 0x40>>();
874 auto end = std::find(name_buf.begin(), name_buf.end(), '\0'); 875 auto end = std::find(name_buf.begin(), name_buf.end(), '\0');
@@ -888,7 +889,7 @@ private:
888 } 889 }
889 890
890 void CreateStrayLayer(Kernel::HLERequestContext& ctx) { 891 void CreateStrayLayer(Kernel::HLERequestContext& ctx) {
891 LOG_DEBUG(Service_VI, "called"); 892 NGLOG_DEBUG(Service_VI, "called");
892 893
893 IPC::RequestParser rp{ctx}; 894 IPC::RequestParser rp{ctx};
894 u32 flags = rp.Pop<u32>(); 895 u32 flags = rp.Pop<u32>();
@@ -908,7 +909,7 @@ private:
908 } 909 }
909 910
910 void DestroyStrayLayer(Kernel::HLERequestContext& ctx) { 911 void DestroyStrayLayer(Kernel::HLERequestContext& ctx) {
911 LOG_WARNING(Service_VI, "(STUBBED) called"); 912 NGLOG_WARNING(Service_VI, "(STUBBED) called");
912 913
913 IPC::RequestParser rp{ctx}; 914 IPC::RequestParser rp{ctx};
914 u64 layer_id = rp.Pop<u64>(); 915 u64 layer_id = rp.Pop<u64>();
@@ -918,7 +919,7 @@ private:
918 } 919 }
919 920
920 void GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx) { 921 void GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx) {
921 LOG_WARNING(Service_VI, "(STUBBED) called"); 922 NGLOG_WARNING(Service_VI, "(STUBBED) called");
922 IPC::RequestParser rp{ctx}; 923 IPC::RequestParser rp{ctx};
923 u64 display_id = rp.Pop<u64>(); 924 u64 display_id = rp.Pop<u64>();
924 925
@@ -967,7 +968,7 @@ Module::Interface::Interface(std::shared_ptr<Module> module, const char* name,
967 : ServiceFramework(name), module(std::move(module)), nv_flinger(std::move(nv_flinger)) {} 968 : ServiceFramework(name), module(std::move(module)), nv_flinger(std::move(nv_flinger)) {}
968 969
969void Module::Interface::GetDisplayService(Kernel::HLERequestContext& ctx) { 970void Module::Interface::GetDisplayService(Kernel::HLERequestContext& ctx) {
970 LOG_WARNING(Service_VI, "(STUBBED) called"); 971 NGLOG_WARNING(Service_VI, "(STUBBED) called");
971 972
972 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 973 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
973 rb.Push(RESULT_SUCCESS); 974 rb.Push(RESULT_SUCCESS);
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp
index b5133e4d6..3853cfa1a 100644
--- a/src/core/loader/nro.cpp
+++ b/src/core/loader/nro.cpp
@@ -137,7 +137,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
137 process->address_mappings = default_address_mappings; 137 process->address_mappings = default_address_mappings;
138 process->resource_limit = 138 process->resource_limit =
139 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); 139 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
140 process->Run(base_addr, 48, Memory::DEFAULT_STACK_SIZE); 140 process->Run(base_addr, THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE);
141 141
142 is_loaded = true; 142 is_loaded = true;
143 return ResultStatus::Success; 143 return ResultStatus::Success;
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 3bc10ed0d..962bed2ab 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -165,7 +165,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
165 process->address_mappings = default_address_mappings; 165 process->address_mappings = default_address_mappings;
166 process->resource_limit = 166 process->resource_limit =
167 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); 167 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
168 process->Run(Memory::PROCESS_IMAGE_VADDR, 48, Memory::DEFAULT_STACK_SIZE); 168 process->Run(Memory::PROCESS_IMAGE_VADDR, THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE);
169 169
170 is_loaded = true; 170 is_loaded = true;
171 return ResultStatus::Success; 171 return ResultStatus::Success;
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 5ee581acf..a022665eb 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -526,6 +526,11 @@ public:
526 return static_cast<GPUVAddr>((static_cast<GPUVAddr>(start_high) << 32) | 526 return static_cast<GPUVAddr>((static_cast<GPUVAddr>(start_high) << 32) |
527 start_low); 527 start_low);
528 } 528 }
529
530 bool IsEnabled() const {
531 return enable != 0 && StartAddress() != 0;
532 }
533
529 } vertex_array[NumVertexArrays]; 534 } vertex_array[NumVertexArrays];
530 535
531 Blend blend; 536 Blend blend;
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp
index 2789a4ca1..2e1edee03 100644
--- a/src/video_core/memory_manager.cpp
+++ b/src/video_core/memory_manager.cpp
@@ -2,6 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/alignment.h"
5#include "common/assert.h" 6#include "common/assert.h"
6#include "video_core/memory_manager.h" 7#include "video_core/memory_manager.h"
7 8
@@ -11,7 +12,8 @@ PAddr MemoryManager::AllocateSpace(u64 size, u64 align) {
11 boost::optional<PAddr> paddr = FindFreeBlock(size, align); 12 boost::optional<PAddr> paddr = FindFreeBlock(size, align);
12 ASSERT(paddr); 13 ASSERT(paddr);
13 14
14 for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) { 15 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) {
16 ASSERT(PageSlot(*paddr + offset) == static_cast<u64>(PageStatus::Unmapped));
15 PageSlot(*paddr + offset) = static_cast<u64>(PageStatus::Allocated); 17 PageSlot(*paddr + offset) = static_cast<u64>(PageStatus::Allocated);
16 } 18 }
17 19
@@ -19,13 +21,8 @@ PAddr MemoryManager::AllocateSpace(u64 size, u64 align) {
19} 21}
20 22
21PAddr MemoryManager::AllocateSpace(PAddr paddr, u64 size, u64 align) { 23PAddr MemoryManager::AllocateSpace(PAddr paddr, u64 size, u64 align) {
22 for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) { 24 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) {
23 if (IsPageMapped(paddr + offset)) { 25 ASSERT(PageSlot(paddr + offset) == static_cast<u64>(PageStatus::Unmapped));
24 return AllocateSpace(size, align);
25 }
26 }
27
28 for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) {
29 PageSlot(paddr + offset) = static_cast<u64>(PageStatus::Allocated); 26 PageSlot(paddr + offset) = static_cast<u64>(PageStatus::Allocated);
30 } 27 }
31 28
@@ -33,12 +30,11 @@ PAddr MemoryManager::AllocateSpace(PAddr paddr, u64 size, u64 align) {
33} 30}
34 31
35PAddr MemoryManager::MapBufferEx(VAddr vaddr, u64 size) { 32PAddr MemoryManager::MapBufferEx(VAddr vaddr, u64 size) {
36 vaddr &= ~Memory::PAGE_MASK; 33 boost::optional<PAddr> paddr = FindFreeBlock(size, PAGE_SIZE);
37
38 boost::optional<PAddr> paddr = FindFreeBlock(size);
39 ASSERT(paddr); 34 ASSERT(paddr);
40 35
41 for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) { 36 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) {
37 ASSERT(PageSlot(*paddr + offset) == static_cast<u64>(PageStatus::Unmapped));
42 PageSlot(*paddr + offset) = vaddr + offset; 38 PageSlot(*paddr + offset) = vaddr + offset;
43 } 39 }
44 40
@@ -46,16 +42,10 @@ PAddr MemoryManager::MapBufferEx(VAddr vaddr, u64 size) {
46} 42}
47 43
48PAddr MemoryManager::MapBufferEx(VAddr vaddr, PAddr paddr, u64 size) { 44PAddr MemoryManager::MapBufferEx(VAddr vaddr, PAddr paddr, u64 size) {
49 vaddr &= ~Memory::PAGE_MASK; 45 ASSERT((paddr & PAGE_MASK) == 0);
50 paddr &= ~Memory::PAGE_MASK;
51 46
52 for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) { 47 for (u64 offset = 0; offset < size; offset += PAGE_SIZE) {
53 if (PageSlot(paddr + offset) != static_cast<u64>(PageStatus::Allocated)) { 48 ASSERT(PageSlot(paddr + offset) == static_cast<u64>(PageStatus::Allocated));
54 return MapBufferEx(vaddr, size);
55 }
56 }
57
58 for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) {
59 PageSlot(paddr + offset) = vaddr + offset; 49 PageSlot(paddr + offset) = vaddr + offset;
60 } 50 }
61 51
@@ -63,23 +53,20 @@ PAddr MemoryManager::MapBufferEx(VAddr vaddr, PAddr paddr, u64 size) {
63} 53}
64 54
65boost::optional<PAddr> MemoryManager::FindFreeBlock(u64 size, u64 align) { 55boost::optional<PAddr> MemoryManager::FindFreeBlock(u64 size, u64 align) {
66 PAddr paddr{}; 56 PAddr paddr = 0;
67 u64 free_space{}; 57 u64 free_space = 0;
68 align = (align + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; 58 align = (align + PAGE_MASK) & ~PAGE_MASK;
69 59
70 while (paddr + free_space < MAX_ADDRESS) { 60 while (paddr + free_space < MAX_ADDRESS) {
71 if (!IsPageMapped(paddr + free_space)) { 61 if (!IsPageMapped(paddr + free_space)) {
72 free_space += Memory::PAGE_SIZE; 62 free_space += PAGE_SIZE;
73 if (free_space >= size) { 63 if (free_space >= size) {
74 return paddr; 64 return paddr;
75 } 65 }
76 } else { 66 } else {
77 paddr += free_space + Memory::PAGE_SIZE; 67 paddr += free_space + PAGE_SIZE;
78 free_space = 0; 68 free_space = 0;
79 const u64 remainder{paddr % align}; 69 paddr = Common::AlignUp(paddr, align);
80 if (!remainder) {
81 paddr = (paddr - remainder) + align;
82 }
83 } 70 }
84 } 71 }
85 72
@@ -89,7 +76,7 @@ boost::optional<PAddr> MemoryManager::FindFreeBlock(u64 size, u64 align) {
89VAddr MemoryManager::PhysicalToVirtualAddress(PAddr paddr) { 76VAddr MemoryManager::PhysicalToVirtualAddress(PAddr paddr) {
90 VAddr base_addr = PageSlot(paddr); 77 VAddr base_addr = PageSlot(paddr);
91 ASSERT(base_addr != static_cast<u64>(PageStatus::Unmapped)); 78 ASSERT(base_addr != static_cast<u64>(PageStatus::Unmapped));
92 return base_addr + (paddr & Memory::PAGE_MASK); 79 return base_addr + (paddr & PAGE_MASK);
93} 80}
94 81
95bool MemoryManager::IsPageMapped(PAddr paddr) { 82bool MemoryManager::IsPageMapped(PAddr paddr) {
@@ -97,14 +84,14 @@ bool MemoryManager::IsPageMapped(PAddr paddr) {
97} 84}
98 85
99VAddr& MemoryManager::PageSlot(PAddr paddr) { 86VAddr& MemoryManager::PageSlot(PAddr paddr) {
100 auto& block = page_table[(paddr >> (Memory::PAGE_BITS + PAGE_TABLE_BITS)) & PAGE_TABLE_MASK]; 87 auto& block = page_table[(paddr >> (PAGE_BITS + PAGE_TABLE_BITS)) & PAGE_TABLE_MASK];
101 if (!block) { 88 if (!block) {
102 block = std::make_unique<PageBlock>(); 89 block = std::make_unique<PageBlock>();
103 for (unsigned index = 0; index < PAGE_BLOCK_SIZE; index++) { 90 for (unsigned index = 0; index < PAGE_BLOCK_SIZE; index++) {
104 (*block)[index] = static_cast<u64>(PageStatus::Unmapped); 91 (*block)[index] = static_cast<u64>(PageStatus::Unmapped);
105 } 92 }
106 } 93 }
107 return (*block)[(paddr >> Memory::PAGE_BITS) & PAGE_BLOCK_MASK]; 94 return (*block)[(paddr >> PAGE_BITS) & PAGE_BLOCK_MASK];
108} 95}
109 96
110} // namespace Tegra 97} // namespace Tegra
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h
index 47da7acd6..b73e283f8 100644
--- a/src/video_core/memory_manager.h
+++ b/src/video_core/memory_manager.h
@@ -24,6 +24,10 @@ public:
24 PAddr MapBufferEx(VAddr vaddr, PAddr paddr, u64 size); 24 PAddr MapBufferEx(VAddr vaddr, PAddr paddr, u64 size);
25 VAddr PhysicalToVirtualAddress(PAddr paddr); 25 VAddr PhysicalToVirtualAddress(PAddr paddr);
26 26
27 static constexpr u64 PAGE_BITS = 16;
28 static constexpr u64 PAGE_SIZE = 1 << PAGE_BITS;
29 static constexpr u64 PAGE_MASK = PAGE_SIZE - 1;
30
27private: 31private:
28 boost::optional<PAddr> FindFreeBlock(u64 size, u64 align = 1); 32 boost::optional<PAddr> FindFreeBlock(u64 size, u64 align = 1);
29 bool IsPageMapped(PAddr paddr); 33 bool IsPageMapped(PAddr paddr);
@@ -35,7 +39,7 @@ private:
35 }; 39 };
36 40
37 static constexpr u64 MAX_ADDRESS{0x10000000000ULL}; 41 static constexpr u64 MAX_ADDRESS{0x10000000000ULL};
38 static constexpr u64 PAGE_TABLE_BITS{14}; 42 static constexpr u64 PAGE_TABLE_BITS{10};
39 static constexpr u64 PAGE_TABLE_SIZE{1 << PAGE_TABLE_BITS}; 43 static constexpr u64 PAGE_TABLE_SIZE{1 << PAGE_TABLE_BITS};
40 static constexpr u64 PAGE_TABLE_MASK{PAGE_TABLE_SIZE - 1}; 44 static constexpr u64 PAGE_TABLE_MASK{PAGE_TABLE_SIZE - 1};
41 static constexpr u64 PAGE_BLOCK_BITS{14}; 45 static constexpr u64 PAGE_BLOCK_BITS{14};
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 2d4a0d6db..82001e7b4 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -127,7 +127,8 @@ RasterizerOpenGL::~RasterizerOpenGL() {
127 } 127 }
128} 128}
129 129
130void RasterizerOpenGL::SetupVertexArray(u8* array_ptr, GLintptr buffer_offset) { 130std::pair<u8*, GLintptr> RasterizerOpenGL::SetupVertexArrays(u8* array_ptr,
131 GLintptr buffer_offset) {
131 MICROPROFILE_SCOPE(OpenGL_VAO); 132 MICROPROFILE_SCOPE(OpenGL_VAO);
132 const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs; 133 const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs;
133 const auto& memory_manager = Core::System().GetInstance().GPU().memory_manager; 134 const auto& memory_manager = Core::System().GetInstance().GPU().memory_manager;
@@ -136,43 +137,59 @@ void RasterizerOpenGL::SetupVertexArray(u8* array_ptr, GLintptr buffer_offset) {
136 state.draw.vertex_buffer = stream_buffer->GetHandle(); 137 state.draw.vertex_buffer = stream_buffer->GetHandle();
137 state.Apply(); 138 state.Apply();
138 139
139 // TODO(bunnei): Add support for 1+ vertex arrays 140 // Upload all guest vertex arrays sequentially to our buffer
140 const auto& vertex_array{regs.vertex_array[0]}; 141 for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) {
141 const auto& vertex_array_limit{regs.vertex_array_limit[0]}; 142 const auto& vertex_array = regs.vertex_array[index];
142 ASSERT_MSG(vertex_array.enable, "vertex array 0 is disabled?"); 143 if (!vertex_array.IsEnabled())
143 ASSERT_MSG(!vertex_array.divisor, "vertex array 0 divisor is unimplemented!"); 144 continue;
144 for (unsigned index = 1; index < Maxwell::NumVertexArrays; ++index) { 145
145 ASSERT_MSG(!regs.vertex_array[index].enable, "vertex array %d is unimplemented!", index); 146 const Tegra::GPUVAddr start = vertex_array.StartAddress();
147 const Tegra::GPUVAddr end = regs.vertex_array_limit[index].LimitAddress();
148
149 ASSERT(end > start);
150 u64 size = end - start + 1;
151
152 // Copy vertex array data
153 const VAddr data_addr{memory_manager->PhysicalToVirtualAddress(start)};
154 res_cache.FlushRegion(data_addr, size, nullptr);
155 Memory::ReadBlock(data_addr, array_ptr, size);
156
157 // Bind the vertex array to the buffer at the current offset.
158 glBindVertexBuffer(index, stream_buffer->GetHandle(), buffer_offset, vertex_array.stride);
159
160 ASSERT_MSG(vertex_array.divisor == 0, "Vertex buffer divisor unimplemented");
161
162 array_ptr += size;
163 buffer_offset += size;
146 } 164 }
147 165
148 // Use the vertex array as-is, assumes that the data is formatted correctly for OpenGL. 166 // Use the vertex array as-is, assumes that the data is formatted correctly for OpenGL.
149 // Enables the first 16 vertex attributes always, as we don't know which ones are actually used 167 // Enables the first 16 vertex attributes always, as we don't know which ones are actually used
150 // until shader time. Note, Tegra technically supports 32, but we're cappinig this to 16 for now 168 // until shader time. Note, Tegra technically supports 32, but we're capping this to 16 for now
151 // to avoid OpenGL errors. 169 // to avoid OpenGL errors.
170 // TODO(Subv): Analyze the shader to identify which attributes are actually used and don't
171 // assume every shader uses them all.
152 for (unsigned index = 0; index < 16; ++index) { 172 for (unsigned index = 0; index < 16; ++index) {
153 auto& attrib = regs.vertex_attrib_format[index]; 173 auto& attrib = regs.vertex_attrib_format[index];
154 NGLOG_DEBUG(HW_GPU, "vertex attrib {}, count={}, size={}, type={}, offset={}, normalize={}", 174 NGLOG_DEBUG(HW_GPU, "vertex attrib {}, count={}, size={}, type={}, offset={}, normalize={}",
155 index, attrib.ComponentCount(), attrib.SizeString(), attrib.TypeString(), 175 index, attrib.ComponentCount(), attrib.SizeString(), attrib.TypeString(),
156 attrib.offset.Value(), attrib.IsNormalized()); 176 attrib.offset.Value(), attrib.IsNormalized());
157 177
158 glVertexAttribPointer(index, attrib.ComponentCount(), MaxwellToGL::VertexType(attrib), 178 auto& buffer = regs.vertex_array[attrib.buffer];
159 attrib.IsNormalized() ? GL_TRUE : GL_FALSE, vertex_array.stride, 179 ASSERT(buffer.IsEnabled());
160 reinterpret_cast<GLvoid*>(buffer_offset + attrib.offset)); 180
161 glEnableVertexAttribArray(index); 181 glEnableVertexAttribArray(index);
182 glVertexAttribFormat(index, attrib.ComponentCount(), MaxwellToGL::VertexType(attrib),
183 attrib.IsNormalized() ? GL_TRUE : GL_FALSE, attrib.offset);
184 glVertexAttribBinding(index, attrib.buffer);
185
162 hw_vao_enabled_attributes[index] = true; 186 hw_vao_enabled_attributes[index] = true;
163 } 187 }
164 188
165 // Copy vertex array data 189 return {array_ptr, buffer_offset};
166 const u64 data_size{vertex_array_limit.LimitAddress() - vertex_array.StartAddress() + 1};
167 const VAddr data_addr{memory_manager->PhysicalToVirtualAddress(vertex_array.StartAddress())};
168 res_cache.FlushRegion(data_addr, data_size, nullptr);
169 Memory::ReadBlock(data_addr, array_ptr, data_size);
170
171 array_ptr += data_size;
172 buffer_offset += data_size;
173} 190}
174 191
175void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size_t ptr_pos) { 192void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset) {
176 // Helper function for uploading uniform data 193 // Helper function for uploading uniform data
177 const auto copy_buffer = [&](GLuint handle, GLintptr offset, GLsizeiptr size) { 194 const auto copy_buffer = [&](GLuint handle, GLintptr offset, GLsizeiptr size) {
178 if (has_ARB_direct_state_access) { 195 if (has_ARB_direct_state_access) {
@@ -190,8 +207,6 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size
190 u32 current_constbuffer_bindpoint = 0; 207 u32 current_constbuffer_bindpoint = 0;
191 208
192 for (unsigned index = 1; index < Maxwell::MaxShaderProgram; ++index) { 209 for (unsigned index = 1; index < Maxwell::MaxShaderProgram; ++index) {
193 ptr_pos += sizeof(GLShader::MaxwellUniformData);
194
195 auto& shader_config = gpu.regs.shader_config[index]; 210 auto& shader_config = gpu.regs.shader_config[index];
196 const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)}; 211 const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)};
197 212
@@ -205,13 +220,16 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size
205 } 220 }
206 221
207 // Upload uniform data as one UBO per stage 222 // Upload uniform data as one UBO per stage
208 const GLintptr ubo_offset = buffer_offset + static_cast<GLintptr>(ptr_pos); 223 const GLintptr ubo_offset = buffer_offset;
209 copy_buffer(uniform_buffers[stage].handle, ubo_offset, 224 copy_buffer(uniform_buffers[stage].handle, ubo_offset,
210 sizeof(GLShader::MaxwellUniformData)); 225 sizeof(GLShader::MaxwellUniformData));
211 GLShader::MaxwellUniformData* ub_ptr = 226 GLShader::MaxwellUniformData* ub_ptr =
212 reinterpret_cast<GLShader::MaxwellUniformData*>(&buffer_ptr[ptr_pos]); 227 reinterpret_cast<GLShader::MaxwellUniformData*>(buffer_ptr);
213 ub_ptr->SetFromRegs(gpu.state.shader_stages[stage]); 228 ub_ptr->SetFromRegs(gpu.state.shader_stages[stage]);
214 229
230 buffer_ptr += sizeof(GLShader::MaxwellUniformData);
231 buffer_offset += sizeof(GLShader::MaxwellUniformData);
232
215 // Fetch program code from memory 233 // Fetch program code from memory
216 GLShader::ProgramCode program_code; 234 GLShader::ProgramCode program_code;
217 const u64 gpu_address{gpu.regs.code_address.CodeAddress() + shader_config.offset}; 235 const u64 gpu_address{gpu.regs.code_address.CodeAddress() + shader_config.offset};
@@ -252,6 +270,24 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size
252 shader_program_manager->UseTrivialGeometryShader(); 270 shader_program_manager->UseTrivialGeometryShader();
253} 271}
254 272
273size_t RasterizerOpenGL::CalculateVertexArraysSize() const {
274 const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs;
275
276 size_t size = 0;
277 for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) {
278 if (!regs.vertex_array[index].IsEnabled())
279 continue;
280
281 const Tegra::GPUVAddr start = regs.vertex_array[index].StartAddress();
282 const Tegra::GPUVAddr end = regs.vertex_array_limit[index].LimitAddress();
283
284 ASSERT(end > start);
285 size += end - start + 1;
286 }
287
288 return size;
289}
290
255bool RasterizerOpenGL::AccelerateDrawBatch(bool is_indexed) { 291bool RasterizerOpenGL::AccelerateDrawBatch(bool is_indexed) {
256 accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays; 292 accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays;
257 DrawArrays(); 293 DrawArrays();
@@ -329,44 +365,49 @@ void RasterizerOpenGL::DrawArrays() {
329 const u64 index_buffer_size{regs.index_array.count * regs.index_array.FormatSizeInBytes()}; 365 const u64 index_buffer_size{regs.index_array.count * regs.index_array.FormatSizeInBytes()};
330 const unsigned vertex_num{is_indexed ? regs.index_array.count : regs.vertex_buffer.count}; 366 const unsigned vertex_num{is_indexed ? regs.index_array.count : regs.vertex_buffer.count};
331 367
332 // TODO(bunnei): Add support for 1+ vertex arrays
333 vs_input_size = vertex_num * regs.vertex_array[0].stride;
334
335 state.draw.vertex_buffer = stream_buffer->GetHandle(); 368 state.draw.vertex_buffer = stream_buffer->GetHandle();
336 state.Apply(); 369 state.Apply();
337 370
338 size_t buffer_size = static_cast<size_t>(vs_input_size); 371 size_t buffer_size = CalculateVertexArraysSize();
372
339 if (is_indexed) { 373 if (is_indexed) {
340 buffer_size = Common::AlignUp(buffer_size, 4) + index_buffer_size; 374 buffer_size = Common::AlignUp<size_t>(buffer_size, 4) + index_buffer_size;
341 } 375 }
342 376
343 // Uniform space for the 5 shader stages 377 // Uniform space for the 5 shader stages
344 buffer_size += sizeof(GLShader::MaxwellUniformData) * Maxwell::MaxShaderStage; 378 buffer_size = Common::AlignUp<size_t>(buffer_size, 4) +
379 sizeof(GLShader::MaxwellUniformData) * Maxwell::MaxShaderStage;
345 380
346 size_t ptr_pos = 0;
347 u8* buffer_ptr; 381 u8* buffer_ptr;
348 GLintptr buffer_offset; 382 GLintptr buffer_offset;
349 std::tie(buffer_ptr, buffer_offset) = 383 std::tie(buffer_ptr, buffer_offset) =
350 stream_buffer->Map(static_cast<GLsizeiptr>(buffer_size), 4); 384 stream_buffer->Map(static_cast<GLsizeiptr>(buffer_size), 4);
351 385
352 SetupVertexArray(buffer_ptr, buffer_offset); 386 u8* offseted_buffer;
353 ptr_pos += vs_input_size; 387 std::tie(offseted_buffer, buffer_offset) = SetupVertexArrays(buffer_ptr, buffer_offset);
388
389 offseted_buffer =
390 reinterpret_cast<u8*>(Common::AlignUp(reinterpret_cast<size_t>(offseted_buffer), 4));
391 buffer_offset = Common::AlignUp<size_t>(buffer_offset, 4);
354 392
355 // If indexed mode, copy the index buffer 393 // If indexed mode, copy the index buffer
356 GLintptr index_buffer_offset = 0; 394 GLintptr index_buffer_offset = 0;
357 if (is_indexed) { 395 if (is_indexed) {
358 ptr_pos = Common::AlignUp(ptr_pos, 4);
359
360 const auto& memory_manager = Core::System().GetInstance().GPU().memory_manager; 396 const auto& memory_manager = Core::System().GetInstance().GPU().memory_manager;
361 const VAddr index_data_addr{ 397 const VAddr index_data_addr{
362 memory_manager->PhysicalToVirtualAddress(regs.index_array.StartAddress())}; 398 memory_manager->PhysicalToVirtualAddress(regs.index_array.StartAddress())};
363 Memory::ReadBlock(index_data_addr, &buffer_ptr[ptr_pos], index_buffer_size); 399 Memory::ReadBlock(index_data_addr, offseted_buffer, index_buffer_size);
364 400
365 index_buffer_offset = buffer_offset + static_cast<GLintptr>(ptr_pos); 401 index_buffer_offset = buffer_offset;
366 ptr_pos += index_buffer_size; 402 offseted_buffer += index_buffer_size;
403 buffer_offset += index_buffer_size;
367 } 404 }
368 405
369 SetupShaders(buffer_ptr, buffer_offset, ptr_pos); 406 offseted_buffer =
407 reinterpret_cast<u8*>(Common::AlignUp(reinterpret_cast<size_t>(offseted_buffer), 4));
408 buffer_offset = Common::AlignUp<size_t>(buffer_offset, 4);
409
410 SetupShaders(offseted_buffer, buffer_offset);
370 411
371 stream_buffer->Unmap(); 412 stream_buffer->Unmap();
372 413
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 03e02b52a..544714b95 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -148,13 +148,13 @@ private:
148 static constexpr size_t STREAM_BUFFER_SIZE = 4 * 1024 * 1024; 148 static constexpr size_t STREAM_BUFFER_SIZE = 4 * 1024 * 1024;
149 std::unique_ptr<OGLStreamBuffer> stream_buffer; 149 std::unique_ptr<OGLStreamBuffer> stream_buffer;
150 150
151 GLsizeiptr vs_input_size; 151 size_t CalculateVertexArraysSize() const;
152 152
153 void SetupVertexArray(u8* array_ptr, GLintptr buffer_offset); 153 std::pair<u8*, GLintptr> SetupVertexArrays(u8* array_ptr, GLintptr buffer_offset);
154 154
155 std::array<OGLBuffer, Tegra::Engines::Maxwell3D::Regs::MaxShaderStage> uniform_buffers; 155 std::array<OGLBuffer, Tegra::Engines::Maxwell3D::Regs::MaxShaderStage> uniform_buffers;
156 156
157 void SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size_t ptr_pos); 157 void SetupShaders(u8* buffer_ptr, GLintptr buffer_offset);
158 158
159 enum class AccelDraw { Disabled, Arrays, Indexed }; 159 enum class AccelDraw { Disabled, Arrays, Indexed };
160 AccelDraw accelerate_draw; 160 AccelDraw accelerate_draw;
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index ced2b8247..7410471cc 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -49,6 +49,7 @@ struct FormatTuple {
49static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{ 49static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{
50 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false, 1}, // ABGR8 50 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false, 1}, // ABGR8
51 {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false, 1}, // B5G6R5 51 {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false, 1}, // B5G6R5
52 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, false, 1}, // A2B10G10R10
52 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT1 53 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT1
53 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT23 54 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT23
54 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT45 55 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT45
@@ -104,9 +105,9 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, u8* gl_buffer, VAddr b
104static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr), 105static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr),
105 SurfaceParams::MaxPixelFormat> 106 SurfaceParams::MaxPixelFormat>
106 morton_to_gl_fns = { 107 morton_to_gl_fns = {
107 MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>, 108 MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>,
108 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>, 109 MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::DXT1>,
109 MortonCopy<true, PixelFormat::DXT45>, 110 MortonCopy<true, PixelFormat::DXT23>, MortonCopy<true, PixelFormat::DXT45>,
110}; 111};
111 112
112static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr), 113static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr),
@@ -114,6 +115,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr),
114 gl_to_morton_fns = { 115 gl_to_morton_fns = {
115 MortonCopy<false, PixelFormat::ABGR8>, 116 MortonCopy<false, PixelFormat::ABGR8>,
116 MortonCopy<false, PixelFormat::B5G6R5>, 117 MortonCopy<false, PixelFormat::B5G6R5>,
118 MortonCopy<false, PixelFormat::A2B10G10R10>,
117 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45 formats is not yet supported 119 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45 formats is not yet supported
118 nullptr, 120 nullptr,
119 nullptr, 121 nullptr,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 6861efe16..bf0fabb29 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -54,9 +54,10 @@ struct SurfaceParams {
54 enum class PixelFormat { 54 enum class PixelFormat {
55 ABGR8 = 0, 55 ABGR8 = 0,
56 B5G6R5 = 1, 56 B5G6R5 = 1,
57 DXT1 = 2, 57 A2B10G10R10 = 2,
58 DXT23 = 3, 58 DXT1 = 3,
59 DXT45 = 4, 59 DXT23 = 4,
60 DXT45 = 5,
60 61
61 Max, 62 Max,
62 Invalid = 255, 63 Invalid = 255,
@@ -88,6 +89,7 @@ struct SurfaceParams {
88 constexpr std::array<unsigned int, MaxPixelFormat> bpp_table = { 89 constexpr std::array<unsigned int, MaxPixelFormat> bpp_table = {
89 32, // ABGR8 90 32, // ABGR8
90 16, // B5G6R5 91 16, // B5G6R5
92 32, // A2B10G10R10
91 64, // DXT1 93 64, // DXT1
92 128, // DXT23 94 128, // DXT23
93 128, // DXT45 95 128, // DXT45
@@ -104,6 +106,8 @@ struct SurfaceParams {
104 switch (format) { 106 switch (format) {
105 case Tegra::RenderTargetFormat::RGBA8_UNORM: 107 case Tegra::RenderTargetFormat::RGBA8_UNORM:
106 return PixelFormat::ABGR8; 108 return PixelFormat::ABGR8;
109 case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
110 return PixelFormat::A2B10G10R10;
107 default: 111 default:
108 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 112 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
109 UNREACHABLE(); 113 UNREACHABLE();
@@ -127,6 +131,8 @@ struct SurfaceParams {
127 return PixelFormat::ABGR8; 131 return PixelFormat::ABGR8;
128 case Tegra::Texture::TextureFormat::B5G6R5: 132 case Tegra::Texture::TextureFormat::B5G6R5:
129 return PixelFormat::B5G6R5; 133 return PixelFormat::B5G6R5;
134 case Tegra::Texture::TextureFormat::A2B10G10R10:
135 return PixelFormat::A2B10G10R10;
130 case Tegra::Texture::TextureFormat::DXT1: 136 case Tegra::Texture::TextureFormat::DXT1:
131 return PixelFormat::DXT1; 137 return PixelFormat::DXT1;
132 case Tegra::Texture::TextureFormat::DXT23: 138 case Tegra::Texture::TextureFormat::DXT23:
@@ -146,6 +152,8 @@ struct SurfaceParams {
146 return Tegra::Texture::TextureFormat::A8R8G8B8; 152 return Tegra::Texture::TextureFormat::A8R8G8B8;
147 case PixelFormat::B5G6R5: 153 case PixelFormat::B5G6R5:
148 return Tegra::Texture::TextureFormat::B5G6R5; 154 return Tegra::Texture::TextureFormat::B5G6R5;
155 case PixelFormat::A2B10G10R10:
156 return Tegra::Texture::TextureFormat::A2B10G10R10;
149 case PixelFormat::DXT1: 157 case PixelFormat::DXT1:
150 return Tegra::Texture::TextureFormat::DXT1; 158 return Tegra::Texture::TextureFormat::DXT1;
151 case PixelFormat::DXT23: 159 case PixelFormat::DXT23:
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index ab0acb20a..baff2c7af 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -295,7 +295,7 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
295 const auto& texcoords = screen_info.display_texcoords; 295 const auto& texcoords = screen_info.display_texcoords;
296 auto left = texcoords.left; 296 auto left = texcoords.left;
297 auto right = texcoords.right; 297 auto right = texcoords.right;
298 if (framebuffer_transform_flags != Tegra::FramebufferConfig::TransformFlags::Unset) 298 if (framebuffer_transform_flags != Tegra::FramebufferConfig::TransformFlags::Unset) {
299 if (framebuffer_transform_flags == Tegra::FramebufferConfig::TransformFlags::FlipV) { 299 if (framebuffer_transform_flags == Tegra::FramebufferConfig::TransformFlags::FlipV) {
300 // Flip the framebuffer vertically 300 // Flip the framebuffer vertically
301 left = texcoords.right; 301 left = texcoords.right;
@@ -306,6 +306,7 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
306 framebuffer_transform_flags); 306 framebuffer_transform_flags);
307 UNIMPLEMENTED(); 307 UNIMPLEMENTED();
308 } 308 }
309 }
309 310
310 std::array<ScreenRectVertex, 4> vertices = {{ 311 std::array<ScreenRectVertex, 4> vertices = {{
311 ScreenRectVertex(x, y, texcoords.top, left), 312 ScreenRectVertex(x, y, texcoords.top, left),
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 4df687786..e0509f0ce 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -53,6 +53,7 @@ u32 BytesPerPixel(TextureFormat format) {
53 // In this case a 'pixel' actually refers to a 4x4 tile. 53 // In this case a 'pixel' actually refers to a 4x4 tile.
54 return 16; 54 return 16;
55 case TextureFormat::A8R8G8B8: 55 case TextureFormat::A8R8G8B8:
56 case TextureFormat::A2B10G10R10:
56 return 4; 57 return 4;
57 case TextureFormat::B5G6R5: 58 case TextureFormat::B5G6R5:
58 return 2; 59 return 2;
@@ -78,6 +79,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
78 unswizzled_data.data(), true, block_height); 79 unswizzled_data.data(), true, block_height);
79 break; 80 break;
80 case TextureFormat::A8R8G8B8: 81 case TextureFormat::A8R8G8B8:
82 case TextureFormat::A2B10G10R10:
81 case TextureFormat::B5G6R5: 83 case TextureFormat::B5G6R5:
82 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, 84 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
83 unswizzled_data.data(), true, block_height); 85 unswizzled_data.data(), true, block_height);
@@ -100,6 +102,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
100 case TextureFormat::DXT23: 102 case TextureFormat::DXT23:
101 case TextureFormat::DXT45: 103 case TextureFormat::DXT45:
102 case TextureFormat::A8R8G8B8: 104 case TextureFormat::A8R8G8B8:
105 case TextureFormat::A2B10G10R10:
103 case TextureFormat::B5G6R5: 106 case TextureFormat::B5G6R5:
104 // TODO(Subv): For the time being just forward the same data without any decoding. 107 // TODO(Subv): For the time being just forward the same data without any decoding.
105 rgba_data = texture_data; 108 rgba_data = texture_data;
diff --git a/src/video_core/textures/texture.h b/src/video_core/textures/texture.h
index 86e45aa88..dc004d361 100644
--- a/src/video_core/textures/texture.h
+++ b/src/video_core/textures/texture.h
@@ -15,6 +15,7 @@ namespace Texture {
15 15
16enum class TextureFormat : u32 { 16enum class TextureFormat : u32 {
17 A8R8G8B8 = 0x8, 17 A8R8G8B8 = 0x8,
18 A2B10G10R10 = 0x9,
18 B5G6R5 = 0x15, 19 B5G6R5 = 0x15,
19 DXT1 = 0x24, 20 DXT1 = 0x24,
20 DXT23 = 0x25, 21 DXT23 = 0x25,
diff --git a/src/yuzu/debugger/graphics/graphics_surface.cpp b/src/yuzu/debugger/graphics/graphics_surface.cpp
index 1e4844b57..5fada74be 100644
--- a/src/yuzu/debugger/graphics/graphics_surface.cpp
+++ b/src/yuzu/debugger/graphics/graphics_surface.cpp
@@ -25,6 +25,8 @@ static Tegra::Texture::TextureFormat ConvertToTextureFormat(
25 switch (render_target_format) { 25 switch (render_target_format) {
26 case Tegra::RenderTargetFormat::RGBA8_UNORM: 26 case Tegra::RenderTargetFormat::RGBA8_UNORM:
27 return Tegra::Texture::TextureFormat::A8R8G8B8; 27 return Tegra::Texture::TextureFormat::A8R8G8B8;
28 case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
29 return Tegra::Texture::TextureFormat::A2B10G10R10;
28 default: 30 default:
29 UNIMPLEMENTED_MSG("Unimplemented RT format"); 31 UNIMPLEMENTED_MSG("Unimplemented RT format");
30 } 32 }
diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp
index cae2864e5..acc4c2e0b 100644
--- a/src/yuzu/debugger/wait_tree.cpp
+++ b/src/yuzu/debugger/wait_tree.cpp
@@ -6,8 +6,8 @@
6#include "yuzu/util/util.h" 6#include "yuzu/util/util.h"
7 7
8#include "core/core.h" 8#include "core/core.h"
9#include "core/hle/kernel/condition_variable.h"
10#include "core/hle/kernel/event.h" 9#include "core/hle/kernel/event.h"
10#include "core/hle/kernel/handle_table.h"
11#include "core/hle/kernel/mutex.h" 11#include "core/hle/kernel/mutex.h"
12#include "core/hle/kernel/thread.h" 12#include "core/hle/kernel/thread.h"
13#include "core/hle/kernel/timer.h" 13#include "core/hle/kernel/timer.h"
@@ -67,6 +67,29 @@ QString WaitTreeText::GetText() const {
67 return text; 67 return text;
68} 68}
69 69
70WaitTreeMutexInfo::WaitTreeMutexInfo(VAddr mutex_address) : mutex_address(mutex_address) {
71 mutex_value = Memory::Read32(mutex_address);
72 owner_handle = static_cast<Kernel::Handle>(mutex_value & Kernel::Mutex::MutexOwnerMask);
73 owner = Kernel::g_handle_table.Get<Kernel::Thread>(owner_handle);
74}
75
76QString WaitTreeMutexInfo::GetText() const {
77 return tr("waiting for mutex 0x%1").arg(mutex_address, 16, 16, QLatin1Char('0'));
78}
79
80std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutexInfo::GetChildren() const {
81 std::vector<std::unique_ptr<WaitTreeItem>> list;
82
83 bool has_waiters = (mutex_value & Kernel::Mutex::MutexHasWaitersFlag) != 0;
84
85 list.push_back(std::make_unique<WaitTreeText>(tr("has waiters: %1").arg(has_waiters)));
86 list.push_back(std::make_unique<WaitTreeText>(
87 tr("owner handle: 0x%1").arg(owner_handle, 8, 16, QLatin1Char('0'))));
88 if (owner != nullptr)
89 list.push_back(std::make_unique<WaitTreeThread>(*owner));
90 return list;
91}
92
70WaitTreeWaitObject::WaitTreeWaitObject(const Kernel::WaitObject& o) : object(o) {} 93WaitTreeWaitObject::WaitTreeWaitObject(const Kernel::WaitObject& o) : object(o) {}
71 94
72bool WaitTreeExpandableItem::IsExpandable() const { 95bool WaitTreeExpandableItem::IsExpandable() const {
@@ -84,11 +107,6 @@ std::unique_ptr<WaitTreeWaitObject> WaitTreeWaitObject::make(const Kernel::WaitO
84 switch (object.GetHandleType()) { 107 switch (object.GetHandleType()) {
85 case Kernel::HandleType::Event: 108 case Kernel::HandleType::Event:
86 return std::make_unique<WaitTreeEvent>(static_cast<const Kernel::Event&>(object)); 109 return std::make_unique<WaitTreeEvent>(static_cast<const Kernel::Event&>(object));
87 case Kernel::HandleType::Mutex:
88 return std::make_unique<WaitTreeMutex>(static_cast<const Kernel::Mutex&>(object));
89 case Kernel::HandleType::ConditionVariable:
90 return std::make_unique<WaitTreeConditionVariable>(
91 static_cast<const Kernel::ConditionVariable&>(object));
92 case Kernel::HandleType::Timer: 110 case Kernel::HandleType::Timer:
93 return std::make_unique<WaitTreeTimer>(static_cast<const Kernel::Timer&>(object)); 111 return std::make_unique<WaitTreeTimer>(static_cast<const Kernel::Timer&>(object));
94 case Kernel::HandleType::Thread: 112 case Kernel::HandleType::Thread:
@@ -160,6 +178,9 @@ QString WaitTreeThread::GetText() const {
160 case THREADSTATUS_WAIT_SYNCH_ANY: 178 case THREADSTATUS_WAIT_SYNCH_ANY:
161 status = tr("waiting for objects"); 179 status = tr("waiting for objects");
162 break; 180 break;
181 case THREADSTATUS_WAIT_MUTEX:
182 status = tr("waiting for mutex");
183 break;
163 case THREADSTATUS_DORMANT: 184 case THREADSTATUS_DORMANT:
164 status = tr("dormant"); 185 status = tr("dormant");
165 break; 186 break;
@@ -186,6 +207,7 @@ QColor WaitTreeThread::GetColor() const {
186 return QColor(Qt::GlobalColor::darkYellow); 207 return QColor(Qt::GlobalColor::darkYellow);
187 case THREADSTATUS_WAIT_SYNCH_ALL: 208 case THREADSTATUS_WAIT_SYNCH_ALL:
188 case THREADSTATUS_WAIT_SYNCH_ANY: 209 case THREADSTATUS_WAIT_SYNCH_ANY:
210 case THREADSTATUS_WAIT_MUTEX:
189 return QColor(Qt::GlobalColor::red); 211 return QColor(Qt::GlobalColor::red);
190 case THREADSTATUS_DORMANT: 212 case THREADSTATUS_DORMANT:
191 return QColor(Qt::GlobalColor::darkCyan); 213 return QColor(Qt::GlobalColor::darkCyan);
@@ -225,11 +247,11 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const {
225 list.push_back(std::make_unique<WaitTreeText>( 247 list.push_back(std::make_unique<WaitTreeText>(
226 tr("last running ticks = %1").arg(thread.last_running_ticks))); 248 tr("last running ticks = %1").arg(thread.last_running_ticks)));
227 249
228 if (thread.held_mutexes.empty()) { 250 if (thread.mutex_wait_address != 0)
229 list.push_back(std::make_unique<WaitTreeText>(tr("not holding mutex"))); 251 list.push_back(std::make_unique<WaitTreeMutexInfo>(thread.mutex_wait_address));
230 } else { 252 else
231 list.push_back(std::make_unique<WaitTreeMutexList>(thread.held_mutexes)); 253 list.push_back(std::make_unique<WaitTreeText>(tr("not waiting for mutex")));
232 } 254
233 if (thread.status == THREADSTATUS_WAIT_SYNCH_ANY || 255 if (thread.status == THREADSTATUS_WAIT_SYNCH_ANY ||
234 thread.status == THREADSTATUS_WAIT_SYNCH_ALL) { 256 thread.status == THREADSTATUS_WAIT_SYNCH_ALL) {
235 list.push_back(std::make_unique<WaitTreeObjectList>(thread.wait_objects, 257 list.push_back(std::make_unique<WaitTreeObjectList>(thread.wait_objects,
@@ -250,33 +272,6 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeEvent::GetChildren() const {
250 return list; 272 return list;
251} 273}
252 274
253WaitTreeMutex::WaitTreeMutex(const Kernel::Mutex& object) : WaitTreeWaitObject(object) {}
254
255std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutex::GetChildren() const {
256 std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
257
258 const auto& mutex = static_cast<const Kernel::Mutex&>(object);
259 if (mutex.GetHasWaiters()) {
260 list.push_back(std::make_unique<WaitTreeText>(tr("locked by thread:")));
261 list.push_back(std::make_unique<WaitTreeThread>(*mutex.GetHoldingThread()));
262 } else {
263 list.push_back(std::make_unique<WaitTreeText>(tr("free")));
264 }
265 return list;
266}
267
268WaitTreeConditionVariable::WaitTreeConditionVariable(const Kernel::ConditionVariable& object)
269 : WaitTreeWaitObject(object) {}
270
271std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeConditionVariable::GetChildren() const {
272 std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
273
274 const auto& condition_variable = static_cast<const Kernel::ConditionVariable&>(object);
275 list.push_back(std::make_unique<WaitTreeText>(
276 tr("available count = %1").arg(condition_variable.GetAvailableCount())));
277 return list;
278}
279
280WaitTreeTimer::WaitTreeTimer(const Kernel::Timer& object) : WaitTreeWaitObject(object) {} 275WaitTreeTimer::WaitTreeTimer(const Kernel::Timer& object) : WaitTreeWaitObject(object) {}
281 276
282std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeTimer::GetChildren() const { 277std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeTimer::GetChildren() const {
@@ -293,21 +288,6 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeTimer::GetChildren() const {
293 return list; 288 return list;
294} 289}
295 290
296WaitTreeMutexList::WaitTreeMutexList(
297 const boost::container::flat_set<Kernel::SharedPtr<Kernel::Mutex>>& list)
298 : mutex_list(list) {}
299
300QString WaitTreeMutexList::GetText() const {
301 return tr("holding mutexes");
302}
303
304std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutexList::GetChildren() const {
305 std::vector<std::unique_ptr<WaitTreeItem>> list(mutex_list.size());
306 std::transform(mutex_list.begin(), mutex_list.end(), list.begin(),
307 [](const auto& t) { return std::make_unique<WaitTreeMutex>(*t); });
308 return list;
309}
310
311WaitTreeThreadList::WaitTreeThreadList(const std::vector<Kernel::SharedPtr<Kernel::Thread>>& list) 291WaitTreeThreadList::WaitTreeThreadList(const std::vector<Kernel::SharedPtr<Kernel::Thread>>& list)
312 : thread_list(list) {} 292 : thread_list(list) {}
313 293
diff --git a/src/yuzu/debugger/wait_tree.h b/src/yuzu/debugger/wait_tree.h
index e538174eb..300ba9ae4 100644
--- a/src/yuzu/debugger/wait_tree.h
+++ b/src/yuzu/debugger/wait_tree.h
@@ -16,8 +16,6 @@ class EmuThread;
16namespace Kernel { 16namespace Kernel {
17class WaitObject; 17class WaitObject;
18class Event; 18class Event;
19class Mutex;
20class ConditionVariable;
21class Thread; 19class Thread;
22class Timer; 20class Timer;
23} // namespace Kernel 21} // namespace Kernel
@@ -61,6 +59,20 @@ public:
61 bool IsExpandable() const override; 59 bool IsExpandable() const override;
62}; 60};
63 61
62class WaitTreeMutexInfo : public WaitTreeExpandableItem {
63 Q_OBJECT
64public:
65 explicit WaitTreeMutexInfo(VAddr mutex_address);
66 QString GetText() const override;
67 std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
68
69private:
70 VAddr mutex_address;
71 u32 mutex_value;
72 Kernel::Handle owner_handle;
73 Kernel::SharedPtr<Kernel::Thread> owner;
74};
75
64class WaitTreeWaitObject : public WaitTreeExpandableItem { 76class WaitTreeWaitObject : public WaitTreeExpandableItem {
65 Q_OBJECT 77 Q_OBJECT
66public: 78public:
@@ -104,20 +116,6 @@ public:
104 std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; 116 std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
105}; 117};
106 118
107class WaitTreeMutex : public WaitTreeWaitObject {
108 Q_OBJECT
109public:
110 explicit WaitTreeMutex(const Kernel::Mutex& object);
111 std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
112};
113
114class WaitTreeConditionVariable : public WaitTreeWaitObject {
115 Q_OBJECT
116public:
117 explicit WaitTreeConditionVariable(const Kernel::ConditionVariable& object);
118 std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
119};
120
121class WaitTreeTimer : public WaitTreeWaitObject { 119class WaitTreeTimer : public WaitTreeWaitObject {
122 Q_OBJECT 120 Q_OBJECT
123public: 121public:
@@ -125,19 +123,6 @@ public:
125 std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; 123 std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
126}; 124};
127 125
128class WaitTreeMutexList : public WaitTreeExpandableItem {
129 Q_OBJECT
130public:
131 explicit WaitTreeMutexList(
132 const boost::container::flat_set<Kernel::SharedPtr<Kernel::Mutex>>& list);
133
134 QString GetText() const override;
135 std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
136
137private:
138 const boost::container::flat_set<Kernel::SharedPtr<Kernel::Mutex>>& mutex_list;
139};
140
141class WaitTreeThreadList : public WaitTreeExpandableItem { 126class WaitTreeThreadList : public WaitTreeExpandableItem {
142 Q_OBJECT 127 Q_OBJECT
143public: 128public: