summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/audio_core/renderer/adsp/audio_renderer.cpp2
-rw-r--r--src/audio_core/renderer/command/command_buffer.cpp4
-rw-r--r--src/audio_core/renderer/command/command_generator.cpp2
-rw-r--r--src/audio_core/renderer/command/effect/aux_.cpp130
-rw-r--r--src/audio_core/renderer/command/effect/i3dl2_reverb.cpp8
-rw-r--r--src/audio_core/renderer/command/effect/reverb.cpp8
-rw-r--r--src/audio_core/renderer/command/resample/upsample.cpp12
-rw-r--r--src/audio_core/renderer/system.cpp2
-rw-r--r--src/audio_core/renderer/system_manager.cpp2
-rw-r--r--src/audio_core/sink/sink_stream.cpp8
-rw-r--r--src/core/CMakeLists.txt16
-rw-r--r--src/core/arm/arm_interface.cpp6
-rw-r--r--src/core/core.cpp42
-rw-r--r--src/core/core.h18
-rw-r--r--src/core/core_timing.cpp2
-rw-r--r--src/core/debugger/gdbstub.cpp28
-rw-r--r--src/core/debugger/gdbstub_arch.cpp14
-rw-r--r--src/core/debugger/gdbstub_arch.h6
-rw-r--r--src/core/file_sys/ips_layer.cpp8
-rw-r--r--src/core/file_sys/registered_cache.cpp2
-rw-r--r--src/core/file_sys/savedata_factory.cpp2
-rw-r--r--src/core/hle/ipc_helpers.h2
-rw-r--r--src/core/hle/kernel/k_client_port.cpp3
-rw-r--r--src/core/hle/kernel/k_code_memory.cpp8
-rw-r--r--src/core/hle/kernel/k_condition_variable.cpp8
-rw-r--r--src/core/hle/kernel/k_handle_table.h3
-rw-r--r--src/core/hle/kernel/k_interrupt_manager.cpp2
-rw-r--r--src/core/hle/kernel/k_scheduler.cpp14
-rw-r--r--src/core/hle/kernel/k_session.cpp3
-rw-r--r--src/core/hle/kernel/k_thread.cpp8
-rw-r--r--src/core/hle/kernel/k_thread.h2
-rw-r--r--src/core/hle/kernel/k_transfer_memory.cpp2
-rw-r--r--src/core/hle/kernel/kernel.cpp46
-rw-r--r--src/core/hle/kernel/kernel.h24
-rw-r--r--src/core/hle/kernel/svc.cpp2
-rw-r--r--src/core/hle/kernel/svc/svc_activity.cpp7
-rw-r--r--src/core/hle/kernel/svc/svc_address_arbiter.cpp6
-rw-r--r--src/core/hle/kernel/svc/svc_cache.cpp2
-rw-r--r--src/core/hle/kernel/svc/svc_code_memory.cpp23
-rw-r--r--src/core/hle/kernel/svc/svc_condition_variable.cpp8
-rw-r--r--src/core/hle/kernel/svc/svc_device_address_space.cpp33
-rw-r--r--src/core/hle/kernel/svc/svc_event.cpp10
-rw-r--r--src/core/hle/kernel/svc/svc_info.cpp14
-rw-r--r--src/core/hle/kernel/svc/svc_ipc.cpp6
-rw-r--r--src/core/hle/kernel/svc/svc_lock.cpp4
-rw-r--r--src/core/hle/kernel/svc/svc_memory.cpp8
-rw-r--r--src/core/hle/kernel/svc/svc_physical_memory.cpp6
-rw-r--r--src/core/hle/kernel/svc/svc_port.cpp2
-rw-r--r--src/core/hle/kernel/svc/svc_process.cpp14
-rw-r--r--src/core/hle/kernel/svc/svc_process_memory.cpp10
-rw-r--r--src/core/hle/kernel/svc/svc_query_memory.cpp2
-rw-r--r--src/core/hle/kernel/svc/svc_resource_limit.cpp20
-rw-r--r--src/core/hle/kernel/svc/svc_session.cpp2
-rw-r--r--src/core/hle/kernel/svc/svc_shared_memory.cpp4
-rw-r--r--src/core/hle/kernel/svc/svc_synchronization.cpp10
-rw-r--r--src/core/hle/kernel/svc/svc_thread.cpp30
-rw-r--r--src/core/hle/kernel/svc/svc_transfer_memory.cpp4
-rw-r--r--src/core/hle/kernel/svc_generator.py2
-rw-r--r--src/core/hle/service/acc/acc.cpp4
-rw-r--r--src/core/hle/service/am/am.cpp26
-rw-r--r--src/core/hle/service/am/applets/applet_error.cpp2
-rw-r--r--src/core/hle/service/am/applets/applet_general_backend.cpp2
-rw-r--r--src/core/hle/service/am/applets/applet_web_browser.cpp2
-rw-r--r--src/core/hle/service/am/tcap.cpp22
-rw-r--r--src/core/hle/service/am/tcap.h20
-rw-r--r--src/core/hle/service/aoc/aoc_u.cpp6
-rw-r--r--src/core/hle/service/apm/apm.cpp2
-rw-r--r--src/core/hle/service/apm/apm_controller.cpp2
-rw-r--r--src/core/hle/service/audio/auddbg.cpp21
-rw-r--r--src/core/hle/service/audio/auddbg.h20
-rw-r--r--src/core/hle/service/audio/audin_a.cpp23
-rw-r--r--src/core/hle/service/audio/audin_a.h20
-rw-r--r--src/core/hle/service/audio/audio.cpp14
-rw-r--r--src/core/hle/service/audio/audout_a.cpp25
-rw-r--r--src/core/hle/service/audio/audout_a.h20
-rw-r--r--src/core/hle/service/audio/audren_a.cpp27
-rw-r--r--src/core/hle/service/audio/audren_a.h20
-rw-r--r--src/core/hle/service/audio/audren_u.cpp2
-rw-r--r--src/core/hle/service/audio/codecctl.cpp29
-rw-r--r--src/core/hle/service/audio/codecctl.h20
-rw-r--r--src/core/hle/service/bcat/bcat_module.cpp10
-rw-r--r--src/core/hle/service/fatal/fatal.cpp2
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp4
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp5
-rw-r--r--src/core/hle/service/hid/hid.cpp22
-rw-r--r--src/core/hle/service/hid/hidbus.cpp4
-rw-r--r--src/core/hle/service/hid/irs.cpp8
-rw-r--r--src/core/hle/service/jit/jit.cpp4
-rw-r--r--src/core/hle/service/ldr/ldr.cpp13
-rw-r--r--src/core/hle/service/nfp/nfp_device.cpp2
-rw-r--r--src/core/hle/service/nvdrv/core/syncpoint_manager.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp4
-rw-r--r--src/core/hle/service/nvdrv/devices/nvmap.cpp4
-rw-r--r--src/core/hle/service/pctl/pctl_module.cpp2
-rw-r--r--src/core/hle/service/pcv/pcv.cpp28
-rw-r--r--src/core/hle/service/prepo/prepo.cpp4
-rw-r--r--src/core/hle/service/service.cpp2
-rw-r--r--src/core/hle/service/sockets/ethc.cpp42
-rw-r--r--src/core/hle/service/sockets/ethc.h26
-rw-r--r--src/core/hle/service/sockets/sockets.cpp4
-rw-r--r--src/core/hle/service/time/time_zone_manager.cpp2
-rw-r--r--src/core/hle/service/wlan/wlan.cpp186
-rw-r--r--src/core/hle/service/wlan/wlan.h18
-rw-r--r--src/core/loader/nso.cpp2
-rw-r--r--src/core/memory.cpp10
-rw-r--r--src/core/memory/cheat_engine.cpp6
-rw-r--r--src/core/reporter.cpp10
-rw-r--r--src/core/telemetry_session.cpp2
-rw-r--r--src/input_common/drivers/joycon.cpp2
-rw-r--r--src/input_common/drivers/sdl_driver.cpp4
-rw-r--r--src/video_core/engines/maxwell_3d.cpp2
-rw-r--r--src/video_core/memory_manager.h2
-rw-r--r--src/video_core/renderer_vulkan/vk_smaa.cpp14
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.h2
-rw-r--r--src/video_core/renderer_vulkan/vk_turbo_mode.cpp4
-rw-r--r--src/video_core/textures/decoders.cpp2
-rw-r--r--src/yuzu/bootmanager.cpp2
-rw-r--r--src/yuzu/main.cpp8
-rw-r--r--src/yuzu_cmd/yuzu.cpp2
119 files changed, 463 insertions, 1014 deletions
diff --git a/src/audio_core/renderer/adsp/audio_renderer.cpp b/src/audio_core/renderer/adsp/audio_renderer.cpp
index d982ef630..78c15629b 100644
--- a/src/audio_core/renderer/adsp/audio_renderer.cpp
+++ b/src/audio_core/renderer/adsp/audio_renderer.cpp
@@ -132,7 +132,7 @@ void AudioRenderer::CreateSinkStreams() {
132} 132}
133 133
134void AudioRenderer::ThreadFunc() { 134void AudioRenderer::ThreadFunc() {
135 constexpr char name[]{"AudioRenderer"}; 135 static constexpr char name[]{"AudioRenderer"};
136 MicroProfileOnThreadCreate(name); 136 MicroProfileOnThreadCreate(name);
137 Common::SetCurrentThreadName(name); 137 Common::SetCurrentThreadName(name);
138 Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); 138 Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical);
diff --git a/src/audio_core/renderer/command/command_buffer.cpp b/src/audio_core/renderer/command/command_buffer.cpp
index 8c6fe97e7..0bd418306 100644
--- a/src/audio_core/renderer/command/command_buffer.cpp
+++ b/src/audio_core/renderer/command/command_buffer.cpp
@@ -251,8 +251,8 @@ void CommandBuffer::GenerateBiquadFilterCommand(const s32 node_id, EffectInfoBas
251 251
252 const auto& parameter{ 252 const auto& parameter{
253 *reinterpret_cast<BiquadFilterInfo::ParameterVersion1*>(effect_info.GetParameter())}; 253 *reinterpret_cast<BiquadFilterInfo::ParameterVersion1*>(effect_info.GetParameter())};
254 const auto state{ 254 const auto state{reinterpret_cast<VoiceState::BiquadFilterState*>(
255 reinterpret_cast<VoiceState::BiquadFilterState*>(effect_info.GetStateBuffer())}; 255 effect_info.GetStateBuffer() + channel * sizeof(VoiceState::BiquadFilterState))};
256 256
257 cmd.input = buffer_offset + parameter.inputs[channel]; 257 cmd.input = buffer_offset + parameter.inputs[channel];
258 cmd.output = buffer_offset + parameter.outputs[channel]; 258 cmd.output = buffer_offset + parameter.outputs[channel];
diff --git a/src/audio_core/renderer/command/command_generator.cpp b/src/audio_core/renderer/command/command_generator.cpp
index 2ea50d128..fba84c7bd 100644
--- a/src/audio_core/renderer/command/command_generator.cpp
+++ b/src/audio_core/renderer/command/command_generator.cpp
@@ -46,7 +46,7 @@ void CommandGenerator::GenerateDataSourceCommand(VoiceInfo& voice_info,
46 while (destination != nullptr) { 46 while (destination != nullptr) {
47 if (destination->IsConfigured()) { 47 if (destination->IsConfigured()) {
48 auto mix_id{destination->GetMixId()}; 48 auto mix_id{destination->GetMixId()};
49 if (mix_id < mix_context.GetCount()) { 49 if (mix_id < mix_context.GetCount() && mix_id != UnusedSplitterId) {
50 auto mix_info{mix_context.GetInfo(mix_id)}; 50 auto mix_info{mix_context.GetInfo(mix_id)};
51 command_buffer.GenerateDepopPrepareCommand( 51 command_buffer.GenerateDepopPrepareCommand(
52 voice_info.node_id, voice_state, render_context.depop_buffer, 52 voice_info.node_id, voice_state, render_context.depop_buffer,
diff --git a/src/audio_core/renderer/command/effect/aux_.cpp b/src/audio_core/renderer/command/effect/aux_.cpp
index e76db893f..c5650effa 100644
--- a/src/audio_core/renderer/command/effect/aux_.cpp
+++ b/src/audio_core/renderer/command/effect/aux_.cpp
@@ -4,6 +4,7 @@
4#include "audio_core/renderer/adsp/command_list_processor.h" 4#include "audio_core/renderer/adsp/command_list_processor.h"
5#include "audio_core/renderer/command/effect/aux_.h" 5#include "audio_core/renderer/command/effect/aux_.h"
6#include "audio_core/renderer/effect/aux_.h" 6#include "audio_core/renderer/effect/aux_.h"
7#include "core/core.h"
7#include "core/memory.h" 8#include "core/memory.h"
8 9
9namespace AudioCore::AudioRenderer { 10namespace AudioCore::AudioRenderer {
@@ -19,10 +20,24 @@ static void ResetAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr aux_in
19 return; 20 return;
20 } 21 }
21 22
22 auto info{reinterpret_cast<AuxInfo::AuxInfoDsp*>(memory.GetPointer(aux_info))}; 23 AuxInfo::AuxInfoDsp info{};
23 info->read_offset = 0; 24 auto info_ptr{&info};
24 info->write_offset = 0; 25 bool host_safe{(aux_info & Core::Memory::YUZU_PAGEMASK) <=
25 info->total_sample_count = 0; 26 (Core::Memory::YUZU_PAGESIZE - sizeof(AuxInfo::AuxInfoDsp))};
27
28 if (host_safe) [[likely]] {
29 info_ptr = memory.GetPointer<AuxInfo::AuxInfoDsp>(aux_info);
30 } else {
31 memory.ReadBlockUnsafe(aux_info, info_ptr, sizeof(AuxInfo::AuxInfoDsp));
32 }
33
34 info_ptr->read_offset = 0;
35 info_ptr->write_offset = 0;
36 info_ptr->total_sample_count = 0;
37
38 if (!host_safe) [[unlikely]] {
39 memory.WriteBlockUnsafe(aux_info, info_ptr, sizeof(AuxInfo::AuxInfoDsp));
40 }
26} 41}
27 42
28/** 43/**
@@ -40,11 +55,10 @@ static void ResetAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr aux_in
40 * @param update_count - If non-zero, send_info_ will be updated. 55 * @param update_count - If non-zero, send_info_ will be updated.
41 * @return Number of samples written. 56 * @return Number of samples written.
42 */ 57 */
43static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_info_, 58static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr send_info_,
44 [[maybe_unused]] u32 sample_count, const CpuAddr send_buffer, 59 [[maybe_unused]] u32 sample_count, CpuAddr send_buffer, u32 count_max,
45 const u32 count_max, std::span<const s32> input, 60 std::span<const s32> input, u32 write_count_, u32 write_offset,
46 const u32 write_count_, const u32 write_offset, 61 u32 update_count) {
47 const u32 update_count) {
48 if (write_count_ > count_max) { 62 if (write_count_ > count_max) {
49 LOG_ERROR(Service_Audio, 63 LOG_ERROR(Service_Audio,
50 "write_count must be smaller than count_max! write_count {}, count_max {}", 64 "write_count must be smaller than count_max! write_count {}, count_max {}",
@@ -52,6 +66,11 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_in
52 return 0; 66 return 0;
53 } 67 }
54 68
69 if (send_info_ == 0) {
70 LOG_ERROR(Service_Audio, "send_info_ is 0!");
71 return 0;
72 }
73
55 if (input.empty()) { 74 if (input.empty()) {
56 LOG_ERROR(Service_Audio, "input buffer is empty!"); 75 LOG_ERROR(Service_Audio, "input buffer is empty!");
57 return 0; 76 return 0;
@@ -67,33 +86,47 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_in
67 } 86 }
68 87
69 AuxInfo::AuxInfoDsp send_info{}; 88 AuxInfo::AuxInfoDsp send_info{};
70 memory.ReadBlockUnsafe(send_info_, &send_info, sizeof(AuxInfo::AuxInfoDsp)); 89 auto send_ptr = &send_info;
90 bool host_safe = (send_info_ & Core::Memory::YUZU_PAGEMASK) <=
91 (Core::Memory::YUZU_PAGESIZE - sizeof(AuxInfo::AuxInfoDsp));
71 92
72 u32 target_write_offset{send_info.write_offset + write_offset}; 93 if (host_safe) [[likely]] {
73 if (target_write_offset > count_max || write_count_ == 0) { 94 send_ptr = memory.GetPointer<AuxInfo::AuxInfoDsp>(send_info_);
95 } else {
96 memory.ReadBlockUnsafe(send_info_, send_ptr, sizeof(AuxInfo::AuxInfoDsp));
97 }
98
99 u32 target_write_offset{send_ptr->write_offset + write_offset};
100 if (target_write_offset > count_max) {
74 return 0; 101 return 0;
75 } 102 }
76 103
77 u32 write_count{write_count_}; 104 u32 write_count{write_count_};
78 u32 write_pos{0}; 105 u32 read_pos{0};
79 while (write_count > 0) { 106 while (write_count > 0) {
80 u32 to_write{std::min(count_max - target_write_offset, write_count)}; 107 u32 to_write{std::min(count_max - target_write_offset, write_count)};
81 108 const auto write_addr = send_buffer + target_write_offset * sizeof(s32);
82 if (to_write > 0) { 109 bool write_safe{(write_addr & Core::Memory::YUZU_PAGEMASK) <=
110 (Core::Memory::YUZU_PAGESIZE - (write_addr + to_write * sizeof(s32)))};
111 if (write_safe) [[likely]] {
112 auto ptr = memory.GetPointer(write_addr);
113 std::memcpy(ptr, &input[read_pos], to_write * sizeof(s32));
114 } else {
83 memory.WriteBlockUnsafe(send_buffer + target_write_offset * sizeof(s32), 115 memory.WriteBlockUnsafe(send_buffer + target_write_offset * sizeof(s32),
84 &input[write_pos], to_write * sizeof(s32)); 116 &input[read_pos], to_write * sizeof(s32));
85 } 117 }
86
87 target_write_offset = (target_write_offset + to_write) % count_max; 118 target_write_offset = (target_write_offset + to_write) % count_max;
88 write_count -= to_write; 119 write_count -= to_write;
89 write_pos += to_write; 120 read_pos += to_write;
90 } 121 }
91 122
92 if (update_count) { 123 if (update_count) {
93 send_info.write_offset = (send_info.write_offset + update_count) % count_max; 124 send_ptr->write_offset = (send_ptr->write_offset + update_count) % count_max;
94 } 125 }
95 126
96 memory.WriteBlockUnsafe(send_info_, &send_info, sizeof(AuxInfo::AuxInfoDsp)); 127 if (!host_safe) [[unlikely]] {
128 memory.WriteBlockUnsafe(send_info_, send_ptr, sizeof(AuxInfo::AuxInfoDsp));
129 }
97 130
98 return write_count_; 131 return write_count_;
99} 132}
@@ -102,7 +135,7 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_in
102 * Read the given memory at return_buffer into the output mix buffer, and update return_info_ if 135 * Read the given memory at return_buffer into the output mix buffer, and update return_info_ if
103 * update_count is set, to notify the game that an update happened. 136 * update_count is set, to notify the game that an update happened.
104 * 137 *
105 * @param memory - Core memory for writing. 138 * @param memory - Core memory for reading.
106 * @param return_info_ - Meta information for where to read the mix buffer. 139 * @param return_info_ - Meta information for where to read the mix buffer.
107 * @param return_buffer - Memory address to read the samples from. 140 * @param return_buffer - Memory address to read the samples from.
108 * @param count_max - Maximum number of samples in the receiving buffer. 141 * @param count_max - Maximum number of samples in the receiving buffer.
@@ -112,16 +145,21 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_in
112 * @param update_count - If non-zero, send_info_ will be updated. 145 * @param update_count - If non-zero, send_info_ will be updated.
113 * @return Number of samples read. 146 * @return Number of samples read.
114 */ 147 */
115static u32 ReadAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr return_info_, 148static u32 ReadAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr return_info_,
116 const CpuAddr return_buffer, const u32 count_max, std::span<s32> output, 149 CpuAddr return_buffer, u32 count_max, std::span<s32> output,
117 const u32 count_, const u32 read_offset, const u32 update_count) { 150 u32 read_count_, u32 read_offset, u32 update_count) {
118 if (count_max == 0) { 151 if (count_max == 0) {
119 return 0; 152 return 0;
120 } 153 }
121 154
122 if (count_ > count_max) { 155 if (read_count_ > count_max) {
123 LOG_ERROR(Service_Audio, "count must be smaller than count_max! count {}, count_max {}", 156 LOG_ERROR(Service_Audio, "count must be smaller than count_max! count {}, count_max {}",
124 count_, count_max); 157 read_count_, count_max);
158 return 0;
159 }
160
161 if (return_info_ == 0) {
162 LOG_ERROR(Service_Audio, "return_info_ is 0!");
125 return 0; 163 return 0;
126 } 164 }
127 165
@@ -136,35 +174,49 @@ static u32 ReadAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr return_i
136 } 174 }
137 175
138 AuxInfo::AuxInfoDsp return_info{}; 176 AuxInfo::AuxInfoDsp return_info{};
139 memory.ReadBlockUnsafe(return_info_, &return_info, sizeof(AuxInfo::AuxInfoDsp)); 177 auto return_ptr = &return_info;
178 bool host_safe = (return_info_ & Core::Memory::YUZU_PAGEMASK) <=
179 (Core::Memory::YUZU_PAGESIZE - sizeof(AuxInfo::AuxInfoDsp));
180
181 if (host_safe) [[likely]] {
182 return_ptr = memory.GetPointer<AuxInfo::AuxInfoDsp>(return_info_);
183 } else {
184 memory.ReadBlockUnsafe(return_info_, return_ptr, sizeof(AuxInfo::AuxInfoDsp));
185 }
140 186
141 u32 target_read_offset{return_info.read_offset + read_offset}; 187 u32 target_read_offset{return_ptr->read_offset + read_offset};
142 if (target_read_offset > count_max) { 188 if (target_read_offset > count_max) {
143 return 0; 189 return 0;
144 } 190 }
145 191
146 u32 read_count{count_}; 192 u32 read_count{read_count_};
147 u32 read_pos{0}; 193 u32 write_pos{0};
148 while (read_count > 0) { 194 while (read_count > 0) {
149 u32 to_read{std::min(count_max - target_read_offset, read_count)}; 195 u32 to_read{std::min(count_max - target_read_offset, read_count)};
150 196 const auto read_addr = return_buffer + target_read_offset * sizeof(s32);
151 if (to_read > 0) { 197 bool read_safe{(read_addr & Core::Memory::YUZU_PAGEMASK) <=
198 (Core::Memory::YUZU_PAGESIZE - (read_addr + to_read * sizeof(s32)))};
199 if (read_safe) [[likely]] {
200 auto ptr = memory.GetPointer(read_addr);
201 std::memcpy(&output[write_pos], ptr, to_read * sizeof(s32));
202 } else {
152 memory.ReadBlockUnsafe(return_buffer + target_read_offset * sizeof(s32), 203 memory.ReadBlockUnsafe(return_buffer + target_read_offset * sizeof(s32),
153 &output[read_pos], to_read * sizeof(s32)); 204 &output[write_pos], to_read * sizeof(s32));
154 } 205 }
155
156 target_read_offset = (target_read_offset + to_read) % count_max; 206 target_read_offset = (target_read_offset + to_read) % count_max;
157 read_count -= to_read; 207 read_count -= to_read;
158 read_pos += to_read; 208 write_pos += to_read;
159 } 209 }
160 210
161 if (update_count) { 211 if (update_count) {
162 return_info.read_offset = (return_info.read_offset + update_count) % count_max; 212 return_ptr->read_offset = (return_ptr->read_offset + update_count) % count_max;
163 } 213 }
164 214
165 memory.WriteBlockUnsafe(return_info_, &return_info, sizeof(AuxInfo::AuxInfoDsp)); 215 if (!host_safe) [[unlikely]] {
216 memory.WriteBlockUnsafe(return_info_, return_ptr, sizeof(AuxInfo::AuxInfoDsp));
217 }
166 218
167 return count_; 219 return read_count_;
168} 220}
169 221
170void AuxCommand::Dump([[maybe_unused]] const ADSP::CommandListProcessor& processor, 222void AuxCommand::Dump([[maybe_unused]] const ADSP::CommandListProcessor& processor,
@@ -189,7 +241,7 @@ void AuxCommand::Process(const ADSP::CommandListProcessor& processor) {
189 update_count)}; 241 update_count)};
190 242
191 if (read != processor.sample_count) { 243 if (read != processor.sample_count) {
192 std::memset(&output_buffer[read], 0, processor.sample_count - read); 244 std::memset(&output_buffer[read], 0, (processor.sample_count - read) * sizeof(s32));
193 } 245 }
194 } else { 246 } else {
195 ResetAuxBufferDsp(*processor.memory, send_buffer_info); 247 ResetAuxBufferDsp(*processor.memory, send_buffer_info);
diff --git a/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp b/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp
index 2187d8a65..27d8b9844 100644
--- a/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp
+++ b/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp
@@ -244,16 +244,16 @@ template <size_t NumChannels>
244static void ApplyI3dl2ReverbEffect(I3dl2ReverbInfo::State& state, 244static void ApplyI3dl2ReverbEffect(I3dl2ReverbInfo::State& state,
245 std::span<std::span<const s32>> inputs, 245 std::span<std::span<const s32>> inputs,
246 std::span<std::span<s32>> outputs, const u32 sample_count) { 246 std::span<std::span<s32>> outputs, const u32 sample_count) {
247 constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes1Ch{ 247 static constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes1Ch{
248 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 248 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
249 }; 249 };
250 constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes2Ch{ 250 static constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes2Ch{
251 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 251 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1,
252 }; 252 };
253 constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes4Ch{ 253 static constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes4Ch{
254 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3, 254 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3,
255 }; 255 };
256 constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes6Ch{ 256 static constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes6Ch{
257 2, 0, 0, 1, 1, 1, 1, 4, 4, 4, 1, 1, 1, 0, 0, 0, 0, 5, 5, 5, 257 2, 0, 0, 1, 1, 1, 1, 4, 4, 4, 1, 1, 1, 0, 0, 0, 0, 5, 5, 5,
258 }; 258 };
259 259
diff --git a/src/audio_core/renderer/command/effect/reverb.cpp b/src/audio_core/renderer/command/effect/reverb.cpp
index 427489214..6fe844ff0 100644
--- a/src/audio_core/renderer/command/effect/reverb.cpp
+++ b/src/audio_core/renderer/command/effect/reverb.cpp
@@ -252,16 +252,16 @@ template <size_t NumChannels>
252static void ApplyReverbEffect(const ReverbInfo::ParameterVersion2& params, ReverbInfo::State& state, 252static void ApplyReverbEffect(const ReverbInfo::ParameterVersion2& params, ReverbInfo::State& state,
253 std::vector<std::span<const s32>>& inputs, 253 std::vector<std::span<const s32>>& inputs,
254 std::vector<std::span<s32>>& outputs, const u32 sample_count) { 254 std::vector<std::span<s32>>& outputs, const u32 sample_count) {
255 constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes1Ch{ 255 static constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes1Ch{
256 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
257 }; 257 };
258 constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes2Ch{ 258 static constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes2Ch{
259 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 259 0, 0, 1, 1, 0, 1, 0, 0, 1, 1,
260 }; 260 };
261 constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes4Ch{ 261 static constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes4Ch{
262 0, 0, 1, 1, 0, 1, 2, 2, 3, 3, 262 0, 0, 1, 1, 0, 1, 2, 2, 3, 3,
263 }; 263 };
264 constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes6Ch{ 264 static constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes6Ch{
265 0, 0, 1, 1, 2, 2, 4, 4, 5, 5, 265 0, 0, 1, 1, 2, 2, 4, 4, 5, 5,
266 }; 266 };
267 267
diff --git a/src/audio_core/renderer/command/resample/upsample.cpp b/src/audio_core/renderer/command/resample/upsample.cpp
index 5f7db12ca..86ddee1a4 100644
--- a/src/audio_core/renderer/command/resample/upsample.cpp
+++ b/src/audio_core/renderer/command/resample/upsample.cpp
@@ -19,24 +19,24 @@ namespace AudioCore::AudioRenderer {
19static void SrcProcessFrame(std::span<s32> output, std::span<const s32> input, 19static void SrcProcessFrame(std::span<s32> output, std::span<const s32> input,
20 const u32 target_sample_count, const u32 source_sample_count, 20 const u32 target_sample_count, const u32 source_sample_count,
21 UpsamplerState* state) { 21 UpsamplerState* state) {
22 constexpr u32 WindowSize = 10; 22 static constexpr u32 WindowSize = 10;
23 constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc1{ 23 static constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc1{
24 0.95376587f, -0.12872314f, 0.060028076f, -0.032470703f, 0.017669678f, 24 0.95376587f, -0.12872314f, 0.060028076f, -0.032470703f, 0.017669678f,
25 -0.009124756f, 0.004272461f, -0.001739502f, 0.000579834f, -0.000091552734f, 25 -0.009124756f, 0.004272461f, -0.001739502f, 0.000579834f, -0.000091552734f,
26 }; 26 };
27 constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc2{ 27 static constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc2{
28 0.8230896f, -0.19161987f, 0.093444824f, -0.05090332f, 0.027557373f, 28 0.8230896f, -0.19161987f, 0.093444824f, -0.05090332f, 0.027557373f,
29 -0.014038086f, 0.0064697266f, -0.002532959f, 0.00079345703f, -0.00012207031f, 29 -0.014038086f, 0.0064697266f, -0.002532959f, 0.00079345703f, -0.00012207031f,
30 }; 30 };
31 constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc3{ 31 static constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc3{
32 0.6298828f, -0.19274902f, 0.09725952f, -0.05319214f, 0.028625488f, 32 0.6298828f, -0.19274902f, 0.09725952f, -0.05319214f, 0.028625488f,
33 -0.014373779f, 0.006500244f, -0.0024719238f, 0.0007324219f, -0.000091552734f, 33 -0.014373779f, 0.006500244f, -0.0024719238f, 0.0007324219f, -0.000091552734f,
34 }; 34 };
35 constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc4{ 35 static constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc4{
36 0.4057312f, -0.1468811f, 0.07601929f, -0.041656494f, 0.022216797f, 36 0.4057312f, -0.1468811f, 0.07601929f, -0.041656494f, 0.022216797f,
37 -0.011016846f, 0.004852295f, -0.0017700195f, 0.00048828125f, -0.000030517578f, 37 -0.011016846f, 0.004852295f, -0.0017700195f, 0.00048828125f, -0.000030517578f,
38 }; 38 };
39 constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc5{ 39 static constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc5{
40 0.1854248f, -0.075164795f, 0.03967285f, -0.021728516f, 0.011474609f, 40 0.1854248f, -0.075164795f, 0.03967285f, -0.021728516f, 0.011474609f,
41 -0.005584717f, 0.0024108887f, -0.0008239746f, 0.00021362305f, 0.0f, 41 -0.005584717f, 0.0024108887f, -0.0008239746f, 0.00021362305f, 0.0f,
42 }; 42 };
diff --git a/src/audio_core/renderer/system.cpp b/src/audio_core/renderer/system.cpp
index 4fac30c7c..31cbee282 100644
--- a/src/audio_core/renderer/system.cpp
+++ b/src/audio_core/renderer/system.cpp
@@ -127,7 +127,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
127 render_device = params.rendering_device; 127 render_device = params.rendering_device;
128 execution_mode = params.execution_mode; 128 execution_mode = params.execution_mode;
129 129
130 core.Memory().ZeroBlock(*core.Kernel().CurrentProcess(), transfer_memory->GetSourceAddress(), 130 core.Memory().ZeroBlock(*core.ApplicationProcess(), transfer_memory->GetSourceAddress(),
131 transfer_memory_size); 131 transfer_memory_size);
132 132
133 // Note: We're not actually using the transfer memory because it's a pain to code for. 133 // Note: We're not actually using the transfer memory because it's a pain to code for.
diff --git a/src/audio_core/renderer/system_manager.cpp b/src/audio_core/renderer/system_manager.cpp
index f66b2b890..ce631f810 100644
--- a/src/audio_core/renderer/system_manager.cpp
+++ b/src/audio_core/renderer/system_manager.cpp
@@ -94,7 +94,7 @@ bool SystemManager::Remove(System& system_) {
94} 94}
95 95
96void SystemManager::ThreadFunc() { 96void SystemManager::ThreadFunc() {
97 constexpr char name[]{"AudioRenderSystemManager"}; 97 static constexpr char name[]{"AudioRenderSystemManager"};
98 MicroProfileOnThreadCreate(name); 98 MicroProfileOnThreadCreate(name);
99 Common::SetCurrentThreadName(name); 99 Common::SetCurrentThreadName(name);
100 Common::SetCurrentThreadPriority(Common::ThreadPriority::High); 100 Common::SetCurrentThreadPriority(Common::ThreadPriority::High);
diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp
index 06c2a876e..39a21b0f0 100644
--- a/src/audio_core/sink/sink_stream.cpp
+++ b/src/audio_core/sink/sink_stream.cpp
@@ -35,7 +35,7 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::vector<s16>& samples) {
35 35
36 if (system_channels == 6 && device_channels == 2) { 36 if (system_channels == 6 && device_channels == 2) {
37 // We're given 6 channels, but our device only outputs 2, so downmix. 37 // We're given 6 channels, but our device only outputs 2, so downmix.
38 constexpr std::array<f32, 4> down_mix_coeff{1.0f, 0.707f, 0.251f, 0.707f}; 38 static constexpr std::array<f32, 4> down_mix_coeff{1.0f, 0.707f, 0.251f, 0.707f};
39 39
40 for (u32 read_index = 0, write_index = 0; read_index < samples.size(); 40 for (u32 read_index = 0, write_index = 0; read_index < samples.size();
41 read_index += system_channels, write_index += device_channels) { 41 read_index += system_channels, write_index += device_channels) {
@@ -202,7 +202,7 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz
202 // If we're paused or going to shut down, we don't want to consume buffers as coretiming is 202 // If we're paused or going to shut down, we don't want to consume buffers as coretiming is
203 // paused and we'll desync, so just play silence. 203 // paused and we'll desync, so just play silence.
204 if (system.IsPaused() || system.IsShuttingDown()) { 204 if (system.IsPaused() || system.IsShuttingDown()) {
205 constexpr std::array<s16, 6> silence{}; 205 static constexpr std::array<s16, 6> silence{};
206 for (size_t i = frames_written; i < num_frames; i++) { 206 for (size_t i = frames_written; i < num_frames; i++) {
207 std::memcpy(&output_buffer[i * frame_size], &silence[0], frame_size_bytes); 207 std::memcpy(&output_buffer[i * frame_size], &silence[0], frame_size_bytes);
208 } 208 }
@@ -270,7 +270,7 @@ void SinkStream::Stall() {
270 if (stalled_lock) { 270 if (stalled_lock) {
271 return; 271 return;
272 } 272 }
273 stalled_lock = system.StallProcesses(); 273 stalled_lock = system.StallApplication();
274} 274}
275 275
276void SinkStream::Unstall() { 276void SinkStream::Unstall() {
@@ -278,7 +278,7 @@ void SinkStream::Unstall() {
278 if (!stalled_lock) { 278 if (!stalled_lock) {
279 return; 279 return;
280 } 280 }
281 system.UnstallProcesses(); 281 system.UnstallApplication();
282 stalled_lock.unlock(); 282 stalled_lock.unlock();
283} 283}
284 284
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 8ef1fcaa8..16ced4595 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -384,8 +384,6 @@ add_library(core STATIC
384 hle/service/am/omm.h 384 hle/service/am/omm.h
385 hle/service/am/spsm.cpp 385 hle/service/am/spsm.cpp
386 hle/service/am/spsm.h 386 hle/service/am/spsm.h
387 hle/service/am/tcap.cpp
388 hle/service/am/tcap.h
389 hle/service/aoc/aoc_u.cpp 387 hle/service/aoc/aoc_u.cpp
390 hle/service/aoc/aoc_u.h 388 hle/service/aoc/aoc_u.h
391 hle/service/apm/apm.cpp 389 hle/service/apm/apm.cpp
@@ -396,28 +394,18 @@ add_library(core STATIC
396 hle/service/apm/apm_interface.h 394 hle/service/apm/apm_interface.h
397 hle/service/audio/audctl.cpp 395 hle/service/audio/audctl.cpp
398 hle/service/audio/audctl.h 396 hle/service/audio/audctl.h
399 hle/service/audio/auddbg.cpp
400 hle/service/audio/auddbg.h
401 hle/service/audio/audin_a.cpp
402 hle/service/audio/audin_a.h
403 hle/service/audio/audin_u.cpp 397 hle/service/audio/audin_u.cpp
404 hle/service/audio/audin_u.h 398 hle/service/audio/audin_u.h
405 hle/service/audio/audio.cpp 399 hle/service/audio/audio.cpp
406 hle/service/audio/audio.h 400 hle/service/audio/audio.h
407 hle/service/audio/audout_a.cpp
408 hle/service/audio/audout_a.h
409 hle/service/audio/audout_u.cpp 401 hle/service/audio/audout_u.cpp
410 hle/service/audio/audout_u.h 402 hle/service/audio/audout_u.h
411 hle/service/audio/audrec_a.cpp 403 hle/service/audio/audrec_a.cpp
412 hle/service/audio/audrec_a.h 404 hle/service/audio/audrec_a.h
413 hle/service/audio/audrec_u.cpp 405 hle/service/audio/audrec_u.cpp
414 hle/service/audio/audrec_u.h 406 hle/service/audio/audrec_u.h
415 hle/service/audio/audren_a.cpp
416 hle/service/audio/audren_a.h
417 hle/service/audio/audren_u.cpp 407 hle/service/audio/audren_u.cpp
418 hle/service/audio/audren_u.h 408 hle/service/audio/audren_u.h
419 hle/service/audio/codecctl.cpp
420 hle/service/audio/codecctl.h
421 hle/service/audio/errors.h 409 hle/service/audio/errors.h
422 hle/service/audio/hwopus.cpp 410 hle/service/audio/hwopus.cpp
423 hle/service/audio/hwopus.h 411 hle/service/audio/hwopus.h
@@ -712,8 +700,6 @@ add_library(core STATIC
712 hle/service/sm/sm_controller.h 700 hle/service/sm/sm_controller.h
713 hle/service/sockets/bsd.cpp 701 hle/service/sockets/bsd.cpp
714 hle/service/sockets/bsd.h 702 hle/service/sockets/bsd.h
715 hle/service/sockets/ethc.cpp
716 hle/service/sockets/ethc.h
717 hle/service/sockets/nsd.cpp 703 hle/service/sockets/nsd.cpp
718 hle/service/sockets/nsd.h 704 hle/service/sockets/nsd.h
719 hle/service/sockets/sfdnsres.cpp 705 hle/service/sockets/sfdnsres.cpp
@@ -780,8 +766,6 @@ add_library(core STATIC
780 hle/service/vi/vi_s.h 766 hle/service/vi/vi_s.h
781 hle/service/vi/vi_u.cpp 767 hle/service/vi/vi_u.cpp
782 hle/service/vi/vi_u.h 768 hle/service/vi/vi_u.h
783 hle/service/wlan/wlan.cpp
784 hle/service/wlan/wlan.h
785 internal_network/network.cpp 769 internal_network/network.cpp
786 internal_network/network.h 770 internal_network/network.h
787 internal_network/network_interface.cpp 771 internal_network/network_interface.cpp
diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp
index 8aa7b9641..4a331d4c1 100644
--- a/src/core/arm/arm_interface.cpp
+++ b/src/core/arm/arm_interface.cpp
@@ -43,9 +43,9 @@ void ARM_Interface::SymbolicateBacktrace(Core::System& system, std::vector<Backt
43 43
44 std::map<std::string, Symbols::Symbols> symbols; 44 std::map<std::string, Symbols::Symbols> symbols;
45 for (const auto& module : modules) { 45 for (const auto& module : modules) {
46 symbols.insert_or_assign(module.second, 46 symbols.insert_or_assign(
47 Symbols::GetSymbols(module.first, system.Memory(), 47 module.second, Symbols::GetSymbols(module.first, system.Memory(),
48 system.CurrentProcess()->Is64BitProcess())); 48 system.ApplicationProcess()->Is64BitProcess()));
49 } 49 }
50 50
51 for (auto& entry : out) { 51 for (auto& entry : out) {
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 47292cd78..fb9b25d12 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -186,7 +186,7 @@ struct System::Impl {
186 void Run() { 186 void Run() {
187 std::unique_lock<std::mutex> lk(suspend_guard); 187 std::unique_lock<std::mutex> lk(suspend_guard);
188 188
189 kernel.Suspend(false); 189 kernel.SuspendApplication(false);
190 core_timing.SyncPause(false); 190 core_timing.SyncPause(false);
191 is_paused.store(false, std::memory_order_relaxed); 191 is_paused.store(false, std::memory_order_relaxed);
192 } 192 }
@@ -195,7 +195,7 @@ struct System::Impl {
195 std::unique_lock<std::mutex> lk(suspend_guard); 195 std::unique_lock<std::mutex> lk(suspend_guard);
196 196
197 core_timing.SyncPause(true); 197 core_timing.SyncPause(true);
198 kernel.Suspend(true); 198 kernel.SuspendApplication(true);
199 is_paused.store(true, std::memory_order_relaxed); 199 is_paused.store(true, std::memory_order_relaxed);
200 } 200 }
201 201
@@ -203,17 +203,17 @@ struct System::Impl {
203 return is_paused.load(std::memory_order_relaxed); 203 return is_paused.load(std::memory_order_relaxed);
204 } 204 }
205 205
206 std::unique_lock<std::mutex> StallProcesses() { 206 std::unique_lock<std::mutex> StallApplication() {
207 std::unique_lock<std::mutex> lk(suspend_guard); 207 std::unique_lock<std::mutex> lk(suspend_guard);
208 kernel.Suspend(true); 208 kernel.SuspendApplication(true);
209 core_timing.SyncPause(true); 209 core_timing.SyncPause(true);
210 return lk; 210 return lk;
211 } 211 }
212 212
213 void UnstallProcesses() { 213 void UnstallApplication() {
214 if (!IsPaused()) { 214 if (!IsPaused()) {
215 core_timing.SyncPause(false); 215 core_timing.SyncPause(false);
216 kernel.Suspend(false); 216 kernel.SuspendApplication(false);
217 } 217 }
218 } 218 }
219 219
@@ -221,7 +221,7 @@ struct System::Impl {
221 debugger = std::make_unique<Debugger>(system, port); 221 debugger = std::make_unique<Debugger>(system, port);
222 } 222 }
223 223
224 SystemResultStatus SetupForMainProcess(System& system, Frontend::EmuWindow& emu_window) { 224 SystemResultStatus SetupForApplicationProcess(System& system, Frontend::EmuWindow& emu_window) {
225 LOG_DEBUG(Core, "initialized OK"); 225 LOG_DEBUG(Core, "initialized OK");
226 226
227 // Setting changes may require a full system reinitialization (e.g., disabling multicore). 227 // Setting changes may require a full system reinitialization (e.g., disabling multicore).
@@ -273,7 +273,7 @@ struct System::Impl {
273 return SystemResultStatus::ErrorGetLoader; 273 return SystemResultStatus::ErrorGetLoader;
274 } 274 }
275 275
276 SystemResultStatus init_result{SetupForMainProcess(system, emu_window)}; 276 SystemResultStatus init_result{SetupForApplicationProcess(system, emu_window)};
277 if (init_result != SystemResultStatus::Success) { 277 if (init_result != SystemResultStatus::Success) {
278 LOG_CRITICAL(Core, "Failed to initialize system (Error {})!", 278 LOG_CRITICAL(Core, "Failed to initialize system (Error {})!",
279 static_cast<int>(init_result)); 279 static_cast<int>(init_result));
@@ -302,7 +302,7 @@ struct System::Impl {
302 static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result)); 302 static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result));
303 } 303 }
304 AddGlueRegistrationForProcess(*app_loader, *main_process); 304 AddGlueRegistrationForProcess(*app_loader, *main_process);
305 kernel.MakeCurrentProcess(main_process); 305 kernel.MakeApplicationProcess(main_process);
306 kernel.InitializeCores(); 306 kernel.InitializeCores();
307 307
308 // Initialize cheat engine 308 // Initialize cheat engine
@@ -585,12 +585,12 @@ void System::DetachDebugger() {
585 } 585 }
586} 586}
587 587
588std::unique_lock<std::mutex> System::StallProcesses() { 588std::unique_lock<std::mutex> System::StallApplication() {
589 return impl->StallProcesses(); 589 return impl->StallApplication();
590} 590}
591 591
592void System::UnstallProcesses() { 592void System::UnstallApplication() {
593 impl->UnstallProcesses(); 593 impl->UnstallApplication();
594} 594}
595 595
596void System::InitializeDebugger() { 596void System::InitializeDebugger() {
@@ -648,8 +648,8 @@ const Kernel::GlobalSchedulerContext& System::GlobalSchedulerContext() const {
648 return impl->kernel.GlobalSchedulerContext(); 648 return impl->kernel.GlobalSchedulerContext();
649} 649}
650 650
651Kernel::KProcess* System::CurrentProcess() { 651Kernel::KProcess* System::ApplicationProcess() {
652 return impl->kernel.CurrentProcess(); 652 return impl->kernel.ApplicationProcess();
653} 653}
654 654
655Core::DeviceMemory& System::DeviceMemory() { 655Core::DeviceMemory& System::DeviceMemory() {
@@ -660,8 +660,8 @@ const Core::DeviceMemory& System::DeviceMemory() const {
660 return *impl->device_memory; 660 return *impl->device_memory;
661} 661}
662 662
663const Kernel::KProcess* System::CurrentProcess() const { 663const Kernel::KProcess* System::ApplicationProcess() const {
664 return impl->kernel.CurrentProcess(); 664 return impl->kernel.ApplicationProcess();
665} 665}
666 666
667ARM_Interface& System::ArmInterface(std::size_t core_index) { 667ARM_Interface& System::ArmInterface(std::size_t core_index) {
@@ -760,8 +760,8 @@ const Core::SpeedLimiter& System::SpeedLimiter() const {
760 return impl->speed_limiter; 760 return impl->speed_limiter;
761} 761}
762 762
763u64 System::GetCurrentProcessProgramID() const { 763u64 System::GetApplicationProcessProgramID() const {
764 return impl->kernel.CurrentProcess()->GetProgramID(); 764 return impl->kernel.ApplicationProcess()->GetProgramID();
765} 765}
766 766
767Loader::ResultStatus System::GetGameName(std::string& out) const { 767Loader::ResultStatus System::GetGameName(std::string& out) const {
@@ -880,11 +880,11 @@ bool System::GetExitLock() const {
880 return impl->exit_lock; 880 return impl->exit_lock;
881} 881}
882 882
883void System::SetCurrentProcessBuildID(const CurrentBuildProcessID& id) { 883void System::SetApplicationProcessBuildID(const CurrentBuildProcessID& id) {
884 impl->build_id = id; 884 impl->build_id = id;
885} 885}
886 886
887const System::CurrentBuildProcessID& System::GetCurrentProcessBuildID() const { 887const System::CurrentBuildProcessID& System::GetApplicationProcessBuildID() const {
888 return impl->build_id; 888 return impl->build_id;
889} 889}
890 890
diff --git a/src/core/core.h b/src/core/core.h
index fb5cda2f5..0042ac170 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -184,8 +184,8 @@ public:
184 /// Forcibly detach the debugger if it is running. 184 /// Forcibly detach the debugger if it is running.
185 void DetachDebugger(); 185 void DetachDebugger();
186 186
187 std::unique_lock<std::mutex> StallProcesses(); 187 std::unique_lock<std::mutex> StallApplication();
188 void UnstallProcesses(); 188 void UnstallApplication();
189 189
190 /** 190 /**
191 * Initialize the debugger. 191 * Initialize the debugger.
@@ -295,11 +295,11 @@ public:
295 /// Gets the manager for the guest device memory 295 /// Gets the manager for the guest device memory
296 [[nodiscard]] const Core::DeviceMemory& DeviceMemory() const; 296 [[nodiscard]] const Core::DeviceMemory& DeviceMemory() const;
297 297
298 /// Provides a pointer to the current process 298 /// Provides a pointer to the application process
299 [[nodiscard]] Kernel::KProcess* CurrentProcess(); 299 [[nodiscard]] Kernel::KProcess* ApplicationProcess();
300 300
301 /// Provides a constant pointer to the current process. 301 /// Provides a constant pointer to the application process.
302 [[nodiscard]] const Kernel::KProcess* CurrentProcess() const; 302 [[nodiscard]] const Kernel::KProcess* ApplicationProcess() const;
303 303
304 /// Provides a reference to the core timing instance. 304 /// Provides a reference to the core timing instance.
305 [[nodiscard]] Timing::CoreTiming& CoreTiming(); 305 [[nodiscard]] Timing::CoreTiming& CoreTiming();
@@ -331,7 +331,7 @@ public:
331 /// Provides a constant reference to the speed limiter 331 /// Provides a constant reference to the speed limiter
332 [[nodiscard]] const Core::SpeedLimiter& SpeedLimiter() const; 332 [[nodiscard]] const Core::SpeedLimiter& SpeedLimiter() const;
333 333
334 [[nodiscard]] u64 GetCurrentProcessProgramID() const; 334 [[nodiscard]] u64 GetApplicationProcessProgramID() const;
335 335
336 /// Gets the name of the current game 336 /// Gets the name of the current game
337 [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const; 337 [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const;
@@ -396,8 +396,8 @@ public:
396 void SetExitLock(bool locked); 396 void SetExitLock(bool locked);
397 [[nodiscard]] bool GetExitLock() const; 397 [[nodiscard]] bool GetExitLock() const;
398 398
399 void SetCurrentProcessBuildID(const CurrentBuildProcessID& id); 399 void SetApplicationProcessBuildID(const CurrentBuildProcessID& id);
400 [[nodiscard]] const CurrentBuildProcessID& GetCurrentProcessBuildID() const; 400 [[nodiscard]] const CurrentBuildProcessID& GetApplicationProcessBuildID() const;
401 401
402 /// Register a host thread as an emulated CPU Core. 402 /// Register a host thread as an emulated CPU Core.
403 void RegisterCoreThread(std::size_t id); 403 void RegisterCoreThread(std::size_t id);
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 6bac6722f..3a63b52e3 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -45,7 +45,7 @@ CoreTiming::~CoreTiming() {
45} 45}
46 46
47void CoreTiming::ThreadEntry(CoreTiming& instance) { 47void CoreTiming::ThreadEntry(CoreTiming& instance) {
48 constexpr char name[] = "HostTiming"; 48 static constexpr char name[] = "HostTiming";
49 MicroProfileOnThreadCreate(name); 49 MicroProfileOnThreadCreate(name);
50 Common::SetCurrentThreadName(name); 50 Common::SetCurrentThreadName(name);
51 Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); 51 Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical);
diff --git a/src/core/debugger/gdbstub.cpp b/src/core/debugger/gdbstub.cpp
index 9c02b7b31..945ec528e 100644
--- a/src/core/debugger/gdbstub.cpp
+++ b/src/core/debugger/gdbstub.cpp
@@ -96,7 +96,7 @@ static std::string EscapeXML(std::string_view data) {
96 96
97GDBStub::GDBStub(DebuggerBackend& backend_, Core::System& system_) 97GDBStub::GDBStub(DebuggerBackend& backend_, Core::System& system_)
98 : DebuggerFrontend(backend_), system{system_} { 98 : DebuggerFrontend(backend_), system{system_} {
99 if (system.CurrentProcess()->Is64BitProcess()) { 99 if (system.ApplicationProcess()->Is64BitProcess()) {
100 arch = std::make_unique<GDBStubA64>(); 100 arch = std::make_unique<GDBStubA64>();
101 } else { 101 } else {
102 arch = std::make_unique<GDBStubA32>(); 102 arch = std::make_unique<GDBStubA32>();
@@ -340,15 +340,15 @@ void GDBStub::HandleBreakpointInsert(std::string_view command) {
340 success = true; 340 success = true;
341 break; 341 break;
342 case BreakpointType::WriteWatch: 342 case BreakpointType::WriteWatch:
343 success = system.CurrentProcess()->InsertWatchpoint(system, addr, size, 343 success = system.ApplicationProcess()->InsertWatchpoint(system, addr, size,
344 Kernel::DebugWatchpointType::Write); 344 Kernel::DebugWatchpointType::Write);
345 break; 345 break;
346 case BreakpointType::ReadWatch: 346 case BreakpointType::ReadWatch:
347 success = system.CurrentProcess()->InsertWatchpoint(system, addr, size, 347 success = system.ApplicationProcess()->InsertWatchpoint(system, addr, size,
348 Kernel::DebugWatchpointType::Read); 348 Kernel::DebugWatchpointType::Read);
349 break; 349 break;
350 case BreakpointType::AccessWatch: 350 case BreakpointType::AccessWatch:
351 success = system.CurrentProcess()->InsertWatchpoint( 351 success = system.ApplicationProcess()->InsertWatchpoint(
352 system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite); 352 system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite);
353 break; 353 break;
354 case BreakpointType::Hardware: 354 case BreakpointType::Hardware:
@@ -391,15 +391,15 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) {
391 break; 391 break;
392 } 392 }
393 case BreakpointType::WriteWatch: 393 case BreakpointType::WriteWatch:
394 success = system.CurrentProcess()->RemoveWatchpoint(system, addr, size, 394 success = system.ApplicationProcess()->RemoveWatchpoint(system, addr, size,
395 Kernel::DebugWatchpointType::Write); 395 Kernel::DebugWatchpointType::Write);
396 break; 396 break;
397 case BreakpointType::ReadWatch: 397 case BreakpointType::ReadWatch:
398 success = system.CurrentProcess()->RemoveWatchpoint(system, addr, size, 398 success = system.ApplicationProcess()->RemoveWatchpoint(system, addr, size,
399 Kernel::DebugWatchpointType::Read); 399 Kernel::DebugWatchpointType::Read);
400 break; 400 break;
401 case BreakpointType::AccessWatch: 401 case BreakpointType::AccessWatch:
402 success = system.CurrentProcess()->RemoveWatchpoint( 402 success = system.ApplicationProcess()->RemoveWatchpoint(
403 system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite); 403 system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite);
404 break; 404 break;
405 case BreakpointType::Hardware: 405 case BreakpointType::Hardware:
@@ -482,7 +482,7 @@ static std::optional<std::string> GetNameFromThreadType64(Core::Memory::Memory&
482 482
483static std::optional<std::string> GetThreadName(Core::System& system, 483static std::optional<std::string> GetThreadName(Core::System& system,
484 const Kernel::KThread* thread) { 484 const Kernel::KThread* thread) {
485 if (system.CurrentProcess()->Is64BitProcess()) { 485 if (system.ApplicationProcess()->Is64BitProcess()) {
486 return GetNameFromThreadType64(system.Memory(), thread); 486 return GetNameFromThreadType64(system.Memory(), thread);
487 } else { 487 } else {
488 return GetNameFromThreadType32(system.Memory(), thread); 488 return GetNameFromThreadType32(system.Memory(), thread);
@@ -555,7 +555,7 @@ void GDBStub::HandleQuery(std::string_view command) {
555 SendReply(fmt::format("TextSeg={:x}", main->first)); 555 SendReply(fmt::format("TextSeg={:x}", main->first));
556 } else { 556 } else {
557 SendReply(fmt::format("TextSeg={:x}", 557 SendReply(fmt::format("TextSeg={:x}",
558 system.CurrentProcess()->PageTable().GetCodeRegionStart())); 558 system.ApplicationProcess()->PageTable().GetCodeRegionStart()));
559 } 559 }
560 } else if (command.starts_with("Xfer:libraries:read::")) { 560 } else if (command.starts_with("Xfer:libraries:read::")) {
561 Loader::AppLoader::Modules modules; 561 Loader::AppLoader::Modules modules;
@@ -729,7 +729,7 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
729 std::string_view command_str{reinterpret_cast<const char*>(&command[0]), command.size()}; 729 std::string_view command_str{reinterpret_cast<const char*>(&command[0]), command.size()};
730 std::string reply; 730 std::string reply;
731 731
732 auto* process = system.CurrentProcess(); 732 auto* process = system.ApplicationProcess();
733 auto& page_table = process->PageTable(); 733 auto& page_table = process->PageTable();
734 734
735 const char* commands = "Commands:\n" 735 const char* commands = "Commands:\n"
diff --git a/src/core/debugger/gdbstub_arch.cpp b/src/core/debugger/gdbstub_arch.cpp
index 4bef09bd7..831c48513 100644
--- a/src/core/debugger/gdbstub_arch.cpp
+++ b/src/core/debugger/gdbstub_arch.cpp
@@ -41,9 +41,8 @@ static void PutSIMDRegister(std::array<u32, 64>& simd_regs, size_t offset, const
41 41
42// For sample XML files see the GDB source /gdb/features 42// For sample XML files see the GDB source /gdb/features
43// This XML defines what the registers are for this specific ARM device 43// This XML defines what the registers are for this specific ARM device
44std::string GDBStubA64::GetTargetXML() const { 44std::string_view GDBStubA64::GetTargetXML() const {
45 constexpr const char* target_xml = 45 return R"(<?xml version="1.0"?>
46 R"(<?xml version="1.0"?>
47<!DOCTYPE target SYSTEM "gdb-target.dtd"> 46<!DOCTYPE target SYSTEM "gdb-target.dtd">
48<target version="1.0"> 47<target version="1.0">
49 <architecture>aarch64</architecture> 48 <architecture>aarch64</architecture>
@@ -178,8 +177,6 @@ std::string GDBStubA64::GetTargetXML() const {
178 <reg name="fpcr" bitsize="32"/> 177 <reg name="fpcr" bitsize="32"/>
179 </feature> 178 </feature>
180</target>)"; 179</target>)";
181
182 return target_xml;
183} 180}
184 181
185std::string GDBStubA64::RegRead(const Kernel::KThread* thread, size_t id) const { 182std::string GDBStubA64::RegRead(const Kernel::KThread* thread, size_t id) const {
@@ -270,9 +267,8 @@ u32 GDBStubA64::BreakpointInstruction() const {
270 return 0xd4200000; 267 return 0xd4200000;
271} 268}
272 269
273std::string GDBStubA32::GetTargetXML() const { 270std::string_view GDBStubA32::GetTargetXML() const {
274 constexpr const char* target_xml = 271 return R"(<?xml version="1.0"?>
275 R"(<?xml version="1.0"?>
276<!DOCTYPE target SYSTEM "gdb-target.dtd"> 272<!DOCTYPE target SYSTEM "gdb-target.dtd">
277<target version="1.0"> 273<target version="1.0">
278 <architecture>arm</architecture> 274 <architecture>arm</architecture>
@@ -378,8 +374,6 @@ std::string GDBStubA32::GetTargetXML() const {
378 <reg name="fpscr" bitsize="32" type="int" group="float" regnum="80"/> 374 <reg name="fpscr" bitsize="32" type="int" group="float" regnum="80"/>
379 </feature> 375 </feature>
380</target>)"; 376</target>)";
381
382 return target_xml;
383} 377}
384 378
385std::string GDBStubA32::RegRead(const Kernel::KThread* thread, size_t id) const { 379std::string GDBStubA32::RegRead(const Kernel::KThread* thread, size_t id) const {
diff --git a/src/core/debugger/gdbstub_arch.h b/src/core/debugger/gdbstub_arch.h
index 2540d6456..34530c788 100644
--- a/src/core/debugger/gdbstub_arch.h
+++ b/src/core/debugger/gdbstub_arch.h
@@ -16,7 +16,7 @@ namespace Core {
16class GDBStubArch { 16class GDBStubArch {
17public: 17public:
18 virtual ~GDBStubArch() = default; 18 virtual ~GDBStubArch() = default;
19 virtual std::string GetTargetXML() const = 0; 19 virtual std::string_view GetTargetXML() const = 0;
20 virtual std::string RegRead(const Kernel::KThread* thread, size_t id) const = 0; 20 virtual std::string RegRead(const Kernel::KThread* thread, size_t id) const = 0;
21 virtual void RegWrite(Kernel::KThread* thread, size_t id, std::string_view value) const = 0; 21 virtual void RegWrite(Kernel::KThread* thread, size_t id, std::string_view value) const = 0;
22 virtual std::string ReadRegisters(const Kernel::KThread* thread) const = 0; 22 virtual std::string ReadRegisters(const Kernel::KThread* thread) const = 0;
@@ -27,7 +27,7 @@ public:
27 27
28class GDBStubA64 final : public GDBStubArch { 28class GDBStubA64 final : public GDBStubArch {
29public: 29public:
30 std::string GetTargetXML() const override; 30 std::string_view GetTargetXML() const override;
31 std::string RegRead(const Kernel::KThread* thread, size_t id) const override; 31 std::string RegRead(const Kernel::KThread* thread, size_t id) const override;
32 void RegWrite(Kernel::KThread* thread, size_t id, std::string_view value) const override; 32 void RegWrite(Kernel::KThread* thread, size_t id, std::string_view value) const override;
33 std::string ReadRegisters(const Kernel::KThread* thread) const override; 33 std::string ReadRegisters(const Kernel::KThread* thread) const override;
@@ -47,7 +47,7 @@ private:
47 47
48class GDBStubA32 final : public GDBStubArch { 48class GDBStubA32 final : public GDBStubArch {
49public: 49public:
50 std::string GetTargetXML() const override; 50 std::string_view GetTargetXML() const override;
51 std::string RegRead(const Kernel::KThread* thread, size_t id) const override; 51 std::string RegRead(const Kernel::KThread* thread, size_t id) const override;
52 void RegWrite(Kernel::KThread* thread, size_t id, std::string_view value) const override; 52 void RegWrite(Kernel::KThread* thread, size_t id, std::string_view value) const override;
53 std::string ReadRegisters(const Kernel::KThread* thread) const override; 53 std::string ReadRegisters(const Kernel::KThread* thread) const override;
diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp
index 5aab428bb..efdf18cee 100644
--- a/src/core/file_sys/ips_layer.cpp
+++ b/src/core/file_sys/ips_layer.cpp
@@ -41,12 +41,12 @@ static IPSFileType IdentifyMagic(const std::vector<u8>& magic) {
41 return IPSFileType::Error; 41 return IPSFileType::Error;
42 } 42 }
43 43
44 constexpr std::array<u8, 5> patch_magic{{'P', 'A', 'T', 'C', 'H'}}; 44 static constexpr std::array<u8, 5> patch_magic{{'P', 'A', 'T', 'C', 'H'}};
45 if (std::equal(magic.begin(), magic.end(), patch_magic.begin())) { 45 if (std::equal(magic.begin(), magic.end(), patch_magic.begin())) {
46 return IPSFileType::IPS; 46 return IPSFileType::IPS;
47 } 47 }
48 48
49 constexpr std::array<u8, 5> ips32_magic{{'I', 'P', 'S', '3', '2'}}; 49 static constexpr std::array<u8, 5> ips32_magic{{'I', 'P', 'S', '3', '2'}};
50 if (std::equal(magic.begin(), magic.end(), ips32_magic.begin())) { 50 if (std::equal(magic.begin(), magic.end(), ips32_magic.begin())) {
51 return IPSFileType::IPS32; 51 return IPSFileType::IPS32;
52 } 52 }
@@ -55,12 +55,12 @@ static IPSFileType IdentifyMagic(const std::vector<u8>& magic) {
55} 55}
56 56
57static bool IsEOF(IPSFileType type, const std::vector<u8>& data) { 57static bool IsEOF(IPSFileType type, const std::vector<u8>& data) {
58 constexpr std::array<u8, 3> eof{{'E', 'O', 'F'}}; 58 static constexpr std::array<u8, 3> eof{{'E', 'O', 'F'}};
59 if (type == IPSFileType::IPS && std::equal(data.begin(), data.end(), eof.begin())) { 59 if (type == IPSFileType::IPS && std::equal(data.begin(), data.end(), eof.begin())) {
60 return true; 60 return true;
61 } 61 }
62 62
63 constexpr std::array<u8, 4> eeof{{'E', 'E', 'O', 'F'}}; 63 static constexpr std::array<u8, 4> eeof{{'E', 'E', 'O', 'F'}};
64 return type == IPSFileType::IPS32 && std::equal(data.begin(), data.end(), eeof.begin()); 64 return type == IPSFileType::IPS32 && std::equal(data.begin(), data.end(), eeof.begin());
65} 65}
66 66
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp
index 878d832c2..a6960170c 100644
--- a/src/core/file_sys/registered_cache.cpp
+++ b/src/core/file_sys/registered_cache.cpp
@@ -71,7 +71,7 @@ static std::string GetRelativePathFromNcaID(const std::array<u8, 16>& nca_id, bo
71} 71}
72 72
73static std::string GetCNMTName(TitleType type, u64 title_id) { 73static std::string GetCNMTName(TitleType type, u64 title_id) {
74 constexpr std::array<const char*, 9> TITLE_TYPE_NAMES{ 74 static constexpr std::array<const char*, 9> TITLE_TYPE_NAMES{
75 "SystemProgram", 75 "SystemProgram",
76 "SystemData", 76 "SystemData",
77 "SystemUpdate", 77 "SystemUpdate",
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp
index 1567da231..769065b6f 100644
--- a/src/core/file_sys/savedata_factory.cpp
+++ b/src/core/file_sys/savedata_factory.cpp
@@ -172,7 +172,7 @@ std::string SaveDataFactory::GetFullPath(Core::System& system, VirtualDir dir,
172 // be interpreted as the title id of the current process. 172 // be interpreted as the title id of the current process.
173 if (type == SaveDataType::SaveData || type == SaveDataType::DeviceSaveData) { 173 if (type == SaveDataType::SaveData || type == SaveDataType::DeviceSaveData) {
174 if (title_id == 0) { 174 if (title_id == 0) {
175 title_id = system.GetCurrentProcessProgramID(); 175 title_id = system.GetApplicationProcessProgramID();
176 } 176 }
177 } 177 }
178 178
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h
index a86bec252..38d6cfaff 100644
--- a/src/core/hle/ipc_helpers.h
+++ b/src/core/hle/ipc_helpers.h
@@ -148,7 +148,7 @@ public:
148 if (context->GetManager()->IsDomain()) { 148 if (context->GetManager()->IsDomain()) {
149 context->AddDomainObject(std::move(iface)); 149 context->AddDomainObject(std::move(iface));
150 } else { 150 } else {
151 kernel.CurrentProcess()->GetResourceLimit()->Reserve( 151 kernel.ApplicationProcess()->GetResourceLimit()->Reserve(
152 Kernel::LimitableResource::SessionCountMax, 1); 152 Kernel::LimitableResource::SessionCountMax, 1);
153 153
154 auto* session = Kernel::KSession::Create(kernel); 154 auto* session = Kernel::KSession::Create(kernel);
diff --git a/src/core/hle/kernel/k_client_port.cpp b/src/core/hle/kernel/k_client_port.cpp
index 2ec623a58..c72a91a76 100644
--- a/src/core/hle/kernel/k_client_port.cpp
+++ b/src/core/hle/kernel/k_client_port.cpp
@@ -60,7 +60,8 @@ bool KClientPort::IsSignaled() const {
60 60
61Result KClientPort::CreateSession(KClientSession** out) { 61Result KClientPort::CreateSession(KClientSession** out) {
62 // Reserve a new session from the resource limit. 62 // Reserve a new session from the resource limit.
63 KScopedResourceReservation session_reservation(kernel.CurrentProcess()->GetResourceLimit(), 63 //! FIXME: we are reserving this from the wrong resource limit!
64 KScopedResourceReservation session_reservation(kernel.ApplicationProcess()->GetResourceLimit(),
64 LimitableResource::SessionCountMax); 65 LimitableResource::SessionCountMax);
65 R_UNLESS(session_reservation.Succeeded(), ResultLimitReached); 66 R_UNLESS(session_reservation.Succeeded(), ResultLimitReached);
66 67
diff --git a/src/core/hle/kernel/k_code_memory.cpp b/src/core/hle/kernel/k_code_memory.cpp
index 884eba001..6c44a9e99 100644
--- a/src/core/hle/kernel/k_code_memory.cpp
+++ b/src/core/hle/kernel/k_code_memory.cpp
@@ -21,7 +21,7 @@ KCodeMemory::KCodeMemory(KernelCore& kernel_)
21 21
22Result KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, size_t size) { 22Result KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, size_t size) {
23 // Set members. 23 // Set members.
24 m_owner = kernel.CurrentProcess(); 24 m_owner = GetCurrentProcessPointer(kernel);
25 25
26 // Get the owner page table. 26 // Get the owner page table.
27 auto& page_table = m_owner->PageTable(); 27 auto& page_table = m_owner->PageTable();
@@ -74,7 +74,7 @@ Result KCodeMemory::Map(VAddr address, size_t size) {
74 R_UNLESS(!m_is_mapped, ResultInvalidState); 74 R_UNLESS(!m_is_mapped, ResultInvalidState);
75 75
76 // Map the memory. 76 // Map the memory.
77 R_TRY(kernel.CurrentProcess()->PageTable().MapPageGroup( 77 R_TRY(GetCurrentProcess(kernel).PageTable().MapPageGroup(
78 address, *m_page_group, KMemoryState::CodeOut, KMemoryPermission::UserReadWrite)); 78 address, *m_page_group, KMemoryState::CodeOut, KMemoryPermission::UserReadWrite));
79 79
80 // Mark ourselves as mapped. 80 // Mark ourselves as mapped.
@@ -91,8 +91,8 @@ Result KCodeMemory::Unmap(VAddr address, size_t size) {
91 KScopedLightLock lk(m_lock); 91 KScopedLightLock lk(m_lock);
92 92
93 // Unmap the memory. 93 // Unmap the memory.
94 R_TRY(kernel.CurrentProcess()->PageTable().UnmapPageGroup(address, *m_page_group, 94 R_TRY(GetCurrentProcess(kernel).PageTable().UnmapPageGroup(address, *m_page_group,
95 KMemoryState::CodeOut)); 95 KMemoryState::CodeOut));
96 96
97 // Mark ourselves as unmapped. 97 // Mark ourselves as unmapped.
98 m_is_mapped = false; 98 m_is_mapped = false;
diff --git a/src/core/hle/kernel/k_condition_variable.cpp b/src/core/hle/kernel/k_condition_variable.cpp
index 0c6b20db3..3f0be1c3f 100644
--- a/src/core/hle/kernel/k_condition_variable.cpp
+++ b/src/core/hle/kernel/k_condition_variable.cpp
@@ -164,8 +164,8 @@ Result KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 value)
164 R_SUCCEED_IF(test_tag != (handle | Svc::HandleWaitMask)); 164 R_SUCCEED_IF(test_tag != (handle | Svc::HandleWaitMask));
165 165
166 // Get the lock owner thread. 166 // Get the lock owner thread.
167 owner_thread = kernel.CurrentProcess() 167 owner_thread = GetCurrentProcess(kernel)
168 ->GetHandleTable() 168 .GetHandleTable()
169 .GetObjectWithoutPseudoHandle<KThread>(handle) 169 .GetObjectWithoutPseudoHandle<KThread>(handle)
170 .ReleasePointerUnsafe(); 170 .ReleasePointerUnsafe();
171 R_UNLESS(owner_thread != nullptr, ResultInvalidHandle); 171 R_UNLESS(owner_thread != nullptr, ResultInvalidHandle);
@@ -213,8 +213,8 @@ void KConditionVariable::SignalImpl(KThread* thread) {
213 thread->EndWait(ResultSuccess); 213 thread->EndWait(ResultSuccess);
214 } else { 214 } else {
215 // Get the previous owner. 215 // Get the previous owner.
216 KThread* owner_thread = kernel.CurrentProcess() 216 KThread* owner_thread = GetCurrentProcess(kernel)
217 ->GetHandleTable() 217 .GetHandleTable()
218 .GetObjectWithoutPseudoHandle<KThread>( 218 .GetObjectWithoutPseudoHandle<KThread>(
219 static_cast<Handle>(prev_tag & ~Svc::HandleWaitMask)) 219 static_cast<Handle>(prev_tag & ~Svc::HandleWaitMask))
220 .ReleasePointerUnsafe(); 220 .ReleasePointerUnsafe();
diff --git a/src/core/hle/kernel/k_handle_table.h b/src/core/hle/kernel/k_handle_table.h
index 37a24e7d9..d7660630c 100644
--- a/src/core/hle/kernel/k_handle_table.h
+++ b/src/core/hle/kernel/k_handle_table.h
@@ -90,7 +90,8 @@ public:
90 // Handle pseudo-handles. 90 // Handle pseudo-handles.
91 if constexpr (std::derived_from<KProcess, T>) { 91 if constexpr (std::derived_from<KProcess, T>) {
92 if (handle == Svc::PseudoHandle::CurrentProcess) { 92 if (handle == Svc::PseudoHandle::CurrentProcess) {
93 auto* const cur_process = m_kernel.CurrentProcess(); 93 //! FIXME: this is the wrong process!
94 auto* const cur_process = m_kernel.ApplicationProcess();
94 ASSERT(cur_process != nullptr); 95 ASSERT(cur_process != nullptr);
95 return cur_process; 96 return cur_process;
96 } 97 }
diff --git a/src/core/hle/kernel/k_interrupt_manager.cpp b/src/core/hle/kernel/k_interrupt_manager.cpp
index 4a6b60d26..fe6a20168 100644
--- a/src/core/hle/kernel/k_interrupt_manager.cpp
+++ b/src/core/hle/kernel/k_interrupt_manager.cpp
@@ -16,7 +16,7 @@ void HandleInterrupt(KernelCore& kernel, s32 core_id) {
16 16
17 auto& current_thread = GetCurrentThread(kernel); 17 auto& current_thread = GetCurrentThread(kernel);
18 18
19 if (auto* process = kernel.CurrentProcess(); process) { 19 if (auto* process = GetCurrentProcessPointer(kernel); process) {
20 // If the user disable count is set, we may need to pin the current thread. 20 // If the user disable count is set, we may need to pin the current thread.
21 if (current_thread.GetUserDisableCount() && !process->GetPinnedThread(core_id)) { 21 if (current_thread.GetUserDisableCount() && !process->GetPinnedThread(core_id)) {
22 KScopedSchedulerLock sl{kernel}; 22 KScopedSchedulerLock sl{kernel};
diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp
index d6676904b..d6c214237 100644
--- a/src/core/hle/kernel/k_scheduler.cpp
+++ b/src/core/hle/kernel/k_scheduler.cpp
@@ -328,7 +328,7 @@ u64 KScheduler::UpdateHighestPriorityThreadsImpl(KernelCore& kernel) {
328} 328}
329 329
330void KScheduler::SwitchThread(KThread* next_thread) { 330void KScheduler::SwitchThread(KThread* next_thread) {
331 KProcess* const cur_process = kernel.CurrentProcess(); 331 KProcess* const cur_process = GetCurrentProcessPointer(kernel);
332 KThread* const cur_thread = GetCurrentThreadPointer(kernel); 332 KThread* const cur_thread = GetCurrentThreadPointer(kernel);
333 333
334 // We never want to schedule a null thread, so use the idle thread if we don't have a next. 334 // We never want to schedule a null thread, so use the idle thread if we don't have a next.
@@ -689,11 +689,11 @@ void KScheduler::RotateScheduledQueue(KernelCore& kernel, s32 core_id, s32 prior
689void KScheduler::YieldWithoutCoreMigration(KernelCore& kernel) { 689void KScheduler::YieldWithoutCoreMigration(KernelCore& kernel) {
690 // Validate preconditions. 690 // Validate preconditions.
691 ASSERT(CanSchedule(kernel)); 691 ASSERT(CanSchedule(kernel));
692 ASSERT(kernel.CurrentProcess() != nullptr); 692 ASSERT(GetCurrentProcessPointer(kernel) != nullptr);
693 693
694 // Get the current thread and process. 694 // Get the current thread and process.
695 KThread& cur_thread = GetCurrentThread(kernel); 695 KThread& cur_thread = GetCurrentThread(kernel);
696 KProcess& cur_process = *kernel.CurrentProcess(); 696 KProcess& cur_process = GetCurrentProcess(kernel);
697 697
698 // If the thread's yield count matches, there's nothing for us to do. 698 // If the thread's yield count matches, there's nothing for us to do.
699 if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) { 699 if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) {
@@ -728,11 +728,11 @@ void KScheduler::YieldWithoutCoreMigration(KernelCore& kernel) {
728void KScheduler::YieldWithCoreMigration(KernelCore& kernel) { 728void KScheduler::YieldWithCoreMigration(KernelCore& kernel) {
729 // Validate preconditions. 729 // Validate preconditions.
730 ASSERT(CanSchedule(kernel)); 730 ASSERT(CanSchedule(kernel));
731 ASSERT(kernel.CurrentProcess() != nullptr); 731 ASSERT(GetCurrentProcessPointer(kernel) != nullptr);
732 732
733 // Get the current thread and process. 733 // Get the current thread and process.
734 KThread& cur_thread = GetCurrentThread(kernel); 734 KThread& cur_thread = GetCurrentThread(kernel);
735 KProcess& cur_process = *kernel.CurrentProcess(); 735 KProcess& cur_process = GetCurrentProcess(kernel);
736 736
737 // If the thread's yield count matches, there's nothing for us to do. 737 // If the thread's yield count matches, there's nothing for us to do.
738 if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) { 738 if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) {
@@ -816,11 +816,11 @@ void KScheduler::YieldWithCoreMigration(KernelCore& kernel) {
816void KScheduler::YieldToAnyThread(KernelCore& kernel) { 816void KScheduler::YieldToAnyThread(KernelCore& kernel) {
817 // Validate preconditions. 817 // Validate preconditions.
818 ASSERT(CanSchedule(kernel)); 818 ASSERT(CanSchedule(kernel));
819 ASSERT(kernel.CurrentProcess() != nullptr); 819 ASSERT(GetCurrentProcessPointer(kernel) != nullptr);
820 820
821 // Get the current thread and process. 821 // Get the current thread and process.
822 KThread& cur_thread = GetCurrentThread(kernel); 822 KThread& cur_thread = GetCurrentThread(kernel);
823 KProcess& cur_process = *kernel.CurrentProcess(); 823 KProcess& cur_process = GetCurrentProcess(kernel);
824 824
825 // If the thread's yield count matches, there's nothing for us to do. 825 // If the thread's yield count matches, there's nothing for us to do.
826 if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) { 826 if (cur_thread.GetYieldScheduleCount() == cur_process.GetScheduledCount()) {
diff --git a/src/core/hle/kernel/k_session.cpp b/src/core/hle/kernel/k_session.cpp
index b6f6fe9d9..7e677c028 100644
--- a/src/core/hle/kernel/k_session.cpp
+++ b/src/core/hle/kernel/k_session.cpp
@@ -33,7 +33,8 @@ void KSession::Initialize(KClientPort* port_, const std::string& name_) {
33 name = name_; 33 name = name_;
34 34
35 // Set our owner process. 35 // Set our owner process.
36 process = kernel.CurrentProcess(); 36 //! FIXME: this is the wrong process!
37 process = kernel.ApplicationProcess();
37 process->Open(); 38 process->Open();
38 39
39 // Set our port. 40 // Set our port.
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp
index 84ff3c64b..2d3da9d66 100644
--- a/src/core/hle/kernel/k_thread.cpp
+++ b/src/core/hle/kernel/k_thread.cpp
@@ -1266,6 +1266,14 @@ KThread& GetCurrentThread(KernelCore& kernel) {
1266 return *GetCurrentThreadPointer(kernel); 1266 return *GetCurrentThreadPointer(kernel);
1267} 1267}
1268 1268
1269KProcess* GetCurrentProcessPointer(KernelCore& kernel) {
1270 return GetCurrentThread(kernel).GetOwnerProcess();
1271}
1272
1273KProcess& GetCurrentProcess(KernelCore& kernel) {
1274 return *GetCurrentProcessPointer(kernel);
1275}
1276
1269s32 GetCurrentCoreId(KernelCore& kernel) { 1277s32 GetCurrentCoreId(KernelCore& kernel) {
1270 return GetCurrentThread(kernel).GetCurrentCore(); 1278 return GetCurrentThread(kernel).GetCurrentCore();
1271} 1279}
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h
index 8b8dc51be..ca82ce3b6 100644
--- a/src/core/hle/kernel/k_thread.h
+++ b/src/core/hle/kernel/k_thread.h
@@ -110,6 +110,8 @@ enum class StepState : u32 {
110void SetCurrentThread(KernelCore& kernel, KThread* thread); 110void SetCurrentThread(KernelCore& kernel, KThread* thread);
111[[nodiscard]] KThread* GetCurrentThreadPointer(KernelCore& kernel); 111[[nodiscard]] KThread* GetCurrentThreadPointer(KernelCore& kernel);
112[[nodiscard]] KThread& GetCurrentThread(KernelCore& kernel); 112[[nodiscard]] KThread& GetCurrentThread(KernelCore& kernel);
113[[nodiscard]] KProcess* GetCurrentProcessPointer(KernelCore& kernel);
114[[nodiscard]] KProcess& GetCurrentProcess(KernelCore& kernel);
113[[nodiscard]] s32 GetCurrentCoreId(KernelCore& kernel); 115[[nodiscard]] s32 GetCurrentCoreId(KernelCore& kernel);
114 116
115class KThread final : public KAutoObjectWithSlabHeapAndContainer<KThread, KWorkerTask>, 117class KThread final : public KAutoObjectWithSlabHeapAndContainer<KThread, KWorkerTask>,
diff --git a/src/core/hle/kernel/k_transfer_memory.cpp b/src/core/hle/kernel/k_transfer_memory.cpp
index 9f34c2d46..faa5c73b5 100644
--- a/src/core/hle/kernel/k_transfer_memory.cpp
+++ b/src/core/hle/kernel/k_transfer_memory.cpp
@@ -16,7 +16,7 @@ KTransferMemory::~KTransferMemory() = default;
16Result KTransferMemory::Initialize(VAddr address_, std::size_t size_, 16Result KTransferMemory::Initialize(VAddr address_, std::size_t size_,
17 Svc::MemoryPermission owner_perm_) { 17 Svc::MemoryPermission owner_perm_) {
18 // Set members. 18 // Set members.
19 owner = kernel.CurrentProcess(); 19 owner = GetCurrentProcessPointer(kernel);
20 20
21 // TODO(bunnei): Lock for transfer memory 21 // TODO(bunnei): Lock for transfer memory
22 22
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 5b72eaaa1..b1922659d 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -102,13 +102,13 @@ struct KernelCore::Impl {
102 102
103 void InitializeCores() { 103 void InitializeCores() {
104 for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { 104 for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
105 cores[core_id]->Initialize((*current_process).Is64BitProcess()); 105 cores[core_id]->Initialize((*application_process).Is64BitProcess());
106 system.Memory().SetCurrentPageTable(*current_process, core_id); 106 system.Memory().SetCurrentPageTable(*application_process, core_id);
107 } 107 }
108 } 108 }
109 109
110 void CloseCurrentProcess() { 110 void CloseApplicationProcess() {
111 KProcess* old_process = current_process.exchange(nullptr); 111 KProcess* old_process = application_process.exchange(nullptr);
112 if (old_process == nullptr) { 112 if (old_process == nullptr) {
113 return; 113 return;
114 } 114 }
@@ -182,7 +182,7 @@ struct KernelCore::Impl {
182 } 182 }
183 } 183 }
184 184
185 CloseCurrentProcess(); 185 CloseApplicationProcess();
186 186
187 // Track kernel objects that were not freed on shutdown 187 // Track kernel objects that were not freed on shutdown
188 { 188 {
@@ -363,8 +363,8 @@ struct KernelCore::Impl {
363 } 363 }
364 } 364 }
365 365
366 void MakeCurrentProcess(KProcess* process) { 366 void MakeApplicationProcess(KProcess* process) {
367 current_process = process; 367 application_process = process;
368 } 368 }
369 369
370 static inline thread_local u32 host_thread_id = UINT32_MAX; 370 static inline thread_local u32 host_thread_id = UINT32_MAX;
@@ -821,7 +821,7 @@ struct KernelCore::Impl {
821 821
822 // Lists all processes that exist in the current session. 822 // Lists all processes that exist in the current session.
823 std::vector<KProcess*> process_list; 823 std::vector<KProcess*> process_list;
824 std::atomic<KProcess*> current_process{}; 824 std::atomic<KProcess*> application_process{};
825 std::unique_ptr<Kernel::GlobalSchedulerContext> global_scheduler_context; 825 std::unique_ptr<Kernel::GlobalSchedulerContext> global_scheduler_context;
826 std::unique_ptr<Kernel::KHardwareTimer> hardware_timer; 826 std::unique_ptr<Kernel::KHardwareTimer> hardware_timer;
827 827
@@ -941,20 +941,20 @@ void KernelCore::AppendNewProcess(KProcess* process) {
941 impl->process_list.push_back(process); 941 impl->process_list.push_back(process);
942} 942}
943 943
944void KernelCore::MakeCurrentProcess(KProcess* process) { 944void KernelCore::MakeApplicationProcess(KProcess* process) {
945 impl->MakeCurrentProcess(process); 945 impl->MakeApplicationProcess(process);
946} 946}
947 947
948KProcess* KernelCore::CurrentProcess() { 948KProcess* KernelCore::ApplicationProcess() {
949 return impl->current_process; 949 return impl->application_process;
950} 950}
951 951
952const KProcess* KernelCore::CurrentProcess() const { 952const KProcess* KernelCore::ApplicationProcess() const {
953 return impl->current_process; 953 return impl->application_process;
954} 954}
955 955
956void KernelCore::CloseCurrentProcess() { 956void KernelCore::CloseApplicationProcess() {
957 impl->CloseCurrentProcess(); 957 impl->CloseApplicationProcess();
958} 958}
959 959
960const std::vector<KProcess*>& KernelCore::GetProcessList() const { 960const std::vector<KProcess*>& KernelCore::GetProcessList() const {
@@ -1202,12 +1202,12 @@ const Kernel::KSharedMemory& KernelCore::GetHidBusSharedMem() const {
1202 return *impl->hidbus_shared_mem; 1202 return *impl->hidbus_shared_mem;
1203} 1203}
1204 1204
1205void KernelCore::Suspend(bool suspended) { 1205void KernelCore::SuspendApplication(bool suspended) {
1206 const bool should_suspend{exception_exited || suspended}; 1206 const bool should_suspend{exception_exited || suspended};
1207 const auto activity = should_suspend ? ProcessActivity::Paused : ProcessActivity::Runnable; 1207 const auto activity = should_suspend ? ProcessActivity::Paused : ProcessActivity::Runnable;
1208 1208
1209 //! This refers to the application process, not the current process. 1209 // Get the application process.
1210 KScopedAutoObject<KProcess> process = CurrentProcess(); 1210 KScopedAutoObject<KProcess> process = ApplicationProcess();
1211 if (process.IsNull()) { 1211 if (process.IsNull()) {
1212 return; 1212 return;
1213 } 1213 }
@@ -1218,8 +1218,8 @@ void KernelCore::Suspend(bool suspended) {
1218 // Wait for process execution to stop. 1218 // Wait for process execution to stop.
1219 bool must_wait{should_suspend}; 1219 bool must_wait{should_suspend};
1220 1220
1221 // KernelCore::Suspend must be called from locked context, or we 1221 // KernelCore::SuspendApplication must be called from locked context,
1222 // could race another call to SetActivity, interfering with waiting. 1222 // or we could race another call to SetActivity, interfering with waiting.
1223 while (must_wait) { 1223 while (must_wait) {
1224 KScopedSchedulerLock sl{*this}; 1224 KScopedSchedulerLock sl{*this};
1225 1225
@@ -1253,9 +1253,9 @@ bool KernelCore::IsShuttingDown() const {
1253 return impl->IsShuttingDown(); 1253 return impl->IsShuttingDown();
1254} 1254}
1255 1255
1256void KernelCore::ExceptionalExit() { 1256void KernelCore::ExceptionalExitApplication() {
1257 exception_exited = true; 1257 exception_exited = true;
1258 Suspend(true); 1258 SuspendApplication(true);
1259} 1259}
1260 1260
1261void KernelCore::EnterSVCProfile() { 1261void KernelCore::EnterSVCProfile() {
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index af0ae0e98..a236e6b42 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -131,17 +131,17 @@ public:
131 /// Adds the given shared pointer to an internal list of active processes. 131 /// Adds the given shared pointer to an internal list of active processes.
132 void AppendNewProcess(KProcess* process); 132 void AppendNewProcess(KProcess* process);
133 133
134 /// Makes the given process the new current process. 134 /// Makes the given process the new application process.
135 void MakeCurrentProcess(KProcess* process); 135 void MakeApplicationProcess(KProcess* process);
136 136
137 /// Retrieves a pointer to the current process. 137 /// Retrieves a pointer to the application process.
138 KProcess* CurrentProcess(); 138 KProcess* ApplicationProcess();
139 139
140 /// Retrieves a const pointer to the current process. 140 /// Retrieves a const pointer to the application process.
141 const KProcess* CurrentProcess() const; 141 const KProcess* ApplicationProcess() const;
142 142
143 /// Closes the current process. 143 /// Closes the application process.
144 void CloseCurrentProcess(); 144 void CloseApplicationProcess();
145 145
146 /// Retrieves the list of processes. 146 /// Retrieves the list of processes.
147 const std::vector<KProcess*>& GetProcessList() const; 147 const std::vector<KProcess*>& GetProcessList() const;
@@ -288,11 +288,11 @@ public:
288 /// Gets the shared memory object for HIDBus services. 288 /// Gets the shared memory object for HIDBus services.
289 const Kernel::KSharedMemory& GetHidBusSharedMem() const; 289 const Kernel::KSharedMemory& GetHidBusSharedMem() const;
290 290
291 /// Suspend/unsuspend all processes. 291 /// Suspend/unsuspend application process.
292 void Suspend(bool suspend); 292 void SuspendApplication(bool suspend);
293 293
294 /// Exceptional exit all processes. 294 /// Exceptional exit application process.
295 void ExceptionalExit(); 295 void ExceptionalExitApplication();
296 296
297 /// Notify emulated CPU cores to shut down. 297 /// Notify emulated CPU cores to shut down.
298 void ShutdownCores(); 298 void ShutdownCores();
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 4ef57356e..1072da8cc 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -4426,7 +4426,7 @@ void Call(Core::System& system, u32 imm) {
4426 auto& kernel = system.Kernel(); 4426 auto& kernel = system.Kernel();
4427 kernel.EnterSVCProfile(); 4427 kernel.EnterSVCProfile();
4428 4428
4429 if (system.CurrentProcess()->Is64BitProcess()) { 4429 if (GetCurrentProcess(system.Kernel()).Is64BitProcess()) {
4430 Call64(system, imm); 4430 Call64(system, imm);
4431 } else { 4431 } else {
4432 Call32(system, imm); 4432 Call32(system, imm);
diff --git a/src/core/hle/kernel/svc/svc_activity.cpp b/src/core/hle/kernel/svc/svc_activity.cpp
index 1dcdb7a15..63bc08555 100644
--- a/src/core/hle/kernel/svc/svc_activity.cpp
+++ b/src/core/hle/kernel/svc/svc_activity.cpp
@@ -16,18 +16,19 @@ Result SetThreadActivity(Core::System& system, Handle thread_handle,
16 thread_activity); 16 thread_activity);
17 17
18 // Validate the activity. 18 // Validate the activity.
19 constexpr auto IsValidThreadActivity = [](ThreadActivity activity) { 19 static constexpr auto IsValidThreadActivity = [](ThreadActivity activity) {
20 return activity == ThreadActivity::Runnable || activity == ThreadActivity::Paused; 20 return activity == ThreadActivity::Runnable || activity == ThreadActivity::Paused;
21 }; 21 };
22 R_UNLESS(IsValidThreadActivity(thread_activity), ResultInvalidEnumValue); 22 R_UNLESS(IsValidThreadActivity(thread_activity), ResultInvalidEnumValue);
23 23
24 // Get the thread from its handle. 24 // Get the thread from its handle.
25 KScopedAutoObject thread = 25 KScopedAutoObject thread =
26 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle); 26 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle);
27 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); 27 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
28 28
29 // Check that the activity is being set on a non-current thread for the current process. 29 // Check that the activity is being set on a non-current thread for the current process.
30 R_UNLESS(thread->GetOwnerProcess() == system.Kernel().CurrentProcess(), ResultInvalidHandle); 30 R_UNLESS(thread->GetOwnerProcess() == GetCurrentProcessPointer(system.Kernel()),
31 ResultInvalidHandle);
31 R_UNLESS(thread.GetPointerUnsafe() != GetCurrentThreadPointer(system.Kernel()), ResultBusy); 32 R_UNLESS(thread.GetPointerUnsafe() != GetCurrentThreadPointer(system.Kernel()), ResultBusy);
32 33
33 // Set the activity. 34 // Set the activity.
diff --git a/src/core/hle/kernel/svc/svc_address_arbiter.cpp b/src/core/hle/kernel/svc/svc_address_arbiter.cpp
index e6a5d2ae5..998bd3f22 100644
--- a/src/core/hle/kernel/svc/svc_address_arbiter.cpp
+++ b/src/core/hle/kernel/svc/svc_address_arbiter.cpp
@@ -72,7 +72,7 @@ Result WaitForAddress(Core::System& system, VAddr address, ArbitrationType arb_t
72 timeout = timeout_ns; 72 timeout = timeout_ns;
73 } 73 }
74 74
75 return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout); 75 return GetCurrentProcess(system.Kernel()).WaitAddressArbiter(address, arb_type, value, timeout);
76} 76}
77 77
78// Signals to an address (via Address Arbiter) 78// Signals to an address (via Address Arbiter)
@@ -95,8 +95,8 @@ Result SignalToAddress(Core::System& system, VAddr address, SignalType signal_ty
95 return ResultInvalidEnumValue; 95 return ResultInvalidEnumValue;
96 } 96 }
97 97
98 return system.Kernel().CurrentProcess()->SignalAddressArbiter(address, signal_type, value, 98 return GetCurrentProcess(system.Kernel())
99 count); 99 .SignalAddressArbiter(address, signal_type, value, count);
100} 100}
101 101
102Result WaitForAddress64(Core::System& system, VAddr address, ArbitrationType arb_type, s32 value, 102Result WaitForAddress64(Core::System& system, VAddr address, ArbitrationType arb_type, s32 value,
diff --git a/src/core/hle/kernel/svc/svc_cache.cpp b/src/core/hle/kernel/svc/svc_cache.cpp
index b5404760e..598b71da5 100644
--- a/src/core/hle/kernel/svc/svc_cache.cpp
+++ b/src/core/hle/kernel/svc/svc_cache.cpp
@@ -38,7 +38,7 @@ Result FlushProcessDataCache(Core::System& system, Handle process_handle, u64 ad
38 38
39 // Get the process from its handle. 39 // Get the process from its handle.
40 KScopedAutoObject process = 40 KScopedAutoObject process =
41 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle); 41 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle);
42 R_UNLESS(process.IsNotNull(), ResultInvalidHandle); 42 R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
43 43
44 // Verify the region is within range. 44 // Verify the region is within range.
diff --git a/src/core/hle/kernel/svc/svc_code_memory.cpp b/src/core/hle/kernel/svc/svc_code_memory.cpp
index ec256b757..538ff1c71 100644
--- a/src/core/hle/kernel/svc/svc_code_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_code_memory.cpp
@@ -46,7 +46,7 @@ Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t
46 R_UNLESS(code_mem != nullptr, ResultOutOfResource); 46 R_UNLESS(code_mem != nullptr, ResultOutOfResource);
47 47
48 // Verify that the region is in range. 48 // Verify that the region is in range.
49 R_UNLESS(system.CurrentProcess()->PageTable().Contains(address, size), 49 R_UNLESS(GetCurrentProcess(system.Kernel()).PageTable().Contains(address, size),
50 ResultInvalidCurrentMemory); 50 ResultInvalidCurrentMemory);
51 51
52 // Initialize the code memory. 52 // Initialize the code memory.
@@ -56,7 +56,7 @@ Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t
56 KCodeMemory::Register(kernel, code_mem); 56 KCodeMemory::Register(kernel, code_mem);
57 57
58 // Add the code memory to the handle table. 58 // Add the code memory to the handle table.
59 R_TRY(system.CurrentProcess()->GetHandleTable().Add(out, code_mem)); 59 R_TRY(GetCurrentProcess(system.Kernel()).GetHandleTable().Add(out, code_mem));
60 60
61 code_mem->Close(); 61 code_mem->Close();
62 62
@@ -79,8 +79,9 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle,
79 R_UNLESS((address < address + size), ResultInvalidCurrentMemory); 79 R_UNLESS((address < address + size), ResultInvalidCurrentMemory);
80 80
81 // Get the code memory from its handle. 81 // Get the code memory from its handle.
82 KScopedAutoObject code_mem = 82 KScopedAutoObject code_mem = GetCurrentProcess(system.Kernel())
83 system.CurrentProcess()->GetHandleTable().GetObject<KCodeMemory>(code_memory_handle); 83 .GetHandleTable()
84 .GetObject<KCodeMemory>(code_memory_handle);
84 R_UNLESS(code_mem.IsNotNull(), ResultInvalidHandle); 85 R_UNLESS(code_mem.IsNotNull(), ResultInvalidHandle);
85 86
86 // NOTE: Here, Atmosphere extends the SVC to allow code memory operations on one's own process. 87 // NOTE: Here, Atmosphere extends the SVC to allow code memory operations on one's own process.
@@ -90,9 +91,10 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle,
90 switch (operation) { 91 switch (operation) {
91 case CodeMemoryOperation::Map: { 92 case CodeMemoryOperation::Map: {
92 // Check that the region is in range. 93 // Check that the region is in range.
93 R_UNLESS( 94 R_UNLESS(GetCurrentProcess(system.Kernel())
94 system.CurrentProcess()->PageTable().CanContain(address, size, KMemoryState::CodeOut), 95 .PageTable()
95 ResultInvalidMemoryRegion); 96 .CanContain(address, size, KMemoryState::CodeOut),
97 ResultInvalidMemoryRegion);
96 98
97 // Check the memory permission. 99 // Check the memory permission.
98 R_UNLESS(IsValidMapCodeMemoryPermission(perm), ResultInvalidNewMemoryPermission); 100 R_UNLESS(IsValidMapCodeMemoryPermission(perm), ResultInvalidNewMemoryPermission);
@@ -102,9 +104,10 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle,
102 } break; 104 } break;
103 case CodeMemoryOperation::Unmap: { 105 case CodeMemoryOperation::Unmap: {
104 // Check that the region is in range. 106 // Check that the region is in range.
105 R_UNLESS( 107 R_UNLESS(GetCurrentProcess(system.Kernel())
106 system.CurrentProcess()->PageTable().CanContain(address, size, KMemoryState::CodeOut), 108 .PageTable()
107 ResultInvalidMemoryRegion); 109 .CanContain(address, size, KMemoryState::CodeOut),
110 ResultInvalidMemoryRegion);
108 111
109 // Check the memory permission. 112 // Check the memory permission.
110 R_UNLESS(IsValidUnmapCodeMemoryPermission(perm), ResultInvalidNewMemoryPermission); 113 R_UNLESS(IsValidUnmapCodeMemoryPermission(perm), ResultInvalidNewMemoryPermission);
diff --git a/src/core/hle/kernel/svc/svc_condition_variable.cpp b/src/core/hle/kernel/svc/svc_condition_variable.cpp
index b59a33e68..8ad1a0b8f 100644
--- a/src/core/hle/kernel/svc/svc_condition_variable.cpp
+++ b/src/core/hle/kernel/svc/svc_condition_variable.cpp
@@ -43,8 +43,8 @@ Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_ke
43 } 43 }
44 44
45 // Wait on the condition variable. 45 // Wait on the condition variable.
46 return system.Kernel().CurrentProcess()->WaitConditionVariable( 46 return GetCurrentProcess(system.Kernel())
47 address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); 47 .WaitConditionVariable(address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout);
48} 48}
49 49
50/// Signal process wide key 50/// Signal process wide key
@@ -52,8 +52,8 @@ void SignalProcessWideKey(Core::System& system, VAddr cv_key, s32 count) {
52 LOG_TRACE(Kernel_SVC, "called, cv_key=0x{:X}, count=0x{:08X}", cv_key, count); 52 LOG_TRACE(Kernel_SVC, "called, cv_key=0x{:X}, count=0x{:08X}", cv_key, count);
53 53
54 // Signal the condition variable. 54 // Signal the condition variable.
55 return system.Kernel().CurrentProcess()->SignalConditionVariable( 55 return GetCurrentProcess(system.Kernel())
56 Common::AlignDown(cv_key, sizeof(u32)), count); 56 .SignalConditionVariable(Common::AlignDown(cv_key, sizeof(u32)), count);
57} 57}
58 58
59Result WaitProcessWideKeyAtomic64(Core::System& system, uint64_t address, uint64_t cv_key, 59Result WaitProcessWideKeyAtomic64(Core::System& system, uint64_t address, uint64_t cv_key,
diff --git a/src/core/hle/kernel/svc/svc_device_address_space.cpp b/src/core/hle/kernel/svc/svc_device_address_space.cpp
index cdc453c35..f68c0e6a9 100644
--- a/src/core/hle/kernel/svc/svc_device_address_space.cpp
+++ b/src/core/hle/kernel/svc/svc_device_address_space.cpp
@@ -37,15 +37,16 @@ Result CreateDeviceAddressSpace(Core::System& system, Handle* out, uint64_t das_
37 KDeviceAddressSpace::Register(system.Kernel(), das); 37 KDeviceAddressSpace::Register(system.Kernel(), das);
38 38
39 // Add to the handle table. 39 // Add to the handle table.
40 R_TRY(system.CurrentProcess()->GetHandleTable().Add(out, das)); 40 R_TRY(GetCurrentProcess(system.Kernel()).GetHandleTable().Add(out, das));
41 41
42 R_SUCCEED(); 42 R_SUCCEED();
43} 43}
44 44
45Result AttachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) { 45Result AttachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) {
46 // Get the device address space. 46 // Get the device address space.
47 KScopedAutoObject das = 47 KScopedAutoObject das = GetCurrentProcess(system.Kernel())
48 system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle); 48 .GetHandleTable()
49 .GetObject<KDeviceAddressSpace>(das_handle);
49 R_UNLESS(das.IsNotNull(), ResultInvalidHandle); 50 R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
50 51
51 // Attach. 52 // Attach.
@@ -54,8 +55,9 @@ Result AttachDeviceAddressSpace(Core::System& system, DeviceName device_name, Ha
54 55
55Result DetachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) { 56Result DetachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) {
56 // Get the device address space. 57 // Get the device address space.
57 KScopedAutoObject das = 58 KScopedAutoObject das = GetCurrentProcess(system.Kernel())
58 system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle); 59 .GetHandleTable()
60 .GetObject<KDeviceAddressSpace>(das_handle);
59 R_UNLESS(das.IsNotNull(), ResultInvalidHandle); 61 R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
60 62
61 // Detach. 63 // Detach.
@@ -94,13 +96,14 @@ Result MapDeviceAddressSpaceByForce(Core::System& system, Handle das_handle, Han
94 R_UNLESS(reserved == 0, ResultInvalidEnumValue); 96 R_UNLESS(reserved == 0, ResultInvalidEnumValue);
95 97
96 // Get the device address space. 98 // Get the device address space.
97 KScopedAutoObject das = 99 KScopedAutoObject das = GetCurrentProcess(system.Kernel())
98 system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle); 100 .GetHandleTable()
101 .GetObject<KDeviceAddressSpace>(das_handle);
99 R_UNLESS(das.IsNotNull(), ResultInvalidHandle); 102 R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
100 103
101 // Get the process. 104 // Get the process.
102 KScopedAutoObject process = 105 KScopedAutoObject process =
103 system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle); 106 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle);
104 R_UNLESS(process.IsNotNull(), ResultInvalidHandle); 107 R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
105 108
106 // Validate that the process address is within range. 109 // Validate that the process address is within range.
@@ -134,13 +137,14 @@ Result MapDeviceAddressSpaceAligned(Core::System& system, Handle das_handle, Han
134 R_UNLESS(reserved == 0, ResultInvalidEnumValue); 137 R_UNLESS(reserved == 0, ResultInvalidEnumValue);
135 138
136 // Get the device address space. 139 // Get the device address space.
137 KScopedAutoObject das = 140 KScopedAutoObject das = GetCurrentProcess(system.Kernel())
138 system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle); 141 .GetHandleTable()
142 .GetObject<KDeviceAddressSpace>(das_handle);
139 R_UNLESS(das.IsNotNull(), ResultInvalidHandle); 143 R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
140 144
141 // Get the process. 145 // Get the process.
142 KScopedAutoObject process = 146 KScopedAutoObject process =
143 system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle); 147 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle);
144 R_UNLESS(process.IsNotNull(), ResultInvalidHandle); 148 R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
145 149
146 // Validate that the process address is within range. 150 // Validate that the process address is within range.
@@ -165,13 +169,14 @@ Result UnmapDeviceAddressSpace(Core::System& system, Handle das_handle, Handle p
165 ResultInvalidCurrentMemory); 169 ResultInvalidCurrentMemory);
166 170
167 // Get the device address space. 171 // Get the device address space.
168 KScopedAutoObject das = 172 KScopedAutoObject das = GetCurrentProcess(system.Kernel())
169 system.CurrentProcess()->GetHandleTable().GetObject<KDeviceAddressSpace>(das_handle); 173 .GetHandleTable()
174 .GetObject<KDeviceAddressSpace>(das_handle);
170 R_UNLESS(das.IsNotNull(), ResultInvalidHandle); 175 R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
171 176
172 // Get the process. 177 // Get the process.
173 KScopedAutoObject process = 178 KScopedAutoObject process =
174 system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle); 179 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle);
175 R_UNLESS(process.IsNotNull(), ResultInvalidHandle); 180 R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
176 181
177 // Validate that the process address is within range. 182 // Validate that the process address is within range.
diff --git a/src/core/hle/kernel/svc/svc_event.cpp b/src/core/hle/kernel/svc/svc_event.cpp
index e8fb9efbc..a948493e8 100644
--- a/src/core/hle/kernel/svc/svc_event.cpp
+++ b/src/core/hle/kernel/svc/svc_event.cpp
@@ -15,7 +15,7 @@ Result SignalEvent(Core::System& system, Handle event_handle) {
15 LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); 15 LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
16 16
17 // Get the current handle table. 17 // Get the current handle table.
18 const KHandleTable& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 18 const KHandleTable& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
19 19
20 // Get the event. 20 // Get the event.
21 KScopedAutoObject event = handle_table.GetObject<KEvent>(event_handle); 21 KScopedAutoObject event = handle_table.GetObject<KEvent>(event_handle);
@@ -28,7 +28,7 @@ Result ClearEvent(Core::System& system, Handle event_handle) {
28 LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); 28 LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
29 29
30 // Get the current handle table. 30 // Get the current handle table.
31 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 31 const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
32 32
33 // Try to clear the writable event. 33 // Try to clear the writable event.
34 { 34 {
@@ -56,10 +56,10 @@ Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) {
56 56
57 // Get the kernel reference and handle table. 57 // Get the kernel reference and handle table.
58 auto& kernel = system.Kernel(); 58 auto& kernel = system.Kernel();
59 auto& handle_table = kernel.CurrentProcess()->GetHandleTable(); 59 auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
60 60
61 // Reserve a new event from the process resource limit 61 // Reserve a new event from the process resource limit
62 KScopedResourceReservation event_reservation(kernel.CurrentProcess(), 62 KScopedResourceReservation event_reservation(GetCurrentProcessPointer(kernel),
63 LimitableResource::EventCountMax); 63 LimitableResource::EventCountMax);
64 R_UNLESS(event_reservation.Succeeded(), ResultLimitReached); 64 R_UNLESS(event_reservation.Succeeded(), ResultLimitReached);
65 65
@@ -68,7 +68,7 @@ Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) {
68 R_UNLESS(event != nullptr, ResultOutOfResource); 68 R_UNLESS(event != nullptr, ResultOutOfResource);
69 69
70 // Initialize the event. 70 // Initialize the event.
71 event->Initialize(kernel.CurrentProcess()); 71 event->Initialize(GetCurrentProcessPointer(kernel));
72 72
73 // Commit the thread reservation. 73 // Commit the thread reservation.
74 event_reservation.Commit(); 74 event_reservation.Commit();
diff --git a/src/core/hle/kernel/svc/svc_info.cpp b/src/core/hle/kernel/svc/svc_info.cpp
index ad56e2fe6..58dc47508 100644
--- a/src/core/hle/kernel/svc/svc_info.cpp
+++ b/src/core/hle/kernel/svc/svc_info.cpp
@@ -44,7 +44,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
44 return ResultInvalidEnumValue; 44 return ResultInvalidEnumValue;
45 } 45 }
46 46
47 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 47 const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
48 KScopedAutoObject process = handle_table.GetObject<KProcess>(handle); 48 KScopedAutoObject process = handle_table.GetObject<KProcess>(handle);
49 if (process.IsNull()) { 49 if (process.IsNull()) {
50 LOG_ERROR(Kernel_SVC, "Process is not valid! info_id={}, info_sub_id={}, handle={:08X}", 50 LOG_ERROR(Kernel_SVC, "Process is not valid! info_id={}, info_sub_id={}, handle={:08X}",
@@ -154,7 +154,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
154 return ResultInvalidCombination; 154 return ResultInvalidCombination;
155 } 155 }
156 156
157 KProcess* const current_process = system.Kernel().CurrentProcess(); 157 KProcess* const current_process = GetCurrentProcessPointer(system.Kernel());
158 KHandleTable& handle_table = current_process->GetHandleTable(); 158 KHandleTable& handle_table = current_process->GetHandleTable();
159 const auto resource_limit = current_process->GetResourceLimit(); 159 const auto resource_limit = current_process->GetResourceLimit();
160 if (!resource_limit) { 160 if (!resource_limit) {
@@ -183,7 +183,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
183 return ResultInvalidCombination; 183 return ResultInvalidCombination;
184 } 184 }
185 185
186 *result = system.Kernel().CurrentProcess()->GetRandomEntropy(info_sub_id); 186 *result = GetCurrentProcess(system.Kernel()).GetRandomEntropy(info_sub_id);
187 return ResultSuccess; 187 return ResultSuccess;
188 188
189 case InfoType::InitialProcessIdRange: 189 case InfoType::InitialProcessIdRange:
@@ -200,9 +200,9 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
200 return ResultInvalidCombination; 200 return ResultInvalidCombination;
201 } 201 }
202 202
203 KScopedAutoObject thread = 203 KScopedAutoObject thread = GetCurrentProcess(system.Kernel())
204 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>( 204 .GetHandleTable()
205 static_cast<Handle>(handle)); 205 .GetObject<KThread>(static_cast<Handle>(handle));
206 if (thread.IsNull()) { 206 if (thread.IsNull()) {
207 LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", 207 LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}",
208 static_cast<Handle>(handle)); 208 static_cast<Handle>(handle));
@@ -249,7 +249,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
249 R_UNLESS(info_sub_id == 0, ResultInvalidCombination); 249 R_UNLESS(info_sub_id == 0, ResultInvalidCombination);
250 250
251 // Get the handle table. 251 // Get the handle table.
252 KProcess* current_process = system.Kernel().CurrentProcess(); 252 KProcess* current_process = GetCurrentProcessPointer(system.Kernel());
253 KHandleTable& handle_table = current_process->GetHandleTable(); 253 KHandleTable& handle_table = current_process->GetHandleTable();
254 254
255 // Get a new handle for the current process. 255 // Get a new handle for the current process.
diff --git a/src/core/hle/kernel/svc/svc_ipc.cpp b/src/core/hle/kernel/svc/svc_ipc.cpp
index 97ce49dde..a7a2c3b92 100644
--- a/src/core/hle/kernel/svc/svc_ipc.cpp
+++ b/src/core/hle/kernel/svc/svc_ipc.cpp
@@ -12,11 +12,9 @@ namespace Kernel::Svc {
12 12
13/// Makes a blocking IPC call to a service. 13/// Makes a blocking IPC call to a service.
14Result SendSyncRequest(Core::System& system, Handle handle) { 14Result SendSyncRequest(Core::System& system, Handle handle) {
15 auto& kernel = system.Kernel();
16
17 // Get the client session from its handle. 15 // Get the client session from its handle.
18 KScopedAutoObject session = 16 KScopedAutoObject session =
19 kernel.CurrentProcess()->GetHandleTable().GetObject<KClientSession>(handle); 17 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KClientSession>(handle);
20 R_UNLESS(session.IsNotNull(), ResultInvalidHandle); 18 R_UNLESS(session.IsNotNull(), ResultInvalidHandle);
21 19
22 LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName()); 20 LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName());
@@ -40,7 +38,7 @@ Result SendAsyncRequestWithUserBuffer(Core::System& system, Handle* out_event_ha
40Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_addr, s32 num_handles, 38Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_addr, s32 num_handles,
41 Handle reply_target, s64 timeout_ns) { 39 Handle reply_target, s64 timeout_ns) {
42 auto& kernel = system.Kernel(); 40 auto& kernel = system.Kernel();
43 auto& handle_table = GetCurrentThread(kernel).GetOwnerProcess()->GetHandleTable(); 41 auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
44 42
45 R_UNLESS(0 <= num_handles && num_handles <= ArgumentHandleCountMax, ResultOutOfRange); 43 R_UNLESS(0 <= num_handles && num_handles <= ArgumentHandleCountMax, ResultOutOfRange);
46 R_UNLESS(system.Memory().IsValidVirtualAddressRange( 44 R_UNLESS(system.Memory().IsValidVirtualAddressRange(
diff --git a/src/core/hle/kernel/svc/svc_lock.cpp b/src/core/hle/kernel/svc/svc_lock.cpp
index 7005ac30b..f3d3e140b 100644
--- a/src/core/hle/kernel/svc/svc_lock.cpp
+++ b/src/core/hle/kernel/svc/svc_lock.cpp
@@ -24,7 +24,7 @@ Result ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address,
24 return ResultInvalidAddress; 24 return ResultInvalidAddress;
25 } 25 }
26 26
27 return system.Kernel().CurrentProcess()->WaitForAddress(thread_handle, address, tag); 27 return GetCurrentProcess(system.Kernel()).WaitForAddress(thread_handle, address, tag);
28} 28}
29 29
30/// Unlock a mutex 30/// Unlock a mutex
@@ -43,7 +43,7 @@ Result ArbitrateUnlock(Core::System& system, VAddr address) {
43 return ResultInvalidAddress; 43 return ResultInvalidAddress;
44 } 44 }
45 45
46 return system.Kernel().CurrentProcess()->SignalToAddress(address); 46 return GetCurrentProcess(system.Kernel()).SignalToAddress(address);
47} 47}
48 48
49Result ArbitrateLock64(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag) { 49Result ArbitrateLock64(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag) {
diff --git a/src/core/hle/kernel/svc/svc_memory.cpp b/src/core/hle/kernel/svc/svc_memory.cpp
index 21f818da6..214bcd073 100644
--- a/src/core/hle/kernel/svc/svc_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_memory.cpp
@@ -113,7 +113,7 @@ Result SetMemoryPermission(Core::System& system, VAddr address, u64 size, Memory
113 R_UNLESS(IsValidSetMemoryPermission(perm), ResultInvalidNewMemoryPermission); 113 R_UNLESS(IsValidSetMemoryPermission(perm), ResultInvalidNewMemoryPermission);
114 114
115 // Validate that the region is in range for the current process. 115 // Validate that the region is in range for the current process.
116 auto& page_table = system.Kernel().CurrentProcess()->PageTable(); 116 auto& page_table = GetCurrentProcess(system.Kernel()).PageTable();
117 R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory); 117 R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory);
118 118
119 // Set the memory attribute. 119 // Set the memory attribute.
@@ -137,7 +137,7 @@ Result SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mas
137 R_UNLESS((mask | attr | SupportedMask) == SupportedMask, ResultInvalidCombination); 137 R_UNLESS((mask | attr | SupportedMask) == SupportedMask, ResultInvalidCombination);
138 138
139 // Validate that the region is in range for the current process. 139 // Validate that the region is in range for the current process.
140 auto& page_table{system.Kernel().CurrentProcess()->PageTable()}; 140 auto& page_table{GetCurrentProcess(system.Kernel()).PageTable()};
141 R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory); 141 R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory);
142 142
143 // Set the memory attribute. 143 // Set the memory attribute.
@@ -149,7 +149,7 @@ Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size)
149 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 149 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
150 src_addr, size); 150 src_addr, size);
151 151
152 auto& page_table{system.Kernel().CurrentProcess()->PageTable()}; 152 auto& page_table{GetCurrentProcess(system.Kernel()).PageTable()};
153 153
154 if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)}; 154 if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)};
155 result.IsError()) { 155 result.IsError()) {
@@ -164,7 +164,7 @@ Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 siz
164 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 164 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
165 src_addr, size); 165 src_addr, size);
166 166
167 auto& page_table{system.Kernel().CurrentProcess()->PageTable()}; 167 auto& page_table{GetCurrentProcess(system.Kernel()).PageTable()};
168 168
169 if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)}; 169 if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)};
170 result.IsError()) { 170 result.IsError()) {
diff --git a/src/core/hle/kernel/svc/svc_physical_memory.cpp b/src/core/hle/kernel/svc/svc_physical_memory.cpp
index 8d00e1fc3..a1f534454 100644
--- a/src/core/hle/kernel/svc/svc_physical_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_physical_memory.cpp
@@ -16,7 +16,7 @@ Result SetHeapSize(Core::System& system, VAddr* out_address, u64 size) {
16 R_UNLESS(size < MainMemorySizeMax, ResultInvalidSize); 16 R_UNLESS(size < MainMemorySizeMax, ResultInvalidSize);
17 17
18 // Set the heap size. 18 // Set the heap size.
19 R_TRY(system.Kernel().CurrentProcess()->PageTable().SetHeapSize(out_address, size)); 19 R_TRY(GetCurrentProcess(system.Kernel()).PageTable().SetHeapSize(out_address, size));
20 20
21 return ResultSuccess; 21 return ResultSuccess;
22} 22}
@@ -45,7 +45,7 @@ Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
45 return ResultInvalidMemoryRegion; 45 return ResultInvalidMemoryRegion;
46 } 46 }
47 47
48 KProcess* const current_process{system.Kernel().CurrentProcess()}; 48 KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())};
49 auto& page_table{current_process->PageTable()}; 49 auto& page_table{current_process->PageTable()};
50 50
51 if (current_process->GetSystemResourceSize() == 0) { 51 if (current_process->GetSystemResourceSize() == 0) {
@@ -94,7 +94,7 @@ Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
94 return ResultInvalidMemoryRegion; 94 return ResultInvalidMemoryRegion;
95 } 95 }
96 96
97 KProcess* const current_process{system.Kernel().CurrentProcess()}; 97 KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())};
98 auto& page_table{current_process->PageTable()}; 98 auto& page_table{current_process->PageTable()};
99 99
100 if (current_process->GetSystemResourceSize() == 0) { 100 if (current_process->GetSystemResourceSize() == 0) {
diff --git a/src/core/hle/kernel/svc/svc_port.cpp b/src/core/hle/kernel/svc/svc_port.cpp
index 2e5d228bb..2b7cebde5 100644
--- a/src/core/hle/kernel/svc/svc_port.cpp
+++ b/src/core/hle/kernel/svc/svc_port.cpp
@@ -34,7 +34,7 @@ Result ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_add
34 34
35 // Get the current handle table. 35 // Get the current handle table.
36 auto& kernel = system.Kernel(); 36 auto& kernel = system.Kernel();
37 auto& handle_table = kernel.CurrentProcess()->GetHandleTable(); 37 auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
38 38
39 // Find the client port. 39 // Find the client port.
40 auto port = kernel.CreateNamedServicePort(port_name); 40 auto port = kernel.CreateNamedServicePort(port_name);
diff --git a/src/core/hle/kernel/svc/svc_process.cpp b/src/core/hle/kernel/svc/svc_process.cpp
index d2c20aad2..c35d2be76 100644
--- a/src/core/hle/kernel/svc/svc_process.cpp
+++ b/src/core/hle/kernel/svc/svc_process.cpp
@@ -9,7 +9,7 @@ namespace Kernel::Svc {
9 9
10/// Exits the current process 10/// Exits the current process
11void ExitProcess(Core::System& system) { 11void ExitProcess(Core::System& system) {
12 auto* current_process = system.Kernel().CurrentProcess(); 12 auto* current_process = GetCurrentProcessPointer(system.Kernel());
13 13
14 LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessID()); 14 LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessID());
15 ASSERT_MSG(current_process->GetState() == KProcess::State::Running, 15 ASSERT_MSG(current_process->GetState() == KProcess::State::Running,
@@ -23,9 +23,9 @@ Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) {
23 LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle); 23 LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle);
24 24
25 // Get the object from the handle table. 25 // Get the object from the handle table.
26 KScopedAutoObject obj = 26 KScopedAutoObject obj = GetCurrentProcess(system.Kernel())
27 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KAutoObject>( 27 .GetHandleTable()
28 static_cast<Handle>(handle)); 28 .GetObject<KAutoObject>(static_cast<Handle>(handle));
29 R_UNLESS(obj.IsNotNull(), ResultInvalidHandle); 29 R_UNLESS(obj.IsNotNull(), ResultInvalidHandle);
30 30
31 // Get the process from the object. 31 // Get the process from the object.
@@ -63,10 +63,10 @@ Result GetProcessList(Core::System& system, s32* out_num_processes, VAddr out_pr
63 return ResultOutOfRange; 63 return ResultOutOfRange;
64 } 64 }
65 65
66 const auto& kernel = system.Kernel(); 66 auto& kernel = system.Kernel();
67 const auto total_copy_size = out_process_ids_size * sizeof(u64); 67 const auto total_copy_size = out_process_ids_size * sizeof(u64);
68 68
69 if (out_process_ids_size > 0 && !kernel.CurrentProcess()->PageTable().IsInsideAddressSpace( 69 if (out_process_ids_size > 0 && !GetCurrentProcess(kernel).PageTable().IsInsideAddressSpace(
70 out_process_ids, total_copy_size)) { 70 out_process_ids, total_copy_size)) {
71 LOG_ERROR(Kernel_SVC, "Address range outside address space. begin=0x{:016X}, end=0x{:016X}", 71 LOG_ERROR(Kernel_SVC, "Address range outside address space. begin=0x{:016X}, end=0x{:016X}",
72 out_process_ids, out_process_ids + total_copy_size); 72 out_process_ids, out_process_ids + total_copy_size);
@@ -92,7 +92,7 @@ Result GetProcessInfo(Core::System& system, s64* out, Handle process_handle,
92 ProcessInfoType info_type) { 92 ProcessInfoType info_type) {
93 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, info_type); 93 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, info_type);
94 94
95 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 95 const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
96 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); 96 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
97 if (process.IsNull()) { 97 if (process.IsNull()) {
98 LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}", 98 LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}",
diff --git a/src/core/hle/kernel/svc/svc_process_memory.cpp b/src/core/hle/kernel/svc/svc_process_memory.cpp
index dbe24e139..4dfd9e5bb 100644
--- a/src/core/hle/kernel/svc/svc_process_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_process_memory.cpp
@@ -45,7 +45,7 @@ Result SetProcessMemoryPermission(Core::System& system, Handle process_handle, V
45 45
46 // Get the process from its handle. 46 // Get the process from its handle.
47 KScopedAutoObject process = 47 KScopedAutoObject process =
48 system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle); 48 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle);
49 R_UNLESS(process.IsNotNull(), ResultInvalidHandle); 49 R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
50 50
51 // Validate that the address is in range. 51 // Validate that the address is in range.
@@ -71,7 +71,7 @@ Result MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_
71 R_UNLESS((src_address < src_address + size), ResultInvalidCurrentMemory); 71 R_UNLESS((src_address < src_address + size), ResultInvalidCurrentMemory);
72 72
73 // Get the processes. 73 // Get the processes.
74 KProcess* dst_process = system.CurrentProcess(); 74 KProcess* dst_process = GetCurrentProcessPointer(system.Kernel());
75 KScopedAutoObject src_process = 75 KScopedAutoObject src_process =
76 dst_process->GetHandleTable().GetObjectWithoutPseudoHandle<KProcess>(process_handle); 76 dst_process->GetHandleTable().GetObjectWithoutPseudoHandle<KProcess>(process_handle);
77 R_UNLESS(src_process.IsNotNull(), ResultInvalidHandle); 77 R_UNLESS(src_process.IsNotNull(), ResultInvalidHandle);
@@ -114,7 +114,7 @@ Result UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle proces
114 R_UNLESS((src_address < src_address + size), ResultInvalidCurrentMemory); 114 R_UNLESS((src_address < src_address + size), ResultInvalidCurrentMemory);
115 115
116 // Get the processes. 116 // Get the processes.
117 KProcess* dst_process = system.CurrentProcess(); 117 KProcess* dst_process = GetCurrentProcessPointer(system.Kernel());
118 KScopedAutoObject src_process = 118 KScopedAutoObject src_process =
119 dst_process->GetHandleTable().GetObjectWithoutPseudoHandle<KProcess>(process_handle); 119 dst_process->GetHandleTable().GetObjectWithoutPseudoHandle<KProcess>(process_handle);
120 R_UNLESS(src_process.IsNotNull(), ResultInvalidHandle); 120 R_UNLESS(src_process.IsNotNull(), ResultInvalidHandle);
@@ -174,7 +174,7 @@ Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst
174 return ResultInvalidCurrentMemory; 174 return ResultInvalidCurrentMemory;
175 } 175 }
176 176
177 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 177 const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
178 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); 178 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
179 if (process.IsNull()) { 179 if (process.IsNull()) {
180 LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).", 180 LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).",
@@ -242,7 +242,7 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d
242 return ResultInvalidCurrentMemory; 242 return ResultInvalidCurrentMemory;
243 } 243 }
244 244
245 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 245 const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
246 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); 246 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
247 if (process.IsNull()) { 247 if (process.IsNull()) {
248 LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).", 248 LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).",
diff --git a/src/core/hle/kernel/svc/svc_query_memory.cpp b/src/core/hle/kernel/svc/svc_query_memory.cpp
index db140a341..ee75ad370 100644
--- a/src/core/hle/kernel/svc/svc_query_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_query_memory.cpp
@@ -22,7 +22,7 @@ Result QueryMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out
22Result QueryProcessMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, 22Result QueryProcessMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info,
23 Handle process_handle, uint64_t address) { 23 Handle process_handle, uint64_t address) {
24 LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); 24 LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address);
25 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 25 const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
26 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); 26 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
27 if (process.IsNull()) { 27 if (process.IsNull()) {
28 LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}", 28 LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}",
diff --git a/src/core/hle/kernel/svc/svc_resource_limit.cpp b/src/core/hle/kernel/svc/svc_resource_limit.cpp
index ebc886028..88166299e 100644
--- a/src/core/hle/kernel/svc/svc_resource_limit.cpp
+++ b/src/core/hle/kernel/svc/svc_resource_limit.cpp
@@ -27,7 +27,7 @@ Result CreateResourceLimit(Core::System& system, Handle* out_handle) {
27 KResourceLimit::Register(kernel, resource_limit); 27 KResourceLimit::Register(kernel, resource_limit);
28 28
29 // Add the limit to the handle table. 29 // Add the limit to the handle table.
30 R_TRY(kernel.CurrentProcess()->GetHandleTable().Add(out_handle, resource_limit)); 30 R_TRY(GetCurrentProcess(kernel).GetHandleTable().Add(out_handle, resource_limit));
31 31
32 return ResultSuccess; 32 return ResultSuccess;
33} 33}
@@ -41,9 +41,9 @@ Result GetResourceLimitLimitValue(Core::System& system, s64* out_limit_value,
41 R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue); 41 R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue);
42 42
43 // Get the resource limit. 43 // Get the resource limit.
44 auto& kernel = system.Kernel(); 44 KScopedAutoObject resource_limit = GetCurrentProcess(system.Kernel())
45 KScopedAutoObject resource_limit = 45 .GetHandleTable()
46 kernel.CurrentProcess()->GetHandleTable().GetObject<KResourceLimit>(resource_limit_handle); 46 .GetObject<KResourceLimit>(resource_limit_handle);
47 R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle); 47 R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle);
48 48
49 // Get the limit value. 49 // Get the limit value.
@@ -61,9 +61,9 @@ Result GetResourceLimitCurrentValue(Core::System& system, s64* out_current_value
61 R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue); 61 R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue);
62 62
63 // Get the resource limit. 63 // Get the resource limit.
64 auto& kernel = system.Kernel(); 64 KScopedAutoObject resource_limit = GetCurrentProcess(system.Kernel())
65 KScopedAutoObject resource_limit = 65 .GetHandleTable()
66 kernel.CurrentProcess()->GetHandleTable().GetObject<KResourceLimit>(resource_limit_handle); 66 .GetObject<KResourceLimit>(resource_limit_handle);
67 R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle); 67 R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle);
68 68
69 // Get the current value. 69 // Get the current value.
@@ -81,9 +81,9 @@ Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_ha
81 R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue); 81 R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue);
82 82
83 // Get the resource limit. 83 // Get the resource limit.
84 auto& kernel = system.Kernel(); 84 KScopedAutoObject resource_limit = GetCurrentProcess(system.Kernel())
85 KScopedAutoObject resource_limit = 85 .GetHandleTable()
86 kernel.CurrentProcess()->GetHandleTable().GetObject<KResourceLimit>(resource_limit_handle); 86 .GetObject<KResourceLimit>(resource_limit_handle);
87 R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle); 87 R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle);
88 88
89 // Set the limit value. 89 // Set the limit value.
diff --git a/src/core/hle/kernel/svc/svc_session.cpp b/src/core/hle/kernel/svc/svc_session.cpp
index 0deb61b62..00fd1605e 100644
--- a/src/core/hle/kernel/svc/svc_session.cpp
+++ b/src/core/hle/kernel/svc/svc_session.cpp
@@ -13,7 +13,7 @@ namespace {
13 13
14template <typename T> 14template <typename T>
15Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u64 name) { 15Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u64 name) {
16 auto& process = *system.CurrentProcess(); 16 auto& process = GetCurrentProcess(system.Kernel());
17 auto& handle_table = process.GetHandleTable(); 17 auto& handle_table = process.GetHandleTable();
18 18
19 // Declare the session we're going to allocate. 19 // Declare the session we're going to allocate.
diff --git a/src/core/hle/kernel/svc/svc_shared_memory.cpp b/src/core/hle/kernel/svc/svc_shared_memory.cpp
index 40d6260e3..18e0dc904 100644
--- a/src/core/hle/kernel/svc/svc_shared_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_shared_memory.cpp
@@ -42,7 +42,7 @@ Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address,
42 R_UNLESS(IsValidSharedMemoryPermission(map_perm), ResultInvalidNewMemoryPermission); 42 R_UNLESS(IsValidSharedMemoryPermission(map_perm), ResultInvalidNewMemoryPermission);
43 43
44 // Get the current process. 44 // Get the current process.
45 auto& process = *system.Kernel().CurrentProcess(); 45 auto& process = GetCurrentProcess(system.Kernel());
46 auto& page_table = process.PageTable(); 46 auto& page_table = process.PageTable();
47 47
48 // Get the shared memory. 48 // Get the shared memory.
@@ -75,7 +75,7 @@ Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr addres
75 R_UNLESS((address < address + size), ResultInvalidCurrentMemory); 75 R_UNLESS((address < address + size), ResultInvalidCurrentMemory);
76 76
77 // Get the current process. 77 // Get the current process.
78 auto& process = *system.Kernel().CurrentProcess(); 78 auto& process = GetCurrentProcess(system.Kernel());
79 auto& page_table = process.PageTable(); 79 auto& page_table = process.PageTable();
80 80
81 // Get the shared memory. 81 // Get the shared memory.
diff --git a/src/core/hle/kernel/svc/svc_synchronization.cpp b/src/core/hle/kernel/svc/svc_synchronization.cpp
index e516a3800..1a8f7e191 100644
--- a/src/core/hle/kernel/svc/svc_synchronization.cpp
+++ b/src/core/hle/kernel/svc/svc_synchronization.cpp
@@ -14,7 +14,7 @@ Result CloseHandle(Core::System& system, Handle handle) {
14 LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle); 14 LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle);
15 15
16 // Remove the handle. 16 // Remove the handle.
17 R_UNLESS(system.Kernel().CurrentProcess()->GetHandleTable().Remove(handle), 17 R_UNLESS(GetCurrentProcess(system.Kernel()).GetHandleTable().Remove(handle),
18 ResultInvalidHandle); 18 ResultInvalidHandle);
19 19
20 return ResultSuccess; 20 return ResultSuccess;
@@ -25,7 +25,7 @@ Result ResetSignal(Core::System& system, Handle handle) {
25 LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); 25 LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle);
26 26
27 // Get the current handle table. 27 // Get the current handle table.
28 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 28 const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
29 29
30 // Try to reset as readable event. 30 // Try to reset as readable event.
31 { 31 {
@@ -59,7 +59,7 @@ Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_addre
59 59
60 auto& kernel = system.Kernel(); 60 auto& kernel = system.Kernel();
61 std::vector<KSynchronizationObject*> objs(num_handles); 61 std::vector<KSynchronizationObject*> objs(num_handles);
62 const auto& handle_table = kernel.CurrentProcess()->GetHandleTable(); 62 const auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
63 Handle* handles = system.Memory().GetPointer<Handle>(handles_address); 63 Handle* handles = system.Memory().GetPointer<Handle>(handles_address);
64 64
65 // Copy user handles. 65 // Copy user handles.
@@ -91,7 +91,7 @@ Result CancelSynchronization(Core::System& system, Handle handle) {
91 91
92 // Get the thread from its handle. 92 // Get the thread from its handle.
93 KScopedAutoObject thread = 93 KScopedAutoObject thread =
94 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(handle); 94 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(handle);
95 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); 95 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
96 96
97 // Cancel the thread's wait. 97 // Cancel the thread's wait.
@@ -106,7 +106,7 @@ void SynchronizePreemptionState(Core::System& system) {
106 KScopedSchedulerLock sl{kernel}; 106 KScopedSchedulerLock sl{kernel};
107 107
108 // If the current thread is pinned, unpin it. 108 // If the current thread is pinned, unpin it.
109 KProcess* cur_process = system.Kernel().CurrentProcess(); 109 KProcess* cur_process = GetCurrentProcessPointer(kernel);
110 const auto core_id = GetCurrentCoreId(kernel); 110 const auto core_id = GetCurrentCoreId(kernel);
111 111
112 if (cur_process->GetPinnedThread(core_id) == GetCurrentThreadPointer(kernel)) { 112 if (cur_process->GetPinnedThread(core_id) == GetCurrentThreadPointer(kernel)) {
diff --git a/src/core/hle/kernel/svc/svc_thread.cpp b/src/core/hle/kernel/svc/svc_thread.cpp
index 3e325c998..b39807841 100644
--- a/src/core/hle/kernel/svc/svc_thread.cpp
+++ b/src/core/hle/kernel/svc/svc_thread.cpp
@@ -28,7 +28,7 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point,
28 28
29 // Adjust core id, if it's the default magic. 29 // Adjust core id, if it's the default magic.
30 auto& kernel = system.Kernel(); 30 auto& kernel = system.Kernel();
31 auto& process = *kernel.CurrentProcess(); 31 auto& process = GetCurrentProcess(kernel);
32 if (core_id == IdealCoreUseProcessValue) { 32 if (core_id == IdealCoreUseProcessValue) {
33 core_id = process.GetIdealCoreId(); 33 core_id = process.GetIdealCoreId();
34 } 34 }
@@ -53,9 +53,9 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point,
53 } 53 }
54 54
55 // Reserve a new thread from the process resource limit (waiting up to 100ms). 55 // Reserve a new thread from the process resource limit (waiting up to 100ms).
56 KScopedResourceReservation thread_reservation( 56 KScopedResourceReservation thread_reservation(&process, LimitableResource::ThreadCountMax, 1,
57 kernel.CurrentProcess(), LimitableResource::ThreadCountMax, 1, 57 system.CoreTiming().GetGlobalTimeNs().count() +
58 system.CoreTiming().GetGlobalTimeNs().count() + 100000000); 58 100000000);
59 if (!thread_reservation.Succeeded()) { 59 if (!thread_reservation.Succeeded()) {
60 LOG_ERROR(Kernel_SVC, "Could not reserve a new thread"); 60 LOG_ERROR(Kernel_SVC, "Could not reserve a new thread");
61 return ResultLimitReached; 61 return ResultLimitReached;
@@ -97,7 +97,7 @@ Result StartThread(Core::System& system, Handle thread_handle) {
97 97
98 // Get the thread from its handle. 98 // Get the thread from its handle.
99 KScopedAutoObject thread = 99 KScopedAutoObject thread =
100 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle); 100 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle);
101 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); 101 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
102 102
103 // Try to start the thread. 103 // Try to start the thread.
@@ -156,11 +156,11 @@ Result GetThreadContext3(Core::System& system, VAddr out_context, Handle thread_
156 156
157 // Get the thread from its handle. 157 // Get the thread from its handle.
158 KScopedAutoObject thread = 158 KScopedAutoObject thread =
159 kernel.CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle); 159 GetCurrentProcess(kernel).GetHandleTable().GetObject<KThread>(thread_handle);
160 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); 160 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
161 161
162 // Require the handle be to a non-current thread in the current process. 162 // Require the handle be to a non-current thread in the current process.
163 const auto* current_process = kernel.CurrentProcess(); 163 const auto* current_process = GetCurrentProcessPointer(kernel);
164 R_UNLESS(current_process == thread->GetOwnerProcess(), ResultInvalidId); 164 R_UNLESS(current_process == thread->GetOwnerProcess(), ResultInvalidId);
165 165
166 // Verify that the thread isn't terminated. 166 // Verify that the thread isn't terminated.
@@ -211,7 +211,7 @@ Result GetThreadPriority(Core::System& system, s32* out_priority, Handle handle)
211 211
212 // Get the thread from its handle. 212 // Get the thread from its handle.
213 KScopedAutoObject thread = 213 KScopedAutoObject thread =
214 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(handle); 214 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(handle);
215 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); 215 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
216 216
217 // Get the thread's priority. 217 // Get the thread's priority.
@@ -222,7 +222,7 @@ Result GetThreadPriority(Core::System& system, s32* out_priority, Handle handle)
222/// Sets the priority for the specified thread 222/// Sets the priority for the specified thread
223Result SetThreadPriority(Core::System& system, Handle thread_handle, s32 priority) { 223Result SetThreadPriority(Core::System& system, Handle thread_handle, s32 priority) {
224 // Get the current process. 224 // Get the current process.
225 KProcess& process = *system.Kernel().CurrentProcess(); 225 KProcess& process = GetCurrentProcess(system.Kernel());
226 226
227 // Validate the priority. 227 // Validate the priority.
228 R_UNLESS(HighestThreadPriority <= priority && priority <= LowestThreadPriority, 228 R_UNLESS(HighestThreadPriority <= priority && priority <= LowestThreadPriority,
@@ -253,7 +253,7 @@ Result GetThreadList(Core::System& system, s32* out_num_threads, VAddr out_threa
253 return ResultOutOfRange; 253 return ResultOutOfRange;
254 } 254 }
255 255
256 auto* const current_process = system.Kernel().CurrentProcess(); 256 auto* const current_process = GetCurrentProcessPointer(system.Kernel());
257 const auto total_copy_size = out_thread_ids_size * sizeof(u64); 257 const auto total_copy_size = out_thread_ids_size * sizeof(u64);
258 258
259 if (out_thread_ids_size > 0 && 259 if (out_thread_ids_size > 0 &&
@@ -284,7 +284,7 @@ Result GetThreadCoreMask(Core::System& system, s32* out_core_id, u64* out_affini
284 284
285 // Get the thread from its handle. 285 // Get the thread from its handle.
286 KScopedAutoObject thread = 286 KScopedAutoObject thread =
287 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle); 287 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle);
288 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); 288 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
289 289
290 // Get the core mask. 290 // Get the core mask.
@@ -297,11 +297,11 @@ Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id
297 u64 affinity_mask) { 297 u64 affinity_mask) {
298 // Determine the core id/affinity mask. 298 // Determine the core id/affinity mask.
299 if (core_id == IdealCoreUseProcessValue) { 299 if (core_id == IdealCoreUseProcessValue) {
300 core_id = system.Kernel().CurrentProcess()->GetIdealCoreId(); 300 core_id = GetCurrentProcess(system.Kernel()).GetIdealCoreId();
301 affinity_mask = (1ULL << core_id); 301 affinity_mask = (1ULL << core_id);
302 } else { 302 } else {
303 // Validate the affinity mask. 303 // Validate the affinity mask.
304 const u64 process_core_mask = system.Kernel().CurrentProcess()->GetCoreMask(); 304 const u64 process_core_mask = GetCurrentProcess(system.Kernel()).GetCoreMask();
305 R_UNLESS((affinity_mask | process_core_mask) == process_core_mask, ResultInvalidCoreId); 305 R_UNLESS((affinity_mask | process_core_mask) == process_core_mask, ResultInvalidCoreId);
306 R_UNLESS(affinity_mask != 0, ResultInvalidCombination); 306 R_UNLESS(affinity_mask != 0, ResultInvalidCombination);
307 307
@@ -316,7 +316,7 @@ Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id
316 316
317 // Get the thread from its handle. 317 // Get the thread from its handle.
318 KScopedAutoObject thread = 318 KScopedAutoObject thread =
319 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle); 319 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle);
320 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); 320 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
321 321
322 // Set the core mask. 322 // Set the core mask.
@@ -329,7 +329,7 @@ Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id
329Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) { 329Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) {
330 // Get the thread from its handle. 330 // Get the thread from its handle.
331 KScopedAutoObject thread = 331 KScopedAutoObject thread =
332 system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle); 332 GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle);
333 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); 333 R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
334 334
335 // Get the thread's id. 335 // Get the thread's id.
diff --git a/src/core/hle/kernel/svc/svc_transfer_memory.cpp b/src/core/hle/kernel/svc/svc_transfer_memory.cpp
index a4c040e49..7ffc24adf 100644
--- a/src/core/hle/kernel/svc/svc_transfer_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_transfer_memory.cpp
@@ -39,11 +39,11 @@ Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u6
39 R_UNLESS(IsValidTransferMemoryPermission(map_perm), ResultInvalidNewMemoryPermission); 39 R_UNLESS(IsValidTransferMemoryPermission(map_perm), ResultInvalidNewMemoryPermission);
40 40
41 // Get the current process and handle table. 41 // Get the current process and handle table.
42 auto& process = *kernel.CurrentProcess(); 42 auto& process = GetCurrentProcess(kernel);
43 auto& handle_table = process.GetHandleTable(); 43 auto& handle_table = process.GetHandleTable();
44 44
45 // Reserve a new transfer memory from the process resource limit. 45 // Reserve a new transfer memory from the process resource limit.
46 KScopedResourceReservation trmem_reservation(kernel.CurrentProcess(), 46 KScopedResourceReservation trmem_reservation(&process,
47 LimitableResource::TransferMemoryCountMax); 47 LimitableResource::TransferMemoryCountMax);
48 R_UNLESS(trmem_reservation.Succeeded(), ResultLimitReached); 48 R_UNLESS(trmem_reservation.Succeeded(), ResultLimitReached);
49 49
diff --git a/src/core/hle/kernel/svc_generator.py b/src/core/hle/kernel/svc_generator.py
index b0a5707ec..34d2ac659 100644
--- a/src/core/hle/kernel/svc_generator.py
+++ b/src/core/hle/kernel/svc_generator.py
@@ -592,7 +592,7 @@ void Call(Core::System& system, u32 imm) {
592 auto& kernel = system.Kernel(); 592 auto& kernel = system.Kernel();
593 kernel.EnterSVCProfile(); 593 kernel.EnterSVCProfile();
594 594
595 if (system.CurrentProcess()->Is64BitProcess()) { 595 if (GetCurrentProcess(system.Kernel()).Is64BitProcess()) {
596 Call64(system, imm); 596 Call64(system, imm);
597 } else { 597 } else {
598 Call32(system, imm); 598 Call32(system, imm);
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 6d1084fd1..1495d64de 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -762,7 +762,7 @@ Result Module::Interface::InitializeApplicationInfoBase() {
762 // processes emulated. As we don't actually have pid support we should assume we're just using 762 // processes emulated. As we don't actually have pid support we should assume we're just using
763 // our own process 763 // our own process
764 const auto launch_property = 764 const auto launch_property =
765 system.GetARPManager().GetLaunchProperty(system.GetCurrentProcessProgramID()); 765 system.GetARPManager().GetLaunchProperty(system.GetApplicationProcessProgramID());
766 766
767 if (launch_property.Failed()) { 767 if (launch_property.Failed()) {
768 LOG_ERROR(Service_ACC, "Failed to get launch property"); 768 LOG_ERROR(Service_ACC, "Failed to get launch property");
@@ -806,7 +806,7 @@ void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx
806 bool is_locked = false; 806 bool is_locked = false;
807 807
808 if (res != Loader::ResultStatus::Success) { 808 if (res != Loader::ResultStatus::Success) {
809 const FileSys::PatchManager pm{system.GetCurrentProcessProgramID(), 809 const FileSys::PatchManager pm{system.GetApplicationProcessProgramID(),
810 system.GetFileSystemController(), 810 system.GetFileSystemController(),
811 system.GetContentProvider()}; 811 system.GetContentProvider()};
812 const auto nacp_unique = pm.GetControlMetadata().first; 812 const auto nacp_unique = pm.GetControlMetadata().first;
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index ebcf6e164..beb2da06e 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -24,7 +24,6 @@
24#include "core/hle/service/am/idle.h" 24#include "core/hle/service/am/idle.h"
25#include "core/hle/service/am/omm.h" 25#include "core/hle/service/am/omm.h"
26#include "core/hle/service/am/spsm.h" 26#include "core/hle/service/am/spsm.h"
27#include "core/hle/service/am/tcap.h"
28#include "core/hle/service/apm/apm_controller.h" 27#include "core/hle/service/apm/apm_controller.h"
29#include "core/hle/service/apm/apm_interface.h" 28#include "core/hle/service/apm/apm_interface.h"
30#include "core/hle/service/bcat/backend/backend.h" 29#include "core/hle/service/bcat/backend/backend.h"
@@ -79,7 +78,7 @@ IWindowController::IWindowController(Core::System& system_)
79IWindowController::~IWindowController() = default; 78IWindowController::~IWindowController() = default;
80 79
81void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) { 80void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) {
82 const u64 process_id = system.CurrentProcess()->GetProcessID(); 81 const u64 process_id = system.ApplicationProcess()->GetProcessID();
83 82
84 LOG_DEBUG(Service_AM, "called. Process ID=0x{:016X}", process_id); 83 LOG_DEBUG(Service_AM, "called. Process ID=0x{:016X}", process_id);
85 84
@@ -1252,7 +1251,7 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex
1252 } 1251 }
1253 1252
1254 auto transfer_mem = 1253 auto transfer_mem =
1255 system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle); 1254 system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle);
1256 1255
1257 if (transfer_mem.IsNull()) { 1256 if (transfer_mem.IsNull()) {
1258 LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle); 1257 LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle);
@@ -1286,7 +1285,7 @@ void ILibraryAppletCreator::CreateHandleStorage(Kernel::HLERequestContext& ctx)
1286 } 1285 }
1287 1286
1288 auto transfer_mem = 1287 auto transfer_mem =
1289 system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle); 1288 system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle);
1290 1289
1291 if (transfer_mem.IsNull()) { 1290 if (transfer_mem.IsNull()) {
1292 LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle); 1291 LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle);
@@ -1465,11 +1464,12 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
1465 const auto backend = BCAT::CreateBackendFromSettings(system, [this](u64 tid) { 1464 const auto backend = BCAT::CreateBackendFromSettings(system, [this](u64 tid) {
1466 return system.GetFileSystemController().GetBCATDirectory(tid); 1465 return system.GetFileSystemController().GetBCATDirectory(tid);
1467 }); 1466 });
1468 const auto build_id_full = system.GetCurrentProcessBuildID(); 1467 const auto build_id_full = system.GetApplicationProcessBuildID();
1469 u64 build_id{}; 1468 u64 build_id{};
1470 std::memcpy(&build_id, build_id_full.data(), sizeof(u64)); 1469 std::memcpy(&build_id, build_id_full.data(), sizeof(u64));
1471 1470
1472 auto data = backend->GetLaunchParameter({system.GetCurrentProcessProgramID(), build_id}); 1471 auto data =
1472 backend->GetLaunchParameter({system.GetApplicationProcessProgramID(), build_id});
1473 if (data.has_value()) { 1473 if (data.has_value()) {
1474 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 1474 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
1475 rb.Push(ResultSuccess); 1475 rb.Push(ResultSuccess);
@@ -1521,7 +1521,7 @@ void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
1521 LOG_DEBUG(Service_AM, "called, uid={:016X}{:016X}", user_id[1], user_id[0]); 1521 LOG_DEBUG(Service_AM, "called, uid={:016X}{:016X}", user_id[1], user_id[0]);
1522 1522
1523 FileSys::SaveDataAttribute attribute{}; 1523 FileSys::SaveDataAttribute attribute{};
1524 attribute.title_id = system.GetCurrentProcessProgramID(); 1524 attribute.title_id = system.GetApplicationProcessProgramID();
1525 attribute.user_id = user_id; 1525 attribute.user_id = user_id;
1526 attribute.type = FileSys::SaveDataType::SaveData; 1526 attribute.type = FileSys::SaveDataType::SaveData;
1527 const auto res = system.GetFileSystemController().CreateSaveData( 1527 const auto res = system.GetFileSystemController().CreateSaveData(
@@ -1551,7 +1551,7 @@ void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
1551 std::array<u8, 0x10> version_string{}; 1551 std::array<u8, 0x10> version_string{};
1552 1552
1553 const auto res = [this] { 1553 const auto res = [this] {
1554 const auto title_id = system.GetCurrentProcessProgramID(); 1554 const auto title_id = system.GetApplicationProcessProgramID();
1555 1555
1556 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), 1556 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
1557 system.GetContentProvider()}; 1557 system.GetContentProvider()};
@@ -1570,7 +1570,7 @@ void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
1570 const auto& version = res.first->GetVersionString(); 1570 const auto& version = res.first->GetVersionString();
1571 std::copy(version.begin(), version.end(), version_string.begin()); 1571 std::copy(version.begin(), version.end(), version_string.begin());
1572 } else { 1572 } else {
1573 constexpr char default_version[]{"1.0.0"}; 1573 static constexpr char default_version[]{"1.0.0"};
1574 std::memcpy(version_string.data(), default_version, sizeof(default_version)); 1574 std::memcpy(version_string.data(), default_version, sizeof(default_version));
1575 } 1575 }
1576 1576
@@ -1588,7 +1588,7 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
1588 u32 supported_languages = 0; 1588 u32 supported_languages = 0;
1589 1589
1590 const auto res = [this] { 1590 const auto res = [this] {
1591 const auto title_id = system.GetCurrentProcessProgramID(); 1591 const auto title_id = system.GetApplicationProcessProgramID();
1592 1592
1593 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), 1593 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
1594 system.GetContentProvider()}; 1594 system.GetContentProvider()};
@@ -1696,7 +1696,8 @@ void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) {
1696 static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size); 1696 static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size);
1697 1697
1698 system.GetFileSystemController().WriteSaveDataSize( 1698 system.GetFileSystemController().WriteSaveDataSize(
1699 type, system.GetCurrentProcessProgramID(), user_id, {new_normal_size, new_journal_size}); 1699 type, system.GetApplicationProcessProgramID(), user_id,
1700 {new_normal_size, new_journal_size});
1700 1701
1701 IPC::ResponseBuilder rb{ctx, 4}; 1702 IPC::ResponseBuilder rb{ctx, 4};
1702 rb.Push(ResultSuccess); 1703 rb.Push(ResultSuccess);
@@ -1720,7 +1721,7 @@ void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) {
1720 user_id[0]); 1721 user_id[0]);
1721 1722
1722 const auto size = system.GetFileSystemController().ReadSaveDataSize( 1723 const auto size = system.GetFileSystemController().ReadSaveDataSize(
1723 type, system.GetCurrentProcessProgramID(), user_id); 1724 type, system.GetApplicationProcessProgramID(), user_id);
1724 1725
1725 IPC::ResponseBuilder rb{ctx, 6}; 1726 IPC::ResponseBuilder rb{ctx, 6};
1726 rb.Push(ResultSuccess); 1727 rb.Push(ResultSuccess);
@@ -1838,7 +1839,6 @@ void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger
1838 std::make_shared<IdleSys>(system)->InstallAsService(service_manager); 1839 std::make_shared<IdleSys>(system)->InstallAsService(service_manager);
1839 std::make_shared<OMM>(system)->InstallAsService(service_manager); 1840 std::make_shared<OMM>(system)->InstallAsService(service_manager);
1840 std::make_shared<SPSM>(system)->InstallAsService(service_manager); 1841 std::make_shared<SPSM>(system)->InstallAsService(service_manager);
1841 std::make_shared<TCAP>(system)->InstallAsService(service_manager);
1842} 1842}
1843 1843
1844IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_) 1844IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_)
diff --git a/src/core/hle/service/am/applets/applet_error.cpp b/src/core/hle/service/am/applets/applet_error.cpp
index bae0d99a6..b013896b4 100644
--- a/src/core/hle/service/am/applets/applet_error.cpp
+++ b/src/core/hle/service/am/applets/applet_error.cpp
@@ -166,7 +166,7 @@ void Error::Execute() {
166 } 166 }
167 167
168 const auto callback = [this] { DisplayCompleted(); }; 168 const auto callback = [this] { DisplayCompleted(); };
169 const auto title_id = system.GetCurrentProcessProgramID(); 169 const auto title_id = system.GetApplicationProcessProgramID();
170 const auto& reporter{system.GetReporter()}; 170 const auto& reporter{system.GetReporter()};
171 171
172 switch (mode) { 172 switch (mode) {
diff --git a/src/core/hle/service/am/applets/applet_general_backend.cpp b/src/core/hle/service/am/applets/applet_general_backend.cpp
index e50acdaf6..1eefa85e3 100644
--- a/src/core/hle/service/am/applets/applet_general_backend.cpp
+++ b/src/core/hle/service/am/applets/applet_general_backend.cpp
@@ -186,7 +186,7 @@ void PhotoViewer::Execute() {
186 const auto callback = [this] { ViewFinished(); }; 186 const auto callback = [this] { ViewFinished(); };
187 switch (mode) { 187 switch (mode) {
188 case PhotoViewerAppletMode::CurrentApp: 188 case PhotoViewerAppletMode::CurrentApp:
189 frontend.ShowPhotosForApplication(system.GetCurrentProcessProgramID(), callback); 189 frontend.ShowPhotosForApplication(system.GetApplicationProcessProgramID(), callback);
190 break; 190 break;
191 case PhotoViewerAppletMode::AllApps: 191 case PhotoViewerAppletMode::AllApps:
192 frontend.ShowAllPhotos(callback); 192 frontend.ShowAllPhotos(callback);
diff --git a/src/core/hle/service/am/applets/applet_web_browser.cpp b/src/core/hle/service/am/applets/applet_web_browser.cpp
index 14aa6f69e..f061bae80 100644
--- a/src/core/hle/service/am/applets/applet_web_browser.cpp
+++ b/src/core/hle/service/am/applets/applet_web_browser.cpp
@@ -393,7 +393,7 @@ void WebBrowser::InitializeOffline() {
393 switch (document_kind) { 393 switch (document_kind) {
394 case DocumentKind::OfflineHtmlPage: 394 case DocumentKind::OfflineHtmlPage:
395 default: 395 default:
396 title_id = system.GetCurrentProcessProgramID(); 396 title_id = system.GetApplicationProcessProgramID();
397 nca_type = FileSys::ContentRecordType::HtmlDocument; 397 nca_type = FileSys::ContentRecordType::HtmlDocument;
398 additional_paths = "html-document"; 398 additional_paths = "html-document";
399 break; 399 break;
diff --git a/src/core/hle/service/am/tcap.cpp b/src/core/hle/service/am/tcap.cpp
deleted file mode 100644
index 818420e22..000000000
--- a/src/core/hle/service/am/tcap.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/am/tcap.h"
5
6namespace Service::AM {
7
8TCAP::TCAP(Core::System& system_) : ServiceFramework{system_, "tcap"} {
9 // clang-format off
10 static const FunctionInfo functions[] = {
11 {0, nullptr, "GetContinuousHighSkinTemperatureEvent"},
12 {1, nullptr, "SetOperationMode"},
13 {2, nullptr, "LoadAndApplySettings"},
14 };
15 // clang-format on
16
17 RegisterHandlers(functions);
18}
19
20TCAP::~TCAP() = default;
21
22} // namespace Service::AM
diff --git a/src/core/hle/service/am/tcap.h b/src/core/hle/service/am/tcap.h
deleted file mode 100644
index 6b2148c29..000000000
--- a/src/core/hle/service/am/tcap.h
+++ /dev/null
@@ -1,20 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/service.h"
7
8namespace Core {
9class System;
10}
11
12namespace Service::AM {
13
14class TCAP final : public ServiceFramework<TCAP> {
15public:
16 explicit TCAP(Core::System& system_);
17 ~TCAP() override;
18};
19
20} // namespace Service::AM
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp
index 368ccd52f..7264f23f9 100644
--- a/src/core/hle/service/aoc/aoc_u.cpp
+++ b/src/core/hle/service/aoc/aoc_u.cpp
@@ -155,7 +155,7 @@ void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) {
155 IPC::ResponseBuilder rb{ctx, 3}; 155 IPC::ResponseBuilder rb{ctx, 3};
156 rb.Push(ResultSuccess); 156 rb.Push(ResultSuccess);
157 157
158 const auto current = system.GetCurrentProcessProgramID(); 158 const auto current = system.GetApplicationProcessProgramID();
159 159
160 const auto& disabled = Settings::values.disabled_addons[current]; 160 const auto& disabled = Settings::values.disabled_addons[current];
161 if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) { 161 if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) {
@@ -182,7 +182,7 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) {
182 LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count, 182 LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count,
183 process_id); 183 process_id);
184 184
185 const auto current = system.GetCurrentProcessProgramID(); 185 const auto current = system.GetApplicationProcessProgramID();
186 186
187 std::vector<u32> out; 187 std::vector<u32> out;
188 const auto& disabled = Settings::values.disabled_addons[current]; 188 const auto& disabled = Settings::values.disabled_addons[current];
@@ -228,7 +228,7 @@ void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) {
228 IPC::ResponseBuilder rb{ctx, 4}; 228 IPC::ResponseBuilder rb{ctx, 4};
229 rb.Push(ResultSuccess); 229 rb.Push(ResultSuccess);
230 230
231 const auto title_id = system.GetCurrentProcessProgramID(); 231 const auto title_id = system.GetApplicationProcessProgramID();
232 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), 232 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
233 system.GetContentProvider()}; 233 system.GetContentProvider()};
234 234
diff --git a/src/core/hle/service/apm/apm.cpp b/src/core/hle/service/apm/apm.cpp
index 8a338d9b1..44b2927a6 100644
--- a/src/core/hle/service/apm/apm.cpp
+++ b/src/core/hle/service/apm/apm.cpp
@@ -14,8 +14,6 @@ void InstallInterfaces(Core::System& system) {
14 auto module_ = std::make_shared<Module>(); 14 auto module_ = std::make_shared<Module>();
15 std::make_shared<APM>(system, module_, system.GetAPMController(), "apm") 15 std::make_shared<APM>(system, module_, system.GetAPMController(), "apm")
16 ->InstallAsService(system.ServiceManager()); 16 ->InstallAsService(system.ServiceManager());
17 std::make_shared<APM>(system, module_, system.GetAPMController(), "apm:p")
18 ->InstallAsService(system.ServiceManager());
19 std::make_shared<APM>(system, module_, system.GetAPMController(), "apm:am") 17 std::make_shared<APM>(system, module_, system.GetAPMController(), "apm:am")
20 ->InstallAsService(system.ServiceManager()); 18 ->InstallAsService(system.ServiceManager());
21 std::make_shared<APM_Sys>(system, system.GetAPMController()) 19 std::make_shared<APM_Sys>(system, system.GetAPMController())
diff --git a/src/core/hle/service/apm/apm_controller.cpp b/src/core/hle/service/apm/apm_controller.cpp
index d6de84066..227fdd0cf 100644
--- a/src/core/hle/service/apm/apm_controller.cpp
+++ b/src/core/hle/service/apm/apm_controller.cpp
@@ -56,7 +56,7 @@ void Controller::SetPerformanceConfiguration(PerformanceMode mode,
56} 56}
57 57
58void Controller::SetFromCpuBoostMode(CpuBoostMode mode) { 58void Controller::SetFromCpuBoostMode(CpuBoostMode mode) {
59 constexpr std::array<PerformanceConfiguration, 3> BOOST_MODE_TO_CONFIG_MAP{{ 59 static constexpr std::array<PerformanceConfiguration, 3> BOOST_MODE_TO_CONFIG_MAP{{
60 PerformanceConfiguration::Config7, 60 PerformanceConfiguration::Config7,
61 PerformanceConfiguration::Config13, 61 PerformanceConfiguration::Config13,
62 PerformanceConfiguration::Config15, 62 PerformanceConfiguration::Config15,
diff --git a/src/core/hle/service/audio/auddbg.cpp b/src/core/hle/service/audio/auddbg.cpp
deleted file mode 100644
index 5541af300..000000000
--- a/src/core/hle/service/audio/auddbg.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/audio/auddbg.h"
5
6namespace Service::Audio {
7
8AudDbg::AudDbg(Core::System& system_, const char* name) : ServiceFramework{system_, name} {
9 // clang-format off
10 static const FunctionInfo functions[] = {
11 {0, nullptr, "RequestSuspendForDebug"},
12 {1, nullptr, "RequestResumeForDebug"},
13 };
14 // clang-format on
15
16 RegisterHandlers(functions);
17}
18
19AudDbg::~AudDbg() = default;
20
21} // namespace Service::Audio
diff --git a/src/core/hle/service/audio/auddbg.h b/src/core/hle/service/audio/auddbg.h
deleted file mode 100644
index 8f26be5dc..000000000
--- a/src/core/hle/service/audio/auddbg.h
+++ /dev/null
@@ -1,20 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/service.h"
7
8namespace Core {
9class System;
10}
11
12namespace Service::Audio {
13
14class AudDbg final : public ServiceFramework<AudDbg> {
15public:
16 explicit AudDbg(Core::System& system_, const char* name);
17 ~AudDbg() override;
18};
19
20} // namespace Service::Audio
diff --git a/src/core/hle/service/audio/audin_a.cpp b/src/core/hle/service/audio/audin_a.cpp
deleted file mode 100644
index 98f4a6048..000000000
--- a/src/core/hle/service/audio/audin_a.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/audio/audin_a.h"
5
6namespace Service::Audio {
7
8AudInA::AudInA(Core::System& system_) : ServiceFramework{system_, "audin:a"} {
9 // clang-format off
10 static const FunctionInfo functions[] = {
11 {0, nullptr, "RequestSuspend"},
12 {1, nullptr, "RequestResume"},
13 {2, nullptr, "GetProcessMasterVolume"},
14 {3, nullptr, "SetProcessMasterVolume"},
15 };
16 // clang-format on
17
18 RegisterHandlers(functions);
19}
20
21AudInA::~AudInA() = default;
22
23} // namespace Service::Audio
diff --git a/src/core/hle/service/audio/audin_a.h b/src/core/hle/service/audio/audin_a.h
deleted file mode 100644
index 19a927de5..000000000
--- a/src/core/hle/service/audio/audin_a.h
+++ /dev/null
@@ -1,20 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/service.h"
7
8namespace Core {
9class System;
10}
11
12namespace Service::Audio {
13
14class AudInA final : public ServiceFramework<AudInA> {
15public:
16 explicit AudInA(Core::System& system_);
17 ~AudInA() override;
18};
19
20} // namespace Service::Audio
diff --git a/src/core/hle/service/audio/audio.cpp b/src/core/hle/service/audio/audio.cpp
index 97da71dfa..ed36e3448 100644
--- a/src/core/hle/service/audio/audio.cpp
+++ b/src/core/hle/service/audio/audio.cpp
@@ -2,17 +2,12 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/hle/service/audio/audctl.h" 4#include "core/hle/service/audio/audctl.h"
5#include "core/hle/service/audio/auddbg.h"
6#include "core/hle/service/audio/audin_a.h"
7#include "core/hle/service/audio/audin_u.h" 5#include "core/hle/service/audio/audin_u.h"
8#include "core/hle/service/audio/audio.h" 6#include "core/hle/service/audio/audio.h"
9#include "core/hle/service/audio/audout_a.h"
10#include "core/hle/service/audio/audout_u.h" 7#include "core/hle/service/audio/audout_u.h"
11#include "core/hle/service/audio/audrec_a.h" 8#include "core/hle/service/audio/audrec_a.h"
12#include "core/hle/service/audio/audrec_u.h" 9#include "core/hle/service/audio/audrec_u.h"
13#include "core/hle/service/audio/audren_a.h"
14#include "core/hle/service/audio/audren_u.h" 10#include "core/hle/service/audio/audren_u.h"
15#include "core/hle/service/audio/codecctl.h"
16#include "core/hle/service/audio/hwopus.h" 11#include "core/hle/service/audio/hwopus.h"
17#include "core/hle/service/service.h" 12#include "core/hle/service/service.h"
18 13
@@ -20,21 +15,12 @@ namespace Service::Audio {
20 15
21void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { 16void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
22 std::make_shared<AudCtl>(system)->InstallAsService(service_manager); 17 std::make_shared<AudCtl>(system)->InstallAsService(service_manager);
23 std::make_shared<AudOutA>(system)->InstallAsService(service_manager);
24 std::make_shared<AudOutU>(system)->InstallAsService(service_manager); 18 std::make_shared<AudOutU>(system)->InstallAsService(service_manager);
25 std::make_shared<AudInA>(system)->InstallAsService(service_manager);
26 std::make_shared<AudInU>(system)->InstallAsService(service_manager); 19 std::make_shared<AudInU>(system)->InstallAsService(service_manager);
27 std::make_shared<AudRecA>(system)->InstallAsService(service_manager); 20 std::make_shared<AudRecA>(system)->InstallAsService(service_manager);
28 std::make_shared<AudRecU>(system)->InstallAsService(service_manager); 21 std::make_shared<AudRecU>(system)->InstallAsService(service_manager);
29 std::make_shared<AudRenA>(system)->InstallAsService(service_manager);
30 std::make_shared<AudRenU>(system)->InstallAsService(service_manager); 22 std::make_shared<AudRenU>(system)->InstallAsService(service_manager);
31 std::make_shared<CodecCtl>(system)->InstallAsService(service_manager);
32 std::make_shared<HwOpus>(system)->InstallAsService(service_manager); 23 std::make_shared<HwOpus>(system)->InstallAsService(service_manager);
33
34 std::make_shared<AudDbg>(system, "audin:d")->InstallAsService(service_manager);
35 std::make_shared<AudDbg>(system, "audout:d")->InstallAsService(service_manager);
36 std::make_shared<AudDbg>(system, "audrec:d")->InstallAsService(service_manager);
37 std::make_shared<AudDbg>(system, "audren:d")->InstallAsService(service_manager);
38} 24}
39 25
40} // namespace Service::Audio 26} // namespace Service::Audio
diff --git a/src/core/hle/service/audio/audout_a.cpp b/src/core/hle/service/audio/audout_a.cpp
deleted file mode 100644
index 5ecb99236..000000000
--- a/src/core/hle/service/audio/audout_a.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/audio/audout_a.h"
5
6namespace Service::Audio {
7
8AudOutA::AudOutA(Core::System& system_) : ServiceFramework{system_, "audout:a"} {
9 // clang-format off
10 static const FunctionInfo functions[] = {
11 {0, nullptr, "RequestSuspend"},
12 {1, nullptr, "RequestResume"},
13 {2, nullptr, "GetProcessMasterVolume"},
14 {3, nullptr, "SetProcessMasterVolume"},
15 {4, nullptr, "GetProcessRecordVolume"},
16 {5, nullptr, "SetProcessRecordVolume"},
17 };
18 // clang-format on
19
20 RegisterHandlers(functions);
21}
22
23AudOutA::~AudOutA() = default;
24
25} // namespace Service::Audio
diff --git a/src/core/hle/service/audio/audout_a.h b/src/core/hle/service/audio/audout_a.h
deleted file mode 100644
index f641cffeb..000000000
--- a/src/core/hle/service/audio/audout_a.h
+++ /dev/null
@@ -1,20 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/service.h"
7
8namespace Core {
9class System;
10}
11
12namespace Service::Audio {
13
14class AudOutA final : public ServiceFramework<AudOutA> {
15public:
16 explicit AudOutA(Core::System& system_);
17 ~AudOutA() override;
18};
19
20} // namespace Service::Audio
diff --git a/src/core/hle/service/audio/audren_a.cpp b/src/core/hle/service/audio/audren_a.cpp
deleted file mode 100644
index e775ac3bf..000000000
--- a/src/core/hle/service/audio/audren_a.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/audio/audren_a.h"
5
6namespace Service::Audio {
7
8AudRenA::AudRenA(Core::System& system_) : ServiceFramework{system_, "audren:a"} {
9 // clang-format off
10 static const FunctionInfo functions[] = {
11 {0, nullptr, "RequestSuspend"},
12 {1, nullptr, "RequestResume"},
13 {2, nullptr, "GetProcessMasterVolume"},
14 {3, nullptr, "SetProcessMasterVolume"},
15 {4, nullptr, "RegisterAppletResourceUserId"},
16 {5, nullptr, "UnregisterAppletResourceUserId"},
17 {6, nullptr, "GetProcessRecordVolume"},
18 {7, nullptr, "SetProcessRecordVolume"},
19 };
20 // clang-format on
21
22 RegisterHandlers(functions);
23}
24
25AudRenA::~AudRenA() = default;
26
27} // namespace Service::Audio
diff --git a/src/core/hle/service/audio/audren_a.h b/src/core/hle/service/audio/audren_a.h
deleted file mode 100644
index 9e08b4245..000000000
--- a/src/core/hle/service/audio/audren_a.h
+++ /dev/null
@@ -1,20 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/service.h"
7
8namespace Core {
9class System;
10}
11
12namespace Service::Audio {
13
14class AudRenA final : public ServiceFramework<AudRenA> {
15public:
16 explicit AudRenA(Core::System& system_);
17 ~AudRenA() override;
18};
19
20} // namespace Service::Audio
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index 0ee28752c..7d730421d 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -455,7 +455,7 @@ void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) {
455 return; 455 return;
456 } 456 }
457 457
458 const auto& handle_table{system.CurrentProcess()->GetHandleTable()}; 458 const auto& handle_table{system.ApplicationProcess()->GetHandleTable()};
459 auto process{handle_table.GetObject<Kernel::KProcess>(process_handle)}; 459 auto process{handle_table.GetObject<Kernel::KProcess>(process_handle)};
460 auto transfer_memory{ 460 auto transfer_memory{
461 process->GetHandleTable().GetObject<Kernel::KTransferMemory>(transfer_memory_handle)}; 461 process->GetHandleTable().GetObject<Kernel::KTransferMemory>(transfer_memory_handle)};
diff --git a/src/core/hle/service/audio/codecctl.cpp b/src/core/hle/service/audio/codecctl.cpp
deleted file mode 100644
index 81b956d7e..000000000
--- a/src/core/hle/service/audio/codecctl.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/audio/codecctl.h"
5
6namespace Service::Audio {
7
8CodecCtl::CodecCtl(Core::System& system_) : ServiceFramework{system_, "codecctl"} {
9 static const FunctionInfo functions[] = {
10 {0, nullptr, "Initialize"},
11 {1, nullptr, "Finalize"},
12 {2, nullptr, "Sleep"},
13 {3, nullptr, "Wake"},
14 {4, nullptr, "SetVolume"},
15 {5, nullptr, "GetVolumeMax"},
16 {6, nullptr, "GetVolumeMin"},
17 {7, nullptr, "SetActiveTarget"},
18 {8, nullptr, "GetActiveTarget"},
19 {9, nullptr, "BindHeadphoneMicJackInterrupt"},
20 {10, nullptr, "IsHeadphoneMicJackInserted"},
21 {11, nullptr, "ClearHeadphoneMicJackInterrupt"},
22 {12, nullptr, "IsRequested"},
23 };
24 RegisterHandlers(functions);
25}
26
27CodecCtl::~CodecCtl() = default;
28
29} // namespace Service::Audio
diff --git a/src/core/hle/service/audio/codecctl.h b/src/core/hle/service/audio/codecctl.h
deleted file mode 100644
index 34da98212..000000000
--- a/src/core/hle/service/audio/codecctl.h
+++ /dev/null
@@ -1,20 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/service.h"
7
8namespace Core {
9class System;
10}
11
12namespace Service::Audio {
13
14class CodecCtl final : public ServiceFramework<CodecCtl> {
15public:
16 explicit CodecCtl(Core::System& system_);
17 ~CodecCtl() override;
18};
19
20} // namespace Service::Audio
diff --git a/src/core/hle/service/bcat/bcat_module.cpp b/src/core/hle/service/bcat/bcat_module.cpp
index cbe690a5d..6e6fed227 100644
--- a/src/core/hle/service/bcat/bcat_module.cpp
+++ b/src/core/hle/service/bcat/bcat_module.cpp
@@ -176,8 +176,8 @@ private:
176 void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) { 176 void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) {
177 LOG_DEBUG(Service_BCAT, "called"); 177 LOG_DEBUG(Service_BCAT, "called");
178 178
179 backend.Synchronize({system.GetCurrentProcessProgramID(), 179 backend.Synchronize({system.GetApplicationProcessProgramID(),
180 GetCurrentBuildID(system.GetCurrentProcessBuildID())}, 180 GetCurrentBuildID(system.GetApplicationProcessBuildID())},
181 GetProgressBackend(SyncType::Normal)); 181 GetProgressBackend(SyncType::Normal));
182 182
183 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 183 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@@ -193,8 +193,8 @@ private:
193 193
194 LOG_DEBUG(Service_BCAT, "called, name={}", name); 194 LOG_DEBUG(Service_BCAT, "called, name={}", name);
195 195
196 backend.SynchronizeDirectory({system.GetCurrentProcessProgramID(), 196 backend.SynchronizeDirectory({system.GetApplicationProcessProgramID(),
197 GetCurrentBuildID(system.GetCurrentProcessBuildID())}, 197 GetCurrentBuildID(system.GetApplicationProcessBuildID())},
198 name, GetProgressBackend(SyncType::Directory)); 198 name, GetProgressBackend(SyncType::Directory));
199 199
200 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 200 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@@ -554,7 +554,7 @@ private:
554void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx) { 554void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx) {
555 LOG_DEBUG(Service_BCAT, "called"); 555 LOG_DEBUG(Service_BCAT, "called");
556 556
557 const auto title_id = system.GetCurrentProcessProgramID(); 557 const auto title_id = system.GetApplicationProcessProgramID();
558 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 558 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
559 rb.Push(ResultSuccess); 559 rb.Push(ResultSuccess);
560 rb.PushIpcInterface<IDeliveryCacheStorageService>(system, fsc.GetBCATDirectory(title_id)); 560 rb.PushIpcInterface<IDeliveryCacheStorageService>(system, fsc.GetBCATDirectory(title_id));
diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp
index 27675615b..2e5919330 100644
--- a/src/core/hle/service/fatal/fatal.cpp
+++ b/src/core/hle/service/fatal/fatal.cpp
@@ -63,7 +63,7 @@ enum class FatalType : u32 {
63}; 63};
64 64
65static void GenerateErrorReport(Core::System& system, Result error_code, const FatalInfo& info) { 65static void GenerateErrorReport(Core::System& system, Result error_code, const FatalInfo& info) {
66 const auto title_id = system.GetCurrentProcessProgramID(); 66 const auto title_id = system.GetApplicationProcessProgramID();
67 std::string crash_report = fmt::format( 67 std::string crash_report = fmt::format(
68 "Yuzu {}-{} crash report\n" 68 "Yuzu {}-{} crash report\n"
69 "Title ID: {:016x}\n" 69 "Title ID: {:016x}\n"
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index 11c604a0f..177447bc1 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -317,7 +317,7 @@ ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFSCurrentProcess()
317 return ResultUnknown; 317 return ResultUnknown;
318 } 318 }
319 319
320 return romfs_factory->OpenCurrentProcess(system.GetCurrentProcessProgramID()); 320 return romfs_factory->OpenCurrentProcess(system.GetApplicationProcessProgramID());
321} 321}
322 322
323ResultVal<FileSys::VirtualFile> FileSystemController::OpenPatchedRomFS( 323ResultVal<FileSys::VirtualFile> FileSystemController::OpenPatchedRomFS(
@@ -502,7 +502,7 @@ FileSys::SaveDataSize FileSystemController::ReadSaveDataSize(FileSys::SaveDataTy
502 const auto res = system.GetAppLoader().ReadControlData(nacp); 502 const auto res = system.GetAppLoader().ReadControlData(nacp);
503 503
504 if (res != Loader::ResultStatus::Success) { 504 if (res != Loader::ResultStatus::Success) {
505 const FileSys::PatchManager pm{system.GetCurrentProcessProgramID(), 505 const FileSys::PatchManager pm{system.GetApplicationProcessProgramID(),
506 system.GetFileSystemController(), 506 system.GetFileSystemController(),
507 system.GetContentProvider()}; 507 system.GetContentProvider()};
508 const auto metadata = pm.GetControlMetadata(); 508 const auto metadata = pm.GetControlMetadata();
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index 447d624e1..e76346ca9 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -1036,8 +1036,9 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) {
1036 1036
1037 LOG_DEBUG(Service_FS, "called, program_index={}", program_index); 1037 LOG_DEBUG(Service_FS, "called, program_index={}", program_index);
1038 1038
1039 auto patched_romfs = fsc.OpenPatchedRomFSWithProgramIndex( 1039 auto patched_romfs =
1040 system.GetCurrentProcessProgramID(), program_index, FileSys::ContentRecordType::Program); 1040 fsc.OpenPatchedRomFSWithProgramIndex(system.GetApplicationProcessProgramID(), program_index,
1041 FileSys::ContentRecordType::Program);
1041 1042
1042 if (patched_romfs.Failed()) { 1043 if (patched_romfs.Failed()) {
1043 // TODO: Find the right error code to use here 1044 // TODO: Find the right error code to use here
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 5a1aa0903..eb3c45a58 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -1830,7 +1830,7 @@ void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) {
1830 ASSERT_MSG(t_mem_1_size == 0x1000, "t_mem_1_size is not 0x1000 bytes"); 1830 ASSERT_MSG(t_mem_1_size == 0x1000, "t_mem_1_size is not 0x1000 bytes");
1831 ASSERT_MSG(t_mem_2_size == 0x7F000, "t_mem_2_size is not 0x7F000 bytes"); 1831 ASSERT_MSG(t_mem_2_size == 0x7F000, "t_mem_2_size is not 0x7F000 bytes");
1832 1832
1833 auto t_mem_1 = system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( 1833 auto t_mem_1 = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
1834 t_mem_1_handle); 1834 t_mem_1_handle);
1835 1835
1836 if (t_mem_1.IsNull()) { 1836 if (t_mem_1.IsNull()) {
@@ -1840,7 +1840,7 @@ void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) {
1840 return; 1840 return;
1841 } 1841 }
1842 1842
1843 auto t_mem_2 = system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( 1843 auto t_mem_2 = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
1844 t_mem_2_handle); 1844 t_mem_2_handle);
1845 1845
1846 if (t_mem_2.IsNull()) { 1846 if (t_mem_2.IsNull()) {
@@ -2127,8 +2127,8 @@ void Hid::WritePalmaWaveEntry(Kernel::HLERequestContext& ctx) {
2127 2127
2128 ASSERT_MSG(t_mem_size == 0x3000, "t_mem_size is not 0x3000 bytes"); 2128 ASSERT_MSG(t_mem_size == 0x3000, "t_mem_size is not 0x3000 bytes");
2129 2129
2130 auto t_mem = 2130 auto t_mem = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
2131 system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(t_mem_handle); 2131 t_mem_handle);
2132 2132
2133 if (t_mem.IsNull()) { 2133 if (t_mem.IsNull()) {
2134 LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle); 2134 LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle);
@@ -2734,25 +2734,11 @@ private:
2734 } 2734 }
2735}; 2735};
2736 2736
2737class HidTmp final : public ServiceFramework<HidTmp> {
2738public:
2739 explicit HidTmp(Core::System& system_) : ServiceFramework{system_, "hid:tmp"} {
2740 // clang-format off
2741 static const FunctionInfo functions[] = {
2742 {0, nullptr, "GetConsoleSixAxisSensorCalibrationValues"},
2743 };
2744 // clang-format on
2745
2746 RegisterHandlers(functions);
2747 }
2748};
2749
2750void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { 2737void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
2751 std::make_shared<Hid>(system)->InstallAsService(service_manager); 2738 std::make_shared<Hid>(system)->InstallAsService(service_manager);
2752 std::make_shared<HidBus>(system)->InstallAsService(service_manager); 2739 std::make_shared<HidBus>(system)->InstallAsService(service_manager);
2753 std::make_shared<HidDbg>(system)->InstallAsService(service_manager); 2740 std::make_shared<HidDbg>(system)->InstallAsService(service_manager);
2754 std::make_shared<HidSys>(system)->InstallAsService(service_manager); 2741 std::make_shared<HidSys>(system)->InstallAsService(service_manager);
2755 std::make_shared<HidTmp>(system)->InstallAsService(service_manager);
2756 2742
2757 std::make_shared<Service::IRS::IRS>(system)->InstallAsService(service_manager); 2743 std::make_shared<Service::IRS::IRS>(system)->InstallAsService(service_manager);
2758 std::make_shared<Service::IRS::IRS_SYS>(system)->InstallAsService(service_manager); 2744 std::make_shared<Service::IRS::IRS_SYS>(system)->InstallAsService(service_manager);
diff --git a/src/core/hle/service/hid/hidbus.cpp b/src/core/hle/service/hid/hidbus.cpp
index 17252a84a..bd94e8f3d 100644
--- a/src/core/hle/service/hid/hidbus.cpp
+++ b/src/core/hle/service/hid/hidbus.cpp
@@ -449,8 +449,8 @@ void HidBus::EnableJoyPollingReceiveMode(Kernel::HLERequestContext& ctx) {
449 449
450 ASSERT_MSG(t_mem_size == 0x1000, "t_mem_size is not 0x1000 bytes"); 450 ASSERT_MSG(t_mem_size == 0x1000, "t_mem_size is not 0x1000 bytes");
451 451
452 auto t_mem = 452 auto t_mem = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
453 system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(t_mem_handle); 453 t_mem_handle);
454 454
455 if (t_mem.IsNull()) { 455 if (t_mem.IsNull()) {
456 LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle); 456 LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle);
diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cpp
index 52f402c56..3bd418e92 100644
--- a/src/core/hle/service/hid/irs.cpp
+++ b/src/core/hle/service/hid/irs.cpp
@@ -196,8 +196,8 @@ void IRS::RunImageTransferProcessor(Kernel::HLERequestContext& ctx) {
196 const auto parameters{rp.PopRaw<Parameters>()}; 196 const auto parameters{rp.PopRaw<Parameters>()};
197 const auto t_mem_handle{ctx.GetCopyHandle(0)}; 197 const auto t_mem_handle{ctx.GetCopyHandle(0)};
198 198
199 auto t_mem = 199 auto t_mem = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
200 system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(t_mem_handle); 200 t_mem_handle);
201 201
202 if (t_mem.IsNull()) { 202 if (t_mem.IsNull()) {
203 LOG_ERROR(Service_IRS, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle); 203 LOG_ERROR(Service_IRS, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle);
@@ -445,8 +445,8 @@ void IRS::RunImageTransferExProcessor(Kernel::HLERequestContext& ctx) {
445 const auto parameters{rp.PopRaw<Parameters>()}; 445 const auto parameters{rp.PopRaw<Parameters>()};
446 const auto t_mem_handle{ctx.GetCopyHandle(0)}; 446 const auto t_mem_handle{ctx.GetCopyHandle(0)};
447 447
448 auto t_mem = 448 auto t_mem = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
449 system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(t_mem_handle); 449 t_mem_handle);
450 450
451 u8* transfer_memory = system.Memory().GetPointer(t_mem->GetSourceAddress()); 451 u8* transfer_memory = system.Memory().GetPointer(t_mem->GetSourceAddress());
452 452
diff --git a/src/core/hle/service/jit/jit.cpp b/src/core/hle/service/jit/jit.cpp
index 1295a44c7..47a1277ea 100644
--- a/src/core/hle/service/jit/jit.cpp
+++ b/src/core/hle/service/jit/jit.cpp
@@ -353,9 +353,9 @@ public:
353 return; 353 return;
354 } 354 }
355 355
356 // Fetch using the handle table for the current process here, 356 // Fetch using the handle table for the application process here,
357 // since we are not multiprocess yet. 357 // since we are not multiprocess yet.
358 const auto& handle_table{system.CurrentProcess()->GetHandleTable()}; 358 const auto& handle_table{system.ApplicationProcess()->GetHandleTable()};
359 359
360 auto process{handle_table.GetObject<Kernel::KProcess>(process_handle)}; 360 auto process{handle_table.GetObject<Kernel::KProcess>(process_handle)};
361 if (process.IsNull()) { 361 if (process.IsNull()) {
diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp
index 652441bc2..2d4d6fe3e 100644
--- a/src/core/hle/service/ldr/ldr.cpp
+++ b/src/core/hle/service/ldr/ldr.cpp
@@ -246,7 +246,7 @@ public:
246 return; 246 return;
247 } 247 }
248 248
249 if (system.GetCurrentProcessProgramID() != header.application_id) { 249 if (system.GetApplicationProcessProgramID() != header.application_id) {
250 LOG_ERROR(Service_LDR, 250 LOG_ERROR(Service_LDR,
251 "Attempting to load NRR with title ID other than current process. (actual " 251 "Attempting to load NRR with title ID other than current process. (actual "
252 "{:016X})!", 252 "{:016X})!",
@@ -542,15 +542,16 @@ public:
542 } 542 }
543 543
544 // Map memory for the NRO 544 // Map memory for the NRO
545 const auto map_result{MapNro(system.CurrentProcess(), nro_address, nro_size, bss_address, 545 const auto map_result{MapNro(system.ApplicationProcess(), nro_address, nro_size,
546 bss_size, nro_size + bss_size)}; 546 bss_address, bss_size, nro_size + bss_size)};
547 if (map_result.Failed()) { 547 if (map_result.Failed()) {
548 IPC::ResponseBuilder rb{ctx, 2}; 548 IPC::ResponseBuilder rb{ctx, 2};
549 rb.Push(map_result.Code()); 549 rb.Push(map_result.Code());
550 } 550 }
551 551
552 // Load the NRO into the mapped memory 552 // Load the NRO into the mapped memory
553 if (const auto result{LoadNro(system.CurrentProcess(), header, nro_address, *map_result)}; 553 if (const auto result{
554 LoadNro(system.ApplicationProcess(), header, nro_address, *map_result)};
554 result.IsError()) { 555 result.IsError()) {
555 IPC::ResponseBuilder rb{ctx, 2}; 556 IPC::ResponseBuilder rb{ctx, 2};
556 rb.Push(map_result.Code()); 557 rb.Push(map_result.Code());
@@ -570,7 +571,7 @@ public:
570 571
571 Result UnmapNro(const NROInfo& info) { 572 Result UnmapNro(const NROInfo& info) {
572 // Each region must be unmapped separately to validate memory state 573 // Each region must be unmapped separately to validate memory state
573 auto& page_table{system.CurrentProcess()->PageTable()}; 574 auto& page_table{system.ApplicationProcess()->PageTable()};
574 575
575 if (info.bss_size != 0) { 576 if (info.bss_size != 0) {
576 CASCADE_CODE(page_table.UnmapCodeMemory( 577 CASCADE_CODE(page_table.UnmapCodeMemory(
@@ -641,7 +642,7 @@ public:
641 LOG_WARNING(Service_LDR, "(STUBBED) called"); 642 LOG_WARNING(Service_LDR, "(STUBBED) called");
642 643
643 initialized = true; 644 initialized = true;
644 current_map_addr = system.CurrentProcess()->PageTable().GetAliasCodeRegionStart(); 645 current_map_addr = system.ApplicationProcess()->PageTable().GetAliasCodeRegionStart();
645 646
646 IPC::ResponseBuilder rb{ctx, 2}; 647 IPC::ResponseBuilder rb{ctx, 2};
647 rb.Push(ResultSuccess); 648 rb.Push(ResultSuccess);
diff --git a/src/core/hle/service/nfp/nfp_device.cpp b/src/core/hle/service/nfp/nfp_device.cpp
index e67a76f55..7a6bbbba7 100644
--- a/src/core/hle/service/nfp/nfp_device.cpp
+++ b/src/core/hle/service/nfp/nfp_device.cpp
@@ -618,7 +618,7 @@ Result NfpDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> dat
618 sizeof(ApplicationArea) - data.size()); 618 sizeof(ApplicationArea) - data.size());
619 619
620 // TODO: Investigate why the title id needs to be moddified 620 // TODO: Investigate why the title id needs to be moddified
621 tag_data.title_id = system.GetCurrentProcessProgramID(); 621 tag_data.title_id = system.GetApplicationProcessProgramID();
622 tag_data.title_id = tag_data.title_id | 0x30000000ULL; 622 tag_data.title_id = tag_data.title_id | 0x30000000ULL;
623 tag_data.settings.settings.appdata_initialized.Assign(1); 623 tag_data.settings.settings.appdata_initialized.Assign(1);
624 tag_data.application_area_id = access_id; 624 tag_data.application_area_id = access_id;
diff --git a/src/core/hle/service/nvdrv/core/syncpoint_manager.h b/src/core/hle/service/nvdrv/core/syncpoint_manager.h
index 4f2cefae5..7728ff596 100644
--- a/src/core/hle/service/nvdrv/core/syncpoint_manager.h
+++ b/src/core/hle/service/nvdrv/core/syncpoint_manager.h
@@ -124,7 +124,7 @@ private:
124 //!< value 124 //!< value
125 }; 125 };
126 126
127 constexpr static std::size_t SyncpointCount{192}; 127 static constexpr std::size_t SyncpointCount{192};
128 std::array<SyncpointInfo, SyncpointCount> syncpoints{}; 128 std::array<SyncpointInfo, SyncpointCount> syncpoints{};
129 std::mutex reservation_lock; 129 std::mutex reservation_lock;
130 130
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
index 0cdde82a7..e12025560 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
@@ -150,9 +150,9 @@ NvResult nvhost_ctrl::IocCtrlEventWait(std::span<const u8> input, std::vector<u8
150 const auto check_failing = [&]() { 150 const auto check_failing = [&]() {
151 if (events[slot].fails > 2) { 151 if (events[slot].fails > 2) {
152 { 152 {
153 auto lk = system.StallProcesses(); 153 auto lk = system.StallApplication();
154 host1x_syncpoint_manager.WaitHost(fence_id, target_value); 154 host1x_syncpoint_manager.WaitHost(fence_id, target_value);
155 system.UnstallProcesses(); 155 system.UnstallApplication();
156 } 156 }
157 params.value.raw = target_value; 157 params.value.raw = target_value;
158 return true; 158 return true;
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp
index 29c1e0f01..277afe0b4 100644
--- a/src/core/hle/service/nvdrv/devices/nvmap.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp
@@ -127,7 +127,7 @@ NvResult nvmap::IocAlloc(std::span<const u8> input, std::vector<u8>& output) {
127 return result; 127 return result;
128 } 128 }
129 bool is_out_io{}; 129 bool is_out_io{};
130 ASSERT(system.CurrentProcess() 130 ASSERT(system.ApplicationProcess()
131 ->PageTable() 131 ->PageTable()
132 .LockForMapDeviceAddressSpace(&is_out_io, handle_description->address, 132 .LockForMapDeviceAddressSpace(&is_out_io, handle_description->address,
133 handle_description->size, 133 handle_description->size,
@@ -254,7 +254,7 @@ NvResult nvmap::IocFree(std::span<const u8> input, std::vector<u8>& output) {
254 254
255 if (auto freeInfo{file.FreeHandle(params.handle, false)}) { 255 if (auto freeInfo{file.FreeHandle(params.handle, false)}) {
256 if (freeInfo->can_unlock) { 256 if (freeInfo->can_unlock) {
257 ASSERT(system.CurrentProcess() 257 ASSERT(system.ApplicationProcess()
258 ->PageTable() 258 ->PageTable()
259 .UnlockForDeviceAddressSpace(freeInfo->address, freeInfo->size) 259 .UnlockForDeviceAddressSpace(freeInfo->address, freeInfo->size)
260 .IsSuccess()); 260 .IsSuccess());
diff --git a/src/core/hle/service/pctl/pctl_module.cpp b/src/core/hle/service/pctl/pctl_module.cpp
index 2a123b42d..083609b34 100644
--- a/src/core/hle/service/pctl/pctl_module.cpp
+++ b/src/core/hle/service/pctl/pctl_module.cpp
@@ -187,7 +187,7 @@ private:
187 187
188 // TODO(ogniK): Recovery flag initialization for pctl:r 188 // TODO(ogniK): Recovery flag initialization for pctl:r
189 189
190 const auto tid = system.GetCurrentProcessProgramID(); 190 const auto tid = system.GetApplicationProcessProgramID();
191 if (tid != 0) { 191 if (tid != 0) {
192 const FileSys::PatchManager pm{tid, system.GetFileSystemController(), 192 const FileSys::PatchManager pm{tid, system.GetFileSystemController(),
193 system.GetContentProvider()}; 193 system.GetContentProvider()};
diff --git a/src/core/hle/service/pcv/pcv.cpp b/src/core/hle/service/pcv/pcv.cpp
index f7a497a14..98037a8d4 100644
--- a/src/core/hle/service/pcv/pcv.cpp
+++ b/src/core/hle/service/pcv/pcv.cpp
@@ -52,32 +52,6 @@ public:
52 } 52 }
53}; 53};
54 54
55class PCV_ARB final : public ServiceFramework<PCV_ARB> {
56public:
57 explicit PCV_ARB(Core::System& system_) : ServiceFramework{system_, "pcv:arb"} {
58 // clang-format off
59 static const FunctionInfo functions[] = {
60 {0, nullptr, "ReleaseControl"},
61 };
62 // clang-format on
63
64 RegisterHandlers(functions);
65 }
66};
67
68class PCV_IMM final : public ServiceFramework<PCV_IMM> {
69public:
70 explicit PCV_IMM(Core::System& system_) : ServiceFramework{system_, "pcv:imm"} {
71 // clang-format off
72 static const FunctionInfo functions[] = {
73 {0, nullptr, "SetClockRate"},
74 };
75 // clang-format on
76
77 RegisterHandlers(functions);
78 }
79};
80
81class IClkrstSession final : public ServiceFramework<IClkrstSession> { 55class IClkrstSession final : public ServiceFramework<IClkrstSession> {
82public: 56public:
83 explicit IClkrstSession(Core::System& system_, DeviceCode deivce_code_) 57 explicit IClkrstSession(Core::System& system_, DeviceCode deivce_code_)
@@ -169,8 +143,6 @@ public:
169 143
170void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { 144void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
171 std::make_shared<PCV>(system)->InstallAsService(sm); 145 std::make_shared<PCV>(system)->InstallAsService(sm);
172 std::make_shared<PCV_ARB>(system)->InstallAsService(sm);
173 std::make_shared<PCV_IMM>(system)->InstallAsService(sm);
174 std::make_shared<CLKRST>(system, "clkrst")->InstallAsService(sm); 146 std::make_shared<CLKRST>(system, "clkrst")->InstallAsService(sm);
175 std::make_shared<CLKRST>(system, "clkrst:i")->InstallAsService(sm); 147 std::make_shared<CLKRST>(system, "clkrst:i")->InstallAsService(sm);
176 std::make_shared<CLKRST_A>(system)->InstallAsService(sm); 148 std::make_shared<CLKRST_A>(system)->InstallAsService(sm);
diff --git a/src/core/hle/service/prepo/prepo.cpp b/src/core/hle/service/prepo/prepo.cpp
index 01040b32a..90c5f8756 100644
--- a/src/core/hle/service/prepo/prepo.cpp
+++ b/src/core/hle/service/prepo/prepo.cpp
@@ -71,7 +71,7 @@ private:
71 Type, process_id, data1.size(), data2.size()); 71 Type, process_id, data1.size(), data2.size());
72 72
73 const auto& reporter{system.GetReporter()}; 73 const auto& reporter{system.GetReporter()};
74 reporter.SavePlayReport(Type, system.GetCurrentProcessProgramID(), {data1, data2}, 74 reporter.SavePlayReport(Type, system.GetApplicationProcessProgramID(), {data1, data2},
75 process_id); 75 process_id);
76 76
77 IPC::ResponseBuilder rb{ctx, 2}; 77 IPC::ResponseBuilder rb{ctx, 2};
@@ -99,7 +99,7 @@ private:
99 Type, user_id[1], user_id[0], process_id, data1.size(), data2.size()); 99 Type, user_id[1], user_id[0], process_id, data1.size(), data2.size());
100 100
101 const auto& reporter{system.GetReporter()}; 101 const auto& reporter{system.GetReporter()};
102 reporter.SavePlayReport(Type, system.GetCurrentProcessProgramID(), {data1, data2}, 102 reporter.SavePlayReport(Type, system.GetApplicationProcessProgramID(), {data1, data2},
103 process_id, user_id); 103 process_id, user_id);
104 104
105 IPC::ResponseBuilder rb{ctx, 2}; 105 IPC::ResponseBuilder rb{ctx, 2};
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 0de67f1e1..1ffc1c694 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -68,7 +68,6 @@
68#include "core/hle/service/time/time.h" 68#include "core/hle/service/time/time.h"
69#include "core/hle/service/usb/usb.h" 69#include "core/hle/service/usb/usb.h"
70#include "core/hle/service/vi/vi.h" 70#include "core/hle/service/vi/vi.h"
71#include "core/hle/service/wlan/wlan.h"
72#include "core/reporter.h" 71#include "core/reporter.h"
73 72
74namespace Service { 73namespace Service {
@@ -306,7 +305,6 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system
306 Time::InstallInterfaces(system); 305 Time::InstallInterfaces(system);
307 USB::InstallInterfaces(*sm, system); 306 USB::InstallInterfaces(*sm, system);
308 VI::InstallInterfaces(*sm, system, *nv_flinger, *hos_binder_driver_server); 307 VI::InstallInterfaces(*sm, system, *nv_flinger, *hos_binder_driver_server);
309 WLAN::InstallInterfaces(*sm, system);
310} 308}
311 309
312Services::~Services() = default; 310Services::~Services() = default;
diff --git a/src/core/hle/service/sockets/ethc.cpp b/src/core/hle/service/sockets/ethc.cpp
deleted file mode 100644
index c12ea999b..000000000
--- a/src/core/hle/service/sockets/ethc.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/sockets/ethc.h"
5
6namespace Service::Sockets {
7
8ETHC_C::ETHC_C(Core::System& system_) : ServiceFramework{system_, "ethc:c"} {
9 // clang-format off
10 static const FunctionInfo functions[] = {
11 {0, nullptr, "Initialize"},
12 {1, nullptr, "Cancel"},
13 {2, nullptr, "GetResult"},
14 {3, nullptr, "GetMediaList"},
15 {4, nullptr, "SetMediaType"},
16 {5, nullptr, "GetMediaType"},
17 {6, nullptr, "Unknown6"},
18 };
19 // clang-format on
20
21 RegisterHandlers(functions);
22}
23
24ETHC_C::~ETHC_C() = default;
25
26ETHC_I::ETHC_I(Core::System& system_) : ServiceFramework{system_, "ethc:i"} {
27 // clang-format off
28 static const FunctionInfo functions[] = {
29 {0, nullptr, "GetReadableHandle"},
30 {1, nullptr, "Cancel"},
31 {2, nullptr, "GetResult"},
32 {3, nullptr, "GetInterfaceList"},
33 {4, nullptr, "GetInterfaceCount"},
34 };
35 // clang-format on
36
37 RegisterHandlers(functions);
38}
39
40ETHC_I::~ETHC_I() = default;
41
42} // namespace Service::Sockets
diff --git a/src/core/hle/service/sockets/ethc.h b/src/core/hle/service/sockets/ethc.h
deleted file mode 100644
index 7c5759a96..000000000
--- a/src/core/hle/service/sockets/ethc.h
+++ /dev/null
@@ -1,26 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/service.h"
7
8namespace Core {
9class System;
10}
11
12namespace Service::Sockets {
13
14class ETHC_C final : public ServiceFramework<ETHC_C> {
15public:
16 explicit ETHC_C(Core::System& system_);
17 ~ETHC_C() override;
18};
19
20class ETHC_I final : public ServiceFramework<ETHC_I> {
21public:
22 explicit ETHC_I(Core::System& system_);
23 ~ETHC_I() override;
24};
25
26} // namespace Service::Sockets
diff --git a/src/core/hle/service/sockets/sockets.cpp b/src/core/hle/service/sockets/sockets.cpp
index 8d3ba6f96..b191b5cf5 100644
--- a/src/core/hle/service/sockets/sockets.cpp
+++ b/src/core/hle/service/sockets/sockets.cpp
@@ -2,7 +2,6 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/hle/service/sockets/bsd.h" 4#include "core/hle/service/sockets/bsd.h"
5#include "core/hle/service/sockets/ethc.h"
6#include "core/hle/service/sockets/nsd.h" 5#include "core/hle/service/sockets/nsd.h"
7#include "core/hle/service/sockets/sfdnsres.h" 6#include "core/hle/service/sockets/sfdnsres.h"
8#include "core/hle/service/sockets/sockets.h" 7#include "core/hle/service/sockets/sockets.h"
@@ -14,9 +13,6 @@ void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system
14 std::make_shared<BSD>(system, "bsd:u")->InstallAsService(service_manager); 13 std::make_shared<BSD>(system, "bsd:u")->InstallAsService(service_manager);
15 std::make_shared<BSDCFG>(system)->InstallAsService(service_manager); 14 std::make_shared<BSDCFG>(system)->InstallAsService(service_manager);
16 15
17 std::make_shared<ETHC_C>(system)->InstallAsService(service_manager);
18 std::make_shared<ETHC_I>(system)->InstallAsService(service_manager);
19
20 std::make_shared<NSD>(system, "nsd:a")->InstallAsService(service_manager); 16 std::make_shared<NSD>(system, "nsd:a")->InstallAsService(service_manager);
21 std::make_shared<NSD>(system, "nsd:u")->InstallAsService(service_manager); 17 std::make_shared<NSD>(system, "nsd:u")->InstallAsService(service_manager);
22 18
diff --git a/src/core/hle/service/time/time_zone_manager.cpp b/src/core/hle/service/time/time_zone_manager.cpp
index f9ada7c93..973f7837a 100644
--- a/src/core/hle/service/time/time_zone_manager.cpp
+++ b/src/core/hle/service/time/time_zone_manager.cpp
@@ -286,7 +286,7 @@ static constexpr int TransitionTime(int year, Rule rule, int offset) {
286} 286}
287 287
288static bool ParsePosixName(const char* name, TimeZoneRule& rule) { 288static bool ParsePosixName(const char* name, TimeZoneRule& rule) {
289 constexpr char default_rule[]{",M4.1.0,M10.5.0"}; 289 static constexpr char default_rule[]{",M4.1.0,M10.5.0"};
290 const char* std_name{name}; 290 const char* std_name{name};
291 int std_len{}; 291 int std_len{};
292 int offset{}; 292 int offset{};
diff --git a/src/core/hle/service/wlan/wlan.cpp b/src/core/hle/service/wlan/wlan.cpp
deleted file mode 100644
index 226e3034c..000000000
--- a/src/core/hle/service/wlan/wlan.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include <memory>
5
6#include "core/hle/service/service.h"
7#include "core/hle/service/sm/sm.h"
8#include "core/hle/service/wlan/wlan.h"
9
10namespace Service::WLAN {
11
12class WLANInfra final : public ServiceFramework<WLANInfra> {
13public:
14 explicit WLANInfra(Core::System& system_) : ServiceFramework{system_, "wlan:inf"} {
15 // clang-format off
16 static const FunctionInfo functions[] = {
17 {0, nullptr, "OpenMode"},
18 {1, nullptr, "CloseMode"},
19 {2, nullptr, "GetMacAddress"},
20 {3, nullptr, "StartScan"},
21 {4, nullptr, "StopScan"},
22 {5, nullptr, "Connect"},
23 {6, nullptr, "CancelConnect"},
24 {7, nullptr, "Disconnect"},
25 {8, nullptr, "GetConnectionEvent"},
26 {9, nullptr, "GetConnectionStatus"},
27 {10, nullptr, "GetState"},
28 {11, nullptr, "GetScanResult"},
29 {12, nullptr, "GetRssi"},
30 {13, nullptr, "ChangeRxAntenna"},
31 {14, nullptr, "GetFwVersion"},
32 {15, nullptr, "RequestSleep"},
33 {16, nullptr, "RequestWakeUp"},
34 {17, nullptr, "RequestIfUpDown"},
35 {18, nullptr, "Unknown18"},
36 {19, nullptr, "Unknown19"},
37 {20, nullptr, "Unknown20"},
38 {21, nullptr, "Unknown21"},
39 {22, nullptr, "Unknown22"},
40 {23, nullptr, "Unknown23"},
41 {24, nullptr, "Unknown24"},
42 {25, nullptr, "Unknown25"},
43 {26, nullptr, "Unknown26"},
44 {27, nullptr, "Unknown27"},
45 {28, nullptr, "Unknown28"},
46 {29, nullptr, "Unknown29"},
47 {30, nullptr, "Unknown30"},
48 {31, nullptr, "Unknown31"},
49 {32, nullptr, "Unknown32"},
50 {33, nullptr, "Unknown33"},
51 {34, nullptr, "Unknown34"},
52 {35, nullptr, "Unknown35"},
53 {36, nullptr, "Unknown36"},
54 {37, nullptr, "Unknown37"},
55 {38, nullptr, "Unknown38"},
56 };
57 // clang-format on
58
59 RegisterHandlers(functions);
60 }
61};
62
63class WLANLocal final : public ServiceFramework<WLANLocal> {
64public:
65 explicit WLANLocal(Core::System& system_) : ServiceFramework{system_, "wlan:lcl"} {
66 // clang-format off
67 static const FunctionInfo functions[] = {
68 {0, nullptr, "Unknown0"},
69 {1, nullptr, "Unknown1"},
70 {2, nullptr, "Unknown2"},
71 {3, nullptr, "Unknown3"},
72 {4, nullptr, "Unknown4"},
73 {5, nullptr, "Unknown5"},
74 {6, nullptr, "GetMacAddress"},
75 {7, nullptr, "CreateBss"},
76 {8, nullptr, "DestroyBss"},
77 {9, nullptr, "StartScan"},
78 {10, nullptr, "StopScan"},
79 {11, nullptr, "Connect"},
80 {12, nullptr, "CancelConnect"},
81 {13, nullptr, "Join"},
82 {14, nullptr, "CancelJoin"},
83 {15, nullptr, "Disconnect"},
84 {16, nullptr, "SetBeaconLostCount"},
85 {17, nullptr, "Unknown17"},
86 {18, nullptr, "Unknown18"},
87 {19, nullptr, "Unknown19"},
88 {20, nullptr, "GetBssIndicationEvent"},
89 {21, nullptr, "GetBssIndicationInfo"},
90 {22, nullptr, "GetState"},
91 {23, nullptr, "GetAllowedChannels"},
92 {24, nullptr, "AddIe"},
93 {25, nullptr, "DeleteIe"},
94 {26, nullptr, "Unknown26"},
95 {27, nullptr, "Unknown27"},
96 {28, nullptr, "CreateRxEntry"},
97 {29, nullptr, "DeleteRxEntry"},
98 {30, nullptr, "Unknown30"},
99 {31, nullptr, "Unknown31"},
100 {32, nullptr, "AddMatchingDataToRxEntry"},
101 {33, nullptr, "RemoveMatchingDataFromRxEntry"},
102 {34, nullptr, "GetScanResult"},
103 {35, nullptr, "Unknown35"},
104 {36, nullptr, "SetActionFrameWithBeacon"},
105 {37, nullptr, "CancelActionFrameWithBeacon"},
106 {38, nullptr, "CreateRxEntryForActionFrame"},
107 {39, nullptr, "DeleteRxEntryForActionFrame"},
108 {40, nullptr, "Unknown40"},
109 {41, nullptr, "Unknown41"},
110 {42, nullptr, "CancelGetActionFrame"},
111 {43, nullptr, "GetRssi"},
112 {44, nullptr, "Unknown44"},
113 {45, nullptr, "Unknown45"},
114 {46, nullptr, "Unknown46"},
115 {47, nullptr, "Unknown47"},
116 {48, nullptr, "Unknown48"},
117 {49, nullptr, "Unknown49"},
118 {50, nullptr, "Unknown50"},
119 {51, nullptr, "Unknown51"},
120 };
121 // clang-format on
122
123 RegisterHandlers(functions);
124 }
125};
126
127class WLANLocalGetFrame final : public ServiceFramework<WLANLocalGetFrame> {
128public:
129 explicit WLANLocalGetFrame(Core::System& system_) : ServiceFramework{system_, "wlan:lg"} {
130 // clang-format off
131 static const FunctionInfo functions[] = {
132 {0, nullptr, "Unknown"},
133 };
134 // clang-format on
135
136 RegisterHandlers(functions);
137 }
138};
139
140class WLANSocketGetFrame final : public ServiceFramework<WLANSocketGetFrame> {
141public:
142 explicit WLANSocketGetFrame(Core::System& system_) : ServiceFramework{system_, "wlan:sg"} {
143 // clang-format off
144 static const FunctionInfo functions[] = {
145 {0, nullptr, "Unknown"},
146 };
147 // clang-format on
148
149 RegisterHandlers(functions);
150 }
151};
152
153class WLANSocketManager final : public ServiceFramework<WLANSocketManager> {
154public:
155 explicit WLANSocketManager(Core::System& system_) : ServiceFramework{system_, "wlan:soc"} {
156 // clang-format off
157 static const FunctionInfo functions[] = {
158 {0, nullptr, "Unknown0"},
159 {1, nullptr, "Unknown1"},
160 {2, nullptr, "Unknown2"},
161 {3, nullptr, "Unknown3"},
162 {4, nullptr, "Unknown4"},
163 {5, nullptr, "Unknown5"},
164 {6, nullptr, "GetMacAddress"},
165 {7, nullptr, "SwitchTsfTimerFunction"},
166 {8, nullptr, "Unknown8"},
167 {9, nullptr, "Unknown9"},
168 {10, nullptr, "Unknown10"},
169 {11, nullptr, "Unknown11"},
170 {12, nullptr, "Unknown12"},
171 };
172 // clang-format on
173
174 RegisterHandlers(functions);
175 }
176};
177
178void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
179 std::make_shared<WLANInfra>(system)->InstallAsService(sm);
180 std::make_shared<WLANLocal>(system)->InstallAsService(sm);
181 std::make_shared<WLANLocalGetFrame>(system)->InstallAsService(sm);
182 std::make_shared<WLANSocketGetFrame>(system)->InstallAsService(sm);
183 std::make_shared<WLANSocketManager>(system)->InstallAsService(sm);
184}
185
186} // namespace Service::WLAN
diff --git a/src/core/hle/service/wlan/wlan.h b/src/core/hle/service/wlan/wlan.h
deleted file mode 100644
index 535c3bf0d..000000000
--- a/src/core/hle/service/wlan/wlan.h
+++ /dev/null
@@ -1,18 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6namespace Core {
7class System;
8}
9
10namespace Service::SM {
11class ServiceManager;
12}
13
14namespace Service::WLAN {
15
16void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
17
18} // namespace Service::WLAN
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 4c3b3c655..a5c384fb5 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -145,7 +145,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core::
145 145
146 // Apply cheats if they exist and the program has a valid title ID 146 // Apply cheats if they exist and the program has a valid title ID
147 if (pm) { 147 if (pm) {
148 system.SetCurrentProcessBuildID(nso_header.build_id); 148 system.SetApplicationProcessBuildID(nso_header.build_id);
149 const auto cheats = pm->CreateCheatList(nso_header.build_id); 149 const auto cheats = pm->CreateCheatList(nso_header.build_id);
150 if (!cheats.empty()) { 150 if (!cheats.empty()) {
151 system.RegisterCheatList(cheats, nso_header.build_id, load_base, image_size); 151 system.RegisterCheatList(cheats, nso_header.build_id, load_base, image_size);
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index af9660b55..4397fcfb1 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -247,11 +247,11 @@ struct Memory::Impl {
247 } 247 }
248 248
249 void ReadBlock(const VAddr src_addr, void* dest_buffer, const std::size_t size) { 249 void ReadBlock(const VAddr src_addr, void* dest_buffer, const std::size_t size) {
250 ReadBlockImpl<false>(*system.CurrentProcess(), src_addr, dest_buffer, size); 250 ReadBlockImpl<false>(*system.ApplicationProcess(), src_addr, dest_buffer, size);
251 } 251 }
252 252
253 void ReadBlockUnsafe(const VAddr src_addr, void* dest_buffer, const std::size_t size) { 253 void ReadBlockUnsafe(const VAddr src_addr, void* dest_buffer, const std::size_t size) {
254 ReadBlockImpl<true>(*system.CurrentProcess(), src_addr, dest_buffer, size); 254 ReadBlockImpl<true>(*system.ApplicationProcess(), src_addr, dest_buffer, size);
255 } 255 }
256 256
257 template <bool UNSAFE> 257 template <bool UNSAFE>
@@ -279,11 +279,11 @@ struct Memory::Impl {
279 } 279 }
280 280
281 void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t size) { 281 void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t size) {
282 WriteBlockImpl<false>(*system.CurrentProcess(), dest_addr, src_buffer, size); 282 WriteBlockImpl<false>(*system.ApplicationProcess(), dest_addr, src_buffer, size);
283 } 283 }
284 284
285 void WriteBlockUnsafe(const VAddr dest_addr, const void* src_buffer, const std::size_t size) { 285 void WriteBlockUnsafe(const VAddr dest_addr, const void* src_buffer, const std::size_t size) {
286 WriteBlockImpl<true>(*system.CurrentProcess(), dest_addr, src_buffer, size); 286 WriteBlockImpl<true>(*system.ApplicationProcess(), dest_addr, src_buffer, size);
287 } 287 }
288 288
289 void ZeroBlock(const Kernel::KProcess& process, const VAddr dest_addr, const std::size_t size) { 289 void ZeroBlock(const Kernel::KProcess& process, const VAddr dest_addr, const std::size_t size) {
@@ -711,7 +711,7 @@ void Memory::UnmapRegion(Common::PageTable& page_table, VAddr base, u64 size) {
711} 711}
712 712
713bool Memory::IsValidVirtualAddress(const VAddr vaddr) const { 713bool Memory::IsValidVirtualAddress(const VAddr vaddr) const {
714 const Kernel::KProcess& process = *system.CurrentProcess(); 714 const Kernel::KProcess& process = *system.ApplicationProcess();
715 const auto& page_table = process.PageTable().PageTableImpl(); 715 const auto& page_table = process.PageTable().PageTableImpl();
716 const size_t page = vaddr >> YUZU_PAGEBITS; 716 const size_t page = vaddr >> YUZU_PAGEBITS;
717 if (page >= page_table.pointers.size()) { 717 if (page >= page_table.pointers.size()) {
diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp
index ffdbacc18..44ee39648 100644
--- a/src/core/memory/cheat_engine.cpp
+++ b/src/core/memory/cheat_engine.cpp
@@ -191,10 +191,10 @@ void CheatEngine::Initialize() {
191 }); 191 });
192 core_timing.ScheduleLoopingEvent(CHEAT_ENGINE_NS, CHEAT_ENGINE_NS, event); 192 core_timing.ScheduleLoopingEvent(CHEAT_ENGINE_NS, CHEAT_ENGINE_NS, event);
193 193
194 metadata.process_id = system.CurrentProcess()->GetProcessID(); 194 metadata.process_id = system.ApplicationProcess()->GetProcessID();
195 metadata.title_id = system.GetCurrentProcessProgramID(); 195 metadata.title_id = system.GetApplicationProcessProgramID();
196 196
197 const auto& page_table = system.CurrentProcess()->PageTable(); 197 const auto& page_table = system.ApplicationProcess()->PageTable();
198 metadata.heap_extents = { 198 metadata.heap_extents = {
199 .base = page_table.GetHeapRegionStart(), 199 .base = page_table.GetHeapRegionStart(),
200 .size = page_table.GetHeapRegionSize(), 200 .size = page_table.GetHeapRegionSize(),
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp
index 59dfb8767..708ae17aa 100644
--- a/src/core/reporter.cpp
+++ b/src/core/reporter.cpp
@@ -110,7 +110,7 @@ json GetProcessorStateData(const std::string& architecture, u64 entry_point, u64
110} 110}
111 111
112json GetProcessorStateDataAuto(Core::System& system) { 112json GetProcessorStateDataAuto(Core::System& system) {
113 const auto* process{system.CurrentProcess()}; 113 const auto* process{system.ApplicationProcess()};
114 auto& arm{system.CurrentArmInterface()}; 114 auto& arm{system.CurrentArmInterface()};
115 115
116 Core::ARM_Interface::ThreadContext64 context{}; 116 Core::ARM_Interface::ThreadContext64 context{};
@@ -234,7 +234,7 @@ void Reporter::SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64
234 } 234 }
235 235
236 const auto timestamp = GetTimestamp(); 236 const auto timestamp = GetTimestamp();
237 const auto title_id = system.GetCurrentProcessProgramID(); 237 const auto title_id = system.GetApplicationProcessProgramID();
238 auto out = GetFullDataAuto(timestamp, title_id, system); 238 auto out = GetFullDataAuto(timestamp, title_id, system);
239 239
240 auto break_out = json{ 240 auto break_out = json{
@@ -261,7 +261,7 @@ void Reporter::SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u
261 } 261 }
262 262
263 const auto timestamp = GetTimestamp(); 263 const auto timestamp = GetTimestamp();
264 const auto title_id = system.GetCurrentProcessProgramID(); 264 const auto title_id = system.GetApplicationProcessProgramID();
265 auto out = GetFullDataAuto(timestamp, title_id, system); 265 auto out = GetFullDataAuto(timestamp, title_id, system);
266 266
267 auto function_out = GetHLERequestContextData(ctx, system.Memory()); 267 auto function_out = GetHLERequestContextData(ctx, system.Memory());
@@ -283,7 +283,7 @@ void Reporter::SaveUnimplementedAppletReport(
283 } 283 }
284 284
285 const auto timestamp = GetTimestamp(); 285 const auto timestamp = GetTimestamp();
286 const auto title_id = system.GetCurrentProcessProgramID(); 286 const auto title_id = system.GetApplicationProcessProgramID();
287 auto out = GetFullDataAuto(timestamp, title_id, system); 287 auto out = GetFullDataAuto(timestamp, title_id, system);
288 288
289 out["applet_common_args"] = { 289 out["applet_common_args"] = {
@@ -376,7 +376,7 @@ void Reporter::SaveUserReport() const {
376 } 376 }
377 377
378 const auto timestamp = GetTimestamp(); 378 const auto timestamp = GetTimestamp();
379 const auto title_id = system.GetCurrentProcessProgramID(); 379 const auto title_id = system.GetApplicationProcessProgramID();
380 380
381 SaveToFile(GetFullDataAuto(timestamp, title_id, system), 381 SaveToFile(GetFullDataAuto(timestamp, title_id, system),
382 GetPath("user_report", title_id, timestamp)); 382 GetPath("user_report", title_id, timestamp));
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp
index 8d5f2be2f..9178b00ca 100644
--- a/src/core/telemetry_session.cpp
+++ b/src/core/telemetry_session.cpp
@@ -34,7 +34,7 @@ static u64 GenerateTelemetryId() {
34 mbedtls_entropy_context entropy; 34 mbedtls_entropy_context entropy;
35 mbedtls_entropy_init(&entropy); 35 mbedtls_entropy_init(&entropy);
36 mbedtls_ctr_drbg_context ctr_drbg; 36 mbedtls_ctr_drbg_context ctr_drbg;
37 constexpr std::array<char, 18> personalization{{"yuzu Telemetry ID"}}; 37 static constexpr std::array<char, 18> personalization{{"yuzu Telemetry ID"}};
38 38
39 mbedtls_ctr_drbg_init(&ctr_drbg); 39 mbedtls_ctr_drbg_init(&ctr_drbg);
40 ASSERT(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, 40 ASSERT(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp
index afc33db57..b4cd39a20 100644
--- a/src/input_common/drivers/joycon.cpp
+++ b/src/input_common/drivers/joycon.cpp
@@ -390,7 +390,7 @@ void Joycons::OnMotionUpdate(std::size_t port, Joycon::ControllerType type, int
390void Joycons::OnRingConUpdate(f32 ring_data) { 390void Joycons::OnRingConUpdate(f32 ring_data) {
391 // To simplify ring detection it will always be mapped to an empty identifier for all 391 // To simplify ring detection it will always be mapped to an empty identifier for all
392 // controllers 392 // controllers
393 constexpr PadIdentifier identifier = { 393 static constexpr PadIdentifier identifier = {
394 .guid = Common::UUID{}, 394 .guid = Common::UUID{},
395 .port = 0, 395 .port = 0,
396 .pad = 0, 396 .pad = 0,
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 88cacd615..5c20b3426 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -616,7 +616,7 @@ bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) {
616 const auto joystick = 616 const auto joystick =
617 GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port)); 617 GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port));
618 618
619 constexpr Common::Input::VibrationStatus test_vibration{ 619 static constexpr Common::Input::VibrationStatus test_vibration{
620 .low_amplitude = 1, 620 .low_amplitude = 1,
621 .low_frequency = 160.0f, 621 .low_frequency = 160.0f,
622 .high_amplitude = 1, 622 .high_amplitude = 1,
@@ -624,7 +624,7 @@ bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) {
624 .type = Common::Input::VibrationAmplificationType::Exponential, 624 .type = Common::Input::VibrationAmplificationType::Exponential,
625 }; 625 };
626 626
627 constexpr Common::Input::VibrationStatus zero_vibration{ 627 static constexpr Common::Input::VibrationStatus zero_vibration{
628 .low_amplitude = 0, 628 .low_amplitude = 0,
629 .low_frequency = 160.0f, 629 .low_frequency = 160.0f,
630 .high_amplitude = 0, 630 .high_amplitude = 0,
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index c501513e4..614d61db4 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -259,7 +259,7 @@ u32 Maxwell3D::GetMaxCurrentVertices() {
259size_t Maxwell3D::EstimateIndexBufferSize() { 259size_t Maxwell3D::EstimateIndexBufferSize() {
260 GPUVAddr start_address = regs.index_buffer.StartAddress(); 260 GPUVAddr start_address = regs.index_buffer.StartAddress();
261 GPUVAddr end_address = regs.index_buffer.EndAddress(); 261 GPUVAddr end_address = regs.index_buffer.EndAddress();
262 constexpr std::array<size_t, 4> max_sizes = { 262 static constexpr std::array<size_t, 4> max_sizes = {
263 std::numeric_limits<u8>::max(), std::numeric_limits<u16>::max(), 263 std::numeric_limits<u8>::max(), std::numeric_limits<u16>::max(),
264 std::numeric_limits<u32>::max(), std::numeric_limits<u32>::max()}; 264 std::numeric_limits<u32>::max(), std::numeric_limits<u32>::max()};
265 const size_t byte_size = regs.index_buffer.FormatSizeInBytes(); 265 const size_t byte_size = regs.index_buffer.FormatSizeInBytes();
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h
index 9ebfb6179..cf56392ef 100644
--- a/src/video_core/memory_manager.h
+++ b/src/video_core/memory_manager.h
@@ -216,7 +216,7 @@ private:
216 std::vector<u64> big_page_continous; 216 std::vector<u64> big_page_continous;
217 std::vector<std::pair<VAddr, std::size_t>> page_stash{}; 217 std::vector<std::pair<VAddr, std::size_t>> page_stash{};
218 218
219 constexpr static size_t continous_bits = 64; 219 static constexpr size_t continous_bits = 64;
220 220
221 const size_t unique_identifier; 221 const size_t unique_identifier;
222 std::unique_ptr<VideoCommon::InvalidationAccumulator> accumulator; 222 std::unique_ptr<VideoCommon::InvalidationAccumulator> accumulator;
diff --git a/src/video_core/renderer_vulkan/vk_smaa.cpp b/src/video_core/renderer_vulkan/vk_smaa.cpp
index 8eb735489..f8735189d 100644
--- a/src/video_core/renderer_vulkan/vk_smaa.cpp
+++ b/src/video_core/renderer_vulkan/vk_smaa.cpp
@@ -468,7 +468,7 @@ VkWriteDescriptorSet CreateWriteDescriptorSet(std::vector<VkDescriptorImageInfo>
468} 468}
469 469
470void ClearColorImage(vk::CommandBuffer& cmdbuf, VkImage image) { 470void ClearColorImage(vk::CommandBuffer& cmdbuf, VkImage image) {
471 constexpr std::array<VkImageSubresourceRange, 1> subresources{{{ 471 static constexpr std::array<VkImageSubresourceRange, 1> subresources{{{
472 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, 472 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
473 .baseMipLevel = 0, 473 .baseMipLevel = 0,
474 .levelCount = 1, 474 .levelCount = 1,
@@ -528,8 +528,8 @@ SMAA::SMAA(const Device& device, MemoryAllocator& allocator, size_t image_count,
528} 528}
529 529
530void SMAA::CreateImages() { 530void SMAA::CreateImages() {
531 constexpr VkExtent2D area_extent{AREATEX_WIDTH, AREATEX_HEIGHT}; 531 static constexpr VkExtent2D area_extent{AREATEX_WIDTH, AREATEX_HEIGHT};
532 constexpr VkExtent2D search_extent{SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT}; 532 static constexpr VkExtent2D search_extent{SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT};
533 533
534 std::tie(m_static_images[Area], m_static_buffer_commits[Area]) = 534 std::tie(m_static_images[Area], m_static_buffer_commits[Area]) =
535 CreateWrappedImage(m_device, m_allocator, area_extent, VK_FORMAT_R8G8_UNORM); 535 CreateWrappedImage(m_device, m_allocator, area_extent, VK_FORMAT_R8G8_UNORM);
@@ -586,12 +586,12 @@ void SMAA::CreateSampler() {
586 586
587void SMAA::CreateShaders() { 587void SMAA::CreateShaders() {
588 // These match the order of the SMAAStage enum 588 // These match the order of the SMAAStage enum
589 constexpr std::array vert_shader_sources{ 589 static constexpr std::array vert_shader_sources{
590 ARRAY_TO_SPAN(SMAA_EDGE_DETECTION_VERT_SPV), 590 ARRAY_TO_SPAN(SMAA_EDGE_DETECTION_VERT_SPV),
591 ARRAY_TO_SPAN(SMAA_BLENDING_WEIGHT_CALCULATION_VERT_SPV), 591 ARRAY_TO_SPAN(SMAA_BLENDING_WEIGHT_CALCULATION_VERT_SPV),
592 ARRAY_TO_SPAN(SMAA_NEIGHBORHOOD_BLENDING_VERT_SPV), 592 ARRAY_TO_SPAN(SMAA_NEIGHBORHOOD_BLENDING_VERT_SPV),
593 }; 593 };
594 constexpr std::array frag_shader_sources{ 594 static constexpr std::array frag_shader_sources{
595 ARRAY_TO_SPAN(SMAA_EDGE_DETECTION_FRAG_SPV), 595 ARRAY_TO_SPAN(SMAA_EDGE_DETECTION_FRAG_SPV),
596 ARRAY_TO_SPAN(SMAA_BLENDING_WEIGHT_CALCULATION_FRAG_SPV), 596 ARRAY_TO_SPAN(SMAA_BLENDING_WEIGHT_CALCULATION_FRAG_SPV),
597 ARRAY_TO_SPAN(SMAA_NEIGHBORHOOD_BLENDING_FRAG_SPV), 597 ARRAY_TO_SPAN(SMAA_NEIGHBORHOOD_BLENDING_FRAG_SPV),
@@ -675,8 +675,8 @@ void SMAA::UploadImages(Scheduler& scheduler) {
675 return; 675 return;
676 } 676 }
677 677
678 constexpr VkExtent2D area_extent{AREATEX_WIDTH, AREATEX_HEIGHT}; 678 static constexpr VkExtent2D area_extent{AREATEX_WIDTH, AREATEX_HEIGHT};
679 constexpr VkExtent2D search_extent{SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT}; 679 static constexpr VkExtent2D search_extent{SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT};
680 680
681 UploadImage(m_device, m_allocator, scheduler, m_static_images[Area], area_extent, 681 UploadImage(m_device, m_allocator, scheduler, m_static_images[Area], area_extent,
682 VK_FORMAT_R8G8_UNORM, ARRAY_TO_SPAN(areaTexBytes)); 682 VK_FORMAT_R8G8_UNORM, ARRAY_TO_SPAN(areaTexBytes));
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h
index b9ee83de7..0ce39616f 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.h
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.h
@@ -113,7 +113,7 @@ public:
113 std::optional<ASTCDecoderPass> astc_decoder_pass; 113 std::optional<ASTCDecoderPass> astc_decoder_pass;
114 const Settings::ResolutionScalingInfo& resolution; 114 const Settings::ResolutionScalingInfo& resolution;
115 115
116 constexpr static size_t indexing_slots = 8 * sizeof(size_t); 116 static constexpr size_t indexing_slots = 8 * sizeof(size_t);
117 std::array<vk::Buffer, indexing_slots> buffers{}; 117 std::array<vk::Buffer, indexing_slots> buffers{};
118 std::array<std::unique_ptr<MemoryCommit>, indexing_slots> buffer_commits{}; 118 std::array<std::unique_ptr<MemoryCommit>, indexing_slots> buffer_commits{};
119}; 119};
diff --git a/src/video_core/renderer_vulkan/vk_turbo_mode.cpp b/src/video_core/renderer_vulkan/vk_turbo_mode.cpp
index c42594149..db04943eb 100644
--- a/src/video_core/renderer_vulkan/vk_turbo_mode.cpp
+++ b/src/video_core/renderer_vulkan/vk_turbo_mode.cpp
@@ -48,7 +48,7 @@ void TurboMode::Run(std::stop_token stop_token) {
48 auto commit = m_allocator.Commit(buffer, MemoryUsage::DeviceLocal); 48 auto commit = m_allocator.Commit(buffer, MemoryUsage::DeviceLocal);
49 49
50 // Create the descriptor pool to contain our descriptor. 50 // Create the descriptor pool to contain our descriptor.
51 constexpr VkDescriptorPoolSize pool_size{ 51 static constexpr VkDescriptorPoolSize pool_size{
52 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 52 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
53 .descriptorCount = 1, 53 .descriptorCount = 1,
54 }; 54 };
@@ -63,7 +63,7 @@ void TurboMode::Run(std::stop_token stop_token) {
63 }); 63 });
64 64
65 // Create the descriptor set layout from the pool. 65 // Create the descriptor set layout from the pool.
66 constexpr VkDescriptorSetLayoutBinding layout_binding{ 66 static constexpr VkDescriptorSetLayoutBinding layout_binding{
67 .binding = 0, 67 .binding = 0,
68 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 68 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
69 .descriptorCount = 1, 69 .descriptorCount = 1,
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 59120cd09..95bcdd37b 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -29,7 +29,7 @@ constexpr u32 pdep(u32 value) {
29 29
30template <u32 mask, u32 incr_amount> 30template <u32 mask, u32 incr_amount>
31void incrpdep(u32& value) { 31void incrpdep(u32& value) {
32 constexpr u32 swizzled_incr = pdep<mask>(incr_amount); 32 static constexpr u32 swizzled_incr = pdep<mask>(incr_amount);
33 value = ((value | ~mask) + swizzled_incr) & mask; 33 value = ((value | ~mask) + swizzled_incr) & mask;
34} 34}
35 35
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index d65991734..352300e88 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -67,7 +67,7 @@ void EmuThread::run() {
67 emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); 67 emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0);
68 if (Settings::values.use_disk_shader_cache.GetValue()) { 68 if (Settings::values.use_disk_shader_cache.GetValue()) {
69 m_system.Renderer().ReadRasterizer()->LoadDiskResources( 69 m_system.Renderer().ReadRasterizer()->LoadDiskResources(
70 m_system.GetCurrentProcessProgramID(), stop_token, 70 m_system.GetApplicationProcessProgramID(), stop_token,
71 [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) { 71 [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) {
72 emit LoadProgress(stage, value, total); 72 emit LoadProgress(stage, value, total);
73 }); 73 });
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index c278d8dab..a1c18ff90 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -219,7 +219,7 @@ static void LogRuntimes() {
219#ifdef _MSC_VER 219#ifdef _MSC_VER
220 // It is possible that the name of the dll will change. 220 // It is possible that the name of the dll will change.
221 // vcruntime140.dll is for 2015 and onwards 221 // vcruntime140.dll is for 2015 and onwards
222 constexpr char runtime_dll_name[] = "vcruntime140.dll"; 222 static constexpr char runtime_dll_name[] = "vcruntime140.dll";
223 UINT sz = GetFileVersionInfoSizeA(runtime_dll_name, nullptr); 223 UINT sz = GetFileVersionInfoSizeA(runtime_dll_name, nullptr);
224 bool runtime_version_inspection_worked = false; 224 bool runtime_version_inspection_worked = false;
225 if (sz > 0) { 225 if (sz > 0) {
@@ -1779,7 +1779,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
1779 std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())} 1779 std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())}
1780 .filename()); 1780 .filename());
1781 } 1781 }
1782 const bool is_64bit = system->Kernel().CurrentProcess()->Is64BitProcess(); 1782 const bool is_64bit = system->Kernel().ApplicationProcess()->Is64BitProcess();
1783 const auto instruction_set_suffix = is_64bit ? tr("(64-bit)") : tr("(32-bit)"); 1783 const auto instruction_set_suffix = is_64bit ? tr("(64-bit)") : tr("(32-bit)");
1784 title_name = tr("%1 %2", "%1 is the title name. %2 indicates if the title is 64-bit or 32-bit") 1784 title_name = tr("%1 %2", "%1 is the title name. %2 indicates if the title is 64-bit or 32-bit")
1785 .arg(QString::fromStdString(title_name), instruction_set_suffix) 1785 .arg(QString::fromStdString(title_name), instruction_set_suffix)
@@ -3532,7 +3532,7 @@ void GMainWindow::OnToggleGraphicsAPI() {
3532} 3532}
3533 3533
3534void GMainWindow::OnConfigurePerGame() { 3534void GMainWindow::OnConfigurePerGame() {
3535 const u64 title_id = system->GetCurrentProcessProgramID(); 3535 const u64 title_id = system->GetApplicationProcessProgramID();
3536 OpenPerGameConfiguration(title_id, current_game_path.toStdString()); 3536 OpenPerGameConfiguration(title_id, current_game_path.toStdString());
3537} 3537}
3538 3538
@@ -3691,7 +3691,7 @@ void GMainWindow::OnCaptureScreenshot() {
3691 return; 3691 return;
3692 } 3692 }
3693 3693
3694 const u64 title_id = system->GetCurrentProcessProgramID(); 3694 const u64 title_id = system->GetApplicationProcessProgramID();
3695 const auto screenshot_path = 3695 const auto screenshot_path =
3696 QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir)); 3696 QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir));
3697 const auto date = 3697 const auto date =
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index d1f7b1d49..77edd58ca 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -405,7 +405,7 @@ int main(int argc, char** argv) {
405 405
406 if (Settings::values.use_disk_shader_cache.GetValue()) { 406 if (Settings::values.use_disk_shader_cache.GetValue()) {
407 system.Renderer().ReadRasterizer()->LoadDiskResources( 407 system.Renderer().ReadRasterizer()->LoadDiskResources(
408 system.GetCurrentProcessProgramID(), std::stop_token{}, 408 system.GetApplicationProcessProgramID(), std::stop_token{},
409 [](VideoCore::LoadCallbackStage, size_t value, size_t total) {}); 409 [](VideoCore::LoadCallbackStage, size_t value, size_t total) {});
410 } 410 }
411 411