summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/expected.h987
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_32.h1
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_64.cpp1
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_cp15.cpp1
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_cp15.h1
-rw-r--r--src/core/arm/dynarmic/arm_exclusive_monitor.cpp2
-rw-r--r--src/core/arm/dynarmic/arm_exclusive_monitor.h1
-rw-r--r--src/core/core.cpp28
-rw-r--r--src/core/core.h2
-rw-r--r--src/core/core_timing.h1
-rw-r--r--src/core/cpu_manager.cpp1
-rw-r--r--src/core/crypto/ctr_encryption_layer.cpp1
-rw-r--r--src/core/crypto/key_manager.cpp3
-rw-r--r--src/core/crypto/key_manager.h1
-rw-r--r--src/core/crypto/partition_data_manager.cpp1
-rw-r--r--src/core/crypto/xts_encryption_layer.cpp1
-rw-r--r--src/core/file_sys/card_image.cpp1
-rw-r--r--src/core/file_sys/control_metadata.h1
-rw-r--r--src/core/file_sys/directory.h1
-rw-r--r--src/core/file_sys/nca_metadata.h1
-rw-r--r--src/core/file_sys/program_metadata.cpp5
-rw-r--r--src/core/file_sys/romfs_factory.cpp11
-rw-r--r--src/core/file_sys/romfs_factory.h3
-rw-r--r--src/core/file_sys/savedata_factory.cpp7
-rw-r--r--src/core/file_sys/savedata_factory.h1
-rw-r--r--src/core/file_sys/sdmc_factory.cpp2
-rw-r--r--src/core/file_sys/submission_package.cpp1
-rw-r--r--src/core/file_sys/system_archive/time_zone_binary.h1
-rw-r--r--src/core/file_sys/vfs.h1
-rw-r--r--src/core/file_sys/vfs_concat.h1
-rw-r--r--src/core/file_sys/vfs_offset.h1
-rw-r--r--src/core/frontend/applets/general_frontend.h1
-rw-r--r--src/core/frontend/applets/software_keyboard.cpp5
-rw-r--r--src/core/frontend/applets/software_keyboard.h7
-rw-r--r--src/core/frontend/applets/web_browser.h1
-rw-r--r--src/core/frontend/emu_window.cpp1
-rw-r--r--src/core/frontend/emu_window.h1
-rw-r--r--src/core/hle/kernel/board/nintendo/nx/secure_monitor.h2
-rw-r--r--src/core/hle/kernel/code_set.h1
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp6
-rw-r--r--src/core/hle/kernel/init/init_slab_setup.cpp2
-rw-r--r--src/core/hle/kernel/k_auto_object_container.h5
-rw-r--r--src/core/hle/kernel/k_class_token.h1
-rw-r--r--src/core/hle/kernel/k_client_session.cpp1
-rw-r--r--src/core/hle/kernel/k_client_session.h2
-rw-r--r--src/core/hle/kernel/k_condition_variable.cpp2
-rw-r--r--src/core/hle/kernel/k_handle_table.cpp1
-rw-r--r--src/core/hle/kernel/k_handle_table.h1
-rw-r--r--src/core/hle/kernel/k_light_condition_variable.h1
-rw-r--r--src/core/hle/kernel/k_light_lock.h1
-rw-r--r--src/core/hle/kernel/k_memory_manager.h1
-rw-r--r--src/core/hle/kernel/k_page_heap.cpp1
-rw-r--r--src/core/hle/kernel/k_page_heap.h3
-rw-r--r--src/core/hle/kernel/k_page_table.cpp4
-rw-r--r--src/core/hle/kernel/k_port.h1
-rw-r--r--src/core/hle/kernel/k_process.cpp11
-rw-r--r--src/core/hle/kernel/k_process.h5
-rw-r--r--src/core/hle/kernel/k_scheduler_lock.h1
-rw-r--r--src/core/hle/kernel/k_scoped_lock.h3
-rw-r--r--src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h1
-rw-r--r--src/core/hle/kernel/k_server_port.cpp1
-rw-r--r--src/core/hle/kernel/k_server_port.h3
-rw-r--r--src/core/hle/kernel/k_server_session.cpp2
-rw-r--r--src/core/hle/kernel/k_server_session.h3
-rw-r--r--src/core/hle/kernel/k_session.cpp1
-rw-r--r--src/core/hle/kernel/k_shared_memory.h1
-rw-r--r--src/core/hle/kernel/k_shared_memory_info.h4
-rw-r--r--src/core/hle/kernel/k_thread.cpp4
-rw-r--r--src/core/hle/kernel/k_trace.h2
-rw-r--r--src/core/hle/kernel/k_transfer_memory.h2
-rw-r--r--src/core/hle/kernel/kernel.cpp38
-rw-r--r--src/core/hle/kernel/kernel.h8
-rw-r--r--src/core/hle/kernel/physical_core.h1
-rw-r--r--src/core/hle/kernel/service_thread.cpp4
-rw-r--r--src/core/hle/kernel/slab_helpers.h8
-rw-r--r--src/core/hle/kernel/svc.cpp22
-rw-r--r--src/core/hle/kernel/svc_wrap.h4
-rw-r--r--src/core/hle/kernel/time_manager.cpp3
-rw-r--r--src/core/hle/kernel/time_manager.h1
-rw-r--r--src/core/hle/result.h210
-rw-r--r--src/core/hle/service/acc/acc.cpp15
-rw-r--r--src/core/hle/service/acc/acc.h1
-rw-r--r--src/core/hle/service/acc/acc_u0.cpp1
-rw-r--r--src/core/hle/service/am/am.cpp16
-rw-r--r--src/core/hle/service/am/applets/applet_error.cpp3
-rw-r--r--src/core/hle/service/am/applets/applet_general_backend.cpp5
-rw-r--r--src/core/hle/service/am/applets/applet_software_keyboard.cpp42
-rw-r--r--src/core/hle/service/am/applets/applet_software_keyboard.h4
-rw-r--r--src/core/hle/service/am/applets/applet_web_browser.cpp3
-rw-r--r--src/core/hle/service/am/applets/applet_web_browser.h1
-rw-r--r--src/core/hle/service/aoc/aoc_u.cpp34
-rw-r--r--src/core/hle/service/aoc/aoc_u.h3
-rw-r--r--src/core/hle/service/apm/apm.cpp1
-rw-r--r--src/core/hle/service/audio/audout_u.cpp1
-rw-r--r--src/core/hle/service/audio/audren_u.cpp3
-rw-r--r--src/core/hle/service/bcat/backend/backend.h1
-rw-r--r--src/core/hle/service/bcat/bcat_module.cpp8
-rw-r--r--src/core/hle/service/btdrv/btdrv.cpp1
-rw-r--r--src/core/hle/service/btm/btm.cpp1
-rw-r--r--src/core/hle/service/fatal/fatal.cpp3
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp27
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp3
-rw-r--r--src/core/hle/service/glue/arp.cpp3
-rw-r--r--src/core/hle/service/glue/glue_manager.cpp4
-rw-r--r--src/core/hle/service/glue/glue_manager.h1
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp1
-rw-r--r--src/core/hle/service/hid/hid.cpp2
-rw-r--r--src/core/hle/service/hid/irs.cpp1
-rw-r--r--src/core/hle/service/ldr/ldr.cpp7
-rw-r--r--src/core/hle/service/lm/lm.cpp3
-rw-r--r--src/core/hle/service/mii/mii_manager.cpp4
-rw-r--r--src/core/hle/service/mii/raw_data.h1
-rw-r--r--src/core/hle/service/nfp/nfp.cpp2
-rw-r--r--src/core/hle/service/nifm/nifm.cpp1
-rw-r--r--src/core/hle/service/nim/nim.cpp1
-rw-r--r--src/core/hle/service/ns/language.h3
-rw-r--r--src/core/hle/service/ns/ns.cpp4
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdevice.h3
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp1
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp1
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp1
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp1
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h1
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_vic.cpp1
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.cpp1
-rw-r--r--src/core/hle/service/nvdrv/nvdrv_interface.cpp3
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.h1
-rw-r--r--src/core/hle/service/pctl/pctl_module.cpp12
-rw-r--r--src/core/hle/service/pm/pm.cpp4
-rw-r--r--src/core/hle/service/prepo/prepo.cpp5
-rw-r--r--src/core/hle/service/ptm/psm.cpp1
-rw-r--r--src/core/hle/service/service.cpp4
-rw-r--r--src/core/hle/service/sm/sm.cpp6
-rw-r--r--src/core/hle/service/sm/sm.h1
-rw-r--r--src/core/hle/service/sm/sm_controller.cpp2
-rw-r--r--src/core/hle/service/sockets/bsd.cpp1
-rw-r--r--src/core/hle/service/spl/spl_module.cpp26
-rw-r--r--src/core/hle/service/time/local_system_clock_context_writer.h1
-rw-r--r--src/core/hle/service/time/standard_steady_clock_core.cpp1
-rw-r--r--src/core/hle/service/time/tick_based_steady_clock_core.cpp1
-rw-r--r--src/core/hle/service/time/time.cpp2
-rw-r--r--src/core/hle/service/time/time_manager.cpp2
-rw-r--r--src/core/hle/service/time/time_manager.h3
-rw-r--r--src/core/hle/service/time/time_sharedmemory.cpp1
-rw-r--r--src/core/hle/service/time/time_sharedmemory.h1
-rw-r--r--src/core/hle/service/time/time_zone_manager.cpp2
-rw-r--r--src/core/hle/service/vi/vi.cpp12
-rw-r--r--src/core/loader/deconstructed_rom_directory.cpp3
-rw-r--r--src/core/loader/elf.cpp1
-rw-r--r--src/core/loader/elf.h2
-rw-r--r--src/core/loader/nax.cpp1
-rw-r--r--src/core/loader/nca.cpp1
-rw-r--r--src/core/loader/nca.h1
-rw-r--r--src/core/loader/nsp.cpp1
-rw-r--r--src/core/loader/nsp.h1
-rw-r--r--src/core/loader/xci.cpp1
-rw-r--r--src/core/loader/xci.h1
-rw-r--r--src/core/memory/cheat_engine.cpp4
-rw-r--r--src/core/network/network.h1
-rw-r--r--src/core/perf_stats.cpp1
-rw-r--r--src/core/reporter.cpp8
-rw-r--r--src/core/tools/freezer.cpp2
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp2
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_special.cpp4
-rw-r--r--src/shader_recompiler/frontend/ir/basic_block.h14
-rw-r--r--src/shader_recompiler/frontend/ir/microinstruction.cpp15
-rw-r--r--src/shader_recompiler/frontend/ir/value.h3
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate_program.cpp2
-rw-r--r--src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp31
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp6
-rw-r--r--src/video_core/vulkan_common/vulkan_device.cpp1
-rw-r--r--src/yuzu/applets/qt_software_keyboard.cpp9
-rw-r--r--src/yuzu/applets/qt_software_keyboard.h12
-rw-r--r--src/yuzu/bootmanager.cpp3
-rw-r--r--src/yuzu/main.cpp9
-rw-r--r--src/yuzu/main.h2
-rw-r--r--src/yuzu_cmd/yuzu.cpp3
179 files changed, 1390 insertions, 541 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index cb5c0f326..23d43a394 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -55,6 +55,7 @@ add_library(common STATIC
55 dynamic_library.h 55 dynamic_library.h
56 error.cpp 56 error.cpp
57 error.h 57 error.h
58 expected.h
58 fiber.cpp 59 fiber.cpp
59 fiber.h 60 fiber.h
60 fs/file.cpp 61 fs/file.cpp
diff --git a/src/common/expected.h b/src/common/expected.h
new file mode 100644
index 000000000..c8d8579c1
--- /dev/null
+++ b/src/common/expected.h
@@ -0,0 +1,987 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5// This is based on the proposed implementation of std::expected (P0323)
6// https://github.com/TartanLlama/expected/blob/master/include/tl/expected.hpp
7
8#pragma once
9
10#include <type_traits>
11#include <utility>
12
13namespace Common {
14
15template <typename T, typename E>
16class Expected;
17
18template <typename E>
19class Unexpected {
20public:
21 Unexpected() = delete;
22
23 constexpr explicit Unexpected(const E& e) : m_val{e} {}
24
25 constexpr explicit Unexpected(E&& e) : m_val{std::move(e)} {}
26
27 constexpr E& value() & {
28 return m_val;
29 }
30
31 constexpr const E& value() const& {
32 return m_val;
33 }
34
35 constexpr E&& value() && {
36 return std::move(m_val);
37 }
38
39 constexpr const E&& value() const&& {
40 return std::move(m_val);
41 }
42
43private:
44 E m_val;
45};
46
47template <typename E>
48constexpr auto operator<=>(const Unexpected<E>& lhs, const Unexpected<E>& rhs) {
49 return lhs.value() <=> rhs.value();
50}
51
52struct unexpect_t {
53 constexpr explicit unexpect_t() = default;
54};
55
56namespace detail {
57
58struct no_init_t {
59 constexpr explicit no_init_t() = default;
60};
61
62/**
63 * This specialization is for when T is not trivially destructible,
64 * so the destructor must be called on destruction of `expected'
65 * Additionally, this requires E to be trivially destructible
66 */
67template <typename T, typename E, bool = std::is_trivially_destructible_v<T>>
68requires std::is_trivially_destructible_v<E>
69struct expected_storage_base {
70 constexpr expected_storage_base() : m_val{T{}}, m_has_val{true} {}
71
72 constexpr expected_storage_base(no_init_t) : m_has_val{false} {}
73
74 template <typename... Args, std::enable_if_t<std::is_constructible_v<T, Args&&...>>* = nullptr>
75 constexpr expected_storage_base(std::in_place_t, Args&&... args)
76 : m_val{std::forward<Args>(args)...}, m_has_val{true} {}
77
78 template <typename U, typename... Args,
79 std::enable_if_t<std::is_constructible_v<T, std::initializer_list<U>&, Args&&...>>* =
80 nullptr>
81 constexpr expected_storage_base(std::in_place_t, std::initializer_list<U> il, Args&&... args)
82 : m_val{il, std::forward<Args>(args)...}, m_has_val{true} {}
83
84 template <typename... Args, std::enable_if_t<std::is_constructible_v<E, Args&&...>>* = nullptr>
85 constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
86 : m_unexpect{std::forward<Args>(args)...}, m_has_val{false} {}
87
88 template <typename U, typename... Args,
89 std::enable_if_t<std::is_constructible_v<E, std::initializer_list<U>&, Args&&...>>* =
90 nullptr>
91 constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il,
92 Args&&... args)
93 : m_unexpect{il, std::forward<Args>(args)...}, m_has_val{false} {}
94
95 ~expected_storage_base() {
96 if (m_has_val) {
97 m_val.~T();
98 }
99 }
100
101 union {
102 T m_val;
103 Unexpected<E> m_unexpect;
104 };
105
106 bool m_has_val;
107};
108
109/**
110 * This specialization is for when T is trivially destructible,
111 * so the destructor of `expected` can be trivial
112 * Additionally, this requires E to be trivially destructible
113 */
114template <typename T, typename E>
115requires std::is_trivially_destructible_v<E>
116struct expected_storage_base<T, E, true> {
117 constexpr expected_storage_base() : m_val{T{}}, m_has_val{true} {}
118
119 constexpr expected_storage_base(no_init_t) : m_has_val{false} {}
120
121 template <typename... Args, std::enable_if_t<std::is_constructible_v<T, Args&&...>>* = nullptr>
122 constexpr expected_storage_base(std::in_place_t, Args&&... args)
123 : m_val{std::forward<Args>(args)...}, m_has_val{true} {}
124
125 template <typename U, typename... Args,
126 std::enable_if_t<std::is_constructible_v<T, std::initializer_list<U>&, Args&&...>>* =
127 nullptr>
128 constexpr expected_storage_base(std::in_place_t, std::initializer_list<U> il, Args&&... args)
129 : m_val{il, std::forward<Args>(args)...}, m_has_val{true} {}
130
131 template <typename... Args, std::enable_if_t<std::is_constructible_v<E, Args&&...>>* = nullptr>
132 constexpr explicit expected_storage_base(unexpect_t, Args&&... args)
133 : m_unexpect{std::forward<Args>(args)...}, m_has_val{false} {}
134
135 template <typename U, typename... Args,
136 std::enable_if_t<std::is_constructible_v<E, std::initializer_list<U>&, Args&&...>>* =
137 nullptr>
138 constexpr explicit expected_storage_base(unexpect_t, std::initializer_list<U> il,
139 Args&&... args)
140 : m_unexpect{il, std::forward<Args>(args)...}, m_has_val{false} {}
141
142 ~expected_storage_base() = default;
143
144 union {
145 T m_val;
146 Unexpected<E> m_unexpect;
147 };
148
149 bool m_has_val;
150};
151
152template <typename T, typename E>
153struct expected_operations_base : expected_storage_base<T, E> {
154 using expected_storage_base<T, E>::expected_storage_base;
155
156 template <typename... Args>
157 void construct(Args&&... args) noexcept {
158 new (std::addressof(this->m_val)) T{std::forward<Args>(args)...};
159 this->m_has_val = true;
160 }
161
162 template <typename Rhs>
163 void construct_with(Rhs&& rhs) noexcept {
164 new (std::addressof(this->m_val)) T{std::forward<Rhs>(rhs).get()};
165 this->m_has_val = true;
166 }
167
168 template <typename... Args>
169 void construct_error(Args&&... args) noexcept {
170 new (std::addressof(this->m_unexpect)) Unexpected<E>{std::forward<Args>(args)...};
171 this->m_has_val = false;
172 }
173
174 void assign(const expected_operations_base& rhs) noexcept {
175 if (!this->m_has_val && rhs.m_has_val) {
176 geterr().~Unexpected<E>();
177 construct(rhs.get());
178 } else {
179 assign_common(rhs);
180 }
181 }
182
183 void assign(expected_operations_base&& rhs) noexcept {
184 if (!this->m_has_val && rhs.m_has_val) {
185 geterr().~Unexpected<E>();
186 construct(std::move(rhs).get());
187 } else {
188 assign_common(rhs);
189 }
190 }
191
192 template <typename Rhs>
193 void assign_common(Rhs&& rhs) {
194 if (this->m_has_val) {
195 if (rhs.m_has_val) {
196 get() = std::forward<Rhs>(rhs).get();
197 } else {
198 destroy_val();
199 construct_error(std::forward<Rhs>(rhs).geterr());
200 }
201 } else {
202 if (!rhs.m_has_val) {
203 geterr() = std::forward<Rhs>(rhs).geterr();
204 }
205 }
206 }
207
208 bool has_value() const {
209 return this->m_has_val;
210 }
211
212 constexpr T& get() & {
213 return this->m_val;
214 }
215
216 constexpr const T& get() const& {
217 return this->m_val;
218 }
219
220 constexpr T&& get() && {
221 return std::move(this->m_val);
222 }
223
224 constexpr const T&& get() const&& {
225 return std::move(this->m_val);
226 }
227
228 constexpr Unexpected<E>& geterr() & {
229 return this->m_unexpect;
230 }
231
232 constexpr const Unexpected<E>& geterr() const& {
233 return this->m_unexpect;
234 }
235
236 constexpr Unexpected<E>&& geterr() && {
237 return std::move(this->m_unexpect);
238 }
239
240 constexpr const Unexpected<E>&& geterr() const&& {
241 return std::move(this->m_unexpect);
242 }
243
244 constexpr void destroy_val() {
245 get().~T();
246 }
247};
248
249/**
250 * This manages conditionally having a trivial copy constructor
251 * This specialization is for when T is trivially copy constructible
252 * Additionally, this requires E to be trivially copy constructible
253 */
254template <typename T, typename E, bool = std::is_trivially_copy_constructible_v<T>>
255requires std::is_trivially_copy_constructible_v<E>
256struct expected_copy_base : expected_operations_base<T, E> {
257 using expected_operations_base<T, E>::expected_operations_base;
258};
259
260/**
261 * This specialization is for when T is not trivially copy constructible
262 * Additionally, this requires E to be trivially copy constructible
263 */
264template <typename T, typename E>
265requires std::is_trivially_copy_constructible_v<E>
266struct expected_copy_base<T, E, false> : expected_operations_base<T, E> {
267 using expected_operations_base<T, E>::expected_operations_base;
268
269 expected_copy_base() = default;
270
271 expected_copy_base(const expected_copy_base& rhs)
272 : expected_operations_base<T, E>{no_init_t{}} {
273 if (rhs.has_value()) {
274 this->construct_with(rhs);
275 } else {
276 this->construct_error(rhs.geterr());
277 }
278 }
279
280 expected_copy_base(expected_copy_base&&) = default;
281
282 expected_copy_base& operator=(const expected_copy_base&) = default;
283
284 expected_copy_base& operator=(expected_copy_base&&) = default;
285};
286
287/**
288 * This manages conditionally having a trivial move constructor
289 * This specialization is for when T is trivially move constructible
290 * Additionally, this requires E to be trivially move constructible
291 */
292template <typename T, typename E, bool = std::is_trivially_move_constructible_v<T>>
293requires std::is_trivially_move_constructible_v<E>
294struct expected_move_base : expected_copy_base<T, E> {
295 using expected_copy_base<T, E>::expected_copy_base;
296};
297
298/**
299 * This specialization is for when T is not trivially move constructible
300 * Additionally, this requires E to be trivially move constructible
301 */
302template <typename T, typename E>
303requires std::is_trivially_move_constructible_v<E>
304struct expected_move_base<T, E, false> : expected_copy_base<T, E> {
305 using expected_copy_base<T, E>::expected_copy_base;
306
307 expected_move_base() = default;
308
309 expected_move_base(const expected_move_base&) = default;
310
311 expected_move_base(expected_move_base&& rhs) noexcept(std::is_nothrow_move_constructible_v<T>)
312 : expected_copy_base<T, E>{no_init_t{}} {
313 if (rhs.has_value()) {
314 this->construct_with(std::move(rhs));
315 } else {
316 this->construct_error(std::move(rhs.geterr()));
317 }
318 }
319
320 expected_move_base& operator=(const expected_move_base&) = default;
321
322 expected_move_base& operator=(expected_move_base&&) = default;
323};
324
325/**
326 * This manages conditionally having a trivial copy assignment operator
327 * This specialization is for when T is trivially copy assignable
328 * Additionally, this requires E to be trivially copy assignable
329 */
330template <typename T, typename E,
331 bool = std::conjunction_v<std::is_trivially_copy_assignable<T>,
332 std::is_trivially_copy_constructible<T>,
333 std::is_trivially_destructible<T>>>
334requires std::conjunction_v<std::is_trivially_copy_assignable<E>,
335 std::is_trivially_copy_constructible<E>,
336 std::is_trivially_destructible<E>>
337struct expected_copy_assign_base : expected_move_base<T, E> {
338 using expected_move_base<T, E>::expected_move_base;
339};
340
341/**
342 * This specialization is for when T is not trivially copy assignable
343 * Additionally, this requires E to be trivially copy assignable
344 */
345template <typename T, typename E>
346requires std::conjunction_v<std::is_trivially_copy_assignable<E>,
347 std::is_trivially_copy_constructible<E>,
348 std::is_trivially_destructible<E>>
349struct expected_copy_assign_base<T, E, false> : expected_move_base<T, E> {
350 using expected_move_base<T, E>::expected_move_base;
351
352 expected_copy_assign_base() = default;
353
354 expected_copy_assign_base(const expected_copy_assign_base&) = default;
355
356 expected_copy_assign_base(expected_copy_assign_base&&) = default;
357
358 expected_copy_assign_base& operator=(const expected_copy_assign_base& rhs) {
359 this->assign(rhs);
360 return *this;
361 }
362
363 expected_copy_assign_base& operator=(expected_copy_assign_base&&) = default;
364};
365
366/**
367 * This manages conditionally having a trivial move assignment operator
368 * This specialization is for when T is trivially move assignable
369 * Additionally, this requires E to be trivially move assignable
370 */
371template <typename T, typename E,
372 bool = std::conjunction_v<std::is_trivially_move_assignable<T>,
373 std::is_trivially_move_constructible<T>,
374 std::is_trivially_destructible<T>>>
375requires std::conjunction_v<std::is_trivially_move_assignable<E>,
376 std::is_trivially_move_constructible<E>,
377 std::is_trivially_destructible<E>>
378struct expected_move_assign_base : expected_copy_assign_base<T, E> {
379 using expected_copy_assign_base<T, E>::expected_copy_assign_base;
380};
381
382/**
383 * This specialization is for when T is not trivially move assignable
384 * Additionally, this requires E to be trivially move assignable
385 */
386template <typename T, typename E>
387requires std::conjunction_v<std::is_trivially_move_assignable<E>,
388 std::is_trivially_move_constructible<E>,
389 std::is_trivially_destructible<E>>
390struct expected_move_assign_base<T, E, false> : expected_copy_assign_base<T, E> {
391 using expected_copy_assign_base<T, E>::expected_copy_assign_base;
392
393 expected_move_assign_base() = default;
394
395 expected_move_assign_base(const expected_move_assign_base&) = default;
396
397 expected_move_assign_base(expected_move_assign_base&&) = default;
398
399 expected_move_assign_base& operator=(const expected_move_assign_base&) = default;
400
401 expected_move_assign_base& operator=(expected_move_assign_base&& rhs) noexcept(
402 std::conjunction_v<std::is_nothrow_move_constructible<T>,
403 std::is_nothrow_move_assignable<T>>) {
404 this->assign(std::move(rhs));
405 return *this;
406 }
407};
408
409/**
410 * expected_delete_ctor_base will conditionally delete copy and move constructors
411 * depending on whether T is copy/move constructible
412 * Additionally, this requires E to be copy/move constructible
413 */
414template <typename T, typename E, bool EnableCopy = std::is_copy_constructible_v<T>,
415 bool EnableMove = std::is_move_constructible_v<T>>
416requires std::conjunction_v<std::is_copy_constructible<E>, std::is_move_constructible<E>>
417struct expected_delete_ctor_base {
418 expected_delete_ctor_base() = default;
419 expected_delete_ctor_base(const expected_delete_ctor_base&) = default;
420 expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = default;
421 expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
422 expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
423};
424
425template <typename T, typename E>
426requires std::conjunction_v<std::is_copy_constructible<E>, std::is_move_constructible<E>>
427struct expected_delete_ctor_base<T, E, true, false> {
428 expected_delete_ctor_base() = default;
429 expected_delete_ctor_base(const expected_delete_ctor_base&) = default;
430 expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = delete;
431 expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
432 expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
433};
434
435template <typename T, typename E>
436requires std::conjunction_v<std::is_copy_constructible<E>, std::is_move_constructible<E>>
437struct expected_delete_ctor_base<T, E, false, true> {
438 expected_delete_ctor_base() = default;
439 expected_delete_ctor_base(const expected_delete_ctor_base&) = delete;
440 expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = default;
441 expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
442 expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
443};
444
445template <typename T, typename E>
446requires std::conjunction_v<std::is_copy_constructible<E>, std::is_move_constructible<E>>
447struct expected_delete_ctor_base<T, E, false, false> {
448 expected_delete_ctor_base() = default;
449 expected_delete_ctor_base(const expected_delete_ctor_base&) = delete;
450 expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = delete;
451 expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = default;
452 expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = default;
453};
454
455/**
456 * expected_delete_assign_base will conditionally delete copy and move assignment operators
457 * depending on whether T is copy/move constructible + assignable
458 * Additionally, this requires E to be copy/move constructible + assignable
459 */
460template <
461 typename T, typename E,
462 bool EnableCopy = std::conjunction_v<std::is_copy_constructible<T>, std::is_copy_assignable<T>>,
463 bool EnableMove = std::conjunction_v<std::is_move_constructible<T>, std::is_move_assignable<T>>>
464requires std::conjunction_v<std::is_copy_constructible<E>, std::is_move_constructible<E>,
465 std::is_copy_assignable<E>, std::is_move_assignable<E>>
466struct expected_delete_assign_base {
467 expected_delete_assign_base() = default;
468 expected_delete_assign_base(const expected_delete_assign_base&) = default;
469 expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
470 expected_delete_assign_base& operator=(const expected_delete_assign_base&) = default;
471 expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = default;
472};
473
474template <typename T, typename E>
475requires std::conjunction_v<std::is_copy_constructible<E>, std::is_move_constructible<E>,
476 std::is_copy_assignable<E>, std::is_move_assignable<E>>
477struct expected_delete_assign_base<T, E, true, false> {
478 expected_delete_assign_base() = default;
479 expected_delete_assign_base(const expected_delete_assign_base&) = default;
480 expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
481 expected_delete_assign_base& operator=(const expected_delete_assign_base&) = default;
482 expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = delete;
483};
484
485template <typename T, typename E>
486requires std::conjunction_v<std::is_copy_constructible<E>, std::is_move_constructible<E>,
487 std::is_copy_assignable<E>, std::is_move_assignable<E>>
488struct expected_delete_assign_base<T, E, false, true> {
489 expected_delete_assign_base() = default;
490 expected_delete_assign_base(const expected_delete_assign_base&) = default;
491 expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
492 expected_delete_assign_base& operator=(const expected_delete_assign_base&) = delete;
493 expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = default;
494};
495
496template <typename T, typename E>
497requires std::conjunction_v<std::is_copy_constructible<E>, std::is_move_constructible<E>,
498 std::is_copy_assignable<E>, std::is_move_assignable<E>>
499struct expected_delete_assign_base<T, E, false, false> {
500 expected_delete_assign_base() = default;
501 expected_delete_assign_base(const expected_delete_assign_base&) = default;
502 expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default;
503 expected_delete_assign_base& operator=(const expected_delete_assign_base&) = delete;
504 expected_delete_assign_base& operator=(expected_delete_assign_base&&) noexcept = delete;
505};
506
507/**
508 * This is needed to be able to construct the expected_default_ctor_base which follows,
509 * while still conditionally deleting the default constructor.
510 */
511struct default_constructor_tag {
512 constexpr explicit default_constructor_tag() = default;
513};
514
515/**
516 * expected_default_ctor_base will ensure that expected
517 * has a deleted default constructor if T is not default constructible
518 * This specialization is for when T is default constructible
519 */
520template <typename T, typename E, bool Enable = std::is_default_constructible_v<T>>
521struct expected_default_ctor_base {
522 constexpr expected_default_ctor_base() noexcept = default;
523 constexpr expected_default_ctor_base(expected_default_ctor_base const&) noexcept = default;
524 constexpr expected_default_ctor_base(expected_default_ctor_base&&) noexcept = default;
525 expected_default_ctor_base& operator=(expected_default_ctor_base const&) noexcept = default;
526 expected_default_ctor_base& operator=(expected_default_ctor_base&&) noexcept = default;
527
528 constexpr explicit expected_default_ctor_base(default_constructor_tag) {}
529};
530
531template <typename T, typename E>
532struct expected_default_ctor_base<T, E, false> {
533 constexpr expected_default_ctor_base() noexcept = delete;
534 constexpr expected_default_ctor_base(expected_default_ctor_base const&) noexcept = default;
535 constexpr expected_default_ctor_base(expected_default_ctor_base&&) noexcept = default;
536 expected_default_ctor_base& operator=(expected_default_ctor_base const&) noexcept = default;
537 expected_default_ctor_base& operator=(expected_default_ctor_base&&) noexcept = default;
538
539 constexpr explicit expected_default_ctor_base(default_constructor_tag) {}
540};
541
542template <typename T, typename E, typename U>
543using expected_enable_forward_value =
544 std::enable_if_t<std::is_constructible_v<T, U&&> &&
545 !std::is_same_v<std::remove_cvref_t<U>, std::in_place_t> &&
546 !std::is_same_v<Expected<T, E>, std::remove_cvref_t<U>> &&
547 !std::is_same_v<Unexpected<E>, std::remove_cvref_t<U>>>;
548
549template <typename T, typename E, typename U, typename G, typename UR, typename GR>
550using expected_enable_from_other = std::enable_if_t<
551 std::is_constructible_v<T, UR> && std::is_constructible_v<E, GR> &&
552 !std::is_constructible_v<T, Expected<U, G>&> && !std::is_constructible_v<T, Expected<U, G>&&> &&
553 !std::is_constructible_v<T, const Expected<U, G>&> &&
554 !std::is_constructible_v<T, const Expected<U, G>&&> &&
555 !std::is_convertible_v<Expected<U, G>&, T> && !std::is_convertible_v<Expected<U, G>&&, T> &&
556 !std::is_convertible_v<const Expected<U, G>&, T> &&
557 !std::is_convertible_v<const Expected<U, G>&&, T>>;
558
559} // namespace detail
560
561template <typename T, typename E>
562class Expected : private detail::expected_move_assign_base<T, E>,
563 private detail::expected_delete_ctor_base<T, E>,
564 private detail::expected_delete_assign_base<T, E>,
565 private detail::expected_default_ctor_base<T, E> {
566public:
567 using value_type = T;
568 using error_type = E;
569 using unexpected_type = Unexpected<E>;
570
571 constexpr Expected() = default;
572 constexpr Expected(const Expected&) = default;
573 constexpr Expected(Expected&&) = default;
574 Expected& operator=(const Expected&) = default;
575 Expected& operator=(Expected&&) = default;
576
577 template <typename... Args, std::enable_if_t<std::is_constructible_v<T, Args&&...>>* = nullptr>
578 constexpr Expected(std::in_place_t, Args&&... args)
579 : impl_base{std::in_place, std::forward<Args>(args)...},
580 ctor_base{detail::default_constructor_tag{}} {}
581
582 template <typename U, typename... Args,
583 std::enable_if_t<std::is_constructible_v<T, std::initializer_list<U>&, Args&&...>>* =
584 nullptr>
585 constexpr Expected(std::in_place_t, std::initializer_list<U> il, Args&&... args)
586 : impl_base{std::in_place, il, std::forward<Args>(args)...},
587 ctor_base{detail::default_constructor_tag{}} {}
588
589 template <typename G = E, std::enable_if_t<std::is_constructible_v<E, const G&>>* = nullptr,
590 std::enable_if_t<!std::is_convertible_v<const G&, E>>* = nullptr>
591 constexpr explicit Expected(const Unexpected<G>& e)
592 : impl_base{unexpect_t{}, e.value()}, ctor_base{detail::default_constructor_tag{}} {}
593
594 template <typename G = E, std::enable_if_t<std::is_constructible_v<E, const G&>>* = nullptr,
595 std::enable_if_t<std::is_convertible_v<const G&, E>>* = nullptr>
596 constexpr Expected(Unexpected<G> const& e)
597 : impl_base{unexpect_t{}, e.value()}, ctor_base{detail::default_constructor_tag{}} {}
598
599 template <typename G = E, std::enable_if_t<std::is_constructible_v<E, G&&>>* = nullptr,
600 std::enable_if_t<!std::is_convertible_v<G&&, E>>* = nullptr>
601 constexpr explicit Expected(Unexpected<G>&& e) noexcept(std::is_nothrow_constructible_v<E, G&&>)
602 : impl_base{unexpect_t{}, std::move(e.value())}, ctor_base{
603 detail::default_constructor_tag{}} {}
604
605 template <typename G = E, std::enable_if_t<std::is_constructible_v<E, G&&>>* = nullptr,
606 std::enable_if_t<std::is_convertible_v<G&&, E>>* = nullptr>
607 constexpr Expected(Unexpected<G>&& e) noexcept(std::is_nothrow_constructible_v<E, G&&>)
608 : impl_base{unexpect_t{}, std::move(e.value())}, ctor_base{
609 detail::default_constructor_tag{}} {}
610
611 template <typename... Args, std::enable_if_t<std::is_constructible_v<E, Args&&...>>* = nullptr>
612 constexpr explicit Expected(unexpect_t, Args&&... args)
613 : impl_base{unexpect_t{}, std::forward<Args>(args)...},
614 ctor_base{detail::default_constructor_tag{}} {}
615
616 template <typename U, typename... Args,
617 std::enable_if_t<std::is_constructible_v<E, std::initializer_list<U>&, Args&&...>>* =
618 nullptr>
619 constexpr explicit Expected(unexpect_t, std::initializer_list<U> il, Args&&... args)
620 : impl_base{unexpect_t{}, il, std::forward<Args>(args)...},
621 ctor_base{detail::default_constructor_tag{}} {}
622
623 template <typename U, typename G,
624 std::enable_if_t<!(std::is_convertible_v<U const&, T> &&
625 std::is_convertible_v<G const&, E>)>* = nullptr,
626 detail::expected_enable_from_other<T, E, U, G, const U&, const G&>* = nullptr>
627 constexpr explicit Expected(const Expected<U, G>& rhs)
628 : ctor_base{detail::default_constructor_tag{}} {
629 if (rhs.has_value()) {
630 this->construct(*rhs);
631 } else {
632 this->construct_error(rhs.error());
633 }
634 }
635
636 template <typename U, typename G,
637 std::enable_if_t<(std::is_convertible_v<U const&, T> &&
638 std::is_convertible_v<G const&, E>)>* = nullptr,
639 detail::expected_enable_from_other<T, E, U, G, const U&, const G&>* = nullptr>
640 constexpr Expected(const Expected<U, G>& rhs) : ctor_base{detail::default_constructor_tag{}} {
641 if (rhs.has_value()) {
642 this->construct(*rhs);
643 } else {
644 this->construct_error(rhs.error());
645 }
646 }
647
648 template <typename U, typename G,
649 std::enable_if_t<!(std::is_convertible_v<U&&, T> && std::is_convertible_v<G&&, E>)>* =
650 nullptr,
651 detail::expected_enable_from_other<T, E, U, G, U&&, G&&>* = nullptr>
652 constexpr explicit Expected(Expected<U, G>&& rhs)
653 : ctor_base{detail::default_constructor_tag{}} {
654 if (rhs.has_value()) {
655 this->construct(std::move(*rhs));
656 } else {
657 this->construct_error(std::move(rhs.error()));
658 }
659 }
660
661 template <typename U, typename G,
662 std::enable_if_t<(std::is_convertible_v<U&&, T> && std::is_convertible_v<G&&, E>)>* =
663 nullptr,
664 detail::expected_enable_from_other<T, E, U, G, U&&, G&&>* = nullptr>
665 constexpr Expected(Expected<U, G>&& rhs) : ctor_base{detail::default_constructor_tag{}} {
666 if (rhs.has_value()) {
667 this->construct(std::move(*rhs));
668 } else {
669 this->construct_error(std::move(rhs.error()));
670 }
671 }
672
673 template <typename U = T, std::enable_if_t<!std::is_convertible_v<U&&, T>>* = nullptr,
674 detail::expected_enable_forward_value<T, E, U>* = nullptr>
675 constexpr explicit Expected(U&& v) : Expected{std::in_place, std::forward<U>(v)} {}
676
677 template <typename U = T, std::enable_if_t<std::is_convertible_v<U&&, T>>* = nullptr,
678 detail::expected_enable_forward_value<T, E, U>* = nullptr>
679 constexpr Expected(U&& v) : Expected{std::in_place, std::forward<U>(v)} {}
680
681 template <typename U = T, typename G = T,
682 std::enable_if_t<std::is_nothrow_constructible_v<T, U&&>>* = nullptr,
683 std::enable_if_t<(
684 !std::is_same_v<Expected<T, E>, std::remove_cvref_t<U>> &&
685 !std::conjunction_v<std::is_scalar<T>, std::is_same<T, std::remove_cvref_t<U>>> &&
686 std::is_constructible_v<T, U> && std::is_assignable_v<G&, U> &&
687 std::is_nothrow_move_constructible_v<E>)>* = nullptr>
688 Expected& operator=(U&& v) {
689 if (has_value()) {
690 val() = std::forward<U>(v);
691 } else {
692 err().~Unexpected<E>();
693 new (valptr()) T{std::forward<U>(v)};
694 this->m_has_val = true;
695 }
696
697 return *this;
698 }
699
700 template <typename U = T, typename G = T,
701 std::enable_if_t<!std::is_nothrow_constructible_v<T, U&&>>* = nullptr,
702 std::enable_if_t<(
703 !std::is_same_v<Expected<T, E>, std::remove_cvref_t<U>> &&
704 !std::conjunction_v<std::is_scalar<T>, std::is_same<T, std::remove_cvref_t<U>>> &&
705 std::is_constructible_v<T, U> && std::is_assignable_v<G&, U> &&
706 std::is_nothrow_move_constructible_v<E>)>* = nullptr>
707 Expected& operator=(U&& v) {
708 if (has_value()) {
709 val() = std::forward<U>(v);
710 } else {
711 auto tmp = std::move(err());
712 err().~Unexpected<E>();
713 new (valptr()) T{std::forward<U>(v)};
714 this->m_has_val = true;
715 }
716
717 return *this;
718 }
719
720 template <typename G = E, std::enable_if_t<std::is_nothrow_copy_constructible_v<G> &&
721 std::is_assignable_v<G&, G>>* = nullptr>
722 Expected& operator=(const Unexpected<G>& rhs) {
723 if (!has_value()) {
724 err() = rhs;
725 } else {
726 this->destroy_val();
727 new (errptr()) Unexpected<E>{rhs};
728 this->m_has_val = false;
729 }
730
731 return *this;
732 }
733
734 template <typename G = E, std::enable_if_t<std::is_nothrow_move_constructible_v<G> &&
735 std::is_move_assignable_v<G>>* = nullptr>
736 Expected& operator=(Unexpected<G>&& rhs) noexcept {
737 if (!has_value()) {
738 err() = std::move(rhs);
739 } else {
740 this->destroy_val();
741 new (errptr()) Unexpected<E>{std::move(rhs)};
742 this->m_has_val = false;
743 }
744
745 return *this;
746 }
747
748 template <typename... Args,
749 std::enable_if_t<std::is_nothrow_constructible_v<T, Args&&...>>* = nullptr>
750 void emplace(Args&&... args) {
751 if (has_value()) {
752 val() = T{std::forward<Args>(args)...};
753 } else {
754 err().~Unexpected<E>();
755 new (valptr()) T{std::forward<Args>(args)...};
756 this->m_has_val = true;
757 }
758 }
759
760 template <typename... Args,
761 std::enable_if_t<!std::is_nothrow_constructible_v<T, Args&&...>>* = nullptr>
762 void emplace(Args&&... args) {
763 if (has_value()) {
764 val() = T{std::forward<Args>(args)...};
765 } else {
766 auto tmp = std::move(err());
767 err().~Unexpected<E>();
768 new (valptr()) T{std::forward<Args>(args)...};
769 this->m_has_val = true;
770 }
771 }
772
773 template <typename U, typename... Args,
774 std::enable_if_t<std::is_nothrow_constructible_v<T, std::initializer_list<U>&,
775 Args&&...>>* = nullptr>
776 void emplace(std::initializer_list<U> il, Args&&... args) {
777 if (has_value()) {
778 T t{il, std::forward<Args>(args)...};
779 val() = std::move(t);
780 } else {
781 err().~Unexpected<E>();
782 new (valptr()) T{il, std::forward<Args>(args)...};
783 this->m_has_val = true;
784 }
785 }
786
787 template <typename U, typename... Args,
788 std::enable_if_t<!std::is_nothrow_constructible_v<T, std::initializer_list<U>&,
789 Args&&...>>* = nullptr>
790 void emplace(std::initializer_list<U> il, Args&&... args) {
791 if (has_value()) {
792 T t{il, std::forward<Args>(args)...};
793 val() = std::move(t);
794 } else {
795 auto tmp = std::move(err());
796 err().~Unexpected<E>();
797 new (valptr()) T{il, std::forward<Args>(args)...};
798 this->m_has_val = true;
799 }
800 }
801
802 constexpr T* operator->() {
803 return valptr();
804 }
805
806 constexpr const T* operator->() const {
807 return valptr();
808 }
809
810 template <typename U = T>
811 constexpr U& operator*() & {
812 return val();
813 }
814
815 template <typename U = T>
816 constexpr const U& operator*() const& {
817 return val();
818 }
819
820 template <typename U = T>
821 constexpr U&& operator*() && {
822 return std::move(val());
823 }
824
825 template <typename U = T>
826 constexpr const U&& operator*() const&& {
827 return std::move(val());
828 }
829
830 constexpr bool has_value() const noexcept {
831 return this->m_has_val;
832 }
833
834 constexpr explicit operator bool() const noexcept {
835 return this->m_has_val;
836 }
837
838 template <typename U = T>
839 constexpr U& value() & {
840 return val();
841 }
842
843 template <typename U = T>
844 constexpr const U& value() const& {
845 return val();
846 }
847
848 template <typename U = T>
849 constexpr U&& value() && {
850 return std::move(val());
851 }
852
853 template <typename U = T>
854 constexpr const U&& value() const&& {
855 return std::move(val());
856 }
857
858 constexpr E& error() & {
859 return err().value();
860 }
861
862 constexpr const E& error() const& {
863 return err().value();
864 }
865
866 constexpr E&& error() && {
867 return std::move(err().value());
868 }
869
870 constexpr const E&& error() const&& {
871 return std::move(err().value());
872 }
873
874 template <typename U>
875 constexpr T value_or(U&& v) const& {
876 static_assert(std::is_copy_constructible_v<T> && std::is_convertible_v<U&&, T>,
877 "T must be copy-constructible and convertible from U&&");
878 return bool(*this) ? **this : static_cast<T>(std::forward<U>(v));
879 }
880
881 template <typename U>
882 constexpr T value_or(U&& v) && {
883 static_assert(std::is_move_constructible_v<T> && std::is_convertible_v<U&&, T>,
884 "T must be move-constructible and convertible from U&&");
885 return bool(*this) ? std::move(**this) : static_cast<T>(std::forward<U>(v));
886 }
887
888private:
889 static_assert(!std::is_reference_v<T>, "T must not be a reference");
890 static_assert(!std::is_same_v<T, std::remove_cv_t<std::in_place_t>>,
891 "T must not be std::in_place_t");
892 static_assert(!std::is_same_v<T, std::remove_cv_t<unexpect_t>>, "T must not be unexpect_t");
893 static_assert(!std::is_same_v<T, std::remove_cv_t<Unexpected<E>>>,
894 "T must not be Unexpected<E>");
895 static_assert(!std::is_reference_v<E>, "E must not be a reference");
896
897 T* valptr() {
898 return std::addressof(this->m_val);
899 }
900
901 const T* valptr() const {
902 return std::addressof(this->m_val);
903 }
904
905 Unexpected<E>* errptr() {
906 return std::addressof(this->m_unexpect);
907 }
908
909 const Unexpected<E>* errptr() const {
910 return std::addressof(this->m_unexpect);
911 }
912
913 template <typename U = T>
914 constexpr U& val() {
915 return this->m_val;
916 }
917
918 template <typename U = T>
919 constexpr const U& val() const {
920 return this->m_val;
921 }
922
923 constexpr Unexpected<E>& err() {
924 return this->m_unexpect;
925 }
926
927 constexpr const Unexpected<E>& err() const {
928 return this->m_unexpect;
929 }
930
931 using impl_base = detail::expected_move_assign_base<T, E>;
932 using ctor_base = detail::expected_default_ctor_base<T, E>;
933};
934
935template <typename T, typename E, typename U, typename F>
936constexpr bool operator==(const Expected<T, E>& lhs, const Expected<U, F>& rhs) {
937 return (lhs.has_value() != rhs.has_value())
938 ? false
939 : (!lhs.has_value() ? lhs.error() == rhs.error() : *lhs == *rhs);
940}
941
942template <typename T, typename E, typename U, typename F>
943constexpr bool operator!=(const Expected<T, E>& lhs, const Expected<U, F>& rhs) {
944 return !operator==(lhs, rhs);
945}
946
947template <typename T, typename E, typename U>
948constexpr bool operator==(const Expected<T, E>& x, const U& v) {
949 return x.has_value() ? *x == v : false;
950}
951
952template <typename T, typename E, typename U>
953constexpr bool operator==(const U& v, const Expected<T, E>& x) {
954 return x.has_value() ? *x == v : false;
955}
956
957template <typename T, typename E, typename U>
958constexpr bool operator!=(const Expected<T, E>& x, const U& v) {
959 return !operator==(x, v);
960}
961
962template <typename T, typename E, typename U>
963constexpr bool operator!=(const U& v, const Expected<T, E>& x) {
964 return !operator==(v, x);
965}
966
967template <typename T, typename E>
968constexpr bool operator==(const Expected<T, E>& x, const Unexpected<E>& e) {
969 return x.has_value() ? false : x.error() == e.value();
970}
971
972template <typename T, typename E>
973constexpr bool operator==(const Unexpected<E>& e, const Expected<T, E>& x) {
974 return x.has_value() ? false : x.error() == e.value();
975}
976
977template <typename T, typename E>
978constexpr bool operator!=(const Expected<T, E>& x, const Unexpected<E>& e) {
979 return !operator==(x, e);
980}
981
982template <typename T, typename E>
983constexpr bool operator!=(const Unexpected<E>& e, const Expected<T, E>& x) {
984 return !operator==(e, x);
985}
986
987} // namespace Common
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.h b/src/core/arm/dynarmic/arm_dynarmic_32.h
index 063605b46..5d47b600d 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_32.h
+++ b/src/core/arm/dynarmic/arm_dynarmic_32.h
@@ -9,7 +9,6 @@
9 9
10#include <dynarmic/interface/A32/a32.h> 10#include <dynarmic/interface/A32/a32.h>
11#include <dynarmic/interface/A64/a64.h> 11#include <dynarmic/interface/A64/a64.h>
12#include <dynarmic/interface/exclusive_monitor.h>
13#include "common/common_types.h" 12#include "common/common_types.h"
14#include "common/hash.h" 13#include "common/hash.h"
15#include "core/arm/arm_interface.h" 14#include "core/arm/arm_interface.h"
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp
index 4fd15f111..4e73cc03a 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp
@@ -18,7 +18,6 @@
18#include "core/core_timing.h" 18#include "core/core_timing.h"
19#include "core/hardware_properties.h" 19#include "core/hardware_properties.h"
20#include "core/hle/kernel/k_process.h" 20#include "core/hle/kernel/k_process.h"
21#include "core/hle/kernel/k_scheduler.h"
22#include "core/hle/kernel/svc.h" 21#include "core/hle/kernel/svc.h"
23#include "core/memory.h" 22#include "core/memory.h"
24 23
diff --git a/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp b/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp
index ebd506121..a043e6735 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp
@@ -8,7 +8,6 @@
8#include "core/arm/dynarmic/arm_dynarmic_cp15.h" 8#include "core/arm/dynarmic/arm_dynarmic_cp15.h"
9#include "core/core.h" 9#include "core/core.h"
10#include "core/core_timing.h" 10#include "core/core_timing.h"
11#include "core/core_timing_util.h"
12 11
13using Callback = Dynarmic::A32::Coprocessor::Callback; 12using Callback = Dynarmic::A32::Coprocessor::Callback;
14using CallbackOrAccessOneWord = Dynarmic::A32::Coprocessor::CallbackOrAccessOneWord; 13using CallbackOrAccessOneWord = Dynarmic::A32::Coprocessor::CallbackOrAccessOneWord;
diff --git a/src/core/arm/dynarmic/arm_dynarmic_cp15.h b/src/core/arm/dynarmic/arm_dynarmic_cp15.h
index 7c7ede79e..f271b2070 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_cp15.h
+++ b/src/core/arm/dynarmic/arm_dynarmic_cp15.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
8#include <optional> 7#include <optional>
9 8
10#include <dynarmic/interface/A32/coprocessor.h> 9#include <dynarmic/interface/A32/coprocessor.h>
diff --git a/src/core/arm/dynarmic/arm_exclusive_monitor.cpp b/src/core/arm/dynarmic/arm_exclusive_monitor.cpp
index 9426a3edf..397d054a8 100644
--- a/src/core/arm/dynarmic/arm_exclusive_monitor.cpp
+++ b/src/core/arm/dynarmic/arm_exclusive_monitor.cpp
@@ -2,8 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cinttypes>
6#include <memory>
7#include "core/arm/dynarmic/arm_exclusive_monitor.h" 5#include "core/arm/dynarmic/arm_exclusive_monitor.h"
8#include "core/memory.h" 6#include "core/memory.h"
9 7
diff --git a/src/core/arm/dynarmic/arm_exclusive_monitor.h b/src/core/arm/dynarmic/arm_exclusive_monitor.h
index 73d41f223..265c4ecef 100644
--- a/src/core/arm/dynarmic/arm_exclusive_monitor.h
+++ b/src/core/arm/dynarmic/arm_exclusive_monitor.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
8#include <unordered_map> 7#include <unordered_map>
9 8
10#include <dynarmic/interface/exclusive_monitor.h> 9#include <dynarmic/interface/exclusive_monitor.h>
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 3c75f42ae..07448fd29 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -19,20 +19,16 @@
19#include "core/cpu_manager.h" 19#include "core/cpu_manager.h"
20#include "core/device_memory.h" 20#include "core/device_memory.h"
21#include "core/file_sys/bis_factory.h" 21#include "core/file_sys/bis_factory.h"
22#include "core/file_sys/card_image.h"
23#include "core/file_sys/mode.h" 22#include "core/file_sys/mode.h"
24#include "core/file_sys/patch_manager.h" 23#include "core/file_sys/patch_manager.h"
25#include "core/file_sys/registered_cache.h" 24#include "core/file_sys/registered_cache.h"
26#include "core/file_sys/romfs_factory.h" 25#include "core/file_sys/romfs_factory.h"
27#include "core/file_sys/savedata_factory.h" 26#include "core/file_sys/savedata_factory.h"
28#include "core/file_sys/sdmc_factory.h"
29#include "core/file_sys/vfs_concat.h" 27#include "core/file_sys/vfs_concat.h"
30#include "core/file_sys/vfs_real.h" 28#include "core/file_sys/vfs_real.h"
31#include "core/hardware_interrupt_manager.h" 29#include "core/hardware_interrupt_manager.h"
32#include "core/hle/kernel/k_client_port.h"
33#include "core/hle/kernel/k_process.h" 30#include "core/hle/kernel/k_process.h"
34#include "core/hle/kernel/k_scheduler.h" 31#include "core/hle/kernel/k_scheduler.h"
35#include "core/hle/kernel/k_thread.h"
36#include "core/hle/kernel/kernel.h" 32#include "core/hle/kernel/kernel.h"
37#include "core/hle/kernel/physical_core.h" 33#include "core/hle/kernel/physical_core.h"
38#include "core/hle/service/am/applets/applets.h" 34#include "core/hle/service/am/applets/applets.h"
@@ -83,12 +79,6 @@ FileSys::StorageId GetStorageIdForFrontendSlot(
83 } 79 }
84} 80}
85 81
86void KProcessDeleter(Kernel::KProcess* process) {
87 process->Destroy();
88}
89
90using KProcessPtr = std::unique_ptr<Kernel::KProcess, decltype(&KProcessDeleter)>;
91
92} // Anonymous namespace 82} // Anonymous namespace
93 83
94FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, 84FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
@@ -261,11 +251,10 @@ struct System::Impl {
261 } 251 }
262 252
263 telemetry_session->AddInitialInfo(*app_loader, fs_controller, *content_provider); 253 telemetry_session->AddInitialInfo(*app_loader, fs_controller, *content_provider);
264 main_process = KProcessPtr{Kernel::KProcess::Create(system.Kernel()), KProcessDeleter}; 254 auto main_process = Kernel::KProcess::Create(system.Kernel());
265 ASSERT(Kernel::KProcess::Initialize(main_process.get(), system, "main", 255 ASSERT(Kernel::KProcess::Initialize(main_process, system, "main",
266 Kernel::KProcess::ProcessType::Userland) 256 Kernel::KProcess::ProcessType::Userland)
267 .IsSuccess()); 257 .IsSuccess());
268 main_process->Open();
269 const auto [load_result, load_parameters] = app_loader->Load(*main_process, system); 258 const auto [load_result, load_parameters] = app_loader->Load(*main_process, system);
270 if (load_result != Loader::ResultStatus::Success) { 259 if (load_result != Loader::ResultStatus::Success) {
271 LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", load_result); 260 LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", load_result);
@@ -275,7 +264,7 @@ struct System::Impl {
275 static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result)); 264 static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result));
276 } 265 }
277 AddGlueRegistrationForProcess(*app_loader, *main_process); 266 AddGlueRegistrationForProcess(*app_loader, *main_process);
278 kernel.MakeCurrentProcess(main_process.get()); 267 kernel.MakeCurrentProcess(main_process);
279 kernel.InitializeCores(); 268 kernel.InitializeCores();
280 269
281 // Initialize cheat engine 270 // Initialize cheat engine
@@ -335,13 +324,11 @@ struct System::Impl {
335 time_manager.Shutdown(); 324 time_manager.Shutdown();
336 core_timing.Shutdown(); 325 core_timing.Shutdown();
337 app_loader.reset(); 326 app_loader.reset();
338 perf_stats.reset();
339 gpu_core.reset(); 327 gpu_core.reset();
328 perf_stats.reset();
340 kernel.Shutdown(); 329 kernel.Shutdown();
341 memory.Reset(); 330 memory.Reset();
342 applet_manager.ClearAll(); 331 applet_manager.ClearAll();
343 // TODO: The main process should be freed based on KAutoObject ref counting.
344 main_process.reset();
345 332
346 LOG_DEBUG(Core, "Shutdown OK"); 333 LOG_DEBUG(Core, "Shutdown OK");
347 } 334 }
@@ -362,7 +349,7 @@ struct System::Impl {
362 } 349 }
363 350
364 Service::Glue::ApplicationLaunchProperty launch{}; 351 Service::Glue::ApplicationLaunchProperty launch{};
365 launch.title_id = process.GetTitleID(); 352 launch.title_id = process.GetProgramID();
366 353
367 FileSys::PatchManager pm{launch.title_id, fs_controller, *content_provider}; 354 FileSys::PatchManager pm{launch.title_id, fs_controller, *content_provider};
368 launch.version = pm.GetGameVersion().value_or(0); 355 launch.version = pm.GetGameVersion().value_or(0);
@@ -403,7 +390,6 @@ struct System::Impl {
403 std::unique_ptr<Tegra::GPU> gpu_core; 390 std::unique_ptr<Tegra::GPU> gpu_core;
404 std::unique_ptr<Hardware::InterruptManager> interrupt_manager; 391 std::unique_ptr<Hardware::InterruptManager> interrupt_manager;
405 std::unique_ptr<Core::DeviceMemory> device_memory; 392 std::unique_ptr<Core::DeviceMemory> device_memory;
406 KProcessPtr main_process{nullptr, KProcessDeleter};
407 Core::Memory::Memory memory; 393 Core::Memory::Memory memory;
408 CpuManager cpu_manager; 394 CpuManager cpu_manager;
409 std::atomic_bool is_powered_on{}; 395 std::atomic_bool is_powered_on{};
@@ -653,6 +639,10 @@ const Core::SpeedLimiter& System::SpeedLimiter() const {
653 return impl->speed_limiter; 639 return impl->speed_limiter;
654} 640}
655 641
642u64 System::GetCurrentProcessProgramID() const {
643 return impl->kernel.CurrentProcess()->GetProgramID();
644}
645
656Loader::ResultStatus System::GetGameName(std::string& out) const { 646Loader::ResultStatus System::GetGameName(std::string& out) const {
657 return impl->GetGameName(out); 647 return impl->GetGameName(out);
658} 648}
diff --git a/src/core/core.h b/src/core/core.h
index 1cfe1bba6..01bc0a2c7 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -297,6 +297,8 @@ public:
297 /// Provides a constant reference to the speed limiter 297 /// Provides a constant reference to the speed limiter
298 [[nodiscard]] const Core::SpeedLimiter& SpeedLimiter() const; 298 [[nodiscard]] const Core::SpeedLimiter& SpeedLimiter() const;
299 299
300 [[nodiscard]] u64 GetCurrentProcessProgramID() const;
301
300 /// Gets the name of the current game 302 /// Gets the name of the current game
301 [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const; 303 [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const;
302 304
diff --git a/src/core/core_timing.h b/src/core/core_timing.h
index b64caacda..888828fd0 100644
--- a/src/core/core_timing.h
+++ b/src/core/core_timing.h
@@ -8,7 +8,6 @@
8#include <chrono> 8#include <chrono>
9#include <functional> 9#include <functional>
10#include <memory> 10#include <memory>
11#include <mutex>
12#include <optional> 11#include <optional>
13#include <string> 12#include <string>
14#include <thread> 13#include <thread>
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp
index 77efcabf0..5d43c6e5d 100644
--- a/src/core/cpu_manager.cpp
+++ b/src/core/cpu_manager.cpp
@@ -6,7 +6,6 @@
6#include "common/microprofile.h" 6#include "common/microprofile.h"
7#include "common/scope_exit.h" 7#include "common/scope_exit.h"
8#include "common/thread.h" 8#include "common/thread.h"
9#include "core/arm/exclusive_monitor.h"
10#include "core/core.h" 9#include "core/core.h"
11#include "core/core_timing.h" 10#include "core/core_timing.h"
12#include "core/cpu_manager.h" 11#include "core/cpu_manager.h"
diff --git a/src/core/crypto/ctr_encryption_layer.cpp b/src/core/crypto/ctr_encryption_layer.cpp
index 1231da8e3..3a2af4f50 100644
--- a/src/core/crypto/ctr_encryption_layer.cpp
+++ b/src/core/crypto/ctr_encryption_layer.cpp
@@ -4,7 +4,6 @@
4 4
5#include <algorithm> 5#include <algorithm>
6#include <cstring> 6#include <cstring>
7#include "common/assert.h"
8#include "core/crypto/ctr_encryption_layer.h" 7#include "core/crypto/ctr_encryption_layer.h"
9 8
10namespace Core::Crypto { 9namespace Core::Crypto {
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp
index a98daed89..9244907b5 100644
--- a/src/core/crypto/key_manager.cpp
+++ b/src/core/crypto/key_manager.cpp
@@ -10,14 +10,12 @@
10#include <locale> 10#include <locale>
11#include <map> 11#include <map>
12#include <sstream> 12#include <sstream>
13#include <string_view>
14#include <tuple> 13#include <tuple>
15#include <vector> 14#include <vector>
16#include <mbedtls/bignum.h> 15#include <mbedtls/bignum.h>
17#include <mbedtls/cipher.h> 16#include <mbedtls/cipher.h>
18#include <mbedtls/cmac.h> 17#include <mbedtls/cmac.h>
19#include <mbedtls/sha256.h> 18#include <mbedtls/sha256.h>
20#include "common/common_funcs.h"
21#include "common/fs/file.h" 19#include "common/fs/file.h"
22#include "common/fs/fs.h" 20#include "common/fs/fs.h"
23#include "common/fs/path_util.h" 21#include "common/fs/path_util.h"
@@ -30,7 +28,6 @@
30#include "core/crypto/partition_data_manager.h" 28#include "core/crypto/partition_data_manager.h"
31#include "core/file_sys/content_archive.h" 29#include "core/file_sys/content_archive.h"
32#include "core/file_sys/nca_metadata.h" 30#include "core/file_sys/nca_metadata.h"
33#include "core/file_sys/partition_filesystem.h"
34#include "core/file_sys/registered_cache.h" 31#include "core/file_sys/registered_cache.h"
35#include "core/hle/service/filesystem/filesystem.h" 32#include "core/hle/service/filesystem/filesystem.h"
36#include "core/loader/loader.h" 33#include "core/loader/loader.h"
diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h
index e771625e1..ac1eb8962 100644
--- a/src/core/crypto/key_manager.h
+++ b/src/core/crypto/key_manager.h
@@ -15,7 +15,6 @@
15#include "common/common_funcs.h" 15#include "common/common_funcs.h"
16#include "common/common_types.h" 16#include "common/common_types.h"
17#include "core/crypto/partition_data_manager.h" 17#include "core/crypto/partition_data_manager.h"
18#include "core/file_sys/vfs_types.h"
19 18
20namespace Common::FS { 19namespace Common::FS {
21class IOFile; 20class IOFile;
diff --git a/src/core/crypto/partition_data_manager.cpp b/src/core/crypto/partition_data_manager.cpp
index 5f1c86a09..d18252a54 100644
--- a/src/core/crypto/partition_data_manager.cpp
+++ b/src/core/crypto/partition_data_manager.cpp
@@ -12,7 +12,6 @@
12#include <cctype> 12#include <cctype>
13#include <cstring> 13#include <cstring>
14#include <mbedtls/sha256.h> 14#include <mbedtls/sha256.h>
15#include "common/assert.h"
16#include "common/common_funcs.h" 15#include "common/common_funcs.h"
17#include "common/common_types.h" 16#include "common/common_types.h"
18#include "common/hex_util.h" 17#include "common/hex_util.h"
diff --git a/src/core/crypto/xts_encryption_layer.cpp b/src/core/crypto/xts_encryption_layer.cpp
index 8f0ba4ee7..c2b7ea309 100644
--- a/src/core/crypto/xts_encryption_layer.cpp
+++ b/src/core/crypto/xts_encryption_layer.cpp
@@ -4,7 +4,6 @@
4 4
5#include <algorithm> 5#include <algorithm>
6#include <cstring> 6#include <cstring>
7#include "common/assert.h"
8#include "core/crypto/xts_encryption_layer.h" 7#include "core/crypto/xts_encryption_layer.h"
9 8
10namespace Core::Crypto { 9namespace Core::Crypto {
diff --git a/src/core/file_sys/card_image.cpp b/src/core/file_sys/card_image.cpp
index 755d3303e..c6300be59 100644
--- a/src/core/file_sys/card_image.cpp
+++ b/src/core/file_sys/card_image.cpp
@@ -14,7 +14,6 @@
14#include "core/file_sys/nca_metadata.h" 14#include "core/file_sys/nca_metadata.h"
15#include "core/file_sys/partition_filesystem.h" 15#include "core/file_sys/partition_filesystem.h"
16#include "core/file_sys/submission_package.h" 16#include "core/file_sys/submission_package.h"
17#include "core/file_sys/vfs_concat.h"
18#include "core/file_sys/vfs_offset.h" 17#include "core/file_sys/vfs_offset.h"
19#include "core/file_sys/vfs_vector.h" 18#include "core/file_sys/vfs_vector.h"
20#include "core/loader/loader.h" 19#include "core/loader/loader.h"
diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h
index af2b723df..3e0b45630 100644
--- a/src/core/file_sys/control_metadata.h
+++ b/src/core/file_sys/control_metadata.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include <memory>
9#include <string> 8#include <string>
10#include "common/common_funcs.h" 9#include "common/common_funcs.h"
11#include "common/common_types.h" 10#include "common/common_types.h"
diff --git a/src/core/file_sys/directory.h b/src/core/file_sys/directory.h
index 0d73eecc9..21c7aefc8 100644
--- a/src/core/file_sys/directory.h
+++ b/src/core/file_sys/directory.h
@@ -6,7 +6,6 @@
6 6
7#include <cstddef> 7#include <cstddef>
8#include <iterator> 8#include <iterator>
9#include <string_view>
10#include "common/common_funcs.h" 9#include "common/common_funcs.h"
11#include "common/common_types.h" 10#include "common/common_types.h"
12 11
diff --git a/src/core/file_sys/nca_metadata.h b/src/core/file_sys/nca_metadata.h
index ce1138a17..75c74ae28 100644
--- a/src/core/file_sys/nca_metadata.h
+++ b/src/core/file_sys/nca_metadata.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include <memory>
9#include <vector> 8#include <vector>
10#include "common/common_funcs.h" 9#include "common/common_funcs.h"
11#include "common/common_types.h" 10#include "common/common_types.h"
diff --git a/src/core/file_sys/program_metadata.cpp b/src/core/file_sys/program_metadata.cpp
index 35a53d36c..4e46c24cf 100644
--- a/src/core/file_sys/program_metadata.cpp
+++ b/src/core/file_sys/program_metadata.cpp
@@ -53,13 +53,16 @@ Loader::ResultStatus ProgramMetadata::Load(VirtualFile file) {
53} 53}
54 54
55/*static*/ ProgramMetadata ProgramMetadata::GetDefault() { 55/*static*/ ProgramMetadata ProgramMetadata::GetDefault() {
56 // Allow use of cores 0~3 and thread priorities 1~63.
57 constexpr u32 default_thread_info_capability = 0x30007F7;
58
56 ProgramMetadata result; 59 ProgramMetadata result;
57 60
58 result.LoadManual( 61 result.LoadManual(
59 true /*is_64_bit*/, FileSys::ProgramAddressSpaceType::Is39Bit /*address_space*/, 62 true /*is_64_bit*/, FileSys::ProgramAddressSpaceType::Is39Bit /*address_space*/,
60 0x2c /*main_thread_prio*/, 0 /*main_thread_core*/, 0x00100000 /*main_thread_stack_size*/, 63 0x2c /*main_thread_prio*/, 0 /*main_thread_core*/, 0x00100000 /*main_thread_stack_size*/,
61 0 /*title_id*/, 0xFFFFFFFFFFFFFFFF /*filesystem_permissions*/, 64 0 /*title_id*/, 0xFFFFFFFFFFFFFFFF /*filesystem_permissions*/,
62 0x1FE00000 /*system_resource_size*/, {} /*capabilities*/); 65 0x1FE00000 /*system_resource_size*/, {default_thread_info_capability} /*capabilities*/);
63 66
64 return result; 67 return result;
65} 68}
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp
index 638c6cea8..291b746b6 100644
--- a/src/core/file_sys/romfs_factory.cpp
+++ b/src/core/file_sys/romfs_factory.cpp
@@ -6,7 +6,6 @@
6#include "common/assert.h" 6#include "common/assert.h"
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/logging/log.h" 8#include "common/logging/log.h"
9#include "core/file_sys/card_image.h"
10#include "core/file_sys/common_funcs.h" 9#include "core/file_sys/common_funcs.h"
11#include "core/file_sys/content_archive.h" 10#include "core/file_sys/content_archive.h"
12#include "core/file_sys/nca_metadata.h" 11#include "core/file_sys/nca_metadata.h"
@@ -39,13 +38,12 @@ void RomFSFactory::SetPackedUpdate(VirtualFile update_raw_file) {
39 38
40ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess(u64 current_process_title_id) const { 39ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess(u64 current_process_title_id) const {
41 if (!updatable) { 40 if (!updatable) {
42 return MakeResult<VirtualFile>(file); 41 return file;
43 } 42 }
44 43
45 const PatchManager patch_manager{current_process_title_id, filesystem_controller, 44 const PatchManager patch_manager{current_process_title_id, filesystem_controller,
46 content_provider}; 45 content_provider};
47 return MakeResult<VirtualFile>( 46 return patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw);
48 patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw));
49} 47}
50 48
51ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFS(u64 title_id, ContentRecordType type) const { 49ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFS(u64 title_id, ContentRecordType type) const {
@@ -58,8 +56,7 @@ ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFS(u64 title_id, ContentRecor
58 56
59 const PatchManager patch_manager{title_id, filesystem_controller, content_provider}; 57 const PatchManager patch_manager{title_id, filesystem_controller, content_provider};
60 58
61 return MakeResult<VirtualFile>( 59 return patch_manager.PatchRomFS(nca->GetRomFS(), nca->GetBaseIVFCOffset(), type);
62 patch_manager.PatchRomFS(nca->GetRomFS(), nca->GetBaseIVFCOffset(), type));
63} 60}
64 61
65ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFSWithProgramIndex( 62ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFSWithProgramIndex(
@@ -83,7 +80,7 @@ ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage,
83 return ResultUnknown; 80 return ResultUnknown;
84 } 81 }
85 82
86 return MakeResult<VirtualFile>(romfs); 83 return romfs;
87} 84}
88 85
89std::shared_ptr<NCA> RomFSFactory::GetEntry(u64 title_id, StorageId storage, 86std::shared_ptr<NCA> RomFSFactory::GetEntry(u64 title_id, StorageId storage,
diff --git a/src/core/file_sys/romfs_factory.h b/src/core/file_sys/romfs_factory.h
index 39db09e4e..2c93a49a5 100644
--- a/src/core/file_sys/romfs_factory.h
+++ b/src/core/file_sys/romfs_factory.h
@@ -5,8 +5,9 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8
8#include "common/common_types.h" 9#include "common/common_types.h"
9#include "core/file_sys/vfs.h" 10#include "core/file_sys/vfs_types.h"
10#include "core/hle/result.h" 11#include "core/hle/result.h"
11 12
12namespace Loader { 13namespace Loader {
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp
index b5254dd75..e6f8514c9 100644
--- a/src/core/file_sys/savedata_factory.cpp
+++ b/src/core/file_sys/savedata_factory.cpp
@@ -9,7 +9,6 @@
9#include "core/core.h" 9#include "core/core.h"
10#include "core/file_sys/savedata_factory.h" 10#include "core/file_sys/savedata_factory.h"
11#include "core/file_sys/vfs.h" 11#include "core/file_sys/vfs.h"
12#include "core/hle/kernel/k_process.h"
13 12
14namespace FileSys { 13namespace FileSys {
15 14
@@ -94,7 +93,7 @@ ResultVal<VirtualDir> SaveDataFactory::Create(SaveDataSpaceId space,
94 return ResultUnknown; 93 return ResultUnknown;
95 } 94 }
96 95
97 return MakeResult<VirtualDir>(std::move(out)); 96 return out;
98} 97}
99 98
100ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, 99ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space,
@@ -115,7 +114,7 @@ ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space,
115 return ResultUnknown; 114 return ResultUnknown;
116 } 115 }
117 116
118 return MakeResult<VirtualDir>(std::move(out)); 117 return out;
119} 118}
120 119
121VirtualDir SaveDataFactory::GetSaveDataSpaceDirectory(SaveDataSpaceId space) const { 120VirtualDir SaveDataFactory::GetSaveDataSpaceDirectory(SaveDataSpaceId space) const {
@@ -143,7 +142,7 @@ std::string SaveDataFactory::GetFullPath(Core::System& system, SaveDataSpaceId s
143 // be interpreted as the title id of the current process. 142 // be interpreted as the title id of the current process.
144 if (type == SaveDataType::SaveData || type == SaveDataType::DeviceSaveData) { 143 if (type == SaveDataType::SaveData || type == SaveDataType::DeviceSaveData) {
145 if (title_id == 0) { 144 if (title_id == 0) {
146 title_id = system.CurrentProcess()->GetTitleID(); 145 title_id = system.GetCurrentProcessProgramID();
147 } 146 }
148 } 147 }
149 148
diff --git a/src/core/file_sys/savedata_factory.h b/src/core/file_sys/savedata_factory.h
index 1d8dc981f..de415b0c4 100644
--- a/src/core/file_sys/savedata_factory.h
+++ b/src/core/file_sys/savedata_factory.h
@@ -8,7 +8,6 @@
8#include <string> 8#include <string>
9#include "common/common_funcs.h" 9#include "common/common_funcs.h"
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "common/swap.h"
12#include "core/file_sys/vfs.h" 11#include "core/file_sys/vfs.h"
13#include "core/hle/result.h" 12#include "core/hle/result.h"
14 13
diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp
index e5c72cd4d..c0e13e56f 100644
--- a/src/core/file_sys/sdmc_factory.cpp
+++ b/src/core/file_sys/sdmc_factory.cpp
@@ -25,7 +25,7 @@ SDMCFactory::SDMCFactory(VirtualDir sd_dir_, VirtualDir sd_mod_dir_)
25SDMCFactory::~SDMCFactory() = default; 25SDMCFactory::~SDMCFactory() = default;
26 26
27ResultVal<VirtualDir> SDMCFactory::Open() const { 27ResultVal<VirtualDir> SDMCFactory::Open() const {
28 return MakeResult<VirtualDir>(sd_dir); 28 return sd_dir;
29} 29}
30 30
31VirtualDir SDMCFactory::GetSDMCModificationLoadRoot(u64 title_id) const { 31VirtualDir SDMCFactory::GetSDMCModificationLoadRoot(u64 title_id) const {
diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp
index f192dffa5..f03124e3d 100644
--- a/src/core/file_sys/submission_package.cpp
+++ b/src/core/file_sys/submission_package.cpp
@@ -4,7 +4,6 @@
4 4
5#include <algorithm> 5#include <algorithm>
6#include <cstring> 6#include <cstring>
7#include <string_view>
8 7
9#include <fmt/ostream.h> 8#include <fmt/ostream.h>
10 9
diff --git a/src/core/file_sys/system_archive/time_zone_binary.h b/src/core/file_sys/system_archive/time_zone_binary.h
index ed2b78227..266c23537 100644
--- a/src/core/file_sys/system_archive/time_zone_binary.h
+++ b/src/core/file_sys/system_archive/time_zone_binary.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <string>
8#include "core/file_sys/vfs_types.h" 7#include "core/file_sys/vfs_types.h"
9 8
10namespace FileSys::SystemArchive { 9namespace FileSys::SystemArchive {
diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h
index ff6935da6..3e625fad6 100644
--- a/src/core/file_sys/vfs.h
+++ b/src/core/file_sys/vfs.h
@@ -9,7 +9,6 @@
9#include <memory> 9#include <memory>
10#include <optional> 10#include <optional>
11#include <string> 11#include <string>
12#include <string_view>
13#include <type_traits> 12#include <type_traits>
14#include <vector> 13#include <vector>
15 14
diff --git a/src/core/file_sys/vfs_concat.h b/src/core/file_sys/vfs_concat.h
index cd32960a5..bd091451e 100644
--- a/src/core/file_sys/vfs_concat.h
+++ b/src/core/file_sys/vfs_concat.h
@@ -6,7 +6,6 @@
6 6
7#include <map> 7#include <map>
8#include <memory> 8#include <memory>
9#include <string_view>
10#include "core/file_sys/vfs.h" 9#include "core/file_sys/vfs.h"
11 10
12namespace FileSys { 11namespace FileSys {
diff --git a/src/core/file_sys/vfs_offset.h b/src/core/file_sys/vfs_offset.h
index 42f78b3d9..7ce1eb336 100644
--- a/src/core/file_sys/vfs_offset.h
+++ b/src/core/file_sys/vfs_offset.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8#include <string_view>
9 8
10#include "core/file_sys/vfs.h" 9#include "core/file_sys/vfs.h"
11 10
diff --git a/src/core/frontend/applets/general_frontend.h b/src/core/frontend/applets/general_frontend.h
index b713b14ee..1647aa975 100644
--- a/src/core/frontend/applets/general_frontend.h
+++ b/src/core/frontend/applets/general_frontend.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <functional> 7#include <functional>
8#include <optional>
9#include "common/common_types.h" 8#include "common/common_types.h"
10 9
11namespace Core::Frontend { 10namespace Core::Frontend {
diff --git a/src/core/frontend/applets/software_keyboard.cpp b/src/core/frontend/applets/software_keyboard.cpp
index 12c76c9ee..c4863ee73 100644
--- a/src/core/frontend/applets/software_keyboard.cpp
+++ b/src/core/frontend/applets/software_keyboard.cpp
@@ -16,7 +16,8 @@ DefaultSoftwareKeyboardApplet::~DefaultSoftwareKeyboardApplet() = default;
16 16
17void DefaultSoftwareKeyboardApplet::InitializeKeyboard( 17void DefaultSoftwareKeyboardApplet::InitializeKeyboard(
18 bool is_inline, KeyboardInitializeParameters initialize_parameters, 18 bool is_inline, KeyboardInitializeParameters initialize_parameters,
19 std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> submit_normal_callback_, 19 std::function<void(Service::AM::Applets::SwkbdResult, std::u16string, bool)>
20 submit_normal_callback_,
20 std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> 21 std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)>
21 submit_inline_callback_) { 22 submit_inline_callback_) {
22 if (is_inline) { 23 if (is_inline) {
@@ -128,7 +129,7 @@ void DefaultSoftwareKeyboardApplet::ExitKeyboard() const {
128} 129}
129 130
130void DefaultSoftwareKeyboardApplet::SubmitNormalText(std::u16string text) const { 131void DefaultSoftwareKeyboardApplet::SubmitNormalText(std::u16string text) const {
131 submit_normal_callback(Service::AM::Applets::SwkbdResult::Ok, text); 132 submit_normal_callback(Service::AM::Applets::SwkbdResult::Ok, text, true);
132} 133}
133 134
134void DefaultSoftwareKeyboardApplet::SubmitInlineText(std::u16string_view text) const { 135void DefaultSoftwareKeyboardApplet::SubmitInlineText(std::u16string_view text) const {
diff --git a/src/core/frontend/applets/software_keyboard.h b/src/core/frontend/applets/software_keyboard.h
index 228a548d4..490c55cc2 100644
--- a/src/core/frontend/applets/software_keyboard.h
+++ b/src/core/frontend/applets/software_keyboard.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <functional> 7#include <functional>
8#include <thread>
9 8
10#include "common/common_types.h" 9#include "common/common_types.h"
11 10
@@ -58,7 +57,7 @@ public:
58 57
59 virtual void InitializeKeyboard( 58 virtual void InitializeKeyboard(
60 bool is_inline, KeyboardInitializeParameters initialize_parameters, 59 bool is_inline, KeyboardInitializeParameters initialize_parameters,
61 std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> 60 std::function<void(Service::AM::Applets::SwkbdResult, std::u16string, bool)>
62 submit_normal_callback_, 61 submit_normal_callback_,
63 std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> 62 std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)>
64 submit_inline_callback_) = 0; 63 submit_inline_callback_) = 0;
@@ -83,7 +82,7 @@ public:
83 82
84 void InitializeKeyboard( 83 void InitializeKeyboard(
85 bool is_inline, KeyboardInitializeParameters initialize_parameters, 84 bool is_inline, KeyboardInitializeParameters initialize_parameters,
86 std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> 85 std::function<void(Service::AM::Applets::SwkbdResult, std::u16string, bool)>
87 submit_normal_callback_, 86 submit_normal_callback_,
88 std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> 87 std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)>
89 submit_inline_callback_) override; 88 submit_inline_callback_) override;
@@ -107,7 +106,7 @@ private:
107 106
108 KeyboardInitializeParameters parameters; 107 KeyboardInitializeParameters parameters;
109 108
110 mutable std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> 109 mutable std::function<void(Service::AM::Applets::SwkbdResult, std::u16string, bool)>
111 submit_normal_callback; 110 submit_normal_callback;
112 mutable std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> 111 mutable std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)>
113 submit_inline_callback; 112 submit_inline_callback;
diff --git a/src/core/frontend/applets/web_browser.h b/src/core/frontend/applets/web_browser.h
index 915dde677..b6a60c994 100644
--- a/src/core/frontend/applets/web_browser.h
+++ b/src/core/frontend/applets/web_browser.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <functional> 7#include <functional>
8#include <string_view>
9 8
10#include "core/hle/service/am/applets/applet_web_browser_types.h" 9#include "core/hle/service/am/applets/applet_web_browser_types.h"
11 10
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp
index e11ec0b0b..e1f7e5886 100644
--- a/src/core/frontend/emu_window.cpp
+++ b/src/core/frontend/emu_window.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cmath>
6#include <mutex> 5#include <mutex>
7#include "common/settings.h" 6#include "common/settings.h"
8#include "core/frontend/emu_window.h" 7#include "core/frontend/emu_window.h"
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h
index 076148698..8a86a1d27 100644
--- a/src/core/frontend/emu_window.h
+++ b/src/core/frontend/emu_window.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8#include <tuple>
9#include <utility> 8#include <utility>
10#include "common/common_types.h" 9#include "common/common_types.h"
11#include "core/frontend/framebuffer_layout.h" 10#include "core/frontend/framebuffer_layout.h"
diff --git a/src/core/hle/kernel/board/nintendo/nx/secure_monitor.h b/src/core/hle/kernel/board/nintendo/nx/secure_monitor.h
index 0c366b252..f77a91dec 100644
--- a/src/core/hle/kernel/board/nintendo/nx/secure_monitor.h
+++ b/src/core/hle/kernel/board/nintendo/nx/secure_monitor.h
@@ -4,8 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common_types.h"
8
9namespace Kernel::Board::Nintendo::Nx::Smc { 7namespace Kernel::Board::Nintendo::Nx::Smc {
10 8
11enum MemorySize { 9enum MemorySize {
diff --git a/src/core/hle/kernel/code_set.h b/src/core/hle/kernel/code_set.h
index d8ad54030..5cc3b9829 100644
--- a/src/core/hle/kernel/code_set.h
+++ b/src/core/hle/kernel/code_set.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <cstddef> 7#include <cstddef>
8#include <vector>
9 8
10#include "common/common_types.h" 9#include "common/common_types.h"
11#include "core/hle/kernel/physical_memory.h" 10#include "core/hle/kernel/physical_memory.h"
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index cee96dd9b..e19544c54 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -5,7 +5,6 @@
5#include <algorithm> 5#include <algorithm>
6#include <array> 6#include <array>
7#include <sstream> 7#include <sstream>
8#include <utility>
9 8
10#include <boost/range/algorithm_ext/erase.hpp> 9#include <boost/range/algorithm_ext/erase.hpp>
11 10
@@ -19,14 +18,9 @@
19#include "core/hle/kernel/k_handle_table.h" 18#include "core/hle/kernel/k_handle_table.h"
20#include "core/hle/kernel/k_process.h" 19#include "core/hle/kernel/k_process.h"
21#include "core/hle/kernel/k_readable_event.h" 20#include "core/hle/kernel/k_readable_event.h"
22#include "core/hle/kernel/k_scheduler.h"
23#include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h"
24#include "core/hle/kernel/k_server_session.h" 21#include "core/hle/kernel/k_server_session.h"
25#include "core/hle/kernel/k_thread.h" 22#include "core/hle/kernel/k_thread.h"
26#include "core/hle/kernel/k_writable_event.h"
27#include "core/hle/kernel/kernel.h" 23#include "core/hle/kernel/kernel.h"
28#include "core/hle/kernel/svc_results.h"
29#include "core/hle/kernel/time_manager.h"
30#include "core/memory.h" 24#include "core/memory.h"
31 25
32namespace Kernel { 26namespace Kernel {
diff --git a/src/core/hle/kernel/init/init_slab_setup.cpp b/src/core/hle/kernel/init/init_slab_setup.cpp
index 10edede17..8ff0f695d 100644
--- a/src/core/hle/kernel/init/init_slab_setup.cpp
+++ b/src/core/hle/kernel/init/init_slab_setup.cpp
@@ -20,8 +20,6 @@
20#include "core/hle/kernel/k_system_control.h" 20#include "core/hle/kernel/k_system_control.h"
21#include "core/hle/kernel/k_thread.h" 21#include "core/hle/kernel/k_thread.h"
22#include "core/hle/kernel/k_transfer_memory.h" 22#include "core/hle/kernel/k_transfer_memory.h"
23#include "core/hle/kernel/memory_types.h"
24#include "core/memory.h"
25 23
26namespace Kernel::Init { 24namespace Kernel::Init {
27 25
diff --git a/src/core/hle/kernel/k_auto_object_container.h b/src/core/hle/kernel/k_auto_object_container.h
index 459953450..4eadfe99d 100644
--- a/src/core/hle/kernel/k_auto_object_container.h
+++ b/src/core/hle/kernel/k_auto_object_container.h
@@ -4,14 +4,9 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <atomic>
8
9#include <boost/intrusive/rbtree.hpp> 7#include <boost/intrusive/rbtree.hpp>
10 8
11#include "common/assert.h"
12#include "common/common_funcs.h" 9#include "common/common_funcs.h"
13#include "common/common_types.h"
14#include "common/intrusive_red_black_tree.h"
15#include "core/hle/kernel/k_auto_object.h" 10#include "core/hle/kernel/k_auto_object.h"
16#include "core/hle/kernel/k_light_lock.h" 11#include "core/hle/kernel/k_light_lock.h"
17 12
diff --git a/src/core/hle/kernel/k_class_token.h b/src/core/hle/kernel/k_class_token.h
index c28db49ec..980010150 100644
--- a/src/core/hle/kernel/k_class_token.h
+++ b/src/core/hle/kernel/k_class_token.h
@@ -6,7 +6,6 @@
6 6
7#include <atomic> 7#include <atomic>
8 8
9#include "common/assert.h"
10#include "common/bit_util.h" 9#include "common/bit_util.h"
11#include "common/common_types.h" 10#include "common/common_types.h"
12 11
diff --git a/src/core/hle/kernel/k_client_session.cpp b/src/core/hle/kernel/k_client_session.cpp
index 8ad1be762..242582f8f 100644
--- a/src/core/hle/kernel/k_client_session.cpp
+++ b/src/core/hle/kernel/k_client_session.cpp
@@ -7,7 +7,6 @@
7#include "core/hle/kernel/k_server_session.h" 7#include "core/hle/kernel/k_server_session.h"
8#include "core/hle/kernel/k_session.h" 8#include "core/hle/kernel/k_session.h"
9#include "core/hle/kernel/k_thread.h" 9#include "core/hle/kernel/k_thread.h"
10#include "core/hle/kernel/svc_results.h"
11#include "core/hle/result.h" 10#include "core/hle/result.h"
12 11
13namespace Kernel { 12namespace Kernel {
diff --git a/src/core/hle/kernel/k_client_session.h b/src/core/hle/kernel/k_client_session.h
index 230e3b6b8..ad6cc4ed1 100644
--- a/src/core/hle/kernel/k_client_session.h
+++ b/src/core/hle/kernel/k_client_session.h
@@ -4,11 +4,9 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
8#include <string> 7#include <string>
9 8
10#include "core/hle/kernel/k_auto_object.h" 9#include "core/hle/kernel/k_auto_object.h"
11#include "core/hle/kernel/k_synchronization_object.h"
12#include "core/hle/kernel/slab_helpers.h" 10#include "core/hle/kernel/slab_helpers.h"
13#include "core/hle/result.h" 11#include "core/hle/result.h"
14 12
diff --git a/src/core/hle/kernel/k_condition_variable.cpp b/src/core/hle/kernel/k_condition_variable.cpp
index ef14ad1d2..7fa9b8cc3 100644
--- a/src/core/hle/kernel/k_condition_variable.cpp
+++ b/src/core/hle/kernel/k_condition_variable.cpp
@@ -2,8 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <vector>
6
7#include "core/arm/exclusive_monitor.h" 5#include "core/arm/exclusive_monitor.h"
8#include "core/core.h" 6#include "core/core.h"
9#include "core/hle/kernel/k_condition_variable.h" 7#include "core/hle/kernel/k_condition_variable.h"
diff --git a/src/core/hle/kernel/k_handle_table.cpp b/src/core/hle/kernel/k_handle_table.cpp
index 44d13169f..e90fc0628 100644
--- a/src/core/hle/kernel/k_handle_table.cpp
+++ b/src/core/hle/kernel/k_handle_table.cpp
@@ -56,6 +56,7 @@ bool KHandleTable::Remove(Handle handle) {
56 } 56 }
57 57
58 // Close the object. 58 // Close the object.
59 kernel.UnregisterInUseObject(obj);
59 obj->Close(); 60 obj->Close();
60 return true; 61 return true;
61} 62}
diff --git a/src/core/hle/kernel/k_handle_table.h b/src/core/hle/kernel/k_handle_table.h
index 2ff6aa160..95ec905ae 100644
--- a/src/core/hle/kernel/k_handle_table.h
+++ b/src/core/hle/kernel/k_handle_table.h
@@ -8,7 +8,6 @@
8 8
9#include "common/assert.h" 9#include "common/assert.h"
10#include "common/bit_field.h" 10#include "common/bit_field.h"
11#include "common/bit_util.h"
12#include "common/common_types.h" 11#include "common/common_types.h"
13#include "core/hle/kernel/k_auto_object.h" 12#include "core/hle/kernel/k_auto_object.h"
14#include "core/hle/kernel/k_spin_lock.h" 13#include "core/hle/kernel/k_spin_lock.h"
diff --git a/src/core/hle/kernel/k_light_condition_variable.h b/src/core/hle/kernel/k_light_condition_variable.h
index a95fa41f3..fb0ad783a 100644
--- a/src/core/hle/kernel/k_light_condition_variable.h
+++ b/src/core/hle/kernel/k_light_condition_variable.h
@@ -10,7 +10,6 @@
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "core/hle/kernel/k_scheduler.h" 11#include "core/hle/kernel/k_scheduler.h"
12#include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" 12#include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h"
13#include "core/hle/kernel/k_thread_queue.h"
14#include "core/hle/kernel/time_manager.h" 13#include "core/hle/kernel/time_manager.h"
15 14
16namespace Kernel { 15namespace Kernel {
diff --git a/src/core/hle/kernel/k_light_lock.h b/src/core/hle/kernel/k_light_lock.h
index f4c45f76a..ad853661d 100644
--- a/src/core/hle/kernel/k_light_lock.h
+++ b/src/core/hle/kernel/k_light_lock.h
@@ -6,7 +6,6 @@
6 6
7#include <atomic> 7#include <atomic>
8 8
9#include "common/common_types.h"
10#include "core/hle/kernel/k_scoped_lock.h" 9#include "core/hle/kernel/k_scoped_lock.h"
11 10
12namespace Kernel { 11namespace Kernel {
diff --git a/src/core/hle/kernel/k_memory_manager.h b/src/core/hle/kernel/k_memory_manager.h
index ac840b3d0..39badc5f1 100644
--- a/src/core/hle/kernel/k_memory_manager.h
+++ b/src/core/hle/kernel/k_memory_manager.h
@@ -8,7 +8,6 @@
8#include <mutex> 8#include <mutex>
9#include <tuple> 9#include <tuple>
10 10
11#include "common/common_funcs.h"
12#include "common/common_types.h" 11#include "common/common_types.h"
13#include "core/hle/kernel/k_page_heap.h" 12#include "core/hle/kernel/k_page_heap.h"
14#include "core/hle/result.h" 13#include "core/hle/result.h"
diff --git a/src/core/hle/kernel/k_page_heap.cpp b/src/core/hle/kernel/k_page_heap.cpp
index 07e062922..29d996d62 100644
--- a/src/core/hle/kernel/k_page_heap.cpp
+++ b/src/core/hle/kernel/k_page_heap.cpp
@@ -4,7 +4,6 @@
4 4
5#include "core/core.h" 5#include "core/core.h"
6#include "core/hle/kernel/k_page_heap.h" 6#include "core/hle/kernel/k_page_heap.h"
7#include "core/memory.h"
8 7
9namespace Kernel { 8namespace Kernel {
10 9
diff --git a/src/core/hle/kernel/k_page_heap.h b/src/core/hle/kernel/k_page_heap.h
index de5d6a189..8d9f30523 100644
--- a/src/core/hle/kernel/k_page_heap.h
+++ b/src/core/hle/kernel/k_page_heap.h
@@ -5,12 +5,9 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include <bit>
9#include <vector> 8#include <vector>
10 9
11#include "common/alignment.h" 10#include "common/alignment.h"
12#include "common/assert.h"
13#include "common/common_funcs.h"
14#include "common/common_types.h" 11#include "common/common_types.h"
15#include "core/hle/kernel/k_page_bitmap.h" 12#include "core/hle/kernel/k_page_bitmap.h"
16#include "core/hle/kernel/memory_types.h" 13#include "core/hle/kernel/memory_types.h"
diff --git a/src/core/hle/kernel/k_page_table.cpp b/src/core/hle/kernel/k_page_table.cpp
index 5e0b620c2..526b87241 100644
--- a/src/core/hle/kernel/k_page_table.cpp
+++ b/src/core/hle/kernel/k_page_table.cpp
@@ -859,7 +859,7 @@ ResultVal<VAddr> KPageTable::SetHeapSize(std::size_t size) {
859 current_heap_addr = heap_region_start + size; 859 current_heap_addr = heap_region_start + size;
860 } 860 }
861 861
862 return MakeResult<VAddr>(heap_region_start); 862 return heap_region_start;
863} 863}
864 864
865ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align, 865ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align,
@@ -893,7 +893,7 @@ ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages,
893 893
894 block_manager->Update(addr, needed_num_pages, state, perm); 894 block_manager->Update(addr, needed_num_pages, state, perm);
895 895
896 return MakeResult<VAddr>(addr); 896 return addr;
897} 897}
898 898
899ResultCode KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) { 899ResultCode KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) {
diff --git a/src/core/hle/kernel/k_port.h b/src/core/hle/kernel/k_port.h
index 4018ea2df..b6e4a1fcd 100644
--- a/src/core/hle/kernel/k_port.h
+++ b/src/core/hle/kernel/k_port.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
8#include <string> 7#include <string>
9 8
10#include "common/common_types.h" 9#include "common/common_types.h"
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp
index 211157ccc..76fd8c285 100644
--- a/src/core/hle/kernel/k_process.cpp
+++ b/src/core/hle/kernel/k_process.cpp
@@ -434,11 +434,6 @@ void KProcess::PrepareForTermination() {
434} 434}
435 435
436void KProcess::Finalize() { 436void KProcess::Finalize() {
437 // Release memory to the resource limit.
438 if (resource_limit != nullptr) {
439 resource_limit->Close();
440 }
441
442 // Finalize the handle table and close any open handles. 437 // Finalize the handle table and close any open handles.
443 handle_table.Finalize(); 438 handle_table.Finalize();
444 439
@@ -460,6 +455,12 @@ void KProcess::Finalize() {
460 } 455 }
461 } 456 }
462 457
458 // Release memory to the resource limit.
459 if (resource_limit != nullptr) {
460 resource_limit->Close();
461 resource_limit = nullptr;
462 }
463
463 // Perform inherited finalization. 464 // Perform inherited finalization.
464 KAutoObjectWithSlabHeapAndContainer<KProcess, KSynchronizationObject>::Finalize(); 465 KAutoObjectWithSlabHeapAndContainer<KProcess, KSynchronizationObject>::Finalize();
465} 466}
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h
index 1a53e2be7..8a8c1fcbb 100644
--- a/src/core/hle/kernel/k_process.h
+++ b/src/core/hle/kernel/k_process.h
@@ -8,7 +8,6 @@
8#include <cstddef> 8#include <cstddef>
9#include <list> 9#include <list>
10#include <string> 10#include <string>
11#include <unordered_map>
12#include <vector> 11#include <vector>
13#include "common/common_types.h" 12#include "common/common_types.h"
14#include "core/hle/kernel/k_address_arbiter.h" 13#include "core/hle/kernel/k_address_arbiter.h"
@@ -155,8 +154,8 @@ public:
155 return process_id; 154 return process_id;
156 } 155 }
157 156
158 /// Gets the title ID corresponding to this process. 157 /// Gets the program ID corresponding to this process.
159 u64 GetTitleID() const { 158 u64 GetProgramID() const {
160 return program_id; 159 return program_id;
161 } 160 }
162 161
diff --git a/src/core/hle/kernel/k_scheduler_lock.h b/src/core/hle/kernel/k_scheduler_lock.h
index 47e315555..c571f2992 100644
--- a/src/core/hle/kernel/k_scheduler_lock.h
+++ b/src/core/hle/kernel/k_scheduler_lock.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include "common/assert.h" 7#include "common/assert.h"
8#include "core/hardware_properties.h"
9#include "core/hle/kernel/k_spin_lock.h" 8#include "core/hle/kernel/k_spin_lock.h"
10#include "core/hle/kernel/k_thread.h" 9#include "core/hle/kernel/k_thread.h"
11#include "core/hle/kernel/kernel.h" 10#include "core/hle/kernel/kernel.h"
diff --git a/src/core/hle/kernel/k_scoped_lock.h b/src/core/hle/kernel/k_scoped_lock.h
index 4fb180fc6..89a7ffe49 100644
--- a/src/core/hle/kernel/k_scoped_lock.h
+++ b/src/core/hle/kernel/k_scoped_lock.h
@@ -7,7 +7,8 @@
7 7
8#pragma once 8#pragma once
9 9
10#include "common/common_types.h" 10#include <concepts>
11#include <type_traits>
11 12
12namespace Kernel { 13namespace Kernel {
13 14
diff --git a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h
index f6c75f2d9..61dc2858f 100644
--- a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h
+++ b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h
@@ -8,7 +8,6 @@
8#pragma once 8#pragma once
9 9
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "core/hle/kernel/k_handle_table.h"
12#include "core/hle/kernel/k_thread.h" 11#include "core/hle/kernel/k_thread.h"
13#include "core/hle/kernel/kernel.h" 12#include "core/hle/kernel/kernel.h"
14#include "core/hle/kernel/time_manager.h" 13#include "core/hle/kernel/time_manager.h"
diff --git a/src/core/hle/kernel/k_server_port.cpp b/src/core/hle/kernel/k_server_port.cpp
index c5dc58387..433fc98e1 100644
--- a/src/core/hle/kernel/k_server_port.cpp
+++ b/src/core/hle/kernel/k_server_port.cpp
@@ -10,7 +10,6 @@
10#include "core/hle/kernel/k_server_port.h" 10#include "core/hle/kernel/k_server_port.h"
11#include "core/hle/kernel/k_server_session.h" 11#include "core/hle/kernel/k_server_session.h"
12#include "core/hle/kernel/k_thread.h" 12#include "core/hle/kernel/k_thread.h"
13#include "core/hle/kernel/svc_results.h"
14 13
15namespace Kernel { 14namespace Kernel {
16 15
diff --git a/src/core/hle/kernel/k_server_port.h b/src/core/hle/kernel/k_server_port.h
index 67a36da40..6302d5e61 100644
--- a/src/core/hle/kernel/k_server_port.h
+++ b/src/core/hle/kernel/k_server_port.h
@@ -7,14 +7,11 @@
7#include <memory> 7#include <memory>
8#include <string> 8#include <string>
9#include <utility> 9#include <utility>
10#include <vector>
11 10
12#include <boost/intrusive/list.hpp> 11#include <boost/intrusive/list.hpp>
13 12
14#include "common/common_types.h"
15#include "core/hle/kernel/k_server_session.h" 13#include "core/hle/kernel/k_server_session.h"
16#include "core/hle/kernel/k_synchronization_object.h" 14#include "core/hle/kernel/k_synchronization_object.h"
17#include "core/hle/result.h"
18 15
19namespace Kernel { 16namespace Kernel {
20 17
diff --git a/src/core/hle/kernel/k_server_session.cpp b/src/core/hle/kernel/k_server_session.cpp
index b9f24475c..2bd53ccbd 100644
--- a/src/core/hle/kernel/k_server_session.cpp
+++ b/src/core/hle/kernel/k_server_session.cpp
@@ -14,7 +14,6 @@
14#include "core/hle/kernel/hle_ipc.h" 14#include "core/hle/kernel/hle_ipc.h"
15#include "core/hle/kernel/k_client_port.h" 15#include "core/hle/kernel/k_client_port.h"
16#include "core/hle/kernel/k_handle_table.h" 16#include "core/hle/kernel/k_handle_table.h"
17#include "core/hle/kernel/k_port.h"
18#include "core/hle/kernel/k_process.h" 17#include "core/hle/kernel/k_process.h"
19#include "core/hle/kernel/k_scheduler.h" 18#include "core/hle/kernel/k_scheduler.h"
20#include "core/hle/kernel/k_server_port.h" 19#include "core/hle/kernel/k_server_port.h"
@@ -22,6 +21,7 @@
22#include "core/hle/kernel/k_session.h" 21#include "core/hle/kernel/k_session.h"
23#include "core/hle/kernel/k_thread.h" 22#include "core/hle/kernel/k_thread.h"
24#include "core/hle/kernel/kernel.h" 23#include "core/hle/kernel/kernel.h"
24#include "core/hle/kernel/service_thread.h"
25#include "core/memory.h" 25#include "core/memory.h"
26 26
27namespace Kernel { 27namespace Kernel {
diff --git a/src/core/hle/kernel/k_server_session.h b/src/core/hle/kernel/k_server_session.h
index d44bc9d4f..5b76bf17c 100644
--- a/src/core/hle/kernel/k_server_session.h
+++ b/src/core/hle/kernel/k_server_session.h
@@ -7,14 +7,11 @@
7#include <memory> 7#include <memory>
8#include <string> 8#include <string>
9#include <utility> 9#include <utility>
10#include <vector>
11 10
12#include <boost/intrusive/list.hpp> 11#include <boost/intrusive/list.hpp>
13 12
14#include "common/threadsafe_queue.h"
15#include "core/hle/kernel/hle_ipc.h" 13#include "core/hle/kernel/hle_ipc.h"
16#include "core/hle/kernel/k_synchronization_object.h" 14#include "core/hle/kernel/k_synchronization_object.h"
17#include "core/hle/kernel/service_thread.h"
18#include "core/hle/result.h" 15#include "core/hle/result.h"
19 16
20namespace Core::Memory { 17namespace Core::Memory {
diff --git a/src/core/hle/kernel/k_session.cpp b/src/core/hle/kernel/k_session.cpp
index 940878e03..a64b56b9e 100644
--- a/src/core/hle/kernel/k_session.cpp
+++ b/src/core/hle/kernel/k_session.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/assert.h"
6#include "core/hle/kernel/k_client_port.h" 5#include "core/hle/kernel/k_client_port.h"
7#include "core/hle/kernel/k_client_session.h" 6#include "core/hle/kernel/k_client_session.h"
8#include "core/hle/kernel/k_scoped_resource_reservation.h" 7#include "core/hle/kernel/k_scoped_resource_reservation.h"
diff --git a/src/core/hle/kernel/k_shared_memory.h b/src/core/hle/kernel/k_shared_memory.h
index e9815f90b..81de36136 100644
--- a/src/core/hle/kernel/k_shared_memory.h
+++ b/src/core/hle/kernel/k_shared_memory.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
8#include <string> 7#include <string>
9 8
10#include "common/common_types.h" 9#include "common/common_types.h"
diff --git a/src/core/hle/kernel/k_shared_memory_info.h b/src/core/hle/kernel/k_shared_memory_info.h
index bf97a0184..20bc19f46 100644
--- a/src/core/hle/kernel/k_shared_memory_info.h
+++ b/src/core/hle/kernel/k_shared_memory_info.h
@@ -4,12 +4,8 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
8#include <string>
9
10#include <boost/intrusive/list.hpp> 7#include <boost/intrusive/list.hpp>
11 8
12#include "common/assert.h"
13#include "core/hle/kernel/slab_helpers.h" 9#include "core/hle/kernel/slab_helpers.h"
14 10
15namespace Kernel { 11namespace Kernel {
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp
index 9f1d3156b..db65ce79a 100644
--- a/src/core/hle/kernel/k_thread.cpp
+++ b/src/core/hle/kernel/k_thread.cpp
@@ -13,8 +13,6 @@
13#include "common/common_types.h" 13#include "common/common_types.h"
14#include "common/fiber.h" 14#include "common/fiber.h"
15#include "common/logging/log.h" 15#include "common/logging/log.h"
16#include "common/scope_exit.h"
17#include "common/thread_queue_list.h"
18#include "core/core.h" 16#include "core/core.h"
19#include "core/cpu_manager.h" 17#include "core/cpu_manager.h"
20#include "core/hardware_properties.h" 18#include "core/hardware_properties.h"
@@ -31,11 +29,9 @@
31#include "core/hle/kernel/svc_results.h" 29#include "core/hle/kernel/svc_results.h"
32#include "core/hle/kernel/time_manager.h" 30#include "core/hle/kernel/time_manager.h"
33#include "core/hle/result.h" 31#include "core/hle/result.h"
34#include "core/memory.h"
35 32
36#ifdef ARCHITECTURE_x86_64 33#ifdef ARCHITECTURE_x86_64
37#include "core/arm/dynarmic/arm_dynarmic_32.h" 34#include "core/arm/dynarmic/arm_dynarmic_32.h"
38#include "core/arm/dynarmic/arm_dynarmic_64.h"
39#endif 35#endif
40 36
41namespace { 37namespace {
diff --git a/src/core/hle/kernel/k_trace.h b/src/core/hle/kernel/k_trace.h
index 79391bccb..d3fed1888 100644
--- a/src/core/hle/kernel/k_trace.h
+++ b/src/core/hle/kernel/k_trace.h
@@ -4,8 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common_funcs.h"
8
9namespace Kernel { 7namespace Kernel {
10 8
11using namespace Common::Literals; 9using namespace Common::Literals;
diff --git a/src/core/hle/kernel/k_transfer_memory.h b/src/core/hle/kernel/k_transfer_memory.h
index 31029a5c2..cb7521823 100644
--- a/src/core/hle/kernel/k_transfer_memory.h
+++ b/src/core/hle/kernel/k_transfer_memory.h
@@ -4,8 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
8
9#include "core/hle/kernel/slab_helpers.h" 7#include "core/hle/kernel/slab_helpers.h"
10#include "core/hle/kernel/svc_types.h" 8#include "core/hle/kernel/svc_types.h"
11#include "core/hle/result.h" 9#include "core/hle/result.h"
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index bea945301..e42a6d36f 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -39,9 +39,7 @@
39#include "core/hle/kernel/kernel.h" 39#include "core/hle/kernel/kernel.h"
40#include "core/hle/kernel/physical_core.h" 40#include "core/hle/kernel/physical_core.h"
41#include "core/hle/kernel/service_thread.h" 41#include "core/hle/kernel/service_thread.h"
42#include "core/hle/kernel/svc_results.h"
43#include "core/hle/kernel/time_manager.h" 42#include "core/hle/kernel/time_manager.h"
44#include "core/hle/lock.h"
45#include "core/hle/result.h" 43#include "core/hle/result.h"
46#include "core/hle/service/sm/sm.h" 44#include "core/hle/service/sm/sm.h"
47#include "core/memory.h" 45#include "core/memory.h"
@@ -91,12 +89,6 @@ struct KernelCore::Impl {
91 } 89 }
92 90
93 void Shutdown() { 91 void Shutdown() {
94 // Shutdown all processes.
95 if (current_process) {
96 current_process->Finalize();
97 current_process->Close();
98 current_process = nullptr;
99 }
100 process_list.clear(); 92 process_list.clear();
101 93
102 // Close all open server ports. 94 // Close all open server ports.
@@ -170,6 +162,24 @@ struct KernelCore::Impl {
170 // Next host thead ID to use, 0-3 IDs represent core threads, >3 represent others 162 // Next host thead ID to use, 0-3 IDs represent core threads, >3 represent others
171 next_host_thread_id = Core::Hardware::NUM_CPU_CORES; 163 next_host_thread_id = Core::Hardware::NUM_CPU_CORES;
172 164
165 // Close kernel objects that were not freed on shutdown
166 {
167 std::lock_guard lk(registered_in_use_objects_lock);
168 if (registered_in_use_objects.size()) {
169 for (auto& object : registered_in_use_objects) {
170 object->Close();
171 }
172 registered_in_use_objects.clear();
173 }
174 }
175
176 // Shutdown all processes.
177 if (current_process) {
178 current_process->Finalize();
179 current_process->Close();
180 current_process = nullptr;
181 }
182
173 // Track kernel objects that were not freed on shutdown 183 // Track kernel objects that were not freed on shutdown
174 { 184 {
175 std::lock_guard lk(registered_objects_lock); 185 std::lock_guard lk(registered_objects_lock);
@@ -714,9 +724,11 @@ struct KernelCore::Impl {
714 std::unordered_set<KServerPort*> server_ports; 724 std::unordered_set<KServerPort*> server_ports;
715 std::unordered_set<KServerSession*> server_sessions; 725 std::unordered_set<KServerSession*> server_sessions;
716 std::unordered_set<KAutoObject*> registered_objects; 726 std::unordered_set<KAutoObject*> registered_objects;
727 std::unordered_set<KAutoObject*> registered_in_use_objects;
717 std::mutex server_ports_lock; 728 std::mutex server_ports_lock;
718 std::mutex server_sessions_lock; 729 std::mutex server_sessions_lock;
719 std::mutex registered_objects_lock; 730 std::mutex registered_objects_lock;
731 std::mutex registered_in_use_objects_lock;
720 732
721 std::unique_ptr<Core::ExclusiveMonitor> exclusive_monitor; 733 std::unique_ptr<Core::ExclusiveMonitor> exclusive_monitor;
722 std::vector<Kernel::PhysicalCore> cores; 734 std::vector<Kernel::PhysicalCore> cores;
@@ -928,6 +940,16 @@ void KernelCore::UnregisterKernelObject(KAutoObject* object) {
928 impl->registered_objects.erase(object); 940 impl->registered_objects.erase(object);
929} 941}
930 942
943void KernelCore::RegisterInUseObject(KAutoObject* object) {
944 std::lock_guard lk(impl->registered_in_use_objects_lock);
945 impl->registered_in_use_objects.insert(object);
946}
947
948void KernelCore::UnregisterInUseObject(KAutoObject* object) {
949 std::lock_guard lk(impl->registered_in_use_objects_lock);
950 impl->registered_in_use_objects.erase(object);
951}
952
931bool KernelCore::IsValidNamedPort(NamedPortTable::const_iterator port) const { 953bool KernelCore::IsValidNamedPort(NamedPortTable::const_iterator port) const {
932 return port != impl->named_ports.cend(); 954 return port != impl->named_ports.cend();
933} 955}
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index b6658b437..d2ceae950 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -204,6 +204,14 @@ public:
204 /// destroyed during the current emulation session. 204 /// destroyed during the current emulation session.
205 void UnregisterKernelObject(KAutoObject* object); 205 void UnregisterKernelObject(KAutoObject* object);
206 206
207 /// Registers kernel objects with guest in use state, this is purely for close
208 /// after emulation has been shutdown.
209 void RegisterInUseObject(KAutoObject* object);
210
211 /// Unregisters a kernel object previously registered with RegisterInUseObject when it was
212 /// destroyed during the current emulation session.
213 void UnregisterInUseObject(KAutoObject* object);
214
207 /// Determines whether or not the given port is a valid named port. 215 /// Determines whether or not the given port is a valid named port.
208 bool IsValidNamedPort(NamedPortTable::const_iterator port) const; 216 bool IsValidNamedPort(NamedPortTable::const_iterator port) const;
209 217
diff --git a/src/core/hle/kernel/physical_core.h b/src/core/hle/kernel/physical_core.h
index 901f7e3b0..16a032e89 100644
--- a/src/core/hle/kernel/physical_core.h
+++ b/src/core/hle/kernel/physical_core.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
8#include <cstddef> 7#include <cstddef>
9#include <memory> 8#include <memory>
10 9
diff --git a/src/core/hle/kernel/service_thread.cpp b/src/core/hle/kernel/service_thread.cpp
index 2ae80beca..6721b6276 100644
--- a/src/core/hle/kernel/service_thread.cpp
+++ b/src/core/hle/kernel/service_thread.cpp
@@ -9,15 +9,11 @@
9#include <vector> 9#include <vector>
10#include <queue> 10#include <queue>
11 11
12#include "common/assert.h"
13#include "common/scope_exit.h" 12#include "common/scope_exit.h"
14#include "common/thread.h" 13#include "common/thread.h"
15#include "core/core.h"
16#include "core/hle/kernel/k_session.h" 14#include "core/hle/kernel/k_session.h"
17#include "core/hle/kernel/kernel.h" 15#include "core/hle/kernel/kernel.h"
18#include "core/hle/kernel/service_thread.h" 16#include "core/hle/kernel/service_thread.h"
19#include "core/hle/lock.h"
20#include "video_core/renderer_base.h"
21 17
22namespace Kernel { 18namespace Kernel {
23 19
diff --git a/src/core/hle/kernel/slab_helpers.h b/src/core/hle/kernel/slab_helpers.h
index 0c5995db0..f1c11256e 100644
--- a/src/core/hle/kernel/slab_helpers.h
+++ b/src/core/hle/kernel/slab_helpers.h
@@ -4,16 +4,8 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <atomic>
8
9#include "common/assert.h"
10#include "common/common_funcs.h"
11#include "common/common_types.h"
12#include "common/intrusive_red_black_tree.h"
13#include "core/hle/kernel/k_auto_object.h" 7#include "core/hle/kernel/k_auto_object.h"
14#include "core/hle/kernel/k_auto_object_container.h" 8#include "core/hle/kernel/k_auto_object_container.h"
15#include "core/hle/kernel/k_light_lock.h"
16#include "core/hle/kernel/k_slab_heap.h"
17#include "core/hle/kernel/kernel.h" 9#include "core/hle/kernel/kernel.h"
18 10
19namespace Kernel { 11namespace Kernel {
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 7f38ade1c..f9d99bc51 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -13,18 +13,11 @@
13#include "common/common_funcs.h" 13#include "common/common_funcs.h"
14#include "common/fiber.h" 14#include "common/fiber.h"
15#include "common/logging/log.h" 15#include "common/logging/log.h"
16#include "common/microprofile.h"
17#include "common/scope_exit.h" 16#include "common/scope_exit.h"
18#include "common/string_util.h"
19#include "core/arm/exclusive_monitor.h"
20#include "core/core.h" 17#include "core/core.h"
21#include "core/core_timing.h" 18#include "core/core_timing.h"
22#include "core/core_timing_util.h"
23#include "core/cpu_manager.h"
24#include "core/hle/kernel/k_address_arbiter.h"
25#include "core/hle/kernel/k_client_port.h" 19#include "core/hle/kernel/k_client_port.h"
26#include "core/hle/kernel/k_client_session.h" 20#include "core/hle/kernel/k_client_session.h"
27#include "core/hle/kernel/k_condition_variable.h"
28#include "core/hle/kernel/k_event.h" 21#include "core/hle/kernel/k_event.h"
29#include "core/hle/kernel/k_handle_table.h" 22#include "core/hle/kernel/k_handle_table.h"
30#include "core/hle/kernel/k_memory_block.h" 23#include "core/hle/kernel/k_memory_block.h"
@@ -35,7 +28,6 @@
35#include "core/hle/kernel/k_resource_limit.h" 28#include "core/hle/kernel/k_resource_limit.h"
36#include "core/hle/kernel/k_scheduler.h" 29#include "core/hle/kernel/k_scheduler.h"
37#include "core/hle/kernel/k_scoped_resource_reservation.h" 30#include "core/hle/kernel/k_scoped_resource_reservation.h"
38#include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h"
39#include "core/hle/kernel/k_shared_memory.h" 31#include "core/hle/kernel/k_shared_memory.h"
40#include "core/hle/kernel/k_synchronization_object.h" 32#include "core/hle/kernel/k_synchronization_object.h"
41#include "core/hle/kernel/k_thread.h" 33#include "core/hle/kernel/k_thread.h"
@@ -47,10 +39,8 @@
47#include "core/hle/kernel/svc_results.h" 39#include "core/hle/kernel/svc_results.h"
48#include "core/hle/kernel/svc_types.h" 40#include "core/hle/kernel/svc_types.h"
49#include "core/hle/kernel/svc_wrap.h" 41#include "core/hle/kernel/svc_wrap.h"
50#include "core/hle/kernel/time_manager.h"
51#include "core/hle/lock.h" 42#include "core/hle/lock.h"
52#include "core/hle/result.h" 43#include "core/hle/result.h"
53#include "core/hle/service/service.h"
54#include "core/memory.h" 44#include "core/memory.h"
55#include "core/reporter.h" 45#include "core/reporter.h"
56 46
@@ -409,7 +399,7 @@ static ResultCode GetProcessId32(Core::System& system, u32* out_process_id_low,
409 399
410/// Wait for the given handles to synchronize, timeout after the specified nanoseconds 400/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
411static ResultCode WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, 401static ResultCode WaitSynchronization(Core::System& system, s32* index, VAddr handles_address,
412 u64 num_handles, s64 nano_seconds) { 402 s32 num_handles, s64 nano_seconds) {
413 LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, num_handles={}, nano_seconds={}", 403 LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, num_handles={}, nano_seconds={}",
414 handles_address, num_handles, nano_seconds); 404 handles_address, num_handles, nano_seconds);
415 405
@@ -427,11 +417,15 @@ static ResultCode WaitSynchronization(Core::System& system, s32* index, VAddr ha
427 R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles, 417 R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles,
428 num_handles), 418 num_handles),
429 ResultInvalidHandle); 419 ResultInvalidHandle);
420 for (const auto& obj : objs) {
421 kernel.RegisterInUseObject(obj);
422 }
430 } 423 }
431 424
432 // Ensure handles are closed when we're done. 425 // Ensure handles are closed when we're done.
433 SCOPE_EXIT({ 426 SCOPE_EXIT({
434 for (u64 i = 0; i < num_handles; ++i) { 427 for (s32 i = 0; i < num_handles; ++i) {
428 kernel.UnregisterInUseObject(objs[i]);
435 objs[i]->Close(); 429 objs[i]->Close();
436 } 430 }
437 }); 431 });
@@ -774,7 +768,7 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle
774 return ResultSuccess; 768 return ResultSuccess;
775 769
776 case GetInfoType::TitleId: 770 case GetInfoType::TitleId:
777 *result = process->GetTitleID(); 771 *result = process->GetProgramID();
778 return ResultSuccess; 772 return ResultSuccess;
779 773
780 case GetInfoType::UserExceptionContextAddr: 774 case GetInfoType::UserExceptionContextAddr:
@@ -1561,6 +1555,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) {
1561 1555
1562 // If we succeeded, persist a reference to the thread. 1556 // If we succeeded, persist a reference to the thread.
1563 thread->Open(); 1557 thread->Open();
1558 system.Kernel().RegisterInUseObject(thread.GetPointerUnsafe());
1564 1559
1565 return ResultSuccess; 1560 return ResultSuccess;
1566} 1561}
@@ -1576,6 +1571,7 @@ static void ExitThread(Core::System& system) {
1576 auto* const current_thread = system.Kernel().CurrentScheduler()->GetCurrentThread(); 1571 auto* const current_thread = system.Kernel().CurrentScheduler()->GetCurrentThread();
1577 system.GlobalSchedulerContext().RemoveThread(current_thread); 1572 system.GlobalSchedulerContext().RemoveThread(current_thread);
1578 current_thread->Exit(); 1573 current_thread->Exit();
1574 system.Kernel().UnregisterInUseObject(current_thread);
1579} 1575}
1580 1576
1581static void ExitThread32(Core::System& system) { 1577static void ExitThread32(Core::System& system) {
diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h
index 913b16494..6e62e656f 100644
--- a/src/core/hle/kernel/svc_wrap.h
+++ b/src/core/hle/kernel/svc_wrap.h
@@ -248,10 +248,10 @@ void SvcWrap64(Core::System& system) {
248} 248}
249 249
250// Used by WaitSynchronization 250// Used by WaitSynchronization
251template <ResultCode func(Core::System&, s32*, u64, u64, s64)> 251template <ResultCode func(Core::System&, s32*, u64, s32, s64)>
252void SvcWrap64(Core::System& system) { 252void SvcWrap64(Core::System& system) {
253 s32 param_1 = 0; 253 s32 param_1 = 0;
254 const u32 retval = func(system, &param_1, Param(system, 1), static_cast<u32>(Param(system, 2)), 254 const u32 retval = func(system, &param_1, Param(system, 1), static_cast<s32>(Param(system, 2)),
255 static_cast<s64>(Param(system, 3))) 255 static_cast<s64>(Param(system, 3)))
256 .raw; 256 .raw;
257 257
diff --git a/src/core/hle/kernel/time_manager.cpp b/src/core/hle/kernel/time_manager.cpp
index ae9b4be2f..8cd7279a3 100644
--- a/src/core/hle/kernel/time_manager.cpp
+++ b/src/core/hle/kernel/time_manager.cpp
@@ -5,10 +5,7 @@
5#include "common/assert.h" 5#include "common/assert.h"
6#include "core/core.h" 6#include "core/core.h"
7#include "core/core_timing.h" 7#include "core/core_timing.h"
8#include "core/core_timing_util.h"
9#include "core/hle/kernel/k_scheduler.h"
10#include "core/hle/kernel/k_thread.h" 8#include "core/hle/kernel/k_thread.h"
11#include "core/hle/kernel/kernel.h"
12#include "core/hle/kernel/time_manager.h" 9#include "core/hle/kernel/time_manager.h"
13 10
14namespace Kernel { 11namespace Kernel {
diff --git a/src/core/hle/kernel/time_manager.h b/src/core/hle/kernel/time_manager.h
index 2d175a9c4..b1fa26e8c 100644
--- a/src/core/hle/kernel/time_manager.h
+++ b/src/core/hle/kernel/time_manager.h
@@ -6,7 +6,6 @@
6 6
7#include <memory> 7#include <memory>
8#include <mutex> 8#include <mutex>
9#include <unordered_map>
10 9
11namespace Core { 10namespace Core {
12class System; 11class System;
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index 2c6b24848..3807b9aa8 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -4,11 +4,10 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <new>
8#include <utility>
9#include "common/assert.h" 7#include "common/assert.h"
10#include "common/bit_field.h" 8#include "common/bit_field.h"
11#include "common/common_types.h" 9#include "common/common_types.h"
10#include "common/expected.h"
12 11
13// All the constants in this file come from http://switchbrew.org/index.php?title=Error_codes 12// All the constants in this file come from http://switchbrew.org/index.php?title=Error_codes
14 13
@@ -155,203 +154,130 @@ constexpr ResultCode ResultSuccess(0);
155constexpr ResultCode ResultUnknown(UINT32_MAX); 154constexpr ResultCode ResultUnknown(UINT32_MAX);
156 155
157/** 156/**
158 * This is an optional value type. It holds a `ResultCode` and, if that code is a success code, 157 * This is an optional value type. It holds a `ResultCode` and, if that code is ResultSuccess, it
159 * also holds a result of type `T`. If the code is an error code then trying to access the inner 158 * also holds a result of type `T`. If the code is an error code (not ResultSuccess), then trying
160 * value fails, thus ensuring that the ResultCode of functions is always checked properly before 159 * to access the inner value with operator* is undefined behavior and will assert with Unwrap().
161 * their return value is used. It is similar in concept to the `std::optional` type 160 * Users of this class must be cognizant to check the status of the ResultVal with operator bool(),
162 * (http://en.cppreference.com/w/cpp/experimental/optional) originally proposed for inclusion in 161 * Code(), Succeeded() or Failed() prior to accessing the inner value.
163 * C++14, or the `Result` type in Rust (http://doc.rust-lang.org/std/result/index.html).
164 * 162 *
165 * An example of how it could be used: 163 * An example of how it could be used:
166 * \code 164 * \code
167 * ResultVal<int> Frobnicate(float strength) { 165 * ResultVal<int> Frobnicate(float strength) {
168 * if (strength < 0.f || strength > 1.0f) { 166 * if (strength < 0.f || strength > 1.0f) {
169 * // Can't frobnicate too weakly or too strongly 167 * // Can't frobnicate too weakly or too strongly
170 * return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Common, 168 * return ResultCode{ErrorModule::Common, 1};
171 * ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
172 * } else { 169 * } else {
173 * // Frobnicated! Give caller a cookie 170 * // Frobnicated! Give caller a cookie
174 * return MakeResult<int>(42); 171 * return 42;
175 * } 172 * }
176 * } 173 * }
177 * \endcode 174 * \endcode
178 * 175 *
179 * \code 176 * \code
180 * ResultVal<int> frob_result = Frobnicate(0.75f); 177 * auto frob_result = Frobnicate(0.75f);
181 * if (frob_result) { 178 * if (frob_result) {
182 * // Frobbed ok 179 * // Frobbed ok
183 * printf("My cookie is %d\n", *frob_result); 180 * printf("My cookie is %d\n", *frob_result);
184 * } else { 181 * } else {
185 * printf("Guess I overdid it. :( Error code: %ux\n", frob_result.code().hex); 182 * printf("Guess I overdid it. :( Error code: %ux\n", frob_result.Code().raw);
186 * } 183 * }
187 * \endcode 184 * \endcode
188 */ 185 */
189template <typename T> 186template <typename T>
190class ResultVal { 187class ResultVal {
191public: 188public:
192 /// Constructs an empty `ResultVal` with the given error code. The code must not be a success 189 constexpr ResultVal() : expected{} {}
193 /// code. 190
194 ResultVal(ResultCode error_code = ResultUnknown) : result_code(error_code) { 191 constexpr ResultVal(ResultCode code) : expected{Common::Unexpected(code)} {}
195 ASSERT(error_code.IsError()); 192
196 } 193 template <typename U>
194 constexpr ResultVal(U&& val) : expected{std::forward<U>(val)} {}
197 195
198 /**
199 * Similar to the non-member function `MakeResult`, with the exception that you can manually
200 * specify the success code. `success_code` must not be an error code.
201 */
202 template <typename... Args> 196 template <typename... Args>
203 [[nodiscard]] static ResultVal WithCode(ResultCode success_code, Args&&... args) { 197 constexpr ResultVal(Args&&... args) : expected{std::in_place, std::forward<Args>(args)...} {}
204 ResultVal<T> result;
205 result.emplace(success_code, std::forward<Args>(args)...);
206 return result;
207 }
208 198
209 ResultVal(const ResultVal& o) noexcept : result_code(o.result_code) { 199 ~ResultVal() = default;
210 if (!o.empty()) {
211 new (&object) T(o.object);
212 }
213 }
214 200
215 ResultVal(ResultVal&& o) noexcept : result_code(o.result_code) { 201 constexpr ResultVal(const ResultVal&) = default;
216 if (!o.empty()) { 202 constexpr ResultVal(ResultVal&&) = default;
217 new (&object) T(std::move(o.object));
218 }
219 }
220 203
221 ~ResultVal() { 204 ResultVal& operator=(const ResultVal&) = default;
222 if (!empty()) { 205 ResultVal& operator=(ResultVal&&) = default;
223 object.~T();
224 }
225 }
226 206
227 ResultVal& operator=(const ResultVal& o) noexcept { 207 [[nodiscard]] constexpr explicit operator bool() const noexcept {
228 if (this == &o) { 208 return expected.has_value();
229 return *this;
230 }
231 if (!empty()) {
232 if (!o.empty()) {
233 object = o.object;
234 } else {
235 object.~T();
236 }
237 } else {
238 if (!o.empty()) {
239 new (&object) T(o.object);
240 }
241 }
242 result_code = o.result_code;
243
244 return *this;
245 } 209 }
246 210
247 ResultVal& operator=(ResultVal&& o) noexcept { 211 [[nodiscard]] constexpr ResultCode Code() const {
248 if (this == &o) { 212 return expected.has_value() ? ResultSuccess : expected.error();
249 return *this;
250 }
251 if (!empty()) {
252 if (!o.empty()) {
253 object = std::move(o.object);
254 } else {
255 object.~T();
256 }
257 } else {
258 if (!o.empty()) {
259 new (&object) T(std::move(o.object));
260 }
261 }
262 result_code = o.result_code;
263
264 return *this;
265 } 213 }
266 214
267 /** 215 [[nodiscard]] constexpr bool Succeeded() const {
268 * Replaces the current result with a new constructed result value in-place. The code must not 216 return expected.has_value();
269 * be an error code.
270 */
271 template <typename... Args>
272 void emplace(ResultCode success_code, Args&&... args) {
273 ASSERT(success_code.IsSuccess());
274 if (!empty()) {
275 object.~T();
276 }
277 new (&object) T(std::forward<Args>(args)...);
278 result_code = success_code;
279 } 217 }
280 218
281 /// Returns true if the `ResultVal` contains an error code and no value. 219 [[nodiscard]] constexpr bool Failed() const {
282 [[nodiscard]] bool empty() const { 220 return !expected.has_value();
283 return result_code.IsError();
284 } 221 }
285 222
286 /// Returns true if the `ResultVal` contains a return value. 223 [[nodiscard]] constexpr T* operator->() {
287 [[nodiscard]] bool Succeeded() const { 224 return std::addressof(expected.value());
288 return result_code.IsSuccess();
289 } 225 }
290 /// Returns true if the `ResultVal` contains an error code and no value. 226
291 [[nodiscard]] bool Failed() const { 227 [[nodiscard]] constexpr const T* operator->() const {
292 return empty(); 228 return std::addressof(expected.value());
293 } 229 }
294 230
295 [[nodiscard]] ResultCode Code() const { 231 [[nodiscard]] constexpr T& operator*() & {
296 return result_code; 232 return *expected;
297 } 233 }
298 234
299 [[nodiscard]] const T& operator*() const { 235 [[nodiscard]] constexpr const T& operator*() const& {
300 return object; 236 return *expected;
301 } 237 }
302 [[nodiscard]] T& operator*() { 238
303 return object; 239 [[nodiscard]] constexpr T&& operator*() && {
240 return *expected;
304 } 241 }
305 [[nodiscard]] const T* operator->() const { 242
306 return &object; 243 [[nodiscard]] constexpr const T&& operator*() const&& {
244 return *expected;
307 } 245 }
308 [[nodiscard]] T* operator->() { 246
309 return &object; 247 [[nodiscard]] constexpr T& Unwrap() & {
248 ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal");
249 return expected.value();
310 } 250 }
311 251
312 /// Returns the value contained in this `ResultVal`, or the supplied default if it is missing. 252 [[nodiscard]] constexpr const T& Unwrap() const& {
313 template <typename U> 253 ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal");
314 [[nodiscard]] T ValueOr(U&& value) const { 254 return expected.value();
315 return !empty() ? object : std::move(value);
316 } 255 }
317 256
318 /// Asserts that the result succeeded and returns a reference to it. 257 [[nodiscard]] constexpr T&& Unwrap() && {
319 [[nodiscard]] T& Unwrap() & {
320 ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal"); 258 ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal");
321 return **this; 259 return std::move(expected.value());
322 } 260 }
323 261
324 [[nodiscard]] T&& Unwrap() && { 262 [[nodiscard]] constexpr const T&& Unwrap() const&& {
325 ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal"); 263 ASSERT_MSG(Succeeded(), "Tried to Unwrap empty ResultVal");
326 return std::move(**this); 264 return std::move(expected.value());
327 } 265 }
328 266
329private: 267 template <typename U>
330 // A union is used to allocate the storage for the value, while allowing us to construct and 268 [[nodiscard]] constexpr T ValueOr(U&& v) const& {
331 // destruct it at will. 269 return expected.value_or(v);
332 union { 270 }
333 T object;
334 };
335 ResultCode result_code;
336};
337 271
338/** 272 template <typename U>
339 * This function is a helper used to construct `ResultVal`s. It receives the arguments to construct 273 [[nodiscard]] constexpr T ValueOr(U&& v) && {
340 * `T` with and creates a success `ResultVal` contained the constructed value. 274 return expected.value_or(v);
341 */ 275 }
342template <typename T, typename... Args>
343[[nodiscard]] ResultVal<T> MakeResult(Args&&... args) {
344 return ResultVal<T>::WithCode(ResultSuccess, std::forward<Args>(args)...);
345}
346 276
347/** 277private:
348 * Deducible overload of MakeResult, allowing the template parameter to be ommited if you're just 278 // TODO: Replace this with std::expected once it is standardized in the STL.
349 * copy or move constructing. 279 Common::Expected<T, ResultCode> expected;
350 */ 280};
351template <typename Arg>
352[[nodiscard]] ResultVal<std::remove_cvref_t<Arg>> MakeResult(Arg&& arg) {
353 return ResultVal<std::remove_cvref_t<Arg>>::WithCode(ResultSuccess, std::forward<Arg>(arg));
354}
355 281
356/** 282/**
357 * Check for the success of `source` (which must evaluate to a ResultVal). If it succeeds, unwraps 283 * Check for the success of `source` (which must evaluate to a ResultVal). If it succeeds, unwraps
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 689b36056..6e63e057e 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -16,7 +16,6 @@
16#include "core/file_sys/control_metadata.h" 16#include "core/file_sys/control_metadata.h"
17#include "core/file_sys/patch_manager.h" 17#include "core/file_sys/patch_manager.h"
18#include "core/hle/ipc_helpers.h" 18#include "core/hle/ipc_helpers.h"
19#include "core/hle/kernel/k_process.h"
20#include "core/hle/kernel/kernel.h" 19#include "core/hle/kernel/kernel.h"
21#include "core/hle/service/acc/acc.h" 20#include "core/hle/service/acc/acc.h"
22#include "core/hle/service/acc/acc_aa.h" 21#include "core/hle/service/acc/acc_aa.h"
@@ -26,9 +25,7 @@
26#include "core/hle/service/acc/async_context.h" 25#include "core/hle/service/acc/async_context.h"
27#include "core/hle/service/acc/errors.h" 26#include "core/hle/service/acc/errors.h"
28#include "core/hle/service/acc/profile_manager.h" 27#include "core/hle/service/acc/profile_manager.h"
29#include "core/hle/service/glue/arp.h"
30#include "core/hle/service/glue/glue_manager.h" 28#include "core/hle/service/glue/glue_manager.h"
31#include "core/hle/service/sm/sm.h"
32#include "core/loader/loader.h" 29#include "core/loader/loader.h"
33 30
34namespace Service::Account { 31namespace Service::Account {
@@ -761,9 +758,8 @@ ResultCode Module::Interface::InitializeApplicationInfoBase() {
761 // TODO(ogniK): This should be changed to reflect the target process for when we have multiple 758 // TODO(ogniK): This should be changed to reflect the target process for when we have multiple
762 // processes emulated. As we don't actually have pid support we should assume we're just using 759 // processes emulated. As we don't actually have pid support we should assume we're just using
763 // our own process 760 // our own process
764 const auto& current_process = system.Kernel().CurrentProcess();
765 const auto launch_property = 761 const auto launch_property =
766 system.GetARPManager().GetLaunchProperty(current_process->GetTitleID()); 762 system.GetARPManager().GetLaunchProperty(system.GetCurrentProcessProgramID());
767 763
768 if (launch_property.Failed()) { 764 if (launch_property.Failed()) {
769 LOG_ERROR(Service_ACC, "Failed to get launch property"); 765 LOG_ERROR(Service_ACC, "Failed to get launch property");
@@ -807,7 +803,7 @@ void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx
807 bool is_locked = false; 803 bool is_locked = false;
808 804
809 if (res != Loader::ResultStatus::Success) { 805 if (res != Loader::ResultStatus::Success) {
810 const FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID(), 806 const FileSys::PatchManager pm{system.GetCurrentProcessProgramID(),
811 system.GetFileSystemController(), 807 system.GetFileSystemController(),
812 system.GetContentProvider()}; 808 system.GetContentProvider()};
813 const auto nacp_unique = pm.GetControlMetadata().first; 809 const auto nacp_unique = pm.GetControlMetadata().first;
@@ -826,6 +822,13 @@ void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx
826 rb.Push(is_locked); 822 rb.Push(is_locked);
827} 823}
828 824
825void Module::Interface::InitializeApplicationInfoV2(Kernel::HLERequestContext& ctx) {
826 LOG_WARNING(Service_ACC, "(STUBBED) called");
827
828 IPC::ResponseBuilder rb{ctx, 2};
829 rb.Push(ResultSuccess);
830}
831
829void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) { 832void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) {
830 IPC::RequestParser rp{ctx}; 833 IPC::RequestParser rp{ctx};
831 Common::UUID user_id = rp.PopRaw<Common::UUID>(); 834 Common::UUID user_id = rp.PopRaw<Common::UUID>();
diff --git a/src/core/hle/service/acc/acc.h b/src/core/hle/service/acc/acc.h
index a83a480cd..f7e9bc4f8 100644
--- a/src/core/hle/service/acc/acc.h
+++ b/src/core/hle/service/acc/acc.h
@@ -33,6 +33,7 @@ public:
33 void IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx); 33 void IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx);
34 void TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx); 34 void TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx);
35 void IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx); 35 void IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx);
36 void InitializeApplicationInfoV2(Kernel::HLERequestContext& ctx);
36 void GetProfileEditor(Kernel::HLERequestContext& ctx); 37 void GetProfileEditor(Kernel::HLERequestContext& ctx);
37 void ListQualifiedUsers(Kernel::HLERequestContext& ctx); 38 void ListQualifiedUsers(Kernel::HLERequestContext& ctx);
38 void LoadOpenContext(Kernel::HLERequestContext& ctx); 39 void LoadOpenContext(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/acc/acc_u0.cpp b/src/core/hle/service/acc/acc_u0.cpp
index ed241647c..df77c58f0 100644
--- a/src/core/hle/service/acc/acc_u0.cpp
+++ b/src/core/hle/service/acc/acc_u0.cpp
@@ -34,6 +34,7 @@ ACC_U0::ACC_U0(std::shared_ptr<Module> module_, std::shared_ptr<ProfileManager>
34 {140, &ACC_U0::InitializeApplicationInfoRestricted, "InitializeApplicationInfoRestricted"}, // 6.0.0+ 34 {140, &ACC_U0::InitializeApplicationInfoRestricted, "InitializeApplicationInfoRestricted"}, // 6.0.0+
35 {141, &ACC_U0::ListQualifiedUsers, "ListQualifiedUsers"}, // 6.0.0+ 35 {141, &ACC_U0::ListQualifiedUsers, "ListQualifiedUsers"}, // 6.0.0+
36 {150, &ACC_U0::IsUserAccountSwitchLocked, "IsUserAccountSwitchLocked"}, // 6.0.0+ 36 {150, &ACC_U0::IsUserAccountSwitchLocked, "IsUserAccountSwitchLocked"}, // 6.0.0+
37 {160, &ACC_U0::InitializeApplicationInfoV2, "InitializeApplicationInfoV2"},
37 }; 38 };
38 // clang-format on 39 // clang-format on
39 40
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index eccdcc20d..50c2ace93 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -15,15 +15,12 @@
15#include "core/file_sys/savedata_factory.h" 15#include "core/file_sys/savedata_factory.h"
16#include "core/hle/ipc_helpers.h" 16#include "core/hle/ipc_helpers.h"
17#include "core/hle/kernel/k_event.h" 17#include "core/hle/kernel/k_event.h"
18#include "core/hle/kernel/k_process.h"
19#include "core/hle/kernel/k_transfer_memory.h" 18#include "core/hle/kernel/k_transfer_memory.h"
20#include "core/hle/kernel/kernel.h"
21#include "core/hle/service/acc/profile_manager.h" 19#include "core/hle/service/acc/profile_manager.h"
22#include "core/hle/service/am/am.h" 20#include "core/hle/service/am/am.h"
23#include "core/hle/service/am/applet_ae.h" 21#include "core/hle/service/am/applet_ae.h"
24#include "core/hle/service/am/applet_oe.h" 22#include "core/hle/service/am/applet_oe.h"
25#include "core/hle/service/am/applets/applet_profile_select.h" 23#include "core/hle/service/am/applets/applet_profile_select.h"
26#include "core/hle/service/am/applets/applet_software_keyboard.h"
27#include "core/hle/service/am/applets/applet_web_browser.h" 24#include "core/hle/service/am/applets/applet_web_browser.h"
28#include "core/hle/service/am/applets/applets.h" 25#include "core/hle/service/am/applets/applets.h"
29#include "core/hle/service/am/idle.h" 26#include "core/hle/service/am/idle.h"
@@ -37,7 +34,6 @@
37#include "core/hle/service/ns/ns.h" 34#include "core/hle/service/ns/ns.h"
38#include "core/hle/service/nvflinger/nvflinger.h" 35#include "core/hle/service/nvflinger/nvflinger.h"
39#include "core/hle/service/pm/pm.h" 36#include "core/hle/service/pm/pm.h"
40#include "core/hle/service/set/set.h"
41#include "core/hle/service/sm/sm.h" 37#include "core/hle/service/sm/sm.h"
42#include "core/hle/service/vi/vi.h" 38#include "core/hle/service/vi/vi.h"
43#include "core/memory.h" 39#include "core/memory.h"
@@ -1432,7 +1428,7 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
1432 u64 build_id{}; 1428 u64 build_id{};
1433 std::memcpy(&build_id, build_id_full.data(), sizeof(u64)); 1429 std::memcpy(&build_id, build_id_full.data(), sizeof(u64));
1434 1430
1435 auto data = backend->GetLaunchParameter({system.CurrentProcess()->GetTitleID(), build_id}); 1431 auto data = backend->GetLaunchParameter({system.GetCurrentProcessProgramID(), build_id});
1436 if (data.has_value()) { 1432 if (data.has_value()) {
1437 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 1433 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
1438 rb.Push(ResultSuccess); 1434 rb.Push(ResultSuccess);
@@ -1484,7 +1480,7 @@ void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
1484 LOG_DEBUG(Service_AM, "called, uid={:016X}{:016X}", user_id[1], user_id[0]); 1480 LOG_DEBUG(Service_AM, "called, uid={:016X}{:016X}", user_id[1], user_id[0]);
1485 1481
1486 FileSys::SaveDataAttribute attribute{}; 1482 FileSys::SaveDataAttribute attribute{};
1487 attribute.title_id = system.CurrentProcess()->GetTitleID(); 1483 attribute.title_id = system.GetCurrentProcessProgramID();
1488 attribute.user_id = user_id; 1484 attribute.user_id = user_id;
1489 attribute.type = FileSys::SaveDataType::SaveData; 1485 attribute.type = FileSys::SaveDataType::SaveData;
1490 const auto res = system.GetFileSystemController().CreateSaveData( 1486 const auto res = system.GetFileSystemController().CreateSaveData(
@@ -1514,7 +1510,7 @@ void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
1514 std::array<u8, 0x10> version_string{}; 1510 std::array<u8, 0x10> version_string{};
1515 1511
1516 const auto res = [this] { 1512 const auto res = [this] {
1517 const auto title_id = system.CurrentProcess()->GetTitleID(); 1513 const auto title_id = system.GetCurrentProcessProgramID();
1518 1514
1519 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), 1515 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
1520 system.GetContentProvider()}; 1516 system.GetContentProvider()};
@@ -1551,7 +1547,7 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
1551 u32 supported_languages = 0; 1547 u32 supported_languages = 0;
1552 1548
1553 const auto res = [this] { 1549 const auto res = [this] {
1554 const auto title_id = system.CurrentProcess()->GetTitleID(); 1550 const auto title_id = system.GetCurrentProcessProgramID();
1555 1551
1556 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), 1552 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
1557 system.GetContentProvider()}; 1553 system.GetContentProvider()};
@@ -1659,7 +1655,7 @@ void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) {
1659 static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size); 1655 static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size);
1660 1656
1661 system.GetFileSystemController().WriteSaveDataSize( 1657 system.GetFileSystemController().WriteSaveDataSize(
1662 type, system.CurrentProcess()->GetTitleID(), user_id, {new_normal_size, new_journal_size}); 1658 type, system.GetCurrentProcessProgramID(), user_id, {new_normal_size, new_journal_size});
1663 1659
1664 IPC::ResponseBuilder rb{ctx, 4}; 1660 IPC::ResponseBuilder rb{ctx, 4};
1665 rb.Push(ResultSuccess); 1661 rb.Push(ResultSuccess);
@@ -1683,7 +1679,7 @@ void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) {
1683 user_id[0]); 1679 user_id[0]);
1684 1680
1685 const auto size = system.GetFileSystemController().ReadSaveDataSize( 1681 const auto size = system.GetFileSystemController().ReadSaveDataSize(
1686 type, system.CurrentProcess()->GetTitleID(), user_id); 1682 type, system.GetCurrentProcessProgramID(), user_id);
1687 1683
1688 IPC::ResponseBuilder rb{ctx, 6}; 1684 IPC::ResponseBuilder rb{ctx, 6};
1689 rb.Push(ResultSuccess); 1685 rb.Push(ResultSuccess);
diff --git a/src/core/hle/service/am/applets/applet_error.cpp b/src/core/hle/service/am/applets/applet_error.cpp
index 36a4aa9cd..a06c2b872 100644
--- a/src/core/hle/service/am/applets/applet_error.cpp
+++ b/src/core/hle/service/am/applets/applet_error.cpp
@@ -9,7 +9,6 @@
9#include "common/string_util.h" 9#include "common/string_util.h"
10#include "core/core.h" 10#include "core/core.h"
11#include "core/frontend/applets/error.h" 11#include "core/frontend/applets/error.h"
12#include "core/hle/kernel/k_process.h"
13#include "core/hle/service/am/am.h" 12#include "core/hle/service/am/am.h"
14#include "core/hle/service/am/applets/applet_error.h" 13#include "core/hle/service/am/applets/applet_error.h"
15#include "core/reporter.h" 14#include "core/reporter.h"
@@ -167,7 +166,7 @@ void Error::Execute() {
167 } 166 }
168 167
169 const auto callback = [this] { DisplayCompleted(); }; 168 const auto callback = [this] { DisplayCompleted(); };
170 const auto title_id = system.CurrentProcess()->GetTitleID(); 169 const auto title_id = system.GetCurrentProcessProgramID();
171 const auto& reporter{system.GetReporter()}; 170 const auto& reporter{system.GetReporter()};
172 171
173 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 0f413f9a0..2c6e9d83c 100644
--- a/src/core/hle/service/am/applets/applet_general_backend.cpp
+++ b/src/core/hle/service/am/applets/applet_general_backend.cpp
@@ -2,14 +2,11 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <string_view>
6
7#include "common/assert.h" 5#include "common/assert.h"
8#include "common/hex_util.h" 6#include "common/hex_util.h"
9#include "common/logging/log.h" 7#include "common/logging/log.h"
10#include "core/core.h" 8#include "core/core.h"
11#include "core/frontend/applets/general_frontend.h" 9#include "core/frontend/applets/general_frontend.h"
12#include "core/hle/kernel/k_process.h"
13#include "core/hle/result.h" 10#include "core/hle/result.h"
14#include "core/hle/service/am/am.h" 11#include "core/hle/service/am/am.h"
15#include "core/hle/service/am/applets/applet_general_backend.h" 12#include "core/hle/service/am/applets/applet_general_backend.h"
@@ -189,7 +186,7 @@ void PhotoViewer::Execute() {
189 const auto callback = [this] { ViewFinished(); }; 186 const auto callback = [this] { ViewFinished(); };
190 switch (mode) { 187 switch (mode) {
191 case PhotoViewerAppletMode::CurrentApp: 188 case PhotoViewerAppletMode::CurrentApp:
192 frontend.ShowPhotosForApplication(system.CurrentProcess()->GetTitleID(), callback); 189 frontend.ShowPhotosForApplication(system.GetCurrentProcessProgramID(), callback);
193 break; 190 break;
194 case PhotoViewerAppletMode::AllApps: 191 case PhotoViewerAppletMode::AllApps:
195 frontend.ShowAllPhotos(callback); 192 frontend.ShowAllPhotos(callback);
diff --git a/src/core/hle/service/am/applets/applet_software_keyboard.cpp b/src/core/hle/service/am/applets/applet_software_keyboard.cpp
index c89aa1bbf..f38f53f69 100644
--- a/src/core/hle/service/am/applets/applet_software_keyboard.cpp
+++ b/src/core/hle/service/am/applets/applet_software_keyboard.cpp
@@ -109,13 +109,18 @@ void SoftwareKeyboard::Execute() {
109 ShowNormalKeyboard(); 109 ShowNormalKeyboard();
110} 110}
111 111
112void SoftwareKeyboard::SubmitTextNormal(SwkbdResult result, std::u16string submitted_text) { 112void SoftwareKeyboard::SubmitTextNormal(SwkbdResult result, std::u16string submitted_text,
113 bool confirmed) {
113 if (complete) { 114 if (complete) {
114 return; 115 return;
115 } 116 }
116 117
117 if (swkbd_config_common.use_text_check && result == SwkbdResult::Ok) { 118 if (swkbd_config_common.use_text_check && result == SwkbdResult::Ok) {
118 SubmitForTextCheck(submitted_text); 119 if (confirmed) {
120 SubmitNormalOutputAndExit(result, submitted_text);
121 } else {
122 SubmitForTextCheck(submitted_text);
123 }
119 } else { 124 } else {
120 SubmitNormalOutputAndExit(result, submitted_text); 125 SubmitNormalOutputAndExit(result, submitted_text);
121 } 126 }
@@ -273,13 +278,21 @@ void SoftwareKeyboard::ProcessTextCheck() {
273 278
274 std::memcpy(&swkbd_text_check, text_check_data.data(), sizeof(SwkbdTextCheck)); 279 std::memcpy(&swkbd_text_check, text_check_data.data(), sizeof(SwkbdTextCheck));
275 280
276 std::u16string text_check_message = 281 std::u16string text_check_message = [this, &swkbd_text_check]() -> std::u16string {
277 swkbd_text_check.text_check_result == SwkbdTextCheckResult::Failure || 282 if (swkbd_text_check.text_check_result == SwkbdTextCheckResult::Failure ||
278 swkbd_text_check.text_check_result == SwkbdTextCheckResult::Confirm 283 swkbd_text_check.text_check_result == SwkbdTextCheckResult::Confirm) {
279 ? Common::UTF16StringFromFixedZeroTerminatedBuffer( 284 return swkbd_config_common.use_utf8
280 swkbd_text_check.text_check_message.data(), 285 ? Common::UTF8ToUTF16(Common::StringFromFixedZeroTerminatedBuffer(
281 swkbd_text_check.text_check_message.size()) 286 reinterpret_cast<const char*>(
282 : u""; 287 swkbd_text_check.text_check_message.data()),
288 swkbd_text_check.text_check_message.size() * sizeof(char16_t)))
289 : Common::UTF16StringFromFixedZeroTerminatedBuffer(
290 swkbd_text_check.text_check_message.data(),
291 swkbd_text_check.text_check_message.size());
292 } else {
293 return u"";
294 }
295 }();
283 296
284 LOG_INFO(Service_AM, "\nTextCheckResult: {}\nTextCheckMessage: {}", 297 LOG_INFO(Service_AM, "\nTextCheckResult: {}\nTextCheckMessage: {}",
285 GetTextCheckResultName(swkbd_text_check.text_check_result), 298 GetTextCheckResultName(swkbd_text_check.text_check_result),
@@ -583,11 +596,12 @@ void SoftwareKeyboard::InitializeFrontendKeyboard() {
583 .disable_cancel_button{disable_cancel_button}, 596 .disable_cancel_button{disable_cancel_button},
584 }; 597 };
585 598
586 frontend.InitializeKeyboard(false, std::move(initialize_parameters), 599 frontend.InitializeKeyboard(
587 [this](SwkbdResult result, std::u16string submitted_text) { 600 false, std::move(initialize_parameters),
588 SubmitTextNormal(result, submitted_text); 601 [this](SwkbdResult result, std::u16string submitted_text, bool confirmed) {
589 }, 602 SubmitTextNormal(result, submitted_text, confirmed);
590 {}); 603 },
604 {});
591 } 605 }
592} 606}
593 607
diff --git a/src/core/hle/service/am/applets/applet_software_keyboard.h b/src/core/hle/service/am/applets/applet_software_keyboard.h
index 9aef1bf11..a0fddd965 100644
--- a/src/core/hle/service/am/applets/applet_software_keyboard.h
+++ b/src/core/hle/service/am/applets/applet_software_keyboard.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common_funcs.h"
8#include "common/common_types.h" 7#include "common/common_types.h"
9#include "core/hle/result.h" 8#include "core/hle/result.h"
10#include "core/hle/service/am/applets/applet_software_keyboard_types.h" 9#include "core/hle/service/am/applets/applet_software_keyboard_types.h"
@@ -37,8 +36,9 @@ public:
37 * 36 *
38 * @param result SwkbdResult enum 37 * @param result SwkbdResult enum
39 * @param submitted_text UTF-16 encoded string 38 * @param submitted_text UTF-16 encoded string
39 * @param confirmed Whether the text has been confirmed after TextCheckResult::Confirm
40 */ 40 */
41 void SubmitTextNormal(SwkbdResult result, std::u16string submitted_text); 41 void SubmitTextNormal(SwkbdResult result, std::u16string submitted_text, bool confirmed);
42 42
43 /** 43 /**
44 * Submits the input text to the application. 44 * Submits the input text to the application.
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 927eeefff..bb5cb61be 100644
--- a/src/core/hle/service/am/applets/applet_web_browser.cpp
+++ b/src/core/hle/service/am/applets/applet_web_browser.cpp
@@ -18,7 +18,6 @@
18#include "core/file_sys/system_archive/system_archive.h" 18#include "core/file_sys/system_archive/system_archive.h"
19#include "core/file_sys/vfs_vector.h" 19#include "core/file_sys/vfs_vector.h"
20#include "core/frontend/applets/web_browser.h" 20#include "core/frontend/applets/web_browser.h"
21#include "core/hle/kernel/k_process.h"
22#include "core/hle/result.h" 21#include "core/hle/result.h"
23#include "core/hle/service/am/am.h" 22#include "core/hle/service/am/am.h"
24#include "core/hle/service/am/applets/applet_web_browser.h" 23#include "core/hle/service/am/applets/applet_web_browser.h"
@@ -395,7 +394,7 @@ void WebBrowser::InitializeOffline() {
395 switch (document_kind) { 394 switch (document_kind) {
396 case DocumentKind::OfflineHtmlPage: 395 case DocumentKind::OfflineHtmlPage:
397 default: 396 default:
398 title_id = system.CurrentProcess()->GetTitleID(); 397 title_id = system.GetCurrentProcessProgramID();
399 nca_type = FileSys::ContentRecordType::HtmlDocument; 398 nca_type = FileSys::ContentRecordType::HtmlDocument;
400 additional_paths = "html-document"; 399 additional_paths = "html-document";
401 break; 400 break;
diff --git a/src/core/hle/service/am/applets/applet_web_browser.h b/src/core/hle/service/am/applets/applet_web_browser.h
index 4f9e81b79..b3364ee06 100644
--- a/src/core/hle/service/am/applets/applet_web_browser.h
+++ b/src/core/hle/service/am/applets/applet_web_browser.h
@@ -7,7 +7,6 @@
7#include <filesystem> 7#include <filesystem>
8#include <optional> 8#include <optional>
9 9
10#include "common/common_funcs.h"
11#include "common/common_types.h" 10#include "common/common_types.h"
12#include "core/file_sys/vfs_types.h" 11#include "core/file_sys/vfs_types.h"
13#include "core/hle/result.h" 12#include "core/hle/result.h"
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp
index 4c54066c6..3c83717b5 100644
--- a/src/core/hle/service/aoc/aoc_u.cpp
+++ b/src/core/hle/service/aoc/aoc_u.cpp
@@ -17,8 +17,6 @@
17#include "core/file_sys/registered_cache.h" 17#include "core/file_sys/registered_cache.h"
18#include "core/hle/ipc_helpers.h" 18#include "core/hle/ipc_helpers.h"
19#include "core/hle/kernel/k_event.h" 19#include "core/hle/kernel/k_event.h"
20#include "core/hle/kernel/k_process.h"
21#include "core/hle/kernel/kernel.h"
22#include "core/hle/service/aoc/aoc_u.h" 20#include "core/hle/service/aoc/aoc_u.h"
23#include "core/loader/loader.h" 21#include "core/loader/loader.h"
24 22
@@ -124,9 +122,14 @@ AOC_U::AOC_U(Core::System& system_)
124 {8, &AOC_U::GetAddOnContentListChangedEvent, "GetAddOnContentListChangedEvent"}, 122 {8, &AOC_U::GetAddOnContentListChangedEvent, "GetAddOnContentListChangedEvent"},
125 {9, nullptr, "GetAddOnContentLostErrorCode"}, 123 {9, nullptr, "GetAddOnContentLostErrorCode"},
126 {10, &AOC_U::GetAddOnContentListChangedEventWithProcessId, "GetAddOnContentListChangedEventWithProcessId"}, 124 {10, &AOC_U::GetAddOnContentListChangedEventWithProcessId, "GetAddOnContentListChangedEventWithProcessId"},
125 {11, &AOC_U::NotifyMountAddOnContent, "NotifyMountAddOnContent"},
126 {12, &AOC_U::NotifyUnmountAddOnContent, "NotifyUnmountAddOnContent"},
127 {13, nullptr, "IsAddOnContentMountedForDebug"},
128 {50, &AOC_U::CheckAddOnContentMountStatus, "CheckAddOnContentMountStatus"},
127 {100, &AOC_U::CreateEcPurchasedEventManager, "CreateEcPurchasedEventManager"}, 129 {100, &AOC_U::CreateEcPurchasedEventManager, "CreateEcPurchasedEventManager"},
128 {101, &AOC_U::CreatePermanentEcPurchasedEventManager, "CreatePermanentEcPurchasedEventManager"}, 130 {101, &AOC_U::CreatePermanentEcPurchasedEventManager, "CreatePermanentEcPurchasedEventManager"},
129 {110, nullptr, "CreateContentsServiceManager"}, 131 {110, nullptr, "CreateContentsServiceManager"},
132 {200, nullptr, "SetRequiredAddOnContentsOnContentsAvailabilityTransition"},
130 }; 133 };
131 // clang-format on 134 // clang-format on
132 135
@@ -153,7 +156,7 @@ void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) {
153 IPC::ResponseBuilder rb{ctx, 3}; 156 IPC::ResponseBuilder rb{ctx, 3};
154 rb.Push(ResultSuccess); 157 rb.Push(ResultSuccess);
155 158
156 const auto current = system.CurrentProcess()->GetTitleID(); 159 const auto current = system.GetCurrentProcessProgramID();
157 160
158 const auto& disabled = Settings::values.disabled_addons[current]; 161 const auto& disabled = Settings::values.disabled_addons[current];
159 if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) { 162 if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) {
@@ -180,7 +183,7 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) {
180 LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count, 183 LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count,
181 process_id); 184 process_id);
182 185
183 const auto current = system.CurrentProcess()->GetTitleID(); 186 const auto current = system.GetCurrentProcessProgramID();
184 187
185 std::vector<u32> out; 188 std::vector<u32> out;
186 const auto& disabled = Settings::values.disabled_addons[current]; 189 const auto& disabled = Settings::values.disabled_addons[current];
@@ -226,7 +229,7 @@ void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) {
226 IPC::ResponseBuilder rb{ctx, 4}; 229 IPC::ResponseBuilder rb{ctx, 4};
227 rb.Push(ResultSuccess); 230 rb.Push(ResultSuccess);
228 231
229 const auto title_id = system.CurrentProcess()->GetTitleID(); 232 const auto title_id = system.GetCurrentProcessProgramID();
230 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), 233 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
231 system.GetContentProvider()}; 234 system.GetContentProvider()};
232 235
@@ -272,6 +275,27 @@ void AOC_U::GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestConte
272 rb.PushCopyObjects(aoc_change_event->GetReadableEvent()); 275 rb.PushCopyObjects(aoc_change_event->GetReadableEvent());
273} 276}
274 277
278void AOC_U::NotifyMountAddOnContent(Kernel::HLERequestContext& ctx) {
279 LOG_WARNING(Service_AOC, "(STUBBED) called");
280
281 IPC::ResponseBuilder rb{ctx, 2};
282 rb.Push(ResultSuccess);
283}
284
285void AOC_U::NotifyUnmountAddOnContent(Kernel::HLERequestContext& ctx) {
286 LOG_WARNING(Service_AOC, "(STUBBED) called");
287
288 IPC::ResponseBuilder rb{ctx, 2};
289 rb.Push(ResultSuccess);
290}
291
292void AOC_U::CheckAddOnContentMountStatus(Kernel::HLERequestContext& ctx) {
293 LOG_WARNING(Service_AOC, "(STUBBED) called");
294
295 IPC::ResponseBuilder rb{ctx, 2};
296 rb.Push(ResultSuccess);
297}
298
275void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { 299void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) {
276 LOG_WARNING(Service_AOC, "(STUBBED) called"); 300 LOG_WARNING(Service_AOC, "(STUBBED) called");
277 301
diff --git a/src/core/hle/service/aoc/aoc_u.h b/src/core/hle/service/aoc/aoc_u.h
index 31d645be8..4b5f7c5f2 100644
--- a/src/core/hle/service/aoc/aoc_u.h
+++ b/src/core/hle/service/aoc/aoc_u.h
@@ -29,6 +29,9 @@ private:
29 void PrepareAddOnContent(Kernel::HLERequestContext& ctx); 29 void PrepareAddOnContent(Kernel::HLERequestContext& ctx);
30 void GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx); 30 void GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx);
31 void GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestContext& ctx); 31 void GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestContext& ctx);
32 void NotifyMountAddOnContent(Kernel::HLERequestContext& ctx);
33 void NotifyUnmountAddOnContent(Kernel::HLERequestContext& ctx);
34 void CheckAddOnContentMountStatus(Kernel::HLERequestContext& ctx);
32 void CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx); 35 void CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx);
33 void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx); 36 void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx);
34 37
diff --git a/src/core/hle/service/apm/apm.cpp b/src/core/hle/service/apm/apm.cpp
index f5ebfe8d6..243ea15b8 100644
--- a/src/core/hle/service/apm/apm.cpp
+++ b/src/core/hle/service/apm/apm.cpp
@@ -3,7 +3,6 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "core/core.h" 5#include "core/core.h"
6#include "core/hle/ipc_helpers.h"
7#include "core/hle/service/apm/apm.h" 6#include "core/hle/service/apm/apm.h"
8#include "core/hle/service/apm/apm_interface.h" 7#include "core/hle/service/apm/apm_interface.h"
9 8
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp
index 81adbfe09..affa7971c 100644
--- a/src/core/hle/service/audio/audout_u.cpp
+++ b/src/core/hle/service/audio/audout_u.cpp
@@ -14,7 +14,6 @@
14#include "core/core.h" 14#include "core/core.h"
15#include "core/hle/ipc_helpers.h" 15#include "core/hle/ipc_helpers.h"
16#include "core/hle/kernel/k_event.h" 16#include "core/hle/kernel/k_event.h"
17#include "core/hle/kernel/kernel.h"
18#include "core/hle/service/audio/audout_u.h" 17#include "core/hle/service/audio/audout_u.h"
19#include "core/hle/service/audio/errors.h" 18#include "core/hle/service/audio/errors.h"
20#include "core/hle/service/kernel_helpers.h" 19#include "core/hle/service/kernel_helpers.h"
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index cdb2a9521..f45e5cecc 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -2,10 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm>
6#include <array> 5#include <array>
7#include <memory> 6#include <memory>
8#include <string_view>
9 7
10#include "audio_core/audio_renderer.h" 8#include "audio_core/audio_renderer.h"
11#include "common/alignment.h" 9#include "common/alignment.h"
@@ -16,7 +14,6 @@
16#include "core/core.h" 14#include "core/core.h"
17#include "core/hle/ipc_helpers.h" 15#include "core/hle/ipc_helpers.h"
18#include "core/hle/kernel/k_event.h" 16#include "core/hle/kernel/k_event.h"
19#include "core/hle/kernel/kernel.h"
20#include "core/hle/service/audio/audren_u.h" 17#include "core/hle/service/audio/audren_u.h"
21#include "core/hle/service/audio/errors.h" 18#include "core/hle/service/audio/errors.h"
22 19
diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h
index 749e046c7..59c6d4740 100644
--- a/src/core/hle/service/bcat/backend/backend.h
+++ b/src/core/hle/service/bcat/backend/backend.h
@@ -7,7 +7,6 @@
7#include <functional> 7#include <functional>
8#include <optional> 8#include <optional>
9#include <string> 9#include <string>
10#include <string_view>
11 10
12#include "common/common_types.h" 11#include "common/common_types.h"
13#include "core/file_sys/vfs_types.h" 12#include "core/file_sys/vfs_types.h"
diff --git a/src/core/hle/service/bcat/bcat_module.cpp b/src/core/hle/service/bcat/bcat_module.cpp
index 27e9b8df8..500e7e52d 100644
--- a/src/core/hle/service/bcat/bcat_module.cpp
+++ b/src/core/hle/service/bcat/bcat_module.cpp
@@ -11,9 +11,7 @@
11#include "core/core.h" 11#include "core/core.h"
12#include "core/file_sys/vfs.h" 12#include "core/file_sys/vfs.h"
13#include "core/hle/ipc_helpers.h" 13#include "core/hle/ipc_helpers.h"
14#include "core/hle/kernel/k_process.h"
15#include "core/hle/kernel/k_readable_event.h" 14#include "core/hle/kernel/k_readable_event.h"
16#include "core/hle/kernel/k_writable_event.h"
17#include "core/hle/service/bcat/backend/backend.h" 15#include "core/hle/service/bcat/backend/backend.h"
18#include "core/hle/service/bcat/bcat.h" 16#include "core/hle/service/bcat/bcat.h"
19#include "core/hle/service/bcat/bcat_module.h" 17#include "core/hle/service/bcat/bcat_module.h"
@@ -179,7 +177,7 @@ private:
179 void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) { 177 void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) {
180 LOG_DEBUG(Service_BCAT, "called"); 178 LOG_DEBUG(Service_BCAT, "called");
181 179
182 backend.Synchronize({system.CurrentProcess()->GetTitleID(), 180 backend.Synchronize({system.GetCurrentProcessProgramID(),
183 GetCurrentBuildID(system.GetCurrentProcessBuildID())}, 181 GetCurrentBuildID(system.GetCurrentProcessBuildID())},
184 GetProgressBackend(SyncType::Normal)); 182 GetProgressBackend(SyncType::Normal));
185 183
@@ -196,7 +194,7 @@ private:
196 194
197 LOG_DEBUG(Service_BCAT, "called, name={}", name); 195 LOG_DEBUG(Service_BCAT, "called, name={}", name);
198 196
199 backend.SynchronizeDirectory({system.CurrentProcess()->GetTitleID(), 197 backend.SynchronizeDirectory({system.GetCurrentProcessProgramID(),
200 GetCurrentBuildID(system.GetCurrentProcessBuildID())}, 198 GetCurrentBuildID(system.GetCurrentProcessBuildID())},
201 name, GetProgressBackend(SyncType::Directory)); 199 name, GetProgressBackend(SyncType::Directory));
202 200
@@ -557,7 +555,7 @@ private:
557void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx) { 555void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx) {
558 LOG_DEBUG(Service_BCAT, "called"); 556 LOG_DEBUG(Service_BCAT, "called");
559 557
560 const auto title_id = system.CurrentProcess()->GetTitleID(); 558 const auto title_id = system.GetCurrentProcessProgramID();
561 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 559 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
562 rb.Push(ResultSuccess); 560 rb.Push(ResultSuccess);
563 rb.PushIpcInterface<IDeliveryCacheStorageService>(system, fsc.GetBCATDirectory(title_id)); 561 rb.PushIpcInterface<IDeliveryCacheStorageService>(system, fsc.GetBCATDirectory(title_id));
diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp
index 088a1a18a..0787f43f4 100644
--- a/src/core/hle/service/btdrv/btdrv.cpp
+++ b/src/core/hle/service/btdrv/btdrv.cpp
@@ -6,7 +6,6 @@
6#include "core/core.h" 6#include "core/core.h"
7#include "core/hle/ipc_helpers.h" 7#include "core/hle/ipc_helpers.h"
8#include "core/hle/kernel/k_event.h" 8#include "core/hle/kernel/k_event.h"
9#include "core/hle/kernel/kernel.h"
10#include "core/hle/service/btdrv/btdrv.h" 9#include "core/hle/service/btdrv/btdrv.h"
11#include "core/hle/service/kernel_helpers.h" 10#include "core/hle/service/kernel_helpers.h"
12#include "core/hle/service/service.h" 11#include "core/hle/service/service.h"
diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp
index 7aabacc19..d337fd317 100644
--- a/src/core/hle/service/btm/btm.cpp
+++ b/src/core/hle/service/btm/btm.cpp
@@ -8,7 +8,6 @@
8#include "core/core.h" 8#include "core/core.h"
9#include "core/hle/ipc_helpers.h" 9#include "core/hle/ipc_helpers.h"
10#include "core/hle/kernel/k_event.h" 10#include "core/hle/kernel/k_event.h"
11#include "core/hle/kernel/kernel.h"
12#include "core/hle/service/btm/btm.h" 11#include "core/hle/service/btm/btm.h"
13#include "core/hle/service/kernel_helpers.h" 12#include "core/hle/service/kernel_helpers.h"
14#include "core/hle/service/service.h" 13#include "core/hle/service/service.h"
diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp
index 2c2619a7d..f84506af0 100644
--- a/src/core/hle/service/fatal/fatal.cpp
+++ b/src/core/hle/service/fatal/fatal.cpp
@@ -11,7 +11,6 @@
11#include "common/swap.h" 11#include "common/swap.h"
12#include "core/core.h" 12#include "core/core.h"
13#include "core/hle/ipc_helpers.h" 13#include "core/hle/ipc_helpers.h"
14#include "core/hle/kernel/k_process.h"
15#include "core/hle/service/fatal/fatal.h" 14#include "core/hle/service/fatal/fatal.h"
16#include "core/hle/service/fatal/fatal_p.h" 15#include "core/hle/service/fatal/fatal_p.h"
17#include "core/hle/service/fatal/fatal_u.h" 16#include "core/hle/service/fatal/fatal_u.h"
@@ -66,7 +65,7 @@ enum class FatalType : u32 {
66 65
67static void GenerateErrorReport(Core::System& system, ResultCode error_code, 66static void GenerateErrorReport(Core::System& system, ResultCode error_code,
68 const FatalInfo& info) { 67 const FatalInfo& info) {
69 const auto title_id = system.CurrentProcess()->GetTitleID(); 68 const auto title_id = system.GetCurrentProcessProgramID();
70 std::string crash_report = fmt::format( 69 std::string crash_report = fmt::format(
71 "Yuzu {}-{} crash report\n" 70 "Yuzu {}-{} crash report\n"
72 "Title ID: {:016x}\n" 71 "Title ID: {:016x}\n"
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index f8f9e32f7..3703ca4c6 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -13,7 +13,6 @@
13#include "core/file_sys/control_metadata.h" 13#include "core/file_sys/control_metadata.h"
14#include "core/file_sys/errors.h" 14#include "core/file_sys/errors.h"
15#include "core/file_sys/mode.h" 15#include "core/file_sys/mode.h"
16#include "core/file_sys/partition_filesystem.h"
17#include "core/file_sys/patch_manager.h" 16#include "core/file_sys/patch_manager.h"
18#include "core/file_sys/registered_cache.h" 17#include "core/file_sys/registered_cache.h"
19#include "core/file_sys/romfs_factory.h" 18#include "core/file_sys/romfs_factory.h"
@@ -21,7 +20,6 @@
21#include "core/file_sys/sdmc_factory.h" 20#include "core/file_sys/sdmc_factory.h"
22#include "core/file_sys/vfs.h" 21#include "core/file_sys/vfs.h"
23#include "core/file_sys/vfs_offset.h" 22#include "core/file_sys/vfs_offset.h"
24#include "core/hle/kernel/k_process.h"
25#include "core/hle/service/filesystem/filesystem.h" 23#include "core/hle/service/filesystem/filesystem.h"
26#include "core/hle/service/filesystem/fsp_ldr.h" 24#include "core/hle/service/filesystem/fsp_ldr.h"
27#include "core/hle/service/filesystem/fsp_pr.h" 25#include "core/hle/service/filesystem/fsp_pr.h"
@@ -226,11 +224,10 @@ ResultVal<FileSys::VirtualFile> VfsDirectoryServiceWrapper::OpenFile(const std::
226 } 224 }
227 225
228 if (mode == FileSys::Mode::Append) { 226 if (mode == FileSys::Mode::Append) {
229 return MakeResult<FileSys::VirtualFile>( 227 return std::make_shared<FileSys::OffsetVfsFile>(file, 0, file->GetSize());
230 std::make_shared<FileSys::OffsetVfsFile>(file, 0, file->GetSize()));
231 } 228 }
232 229
233 return MakeResult<FileSys::VirtualFile>(file); 230 return file;
234} 231}
235 232
236ResultVal<FileSys::VirtualDir> VfsDirectoryServiceWrapper::OpenDirectory(const std::string& path_) { 233ResultVal<FileSys::VirtualDir> VfsDirectoryServiceWrapper::OpenDirectory(const std::string& path_) {
@@ -240,7 +237,7 @@ ResultVal<FileSys::VirtualDir> VfsDirectoryServiceWrapper::OpenDirectory(const s
240 // TODO(DarkLordZach): Find a better error code for this 237 // TODO(DarkLordZach): Find a better error code for this
241 return FileSys::ERROR_PATH_NOT_FOUND; 238 return FileSys::ERROR_PATH_NOT_FOUND;
242 } 239 }
243 return MakeResult(dir); 240 return dir;
244} 241}
245 242
246ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType( 243ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType(
@@ -252,12 +249,12 @@ ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType(
252 auto filename = Common::FS::GetFilename(path); 249 auto filename = Common::FS::GetFilename(path);
253 // TODO(Subv): Some games use the '/' path, find out what this means. 250 // TODO(Subv): Some games use the '/' path, find out what this means.
254 if (filename.empty()) 251 if (filename.empty())
255 return MakeResult(FileSys::EntryType::Directory); 252 return FileSys::EntryType::Directory;
256 253
257 if (dir->GetFile(filename) != nullptr) 254 if (dir->GetFile(filename) != nullptr)
258 return MakeResult(FileSys::EntryType::File); 255 return FileSys::EntryType::File;
259 if (dir->GetSubdirectory(filename) != nullptr) 256 if (dir->GetSubdirectory(filename) != nullptr)
260 return MakeResult(FileSys::EntryType::Directory); 257 return FileSys::EntryType::Directory;
261 return FileSys::ERROR_PATH_NOT_FOUND; 258 return FileSys::ERROR_PATH_NOT_FOUND;
262} 259}
263 260
@@ -270,7 +267,7 @@ ResultVal<FileSys::FileTimeStampRaw> VfsDirectoryServiceWrapper::GetFileTimeStam
270 if (GetEntryType(path).Failed()) { 267 if (GetEntryType(path).Failed()) {
271 return FileSys::ERROR_PATH_NOT_FOUND; 268 return FileSys::ERROR_PATH_NOT_FOUND;
272 } 269 }
273 return MakeResult(dir->GetFileTimeStamp(Common::FS::GetFilename(path))); 270 return dir->GetFileTimeStamp(Common::FS::GetFilename(path));
274} 271}
275 272
276FileSystemController::FileSystemController(Core::System& system_) : system{system_} {} 273FileSystemController::FileSystemController(Core::System& system_) : system{system_} {}
@@ -322,7 +319,7 @@ ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFSCurrentProcess()
322 return ResultUnknown; 319 return ResultUnknown;
323 } 320 }
324 321
325 return romfs_factory->OpenCurrentProcess(system.CurrentProcess()->GetTitleID()); 322 return romfs_factory->OpenCurrentProcess(system.GetCurrentProcessProgramID());
326} 323}
327 324
328ResultVal<FileSys::VirtualFile> FileSystemController::OpenPatchedRomFS( 325ResultVal<FileSys::VirtualFile> FileSystemController::OpenPatchedRomFS(
@@ -395,7 +392,7 @@ ResultVal<FileSys::VirtualDir> FileSystemController::OpenSaveDataSpace(
395 return FileSys::ERROR_ENTITY_NOT_FOUND; 392 return FileSys::ERROR_ENTITY_NOT_FOUND;
396 } 393 }
397 394
398 return MakeResult(save_data_factory->GetSaveDataSpaceDirectory(space)); 395 return save_data_factory->GetSaveDataSpaceDirectory(space);
399} 396}
400 397
401ResultVal<FileSys::VirtualDir> FileSystemController::OpenSDMC() const { 398ResultVal<FileSys::VirtualDir> FileSystemController::OpenSDMC() const {
@@ -421,7 +418,7 @@ ResultVal<FileSys::VirtualDir> FileSystemController::OpenBISPartition(
421 return FileSys::ERROR_INVALID_ARGUMENT; 418 return FileSys::ERROR_INVALID_ARGUMENT;
422 } 419 }
423 420
424 return MakeResult<FileSys::VirtualDir>(std::move(part)); 421 return part;
425} 422}
426 423
427ResultVal<FileSys::VirtualFile> FileSystemController::OpenBISPartitionStorage( 424ResultVal<FileSys::VirtualFile> FileSystemController::OpenBISPartitionStorage(
@@ -437,7 +434,7 @@ ResultVal<FileSys::VirtualFile> FileSystemController::OpenBISPartitionStorage(
437 return FileSys::ERROR_INVALID_ARGUMENT; 434 return FileSys::ERROR_INVALID_ARGUMENT;
438 } 435 }
439 436
440 return MakeResult<FileSys::VirtualFile>(std::move(part)); 437 return part;
441} 438}
442 439
443u64 FileSystemController::GetFreeSpaceSize(FileSys::StorageId id) const { 440u64 FileSystemController::GetFreeSpaceSize(FileSys::StorageId id) const {
@@ -507,7 +504,7 @@ FileSys::SaveDataSize FileSystemController::ReadSaveDataSize(FileSys::SaveDataTy
507 const auto res = system.GetAppLoader().ReadControlData(nacp); 504 const auto res = system.GetAppLoader().ReadControlData(nacp);
508 505
509 if (res != Loader::ResultStatus::Success) { 506 if (res != Loader::ResultStatus::Success) {
510 const FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID(), 507 const FileSys::PatchManager pm{system.GetCurrentProcessProgramID(),
511 system.GetFileSystemController(), 508 system.GetFileSystemController(),
512 system.GetContentProvider()}; 509 system.GetContentProvider()};
513 const auto metadata = pm.GetControlMetadata(); 510 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 50c788dd6..3501bc1a4 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -26,7 +26,6 @@
26#include "core/file_sys/system_archive/system_archive.h" 26#include "core/file_sys/system_archive/system_archive.h"
27#include "core/file_sys/vfs.h" 27#include "core/file_sys/vfs.h"
28#include "core/hle/ipc_helpers.h" 28#include "core/hle/ipc_helpers.h"
29#include "core/hle/kernel/k_process.h"
30#include "core/hle/service/filesystem/filesystem.h" 29#include "core/hle/service/filesystem/filesystem.h"
31#include "core/hle/service/filesystem/fsp_srv.h" 30#include "core/hle/service/filesystem/fsp_srv.h"
32#include "core/reporter.h" 31#include "core/reporter.h"
@@ -1035,7 +1034,7 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) {
1035 LOG_DEBUG(Service_FS, "called, program_index={}", program_index); 1034 LOG_DEBUG(Service_FS, "called, program_index={}", program_index);
1036 1035
1037 auto patched_romfs = fsc.OpenPatchedRomFSWithProgramIndex( 1036 auto patched_romfs = fsc.OpenPatchedRomFSWithProgramIndex(
1038 system.CurrentProcess()->GetTitleID(), program_index, FileSys::ContentRecordType::Program); 1037 system.GetCurrentProcessProgramID(), program_index, FileSys::ContentRecordType::Program);
1039 1038
1040 if (patched_romfs.Failed()) { 1039 if (patched_romfs.Failed()) {
1041 // TODO: Find the right error code to use here 1040 // TODO: Find the right error code to use here
diff --git a/src/core/hle/service/glue/arp.cpp b/src/core/hle/service/glue/arp.cpp
index 70cd63c6b..2feead2aa 100644
--- a/src/core/hle/service/glue/arp.cpp
+++ b/src/core/hle/service/glue/arp.cpp
@@ -6,7 +6,6 @@
6 6
7#include "common/logging/log.h" 7#include "common/logging/log.h"
8#include "core/core.h" 8#include "core/core.h"
9#include "core/file_sys/control_metadata.h"
10#include "core/hle/ipc_helpers.h" 9#include "core/hle/ipc_helpers.h"
11#include "core/hle/kernel/k_process.h" 10#include "core/hle/kernel/k_process.h"
12#include "core/hle/kernel/kernel.h" 11#include "core/hle/kernel/kernel.h"
@@ -27,7 +26,7 @@ std::optional<u64> GetTitleIDForProcessID(const Core::System& system, u64 proces
27 return std::nullopt; 26 return std::nullopt;
28 } 27 }
29 28
30 return (*iter)->GetTitleID(); 29 return (*iter)->GetProgramID();
31} 30}
32} // Anonymous namespace 31} // Anonymous namespace
33 32
diff --git a/src/core/hle/service/glue/glue_manager.cpp b/src/core/hle/service/glue/glue_manager.cpp
index aa9d48c0c..48e133b48 100644
--- a/src/core/hle/service/glue/glue_manager.cpp
+++ b/src/core/hle/service/glue/glue_manager.cpp
@@ -26,7 +26,7 @@ ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id)
26 return ERR_NOT_REGISTERED; 26 return ERR_NOT_REGISTERED;
27 } 27 }
28 28
29 return MakeResult<ApplicationLaunchProperty>(iter->second.launch); 29 return iter->second.launch;
30} 30}
31 31
32ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const { 32ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
@@ -39,7 +39,7 @@ ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
39 return ERR_NOT_REGISTERED; 39 return ERR_NOT_REGISTERED;
40 } 40 }
41 41
42 return MakeResult<std::vector<u8>>(iter->second.control); 42 return iter->second.control;
43} 43}
44 44
45ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch, 45ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
diff --git a/src/core/hle/service/glue/glue_manager.h b/src/core/hle/service/glue/glue_manager.h
index a7f5ce3ee..4bc5297c6 100644
--- a/src/core/hle/service/glue/glue_manager.h
+++ b/src/core/hle/service/glue/glue_manager.h
@@ -7,7 +7,6 @@
7#include <map> 7#include <map>
8#include <vector> 8#include <vector>
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "core/file_sys/control_metadata.h"
11#include "core/file_sys/romfs_factory.h" 10#include "core/file_sys/romfs_factory.h"
12#include "core/hle/result.h" 11#include "core/hle/result.h"
13 12
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index b7f551e40..196876810 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -16,7 +16,6 @@
16#include "core/hle/kernel/k_event.h" 16#include "core/hle/kernel/k_event.h"
17#include "core/hle/kernel/k_readable_event.h" 17#include "core/hle/kernel/k_readable_event.h"
18#include "core/hle/kernel/k_writable_event.h" 18#include "core/hle/kernel/k_writable_event.h"
19#include "core/hle/kernel/kernel.h"
20#include "core/hle/service/hid/controllers/npad.h" 19#include "core/hle/service/hid/controllers/npad.h"
21#include "core/hle/service/kernel_helpers.h" 20#include "core/hle/service/kernel_helpers.h"
22 21
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 043320d50..10c64d41a 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -8,13 +8,11 @@
8#include "common/settings.h" 8#include "common/settings.h"
9#include "core/core.h" 9#include "core/core.h"
10#include "core/core_timing.h" 10#include "core/core_timing.h"
11#include "core/frontend/emu_window.h"
12#include "core/frontend/input.h" 11#include "core/frontend/input.h"
13#include "core/hle/ipc_helpers.h" 12#include "core/hle/ipc_helpers.h"
14#include "core/hle/kernel/k_readable_event.h" 13#include "core/hle/kernel/k_readable_event.h"
15#include "core/hle/kernel/k_shared_memory.h" 14#include "core/hle/kernel/k_shared_memory.h"
16#include "core/hle/kernel/k_transfer_memory.h" 15#include "core/hle/kernel/k_transfer_memory.h"
17#include "core/hle/kernel/k_writable_event.h"
18#include "core/hle/kernel/kernel.h" 16#include "core/hle/kernel/kernel.h"
19#include "core/hle/service/hid/errors.h" 17#include "core/hle/service/hid/errors.h"
20#include "core/hle/service/hid/hid.h" 18#include "core/hle/service/hid/hid.h"
diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cpp
index 4a92c6234..8812b8ecb 100644
--- a/src/core/hle/service/hid/irs.cpp
+++ b/src/core/hle/service/hid/irs.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/swap.h"
6#include "core/core.h" 5#include "core/core.h"
7#include "core/core_timing.h" 6#include "core/core_timing.h"
8#include "core/hle/ipc_helpers.h" 7#include "core/hle/ipc_helpers.h"
diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp
index 24b7e4435..32eff3b2a 100644
--- a/src/core/hle/service/ldr/ldr.cpp
+++ b/src/core/hle/service/ldr/ldr.cpp
@@ -12,7 +12,6 @@
12#include "core/core.h" 12#include "core/core.h"
13#include "core/hle/ipc_helpers.h" 13#include "core/hle/ipc_helpers.h"
14#include "core/hle/kernel/k_page_table.h" 14#include "core/hle/kernel/k_page_table.h"
15#include "core/hle/kernel/k_process.h"
16#include "core/hle/kernel/k_system_control.h" 15#include "core/hle/kernel/k_system_control.h"
17#include "core/hle/kernel/svc_results.h" 16#include "core/hle/kernel/svc_results.h"
18#include "core/hle/service/ldr/ldr.h" 17#include "core/hle/service/ldr/ldr.h"
@@ -247,7 +246,7 @@ public:
247 return; 246 return;
248 } 247 }
249 248
250 if (system.CurrentProcess()->GetTitleID() != header.application_id) { 249 if (system.GetCurrentProcessProgramID() != header.application_id) {
251 LOG_ERROR(Service_LDR, 250 LOG_ERROR(Service_LDR,
252 "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 "
253 "{:016X})!", 252 "{:016X})!",
@@ -335,7 +334,7 @@ public:
335 CASCADE_CODE(result); 334 CASCADE_CODE(result);
336 335
337 if (ValidateRegionForMap(page_table, addr, size)) { 336 if (ValidateRegionForMap(page_table, addr, size)) {
338 return MakeResult<VAddr>(addr); 337 return addr;
339 } 338 }
340 } 339 }
341 340
@@ -371,7 +370,7 @@ public:
371 } 370 }
372 371
373 if (ValidateRegionForMap(page_table, addr, size)) { 372 if (ValidateRegionForMap(page_table, addr, size)) {
374 return MakeResult<VAddr>(addr); 373 return addr;
375 } 374 }
376 } 375 }
377 376
diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index 794504314..e40383134 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -2,19 +2,16 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <sstream>
6#include <string> 5#include <string>
7 6
8#include <optional> 7#include <optional>
9#include <unordered_map> 8#include <unordered_map>
10#include <boost/container_hash/hash.hpp> 9#include <boost/container_hash/hash.hpp>
11#include "common/logging/log.h" 10#include "common/logging/log.h"
12#include "common/scope_exit.h"
13#include "core/core.h" 11#include "core/core.h"
14#include "core/hle/ipc_helpers.h" 12#include "core/hle/ipc_helpers.h"
15#include "core/hle/service/lm/lm.h" 13#include "core/hle/service/lm/lm.h"
16#include "core/hle/service/service.h" 14#include "core/hle/service/service.h"
17#include "core/memory.h"
18 15
19namespace Service::LM { 16namespace Service::LM {
20enum class LogSeverity : u8 { 17enum class LogSeverity : u8 {
diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp
index 4fef2aea4..ca4ed35bb 100644
--- a/src/core/hle/service/mii/mii_manager.cpp
+++ b/src/core/hle/service/mii/mii_manager.cpp
@@ -443,14 +443,14 @@ ResultVal<std::vector<MiiInfoElement>> MiiManager::GetDefault(SourceFlag source_
443 std::vector<MiiInfoElement> result; 443 std::vector<MiiInfoElement> result;
444 444
445 if ((source_flag & SourceFlag::Default) == SourceFlag::None) { 445 if ((source_flag & SourceFlag::Default) == SourceFlag::None) {
446 return MakeResult(std::move(result)); 446 return result;
447 } 447 }
448 448
449 for (std::size_t index = BaseMiiCount; index < DefaultMiiCount; index++) { 449 for (std::size_t index = BaseMiiCount; index < DefaultMiiCount; index++) {
450 result.emplace_back(BuildDefault(index), Source::Default); 450 result.emplace_back(BuildDefault(index), Source::Default);
451 } 451 }
452 452
453 return MakeResult(std::move(result)); 453 return result;
454} 454}
455 455
456ResultCode MiiManager::GetIndex([[maybe_unused]] const MiiInfo& info, u32& index) { 456ResultCode MiiManager::GetIndex([[maybe_unused]] const MiiInfo& info, u32& index) {
diff --git a/src/core/hle/service/mii/raw_data.h b/src/core/hle/service/mii/raw_data.h
index a0d2b9d3a..bd90c2162 100644
--- a/src/core/hle/service/mii/raw_data.h
+++ b/src/core/hle/service/mii/raw_data.h
@@ -6,7 +6,6 @@
6 6
7#include <array> 7#include <array>
8 8
9#include "common/common_types.h"
10#include "core/hle/service/mii/mii_manager.h" 9#include "core/hle/service/mii/mii_manager.h"
11 10
12namespace Service::Mii::RawData { 11namespace Service::Mii::RawData {
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp
index 6791f20a5..693ffc71a 100644
--- a/src/core/hle/service/nfp/nfp.cpp
+++ b/src/core/hle/service/nfp/nfp.cpp
@@ -9,8 +9,6 @@
9#include "core/core.h" 9#include "core/core.h"
10#include "core/hle/ipc_helpers.h" 10#include "core/hle/ipc_helpers.h"
11#include "core/hle/kernel/k_event.h" 11#include "core/hle/kernel/k_event.h"
12#include "core/hle/kernel/k_thread.h"
13#include "core/hle/kernel/kernel.h"
14#include "core/hle/lock.h" 12#include "core/hle/lock.h"
15#include "core/hle/service/nfp/nfp.h" 13#include "core/hle/service/nfp/nfp.h"
16#include "core/hle/service/nfp/nfp_user.h" 14#include "core/hle/service/nfp/nfp_user.h"
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp
index f13dc8b0d..a253dd066 100644
--- a/src/core/hle/service/nifm/nifm.cpp
+++ b/src/core/hle/service/nifm/nifm.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/settings.h"
6#include "core/core.h" 5#include "core/core.h"
7#include "core/hle/ipc_helpers.h" 6#include "core/hle/ipc_helpers.h"
8#include "core/hle/kernel/k_event.h" 7#include "core/hle/kernel/k_event.h"
diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp
index 30fb060b8..196f274e1 100644
--- a/src/core/hle/service/nim/nim.cpp
+++ b/src/core/hle/service/nim/nim.cpp
@@ -7,7 +7,6 @@
7#include "core/core.h" 7#include "core/core.h"
8#include "core/hle/ipc_helpers.h" 8#include "core/hle/ipc_helpers.h"
9#include "core/hle/kernel/k_event.h" 9#include "core/hle/kernel/k_event.h"
10#include "core/hle/kernel/kernel.h"
11#include "core/hle/service/kernel_helpers.h" 10#include "core/hle/service/kernel_helpers.h"
12#include "core/hle/service/nim/nim.h" 11#include "core/hle/service/nim/nim.h"
13#include "core/hle/service/service.h" 12#include "core/hle/service/service.h"
diff --git a/src/core/hle/service/ns/language.h b/src/core/hle/service/ns/language.h
index d84c3f277..2cc8e4806 100644
--- a/src/core/hle/service/ns/language.h
+++ b/src/core/hle/service/ns/language.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <optional> 7#include <optional>
8#include <string>
9#include "common/common_types.h" 8#include "common/common_types.h"
10 9
11namespace Service::Set { 10namespace Service::Set {
@@ -43,4 +42,4 @@ constexpr u32 GetSupportedLanguageFlag(const ApplicationLanguage lang) {
43const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList(ApplicationLanguage lang); 42const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList(ApplicationLanguage lang);
44std::optional<ApplicationLanguage> ConvertToApplicationLanguage(Set::LanguageCode language_code); 43std::optional<ApplicationLanguage> ConvertToApplicationLanguage(Set::LanguageCode language_code);
45std::optional<Set::LanguageCode> ConvertToLanguageCode(ApplicationLanguage lang); 44std::optional<Set::LanguageCode> ConvertToLanguageCode(ApplicationLanguage lang);
46} // namespace Service::NS \ No newline at end of file 45} // namespace Service::NS
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp
index 931b48f72..64ffc8572 100644
--- a/src/core/hle/service/ns/ns.cpp
+++ b/src/core/hle/service/ns/ns.cpp
@@ -414,7 +414,7 @@ ResultVal<u8> IApplicationManagerInterface::GetApplicationDesiredLanguage(
414 for (const auto lang : *priority_list) { 414 for (const auto lang : *priority_list) {
415 const auto supported_flag = GetSupportedLanguageFlag(lang); 415 const auto supported_flag = GetSupportedLanguageFlag(lang);
416 if (supported_languages == 0 || (supported_languages & supported_flag) == supported_flag) { 416 if (supported_languages == 0 || (supported_languages & supported_flag) == supported_flag) {
417 return MakeResult(static_cast<u8>(lang)); 417 return static_cast<u8>(lang);
418 } 418 }
419 } 419 }
420 420
@@ -448,7 +448,7 @@ ResultVal<u64> IApplicationManagerInterface::ConvertApplicationLanguageToLanguag
448 return ERR_APPLICATION_LANGUAGE_NOT_FOUND; 448 return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
449 } 449 }
450 450
451 return MakeResult(static_cast<u64>(*language_code)); 451 return static_cast<u64>(*language_code);
452} 452}
453 453
454IApplicationVersionInterface::IApplicationVersionInterface(Core::System& system_) 454IApplicationVersionInterface::IApplicationVersionInterface(Core::System& system_)
diff --git a/src/core/hle/service/nvdrv/devices/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h
index 5b73a5a34..3d874243a 100644
--- a/src/core/hle/service/nvdrv/devices/nvdevice.h
+++ b/src/core/hle/service/nvdrv/devices/nvdevice.h
@@ -5,11 +5,8 @@
5#pragma once 5#pragma once
6 6
7#include <vector> 7#include <vector>
8#include "common/bit_field.h"
9#include "common/common_types.h" 8#include "common/common_types.h"
10#include "common/swap.h"
11#include "core/hle/service/nvdrv/nvdata.h" 9#include "core/hle/service/nvdrv/nvdata.h"
12#include "core/hle/service/service.h"
13 10
14namespace Core { 11namespace Core {
15class System; 12class System;
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
index 4ee8c5733..68f1e9060 100644
--- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
@@ -10,7 +10,6 @@
10#include "core/hle/service/nvdrv/devices/nvmap.h" 10#include "core/hle/service/nvdrv/devices/nvmap.h"
11#include "core/perf_stats.h" 11#include "core/perf_stats.h"
12#include "video_core/gpu.h" 12#include "video_core/gpu.h"
13#include "video_core/renderer_base.h"
14 13
15namespace Service::Nvidia::Devices { 14namespace Service::Nvidia::Devices {
16 15
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
index 7dc41d875..85170cdb3 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
@@ -10,10 +10,8 @@
10#include "core/core.h" 10#include "core/core.h"
11#include "core/hle/service/nvdrv/devices/nvhost_as_gpu.h" 11#include "core/hle/service/nvdrv/devices/nvhost_as_gpu.h"
12#include "core/hle/service/nvdrv/devices/nvmap.h" 12#include "core/hle/service/nvdrv/devices/nvmap.h"
13#include "core/memory.h"
14#include "video_core/memory_manager.h" 13#include "video_core/memory_manager.h"
15#include "video_core/rasterizer_interface.h" 14#include "video_core/rasterizer_interface.h"
16#include "video_core/renderer_base.h"
17 15
18namespace Service::Nvidia::Devices { 16namespace Service::Nvidia::Devices {
19 17
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
index d8b684f4f..05b4e2151 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
@@ -7,7 +7,6 @@
7#include "common/logging/log.h" 7#include "common/logging/log.h"
8#include "core/core.h" 8#include "core/core.h"
9#include "core/core_timing.h" 9#include "core/core_timing.h"
10#include "core/core_timing_util.h"
11#include "core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h" 10#include "core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h"
12 11
13namespace Service::Nvidia::Devices { 12namespace Service::Nvidia::Devices {
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
index 54ac105d5..0a043e386 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
@@ -10,7 +10,6 @@
10#include "core/hle/service/nvdrv/syncpoint_manager.h" 10#include "core/hle/service/nvdrv/syncpoint_manager.h"
11#include "core/memory.h" 11#include "core/memory.h"
12#include "video_core/gpu.h" 12#include "video_core/gpu.h"
13#include "video_core/memory_manager.h"
14 13
15namespace Service::Nvidia::Devices { 14namespace Service::Nvidia::Devices {
16namespace { 15namespace {
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
index 6c1edce33..0d7d4ad03 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
@@ -6,7 +6,6 @@
6#include "common/logging/log.h" 6#include "common/logging/log.h"
7#include "core/core.h" 7#include "core/core.h"
8#include "core/hle/service/nvdrv/devices/nvhost_nvdec.h" 8#include "core/hle/service/nvdrv/devices/nvhost_nvdec.h"
9#include "video_core/memory_manager.h"
10#include "video_core/renderer_base.h" 9#include "video_core/renderer_base.h"
11 10
12namespace Service::Nvidia::Devices { 11namespace Service::Nvidia::Devices {
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
index ae4199b79..351625c17 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <map>
8#include <vector> 7#include <vector>
9#include "common/common_types.h" 8#include "common/common_types.h"
10#include "common/swap.h" 9#include "common/swap.h"
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
index 21d101e8a..eac4dd530 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
@@ -6,7 +6,6 @@
6#include "common/logging/log.h" 6#include "common/logging/log.h"
7#include "core/core.h" 7#include "core/core.h"
8#include "core/hle/service/nvdrv/devices/nvhost_vic.h" 8#include "core/hle/service/nvdrv/devices/nvhost_vic.h"
9#include "video_core/memory_manager.h"
10#include "video_core/renderer_base.h" 9#include "video_core/renderer_base.h"
11 10
12namespace Service::Nvidia::Devices { 11namespace Service::Nvidia::Devices {
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp
index ff405099a..aa7e47cbf 100644
--- a/src/core/hle/service/nvdrv/nvdrv.cpp
+++ b/src/core/hle/service/nvdrv/nvdrv.cpp
@@ -8,7 +8,6 @@
8#include "core/core.h" 8#include "core/core.h"
9#include "core/hle/ipc_helpers.h" 9#include "core/hle/ipc_helpers.h"
10#include "core/hle/kernel/k_event.h" 10#include "core/hle/kernel/k_event.h"
11#include "core/hle/kernel/k_readable_event.h"
12#include "core/hle/kernel/k_writable_event.h" 11#include "core/hle/kernel/k_writable_event.h"
13#include "core/hle/service/nvdrv/devices/nvdevice.h" 12#include "core/hle/service/nvdrv/devices/nvdevice.h"
14#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" 13#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h"
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp
index d61fb73dc..c16babe14 100644
--- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp
+++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp
@@ -7,9 +7,6 @@
7#include "core/core.h" 7#include "core/core.h"
8#include "core/hle/ipc_helpers.h" 8#include "core/hle/ipc_helpers.h"
9#include "core/hle/kernel/k_readable_event.h" 9#include "core/hle/kernel/k_readable_event.h"
10#include "core/hle/kernel/k_thread.h"
11#include "core/hle/kernel/k_writable_event.h"
12#include "core/hle/kernel/kernel.h"
13#include "core/hle/service/nvdrv/nvdata.h" 10#include "core/hle/service/nvdrv/nvdata.h"
14#include "core/hle/service/nvdrv/nvdrv.h" 11#include "core/hle/service/nvdrv/nvdrv.h"
15#include "core/hle/service/nvdrv/nvdrv_interface.h" 12#include "core/hle/service/nvdrv/nvdrv_interface.h"
diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h
index 78de3f354..7b7baeaea 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.h
+++ b/src/core/hle/service/nvflinger/buffer_queue.h
@@ -8,7 +8,6 @@
8#include <list> 8#include <list>
9#include <mutex> 9#include <mutex>
10#include <optional> 10#include <optional>
11#include <vector>
12 11
13#include "common/common_funcs.h" 12#include "common/common_funcs.h"
14#include "common/math_util.h" 13#include "common/math_util.h"
diff --git a/src/core/hle/service/pctl/pctl_module.cpp b/src/core/hle/service/pctl/pctl_module.cpp
index 6949fcf3b..240776101 100644
--- a/src/core/hle/service/pctl/pctl_module.cpp
+++ b/src/core/hle/service/pctl/pctl_module.cpp
@@ -7,7 +7,6 @@
7#include "core/file_sys/control_metadata.h" 7#include "core/file_sys/control_metadata.h"
8#include "core/file_sys/patch_manager.h" 8#include "core/file_sys/patch_manager.h"
9#include "core/hle/ipc_helpers.h" 9#include "core/hle/ipc_helpers.h"
10#include "core/hle/kernel/k_process.h"
11#include "core/hle/service/pctl/pctl.h" 10#include "core/hle/service/pctl/pctl.h"
12#include "core/hle/service/pctl/pctl_module.h" 11#include "core/hle/service/pctl/pctl_module.h"
13 12
@@ -45,7 +44,7 @@ public:
45 {1014, nullptr, "ConfirmPlayableApplicationVideoOld"}, 44 {1014, nullptr, "ConfirmPlayableApplicationVideoOld"},
46 {1015, nullptr, "ConfirmPlayableApplicationVideo"}, 45 {1015, nullptr, "ConfirmPlayableApplicationVideo"},
47 {1016, nullptr, "ConfirmShowNewsPermission"}, 46 {1016, nullptr, "ConfirmShowNewsPermission"},
48 {1017, nullptr, "EndFreeCommunication"}, 47 {1017, &IParentalControlService::EndFreeCommunication, "EndFreeCommunication"},
49 {1018, &IParentalControlService::IsFreeCommunicationAvailable, "IsFreeCommunicationAvailable"}, 48 {1018, &IParentalControlService::IsFreeCommunicationAvailable, "IsFreeCommunicationAvailable"},
50 {1031, &IParentalControlService::IsRestrictionEnabled, "IsRestrictionEnabled"}, 49 {1031, &IParentalControlService::IsRestrictionEnabled, "IsRestrictionEnabled"},
51 {1032, nullptr, "GetSafetyLevel"}, 50 {1032, nullptr, "GetSafetyLevel"},
@@ -189,7 +188,7 @@ private:
189 188
190 // TODO(ogniK): Recovery flag initialization for pctl:r 189 // TODO(ogniK): Recovery flag initialization for pctl:r
191 190
192 const auto tid = system.CurrentProcess()->GetTitleID(); 191 const auto tid = system.GetCurrentProcessProgramID();
193 if (tid != 0) { 192 if (tid != 0) {
194 const FileSys::PatchManager pm{tid, system.GetFileSystemController(), 193 const FileSys::PatchManager pm{tid, system.GetFileSystemController(),
195 system.GetContentProvider()}; 194 system.GetContentProvider()};
@@ -237,6 +236,13 @@ private:
237 rb.Push(ResultSuccess); 236 rb.Push(ResultSuccess);
238 } 237 }
239 238
239 void EndFreeCommunication(Kernel::HLERequestContext& ctx) {
240 LOG_WARNING(Service_PCTL, "(STUBBED) called");
241
242 IPC::ResponseBuilder rb{ctx, 2};
243 rb.Push(ResultSuccess);
244 }
245
240 void IsFreeCommunicationAvailable(Kernel::HLERequestContext& ctx) { 246 void IsFreeCommunicationAvailable(Kernel::HLERequestContext& ctx) {
241 LOG_WARNING(Service_PCTL, "(STUBBED) called"); 247 LOG_WARNING(Service_PCTL, "(STUBBED) called");
242 248
diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp
index f675740b4..88fc5b5cc 100644
--- a/src/core/hle/service/pm/pm.cpp
+++ b/src/core/hle/service/pm/pm.cpp
@@ -101,7 +101,7 @@ private:
101 101
102 const auto process = 102 const auto process =
103 SearchProcessList(kernel.GetProcessList(), [title_id](const auto& proc) { 103 SearchProcessList(kernel.GetProcessList(), [title_id](const auto& proc) {
104 return proc->GetTitleID() == title_id; 104 return proc->GetProgramID() == title_id;
105 }); 105 });
106 106
107 if (!process.has_value()) { 107 if (!process.has_value()) {
@@ -152,7 +152,7 @@ private:
152 152
153 IPC::ResponseBuilder rb{ctx, 4}; 153 IPC::ResponseBuilder rb{ctx, 4};
154 rb.Push(ResultSuccess); 154 rb.Push(ResultSuccess);
155 rb.Push((*process)->GetTitleID()); 155 rb.Push((*process)->GetProgramID());
156 } 156 }
157 157
158 const std::vector<Kernel::KProcess*>& process_list; 158 const std::vector<Kernel::KProcess*>& process_list;
diff --git a/src/core/hle/service/prepo/prepo.cpp b/src/core/hle/service/prepo/prepo.cpp
index 32db6834c..5c8a44688 100644
--- a/src/core/hle/service/prepo/prepo.cpp
+++ b/src/core/hle/service/prepo/prepo.cpp
@@ -6,7 +6,6 @@
6#include "common/logging/log.h" 6#include "common/logging/log.h"
7#include "core/core.h" 7#include "core/core.h"
8#include "core/hle/ipc_helpers.h" 8#include "core/hle/ipc_helpers.h"
9#include "core/hle/kernel/k_process.h"
10#include "core/hle/service/acc/profile_manager.h" 9#include "core/hle/service/acc/profile_manager.h"
11#include "core/hle/service/prepo/prepo.h" 10#include "core/hle/service/prepo/prepo.h"
12#include "core/hle/service/service.h" 11#include "core/hle/service/service.h"
@@ -73,7 +72,7 @@ private:
73 Type, process_id, data1.size(), data2.size()); 72 Type, process_id, data1.size(), data2.size());
74 73
75 const auto& reporter{system.GetReporter()}; 74 const auto& reporter{system.GetReporter()};
76 reporter.SavePlayReport(Type, system.CurrentProcess()->GetTitleID(), {data1, data2}, 75 reporter.SavePlayReport(Type, system.GetCurrentProcessProgramID(), {data1, data2},
77 process_id); 76 process_id);
78 77
79 IPC::ResponseBuilder rb{ctx, 2}; 78 IPC::ResponseBuilder rb{ctx, 2};
@@ -101,7 +100,7 @@ private:
101 Type, user_id[1], user_id[0], process_id, data1.size(), data2.size()); 100 Type, user_id[1], user_id[0], process_id, data1.size(), data2.size());
102 101
103 const auto& reporter{system.GetReporter()}; 102 const auto& reporter{system.GetReporter()};
104 reporter.SavePlayReport(Type, system.CurrentProcess()->GetTitleID(), {data1, data2}, 103 reporter.SavePlayReport(Type, system.GetCurrentProcessProgramID(), {data1, data2},
105 process_id, user_id); 104 process_id, user_id);
106 105
107 IPC::ResponseBuilder rb{ctx, 2}; 106 IPC::ResponseBuilder rb{ctx, 2};
diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cpp
index 22ff5269c..5d248f671 100644
--- a/src/core/hle/service/ptm/psm.cpp
+++ b/src/core/hle/service/ptm/psm.cpp
@@ -8,7 +8,6 @@
8#include "core/core.h" 8#include "core/core.h"
9#include "core/hle/ipc_helpers.h" 9#include "core/hle/ipc_helpers.h"
10#include "core/hle/kernel/k_event.h" 10#include "core/hle/kernel/k_event.h"
11#include "core/hle/kernel/kernel.h"
12#include "core/hle/service/kernel_helpers.h" 11#include "core/hle/service/kernel_helpers.h"
13#include "core/hle/service/ptm/psm.h" 12#include "core/hle/service/ptm/psm.h"
14#include "core/hle/service/service.h" 13#include "core/hle/service/service.h"
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 065133166..f54e6fe56 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -2,19 +2,15 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm>
6#include <fmt/format.h> 5#include <fmt/format.h>
7#include "common/assert.h" 6#include "common/assert.h"
8#include "common/logging/log.h" 7#include "common/logging/log.h"
9#include "common/settings.h" 8#include "common/settings.h"
10#include "common/string_util.h"
11#include "core/core.h" 9#include "core/core.h"
12#include "core/hle/ipc.h" 10#include "core/hle/ipc.h"
13#include "core/hle/ipc_helpers.h" 11#include "core/hle/ipc_helpers.h"
14#include "core/hle/kernel/k_client_port.h"
15#include "core/hle/kernel/k_process.h" 12#include "core/hle/kernel/k_process.h"
16#include "core/hle/kernel/k_server_port.h" 13#include "core/hle/kernel/k_server_port.h"
17#include "core/hle/kernel/k_thread.h"
18#include "core/hle/kernel/kernel.h" 14#include "core/hle/kernel/kernel.h"
19#include "core/hle/service/acc/acc.h" 15#include "core/hle/service/acc/acc.h"
20#include "core/hle/service/am/am.h" 16#include "core/hle/service/am/am.h"
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index ae4dc4a75..eaa172595 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -12,8 +12,6 @@
12#include "core/hle/kernel/k_port.h" 12#include "core/hle/kernel/k_port.h"
13#include "core/hle/kernel/k_scoped_resource_reservation.h" 13#include "core/hle/kernel/k_scoped_resource_reservation.h"
14#include "core/hle/kernel/k_server_port.h" 14#include "core/hle/kernel/k_server_port.h"
15#include "core/hle/kernel/k_server_session.h"
16#include "core/hle/kernel/k_session.h"
17#include "core/hle/result.h" 15#include "core/hle/result.h"
18#include "core/hle/service/sm/sm.h" 16#include "core/hle/service/sm/sm.h"
19#include "core/hle/service/sm/sm_controller.h" 17#include "core/hle/service/sm/sm_controller.h"
@@ -87,7 +85,7 @@ ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name
87 auto handler = it->second; 85 auto handler = it->second;
88 port->GetServerPort().SetSessionHandler(std::move(handler)); 86 port->GetServerPort().SetSessionHandler(std::move(handler));
89 87
90 return MakeResult(port); 88 return port;
91} 89}
92 90
93/** 91/**
@@ -165,7 +163,7 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext&
165 163
166 LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId()); 164 LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId());
167 165
168 return MakeResult(session); 166 return session;
169} 167}
170 168
171void SM::RegisterService(Kernel::HLERequestContext& ctx) { 169void SM::RegisterService(Kernel::HLERequestContext& ctx) {
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h
index 068c78588..021eb51b4 100644
--- a/src/core/hle/service/sm/sm.h
+++ b/src/core/hle/service/sm/sm.h
@@ -6,7 +6,6 @@
6 6
7#include <memory> 7#include <memory>
8#include <string> 8#include <string>
9#include <type_traits>
10#include <unordered_map> 9#include <unordered_map>
11 10
12#include "common/concepts.h" 11#include "common/concepts.h"
diff --git a/src/core/hle/service/sm/sm_controller.cpp b/src/core/hle/service/sm/sm_controller.cpp
index b5fbc4569..09f9ecee1 100644
--- a/src/core/hle/service/sm/sm_controller.cpp
+++ b/src/core/hle/service/sm/sm_controller.cpp
@@ -7,10 +7,8 @@
7#include "core/core.h" 7#include "core/core.h"
8#include "core/hle/ipc_helpers.h" 8#include "core/hle/ipc_helpers.h"
9#include "core/hle/kernel/k_client_port.h" 9#include "core/hle/kernel/k_client_port.h"
10#include "core/hle/kernel/k_client_session.h"
11#include "core/hle/kernel/k_port.h" 10#include "core/hle/kernel/k_port.h"
12#include "core/hle/kernel/k_scoped_resource_reservation.h" 11#include "core/hle/kernel/k_scoped_resource_reservation.h"
13#include "core/hle/kernel/k_server_port.h"
14#include "core/hle/kernel/k_server_session.h" 12#include "core/hle/kernel/k_server_session.h"
15#include "core/hle/kernel/k_session.h" 13#include "core/hle/kernel/k_session.h"
16#include "core/hle/service/sm/sm_controller.h" 14#include "core/hle/service/sm/sm_controller.h"
diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp
index b9e765f1d..f83272633 100644
--- a/src/core/hle/service/sockets/bsd.cpp
+++ b/src/core/hle/service/sockets/bsd.cpp
@@ -4,7 +4,6 @@
4 4
5#include <array> 5#include <array>
6#include <memory> 6#include <memory>
7#include <string>
8#include <utility> 7#include <utility>
9#include <vector> 8#include <vector>
10 9
diff --git a/src/core/hle/service/spl/spl_module.cpp b/src/core/hle/service/spl/spl_module.cpp
index ed4c06260..10f7d1461 100644
--- a/src/core/hle/service/spl/spl_module.cpp
+++ b/src/core/hle/service/spl/spl_module.cpp
@@ -120,40 +120,40 @@ ResultVal<u64> Module::Interface::GetConfigImpl(ConfigItem config_item) const {
120 return ResultSecureMonitorNotImplemented; 120 return ResultSecureMonitorNotImplemented;
121 case ConfigItem::ExosphereApiVersion: 121 case ConfigItem::ExosphereApiVersion:
122 // Get information about the current exosphere version. 122 // Get information about the current exosphere version.
123 return MakeResult((u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MAJOR} << 56) | 123 return (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MAJOR} << 56) |
124 (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MINOR} << 48) | 124 (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MINOR} << 48) |
125 (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MICRO} << 40) | 125 (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MICRO} << 40) |
126 (static_cast<u64>(HLE::ApiVersion::GetTargetFirmware()))); 126 (static_cast<u64>(HLE::ApiVersion::GetTargetFirmware()));
127 case ConfigItem::ExosphereNeedsReboot: 127 case ConfigItem::ExosphereNeedsReboot:
128 // We are executing, so we aren't in the process of rebooting. 128 // We are executing, so we aren't in the process of rebooting.
129 return MakeResult(u64{0}); 129 return u64{0};
130 case ConfigItem::ExosphereNeedsShutdown: 130 case ConfigItem::ExosphereNeedsShutdown:
131 // We are executing, so we aren't in the process of shutting down. 131 // We are executing, so we aren't in the process of shutting down.
132 return MakeResult(u64{0}); 132 return u64{0};
133 case ConfigItem::ExosphereGitCommitHash: 133 case ConfigItem::ExosphereGitCommitHash:
134 // Get information about the current exosphere git commit hash. 134 // Get information about the current exosphere git commit hash.
135 return MakeResult(u64{0}); 135 return u64{0};
136 case ConfigItem::ExosphereHasRcmBugPatch: 136 case ConfigItem::ExosphereHasRcmBugPatch:
137 // Get information about whether this unit has the RCM bug patched. 137 // Get information about whether this unit has the RCM bug patched.
138 return MakeResult(u64{0}); 138 return u64{0};
139 case ConfigItem::ExosphereBlankProdInfo: 139 case ConfigItem::ExosphereBlankProdInfo:
140 // Get whether this unit should simulate a "blanked" PRODINFO. 140 // Get whether this unit should simulate a "blanked" PRODINFO.
141 return MakeResult(u64{0}); 141 return u64{0};
142 case ConfigItem::ExosphereAllowCalWrites: 142 case ConfigItem::ExosphereAllowCalWrites:
143 // Get whether this unit should allow writing to the calibration partition. 143 // Get whether this unit should allow writing to the calibration partition.
144 return MakeResult(u64{0}); 144 return u64{0};
145 case ConfigItem::ExosphereEmummcType: 145 case ConfigItem::ExosphereEmummcType:
146 // Get what kind of emummc this unit has active. 146 // Get what kind of emummc this unit has active.
147 return MakeResult(u64{0}); 147 return u64{0};
148 case ConfigItem::ExospherePayloadAddress: 148 case ConfigItem::ExospherePayloadAddress:
149 // Gets the physical address of the reboot payload buffer, if one exists. 149 // Gets the physical address of the reboot payload buffer, if one exists.
150 return ResultSecureMonitorNotInitialized; 150 return ResultSecureMonitorNotInitialized;
151 case ConfigItem::ExosphereLogConfiguration: 151 case ConfigItem::ExosphereLogConfiguration:
152 // Get the log configuration. 152 // Get the log configuration.
153 return MakeResult(u64{0}); 153 return u64{0};
154 case ConfigItem::ExosphereForceEnableUsb30: 154 case ConfigItem::ExosphereForceEnableUsb30:
155 // Get whether usb 3.0 should be force-enabled. 155 // Get whether usb 3.0 should be force-enabled.
156 return MakeResult(u64{0}); 156 return u64{0};
157 default: 157 default:
158 return ResultSecureMonitorInvalidArgument; 158 return ResultSecureMonitorInvalidArgument;
159 } 159 }
diff --git a/src/core/hle/service/time/local_system_clock_context_writer.h b/src/core/hle/service/time/local_system_clock_context_writer.h
index 6be617392..ac6c7b4b1 100644
--- a/src/core/hle/service/time/local_system_clock_context_writer.h
+++ b/src/core/hle/service/time/local_system_clock_context_writer.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "core/hle/service/time/errors.h"
8#include "core/hle/service/time/system_clock_context_update_callback.h" 7#include "core/hle/service/time/system_clock_context_update_callback.h"
9#include "core/hle/service/time/time_sharedmemory.h" 8#include "core/hle/service/time/time_sharedmemory.h"
10 9
diff --git a/src/core/hle/service/time/standard_steady_clock_core.cpp b/src/core/hle/service/time/standard_steady_clock_core.cpp
index 59a272f4a..a1ffdd524 100644
--- a/src/core/hle/service/time/standard_steady_clock_core.cpp
+++ b/src/core/hle/service/time/standard_steady_clock_core.cpp
@@ -4,7 +4,6 @@
4 4
5#include "core/core.h" 5#include "core/core.h"
6#include "core/core_timing.h" 6#include "core/core_timing.h"
7#include "core/core_timing_util.h"
8#include "core/hardware_properties.h" 7#include "core/hardware_properties.h"
9#include "core/hle/service/time/standard_steady_clock_core.h" 8#include "core/hle/service/time/standard_steady_clock_core.h"
10 9
diff --git a/src/core/hle/service/time/tick_based_steady_clock_core.cpp b/src/core/hle/service/time/tick_based_steady_clock_core.cpp
index 8baaa2a6a..47d4ab980 100644
--- a/src/core/hle/service/time/tick_based_steady_clock_core.cpp
+++ b/src/core/hle/service/time/tick_based_steady_clock_core.cpp
@@ -4,7 +4,6 @@
4 4
5#include "core/core.h" 5#include "core/core.h"
6#include "core/core_timing.h" 6#include "core/core_timing.h"
7#include "core/core_timing_util.h"
8#include "core/hardware_properties.h" 7#include "core/hardware_properties.h"
9#include "core/hle/service/time/tick_based_steady_clock_core.h" 8#include "core/hle/service/time/tick_based_steady_clock_core.h"
10 9
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index d84a111c2..4d8823b5a 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -5,10 +5,8 @@
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6#include "core/core.h" 6#include "core/core.h"
7#include "core/core_timing.h" 7#include "core/core_timing.h"
8#include "core/core_timing_util.h"
9#include "core/hardware_properties.h" 8#include "core/hardware_properties.h"
10#include "core/hle/ipc_helpers.h" 9#include "core/hle/ipc_helpers.h"
11#include "core/hle/kernel/k_scheduler.h"
12#include "core/hle/kernel/kernel.h" 10#include "core/hle/kernel/kernel.h"
13#include "core/hle/service/time/time.h" 11#include "core/hle/service/time/time.h"
14#include "core/hle/service/time/time_interface.h" 12#include "core/hle/service/time/time_interface.h"
diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp
index 9c4c960ef..c1e4e6cce 100644
--- a/src/core/hle/service/time/time_manager.cpp
+++ b/src/core/hle/service/time/time_manager.cpp
@@ -8,8 +8,10 @@
8#include "common/settings.h" 8#include "common/settings.h"
9#include "common/time_zone.h" 9#include "common/time_zone.h"
10#include "core/hle/service/time/ephemeral_network_system_clock_context_writer.h" 10#include "core/hle/service/time/ephemeral_network_system_clock_context_writer.h"
11#include "core/hle/service/time/ephemeral_network_system_clock_core.h"
11#include "core/hle/service/time/local_system_clock_context_writer.h" 12#include "core/hle/service/time/local_system_clock_context_writer.h"
12#include "core/hle/service/time/network_system_clock_context_writer.h" 13#include "core/hle/service/time/network_system_clock_context_writer.h"
14#include "core/hle/service/time/tick_based_steady_clock_core.h"
13#include "core/hle/service/time/time_manager.h" 15#include "core/hle/service/time/time_manager.h"
14 16
15namespace Service::Time { 17namespace Service::Time {
diff --git a/src/core/hle/service/time/time_manager.h b/src/core/hle/service/time/time_manager.h
index 3af868d87..2404067c0 100644
--- a/src/core/hle/service/time/time_manager.h
+++ b/src/core/hle/service/time/time_manager.h
@@ -5,15 +5,12 @@
5#pragma once 5#pragma once
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/time_zone.h"
9#include "core/file_sys/vfs_types.h" 8#include "core/file_sys/vfs_types.h"
10#include "core/hle/service/time/clock_types.h" 9#include "core/hle/service/time/clock_types.h"
11#include "core/hle/service/time/ephemeral_network_system_clock_core.h"
12#include "core/hle/service/time/standard_local_system_clock_core.h" 10#include "core/hle/service/time/standard_local_system_clock_core.h"
13#include "core/hle/service/time/standard_network_system_clock_core.h" 11#include "core/hle/service/time/standard_network_system_clock_core.h"
14#include "core/hle/service/time/standard_steady_clock_core.h" 12#include "core/hle/service/time/standard_steady_clock_core.h"
15#include "core/hle/service/time/standard_user_system_clock_core.h" 13#include "core/hle/service/time/standard_user_system_clock_core.h"
16#include "core/hle/service/time/tick_based_steady_clock_core.h"
17#include "core/hle/service/time/time_sharedmemory.h" 14#include "core/hle/service/time/time_sharedmemory.h"
18#include "core/hle/service/time/time_zone_content_manager.h" 15#include "core/hle/service/time/time_zone_content_manager.h"
19 16
diff --git a/src/core/hle/service/time/time_sharedmemory.cpp b/src/core/hle/service/time/time_sharedmemory.cpp
index 176ad0eee..ed9f75ed6 100644
--- a/src/core/hle/service/time/time_sharedmemory.cpp
+++ b/src/core/hle/service/time/time_sharedmemory.cpp
@@ -4,7 +4,6 @@
4 4
5#include "core/core.h" 5#include "core/core.h"
6#include "core/core_timing.h" 6#include "core/core_timing.h"
7#include "core/core_timing_util.h"
8#include "core/hardware_properties.h" 7#include "core/hardware_properties.h"
9#include "core/hle/kernel/kernel.h" 8#include "core/hle/kernel/kernel.h"
10#include "core/hle/service/time/clock_types.h" 9#include "core/hle/service/time/clock_types.h"
diff --git a/src/core/hle/service/time/time_sharedmemory.h b/src/core/hle/service/time/time_sharedmemory.h
index d471b5d18..9307ea795 100644
--- a/src/core/hle/service/time/time_sharedmemory.h
+++ b/src/core/hle/service/time/time_sharedmemory.h
@@ -7,7 +7,6 @@
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/uuid.h" 8#include "common/uuid.h"
9#include "core/hle/kernel/k_shared_memory.h" 9#include "core/hle/kernel/k_shared_memory.h"
10#include "core/hle/kernel/k_thread.h"
11#include "core/hle/service/time/clock_types.h" 10#include "core/hle/service/time/clock_types.h"
12 11
13namespace Service::Time { 12namespace Service::Time {
diff --git a/src/core/hle/service/time/time_zone_manager.cpp b/src/core/hle/service/time/time_zone_manager.cpp
index 6da893790..2989cee5e 100644
--- a/src/core/hle/service/time/time_zone_manager.cpp
+++ b/src/core/hle/service/time/time_zone_manager.cpp
@@ -9,8 +9,6 @@
9#include "core/file_sys/content_archive.h" 9#include "core/file_sys/content_archive.h"
10#include "core/file_sys/nca_metadata.h" 10#include "core/file_sys/nca_metadata.h"
11#include "core/file_sys/registered_cache.h" 11#include "core/file_sys/registered_cache.h"
12#include "core/file_sys/romfs.h"
13#include "core/file_sys/system_archive/system_archive.h"
14#include "core/hle/service/time/time_zone_manager.h" 12#include "core/hle/service/time/time_zone_manager.h"
15 13
16namespace Service::Time::TimeZone { 14namespace Service::Time::TimeZone {
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 439e7e472..63d5242c4 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -21,9 +21,7 @@
21#include "core/hle/ipc_helpers.h" 21#include "core/hle/ipc_helpers.h"
22#include "core/hle/kernel/k_readable_event.h" 22#include "core/hle/kernel/k_readable_event.h"
23#include "core/hle/kernel/k_thread.h" 23#include "core/hle/kernel/k_thread.h"
24#include "core/hle/kernel/k_writable_event.h"
25#include "core/hle/service/nvdrv/nvdata.h" 24#include "core/hle/service/nvdrv/nvdata.h"
26#include "core/hle/service/nvdrv/nvdrv.h"
27#include "core/hle/service/nvflinger/buffer_queue.h" 25#include "core/hle/service/nvflinger/buffer_queue.h"
28#include "core/hle/service/nvflinger/nvflinger.h" 26#include "core/hle/service/nvflinger/nvflinger.h"
29#include "core/hle/service/service.h" 27#include "core/hle/service/service.h"
@@ -1284,15 +1282,15 @@ private:
1284 static ResultVal<ConvertedScaleMode> ConvertScalingModeImpl(NintendoScaleMode mode) { 1282 static ResultVal<ConvertedScaleMode> ConvertScalingModeImpl(NintendoScaleMode mode) {
1285 switch (mode) { 1283 switch (mode) {
1286 case NintendoScaleMode::None: 1284 case NintendoScaleMode::None:
1287 return MakeResult(ConvertedScaleMode::None); 1285 return ConvertedScaleMode::None;
1288 case NintendoScaleMode::Freeze: 1286 case NintendoScaleMode::Freeze:
1289 return MakeResult(ConvertedScaleMode::Freeze); 1287 return ConvertedScaleMode::Freeze;
1290 case NintendoScaleMode::ScaleToWindow: 1288 case NintendoScaleMode::ScaleToWindow:
1291 return MakeResult(ConvertedScaleMode::ScaleToWindow); 1289 return ConvertedScaleMode::ScaleToWindow;
1292 case NintendoScaleMode::ScaleAndCrop: 1290 case NintendoScaleMode::ScaleAndCrop:
1293 return MakeResult(ConvertedScaleMode::ScaleAndCrop); 1291 return ConvertedScaleMode::ScaleAndCrop;
1294 case NintendoScaleMode::PreserveAspectRatio: 1292 case NintendoScaleMode::PreserveAspectRatio:
1295 return MakeResult(ConvertedScaleMode::PreserveAspectRatio); 1293 return ConvertedScaleMode::PreserveAspectRatio;
1296 default: 1294 default:
1297 LOG_ERROR(Service_VI, "Invalid scaling mode specified, mode={}", mode); 1295 LOG_ERROR(Service_VI, "Invalid scaling mode specified, mode={}", mode);
1298 return ERR_OPERATION_FAILED; 1296 return ERR_OPERATION_FAILED;
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp
index a19bb220a..1b5aca65d 100644
--- a/src/core/loader/deconstructed_rom_directory.cpp
+++ b/src/core/loader/deconstructed_rom_directory.cpp
@@ -2,9 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cinttypes>
6#include <cstring> 5#include <cstring>
7#include "common/common_funcs.h"
8#include "common/logging/log.h" 6#include "common/logging/log.h"
9#include "core/core.h" 7#include "core/core.h"
10#include "core/file_sys/content_archive.h" 8#include "core/file_sys/content_archive.h"
@@ -13,7 +11,6 @@
13#include "core/file_sys/romfs_factory.h" 11#include "core/file_sys/romfs_factory.h"
14#include "core/hle/kernel/k_page_table.h" 12#include "core/hle/kernel/k_page_table.h"
15#include "core/hle/kernel/k_process.h" 13#include "core/hle/kernel/k_process.h"
16#include "core/hle/kernel/kernel.h"
17#include "core/hle/service/filesystem/filesystem.h" 14#include "core/hle/service/filesystem/filesystem.h"
18#include "core/loader/deconstructed_rom_directory.h" 15#include "core/loader/deconstructed_rom_directory.h"
19#include "core/loader/nso.h" 16#include "core/loader/nso.h"
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 3d9276f15..d0250bdb4 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -4,7 +4,6 @@
4 4
5#include <cstring> 5#include <cstring>
6#include <memory> 6#include <memory>
7#include <string>
8#include "common/common_funcs.h" 7#include "common/common_funcs.h"
9#include "common/common_types.h" 8#include "common/common_types.h"
10#include "common/logging/log.h" 9#include "common/logging/log.h"
diff --git a/src/core/loader/elf.h b/src/core/loader/elf.h
index 890299a20..bff51ec17 100644
--- a/src/core/loader/elf.h
+++ b/src/core/loader/elf.h
@@ -4,8 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <string>
8#include "common/common_types.h"
9#include "core/loader/loader.h" 7#include "core/loader/loader.h"
10 8
11namespace Core { 9namespace Core {
diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp
index aceb66414..3375dab7c 100644
--- a/src/core/loader/nax.cpp
+++ b/src/core/loader/nax.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h"
6#include "core/file_sys/content_archive.h" 5#include "core/file_sys/content_archive.h"
7#include "core/file_sys/romfs.h" 6#include "core/file_sys/romfs.h"
8#include "core/file_sys/xts_archive.h" 7#include "core/file_sys/xts_archive.h"
diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp
index aa51b0daa..219bbeaf5 100644
--- a/src/core/loader/nca.cpp
+++ b/src/core/loader/nca.cpp
@@ -4,7 +4,6 @@
4 4
5#include <utility> 5#include <utility>
6 6
7#include "common/logging/log.h"
8#include "core/core.h" 7#include "core/core.h"
9#include "core/file_sys/content_archive.h" 8#include "core/file_sys/content_archive.h"
10#include "core/file_sys/romfs_factory.h" 9#include "core/file_sys/romfs_factory.h"
diff --git a/src/core/loader/nca.h b/src/core/loader/nca.h
index f2ff080bb..c0db8c740 100644
--- a/src/core/loader/nca.h
+++ b/src/core/loader/nca.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "core/file_sys/vfs.h"
9#include "core/loader/loader.h" 8#include "core/loader/loader.h"
10 9
11namespace Core { 10namespace Core {
diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp
index 8b167ad3c..f7ccc678d 100644
--- a/src/core/loader/nsp.cpp
+++ b/src/core/loader/nsp.cpp
@@ -6,7 +6,6 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "core/core.h" 8#include "core/core.h"
9#include "core/file_sys/card_image.h"
10#include "core/file_sys/content_archive.h" 9#include "core/file_sys/content_archive.h"
11#include "core/file_sys/control_metadata.h" 10#include "core/file_sys/control_metadata.h"
12#include "core/file_sys/nca_metadata.h" 11#include "core/file_sys/nca_metadata.h"
diff --git a/src/core/loader/nsp.h b/src/core/loader/nsp.h
index 50406a92e..378e4077a 100644
--- a/src/core/loader/nsp.h
+++ b/src/core/loader/nsp.h
@@ -6,7 +6,6 @@
6 6
7#include <memory> 7#include <memory>
8#include "common/common_types.h" 8#include "common/common_types.h"
9#include "core/file_sys/vfs.h"
10#include "core/loader/loader.h" 9#include "core/loader/loader.h"
11 10
12namespace FileSys { 11namespace FileSys {
diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp
index 269603eef..8c6c1a3fd 100644
--- a/src/core/loader/xci.cpp
+++ b/src/core/loader/xci.cpp
@@ -11,7 +11,6 @@
11#include "core/file_sys/control_metadata.h" 11#include "core/file_sys/control_metadata.h"
12#include "core/file_sys/patch_manager.h" 12#include "core/file_sys/patch_manager.h"
13#include "core/file_sys/registered_cache.h" 13#include "core/file_sys/registered_cache.h"
14#include "core/file_sys/romfs.h"
15#include "core/file_sys/submission_package.h" 14#include "core/file_sys/submission_package.h"
16#include "core/hle/kernel/k_process.h" 15#include "core/hle/kernel/k_process.h"
17#include "core/hle/service/filesystem/filesystem.h" 16#include "core/hle/service/filesystem/filesystem.h"
diff --git a/src/core/loader/xci.h b/src/core/loader/xci.h
index 30caaf90e..6e3810e48 100644
--- a/src/core/loader/xci.h
+++ b/src/core/loader/xci.h
@@ -6,7 +6,6 @@
6 6
7#include <memory> 7#include <memory>
8#include "common/common_types.h" 8#include "common/common_types.h"
9#include "core/file_sys/vfs.h"
10#include "core/loader/loader.h" 9#include "core/loader/loader.h"
11 10
12namespace FileSys { 11namespace FileSys {
diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp
index 46a7e09b4..20f0e90f5 100644
--- a/src/core/memory/cheat_engine.cpp
+++ b/src/core/memory/cheat_engine.cpp
@@ -8,8 +8,6 @@
8#include "common/swap.h" 8#include "common/swap.h"
9#include "core/core.h" 9#include "core/core.h"
10#include "core/core_timing.h" 10#include "core/core_timing.h"
11#include "core/core_timing_util.h"
12#include "core/hardware_properties.h"
13#include "core/hle/kernel/k_page_table.h" 11#include "core/hle/kernel/k_page_table.h"
14#include "core/hle/kernel/k_process.h" 12#include "core/hle/kernel/k_process.h"
15#include "core/hle/service/hid/controllers/npad.h" 13#include "core/hle/service/hid/controllers/npad.h"
@@ -194,7 +192,7 @@ void CheatEngine::Initialize() {
194 core_timing.ScheduleEvent(CHEAT_ENGINE_NS, event); 192 core_timing.ScheduleEvent(CHEAT_ENGINE_NS, event);
195 193
196 metadata.process_id = system.CurrentProcess()->GetProcessID(); 194 metadata.process_id = system.CurrentProcess()->GetProcessID();
197 metadata.title_id = system.CurrentProcess()->GetTitleID(); 195 metadata.title_id = system.GetCurrentProcessProgramID();
198 196
199 const auto& page_table = system.CurrentProcess()->PageTable(); 197 const auto& page_table = system.CurrentProcess()->PageTable();
200 metadata.heap_extents = { 198 metadata.heap_extents = {
diff --git a/src/core/network/network.h b/src/core/network/network.h
index fdd3e4655..e85df3ab7 100644
--- a/src/core/network/network.h
+++ b/src/core/network/network.h
@@ -6,7 +6,6 @@
6 6
7#include <array> 7#include <array>
8#include <optional> 8#include <optional>
9#include <utility>
10 9
11#include "common/common_funcs.h" 10#include "common/common_funcs.h"
12#include "common/common_types.h" 11#include "common/common_types.h"
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp
index c9ded49d0..52c43c857 100644
--- a/src/core/perf_stats.cpp
+++ b/src/core/perf_stats.cpp
@@ -14,7 +14,6 @@
14#include "common/fs/file.h" 14#include "common/fs/file.h"
15#include "common/fs/fs.h" 15#include "common/fs/fs.h"
16#include "common/fs/path_util.h" 16#include "common/fs/path_util.h"
17#include "common/math_util.h"
18#include "common/settings.h" 17#include "common/settings.h"
19#include "core/perf_stats.h" 18#include "core/perf_stats.h"
20 19
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp
index 365b8f906..d4becdc0a 100644
--- a/src/core/reporter.cpp
+++ b/src/core/reporter.cpp
@@ -236,7 +236,7 @@ void Reporter::SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64
236 } 236 }
237 237
238 const auto timestamp = GetTimestamp(); 238 const auto timestamp = GetTimestamp();
239 const auto title_id = system.CurrentProcess()->GetTitleID(); 239 const auto title_id = system.GetCurrentProcessProgramID();
240 auto out = GetFullDataAuto(timestamp, title_id, system); 240 auto out = GetFullDataAuto(timestamp, title_id, system);
241 241
242 auto break_out = json{ 242 auto break_out = json{
@@ -263,7 +263,7 @@ void Reporter::SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u
263 } 263 }
264 264
265 const auto timestamp = GetTimestamp(); 265 const auto timestamp = GetTimestamp();
266 const auto title_id = system.CurrentProcess()->GetTitleID(); 266 const auto title_id = system.GetCurrentProcessProgramID();
267 auto out = GetFullDataAuto(timestamp, title_id, system); 267 auto out = GetFullDataAuto(timestamp, title_id, system);
268 268
269 auto function_out = GetHLERequestContextData(ctx, system.Memory()); 269 auto function_out = GetHLERequestContextData(ctx, system.Memory());
@@ -285,7 +285,7 @@ void Reporter::SaveUnimplementedAppletReport(
285 } 285 }
286 286
287 const auto timestamp = GetTimestamp(); 287 const auto timestamp = GetTimestamp();
288 const auto title_id = system.CurrentProcess()->GetTitleID(); 288 const auto title_id = system.GetCurrentProcessProgramID();
289 auto out = GetFullDataAuto(timestamp, title_id, system); 289 auto out = GetFullDataAuto(timestamp, title_id, system);
290 290
291 out["applet_common_args"] = { 291 out["applet_common_args"] = {
@@ -377,7 +377,7 @@ void Reporter::SaveUserReport() const {
377 } 377 }
378 378
379 const auto timestamp = GetTimestamp(); 379 const auto timestamp = GetTimestamp();
380 const auto title_id = system.CurrentProcess()->GetTitleID(); 380 const auto title_id = system.GetCurrentProcessProgramID();
381 381
382 SaveToFile(GetFullDataAuto(timestamp, title_id, system), 382 SaveToFile(GetFullDataAuto(timestamp, title_id, system),
383 GetPath("user_report", title_id, timestamp)); 383 GetPath("user_report", title_id, timestamp));
diff --git a/src/core/tools/freezer.cpp b/src/core/tools/freezer.cpp
index 2e09faa6d..032c71aff 100644
--- a/src/core/tools/freezer.cpp
+++ b/src/core/tools/freezer.cpp
@@ -6,8 +6,6 @@
6#include "common/logging/log.h" 6#include "common/logging/log.h"
7#include "core/core.h" 7#include "core/core.h"
8#include "core/core_timing.h" 8#include "core/core_timing.h"
9#include "core/core_timing_util.h"
10#include "core/hardware_properties.h"
11#include "core/memory.h" 9#include "core/memory.h"
12#include "core/tools/freezer.h" 10#include "core/tools/freezer.h"
13 11
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp
index ff64c6924..e537f6073 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp
@@ -18,7 +18,7 @@ namespace Shader::Backend::GLASM {
18#define NotImplemented() throw NotImplementedException("GLASM instruction {}", __LINE__) 18#define NotImplemented() throw NotImplementedException("GLASM instruction {}", __LINE__)
19 19
20static void DefinePhi(EmitContext& ctx, IR::Inst& phi) { 20static void DefinePhi(EmitContext& ctx, IR::Inst& phi) {
21 switch (phi.Arg(0).Type()) { 21 switch (phi.Type()) {
22 case IR::Type::U1: 22 case IR::Type::U1:
23 case IR::Type::U32: 23 case IR::Type::U32:
24 case IR::Type::F32: 24 case IR::Type::F32:
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp
index 9b866f889..67f9dad68 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp
@@ -68,7 +68,7 @@ void EmitPhi(EmitContext& ctx, IR::Inst& phi) {
68 } 68 }
69 if (!phi.Definition<Id>().is_valid) { 69 if (!phi.Definition<Id>().is_valid) {
70 // The phi node wasn't forward defined 70 // The phi node wasn't forward defined
71 ctx.var_alloc.PhiDefine(phi, phi.Arg(0).Type()); 71 ctx.var_alloc.PhiDefine(phi, phi.Type());
72 } 72 }
73} 73}
74 74
@@ -80,7 +80,7 @@ void EmitReference(EmitContext& ctx, const IR::Value& value) {
80 80
81void EmitPhiMove(EmitContext& ctx, const IR::Value& phi_value, const IR::Value& value) { 81void EmitPhiMove(EmitContext& ctx, const IR::Value& phi_value, const IR::Value& value) {
82 IR::Inst& phi{*phi_value.InstRecursive()}; 82 IR::Inst& phi{*phi_value.InstRecursive()};
83 const auto phi_type{phi.Arg(0).Type()}; 83 const auto phi_type{phi.Type()};
84 if (!phi.Definition<Id>().is_valid) { 84 if (!phi.Definition<Id>().is_valid) {
85 // The phi node wasn't forward defined 85 // The phi node wasn't forward defined
86 ctx.var_alloc.PhiDefine(phi, phi_type); 86 ctx.var_alloc.PhiDefine(phi, phi_type);
diff --git a/src/shader_recompiler/frontend/ir/basic_block.h b/src/shader_recompiler/frontend/ir/basic_block.h
index 7e134b4c7..9ce1ed07e 100644
--- a/src/shader_recompiler/frontend/ir/basic_block.h
+++ b/src/shader_recompiler/frontend/ir/basic_block.h
@@ -152,6 +152,17 @@ public:
152 return instructions.crend(); 152 return instructions.crend();
153 } 153 }
154 154
155 // Set the order of the block, it can be set pre order, the user decides
156 void SetOrder(u32 new_order) {
157 order = new_order;
158 }
159
160 // Get the order of the block.
161 // The higher, the closer is the block to the end.
162 [[nodiscard]] u32 GetOrder() const {
163 return order;
164 }
165
155private: 166private:
156 /// Memory pool for instruction list 167 /// Memory pool for instruction list
157 ObjectPool<Inst>* inst_pool; 168 ObjectPool<Inst>* inst_pool;
@@ -171,6 +182,9 @@ private:
171 182
172 /// Intrusively stored host definition of this block. 183 /// Intrusively stored host definition of this block.
173 u32 definition{}; 184 u32 definition{};
185
186 /// Order of the block.
187 u32 order{};
174}; 188};
175 189
176using BlockList = std::vector<Block*>; 190using BlockList = std::vector<Block*>;
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp
index 3dfa5a880..30b470bdd 100644
--- a/src/shader_recompiler/frontend/ir/microinstruction.cpp
+++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp
@@ -6,6 +6,7 @@
6#include <memory> 6#include <memory>
7 7
8#include "shader_recompiler/exception.h" 8#include "shader_recompiler/exception.h"
9#include "shader_recompiler/frontend/ir/basic_block.h"
9#include "shader_recompiler/frontend/ir/type.h" 10#include "shader_recompiler/frontend/ir/type.h"
10#include "shader_recompiler/frontend/ir/value.h" 11#include "shader_recompiler/frontend/ir/value.h"
11 12
@@ -253,6 +254,10 @@ Inst* Inst::GetAssociatedPseudoOperation(IR::Opcode opcode) {
253} 254}
254 255
255IR::Type Inst::Type() const { 256IR::Type Inst::Type() const {
257 if (op == IR::Opcode::Phi) {
258 // The type of a phi node is stored in its flags
259 return Flags<IR::Type>();
260 }
256 return TypeOf(op); 261 return TypeOf(op);
257} 262}
258 263
@@ -291,6 +296,16 @@ void Inst::AddPhiOperand(Block* predecessor, const Value& value) {
291 phi_args.emplace_back(predecessor, value); 296 phi_args.emplace_back(predecessor, value);
292} 297}
293 298
299void Inst::OrderPhiArgs() {
300 if (op != Opcode::Phi) {
301 throw LogicError("{} is not a Phi instruction", op);
302 }
303 std::sort(phi_args.begin(), phi_args.end(),
304 [](const std::pair<Block*, Value>& a, const std::pair<Block*, Value>& b) {
305 return a.first->GetOrder() < b.first->GetOrder();
306 });
307}
308
294void Inst::Invalidate() { 309void Inst::Invalidate() {
295 ClearArgs(); 310 ClearArgs();
296 ReplaceOpcode(Opcode::Void); 311 ReplaceOpcode(Opcode::Void);
diff --git a/src/shader_recompiler/frontend/ir/value.h b/src/shader_recompiler/frontend/ir/value.h
index 334bb47aa..6c9ef6bdd 100644
--- a/src/shader_recompiler/frontend/ir/value.h
+++ b/src/shader_recompiler/frontend/ir/value.h
@@ -182,6 +182,9 @@ public:
182 /// Add phi operand to a phi instruction. 182 /// Add phi operand to a phi instruction.
183 void AddPhiOperand(Block* predecessor, const Value& value); 183 void AddPhiOperand(Block* predecessor, const Value& value);
184 184
185 /// Orders the Phi arguments from farthest away to nearest.
186 void OrderPhiArgs();
187
185 void Invalidate(); 188 void Invalidate();
186 void ClearArgs(); 189 void ClearArgs();
187 190
diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.cpp b/src/shader_recompiler/frontend/maxwell/translate_program.cpp
index 012d55357..2fc542f0e 100644
--- a/src/shader_recompiler/frontend/maxwell/translate_program.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate_program.cpp
@@ -27,9 +27,11 @@ IR::BlockList GenerateBlocks(const IR::AbstractSyntaxList& syntax_list) {
27 } 27 }
28 IR::BlockList blocks; 28 IR::BlockList blocks;
29 blocks.reserve(num_syntax_blocks); 29 blocks.reserve(num_syntax_blocks);
30 u32 order_index{};
30 for (const auto& node : syntax_list) { 31 for (const auto& node : syntax_list) {
31 if (node.type == IR::AbstractSyntaxNode::Type::Block) { 32 if (node.type == IR::AbstractSyntaxNode::Type::Block) {
32 blocks.push_back(node.data.block); 33 blocks.push_back(node.data.block);
34 blocks.back()->SetOrder(order_index++);
33 } 35 }
34 } 36 }
35 return blocks; 37 return blocks;
diff --git a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp
index 53145fb5e..87aa09358 100644
--- a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp
+++ b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp
@@ -14,6 +14,7 @@
14// https://link.springer.com/chapter/10.1007/978-3-642-37051-9_6 14// https://link.springer.com/chapter/10.1007/978-3-642-37051-9_6
15// 15//
16 16
17#include <deque>
17#include <span> 18#include <span>
18#include <variant> 19#include <variant>
19#include <vector> 20#include <vector>
@@ -370,6 +371,26 @@ void VisitBlock(Pass& pass, IR::Block* block) {
370 } 371 }
371 pass.SealBlock(block); 372 pass.SealBlock(block);
372} 373}
374
375IR::Type GetConcreteType(IR::Inst* inst) {
376 std::deque<IR::Inst*> queue;
377 queue.push_back(inst);
378 while (!queue.empty()) {
379 IR::Inst* current = queue.front();
380 queue.pop_front();
381 const size_t num_args{current->NumArgs()};
382 for (size_t i = 0; i < num_args; ++i) {
383 const auto set_type = current->Arg(i).Type();
384 if (set_type != IR::Type::Opaque) {
385 return set_type;
386 }
387 if (!current->Arg(i).IsImmediate()) {
388 queue.push_back(current->Arg(i).Inst());
389 }
390 }
391 }
392 return IR::Type::Opaque;
393}
373} // Anonymous namespace 394} // Anonymous namespace
374 395
375void SsaRewritePass(IR::Program& program) { 396void SsaRewritePass(IR::Program& program) {
@@ -378,6 +399,16 @@ void SsaRewritePass(IR::Program& program) {
378 for (auto block = program.post_order_blocks.rbegin(); block != end; ++block) { 399 for (auto block = program.post_order_blocks.rbegin(); block != end; ++block) {
379 VisitBlock(pass, *block); 400 VisitBlock(pass, *block);
380 } 401 }
402 for (auto block = program.post_order_blocks.rbegin(); block != end; ++block) {
403 for (IR::Inst& inst : (*block)->Instructions()) {
404 if (inst.GetOpcode() == IR::Opcode::Phi) {
405 if (inst.Type() == IR::Type::Opaque) {
406 inst.SetFlags(GetConcreteType(&inst));
407 }
408 inst.OrderPhiArgs();
409 }
410 }
411 }
381} 412}
382 413
383} // namespace Shader::Optimization 414} // namespace Shader::Optimization
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index b909c387e..a6d9f7c43 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -10,16 +10,14 @@
10#include <string_view> 10#include <string_view>
11#include <tuple> 11#include <tuple>
12#include <utility> 12#include <utility>
13
13#include <glad/glad.h> 14#include <glad/glad.h>
14#include "common/alignment.h" 15
15#include "common/assert.h" 16#include "common/assert.h"
16#include "common/logging/log.h" 17#include "common/logging/log.h"
17#include "common/math_util.h" 18#include "common/math_util.h"
18#include "common/microprofile.h" 19#include "common/microprofile.h"
19#include "common/scope_exit.h"
20#include "common/settings.h" 20#include "common/settings.h"
21#include "core/core.h"
22#include "core/hle/kernel/k_process.h"
23#include "core/memory.h" 21#include "core/memory.h"
24#include "video_core/engines/kepler_compute.h" 22#include "video_core/engines/kepler_compute.h"
25#include "video_core/engines/maxwell_3d.h" 23#include "video_core/engines/maxwell_3d.h"
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp
index 0f807990c..95106f88f 100644
--- a/src/video_core/vulkan_common/vulkan_device.cpp
+++ b/src/video_core/vulkan_common/vulkan_device.cpp
@@ -103,6 +103,7 @@ std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(vk::Physica
103 VK_FORMAT_A8B8G8R8_SNORM_PACK32, 103 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
104 VK_FORMAT_A8B8G8R8_SINT_PACK32, 104 VK_FORMAT_A8B8G8R8_SINT_PACK32,
105 VK_FORMAT_A8B8G8R8_SRGB_PACK32, 105 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
106 VK_FORMAT_R5G6B5_UNORM_PACK16,
106 VK_FORMAT_B5G6R5_UNORM_PACK16, 107 VK_FORMAT_B5G6R5_UNORM_PACK16,
107 VK_FORMAT_A2B10G10R10_UNORM_PACK32, 108 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
108 VK_FORMAT_A2B10G10R10_UINT_PACK32, 109 VK_FORMAT_A2B10G10R10_UINT_PACK32,
diff --git a/src/yuzu/applets/qt_software_keyboard.cpp b/src/yuzu/applets/qt_software_keyboard.cpp
index 8fc0c5a36..a83a11a95 100644
--- a/src/yuzu/applets/qt_software_keyboard.cpp
+++ b/src/yuzu/applets/qt_software_keyboard.cpp
@@ -413,7 +413,7 @@ void QtSoftwareKeyboardDialog::ShowTextCheckDialog(
413 ? ui->text_edit_osk->toPlainText().toStdU16String() 413 ? ui->text_edit_osk->toPlainText().toStdU16String()
414 : ui->line_edit_osk->text().toStdU16String(); 414 : ui->line_edit_osk->text().toStdU16String();
415 415
416 emit SubmitNormalText(SwkbdResult::Ok, std::move(text)); 416 emit SubmitNormalText(SwkbdResult::Ok, std::move(text), true);
417 break; 417 break;
418 } 418 }
419 } 419 }
@@ -1510,7 +1510,8 @@ QtSoftwareKeyboard::~QtSoftwareKeyboard() = default;
1510 1510
1511void QtSoftwareKeyboard::InitializeKeyboard( 1511void QtSoftwareKeyboard::InitializeKeyboard(
1512 bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters, 1512 bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters,
1513 std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> submit_normal_callback_, 1513 std::function<void(Service::AM::Applets::SwkbdResult, std::u16string, bool)>
1514 submit_normal_callback_,
1514 std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> 1515 std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)>
1515 submit_inline_callback_) { 1516 submit_inline_callback_) {
1516 if (is_inline) { 1517 if (is_inline) {
@@ -1609,8 +1610,8 @@ void QtSoftwareKeyboard::ExitKeyboard() const {
1609} 1610}
1610 1611
1611void QtSoftwareKeyboard::SubmitNormalText(Service::AM::Applets::SwkbdResult result, 1612void QtSoftwareKeyboard::SubmitNormalText(Service::AM::Applets::SwkbdResult result,
1612 std::u16string submitted_text) const { 1613 std::u16string submitted_text, bool confirmed) const {
1613 submit_normal_callback(result, submitted_text); 1614 submit_normal_callback(result, submitted_text, confirmed);
1614} 1615}
1615 1616
1616void QtSoftwareKeyboard::SubmitInlineText(Service::AM::Applets::SwkbdReplyType reply_type, 1617void QtSoftwareKeyboard::SubmitInlineText(Service::AM::Applets::SwkbdReplyType reply_type,
diff --git a/src/yuzu/applets/qt_software_keyboard.h b/src/yuzu/applets/qt_software_keyboard.h
index 1a03c098c..592d9c085 100644
--- a/src/yuzu/applets/qt_software_keyboard.h
+++ b/src/yuzu/applets/qt_software_keyboard.h
@@ -51,8 +51,8 @@ public:
51 void ExitKeyboard(); 51 void ExitKeyboard();
52 52
53signals: 53signals:
54 void SubmitNormalText(Service::AM::Applets::SwkbdResult result, 54 void SubmitNormalText(Service::AM::Applets::SwkbdResult result, std::u16string submitted_text,
55 std::u16string submitted_text) const; 55 bool confirmed = false) const;
56 56
57 void SubmitInlineText(Service::AM::Applets::SwkbdReplyType reply_type, 57 void SubmitInlineText(Service::AM::Applets::SwkbdReplyType reply_type,
58 std::u16string submitted_text, s32 cursor_position) const; 58 std::u16string submitted_text, s32 cursor_position) const;
@@ -234,7 +234,7 @@ public:
234 234
235 void InitializeKeyboard( 235 void InitializeKeyboard(
236 bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters, 236 bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters,
237 std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> 237 std::function<void(Service::AM::Applets::SwkbdResult, std::u16string, bool)>
238 submit_normal_callback_, 238 submit_normal_callback_,
239 std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> 239 std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)>
240 submit_inline_callback_) override; 240 submit_inline_callback_) override;
@@ -272,13 +272,13 @@ signals:
272 void MainWindowExitKeyboard() const; 272 void MainWindowExitKeyboard() const;
273 273
274private: 274private:
275 void SubmitNormalText(Service::AM::Applets::SwkbdResult result, 275 void SubmitNormalText(Service::AM::Applets::SwkbdResult result, std::u16string submitted_text,
276 std::u16string submitted_text) const; 276 bool confirmed) const;
277 277
278 void SubmitInlineText(Service::AM::Applets::SwkbdReplyType reply_type, 278 void SubmitInlineText(Service::AM::Applets::SwkbdReplyType reply_type,
279 std::u16string submitted_text, s32 cursor_position) const; 279 std::u16string submitted_text, s32 cursor_position) const;
280 280
281 mutable std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> 281 mutable std::function<void(Service::AM::Applets::SwkbdResult, std::u16string, bool)>
282 submit_normal_callback; 282 submit_normal_callback;
283 mutable std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> 283 mutable std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)>
284 submit_inline_callback; 284 submit_inline_callback;
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 40fd47406..46ab0603d 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -32,7 +32,6 @@
32#include "common/settings.h" 32#include "common/settings.h"
33#include "core/core.h" 33#include "core/core.h"
34#include "core/frontend/framebuffer_layout.h" 34#include "core/frontend/framebuffer_layout.h"
35#include "core/hle/kernel/k_process.h"
36#include "input_common/keyboard.h" 35#include "input_common/keyboard.h"
37#include "input_common/main.h" 36#include "input_common/main.h"
38#include "input_common/mouse/mouse_input.h" 37#include "input_common/mouse/mouse_input.h"
@@ -66,7 +65,7 @@ void EmuThread::run() {
66 65
67 if (Settings::values.use_disk_shader_cache.GetValue()) { 66 if (Settings::values.use_disk_shader_cache.GetValue()) {
68 system.Renderer().ReadRasterizer()->LoadDiskResources( 67 system.Renderer().ReadRasterizer()->LoadDiskResources(
69 system.CurrentProcess()->GetTitleID(), stop_token, 68 system.GetCurrentProcessProgramID(), stop_token,
70 [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) { 69 [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) {
71 emit LoadProgress(stage, value, total); 70 emit LoadProgress(stage, value, total);
72 }); 71 });
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 182b486e9..4e5552d2a 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -485,8 +485,9 @@ void GMainWindow::SoftwareKeyboardInitialize(
485 } else { 485 } else {
486 connect( 486 connect(
487 software_keyboard, &QtSoftwareKeyboardDialog::SubmitNormalText, this, 487 software_keyboard, &QtSoftwareKeyboardDialog::SubmitNormalText, this,
488 [this](Service::AM::Applets::SwkbdResult result, std::u16string submitted_text) { 488 [this](Service::AM::Applets::SwkbdResult result, std::u16string submitted_text,
489 emit SoftwareKeyboardSubmitNormalText(result, submitted_text); 489 bool confirmed) {
490 emit SoftwareKeyboardSubmitNormalText(result, submitted_text, confirmed);
490 }, 491 },
491 Qt::QueuedConnection); 492 Qt::QueuedConnection);
492 } 493 }
@@ -2764,7 +2765,7 @@ void GMainWindow::OnConfigureTas() {
2764} 2765}
2765 2766
2766void GMainWindow::OnConfigurePerGame() { 2767void GMainWindow::OnConfigurePerGame() {
2767 const u64 title_id = system->CurrentProcess()->GetTitleID(); 2768 const u64 title_id = system->GetCurrentProcessProgramID();
2768 OpenPerGameConfiguration(title_id, game_path.toStdString()); 2769 OpenPerGameConfiguration(title_id, game_path.toStdString());
2769} 2770}
2770 2771
@@ -2863,7 +2864,7 @@ void GMainWindow::OnToggleFilterBar() {
2863} 2864}
2864 2865
2865void GMainWindow::OnCaptureScreenshot() { 2866void GMainWindow::OnCaptureScreenshot() {
2866 const u64 title_id = system->CurrentProcess()->GetTitleID(); 2867 const u64 title_id = system->GetCurrentProcessProgramID();
2867 const auto screenshot_path = 2868 const auto screenshot_path =
2868 QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir)); 2869 QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir));
2869 const auto date = 2870 const auto date =
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index aed15a0a0..981102daa 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -150,7 +150,7 @@ signals:
150 void ProfileSelectorFinishedSelection(std::optional<Common::UUID> uuid); 150 void ProfileSelectorFinishedSelection(std::optional<Common::UUID> uuid);
151 151
152 void SoftwareKeyboardSubmitNormalText(Service::AM::Applets::SwkbdResult result, 152 void SoftwareKeyboardSubmitNormalText(Service::AM::Applets::SwkbdResult result,
153 std::u16string submitted_text); 153 std::u16string submitted_text, bool confirmed);
154 void SoftwareKeyboardSubmitInlineText(Service::AM::Applets::SwkbdReplyType reply_type, 154 void SoftwareKeyboardSubmitInlineText(Service::AM::Applets::SwkbdReplyType reply_type,
155 std::u16string submitted_text, s32 cursor_position); 155 std::u16string submitted_text, s32 cursor_position);
156 156
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 67587cc54..b44ea0cc4 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -28,7 +28,6 @@
28#include "core/crypto/key_manager.h" 28#include "core/crypto/key_manager.h"
29#include "core/file_sys/registered_cache.h" 29#include "core/file_sys/registered_cache.h"
30#include "core/file_sys/vfs_real.h" 30#include "core/file_sys/vfs_real.h"
31#include "core/hle/kernel/k_process.h"
32#include "core/hle/service/filesystem/filesystem.h" 31#include "core/hle/service/filesystem/filesystem.h"
33#include "core/loader/loader.h" 32#include "core/loader/loader.h"
34#include "core/telemetry_session.h" 33#include "core/telemetry_session.h"
@@ -203,7 +202,7 @@ int main(int argc, char** argv) {
203 202
204 if (Settings::values.use_disk_shader_cache.GetValue()) { 203 if (Settings::values.use_disk_shader_cache.GetValue()) {
205 system.Renderer().ReadRasterizer()->LoadDiskResources( 204 system.Renderer().ReadRasterizer()->LoadDiskResources(
206 system.CurrentProcess()->GetTitleID(), std::stop_token{}, 205 system.GetCurrentProcessProgramID(), std::stop_token{},
207 [](VideoCore::LoadCallbackStage, size_t value, size_t total) {}); 206 [](VideoCore::LoadCallbackStage, size_t value, size_t total) {});
208 } 207 }
209 208