diff options
Diffstat (limited to 'src/core')
59 files changed, 827 insertions, 534 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 3cc9160ca..780a3affe 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -67,6 +67,8 @@ add_library(core STATIC | |||
| 67 | hle/kernel/memory.h | 67 | hle/kernel/memory.h |
| 68 | hle/kernel/mutex.cpp | 68 | hle/kernel/mutex.cpp |
| 69 | hle/kernel/mutex.h | 69 | hle/kernel/mutex.h |
| 70 | hle/kernel/object.cpp | ||
| 71 | hle/kernel/object.h | ||
| 70 | hle/kernel/process.cpp | 72 | hle/kernel/process.cpp |
| 71 | hle/kernel/process.h | 73 | hle/kernel/process.h |
| 72 | hle/kernel/resource_limit.cpp | 74 | hle/kernel/resource_limit.cpp |
| @@ -204,6 +206,8 @@ add_library(core STATIC | |||
| 204 | hle/service/ldr/ldr.h | 206 | hle/service/ldr/ldr.h |
| 205 | hle/service/lm/lm.cpp | 207 | hle/service/lm/lm.cpp |
| 206 | hle/service/lm/lm.h | 208 | hle/service/lm/lm.h |
| 209 | hle/service/mig/mig.cpp | ||
| 210 | hle/service/mig/mig.h | ||
| 207 | hle/service/mii/mii.cpp | 211 | hle/service/mii/mii.cpp |
| 208 | hle/service/mii/mii.h | 212 | hle/service/mii/mii.h |
| 209 | hle/service/mm/mm_u.cpp | 213 | hle/service/mm/mm_u.cpp |
| @@ -261,6 +265,8 @@ add_library(core STATIC | |||
| 261 | hle/service/pm/pm.h | 265 | hle/service/pm/pm.h |
| 262 | hle/service/prepo/prepo.cpp | 266 | hle/service/prepo/prepo.cpp |
| 263 | hle/service/prepo/prepo.h | 267 | hle/service/prepo/prepo.h |
| 268 | hle/service/psc/psc.cpp | ||
| 269 | hle/service/psc/psc.h | ||
| 264 | hle/service/service.cpp | 270 | hle/service/service.cpp |
| 265 | hle/service/service.h | 271 | hle/service/service.h |
| 266 | hle/service/set/set.cpp | 272 | hle/service/set/set.cpp |
| @@ -309,10 +315,6 @@ add_library(core STATIC | |||
| 309 | hle/service/vi/vi_u.h | 315 | hle/service/vi/vi_u.h |
| 310 | hle/service/wlan/wlan.cpp | 316 | hle/service/wlan/wlan.cpp |
| 311 | hle/service/wlan/wlan.h | 317 | hle/service/wlan/wlan.h |
| 312 | hw/hw.cpp | ||
| 313 | hw/hw.h | ||
| 314 | hw/lcd.cpp | ||
| 315 | hw/lcd.h | ||
| 316 | loader/deconstructed_rom_directory.cpp | 318 | loader/deconstructed_rom_directory.cpp |
| 317 | loader/deconstructed_rom_directory.h | 319 | loader/deconstructed_rom_directory.h |
| 318 | loader/elf.cpp | 320 | loader/elf.cpp |
diff --git a/src/core/core.cpp b/src/core/core.cpp index b7f4b4532..54fc4170f 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -15,9 +15,7 @@ | |||
| 15 | #include "core/hle/service/service.h" | 15 | #include "core/hle/service/service.h" |
| 16 | #include "core/hle/service/sm/controller.h" | 16 | #include "core/hle/service/sm/controller.h" |
| 17 | #include "core/hle/service/sm/sm.h" | 17 | #include "core/hle/service/sm/sm.h" |
| 18 | #include "core/hw/hw.h" | ||
| 19 | #include "core/loader/loader.h" | 18 | #include "core/loader/loader.h" |
| 20 | #include "core/memory_setup.h" | ||
| 21 | #include "core/settings.h" | 19 | #include "core/settings.h" |
| 22 | #include "file_sys/vfs_real.h" | 20 | #include "file_sys/vfs_real.h" |
| 23 | #include "video_core/video_core.h" | 21 | #include "video_core/video_core.h" |
| @@ -86,7 +84,7 @@ System::ResultStatus System::SingleStep() { | |||
| 86 | return RunLoop(false); | 84 | return RunLoop(false); |
| 87 | } | 85 | } |
| 88 | 86 | ||
| 89 | System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& filepath) { | 87 | System::ResultStatus System::Load(EmuWindow& emu_window, const std::string& filepath) { |
| 90 | app_loader = Loader::GetLoader(std::make_shared<FileSys::RealVfsFile>(filepath)); | 88 | app_loader = Loader::GetLoader(std::make_shared<FileSys::RealVfsFile>(filepath)); |
| 91 | 89 | ||
| 92 | if (!app_loader) { | 90 | if (!app_loader) { |
| @@ -163,7 +161,7 @@ Cpu& System::CpuCore(size_t core_index) { | |||
| 163 | return *cpu_cores[core_index]; | 161 | return *cpu_cores[core_index]; |
| 164 | } | 162 | } |
| 165 | 163 | ||
| 166 | System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { | 164 | System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) { |
| 167 | LOG_DEBUG(HW_Memory, "initialized OK"); | 165 | LOG_DEBUG(HW_Memory, "initialized OK"); |
| 168 | 166 | ||
| 169 | CoreTiming::Init(); | 167 | CoreTiming::Init(); |
| @@ -180,7 +178,6 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { | |||
| 180 | telemetry_session = std::make_unique<Core::TelemetrySession>(); | 178 | telemetry_session = std::make_unique<Core::TelemetrySession>(); |
| 181 | service_manager = std::make_shared<Service::SM::ServiceManager>(); | 179 | service_manager = std::make_shared<Service::SM::ServiceManager>(); |
| 182 | 180 | ||
| 183 | HW::Init(); | ||
| 184 | Kernel::Init(system_mode); | 181 | Kernel::Init(system_mode); |
| 185 | Service::Init(service_manager); | 182 | Service::Init(service_manager); |
| 186 | GDBStub::Init(); | 183 | GDBStub::Init(); |
| @@ -224,7 +221,6 @@ void System::Shutdown() { | |||
| 224 | GDBStub::Shutdown(); | 221 | GDBStub::Shutdown(); |
| 225 | Service::Shutdown(); | 222 | Service::Shutdown(); |
| 226 | Kernel::Shutdown(); | 223 | Kernel::Shutdown(); |
| 227 | HW::Shutdown(); | ||
| 228 | service_manager.reset(); | 224 | service_manager.reset(); |
| 229 | telemetry_session.reset(); | 225 | telemetry_session.reset(); |
| 230 | gpu_core.reset(); | 226 | gpu_core.reset(); |
diff --git a/src/core/core.h b/src/core/core.h index c123fe401..f8b6644bb 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "core/arm/exclusive_monitor.h" | 12 | #include "core/arm/exclusive_monitor.h" |
| 13 | #include "core/core_cpu.h" | 13 | #include "core/core_cpu.h" |
| 14 | #include "core/hle/kernel/kernel.h" | 14 | #include "core/hle/kernel/object.h" |
| 15 | #include "core/hle/kernel/scheduler.h" | 15 | #include "core/hle/kernel/scheduler.h" |
| 16 | #include "core/loader/loader.h" | 16 | #include "core/loader/loader.h" |
| 17 | #include "core/memory.h" | 17 | #include "core/memory.h" |
| @@ -81,11 +81,12 @@ public: | |||
| 81 | 81 | ||
| 82 | /** | 82 | /** |
| 83 | * Load an executable application. | 83 | * Load an executable application. |
| 84 | * @param emu_window Pointer to the host-system window used for video output and keyboard input. | 84 | * @param emu_window Reference to the host-system window used for video output and keyboard |
| 85 | * input. | ||
| 85 | * @param filepath String path to the executable application to load on the host file system. | 86 | * @param filepath String path to the executable application to load on the host file system. |
| 86 | * @returns ResultStatus code, indicating if the operation succeeded. | 87 | * @returns ResultStatus code, indicating if the operation succeeded. |
| 87 | */ | 88 | */ |
| 88 | ResultStatus Load(EmuWindow* emu_window, const std::string& filepath); | 89 | ResultStatus Load(EmuWindow& emu_window, const std::string& filepath); |
| 89 | 90 | ||
| 90 | /** | 91 | /** |
| 91 | * Indicates if the emulated system is powered on (all subsystems initialized and able to run an | 92 | * Indicates if the emulated system is powered on (all subsystems initialized and able to run an |
| @@ -186,11 +187,12 @@ private: | |||
| 186 | 187 | ||
| 187 | /** | 188 | /** |
| 188 | * Initialize the emulated system. | 189 | * Initialize the emulated system. |
| 189 | * @param emu_window Pointer to the host-system window used for video output and keyboard input. | 190 | * @param emu_window Reference to the host-system window used for video output and keyboard |
| 191 | * input. | ||
| 190 | * @param system_mode The system mode. | 192 | * @param system_mode The system mode. |
| 191 | * @return ResultStatus code, indicating if the operation succeeded. | 193 | * @return ResultStatus code, indicating if the operation succeeded. |
| 192 | */ | 194 | */ |
| 193 | ResultStatus Init(EmuWindow* emu_window, u32 system_mode); | 195 | ResultStatus Init(EmuWindow& emu_window, u32 system_mode); |
| 194 | 196 | ||
| 195 | /// AppLoader used to load the current executing application | 197 | /// AppLoader used to load the current executing application |
| 196 | std::unique_ptr<Loader::AppLoader> app_loader; | 198 | std::unique_ptr<Loader::AppLoader> app_loader; |
diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp index 54e15a701..46a522fcd 100644 --- a/src/core/core_cpu.cpp +++ b/src/core/core_cpu.cpp | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include "core/arm/unicorn/arm_unicorn.h" | 12 | #include "core/arm/unicorn/arm_unicorn.h" |
| 13 | #include "core/core_cpu.h" | 13 | #include "core/core_cpu.h" |
| 14 | #include "core/core_timing.h" | 14 | #include "core/core_timing.h" |
| 15 | #include "core/hle/kernel/kernel.h" | ||
| 16 | #include "core/hle/kernel/scheduler.h" | 15 | #include "core/hle/kernel/scheduler.h" |
| 17 | #include "core/hle/kernel/thread.h" | 16 | #include "core/hle/kernel/thread.h" |
| 18 | #include "core/settings.h" | 17 | #include "core/settings.h" |
diff --git a/src/core/file_sys/vfs_vector.cpp b/src/core/file_sys/vfs_vector.cpp index 4c6337e3a..fda603960 100644 --- a/src/core/file_sys/vfs_vector.cpp +++ b/src/core/file_sys/vfs_vector.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <utility> | ||
| 6 | #include "core/file_sys/vfs_vector.h" | 7 | #include "core/file_sys/vfs_vector.h" |
| 7 | 8 | ||
| 8 | namespace FileSys { | 9 | namespace FileSys { |
| @@ -31,16 +32,18 @@ bool VectorVfsDirectory::IsReadable() const { | |||
| 31 | std::string VectorVfsDirectory::GetName() const { | 32 | std::string VectorVfsDirectory::GetName() const { |
| 32 | return name; | 33 | return name; |
| 33 | } | 34 | } |
| 35 | |||
| 34 | std::shared_ptr<VfsDirectory> VectorVfsDirectory::GetParentDirectory() const { | 36 | std::shared_ptr<VfsDirectory> VectorVfsDirectory::GetParentDirectory() const { |
| 35 | return parent; | 37 | return parent; |
| 36 | } | 38 | } |
| 37 | 39 | ||
| 38 | template <typename T> | 40 | template <typename T> |
| 39 | static bool FindAndRemoveVectorElement(std::vector<T>& vec, std::string_view name) { | 41 | static bool FindAndRemoveVectorElement(std::vector<T>& vec, std::string_view name) { |
| 40 | auto iter = std::find_if(vec.begin(), vec.end(), [name](T e) { return e->GetName() == name; }); | 42 | const auto iter = |
| 43 | std::find_if(vec.begin(), vec.end(), [name](const T& e) { return e->GetName() == name; }); | ||
| 41 | if (iter == vec.end()) | 44 | if (iter == vec.end()) |
| 42 | return false; | 45 | return false; |
| 43 | auto old_size = vec.size(); | 46 | |
| 44 | vec.erase(iter); | 47 | vec.erase(iter); |
| 45 | return true; | 48 | return true; |
| 46 | } | 49 | } |
| @@ -77,7 +80,7 @@ void VectorVfsDirectory::AddDirectory(VirtualDir dir) { | |||
| 77 | bool VectorVfsDirectory::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) { | 80 | bool VectorVfsDirectory::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) { |
| 78 | if (!DeleteFile(file->GetName())) | 81 | if (!DeleteFile(file->GetName())) |
| 79 | return false; | 82 | return false; |
| 80 | dirs.emplace_back(dir); | 83 | dirs.emplace_back(std::move(dir)); |
| 81 | return true; | 84 | return true; |
| 82 | } | 85 | } |
| 83 | } // namespace FileSys | 86 | } // namespace FileSys |
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 5ca573652..75f6b8235 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp | |||
| @@ -37,7 +37,6 @@ | |||
| 37 | #include "core/core.h" | 37 | #include "core/core.h" |
| 38 | #include "core/core_cpu.h" | 38 | #include "core/core_cpu.h" |
| 39 | #include "core/gdbstub/gdbstub.h" | 39 | #include "core/gdbstub/gdbstub.h" |
| 40 | #include "core/hle/kernel/kernel.h" | ||
| 41 | #include "core/hle/kernel/scheduler.h" | 40 | #include "core/hle/kernel/scheduler.h" |
| 42 | #include "core/loader/loader.h" | 41 | #include "core/loader/loader.h" |
| 43 | #include "core/memory.h" | 42 | #include "core/memory.h" |
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 7fb0da408..d3a734831 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h | |||
| @@ -5,15 +5,18 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <cstring> | ||
| 9 | #include <memory> | ||
| 8 | #include <tuple> | 10 | #include <tuple> |
| 9 | #include <type_traits> | 11 | #include <type_traits> |
| 10 | #include <utility> | 12 | #include <utility> |
| 13 | #include "common/assert.h" | ||
| 14 | #include "common/common_types.h" | ||
| 11 | #include "core/hle/ipc.h" | 15 | #include "core/hle/ipc.h" |
| 12 | #include "core/hle/kernel/client_port.h" | 16 | #include "core/hle/kernel/client_port.h" |
| 13 | #include "core/hle/kernel/client_session.h" | 17 | #include "core/hle/kernel/client_session.h" |
| 14 | #include "core/hle/kernel/handle_table.h" | ||
| 15 | #include "core/hle/kernel/hle_ipc.h" | 18 | #include "core/hle/kernel/hle_ipc.h" |
| 16 | #include "core/hle/kernel/kernel.h" | 19 | #include "core/hle/kernel/object.h" |
| 17 | #include "core/hle/kernel/server_port.h" | 20 | #include "core/hle/kernel/server_port.h" |
| 18 | 21 | ||
| 19 | namespace IPC { | 22 | namespace IPC { |
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index 6a10efab1..7a17ed162 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/core.h" | 10 | #include "core/core.h" |
| 11 | #include "core/hle/kernel/errors.h" | 11 | #include "core/hle/kernel/errors.h" |
| 12 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/object.h" |
| 13 | #include "core/hle/kernel/process.h" | 13 | #include "core/hle/kernel/process.h" |
| 14 | #include "core/hle/kernel/thread.h" | 14 | #include "core/hle/kernel/thread.h" |
| 15 | #include "core/hle/result.h" | 15 | #include "core/hle/result.h" |
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp index 2d6051e8b..7933c105c 100644 --- a/src/core/hle/kernel/client_port.cpp +++ b/src/core/hle/kernel/client_port.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include "core/hle/kernel/client_session.h" | 8 | #include "core/hle/kernel/client_session.h" |
| 9 | #include "core/hle/kernel/errors.h" | 9 | #include "core/hle/kernel/errors.h" |
| 10 | #include "core/hle/kernel/hle_ipc.h" | 10 | #include "core/hle/kernel/hle_ipc.h" |
| 11 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/object.h" |
| 12 | #include "core/hle/kernel/server_port.h" | 12 | #include "core/hle/kernel/server_port.h" |
| 13 | #include "core/hle/kernel/server_session.h" | 13 | #include "core/hle/kernel/server_session.h" |
| 14 | 14 | ||
diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h index a829aeb6d..b42c94bde 100644 --- a/src/core/hle/kernel/client_port.h +++ b/src/core/hle/kernel/client_port.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <string> | 7 | #include <string> |
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "core/hle/kernel/kernel.h" | 9 | #include "core/hle/kernel/object.h" |
| 10 | #include "core/hle/result.h" | 10 | #include "core/hle/result.h" |
| 11 | 11 | ||
| 12 | namespace Kernel { | 12 | namespace Kernel { |
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index 2258f95bc..dabd93ed7 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <string> | 8 | #include <string> |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/object.h" |
| 11 | #include "core/hle/result.h" | 11 | #include "core/hle/result.h" |
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index 37e0766c3..5623c4b6a 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "core/hle/kernel/event.h" | 7 | #include "core/hle/kernel/event.h" |
| 8 | #include "core/hle/kernel/kernel.h" | 8 | #include "core/hle/kernel/object.h" |
| 9 | #include "core/hle/kernel/thread.h" | 9 | #include "core/hle/kernel/thread.h" |
| 10 | 10 | ||
| 11 | namespace Kernel { | 11 | namespace Kernel { |
diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h index e5c924a75..1c99911b2 100644 --- a/src/core/hle/kernel/event.h +++ b/src/core/hle/kernel/event.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "core/hle/kernel/kernel.h" | 8 | #include "core/hle/kernel/object.h" |
| 9 | #include "core/hle/kernel/wait_object.h" | 9 | #include "core/hle/kernel/wait_object.h" |
| 10 | 10 | ||
| 11 | namespace Kernel { | 11 | namespace Kernel { |
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index 7dd67f80f..28e21428a 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/hle/kernel/errors.h" | 9 | #include "core/hle/kernel/errors.h" |
| 10 | #include "core/hle/kernel/handle_table.h" | 10 | #include "core/hle/kernel/handle_table.h" |
| 11 | #include "core/hle/kernel/kernel.h" | ||
| 12 | #include "core/hle/kernel/process.h" | 11 | #include "core/hle/kernel/process.h" |
| 13 | #include "core/hle/kernel/thread.h" | 12 | #include "core/hle/kernel/thread.h" |
| 14 | 13 | ||
diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h index ba968c666..22ddda630 100644 --- a/src/core/hle/kernel/handle_table.h +++ b/src/core/hle/kernel/handle_table.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <cstddef> | 8 | #include <cstddef> |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/object.h" |
| 11 | #include "core/hle/result.h" | 11 | #include "core/hle/result.h" |
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 771d6d476..5dd1b68d7 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -3,17 +3,21 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <array> | ||
| 7 | #include <sstream> | ||
| 6 | #include <utility> | 8 | #include <utility> |
| 7 | 9 | ||
| 8 | #include <boost/range/algorithm_ext/erase.hpp> | 10 | #include <boost/range/algorithm_ext/erase.hpp> |
| 11 | |||
| 9 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| 10 | #include "common/common_funcs.h" | 13 | #include "common/common_funcs.h" |
| 11 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | #include "common/logging/log.h" | ||
| 12 | #include "core/hle/ipc_helpers.h" | 16 | #include "core/hle/ipc_helpers.h" |
| 13 | #include "core/hle/kernel/event.h" | 17 | #include "core/hle/kernel/event.h" |
| 14 | #include "core/hle/kernel/handle_table.h" | 18 | #include "core/hle/kernel/handle_table.h" |
| 15 | #include "core/hle/kernel/hle_ipc.h" | 19 | #include "core/hle/kernel/hle_ipc.h" |
| 16 | #include "core/hle/kernel/kernel.h" | 20 | #include "core/hle/kernel/object.h" |
| 17 | #include "core/hle/kernel/process.h" | 21 | #include "core/hle/kernel/process.h" |
| 18 | #include "core/hle/kernel/server_session.h" | 22 | #include "core/hle/kernel/server_session.h" |
| 19 | #include "core/memory.h" | 23 | #include "core/memory.h" |
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index ee4abebf2..9ce52db24 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 14 | #include "common/swap.h" | 14 | #include "common/swap.h" |
| 15 | #include "core/hle/ipc.h" | 15 | #include "core/hle/ipc.h" |
| 16 | #include "core/hle/kernel/kernel.h" | 16 | #include "core/hle/kernel/object.h" |
| 17 | #include "core/hle/kernel/server_session.h" | 17 | #include "core/hle/kernel/server_session.h" |
| 18 | #include "core/hle/kernel/thread.h" | 18 | #include "core/hle/kernel/thread.h" |
| 19 | 19 | ||
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 402ae900f..2bc45d7db 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -4,120 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <cstddef> | ||
| 8 | #include <string> | ||
| 9 | #include <utility> | ||
| 10 | #include <boost/smart_ptr/intrusive_ptr.hpp> | ||
| 11 | #include "common/assert.h" | ||
| 12 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 13 | 8 | ||
| 14 | namespace Kernel { | 9 | namespace Kernel { |
| 15 | 10 | ||
| 16 | using Handle = u32; | ||
| 17 | |||
| 18 | enum class HandleType : u32 { | ||
| 19 | Unknown, | ||
| 20 | Event, | ||
| 21 | SharedMemory, | ||
| 22 | Thread, | ||
| 23 | Process, | ||
| 24 | AddressArbiter, | ||
| 25 | Timer, | ||
| 26 | ResourceLimit, | ||
| 27 | CodeSet, | ||
| 28 | ClientPort, | ||
| 29 | ServerPort, | ||
| 30 | ClientSession, | ||
| 31 | ServerSession, | ||
| 32 | }; | ||
| 33 | |||
| 34 | enum class ResetType { | ||
| 35 | OneShot, | ||
| 36 | Sticky, | ||
| 37 | Pulse, | ||
| 38 | }; | ||
| 39 | |||
| 40 | class Object : NonCopyable { | ||
| 41 | public: | ||
| 42 | virtual ~Object() {} | ||
| 43 | |||
| 44 | /// Returns a unique identifier for the object. For debugging purposes only. | ||
| 45 | unsigned int GetObjectId() const { | ||
| 46 | return object_id; | ||
| 47 | } | ||
| 48 | |||
| 49 | virtual std::string GetTypeName() const { | ||
| 50 | return "[BAD KERNEL OBJECT TYPE]"; | ||
| 51 | } | ||
| 52 | virtual std::string GetName() const { | ||
| 53 | return "[UNKNOWN KERNEL OBJECT]"; | ||
| 54 | } | ||
| 55 | virtual Kernel::HandleType GetHandleType() const = 0; | ||
| 56 | |||
| 57 | /** | ||
| 58 | * Check if a thread can wait on the object | ||
| 59 | * @return True if a thread can wait on the object, otherwise false | ||
| 60 | */ | ||
| 61 | bool IsWaitable() const { | ||
| 62 | switch (GetHandleType()) { | ||
| 63 | case HandleType::Event: | ||
| 64 | case HandleType::Thread: | ||
| 65 | case HandleType::Timer: | ||
| 66 | case HandleType::ServerPort: | ||
| 67 | case HandleType::ServerSession: | ||
| 68 | return true; | ||
| 69 | |||
| 70 | case HandleType::Unknown: | ||
| 71 | case HandleType::SharedMemory: | ||
| 72 | case HandleType::Process: | ||
| 73 | case HandleType::AddressArbiter: | ||
| 74 | case HandleType::ResourceLimit: | ||
| 75 | case HandleType::CodeSet: | ||
| 76 | case HandleType::ClientPort: | ||
| 77 | case HandleType::ClientSession: | ||
| 78 | return false; | ||
| 79 | } | ||
| 80 | |||
| 81 | UNREACHABLE(); | ||
| 82 | } | ||
| 83 | |||
| 84 | public: | ||
| 85 | static unsigned int next_object_id; | ||
| 86 | |||
| 87 | private: | ||
| 88 | friend void intrusive_ptr_add_ref(Object*); | ||
| 89 | friend void intrusive_ptr_release(Object*); | ||
| 90 | |||
| 91 | unsigned int ref_count = 0; | ||
| 92 | unsigned int object_id = next_object_id++; | ||
| 93 | }; | ||
| 94 | |||
| 95 | // Special functions used by boost::instrusive_ptr to do automatic ref-counting | ||
| 96 | inline void intrusive_ptr_add_ref(Object* object) { | ||
| 97 | ++object->ref_count; | ||
| 98 | } | ||
| 99 | |||
| 100 | inline void intrusive_ptr_release(Object* object) { | ||
| 101 | if (--object->ref_count == 0) { | ||
| 102 | delete object; | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | template <typename T> | ||
| 107 | using SharedPtr = boost::intrusive_ptr<T>; | ||
| 108 | |||
| 109 | /** | ||
| 110 | * Attempts to downcast the given Object pointer to a pointer to T. | ||
| 111 | * @return Derived pointer to the object, or `nullptr` if `object` isn't of type T. | ||
| 112 | */ | ||
| 113 | template <typename T> | ||
| 114 | inline SharedPtr<T> DynamicObjectCast(SharedPtr<Object> object) { | ||
| 115 | if (object != nullptr && object->GetHandleType() == T::HANDLE_TYPE) { | ||
| 116 | return boost::static_pointer_cast<T>(std::move(object)); | ||
| 117 | } | ||
| 118 | return nullptr; | ||
| 119 | } | ||
| 120 | |||
| 121 | /// Initialize the kernel with the specified system mode. | 11 | /// Initialize the kernel with the specified system mode. |
| 122 | void Init(u32 system_mode); | 12 | void Init(u32 system_mode); |
| 123 | 13 | ||
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 12b974c4b..cb7f58b35 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp | |||
| @@ -12,8 +12,8 @@ | |||
| 12 | #include "core/core.h" | 12 | #include "core/core.h" |
| 13 | #include "core/hle/kernel/errors.h" | 13 | #include "core/hle/kernel/errors.h" |
| 14 | #include "core/hle/kernel/handle_table.h" | 14 | #include "core/hle/kernel/handle_table.h" |
| 15 | #include "core/hle/kernel/kernel.h" | ||
| 16 | #include "core/hle/kernel/mutex.h" | 15 | #include "core/hle/kernel/mutex.h" |
| 16 | #include "core/hle/kernel/object.h" | ||
| 17 | #include "core/hle/kernel/thread.h" | 17 | #include "core/hle/kernel/thread.h" |
| 18 | #include "core/hle/result.h" | 18 | #include "core/hle/result.h" |
| 19 | 19 | ||
diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index febfde698..45268bbe9 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "core/hle/kernel/kernel.h" | 8 | #include "core/hle/kernel/object.h" |
| 9 | 9 | ||
| 10 | union ResultCode; | 10 | union ResultCode; |
| 11 | 11 | ||
diff --git a/src/core/hle/kernel/object.cpp b/src/core/hle/kernel/object.cpp new file mode 100644 index 000000000..cdba272f5 --- /dev/null +++ b/src/core/hle/kernel/object.cpp | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | // Copyright 2018 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/assert.h" | ||
| 6 | #include "core/hle/kernel/object.h" | ||
| 7 | |||
| 8 | namespace Kernel { | ||
| 9 | |||
| 10 | Object::~Object() = default; | ||
| 11 | |||
| 12 | bool Object::IsWaitable() const { | ||
| 13 | switch (GetHandleType()) { | ||
| 14 | case HandleType::Event: | ||
| 15 | case HandleType::Thread: | ||
| 16 | case HandleType::Timer: | ||
| 17 | case HandleType::ServerPort: | ||
| 18 | case HandleType::ServerSession: | ||
| 19 | return true; | ||
| 20 | |||
| 21 | case HandleType::Unknown: | ||
| 22 | case HandleType::SharedMemory: | ||
| 23 | case HandleType::Process: | ||
| 24 | case HandleType::AddressArbiter: | ||
| 25 | case HandleType::ResourceLimit: | ||
| 26 | case HandleType::CodeSet: | ||
| 27 | case HandleType::ClientPort: | ||
| 28 | case HandleType::ClientSession: | ||
| 29 | return false; | ||
| 30 | } | ||
| 31 | |||
| 32 | UNREACHABLE(); | ||
| 33 | } | ||
| 34 | |||
| 35 | } // namespace Kernel | ||
diff --git a/src/core/hle/kernel/object.h b/src/core/hle/kernel/object.h new file mode 100644 index 000000000..83df68dfd --- /dev/null +++ b/src/core/hle/kernel/object.h | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | // Copyright 2018 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <string> | ||
| 8 | #include <utility> | ||
| 9 | |||
| 10 | #include <boost/smart_ptr/intrusive_ptr.hpp> | ||
| 11 | |||
| 12 | #include "common/common_types.h" | ||
| 13 | |||
| 14 | namespace Kernel { | ||
| 15 | |||
| 16 | using Handle = u32; | ||
| 17 | |||
| 18 | enum class HandleType : u32 { | ||
| 19 | Unknown, | ||
| 20 | Event, | ||
| 21 | SharedMemory, | ||
| 22 | Thread, | ||
| 23 | Process, | ||
| 24 | AddressArbiter, | ||
| 25 | Timer, | ||
| 26 | ResourceLimit, | ||
| 27 | CodeSet, | ||
| 28 | ClientPort, | ||
| 29 | ServerPort, | ||
| 30 | ClientSession, | ||
| 31 | ServerSession, | ||
| 32 | }; | ||
| 33 | |||
| 34 | enum class ResetType { | ||
| 35 | OneShot, | ||
| 36 | Sticky, | ||
| 37 | Pulse, | ||
| 38 | }; | ||
| 39 | |||
| 40 | class Object : NonCopyable { | ||
| 41 | public: | ||
| 42 | virtual ~Object(); | ||
| 43 | |||
| 44 | /// Returns a unique identifier for the object. For debugging purposes only. | ||
| 45 | unsigned int GetObjectId() const { | ||
| 46 | return object_id; | ||
| 47 | } | ||
| 48 | |||
| 49 | virtual std::string GetTypeName() const { | ||
| 50 | return "[BAD KERNEL OBJECT TYPE]"; | ||
| 51 | } | ||
| 52 | virtual std::string GetName() const { | ||
| 53 | return "[UNKNOWN KERNEL OBJECT]"; | ||
| 54 | } | ||
| 55 | virtual HandleType GetHandleType() const = 0; | ||
| 56 | |||
| 57 | /** | ||
| 58 | * Check if a thread can wait on the object | ||
| 59 | * @return True if a thread can wait on the object, otherwise false | ||
| 60 | */ | ||
| 61 | bool IsWaitable() const; | ||
| 62 | |||
| 63 | public: | ||
| 64 | static unsigned int next_object_id; | ||
| 65 | |||
| 66 | private: | ||
| 67 | friend void intrusive_ptr_add_ref(Object*); | ||
| 68 | friend void intrusive_ptr_release(Object*); | ||
| 69 | |||
| 70 | unsigned int ref_count = 0; | ||
| 71 | unsigned int object_id = next_object_id++; | ||
| 72 | }; | ||
| 73 | |||
| 74 | // Special functions used by boost::instrusive_ptr to do automatic ref-counting | ||
| 75 | inline void intrusive_ptr_add_ref(Object* object) { | ||
| 76 | ++object->ref_count; | ||
| 77 | } | ||
| 78 | |||
| 79 | inline void intrusive_ptr_release(Object* object) { | ||
| 80 | if (--object->ref_count == 0) { | ||
| 81 | delete object; | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | template <typename T> | ||
| 86 | using SharedPtr = boost::intrusive_ptr<T>; | ||
| 87 | |||
| 88 | /** | ||
| 89 | * Attempts to downcast the given Object pointer to a pointer to T. | ||
| 90 | * @return Derived pointer to the object, or `nullptr` if `object` isn't of type T. | ||
| 91 | */ | ||
| 92 | template <typename T> | ||
| 93 | inline SharedPtr<T> DynamicObjectCast(SharedPtr<Object> object) { | ||
| 94 | if (object != nullptr && object->GetHandleType() == T::HANDLE_TYPE) { | ||
| 95 | return boost::static_pointer_cast<T>(std::move(object)); | ||
| 96 | } | ||
| 97 | return nullptr; | ||
| 98 | } | ||
| 99 | |||
| 100 | } // namespace Kernel | ||
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 68e77a4d1..1204026be 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #include <boost/container/static_vector.hpp> | 12 | #include <boost/container/static_vector.hpp> |
| 13 | #include "common/bit_field.h" | 13 | #include "common/bit_field.h" |
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | #include "core/hle/kernel/kernel.h" | 15 | #include "core/hle/kernel/object.h" |
| 16 | #include "core/hle/kernel/thread.h" | 16 | #include "core/hle/kernel/thread.h" |
| 17 | #include "core/hle/kernel/vm_manager.h" | 17 | #include "core/hle/kernel/vm_manager.h" |
| 18 | 18 | ||
diff --git a/src/core/hle/kernel/resource_limit.h b/src/core/hle/kernel/resource_limit.h index cc689a27a..0fa141db3 100644 --- a/src/core/hle/kernel/resource_limit.h +++ b/src/core/hle/kernel/resource_limit.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "core/hle/kernel/kernel.h" | 8 | #include "core/hle/kernel/object.h" |
| 9 | 9 | ||
| 10 | namespace Kernel { | 10 | namespace Kernel { |
| 11 | 11 | ||
diff --git a/src/core/hle/kernel/scheduler.h b/src/core/hle/kernel/scheduler.h index cdc14808b..1a4ee8f36 100644 --- a/src/core/hle/kernel/scheduler.h +++ b/src/core/hle/kernel/scheduler.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/thread_queue_list.h" | 10 | #include "common/thread_queue_list.h" |
| 11 | #include "core/hle/kernel/object.h" | ||
| 11 | #include "core/hle/kernel/thread.h" | 12 | #include "core/hle/kernel/thread.h" |
| 12 | 13 | ||
| 13 | class ARM_Interface; | 14 | class ARM_Interface; |
diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp index 0b7061403..7b6211fd8 100644 --- a/src/core/hle/kernel/server_port.cpp +++ b/src/core/hle/kernel/server_port.cpp | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "core/hle/kernel/client_port.h" | 7 | #include "core/hle/kernel/client_port.h" |
| 8 | #include "core/hle/kernel/errors.h" | 8 | #include "core/hle/kernel/errors.h" |
| 9 | #include "core/hle/kernel/kernel.h" | 9 | #include "core/hle/kernel/object.h" |
| 10 | #include "core/hle/kernel/server_port.h" | 10 | #include "core/hle/kernel/server_port.h" |
| 11 | #include "core/hle/kernel/server_session.h" | 11 | #include "core/hle/kernel/server_session.h" |
| 12 | #include "core/hle/kernel/thread.h" | 12 | #include "core/hle/kernel/thread.h" |
diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h index e6546687e..7f6d6b3eb 100644 --- a/src/core/hle/kernel/server_port.h +++ b/src/core/hle/kernel/server_port.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include <tuple> | 9 | #include <tuple> |
| 10 | #include <vector> | 10 | #include <vector> |
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/object.h" |
| 13 | #include "core/hle/kernel/wait_object.h" | 13 | #include "core/hle/kernel/wait_object.h" |
| 14 | 14 | ||
| 15 | namespace Kernel { | 15 | namespace Kernel { |
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index c7656cc49..2bce54fee 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include <vector> | 9 | #include <vector> |
| 10 | 10 | ||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/object.h" |
| 13 | #include "core/hle/kernel/wait_object.h" | 13 | #include "core/hle/kernel/wait_object.h" |
| 14 | #include "core/hle/result.h" | 14 | #include "core/hle/result.h" |
| 15 | 15 | ||
diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h index e69b034a7..7a551f5e4 100644 --- a/src/core/hle/kernel/session.h +++ b/src/core/hle/kernel/session.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/kernel/kernel.h" | 7 | #include "core/hle/kernel/object.h" |
| 8 | 8 | ||
| 9 | namespace Kernel { | 9 | namespace Kernel { |
| 10 | 10 | ||
diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h index 17b9cedc4..8a6f68529 100644 --- a/src/core/hle/kernel/shared_memory.h +++ b/src/core/hle/kernel/shared_memory.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include <vector> | 9 | #include <vector> |
| 10 | 10 | ||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/object.h" |
| 13 | #include "core/hle/kernel/process.h" | 13 | #include "core/hle/kernel/process.h" |
| 14 | #include "core/hle/result.h" | 14 | #include "core/hle/result.h" |
| 15 | 15 | ||
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index d1cbbc1f2..5db2db687 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -267,7 +267,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 267 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, | 267 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, |
| 268 | info_sub_id, handle); | 268 | info_sub_id, handle); |
| 269 | 269 | ||
| 270 | auto& vm_manager = Core::CurrentProcess()->vm_manager; | 270 | const auto& vm_manager = Core::CurrentProcess()->vm_manager; |
| 271 | 271 | ||
| 272 | switch (static_cast<GetInfoType>(info_id)) { | 272 | switch (static_cast<GetInfoType>(info_id)) { |
| 273 | case GetInfoType::AllowedCpuIdBitmask: | 273 | case GetInfoType::AllowedCpuIdBitmask: |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 93ea58a1e..cdb8120f2 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -20,8 +20,8 @@ | |||
| 20 | #include "core/core_timing_util.h" | 20 | #include "core/core_timing_util.h" |
| 21 | #include "core/hle/kernel/errors.h" | 21 | #include "core/hle/kernel/errors.h" |
| 22 | #include "core/hle/kernel/handle_table.h" | 22 | #include "core/hle/kernel/handle_table.h" |
| 23 | #include "core/hle/kernel/kernel.h" | ||
| 24 | #include "core/hle/kernel/memory.h" | 23 | #include "core/hle/kernel/memory.h" |
| 24 | #include "core/hle/kernel/object.h" | ||
| 25 | #include "core/hle/kernel/process.h" | 25 | #include "core/hle/kernel/process.h" |
| 26 | #include "core/hle/kernel/thread.h" | 26 | #include "core/hle/kernel/thread.h" |
| 27 | #include "core/hle/result.h" | 27 | #include "core/hle/result.h" |
| @@ -252,13 +252,14 @@ void Thread::ResumeFromWait() { | |||
| 252 | * slot: The index of the first free slot in the indicated page. | 252 | * slot: The index of the first free slot in the indicated page. |
| 253 | * alloc_needed: Whether there's a need to allocate a new TLS page (All pages are full). | 253 | * alloc_needed: Whether there's a need to allocate a new TLS page (All pages are full). |
| 254 | */ | 254 | */ |
| 255 | std::tuple<u32, u32, bool> GetFreeThreadLocalSlot(std::vector<std::bitset<8>>& tls_slots) { | 255 | static std::tuple<std::size_t, std::size_t, bool> GetFreeThreadLocalSlot( |
| 256 | const std::vector<std::bitset<8>>& tls_slots) { | ||
| 256 | // Iterate over all the allocated pages, and try to find one where not all slots are used. | 257 | // Iterate over all the allocated pages, and try to find one where not all slots are used. |
| 257 | for (unsigned page = 0; page < tls_slots.size(); ++page) { | 258 | for (std::size_t page = 0; page < tls_slots.size(); ++page) { |
| 258 | const auto& page_tls_slots = tls_slots[page]; | 259 | const auto& page_tls_slots = tls_slots[page]; |
| 259 | if (!page_tls_slots.all()) { | 260 | if (!page_tls_slots.all()) { |
| 260 | // We found a page with at least one free slot, find which slot it is | 261 | // We found a page with at least one free slot, find which slot it is |
| 261 | for (unsigned slot = 0; slot < page_tls_slots.size(); ++slot) { | 262 | for (std::size_t slot = 0; slot < page_tls_slots.size(); ++slot) { |
| 262 | if (!page_tls_slots.test(slot)) { | 263 | if (!page_tls_slots.test(slot)) { |
| 263 | return std::make_tuple(page, slot, false); | 264 | return std::make_tuple(page, slot, false); |
| 264 | } | 265 | } |
| @@ -333,11 +334,8 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 333 | 334 | ||
| 334 | // Find the next available TLS index, and mark it as used | 335 | // Find the next available TLS index, and mark it as used |
| 335 | auto& tls_slots = owner_process->tls_slots; | 336 | auto& tls_slots = owner_process->tls_slots; |
| 336 | bool needs_allocation = true; | ||
| 337 | u32 available_page; // Which allocated page has free space | ||
| 338 | u32 available_slot; // Which slot within the page is free | ||
| 339 | 337 | ||
| 340 | std::tie(available_page, available_slot, needs_allocation) = GetFreeThreadLocalSlot(tls_slots); | 338 | auto [available_page, available_slot, needs_allocation] = GetFreeThreadLocalSlot(tls_slots); |
| 341 | 339 | ||
| 342 | if (needs_allocation) { | 340 | if (needs_allocation) { |
| 343 | // There are no already-allocated pages with free slots, lets allocate a new one. | 341 | // There are no already-allocated pages with free slots, lets allocate a new one. |
| @@ -359,7 +357,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 359 | owner_process->linear_heap_used += Memory::PAGE_SIZE; | 357 | owner_process->linear_heap_used += Memory::PAGE_SIZE; |
| 360 | 358 | ||
| 361 | tls_slots.emplace_back(0); // The page is completely available at the start | 359 | tls_slots.emplace_back(0); // The page is completely available at the start |
| 362 | available_page = static_cast<u32>(tls_slots.size() - 1); | 360 | available_page = tls_slots.size() - 1; |
| 363 | available_slot = 0; // Use the first slot in the new page | 361 | available_slot = 0; // Use the first slot in the new page |
| 364 | 362 | ||
| 365 | auto& vm_manager = owner_process->vm_manager; | 363 | auto& vm_manager = owner_process->vm_manager; |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 3a96db5f3..146955e13 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "core/arm/arm_interface.h" | 13 | #include "core/arm/arm_interface.h" |
| 14 | #include "core/hle/kernel/kernel.h" | 14 | #include "core/hle/kernel/object.h" |
| 15 | #include "core/hle/kernel/wait_object.h" | 15 | #include "core/hle/kernel/wait_object.h" |
| 16 | #include "core/hle/result.h" | 16 | #include "core/hle/result.h" |
| 17 | 17 | ||
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index 904a3d0a5..282360745 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include "core/core_timing.h" | 8 | #include "core/core_timing.h" |
| 9 | #include "core/core_timing_util.h" | 9 | #include "core/core_timing_util.h" |
| 10 | #include "core/hle/kernel/handle_table.h" | 10 | #include "core/hle/kernel/handle_table.h" |
| 11 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/object.h" |
| 12 | #include "core/hle/kernel/thread.h" | 12 | #include "core/hle/kernel/thread.h" |
| 13 | #include "core/hle/kernel/timer.h" | 13 | #include "core/hle/kernel/timer.h" |
| 14 | 14 | ||
diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h index c63f0ed90..4dddc67e0 100644 --- a/src/core/hle/kernel/timer.h +++ b/src/core/hle/kernel/timer.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "core/hle/kernel/kernel.h" | 8 | #include "core/hle/kernel/object.h" |
| 9 | #include "core/hle/kernel/wait_object.h" | 9 | #include "core/hle/kernel/wait_object.h" |
| 10 | 10 | ||
| 11 | namespace Kernel { | 11 | namespace Kernel { |
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 9d26fd781..479cacb62 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <iterator> | 6 | #include <iterator> |
| 6 | #include <utility> | 7 | #include <utility> |
| 7 | #include "common/assert.h" | 8 | #include "common/assert.h" |
| @@ -175,9 +176,9 @@ VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) { | |||
| 175 | 176 | ||
| 176 | ResultCode VMManager::UnmapRange(VAddr target, u64 size) { | 177 | ResultCode VMManager::UnmapRange(VAddr target, u64 size) { |
| 177 | CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); | 178 | CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); |
| 178 | VAddr target_end = target + size; | 179 | const VAddr target_end = target + size; |
| 179 | 180 | ||
| 180 | VMAIter end = vma_map.end(); | 181 | const VMAIter end = vma_map.end(); |
| 181 | // The comparison against the end of the range must be done using addresses since VMAs can be | 182 | // The comparison against the end of the range must be done using addresses since VMAs can be |
| 182 | // merged during this process, causing invalidation of the iterators. | 183 | // merged during this process, causing invalidation of the iterators. |
| 183 | while (vma != end && vma->second.base < target_end) { | 184 | while (vma != end && vma->second.base < target_end) { |
| @@ -207,9 +208,9 @@ VMManager::VMAHandle VMManager::Reprotect(VMAHandle vma_handle, VMAPermission ne | |||
| 207 | 208 | ||
| 208 | ResultCode VMManager::ReprotectRange(VAddr target, u64 size, VMAPermission new_perms) { | 209 | ResultCode VMManager::ReprotectRange(VAddr target, u64 size, VMAPermission new_perms) { |
| 209 | CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); | 210 | CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); |
| 210 | VAddr target_end = target + size; | 211 | const VAddr target_end = target + size; |
| 211 | 212 | ||
| 212 | VMAIter end = vma_map.end(); | 213 | const VMAIter end = vma_map.end(); |
| 213 | // The comparison against the end of the range must be done using addresses since VMAs can be | 214 | // The comparison against the end of the range must be done using addresses since VMAs can be |
| 214 | // merged during this process, causing invalidation of the iterators. | 215 | // merged during this process, causing invalidation of the iterators. |
| 215 | while (vma != end && vma->second.base < target_end) { | 216 | while (vma != end && vma->second.base < target_end) { |
| @@ -258,14 +259,14 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u64 size) { | |||
| 258 | return ERR_INVALID_ADDRESS; | 259 | return ERR_INVALID_ADDRESS; |
| 259 | } | 260 | } |
| 260 | 261 | ||
| 261 | VirtualMemoryArea& vma = vma_handle->second; | 262 | const VirtualMemoryArea& vma = vma_handle->second; |
| 262 | if (vma.type != VMAType::Free) { | 263 | if (vma.type != VMAType::Free) { |
| 263 | // Region is already allocated | 264 | // Region is already allocated |
| 264 | return ERR_INVALID_ADDRESS_STATE; | 265 | return ERR_INVALID_ADDRESS_STATE; |
| 265 | } | 266 | } |
| 266 | 267 | ||
| 267 | u64 start_in_vma = base - vma.base; | 268 | const VAddr start_in_vma = base - vma.base; |
| 268 | u64 end_in_vma = start_in_vma + size; | 269 | const VAddr end_in_vma = start_in_vma + size; |
| 269 | 270 | ||
| 270 | if (end_in_vma > vma.size) { | 271 | if (end_in_vma > vma.size) { |
| 271 | // Requested allocation doesn't fit inside VMA | 272 | // Requested allocation doesn't fit inside VMA |
| @@ -288,17 +289,16 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMARange(VAddr target, u64 size) { | |||
| 288 | ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x{:016X}", size); | 289 | ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x{:016X}", size); |
| 289 | ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x{:016X}", target); | 290 | ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x{:016X}", target); |
| 290 | 291 | ||
| 291 | VAddr target_end = target + size; | 292 | const VAddr target_end = target + size; |
| 292 | ASSERT(target_end >= target); | 293 | ASSERT(target_end >= target); |
| 293 | ASSERT(target_end <= MAX_ADDRESS); | 294 | ASSERT(target_end <= MAX_ADDRESS); |
| 294 | ASSERT(size > 0); | 295 | ASSERT(size > 0); |
| 295 | 296 | ||
| 296 | VMAIter begin_vma = StripIterConstness(FindVMA(target)); | 297 | VMAIter begin_vma = StripIterConstness(FindVMA(target)); |
| 297 | VMAIter i_end = vma_map.lower_bound(target_end); | 298 | const VMAIter i_end = vma_map.lower_bound(target_end); |
| 298 | for (auto i = begin_vma; i != i_end; ++i) { | 299 | if (std::any_of(begin_vma, i_end, |
| 299 | if (i->second.type == VMAType::Free) { | 300 | [](const auto& entry) { return entry.second.type == VMAType::Free; })) { |
| 300 | return ERR_INVALID_ADDRESS_STATE; | 301 | return ERR_INVALID_ADDRESS_STATE; |
| 301 | } | ||
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | if (target != begin_vma->second.base) { | 304 | if (target != begin_vma->second.base) { |
| @@ -346,7 +346,7 @@ VMManager::VMAIter VMManager::SplitVMA(VMAIter vma_handle, u64 offset_in_vma) { | |||
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | VMManager::VMAIter VMManager::MergeAdjacent(VMAIter iter) { | 348 | VMManager::VMAIter VMManager::MergeAdjacent(VMAIter iter) { |
| 349 | VMAIter next_vma = std::next(iter); | 349 | const VMAIter next_vma = std::next(iter); |
| 350 | if (next_vma != vma_map.end() && iter->second.CanBeMergedWith(next_vma->second)) { | 350 | if (next_vma != vma_map.end() && iter->second.CanBeMergedWith(next_vma->second)) { |
| 351 | iter->second.size += next_vma->second.size; | 351 | iter->second.size += next_vma->second.size; |
| 352 | vma_map.erase(next_vma); | 352 | vma_map.erase(next_vma); |
| @@ -382,22 +382,22 @@ void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) { | |||
| 382 | } | 382 | } |
| 383 | } | 383 | } |
| 384 | 384 | ||
| 385 | u64 VMManager::GetTotalMemoryUsage() { | 385 | u64 VMManager::GetTotalMemoryUsage() const { |
| 386 | LOG_WARNING(Kernel, "(STUBBED) called"); | 386 | LOG_WARNING(Kernel, "(STUBBED) called"); |
| 387 | return 0xF8000000; | 387 | return 0xF8000000; |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | u64 VMManager::GetTotalHeapUsage() { | 390 | u64 VMManager::GetTotalHeapUsage() const { |
| 391 | LOG_WARNING(Kernel, "(STUBBED) called"); | 391 | LOG_WARNING(Kernel, "(STUBBED) called"); |
| 392 | return 0x0; | 392 | return 0x0; |
| 393 | } | 393 | } |
| 394 | 394 | ||
| 395 | VAddr VMManager::GetAddressSpaceBaseAddr() { | 395 | VAddr VMManager::GetAddressSpaceBaseAddr() const { |
| 396 | LOG_WARNING(Kernel, "(STUBBED) called"); | 396 | LOG_WARNING(Kernel, "(STUBBED) called"); |
| 397 | return 0x8000000; | 397 | return 0x8000000; |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | u64 VMManager::GetAddressSpaceSize() { | 400 | u64 VMManager::GetAddressSpaceSize() const { |
| 401 | LOG_WARNING(Kernel, "(STUBBED) called"); | 401 | LOG_WARNING(Kernel, "(STUBBED) called"); |
| 402 | return MAX_ADDRESS; | 402 | return MAX_ADDRESS; |
| 403 | } | 403 | } |
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 38e4ebcd3..98bd04bea 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h | |||
| @@ -190,16 +190,16 @@ public: | |||
| 190 | void LogLayout() const; | 190 | void LogLayout() const; |
| 191 | 191 | ||
| 192 | /// Gets the total memory usage, used by svcGetInfo | 192 | /// Gets the total memory usage, used by svcGetInfo |
| 193 | u64 GetTotalMemoryUsage(); | 193 | u64 GetTotalMemoryUsage() const; |
| 194 | 194 | ||
| 195 | /// Gets the total heap usage, used by svcGetInfo | 195 | /// Gets the total heap usage, used by svcGetInfo |
| 196 | u64 GetTotalHeapUsage(); | 196 | u64 GetTotalHeapUsage() const; |
| 197 | 197 | ||
| 198 | /// Gets the total address space base address, used by svcGetInfo | 198 | /// Gets the total address space base address, used by svcGetInfo |
| 199 | VAddr GetAddressSpaceBaseAddr(); | 199 | VAddr GetAddressSpaceBaseAddr() const; |
| 200 | 200 | ||
| 201 | /// Gets the total address space address size, used by svcGetInfo | 201 | /// Gets the total address space address size, used by svcGetInfo |
| 202 | u64 GetAddressSpaceSize(); | 202 | u64 GetAddressSpaceSize() const; |
| 203 | 203 | ||
| 204 | /// Each VMManager has its own page table, which is set as the main one when the owning process | 204 | /// Each VMManager has its own page table, which is set as the main one when the owning process |
| 205 | /// is scheduled. | 205 | /// is scheduled. |
diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/wait_object.cpp index 97394bca2..7681cdee7 100644 --- a/src/core/hle/kernel/wait_object.cpp +++ b/src/core/hle/kernel/wait_object.cpp | |||
| @@ -5,8 +5,7 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/hle/kernel/kernel.h" | 8 | #include "core/hle/kernel/object.h" |
| 9 | #include "core/hle/kernel/memory.h" | ||
| 10 | #include "core/hle/kernel/process.h" | 9 | #include "core/hle/kernel/process.h" |
| 11 | #include "core/hle/kernel/thread.h" | 10 | #include "core/hle/kernel/thread.h" |
| 12 | #include "core/hle/kernel/timer.h" | 11 | #include "core/hle/kernel/timer.h" |
diff --git a/src/core/hle/kernel/wait_object.h b/src/core/hle/kernel/wait_object.h index 78bfd8c6c..b5fbc647b 100644 --- a/src/core/hle/kernel/wait_object.h +++ b/src/core/hle/kernel/wait_object.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include <vector> | 7 | #include <vector> |
| 8 | #include <boost/smart_ptr/intrusive_ptr.hpp> | 8 | #include <boost/smart_ptr/intrusive_ptr.hpp> |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/object.h" |
| 11 | 11 | ||
| 12 | namespace Kernel { | 12 | namespace Kernel { |
| 13 | 13 | ||
diff --git a/src/core/hle/service/mig/mig.cpp b/src/core/hle/service/mig/mig.cpp new file mode 100644 index 000000000..d16367f2c --- /dev/null +++ b/src/core/hle/service/mig/mig.cpp | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <memory> | ||
| 6 | |||
| 7 | #include "core/hle/service/mig/mig.h" | ||
| 8 | #include "core/hle/service/service.h" | ||
| 9 | #include "core/hle/service/sm/sm.h" | ||
| 10 | |||
| 11 | namespace Service::Migration { | ||
| 12 | |||
| 13 | class MIG_USR final : public ServiceFramework<MIG_USR> { | ||
| 14 | public: | ||
| 15 | explicit MIG_USR() : ServiceFramework{"mig:usr"} { | ||
| 16 | // clang-format off | ||
| 17 | static const FunctionInfo functions[] = { | ||
| 18 | {10, nullptr, "TryGetLastMigrationInfo"}, | ||
| 19 | {100, nullptr, "CreateServer"}, | ||
| 20 | {101, nullptr, "ResumeServer"}, | ||
| 21 | {200, nullptr, "CreateClient"}, | ||
| 22 | {201, nullptr, "ResumeClient"}, | ||
| 23 | }; | ||
| 24 | // clang-format on | ||
| 25 | |||
| 26 | RegisterHandlers(functions); | ||
| 27 | } | ||
| 28 | }; | ||
| 29 | |||
| 30 | void InstallInterfaces(SM::ServiceManager& sm) { | ||
| 31 | std::make_shared<MIG_USR>()->InstallAsService(sm); | ||
| 32 | } | ||
| 33 | |||
| 34 | } // namespace Service::Migration | ||
diff --git a/src/core/hle/service/mig/mig.h b/src/core/hle/service/mig/mig.h new file mode 100644 index 000000000..288c1c1b3 --- /dev/null +++ b/src/core/hle/service/mig/mig.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | namespace Service::SM { | ||
| 8 | class ServiceManager; | ||
| 9 | } | ||
| 10 | |||
| 11 | namespace Service::Migration { | ||
| 12 | |||
| 13 | void InstallInterfaces(SM::ServiceManager& sm); | ||
| 14 | |||
| 15 | } // namespace Service::Migration | ||
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index 89c703310..98017267c 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp | |||
| @@ -2,12 +2,459 @@ | |||
| 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 "core/hle/ipc_helpers.h" | ||
| 6 | #include "core/hle/kernel/hle_ipc.h" | ||
| 5 | #include "core/hle/service/ns/ns.h" | 7 | #include "core/hle/service/ns/ns.h" |
| 6 | #include "core/hle/service/ns/pl_u.h" | 8 | #include "core/hle/service/ns/pl_u.h" |
| 7 | 9 | ||
| 8 | namespace Service::NS { | 10 | namespace Service::NS { |
| 9 | 11 | ||
| 12 | class IAccountProxyInterface final : public ServiceFramework<IAccountProxyInterface> { | ||
| 13 | public: | ||
| 14 | explicit IAccountProxyInterface() : ServiceFramework{"IAccountProxyInterface"} { | ||
| 15 | // clang-format off | ||
| 16 | static const FunctionInfo functions[] = { | ||
| 17 | {0, nullptr, "CreateUserAccount"}, | ||
| 18 | }; | ||
| 19 | // clang-format on | ||
| 20 | |||
| 21 | RegisterHandlers(functions); | ||
| 22 | } | ||
| 23 | }; | ||
| 24 | |||
| 25 | class IApplicationManagerInterface final : public ServiceFramework<IApplicationManagerInterface> { | ||
| 26 | public: | ||
| 27 | explicit IApplicationManagerInterface() : ServiceFramework{"IApplicationManagerInterface"} { | ||
| 28 | // clang-format off | ||
| 29 | static const FunctionInfo functions[] = { | ||
| 30 | {0, nullptr, "ListApplicationRecord"}, | ||
| 31 | {1, nullptr, "GenerateApplicationRecordCount"}, | ||
| 32 | {2, nullptr, "GetApplicationRecordUpdateSystemEvent"}, | ||
| 33 | {3, nullptr, "GetApplicationViewDeprecated"}, | ||
| 34 | {4, nullptr, "DeleteApplicationEntity"}, | ||
| 35 | {5, nullptr, "DeleteApplicationCompletely"}, | ||
| 36 | {6, nullptr, "IsAnyApplicationEntityRedundant"}, | ||
| 37 | {7, nullptr, "DeleteRedundantApplicationEntity"}, | ||
| 38 | {8, nullptr, "IsApplicationEntityMovable"}, | ||
| 39 | {9, nullptr, "MoveApplicationEntity"}, | ||
| 40 | {11, nullptr, "CalculateApplicationOccupiedSize"}, | ||
| 41 | {16, nullptr, "PushApplicationRecord"}, | ||
| 42 | {17, nullptr, "ListApplicationRecordContentMeta"}, | ||
| 43 | {19, nullptr, "LaunchApplication"}, | ||
| 44 | {21, nullptr, "GetApplicationContentPath"}, | ||
| 45 | {22, nullptr, "TerminateApplication"}, | ||
| 46 | {23, nullptr, "ResolveApplicationContentPath"}, | ||
| 47 | {26, nullptr, "BeginInstallApplication"}, | ||
| 48 | {27, nullptr, "DeleteApplicationRecord"}, | ||
| 49 | {30, nullptr, "RequestApplicationUpdateInfo"}, | ||
| 50 | {32, nullptr, "CancelApplicationDownload"}, | ||
| 51 | {33, nullptr, "ResumeApplicationDownload"}, | ||
| 52 | {35, nullptr, "UpdateVersionList"}, | ||
| 53 | {36, nullptr, "PushLaunchVersion"}, | ||
| 54 | {37, nullptr, "ListRequiredVersion"}, | ||
| 55 | {38, nullptr, "CheckApplicationLaunchVersion"}, | ||
| 56 | {39, nullptr, "CheckApplicationLaunchRights"}, | ||
| 57 | {40, nullptr, "GetApplicationLogoData"}, | ||
| 58 | {41, nullptr, "CalculateApplicationDownloadRequiredSize"}, | ||
| 59 | {42, nullptr, "CleanupSdCard"}, | ||
| 60 | {43, nullptr, "CheckSdCardMountStatus"}, | ||
| 61 | {44, nullptr, "GetSdCardMountStatusChangedEvent"}, | ||
| 62 | {45, nullptr, "GetGameCardAttachmentEvent"}, | ||
| 63 | {46, nullptr, "GetGameCardAttachmentInfo"}, | ||
| 64 | {47, nullptr, "GetTotalSpaceSize"}, | ||
| 65 | {48, nullptr, "GetFreeSpaceSize"}, | ||
| 66 | {49, nullptr, "GetSdCardRemovedEvent"}, | ||
| 67 | {52, nullptr, "GetGameCardUpdateDetectionEvent"}, | ||
| 68 | {53, nullptr, "DisableApplicationAutoDelete"}, | ||
| 69 | {54, nullptr, "EnableApplicationAutoDelete"}, | ||
| 70 | {55, nullptr, "GetApplicationDesiredLanguage"}, | ||
| 71 | {56, nullptr, "SetApplicationTerminateResult"}, | ||
| 72 | {57, nullptr, "ClearApplicationTerminateResult"}, | ||
| 73 | {58, nullptr, "GetLastSdCardMountUnexpectedResult"}, | ||
| 74 | {59, nullptr, "ConvertApplicationLanguageToLanguageCode"}, | ||
| 75 | {60, nullptr, "ConvertLanguageCodeToApplicationLanguage"}, | ||
| 76 | {61, nullptr, "GetBackgroundDownloadStressTaskInfo"}, | ||
| 77 | {62, nullptr, "GetGameCardStopper"}, | ||
| 78 | {63, nullptr, "IsSystemProgramInstalled"}, | ||
| 79 | {64, nullptr, "StartApplyDeltaTask"}, | ||
| 80 | {65, nullptr, "GetRequestServerStopper"}, | ||
| 81 | {66, nullptr, "GetBackgroundApplyDeltaStressTaskInfo"}, | ||
| 82 | {67, nullptr, "CancelApplicationApplyDelta"}, | ||
| 83 | {68, nullptr, "ResumeApplicationApplyDelta"}, | ||
| 84 | {69, nullptr, "CalculateApplicationApplyDeltaRequiredSize"}, | ||
| 85 | {70, nullptr, "ResumeAll"}, | ||
| 86 | {71, nullptr, "GetStorageSize"}, | ||
| 87 | {80, nullptr, "RequestDownloadApplication"}, | ||
| 88 | {81, nullptr, "RequestDownloadAddOnContent"}, | ||
| 89 | {82, nullptr, "DownloadApplication"}, | ||
| 90 | {83, nullptr, "CheckApplicationResumeRights"}, | ||
| 91 | {84, nullptr, "GetDynamicCommitEvent"}, | ||
| 92 | {85, nullptr, "RequestUpdateApplication2"}, | ||
| 93 | {86, nullptr, "EnableApplicationCrashReport"}, | ||
| 94 | {87, nullptr, "IsApplicationCrashReportEnabled"}, | ||
| 95 | {90, nullptr, "BoostSystemMemoryResourceLimit"}, | ||
| 96 | {100, nullptr, "ResetToFactorySettings"}, | ||
| 97 | {101, nullptr, "ResetToFactorySettingsWithoutUserSaveData"}, | ||
| 98 | {102, nullptr, "ResetToFactorySettingsForRefurbishment"}, | ||
| 99 | {200, nullptr, "CalculateUserSaveDataStatistics"}, | ||
| 100 | {201, nullptr, "DeleteUserSaveDataAll"}, | ||
| 101 | {210, nullptr, "DeleteUserSystemSaveData"}, | ||
| 102 | {220, nullptr, "UnregisterNetworkServiceAccount"}, | ||
| 103 | {300, nullptr, "GetApplicationShellEvent"}, | ||
| 104 | {301, nullptr, "PopApplicationShellEventInfo"}, | ||
| 105 | {302, nullptr, "LaunchLibraryApplet"}, | ||
| 106 | {303, nullptr, "TerminateLibraryApplet"}, | ||
| 107 | {304, nullptr, "LaunchSystemApplet"}, | ||
| 108 | {305, nullptr, "TerminateSystemApplet"}, | ||
| 109 | {306, nullptr, "LaunchOverlayApplet"}, | ||
| 110 | {307, nullptr, "TerminateOverlayApplet"}, | ||
| 111 | {400, nullptr, "GetApplicationControlData"}, | ||
| 112 | {401, nullptr, "InvalidateAllApplicationControlCache"}, | ||
| 113 | {402, nullptr, "RequestDownloadApplicationControlData"}, | ||
| 114 | {403, nullptr, "GetMaxApplicationControlCacheCount"}, | ||
| 115 | {404, nullptr, "InvalidateApplicationControlCache"}, | ||
| 116 | {405, nullptr, "ListApplicationControlCacheEntryInfo"}, | ||
| 117 | {502, nullptr, "RequestCheckGameCardRegistration"}, | ||
| 118 | {503, nullptr, "RequestGameCardRegistrationGoldPoint"}, | ||
| 119 | {504, nullptr, "RequestRegisterGameCard"}, | ||
| 120 | {505, nullptr, "GetGameCardMountFailureEvent"}, | ||
| 121 | {506, nullptr, "IsGameCardInserted"}, | ||
| 122 | {507, nullptr, "EnsureGameCardAccess"}, | ||
| 123 | {508, nullptr, "GetLastGameCardMountFailureResult"}, | ||
| 124 | {509, nullptr, "ListApplicationIdOnGameCard"}, | ||
| 125 | {600, nullptr, "CountApplicationContentMeta"}, | ||
| 126 | {601, nullptr, "ListApplicationContentMetaStatus"}, | ||
| 127 | {602, nullptr, "ListAvailableAddOnContent"}, | ||
| 128 | {603, nullptr, "GetOwnedApplicationContentMetaStatus"}, | ||
| 129 | {604, nullptr, "RegisterContentsExternalKey"}, | ||
| 130 | {605, nullptr, "ListApplicationContentMetaStatusWithRightsCheck"}, | ||
| 131 | {606, nullptr, "GetContentMetaStorage"}, | ||
| 132 | {700, nullptr, "PushDownloadTaskList"}, | ||
| 133 | {701, nullptr, "ClearTaskStatusList"}, | ||
| 134 | {702, nullptr, "RequestDownloadTaskList"}, | ||
| 135 | {703, nullptr, "RequestEnsureDownloadTask"}, | ||
| 136 | {704, nullptr, "ListDownloadTaskStatus"}, | ||
| 137 | {705, nullptr, "RequestDownloadTaskListData"}, | ||
| 138 | {800, nullptr, "RequestVersionList"}, | ||
| 139 | {801, nullptr, "ListVersionList"}, | ||
| 140 | {802, nullptr, "RequestVersionListData"}, | ||
| 141 | {900, nullptr, "GetApplicationRecord"}, | ||
| 142 | {901, nullptr, "GetApplicationRecordProperty"}, | ||
| 143 | {902, nullptr, "EnableApplicationAutoUpdate"}, | ||
| 144 | {903, nullptr, "DisableApplicationAutoUpdate"}, | ||
| 145 | {904, nullptr, "TouchApplication"}, | ||
| 146 | {905, nullptr, "RequestApplicationUpdate"}, | ||
| 147 | {906, nullptr, "IsApplicationUpdateRequested"}, | ||
| 148 | {907, nullptr, "WithdrawApplicationUpdateRequest"}, | ||
| 149 | {908, nullptr, "ListApplicationRecordInstalledContentMeta"}, | ||
| 150 | {909, nullptr, "WithdrawCleanupAddOnContentsWithNoRightsRecommendation"}, | ||
| 151 | {1000, nullptr, "RequestVerifyApplicationDeprecated"}, | ||
| 152 | {1001, nullptr, "CorruptApplicationForDebug"}, | ||
| 153 | {1002, nullptr, "RequestVerifyAddOnContentsRights"}, | ||
| 154 | {1003, nullptr, "RequestVerifyApplication"}, | ||
| 155 | {1004, nullptr, "CorruptContentForDebug"}, | ||
| 156 | {1200, nullptr, "NeedsUpdateVulnerability"}, | ||
| 157 | {1300, nullptr, "IsAnyApplicationEntityInstalled"}, | ||
| 158 | {1301, nullptr, "DeleteApplicationContentEntities"}, | ||
| 159 | {1302, nullptr, "CleanupUnrecordedApplicationEntity"}, | ||
| 160 | {1303, nullptr, "CleanupAddOnContentsWithNoRights"}, | ||
| 161 | {1304, nullptr, "DeleteApplicationContentEntity"}, | ||
| 162 | {1305, nullptr, "TryDeleteRunningApplicationEntity"}, | ||
| 163 | {1306, nullptr, "TryDeleteRunningApplicationCompletely"}, | ||
| 164 | {1307, nullptr, "TryDeleteRunningApplicationContentEntities"}, | ||
| 165 | {1400, nullptr, "PrepareShutdown"}, | ||
| 166 | {1500, nullptr, "FormatSdCard"}, | ||
| 167 | {1501, nullptr, "NeedsSystemUpdateToFormatSdCard"}, | ||
| 168 | {1502, nullptr, "GetLastSdCardFormatUnexpectedResult"}, | ||
| 169 | {1504, nullptr, "InsertSdCard"}, | ||
| 170 | {1505, nullptr, "RemoveSdCard"}, | ||
| 171 | {1600, nullptr, "GetSystemSeedForPseudoDeviceId"}, | ||
| 172 | {1601, nullptr, "ResetSystemSeedForPseudoDeviceId"}, | ||
| 173 | {1700, nullptr, "ListApplicationDownloadingContentMeta"}, | ||
| 174 | {1701, nullptr, "GetApplicationView"}, | ||
| 175 | {1702, nullptr, "GetApplicationDownloadTaskStatus"}, | ||
| 176 | {1703, nullptr, "GetApplicationViewDownloadErrorContext"}, | ||
| 177 | {1800, nullptr, "IsNotificationSetupCompleted"}, | ||
| 178 | {1801, nullptr, "GetLastNotificationInfoCount"}, | ||
| 179 | {1802, nullptr, "ListLastNotificationInfo"}, | ||
| 180 | {1803, nullptr, "ListNotificationTask"}, | ||
| 181 | {1900, nullptr, "IsActiveAccount"}, | ||
| 182 | {1901, nullptr, "RequestDownloadApplicationPrepurchasedRights"}, | ||
| 183 | {1902, nullptr, "GetApplicationTicketInfo"}, | ||
| 184 | {2000, nullptr, "GetSystemDeliveryInfo"}, | ||
| 185 | {2001, nullptr, "SelectLatestSystemDeliveryInfo"}, | ||
| 186 | {2002, nullptr, "VerifyDeliveryProtocolVersion"}, | ||
| 187 | {2003, nullptr, "GetApplicationDeliveryInfo"}, | ||
| 188 | {2004, nullptr, "HasAllContentsToDeliver"}, | ||
| 189 | {2005, nullptr, "CompareApplicationDeliveryInfo"}, | ||
| 190 | {2006, nullptr, "CanDeliverApplication"}, | ||
| 191 | {2007, nullptr, "ListContentMetaKeyToDeliverApplication"}, | ||
| 192 | {2008, nullptr, "NeedsSystemUpdateToDeliverApplication"}, | ||
| 193 | {2009, nullptr, "EstimateRequiredSize"}, | ||
| 194 | {2010, nullptr, "RequestReceiveApplication"}, | ||
| 195 | {2011, nullptr, "CommitReceiveApplication"}, | ||
| 196 | {2012, nullptr, "GetReceiveApplicationProgress"}, | ||
| 197 | {2013, nullptr, "RequestSendApplication"}, | ||
| 198 | {2014, nullptr, "GetSendApplicationProgress"}, | ||
| 199 | {2015, nullptr, "CompareSystemDeliveryInfo"}, | ||
| 200 | {2016, nullptr, "ListNotCommittedContentMeta"}, | ||
| 201 | {2017, nullptr, "CreateDownloadTask"}, | ||
| 202 | }; | ||
| 203 | // clang-format on | ||
| 204 | |||
| 205 | RegisterHandlers(functions); | ||
| 206 | } | ||
| 207 | }; | ||
| 208 | |||
| 209 | class IApplicationVersionInterface final : public ServiceFramework<IApplicationVersionInterface> { | ||
| 210 | public: | ||
| 211 | explicit IApplicationVersionInterface() : ServiceFramework{"IApplicationVersionInterface"} { | ||
| 212 | // clang-format off | ||
| 213 | static const FunctionInfo functions[] = { | ||
| 214 | {0, nullptr, "GetLaunchRequiredVersion"}, | ||
| 215 | {1, nullptr, "UpgradeLaunchRequiredVersion"}, | ||
| 216 | {35, nullptr, "UpdateVersionList"}, | ||
| 217 | {36, nullptr, "PushLaunchVersion"}, | ||
| 218 | {37, nullptr, "ListRequiredVersion"}, | ||
| 219 | {800, nullptr, "RequestVersionList"}, | ||
| 220 | {801, nullptr, "ListVersionList"}, | ||
| 221 | {802, nullptr, "RequestVersionListData"}, | ||
| 222 | {1000, nullptr, "PerformAutoUpdate"}, | ||
| 223 | }; | ||
| 224 | // clang-format on | ||
| 225 | |||
| 226 | RegisterHandlers(functions); | ||
| 227 | } | ||
| 228 | }; | ||
| 229 | |||
| 230 | class IContentManagerInterface final : public ServiceFramework<IContentManagerInterface> { | ||
| 231 | public: | ||
| 232 | explicit IContentManagerInterface() : ServiceFramework{"IContentManagerInterface"} { | ||
| 233 | // clang-format off | ||
| 234 | static const FunctionInfo functions[] = { | ||
| 235 | {11, nullptr, "CalculateApplicationOccupiedSize"}, | ||
| 236 | {43, nullptr, "CheckSdCardMountStatus"}, | ||
| 237 | {47, nullptr, "GetTotalSpaceSize"}, | ||
| 238 | {48, nullptr, "GetFreeSpaceSize"}, | ||
| 239 | {600, nullptr, "CountApplicationContentMeta"}, | ||
| 240 | {601, nullptr, "ListApplicationContentMetaStatus"}, | ||
| 241 | {605, nullptr, "ListApplicationContentMetaStatusWithRightsCheck"}, | ||
| 242 | {607, nullptr, "IsAnyApplicationRunning"}, | ||
| 243 | }; | ||
| 244 | // clang-format on | ||
| 245 | |||
| 246 | RegisterHandlers(functions); | ||
| 247 | } | ||
| 248 | }; | ||
| 249 | |||
| 250 | class IDocumentInterface final : public ServiceFramework<IDocumentInterface> { | ||
| 251 | public: | ||
| 252 | explicit IDocumentInterface() : ServiceFramework{"IDocumentInterface"} { | ||
| 253 | // clang-format off | ||
| 254 | static const FunctionInfo functions[] = { | ||
| 255 | {21, nullptr, "GetApplicationContentPath"}, | ||
| 256 | {23, nullptr, "ResolveApplicationContentPath"}, | ||
| 257 | }; | ||
| 258 | // clang-format on | ||
| 259 | |||
| 260 | RegisterHandlers(functions); | ||
| 261 | } | ||
| 262 | }; | ||
| 263 | |||
| 264 | class IDownloadTaskInterface final : public ServiceFramework<IDownloadTaskInterface> { | ||
| 265 | public: | ||
| 266 | explicit IDownloadTaskInterface() : ServiceFramework{"IDownloadTaskInterface"} { | ||
| 267 | // clang-format off | ||
| 268 | static const FunctionInfo functions[] = { | ||
| 269 | {701, nullptr, "ClearTaskStatusList"}, | ||
| 270 | {702, nullptr, "RequestDownloadTaskList"}, | ||
| 271 | {703, nullptr, "RequestEnsureDownloadTask"}, | ||
| 272 | {704, nullptr, "ListDownloadTaskStatus"}, | ||
| 273 | {705, nullptr, "RequestDownloadTaskListData"}, | ||
| 274 | {706, nullptr, "TryCommitCurrentApplicationDownloadTask"}, | ||
| 275 | {707, nullptr, "EnableAutoCommit"}, | ||
| 276 | {708, nullptr, "DisableAutoCommit"}, | ||
| 277 | {709, nullptr, "TriggerDynamicCommitEvent"}, | ||
| 278 | }; | ||
| 279 | // clang-format on | ||
| 280 | |||
| 281 | RegisterHandlers(functions); | ||
| 282 | } | ||
| 283 | }; | ||
| 284 | |||
| 285 | class IECommerceInterface final : public ServiceFramework<IECommerceInterface> { | ||
| 286 | public: | ||
| 287 | explicit IECommerceInterface() : ServiceFramework{"IECommerceInterface"} { | ||
| 288 | // clang-format off | ||
| 289 | static const FunctionInfo functions[] = { | ||
| 290 | {0, nullptr, "RequestLinkDevice"}, | ||
| 291 | }; | ||
| 292 | // clang-format on | ||
| 293 | |||
| 294 | RegisterHandlers(functions); | ||
| 295 | } | ||
| 296 | }; | ||
| 297 | |||
| 298 | class IFactoryResetInterface final : public ServiceFramework<IFactoryResetInterface> { | ||
| 299 | public: | ||
| 300 | explicit IFactoryResetInterface() : ServiceFramework{"IFactoryResetInterface"} { | ||
| 301 | // clang-format off | ||
| 302 | static const FunctionInfo functions[] = { | ||
| 303 | {100, nullptr, "ResetToFactorySettings"}, | ||
| 304 | {101, nullptr, "ResetToFactorySettingsWithoutUserSaveData"}, | ||
| 305 | {102, nullptr, "ResetToFactorySettingsForRefurbishment "}, | ||
| 306 | }; | ||
| 307 | // clang-format on | ||
| 308 | |||
| 309 | RegisterHandlers(functions); | ||
| 310 | } | ||
| 311 | }; | ||
| 312 | |||
| 313 | class NS final : public ServiceFramework<NS> { | ||
| 314 | public: | ||
| 315 | explicit NS(const char* name) : ServiceFramework{name} { | ||
| 316 | // clang-format off | ||
| 317 | static const FunctionInfo functions[] = { | ||
| 318 | {7992, &NS::PushInterface<IECommerceInterface>, "GetECommerceInterface"}, | ||
| 319 | {7993, &NS::PushInterface<IApplicationVersionInterface>, "GetApplicationVersionInterface"}, | ||
| 320 | {7994, &NS::PushInterface<IFactoryResetInterface>, "GetFactoryResetInterface"}, | ||
| 321 | {7995, &NS::PushInterface<IAccountProxyInterface>, "GetAccountProxyInterface"}, | ||
| 322 | {7996, &NS::PushInterface<IApplicationManagerInterface>, "GetApplicationManagerInterface"}, | ||
| 323 | {7997, &NS::PushInterface<IDownloadTaskInterface>, "GetDownloadTaskInterface"}, | ||
| 324 | {7998, &NS::PushInterface<IContentManagerInterface>, "GetContentManagementInterface"}, | ||
| 325 | {7999, &NS::PushInterface<IDocumentInterface>, "GetDocumentInterface"}, | ||
| 326 | }; | ||
| 327 | // clang-format on | ||
| 328 | |||
| 329 | RegisterHandlers(functions); | ||
| 330 | } | ||
| 331 | |||
| 332 | private: | ||
| 333 | template <typename T> | ||
| 334 | void PushInterface(Kernel::HLERequestContext& ctx) { | ||
| 335 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 336 | rb.Push(RESULT_SUCCESS); | ||
| 337 | rb.PushIpcInterface<T>(); | ||
| 338 | |||
| 339 | LOG_DEBUG(Service_NS, "called"); | ||
| 340 | } | ||
| 341 | }; | ||
| 342 | |||
| 343 | class NS_DEV final : public ServiceFramework<NS_DEV> { | ||
| 344 | public: | ||
| 345 | explicit NS_DEV() : ServiceFramework{"ns:dev"} { | ||
| 346 | // clang-format off | ||
| 347 | static const FunctionInfo functions[] = { | ||
| 348 | {0, nullptr, "LaunchProgram"}, | ||
| 349 | {1, nullptr, "TerminateProcess"}, | ||
| 350 | {2, nullptr, "TerminateProgram"}, | ||
| 351 | {3, nullptr, "GetShellEventHandle"}, | ||
| 352 | {4, nullptr, "GetShellEventInfo"}, | ||
| 353 | {5, nullptr, "TerminateApplication"}, | ||
| 354 | {6, nullptr, "PrepareLaunchProgramFromHost"}, | ||
| 355 | {7, nullptr, "LaunchApplication"}, | ||
| 356 | {8, nullptr, "LaunchApplicationWithStorageId"}, | ||
| 357 | }; | ||
| 358 | // clang-format on | ||
| 359 | |||
| 360 | RegisterHandlers(functions); | ||
| 361 | } | ||
| 362 | }; | ||
| 363 | |||
| 364 | class ISystemUpdateControl final : public ServiceFramework<ISystemUpdateControl> { | ||
| 365 | public: | ||
| 366 | explicit ISystemUpdateControl() : ServiceFramework{"ISystemUpdateControl"} { | ||
| 367 | // clang-format off | ||
| 368 | static const FunctionInfo functions[] = { | ||
| 369 | {0, nullptr, "HasDownloaded"}, | ||
| 370 | {1, nullptr, "RequestCheckLatestUpdate"}, | ||
| 371 | {2, nullptr, "RequestDownloadLatestUpdate"}, | ||
| 372 | {3, nullptr, "GetDownloadProgress"}, | ||
| 373 | {4, nullptr, "ApplyDownloadedUpdate"}, | ||
| 374 | {5, nullptr, "RequestPrepareCardUpdate"}, | ||
| 375 | {6, nullptr, "GetPrepareCardUpdateProgress"}, | ||
| 376 | {7, nullptr, "HasPreparedCardUpdate"}, | ||
| 377 | {8, nullptr, "ApplyCardUpdate"}, | ||
| 378 | {9, nullptr, "GetDownloadedEulaDataSize"}, | ||
| 379 | {10, nullptr, "GetDownloadedEulaData"}, | ||
| 380 | {11, nullptr, "SetupCardUpdate"}, | ||
| 381 | {12, nullptr, "GetPreparedCardUpdateEulaDataSize"}, | ||
| 382 | {13, nullptr, "GetPreparedCardUpdateEulaData"}, | ||
| 383 | {14, nullptr, "SetupCardUpdateViaSystemUpdater"}, | ||
| 384 | {15, nullptr, "HasReceived"}, | ||
| 385 | {16, nullptr, "RequestReceiveSystemUpdate"}, | ||
| 386 | {17, nullptr, "GetReceiveProgress"}, | ||
| 387 | {18, nullptr, "ApplyReceivedUpdate"}, | ||
| 388 | {19, nullptr, "GetReceivedEulaDataSize"}, | ||
| 389 | {20, nullptr, "GetReceivedEulaData"}, | ||
| 390 | {21, nullptr, "SetupToReceiveSystemUpdate"}, | ||
| 391 | }; | ||
| 392 | // clang-format on | ||
| 393 | |||
| 394 | RegisterHandlers(functions); | ||
| 395 | } | ||
| 396 | }; | ||
| 397 | |||
| 398 | class NS_SU final : public ServiceFramework<NS_SU> { | ||
| 399 | public: | ||
| 400 | explicit NS_SU() : ServiceFramework{"ns:su"} { | ||
| 401 | // clang-format off | ||
| 402 | static const FunctionInfo functions[] = { | ||
| 403 | {0, nullptr, "GetBackgroundNetworkUpdateState"}, | ||
| 404 | {1, &NS_SU::OpenSystemUpdateControl, "OpenSystemUpdateControl"}, | ||
| 405 | {2, nullptr, "NotifyExFatDriverRequired"}, | ||
| 406 | {3, nullptr, "ClearExFatDriverStatusForDebug"}, | ||
| 407 | {4, nullptr, "RequestBackgroundNetworkUpdate"}, | ||
| 408 | {5, nullptr, "NotifyBackgroundNetworkUpdate"}, | ||
| 409 | {6, nullptr, "NotifyExFatDriverDownloadedForDebug"}, | ||
| 410 | {9, nullptr, "GetSystemUpdateNotificationEventForContentDelivery"}, | ||
| 411 | {10, nullptr, "NotifySystemUpdateForContentDelivery"}, | ||
| 412 | {11, nullptr, "PrepareShutdown"}, | ||
| 413 | {16, nullptr, "DestroySystemUpdateTask"}, | ||
| 414 | {17, nullptr, "RequestSendSystemUpdate"}, | ||
| 415 | {18, nullptr, "GetSendSystemUpdateProgress"}, | ||
| 416 | }; | ||
| 417 | // clang-format on | ||
| 418 | |||
| 419 | RegisterHandlers(functions); | ||
| 420 | } | ||
| 421 | |||
| 422 | private: | ||
| 423 | void OpenSystemUpdateControl(Kernel::HLERequestContext& ctx) { | ||
| 424 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 425 | rb.Push(RESULT_SUCCESS); | ||
| 426 | rb.PushIpcInterface<ISystemUpdateControl>(); | ||
| 427 | |||
| 428 | LOG_DEBUG(Service_NS, "called"); | ||
| 429 | } | ||
| 430 | }; | ||
| 431 | |||
| 432 | class NS_VM final : public ServiceFramework<NS_VM> { | ||
| 433 | public: | ||
| 434 | explicit NS_VM() : ServiceFramework{"ns:vm"} { | ||
| 435 | // clang-format off | ||
| 436 | static const FunctionInfo functions[] = { | ||
| 437 | {1200, nullptr, "NeedsUpdateVulnerability"}, | ||
| 438 | {1201, nullptr, "UpdateSafeSystemVersionForDebug"}, | ||
| 439 | {1202, nullptr, "GetSafeSystemVersion"}, | ||
| 440 | }; | ||
| 441 | // clang-format on | ||
| 442 | |||
| 443 | RegisterHandlers(functions); | ||
| 444 | } | ||
| 445 | }; | ||
| 446 | |||
| 10 | void InstallInterfaces(SM::ServiceManager& service_manager) { | 447 | void InstallInterfaces(SM::ServiceManager& service_manager) { |
| 448 | std::make_shared<NS>("ns:am2")->InstallAsService(service_manager); | ||
| 449 | std::make_shared<NS>("ns:ec")->InstallAsService(service_manager); | ||
| 450 | std::make_shared<NS>("ns:rid")->InstallAsService(service_manager); | ||
| 451 | std::make_shared<NS>("ns:rt")->InstallAsService(service_manager); | ||
| 452 | std::make_shared<NS>("ns:web")->InstallAsService(service_manager); | ||
| 453 | |||
| 454 | std::make_shared<NS_DEV>()->InstallAsService(service_manager); | ||
| 455 | std::make_shared<NS_SU>()->InstallAsService(service_manager); | ||
| 456 | std::make_shared<NS_VM>()->InstallAsService(service_manager); | ||
| 457 | |||
| 11 | std::make_shared<PL_U>()->InstallAsService(service_manager); | 458 | std::make_shared<PL_U>()->InstallAsService(service_manager); |
| 12 | } | 459 | } |
| 13 | 460 | ||
diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index 7132b18ad..adf180509 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp | |||
| @@ -4,9 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | 6 | ||
| 7 | #include "common/alignment.h" | 7 | #include "common/assert.h" |
| 8 | #include "common/scope_exit.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "core/core_timing.h" | ||
| 10 | #include "core/hle/service/nvflinger/buffer_queue.h" | 9 | #include "core/hle/service/nvflinger/buffer_queue.h" |
| 11 | 10 | ||
| 12 | namespace Service { | 11 | namespace Service { |
diff --git a/src/core/hle/service/psc/psc.cpp b/src/core/hle/service/psc/psc.cpp new file mode 100644 index 000000000..bbad870a2 --- /dev/null +++ b/src/core/hle/service/psc/psc.cpp | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <memory> | ||
| 6 | |||
| 7 | #include "common/logging/log.h" | ||
| 8 | #include "core/hle/ipc_helpers.h" | ||
| 9 | #include "core/hle/service/psc/psc.h" | ||
| 10 | #include "core/hle/service/service.h" | ||
| 11 | #include "core/hle/service/sm/sm.h" | ||
| 12 | |||
| 13 | namespace Service::PSC { | ||
| 14 | |||
| 15 | class PSC_C final : public ServiceFramework<PSC_C> { | ||
| 16 | public: | ||
| 17 | explicit PSC_C() : ServiceFramework{"psc:c"} { | ||
| 18 | // clang-format off | ||
| 19 | static const FunctionInfo functions[] = { | ||
| 20 | {0, nullptr, "Unknown1"}, | ||
| 21 | {1, nullptr, "Unknown2"}, | ||
| 22 | {2, nullptr, "Unknown3"}, | ||
| 23 | {3, nullptr, "Unknown4"}, | ||
| 24 | {4, nullptr, "Unknown5"}, | ||
| 25 | {5, nullptr, "Unknown6"}, | ||
| 26 | {6, nullptr, "Unknown7"}, | ||
| 27 | }; | ||
| 28 | // clang-format on | ||
| 29 | |||
| 30 | RegisterHandlers(functions); | ||
| 31 | } | ||
| 32 | }; | ||
| 33 | |||
| 34 | class IPmModule final : public ServiceFramework<IPmModule> { | ||
| 35 | public: | ||
| 36 | explicit IPmModule() : ServiceFramework{"IPmModule"} { | ||
| 37 | // clang-format off | ||
| 38 | static const FunctionInfo functions[] = { | ||
| 39 | {0, nullptr, "Initialize"}, | ||
| 40 | {1, nullptr, "GetRequest"}, | ||
| 41 | {2, nullptr, "Acknowledge"}, | ||
| 42 | {3, nullptr, "Unknown1"}, | ||
| 43 | }; | ||
| 44 | // clang-format on | ||
| 45 | |||
| 46 | RegisterHandlers(functions); | ||
| 47 | } | ||
| 48 | }; | ||
| 49 | |||
| 50 | class PSC_M final : public ServiceFramework<PSC_M> { | ||
| 51 | public: | ||
| 52 | explicit PSC_M() : ServiceFramework{"psc:m"} { | ||
| 53 | // clang-format off | ||
| 54 | static const FunctionInfo functions[] = { | ||
| 55 | {0, &PSC_M::GetPmModule, "GetPmModule"}, | ||
| 56 | }; | ||
| 57 | // clang-format on | ||
| 58 | |||
| 59 | RegisterHandlers(functions); | ||
| 60 | } | ||
| 61 | |||
| 62 | private: | ||
| 63 | void GetPmModule(Kernel::HLERequestContext& ctx) { | ||
| 64 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 65 | rb.Push(RESULT_SUCCESS); | ||
| 66 | rb.PushIpcInterface<IPmModule>(); | ||
| 67 | |||
| 68 | LOG_DEBUG(Service_PSC, "called"); | ||
| 69 | } | ||
| 70 | }; | ||
| 71 | |||
| 72 | void InstallInterfaces(SM::ServiceManager& sm) { | ||
| 73 | std::make_shared<PSC_C>()->InstallAsService(sm); | ||
| 74 | std::make_shared<PSC_M>()->InstallAsService(sm); | ||
| 75 | } | ||
| 76 | |||
| 77 | } // namespace Service::PSC | ||
diff --git a/src/core/hle/service/psc/psc.h b/src/core/hle/service/psc/psc.h new file mode 100644 index 000000000..5052eb02c --- /dev/null +++ b/src/core/hle/service/psc/psc.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | namespace Service::SM { | ||
| 8 | class ServiceManager; | ||
| 9 | } | ||
| 10 | |||
| 11 | namespace Service::PSC { | ||
| 12 | |||
| 13 | void InstallInterfaces(SM::ServiceManager& sm); | ||
| 14 | |||
| 15 | } // namespace Service::PSC | ||
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 828666e9b..61e0c34a0 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include "core/hle/service/ldn/ldn.h" | 38 | #include "core/hle/service/ldn/ldn.h" |
| 39 | #include "core/hle/service/ldr/ldr.h" | 39 | #include "core/hle/service/ldr/ldr.h" |
| 40 | #include "core/hle/service/lm/lm.h" | 40 | #include "core/hle/service/lm/lm.h" |
| 41 | #include "core/hle/service/mig/mig.h" | ||
| 41 | #include "core/hle/service/mii/mii.h" | 42 | #include "core/hle/service/mii/mii.h" |
| 42 | #include "core/hle/service/mm/mm_u.h" | 43 | #include "core/hle/service/mm/mm_u.h" |
| 43 | #include "core/hle/service/ncm/ncm.h" | 44 | #include "core/hle/service/ncm/ncm.h" |
| @@ -52,6 +53,7 @@ | |||
| 52 | #include "core/hle/service/pcv/pcv.h" | 53 | #include "core/hle/service/pcv/pcv.h" |
| 53 | #include "core/hle/service/pm/pm.h" | 54 | #include "core/hle/service/pm/pm.h" |
| 54 | #include "core/hle/service/prepo/prepo.h" | 55 | #include "core/hle/service/prepo/prepo.h" |
| 56 | #include "core/hle/service/psc/psc.h" | ||
| 55 | #include "core/hle/service/service.h" | 57 | #include "core/hle/service/service.h" |
| 56 | #include "core/hle/service/set/settings.h" | 58 | #include "core/hle/service/set/settings.h" |
| 57 | #include "core/hle/service/sm/controller.h" | 59 | #include "core/hle/service/sm/controller.h" |
| @@ -224,6 +226,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { | |||
| 224 | LDN::InstallInterfaces(*sm); | 226 | LDN::InstallInterfaces(*sm); |
| 225 | LDR::InstallInterfaces(*sm); | 227 | LDR::InstallInterfaces(*sm); |
| 226 | LM::InstallInterfaces(*sm); | 228 | LM::InstallInterfaces(*sm); |
| 229 | Migration::InstallInterfaces(*sm); | ||
| 227 | Mii::InstallInterfaces(*sm); | 230 | Mii::InstallInterfaces(*sm); |
| 228 | MM::InstallInterfaces(*sm); | 231 | MM::InstallInterfaces(*sm); |
| 229 | NCM::InstallInterfaces(*sm); | 232 | NCM::InstallInterfaces(*sm); |
| @@ -238,6 +241,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { | |||
| 238 | PCV::InstallInterfaces(*sm); | 241 | PCV::InstallInterfaces(*sm); |
| 239 | PlayReport::InstallInterfaces(*sm); | 242 | PlayReport::InstallInterfaces(*sm); |
| 240 | PM::InstallInterfaces(*sm); | 243 | PM::InstallInterfaces(*sm); |
| 244 | PSC::InstallInterfaces(*sm); | ||
| 241 | Set::InstallInterfaces(*sm); | 245 | Set::InstallInterfaces(*sm); |
| 242 | Sockets::InstallInterfaces(*sm); | 246 | Sockets::InstallInterfaces(*sm); |
| 243 | SPL::InstallInterfaces(*sm); | 247 | SPL::InstallInterfaces(*sm); |
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 180f22703..046c5e18d 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -8,10 +8,9 @@ | |||
| 8 | #include <string> | 8 | #include <string> |
| 9 | #include <unordered_map> | 9 | #include <unordered_map> |
| 10 | #include <boost/container/flat_map.hpp> | 10 | #include <boost/container/flat_map.hpp> |
| 11 | #include "common/bit_field.h" | ||
| 12 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 13 | #include "core/hle/kernel/hle_ipc.h" | 12 | #include "core/hle/kernel/hle_ipc.h" |
| 14 | #include "core/hle/kernel/kernel.h" | 13 | #include "core/hle/kernel/object.h" |
| 15 | 14 | ||
| 16 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 15 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 17 | // Namespace Service | 16 | // Namespace Service |
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index e2a00e4f6..e8ea62f08 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h | |||
| @@ -4,9 +4,11 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | ||
| 7 | #include <string> | 8 | #include <string> |
| 8 | #include <unordered_map> | 9 | #include <unordered_map> |
| 9 | #include "core/hle/kernel/kernel.h" | 10 | |
| 11 | #include "core/hle/kernel/object.h" | ||
| 10 | #include "core/hle/result.h" | 12 | #include "core/hle/result.h" |
| 11 | #include "core/hle/service/service.h" | 13 | #include "core/hle/service/service.h" |
| 12 | 14 | ||
| @@ -19,6 +21,8 @@ class SessionRequestHandler; | |||
| 19 | 21 | ||
| 20 | namespace Service::SM { | 22 | namespace Service::SM { |
| 21 | 23 | ||
| 24 | class Controller; | ||
| 25 | |||
| 22 | /// Interface to "sm:" service | 26 | /// Interface to "sm:" service |
| 23 | class SM final : public ServiceFramework<SM> { | 27 | class SM final : public ServiceFramework<SM> { |
| 24 | public: | 28 | public: |
| @@ -32,8 +36,6 @@ private: | |||
| 32 | std::shared_ptr<ServiceManager> service_manager; | 36 | std::shared_ptr<ServiceManager> service_manager; |
| 33 | }; | 37 | }; |
| 34 | 38 | ||
| 35 | class Controller; | ||
| 36 | |||
| 37 | constexpr ResultCode ERR_SERVICE_NOT_REGISTERED(-1); | 39 | constexpr ResultCode ERR_SERVICE_NOT_REGISTERED(-1); |
| 38 | constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(-1); | 40 | constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(-1); |
| 39 | constexpr ResultCode ERR_INVALID_NAME_SIZE(-1); | 41 | constexpr ResultCode ERR_INVALID_NAME_SIZE(-1); |
diff --git a/src/core/hw/aes/ccm.cpp b/src/core/hw/aes/ccm.cpp deleted file mode 100644 index 1ee37aaa4..000000000 --- a/src/core/hw/aes/ccm.cpp +++ /dev/null | |||
| @@ -1,28 +0,0 @@ | |||
| 1 | // Copyright 2017 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | #include "common/alignment.h" | ||
| 7 | #include "common/assert.h" | ||
| 8 | #include "common/logging/log.h" | ||
| 9 | #include "core/hw/aes/ccm.h" | ||
| 10 | #include "core/hw/aes/key.h" | ||
| 11 | |||
| 12 | namespace HW { | ||
| 13 | namespace AES { | ||
| 14 | |||
| 15 | std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& nonce, | ||
| 16 | size_t slot_id) { | ||
| 17 | UNIMPLEMENTED(); | ||
| 18 | return {}; | ||
| 19 | } | ||
| 20 | |||
| 21 | std::vector<u8> DecryptVerifyCCM(const std::vector<u8>& cipher, const CCMNonce& nonce, | ||
| 22 | size_t slot_id) { | ||
| 23 | UNIMPLEMENTED(); | ||
| 24 | return {}; | ||
| 25 | } | ||
| 26 | |||
| 27 | } // namespace AES | ||
| 28 | } // namespace HW | ||
diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp deleted file mode 100644 index 2f48068c1..000000000 --- a/src/core/hw/hw.cpp +++ /dev/null | |||
| @@ -1,96 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/common_types.h" | ||
| 6 | #include "common/logging/log.h" | ||
| 7 | #include "core/hw/hw.h" | ||
| 8 | #include "core/hw/lcd.h" | ||
| 9 | |||
| 10 | namespace HW { | ||
| 11 | |||
| 12 | template <typename T> | ||
| 13 | inline void Read(T& var, const u32 addr) { | ||
| 14 | switch (addr & 0xFFFFF000) { | ||
| 15 | case VADDR_GPU: | ||
| 16 | case VADDR_GPU + 0x1000: | ||
| 17 | case VADDR_GPU + 0x2000: | ||
| 18 | case VADDR_GPU + 0x3000: | ||
| 19 | case VADDR_GPU + 0x4000: | ||
| 20 | case VADDR_GPU + 0x5000: | ||
| 21 | case VADDR_GPU + 0x6000: | ||
| 22 | case VADDR_GPU + 0x7000: | ||
| 23 | case VADDR_GPU + 0x8000: | ||
| 24 | case VADDR_GPU + 0x9000: | ||
| 25 | case VADDR_GPU + 0xA000: | ||
| 26 | case VADDR_GPU + 0xB000: | ||
| 27 | case VADDR_GPU + 0xC000: | ||
| 28 | case VADDR_GPU + 0xD000: | ||
| 29 | case VADDR_GPU + 0xE000: | ||
| 30 | case VADDR_GPU + 0xF000: | ||
| 31 | break; | ||
| 32 | case VADDR_LCD: | ||
| 33 | LCD::Read(var, addr); | ||
| 34 | break; | ||
| 35 | default: | ||
| 36 | LOG_ERROR(HW_Memory, "Unknown Read{} @ 0x{:08X}", sizeof(var) * 8, addr); | ||
| 37 | break; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | template <typename T> | ||
| 42 | inline void Write(u32 addr, const T data) { | ||
| 43 | switch (addr & 0xFFFFF000) { | ||
| 44 | case VADDR_GPU: | ||
| 45 | case VADDR_GPU + 0x1000: | ||
| 46 | case VADDR_GPU + 0x2000: | ||
| 47 | case VADDR_GPU + 0x3000: | ||
| 48 | case VADDR_GPU + 0x4000: | ||
| 49 | case VADDR_GPU + 0x5000: | ||
| 50 | case VADDR_GPU + 0x6000: | ||
| 51 | case VADDR_GPU + 0x7000: | ||
| 52 | case VADDR_GPU + 0x8000: | ||
| 53 | case VADDR_GPU + 0x9000: | ||
| 54 | case VADDR_GPU + 0xA000: | ||
| 55 | case VADDR_GPU + 0xB000: | ||
| 56 | case VADDR_GPU + 0xC000: | ||
| 57 | case VADDR_GPU + 0xD000: | ||
| 58 | case VADDR_GPU + 0xE000: | ||
| 59 | case VADDR_GPU + 0xF000: | ||
| 60 | break; | ||
| 61 | case VADDR_LCD: | ||
| 62 | LCD::Write(addr, data); | ||
| 63 | break; | ||
| 64 | default: | ||
| 65 | LOG_ERROR(HW_Memory, "Unknown Write{} 0x{:08X} @ 0x{:08X}", sizeof(data) * 8, data, addr); | ||
| 66 | break; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | // Explicitly instantiate template functions because we aren't defining this in the header: | ||
| 71 | |||
| 72 | template void Read<u64>(u64& var, const u32 addr); | ||
| 73 | template void Read<u32>(u32& var, const u32 addr); | ||
| 74 | template void Read<u16>(u16& var, const u32 addr); | ||
| 75 | template void Read<u8>(u8& var, const u32 addr); | ||
| 76 | |||
| 77 | template void Write<u64>(u32 addr, const u64 data); | ||
| 78 | template void Write<u32>(u32 addr, const u32 data); | ||
| 79 | template void Write<u16>(u32 addr, const u16 data); | ||
| 80 | template void Write<u8>(u32 addr, const u8 data); | ||
| 81 | |||
| 82 | /// Update hardware | ||
| 83 | void Update() {} | ||
| 84 | |||
| 85 | /// Initialize hardware | ||
| 86 | void Init() { | ||
| 87 | LCD::Init(); | ||
| 88 | LOG_DEBUG(HW, "Initialized OK"); | ||
| 89 | } | ||
| 90 | |||
| 91 | /// Shutdown hardware | ||
| 92 | void Shutdown() { | ||
| 93 | LCD::Shutdown(); | ||
| 94 | LOG_DEBUG(HW, "Shutdown OK"); | ||
| 95 | } | ||
| 96 | } // namespace HW | ||
diff --git a/src/core/hw/hw.h b/src/core/hw/hw.h deleted file mode 100644 index 5890d2b5c..000000000 --- a/src/core/hw/hw.h +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | namespace HW { | ||
| 10 | |||
| 11 | /// Beginnings of IO register regions, in the user VA space. | ||
| 12 | enum : u32 { | ||
| 13 | VADDR_HASH = 0x1EC01000, | ||
| 14 | VADDR_CSND = 0x1EC03000, | ||
| 15 | VADDR_DSP = 0x1EC40000, | ||
| 16 | VADDR_PDN = 0x1EC41000, | ||
| 17 | VADDR_CODEC = 0x1EC41000, | ||
| 18 | VADDR_SPI = 0x1EC42000, | ||
| 19 | VADDR_SPI_2 = 0x1EC43000, // Only used under TWL_FIRM? | ||
| 20 | VADDR_I2C = 0x1EC44000, | ||
| 21 | VADDR_CODEC_2 = 0x1EC45000, | ||
| 22 | VADDR_HID = 0x1EC46000, | ||
| 23 | VADDR_GPIO = 0x1EC47000, | ||
| 24 | VADDR_I2C_2 = 0x1EC48000, | ||
| 25 | VADDR_SPI_3 = 0x1EC60000, | ||
| 26 | VADDR_I2C_3 = 0x1EC61000, | ||
| 27 | VADDR_MIC = 0x1EC62000, | ||
| 28 | VADDR_PXI = 0x1EC63000, | ||
| 29 | VADDR_LCD = 0x1ED02000, | ||
| 30 | VADDR_DSP_2 = 0x1ED03000, | ||
| 31 | VADDR_HASH_2 = 0x1EE01000, | ||
| 32 | VADDR_GPU = 0x1EF00000, | ||
| 33 | }; | ||
| 34 | |||
| 35 | template <typename T> | ||
| 36 | void Read(T& var, const u32 addr); | ||
| 37 | |||
| 38 | template <typename T> | ||
| 39 | void Write(u32 addr, const T data); | ||
| 40 | |||
| 41 | /// Update hardware | ||
| 42 | void Update(); | ||
| 43 | |||
| 44 | /// Initialize hardware | ||
| 45 | void Init(); | ||
| 46 | |||
| 47 | /// Shutdown hardware | ||
| 48 | void Shutdown(); | ||
| 49 | |||
| 50 | } // namespace HW | ||
diff --git a/src/core/hw/lcd.cpp b/src/core/hw/lcd.cpp deleted file mode 100644 index 0b62174d5..000000000 --- a/src/core/hw/lcd.cpp +++ /dev/null | |||
| @@ -1,67 +0,0 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cstring> | ||
| 6 | #include "common/common_types.h" | ||
| 7 | #include "common/logging/log.h" | ||
| 8 | #include "core/hw/hw.h" | ||
| 9 | #include "core/hw/lcd.h" | ||
| 10 | #include "core/tracer/recorder.h" | ||
| 11 | |||
| 12 | namespace LCD { | ||
| 13 | |||
| 14 | Regs g_regs; | ||
| 15 | |||
| 16 | template <typename T> | ||
| 17 | inline void Read(T& var, const u32 raw_addr) { | ||
| 18 | u32 addr = raw_addr - HW::VADDR_LCD; | ||
| 19 | u32 index = addr / 4; | ||
| 20 | |||
| 21 | // Reads other than u32 are untested, so I'd rather have them abort than silently fail | ||
| 22 | if (index >= 0x400 || !std::is_same<T, u32>::value) { | ||
| 23 | LOG_ERROR(HW_LCD, "Unknown Read{} @ 0x{:08X}", sizeof(var) * 8, addr); | ||
| 24 | return; | ||
| 25 | } | ||
| 26 | |||
| 27 | var = g_regs[index]; | ||
| 28 | } | ||
| 29 | |||
| 30 | template <typename T> | ||
| 31 | inline void Write(u32 addr, const T data) { | ||
| 32 | addr -= HW::VADDR_LCD; | ||
| 33 | u32 index = addr / 4; | ||
| 34 | |||
| 35 | // Writes other than u32 are untested, so I'd rather have them abort than silently fail | ||
| 36 | if (index >= 0x400 || !std::is_same<T, u32>::value) { | ||
| 37 | LOG_ERROR(HW_LCD, "Unknown Write{} 0x{:08X} @ 0x{:08X}", sizeof(data) * 8, data, addr); | ||
| 38 | return; | ||
| 39 | } | ||
| 40 | |||
| 41 | g_regs[index] = static_cast<u32>(data); | ||
| 42 | } | ||
| 43 | |||
| 44 | // Explicitly instantiate template functions because we aren't defining this in the header: | ||
| 45 | |||
| 46 | template void Read<u64>(u64& var, const u32 addr); | ||
| 47 | template void Read<u32>(u32& var, const u32 addr); | ||
| 48 | template void Read<u16>(u16& var, const u32 addr); | ||
| 49 | template void Read<u8>(u8& var, const u32 addr); | ||
| 50 | |||
| 51 | template void Write<u64>(u32 addr, const u64 data); | ||
| 52 | template void Write<u32>(u32 addr, const u32 data); | ||
| 53 | template void Write<u16>(u32 addr, const u16 data); | ||
| 54 | template void Write<u8>(u32 addr, const u8 data); | ||
| 55 | |||
| 56 | /// Initialize hardware | ||
| 57 | void Init() { | ||
| 58 | memset(&g_regs, 0, sizeof(g_regs)); | ||
| 59 | LOG_DEBUG(HW_LCD, "Initialized OK"); | ||
| 60 | } | ||
| 61 | |||
| 62 | /// Shutdown hardware | ||
| 63 | void Shutdown() { | ||
| 64 | LOG_DEBUG(HW_LCD, "Shutdown OK"); | ||
| 65 | } | ||
| 66 | |||
| 67 | } // namespace LCD | ||
diff --git a/src/core/hw/lcd.h b/src/core/hw/lcd.h deleted file mode 100644 index d2db9700f..000000000 --- a/src/core/hw/lcd.h +++ /dev/null | |||
| @@ -1,86 +0,0 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <cstddef> | ||
| 8 | #include <type_traits> | ||
| 9 | #include "common/bit_field.h" | ||
| 10 | #include "common/common_funcs.h" | ||
| 11 | #include "common/common_types.h" | ||
| 12 | |||
| 13 | #define LCD_REG_INDEX(field_name) (offsetof(LCD::Regs, field_name) / sizeof(u32)) | ||
| 14 | |||
| 15 | namespace LCD { | ||
| 16 | |||
| 17 | struct Regs { | ||
| 18 | |||
| 19 | union ColorFill { | ||
| 20 | u32 raw; | ||
| 21 | |||
| 22 | BitField<0, 8, u32> color_r; | ||
| 23 | BitField<8, 8, u32> color_g; | ||
| 24 | BitField<16, 8, u32> color_b; | ||
| 25 | BitField<24, 1, u32> is_enabled; | ||
| 26 | }; | ||
| 27 | |||
| 28 | INSERT_PADDING_WORDS(0x81); | ||
| 29 | ColorFill color_fill_top; | ||
| 30 | INSERT_PADDING_WORDS(0xE); | ||
| 31 | u32 backlight_top; | ||
| 32 | |||
| 33 | INSERT_PADDING_WORDS(0x1F0); | ||
| 34 | |||
| 35 | ColorFill color_fill_bottom; | ||
| 36 | INSERT_PADDING_WORDS(0xE); | ||
| 37 | u32 backlight_bottom; | ||
| 38 | INSERT_PADDING_WORDS(0x16F); | ||
| 39 | |||
| 40 | static constexpr size_t NumIds() { | ||
| 41 | return sizeof(Regs) / sizeof(u32); | ||
| 42 | } | ||
| 43 | |||
| 44 | const u32& operator[](int index) const { | ||
| 45 | const u32* content = reinterpret_cast<const u32*>(this); | ||
| 46 | return content[index]; | ||
| 47 | } | ||
| 48 | |||
| 49 | u32& operator[](int index) { | ||
| 50 | u32* content = reinterpret_cast<u32*>(this); | ||
| 51 | return content[index]; | ||
| 52 | } | ||
| 53 | }; | ||
| 54 | static_assert(std::is_standard_layout<Regs>::value, "Structure does not use standard layout"); | ||
| 55 | |||
| 56 | // TODO: MSVC does not support using offsetof() on non-static data members even though this | ||
| 57 | // is technically allowed since C++11. This macro should be enabled once MSVC adds | ||
| 58 | // support for that. | ||
| 59 | #ifndef _MSC_VER | ||
| 60 | #define ASSERT_REG_POSITION(field_name, position) \ | ||
| 61 | static_assert(offsetof(Regs, field_name) == position * 4, \ | ||
| 62 | "Field " #field_name " has invalid position") | ||
| 63 | |||
| 64 | ASSERT_REG_POSITION(color_fill_top, 0x81); | ||
| 65 | ASSERT_REG_POSITION(backlight_top, 0x90); | ||
| 66 | ASSERT_REG_POSITION(color_fill_bottom, 0x281); | ||
| 67 | ASSERT_REG_POSITION(backlight_bottom, 0x290); | ||
| 68 | |||
| 69 | #undef ASSERT_REG_POSITION | ||
| 70 | #endif // !defined(_MSC_VER) | ||
| 71 | |||
| 72 | extern Regs g_regs; | ||
| 73 | |||
| 74 | template <typename T> | ||
| 75 | void Read(T& var, const u32 addr); | ||
| 76 | |||
| 77 | template <typename T> | ||
| 78 | void Write(u32 addr, const T data); | ||
| 79 | |||
| 80 | /// Initialize hardware | ||
| 81 | void Init(); | ||
| 82 | |||
| 83 | /// Shutdown hardware | ||
| 84 | void Shutdown(); | ||
| 85 | |||
| 86 | } // namespace LCD | ||
diff --git a/src/core/loader/deconstructed_rom_directory.h b/src/core/loader/deconstructed_rom_directory.h index 982a037f7..7319ba6ea 100644 --- a/src/core/loader/deconstructed_rom_directory.h +++ b/src/core/loader/deconstructed_rom_directory.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include <string> | 7 | #include <string> |
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "core/file_sys/program_metadata.h" | 9 | #include "core/file_sys/program_metadata.h" |
| 10 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/object.h" |
| 11 | #include "core/loader/loader.h" | 11 | #include "core/loader/loader.h" |
| 12 | 12 | ||
| 13 | namespace Loader { | 13 | namespace Loader { |
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index fbf11e5d0..3ca6bcf8b 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | #include "common/file_util.h" | 15 | #include "common/file_util.h" |
| 16 | #include "core/file_sys/vfs.h" | 16 | #include "core/file_sys/vfs.h" |
| 17 | #include "core/hle/kernel/kernel.h" | 17 | #include "core/hle/kernel/object.h" |
| 18 | 18 | ||
| 19 | namespace Kernel { | 19 | namespace Kernel { |
| 20 | struct AddressMapping; | 20 | struct AddressMapping; |
diff --git a/src/core/loader/nca.h b/src/core/loader/nca.h index 52c95953a..2edd81cb9 100644 --- a/src/core/loader/nca.h +++ b/src/core/loader/nca.h | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "core/file_sys/content_archive.h" | 9 | #include "core/file_sys/content_archive.h" |
| 10 | #include "core/file_sys/program_metadata.h" | 10 | #include "core/file_sys/program_metadata.h" |
| 11 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/object.h" |
| 12 | #include "core/loader/loader.h" | 12 | #include "core/loader/loader.h" |
| 13 | 13 | ||
| 14 | namespace Loader { | 14 | namespace Loader { |
diff --git a/src/core/loader/nro.h b/src/core/loader/nro.h index 04a0f497e..bb01c9e25 100644 --- a/src/core/loader/nro.h +++ b/src/core/loader/nro.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <string> | 7 | #include <string> |
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "core/hle/kernel/kernel.h" | 9 | #include "core/hle/kernel/object.h" |
| 10 | #include "core/loader/linker.h" | 10 | #include "core/loader/linker.h" |
| 11 | #include "core/loader/loader.h" | 11 | #include "core/loader/loader.h" |
| 12 | 12 | ||
diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h index 3f7567500..aaeb1f2a9 100644 --- a/src/core/loader/nso.h +++ b/src/core/loader/nso.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <string> | 7 | #include <string> |
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "core/hle/kernel/kernel.h" | 9 | #include "core/hle/kernel/object.h" |
| 10 | #include "core/loader/linker.h" | 10 | #include "core/loader/linker.h" |
| 11 | #include "core/loader/loader.h" | 11 | #include "core/loader/loader.h" |
| 12 | 12 | ||
diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 444bcc387..79e0b347b 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp | |||
| @@ -5,10 +5,9 @@ | |||
| 5 | #include "core/gdbstub/gdbstub.h" | 5 | #include "core/gdbstub/gdbstub.h" |
| 6 | #include "core/hle/service/hid/hid.h" | 6 | #include "core/hle/service/hid/hid.h" |
| 7 | #include "core/settings.h" | 7 | #include "core/settings.h" |
| 8 | #include "video_core/renderer_base.h" | ||
| 8 | #include "video_core/video_core.h" | 9 | #include "video_core/video_core.h" |
| 9 | 10 | ||
| 10 | #include "core/frontend/emu_window.h" | ||
| 11 | |||
| 12 | namespace Settings { | 11 | namespace Settings { |
| 13 | 12 | ||
| 14 | Values values = {}; | 13 | Values values = {}; |
| @@ -20,9 +19,8 @@ void Apply() { | |||
| 20 | 19 | ||
| 21 | VideoCore::g_toggle_framelimit_enabled = values.toggle_framelimit; | 20 | VideoCore::g_toggle_framelimit_enabled = values.toggle_framelimit; |
| 22 | 21 | ||
| 23 | if (VideoCore::g_emu_window) { | 22 | if (VideoCore::g_renderer) { |
| 24 | auto layout = VideoCore::g_emu_window->GetFramebufferLayout(); | 23 | VideoCore::g_renderer->UpdateCurrentFramebufferLayout(); |
| 25 | VideoCore::g_emu_window->UpdateCurrentFramebufferLayout(layout.width, layout.height); | ||
| 26 | } | 24 | } |
| 27 | 25 | ||
| 28 | Service::HID::ReloadInputDevices(); | 26 | Service::HID::ReloadInputDevices(); |